diff --git "a/test.csv" "b/test.csv" new file mode 100644--- /dev/null +++ "b/test.csv" @@ -0,0 +1,5098 @@ +id,java,python +E0,"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; System . out . println ( Math . max ( x , y ) ) ; } } +","x , y = map ( int , str ( input ( ) ) . split ( ' ▁ ' ) ) NEW_LINE print ( ' { } ' . format ( x if x > y else y ) ) NEW_LINE +" +E1,"import java . util . Scanner ; import java . util . TreeSet ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . length ( ) == 26 ) { TreeSet < Character > set = new TreeSet < > ( ) ; set . add ( s . charAt ( 25 ) ) ; for ( int i = 24 ; 0 <= i ; i -- ) { if ( set . higher ( s . charAt ( i ) ) != null ) { System . out . println ( s . substring ( 0 , i ) + set . higher ( s . charAt ( i ) ) ) ; return ; } else { set . add ( s . charAt ( i ) ) ; } } System . out . println ( - 1 ) ; } else { for ( int i = ' a ' ; i <= ' z ' ; i ++ ) { if ( s . indexOf ( i ) == - 1 ) { System . out . println ( s + ( char ) i ) ; break ; } } } } } +","s = input ( ) NEW_LINE if len ( s ) != 26 : NEW_LINE INDENT se = set ( [ ] ) NEW_LINE for w in s : NEW_LINE INDENT se . add ( w ) NEW_LINE DEDENT for i in range ( 26 ) : NEW_LINE INDENT w = chr ( ord ( ' a ' ) + i ) NEW_LINE if w not in se : NEW_LINE INDENT print ( s + w ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT if s == "" zyxwvutsrqponmlkjihgfedcba "" : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT se = set ( [ ] ) NEW_LINE for i in reversed ( range ( 26 ) ) : NEW_LINE INDENT se . add ( s [ i ] ) NEW_LINE for j in range ( ord ( s [ i ] ) - ord ( ' a ' ) + 1 , 26 ) : NEW_LINE INDENT if chr ( ord ( ' a ' ) + j ) in se : NEW_LINE INDENT print ( s [ : i ] + chr ( ord ( ' a ' ) + j ) ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT +" +E2,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] pushes = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { pushes [ i ] = sc . nextInt ( ) ; } int sum = 0 ; int till = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( till > pushes [ i ] ) { sum += ( pushes [ i ] - pushes [ i - 1 ] ) ; } else { sum += T ; } till = pushes [ i ] + T ; } System . out . println ( sum ) ; sc . close ( ) ; } } +","def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def dmp ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def probC ( ) : NEW_LINE INDENT N , T = getIntList ( ) NEW_LINE Ts = getIntList ( ) NEW_LINE dmp ( ( N , T , Ts ) ) NEW_LINE total = Ts [ 0 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT total += min ( T , Ts [ i ] - Ts [ i - 1 ] ) NEW_LINE DEDENT return total + T NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE +" +E3,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int num = scn . nextInt ( ) ; int ans = 0 ; if ( num % 2 == 0 ) { ans = num - 1 ; } else { ans = num + 1 ; } System . out . println ( ans ) ; } } +","n = int ( input ( ) ) NEW_LINE if n % 2 == 0 : NEW_LINE INDENT print ( n - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n + 1 ) NEW_LINE DEDENT +" +E4,"import java . lang . reflect . Array ; import java . util . * ; public class Main { private void print ( ArrayList < Integer > arrayMid ) { StringBuilder Mid = new StringBuilder ( ) ; for ( int i = 0 ; i < arrayMid . size ( ) ; i ++ ) { Mid . append ( arrayMid . get ( i ) + "" ▁ "" ) ; } System . out . println ( Mid ) ; } private void Even ( int K , int N ) { ArrayList < Integer > arrayMid = new ArrayList < Integer > ( N ) ; arrayMid . add ( 0 , K / 2 ) ; for ( int i = 1 ; i < N ; i ++ ) { arrayMid . add ( i , K ) ; } print ( arrayMid ) ; } private void Odd ( int K , int N ) { ArrayList < Integer > arrayMid = new ArrayList < Integer > ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { arrayMid . add ( i , ( K + 1 ) / 2 ) ; } for ( int i = 0 ; i < N / 2 ; i ++ ) { if ( arrayMid . get ( arrayMid . size ( ) - 1 ) == 1 ) arrayMid . remove ( arrayMid . size ( ) - 1 ) ; else { arrayMid . set ( ( arrayMid . size ( ) - 1 ) , arrayMid . get ( arrayMid . size ( ) - 1 ) - 1 ) ; for ( int j = arrayMid . size ( ) ; j < N ; j ++ ) arrayMid . add ( j , K ) ; } } print ( arrayMid ) ; } private void Judge ( int K , int N ) { if ( K % 2 == 0 ) Even ( K , N ) ; else Odd ( K , N ) ; } public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int [ ] in = new int [ 2 ] ; for ( int i = 0 ; i < 2 ; i ++ ) { in [ i ] = input . nextInt ( ) ; } Main myEncyclopedia = new Main ( ) ; myEncyclopedia . Judge ( in [ 0 ] , in [ 1 ] ) ; input . close ( ) ; } } +","import math NEW_LINE def main ( ) : NEW_LINE INDENT [ K , N ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE r = [ ] NEW_LINE if K == 1 : NEW_LINE INDENT r = [ 1 ] * ( ( N + 1 ) // 2 ) NEW_LINE DEDENT elif K % 2 == 0 : NEW_LINE INDENT r = [ K // 2 ] NEW_LINE r += [ K ] * ( N - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT t = N // 2 NEW_LINE x = int ( math . log ( N * ( K - 1 ) + 1 , K ) - 1 ) NEW_LINE while t < ( ( K ** ( x + 1 ) - 1 ) / ( K - 1 ) + x ) // 2 : NEW_LINE INDENT x -= 1 NEW_LINE DEDENT x += 1 NEW_LINE r = [ ( K + 1 ) // 2 ] * ( N - x ) NEW_LINE r += [ 0 ] * x NEW_LINE t = ( ( K ** ( x + 1 ) - 1 ) / ( K - 1 ) + x ) // 2 - t NEW_LINE for i in range ( x , 0 , - 1 ) : NEW_LINE INDENT r [ N - i ] = 1 NEW_LINE t -= 1 NEW_LINE for j in range ( K - 1 ) : NEW_LINE INDENT if t == 0 : NEW_LINE INDENT break NEW_LINE DEDENT if K ** i - 1 <= t * ( K - 1 ) : NEW_LINE INDENT r [ N - i ] += 1 NEW_LINE t -= ( K ** i - 1 ) // ( K - 1 ) NEW_LINE DEDENT DEDENT if t == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT for i in range ( len ( r ) - 1 , - 1 , - 1 ) : NEW_LINE INDENT if r [ i ] == 0 : NEW_LINE INDENT r . pop ( ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( ' ▁ ' . join ( list ( map ( str , r ) ) ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E5,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; System . out . println ( reader . nextInt ( ) <= 8 && reader . nextInt ( ) <= 8 ? "" Yay ! "" : "" : ( "" ) ; reader . close ( ) ; } } +","A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if A <= 8 and B <= 8 : NEW_LINE INDENT print ( ' Yay ! ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' : ( ' ) NEW_LINE DEDENT +" +E6,"import java . util . Arrays ; import java . util . Scanner ; public class Main { static long pow ( long b , long n , long mod ) { if ( n == 0 ) return 1 ; if ( n % 2 == 0 ) { long t = pow ( b , n / 2 , mod ) ; return t * t % mod ; } return b * pow ( b , n - 1 , mod ) % mod ; } public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; final int MOD = 1000000007 ; long [ ] as = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextInt ( ) ; } Arrays . sort ( as ) ; if ( a == 1 ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( as [ i ] ) ; } return ; } int cnt = 0 ; while ( cnt < b && as [ 0 ] * a < as [ n - 1 ] ) { as [ 0 ] *= a ; as [ 0 ] %= MOD ; Arrays . sort ( as ) ; cnt ++ ; } b -= cnt ; for ( int i = 0 ; i < b % n ; i ++ ) { as [ 0 ] *= a ; as [ 0 ] %= MOD ; long [ ] nxt = new long [ n ] ; for ( int j = 0 ; j < n - 1 ; j ++ ) { nxt [ j ] = as [ j + 1 ] ; } nxt [ n - 1 ] = as [ 0 ] ; as = nxt ; } for ( int i = 0 ; i < n ; i ++ ) { as [ i ] *= pow ( a , b / n , MOD ) ; System . out . println ( as [ i ] % MOD ) ; } } } +","import heapq NEW_LINE N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE src = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if A == 1 : NEW_LINE INDENT for v in sorted ( src ) : NEW_LINE INDENT print ( v ) NEW_LINE DEDENT exit ( ) NEW_LINE DEDENT mem = [ ] NEW_LINE maxv = 0 NEW_LINE for i , v in enumerate ( src ) : NEW_LINE INDENT mem . append ( ( v , i ) ) NEW_LINE if v > maxv : maxv = v NEW_LINE DEDENT heapq . heapify ( mem ) NEW_LINE while True : NEW_LINE INDENT v , i = heapq . heappop ( mem ) NEW_LINE if B == 0 or ( v * A > maxv and B % N == 0 ) : NEW_LINE INDENT heapq . heappush ( mem , ( v , i ) ) NEW_LINE break NEW_LINE DEDENT maxv = max ( maxv , v * A ) NEW_LINE heapq . heappush ( mem , ( v * A , i ) ) NEW_LINE B -= 1 NEW_LINE DEDENT MOD = 10 ** 9 + 7 NEW_LINE p = pow ( A , B // N , MOD ) NEW_LINE while mem : NEW_LINE INDENT v , i = heapq . heappop ( mem ) NEW_LINE print ( ( v * p ) % MOD ) NEW_LINE DEDENT +" +E7,"import java . util . HashMap ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int m = in . nextInt ( ) , n = in . nextInt ( ) , N = in . nextInt ( ) ; int ans = 0 , rem = 0 ; while ( N + rem >= m ) { ans += N ; N += rem ; rem = N % m ; N = N / m * n ; } System . out . println ( ans + N ) ; } } +","m , n , N = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE result = N NEW_LINE s = N NEW_LINE while s >= m : NEW_LINE INDENT x , s = divmod ( s , m ) NEW_LINE s += x * n NEW_LINE result += x * n NEW_LINE DEDENT print ( result ) NEW_LINE +" +E8,"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int w = scan . nextInt ( ) ; int h = scan . nextInt ( ) ; int n = scan . nextInt ( ) ; int x_min = 0 ; int y_min = 0 ; int x_max = w ; int y_max = h ; for ( int i = 0 ; i < n ; i ++ ) { int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; if ( a == 1 ) { if ( x_min < x ) { x_min = x ; } } else if ( a == 2 ) { if ( x_max > x ) { x_max = x ; } } else if ( a == 3 ) { if ( y_min < y ) { y_min = y ; } } else if ( a == 4 ) { if ( y_max > y ) { y_max = y ; } } } int area = 0 ; if ( x_max > x_min && y_max > y_min ) { area = ( x_max - x_min ) * ( y_max - y_min ) ; } System . out . println ( area ) ; } } +","w , h , n = map ( int , input ( ) . split ( ) ) NEW_LINE x1 = [ ] NEW_LINE x2 = [ ] NEW_LINE y3 = [ ] NEW_LINE y4 = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT x , y , a = map ( int , input ( ) . split ( ) ) NEW_LINE if a == 1 : NEW_LINE INDENT x1 . append ( x ) NEW_LINE DEDENT elif a == 2 : NEW_LINE INDENT x2 . append ( x ) NEW_LINE DEDENT elif a == 3 : NEW_LINE INDENT y3 . append ( y ) NEW_LINE DEDENT else : NEW_LINE INDENT y4 . append ( y ) NEW_LINE DEDENT DEDENT for t in [ x1 , y3 ] : NEW_LINE INDENT if not t : NEW_LINE INDENT t . append ( 0 ) NEW_LINE DEDENT DEDENT if not x2 : NEW_LINE INDENT x2 . append ( w ) NEW_LINE DEDENT if not y4 : NEW_LINE INDENT y4 . append ( h ) NEW_LINE DEDENT if max ( x1 ) >= min ( x2 ) or max ( y3 ) >= min ( y4 ) : NEW_LINE INDENT print ( 0 ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( ( min ( x2 ) - max ( x1 ) ) * ( min ( y4 ) - max ( y3 ) ) ) NEW_LINE +" +E9,"import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int L = s . length ( ) ; int same = 0 ; if ( s . charAt ( 0 ) == s . charAt ( L - 1 ) ) { same = 1 ; } if ( ( L + same ) % 2 == 0 ) { System . out . println ( "" Second "" ) ; } else { System . out . println ( "" First "" ) ; } } } +","S = input ( ) NEW_LINE if S [ 0 ] == S [ - 1 ] : NEW_LINE INDENT if len ( S ) % 2 == 0 : NEW_LINE INDENT print ( "" First "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Second "" ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if len ( S ) % 2 == 1 : NEW_LINE INDENT print ( "" First "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Second "" ) NEW_LINE DEDENT DEDENT +" +E10,"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = new String ( br . readLine ( ) ) ; long total = 0 , bit ; int lOprIndex , rOprIndex ; String tmp = new String ( ) ; for ( int i = 0 ; i < Math . pow ( 2 , s . length ( ) - 1 ) ; i ++ ) { lOprIndex = 0 ; rOprIndex = 1 ; for ( bit = i ; bit != 0 ; bit = bit >> 1 ) { if ( ( bit & 1 ) == 1 ) { tmp = s . substring ( lOprIndex , rOprIndex ) ; total += Long . parseLong ( tmp . toString ( ) ) ; lOprIndex = rOprIndex ; } rOprIndex ++ ; } tmp = s . substring ( lOprIndex , s . length ( ) ) ; total += Long . parseLong ( tmp . toString ( ) ) ; } System . out . println ( total ) ; } } +","print ( ( lambda S : sum ( eval ( ' ' . join ( ' ' . join ( i ) for i in zip ( S , ( [ ' ' , ' + ' ] [ int ( i ) ] for i in ' { :0 > { } b } 0' . format ( i , len ( S ) - 1 ) ) ) ) ) for i in range ( 1 << len ( S ) - 1 ) ) ) ( input ( ) ) ) NEW_LINE +" +E11,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long length [ ] = { sc . nextInt ( ) , sc . nextInt ( ) } ; String st [ ] = { sc . next ( ) , sc . next ( ) } ; long gcd = gcd ( length [ 0 ] , length [ 1 ] ) ; boolean ok = true ; for ( int i = 0 ; i < gcd ; i ++ ) { if ( st [ 0 ] . charAt ( ( int ) ( length [ 0 ] / gcd * i ) ) != st [ 1 ] . charAt ( ( int ) ( length [ 1 ] / gcd * i ) ) ) { ok = false ; break ; } } System . out . println ( ok ? length [ 0 ] * length [ 1 ] / gcd : - 1 ) ; } public static long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } } +","N , M = ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE S = input ( ) NEW_LINE T = input ( ) NEW_LINE def gcd ( x , y ) : NEW_LINE INDENT x , y = min ( x , y ) , max ( x , y ) NEW_LINE if y % x == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT return gcd ( x , y % x ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT if S [ 0 ] != T [ 0 ] : NEW_LINE INDENT return - 1 NEW_LINE DEDENT g = gcd ( N , M ) NEW_LINE n = N // g NEW_LINE m = M // g NEW_LINE for i in range ( g ) : NEW_LINE INDENT if S [ n * i ] != T [ m * i ] : NEW_LINE INDENT return - 1 NEW_LINE DEDENT DEDENT return N * M // g NEW_LINE DEDENT print ( main ( ) ) NEW_LINE +" +E12,"import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > set = new HashSet < > ( ) ; set . add ( sc . nextInt ( ) ) ; set . add ( sc . nextInt ( ) ) ; set . add ( sc . nextInt ( ) ) ; System . out . println ( set . size ( ) ) ; } } +","print ( len ( set ( map ( int , input ( ) . split ( ) ) ) ) ) NEW_LINE +" +E13,"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String po = sc . nextLine ( ) ; System . out . println ( po . replace ( "" , "" , "" ▁ "" ) ) ; } } +","a , b , c = input ( ) . split ( ' , ' ) NEW_LINE print ( a , b , c ) NEW_LINE +" +E14,"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long X = sc . nextLong ( ) ; long Y = sc . nextLong ( ) ; int ans = 0 ; while ( X <= Y ) { X *= 2 ; ans ++ ; } System . out . println ( ans ) ; } } +","x , y = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 1 NEW_LINE a = x NEW_LINE for _ in range ( 61 ) : NEW_LINE INDENT a *= 2 NEW_LINE if a <= y : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E15,"import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { new Thread ( null , ( ) -> { int n ; int k ; List < Integer > as = new ArrayList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ) { n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { as . add ( sc . nextInt ( ) - 1 ) ; } } System . out . println ( new Calculator ( n , k , as ) . calculate ( ) ) ; } , "" "" , 1 << 27 ) . start ( ) ; } } class Calculator { private int k ; private int answer = 0 ; private boolean isCalculate = false ; private List < List < Integer > > lists = new ArrayList < > ( ) ; Calculator ( int n , int k , List < Integer > as ) { this . k = k ; for ( int i = 0 ; i < n ; i ++ ) { this . lists . add ( new ArrayList < > ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { int j = as . get ( i ) ; if ( 0 < i ) { this . lists . get ( j ) . add ( i ) ; } else if ( 0 < j ) { this . answer ++ ; } } } int calculate ( ) { if ( ! this . isCalculate ) { this . dfs ( 0 , 0 ) ; this . isCalculate = true ; } return this . answer ; } private int dfs ( int a , int pre ) { int h = 0 ; for ( int i : this . lists . get ( a ) ) { h = Math . max ( h , this . dfs ( i , a ) ) ; } if ( 0 < pre && h == this . k - 1 ) { h = 0 ; this . answer ++ ; } else { h ++ ; } return h ; } } +","from sys import exit , setrecursionlimit NEW_LINE from itertools import product NEW_LINE def read ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def reads ( ) : NEW_LINE INDENT return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE DEDENT def argmin ( ll ) : NEW_LINE INDENT ll = list ( ll ) NEW_LINE return ll . index ( min ( ll ) ) NEW_LINE DEDENT setrecursionlimit ( 1000000 ) NEW_LINE ( N , K ) = reads ( ) NEW_LINE parent = [ x - 1 for x in reads ( ) ] NEW_LINE result = 0 NEW_LINE if parent [ 0 ] != 0 : NEW_LINE INDENT parent [ 0 ] = 0 NEW_LINE result += 1 NEW_LINE DEDENT children = [ [ ] for _ in range ( N ) ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT children [ parent [ i ] ] . append ( i ) NEW_LINE DEDENT color = [ 0 ] * N NEW_LINE def walk ( i ) : NEW_LINE INDENT global result NEW_LINE for x in children [ i ] : NEW_LINE INDENT walk ( x ) NEW_LINE if color [ x ] == 1 and parent [ x ] != 0 : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT color [ i ] = min ( [ K ] + [ color [ x ] - 1 for x in children [ i ] if color [ x ] >= 2 ] ) NEW_LINE DEDENT walk ( 0 ) NEW_LINE print ( result ) NEW_LINE +" +E16,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; final int Q = sc . nextInt ( ) ; int [ ] [ ] LR = new int [ N + 1 ] [ N + 1 ] ; int [ ] [ ] sum = new int [ N + 1 ] [ N + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { int li = sc . nextInt ( ) ; int ri = sc . nextInt ( ) ; LR [ li ] [ ri ] ++ ; } for ( int i = 1 ; i < N + 1 ; i ++ ) { for ( int j = 1 ; j < N + 1 ; j ++ ) { sum [ i ] [ j ] += sum [ i ] [ j - 1 ] + LR [ i ] [ j ] ; } } int [ ] ANS = new int [ Q ] ; for ( int i = 0 ; i < Q ; i ++ ) { int ans = 0 ; int pi = sc . nextInt ( ) ; int qi = sc . nextInt ( ) ; for ( int j = pi ; j <= qi ; j ++ ) { ans += sum [ j ] [ qi ] - sum [ j ] [ pi - 1 ] ; } ANS [ i ] = ans ; } for ( int i = 0 ; i < Q ; i ++ ) System . out . println ( ANS [ i ] ) ; } } +","from itertools import accumulate NEW_LINE N , M , Q = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ [ 0 ] * ( N + 1 ) for i in range ( N + 1 ) ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT L , R = map ( int , input ( ) . split ( ) ) NEW_LINE a [ L ] [ R ] += 1 NEW_LINE DEDENT b = [ list ( accumulate ( a [ i ] ) ) for i in range ( N + 1 ) ] NEW_LINE k = [ [ b [ j ] [ i ] for j in range ( i + 1 ) ] for i in range ( N + 1 ) ] NEW_LINE ans = [ list ( accumulate ( reversed ( k [ i ] ) ) ) [ : : - 1 ] for i in range ( N + 1 ) ] NEW_LINE for i in range ( Q ) : NEW_LINE INDENT p , q = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ans [ q ] [ p - q - 1 ] ) NEW_LINE DEDENT +" +E17,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int po [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { po [ sc . nextInt ( ) ] ++ ; } int r = 0 , l = 0 ; for ( int i = x ; i <= n ; i ++ ) { r += po [ i ] ; } for ( int i = 0 ; i <= x ; i ++ ) { l += po [ i ] ; } System . out . println ( Math . min ( r , l ) ) ; } } +","N , M , X = ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE A = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE Z = [ 0 ] * N NEW_LINE for a in A : NEW_LINE INDENT Z [ a ] = 1 NEW_LINE DEDENT lower = 0 NEW_LINE for i in range ( 0 , X + 1 ) : NEW_LINE INDENT lower += Z [ i ] NEW_LINE DEDENT higher = 0 NEW_LINE for i in range ( X , N ) : NEW_LINE INDENT higher += Z [ i ] NEW_LINE DEDENT print ( min ( lower , higher ) ) NEW_LINE +" +E18,"import java . util . * ; public class Main { static ArrayList < Edge > edges [ ] ; static int d [ ] ; static int max ; static int maxt ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; edges = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) edges [ i ] = new ArrayList < Edge > ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; edges [ a ] . add ( new Edge ( b , 1 ) ) ; edges [ b ] . add ( new Edge ( a , 1 ) ) ; } int s = 0 ; d = new int [ N ] ; Arrays . fill ( d , - 1 ) ; d [ s ] = 0 ; max = 0 ; maxt = - 1 ; dfs ( s ) ; s = maxt ; d = new int [ N ] ; Arrays . fill ( d , - 1 ) ; d [ s ] = 0 ; max = 0 ; maxt = - 1 ; dfs ( s ) ; System . out . printf ( "" % d ▁ % d % n "" , s + 1 , maxt + 1 ) ; } private static void dfs ( int i ) { for ( Edge e : edges [ i ] ) { if ( d [ e . v ] == - 1 ) { d [ e . v ] = d [ i ] + e . w ; if ( d [ e . v ] > max ) { max = d [ e . v ] ; maxt = e . v ; } dfs ( e . v ) ; } } return ; } private static class Edge { int u ; int v ; int w ; Edge ( int v , int w ) { this . u = u ; this . v = v ; this . w = w ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details . +","import sys NEW_LINE from collections import deque NEW_LINE def dfs ( edges , start ) : NEW_LINE INDENT visited = [ 0 ] * len ( edges ) NEW_LINE visited [ start ] = 1 NEW_LINE ans , dist = 0 , 0 NEW_LINE stack = deque ( [ ( start , 0 ) ] ) NEW_LINE pop , append = stack . pop , stack . append NEW_LINE while stack : NEW_LINE INDENT v , _dist = pop ( ) NEW_LINE if _dist > dist : NEW_LINE INDENT ans , dist = v , _dist NEW_LINE DEDENT for e in edges [ v ] : NEW_LINE INDENT if visited [ e ] : NEW_LINE INDENT continue NEW_LINE DEDENT visited [ e ] = 1 NEW_LINE append ( ( e , _dist + 1 ) ) NEW_LINE DEDENT DEDENT return ans , dist NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE edges = [ [ ] for _ in [ 0 ] * N ] NEW_LINE for ( a , b ) in ( map ( int , l . split ( ) ) for l in sys . stdin ) : NEW_LINE INDENT edges [ a - 1 ] . append ( b - 1 ) NEW_LINE edges [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT v , _ = dfs ( edges , 0 ) NEW_LINE print ( v + 1 , dfs ( edges , v ) [ 0 ] + 1 ) NEW_LINE DEDENT +" +E19,"import java . util . HashSet ; import java . util . Scanner ; public class Main { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; while ( t -- != 0 ) { long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = scan . nextLong ( ) ; long d = scan . nextLong ( ) ; System . out . println ( eval ( a , b , c , d ) ? "" Yes "" : "" No "" ) ; } } boolean eval ( long a , long b , long c , long d ) { if ( b > a || b > d ) return false ; if ( c >= b ) return true ; if ( b - gcd ( b , d ) + ( a % gcd ( b , d ) ) > c ) return false ; else return true ; } long gcd ( long a , long b ) { if ( a % b == 0 ) return b ; return gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } +","T = int ( input ( ) ) NEW_LINE ABCD = [ [ int ( _ ) for _ in input ( ) . split ( ) ] for _ in range ( T ) ] NEW_LINE def gcd ( x , y ) : NEW_LINE INDENT if x < y : NEW_LINE INDENT return gcd ( y , x ) NEW_LINE DEDENT elif x % y == 0 : NEW_LINE INDENT return y NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT for a , b , c , d in ABCD : NEW_LINE INDENT if a < b or d < b : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT g = gcd ( b , d ) NEW_LINE x = g * ( c // g ) + ( a % g ) NEW_LINE if x <= c : NEW_LINE INDENT x += g NEW_LINE DEDENT if x >= b : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE NEW_LINE DEDENT DEDENT DEDENT +" +E20,"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; if ( k == 1 ) { System . out . println ( 1 ) ; System . out . print ( 1 ) ; return ; } int n = 2 * ( ( k + 3 ) / 4 ) ; int curt = n * 2 - k ; int [ ] [ ] mat = new int [ n ] [ n ] ; for ( int r = 0 ; r < n ; r ++ ) { for ( int c = 0 ; c < n ; c ++ ) { if ( r % 2 == 1 && ( r + c ) % n < n - curt ) { mat [ r ] [ c ] = n + ( r + c ) % n ; mat [ r ] [ c ] ++ ; } else { mat [ r ] [ c ] = ( r + c ) % n ; mat [ r ] [ c ] ++ ; } } } int rr = 1 ; System . out . println ( n ) ; for ( int [ ] row : mat ) { int cc = 1 ; for ( int x : row ) { System . out . print ( x ) ; if ( cc < n ) System . out . print ( "" ▁ "" ) ; cc ++ ; } if ( rr < n ) System . out . println ( "" "" ) ; rr ++ ; } } } +","import math NEW_LINE k = int ( input ( ) ) NEW_LINE if k == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT n = math . ceil ( k / 4 ) * 2 NEW_LINE ans = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT tmp = [ ] NEW_LINE for j in range ( n ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT tmp . append ( ( i + j ) % n + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT tmp . append ( n + ( i + j ) % n + 1 ) NEW_LINE DEDENT DEDENT ans . append ( tmp ) NEW_LINE DEDENT kazu = n * 2 NEW_LINE while kazu != k : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ans [ i ] [ j ] == kazu : NEW_LINE INDENT ans [ i ] [ j ] -= n NEW_LINE DEDENT DEDENT DEDENT kazu -= 1 NEW_LINE DEDENT print ( n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( * ans [ i ] ) NEW_LINE DEDENT +" +E21,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int n , s ; s = 0 ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int a [ ] = new int [ n + 1 ] ; a [ 1 ] = sc . nextInt ( ) ; for ( int i = 2 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; for ( int j = 1 ; j < i ; j ++ ) { if ( a [ j ] == a [ i ] ) { s = s + 1 ; break ; } } } System . out . println ( s ) ; } } +","n = int ( input ( ) ) NEW_LINE a = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE b = list ( set ( a ) ) NEW_LINE print ( len ( a ) - len ( b ) ) NEW_LINE +" +E22,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . PriorityQueue ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] input = new int [ n ] ; String [ ] tmpArray = br . readLine ( ) . split ( "" ▁ "" ) ; for ( int i = 0 ; i < n ; i ++ ) { input [ i ] = Integer . parseInt ( tmpArray [ i ] ) ; } Arrays . sort ( input ) ; int a = 0 ; int b = n - 1 ; int med = input [ n - 1 ] / 2 ; for ( int i = 1 ; i < n - 2 ; i ++ ) { if ( Math . abs ( input [ a ] - med ) >= Math . abs ( input [ i ] - med ) ) { a = i ; } } System . out . println ( input [ b ] + "" ▁ "" + input [ a ] ) ; } } +","def main ( ) : NEW_LINE INDENT n = input ( ) NEW_LINE a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE ai = max ( a ) NEW_LINE a . remove ( ai ) NEW_LINE aj = float ( ' inf ' ) NEW_LINE tmp = float ( ' inf ' ) NEW_LINE for aa in a : NEW_LINE INDENT diff = abs ( ai / 2 - aa ) NEW_LINE if diff < tmp : NEW_LINE INDENT tmp = diff NEW_LINE aj = aa NEW_LINE DEDENT DEDENT print ( ai , aj ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E23,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; for ( int i = 0 ; i < m ; ++ i ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int [ ] d = new int [ m - 1 ] ; for ( int i = 0 ; i < m - 1 ; ++ i ) { d [ i ] = a [ i + 1 ] - a [ i ] ; } Arrays . sort ( d ) ; int c = 0 ; for ( int i = 0 ; i < m - n ; ++ i ) { c += d [ i ] ; } System . out . println ( c ) ; } } +","N , M = map ( int , input ( ) . split ( ) ) NEW_LINE zahyo = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE zahyo . sort ( ) NEW_LINE sa = [ 0 for _ in range ( M - 1 ) ] NEW_LINE for i in range ( M - 1 ) : NEW_LINE INDENT sa [ i ] = zahyo [ i + 1 ] - zahyo [ i ] NEW_LINE DEDENT sa . sort ( reverse = True ) NEW_LINE sa = sa [ N - 1 : ] NEW_LINE print ( sum ( sa ) ) NEW_LINE +" +E24,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long l = sc . nextLong ( ) ; long ans = k / l * b ; k -= k / l * l ; System . out . println ( ans + ( k == 0 ? 0 : Math . min ( k * a , b ) ) ) ; } } +","import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE A , B , K , L = map ( int , input ( ) . split ( ) ) NEW_LINE s = K // L NEW_LINE print ( min ( K * A , s * B + ( K - s * L ) * A , ( s + 1 ) * B ) ) NEW_LINE +" +E25,"import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int N = sc . nextInt ( ) ; int [ ] values = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int ans = Integer . MIN_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { int aokiSum = Integer . MIN_VALUE ; int aokiPosi = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) continue ; int tmp = 0 ; for ( int k = Math . min ( i , j ) ; k <= Math . max ( i , j ) ; k ++ ) { if ( ( k - Math . min ( i , j ) + 1 ) % 2 == 0 ) { tmp += values [ k ] ; } } if ( tmp > aokiSum ) { aokiPosi = j ; aokiSum = tmp ; } } int tmp = 0 ; for ( int k = Math . min ( i , aokiPosi ) ; k <= Math . max ( i , aokiPosi ) ; k ++ ) { if ( ( k - Math . min ( i , aokiPosi ) + 1 ) % 2 == 1 ) { tmp += values [ k ] ; } } ans = Math . max ( tmp , ans ) ; } System . out . println ( ans ) ; } } +","N = input ( ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def aoki ( i , array ) : NEW_LINE INDENT maxi = - 100000000 NEW_LINE for j in range ( len ( array ) ) : NEW_LINE INDENT tmp = 0 NEW_LINE if j != i : NEW_LINE INDENT if j < i : NEW_LINE INDENT T = array [ j : i + 1 ] NEW_LINE DEDENT elif j > i : NEW_LINE INDENT T = array [ i : j + 1 ] NEW_LINE DEDENT for k in range ( len ( T ) ) : NEW_LINE INDENT if k % 2 == 1 : NEW_LINE INDENT tmp += T [ k ] NEW_LINE DEDENT DEDENT if maxi < tmp : NEW_LINE INDENT choice = j NEW_LINE maxi = tmp NEW_LINE DEDENT DEDENT DEDENT return choice NEW_LINE DEDENT maxi = - 10000000000000 NEW_LINE for i in range ( len ( L ) ) : NEW_LINE INDENT aoki_choice = aoki ( i , L ) NEW_LINE tmp = 0 NEW_LINE if i < aoki_choice : NEW_LINE INDENT T = L [ i : aoki_choice + 1 ] NEW_LINE for j in range ( len ( T ) ) : NEW_LINE INDENT if j % 2 == 0 : NEW_LINE INDENT tmp += T [ j ] NEW_LINE DEDENT DEDENT DEDENT elif i > aoki_choice : NEW_LINE INDENT T = L [ aoki_choice : i + 1 ] NEW_LINE for j in range ( len ( T ) ) : NEW_LINE INDENT if j % 2 == 0 : NEW_LINE INDENT tmp += T [ j ] NEW_LINE DEDENT DEDENT DEDENT maxi = max ( tmp , maxi ) NEW_LINE DEDENT print ( maxi ) NEW_LINE +" +E26,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int temp = scanner . nextInt ( ) ; if ( temp > Math . abs ( temp - K ) ) { sum += Math . abs ( ( temp - K ) * 2 ) ; } else { sum += temp * 2 ; } } System . out . println ( sum ) ; } } +","N = int ( input ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE X = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sum_len = 0 NEW_LINE for i in range ( len ( X ) ) : NEW_LINE INDENT if X [ i ] < abs ( K - X [ i ] ) : NEW_LINE INDENT sum_len += X [ i ] * 2 NEW_LINE DEDENT else : NEW_LINE INDENT sum_len += abs ( K - X [ i ] ) * 2 NEW_LINE DEDENT DEDENT print ( sum_len ) NEW_LINE +" +E27,"import java . util . * ; public class Main { 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 ( ) ; System . out . println ( win ( A ) ? "" First "" : "" Second "" ) ; sc . close ( ) ; } static boolean win ( int [ ] A ) { int N = A . length ; int even = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( A [ i ] % 2 == 0 ) even ++ ; if ( even % 2 == 1 ) { return true ; } else { if ( even == N - 1 ) { for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 1 ) { if ( A [ i ] == 1 ) return false ; A [ i ] -- ; break ; } } int gcd = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) gcd = gcd ( gcd , A [ i ] ) ; for ( int i = 0 ; i < N ; i ++ ) A [ i ] /= gcd ; return ! win ( A ) ; } else { return false ; } } } static int gcd ( int a , int b ) { return a % b == 0 ? b : gcd ( b , a % b ) ; } } +","from fractions import gcd NEW_LINE def gcdL ( L ) : NEW_LINE INDENT g = L [ 0 ] NEW_LINE for i in range ( 1 , len ( L ) ) : NEW_LINE INDENT if g == 1 : NEW_LINE INDENT return ( g ) NEW_LINE DEDENT g = gcd ( g , L [ i ] ) NEW_LINE DEDENT return g NEW_LINE DEDENT def play ( A , i ) : NEW_LINE INDENT A [ i ] -= 1 NEW_LINE g = gcdL ( A ) NEW_LINE return [ x // g for x in A ] NEW_LINE DEDENT def cnt ( A ) : NEW_LINE INDENT odd , even = 0 , 0 NEW_LINE for a in A : NEW_LINE INDENT if a % 2 : NEW_LINE INDENT odd += 1 NEW_LINE DEDENT else : NEW_LINE INDENT even += 1 NEW_LINE DEDENT DEDENT return odd , even NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE First = 1 NEW_LINE while True : NEW_LINE INDENT odd , even = cnt ( A ) NEW_LINE if even % 2 : NEW_LINE INDENT print ( ' First ' if First else ' Second ' ) NEW_LINE break NEW_LINE DEDENT elif odd > 1 : NEW_LINE INDENT print ( ' Second ' if First else ' First ' ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if A [ i ] % 2 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if A [ i ] == 1 : NEW_LINE INDENT print ( ' Second ' if First else ' First ' ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT A = play ( A , i ) NEW_LINE First ^= 1 NEW_LINE DEDENT DEDENT DEDENT +" +E28,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . next ( ) . split ( "" "" ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] . equals ( s [ s . length - i - 1 ] ) || s [ i ] . equals ( "" * "" ) || s [ s . length - i - 1 ] . equals ( "" * "" ) ) continue ; System . out . println ( "" NO "" ) ; return ; } System . out . println ( "" YES "" ) ; } } +","s = input ( ) NEW_LINE t = s [ : : - 1 ] NEW_LINE for x , y in zip ( s , t ) : NEW_LINE INDENT if x != ' * ' and y != ' * ' and x != y : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( ' YES ' ) NEW_LINE +" +E29,"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int M = sc . nextInt ( ) ; int [ ] B = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int n = 0 ; for ( int m = 0 ; m < M ; m ++ ) { while ( true ) { if ( n >= N ) { out . println ( "" no "" ) ; return ; } if ( A [ n ] <= B [ m ] && B [ m ] <= A [ n ] + T ) { n ++ ; break ; } n ++ ; } } out . println ( "" yes "" ) ; } } +","t = int ( input ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE m = int ( input ( ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if n < m : NEW_LINE INDENT print ( "" no "" ) NEW_LINE exit ( ) NEW_LINE DEDENT for i in b : NEW_LINE INDENT for l in range ( len ( a ) ) : NEW_LINE INDENT if i - t - 1 < a [ l ] < i + 1 : NEW_LINE INDENT a . pop ( l ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if len ( a ) == n - m : NEW_LINE INDENT print ( "" yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" no "" ) NEW_LINE DEDENT +" +E30,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] data = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { data [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int x = 1 ; while ( x <= D ) { cnt ++ ; x += data [ i ] ; } } System . out . println ( X + cnt ) ; sc . close ( ) ; } } +","N = int ( input ( ) ) NEW_LINE D , X = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT A = int ( input ( ) ) NEW_LINE ans += ( D - 1 ) // A + 1 NEW_LINE DEDENT print ( ans + X ) NEW_LINE +" +E31,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int sq = sc . nextInt ( ) ; String s = "" "" ; int t = 0 ; int a = 0 ; for ( int i = 0 ; i < sq ; i ++ ) { s = sc . next ( ) ; for ( int j = 0 ; j < sq ; j ++ ) { if ( s . charAt ( j ) == ' R ' ) { t ++ ; } else if ( s . charAt ( j ) == ' B ' ) { a ++ ; } } } if ( a == t ) { System . out . println ( "" DRAW "" ) ; } else if ( a > t ) { System . out . println ( "" AOKI "" ) ; } else if ( a < t ) { System . out . println ( "" TAKAHASHI "" ) ; } } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } +","* a , = open ( 0 ) . read ( ) ; s , t = map ( a . count , "" RB "" ) ; print ( [ "" ADORKAIW "" [ s == t : : 2 ] , "" TAKAHASHI "" ] [ s > t ] ) NEW_LINE +" +E32,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int ans = A * S + B * T ; if ( S + T >= K ) ans -= C * ( S + T ) ; System . out . println ( ans ) ; } } +","a , b , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE s , t = map ( int , input ( ) . split ( ) ) NEW_LINE total = s + t NEW_LINE discount = 0 NEW_LINE if total >= k : NEW_LINE INDENT discount = total * c NEW_LINE DEDENT adm = ( s * a ) + ( t * b ) NEW_LINE print ( adm - discount ) NEW_LINE +" +E33,"import java . util . * ; import java . util . stream . Collectors ; import java . util . stream . Stream ; public class Main { static Map < Integer , List < Integer > > map ; static long ans = 0 ; static int [ ] keys ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) , W = in . nextInt ( ) ; map = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int w = in . nextInt ( ) , v = in . nextInt ( ) ; if ( ! map . containsKey ( w ) ) { List < Integer > list = new ArrayList < > ( ) ; list . add ( v ) ; map . put ( w , list ) ; } else { map . get ( w ) . add ( v ) ; } } keys = new int [ map . keySet ( ) . size ( ) ] ; int idx = 0 ; for ( int key : map . keySet ( ) ) { keys [ idx ++ ] = key ; } map . keySet ( ) . stream ( ) . map ( key -> map . get ( key ) ) . forEach ( list -> Collections . sort ( list , Collections . reverseOrder ( ) ) ) ; solve ( W , 0 , 0 , 0L ) ; System . out . println ( ans ) ; } public static void solve ( int W , int idx , int wSum , long vSum ) { if ( idx == keys . length ) { ans = Math . max ( ans , vSum ) ; } else { solve ( W , idx + 1 , wSum , vSum ) ; for ( int v : map . get ( keys [ idx ] ) ) { if ( W - wSum < keys [ idx ] ) return ; wSum += keys [ idx ] ; vSum += ( long ) v ; solve ( W , idx + 1 , wSum , vSum ) ; } } } } +","n , W = map ( int , input ( ) . split ( ) ) NEW_LINE iw , v = map ( int , input ( ) . split ( ) ) NEW_LINE d = { 0 : [ v ] , 1 : [ ] , 2 : [ ] , 3 : [ ] } NEW_LINE for _ in range ( 1 , n ) : NEW_LINE INDENT w , v = map ( int , input ( ) . split ( ) ) NEW_LINE d [ w - iw ] . append ( v ) NEW_LINE DEDENT for i in range ( 4 ) : NEW_LINE INDENT d [ i ] = sorted ( d [ i ] , reverse = True ) NEW_LINE DEDENT ret = - 1 NEW_LINE for i in range ( min ( n , len ( d [ 0 ] ) ) + 1 ) : NEW_LINE INDENT if i * iw > W : NEW_LINE INDENT break NEW_LINE DEDENT for j in range ( min ( n - i , len ( d [ 1 ] ) ) + 1 ) : NEW_LINE INDENT if i * iw + j * ( iw + 1 ) > W : NEW_LINE INDENT break NEW_LINE DEDENT for k in range ( min ( n - ( i + j ) , len ( d [ 2 ] ) ) + 1 ) : NEW_LINE INDENT if i * iw + j * ( iw + 1 ) + k * ( iw + 2 ) > W : NEW_LINE INDENT break NEW_LINE DEDENT for l in range ( min ( n - ( i + j + k ) , len ( d [ 3 ] ) ) + 1 ) : NEW_LINE INDENT if i * iw + j * ( iw + 1 ) + k * ( iw + 2 ) + l * ( iw + 3 ) > W : NEW_LINE INDENT continue NEW_LINE DEDENT V = sum ( d [ 0 ] [ : i ] ) + sum ( d [ 1 ] [ : j ] ) + sum ( d [ 2 ] [ : k ] ) + sum ( d [ 3 ] [ : l ] ) NEW_LINE ret = max ( ret , V ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ret ) NEW_LINE +" +E34,"import java . util . Scanner ; import java . util . * ; public class Main { public static ArrayList < Integer > linkList [ ] [ ] ; public static int dists [ ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; linkList = new ArrayList [ N + 1 ] [ 2 ] ; dists = new int [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { dists [ i ] = Integer . MIN_VALUE ; linkList [ i ] [ 0 ] = new ArrayList < Integer > ( ) ; linkList [ i ] [ 1 ] = new ArrayList < Integer > ( ) ; } for ( int i = 0 ; i < M ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; linkList [ l ] [ 0 ] . add ( r ) ; linkList [ l ] [ 1 ] . add ( d ) ; linkList [ r ] [ 0 ] . add ( l ) ; linkList [ r ] [ 1 ] . add ( - d ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( dists [ i ] != Integer . MIN_VALUE ) continue ; if ( ! dfs ( i , 0 ) ) { System . out . println ( "" No "" ) ; return ; } } System . out . println ( "" Yes "" ) ; } public static boolean dfs ( int i , int dist ) { if ( dists [ i ] != Integer . MIN_VALUE ) return dists [ i ] == dist ; dists [ i ] = dist ; for ( int j = 0 ; j < linkList [ i ] [ 0 ] . size ( ) ; j ++ ) { if ( ! dfs ( linkList [ i ] [ 0 ] . get ( j ) , dist + linkList [ i ] [ 1 ] . get ( j ) ) ) return false ; } return true ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details . +","def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def find ( x ) : NEW_LINE INDENT if par [ x ] == x : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT par [ x ] , dist [ x ] = find ( par [ x ] ) , dist [ x ] + dist [ par [ x ] ] NEW_LINE return par [ x ] NEW_LINE DEDENT DEDENT N , M = inpl ( ) NEW_LINE par = list ( range ( N + 1 ) ) NEW_LINE dist = [ 0 for _ in range ( N + 1 ) ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT l , r , d = inpl ( ) NEW_LINE fl = find ( l ) NEW_LINE fr = find ( r ) NEW_LINE if fl != fr : NEW_LINE INDENT par [ fr ] = fl NEW_LINE dist [ fr ] = d + dist [ l ] - dist [ r ] NEW_LINE DEDENT elif d + dist [ l ] - dist [ r ] != 0 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT +" +E35,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( a == b ? c : b == c ? a : b ) ; } } +","A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if A == B : NEW_LINE INDENT print ( C ) NEW_LINE DEDENT elif A == C : NEW_LINE INDENT print ( B ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( A ) NEW_LINE DEDENT +" +E36,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class A { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int y = in . ints ( ) , m = in . ints ( ) , d = in . ints ( ) ; if ( m <= 2 ) { y -= 1 ; m += 12 ; } int r = 365 * y + ( y / 4 ) - ( y / 100 ) + ( y / 400 ) + ( 306 * ( m + 1 ) / 10 ) + d - 429 ; out . println ( 735369 - r ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } } +","y = int ( input ( ) ) NEW_LINE m = int ( input ( ) ) NEW_LINE d = int ( input ( ) ) NEW_LINE def f ( x ) : NEW_LINE INDENT return int ( x // 1 ) NEW_LINE DEDENT def F ( y , m , d ) : NEW_LINE INDENT if m == 1 or m == 2 : NEW_LINE INDENT y -= 1 NEW_LINE m += 12 NEW_LINE DEDENT return int ( 365 * y + f ( y / 4 ) - f ( y / 100 ) + f ( y / 400 ) + f ( 306 * ( m + 1 ) / 10 ) + d - 429 ) NEW_LINE DEDENT print ( F ( 2014 , 5 , 17 ) - F ( y , m , d ) ) NEW_LINE +" +E37,"import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long K = sc . nextLong ( ) ; Set < Long > sunekeSet = new LinkedHashSet < > ( ) ; for ( long m = 1 ; m <= 10e15 ; m *= 10 ) { boolean sunukeCheckFlag = true ; for ( int i = 1 ; sunukeCheckFlag ; i ++ ) { long x = i * m + m - 1 ; long y = ( i + 1 ) * m + m - 1 ; if ( x * Sn ( y ) <= y * Sn ( x ) ) { sunekeSet . add ( x ) ; if ( K == sunekeSet . size ( ) ) { sunekeSet . stream ( ) . forEach ( System . out :: println ) ; return ; } } else { sunukeCheckFlag = false ; } } } } public static long Sn ( long num ) { long Sn = 0 ; while ( num != 0 ) { Sn += num % 10 ; num /= 10 ; } return Sn ; } } +","f = lambda x : sum ( map ( int , str ( x ) ) ) NEW_LINE ans = [ ] NEW_LINE def check ( x ) : NEW_LINE INDENT y = f ( x ) NEW_LINE while ans : NEW_LINE INDENT p = ans [ - 1 ] NEW_LINE if p * y > x * f ( p ) : ans . pop ( - 1 ) NEW_LINE else : break NEW_LINE DEDENT ans . append ( x ) NEW_LINE DEDENT k = int ( input ( ) ) NEW_LINE for i in range ( 1 , 100 ) : NEW_LINE INDENT check ( i ) NEW_LINE DEDENT a , b = 0 , 1 NEW_LINE while a < 1e12 : NEW_LINE INDENT for i in range ( 100 , 1000 ) : NEW_LINE INDENT check ( i * b + a ) NEW_LINE DEDENT a = a * 10 + 9 NEW_LINE b *= 10 NEW_LINE DEDENT for i in range ( k ) : NEW_LINE INDENT print ( ans [ i ] ) NEW_LINE DEDENT +" +E38,"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int N = sc . nextInt ( ) ; int [ ] [ ] map = new int [ N ] [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { map [ i ] [ 0 ] = sc . nextInt ( ) ; map [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { int start = map [ i ] [ 0 ] ; int end = map [ i ] [ 1 ] ; String tmp = new String ( s ) ; char [ ] target = tmp . substring ( start - 1 , end ) . toCharArray ( ) ; for ( int j = 0 ; j <= end - start ; j ++ ) { s [ start - 1 + j ] = target [ target . length - j - 1 ] ; } } System . out . println ( new String ( s ) ) ; } } +","def solve ( ) : NEW_LINE INDENT s = input ( ) NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT l , r = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE tmp = s [ l - 1 : r ] NEW_LINE s = s [ 0 : l - 1 ] + tmp [ : : - 1 ] + s [ r : : ] NEW_LINE DEDENT print ( s ) NEW_LINE DEDENT solve ( ) NEW_LINE +" +E39,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( ( x - t > 0 ) ? x - t : 0 ) ; sc . close ( ) ; } } +","a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a - b > 0 : NEW_LINE INDENT print ( a - b ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT +" +E40,"import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int q = scanner . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; System . out . println ( solve ( a , b ) ) ; } } private static long solve ( long a , long b ) { if ( a > b ) return solve ( b , a ) ; if ( a == b ) return 2 * a - 2 ; if ( a + 1 == b ) return 2 * a - 2 ; long ab = a * b ; long c = findUpperRoot ( ab ) ; if ( c * ( c + 1 ) >= ab ) return 2 * c - 2 ; return 2 * c - 1 ; } private static long findUpperRoot ( long n ) { long ll = 0 ; long ul = ( long ) Math . sqrt ( n ) + 1 ; while ( ll + 1 < ul ) { long mid = ( ll + ul ) / 2 ; if ( mid * mid < n ) { ll = mid ; } else { ul = mid ; } } return ll ; } } +","import math NEW_LINE q = int ( input ( ) ) NEW_LINE for j in range ( q ) : NEW_LINE INDENT AB = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE AB . sort ( ) NEW_LINE ab = AB [ 0 ] * AB [ 1 ] NEW_LINE for i in range ( int ( math . sqrt ( ab ) ) , AB [ 1 ] + 1 ) : NEW_LINE INDENT if i * i >= ab : NEW_LINE INDENT x = i - 1 NEW_LINE break NEW_LINE DEDENT DEDENT if x == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE continue NEW_LINE DEDENT for i in range ( int ( ab / x ) , ab + 1 ) : NEW_LINE INDENT if x * i >= ab : NEW_LINE INDENT y = i - 1 NEW_LINE break NEW_LINE DEDENT DEDENT cnt1 = 2 * x NEW_LINE cnts = 1 if x == y else 0 NEW_LINE cntdd = 1 if x - AB [ 0 ] >= 0 else 0 NEW_LINE cntdu = 1 if AB [ 1 ] - y >= 0 and ( AB [ 1 ] + 1 ) * ( x - AB [ 1 ] + y ) >= ab else 0 NEW_LINE print ( cnt1 - cnts - cntdd - cntdu ) NEW_LINE DEDENT +" +E41,"import java . math . BigInteger ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long H = sc . nextInt ( ) - 1 ; long W = sc . nextInt ( ) - 1 ; long A = sc . nextInt ( ) - 1 ; long B = sc . nextInt ( ) - 1 ; long MOD = 1000000007L ; BigInteger BMOD = BigInteger . valueOf ( MOD ) ; long x = 1 ; long y = 1 ; for ( long i = W - B ; i <= W - B - 1 + H ; i ++ ) { y = ( y * i ) % MOD ; } for ( long i = 1 ; i <= H ; i ++ ) { y = ( y * BigInteger . valueOf ( i ) . modInverse ( BMOD ) . longValue ( ) ) % MOD ; } long ans = ( x * y ) % MOD ; long a1 = B + 1 ; long a2 = 1 ; long b1 = W - B - 1 + H ; long b2 = H ; for ( int i = 1 ; i < H - A ; i ++ ) { x = ( x * a1 ) % MOD ; x = ( x * BigInteger . valueOf ( a2 ) . modInverse ( BMOD ) . longValue ( ) ) % MOD ; a1 += 1 ; a2 += 1 ; y = ( y * b2 ) % MOD ; y = ( y * BigInteger . valueOf ( b1 ) . modInverse ( BMOD ) . longValue ( ) ) % MOD ; b1 -= 1 ; b2 -= 1 ; ans = ( ans + x * y ) % MOD ; } System . out . println ( ans ) ; } } +","H , W , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE P = 10 ** 9 + 7 NEW_LINE N = H + W NEW_LINE def fact ( N , P ) : NEW_LINE INDENT ret = [ 1 ] * ( N + 1 ) NEW_LINE for n in range ( 2 , N + 1 ) : NEW_LINE INDENT ret [ n ] = ( ret [ n - 1 ] * n ) % P NEW_LINE DEDENT return ret NEW_LINE DEDENT def pow_r ( a , b , P ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT if b % 2 == 0 : NEW_LINE INDENT return pow_r ( ( a ** 2 ) % P , b // 2 , P ) NEW_LINE DEDENT else : NEW_LINE INDENT return ( a * pow_r ( ( a ** 2 ) % P , ( b - 1 ) // 2 , P ) ) % P NEW_LINE DEDENT DEDENT def inv_fact ( N , P ) : NEW_LINE INDENT ret = [ 1 ] * ( N + 1 ) NEW_LINE fac = fact ( N , P ) NEW_LINE ret [ N ] = pow_r ( fac [ N ] , P - 2 , P ) NEW_LINE for n in reversed ( range ( 2 , N ) ) : NEW_LINE INDENT ret [ n ] = ( ret [ n + 1 ] * ( n + 1 ) ) % P NEW_LINE DEDENT return ret NEW_LINE DEDENT fac = fact ( N , P ) NEW_LINE inv = inv_fact ( N , P ) NEW_LINE def combination ( n , r , P ) : NEW_LINE INDENT return ( fac [ n ] * inv [ r ] * inv [ n - r ] ) % P NEW_LINE DEDENT sub = 0 NEW_LINE for a in range ( A ) : NEW_LINE INDENT sub = ( sub + combination ( ( H - 1 - a ) + ( B - 1 ) , B - 1 , P ) * combination ( a + ( W - 1 - B ) , a , P ) ) % P NEW_LINE DEDENT print ( ( combination ( ( H - 1 ) + ( W - 1 ) , H - 1 , P ) - sub ) % P ) NEW_LINE +" +E42,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; import java . util . HashMap ; public class Main { public static void main ( String args [ ] ) { int leftNum , rightNum , cnt = 0 ; Scanner scan = new Scanner ( System . in ) ; leftNum = scan . nextInt ( ) ; rightNum = scan . nextInt ( ) ; ArrayList < Integer > l_list = new ArrayList < Integer > ( ) ; ArrayList < Integer > r_list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < leftNum ; i ++ ) l_list . add ( scan . nextInt ( ) ) ; for ( int i = 0 ; i < rightNum ; i ++ ) r_list . add ( scan . nextInt ( ) ) ; for ( int i = 0 ; i < leftNum ; i ++ ) { int sameIndex = r_list . indexOf ( l_list . get ( i ) ) ; if ( sameIndex != - 1 ) { cnt ++ ; l_list . set ( i , - 1 ) ; r_list . set ( sameIndex , - 1 ) ; } } System . out . println ( cnt ) ; } } +","from collections import Counter NEW_LINE L , R = map ( int , input ( ) . split ( ) ) NEW_LINE inputs_l = Counter ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE inputs_r = Counter ( [ int ( i ) for i in input ( ) . split ( ) ] ) NEW_LINE print ( sum ( [ min ( inputs_r [ key ] , value ) for key , value in inputs_l . items ( ) ] ) ) NEW_LINE +" +E43,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int max = 1 ; for ( int i = 2 ; i <= x ; i ++ ) { int tmp = i * i ; while ( tmp <= x ) { if ( tmp > max ) { max = tmp ; } tmp *= i ; } } System . out . println ( max ) ; sc . close ( ) ; } } +","x = int ( input ( ) ) NEW_LINE y = [ ] NEW_LINE for i in range ( 1 , 33 ) : NEW_LINE INDENT for j in range ( 2 , 11 ) : NEW_LINE INDENT y . append ( i ** j ) NEW_LINE DEDENT DEDENT ans = 1 NEW_LINE for i in y : NEW_LINE INDENT if i <= x : NEW_LINE INDENT ans = max ( ans , i ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E44,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int prev = - 1 ; int count = 0 ; int max = 0 ; for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( prev == arr [ i % n ] ) { count ++ ; if ( max < count ) { max = count ; } } else { count = 1 ; } prev = arr [ i % n ] ; } if ( max > n ) { System . out . println ( - 1 ) ; } else { System . out . println ( ( max - 1 ) / 2 + 1 ) ; } } } +","a = [ int ( input ( ) ) for _ in [ 0 ] * int ( input ( ) ) ] * 2 NEW_LINE if len ( set ( a ) ) < 2 : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT b = c = m = 0 NEW_LINE for i in a : NEW_LINE INDENT if i : NEW_LINE INDENT b += 1 NEW_LINE m = max ( m , b , c ) NEW_LINE c = 0 NEW_LINE DEDENT else : NEW_LINE INDENT c += 1 NEW_LINE m = max ( m , b , c ) NEW_LINE b = 0 NEW_LINE DEDENT DEDENT print ( ~ - m // 2 + 1 ) NEW_LINE +" +E45,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; int ng1 = scn . nextInt ( ) ; int ng2 = scn . nextInt ( ) ; int ng3 = scn . nextInt ( ) ; String ans = "" "" ; if ( n == ng1 || n == ng2 || n == ng3 ) { ans = "" NO "" ; } else { for ( int i = 0 ; i < 100 ; i ++ ) { if ( n - 3 != ng1 && n - 3 != ng2 && n - 3 != ng3 ) n -= 3 ; else if ( n - 2 != ng1 && n - 2 != ng2 && n - 2 != ng3 ) n -= 2 ; else if ( n - 1 != ng1 && n - 1 != ng2 && n - 1 != ng3 ) n -= 1 ; } if ( n > 0 ) ans = "" NO "" ; else ans = "" YES "" ; } System . out . println ( ans ) ; } } +","import sys NEW_LINE N = int ( input ( ) ) NEW_LINE NG1 = int ( input ( ) ) NEW_LINE NG2 = int ( input ( ) ) NEW_LINE NG3 = int ( input ( ) ) NEW_LINE if N == NG1 or N == NG2 or N == NG3 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT queue = [ ] NEW_LINE queue . append ( ( 0 , N ) ) NEW_LINE judge = [ ] NEW_LINE while queue : NEW_LINE INDENT a = queue . pop ( 0 ) NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT b = a [ 1 ] - [ 1 , 2 , 3 ] [ i ] NEW_LINE if b != NG1 and b != NG2 and b != NG3 and a [ 0 ] < 100 : NEW_LINE INDENT num = ( a [ 0 ] + 1 , b ) NEW_LINE if b > 0 and num [ 0 ] < 100 and num not in judge and ( 100 - num [ 0 ] ) * 3 >= b : NEW_LINE INDENT queue . append ( num ) NEW_LINE judge . append ( num ) NEW_LINE DEDENT elif b == 0 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ' NO ' ) NEW_LINE +" +E46,"import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; public class Main { private static List < Set < Integer > > edge ; private static boolean [ ] checked ; private static boolean dfs ( int i ) { if ( checked [ i ] ) return false ; checked [ i ] = true ; Set < Integer > set = edge . get ( i ) ; for ( int j : set ) { edge . get ( j ) . remove ( i ) ; if ( ! dfs ( j ) ) return false ; } set . clear ( ) ; return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; edge = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { edge . add ( new HashSet < > ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { int u = sc . nextInt ( ) - 1 ; int v = sc . nextInt ( ) - 1 ; edge . get ( u ) . add ( v ) ; edge . get ( v ) . add ( u ) ; } checked = new boolean [ n ] ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( dfs ( i ) ) res ++ ; } System . out . println ( res ) ; sc . close ( ) ; } } +","N , M = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE E = [ ] NEW_LINE V = [ [ i + 1 , 0 ] for i in range ( N ) ] NEW_LINE searched_vertex = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT u , v = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE E . append ( [ u , v , True ] ) NEW_LINE DEDENT cnt_trees = 0 NEW_LINE def find_tree ( vertex ) : NEW_LINE INDENT flag = True NEW_LINE index , reached = vertex NEW_LINE if reached == 0 : NEW_LINE INDENT V [ index - 1 ] [ 1 ] = 1 NEW_LINE DEDENT searched_vertex . append ( index ) NEW_LINE while searched_vertex : NEW_LINE INDENT i = searched_vertex [ len ( searched_vertex ) - 1 ] NEW_LINE for edge_index in range ( len ( E ) ) : NEW_LINE INDENT u , v , unused = E [ edge_index ] NEW_LINE if unused : NEW_LINE INDENT if u == i : NEW_LINE INDENT E [ edge_index ] [ 2 ] = False NEW_LINE for ind in range ( len ( searched_vertex ) ) : NEW_LINE INDENT if v == searched_vertex [ ind ] : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT V [ v - 1 ] [ 1 ] = 1 NEW_LINE searched_vertex . append ( v ) NEW_LINE break NEW_LINE DEDENT DEDENT elif v == i : NEW_LINE INDENT E [ edge_index ] [ 2 ] = False NEW_LINE for ind in range ( len ( searched_vertex ) ) : NEW_LINE INDENT if u == searched_vertex [ ind ] : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT V [ u - 1 ] [ 1 ] = 1 NEW_LINE searched_vertex . append ( u ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT else : NEW_LINE INDENT searched_vertex . pop ( ) NEW_LINE DEDENT DEDENT return flag NEW_LINE DEDENT for index , reached in V : NEW_LINE INDENT if reached == 0 : NEW_LINE INDENT for j in range ( len ( E ) ) : NEW_LINE INDENT E [ j ] [ 2 ] = True NEW_LINE DEDENT if find_tree ( ( index , reached ) ) : NEW_LINE INDENT cnt_trees += 1 NEW_LINE DEDENT DEDENT DEDENT print ( cnt_trees ) NEW_LINE +" +E47,"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; double R = sc . nextDouble ( ) ; double G = sc . nextDouble ( ) ; System . out . println ( ( int ) ( G + ( G - R ) ) ) ; } } +","R = int ( input ( ) ) NEW_LINE G = int ( input ( ) ) NEW_LINE print ( 2 * G - R ) NEW_LINE +" +E48,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) - 1 ; int b = Integer . parseInt ( sc . next ( ) ) - 1 ; System . out . println ( a * b ) ; } } +","a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( a - 1 ) * ( b - 1 ) ) NEW_LINE +" +E49,"import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; String [ ] s = new String [ h ] ; for ( int i = 0 ; i < h ; i ++ ) { s [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < h ; i ++ ) { System . out . println ( s [ i ] ) ; System . out . println ( s [ i ] ) ; } sc . close ( ) ; } } +","import sys , re NEW_LINE from collections import deque , defaultdict , Counter NEW_LINE from math import ceil , sqrt , hypot , factorial , pi , sin , cos , radians NEW_LINE from itertools import permutations , combinations , product NEW_LINE from operator import itemgetter , mul NEW_LINE from copy import deepcopy NEW_LINE from string import ascii_lowercase , ascii_uppercase , digits NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE H , W = MAP ( ) NEW_LINE C = [ input ( ) for _ in range ( H ) ] NEW_LINE for x in C : NEW_LINE INDENT print ( x ) NEW_LINE print ( x ) NEW_LINE DEDENT +" +E50,"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; Set < String > set = new HashSet ( ) ; for ( int i = 0 ; i < N ; i ++ ) { set . add ( sc . next ( ) ) ; } System . out . println ( set . size ( ) ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details . +","print ( len ( set ( [ input ( ) for _ in range ( int ( input ( ) ) ) ] ) ) ) NEW_LINE +" +E51,"import java . util . Scanner ; public class Main { static int ans , N ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String S [ ] = s . split ( "" "" ) ; s = "" "" ; for ( int i = 0 ; i < S . length ; i ++ ) { s += 10 - Integer . parseInt ( S [ i ] ) ; } System . out . println ( s ) ; } } +","n = int ( input ( ) ) NEW_LINE print ( 111 + 999 - n ) NEW_LINE +" +E52,"import java . util . Scanner ; class Main { static long gcd ( long a , long b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String in = scan . next ( ) ; String [ ] in2 = in . split ( "" / "" ) ; long x = Long . parseLong ( in2 [ 0 ] ) ; long y = Long . parseLong ( in2 [ 1 ] ) ; long g = gcd ( x , y ) ; x /= g ; y /= g ; scan . close ( ) ; long n = 2 * x / y ; n = Math . max ( n , 1 ) ; boolean f = true ; for ( ; n <= 2 * x / y + 1 ; n ++ ) { if ( n % y == 0 ) { System . out . println ( n + "" ▁ "" + ( n * ( n + 1 ) / 2 - n / y * x ) ) ; f = false ; } } if ( f ) System . out . println ( "" Impossible "" ) ; } } +","import sys NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt , ceil , floor NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE from string import ascii_lowercase NEW_LINE INF = float ( "" inf "" ) NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE dy = [ 0 , - 1 , 0 , 1 ] NEW_LINE dx = [ 1 , 0 , - 1 , 0 ] NEW_LINE def inside ( y : int , x : int , H : int , W : int ) -> bool : return 0 <= y < H and 0 <= x < W NEW_LINE def main ( ) : NEW_LINE INDENT X , Y = map ( int , input ( ) . split ( "" / "" ) ) NEW_LINE ans_list = [ ] NEW_LINE for n in range ( max ( 0 , 2 * X // Y - 10 ) , 2 * X // Y + 10 ) : NEW_LINE INDENT a = n * ( Y + n * Y - 2 * X ) NEW_LINE if a % ( 2 * Y ) == 0 : NEW_LINE INDENT m = a // ( 2 * Y ) NEW_LINE if 0 < m <= n : NEW_LINE INDENT ans_list . append ( "" { 0 } ▁ { 1 } "" . format ( n , m ) ) NEW_LINE DEDENT DEDENT DEDENT if ans_list : NEW_LINE INDENT print ( * ans_list , sep = "" \n "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Impossible "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E53,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int n , a , b , digitsSum = 0 , totalSum = 0 ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; for ( int i = 1 ; i <= n ; 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 ) ; } } +","N , A , B = map ( int , input ( ) . split ( "" ▁ "" ) ) NEW_LINE total = 0 NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT sum = 0 NEW_LINE temp = i NEW_LINE for m in range ( 5 ) : NEW_LINE INDENT sum += temp % 10 NEW_LINE temp = temp // 10 NEW_LINE DEDENT if A <= sum and sum <= B : NEW_LINE INDENT total += i NEW_LINE DEDENT DEDENT print ( total ) NEW_LINE +" +E54,"import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String input = s . next ( ) ; int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; for ( int i = 0 ; i < input . length ( ) ; i ++ ) { if ( i == a || i == b || i == c || i == d ) { System . out . print ( "" \"" "" ) ; } System . out . print ( input . charAt ( i ) ) ; } if ( input . length ( ) == d ) { System . out . print ( "" \"" "" ) ; } System . out . println ( ) ; } } +","s = input ( ) NEW_LINE a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE print ( s [ 0 : a ] + ' "" ' + s [ a : b ] + ' "" ' + s [ b : c ] + ' "" ' + s [ c : d ] + ' "" ' + s [ d : ] ) NEW_LINE +" +E55,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i <= n ; i += 7 ) { for ( int j = 0 ; i + j <= n ; j += 4 ) { if ( i + j == n ) { System . out . println ( "" Yes "" ) ; return ; } } } System . out . println ( "" No "" ) ; } } +","N = int ( input ( ) ) NEW_LINE for cake in range ( 26 ) : NEW_LINE INDENT flag = False NEW_LINE for donut in range ( 15 ) : NEW_LINE INDENT if 4 * cake + 7 * donut == N : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT +" +E56,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( b <= a ? "" delicious "" : b <= x + a ? "" safe "" : "" dangerous "" ) ; } } +","x , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if 0 < b - a <= x : print ( "" safe "" ) NEW_LINE else : print ( "" ddealnigceiroouuss "" [ b - a > x : : 2 ] ) NEW_LINE +" +E57,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AMoveAndWin solver = new AMoveAndWin ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AMoveAndWin { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) , a = in . ints ( ) , b = in . ints ( ) ; if ( ( b - a ) % 2 == 0 ) { out . println ( "" Alice "" ) ; } else { out . println ( "" Borys "" ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } } +","n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if ( ( b - a ) % 2 == 0 ) : NEW_LINE INDENT print ( "" Alice "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Borys "" ) NEW_LINE DEDENT +" +E58,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s [ ] = "" abcdefghijklmnopqrstuvwxyz "" . split ( "" "" , 0 ) ; String po = sc . next ( ) ; String a [ ] = po . split ( "" "" , 0 ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { map . put ( a [ i ] , 0 ) ; } if ( map . size ( ) == 26 ) System . out . println ( "" None "" ) ; else for ( int i = 0 ; i < s . length ; i ++ ) { if ( ! map . containsKey ( s [ i ] ) ) { System . out . println ( s [ i ] ) ; break ; } } } } +","S = str ( input ( ) ) NEW_LINE ascii_letters = "" abcdefghijklmnopqrstuvwxyz "" NEW_LINE for letter in ascii_letters : NEW_LINE INDENT if letter not in S : NEW_LINE INDENT print ( letter ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( "" None "" ) NEW_LINE +" +E59,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int sum = 0 ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; max = Math . max ( max , a ) ; sum += a ; } if ( max < sum - max ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } sc . close ( ) ; } } +","N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE L . sort ( reverse = 1 ) NEW_LINE length = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT length += L [ i ] NEW_LINE DEDENT if L [ 0 ] < length : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E60,"import java . util . * ; public class Main { private static long f ( long x ) { long ret = 0 ; while ( x > 0 ) { ret += x % 10 ; x /= 10 ; } return ret ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; ArrayList < Long > set = new ArrayList < Long > ( ) ; for ( long i = Math . max ( 1 , N - 1000 ) ; i < N ; i ++ ) { long val = i + f ( i ) ; if ( val == N ) { set . add ( i ) ; } } System . out . println ( set . size ( ) ) ; for ( long c : set ) { System . out . println ( c ) ; } } } +","n = int ( input ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( max ( 1 , n - 200 ) , n ) : NEW_LINE INDENT if i + sum ( [ int ( x ) for x in list ( str ( i ) ) ] ) == n : NEW_LINE INDENT a . append ( i ) NEW_LINE DEDENT DEDENT print ( len ( a ) ) NEW_LINE for x in a : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT +" +E61,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( input . readLine ( ) ) ; StringTokenizer tokenizer ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { tokenizer = new StringTokenizer ( input . readLine ( ) ) ; sum += Math . abs ( Integer . parseInt ( tokenizer . nextToken ( ) ) - Integer . parseInt ( tokenizer . nextToken ( ) ) ) + 1 ; } System . out . println ( sum ) ; } } +","N = int ( input ( ) ) NEW_LINE lr = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( N ) ] NEW_LINE print ( sum ( list ( zip ( * lr ) ) [ 1 ] ) - sum ( list ( zip ( * lr ) ) [ 0 ] ) + N ) NEW_LINE +" +E62,"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char [ ] c = sc . next ( ) . toCharArray ( ) ; boolean sh [ ] = new boolean [ n + 2 ] ; for ( int z = 0 ; z < 4 ; z ++ ) { Arrays . fill ( sh , false ) ; sh [ 0 ] = ( z & 1 ) == 0 ; sh [ 1 ] = ( z & 2 ) == 0 ; for ( int i = 2 ; i < n + 2 ; i ++ ) { sh [ i ] = sh [ i - 1 ] ^ sh [ i - 2 ] ^ c [ ( i - 1 ) % n ] == ' o ' ; } if ( sh [ n ] == sh [ 0 ] && sh [ n + 1 ] == sh [ 1 ] ) { put ( sh ) ; return ; } } System . out . println ( - 1 ) ; } static void put ( boolean [ ] sh ) { for ( int i = 0 ; i < sh . length - 2 ; i ++ ) { System . out . print ( sh [ i ] ? "" S "" : "" W "" ) ; } System . out . println ( ) ; } } +","n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE s = list ( map ( lambda x : 1 if x == "" o "" else - 1 , list ( s ) ) ) NEW_LINE flag = False NEW_LINE for start in [ [ 1 , 1 ] , [ 1 , - 1 ] , [ - 1 , 1 ] , [ - 1 , - 1 ] ] : NEW_LINE INDENT circle = start + [ 0 ] * ( n - 2 ) NEW_LINE for i in range ( 1 , n - 1 ) : NEW_LINE INDENT circle [ i + 1 ] = circle [ i ] * s [ i ] * circle [ i - 1 ] NEW_LINE DEDENT if circle [ - 2 ] == circle [ - 1 ] * s [ - 1 ] * circle [ 0 ] and circle [ - 1 ] == circle [ 0 ] * s [ 0 ] * circle [ 1 ] : NEW_LINE INDENT flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT ans = "" "" NEW_LINE for i in circle : NEW_LINE INDENT if i == 1 : NEW_LINE INDENT ans += "" S "" NEW_LINE DEDENT else : NEW_LINE INDENT ans += "" W "" NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT +" +E63,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int m = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( m >= d ) { if ( m % d == 0 ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } else { System . out . println ( "" NO "" ) ; } } } +","print ( "" YNEOS "" [ eval ( input ( ) . replace ( ' ▁ ' , ' % ' ) ) > 0 : : 2 ] ) NEW_LINE +" +E64,"import java . util . * ; import java . awt . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] d = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } long m = 1000000007 ; Arrays . sort ( d ) ; int [ ] two = new int [ n ] ; for ( int i = n - 1 ; i > 0 ; i -- ) { int j = i - 1 ; while ( true ) { if ( j < 0 ) { two [ i ] = - 1 ; break ; } if ( d [ j ] * 2 <= d [ i ] ) { two [ i ] = j ; break ; } else { j -- ; } } } long [ ] [ ] dp = new long [ n ] [ 4 ] ; dp [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] + 1 ) % m ; if ( two [ i ] != - 1 ) { dp [ i ] [ 1 ] = ( dp [ i - 1 ] [ 1 ] + dp [ two [ i ] ] [ 0 ] ) % m ; dp [ i ] [ 2 ] = ( dp [ i - 1 ] [ 2 ] + dp [ two [ i ] ] [ 1 ] ) % m ; dp [ i ] [ 3 ] = ( dp [ i - 1 ] [ 3 ] + dp [ two [ i ] ] [ 2 ] ) % m ; } } System . out . println ( dp [ n - 1 ] [ 3 ] ) ; } } +","from bisect import bisect NEW_LINE n = int ( input ( ) ) NEW_LINE d = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE a , d , mod , ans = [ ] , sorted ( d ) , 10 ** 9 + 7 , 0 NEW_LINE for i in range ( n ) : a . append ( n - bisect ( d , d [ i ] * 2 - 1 ) ) NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : a [ i ] += a [ i + 1 ] NEW_LINE for i in range ( n ) : ans = ( ans + bisect ( d , d [ i ] // 2 ) * a [ min ( n - 1 , bisect ( d , d [ i ] * 2 - 1 ) ) ] ) % mod NEW_LINE print ( ans ) NEW_LINE +" +E65,"import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long [ ] A = new long [ N ] ; long [ ] B = new long [ N ] ; HashMap < Long , Integer > map = new HashMap < Long , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextLong ( ) ; B [ i ] = A [ i ] ; } Arrays . sort ( A ) ; for ( int i = 0 ; i < N ; i ++ ) { map . put ( A [ i ] , i ) ; } int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 != map . get ( B [ i ] ) % 2 ) { ans ++ ; } } System . out . println ( ans / 2 ) ; } } +","import bisect NEW_LINE n = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE e = [ ] NEW_LINE for i in range ( n // 2 ) : NEW_LINE INDENT j = int ( input ( ) ) NEW_LINE e . append ( j ) NEW_LINE l . append ( j ) NEW_LINE j = int ( input ( ) ) NEW_LINE l . append ( j ) NEW_LINE DEDENT if n % 2 == 1 : NEW_LINE INDENT j = int ( input ( ) ) NEW_LINE e . append ( j ) NEW_LINE l . append ( j ) NEW_LINE DEDENT l . sort ( ) NEW_LINE e . sort ( ) NEW_LINE res = 0 NEW_LINE for i in range ( 0 , n , 2 ) : NEW_LINE INDENT if e [ min ( len ( e ) - 1 , bisect . bisect_left ( e , l [ i ] ) ) ] != l [ i ] : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE +" +E66,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ProblemC solver = new ProblemC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ProblemC { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int [ ] l = new int [ n + 1 ] ; int [ ] r = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { l [ i ] = in . nextInt ( ) ; r [ i ] = in . nextInt ( ) ; } Arrays . sort ( l ) ; Arrays . sort ( r ) ; long ans = 0 ; for ( int i = 0 ; i < n + 1 ; i ++ ) { ans += Math . max ( 0 , l [ n - i ] - r [ i ] ) ; } ans *= 2 ; out . println ( ans ) ; } } static class FastScanner { private BufferedReader in ; private StringTokenizer st ; public FastScanner ( 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 sys NEW_LINE from operator import itemgetter NEW_LINE N = int ( input ( ) ) NEW_LINE sorted_l = sorted ( ( tuple ( map ( int , l . split ( ) ) ) for l in sys . stdin ) , reverse = True ) NEW_LINE sorted_r = sorted ( sorted_l , key = itemgetter ( 1 ) ) NEW_LINE pos1 , ans1 = 0 , 0 NEW_LINE pos2 , ans2 = 0 , 0 NEW_LINE for i , j in enumerate ( i // 2 for i in range ( N ) ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT dist1 , dist2 = max ( sorted_l [ j ] [ 0 ] - pos1 , 0 ) , max ( pos2 - sorted_r [ j ] [ 1 ] , 0 ) NEW_LINE pos1 , ans1 = pos1 + dist1 , ans1 + dist1 NEW_LINE pos2 , ans2 = pos2 - dist2 , ans2 + dist2 NEW_LINE DEDENT else : NEW_LINE INDENT dist1 , dist2 = max ( pos1 - sorted_r [ j ] [ 1 ] , 0 ) , max ( sorted_l [ j ] [ 0 ] - pos2 , 0 ) NEW_LINE pos1 , ans1 = pos1 - dist1 , ans1 + dist1 NEW_LINE pos2 , ans2 = pos2 + dist2 , ans2 + dist2 NEW_LINE DEDENT DEDENT print ( max ( ans1 + abs ( pos1 ) , ans2 + abs ( pos2 ) ) ) NEW_LINE +" +E67,"import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , a = scanner . nextInt ( ) , b = scanner . nextInt ( ) ; int [ ] s = java . util . stream . IntStream . range ( 0 , n ) . map ( i -> scanner . nextInt ( ) ) . toArray ( ) ; double d = Arrays . stream ( s ) . max ( ) . getAsInt ( ) - Arrays . stream ( s ) . min ( ) . getAsInt ( ) ; System . out . println ( d == 0 ? - 1 : b / d + "" ▁ "" + ( a - Arrays . stream ( s ) . average ( ) . getAsDouble ( ) * b / d ) ) ; } } +","n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE d = max ( s ) - min ( s ) NEW_LINE if d != 0 : NEW_LINE INDENT print ( b / d , a - ( sum ( s ) / n ) * ( b / d ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if b != 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 , a - s [ 0 ] ) NEW_LINE DEDENT DEDENT +" +E68,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; Arrays . sort ( b ) ; int users = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { users ++ ; } else { break ; } } int output = users ; int nowA = users ; int nowB = 0 ; int nowATmp = 0 ; int nowBTmp = 0 ; for ( int i = 1 ; i < 1000001 ; i ++ ) { nowATmp = nowA ; nowBTmp = nowB ; for ( int j = 0 ; j < n - nowA ; j ++ ) { if ( a [ nowA + j ] == i ) { users ++ ; nowATmp ++ ; } else { break ; } } nowA = nowATmp ; for ( int j = 0 ; j < n - nowB ; j ++ ) { if ( b [ nowB + j ] == i - 1 ) { users -- ; nowBTmp ++ ; } else { break ; } } nowB = nowBTmp ; if ( users > output ) { output = users ; } } System . out . println ( output ) ; } } +","n = int ( input ( ) ) NEW_LINE k = 1000000 NEW_LINE nums = [ 0 for _ in range ( k + 2 ) ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE nums [ a ] += 1 NEW_LINE nums [ b + 1 ] -= 1 NEW_LINE DEDENT for i in range ( 1 , k + 1 ) : NEW_LINE INDENT nums [ i ] += nums [ i - 1 ] NEW_LINE DEDENT print ( max ( nums ) ) NEW_LINE +" +E69,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; String s = sc . next ( ) ; String [ ] field = new String [ 9 ] ; int count = 0 ; for ( int i = 0 ; i < 9 ; i ++ ) { field [ i ] = sc . next ( ) ; } int dx = 0 ; int dy = 0 ; if ( s . equals ( "" R "" ) ) { dx = 1 ; dy = 0 ; } else if ( s . equals ( "" L "" ) ) { dx = - 1 ; dy = 0 ; } else if ( s . equals ( "" U "" ) ) { dx = 0 ; dy = - 1 ; } else if ( s . equals ( "" D "" ) ) { dx = 0 ; dy = 1 ; } else if ( s . equals ( "" RU "" ) ) { dx = 1 ; dy = - 1 ; } else if ( s . equals ( "" RD "" ) ) { dx = 1 ; dy = 1 ; } else if ( s . equals ( "" LU "" ) ) { dx = - 1 ; dy = - 1 ; } else if ( s . equals ( "" LD "" ) ) { dx = - 1 ; dy = 1 ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { sb . append ( field [ y - 1 ] . charAt ( x - 1 ) ) ; if ( x == 1 && dx == - 1 ) { dx = 1 ; } if ( x == 9 && dx == 1 ) { dx = - 1 ; } if ( y == 1 && dy == - 1 ) { dy = 1 ; } if ( y == 9 && dy == 1 ) { dy = - 1 ; } x += dx ; y += dy ; } System . out . println ( sb ) ; } } +","x , y , w = input ( ) . split ( ) NEW_LINE x , y = int ( x ) + 7 , int ( y ) + 7 NEW_LINE A = [ input ( ) for i in range ( 9 ) ] NEW_LINE B = [ a [ 1 : ] [ : : - 1 ] + a + a [ : - 1 ] [ : : - 1 ] for a in A ] NEW_LINE C = B [ 1 : ] [ : : - 1 ] + B + B [ : - 1 ] [ : : - 1 ] NEW_LINE D = { ' R ' : ( 1 , 0 ) , ' L ' : ( - 1 , 0 ) , ' U ' : ( 0 , - 1 ) , ' D ' : ( 0 , 1 ) , ' RU ' : ( 1 , - 1 ) , ' RD ' : ( 1 , 1 ) , ' LU ' : ( - 1 , - 1 ) , ' LD ' : ( - 1 , 1 ) } NEW_LINE ans = C [ y ] [ x ] NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT dx , dy = D [ w ] NEW_LINE x += dx NEW_LINE y += dy NEW_LINE ans += C [ y ] [ x ] NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E70,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) , k = in . ints ( ) ; double p = 1L + 3L * ( n - 1L ) + 6L * ( n - k ) * ( k - 1L ) ; p /= n ; p /= n ; p /= n ; out . println ( p ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } } +","N , K = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( ( K - 1 ) * ( N - K ) * 6 + ( N - 1 ) * 3 + 1 ) / N ** 3 ) NEW_LINE +" +E71,"import java . util . Scanner ; public class Main { static int sum ; static int [ ] dx = { 0 , 0 , 1 , - 1 } ; static int [ ] dy = { 1 , - 1 , 0 , 0 } ; static char [ ] [ ] map ; static int count ; static boolean [ ] [ ] ma ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; map = new char [ 10 ] [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { String a = sc . next ( ) ; for ( int j = 0 ; j < 10 ; j ++ ) { map [ i ] [ j ] = a . charAt ( j ) ; if ( map [ i ] [ j ] == ' o ' ) { sum ++ ; } } } for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { if ( map [ i ] [ j ] == ' x ' ) { map [ i ] [ j ] = ' o ' ; count = 0 ; ma = new boolean [ 10 ] [ 10 ] ; dfs ( j , i ) ; if ( count == ( sum + 1 ) ) { System . out . println ( "" YES "" ) ; return ; } else { map [ i ] [ j ] = ' x ' ; } } } } System . out . println ( "" NO "" ) ; } static boolean judge ( int x , int y ) { return x >= 0 && x < 10 && y >= 0 && y < 10 ; } static void dfs ( int x , int y ) { if ( ma [ y ] [ x ] == true ) { return ; } count ++ ; map [ y ] [ x ] = ' x ' ; ma [ y ] [ x ] = true ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( judge ( x + dx [ i ] , y + dy [ i ] ) && map [ y + dy [ i ] ] [ x + dx [ i ] ] != ' x ' ) { dfs ( x + dx [ i ] , y + dy [ i ] ) ; } } map [ y ] [ x ] = ' o ' ; } } +","H , W = ( 10 , 10 ) NEW_LINE field = [ list ( input ( ) ) for _ in range ( H ) ] NEW_LINE Around = [ [ 0 ] * W for _ in range ( H ) ] NEW_LINE cnt_islands = 0 NEW_LINE def dfs ( x , y ) : NEW_LINE INDENT if x < 0 or x >= W or y < 0 or y >= H or field [ y ] [ x ] == "" r "" : NEW_LINE INDENT return NEW_LINE DEDENT if field [ y ] [ x ] == "" x "" : NEW_LINE INDENT field [ y ] [ x ] = "" r "" NEW_LINE Around [ y ] [ x ] += 1 NEW_LINE return NEW_LINE DEDENT field [ y ] [ x ] = "" r "" NEW_LINE dfs ( x + 1 , y ) NEW_LINE dfs ( x - 1 , y ) NEW_LINE dfs ( x , y + 1 ) NEW_LINE dfs ( x , y - 1 ) NEW_LINE DEDENT for y in range ( H ) : NEW_LINE INDENT for x in range ( W ) : NEW_LINE INDENT if field [ y ] [ x ] == "" o "" : NEW_LINE INDENT for yr in range ( H ) : NEW_LINE INDENT for xr in range ( W ) : NEW_LINE INDENT if field [ yr ] [ xr ] == "" r "" : NEW_LINE INDENT field [ yr ] [ xr ] = "" x "" NEW_LINE DEDENT DEDENT DEDENT dfs ( x , y ) NEW_LINE cnt_islands += 1 NEW_LINE DEDENT DEDENT DEDENT if cnt_islands == 1 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT f = False NEW_LINE for y in range ( H ) : NEW_LINE INDENT for x in range ( W ) : NEW_LINE INDENT if Around [ y ] [ x ] == cnt_islands : NEW_LINE INDENT f = True NEW_LINE print ( ' YES ' ) NEW_LINE break NEW_LINE DEDENT DEDENT if f : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if not f : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT DEDENT +" +E72,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { arr [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] % 2 != 0 ) { System . out . println ( "" No "" ) ; return ; } } System . out . println ( "" Yes "" ) ; } } +","import collections NEW_LINE letter = collections . Counter ( input ( ) ) NEW_LINE counter = 0 NEW_LINE for v in letter . values ( ) : NEW_LINE INDENT if v % 2 == 1 : NEW_LINE INDENT counter += 1 NEW_LINE break NEW_LINE DEDENT DEDENT print ( "" Yes "" ) if counter == 0 else print ( "" No "" ) NEW_LINE +" +E73,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int L = scanner . nextInt ( ) ; int N = scanner . nextInt ( ) ; int [ ] x = new int [ N ] ; int [ ] y = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = scanner . nextInt ( ) ; y [ N - i - 1 ] = L - x [ i ] ; } long [ ] x2 = new long [ N + 1 ] ; long [ ] y2 = new long [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) x2 [ i ] = x2 [ i - 1 ] + x [ i - 1 ] * 2L ; for ( int i = 1 ; i <= N ; i ++ ) y2 [ i ] = y2 [ i - 1 ] + y [ i - 1 ] * 2L ; long max = x [ N - 1 ] ; for ( int n = N - 1 ; n > 0 ; n -- ) { int m = N - n ; if ( n > m ) { max = Math . max ( max , Math . max ( x2 [ n - 1 ] - x2 [ n - m - 1 ] + y2 [ m ] - y2 [ 0 ] + x [ n - 1 ] , x2 [ n ] - x2 [ n - m ] + y2 [ m - 1 ] - y2 [ 0 ] + y [ m - 1 ] ) ) ; } else { max = Math . max ( max , Math . max ( x2 [ n - 1 ] - x2 [ 0 ] + y2 [ m ] - y2 [ m - n ] + x [ n - 1 ] , x2 [ n ] - x2 [ 0 ] + y2 [ m - 1 ] - y2 [ Math . max ( m - n - 1 , 0 ) ] + y [ m - 1 ] ) ) ; } } max = Math . max ( max , y [ N - 1 ] ) ; System . out . println ( max ) ; } } +","L , N = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ 0 ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT X . append ( int ( input ( ) ) ) NEW_LINE DEDENT s = [ 0 ] * ( N + 1 ) NEW_LINE t = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT s [ i ] = s [ i - 1 ] + X [ i ] NEW_LINE t [ i ] = t [ i - 1 ] + ( L - X [ N - i + 1 ] ) NEW_LINE DEDENT Y = [ 0 ] + [ L - X [ N - i ] for i in range ( N ) ] NEW_LINE def get_d ( s , x , i ) : NEW_LINE INDENT if i == N : NEW_LINE INDENT return x [ N ] NEW_LINE DEDENT a = i + ( N - i ) // 2 NEW_LINE return ( 2 * ( s [ a ] - s [ i - 1 ] + L * ( N - a ) - s [ N ] + s [ a ] ) - ( x [ a ] if ( N - i ) % 2 == 0 else ( L - x [ a + 1 ] ) ) ) NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT ans = max ( ans , get_d ( s , X , i ) , get_d ( t , Y , i ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E74,"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int res = 0 ; Integer [ ] a = new Integer [ n ] ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; map . put ( a [ i ] , map . getOrDefault ( a [ i ] , 0 ) + 1 ) ; } Arrays . sort ( a , ( x , y ) -> y - x ) ; for ( int key : a ) { int countKey = map . getOrDefault ( key , 0 ) ; if ( countKey > 0 ) { map . put ( key , countKey - 1 ) ; int diff = Integer . highestOneBit ( key ) * 2 - key ; int countDiff = map . getOrDefault ( diff , 0 ) ; if ( countDiff > 0 ) { map . put ( diff , countDiff - 1 ) ; res ++ ; } else map . put ( key , countKey ) ; } } System . out . println ( res ) ; } } +","from collections import Counter NEW_LINE input ( ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A . sort ( reverse = True ) NEW_LINE C = Counter ( A ) NEW_LINE ans = 0 NEW_LINE for a in A : NEW_LINE INDENT if not C [ a ] : NEW_LINE INDENT continue NEW_LINE DEDENT C [ a ] -= 1 NEW_LINE t = 2 ** a . bit_length ( ) - a NEW_LINE if C [ t ] : NEW_LINE INDENT C [ t ] -= 1 NEW_LINE ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E75,"import java . util . * ; public class Main { public static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; final int INF = 1_000_000_000 ; int n = sc . nextInt ( ) ; long c = sc . nextLong ( ) ; long [ ] x = new long [ n ] ; long [ ] v = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextLong ( ) ; v [ i ] = sc . nextLong ( ) ; } long sum1 = 0 ; long sum2 = 0 ; long [ ] dp1 = new long [ n + 1 ] ; long [ ] dp2 = new long [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { sum1 += v [ i ] ; dp1 [ i + 1 ] = sum1 - x [ i ] ; dp1 [ i + 1 ] = Math . max ( dp1 [ i ] , dp1 [ i + 1 ] ) ; sum2 += v [ n - i - 1 ] ; dp2 [ i + 1 ] = sum2 - ( c - x [ n - i - 1 ] ) ; dp2 [ i + 1 ] = Math . max ( dp2 [ i ] , dp2 [ i + 1 ] ) ; } long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long a1 = Math . max ( dp1 [ i + 1 ] , dp1 [ i + 1 ] - x [ i ] + dp2 [ n - i - 1 ] ) ; long a2 = Math . max ( dp2 [ i + 1 ] , dp2 [ i + 1 ] - ( c - x [ n - i - 1 ] ) + dp1 [ n - i - 1 ] ) ; long aa = Math . max ( a1 , a2 ) ; ans = Math . max ( ans , aa ) ; } System . out . println ( ans ) ; } } +","N , C = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE X = [ 0 ] * N NEW_LINE V = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT X [ i ] , V [ i ] = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE DEDENT def calc ( X , V ) : NEW_LINE INDENT Vcumsum = [ 0 ] NEW_LINE for v in V : NEW_LINE INDENT Vcumsum += [ Vcumsum [ - 1 ] + v ] NEW_LINE DEDENT cumsum = [ 0 ] * ( N + 1 ) NEW_LINE cumsum_r = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT cumsum [ i + 1 ] = Vcumsum [ i + 1 ] - X [ i ] NEW_LINE cumsum_r [ i + 1 ] = Vcumsum [ N ] - Vcumsum [ N - i - 1 ] - ( C - X [ - 1 - i ] ) NEW_LINE DEDENT cumsum_max = [ 0 ] * ( N + 1 ) NEW_LINE cumsum_r_max = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT cumsum_max [ i + 1 ] = max ( cumsum [ i + 1 ] , cumsum_max [ i ] ) NEW_LINE cumsum_r_max [ i + 1 ] = max ( cumsum_r [ i + 1 ] , cumsum_r_max [ i ] ) NEW_LINE DEDENT res = max ( cumsum_max [ - 1 ] , cumsum_r_max [ - 1 ] ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT res = max ( res , cumsum_max [ i + 1 ] + cumsum_r_max [ N - i - 1 ] - X [ i ] , cumsum_r_max [ i + 1 ] + cumsum_max [ N - i - 1 ] - ( C - X [ - 1 - i ] ) ) NEW_LINE DEDENT return res NEW_LINE DEDENT print ( calc ( X , V ) ) NEW_LINE +" +E76,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( ( a - 1 ) * ( b - 1 ) ) ; } } +","n , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( n - 1 ) * ( m - 1 ) ) NEW_LINE +" +E77,"import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ma = sc . nextInt ( ) ; int mb = sc . nextInt ( ) ; int [ ] [ ] dp = new int [ 401 ] [ 401 ] ; for ( int i = 0 ; i < 401 ; i ++ ) { Arrays . fill ( dp [ i ] , Integer . MAX_VALUE ) ; } dp [ 0 ] [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; for ( int j = 400 ; j >= a ; j -- ) { for ( int k = 400 ; k >= b ; k -- ) { if ( dp [ j - a ] [ k - b ] != Integer . MAX_VALUE ) { dp [ j ] [ k ] = Math . min ( dp [ j ] [ k ] , c + dp [ j - a ] [ k - b ] ) ; } } } } int ans = Integer . MAX_VALUE ; for ( int i = 1 ; 401 > Math . max ( ma , mb ) * i ; i ++ ) { if ( dp [ ma * i ] [ mb * i ] != Integer . MAX_VALUE ) { ans = Math . min ( ans , dp [ ma * i ] [ mb * i ] ) ; } } if ( ans == Integer . MAX_VALUE ) { System . out . println ( - 1 ) ; } else { System . out . println ( ans ) ; } } } +","NM = 40 NEW_LINE ABM = 10 NEW_LINE MM = 400 NEW_LINE N , M1 , M2 = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE B = [ ] NEW_LINE C = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE A . append ( a ) NEW_LINE B . append ( b ) NEW_LINE C . append ( c ) NEW_LINE DEDENT cmax = max ( C ) NEW_LINE CM = N * cmax + 10 NEW_LINE dp = [ [ [ CM for broop in range ( 401 ) ] for aroop in range ( 401 ) ] for nroop in range ( N + 1 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT for cb in range ( 401 ) : NEW_LINE INDENT for ca in range ( 401 ) : NEW_LINE INDENT if dp [ i ] [ ca ] [ cb ] == CM : NEW_LINE INDENT continue NEW_LINE DEDENT dp [ i + 1 ] [ ca ] [ cb ] = min ( dp [ i + 1 ] [ ca ] [ cb ] , dp [ i ] [ ca ] [ cb ] ) NEW_LINE if ca + A [ i ] < 401 and cb + B [ i ] < 401 : NEW_LINE INDENT dp [ i + 1 ] [ ca + A [ i ] ] [ cb + B [ i ] ] = min ( dp [ i + 1 ] [ ca + A [ i ] ] [ cb + B [ i ] ] , dp [ i ] [ ca ] [ cb ] + C [ i ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT ans = CM NEW_LINE for cb in range ( 400 ) : NEW_LINE INDENT for ca in range ( 400 ) : NEW_LINE INDENT CB = cb + 1 NEW_LINE CA = ca + 1 NEW_LINE if CA * M2 == CB * M1 : NEW_LINE INDENT ans = min ( ans , dp [ N ] [ CA ] [ CB ] ) NEW_LINE DEDENT DEDENT DEDENT if ans == CM : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ans ) NEW_LINE DEDENT +" +E78,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( b == 100 ) { System . out . println ( 101 * ( int ) Math . pow ( 100 , a ) ) ; } else { System . out . println ( b * ( int ) Math . pow ( 100 , a ) ) ; } } } +","D , N = map ( int , input ( ) . split ( ) ) NEW_LINE count = 0 NEW_LINE x = 0 NEW_LINE while count != N : NEW_LINE INDENT x += 1 NEW_LINE if x % 100 ** D == 0 and x % 100 ** ( D + 1 ) != 0 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( x ) NEW_LINE +" +E79,"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( n / 3 ) ; sc . close ( ) ; } } +","print ( int ( input ( ) ) // 3 ) NEW_LINE +" +E80,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; System . out . println ( "" A "" + sc . next ( ) . charAt ( 0 ) + "" C "" ) ; sc . next ( ) ; } } +","print ( "" A "" + input ( ) [ 8 ] + "" C "" ) NEW_LINE +" +E81,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; out . println ( S . charAt ( S . length ( ) - 1 ) == ' T ' ? "" YES "" : "" NO "" ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } +","s = input ( ) NEW_LINE if ( s [ - 1 ] == "" T "" ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT +" +E82,"import java . util . * ; public class Main { static int [ ] [ ] [ ] dp ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int prev = - 1 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( prev == a ) { count ++ ; prev = - 1 ; } else { prev = a ; } } System . out . println ( count ) ; } } +","n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if a [ i ] == a [ i - 1 ] : NEW_LINE INDENT ans += 1 NEW_LINE a [ i ] = ' x ' NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E83,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long X = sc . nextLong ( ) ; long [ ] positionArr = new long [ N ] ; long [ ] cumulativeSum = new long [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { positionArr [ i ] = sc . nextLong ( ) ; cumulativeSum [ i + 1 ] = cumulativeSum [ i ] + positionArr [ i ] ; } long sum = X * N + 5 * cumulativeSum [ N ] ; for ( int i = 1 ; i < N ; i ++ ) { long cost = X * i + 5 * ( cumulativeSum [ N ] - cumulativeSum [ N - i ] ) ; for ( int j = 5 , k = N - i ; k >= 0 ; j += 2 , k -= i ) { if ( cost > sum ) { break ; } cost += j * ( cumulativeSum [ k ] - cumulativeSum [ Math . max ( k - i , 0 ) ] ) ; } sum = Math . min ( sum , cost ) ; } System . out . println ( sum + X * N ) ; } } +","iN , iX = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE aX = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE aCum = [ 0 ] * iN NEW_LINE aCum [ 0 ] = aX [ 0 ] NEW_LINE for i in range ( 1 , iN ) : NEW_LINE INDENT aCum [ i ] = aCum [ i - 1 ] + aX [ i ] NEW_LINE DEDENT def fCeil ( iT , iR ) : NEW_LINE INDENT return - 1 * iT // iR * - 1 NEW_LINE DEDENT def fCalcCost ( iN , iX , aCum , iK ) : NEW_LINE INDENT return ( iN + iK ) * iX + 5 * aCum [ - 1 ] + sum ( 2 * aCum [ - i * iK - 1 ] for i in range ( 2 , fCeil ( iN , iK ) ) ) NEW_LINE DEDENT iTotalCost = fCalcCost ( iN , iX , aCum , 1 ) NEW_LINE iULim = fCeil ( iN , 2 ) + 1 NEW_LINE for iK in range ( 2 , fCeil ( iN , 2 ) + 1 ) : NEW_LINE INDENT iThisCost = fCalcCost ( iN , iX , aCum , iK ) NEW_LINE if iThisCost > iTotalCost : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT iTotalCost = iThisCost NEW_LINE DEDENT DEDENT print ( iTotalCost ) NEW_LINE +" +E84,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int h = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( a + b ) * h / 2 ) ; } } +","a , b , h = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE S = int ( ( a + b ) * h / 2 ) NEW_LINE print ( S ) NEW_LINE +" +E85,"import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main implements Runnable { public static void main ( String [ ] args ) { new Thread ( null , new Main ( ) , "" "" , Runtime . getRuntime ( ) . maxMemory ( ) ) . start ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean [ ] [ ] a = new boolean [ n ] [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { String s = sc . next ( ) ; for ( int j = 0 ; j < n ; ++ j ) { a [ i ] [ n - 1 - j ] = s . charAt ( j ) == ' o ' ; } } int cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < n ; ++ j ) { if ( a [ i ] [ j ] ) continue ; if ( ! a [ i ] [ j ] ) { ++ cnt ; for ( int k = j ; k < n ; ++ k ) { a [ i ] [ k ] = true ; } for ( int k = 0 ; i + 1 < n && k <= j ; ++ k ) { a [ i + 1 ] [ k ] = true ; } } } } System . out . println ( cnt ) ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } +","field = [ ] NEW_LINE n = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT field . append ( list ( map ( str , input ( ) ) ) ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ' . ' in field [ i ] : NEW_LINE INDENT j = n - field [ i ] [ : : - 1 ] . index ( ' . ' ) - 1 NEW_LINE field [ i ] = [ ' o ' ] * n NEW_LINE if i != n - 1 : NEW_LINE INDENT field [ i + 1 ] [ j : ] = [ ' O ' ] * len ( field [ i + 1 ] [ j : ] ) NEW_LINE DEDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E86,"import java . util . * ; public class Main { private class Section { int l , r , v ; public Section ( int now , int t , int v ) { this . l = now ; this . r = now + t ; this . v = v ; } public double getMaxV ( double t ) { if ( t < l ) { return v + ( l - t ) ; } else if ( r < t ) { return v + ( t - r ) ; } else { return v ; } } } public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int t [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { t [ i ] = sc . nextInt ( ) ; } Section secs [ ] = new Section [ n + 2 ] ; int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int v = sc . nextInt ( ) ; secs [ i ] = new Section ( sum , t [ i - 1 ] , v ) ; sum += t [ i - 1 ] ; } secs [ 0 ] = new Section ( 0 , 0 , 0 ) ; secs [ n + 1 ] = new Section ( sum , 0 , 0 ) ; double ans = 0.0 ; for ( double now = 0.0 ; now <= sum - 0.5 ; now += 0.5 ) { double v1 = secs [ 0 ] . getMaxV ( now ) ; double v2 = secs [ 0 ] . getMaxV ( now + 0.5 ) ; for ( int i = 1 ; i < n + 2 ; i ++ ) { v1 = Math . min ( v1 , secs [ i ] . getMaxV ( now ) ) ; v2 = Math . min ( v2 , secs [ i ] . getMaxV ( now + 0.5 ) ) ; } ans += ( v1 + v2 ) * 0.25 ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } } +","n = int ( input ( ) ) NEW_LINE t = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE v = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE maxspeed = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( n - 1 , 0 , - 1 ) : NEW_LINE INDENT maxspeed [ i ] = min ( v [ i ] , v [ i - 1 ] , t [ i ] + maxspeed [ i + 1 ] ) NEW_LINE DEDENT def dist ( i , first ) : NEW_LINE INDENT ta = v [ i ] - first NEW_LINE tb = v [ i ] - maxspeed [ i + 1 ] NEW_LINE if ta + tb <= t [ i ] : NEW_LINE INDENT c = ( first + v [ i ] ) * ta / 2 + v [ i ] * ( t [ i ] - ta - tb ) + ( maxspeed [ i + 1 ] + v [ i ] ) * tb / 2 NEW_LINE lastspeed = maxspeed [ i + 1 ] NEW_LINE DEDENT elif maxspeed [ i + 1 ] - first > t [ i ] : NEW_LINE INDENT c = ( first + first + t [ i ] ) * t [ i ] / 2 NEW_LINE lastspeed = first + t [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT a = ( maxspeed [ i + 1 ] + t [ i ] - first ) / 2 NEW_LINE c = ( first + first + a ) * a / 2 + ( first + a + maxspeed [ i + 1 ] ) * ( t [ i ] - a ) / 2 NEW_LINE lastspeed = maxspeed [ i + 1 ] NEW_LINE DEDENT return c , lastspeed NEW_LINE DEDENT ans = 0 NEW_LINE firstspeed = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT d , firstspeed = dist ( i , firstspeed ) NEW_LINE ans += d NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E87,"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int l [ ] = new int [ N ] ; int r [ ] = new int [ N ] ; int s [ ] = new int [ N ] ; int point [ ] = new int [ M ] ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { l [ i ] = sc . nextInt ( ) - 1 ; r [ i ] = sc . nextInt ( ) - 1 ; s [ i ] = sc . nextInt ( ) ; sum += s [ i ] ; point [ l [ i ] ] += s [ i ] ; if ( r [ i ] != M - 1 ) { point [ r [ i ] + 1 ] -= s [ i ] ; } } int min = Integer . MAX_VALUE ; int temp = 0 ; for ( int i = 0 ; i < M ; i ++ ) { temp += point [ i ] ; min = Math . min ( min , temp ) ; } System . out . println ( sum - min ) ; } } +","import itertools NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE score = [ 0 ] * ( M + 1 ) NEW_LINE s_sum = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT l , r , s = map ( int , input ( ) . split ( ) ) NEW_LINE score [ ( l - 1 ) ] += s NEW_LINE score [ r ] += - s NEW_LINE s_sum += s NEW_LINE DEDENT score_list = list ( itertools . accumulate ( score ) ) NEW_LINE ans = s_sum - min ( score_list [ : - 1 ] ) NEW_LINE print ( ans ) NEW_LINE +" +E88,"import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int D = sc . nextInt ( ) ; String S = "" "" ; switch ( D ) { case 22 : S = "" Christmas ▁ Eve ▁ Eve ▁ Eve "" ; break ; case 23 : S = "" Christmas ▁ Eve ▁ Eve "" ; break ; case 24 : S = "" Christmas ▁ Eve "" ; break ; case 25 : S = "" Christmas "" ; break ; } System . out . println ( S ) ; } } +","D = int ( input ( ) ) NEW_LINE print ( "" Christmas "" + "" ▁ Eve "" * ( 25 - D ) ) NEW_LINE +" +E89,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String turn = "" Ant "" ; while ( n > 0 ) { if ( turn . equals ( "" Ant "" ) ) { n -= a ; turn = "" Bug "" ; } else { n -= b ; turn = "" Ant "" ; } } if ( turn . equals ( "" Ant "" ) ) { System . out . println ( "" Bug "" ) ; } else { System . out . println ( "" Ant "" ) ; } } } +","n , a , b = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE num = n % ( a + b ) NEW_LINE if num == 0 : NEW_LINE INDENT print ( "" Bug "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Ant "" if num <= a else "" Bug "" ) NEW_LINE DEDENT +" +E90,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . Scanner ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String [ ] bu = s . split ( "" ▁ "" ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < bu . length - 1 ; i ++ ) { if ( bu [ i ] . charAt ( 0 ) == ' L ' ) { sb . append ( "" < ▁ "" ) ; } else if ( bu [ i ] . charAt ( 0 ) == ' R ' ) { sb . append ( "" > ▁ "" ) ; } else if ( bu [ i ] . charAt ( 0 ) == ' A ' ) { sb . append ( "" A ▁ "" ) ; } } if ( bu [ bu . length - 1 ] . charAt ( 0 ) == ' L ' ) { sb . append ( "" < "" ) ; } else if ( bu [ bu . length - 1 ] . charAt ( 0 ) == ' R ' ) { sb . append ( "" > "" ) ; } else if ( bu [ bu . length - 1 ] . charAt ( 0 ) == ' A ' ) { sb . append ( "" A "" ) ; } System . out . println ( sb . toString ( ) ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } +","n = input ( ) NEW_LINE print ( n . replace ( "" Right "" , "" > "" ) . replace ( "" AtCoder "" , "" A "" ) . replace ( "" Left "" , "" < "" ) ) NEW_LINE +" +E91,"import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String X = sc . next ( ) ; if ( X . charAt ( 0 ) == X . charAt ( 1 ) && X . charAt ( 1 ) == X . charAt ( 2 ) ) { System . out . println ( "" Yes "" ) ; } else if ( X . charAt ( 1 ) == X . charAt ( 2 ) && X . charAt ( 2 ) == X . charAt ( 3 ) ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","num = input ( ) NEW_LINE print ( "" Yes "" if num [ 0 ] == num [ 1 ] == num [ 2 ] or num [ 1 ] == num [ 2 ] == num [ 3 ] else "" No "" ) NEW_LINE +" +E92,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int x = sc . nextInt ( ) ; if ( ! map . containsKey ( x ) ) { map . put ( x , 1 ) ; } else { map . put ( x , map . get ( x ) + 1 ) ; } } List < Integer > list = new ArrayList < > ( map . values ( ) ) ; Collections . sort ( list ) ; int ans = 0 ; for ( int i = 0 ; i < list . size ( ) - K ; i ++ ) { ans += list . get ( i ) ; } System . out . println ( ans ) ; } } } +","def main ( ) : NEW_LINE INDENT from collections import Counter NEW_LINE n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 0 NEW_LINE for index , ( key , value ) in enumerate ( sorted ( Counter ( a ) . items ( ) , key = lambda x : x [ 1 ] , reverse = True ) , 1 ) : NEW_LINE INDENT if index > k : NEW_LINE INDENT ans += value NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E93,"import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = Math . max ( a * b , c * d ) ; System . out . println ( ans ) ; sc . close ( ) ; } } +","a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if a [ 0 ] * a [ 1 ] == a [ 2 ] * a [ 3 ] : NEW_LINE INDENT print ( a [ 0 ] * a [ 1 ] ) NEW_LINE DEDENT elif a [ 0 ] * a [ 1 ] > a [ 2 ] * a [ 3 ] : NEW_LINE INDENT print ( a [ 0 ] * a [ 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a [ 2 ] * a [ 3 ] ) NEW_LINE DEDENT +" +E94,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( ( b - a % b ) % b ) ; } } +","a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( b - a % b if a % b != 0 else 0 ) NEW_LINE +" +E95,"import java . math . BigDecimal ; import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int W = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; System . out . println ( calc ( W - 1 , H - 1 ) ) ; } private static long calc ( long w , long h ) { long start = Math . max ( w , h ) + 1 ; long a = 1 ; long b = 1 ; for ( long i = start ; i <= w + h ; i ++ ) { a *= i ; b *= i - start + 1 ; a = a % 1000000007l ; b = b % 1000000007l ; } return a * pow ( b , 1000000005l ) % 1000000007l ; } static long pow ( long a , long n ) { long mod = 1000000007l ; long tmp = 1 ; while ( n != 0 ) { if ( n % 2 == 1 ) tmp = tmp * a % mod ; a = a * a % mod ; n /= 2 ; } return tmp ; } } +","x , y = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = x - 1 , y - 1 NEW_LINE mod = 1000000007 NEW_LINE c = 1 NEW_LINE for i in range ( min ( x , y ) ) : NEW_LINE INDENT c = ( c * ( x + y - i ) * pow ( i + 1 , mod - 2 , mod ) % mod ) NEW_LINE DEDENT print ( c % mod ) NEW_LINE +" +E96,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long xor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; xor ^= grundy ( a , k ) ; } System . out . println ( ( xor == 0 ) ? "" Aoki "" : "" Takahashi "" ) ; } static long grundy ( int a , int k ) { if ( a % k == 0 ) return a / k ; if ( a < k ) return 0 ; long d = a / k + 1 ; long rem = a % d ; long c = ( long ) Math . ceil ( ( double ) ( a / k * k - rem ) / d ) ; long b = d * c + rem ; if ( b % k == 0 ) return b / k ; a = ( int ) ( b - d ) ; return grundy ( a , k ) ; } } +","def extgcd ( a , b ) : NEW_LINE INDENT if b : NEW_LINE INDENT d , y , x = extgcd ( b , a % b ) NEW_LINE y -= ( a / b ) * x NEW_LINE return d , x , y NEW_LINE DEDENT else : NEW_LINE INDENT return a , 1 , 0 NEW_LINE DEDENT DEDENT N = int ( input ( ) ) NEW_LINE grundy = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT a , k = map ( int , input ( ) . split ( ) ) NEW_LINE while a % k : NEW_LINE INDENT p , q = divmod ( a , k ) NEW_LINE a -= ( p + 1 ) * ( ( q + p ) // ( p + 1 ) ) NEW_LINE DEDENT grundy ^= a // k NEW_LINE DEDENT print ( ' Takahashi ' if grundy else ' Aoki ' ) NEW_LINE +" +E97,"import java . io . InputStream ; import java . io . PrintStream ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; void solv ( int [ ] [ ] x ) { Arrays . sort ( x , new Comparator < int [ ] > ( ) { @ Override public int compare ( int [ ] a , int [ ] b ) { int x = a [ 1 ] - b [ 1 ] ; if ( x == 0 ) { return a [ 2 ] - b [ 2 ] ; } return x ; } } ) ; int prev = - 1 ; int num = 0 ; for ( int i = 0 ; i < x . length ; i ++ ) { if ( x [ i ] [ 1 ] != prev ) { num = 1 ; prev = x [ i ] [ 1 ] ; } else { num ++ ; } x [ i ] [ 3 ] = num ; } Arrays . sort ( x , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int [ ] a : x ) { sb . append ( String . format ( "" % 06d % 06d \n "" , a [ 1 ] , a [ 3 ] ) ) ; } out . print ( sb ) ; } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] x = new int [ m ] [ 4 ] ; for ( int i = 0 ; i < m ; i ++ ) { x [ i ] = new int [ ] { i , sc . nextInt ( ) , sc . nextInt ( ) , - 1 } ; } solv ( x ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } } +","N , M = map ( int , input ( ) . split ( ) ) NEW_LINE py = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT py . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE py [ i ] . append ( i ) NEW_LINE DEDENT py . sort ( key = lambda x : ( x [ 0 ] , x [ 1 ] ) ) NEW_LINE number = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT ct = 1 NEW_LINE number . append ( ( str ( py [ i ] [ 0 ] ) . zfill ( 6 ) + str ( ct ) . zfill ( 6 ) , py [ i ] [ 2 ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if py [ i - 1 ] [ 0 ] == py [ i ] [ 0 ] : NEW_LINE INDENT ct += 1 NEW_LINE number . append ( ( str ( py [ i ] [ 0 ] ) . zfill ( 6 ) + str ( ct ) . zfill ( 6 ) , py [ i ] [ 2 ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ct = 1 NEW_LINE number . append ( ( str ( py [ i ] [ 0 ] ) . zfill ( 6 ) + str ( ct ) . zfill ( 6 ) , py [ i ] [ 2 ] ) ) NEW_LINE DEDENT DEDENT DEDENT number . sort ( key = lambda x : x [ 1 ] ) NEW_LINE for i in number : NEW_LINE INDENT print ( i [ 0 ] ) NEW_LINE DEDENT +" +E98,"import java . util . Arrays ; import java . util . PriorityQueue ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int Q = scan . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { A [ i ] = scan . nextInt ( ) ; B [ i ] = A [ i ] ; } Arrays . sort ( B ) ; int ans = 1000000001 ; PriorityQueue < Integer > que = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( i + Q - 1 >= N || B [ i + Q - 1 ] - B [ i ] >= ans ) continue ; int left = - 1 , right = ans ; while ( right - left > 1 ) { int center = ( right + left ) / 2 ; int cnt = 0 ; que . clear ( ) ; for ( int j = 0 ; j < N ; ++ j ) { if ( A [ j ] < B [ i ] ) que . clear ( ) ; else { que . add ( A [ j ] ) ; if ( que . size ( ) >= K ) { if ( que . poll ( ) - B [ i ] <= center ) ++ cnt ; if ( cnt >= Q ) { break ; } } } } if ( cnt >= Q ) right = center ; else left = center ; } ans = Math . min ( ans , right ) ; } System . out . println ( ans ) ; } } +","N , K , Q = map ( int , input ( ) . split ( ) ) NEW_LINE As = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = 10 ** 9 NEW_LINE for Y in sorted ( As ) [ : N - Q - K + 2 ] : NEW_LINE INDENT cands = [ ] NEW_LINE cs = [ ] NEW_LINE for A in As + [ 0 ] : NEW_LINE INDENT if A < Y : NEW_LINE INDENT if len ( cs ) >= K : NEW_LINE INDENT cands += sorted ( cs ) [ : len ( cs ) - K + 1 ] NEW_LINE DEDENT cs = [ ] NEW_LINE DEDENT else : NEW_LINE INDENT cs += [ A ] NEW_LINE DEDENT DEDENT if len ( cands ) < Q : continue NEW_LINE X = sorted ( cands ) [ Q - 1 ] NEW_LINE ans = min ( ans , X - Y ) NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E99,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 2 ] ; a [ 0 ] = sc . nextInt ( ) ; a [ 1 ] = sc . nextInt ( ) ; System . out . println ( a [ 1 ] + "" ▁ "" + a [ 0 ] ) ; } } +","a , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( b , a ) NEW_LINE +" +E100,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] arr = new char [ ] { ' A ' , ' B ' , ' X ' , ' Y ' } ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < arr . length ; i ++ ) { for ( int j = 0 ; j < arr . length ; j ++ ) { for ( int k = 0 ; k < arr . length ; k ++ ) { for ( int l = 0 ; l < arr . length ; l ++ ) { if ( i == k && j == l ) { continue ; } String x = s . replaceAll ( String . valueOf ( arr [ i ] ) + String . valueOf ( arr [ j ] ) , "" L "" ) ; x = x . replaceAll ( String . valueOf ( arr [ k ] ) + String . valueOf ( arr [ l ] ) , "" R "" ) ; int len = x . length ( ) ; if ( min > len ) { min = len ; } } } } } System . out . println ( min ) ; } } +","from itertools import product NEW_LINE import re NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE C = input ( ) NEW_LINE ans = 2000 NEW_LINE for X in product ( "" ABXY "" , repeat = 4 ) : NEW_LINE INDENT L = "" "" . join ( X [ : 2 ] ) NEW_LINE R = "" "" . join ( X [ 2 : ] ) NEW_LINE ans = min ( ans , len ( C . replace ( L , "" L "" ) . replace ( R , "" R "" ) ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E101,"import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Integer [ ] a = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a , Comparator . reverseOrder ( ) ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { ans += a [ i ] ; } } System . out . println ( ans ) ; } } +","N = int ( input ( ) ) NEW_LINE A = sorted ( [ int ( i ) for i in input ( ) . split ( ) ] , reverse = True ) NEW_LINE print ( sum ( A [ : : 2 ] ) ) NEW_LINE +" +E102,"import java . util . * ; public class Main { private static int n ; private static String [ ] x ; private static int count = 0 ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; x = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = scan . next ( ) ; } } public static void main ( String args [ ] ) { input ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( x [ i ] . contains ( "" x "" ) ) { int j = 0 ; while ( x [ i ] . indexOf ( ' x ' , j ) != - 1 ) { j = x [ i ] . indexOf ( ' x ' , j ) + 1 ; count ++ ; } } } boolean flag = true ; for ( int i = 0 ; i < 9 ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( x [ j ] . charAt ( i ) == ' o ' ) { if ( flag ) { count ++ ; flag = false ; } } else flag = true ; } flag = true ; } System . out . println ( count ) ; } } +","n = int ( input ( ) ) NEW_LINE l = [ input ( ) for i in range ( n ) ] NEW_LINE sum = 0 NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT for j in range ( 9 ) : NEW_LINE INDENT if l [ i ] [ j ] == ' x ' : NEW_LINE INDENT sum += 1 NEW_LINE DEDENT elif l [ i ] [ j ] == ' o ' and ( i + 1 == len ( l ) or l [ i + 1 ] [ j ] != ' o ' ) : NEW_LINE INDENT sum += 1 NEW_LINE DEDENT DEDENT DEDENT print ( sum ) NEW_LINE +" +E103,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; HashMap < Integer , ArrayList < Integer > > map = new HashMap < > ( ) ; boolean [ ] isVisited = new boolean [ n + 1 ] ; isVisited [ 0 ] = true ; for ( int i = 0 ; i < m ; i ++ ) { int num1 = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; if ( map . containsKey ( num1 ) ) { map . get ( num1 ) . add ( num2 ) ; } else { ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( num2 ) ; map . put ( num1 , list ) ; } if ( map . containsKey ( num2 ) ) { map . get ( num2 ) . add ( num1 ) ; } else { ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( num1 ) ; map . put ( num2 , list ) ; } } System . out . println ( helper ( map , isVisited , 1 ) ) ; } private static int helper ( HashMap < Integer , ArrayList < Integer > > map , boolean [ ] isVisited , int current ) { if ( isVisited [ current ] || ! map . containsKey ( current ) ) return 0 ; isVisited [ current ] = true ; if ( check ( isVisited ) ) { isVisited [ current ] = false ; return 1 ; } ArrayList < Integer > list = map . get ( current ) ; int count = 0 ; for ( int num : list ) { count += helper ( map , isVisited , num ) ; } isVisited [ current ] = false ; return count ; } private static boolean check ( boolean [ ] isVisited ) { for ( int i = 0 ; i < isVisited . length ; i ++ ) { if ( ! isVisited [ i ] ) return false ; } return true ; } } +","n , m = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ [ ] for _ in range ( n ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE X [ a - 1 ] . append ( b - 1 ) NEW_LINE X [ b - 1 ] . append ( a - 1 ) NEW_LINE DEDENT path = [ i for i in range ( 2 , n + 1 ) ] NEW_LINE visited = [ 1 ] + [ 0 ] * ( n - 1 ) NEW_LINE def dfs ( v ) : NEW_LINE INDENT if visited == [ 1 ] * n : NEW_LINE INDENT return 1 NEW_LINE DEDENT res = 0 NEW_LINE for x in X [ v ] : NEW_LINE INDENT if visited [ x ] == 0 : NEW_LINE INDENT visited [ x ] = 1 NEW_LINE res += dfs ( x ) NEW_LINE visited [ x ] = 0 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT print ( dfs ( 0 ) ) NEW_LINE +" +E104,"import java . io . * ; import java . util . * ; import java . lang . Math . * ; public class Main { private static MyScanner scanner ; public static void main ( String [ ] args ) { Main instance = new Main ( ) ; scanner = instance . new MyScanner ( ) ; instance . solve ( ) ; } private void solve ( ) { try { Long counter = 0l ; Long N = scanner . nextLong ( ) ; Long M = scanner . nextLong ( ) ; Long amari ; if ( M > 2 * N ) { counter += N ; M -= 2 * N ; } else { counter += M / 2 ; M -= ( M / 2 ) * 2 ; } if ( M > 3 ) { counter += M / 4 ; } System . out . println ( counter ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } private class MyScanner { String [ ] s ; int i ; BufferedReader br ; String reg = "" ▁ "" ; MyScanner ( ) { s = new String [ 0 ] ; i = 0 ; br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public String next ( ) throws IOException { if ( i < s . length ) return s [ i ++ ] ; String line = br . readLine ( ) ; while ( line . equals ( "" "" ) ) { line = br . readLine ( ) ; } s = line . split ( reg , 0 ) ; i = 0 ; return s [ i ++ ] ; } public int nextInt ( ) throws NumberFormatException , IOException { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) throws NumberFormatException , IOException { return Double . parseDouble ( next ( ) ) ; } public long nextLong ( ) throws NumberFormatException , IOException { return Long . parseLong ( next ( ) ) ; } } } +","N , M = map ( int , input ( ) . split ( ) ) NEW_LINE S_num = N NEW_LINE cc_num = M // 2 NEW_LINE if ( S_num <= cc_num ) : NEW_LINE INDENT ans = ( S_num + cc_num ) // 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans = cc_num NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E105,"import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String args [ ] ) { String s = sc . nextLine ( ) ; long k = sc . nextLong ( ) ; int numOfOnes = 0 ; int ans = 1 ; for ( char ch : s . toCharArray ( ) ) { if ( ch != '1' ) { ans = Integer . valueOf ( String . valueOf ( ch ) ) ; break ; } else { numOfOnes ++ ; } } System . out . println ( k <= numOfOnes ? ""1"" : ans ) ; } } +","s = input ( ) NEW_LINE K = int ( input ( ) ) NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if i == K - 1 : NEW_LINE INDENT print ( s [ i ] ) NEW_LINE break NEW_LINE DEDENT if s [ i ] == '1' : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( s [ i ] ) NEW_LINE break NEW_LINE DEDENT DEDENT +" +E106,"import java . util . * ; import java . lang . * ; import java . math . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] pr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { pr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( pr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( pr [ pr . length - 1 - i ] != pr [ pr . length - 1 - i - 1 ] ) { System . out . println ( pr [ pr . length - 1 - i - 1 ] ) ; break ; } } sc . close ( ) ; } } +","n = int ( input ( ) ) NEW_LINE a = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE a = sorted ( set ( a ) , reverse = True ) NEW_LINE if len ( a ) > 1 : NEW_LINE INDENT print ( a [ 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a [ 0 ] ) NEW_LINE DEDENT +" +E107,"import java . math . BigInteger ; import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] abc = scanner . nextLine ( ) . split ( "" ▁ "" , 3 ) ; BigInteger a = new BigInteger ( abc [ 0 ] ) ; BigInteger b = new BigInteger ( abc [ 1 ] ) ; BigInteger c = new BigInteger ( abc [ 2 ] ) ; BigInteger x = a . multiply ( b ) . multiply ( c ) ; BigInteger mod = new BigInteger ( ""1000000007"" ) ; System . out . println ( x . mod ( mod ) ) ; } } +","A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( A * B * C ) % 1000000007 ) NEW_LINE +" +E108,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int p = sc . nextInt ( ) ; int even = 0 ; int odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; if ( a % 2 == 0 ) { even ++ ; } else { odd ++ ; } } if ( p == 0 ) { if ( odd == 0 ) { System . out . println ( ( long ) Math . pow ( 2 , n ) ) ; } else { System . out . println ( ( long ) Math . pow ( 2 , n - 1 ) ) ; } } else { if ( odd == 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( ( long ) Math . pow ( 2 , n - 1 ) ) ; } } } } +","N , P = map ( int , input ( ) . split ( ) ) NEW_LINE lst_A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE lst_odd_even = [ x % 2 for x in lst_A ] NEW_LINE if 1 in lst_odd_even : NEW_LINE INDENT ans = 2 ** ( N - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT if P == 0 : NEW_LINE INDENT ans = 2 ** N NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E109,"import java . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] e = in . readLine ( ) . split ( "" ▁ "" ) ; char b = in . readLine ( ) . charAt ( 0 ) ; String l = in . readLine ( ) ; int n = 0 ; for ( int i = 0 ; i < e . length ; ++ i ) { if ( 0 <= l . indexOf ( e [ i ] ) ) { ++ n ; } } boolean f = 0 <= l . indexOf ( b ) ; switch ( n ) { case 6 : System . out . println ( 1 ) ; break ; case 5 : System . out . println ( f ? 2 : 3 ) ; break ; case 4 : System . out . println ( 4 ) ; break ; case 3 : System . out . println ( 5 ) ; break ; default : System . out . println ( 0 ) ; break ; } } } +","s = input ( ) . split ( ) NEW_LINE t = input ( ) NEW_LINE r = input ( ) . split ( ) NEW_LINE if s == r : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT elif len ( set ( s + [ t ] ) & set ( r ) ) == 6 : NEW_LINE INDENT print ( 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT f = 8 - len ( set ( s ) & set ( r ) ) NEW_LINE if f < 6 : NEW_LINE INDENT print ( f ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT DEDENT +" +E110,"import java . awt . * ; import java . util . * ; public class Main { static Scanner s = new Scanner ( System . in ) ; static int g ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { Point st = new Point ( g ( ) , g ( ) ) , go = new Point ( g ( ) , g ( ) ) ; if ( st . y > go . y ) { Point buf = go ; go = st ; st = buf ; } Comparator < Point > c = Comparator . comparingDouble ( Point :: getX ) ; TreeSet < Point > p = new TreeSet < > ( st . x < go . x ? c : c . reversed ( ) ) ; for ( int i = g ( ) ; i > 0 ; -- i ) { int x = g ( ) , y = g ( ) ; if ( st . y <= y && y <= go . y ) p . add ( new Point ( x , y ) ) ; } int v = lis ( p . subSet ( st , true , go , true ) ) ; System . out . println ( ( Math . abs ( st . x - go . x ) + Math . abs ( st . y - go . y ) ) * 100L + v * - 20 + ( v == Math . min ( go . y - st . y , Math . abs ( go . x - st . x ) ) + 1 ? v + 1 : v ) * 5 * Math . PI ) ; } static int lis ( NavigableSet < Point > p ) { ArrayList < Integer > l = new ArrayList < > ( ) ; l . add ( Integer . MIN_VALUE ) ; while ( ! p . isEmpty ( ) ) { int y = p . pollFirst ( ) . y ; if ( l . get ( l . size ( ) - 1 ) < y ) l . add ( y ) ; else { int v = Collections . binarySearch ( l , y ) ; if ( v < 0 ) l . set ( ~ v , y ) ; } } return l . size ( ) - 1 ; } } +","def LIS ( L ) : NEW_LINE INDENT from bisect import bisect NEW_LINE best = [ ] NEW_LINE for i in L : NEW_LINE INDENT pos = bisect ( best , i ) NEW_LINE if len ( best ) <= pos : NEW_LINE INDENT best . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT best [ pos ] = i NEW_LINE DEDENT DEDENT return len ( best ) NEW_LINE DEDENT import math NEW_LINE x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE W = abs ( x2 - x1 ) NEW_LINE H = abs ( y2 - y1 ) NEW_LINE xsgn = 2 * ( x2 > x1 ) - 1 NEW_LINE ysgn = 2 * ( y2 > y1 ) - 1 NEW_LINE XY = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if ( x - x1 ) * ( x - x2 ) <= 0 and ( y - y1 ) * ( y - y2 ) <= 0 : NEW_LINE INDENT XY += [ [ xsgn * ( x - x1 ) , ysgn * ( y - y1 ) ] ] NEW_LINE DEDENT DEDENT N = len ( XY ) NEW_LINE short = 20 - 5 * math . pi NEW_LINE long = 10 * math . pi - 20 NEW_LINE straight = 100 * ( W + H ) NEW_LINE XY . sort ( ) NEW_LINE Y = [ y for x , y in XY ] NEW_LINE fountain = LIS ( Y ) NEW_LINE if fountain < min ( W , H ) + 1 : NEW_LINE INDENT print ( straight - short * fountain ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( straight - short * ( fountain - 1 ) + long ) NEW_LINE DEDENT +" +E111,"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int Y = Integer . parseInt ( sc . next ( ) ) ; for ( int a = 0 ; a <= N ; a ++ ) { for ( int b = 0 ; b <= N - a ; b ++ ) { if ( a * 10000 + b * 5000 + ( N - a - b ) * 1000 == Y ) { System . out . println ( a + "" ▁ "" + b + "" ▁ "" + ( N - a - b ) ) ; return ; } } } System . out . println ( "" - 1 ▁ - 1 ▁ - 1"" ) ; } } +","def find ( n , y ) : NEW_LINE INDENT for i in range ( n + 1 ) : NEW_LINE INDENT for j in range ( n + 1 - i ) : NEW_LINE INDENT if 10000 * i + 5000 * j + 1000 * ( n - i - j ) == y : NEW_LINE INDENT return i , j , n - i - j NEW_LINE DEDENT DEDENT DEDENT return - 1 , - 1 , - 1 NEW_LINE DEDENT N , Y = map ( int , input ( ) . split ( ) ) NEW_LINE i , j , k = find ( N , Y ) NEW_LINE print ( "" { } ▁ { } ▁ { } "" . format ( i , j , k ) ) NEW_LINE +" +E112,"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int s = ( a * c ) + ( a * b ) + ( b * c ) ; System . out . print ( s * 2 ) ; } } +","A , B , C = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE print ( A * B * 2 + B * C * 2 + A * C * 2 ) NEW_LINE +" +E113,"import java . util . * ; public class Main { long INF = Long . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; char [ ] t = T . toCharArray ( ) ; int ans = 2 * N ; lavel : for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N - ( i ) ; j ++ ) { if ( s [ i + j ] != t [ j ] ) { continue lavel ; } if ( j == N - i - 1 ) { System . out . println ( ( N + i ) ) ; return ; } } } System . out . println ( ans ) ; } } +","N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE t = input ( ) NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT if s [ i : ] == t [ : N - i ] : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( len ( s + t [ N - i : ] ) ) NEW_LINE +" +E114,"import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; double inA = sc . nextDouble ( ) ; double inB = sc . nextDouble ( ) ; double A = Math . min ( inA , inB ) ; double B = Math . max ( inA , inB ) ; double r = Math . sqrt ( Math . pow ( A , 2 ) + Math . pow ( B , 2 ) ) ; double p = Math . atan ( A / B ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { double inC = sc . nextDouble ( ) ; double inD = sc . nextDouble ( ) ; double C = Math . min ( inC , inD ) ; double D = Math . max ( inC , inD ) ; if ( C >= A && D >= B ) { System . out . println ( "" YES "" ) ; } else if ( C < A && D < B || r < D ) { System . out . println ( "" NO "" ) ; } else if ( C >= r * Math . cos ( Math . asin ( D / r ) - 2 * p ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } } } +","import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE C = [ 0 ] * N NEW_LINE D = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT C [ i ] , D [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT res = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT curr = False NEW_LINE if A <= C [ i ] and B <= D [ i ] : NEW_LINE INDENT curr = True NEW_LINE DEDENT if B <= C [ i ] and A <= D [ i ] : NEW_LINE INDENT curr = True NEW_LINE DEDENT if curr == False : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT if j == 1 : NEW_LINE INDENT temp = A NEW_LINE A = B NEW_LINE B = temp NEW_LINE DEDENT lo = math . atan ( B / A ) NEW_LINE hi = math . pi / 2 NEW_LINE mid = 0 NEW_LINE cnt = 0 NEW_LINE while lo < hi and cnt < 50 : NEW_LINE INDENT mid = ( lo + hi ) / 2 NEW_LINE if A * math . sin ( mid ) + B * math . cos ( mid ) < max ( C [ i ] , D [ i ] ) : NEW_LINE INDENT lo = mid NEW_LINE DEDENT else : NEW_LINE INDENT hi = mid NEW_LINE DEDENT cnt += 1 NEW_LINE DEDENT if A * math . cos ( lo ) + B * math . sin ( lo ) <= min ( C [ i ] , D [ i ] ) : NEW_LINE INDENT curr |= True NEW_LINE DEDENT DEDENT DEDENT if curr == True : NEW_LINE INDENT res . append ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( "" NO "" ) NEW_LINE DEDENT DEDENT print ( "" \n "" . join ( map ( str , res ) ) ) NEW_LINE +" +E115,"import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans [ ] = new int [ n ] ; int a [ ] = new int [ 2 * m ] ; for ( int i = 0 ; i <= 2 * m - 2 ; i = i + 2 ) { a [ i ] = sc . nextInt ( ) ; a [ i + 1 ] = sc . nextInt ( ) ; ans [ a [ i ] - 1 ] ++ ; ans [ a [ i + 1 ] - 1 ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( ans [ i ] ) ; } } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } +","n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ 0 ] * n NEW_LINE for i in range ( m ) : NEW_LINE INDENT b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a [ b - 1 ] += 1 NEW_LINE a [ c - 1 ] += 1 NEW_LINE DEDENT for i in a : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT +" +E116,"import java . util . Scanner ; public class Main { static final int MOD = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long A = sc . nextLong ( ) ; final long B = sc . nextLong ( ) ; final long C = sc . nextLong ( ) ; sc . close ( ) ; long div = getInverse ( getMod ( A * ( B + C ) - B * C ) ) ; long c = getMod ( getMod ( B * ( C - A ) ) * div ) ; long r = getMod ( getMod ( C * ( B - A ) ) * div ) ; System . out . println ( r + "" ▁ "" + c ) ; } static long getPower ( long a , int n ) { if ( n == 0 ) { return 1 ; } else if ( n % 2 == 0 ) { return getPower ( getMod ( a * a ) , n / 2 ) ; } else { return getMod ( a * getPower ( a , n - 1 ) ) ; } } static long getInverse ( long a ) { return getPower ( a , MOD - 2 ) ; } static long getMod ( long a ) { if ( a >= 0 ) { return a % MOD ; } else { return MOD + a % MOD ; } } } +","A = int ( input ( ) ) NEW_LINE C = int ( input ( ) ) NEW_LINE B = int ( input ( ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def power ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif y == 1 : NEW_LINE INDENT return x % mod NEW_LINE DEDENT elif y % 2 == 0 : NEW_LINE INDENT return power ( x , y // 2 ) ** 2 % mod NEW_LINE DEDENT else : NEW_LINE INDENT return ( power ( x , y // 2 ) ** 2 ) * x % mod NEW_LINE DEDENT DEDENT inv = power ( A * B + A * C - B * C , mod - 2 ) NEW_LINE i = ( ( ( 2 * B * C - A * B - A * C ) % mod ) * inv ) % mod NEW_LINE j = A * B * inv - 1 NEW_LINE print ( ( i - j ) % mod , j % mod ) NEW_LINE +" +E117,"import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; long ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { long t = sc . nextLong ( ) ; long g = gcd ( ans , t ) ; ans = t / g * ans ; } out . println ( ans ) ; } static long gcd ( long a , long b ) { long temp ; while ( ( temp = a % b ) != 0 ) { a = b ; b = temp ; } return b ; } } +","from fractions import gcd NEW_LINE from functools import reduce NEW_LINE N = int ( input ( ) ) NEW_LINE T = map ( int , [ input ( ) for _ in range ( N ) ] ) NEW_LINE def lcm_base ( x , y ) : NEW_LINE INDENT return ( x * y ) // gcd ( x , y ) NEW_LINE DEDENT def lcm ( numbers ) : NEW_LINE INDENT return reduce ( lcm_base , numbers , 1 ) NEW_LINE DEDENT print ( lcm ( T ) ) NEW_LINE +" +E118,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int buf = n / 2 ; System . out . println ( buf * ( n - buf ) ) ; } } +","k = int ( input ( ) ) NEW_LINE if k % 2 == 0 : NEW_LINE INDENT even = k // 2 NEW_LINE odd = k // 2 NEW_LINE DEDENT else : NEW_LINE INDENT even = k // 2 NEW_LINE odd = k // 2 + 1 NEW_LINE DEDENT print ( even * odd ) NEW_LINE +" +E119,"import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ 3 ] ; int [ ] A = new int [ 2 ] ; int [ ] B = new int [ 2 ] ; Arrays . fill ( A , 101 ) ; Arrays . fill ( B , 101 ) ; String ans = "" Yes "" ; for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { arr [ i ] [ j ] = reader . nextInt ( ) ; } } A [ 0 ] = arr [ 0 ] [ 0 ] - arr [ 1 ] [ 0 ] ; A [ 1 ] = arr [ 1 ] [ 0 ] - arr [ 2 ] [ 0 ] ; B [ 0 ] = arr [ 0 ] [ 0 ] - arr [ 0 ] [ 1 ] ; B [ 1 ] = arr [ 0 ] [ 1 ] - arr [ 0 ] [ 2 ] ; for ( int i = 1 ; i < 3 ; i ++ ) { for ( int j = 1 ; j < 3 ; j ++ ) { if ( arr [ i - 1 ] [ j ] - A [ i - 1 ] != arr [ i ] [ j ] || arr [ i ] [ j - 1 ] - B [ j - 1 ] != arr [ i ] [ j ] ) { ans = "" No "" ; } } } System . out . print ( ans ) ; reader . close ( ) ; } } +","c = [ [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ] NEW_LINE for i in range ( 0 , 3 ) : NEW_LINE INDENT c [ i ] = [ int ( j ) for j in input ( ) . split ( "" ▁ "" ) ] NEW_LINE DEDENT f = True NEW_LINE for i in range ( 0 , 2 ) : NEW_LINE INDENT f = f and c [ i ] [ 0 ] - c [ i ] [ 1 ] == c [ i + 1 ] [ 0 ] - c [ i + 1 ] [ 1 ] NEW_LINE f = f and c [ i ] [ 1 ] - c [ i ] [ 2 ] == c [ i + 1 ] [ 1 ] - c [ i + 1 ] [ 2 ] NEW_LINE DEDENT for i in range ( 0 , 2 ) : NEW_LINE INDENT f = f and c [ 0 ] [ i ] - c [ 1 ] [ i ] == c [ 0 ] [ i + 1 ] - c [ 1 ] [ i + 1 ] NEW_LINE f = f and c [ 1 ] [ i ] - c [ 2 ] [ i ] == c [ 1 ] [ i + 1 ] - c [ 2 ] [ i + 1 ] NEW_LINE DEDENT if f : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E120,"import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > A = new ArrayList < > ( ) ; ArrayList < Integer > B = new ArrayList < > ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { int a = sc . nextInt ( ) ; A . add ( a ) ; B . add ( a ) ; } Collections . sort ( A , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < A . size ( ) ; i ++ ) { System . out . println ( A . indexOf ( B . get ( i ) ) + 1 ) ; } } } +","A = [ int ( input ( ) ) for i in range ( 3 ) ] NEW_LINE s = sorted ( A ) [ : : - 1 ] NEW_LINE for i in A : NEW_LINE INDENT print ( s . index ( i ) + 1 ) NEW_LINE DEDENT +" +E121,"import java . util . * ; import java . io . * ; import java . awt . geom . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; Node [ ] nodes = new Node [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { nodes [ i ] = new Node ( i ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { String [ ] s = br . readLine ( ) . split ( "" ▁ "" ) ; int a = Integer . parseInt ( s [ 0 ] ) - 1 ; int b = Integer . parseInt ( s [ 1 ] ) - 1 ; nodes [ a ] . adj . add ( nodes [ b ] ) ; nodes [ b ] . adj . add ( nodes [ a ] ) ; } if ( solve ( nodes [ 0 ] , - 1 ) != 0 ) { System . out . println ( "" Alice "" ) ; } else { System . out . println ( "" Bob "" ) ; } } static int solve ( Node a , int from ) { if ( a . adj . size ( ) == 1 && a . i != 0 ) { return 0 ; } int ans = 0 ; for ( Node n : a . adj ) { if ( n . i != from ) { ans ^= 1 + solve ( n , a . i ) ; } } return ans ; } } class Node { int i ; ArrayList < Node > adj ; public Node ( int ii ) { i = ii ; adj = new ArrayList < Node > ( ) ; } } +","import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE gosa = 1.0 / 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE e = collections . defaultdict ( set ) NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT a , b = LI ( ) NEW_LINE e [ a ] . add ( b ) NEW_LINE e [ b ] . add ( a ) NEW_LINE DEDENT def f ( i , c ) : NEW_LINE INDENT r = 0 NEW_LINE for j in e [ i ] : NEW_LINE INDENT if j == c : NEW_LINE INDENT continue NEW_LINE DEDENT t = f ( j , i ) NEW_LINE r ^= t NEW_LINE DEDENT return r + 1 NEW_LINE DEDENT if f ( 1 , - 1 ) == 1 : NEW_LINE INDENT return ' Bob ' NEW_LINE DEDENT return ' Alice ' NEW_LINE DEDENT print ( main ( ) ) NEW_LINE +" +E122,"import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; public class Main { private static Map < Integer , Set < Integer > > neighborsMap = new HashMap < > ( ) ; private static Set < Integer > p = new HashSet < Integer > ( ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; final int G = sc . nextInt ( ) ; final int E = sc . nextInt ( ) ; for ( int i = 0 ; i <= N ; i ++ ) neighborsMap . put ( i , new HashSet < Integer > ( ) ) ; for ( int i = 0 ; i < G ; i ++ ) p . add ( sc . nextInt ( ) ) ; for ( int i = 0 ; i < E ; i ++ ) { int id1 = sc . nextInt ( ) ; int id2 = sc . nextInt ( ) ; neighborsMap . get ( id1 ) . add ( id2 ) ; neighborsMap . get ( id2 ) . add ( id1 ) ; } sc . close ( ) ; int ans = 0 ; while ( p . size ( ) > 0 && calcMaxFlow ( 0 , new HashSet < Integer > ( ) ) ) { ans ++ ; } System . out . println ( ans ) ; } private static boolean calcMaxFlow ( int currentId , Set < Integer > visited ) { visited . add ( currentId ) ; if ( p . contains ( currentId ) ) { p . remove ( currentId ) ; return true ; } Integer [ ] neighbors = neighborsMap . get ( currentId ) . toArray ( new Integer [ neighborsMap . get ( currentId ) . size ( ) ] ) ; if ( neighbors . length == 0 ) { return false ; } for ( int n : neighbors ) { if ( visited . contains ( n ) ) { continue ; } neighborsMap . get ( currentId ) . remove ( n ) ; if ( ! calcMaxFlow ( n , visited ) ) { neighborsMap . get ( currentId ) . add ( n ) ; } else { return true ; } } visited . remove ( currentId ) ; return false ; } } +","class Ford_Fulkerson : NEW_LINE INDENT def __init__ ( self , N ) : NEW_LINE INDENT self . used = [ False ] * ( N + 1 ) NEW_LINE self . G = [ [ 0 ] * ( N + 1 ) for i in range ( N + 1 ) ] NEW_LINE DEDENT def add_edge ( self , fr , to , cap ) : NEW_LINE INDENT self . G [ fr ] [ to ] = cap NEW_LINE DEDENT def dfs ( self , v , t , f ) : NEW_LINE INDENT if v == t : NEW_LINE INDENT return f NEW_LINE DEDENT self . used [ v ] = True NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT if v == i : NEW_LINE INDENT continue NEW_LINE DEDENT if ( not self . used [ i ] ) and self . G [ v ] [ i ] > 0 : NEW_LINE INDENT d = self . dfs ( i , t , min ( f , self . G [ v ] [ i ] ) ) NEW_LINE if d > 0 : NEW_LINE INDENT self . G [ v ] [ i ] -= d NEW_LINE self . G [ i ] [ v ] += d NEW_LINE return d NEW_LINE DEDENT DEDENT DEDENT return 0 NEW_LINE DEDENT DEDENT N , G , E = map ( int , input ( ) . split ( ) ) NEW_LINE p = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE F = Ford_Fulkerson ( N ) NEW_LINE for i in range ( G ) : NEW_LINE INDENT F . add_edge ( p [ i ] , N , 1 ) NEW_LINE DEDENT for i in range ( E ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE F . add_edge ( a , b , 1 ) NEW_LINE F . add_edge ( b , a , 1 ) NEW_LINE DEDENT num = 0 NEW_LINE while True : NEW_LINE INDENT F . used = [ False ] * ( N + 1 ) NEW_LINE f = F . dfs ( 0 , N , 10 ** 9 ) NEW_LINE if f == 0 : NEW_LINE INDENT break NEW_LINE DEDENT num += f NEW_LINE DEDENT print ( num ) NEW_LINE +" +E123,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { int x , a , b ; Scanner sc = new Scanner ( System . in ) ; x = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; simpleDist ( x , a , b ) ; } private static void simpleDist ( int x , int a , int b ) { int max = 1000 , min = 1 ; if ( ( x <= max && a <= max && b <= max ) && ( x >= min && a >= min && b >= min ) ) { String res = Math . abs ( x - a ) < Math . abs ( x - b ) ? "" A "" : "" B "" ; System . out . println ( res ) ; } } } +","X , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ "" A "" , "" B "" ] [ not ( abs ( X - A ) < abs ( X - B ) ) ] ) NEW_LINE +" +E124,"import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int input1 = scan . nextInt ( ) ; int input2 = scan . nextInt ( ) ; int [ ] [ ] sui = new int [ input1 ] [ 3 ] ; for ( int [ ] _sui : sui ) { _sui [ 0 ] = scan . nextInt ( ) ; _sui [ 1 ] = scan . nextInt ( ) ; _sui [ 2 ] = scan . nextInt ( ) ; } for ( int repeatCount = 0 ; repeatCount < input2 ; repeatCount ++ ) { int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; double answer = 0.0 ; double normal = 0.0 ; double rate1 = 1.0 ; double rate2 = 0.0 ; for ( int i = 0 ; i < sui . length ; i ++ ) { normal = sui [ i ] [ 1 ] * sui [ i ] [ 1 ] * sui [ i ] [ 2 ] / 3.0 * Math . PI ; boolean flag = true ; if ( sui [ i ] [ 0 ] <= a && sui [ i ] [ 0 ] + sui [ i ] [ 2 ] >= a ) { rate1 = ( sui [ i ] [ 0 ] + sui [ i ] [ 2 ] - a ) / ( double ) sui [ i ] [ 2 ] ; flag = false ; } if ( sui [ i ] [ 0 ] + sui [ i ] [ 2 ] >= b && sui [ i ] [ 0 ] <= b ) { rate2 = ( sui [ i ] [ 0 ] + sui [ i ] [ 2 ] - b ) / ( double ) sui [ i ] [ 2 ] ; flag = false ; } if ( sui [ i ] [ 0 ] >= a && sui [ i ] [ 0 ] + sui [ i ] [ 2 ] <= b ) { rate1 = 1.0 ; rate2 = 0.0 ; flag = false ; } if ( flag ) { rate1 = 0.0 ; rate2 = 0.0 ; } answer += normal * ( rate1 * rate1 * rate1 - rate2 * rate2 * rate2 ) ; rate1 = 1.0 ; rate2 = 0.0 ; } System . out . println ( String . format ( "" % 6f "" , answer ) ) ; } } } +","import math NEW_LINE N , Q = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ 0 ] * N NEW_LINE R = [ 0 ] * N NEW_LINE H = [ 0 ] * N NEW_LINE for i in range ( N ) : NEW_LINE INDENT X [ i ] , R [ i ] , H [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT A = [ 0 ] * Q NEW_LINE B = [ 0 ] * Q NEW_LINE for i in range ( Q ) : NEW_LINE INDENT A [ i ] , B [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT MAX_X = 3 * 10 ** 4 NEW_LINE V = [ 0 ] * MAX_X NEW_LINE for x in range ( MAX_X ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if X [ i ] > x or X [ i ] + H [ i ] < x : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT Rleft = ( X [ i ] + H [ i ] - x ) * R [ i ] / H [ i ] NEW_LINE Rright = max ( 0 , ( X [ i ] + H [ i ] - ( x + 1 ) ) * R [ i ] / H [ i ] ) NEW_LINE Vleft = math . pi * Rleft ** 2 * ( X [ i ] + H [ i ] - x ) / 3 NEW_LINE Vright = math . pi * Rright ** 2 * ( X [ i ] + H [ i ] - ( x + 1 ) ) / 3 NEW_LINE V [ x ] += Vleft - Vright NEW_LINE DEDENT DEDENT DEDENT cum_sum = [ 0 ] * ( MAX_X + 1 ) NEW_LINE for x in range ( MAX_X ) : NEW_LINE INDENT cum_sum [ x + 1 ] = V [ x ] + cum_sum [ x ] NEW_LINE DEDENT for i in range ( Q ) : NEW_LINE INDENT res = cum_sum [ B [ i ] ] - cum_sum [ A [ i ] ] NEW_LINE print ( res ) NEW_LINE DEDENT +" +E125,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int N = in . nextInt ( ) ; int h = N / 3600 ; int m = N / 60 % 60 ; int s = N % 60 ; out . printf ( "" % 02d : %02d : %02d "" , h , m , s ) ; out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } +","n = int ( input ( ) ) NEW_LINE h = n // ( 60 * 60 ) NEW_LINE m = ( n % ( 60 * 60 ) ) // 60 NEW_LINE s = ( n % ( 60 * 60 ) ) % 60 NEW_LINE print ( ' { :02 } : { : 02 } : { : 02 } ' . format ( h , m , s ) ) NEW_LINE +" +E126,"import java . util . * ; import java . io . * ; class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int idx = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] == 1 ) idx = i ; } int ans = n ; int x = k - 1 ; for ( int i = Math . max ( idx - k , 1 ) - 1 ; i < Math . min ( idx + k , n ) ; i ++ ) { int curr = 1 + ( i + x - 1 ) / x ; int tmp = n - ( i + k ) ; curr += ( tmp + x - 1 ) / x ; ans = Math . min ( ans , curr ) ; } pw . println ( ans ) ; pw . close ( ) ; } static class Scanner { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public Scanner ( FileReader s ) { br = new BufferedReader ( 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 ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } } } +","import math NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A_ = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = math . ceil ( ( N - 1 ) / ( K - 1 ) ) NEW_LINE print ( ans ) NEW_LINE +" +E127,"import java . util . Scanner ; class Main { static boolean [ ] al ; static int [ ] c ; static int [ ] t ; static int n ; static int search ( ) { boolean f = true ; for ( int i = 0 ; i < n ; i ++ ) f = ( f && t [ i ] > 0 ) ; if ( f ) return 0 ; int min = n ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! al [ i ] ) { al [ i ] = true ; for ( int j = 0 ; j < n ; j ++ ) t [ j ] += ( c [ ( j + i ) % n ] > 0 ) ? 1 : 0 ; min = Math . min ( min , search ( ) + 1 ) ; for ( int j = 0 ; j < n ; j ++ ) t [ j ] -= ( c [ ( j + i ) % n ] > 0 ) ? 1 : 0 ; al [ i ] = false ; } } return min ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String cin = scan . next ( ) ; n = cin . length ( ) ; c = new int [ n ] ; t = new int [ n ] ; al = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = t [ i ] = ( cin . charAt ( i ) == ' o ' ) ? 1 : 0 ; al [ i ] = false ; } al [ 0 ] = true ; System . out . println ( search ( ) + 1 ) ; } } +","import copy as co NEW_LINE class circle ( ) : NEW_LINE INDENT def __init__ ( self , numlist , amount_of_can ) : NEW_LINE INDENT self . numcircle = numlist NEW_LINE self . til = 0 NEW_LINE self . cansee = amount_of_can NEW_LINE self . times = 1 NEW_LINE DEDENT def right_rotation ( self , num , length ) : NEW_LINE INDENT a = self . numcircle [ : length - num ] NEW_LINE b = self . numcircle [ length - num : ] NEW_LINE return b + a NEW_LINE DEDENT DEDENT def sup_and ( str1 , str2 , length ) : NEW_LINE INDENT count = 0 NEW_LINE for x in range ( 0 , length ) : NEW_LINE INDENT str1 [ x ] = str1 [ x ] or str2 [ x ] NEW_LINE count += str1 [ x ] NEW_LINE DEDENT return count NEW_LINE DEDENT def search ( circlelist , length , TV ) : NEW_LINE INDENT list1 = [ ] NEW_LINE for x in range ( circlelist . til + 1 , length ) : NEW_LINE INDENT circlelist2 = co . deepcopy ( circlelist ) NEW_LINE circlelist2 . cansee = sup_and ( circlelist2 . numcircle , TV . right_rotation ( x , length ) , length ) NEW_LINE circlelist2 . til = x NEW_LINE circlelist2 . times += 1 NEW_LINE list1 . append ( circlelist2 ) NEW_LINE DEDENT return list1 NEW_LINE DEDENT inp1 = input ( ) NEW_LINE amount_of_can = 0 NEW_LINE numlist = [ ] NEW_LINE for x in inp1 : NEW_LINE INDENT if x == ' x ' : NEW_LINE INDENT numlist . append ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT numlist . append ( 1 ) NEW_LINE amount_of_can += 1 NEW_LINE DEDENT DEDENT length = len ( numlist ) NEW_LINE if amount_of_can == length : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT circlelist = circle ( numlist , amount_of_can ) NEW_LINE alllist1 = [ circlelist ] NEW_LINE TV = co . deepcopy ( circlelist ) NEW_LINE while True : NEW_LINE INDENT alllist2 = [ ] NEW_LINE while alllist1 : NEW_LINE INDENT alllist2 . extend ( search ( alllist1 . pop ( ) , length , TV ) ) NEW_LINE DEDENT alllist1 = alllist2 NEW_LINE for x in alllist1 : NEW_LINE INDENT if x . cansee == length : NEW_LINE INDENT print ( x . times ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT +" +E128,"import java . util . * ; public class Main { private final static long MOD = 1000000007 ; public static long mul ( long n , long m ) { return ( n * m ) % MOD ; } public static long fact ( long n ) { long ans = 1 ; for ( long i = n ; i >= 1 ; i -- ) { ans = mul ( ans , i ) ; } return ans ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int N = s . nextInt ( ) ; int t [ ] = new int [ N ] ; int counter [ ] = new int [ 10001 ] ; for ( int i = 0 ; i < N ; i ++ ) { t [ i ] = s . nextInt ( ) ; counter [ t [ i ] ] ++ ; } Arrays . sort ( t ) ; long currenttime = 0 ; long penalty = 0 ; for ( int time : t ) { currenttime += time ; penalty += currenttime ; } long count = 1 ; for ( int i = 0 ; i < counter . length ; i ++ ) { count = mul ( count , fact ( counter [ i ] ) ) ; } System . out . println ( penalty ) ; System . out . println ( count ) ; } } +","n = int ( input ( ) ) NEW_LINE t = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT t [ i ] = int ( input ( ) ) NEW_LINE DEDENT t . sort ( ) NEW_LINE m = 10 ** 9 + 7 NEW_LINE res = 0 NEW_LINE ass = 1 NEW_LINE p = [ 1 ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT p . append ( p [ - 1 ] * i % m ) NEW_LINE DEDENT c = 0 NEW_LINE k = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT c += t [ i ] NEW_LINE res += c NEW_LINE if i != n - 1 : NEW_LINE INDENT if t [ i ] != t [ i + 1 ] : NEW_LINE INDENT ass = ass * p [ k ] % m NEW_LINE k = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ass = ass * p [ k ] % m NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE print ( ass ) NEW_LINE +" +E129,"import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > TList = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { TList . add ( sc . nextInt ( ) ) ; } Collections . sort ( TList ) ; int cnt = 0 ; int bus = 0 ; int start = TList . get ( 0 ) ; for ( int i : TList ) { if ( cnt < C && i <= start + K ) { cnt ++ ; continue ; } cnt = 1 ; start = i ; bus ++ ; } bus ++ ; System . out . println ( bus ) ; } } +","from math import ceil NEW_LINE def main ( ) : NEW_LINE INDENT N , C , K = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Ts = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT Ts . append ( int ( input ( ) ) ) NEW_LINE DEDENT Ts . sort ( ) NEW_LINE bus_ct = 0 NEW_LINE in_bus = 1 NEW_LINE st = Ts . pop ( 0 ) + K NEW_LINE for Ti in Ts : NEW_LINE INDENT if Ti > st : NEW_LINE INDENT bus_ct += 1 NEW_LINE in_bus = 1 NEW_LINE st = Ti + K NEW_LINE DEDENT elif Ti <= st : NEW_LINE INDENT in_bus += 1 NEW_LINE DEDENT if in_bus > C : NEW_LINE INDENT bus_ct += 1 NEW_LINE in_bus = 1 NEW_LINE st = Ti + K NEW_LINE DEDENT DEDENT if in_bus : NEW_LINE INDENT bus_ct += 1 NEW_LINE DEDENT print ( bus_ct ) NEW_LINE DEDENT main ( ) NEW_LINE +" +E130,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; public class Main { private static int n ; private static long a , b ; private static long [ ] enemy ; private static boolean C ( long k ) { long cnt = 0 ; for ( long hp : enemy ) { hp -= b * k ; if ( hp > 0 ) { cnt += Math . ceil ( ( double ) hp / ( a - b ) ) ; } } if ( cnt > k ) return false ; else return true ; } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( "" ▁ "" ) ; n = Integer . parseInt ( str [ 0 ] ) ; a = Long . parseLong ( str [ 1 ] ) ; b = Long . parseLong ( str [ 2 ] ) ; enemy = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) enemy [ i ] = Long . parseLong ( br . readLine ( ) ) ; long l = 0 , r = ( long ) 1e9 + 1 , med = - 1 ; while ( r - l > 0 ) { med = ( r + l ) / 2 ; if ( C ( med ) ) { r = med ; } else { l = med + 1 ; } } System . out . println ( l ) ; } } +","import heapq NEW_LINE n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE h = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE h . sort ( ) NEW_LINE p = a - b NEW_LINE def c ( w ) : NEW_LINE INDENT k = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT l [ i ] = l [ i ] - b * w NEW_LINE if l [ i ] > 0 : NEW_LINE INDENT k += l [ i ] // p NEW_LINE if l [ i ] % p != 0 : NEW_LINE INDENT k += 1 NEW_LINE DEDENT DEDENT DEDENT if w >= k : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT s = 0 NEW_LINE f = 10 ** 14 NEW_LINE while f - s >= 2 : NEW_LINE INDENT m = ( f + s ) // 2 NEW_LINE l = h [ : : ] NEW_LINE if c ( m ) : NEW_LINE INDENT f = m NEW_LINE DEDENT else : NEW_LINE INDENT s = m NEW_LINE DEDENT DEDENT l = h [ : : ] NEW_LINE if c ( s ) : NEW_LINE INDENT print ( s ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( f ) NEW_LINE DEDENT +" +E131,"import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; char [ ] S = sc . next ( ) . toCharArray ( ) ; boolean [ ] a = new boolean [ N ] ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] = S [ i ] == ' A ' ; boolean flip = false ; int idx = 0 ; int T = Math . min ( 2 * N , K ) ; for ( int i = 0 ; i < T ; i ++ ) { if ( a [ idx ] ^ flip ) { a [ idx ] = false ^ flip ; } else { flip ^= true ; a [ idx ] = true ^ flip ; idx = ( idx + 1 ) % N ; } } if ( T < K && N % 2 == 1 ) a [ idx ] ^= ( K - T ) % 2 == 1 ; for ( int i = 0 ; i < N ; i ++ ) pw . print ( a [ ( i + idx ) % N ] ^ flip ? ' A ' : ' B ' ) ; pw . println ( ) ; sc . close ( ) ; pw . close ( ) ; } } +","import sys NEW_LINE from itertools import accumulate NEW_LINE from collections import deque NEW_LINE def solve ( ) : NEW_LINE INDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE S = input ( ) NEW_LINE q = deque ( [ 1 if c == ' A ' else 0 for c in S ] ) NEW_LINE cb = 0 NEW_LINE for i in range ( min ( K , 2 * N + K % 2 ) ) : NEW_LINE INDENT if q [ 0 ] == ( cb ^ 1 ) : NEW_LINE INDENT q [ 0 ] ^= 1 NEW_LINE DEDENT else : NEW_LINE INDENT q . popleft ( ) NEW_LINE q . append ( cb ) NEW_LINE cb ^= 1 NEW_LINE DEDENT DEDENT ans = [ ' A ' if ( c ^ cb ) else ' B ' for c in q ] NEW_LINE print ( ' ' . join ( ans ) ) NEW_LINE DEDENT def debug ( x , table ) : NEW_LINE INDENT for name , val in table . items ( ) : NEW_LINE INDENT if x is val : NEW_LINE INDENT print ( ' DEBUG : { } ▁ - > ▁ { } ' . format ( name , val ) , file = sys . stderr ) NEW_LINE return None NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT +" +E132,"import java . util . Scanner ; public class Main { public static void main ( String [ ] arg ) { Scanner in = new Scanner ( System . in ) ; int a = in . nextInt ( ) ; String op = in . next ( ) ; int b = in . nextInt ( ) ; if ( op . equals ( "" + "" ) ) { System . out . print ( a + b ) ; } else if ( op . equals ( "" - "" ) ) { System . out . print ( a - b ) ; } } } +","print ( eval ( input ( ) ) ) NEW_LINE +" +E133,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner io = new Scanner ( System . in ) ; String S = io . next ( ) ; long ans = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == ' U ' ) { ans += ( ( S . length ( ) - 1 ) - i ) + i * 2 ; } else { ans += ( ( S . length ( ) - 1 ) - i ) * 2 + i ; } } System . out . println ( ans ) ; } } +","import sys NEW_LINE stdin = sys . stdin NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE s = ns ( ) NEW_LINE n = len ( s ) NEW_LINE ans = 0 NEW_LINE for idx , si in enumerate ( s ) : NEW_LINE INDENT if si == ' U ' : NEW_LINE INDENT ans += ( n - idx - 1 ) + 2 * idx NEW_LINE DEDENT else : NEW_LINE INDENT ans += 2 * ( n - idx - 1 ) + idx NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE +" +E134,"import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { public static String process ( TestCase testCase ) { final int N = testCase . N ; final int X = testCase . X ; final List < Integer > x = testCase . x ; final int num = x . stream ( ) . map ( xi -> Math . abs ( X - xi ) ) . reduce ( Main :: gcd ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "" x ▁ is ▁ empty "" ) ) ; return String . valueOf ( num ) ; } private static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } else { return gcd ( b , a % b ) ; } } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; final List < Integer > x = IntStream . range ( 0 , N ) . mapToObj ( i -> sc . nextInt ( ) ) . collect ( Collectors . toList ( ) ) ; return new TestCase ( N , X , x ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; final int X ; final List < Integer > x ; public TestCase ( int N , int X , List < Integer > x ) { this . N = N ; this . X = X ; this . x = x ; } } } +","def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( b , a % b ) NEW_LINE DEDENT DEDENT N , A = map ( int , input ( ) . split ( ) ) NEW_LINE X = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Y = [ ] NEW_LINE for x in X : NEW_LINE INDENT Y . append ( abs ( A - x ) ) NEW_LINE DEDENT ans = max ( Y ) NEW_LINE for y in Y : NEW_LINE INDENT ans = gcd ( y , ans ) NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E135,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long ans ; ans = N - K + 1 ; System . out . println ( ans ) ; } } +","N , i = map ( int , input ( ) . split ( ) ) NEW_LINE print ( N - i + 1 ) NEW_LINE +" +E136,"import java . util . * ; public class Main { 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 sq = ( int ) Math . sqrt ( ( double ) N ) ; if ( ( A + B > N + 1 ) || ( A < sq && B < sq ) ) System . out . println ( - 1 ) ; else if ( A + B == N + 1 ) { for ( int i = B ; i <= N ; ++ i ) System . out . print ( i + "" ▁ "" ) ; for ( int i = B - 1 ; i >= 1 ; -- i ) System . out . print ( i + "" ▁ "" ) ; System . out . println ( ) ; } else { int tempA = ( N / B ) + ( N % B != 0 ? 1 : 0 ) ; int hidari = 0 ; while ( tempA + hidari != A ) { hidari ++ ; if ( hidari > N ) { System . out . println ( - 1 ) ; return ; } if ( ( N - hidari ) % B == 0 ) tempA -- ; } int nowN = N - hidari ; for ( int i = 1 ; i <= hidari ; ++ i ) System . out . print ( i + "" ▁ "" ) ; for ( int i = 1 ; i <= nowN / B ; i ++ ) { for ( int j = i * B ; j > ( i - 1 ) * B ; j -- ) { System . out . print ( ( j + hidari ) + "" ▁ "" ) ; } } for ( int j = nowN ; j > B * ( nowN / B ) ; -- j ) System . out . print ( ( j + hidari ) + "" ▁ "" ) ; System . out . println ( ) ; } return ; } } +","N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = list ( range ( A ) ) NEW_LINE m = 0 NEW_LINE rest = N - A NEW_LINE B -= 1 NEW_LINE if rest < B : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT if rest / A > B : NEW_LINE INDENT print ( - 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT while rest > B : NEW_LINE INDENT s = min ( A , rest - B + 1 ) NEW_LINE ans += list ( range ( m - s , m ) ) NEW_LINE m -= s NEW_LINE rest -= s NEW_LINE B -= 1 NEW_LINE DEDENT ans += list ( range ( m - B , m ) ) [ : : - 1 ] NEW_LINE m -= B NEW_LINE print ( "" ▁ "" . join ( [ str ( x - m + 1 ) for x in ans ] ) ) NEW_LINE +" +E137,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int min = Integer . MAX_VALUE ; for ( char c = ' a ' ; c <= ' z ' ; c = ( char ) ( c + 1 ) ) { int max = 0 ; int current = 0 ; String t = String . valueOf ( c ) ; int idx = s . indexOf ( t ) ; while ( idx != - 1 ) { if ( max < idx - current ) { max = idx - current ; } current = idx + 1 ; idx = s . indexOf ( t , current ) ; } if ( max < s . length ( ) - current + 1 ) { max = s . length ( ) - current ; } if ( min > max ) { min = max ; } } System . out . println ( min ) ; } } +","from string import ascii_lowercase NEW_LINE s = input ( ) NEW_LINE ans = 100 NEW_LINE for c in ascii_lowercase : NEW_LINE INDENT ans = min ( ans , max ( [ len ( x ) for x in s . split ( c ) ] ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E138,"import java . util . * ; import static java . lang . System . in ; import static java . lang . System . out ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; String [ ] input = sc . nextLine ( ) . split ( "" ▁ "" , 0 ) ; int [ ] lh = new int [ 2 ] ; lh [ 0 ] = Integer . parseInt ( input [ 0 ] ) ; lh [ 1 ] = Integer . parseInt ( input [ 1 ] ) ; int num = sc . nextInt ( ) ; int [ ] st = new int [ num ] ; for ( int i = 0 ; i < num ; i ++ ) st [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < num ; i ++ ) if ( st [ i ] < lh [ 0 ] ) out . println ( lh [ 0 ] - st [ i ] ) ; else if ( st [ i ] > lh [ 1 ] ) out . println ( - 1 ) ; else out . println ( ""0"" ) ; } } +","l , h = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE if a < l : NEW_LINE INDENT print ( l - a ) NEW_LINE DEDENT elif l <= a <= h : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT DEDENT +" +E139,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int [ ] b = new int [ N + 1 ] ; int [ ] c = new int [ N ] ; for ( int i = 1 ; i < N + 1 ; i ++ ) { b [ i ] = i ; } for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ a [ i ] ] -- ; if ( b [ a [ i ] ] >= 0 ) c [ b [ a [ i ] ] ] ++ ; } int L = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( c [ i ] == 0 ) L ++ ; } for ( int i = 0 ; i < M ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( b [ a [ x - 1 ] ] >= 0 ) c [ b [ a [ x - 1 ] ] ] -- ; if ( b [ a [ x - 1 ] ] >= 0 && c [ b [ a [ x - 1 ] ] ] == 0 ) L ++ ; b [ a [ x - 1 ] ] ++ ; a [ x - 1 ] = y ; b [ y ] -- ; if ( b [ y ] >= 0 && c [ b [ y ] ] == 0 ) L -- ; if ( b [ y ] >= 0 ) c [ b [ y ] ] ++ ; System . out . println ( L ) ; } } } +","from collections import Counter NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE src = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( M ) ] NEW_LINE ctr = Counter ( A ) NEW_LINE cover = [ 0 ] * ( 2 * N + 1 ) NEW_LINE for k , v in ctr . items ( ) : NEW_LINE INDENT for i in range ( k , k - v , - 1 ) : NEW_LINE INDENT cover [ i + N ] += 1 NEW_LINE DEDENT DEDENT ans = cover [ N + 1 : ] . count ( 0 ) NEW_LINE for x , y in src : NEW_LINE INDENT ctr [ A [ x - 1 ] ] -= 1 NEW_LINE ai = A [ x - 1 ] + N - ctr [ A [ x - 1 ] ] NEW_LINE cover [ ai ] -= 1 NEW_LINE if ai > N and cover [ ai ] == 0 : ans += 1 NEW_LINE A [ x - 1 ] = y NEW_LINE bi = y + N - ctr [ y ] NEW_LINE if bi > N and cover [ bi ] == 0 : ans -= 1 NEW_LINE cover [ bi ] += 1 NEW_LINE ctr [ y ] += 1 NEW_LINE print ( ans ) NEW_LINE DEDENT +" +E140,"import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] s = sc . nextLine ( ) . split ( "" ▁ "" ) ; int [ ] n = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { n [ i ] = Integer . parseInt ( s [ i ] ) ; } PriorityQueue < int [ ] > pq = new PriorityQueue < int [ ] > ( new MyComp ( ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 0 ; i < N ; i ++ ) { pq . add ( new int [ ] { i + 1 , n [ i ] } ) ; if ( i >= K - 1 ) { if ( i >= K ) pq . poll ( ) ; int [ ] p = pq . poll ( ) ; out . println ( p [ 0 ] ) ; pq . add ( p ) ; } } out . flush ( ) ; } } class MyComp implements Comparator { @ Override public int compare ( Object arg1 , Object arg2 ) { int v1 = ( ( int [ ] ) arg1 ) [ 1 ] ; int v2 = ( ( int [ ] ) arg2 ) [ 1 ] ; return Integer . compare ( v2 , v1 ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details . +","import heapq NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE src = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE hq = [ ] NEW_LINE heapq . heapify ( hq ) NEW_LINE for i , a in enumerate ( src [ : K ] ) : NEW_LINE INDENT heapq . heappush ( hq , ( - a , i + 1 ) ) NEW_LINE DEDENT for i , a in enumerate ( src [ K : ] ) : NEW_LINE INDENT b , j = hq [ 0 ] NEW_LINE print ( j ) NEW_LINE if a < - b : NEW_LINE INDENT heapq . heappop ( hq ) NEW_LINE heapq . heappush ( hq , ( - a , K + i + 1 ) ) NEW_LINE DEDENT DEDENT b , j = hq [ 0 ] NEW_LINE print ( j ) NEW_LINE +" +E141,"import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N , b , c = 0 , d = 0 ; N = sc . nextInt ( ) ; Integer [ ] a = new Integer [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { b = sc . nextInt ( ) ; a [ i ] = b ; } Arrays . sort ( a , Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { c += a [ i ] ; i ++ ; if ( i < N ) { d += a [ i ] ; } } System . out . println ( c - d ) ; sc . close ( ) ; } } +","n = int ( input ( ) ) NEW_LINE list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE list . sort ( ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ans += ( - 1 ) ** ( i - 1 ) * list [ - i ] NEW_LINE DEDENT print ( ans ) NEW_LINE +" +E142,"import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String [ ] days = { "" Monday "" , "" Tuesday "" , "" Wednesday "" , "" Thursday "" , "" Friday "" , "" Saturday "" , "" Sunday "" } ; String in = s . next ( ) ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( days [ i ] . equals ( in ) ) { System . out . println ( Math . max ( 5 - i , 0 ) ) ; return ; } } } } +","day = input ( ) NEW_LINE if day == "" Monday "" : NEW_LINE INDENT print ( 5 ) NEW_LINE DEDENT elif day == "" Tuesday "" : NEW_LINE INDENT print ( 4 ) NEW_LINE DEDENT elif day == "" Wednesday "" : NEW_LINE INDENT print ( 3 ) NEW_LINE DEDENT elif day == "" Thursday "" : NEW_LINE INDENT print ( 2 ) NEW_LINE DEDENT elif day == "" Friday "" : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT +" +E143,"import java . util . * ; import static java . lang . Math . * ; public class A { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int zz = 1 ; zz <= T ; zz ++ ) { int N = in . nextInt ( ) ; long [ ] M = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) M [ i ] = in . nextInt ( ) ; long ans1 = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { ans1 += max ( 0 , M [ i ] - M [ i + 1 ] ) ; } long max = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { max = max ( max , M [ i ] - M [ i + 1 ] ) ; } long ans2 = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) ans2 += min ( max , M [ i ] ) ; System . out . format ( "" Case ▁ # % d : ▁ % d ▁ % d \n "" , zz , ans1 , ans2 ) ; } } } +","def solve ( ) : NEW_LINE INDENT N = input ( ) NEW_LINE ar = [ int ( _ ) for _ in raw_input ( ) . split ( ) ] NEW_LINE diffs = [ a - b for a , b in zip ( ar , ar [ 1 : ] ) ] NEW_LINE eat1 = sum ( max ( x , 0 ) for x in diffs ) NEW_LINE rate = max ( diffs + [ 0 ] ) NEW_LINE eat2 = sum ( min ( x , rate ) for x in ar [ : - 1 ] ) NEW_LINE return eat1 , eat2 NEW_LINE DEDENT T = input ( ) NEW_LINE for t in range ( 1 , T + 1 ) : NEW_LINE INDENT a , b = solve ( ) NEW_LINE print ' Case ▁ # % d : ▁ % d ▁ % d ' % ( t , a , b ) NEW_LINE DEDENT +" +E144,"import java . util . * ; import java . io . * ; public class Main implements Runnable { public Scanner in ; public PrintWriter out ; Main ( ) throws IOException { in = new Scanner ( new File ( "" in "" ) ) ; out = new PrintWriter ( new File ( "" out "" ) ) ; } void close ( ) throws IOException { out . close ( ) ; } public void run ( ) { int tn = in . nextInt ( ) ; for ( int test = 1 ; test <= tn ; test ++ ) { int n = in . nextInt ( ) ; double [ ] x = new double [ n ] ; double [ ] y = new double [ n ] ; double [ ] r = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = in . nextDouble ( ) ; y [ i ] = in . nextDouble ( ) ; r [ i ] = in . nextDouble ( ) ; } double res = 1E100 ; if ( n == 1 ) { res = r [ 0 ] ; } else if ( n == 2 ) { res = Math . max ( r [ 0 ] , r [ 1 ] ) ; } else { for ( int i = 0 ; i < 3 ; i ++ ) { int j = ( i + 1 ) % 3 ; int k = ( i + 2 ) % 3 ; res = Math . min ( res , Math . max ( r [ i ] , 0.5 * ( Math . hypot ( x [ j ] - x [ k ] , y [ j ] - y [ k ] ) + r [ j ] + r [ k ] ) ) ) ; } } out . println ( "" Case ▁ # "" + test + "" : ▁ "" + res ) ; } try { close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } public static void main ( String [ ] args ) throws IOException { new Thread ( new Main ( ) ) . start ( ) ; } } +","import sys NEW_LINE from math import sqrt NEW_LINE class Obj : NEW_LINE INDENT pass NEW_LINE DEDENT def dist ( o1 , o2 ) : NEW_LINE INDENT return ( sqrt ( ( o1 . x - o2 . x ) ** 2 + ( o1 . y - o2 . y ) ** 2 ) + o2 . r + o1 . r ) / 2.0 NEW_LINE DEDENT def solve ( a ) : NEW_LINE INDENT n = len ( a ) NEW_LINE if n == 1 : NEW_LINE INDENT return a [ 0 ] . r NEW_LINE DEDENT if n == 2 : NEW_LINE INDENT return max ( a [ 0 ] . r , a [ 1 ] . r ) NEW_LINE DEDENT res = max ( dist ( a [ 0 ] , a [ 1 ] ) , a [ 2 ] . r ) NEW_LINE res = min ( res , max ( dist ( a [ 0 ] , a [ 2 ] ) , a [ 1 ] . r ) ) NEW_LINE res = min ( res , max ( dist ( a [ 1 ] , a [ 2 ] ) , a [ 0 ] . r ) ) NEW_LINE return res NEW_LINE DEDENT nCases = int ( sys . stdin . readline ( ) ) NEW_LINE for c in xrange ( 1 , nCases + 1 ) : NEW_LINE INDENT n = int ( sys . stdin . readline ( ) ) NEW_LINE a = [ ] NEW_LINE for i in xrange ( n ) : NEW_LINE INDENT o = Obj ( ) ; NEW_LINE ( o . x , o . y , o . r ) = [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE a . append ( o ) NEW_LINE DEDENT print "" Case ▁ # "" + str ( c ) + "" : ▁ "" + repr ( solve ( a ) ) NEW_LINE DEDENT +" +E145,"import java . util . * ; import static java . lang . Math . * ; public class A { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; int [ ] num = { 0 , 6 , 2 , 8 , 3 , 4 , 5 , 7 , 1 , 9 } ; char [ ] ch = { ' Z ' , ' X ' , ' W ' , ' G ' , ' H ' , ' R ' , ' F ' , ' V ' , ' O ' , ' E ' } ; String [ ] word = { "" ZERO "" , "" SIX "" , "" TWO "" , "" EIGHT "" , "" THREE "" , "" FOUR "" , "" FIVE "" , "" SEVEN "" , "" ONE "" , "" NINE "" } ; for ( int zz = 1 ; zz <= T ; zz ++ ) { String S = in . next ( ) ; int [ ] C = new int [ 26 ] ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { C [ ( int ) ( S . charAt ( i ) - ' A ' ) ] ++ ; } int [ ] ans = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { int count = C [ ( int ) ( ch [ i ] - ' A ' ) ] ; ans [ num [ i ] ] += count ; for ( int j = 0 ; j < word [ i ] . length ( ) ; j ++ ) { C [ ( int ) ( word [ i ] . charAt ( j ) - ' A ' ) ] -= count ; } } for ( int i = 0 ; i < 10 ; i ++ ) { if ( C [ i ] != 0 ) { throw new RuntimeException ( ) ; } } System . out . format ( "" Case ▁ # % d : ▁ "" , zz ) ; for ( int i = 0 ; i < 10 ; i ++ ) for ( int j = 0 ; j < ans [ i ] ; j ++ ) System . out . print ( i ) ; System . out . println ( ) ; } } } +","import sys NEW_LINE sys . setrecursionlimit ( 100000 ) NEW_LINE inp = sys . stdin NEW_LINE outp = sys . stdout NEW_LINE words = [ "" ZERO "" , "" ONE "" , "" TWO "" , "" THREE "" , "" FOUR "" , "" FIVE "" , "" SIX "" , "" SEVEN "" , "" EIGHT "" , "" NINE "" ] NEW_LINE m = [ ( 0 , ' Z ' ) , ( 2 , ' W ' ) , ( 4 , ' U ' ) , ( 6 , ' X ' ) , ( 7 , ' S ' ) , ( 5 , ' V ' ) , ( 1 , ' O ' ) , ( 3 , ' R ' ) , ( 8 , ' H ' ) , ( 9 , ' E ' ) ] NEW_LINE def solve ( ) : NEW_LINE INDENT x = sys . stdin . readline ( ) . strip ( ) NEW_LINE f = [ 0 ] * 10 NEW_LINE for ( d , c ) in m : NEW_LINE INDENT cnt = x . count ( c ) NEW_LINE f [ d ] += cnt NEW_LINE for c2 in words [ d ] : NEW_LINE INDENT x = x . replace ( c2 , ' ' , cnt ) NEW_LINE DEDENT DEDENT assert x == ' ' NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT outp . write ( ( ' % d ' % i ) * f [ i ] ) NEW_LINE DEDENT print NEW_LINE DEDENT T = int ( inp . readline ( ) ) NEW_LINE for i in range ( T ) : NEW_LINE INDENT outp . write ( ' Case ▁ # % d : ▁ ' % ( i + 1 ) ) NEW_LINE solve ( ) NEW_LINE DEDENT +" +E146,"import java . io . * ; import java . util . * ; public class AAA { boolean getsum1 ( int n , int k ) { TreeSet < Integer > y = new TreeSet < Integer > ( ) ; while ( true ) { if ( y . contains ( n ) ) return false ; y . add ( n ) ; int res = 0 ; while ( n != 0 ) { res += ( n % k ) * ( n % k ) ; n /= k ; } n = res ; if ( n == 1 ) return true ; } } TreeMap < Integer , Integer > result = new TreeMap < Integer , Integer > ( ) ; void solve ( ) throws IOException { Scanner in = new Scanner ( new FileInputStream ( "" input . txt "" ) ) ; PrintWriter out = new PrintWriter ( new FileOutputStream ( "" output . txt "" ) ) ; String s ; int n = in . nextInt ( ) ; in . nextLine ( ) ; for ( int t = 1 ; t <= n ; ++ t ) { s = in . nextLine ( ) ; if ( s == null ) break ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; Scanner in2 = new Scanner ( s ) ; while ( in2 . hasNextInt ( ) ) a . add ( in2 . nextInt ( ) ) ; int mask = 0 ; for ( int i = 0 ; i < a . size ( ) ; ++ i ) mask += 1 << a . get ( i ) ; if ( a . size ( ) == 9 ) result . put ( mask , 11814485 ) ; int tr = 2 ; if ( result . containsKey ( mask ) ) { tr = result . get ( mask ) ; } else { while ( true ) { boolean good = true ; for ( int i = a . size ( ) - 1 ; i >= 0 ; -- i ) if ( ! getsum1 ( tr , a . get ( i ) ) ) { good = false ; break ; } if ( good ) break ; tr ++ ; } result . put ( mask , tr ) ; } out . println ( "" Case ▁ # "" + t + "" : ▁ "" + tr ) ; out . flush ( ) ; } out . close ( ) ; } public static void main ( String [ ] args ) throws IOException { AAA a = new AAA ( ) ; a . solve ( ) ; } } +","import os , sys NEW_LINE def convertToBase ( number , base ) : NEW_LINE INDENT digits = [ ] NEW_LINE mod = base NEW_LINE prevMod = 1 NEW_LINE while number > 0 : NEW_LINE INDENT digit = ( number % mod ) / prevMod NEW_LINE digits . append ( digit ) NEW_LINE number = number - digit * prevMod NEW_LINE prevMod = mod NEW_LINE mod *= base NEW_LINE DEDENT if len ( digits ) == 0 : NEW_LINE INDENT digits = [ 0 ] NEW_LINE DEDENT return digits NEW_LINE DEDENT def squareDigits ( digits ) : NEW_LINE INDENT return sum ( [ x * x for x in digits ] ) NEW_LINE DEDENT def isHappy ( number , base ) : NEW_LINE INDENT foundNums = set ( ) NEW_LINE while True : NEW_LINE INDENT digits = convertToBase ( number , base ) NEW_LINE number = squareDigits ( digits ) NEW_LINE if number == 1 : NEW_LINE INDENT return True NEW_LINE DEDENT if number in foundNums : NEW_LINE INDENT return False NEW_LINE DEDENT foundNums . add ( number ) NEW_LINE DEDENT DEDENT def main ( filename ) : NEW_LINE INDENT fileLines = open ( filename , ' r ' ) . readlines ( ) NEW_LINE index = 0 NEW_LINE words = [ ] NEW_LINE numCases = int ( fileLines [ index ] [ : - 1 ] ) NEW_LINE index += 1 NEW_LINE for caseNum in range ( numCases ) : NEW_LINE INDENT bases = [ int ( x ) for x in fileLines [ index ] [ : - 1 ] . split ( ' ▁ ' ) ] NEW_LINE index += 1 NEW_LINE i = 2 NEW_LINE while True : NEW_LINE INDENT happy = True NEW_LINE for base in bases : NEW_LINE INDENT if ( not isHappy ( i , base ) ) : NEW_LINE INDENT happy = False NEW_LINE break NEW_LINE DEDENT DEDENT if happy : NEW_LINE INDENT break NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print "" Case ▁ # % d : ▁ % d "" % ( caseNum + 1 , i ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( sys . argv [ 1 ] ) NEW_LINE DEDENT +" +E147,"import java . io . FileReader ; import java . io . FileWriter ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Scanner ; public class FullBinaryTree { public final static String INPUT_FILE_NAME = "" B - large ( 1 ) . in "" ; public final static String OUTPUT_FILE_NAME = "" FullBinaryTree . out "" ; public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( new FileReader ( INPUT_FILE_NAME ) ) ; PrintWriter out = new PrintWriter ( new FileWriter ( OUTPUT_FILE_NAME ) ) ) { int numT = in . nextInt ( ) ; for ( int t = 1 ; t <= numT ; t ++ ) { System . out . println ( "" Case ▁ "" + t ) ; int numNode = in . nextInt ( ) ; ArrayList < Node > nodes = new ArrayList < > ( ) ; for ( int i = 0 ; i < numNode ; i ++ ) { nodes . add ( new Node ( ) ) ; } for ( int i = 0 ; i < numNode - 1 ; i ++ ) { int a = in . nextInt ( ) - 1 ; int b = in . nextInt ( ) - 1 ; nodes . get ( a ) . addChild ( nodes . get ( b ) ) ; nodes . get ( b ) . addChild ( nodes . get ( a ) ) ; } int best = 0 ; for ( Node n : nodes ) { best = Math . max ( best , n . maxChildren ( null ) ) ; } int res = numNode - best ; out . println ( "" Case ▁ # "" + t + "" : ▁ "" + res ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } public static class Node { ArrayList < Node > children ; public Node ( ) { children = new ArrayList < > ( ) ; } public void addChild ( Node n ) { children . add ( n ) ; } public int maxChildren ( Node parent ) { int best = 0 ; int best2 = 0 ; for ( Node n : children ) { if ( n != parent ) { int nv = n . maxChildren ( this ) ; if ( nv > best ) { best2 = best ; best = nv ; } else if ( nv > best2 ) { best2 = nv ; } } } if ( best2 == 0 ) return 1 ; return best + best2 + 1 ; } } } +","from collections import defaultdict NEW_LINE from heapq import nlargest NEW_LINE def maxSize ( adj , node , parent ) : NEW_LINE INDENT children = adj [ node ] - { parent } NEW_LINE if len ( children ) == 1 : return 1 NEW_LINE return sum ( nlargest ( 2 , ( maxSize ( adj , child , node ) for child in children ) ) ) + 1 NEW_LINE DEDENT for t in range ( int ( input ( ) ) ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE adj = defaultdict ( set ) NEW_LINE for _ in range ( N - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE adj [ a ] . add ( b ) NEW_LINE adj [ b ] . add ( a ) NEW_LINE DEDENT result = N - max ( maxSize ( adj , root , None ) for root in range ( 1 , N + 1 ) ) NEW_LINE assert 0 <= result <= N NEW_LINE print ( ' Case ▁ # { } : ▁ { } ' . format ( t + 1 , result ) ) NEW_LINE DEDENT +" +E148,"import java . math . BigInteger ; import java . util . Scanner ; public class B { private static int parse ( String s ) { BigInteger integer = new BigInteger ( s ) ; integer = integer . mod ( BigInteger . valueOf ( 210 ) ) ; return integer . intValue ( ) ; } public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int N = scanner . nextInt ( ) ; for ( int testCase = 1 ; testCase <= N ; ++ testCase ) { final String line = scanner . next ( ) ; final int n = line . length ( ) ; final int [ ] [ ] partsTable = new int [ n ] [ n + 1 ] ; for ( int begin = 0 ; begin < n ; ++ begin ) { for ( int end = begin + 1 ; end <= n ; ++ end ) { partsTable [ begin ] [ end ] = parse ( line . substring ( begin , end ) ) ; } } final long [ ] [ ] memo = new long [ n + 1 ] [ 210 ] ; ++ memo [ 0 ] [ 0 ] ; for ( int endIndex = 1 ; endIndex <= n ; ++ endIndex ) { for ( int beginIndex = 0 ; beginIndex < endIndex ; ++ beginIndex ) { { for ( int prevMod = 0 ; prevMod < 210 ; ++ prevMod ) { final int nextMod = ( prevMod + partsTable [ beginIndex ] [ endIndex ] ) % 210 ; memo [ endIndex ] [ nextMod ] += memo [ beginIndex ] [ prevMod ] ; } } if ( beginIndex != 0 ) { for ( int prevMod = 0 ; prevMod < 210 ; ++ prevMod ) { final int nextMod = ( prevMod - partsTable [ beginIndex ] [ endIndex ] + 210 ) % 210 ; memo [ endIndex ] [ nextMod ] += memo [ beginIndex ] [ prevMod ] ; } } } } long answer = 0 ; for ( int mod = 0 ; mod < 210 ; ++ mod ) { if ( mod % 2 == 0 || mod % 3 == 0 || mod % 5 == 0 || mod % 7 == 0 ) { answer += memo [ n ] [ mod ] ; } } System . out . printf ( "" Case ▁ # % d : ▁ % d \n "" , testCase , answer ) ; } } } +","ops = [ int . __add__ , int . __sub__ ] NEW_LINE ugly_count = 0 NEW_LINE def is_ugly ( num ) : NEW_LINE INDENT return num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0 NEW_LINE DEDENT def count_ugly ( left_slice_num , right_slice , op ) : NEW_LINE INDENT global ugly_count NEW_LINE if is_ugly ( op ( left_slice_num , int ( right_slice ) ) ) : NEW_LINE INDENT ugly_count += 1 NEW_LINE DEDENT if len ( right_slice ) > 1 : NEW_LINE INDENT for i in xrange ( - 1 , - len ( right_slice ) , - 1 ) : NEW_LINE INDENT for sub_op in ops : NEW_LINE INDENT count_ugly ( op ( left_slice_num , int ( right_slice [ : i ] ) ) , right_slice [ i : ] , sub_op ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT testsCount = int ( raw_input ( ) ) NEW_LINE for i in xrange ( testsCount ) : NEW_LINE INDENT ugly_count = 0 NEW_LINE count_ugly ( 0 , raw_input ( ) , int . __add__ ) NEW_LINE print "" Case ▁ # % d : ▁ % d "" % ( i + 1 , ugly_count ) NEW_LINE DEDENT DEDENT +" +E149,"package common ; import java . io . BufferedReader ; import java . io . File ; import java . io . FileReader ; import java . io . FileWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class Helper { public static String [ ] getAllFileContentAsArray ( String filename ) throws Exception { BufferedReader in = new BufferedReader ( new FileReader ( filename ) ) ; List < String > all = new ArrayList < String > ( ) ; String s = in . readLine ( ) ; while ( s != null ) { all . add ( s ) ; s = in . readLine ( ) ; } in . close ( ) ; return all . toArray ( new String [ 0 ] ) ; } public static void writeToFile ( String [ ] cont , String filename ) throws Exception { File file = new File ( filename ) ; file . delete ( ) ; FileWriter w = null ; try { w = new FileWriter ( file , true ) ; for ( String s : cont ) { w . write ( s + "" \n "" ) ; } } finally { if ( w != null ) { w . close ( ) ; } } } public static int [ ] getIntegersFromString ( String s ) throws Exception { List < Integer > a = new ArrayList < Integer > ( ) ; for ( String se : s . split ( "" ▁ "" ) ) { try { Integer x = Integer . parseInt ( se ) ; a . add ( x ) ; } catch ( Exception e ) { } } int [ ] ret = new int [ a . size ( ) ] ; for ( int i = 0 ; i < a . size ( ) ; ++ i ) { ret [ i ] = a . get ( i ) . intValue ( ) ; } return ret ; } private Helper ( ) { } } +","inp_file = file ( "" B - small . in "" ) NEW_LINE out_file = file ( "" B - small . out "" , "" w "" ) NEW_LINE def solve ( line ) : NEW_LINE INDENT A , B , P = [ int ( c1 ) for c1 in line . split ( "" ▁ "" ) ] NEW_LINE numbers = range ( A , B + 1 ) NEW_LINE sets = range ( B - A + 1 ) NEW_LINE for c1 in primes : NEW_LINE INDENT if c1 < P : continue NEW_LINE if c1 > B / 2 + 1 : break NEW_LINE same = [ ] NEW_LINE for c2 in numbers : NEW_LINE INDENT if not c2 % c1 : same . append ( c2 - A ) NEW_LINE DEDENT sets = merge_sets ( sets , same ) NEW_LINE DEDENT counted = [ ] NEW_LINE c2 = 0 NEW_LINE for c1 in sets : NEW_LINE INDENT if not c1 in counted : NEW_LINE INDENT counted . append ( c1 ) NEW_LINE c2 += 1 NEW_LINE DEDENT DEDENT return str ( c2 ) NEW_LINE DEDENT def merge_sets ( sets , same ) : NEW_LINE INDENT to_change = [ sets [ c1 ] for c1 in same ] NEW_LINE for c1 in range ( len ( sets ) ) : NEW_LINE INDENT if sets [ c1 ] in to_change : NEW_LINE INDENT sets [ c1 ] = to_change [ 0 ] NEW_LINE DEDENT DEDENT return sets NEW_LINE DEDENT p_file = file ( "" primes1000 . txt "" ) NEW_LINE primes = [ int ( c1 ) for c1 in p_file . read ( ) . split ( "" \n "" ) ] NEW_LINE p_file . close ( ) NEW_LINE num = int ( inp_file . readline ( ) ) NEW_LINE for case in range ( num ) : NEW_LINE INDENT line = inp_file . readline ( ) [ : - 1 ] NEW_LINE out_file . write ( "" Case ▁ # % s : ▁ "" % ( case + 1 ) + solve ( line ) + "" \n "" ) NEW_LINE DEDENT inp_file . close ( ) NEW_LINE out_file . close ( ) NEW_LINE +" +E150,"public class Point { public double x , y ; public Point ( double x , double y ) { this . x = x ; this . y = y ; } public Point ( ) { x = 0 ; y = 0 ; } @ Override public boolean equals ( Object arg0 ) { Point pt = ( Point ) arg0 ; return CG . dblcmp ( pt . x , x ) == 0 && CG . dblcmp ( pt . y , y ) == 0 ; } public Point minus ( Point p ) { return new Point ( x - p . x , y - p . y ) ; } public Point add ( Point p ) { return new Point ( x + p . x , y + p . y ) ; } public Point mul ( double n ) { return new Point ( n * x , n * y ) ; } public double abs ( ) { return Math . sqrt ( x * x + y * y ) ; } public void copy ( Point p ) { this . x = p . x ; this . y = p . y ; } } +","import math NEW_LINE eps = 0.0000001 NEW_LINE def Solve ( H , W , D , c ) : NEW_LINE INDENT angles = [ ] NEW_LINE W = W - 2 NEW_LINE H = H - 2 NEW_LINE found = False NEW_LINE y = - 0.5 NEW_LINE for line in c : NEW_LINE INDENT x = - 0.5 NEW_LINE for char in line : NEW_LINE INDENT if char == "" X "" : NEW_LINE INDENT found = True NEW_LINE break NEW_LINE DEDENT x = x + 1 NEW_LINE DEDENT if found : NEW_LINE INDENT break NEW_LINE DEDENT y = y + 1 NEW_LINE DEDENT mx = x NEW_LINE my = y NEW_LINE co = 0 NEW_LINE for xcopy in range ( - 50 , 50 ) : NEW_LINE INDENT for ycopy in range ( - 50 , 50 ) : NEW_LINE INDENT if ( xcopy == 0 and ycopy == 0 ) : NEW_LINE INDENT continue NEW_LINE DEDENT if xcopy % 2 != 0 : NEW_LINE INDENT mx = ( xcopy + 1 ) * ( W ) - x NEW_LINE DEDENT else : NEW_LINE INDENT mx = xcopy * ( W ) + x NEW_LINE DEDENT if ycopy % 2 != 0 : NEW_LINE INDENT my = ( ycopy + 1 ) * ( H ) - y NEW_LINE DEDENT else : NEW_LINE INDENT my = ycopy * ( H ) + y NEW_LINE DEDENT dist = math . sqrt ( ( mx - x ) ** 2 + ( my - y ) ** 2 ) NEW_LINE if dist <= D : NEW_LINE INDENT a = 0 NEW_LINE a = math . atan2 ( ( my - y ) , ( mx - x ) ) NEW_LINE if not hasAngle ( a , angles ) : NEW_LINE INDENT co = co + 1 NEW_LINE angles . append ( a ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return co NEW_LINE DEDENT def hasAngle ( a , angles ) : NEW_LINE INDENT for an in angles : NEW_LINE INDENT if abs ( an - a ) < eps : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT f = open ( ' d . in ' ) NEW_LINE T = int ( f . readline ( ) ) NEW_LINE for t in range ( T ) : NEW_LINE INDENT H , W , D = map ( int , f . readline ( ) . split ( ) ) NEW_LINE c = [ ] NEW_LINE for x in range ( H ) : NEW_LINE INDENT c . append ( f . readline ( ) ) NEW_LINE DEDENT result = Solve ( H , W , D , c ) NEW_LINE print "" Case ▁ # % d : ▁ % s "" % ( t + 1 , result ) NEW_LINE DEDENT +" +E151,"import java . util . * ; import java . io . * ; import java . math . * ; import static java . lang . Math . * ; import static java . lang . Integer . * ; import static java . lang . System . * ; public class B { public static String [ ] parts ( BufferedReader br ) throws Exception { String line = br . readLine ( ) ; if ( line == null ) return null ; return line . trim ( ) . split ( "" \\ s + "" ) ; } public static void main ( String args [ ] ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; int cas = parseInt ( br . readLine ( ) ) ; for ( int z = 1 ; z <= cas ; z ++ ) { int n = parseInt ( br . readLine ( ) ) ; String [ ] ss = parts ( br ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = parseInt ( ss [ i ] ) ; int [ ] cl = new int [ n ] ; int [ ] cr = new int [ n ] ; HashMap < Integer , Integer > where = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { where . put ( arr [ i ] , i ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; if ( i < j && arr [ j ] > arr [ i ] ) cl [ i ] ++ ; if ( i > j && arr [ j ] > arr [ i ] ) cr [ i ] ++ ; } } int ans = 0 ; Arrays . sort ( arr ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int x = arr [ i ] ; int j = where . get ( x ) ; ans += min ( cl [ j ] , cr [ j ] ) ; } out . println ( "" Case ▁ # "" + z + "" : ▁ "" + ans ) ; } } } +","import sys NEW_LINE def solve ( n , s ) : NEW_LINE INDENT cnt = 0 NEW_LINE while n > 0 : NEW_LINE INDENT m = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if s [ i ] < s [ m ] : NEW_LINE INDENT m = i NEW_LINE DEDENT DEDENT cnt += min ( m , n - 1 - m ) NEW_LINE n = n - 1 NEW_LINE del s [ m ] NEW_LINE DEDENT return cnt NEW_LINE DEDENT t = int ( sys . stdin . readline ( ) ) NEW_LINE for test_case in range ( 1 , t + 1 ) : NEW_LINE INDENT n = int ( sys . stdin . readline ( ) ) NEW_LINE s = [ int ( y ) for y in sys . stdin . readline ( ) . split ( ) ] NEW_LINE print ( ' Case ▁ # % d : ▁ % d ' % ( test_case , solve ( n , s ) ) ) NEW_LINE DEDENT +" +E152,"import java . util . * ; public class WorldCup { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int T = sc . nextInt ( ) ; for ( int i = 1 ; i <= T ; i ++ ) { System . out . println ( "" Case ▁ # "" + i + "" : ▁ "" + solveCase ( ) ) ; } } static long solveCase ( ) { N = sc . nextInt ( ) ; req = new int [ 1 << N ] ; for ( int i = 0 ; i < req . length ; i ++ ) req [ i ] = sc . nextInt ( ) ; cost = new int [ N ] [ ] ; memo = new long [ N ] [ ] [ ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { cost [ i ] = new int [ 1 << i ] ; memo [ i ] = new long [ i + 1 ] [ 1 << i ] ; for ( long [ ] arr : memo [ i ] ) Arrays . fill ( arr , - 1L ) ; for ( int j = 0 ; j < cost [ i ] . length ; j ++ ) cost [ i ] [ j ] = sc . nextInt ( ) ; } return solve ( 0 , 0 , 0 ) ; } static int N ; static int [ ] req ; static int [ ] [ ] cost ; static long [ ] [ ] [ ] memo ; static final long INF = Integer . MAX_VALUE * 1000L ; static long solve ( int index , int level , int count ) { if ( level >= N ) return count >= N - req [ index ] ? 0 : INF ; if ( memo [ level ] [ count ] [ index ] == - 1 ) { long skip = solve ( index * 2 , level + 1 , count ) + solve ( index * 2 + 1 , level + 1 , count ) ; long choose = solve ( index * 2 , level + 1 , count + 1 ) + solve ( index * 2 + 1 , level + 1 , count + 1 ) + cost [ level ] [ index ] ; memo [ level ] [ count ] [ index ] = Math . min ( skip , choose ) ; } return memo [ level ] [ count ] [ index ] ; } } +","inf = 2 * 10 ** 20 NEW_LINE def inv ( x ) : NEW_LINE INDENT return P - int ( x ) NEW_LINE DEDENT def xl ( l ) : NEW_LINE INDENT return xrange ( len ( l ) ) NEW_LINE DEDENT debug = False NEW_LINE for case in range ( input ( ) ) : NEW_LINE INDENT print "" Case ▁ # "" + str ( case + 1 ) + "" : "" , NEW_LINE P = input ( ) NEW_LINE need = map ( inv , raw_input ( ) . split ( ) ) NEW_LINE costs = [ ] NEW_LINE for i in xrange ( P ) : NEW_LINE INDENT costs = map ( int , raw_input ( ) . split ( ) ) + costs NEW_LINE DEDENT v = [ [ inf for i in xrange ( P + 1 ) ] for j in xrange ( 2 ** ( P + 1 ) - 1 ) ] NEW_LINE if debug : print len ( v ) , 2 ** ( P + 1 ) - 1 , 2 ** P NEW_LINE leaves = 2 ** P - 1 NEW_LINE for ( i , x ) in enumerate ( need ) : NEW_LINE INDENT for j in xrange ( x , P + 1 ) : NEW_LINE INDENT v [ leaves + i ] [ j ] = 0 NEW_LINE DEDENT DEDENT for n in xrange ( leaves - 1 , - 1 , - 1 ) : NEW_LINE INDENT if debug : print n , 2 * n + 1 , 2 * n + 2 NEW_LINE for i in xrange ( P + 1 ) : NEW_LINE INDENT if i == P : NEW_LINE INDENT buy = inf NEW_LINE DEDENT else : NEW_LINE INDENT buy = v [ 2 * n + 1 ] [ i + 1 ] + v [ 2 * n + 2 ] [ i + 1 ] + costs [ n ] NEW_LINE DEDENT skip = v [ 2 * n + 1 ] [ i ] + v [ 2 * n + 2 ] [ i ] NEW_LINE v [ n ] [ i ] = min ( buy , skip ) NEW_LINE DEDENT DEDENT print v [ 0 ] [ 0 ] NEW_LINE if debug : NEW_LINE INDENT print costs NEW_LINE for ( i , x ) in enumerate ( v ) : print i , x NEW_LINE DEDENT DEDENT +" +E153,"import java . io . * ; import java . math . BigInteger ; import java . util . * ; public class Solution { BufferedReader in ; PrintWriter out ; StringTokenizer st ; String nextToken ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( in . readLine ( ) ) ; } return st . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; } void solve ( ) throws IOException { st = new StringTokenizer ( in . readLine ( ) , "" / "" ) ; long p = nextLong ( ) ; long q = nextLong ( ) ; long gcd = BigInteger . valueOf ( p ) . gcd ( BigInteger . valueOf ( q ) ) . longValue ( ) ; long qq = q / gcd ; if ( ( qq & ( qq - 1 ) ) == 0 ) { p /= gcd ; int ans = 1 ; while ( p < qq / 2 ) { ans ++ ; qq /= 2 ; } out . println ( ans ) ; } else { out . println ( "" impossible "" ) ; } } void run ( ) { try { in = new BufferedReader ( new FileReader ( "" input . txt "" ) ) ; out = new PrintWriter ( "" output . txt "" ) ; Locale . setDefault ( Locale . UK ) ; int tt = nextInt ( ) ; for ( int t = 1 ; t <= tt ; t ++ ) { out . print ( "" Case ▁ # "" + t + "" : ▁ "" ) ; solve ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { out . close ( ) ; } } public static void main ( String Args [ ] ) { new Solution ( ) . run ( ) ; } } +","import functools NEW_LINE import multiprocessing NEW_LINE import fractions NEW_LINE def pow2 ( x ) : NEW_LINE INDENT return x != 0 and ( ( x & ( x - 1 ) ) == 0 ) NEW_LINE DEDENT def solve ( cs , f ) : NEW_LINE INDENT if not pow2 ( f . denominator ) : NEW_LINE INDENT return cs , ' impossible ' NEW_LINE DEDENT ret = 1 NEW_LINE while f < fractions . Fraction ( 1 , 2 ) : NEW_LINE INDENT ret += 1 NEW_LINE f *= 2 NEW_LINE DEDENT return cs , ret NEW_LINE DEDENT def reducer ( l , result ) : NEW_LINE INDENT l . append ( result ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT T = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE with multiprocessing . Pool ( processes = 8 ) as pool : NEW_LINE INDENT for cs in range ( T ) : NEW_LINE INDENT f = fractions . Fraction ( input ( ) ) NEW_LINE solve ( cs , f ) NEW_LINE pool . apply_async ( solve , args = ( cs + 1 , f , ) , callback = functools . partial ( reducer , l ) ) NEW_LINE DEDENT pool . close ( ) NEW_LINE pool . join ( ) NEW_LINE DEDENT for cs , result in sorted ( l , key = lambda x : x [ 0 ] ) : NEW_LINE INDENT print ( ' Case ▁ # { } : ▁ { } ' . format ( cs , result ) ) NEW_LINE DEDENT DEDENT +" +E154,"import java . util . Scanner ; import java . io . * ; import java . math . BigInteger ; public class A { public static void main ( String [ ] args ) throws Throwable { Scanner in = new Scanner ( new File ( "" in . txt "" ) ) ; PrintStream out = new PrintStream ( new File ( "" out . txt "" ) ) ; int t = in . nextInt ( ) ; in . nextLine ( ) ; for ( int c = 1 ; c <= t ; c ++ ) { out . print ( "" Case ▁ # "" ) ; out . print ( c ) ; out . print ( "" : ▁ "" ) ; out . println ( getSolution ( in ) ) ; } } private static String getSolution ( Scanner in ) { long n ; int pd , pg ; n = in . nextLong ( ) ; pd = in . nextInt ( ) ; pg = in . nextInt ( ) ; int factor = gcf ( 100 , pd ) ; if ( 100 / factor > n ) return "" Broken "" ; if ( ( pg == 100 && pd != 100 ) || ( pg == 0 && pd != 0 ) ) return "" Broken "" ; return "" Possible "" ; } public static int gcf ( int a , int b ) { int s ; if ( a > b ) s = b ; else s = a ; for ( int i = s ; i > 0 ; i -- ) { if ( ( a % i == 0 ) && ( b % i == 0 ) ) return i ; } return - 1 ; } } +","import sys , time NEW_LINE start_time = time . time ( ) NEW_LINE try : NEW_LINE INDENT if len ( sys . argv ) > 1 : NEW_LINE INDENT inname = sys . argv [ 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT inname = input ( "" Enter ▁ input ▁ filename : ▁ "" ) NEW_LINE DEDENT assert inname . endswith ( ' . in ' ) NEW_LINE outname = inname . replace ( ' . in ' , ' . out ' ) NEW_LINE with open ( inname ) as fin : NEW_LINE INDENT with open ( outname , ' w ' ) as fout : NEW_LINE INDENT num_cases = int ( fin . readline ( ) ) NEW_LINE for case_idx in range ( 1 , 1 + num_cases ) : NEW_LINE INDENT if time . time ( ) >= start_time + 5 : NEW_LINE INDENT print ( "" [ = = ▁ Case ▁ % d ▁ of ▁ % d ▁ = = ] "" % ( case_idx , num_cases ) ) NEW_LINE DEDENT N , pD , pG = [ int ( x ) for x in fin . readline ( ) . split ( ) ] NEW_LINE answer = True NEW_LINE N = min ( N , 100 ) NEW_LINE if pG == 100 and pD != 100 : answer = False NEW_LINE if pG == 0 and pD != 0 : answer = False NEW_LINE if all ( ( pD * D ) % 100 for D in range ( 1 , 1 + N ) ) : answer = False NEW_LINE print ( "" Case ▁ # { } : ▁ { } "" . format ( case_idx , ' Possible ' if answer else ' Broken ' ) , file = fout ) NEW_LINE DEDENT DEDENT DEDENT DEDENT except : NEW_LINE INDENT import traceback NEW_LINE print ( "" Exception ▁ caught : "" , file = sys . stderr ) NEW_LINE print ( ' - ' * 60 , file = sys . stderr ) NEW_LINE traceback . print_exc ( file = sys . stderr ) NEW_LINE print ( ' - ' * 60 , file = sys . stderr ) NEW_LINE input ( "" Press ▁ Enter ▁ to ▁ close "" ) NEW_LINE DEDENT else : NEW_LINE INDENT total_time = time . time ( ) - start_time NEW_LINE print ( "" Completed ▁ in ▁ % .1f ▁ seconds "" % total_time , file = sys . stderr ) NEW_LINE time . sleep ( 3 ) NEW_LINE DEDENT +" +E155,"import java . util . * ; public class c { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int T = input . nextInt ( ) ; for ( int t = 1 ; t <= T ; t ++ ) { System . out . print ( "" Case ▁ # "" + t + "" : ▁ "" ) ; int n = input . nextInt ( ) ; PriorityQueue < Double > finish = new PriorityQueue < Double > ( ) ; PriorityQueue < Hiker > lap = new PriorityQueue < Hiker > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int d = input . nextInt ( ) ; int h = input . nextInt ( ) ; int m = input . nextInt ( ) ; for ( int j = 0 ; j < h ; j ++ ) { int time = m + j ; double ft = time * ( 360.0 - d ) / 360 ; finish . add ( ft ) ; lap . add ( new Hiker ( ft + time , time ) ) ; } } int size = lap . size ( ) ; int res = size , count = size ; while ( ! finish . isEmpty ( ) ) { while ( count < 2 * size && lap . peek ( ) . time <= finish . peek ( ) ) { Hiker h = lap . poll ( ) ; count ++ ; h . time += h . add ; lap . add ( h ) ; } if ( count == 2 * size ) break ; count -- ; res = Math . min ( res , count ) ; double x = finish . poll ( ) ; } System . out . println ( res ) ; } } static class Hiker implements Comparable < Hiker > { double time ; double add ; public Hiker ( double tt , double aa ) { time = tt ; add = aa ; } @ Override public int compareTo ( Hiker o ) { return Double . compare ( time , o . time ) ; } } } +","import os , sys , time , random NEW_LINE time . clock ( ) NEW_LINE sys . stdin = open ( ' C - small - 1 - attempt0 . in ' ) NEW_LINE sys . stdout = open ( ' C - small - 1 - attempt0 . out ' , ' w ' ) NEW_LINE def Work ( ) : NEW_LINE INDENT n = int ( input ( ) . strip ( ) ) NEW_LINE sb = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT d , h , m = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE for j in range ( h ) : NEW_LINE INDENT sb . append ( ( d , 360 / ( m + j ) ) ) NEW_LINE DEDENT DEDENT sb . sort ( key = lambda d : d [ - 1 ] , reverse = True ) NEW_LINE if sb [ 0 ] [ 1 ] == sb [ 1 ] [ 1 ] : return 0 NEW_LINE ar1 = ( 360 - sb [ 1 ] [ 0 ] ) / sb [ 1 ] [ 1 ] NEW_LINE meet = ( 360 + sb [ 1 ] [ 0 ] - sb [ 0 ] [ 0 ] ) / ( sb [ 0 ] [ 1 ] - sb [ 1 ] [ 1 ] ) NEW_LINE if meet <= ar1 + 1e-8 : return 1 NEW_LINE return 0 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT T = int ( input ( ) ) NEW_LINE for i in range ( T ) : NEW_LINE INDENT print ( ' Case ▁ # % d : ▁ % d ' % ( i + 1 , Work ( ) ) ) NEW_LINE DEDENT sys . stderr . write ( ' completed ▁ % .3f \n ' % time . clock ( ) ) NEW_LINE DEDENT +" +E156,"import java . io . * ; import java . util . * ; public class Round0A { int cases ; long calc ( long N ) { boolean seen [ ] = new boolean [ 10 ] ; int nSeen = 0 ; long x = N ; while ( true ) { String s = "" "" + x ; for ( int n = 0 ; n < s . length ( ) ; n ++ ) { char c = s . charAt ( n ) ; if ( ! seen [ c - '0' ] ) { seen [ c - '0' ] = true ; nSeen ++ ; } } if ( nSeen == 10 ) break ; x += N ; } return x ; } String calcS ( long N ) { if ( N == 0 ) return "" INSOMNIA "" ; return "" "" + calc ( N ) ; } void process ( Scanner scanner , PrintStream out ) throws IOException { cases = scanner . nextInt ( ) ; scanner . nextLine ( ) ; for ( int curCase = 0 ; curCase < cases ; curCase ++ ) { long N = scanner . nextLong ( ) ; out . println ( "" Case ▁ # "" + ( curCase + 1 ) + "" : ▁ "" + calcS ( N ) ) ; } } Round0A ( ) throws IOException { Scanner in = new Scanner ( new File ( "" C : \\ Users \\ Olaf \\ Downloads \\ A - large . in "" ) ) ; PrintStream out = new PrintStream ( "" out - A - large . txt "" ) ; process ( in , out ) ; in . close ( ) ; out . close ( ) ; } public static void main ( String [ ] args ) throws IOException { new Round0A ( ) ; } } +","import sys NEW_LINE def sheep ( N ) : NEW_LINE INDENT if N == 0 : return "" INSOMNIA "" NEW_LINE d = 0 ; t = N NEW_LINE while 1 : NEW_LINE INDENT for x in str ( t ) : d |= 1 << int ( x ) NEW_LINE if d == 1023 : return t NEW_LINE t += N NEW_LINE DEDENT DEDENT case = 0 NEW_LINE for x in sys . stdin : NEW_LINE INDENT if case > 0 : NEW_LINE INDENT N = int ( x . strip ( ) ) NEW_LINE print "" Case ▁ # % d : "" % case , sheep ( N ) NEW_LINE DEDENT case += 1 NEW_LINE DEDENT +" +E157,"import java . util . * ; import java . io . * ; import java . math . * ; import static java . lang . Math . * ; import static java . lang . Integer . * ; import static java . lang . System . * ; public class A { public static String [ ] parts ( BufferedReader br ) throws Exception { String line = br . readLine ( ) ; if ( line == null ) return null ; return line . trim ( ) . split ( "" \\ s + "" ) ; } public static void main ( String args [ ] ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; int cas = parseInt ( br . readLine ( ) ) ; for ( int z = 1 ; z <= cas ; z ++ ) { String [ ] ss = parts ( br ) ; int n = parseInt ( ss [ 0 ] ) ; int m = parseInt ( ss [ 1 ] ) ; ss = parts ( br ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = parseInt ( ss [ i ] ) ; Arrays . sort ( arr ) ; int ans = 0 ; for ( int i = 0 , j = n - 1 ; i <= j ; ) { while ( i < j && arr [ i ] + arr [ j ] > m ) { j -- ; ans ++ ; } i ++ ; j -- ; ans ++ ; } out . println ( "" Case ▁ # "" + z + "" : ▁ "" + ans ) ; } } } +","import collections NEW_LINE import sys NEW_LINE if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT f = sys . stdin NEW_LINE if len ( sys . argv ) >= 2 : NEW_LINE INDENT fn = sys . argv [ 1 ] NEW_LINE if fn != ' - ' : NEW_LINE INDENT f = open ( fn ) NEW_LINE DEDENT DEDENT T = int ( f . readline ( ) ) NEW_LINE for _T in xrange ( T ) : NEW_LINE INDENT N , X = map ( int , f . readline ( ) . split ( ) ) NEW_LINE disks = map ( int , f . readline ( ) . split ( ) ) NEW_LINE assert len ( disks ) == N NEW_LINE disks . sort ( ) NEW_LINE disks = collections . deque ( disks ) NEW_LINE r = 0 NEW_LINE while disks : NEW_LINE INDENT x1 = disks . pop ( ) NEW_LINE if disks and x1 + disks [ 0 ] <= X : NEW_LINE INDENT disks . popleft ( ) NEW_LINE DEDENT r += 1 NEW_LINE DEDENT print "" Case ▁ # % d : ▁ % d "" % ( _T + 1 , r ) NEW_LINE DEDENT DEDENT +" +E158,"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 B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int numCases = sc . nextInt ( ) ; for ( int caseNum = 1 ; caseNum <= numCases ; caseNum ++ ) { int N = sc . nextInt ( ) ; Map < Integer , Integer > counts = new HashMap < > ( ) ; for ( int i = 0 ; i < 2 * N - 1 ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { int height = sc . nextInt ( ) ; if ( counts . containsKey ( height ) ) { counts . put ( height , counts . get ( height ) + 1 ) ; } else { counts . put ( height , 1 ) ; } } } List < Integer > heights = new ArrayList < > ( ) ; for ( Map . Entry < Integer , Integer > entry : counts . entrySet ( ) ) { if ( entry . getValue ( ) % 2 != 0 ) { heights . add ( entry . getKey ( ) ) ; } } Collections . sort ( heights ) ; System . out . print ( "" Case ▁ # "" + caseNum + "" : "" ) ; for ( int h : heights ) { System . out . print ( "" ▁ "" + h ) ; } System . out . println ( ) ; } } } +","t = int ( raw_input ( ) ) NEW_LINE for cas in xrange ( 1 , t + 1 ) : NEW_LINE INDENT n = int ( raw_input ( ) ) NEW_LINE ct = dict ( zip ( xrange ( 1 , 2501 ) , [ 0 for i in xrange ( 1 , 2501 ) ] ) ) NEW_LINE for i in xrange ( 1 , 2 * n ) : NEW_LINE INDENT nums = map ( int , raw_input ( ) . split ( ) ) NEW_LINE for num in nums : NEW_LINE INDENT ct [ num ] += 1 NEW_LINE DEDENT DEDENT ans = [ ] NEW_LINE for i in ct : NEW_LINE INDENT if ct [ i ] % 2 == 1 : NEW_LINE INDENT ans . append ( i ) NEW_LINE DEDENT DEDENT ans . sort ( ) NEW_LINE ans = "" ▁ "" . join ( map ( str , ans ) ) NEW_LINE print "" Case ▁ # { } : ▁ { } "" . format ( cas , ans ) NEW_LINE DEDENT +" +E159,"import java . io . * ; import java . util . * ; import java . math . * ; public class Main implements Runnable { StreamTokenizer ST ; PrintWriter out ; BufferedReader br ; Scanner in ; String FileName = "" test "" ; int inf = 1000000000 ; int nextInt ( ) throws IOException { ST . nextToken ( ) ; return ( int ) ST . nval ; } String next ( ) throws IOException { ST . nextToken ( ) ; return ST . sval ; } double nextD ( ) throws IOException { ST . nextToken ( ) ; return ST . nval ; } public static void main ( String [ ] args ) throws IOException { new Thread ( new Main ( ) ) . start ( ) ; } public void run ( ) { try { out = new PrintWriter ( new BufferedWriter ( new FileWriter ( new File ( "" output . txt "" ) ) ) ) ; br = new BufferedReader ( new FileReader ( "" input . txt "" ) ) ; in = new Scanner ( br ) ; ST = new StreamTokenizer ( br ) ; solve ( ) ; out . close ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } } public void solve ( ) throws IOException { BigDecimal d = BigDecimal . valueOf ( 5 ) ; BigDecimal l = BigDecimal . valueOf ( 2 ) ; BigDecimal r = BigDecimal . valueOf ( 3 ) ; BigDecimal e = BigDecimal . valueOf ( 1 ) ; e = e . divide ( BigDecimal . TEN . pow ( 100 ) ) ; while ( r . subtract ( l ) . compareTo ( e ) > 0 ) { BigDecimal m = l . add ( r ) . divide ( BigDecimal . valueOf ( 2 ) ) ; if ( m . multiply ( m ) . compareTo ( d ) > 0 ) r = m ; else l = m ; } r = r . add ( BigDecimal . valueOf ( 3 ) ) ; int tests = nextInt ( ) ; for ( int test = 1 ; test <= tests ; test ++ ) { out . print ( "" Case ▁ # "" + test + "" : ▁ "" ) ; BigDecimal x = r . pow ( nextInt ( ) ) ; String s = x . toString ( ) ; s = ""0"" + s . substring ( 0 , s . indexOf ( ' . ' ) ) ; out . println ( s . substring ( s . length ( ) - 3 , s . length ( ) ) ) ; } } } +","A = 3 NEW_LINE B = 1 NEW_LINE n = 1 NEW_LINE tmp = 0 NEW_LINE X = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] NEW_LINE Y = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] NEW_LINE while n < 31 : NEW_LINE INDENT X [ n ] = A NEW_LINE Y [ n ] = B NEW_LINE tmp = 3 * A + B * 5 NEW_LINE B = A + 3 * B NEW_LINE A = tmp NEW_LINE n = n + 1 NEW_LINE DEDENT d = 22360679774997896964091736687312762354406183596115257242708972454105209256378048 NEW_LINE N = input ( ) NEW_LINE n = 0 NEW_LINE while n < N : NEW_LINE INDENT n = n + 1 NEW_LINE f = input ( ) NEW_LINE p = X [ f ] + int ( Y [ f ] * d / 10000000000000000000000000000000000000000000000000000000000000000000000000000000 ) NEW_LINE print "" Case ▁ # % d : ▁ % .3d "" % ( n , int ( p ) % 1000 ) NEW_LINE DEDENT +" +E160,"package c_2015 ; import java . util . Scanner ; public class C { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int kases = in . nextInt ( ) ; for ( int kas = 1 ; kas <= kases ; kas ++ ) { int C = in . nextInt ( ) ; int D = in . nextInt ( ) ; int V = in . nextInt ( ) ; if ( kas == 31 ) { C = C ; } long max = 0 ; int added = 0 ; for ( int i = 0 ; i < D ; i ++ ) { long coin = in . nextLong ( ) ; while ( max + 1 < coin ) { max += C * ( max + 1 ) ; added ++ ; } max += C * coin ; } while ( max < V ) { max += C * ( max + 1 ) ; added ++ ; } System . out . println ( "" Case ▁ # "" + kas + "" : ▁ "" + added ) ; } } } +","testSum = input ( ) NEW_LINE for test in xrange ( testSum ) : NEW_LINE INDENT c , d , v = map ( int , raw_input ( ) . split ( ) ) NEW_LINE coins = map ( int , raw_input ( ) . split ( ) ) NEW_LINE ansCoins = [ ] NEW_LINE now = 0 NEW_LINE ans = 0 NEW_LINE i = 0 NEW_LINE while now < v : NEW_LINE INDENT if i < len ( coins ) and ( coins [ i ] <= now + 1 ) : NEW_LINE INDENT ansCoins . append ( coins [ i ] ) NEW_LINE now = now + coins [ i ] * c NEW_LINE i = i + 1 NEW_LINE DEDENT else : NEW_LINE INDENT ansCoins . append ( now + 1 ) NEW_LINE ans = ans + 1 NEW_LINE now = now + ( now + 1 ) * c NEW_LINE DEDENT DEDENT print "" Case ▁ # "" + str ( test + 1 ) + "" : "" , ans NEW_LINE DEDENT +" +E161,"import java . io . IOException ; public class ProblemC extends CodeJammer { public void print ( boolean [ ] [ ] g , int l ) { for ( int i = 0 ; i < l ; i ++ ) { String s = "" "" ; for ( int j = 0 ; j < l ; j ++ ) { if ( g [ i ] [ j ] ) { s += ""1"" ; } else { s += ""0"" ; } } System . out . println ( s ) ; } } @ Override public void process ( ) throws IOException { int r = reader . readInt ( ) ; boolean [ ] [ ] g = new boolean [ 101 ] [ 101 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { for ( int j = 0 ; j < 101 ; j ++ ) { g [ i ] [ j ] = false ; } } for ( int n = 0 ; n < r ; n ++ ) { int [ ] data = reader . readArray ( ) ; for ( int i = data [ 0 ] ; i <= data [ 2 ] ; i ++ ) { for ( int j = data [ 1 ] ; j <= data [ 3 ] ; j ++ ) { g [ i ] [ j ] = true ; } } } long alive = 1 ; int turns = 0 ; while ( alive > 0 ) { alive = 0 ; for ( int s = 200 ; s >= 0 ; s -- ) { for ( int i = 0 ; i <= s && i <= 100 ; i ++ ) { int j = s - i ; if ( j >= 0 && j <= 100 ) { int neighs = 0 ; if ( i > 0 && g [ i - 1 ] [ j ] ) neighs ++ ; if ( j > 0 && g [ i ] [ j - 1 ] ) neighs ++ ; if ( neighs == 0 ) g [ i ] [ j ] = false ; if ( neighs == 2 ) g [ i ] [ j ] = true ; if ( g [ i ] [ j ] ) alive ++ ; } } } turns ++ ; } output ( turns ) ; } public static void main ( String [ ] args ) { ProblemC p = new ProblemC ( ) ; p . run ( args ) ; } } +","from __future__ import division NEW_LINE import collections NEW_LINE import itertools NEW_LINE import sys NEW_LINE import copy NEW_LINE class gcj : NEW_LINE INDENT IN = sys . stdin NEW_LINE number = 0 NEW_LINE @ classmethod NEW_LINE def case ( cls ) : NEW_LINE INDENT cls . number += 1 NEW_LINE return ' Case ▁ # % d : ' % cls . number NEW_LINE DEDENT @ classmethod NEW_LINE def line ( cls , type = str ) : NEW_LINE INDENT line = cls . IN . readline ( ) NEW_LINE return type ( line . strip ( ' \n ' ) ) NEW_LINE DEDENT @ classmethod NEW_LINE def splitline ( cls , type = str ) : NEW_LINE INDENT line = cls . IN . readline ( ) NEW_LINE return [ type ( x ) for x in line . split ( ) ] NEW_LINE DEDENT DEDENT def go ( ) : NEW_LINE INDENT c = gcj . line ( int ) NEW_LINE for _ in xrange ( c ) : NEW_LINE INDENT r = gcj . line ( int ) NEW_LINE grid = [ [ 0 ] * 101 for _ in xrange ( 101 ) ] NEW_LINE for _ in xrange ( r ) : NEW_LINE INDENT x1 , y1 , x2 , y2 = gcj . splitline ( int ) NEW_LINE for x in xrange ( x1 , x2 + 1 ) : NEW_LINE INDENT for y in xrange ( y1 , y2 + 1 ) : NEW_LINE INDENT grid [ x ] [ y ] = 1 NEW_LINE DEDENT DEDENT DEDENT print gcj . case ( ) , solve ( grid ) NEW_LINE DEDENT DEDENT def solve ( grid ) : NEW_LINE INDENT t = 0 NEW_LINE while True : NEW_LINE INDENT done = True NEW_LINE for x in xrange ( 100 , 0 , - 1 ) : NEW_LINE INDENT for y in xrange ( 100 , 0 , - 1 ) : NEW_LINE INDENT if grid [ x ] [ y ] == 1 : NEW_LINE INDENT done = False NEW_LINE DEDENT if grid [ x - 1 ] [ y ] == grid [ x ] [ y - 1 ] : NEW_LINE INDENT grid [ x ] [ y ] = grid [ x ] [ y - 1 ] NEW_LINE DEDENT DEDENT DEDENT if done : NEW_LINE INDENT return t NEW_LINE DEDENT t += 1 NEW_LINE DEDENT DEDENT go ( ) NEW_LINE +" +E162,"import java . util . Scanner ; public class A { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int T = sc . nextInt ( ) ; for ( int i = 1 ; i <= T ; ++ i ) { long N = sc . nextLong ( ) ; System . out . printf ( "" Case ▁ # % d : ▁ % d \n "" , i , solve ( N ) ) ; } } static long solve ( long v ) { if ( v <= 10 ) return v ; int len = ( "" "" + v ) . length ( ) ; long mod = 1 ; for ( int i = 0 ; i < len / 2 ; ++ i ) { mod *= 10 ; } if ( v % mod == 0 ) return solve ( v - 1 ) + 1 ; long add = v % mod - 1 ; v -= add ; long rev = 0 ; long tmp = v ; while ( tmp > 0 ) { rev *= 10 ; rev += tmp % 10 ; tmp /= 10 ; } if ( rev != v ) return solve ( rev ) + add + 1 ; return solve ( v - 1 ) + add + 1 ; } } +","import os , sys , time , random NEW_LINE time . clock ( ) NEW_LINE sys . stdin = open ( ' A - large . in ' ) NEW_LINE sys . stdout = open ( ' A - large . out ' , ' w ' ) NEW_LINE def flip ( x ) : NEW_LINE INDENT return int ( str ( x ) [ : : - 1 ] . lstrip ( '0' ) ) NEW_LINE DEDENT def Preprocess ( ) : NEW_LINE INDENT global f NEW_LINE n = 100002 NEW_LINE f = [ n ] * n NEW_LINE f [ 1 ] = 1 NEW_LINE for i in range ( 1 , n - 1 ) : NEW_LINE INDENT f [ i + 1 ] = min ( f [ i + 1 ] , f [ i ] + 1 ) NEW_LINE if flip ( i ) < n : NEW_LINE INDENT f [ flip ( i ) ] = min ( f [ flip ( i ) ] , f [ i ] + 1 ) NEW_LINE DEDENT DEDENT DEDENT def GetCheckPoint ( x ) : NEW_LINE INDENT l = len ( str ( x ) ) NEW_LINE if str ( x ) . endswith ( '0' * ( l - l // 2 ) ) : NEW_LINE INDENT return GetCheckPoint ( x - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ret = int ( str ( x ) [ : l // 2 ] + '0' * ( l - l // 2 - 1 ) + '1' ) NEW_LINE if str ( x ) [ : l // 2 ] == '1' + '0' * ( l // 2 - 1 ) : NEW_LINE INDENT return GetCheckPoint ( ret - 2 ) NEW_LINE DEDENT return ret NEW_LINE DEDENT DEDENT def Calc ( n ) : NEW_LINE INDENT if n < 100 : return f [ n ] NEW_LINE cp = GetCheckPoint ( n ) NEW_LINE return Calc ( flip ( cp ) ) + 1 + n - cp NEW_LINE DEDENT def Work ( ) : NEW_LINE INDENT n = int ( input ( ) . strip ( ) ) NEW_LINE return Calc ( n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT Preprocess ( ) NEW_LINE T = int ( input ( ) ) NEW_LINE for i in range ( T ) : NEW_LINE INDENT print ( ' Case ▁ # % d : ▁ % d ' % ( i + 1 , Work ( ) ) ) NEW_LINE DEDENT sys . stderr . write ( ' completed ▁ % .3f \n ' % time . clock ( ) ) NEW_LINE DEDENT +" +E163,"import java . util . * ; public class B { static int a , b , k ; static long doit ( ) { int i , j ; long l = 0 ; if ( a < 1001 && b < 1001 && k < 1001 ) { for ( i = 0 ; i < a ; i ++ ) for ( j = 0 ; j < b ; j ++ ) if ( ( i & j ) < k ) l ++ ; } return l ; } public static void main ( String arg [ ] ) throws Exception { int tc , t ; long ans ; Scanner s = new Scanner ( System . in ) ; String line = s . nextLine ( ) ; tc = Integer . parseInt ( line ) ; for ( t = 1 ; t <= tc ; t ++ ) { line = s . nextLine ( ) ; String ss [ ] = line . split ( "" ▁ + "" ) ; a = Integer . parseInt ( ss [ 0 ] ) ; b = Integer . parseInt ( ss [ 1 ] ) ; k = Integer . parseInt ( ss [ 2 ] ) ; ans = doit ( ) ; System . out . println ( "" Case ▁ # "" + t + "" : ▁ "" + ans ) ; } } } +","import sys NEW_LINE from itertools import zip_longest as zip NEW_LINE T = int ( sys . stdin . readline ( ) . strip ( ) ) NEW_LINE for t in range ( T ) : NEW_LINE INDENT A , B , K = tuple ( int ( i ) for i in sys . stdin . readline ( ) . strip ( ) . split ( ) ) NEW_LINE cnt = 0 NEW_LINE for a in range ( A ) : NEW_LINE INDENT for b in range ( B ) : NEW_LINE INDENT if a & b < K : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT DEDENT print ( "" Case ▁ # % d : ▁ % d "" % ( t + 1 , cnt ) ) NEW_LINE DEDENT +" +E164,"import java . util . * ; import java . io . * ; import java . math . * ; public class b { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new FileReader ( args [ 0 ] ) ) ; String str ; int numCases = Integer . parseInt ( br . readLine ( ) ) ; for ( int nCase = 1 ; nCase <= numCases ; nCase ++ ) { String [ ] sa = br . readLine ( ) . split ( "" ▁ "" ) ; int L = Integer . parseInt ( sa [ 0 ] ) ; int P = Integer . parseInt ( sa [ 1 ] ) ; int C = Integer . parseInt ( sa [ 2 ] ) ; double R = ( double ) P / L ; int count = 0 ; while ( R > C ) { R = Math . sqrt ( R ) ; count ++ ; } System . out . println ( "" Case ▁ # "" + nCase + "" : ▁ "" + count ) ; } br . close ( ) ; } } +","import sys NEW_LINE def ntests ( L , P , C ) : NEW_LINE INDENT ratio = P * 1.0 / L NEW_LINE if ratio <= C : return 0 NEW_LINE if L == 1 and P == 3 : return 1 NEW_LINE testpoint = int ( L * ( ratio ** 0.5 ) ) NEW_LINE count = max ( 1 + ntests ( L , testpoint , C ) , 1 + ntests ( testpoint , P , C ) ) NEW_LINE if ( testpoint * testpoint == L * P or testpoint + 1 == P ) : NEW_LINE INDENT return count NEW_LINE DEDENT count2 = max ( 1 + ntests ( L , testpoint + 1 , C ) , 1 + ntests ( testpoint + 1 , P , C ) ) NEW_LINE return min ( count , count2 ) NEW_LINE DEDENT infile = sys . stdin NEW_LINE T = int ( infile . readline ( ) . strip ( ) ) NEW_LINE for i in xrange ( T ) : NEW_LINE INDENT L , P , C = map ( int , infile . readline ( ) . strip ( ) . split ( ) ) NEW_LINE result = ntests ( L , P , C ) NEW_LINE print ( "" Case ▁ # % d : ▁ % s "" % ( i + 1 , str ( result ) ) ) NEW_LINE DEDENT +" +E165,"import java . util . * ; import java . io . * ; public class D { public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( new File ( "" D - large . in "" ) ) ; PrintWriter out = new PrintWriter ( new FileWriter ( new File ( "" D - large . out "" ) ) ) ; int t = in . nextInt ( ) ; for ( int x = 0 ; x < t ; x ++ ) { int n = in . nextInt ( ) ; double [ ] naomi = new double [ n ] ; for ( int y = 0 ; y < n ; y ++ ) { naomi [ y ] = in . nextDouble ( ) ; } double [ ] ken = new double [ n ] ; for ( int z = 0 ; z < n ; z ++ ) { ken [ z ] = in . nextDouble ( ) ; } Arrays . sort ( naomi ) ; Arrays . sort ( ken ) ; int index = 0 ; int win1 = 0 ; for ( int a = 0 ; a < ken . length ; a ++ ) { while ( index < n && naomi [ index ] < ken [ a ] ) { index ++ ; } if ( index < n ) { win1 ++ ; index ++ ; } } index = 0 ; int win2 = 0 ; for ( int b = 0 ; b < naomi . length ; b ++ ) { while ( index < n && ken [ index ] < naomi [ b ] ) { index ++ ; win2 ++ ; } index ++ ; } out . println ( "" Case ▁ # "" + ( x + 1 ) + "" : ▁ "" + win1 + "" ▁ "" + win2 ) ; } out . close ( ) ; } } +","def war ( n , k ) : NEW_LINE INDENT n = [ float ( block ) for block in n . split ( "" ▁ "" ) ] NEW_LINE k = [ float ( block ) for block in k . split ( "" ▁ "" ) ] NEW_LINE points = 0 NEW_LINE n = reversed ( sorted ( n ) ) NEW_LINE for nblock in n : NEW_LINE INDENT if nblock > max ( k ) : NEW_LINE INDENT points += 1 NEW_LINE k . remove ( min ( k ) ) NEW_LINE DEDENT else : NEW_LINE INDENT k . remove ( min ( [ block for block in k if block > nblock ] ) ) NEW_LINE DEDENT DEDENT return str ( points ) NEW_LINE DEDENT def dwar ( n , k ) : NEW_LINE INDENT n = [ float ( block ) for block in n . split ( "" ▁ "" ) ] NEW_LINE k = [ float ( block ) for block in k . split ( "" ▁ "" ) ] NEW_LINE points = 0 NEW_LINE n = sorted ( n ) NEW_LINE for nblock in n : NEW_LINE INDENT if nblock > min ( k ) : NEW_LINE INDENT points += 1 NEW_LINE k . remove ( min ( k ) ) NEW_LINE DEDENT else : NEW_LINE INDENT k . remove ( max ( k ) ) NEW_LINE DEDENT DEDENT return str ( points ) NEW_LINE DEDENT input_text = open ( "" input . in "" ) NEW_LINE lines = input_text . readlines ( ) NEW_LINE input_text . close ( ) NEW_LINE with open ( "" output "" , "" a "" ) as outputfile : NEW_LINE INDENT for num in range ( 0 , int ( lines [ 0 ] ) ) : NEW_LINE INDENT outputfile . write ( "" Case ▁ # "" + str ( num + 1 ) + "" : ▁ "" + dwar ( lines [ num * 3 + 2 ] , lines [ num * 3 + 3 ] ) + "" ▁ "" + war ( lines [ num * 3 + 2 ] , lines [ num * 3 + 3 ] ) + "" \n "" ) NEW_LINE DEDENT DEDENT +" +E166,"import java . util . Arrays ; import java . util . Scanner ; public class Space { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; for ( int i = 1 ; i <= T ; i ++ ) { int L = sc . nextInt ( ) ; long t = sc . nextLong ( ) ; int N = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; long time = t ; int [ ] a = new int [ 1000001 ] ; for ( int j = 0 ; j < C ; j ++ ) { a [ j ] = sc . nextInt ( ) ; } for ( int j = C ; j < N ; j ++ ) { a [ j ] = a [ j - C ] ; } int index = 0 ; while ( t > 0 && index < N ) { if ( a [ index ] > ( t / 2 ) ) { a [ index ] -= t / 2 ; t = - 1 ; } else { t -= a [ index ] * 2 ; index ++ ; } } if ( t > 0 ) { time -= t ; } if ( index < N ) { Arrays . sort ( a , index , ( int ) N ) ; for ( int j = ( int ) ( N - 1 ) ; j >= index ; j -- ) { if ( L > 0 ) { time += a [ j ] ; L -- ; } else { time += a [ j ] * 2 ; } } } System . out . println ( "" Case ▁ # "" + i + "" : ▁ "" + time ) ; } } } +","import sys NEW_LINE from itertools import islice NEW_LINE def solve ( L , t , N , C , a ) : NEW_LINE INDENT tot_dist = 0 NEW_LINE eff_dists = [ ] NEW_LINE for s in xrange ( N ) : NEW_LINE INDENT d = a [ s % len ( a ) ] NEW_LINE if tot_dist + d <= t : NEW_LINE INDENT eff_dists . append ( ( d , 0 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT if tot_dist >= t : NEW_LINE INDENT eff_dists . append ( ( d , d ) ) NEW_LINE DEDENT else : NEW_LINE INDENT eff_dists . append ( ( d , d - ( t - tot_dist ) ) ) NEW_LINE DEDENT DEDENT tot_dist += d NEW_LINE DEDENT tot_time = 0 NEW_LINE for dist , eff_dist in sorted ( eff_dists , key = lambda x : x [ 1 ] , reverse = True ) : NEW_LINE INDENT if L > 0 : NEW_LINE INDENT tot_time += eff_dist + 2 * ( dist - eff_dist ) NEW_LINE L -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT tot_time += dist * 2 NEW_LINE DEDENT DEDENT return tot_time // 2 NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT T = int ( next ( sys . stdin ) ) NEW_LINE for test in xrange ( 1 , T + 1 ) : NEW_LINE INDENT print >> sys . stderr , test NEW_LINE line = next ( sys . stdin ) NEW_LINE L , t , N , C , a = line . split ( None , 4 ) NEW_LINE L , t , N , C = map ( int , ( L , t , N , C ) ) NEW_LINE a = list ( int ( ai ) * 2 for ai in a . split ( ) ) NEW_LINE print "" Case ▁ # % s : ▁ % s "" % ( test , solve ( L , t , N , C , a ) ) NEW_LINE DEDENT DEDENT main ( ) NEW_LINE +" +E167,"package c_2015 ; import java . util . Scanner ; public class B { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int kases = in . nextInt ( ) ; for ( int kas = 1 ; kas <= kases ; kas ++ ) { int K = in . nextInt ( ) ; int L = in . nextInt ( ) ; int S = in . nextInt ( ) ; String keyboard = in . next ( ) ; String target = in . next ( ) ; int [ ] keys = new int [ 26 ] ; for ( int i = 0 ; i < K ; i ++ ) keys [ keyboard . charAt ( i ) - ' A ' ] ++ ; boolean possible = true ; for ( int i = 0 ; i < L ; i ++ ) if ( keys [ target . charAt ( i ) - ' A ' ] == 0 ) possible = false ; if ( ! possible ) { System . out . println ( "" Case ▁ # "" + kas + "" : ▁ 0.0"" ) ; continue ; } int [ ] EV = new int [ S ] ; int p ; outer : for ( p = L - 1 ; p > 0 ; p -- ) { for ( int i = 0 ; i < p ; i ++ ) { if ( target . charAt ( i ) != target . charAt ( L - p + i ) ) continue outer ; } break ; } int max = ( S - p ) / ( L - p ) ; double prob_word = 1 ; for ( int i = 0 ; i < L ; i ++ ) { prob_word *= keys [ target . charAt ( i ) - ' A ' ] / ( 0.0 + K ) ; } System . out . println ( "" Case ▁ # "" + kas + "" : ▁ "" + ( max - prob_word * ( S - L + 1 ) ) ) ; } } } +","import sys NEW_LINE import math NEW_LINE from collections import defaultdict NEW_LINE f = open ( ' B - large . in ' ) NEW_LINE tests = int ( f . readline ( ) ) NEW_LINE def getOffset ( keys , target ) : NEW_LINE INDENT s = set ( list ( keys ) ) NEW_LINE for c in target : NEW_LINE INDENT if c not in s : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT offset = 1 NEW_LINE while offset < len ( target ) : NEW_LINE INDENT if target [ : len ( target ) - offset ] == target [ offset : ] : NEW_LINE INDENT break NEW_LINE DEDENT offset += 1 NEW_LINE DEDENT return offset NEW_LINE DEDENT def getExp ( keys , target , s ) : NEW_LINE INDENT d = defaultdict ( lambda : 0.0 ) NEW_LINE for c in keys : NEW_LINE INDENT d [ c ] += 1.0 / len ( keys ) NEW_LINE DEDENT tot = 1.0 NEW_LINE for c in target : NEW_LINE INDENT tot *= d [ c ] NEW_LINE DEDENT return tot * ( s - len ( target ) + 1 ) NEW_LINE DEDENT for t in xrange ( tests ) : NEW_LINE INDENT k , l , s = map ( int , f . readline ( ) . rstrip ( ) . split ( ) ) NEW_LINE keys = f . readline ( ) . rstrip ( ) NEW_LINE target = f . readline ( ) . rstrip ( ) NEW_LINE offset = getOffset ( keys , target ) NEW_LINE if offset == 0 : NEW_LINE INDENT print "" Case ▁ # "" + str ( t + 1 ) + "" : ▁ 0.0"" NEW_LINE continue NEW_LINE DEDENT needed = 1 + ( s - len ( target ) ) // offset NEW_LINE ans = max ( 0.0 , needed - getExp ( keys , target , s ) ) NEW_LINE if ans < 0.000000001 : NEW_LINE INDENT ans = 0.0 NEW_LINE DEDENT print "" Case ▁ # "" + str ( t + 1 ) + "" : ▁ "" + str ( ans ) NEW_LINE DEDENT +" +E168,"import java . util . * ; import java . io . * ; public class SolB implements Runnable { public static void main ( String [ ] args ) { new Thread ( new SolB ( ) ) . start ( ) ; } @ Override public void run ( ) { try { br = new BufferedReader ( new FileReader ( FNAME + "" . in "" ) ) ; out = new PrintWriter ( FNAME + "" . out "" ) ; solve ( ) ; out . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } BufferedReader br ; StringTokenizer st ; PrintWriter out ; boolean eof = false ; String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { eof = true ; return ""0"" ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } private final String FNAME = "" B - small - attempt0"" ; int [ ] dx = new int [ ] { - 1 , 0 , 0 , 1 } ; int [ ] dy = new int [ ] { 0 , - 1 , 1 , 0 } ; char [ ] dirch = new char [ ] { ' W ' , ' S ' , ' N ' , ' E ' } ; void solve ( ) { int tests = nextInt ( ) ; for ( int test = 1 ; test <= tests ; test ++ ) { out . print ( "" Case ▁ # "" + test + "" : ▁ "" ) ; int xf = nextInt ( ) ; int yf = nextInt ( ) ; String ans = "" "" ; for ( int i = 0 ; i < Math . abs ( xf ) ; i ++ ) { if ( xf < 0 ) { ans += "" EW "" ; } else { ans += "" WE "" ; } } for ( int i = 0 ; i < Math . abs ( yf ) ; i ++ ) { if ( yf < 0 ) { ans += "" NS "" ; } else { ans += "" SN "" ; } } out . println ( ans ) ; } } } +","import sys NEW_LINE T = int ( sys . stdin . readline ( ) ) NEW_LINE for ca in xrange ( 1 , T + 1 ) : NEW_LINE INDENT [ X , Y ] = [ int ( v ) for v in sys . stdin . readline ( ) . split ( "" ▁ "" ) ] NEW_LINE print "" Case ▁ # % d : ▁ "" % ca , NEW_LINE if X > 0 : NEW_LINE INDENT for i in range ( X ) : NEW_LINE INDENT sys . stdout . write ( "" W "" ) , NEW_LINE sys . stdout . write ( "" E "" ) , NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT X = - X NEW_LINE for i in range ( X ) : NEW_LINE INDENT sys . stdout . write ( "" E "" ) , NEW_LINE sys . stdout . write ( "" W "" ) , NEW_LINE DEDENT DEDENT if Y > 0 : NEW_LINE INDENT for i in range ( Y ) : NEW_LINE INDENT sys . stdout . write ( "" S "" ) , NEW_LINE sys . stdout . write ( "" N "" ) , NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT Y = - Y NEW_LINE for i in range ( Y ) : NEW_LINE INDENT sys . stdout . write ( "" N "" ) , NEW_LINE sys . stdout . write ( "" S "" ) , NEW_LINE DEDENT DEDENT print "" "" NEW_LINE DEDENT +" +E169,"import java . io . * ; import java . util . * ;    public class Main { public static Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) , 640000 ) ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;    public static void solve ( ) { String s = in . next ( ) ; s += ' ; ' ;    boolean isNumber = true ; boolean first = true ; boolean leadingZero = false ; StringBuilder part = new StringBuilder ( ) ; +","import re     def is_int ( s : str ) -> bool : if len ( s ) > 0 and ( s [ 0 ] == ""0"" and len ( s ) > 1 ) : return False else : try : int ( s ) return True except : return False     def partition ( pred , iterable ) : trues = [ ] falses = [ ] for item in iterable : if pred ( item ) : trues . append ( item ) else : falses . append ( item ) return trues , falses     def print_ans ( s ) : if len ( s ) > 0 : print ( "" \ "" { } \ "" "" . format ( "" , "" . join ( s ) ) ) else : print ( "" - "" )     s = re . split ( "" ; | , "" , input ( ) ) s_int , s_str = partition ( is_int , s ) print_ans ( s_int ) print_ans ( s_str ) NEW_LINE +" +E170,"import java . util . Scanner ;   public class A1207 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int r = 0 ; int b = scanner . nextInt ( ) , p = scanner . nextInt ( ) , f = scanner . nextInt ( ) ; int h = scanner . nextInt ( ) , c = scanner . nextInt ( ) ; if ( h > c ) { if ( b / 2 >= p ) { r = p * h ; b = b / 2 - p ; if ( b > f ) { r += f * c ; } else { r += b * c ; } } else { r = b / 2 * h ; } } else { if ( b / 2 >= f ) { r = f * c ; b = b / 2 - f ; if ( b > p ) { r += p * h ; } else { r += b * h ; } } else { r = b / 2 * c ; } } System . out . println ( r ) ; } } } +","def solve ( ) : b , p , f = map ( int , input ( ) . split ( ) ) h , c = map ( int , input ( ) . split ( ) )   NEW_LINE +" +E171,"import java . util . * ;   public class Absolutezero { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String [ ] s1 = s . split ( "" : "" ) ; String [ ] t1 = t . split ( "" : "" ) ; int h1 = Integer . parseInt ( s1 [ 0 ] ) ; int m1 = Integer . parseInt ( s1 [ 1 ] ) ;   int h2 = Integer . parseInt ( t1 [ 0 ] ) ; int m2 = Integer . parseInt ( t1 [ 1 ] ) ;   +","a = input ( ) . split ( ' : ' ) b = input ( ) . split ( ' : ' )       x = int ( a [ 0 ] ) * 60 + int ( a [ 1 ] ) y = int ( b [ 0 ] ) * 60 + int ( b [ 1 ] )     if y > x : x = ( ( int ( a [ 0 ] ) + 24 ) * 60 ) + int ( a [ 1 ] )     z = x - y   hr = str ( z // 60 ) . rjust ( 2 , '0' ) z %= 60 mi = str ( z ) . rjust ( 2 , '0' )   print ( f "" { hr } : { mi } "" )   NEW_LINE +" +E172,"import java . lang . * ; import java . util . * ;   public class Abhishek {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } int m = sc . nextInt ( ) ; int [ ] g = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { g [ i ] = sc . nextInt ( ) ; } Arrays . sort ( b ) ; Arrays . sort ( g ) ; int i = 0 , j = 0 , count = 0 ; while ( i < n && j < m ) { if ( Math . abs ( b [ i ] - g [ j ] ) <= 1 ) { count ++ ; i ++ ; j ++ ; } else if ( b [ i ] < g [ j ] ) { i ++ ; } else { j ++ ; } } System . out . println ( count ) ;   }   } +","n = int ( input ( ) ) nn = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) mm = list ( map ( int , input ( ) . split ( ) ) ) nn . sort ( ) mm . sort ( ) i = 0j = 0 count = 0   while i < n and j < m : if abs ( nn [ i ] - mm [ j ] ) <= 1 : count += 1 i += 1 j += 1 elif nn [ i ] < mm [ j ] : i += 1 else : j += 1 print ( count ) NEW_LINE +" +E173,"import java . util . Scanner ;   public class Vsa {   public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ; System . out . println ( ( n % 2 == 0 ) ? "" Mahmoud "" : "" Ehab "" ) ;   } } +","n = int ( input ( ) )   if n == 1 : print ( ' Ehab ' ) elif n % 2 == 0 : print ( ' Mahmoud ' ) else : print ( ' Ehab ' ) NEW_LINE +" +E174,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; int c [ ] = new int [ n ] ; int d [ ] = new int [ 2 ] ; boolean num [ ] = new boolean [ n + 1 ] ;   for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; c [ i ] = a [ i ] ; num [ i ] = false ; }   for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; }   int flag = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != b [ i ] ) { d [ flag ] = i ; flag ++ ; } else { num [ a [ i ] ] = true ; num [ b [ i ] ] = true ; } }   if ( flag == 2 ) { if ( num [ a [ d [ 1 ] ] ] || num [ b [ d [ 0 ] ] ] ) { a [ d [ 1 ] ] = b [ d [ 1 ] ] ; } else { a [ d [ 0 ] ] = b [ d [ 0 ] ] ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] + "" ▁ "" ) ; } } if ( flag == 1 ) { for ( int i = 1 ; i <= n ; i ++ ) { if ( num [ i ] != true ) { a [ d [ 0 ] ] = i ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] + "" ▁ "" ) ; } }    }   } +","import sysinput = sys . stdin . buffer . readline   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) )   ''' diffs ▁ = [ ] miss ▁ = ▁ set ( list ( range ( 1 , n + 1 ) ) ) for ▁ i ▁ in ▁ range ( n ) : ▁ ▁ ▁ ▁ if ▁ a [ i ] ▁ ! = ▁ b [ i ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ diffs . append ( i ) ▁ ▁ ▁ ▁ miss . discard ( a [ i ] )  if ▁ len ( diffs ) ▁ = = ▁ 1 : ▁ ▁ ▁ ▁ # ▁ no ▁ other ▁ option ▁ ▁ ▁ ▁ a [ diffs [ 0 ] ] ▁ = ▁ list ( miss ) [0 ] else : ▁ ▁ ▁ ▁ # ▁ must ▁ be ▁ 2 ▁ ▁ ▁ ▁ if ▁ { a [ diffs [ 0 ] ] , b [ diffs [ 1 ] ] } ▁ = = ▁ miss : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ a [ diffs [ 1 ] ] ▁ = ▁ b [ diffs [ 1 ] ] ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ a [ diffs [ 0 ] ] ▁ = ▁ b [ diffs [ 0 ] ] '''   two = - 1 missing = - 1   counts = [ [ ] for i in range ( n + 1 ) ] for i in range ( n ) : counts [ a [ i ] ] . append ( i ) if len ( counts [ a [ i ] ] ) == 2 : two = a [ i ]   for i in range ( 1 , n + 1 ) : if len ( counts [ i ] ) == 0 : missing = i break   def diff ( a , b ) : diffs = 0 for i in range ( n ) : diffs += a [ i ] != b [ i ] return diffs   for i in range ( 2 ) : perm = a . copy ( ) perm [ counts [ two ] [ i ] ] = missing   if diff ( perm , b ) == 1 : print ( * perm ) break NEW_LINE +" +E175,"import java . util . Scanner ;   public class TrafficLights {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int l = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int v = sc . nextInt ( ) ; int g = sc . nextInt ( ) ; int r = sc . nextInt ( ) ;   double ans = l * 1.0 / v ; double v1 = ( d * 1.0 / v ) % ( g + r ) ; if ( v1 >= g ) ans += g + r - v1 ;   System . out . println ( ans ) ; } } +","import sysimport mathdef fn ( l , d , v , g , r ) : t = float ( d ) / float ( v ) if t < g : return float ( l ) / float ( v ) elif t <= g + r : t = g + r return t + ( float ( l ) - float ( d ) ) / float ( v ) elif t > g + r : t1 = t k = t // ( g + r ) t = t - k * ( g + r ) if t < g : return float ( l ) / float ( v ) elif t <= g + r : t = g + r return ( k + 1 ) * t + ( float ( l ) - float ( d ) ) / float ( v ) if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) l = ( data [ 0 ] ) d = data [ 1 ] v = data [ 2 ] g = data [ 3 ] r = data [ 4 ] print ( fn ( l , d , v , g , r ) ) NEW_LINE +" +E176,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class NiceTable {   static int [ ] [ ] bestAns ; static int leastChanged ; static int w , h ; public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; h = fs . nextInt ( ) ; w = fs . nextInt ( ) ; int [ ] [ ] board = new int [ w ] [ h ] ; String letters = "" ACGT "" ; for ( int y = 0 ; y < h ; y ++ ) { String next = fs . next ( ) ; for ( int x = 0 ; x < w ; x ++ ) { board [ x ] [ y ] = letters . indexOf ( next . charAt ( x ) + "" "" ) ; } } leastChanged = w * h ; solveHLines ( board , 0 , 1 ) ; solveHLines ( board , 0 , 2 ) ; solveHLines ( board , 0 , 3 ) ; solveHLines ( board , 1 , 2 ) ; solveHLines ( board , 1 , 3 ) ; solveHLines ( board , 2 , 3 ) ; solveVLines ( board , 0 , 1 ) ; solveVLines ( board , 0 , 2 ) ; solveVLines ( board , 0 , 3 ) ; solveVLines ( board , 1 , 2 ) ; solveVLines ( board , 1 , 3 ) ; solveVLines ( board , 2 , 3 ) ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int y = 0 ; y < h ; y ++ ) { for ( int x = 0 ; x < w ; x ++ ) { char toPrint = letters . charAt ( bestAns [ x ] [ y ] ) ; out . print ( toPrint ) ; } out . println ( ) ; } out . close ( ) ; +","from itertools import permutationsfrom sys import stdin , stdoutly , lx = map ( int , input ( ) . split ( ) ) grid = [ [ c for c in inp ] for inp in stdin . read ( ) . splitlines ( ) ]   first = set ( ) bl = [ ] bpattern = [ ] bcost = 1e6 flip_row = False   for l in permutations ( ' AGCT ' ) : if bcost == 0 : break if ' ' . join ( l [ : 2 ] ) in first : continue   first |= set ( [ ' ' . join ( l [ : 2 ] ) , ' ' . join ( l [ 1 : : - 1 ] ) ] ) NEW_LINE +" +E177,"   import java . io . * ; import java . util . * ; public class pt { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int b2 = sc . nextInt ( ) ; int c2 = sc . nextInt ( ) ; if ( a == 0 && b == 0 && a2 == 0 && b2 == 0 ) { if ( c == 0 && c2 == 0 ) out . println ( "" - 1"" ) ; else out . println ( ""0"" ) ; } else if ( a * b2 == b * a2 ) { if ( c * b2 == b * c2 && c * a2 == a * c2 ) out . println ( "" - 1"" ) ; else out . println ( ""0"" ) ; } else { out . println ( ""1"" ) ; }   out . flush ( ) ; }   static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } +","line1 = input ( ) . split ( "" ▁ "" ) line2 = input ( ) . split ( "" ▁ "" ) A1 = int ( line1 [ 0 ] ) A2 = int ( line2 [ 0 ] ) B1 = int ( line1 [ 1 ] ) B2 = int ( line2 [ 1 ] ) C1 = int ( line1 [ 2 ] ) C2 = int ( line2 [ 2 ] )   Z = lambda x , y , z : not x and not y and z   if A1 * B2 - A2 * B1 : print ( 1 ) elif Z ( A1 , B1 , C1 ) or Z ( A2 , B2 , C2 ) or ( C1 * B2 - C2 * B1 ) or ( A1 * C2 - A2 * C1 ) : print ( 0 ) else : print ( - 1 )   NEW_LINE +" +E178,"import java . util . * ; import java . io . * ;   public class Codeforces {   InputStream is ; PrintWriter out ; String INPUT = "" "" ;   +","import sysinput = sys . stdin . readline   from bisect import bisect_left as bs   '''   '''   def solve ( n , a ) : b = a [ : : ] b . sort ( ) done = [ 0 ] * n   res = [ ] for i in range ( n ) : if not done [ i ] : if a [ i ] == b [ i ] : res . append ( [ i + 1 ] ) done [ i ] = 1 else : r = [ ] while not done [ i ] : r . append ( i + 1 ) done [ i ] = 1 i = bs ( b , a [ i ] ) res . append ( r ) return res   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   res = solve ( n , a ) print ( len ( res ) ) for r in res : print ( len ( r ) , * r ) NEW_LINE +" +E179,"import java . util . * ; import java . io . * ; public class EdE { static long [ ] mods = { 1000000007 , 998244353 , 1000000009 } ; static long mod = mods [ 0 ] ; public static MyScanner sc ; public static PrintWriter out ; public static void main ( String [ ] omkar ) throws Exception { +","for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) s = input ( ) m = n - 1 for i in range ( n ) : if s [ i ] == ' > ' or s [ n - 1 - i ] == ' < ' : m = min ( m , i ) print ( m ) NEW_LINE +" +E180,"import java . util . * ; import java . io . * ; import java . math . * ;   public class Main { static PrintWriter pw = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) throws IOException , InterruptedException { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; w : while ( t -- > 0 ) { int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) , f = sc . next ( ) . toCharArray ( ) ; pair [ ] q = new pair [ m ] ; for ( int i = 0 ; i < q . length ; i ++ ) { q [ i ] = new pair ( sc . nextInt ( ) , sc . nextInt ( ) ) ; } int N = 1 ; while ( N < n ) N <<= 1 ; +","import sys , io , os NEW_LINE if os . environ [ ' USERNAME ' ] == ' kissz ' : inp1 = inp2 = open ( ' in . txt ' , ' r ' ) . readline NEW_LINE def debug ( * args ) : print ( * args , file = sys . stderr ) NEW_LINE else : NEW_LINE +" +E181,"import java . util . * ; import java . io . * ; public class Main2 { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static FastReader sc = new FastReader ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { int z = 1 ; +","import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE +" +E182,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Maximizer { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( reader . readLine ( ) ) ;   String num = st . nextToken ( ) ; int n = num . length ( ) ; char [ ] a = num . toCharArray ( ) ;   int k = Integer . parseInt ( st . nextToken ( ) ) ;   for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( k == 0 ) break ; int max = i ;   for ( int j = i + 1 ; j < i + k + 1 && j < n ; j ++ ) if ( a [ j ] > a [ max ] ) max = j ;   int ok = max - i ; if ( ok > 0 ) { char x = a [ max ] ; while ( max > i ) { a [ max ] = a [ max - 1 ] ; max -- ; } a [ max ] = x ; k -= ok ; } }   StringBuilder ans = new StringBuilder ( ) ;   for ( int i = 0 ; i < n ; i ++ ) { ans . append ( a [ i ] ) ; }   System . out . println ( ans ) ; } } +","n , k = map ( int , input ( ) . split ( ) ) ; s = [ i for i in str ( n ) ] ; i = 0 n = len ( s ) for i in range ( n ) : x = i for j in range ( i + 1 , min ( n , i + k + 1 ) ) : if s [ x ] < s [ j ] : x = j NEW_LINE +" +E183,"import java . util . Scanner ;   public class Balanced_Matrix {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int t = in . nextInt ( ) ; int n ; while ( t -- != 0 ) { n = in . nextInt ( ) ; if ( n % 4 != 0 ) { System . out . println ( "" NO "" ) ; } else { System . out . println ( "" YES "" ) ; for ( int i = 2 ; i <= n ; i += 2 ) { System . out . print ( i + "" ▁ "" ) ; }   for ( int i = 1 ; i < n - 1 ; i += 2 ) { System . out . print ( i + "" ▁ "" ) ; } System . out . println ( n + n / 2 - 1 ) ; }   }   }   } +","for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) if ( n * ( n - 1 ) / 2 ) % 2 == 0 : a = list ( range ( 2 , n + 1 , 2 ) ) b = list ( range ( 1 , n - 1 , 2 ) ) print ( "" YES "" ) print ( * list ( a + b + [ sum ( a ) - sum ( b ) ] ) ) else : print ( "" NO "" ) NEW_LINE +" +E184,"import java . util . * ; import java . lang . * ; import java . io . * ; public class Choosing_Symbol_Pairs {   public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; Map < Character , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( m . containsKey ( s . charAt ( i ) ) ) m . put ( s . charAt ( i ) , m . get ( s . charAt ( i ) ) + 1 ) ; else m . put ( s . charAt ( i ) , 1 ) ; } long ans = 0 ; for ( Character c : m . keySet ( ) ) ans += Math . pow ( m . get ( c ) , 2 ) ; System . out . println ( ans ) ; }   } +","word = input ( ) ans = 0 num = { }   for i in word : num [ i ] = num . get ( i , 0 ) + 1   for j in num . values ( ) : ans += j ** 2   print ( ans ) NEW_LINE +" +E185,"import java . util . ArrayList ; import java . util . Collections ; import java . util . HashSet ; import java . util . Scanner ;   public class bingo { static class Joe implements Comparable < Joe > { ArrayList < Integer > list ; int ogIndex ; public Joe ( ArrayList < Integer > list , int ogIndex ) { this . list = list ; this . ogIndex = ogIndex ; } @ Override public int compareTo ( Joe other ) { int min = Math . min ( list . size ( ) , other . list . size ( ) ) ; for ( int i = 0 ; i < min ; i ++ ) { if ( list . get ( i ) != other . list . get ( i ) ) return list . get ( i ) - other . list . get ( i ) ; } return other . list . size ( ) - list . size ( ) ; } public boolean isSuperSet ( Joe in ) { if ( in . list . size ( ) > list . size ( ) ) return false ; HashSet < Integer > inSet = new HashSet < Integer > ( ) ; for ( int e : list ) inSet . add ( e ) ; for ( int e : in . list ) if ( ! inSet . contains ( e ) ) return false ; return true ; } public String toString ( ) { return list . toString ( ) ; } } public static void main ( String [ ] args ) { +","from sys import stdin , stdoutfrom os import pathif path . exists ( "" input . txt "" ) : stdin = open ( "" input . txt "" , ' r ' ) wr = stdout . writerd = lambda : stdin . readline ( ) . strip ( ) NEW_LINE +" +E186,"import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; import java . util . Vector ; import javafx . util . Pair ;   public class NewClass {   static int n11 = 100000 ; static boolean a11 [ ] = new boolean [ n11 + 1 ] ; static Vector < Long > v11 = new Vector ( ) ;   static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; }   static void seive ( ) { +","for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE l = list ( ) NEW_LINE for i in range ( n ) : x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l . append ( x ) NEW_LINE for i in l : c = 1 NEW_LINE for j in l : if NEW_LINE abs ( i [ 0 ] - j [ 0 ] ) + abs ( i [ 1 ] - j [ 1 ] ) > k : c = 0 NEW_LINE break NEW_LINE if c == 1 : print ( 1 ) NEW_LINE break NEW_LINE if c == 0 : print ( - 1 )   NEW_LINE +" +E187,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class CF749A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( n / 2 ) ; for ( int i = 1 ; i < n / 2 ; i ++ ) { System . out . print ( ""2 ▁ "" ) ; } System . out . print ( ( n & 1 ) == 0 ? 2 : 3 ) ; }   } +","n = int ( input ( ) ) if n % 2 == 0 : print ( n // 2 ) print ( '2 ▁ ' * ( n // 2 ) ) else : n = n - 3 print ( n // 2 + 1 ) print ( '2 ▁ ' * ( n // 2 ) + '3' ) NEW_LINE +" +E188,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","import mathinfo = [ int ( x ) for x in input ( ) . split ( ) ] lanes = info [ 0 ] desks = info [ 1 ] location = info [ 2 ] seats_in_lane = 2 * deskslane = math . ceil ( location / seats_in_lane ) starting_group = ( ( lane - 1 ) * seats_in_lane ) + 1 NEW_LINE +" +E189,"import java . util . * ;   public class M_Round_4 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   +","for _ in range ( int ( input ( ) ) ) : input ( ) NEW_LINE n = [ i for i in input ( ) ] NEW_LINE n . sort ( ) NEW_LINE print ( "" "" . join ( n ) ) NEW_LINE +" +E190,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Codeforces {   private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ;   public static int [ ] LPS ( String p ) { int [ ] lps = new int [ p . length ( ) ] ;   int i = 1 ; int j = 0 ; while ( i < p . length ( ) ) { if ( p . charAt ( i ) == p . charAt ( j ) ) { lps [ i ] = j + 1 ; i ++ ; j ++ ; } else { if ( j == 0 ) { lps [ i ] = 0 ; i ++ ; } else { j = lps [ j - 1 ] ; } } } return lps ; }   public static void KMP ( String text , String pattern ) { int [ ] lps = LPS ( pattern ) ; int i = 0 ; int j = 0 ; ArrayList < Integer > matches = new ArrayList < > ( ) ; while ( i < text . length ( ) ) { if ( text . charAt ( i ) == pattern . charAt ( j ) ) { i ++ ; j ++ ; } else { if ( j != 0 ) { j = lps [ j - 1 ] ; } else { i ++ ; } } if ( j == pattern . length ( ) ) { matches . add ( i - j ) ; j = lps [ j - 1 ] ; } } for ( int x : matches ) { System . out . println ( "" Match ▁ at ▁ : ▁ "" + x ) ; } }   private static class SegmentTree { private long [ ] st ; private int size ; private int n ; private long [ ] a ; SegmentTree ( long [ ] a , int n ) { this . size = 4 * n ; this . n = n ; this . a = a ; st = new long [ size ] ; +","def gcd ( a , b ) : while a % b : a , b = b , a % b return ba , b = map ( int , input ( ) . split ( ) ) g = gcd ( a , b ) a //= gb //= gcnt = 0 for i in [ 2 , 3 , 5 ] : while a % i == 0 : a //= i cnt += 1 while b % i == 0 : b //= i cnt += 1 if a == 1 and b == 1 : print ( cnt ) else : print ( - 1 ) NEW_LINE +" +E191,"import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . * ;   public class cp { static BufferedReader br ; static StringTokenizer st ;   public static void main ( String [ ] args ) throws IOException {   br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   st = readLine ( ) ; int n = tokenInt ( ) ; int t = tokenInt ( ) ;   st = readLine ( ) ; int [ ] array = readIntArray ( n ) ;   +","n , t = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) i = 1 while i < t : i += a [ i - 1 ] print ( ' YES ' if i == t else ' NO ' ) NEW_LINE +" +E192,"import java . util . * ; public class VanyaL { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int l = s . nextInt ( ) ; double [ ] arr = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } Arrays . sort ( arr ) ; double dis = arr [ 0 ] - 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { double k = ( arr [ i + 1 ] - arr [ i ] ) / 2 ; if ( k > dis ) { dis = k ; } } if ( ( l - arr [ n - 1 ] ) > dis ) { dis = l - arr [ n - 1 ] ; } System . out . println ( dis ) ; } } +","n , l = map ( int , input ( ) . split ( ) ) lights = sorted ( list ( map ( int , input ( ) . split ( ) ) ) , reverse = True )   max_dif = 0   for i in range ( len ( lights ) - 1 ) : max_dif = max ( max_dif , lights [ i ] - lights [ i + 1 ] )   print ( format ( max ( max_dif / 2 , lights [ - 1 ] , l - lights [ 0 ] ) , ' . 10f ' ) ) NEW_LINE +" +E193,"import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ;     public class DivisibilitySeven {   public static void main ( String [ ] args ) {   InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader sc = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Solver solver = new Solver ( ) ; +","n = [ int ( i ) for i in input ( ) ] for x in [ 1 , 6 , 8 , 9 ] : for i in range ( len ( n ) ) : if n [ i ] == x : del n [ i ] break   prefix = [ 1869 , 6189 , 1689 , 6198 , 1698 , 9861 , 1896 ] res = sum ( [ n [ i ] * pow ( 10 , len ( n ) - i - 1 , 7 ) for i in range ( len ( n ) ) ] ) print ( prefix [ - res * pow ( 10 , 5 * len ( n ) , 7 ) % 7 ] , end = ' ' ) print ( * n , sep = ' ' ) NEW_LINE +" +E194,"import java . util . * ; public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int i = 0 ; int j = 0 ; int t = sc . nextInt ( ) ; for ( int f = 0 ; f < t ; f ++ ) {   int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int count = 0 ; int [ ] row = new int [ n ] ; int [ ] column = new int [ m ] ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { int current = sc . nextInt ( ) ; if ( current == 1 ) { row [ i ] = 1 ; column [ j ] = 1 ; } } } for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( row [ i ] == 0 && column [ j ] == 0 ) { count ++ ; row [ i ] = 1 ; column [ j ] = 1 ; } } } if ( count % 2 == 0 ) { System . out . println ( "" Vivek "" ) ; } else { System . out . println ( "" Ashish "" ) ; }   count = 0 ; }   sc . close ( ) ; }   } +","t = int ( input ( ) ) s = [ ] for i in range ( t ) : k = 0 x = list ( map ( int , input ( ) . split ( ) ) ) n = x [ 0 ] m = x [ 1 ] indices1 = [ ] mylist = [ ] for j in range ( n ) : y = list ( map ( str , input ( ) . split ( ) ) ) indices = [ o for o , z in enumerate ( y ) if z == ""1"" ] NEW_LINE +" +E195,"import java . util . * ; public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int sum = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ch = s . charAt ( i ) ; int x = Character . getNumericValue ( ch ) ; if ( ( x & 1 ) == 0 ) { sum += i + 1 ; } } System . out . println ( sum ) ;   } } +","n = int ( input ( ) ) s = str ( input ( ) ) ans = 0 for i in range ( n ) : if int ( s [ i ] ) % 2 == 0 : ans += ( i + 1 ) print ( ans ) NEW_LINE +" +E196,"import java . io . * ; import java . util . * ; public class CF1361B {   static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } static int MOD = 1000000007 ; public static void main ( String [ ] args ) { FastReader br = new FastReader ( ) ; int T = br . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; int n , p = 0 ; int [ ] a = new int [ 0 ] ; int num = 0 ; int cur = 0 ; long ans = 0 ; +","from math import log2   def main ( ) : t = int ( input ( ) ) allAns = [ ] MOD = 10 ** 9 + 7 for _ in range ( t ) : n , p = readIntArr ( ) a = readIntArr ( ) if p == 1 : NEW_LINE +" +E197,"import java . util . * ; import java . io . * ; public class Main implements Runnable { FastScanner sc ; PrintWriter pw ; final class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { try { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } public long nlo ( ) { return Long . parseLong ( next ( ) ) ; } public String next ( ) { if ( st . hasMoreTokens ( ) ) return st . nextToken ( ) ; try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } public int ni ( ) { return Integer . parseInt ( next ( ) ) ; } public String nli ( ) { String line = "" "" ; if ( st . hasMoreTokens ( ) ) line = st . nextToken ( ) ; else try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } while ( st . hasMoreTokens ( ) ) line += "" ▁ "" + st . nextToken ( ) ; return line ; } public double nd ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { new Thread ( null , new Main ( ) , "" codeforces "" , 1 << 25 ) . start ( ) ; } public void run ( ) { sc = new FastScanner ( ) ; pw = new PrintWriter ( System . out ) ; solve ( ) ; pw . flush ( ) ; pw . close ( ) ; } public long gcd ( long a , long b ) { return b == 0L ? a : gcd ( b , a % b ) ; } public long ppow ( long a , long b , long mod ) { if ( b == 0L ) return 1L ; long tmp = 1 ; while ( b > 1L ) { if ( ( b & 1L ) == 1 ) tmp *= a ; a *= a ; a %= mod ; tmp %= mod ; b >>= 1 ; } return ( tmp * a ) % mod ; } +","def isquare ( n ) : h = n l = 1 while h - l > 1 : m = ( h + l ) // 2 if m * m <= n : l = m elif m * m > n : h = m return la , b = map ( int , input ( ) . split ( ) ) lsta = [ ] lstb = [ ] for i in range ( 3 , a ) : if isquare ( a * a - i * i ) ** 2 == a * a - i * i : lsta . append ( [ i , isquare ( a * a - i * i ) ] ) for i in range ( 3 , b ) : if isquare ( b * b - i * i ) ** 2 == b * b - i * i : lstb . append ( [ i , isquare ( b * b - i * i ) ] ) flag = Falsefor p , q in lsta : for r , s in lstb : if p * r == q * s : if q == s : p , q , r , s = p , q , r , - s else : p , q , r , s = p , q , - r , s flag = True break if flag : breakif flag : print ( "" YES \n "" , 0 , 0 , ' \n ' , p , q , ' \n ' , r , s ) else : print ( "" NO "" ) NEW_LINE +" +E198,"import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } int c = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int sum = ar [ i ] + ar [ i + 1 ] ; if ( sum < k ) { ar [ i + 1 ] += k - sum ; c += k - sum ; } } System . out . println ( c ) ; for ( Integer integer : ar ) { System . out . print ( integer + "" ▁ "" ) ; } System . out . println ( ) ;     }    public static long power ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = ans * a ; ans %= c ; } a = a * a ; a %= c ; b /= 2 ; } return ans ; }   public static long power1 ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = multiply ( ans , a , c ) ; } a = multiply ( a , a , c ) ; b /= 2 ;   } return ans ;   }   public static long multiply ( long a , long b , long c ) { long res = 0 ; a %= c ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res + a ) % c ; } a = ( a + a ) % c ; b /= 2 ; }   return res % c ;   }   public static long totient ( long n ) { long result = n ; for ( long i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { +","m , k = [ int ( i ) for i in input ( ) . split ( ) ]   days = [ int ( i ) for i in input ( ) . split ( ) ]     s1 = 0 for q in range ( 1 , m ) : if days [ q ] + days [ q - 1 ] < k : s1 += k - ( days [ q ] + days [ q - 1 ] ) days [ q ] += k - ( days [ q ] + days [ q - 1 ] )   print ( s1 ) print ( * days ) NEW_LINE +" +E199,"import java . util . Arrays ; import java . util . Scanner ;   public class B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; String s = sc . next ( ) ; char [ ] ch = s . toCharArray ( ) ; long arr [ ] = new long [ 10 ] ; for ( long i = 1 ; i <= 9 ; i ++ ) { arr [ ( int ) i ] = sc . nextLong ( ) ; } +","n = int ( input ( ) ) A = [ int ( d ) for d in input ( ) ] f = [ int ( x ) for x in input ( ) . split ( ) ] flag = Falsefor i in range ( n ) : d = A [ i ] x = f [ A [ i ] - 1 ] if x > d : flag = True A [ i ] = x elif x == d : continue else : if flag : breakA = list ( map ( str , A ) ) print ( ' ' . join ( A ) ) NEW_LINE +" +E200,"import java . io . * ; import java . util . * ; public class Main implements Runnable { private void solve ( ) throws IOException { char s [ ] = ( "" ▁ "" + nextLine ( ) ) . toCharArray ( ) ; int n = s . length - 1 ; int dp [ ] = new int [ n + 1 ] ; +","import sysfrom math import gcd , sqrt , ceil , log2from collections import defaultdict , Counter , dequefrom bisect import bisect_left , bisect_rightimport mathimport heapqfrom itertools import permutations   NEW_LINE +" +E201,"import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int count = 0 ; if ( b == 0 ) { System . out . println ( 0 ) ; } else { if ( a == 0 ) { while ( b != 0 && c > 1 ) { count = count + 3 ; b = b - 1 ; c = c - 2 ; } System . out . println ( count ) ; } else if ( c == 0 ) { while ( a != 0 && b > 1 ) { count = count + 3 ; a = a - 1 ; b = b - 2 ; } System . out . println ( count ) ; } else { while ( b != 0 && c > 1 ) { count = count + 3 ; b = b - 1 ; c = c - 2 ; } while ( a != 0 && b > 1 ) { count = count + 3 ; a = a - 1 ; b = b - 2 ; } System . out . println ( count ) ; } } } } } +","t = int ( input ( ) ) for i in range ( t ) : a , b , c = map ( int , input ( ) . split ( ) ) count = 0 if b > 0 and c > 1 : while b > 0 and c > 1 : b = b - 1 c = c - 2 count += 1 if a > 0 and b > 1 : while a > 0 and b > 1 : a = a - 1 b = b - 2 count += 1 print ( count * 3 )       NEW_LINE +" +E202,"import java . io . * ; import java . util . * ; import static java . lang . Math . * ;   public class LipschitzSequenceMaxIslands { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int [ ] diff = new int [ N - 1 ] ; Arrays . setAll ( a , i -> sc . nextInt ( ) ) ; Arrays . setAll ( diff , i -> abs ( a [ i + 1 ] - a [ i ] ) ) ; int [ ] [ ] bounds = new int [ 2 ] [ N ] ; ArrayDeque < Integer > decr = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { +","f = lambda : map ( int , input ( ) . split ( ) ) n , m = f ( ) t = list ( f ( ) ) p = [ 1e9 ] + [ abs ( b - a ) for a , b in zip ( t , t [ 1 : ] ) ] + [ 1e9 ] L , R = [ 0 ] * n , [ 0 ] * nfor i in range ( 1 , n ) : j = n - i x , y = i - 1 , j + 1 a , b = p [ i ] , p [ j ] while a > p [ x ] : x = L [ x ] while b >= p [ y ] : y = R [ y ] L [ i ] , R [ j ] = x , yfor k in range ( m ) : l , r = f ( ) print ( sum ( ( i - max ( l - 1 , L [ i ] ) ) * ( min ( r , R [ i ] ) - i ) * p [ i ] for i in range ( l , r ) ) ) NEW_LINE +" +E203,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Scanner ;   public class _0697IntegerPoints {   public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int cases = Integer . parseInt ( br . readLine ( ) ) ; while ( cases > 0 ) { int n = Integer . parseInt ( br . readLine ( ) ) ; String [ ] arr = new String [ n ] ; arr = br . readLine ( ) . trim ( ) . split ( "" ▁ "" ) ; int m = Integer . parseInt ( br . readLine ( ) ) ; String [ ] arr1 = new String [ m ] ; arr1 = br . readLine ( ) . trim ( ) . split ( "" ▁ "" ) ; long count = 0 ; long even1 = 0 ; long even2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int val = Integer . parseInt ( arr [ i ] ) ; if ( val % 2 == 0 ) even1 ++ ; } for ( int i = 0 ; i < m ; i ++ ) { int val = Integer . parseInt ( arr1 [ i ] ) ; if ( val % 2 == 0 ) even2 ++ ; } count += even1 * even2 ; count += ( n - even1 ) * ( m - even2 ) ; System . out . println ( count ) ; cases -- ; } }   } +","cases = int ( input ( ) ) while cases : cases -= 1 x = int ( input ( ) ) arrx = list ( map ( int , input ( ) . split ( ) ) ) y = int ( input ( ) ) arry = list ( map ( int , input ( ) . split ( ) ) )   ans = sum ( 1 for i in arrx if i % 2 == 0 ) * sum ( 1 for i in arry if i % 2 == 0 ) + sum ( 1 for i in arrx if i % 2 != 0 ) * sum ( 1 for i in arry if i % 2 != 0 ) print ( ans ) NEW_LINE +" +E204,"# include < iostream > # include < vector > # include < iomanip > # include < cstring > # include < string . h > # include < iterator > # include < math . h > # include < set > # include < queue > # include < stack > # include < algorithm > # include < tuple > # include < limits . h > # include < string > # include < bitset > # include < map > # include < numeric > # include < unordered_map >   # define endl cout << "" \n "" # define lli long long int # define ld long double # define M_PI ( 3.14159265358979323846264338327950288 ) # define MOD ( 1000000007 )   using namespace std ;   +","MAX_LEN = int ( 1e5 ) n = int ( input ( ) ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] m = int ( input ( ) ) b = list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) curr , k , c , res = 0 , 0 , [ ] , [ ] for i in range ( n ) : t = a [ i ] last = curr if t [ 0 ] == 1 : curr += 1 if len ( c ) < MAX_LEN : c . append ( t [ 1 ] ) if k < m and b [ k ] == curr - 1 : res . append ( t [ 1 ] ) k += 1 else : curr += t [ 1 ] * t [ 2 ] while t [ 2 ] > 0 and len ( c ) < MAX_LEN : c . extend ( c [ : t [ 1 ] ] ) t [ 2 ] -= 1 while k < m and last <= b [ k ] < curr : res . append ( c [ ( b [ k ] - last ) % t [ 1 ] ] ) k += 1 print ( ' ▁ ' . join ( map ( str , res [ : m ] ) ) ) NEW_LINE +" +E205,"import java . util . * ;   public class A { public static void main ( String [ ] args ) { List < String > pre = new ArrayList < > ( ) ; List < String > post = new ArrayList < > ( ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { pre . add ( sc . next ( ) ) ; post . add ( sc . next ( ) ) ; } +","def get_key ( my_dict , val ) : for key , value in my_dict . items ( ) : if val == value : return key return - 1   n = int ( input ( ) ) arr = { } for _ in range ( n ) : a , b = input ( ) . split ( ) x = get_key ( arr , a ) if x == - 1 : arr [ a ] = b   else : arr [ x ] = b   print ( len ( arr ) ) for i , j in arr . items ( ) : print ( i , j ) NEW_LINE +" +E206,"import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner input = new Scanner ( System . in ) ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; int temp = 0 ; int i = 1 ; while ( a >= 0 && b >= 0 ) { if ( temp == 0 ) { a -= i ; if ( a < 0 ) { System . out . println ( "" Vladik "" ) ; return ; } temp = ++ temp % 2 ; } else if ( temp == 1 ) { b -= i ; if ( b < 0 ) { System . out . println ( "" Valera "" ) ; return ; } temp = ++ temp % 2 ; } i ++ ; } } } +","a , b = map ( int , input ( ) . split ( ) ) print ( ' VVlaaldeirka ' [ ( ( 4 * b + 1 ) ** .5 - 1 ) // 2 < a ** .5 // 1 : : 2 ] ) NEW_LINE +" +E207,"import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ; +","def main ( ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) c = [ ] for i in range ( n - 1 ) : c += [ a [ i + 1 ] - a [ i ] ] print ( min ( c ) , c . count ( min ( c ) ) )   if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE +" +E208,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","n , L = map ( int , input ( ) . split ( ) ) kefa = list ( map ( int , input ( ) . split ( ) ) ) sasha = list ( map ( int , input ( ) . split ( ) ) ) def check ( kefa , sasha ) : X = [ ( kefa [ i ] - sasha [ i ] + L ) % L for i in range ( n ) ] if len ( set ( X ) ) == 1 : return True else : return Falsedef rotate ( arr , n ) : x = arr [ n - 1 ] for i in range ( n - 1 , 0 , - 1 ) : arr [ i ] = arr [ i - 1 ] arr [ 0 ] = x return arrok = Falsefor l in range ( n + 1 ) : sasha = rotate ( sasha , n ) if check ( kefa , sasha ) == True : ok = Trueif ok == True : print ( "" Yes "" ) else : print ( "" No "" ) NEW_LINE +" +E209,"import java . util . * ; public class Main {   static int civ [ ] = new int [ 1000006 + 1 ] ; static void feed ( ) { for ( int i = 0 ; i < civ . length ; i ++ ) {   civ [ i ] = 1 ; }   civ [ 0 ] = civ [ 1 ] = 0 ;   for ( int i = 2 ; i * i < civ . length ; i ++ ) { if ( civ [ i ] == 1 ) { for ( int j = i ; j * i < civ . length ; j ++ ) civ [ i * j ] = 0 ; } }   }   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) {   arr [ i ] = sc . nextLong ( ) ; } feed ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long tp = ( long ) Math . sqrt ( arr [ i ] ) ;   if ( tp * tp == arr [ i ] && civ [ ( int ) tp ] == 1 ) { System . out . println ( "" YES "" ) ; } else System . out . println ( "" NO "" ) ;    } } } +","n = 1000000 a = [ 1 ] * ns = set ( ) for i in range ( 2 , n ) : if a [ i ] : s . add ( i * i ) for j in range ( i * i , n , i ) : a [ j ] = 0 input ( ) for x in map ( int , input ( ) . split ( ) ) : print ( [ "" NO "" , "" YES "" ] [ x in s ] ) NEW_LINE +" +E210,"  import java . util . * ; import java . lang . * ; import java . io . * ;   public class B { 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 N = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] [ ] ip = new int [ N ] [ 2 ] ; int negs = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ip [ i ] [ 1 ] = i ; ip [ i ] [ 0 ] = Integer . parseInt ( st . nextToken ( ) ) ; if ( ip [ i ] [ 0 ] >= 0 ) { ip [ i ] [ 0 ] = - ip [ i ] [ 0 ] - 1 ; } if ( ip [ i ] [ 0 ] < 0 ) { negs ++ ; } }   if ( negs % 2 == 1 ) { int min = 1 , idx = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( min > ip [ i ] [ 0 ] ) { min = ip [ i ] [ 0 ] ; idx = i ; } } ip [ idx ] [ 0 ] = - ip [ idx ] [ 0 ] - 1 ; }    for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( ip [ i ] [ 0 ] + "" ▁ "" ) ; } System . out . println ( ) ;   } } +","n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) neg , neg1 = 0 , [ ] pos , pos1 = 0 , [ ] for i in range ( n ) : if l [ i ] >= 0 : l [ i ] = - l [ i ] - 1 if n % 2 == 0 : print ( * l ) else : l1 = sorted ( l ) l [ l . index ( l1 [ 0 ] ) ] = - l1 [ 0 ] - 1 print ( * l ) NEW_LINE +" +E211,"import java . util . Scanner ;   public class Solutions { static long dp [ ] [ ] ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int c [ ] = new int [ n ] ; c [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) c [ i ] = Math . max ( c [ i + 1 ] , arr [ i ] ) ; int max = b ; for ( int i = 0 ; i < n ; i ++ ) { int temp = b % arr [ i ] + ( b / arr [ i ] ) * c [ i ] ; if ( temp > max ) max = temp ; } System . out . println ( max ) ; } } +","    n , b = map ( int , input ( ) . split ( ) )   t = list ( map ( int , input ( ) . split ( ) ) )   ans = 0   ma = 999999999 mi = 0 for i in range ( n ) :   if t [ i ] < ma : ma = t [ i ] elif t [ i ] > ma : temp = b // ma   rest = b - ( b // ma ) * ma rest += ( temp ) * t [ i ]   ans = max ( rest , ans )   print ( max ( ans , b ) )     NEW_LINE +" +E212,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . next ( ) ; StringBuilder ans = new StringBuilder ( ) ; ArrayList < Integer > a1 = new ArrayList < > ( ) , a2 = new ArrayList < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' r ' ) ans . append ( ( i + 1 ) + "" \n "" ) ; } for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == ' l ' ) ans . append ( ( i + 1 ) + "" \n "" ) ; } System . out . println ( ans ) ; +","import osimport sysfrom io import BytesIO , IOBase   sys . setrecursionlimit ( 95000 )     def main ( ) : pass     NEW_LINE +" +E213,"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . Scanner ; import java . util . TreeMap ; import java . util . TreeSet ;    public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int x = input . nextInt ( ) ; int t = input . nextInt ( ) ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; int da = input . nextInt ( ) ; int db = input . nextInt ( ) ; if ( x == 0 ) { System . out . println ( "" YES "" ) ; return ; } for ( int i = 0 ; i < t ; i ++ ) { if ( ( a - da * i ) == x ) { System . out . println ( "" YES "" ) ; return ; } } for ( int i = 0 ; i < t ; i ++ ) { if ( ( b - db * i ) == x ) { System . out . println ( "" YES "" ) ; return ; } } for ( int i = 0 ; i < t ; i ++ ) { for ( int j = 0 ; j < t ; j ++ ) { if ( ( a - da * i ) + ( b - db * j ) == x ) { System . out . println ( "" YES "" ) ; return ; } } } for ( int i = t - 1 ; i >= 0 ; i -- ) { for ( int j = 0 ; j < t ; j ++ ) { if ( ( a - da * i ) + ( b - db * j ) == x ) { System . out . println ( "" YES "" ) ; return ; } } } System . out . println ( "" NO "" ) ; } } +","x , t , a , b , da , db = [ int ( i ) for i in input ( ) . split ( ) ]   if x == 0 : print ( "" YES "" ) exit ( 0 )   for i in range ( t ) : for j in range ( t ) : if ( a - i * da + b - j * db == x ) or ( a - i * da == x ) or ( b - j * db == x ) : print ( "" YES "" ) exit ( 0 )   print ( "" NO "" ) NEW_LINE +" +E214,"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; Arrays . sort ( a ) ; boolean v = false ; for ( int j = 0 ; j < n - 2 ; j ++ ) { if ( ( a [ j ] + a [ j + 1 ] ) > a [ j + 2 ] ) { v = true ; break ; } } if ( v == false ) System . out . println ( "" NO "" ) ; else System . out . println ( "" YES "" ) ; } } +","from itertools import combinations   def solve ( ) : n = int ( input ( ) ) ls = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) for x , y , z in zip ( ls , ls [ 1 : ] , ls [ 2 : ] ) : if x > z - y and x <= y + z : print ( ' YES ' ) return print ( ' NO ' )   if __name__ == ' _ _ main _ _ ' : solve ( ) NEW_LINE +" +E215,"import java . lang . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; char [ ] a = sc . nextLine ( ) . toCharArray ( ) ; char s = a [ 0 ] ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( s < a [ i ] ) s = a [ i ] ; } int count = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] == s ) { count ++ ; } } for ( int i = 0 ; i < count ; i ++ ) System . out . print ( s ) ;   } } +","def solution ( s ) : s = sorted ( s , reverse = True ) n = len ( s ) ans = s [ 0 ] for i in range ( 1 , n ) : if ( s [ i - 1 ] == s [ i ] ) : ans += ( s [ i ] ) else : return ans return ans   s = input ( ) print ( solution ( s ) ) NEW_LINE +" +E216,"import java . util . * ; public class DesignTutorialLearnFromMath { public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ; int val = sc . nextInt ( ) ;   int val1 ; if ( val % 2 == 0 ) { val1 = 8 ; } else { val1 = 9 ;   } System . out . println ( val1 + "" ▁ "" + ( val - val1 ) ) ; } } +","n = int ( input ( ) ) if n % 2 == 0 : print ( 4 , n - 4 ) else : print ( 9 , n - 9 ) NEW_LINE +" +E217,"import java . util . * ; import java . io . * ;   public class Main { private StreamTokenizer in ; private PrintWriter out ;   public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; }   private String substring ( String str , int idx , int len ) { return str . substring ( idx , str . offsetByCodePoints ( idx , len ) ) ; }   private void run ( ) throws IOException { in = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ;   solve ( ) ;   out . flush ( ) ; }   private int nextInt ( ) throws IOException { in . nextToken ( ) ;   return ( int ) in . nval ; }   private String nextString ( ) throws IOException { in . nextToken ( ) ;   return in . sval ; }   private void solve ( ) throws IOException { final int rows = nextInt ( ) ; final int cols = nextInt ( ) ;   +","raw = input ( ) R , C = ( int ( token ) for token in raw . split ( ' ▁ ' ) ) mat = list ( ) for i in range ( R ) : row = input ( ) mat . append ( row )   count = 0 for i in range ( 1 , R ) : for j in range ( 1 , C ) : sq = [ mat [ i - 1 ] [ j - 1 ] , mat [ i - 1 ] [ j ] , mat [ i ] [ j - 1 ] , mat [ i ] [ j ] ] sq . sort ( ) if ' ' . join ( sq ) == ' acef ' : count += 1 print ( count )   NEW_LINE +" +E218,"import java . awt . * ; import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; boolean [ ] peak = new boolean [ n + 1 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] && arr [ i ] > arr [ i + 1 ] ) peak [ i ] = true ; } int count = 0 ; for ( int i = 2 ; i < k ; i ++ ) { if ( peak [ i ] ) count ++ ; } int max = count ; int l = 1 ; int L = 2 , R = k + 1 ; while ( R <= n ) { if ( peak [ L ] ) count -- ; if ( peak [ R - 1 ] ) count ++ ; if ( count > max ) { max = count ; l = L ; } R ++ ; L ++ ; } sb . append ( ( max + 1 ) + "" ▁ "" + l + "" \n "" ) ; } System . out . println ( sb ) ; } } +","import sys   def answer ( n , k , a ) : peaks = [ False ] * n NEW_LINE +" +E219,"import java . util . * ;   public class codeforces { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = "" "" ;   int n = sc . nextInt ( ) ; String s = sc . next ( ) ;   ArrayList < String > gram = new ArrayList < String > ( ) ; ArrayList < Integer > count = new ArrayList < Integer > ( ) ;   for ( int i = 0 ; i < n - 1 ; i ++ ) { x = "" "" + s . charAt ( i ) + s . charAt ( i + 1 ) ; boolean flag = false ; for ( int j = 0 ; j < gram . size ( ) ; j ++ ) { if ( x . equals ( gram . get ( j ) ) ) { count . set ( j , count . get ( j ) + 1 ) ; flag = true ; } } if ( flag == false ) { gram . add ( x ) ; count . add ( 1 ) ; } } String ans = "" "" ; int start = 0 ; for ( int i = 0 ; i < count . size ( ) ; i ++ ) { if ( count . get ( i ) > start ) { start = count . get ( i ) ; ans = gram . get ( i ) ; }   } System . out . println ( ans ) ;     } } +","n = int ( input ( ) ) s = input ( ) k = [ s [ i : i + 2 ] for i in range ( n - 1 ) ] print ( max ( k , key = k . count ) ) NEW_LINE +" +E220,"import java . io . File ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class p007 { public static void main ( String args [ ] ) throws Exception { StringTokenizer stok = new StringTokenizer ( new Scanner ( System . in ) . useDelimiter ( "" \\ A "" ) . next ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; char [ ] s = new char [ ( int ) 1e7 ] ; long mod = ( long ) 1e9 + 7 ; int T = Integer . parseInt ( stok . nextToken ( ) ) ; while ( T -- > 0 ) { int x = Integer . parseInt ( stok . nextToken ( ) ) ; char [ ] ss = stok . nextToken ( ) . toCharArray ( ) ; for ( int i = 0 ; i < ss . length ; i ++ ) s [ i ] = ss [ i ] ; long n = ss . length ; boolean fl = true ; for ( int i = 0 ; i < x ; i ++ ) { int v = s [ i ] - 49 , cnt = 0 ; long d = ( n - i - 1 ) ; long nn = ( n + v * d ) % mod ; while ( ++ cnt <= v ) { if ( n <= x && fl ) { for ( int j = i + 1 ; j <= n ; j ++ ) s [ j + ( int ) ( cnt * d ) ] = s [ j ] ; } else fl = false ; } n = nn ; } sb . append ( ( n + mod ) % mod + "" \n "" ) ; } System . out . println ( sb ) ; } } +","def main ( ) : t = int ( input ( ) ) allans = [ ] for _ in range ( t ) : x = int ( input ( ) ) arr = [ int ( z ) for z in input ( ) ] n = len ( arr ) j = 1 for i in range ( x ) : if j == n : break for yy in range ( arr [ i ] - 1 ) : if len ( arr ) > x : break for zz in range ( i + 1 , n ) : if len ( arr ) > x : break arr . append ( arr [ zz ] ) n += ( ( n - j + MOD ) % MOD ) * ( arr [ i ] - 1 ) j += 1 n %= MOD NEW_LINE +" +E221,"import java . io . * ; import java . util . * ;   public class Main { private static String smallest ( String a ) { if ( a . length ( ) % 2 == 1 ) { return a ; } String first = smallest ( a . substring ( 0 , a . length ( ) / 2 ) ) ; String second = smallest ( a . substring ( a . length ( ) / 2 ) ) ; if ( first . compareTo ( second ) < 0 ) { return first + second ; } return second + first ; } private static boolean equal ( String a , String b ) { return smallest ( a ) . equals ( smallest ( b ) ) ; } public static void main ( String [ ] args ) throws IOException { +","a = input ( ) b = input ( )   def dfs ( sa , sb ) : if sa == sb : return True if len ( sa ) & 1 : return False n = len ( sa ) // 2 sa1 = sa [ : n ] sa2 = sa [ n : ] sb1 = sb [ : n ] sb2 = sb [ n : ] if dfs ( sa1 , sb2 ) and dfs ( sa2 , sb1 ) : return True if dfs ( sa1 , sb1 ) and dfs ( sa2 , sb2 ) : return True return False   if dfs ( a , b ) : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E222,"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static FileWriter fw ; static long oo = Long . MAX_VALUE ; +","n , m , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a1 = [ ] for i in range ( n ) : a1 . append ( ( a [ i ] , i ) ) a1 . sort ( reverse = True ) _max = [ 0 ] * nans = 0 for i in range ( m * k ) : _max [ a1 [ i ] [ 1 ] ] = 1 ans += a1 [ i ] [ 0 ] print ( ans ) _sum = 0 ans_ar = [ ] for i in range ( n ) : _sum += _max [ i ] if _sum == m : ans_ar . append ( i + 1 ) _sum = 0 ans_ar . pop ( ) print ( * ans_ar )           NEW_LINE +" +E223,"  import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . math . * ; public class c705b { +","import reimport sysexit = sys . exitfrom bisect import bisect_left as bsl , bisect_right as bsrfrom collections import Counter , defaultdict as ddict , dequefrom functools import lru_cachecache = lru_cache ( None ) from heapq import * from itertools import * from math import inffrom pprint import pprint as ppenum = enumerateri = lambda : int ( rln ( ) ) ris = lambda : list ( map ( int , rfs ( ) ) ) rln = sys . stdin . readlinerl = lambda : rln ( ) . rstrip ( ' \n ' ) rfs = lambda : rln ( ) . split ( ) mod = 1000000007 d4 = [ ( 0 , - 1 ) , ( 1 , 0 ) , ( 0 , 1 ) , ( - 1 , 0 ) ] d8 = [ ( - 1 , - 1 ) , ( 0 , - 1 ) , ( 1 , - 1 ) , ( - 1 , 0 ) , ( 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) , ( 1 , 1 ) ] NEW_LINE +" +E224,"import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; sc . nextLine ( ) ; while ( t -- > 0 ) { String s1 = sc . nextLine ( ) ; StringBuilder s2 = new StringBuilder ( ) ; int cr = 0 , cs = 0 , cp = 0 ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) == ' R ' ) { cp ++ ; } else if ( s1 . charAt ( i ) == ' P ' ) { cs ++ ; } else { cr ++ ; } } char c ; if ( cp >= cs && cp >= cr ) { c = ' P ' ; } else if ( cs >= cp && cs >= cr ) { c = ' S ' ; } else { c = ' R ' ; } for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { s2 . append ( c ) ; } System . out . println ( s2 . toString ( ) ) ; } } }   +","from sys import stdin , stdoutstdin . readlinedef mp ( ) : return list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) def it ( ) : return int ( stdin . readline ( ) . strip ( ) ) from collections import defaultdict as dd , Counter as C , dequefrom math import ceil , gcd     NEW_LINE +" +E225,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","import sysimport mathfrom collections import OrderedDictdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n , p = minput ( ) s = input ( ) s1 = s [ : ( n - p ) ] s2 = s [ p : ] if ( s1 == s2 and s1 . count ( ' . ' ) == 0 and s2 . count ( ' . ' ) == 0 ) or n == 1 or n == p : print ( ' NO ' ) else : for i in range ( n - p ) : if s [ i ] == ' . ' : if s [ p + i ] == '0' or s [ p + i ] == ' . ' : s = s [ : i ] + '1' + s [ i + 1 : ] else : s = s [ : i ] + '0' + s [ i + 1 : ] break elif s [ p + i ] == ' . ' : if s [ i ] == '0' or s [ i ] == ' . ' : s = s [ : p + i ] + '1' + s [ p + i + 1 : ] else : s = s [ : p + i ] + '0' + s [ p + i + 1 : ] break s = s . replace ( ' . ' , '0' ) print ( s ) NEW_LINE +" +E226,"import java . util . Scanner ; public class Acm2challenge3 { public static void main ( String [ ] args ) { +","for _ in range ( int ( input ( ) ) ) : a , b = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE print ( a ^ b ) NEW_LINE +" +E227,"import java . text . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int r = scanner . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] flag = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = scanner . nextInt ( ) ; flag [ i ] = 0 ; } int cnt = 0 ; int begin = 0 ; if ( r - 1 < n ) begin = r - 1 ; else begin = n - 1 ; for ( int i = begin ; ; ) { if ( a [ i ] == 1 ) { cnt ++ ; flag [ i ] = 1 ; if ( i + r - 1 >= n - 1 ) break ; if ( i + 2 * r - 1 <= n - 1 ) i = i + 2 * r - 1 ; else i = n - 1 ; continue ; } while ( i >= 0 && a [ i ] == 0 && flag [ i ] == 0 ) i -- ; if ( i == - 1 || flag [ i ] == 1 ) { System . out . println ( "" - 1"" ) ; return ; } cnt ++ ; flag [ i ] = 1 ; if ( i + r - 1 >= n - 1 ) break ; if ( i + 2 * r - 1 <= n - 1 ) i = i + 2 * r - 1 ; else i = n - 1 ; } if ( cnt == 0 ) System . out . println ( "" - 1"" ) ; else System . out . println ( cnt ) ; scanner . close ( ) ; } +","    n , r = map ( int , input ( ) . split ( ) )     t = list ( map ( int , input ( ) . split ( ) ) )       arr = [ 0 ] * ( n + 1 )     for i in range ( n ) :   if t [ i ] == 1 : arr [ max ( i - r + 1 , 0 ) ] += 1 arr [ min ( n , i + r ) ] -= 1         for j in range ( 1 , n + 1 ) : arr [ j ] += arr [ j - 1 ]         if 0 in arr [ : n ] : print ( - 1 ) else : ans = 0   for i in range ( n ) : st = max ( 0 , i - r + 1 ) en = min ( i + r , n )   h = 0   for j in range ( st , en ) : if arr [ j ] == 1 : h += 1 if h == 0 : ans += 1 for j in range ( st , en ) : arr [ j ] -= 1   print ( sum ( t ) - ans )     NEW_LINE +" +E228,"  import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; String str = "" "" ; String ans = "" "" ; boolean f = false ; for ( int i = 0 ; i < n ; ++ i ) { String in = sc . next ( ) ; str += in + "" ) "" ; } for ( int i = ' a ' ; i <= ' z ' ; ++ i ) { if ( ! str . contains ( "" "" + ( char ) i ) ) { f = true ; out . println ( ( char ) i ) ; break ; } } if ( ! f ) { String in = "" "" ; for ( int i = ' a ' ; i <= ' z ' ; ++ i ) { for ( int j = ' a ' ; j <= ' z ' ; ++ j ) { in = ( char ) i + "" "" ; in += ( char ) j ; if ( ! str . contains ( in ) ) { out . println ( in ) ; f = true ; break ; } } if ( f ) break ; } } out . close ( ) ;   }   +","ans = [ ] for i in range ( 27 ) : for j in range ( 27 ) : for t in range ( 27 ) : tempa = [ i , j , t ] s = ' ' for q in range ( len ( tempa ) ) : if ( tempa [ q ] == 26 ) : continue ; else : s += chr ( tempa [ q ] + 97 ) ans . append ( [ len ( s ) , s ] )   ans . sort ( ) pg = [ ]   x = int ( input ( ) ) for i in range ( x ) : s = input ( ) pg . append ( s ) for i in range ( len ( ans ) ) : flag = 0 for j in range ( len ( pg ) ) : if ( ans [ i ] [ 1 ] in pg [ j ] ) : flag += 1 if ( flag == 0 ) : print ( ans [ i ] [ 1 ] ) exit ( )       NEW_LINE +" +E229,"import java . util . Scanner ;   public class DigitGame { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   String t = scanner . nextLine ( ) ; int tt = Integer . parseInt ( t ) ;   while ( tt -- != 0 ) { String n = scanner . nextLine ( ) ; int nn = Integer . parseInt ( n ) ; String number = scanner . nextLine ( ) ; System . out . println ( solve ( nn , number ) ) ; } }   public static int solve ( int n , String number ) {   if ( n % 2 == 1 ) { int counter = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( Integer . parseInt ( String . valueOf ( number . charAt ( i ) ) ) % 2 == 0 ) { counter ++ ; } i ++ ; } if ( counter > ( n - 1 ) / 2 ) { return 2 ; } else { return 1 ; } } else { int counter = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( Integer . parseInt ( String . valueOf ( number . charAt ( i ) ) ) % 2 == 1 ) { counter ++ ; } i ++ ; } if ( counter > ( n - 2 ) / 2 ) { return 1 ; } else { return 2 ; } }   } } +","for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE r = [ int ( i ) for i in s [ 0 : : 2 ] ] NEW_LINE b = [ int ( i ) for i in s [ 1 : : 2 ] ] NEW_LINE win = 0 NEW_LINE if n % 2 == 1 : win = 2 NEW_LINE for i in r : if NEW_LINE i % 2 == 1 : win = 1 NEW_LINE break else : win = 1 NEW_LINE for i in b : if NEW_LINE i % 2 == 0 : win = 2 NEW_LINE break NEW_LINE print ( win ) NEW_LINE +" +E230,"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String s1 = s . nextLine ( ) ; if ( s1 . contains ( "" ABC "" ) || s1 . contains ( "" ACB "" ) || s1 . contains ( "" BAC "" ) || s1 . contains ( "" BCA "" ) || s1 . contains ( "" CBA "" ) || s1 . contains ( "" CAB "" ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","from itertools import permutations   flag = 0 a = input ( ) a_list = list ( permutations ( "" ABC "" ) ) a_list = [ "" "" . join ( x ) for x in a_list ] for x in a_list : if x in a : flag = 1 if flag == 1 : print ( "" Yes "" ) else : print ( "" No "" ) NEW_LINE +" +E231,"import java . util . * ; public class ApplejackStorage { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ 100001 ] ; int [ ] freq = new int [ 100001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; arr [ num ] ++ ; freq [ arr [ num ] ] ++ ; } int q = sc . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { String s = sc . next ( ) ; int x = sc . nextInt ( ) ; if ( s . equals ( "" + "" ) ) { arr [ x ] ++ ; freq [ arr [ x ] ] ++ ; } else { freq [ arr [ x ] ] -- ; arr [ x ] -- ; } if ( freq [ 8 ] > 0 || ( freq [ 6 ] > 0 && freq [ 2 ] > 1 ) || ( freq [ 4 ] > 1 ) || ( freq [ 4 ] > 0 && freq [ 2 ] > 2 ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } } } +","from sys import stdin NEW_LINE input = stdin . readline NEW_LINE input ( ) NEW_LINE * a , = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE s , r = [ 0 ] * 2 NEW_LINE cnt = [ 0 ] * 100002 NEW_LINE for i in a : NEW_LINE INDENT cnt [ i ] += 1 NEW_LINE if cnt [ i ] % 4 == 0 : NEW_LINE INDENT s += 1 NEW_LINE DEDENT if cnt [ i ] % 2 == 0 : NEW_LINE INDENT r += 1 NEW_LINE DEDENT DEDENT q = int ( input ( ) ) NEW_LINE for i in range ( q ) : NEW_LINE INDENT sign , n = input ( ) . split ( ) NEW_LINE n = int ( n ) NEW_LINE if sign == ' + ' : NEW_LINE INDENT cnt [ n ] += 1 NEW_LINE if cnt [ n ] % 4 == 0 : NEW_LINE INDENT s += 1 NEW_LINE DEDENT if cnt [ n ] % 2 == 0 : NEW_LINE INDENT r += 1 NEW_LINE DEDENT DEDENT elif sign == ' - ' : NEW_LINE INDENT if cnt [ n ] % 4 == 0 : NEW_LINE INDENT s -= 1 NEW_LINE DEDENT if cnt [ n ] % 2 == 0 : NEW_LINE INDENT r -= 1 NEW_LINE DEDENT cnt [ n ] -= 1 NEW_LINE DEDENT print ( ' YES ' if s > 1 or ( s == 1 and r > 3 ) else ' NO ' ) NEW_LINE DEDENT +" +E232,"import java . util . * ; import java . io . * ; import java . math . * ;   public class A { public static void main ( String hi [ ] ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; if ( K == 0 ) { System . out . println ( "" a "" ) ; return ; } StringBuilder sb = new StringBuilder ( ) ; for ( int c = 0 ; c < 26 ; c ++ ) { if ( K == 0 ) break ; int low = 1 ; int high = 446 ; while ( low != high ) { int mid = ( low + high + 1 ) / 2 ; if ( mid * ( mid + 1 ) / 2 > K ) high = mid - 1 ; else low = mid ; } K -= low * ( low + 1 ) / 2 ; while ( low -- > - 1 ) sb . append ( ( char ) ( ' a ' + c ) ) ; } if ( K > 0 ) { int lol = 4 / 0 ; } System . out . print ( sb ) ; } } +","k , s , o = int ( input ( ) ) , "" z "" , 97 while k : q = int ( ( ( 1 + 8 * k ) ** .5 - 1 ) / 2 ) + 1 k -= q * ( q - 1 ) // 2 s += chr ( o ) * q o += 1 print ( s ) NEW_LINE +" +E233,"import java . util . Scanner ;   public class rasberryandhoney { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int days = sc . nextInt ( ) ; int cost = sc . nextInt ( ) ;   int [ ] arr = new int [ days ] ;   for ( int i = 0 ; i < days ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < days - 1 ; i ++ ) { max = Math . max ( max , arr [ i ] - arr [ i + 1 ] ) ; }   if ( max <= 0 ) System . out . println ( 0 ) ; else { if ( cost > max ) System . out . println ( 0 ) ; else System . out . println ( max - cost ) ; } } } +","n , c = map ( int , input ( ) . split ( ) ) prices = list ( map ( int , input ( ) . split ( ) ) )   max_i = Nonemax_p = Nonefor i , p in enumerate ( prices ) : if max_p is None or ( i < len ( prices ) - 1 and p - prices [ i + 1 ] > max_p ) : max_i = i max_p = p - prices [ i + 1 ]   print ( max ( 0 , prices [ max_i ] - c - prices [ max_i + 1 ] ) ) NEW_LINE +" +E234,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class K_good { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   StringTokenizer st = new StringTokenizer ( reader . readLine ( ) ) ;   int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; int count = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { String num = reader . readLine ( ) ; boolean [ ] check = new boolean [ 10 ] ; boolean flag = true ;   for ( int j = 0 ; j < num . length ( ) ; j ++ ) { check [ num . charAt ( j ) - '0' ] = true ; }   for ( int j = 0 ; j < k + 1 ; j ++ ) { if ( ! check [ j ] ) flag = false ; }   if ( flag ) count ++ ; }   System . out . println ( count ) ; } } +","import sysinput = sys . stdin . readlineimport math   def inpit ( ) : NEW_LINE +" +E235,"import java . util . * ; import java . math . * ; public class YoungExplorers { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int size = sc . nextInt ( ) ;   int [ ] arr = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) arr [ i ] = sc . nextInt ( ) ; shuffleArray ( arr ) ; Arrays . sort ( arr ) ; int out = 0 ; int num = 0 ; int goal = 0 ; outer : for ( int i = 0 ; i < size ; ) { goal = arr [ i ] ; num ++ ; if ( goal <= num ) { out ++ ; num = 0 ; goal = 0 ; } i ++ ;   } System . out . println ( out ) ; } } static void shuffleArray ( int [ ] arr ) { int n = arr . length ; Random rnd = new Random ( ) ; for ( int i = 0 ; i < n ; ++ i ) { int tmp = arr [ i ] ; int randomPos = i + rnd . nextInt ( n - i ) ; arr [ i ] = arr [ randomPos ] ; arr [ randomPos ] = tmp ; } } } +","from sys import stdin ''' class ▁ PriorityQueueBase : ▁ ▁ ▁ ▁ class ▁ _ Item : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ _ _ slots _ _ ▁ = ▁ ' _ key ' , ' _ value '   ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ def ▁ _ _ init _ _ ( self , k , v ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ self . _ key ▁ = ▁ k ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ self . _ value ▁ = ▁ v  ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ def ▁ _ _ lt _ _ ( self , other ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ self . _ key ▁ < ▁ other . _ key  ▁ ▁ ▁ ▁ def ▁ is _ empty ( self ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ len ( self ) ▁ = = ▁ 0 def ▁ queue _ time ( customers , n ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 1 , len ( customers ) ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ i ▁ = ▁ i % n ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ while ▁ i % n < n ▁ and ▁ customers [ i % n ] > customers [ ( i + 1 ) % n ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ i + = 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ customers [ i % n ] ▁ = customers [ i % n ] ▁ + ▁ customers [ i ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ customers [ i ] ▁ = ▁ 0 ▁ ▁ ▁ ▁ return ▁ customers def ▁ phi ( n ) : ▁ ▁ ▁ ▁ result ▁ = ▁ n ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 2 , int ( pow ( n , 0.5 ) ) + 1 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ while ▁ n % i ▁ = = ▁ 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ n / = i ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ result - = result / i ▁ ▁ ▁ ▁ if ▁ n > 1 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ result ▁ - = ▁ result / n ▁ ▁ ▁ ▁ return ▁ result ''' def main ( ) : input = stdin . buffer . readline for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) cur = 0 ans = 0 for i in range ( n ) : cur += 1 if cur == a [ i ] : ans += 1 cur = 0 print ( ans ) main ( ) NEW_LINE +" +E236,"import java . util . Scanner ; public class Decoding { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; String text = sc . next ( ) ; String newText = "" "" ; int i = 0 ; while ( num != 0 ) { if ( num % 2 != 0 ) { newText = newText + text . toCharArray ( ) [ i ] ; } else { newText = text . toCharArray ( ) [ i ] + newText ; } num -- ; i ++ ; } System . out . println ( newText ) ; } } +","n = int ( input ( ) ) s = list ( str ( input ( ) ) ) r = [ "" "" ] * nif n % 2 != 0 : j = n // 2 for i in range ( n ) : if i % 2 == 0 : r [ j + i ] = s [ i ] j += i else : r [ j - i ] = s [ i ] j -= ielse : j = ( n // 2 ) - 1 for i in range ( n ) : if i % 2 != 0 : r [ j + i ] = s [ i ] j += i else : r [ j - i ] = s [ i ] j -= i   print ( "" "" . join ( r ) ) NEW_LINE +" +E237,"import java . io . * ; import java . util . * ;   public class Main { private static long binarySearch1 ( long [ ] arr , long tar ) { int low = 0 ; int high = arr . length - 1 ; long ans = - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( arr [ mid ] <= tar ) { low = mid + 1 ; ans = arr [ mid ] ; } else { high = mid - 1 ; } } return ans ; } private static long binarySearch2 ( long [ ] arr , long tar ) { int low = 0 ; int high = arr . length - 1 ; long ans = - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( arr [ mid ] >= tar ) { high = mid - 1 ; ans = arr [ mid ] ; } else { low = mid + 1 ; } } return ans ; } private static long solve ( long [ ] a , long [ ] b , long [ ] c ) { long min = Long . MAX_VALUE ; for ( long i : b ) { long j = binarySearch1 ( a , i ) ; long k = binarySearch2 ( c , i ) ; if ( j == - 1 || k == - 1 ) { continue ; } min = Math . min ( min , ( i - j ) * ( i - j ) + ( k - i ) * ( k - i ) + ( k - j ) * ( k - j ) ) ; } return min ; } public static void main ( String [ ] args ) throws IOException { +","mod = 1000000007 eps = 10 ** - 9     def main ( ) : import sys from bisect import bisect_left input = sys . stdin . buffer . readline   def calc ( r , g , b ) : return ( r - g ) ** 2 + ( g - b ) ** 2 + ( b - r ) ** 2   for _ in range ( int ( input ( ) ) ) : NR , NG , NB = map ( int , input ( ) . split ( ) ) R = list ( map ( int , input ( ) . split ( ) ) ) G = list ( map ( int , input ( ) . split ( ) ) ) B = list ( map ( int , input ( ) . split ( ) ) ) R . sort ( ) B . sort ( ) G . sort ( ) ans = float ( ' inf ' )   NEW_LINE +" +E238,"import java . util . * ;   public class Main { static Scanner input = new Scanner ( System . in ) ; static int mod = 1000000007 ;   public static void main ( String [ ] args ) { int n = input . nextInt ( ) , l , r , lenth ; for ( int i = 0 ; i < n ; i ++ ) { l = input . nextInt ( ) ; r = input . nextInt ( ) ; lenth = r - l + 1 ; if ( l % 2 == 1 ) { if ( lenth % 2 == 1 ) { System . out . println ( - l - ( lenth - 1 ) / 2 ) ; } else { System . out . println ( lenth / 2 ) ; } } else { if ( lenth % 2 == 1 ) { System . out . println ( l + ( lenth - 1 ) / 2 ) ; } else { System . out . println ( - lenth / 2 ) ; } } } input . close ( ) ; }   public static int modulo ( int dividend ) { while ( dividend >= mod ) dividend -= mod ; return dividend ; }   public static int combination ( int n , int r ) { int ans = 1 ; for ( int i = 1 ; i <= r ; i ++ ) { ans *= ( n - i + 1 ) ; ans /= i ; } return ans ; } }   +","import math   def total ( l , r ) : l -= 1 if l % 2 == 0 : l /= 2 else : l = int ( math . ceil ( l / 2 ) * - 1 ) if r % 2 == 0 : r /= 2 else : r = int ( math . ceil ( r / 2 ) * - 1 ) return int ( r - l )   q = int ( input ( ) ) ans = "" ""   for i in range ( q ) : l , r = map ( int , input ( ) . split ( ) ) ans += str ( total ( l , r ) ) + "" \n ""   print ( ans ) NEW_LINE +" +E239,"import java . io . * ; import java . util . * ;   public class B_1095 { static PrintWriter pw = new PrintWriter ( System . out ) ;   public static void main ( String arg [ ] ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; StringTokenizer token = new StringTokenizer ( "" ▁ "" ) ;   int i = 0 ; int j = 0 ; int x = 0 ; int n = 0 ; int arr [ ] ;   n = Integer . parseInt ( br . readLine ( ) ) ; arr = new int [ n ] ;   token = new StringTokenizer ( br . readLine ( ) ) ;   for ( j = 0 ; j <= n - 1 ; j ++ ) arr [ j ] = Integer . parseInt ( token . nextToken ( ) ) ;   pw . println ( getResult ( n , arr ) ) ;   pw . close ( ) ;   }   private static int getResult ( int n , int arr [ ] ) {   int i = 0 ; int sum = 0 ; int min = Integer . MAX_VALUE ; int min2 = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; int max2 = Integer . MIN_VALUE ;   int minpos = - 1 ; int maxpos = - 1 ;    for ( i = 0 ; i <= n - 1 ; i ++ ) { if ( arr [ i ] > max ) { max = arr [ i ] ; maxpos = i ; }   if ( arr [ i ] < min ) { min = arr [ i ] ; minpos = i ; } }   for ( i = 0 ; i <= n - 1 ; i ++ ) { if ( arr [ i ] > max2 && i != maxpos ) max2 = arr [ i ] ;   if ( arr [ i ] < min2 && i != minpos ) min2 = arr [ i ] ; } return Math . min ( max - min2 , max2 - min ) ;   } } +","n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] a . sort ( ) print ( min ( a [ - 2 ] - a [ 0 ] , a [ - 1 ] - a [ 1 ] ) ) NEW_LINE +" +E240,"import java . util . Scanner ;   public class Problem275A {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a [ ] [ ] = new int [ 5 ] [ 5 ] ; for ( int i = 1 ; i <= 3 ; i ++ ) for ( int j = 1 ; j <= 3 ; j ++ ) a [ i ] [ j ] = sc . nextInt ( ) ; for ( int i = 1 ; i <= 3 ; i ++ ) { for ( int j = 1 ; j <= 3 ; j ++ ) { if ( ( a [ i ] [ j ] + a [ i ] [ j + 1 ] + a [ i + 1 ] [ j ] + a [ i - 1 ] [ j ] + a [ i ] [ j - 1 ] ) % 2 == 0 ) System . out . print ( ""1"" ) ; else System . out . print ( ""0"" ) ; } System . out . println ( ) ; } } } +","lights = [ [ 1 for _ in range ( 3 ) ] for _ in range ( 3 ) ] count = [ ] for _ in range ( 3 ) : count . append ( [ int ( i ) for i in input ( ) . split ( ' ▁ ' ) ] )   for i , row in enumerate ( count ) : for j , val in enumerate ( row ) : if val % 2 == 1 : lights [ i ] [ j ] = 0 if lights [ i ] [ j ] == 1 else 1 if i > 0 : lights [ i - 1 ] [ j ] = 0 if lights [ i - 1 ] [ j ] == 1 else 1 if i < 2 : lights [ i + 1 ] [ j ] = 0 if lights [ i + 1 ] [ j ] == 1 else 1 if j > 0 : lights [ i ] [ j - 1 ] = 0 if lights [ i ] [ j - 1 ] == 1 else 1 if j < 2 : lights [ i ] [ j + 1 ] = 0 if lights [ i ] [ j + 1 ] == 1 else 1   for row in lights : print ( ' ' . join ( [ str ( i ) for i in row ] ) ) NEW_LINE +" +E241,"  import java . util . Scanner ; import java . util . Arrays ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int n , m , i , j , c , k ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ m ] ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } k = 0 ; for ( i = 0 ; i < n ; i ++ ) { c = a [ i ] [ 0 ] ; for ( j = 0 ; j < m ; j ++ ) { if ( a [ i ] [ j ] < c ) c = a [ i ] [ j ] ; } if ( c > k ) k = c ; } System . out . println ( k ) ; } catch ( Exception e ) { } } } +","n , m = map ( int , input ( ) . split ( ) ) ans = 1 for _ in range ( n ) : a = list ( map ( int , input ( ) . split ( ) ) ) ans = max ( ans , min ( a ) ) print ( ans ) NEW_LINE +" +E242,"import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . FileOutputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . BitSet ; import java . util . Calendar ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . PriorityQueue ; import java . util . SortedSet ; import java . util . Stack ; import java . util . StringTokenizer ; import java . util . TreeMap ; import java . util . TreeSet ;   public class B_VK2017_Round3 {   public static long MOD = 1000000007 ;   public static void main ( String [ ] args ) throws FileNotFoundException { +","n = int ( input ( ) ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] solved = [ 0 for i in range ( 5 ) ] score = [ 0 for i in range ( 5 ) ] for i in range ( n ) : for j in range ( 5 ) : solved [ j ] += int ( a [ i ] [ j ] > - 1 ) for k in range ( 31 * n + 1 ) : for i in range ( 5 ) : tot = n + k cur = solved [ i ] if a [ 0 ] [ i ] > - 1 and a [ 1 ] [ i ] > - 1 and a [ 0 ] [ i ] > a [ 1 ] [ i ] : cur += k score [ i ] = 500 while score [ i ] < 3000 and 2 * cur <= tot : cur *= 2 ; score [ i ] += 500 res = [ 0 , 0 ] for j in range ( 2 ) : for i in range ( 5 ) : if a [ j ] [ i ] > - 1 : res [ j ] += score [ i ] / 250 * ( 250 - a [ j ] [ i ] ) if res [ 0 ] > res [ 1 ] : print ( k ) exit ( ) print ( "" - 1"" ) NEW_LINE +" +E243,"import java . util . * ; import java . io . * ;   public class freebies { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String a = br . readLine ( ) ; a = br . readLine ( ) ; String [ ] info = a . split ( "" ▁ "" ) ; int [ ] left = new int [ 1002 ] ; int max = 0 ; for ( int z = 0 ; z < info . length ; z ++ ) { int current = Integer . parseInt ( info [ z ] ) ; left [ current ] ++ ; max = Math . max ( max , left [ current ] ) ; } for ( int z = 1 ; z < left . length ; z ++ ) { left [ z ] += left [ z - 1 ] ; } a = br . readLine ( ) ; int dist = Integer . parseInt ( a ) + 1 ; for ( int z = dist ; z < left . length ; z ++ ) { max = Math . max ( max , left [ z ] - left [ z - dist ] ) ; } System . out . println ( max ) ; } } +","import osimport sysfrom io import BytesIO , IOBase   BUFSIZE = 8192     class FastIO ( IOBase ) : newlines = 0   def __init__ ( self , file ) : self . _fd = file . fileno ( ) self . buffer = BytesIO ( ) self . writable = "" x "" in file . mode or "" r "" not in file . mode self . write = self . buffer . write if self . writable else None   def read ( self ) : while True : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) if not b : break ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines = 0 return self . buffer . read ( )   def readline ( self ) : while self . newlines == 0 : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) self . newlines = b . count ( b "" \n "" ) + ( not b ) ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines -= 1 return self . buffer . readline ( )   def flush ( self ) : if self . writable : os . write ( self . _fd , self . buffer . getvalue ( ) ) self . buffer . truncate ( 0 ) , self . buffer . seek ( 0 )     class IOWrapper ( IOBase ) : def __init__ ( self , file ) : self . buffer = FastIO ( file ) self . flush = self . buffer . flush self . writable = self . buffer . writable self . write = lambda s : self . buffer . write ( s . encode ( "" ascii "" ) ) self . read = lambda : self . buffer . read ( ) . decode ( "" ascii "" ) self . readline = lambda : self . buffer . readline ( ) . decode ( "" ascii "" )     sys . stdin , sys . stdout = IOWrapper ( sys . stdin ) , IOWrapper ( sys . stdout ) input = lambda : sys . stdin . readline ( ) . rstrip ( "" \n "" ) NEW_LINE +" +E244,"import java . util . * ; import java . io . * ;   public class CF { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ;   +","import sys   from collections import defaultdict   POINTS_WIN = 3 POINTS_DRAW = 1 POINTS_LOSS = 0     def sort_order ( item : dict ) -> tuple : return - item [ "" points "" ] , - item [ "" score _ diff "" ] , - item [ "" score "" ]     def standings ( teams : list , games : list ) -> list : teams_data = { t : defaultdict ( int , { "" name "" : t } ) for t in teams } for lt , rt , ls , rs in games : teams_data [ lt ] [ "" score "" ] += ls teams_data [ rt ] [ "" score "" ] += rs   if ls == rs : teams_data [ lt ] [ "" points "" ] += POINTS_DRAW teams_data [ rt ] [ "" points "" ] += POINTS_DRAW elif ls < rs : teams_data [ lt ] [ "" points "" ] += POINTS_LOSS teams_data [ lt ] [ "" score _ diff "" ] -= rs - ls teams_data [ rt ] [ "" points "" ] += POINTS_WIN teams_data [ rt ] [ "" score _ diff "" ] += rs - ls else : teams_data [ lt ] [ "" points "" ] += POINTS_WIN teams_data [ lt ] [ "" score _ diff "" ] += ls - rs teams_data [ rt ] [ "" points "" ] += POINTS_LOSS teams_data [ rt ] [ "" score _ diff "" ] -= ls - rs   return list ( sorted ( teams_data . values ( ) , key = sort_order ) )     def parse_teams ( n : int ) -> list : teams = [ ] for i in range ( n ) : teams . append ( input ( ) ) return teams     def parse_games ( n : int ) -> list : games = [ ] for _ in range ( int ( n * ( n - 1 ) / 2 ) ) : line = sys . stdin . readline ( ) . strip ( ) teams , scores = line . split ( "" ▁ "" ) left_team , right_team = teams . split ( "" - "" ) left_score , right_score = map ( int , scores . split ( "" : "" ) ) games . append ( ( left_team , right_team , left_score , right_score ) )   return games     if __name__ == "" _ _ main _ _ "" : n = int ( input ( ) ) teams = parse_teams ( n ) games = parse_games ( n )   NEW_LINE +" +E245,"import java . util . * ; import java . math . * ; public class RockAndLever { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int size = sc . nextInt ( ) ; long [ ] arr = new long [ 33 ] ; for ( int i = 0 ; i < size ; i ++ ) { arr [ Integer . numberOfLeadingZeros ( sc . nextInt ( ) ) ] ++ ; } long out = 0 ; for ( int i = 1 ; i < 33 ; i ++ ) { out += arr [ i ] * ( arr [ i ] - 1 ) / 2 ; } System . out . println ( out ) ; } } } +","from math import log2   for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) )   d = dict ( )   for i in range ( len ( a ) ) : a [ i ] = int ( log2 ( a [ i ] ) )   NEW_LINE +" +E246,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { static class FastScanner { 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 [ ] nextArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long [ ] nextArray ( long n ) { long [ ] a = new long [ ( int ) n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } static class FastWriter extends PrintWriter { FastWriter ( ) { super ( System . out ) ; } void println ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + "" ▁ "" ) ; } println ( ) ; } void println ( long [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + "" ▁ "" ) ; } println ( ) ; } } public static void main ( String [ ] args ) { FastScanner in = new FastScanner ( ) ; FastWriter out = new FastWriter ( ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { out . print ( i + "" ▁ "" ) ; } out . println ( ) ; } out . close ( ) ; } } +","t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT +" +E247,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ;   int n = input . nextInt ( ) ; String s = input . next ( ) ; int a [ ] = new int [ n ] ; int left = - 1 ; int right = - 1 ; int count = 0 ; int ans [ ] = new int [ n ] ; Arrays . fill ( ans , 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' L ' && right == - 1 ) { for ( int j = 0 ; j <= i ; j ++ ) { ans [ j ] = 0 ; } left = - 1 ; right = - 1 ; } else if ( s . charAt ( i ) == ' L ' && right != - 1 ) { for ( int j = right ; j <= i ; j ++ ) { ans [ j ] = 0 ; } if ( ( i - right + 1 ) % 2 != 0 ) ans [ right ] = 1 ; left = - 1 ; right = - 1 ; } else if ( s . charAt ( i ) == ' R ' && right != - 1 ) { for ( int j = right ; j < n ; j ++ ) { ans [ j ] = 0 ; } } else if ( s . charAt ( i ) == ' R ' ) { right = i ; } } if ( right != - 1 && left == - 1 ) { for ( int i = right ; i < n ; i ++ ) { ans [ i ] = 0 ; } } for ( int i = 0 ; i < n ; i ++ ) { count += ans [ i ] ; } +","class Stack ( ) : def __init__ ( self ) : self . stack = [ ] self . len = 0   def top ( self ) : assert not self . empty ( ) return self . stack [ self . len - 1 ]   def pop ( self ) : assert not self . empty ( ) self . len -= 1 return self . stack . pop ( )   def push ( self , x ) : self . len += 1 self . stack . append ( x )   def empty ( self ) : return self . len == 0   def calc ( n , pos ) : st = Stack ( ) last_pos = - 1 ans = 0 for i in range ( n ) : if pos [ i ] == "" R "" : if st . empty ( ) : ans += i - last_pos - 1 st . push ( i ) elif pos [ i ] == "" L "" : if st . empty ( ) : last_pos = i else : left_R = st . pop ( ) ; ans += ( i - left_R + 1 ) % 2 last_pos = i if st . empty ( ) : ans += n - last_pos - 1 return ans     n = int ( input ( ) ) pos = str ( input ( ) ) print ( calc ( n , pos ) ) NEW_LINE +" +E248,"  import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; import java . util . Stack ;    public class UkkonenForPreXSufEditTest { static int [ ] suffixOccurrences ; static Node root ; +","from functools import cmp_to_key           def calc_lcp ( s , sa ) :   rank = [ 0 for _ in range ( len ( s ) ) ]   for i in range ( len ( s ) ) :   rank [ sa [ i ] ] = i   lcp = [ 0 for _ in range ( len ( s ) - 1 ) ]   h = 0   for i in range ( len ( s ) ) :   if rank [ i ] < len ( s ) - 1 :   while max ( i , sa [ rank [ i ] + 1 ] ) + h < len ( s ) and s [ i + h ] == s [ sa [ rank [ i ] + 1 ] + h ] :   h += 1   lcp [ rank [ i ] ] = h   if h > 0 :   h -= 1   return lcp , rank       def suffix_array ( s ) :   sa = [ i for i in range ( len ( s ) ) ]   rank = [ ord ( s [ i ] ) for i in range ( len ( s ) ) ]   k = 1   while k < len ( s ) :   key = [ 0 for _ in range ( len ( s ) ) ]   base = max ( rank ) + 2   for i in range ( len ( s ) ) :   key [ i ] = rank [ i ] * base + ( rank [ i + k ] + 1 if i + k < len ( s ) else 0 )   sa . sort ( key = ( lambda i : key [ i ] ) )       rank [ sa [ 0 ] ] = 0   for i in range ( 1 , len ( s ) ) :   rank [ sa [ i ] ] = rank [ sa [ i - 1 ] ] if key [ sa [ i - 1 ] ] == key [ sa [ i ] ] else i   k *= 2   NEW_LINE +" +E249,"import java . util . * ; import java . io . * ;   public class Main { class FastScanner { 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 ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastScanner scan = new Main ( ) . new FastScanner ( ) ; int t = scan . nextInt ( ) ; while ( t -- > 0 ) {   int n = scan . nextInt ( ) ; int a [ ] = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = scan . nextInt ( ) ; if ( a [ i ] <= 2048 ) { sum += a [ i ] ; } } if ( sum >= 2048 ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } } } +","from sys import stdin     for _ in range ( int ( stdin . readline ( ) ) ) : n = int ( stdin . readline ( ) ) a = list ( map ( int , stdin . readline ( ) . split ( ) ) ) res = False total = 0 for i in a : if i < 2048 : total += i elif i == 2048 : res = True break if total >= 2048 : res = True   print ( ' YES ' if res else ' NO ' ) NEW_LINE +" +E250,"import java . util . * ;   public class VotingPhotos {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; HashMap < Integer , Integer > hm = new HashMap < > ( ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int like = 1 ; int id = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( ! hm . containsKey ( a [ i ] ) ) { hm . put ( a [ i ] , 1 ) ; } else { int value = hm . get ( a [ i ] ) ; value ++ ; hm . put ( a [ i ] , value ) ; if ( value > like ) { like = value ; id = a [ i ] ; } } } if ( id == 0 ) { System . out . println ( a [ 0 ] ) ; } else { System . out . println ( id ) ; } } } +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) k = 0 pas = 0 a = a [ : : - 1 ] for i in set ( a ) : s = a . count ( i ) if s > k : pas = i k = s elif s == k : if a . index ( i ) > a . index ( pas ) : pas = i k = a . count ( i ) print ( pas ) NEW_LINE +" +E251,"  import java . util . * ; import java . lang . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scn = new Scanner ( System . in ) ; int t = scn . nextInt ( ) ; while ( t -- > 0 ) { int d = scn . nextInt ( ) ; long a = d + 1 ; a = primeNext ( a ) ; long b = a + d ; b = primeNext ( b ) ; long ans = a * b ; System . out . println ( ans ) ; } } public static long primeNext ( long n ) { while ( true ) { if ( isPrime ( n ) ) { break ; } else { n ++ ; } } return n ; } public static boolean isPrime ( long n ) { boolean flag = true ; for ( long i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { flag = false ; break ; } } return flag ; } } +","for _ in range ( int ( input ( ) ) ) : d = int ( input ( ) ) NEW_LINE def prime ( a ) : for NEW_LINE i in range ( 2 , int ( a ** 0.5 ) + 1 ) : NEW_LINE if a % i == 0 : return False NEW_LINE return True NEW_LINE k = 1 NEW_LINE b = k + d NEW_LINE while not prime ( b ) : b += 1 NEW_LINE k *= b NEW_LINE p = k + d NEW_LINE while not prime ( p ) : p += 1 NEW_LINE print ( k * p ) NEW_LINE +" +E252,"import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { +","n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) s = sum ( l )   def solve ( ) : if s < n : return [ - 1 ] for i in range ( m ) : if l [ i ] > n - i : return [ - 1 ]   ov = s - n idx = 1 sln = [ ]   for i in range ( m ) : if ov > 0 and idx != 1 : d = min ( ov , l [ i - 1 ] - 1 ) idx -= d ov -= d sln . append ( idx ) idx += l [ i ]   return sln   print ( * solve ( ) ) NEW_LINE +" +E253,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Solution { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   public static void main ( String [ ] args ) throws IOException {   int n = nextInt ( ) ; int inp [ ] = readIntArray ( ) ; int min1 = inp [ 0 ] , max1 = inp [ 1 ] ; inp = readIntArray ( ) ; int min2 = inp [ 0 ] , max2 = inp [ 1 ] ; inp = readIntArray ( ) ; int min3 = inp [ 0 ] , max3 = inp [ 1 ] ;   int res1 = min1 , res2 = min2 , res3 = min3 ; int tot = ( res1 + res2 + res3 ) ; if ( tot < n ) { res1 += Math . min ( ( n - tot ) , ( max1 - res1 ) ) ; tot = ( res1 + res2 + res3 ) ; } if ( tot < n ) { res2 += Math . min ( ( n - tot ) , ( max2 - res2 ) ) ; tot = ( res1 + res2 + res3 ) ; }   if ( tot < n ) { res3 += Math . min ( ( n - tot ) , ( max3 - res3 ) ) ; } println ( res1 + "" ▁ "" + res2 + "" ▁ "" + res3 ) ; }   public static void swap ( int arr [ ] , int from , int to ) { println ( "" swapping : ▁ "" + from + "" ▁ & ▁ "" + to ) ; int temp = arr [ from ] ; arr [ from ] = arr [ to ] ; arr [ to ] = temp ; }    +","n = int ( input ( ) ) mn1 , mx1 = map ( int , input ( ) . split ( ) ) mn2 , mx2 = map ( int , input ( ) . split ( ) ) mn3 , mx3 = map ( int , input ( ) . split ( ) )   fd = n - mn2 - mn3if fd > mx1 : fd = mx1n -= fdsd = n - mn3if sd > mx2 : sd = mx2td = n - sdprint ( fd , sd , td ) NEW_LINE +" +E254,"import javax . print . DocFlavor ; import java . io . * ; import java . net . Inet4Address ; import java . sql . ClientInfoStatus ; import java . util . * ;   +","n , k = map ( int , input ( ) . split ( ) ) s = input ( ) d = { }   val = 0 ; i = 0 while i < n : count = 1 ch = s [ i ] i += 1 while i < n : if s [ i ] == s [ i - 1 ] : count += 1 i += 1 else : break d [ ch ] = d . get ( ch , 0 ) + ( count // k )   print ( max ( d . values ( ) ) ) NEW_LINE +" +E255,"  import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class experiment { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ;   +","from collections import defaultdict as dcdef mlt ( ) : return map ( int , input ( ) . split ( ) ) def arp ( ) : return [ * mlt ( ) ]     s = input ( ) mp = dc ( lambda : 0 ) for n in s : mp [ ord ( n ) - 97 ] += 1 cntr = 0 for n in s : if mp [ ord ( n ) - 97 ] % 2 : cntr += 1   if cntr <= 1 : print ( ' First ' ) else : s1 = [ ' Second ' , ' First ' ] print ( s1 [ len ( s ) % 2 ] ) NEW_LINE +" +E256,"import java . util . * ; import static java . lang . Math . pow ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; System . out . println ( ( ( n & 1 ) == 0 ) ? ( int ) pow ( 2 , n / 2 ) : 0 ) ; } } +","def dp ( n ) : if n < 0 : return 0 if not n : return 1 return 2 * dp ( n - 2 ) print ( dp ( int ( input ( ) ) ) ) NEW_LINE +" +E257,"import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { int x , y , z ; Student ( int x , int y , int z ) { this . x = x ; this . y = y ; this . z = z ; } } static int prime [ ] ; static void sieveOfEratosthenes ( int n ) { +","def add ( vertex , neighbour ) : if vertex in graph : graph [ vertex ] . append ( neighbour ) else : graph [ vertex ] = [ neighbour ] if neighbour in graph : NEW_LINE +" +E258,"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( 1 ) ; if ( n == 1 ) { System . out . println ( ""1"" ) ; return ; } int i = 2 , d = 1 ; while ( i < n ) { if ( n % i == 0 ) { list . add ( i ) ; d = i ; } i += d ; } list . add ( n ) ; for ( i = list . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( list . get ( i ) + "" ▁ "" ) ; } } } +","n = int ( input ( ) ) NEW_LINE for i in range ( n , 0 , - 1 ) : if NEW_LINE n % i == 0 : n = i NEW_LINE print ( i , end = ' ▁ ' ) NEW_LINE +" +E259,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Math . * ; import static java . lang . System . out ; import java . util . * ; import java . io . PrintStream ; import java . io . PrintWriter ; public class A { static final int N = ( int ) ( 1e5 + 100 ) ; static final int mod = 1000000007 ; static final long temp = 998244353 ; static final long MOD = 1000000007 ; static final long M = ( long ) 1e9 + 7 ; static class Pair implements Comparable < Pair > { long first , second ; public Pair ( long aa , long bb ) { first = aa ; second = bb ; } public int compareTo ( Pair o ) { return ( int ) ( o . first - this . first ) ; } } static class Tuple implements Comparable < Tuple > { long first , second , third ; public Tuple ( long first , long second , long third ) { this . first = first ; this . second = second ; this . third = third ; } public int compareTo ( Tuple o ) { return ( int ) ( o . third - this . third ) ; } } public static class DSU { int [ ] parent ; int [ ] rank ; +","import sysimport math   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) i = 1 ans = [ a [ 0 ] ] while i < n : if math . gcd ( ans [ - 1 ] , a [ i ] ) == 1 : ans . append ( a [ i ] ) i += 1 else : ans . append ( 1 ) print ( len ( ans ) - n ) print ( * ans ) NEW_LINE +" +E260,"import java . util . * ; public class ChessCheater {   public static void main ( String [ ] args ) { +","t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE s = list ( s ) NEW_LINE sum = 1 NEW_LINE j = 0 NEW_LINE for i in range ( n ) : if NEW_LINE s [ i ] == ' W ' : j = i NEW_LINE break NEW_LINE l = j NEW_LINE j = j + 1 NEW_LINE lst = [ ] NEW_LINE while j < n : if NEW_LINE s [ l ] == s [ j ] and j - l == 1 : j += 1 NEW_LINE l += 1 elif s [ l ] == s [ j ] and j - l > 1 : lst . append ( [ j - l - 1 , l + 1 ] ) NEW_LINE l = j NEW_LINE j += 1 else : j += 1 NEW_LINE +" +E261,"import java . nio . file . LinkOption ; import java . util . * ; public class Example { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int n = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . length ( ) == 2 ) { int a = Integer . parseInt ( String . valueOf ( s . charAt ( 0 ) ) ) ; int b = Integer . parseInt ( String . valueOf ( s . charAt ( 1 ) ) ) ; if ( b > a ) { System . out . println ( "" YES "" ) ; System . out . println ( 2 ) ; System . out . println ( s . charAt ( 0 ) + "" ▁ "" + s . charAt ( 1 ) ) ; } else System . out . println ( "" NO "" ) ; } else { System . out . println ( "" YES "" ) ; System . out . println ( 2 ) ; System . out . println ( s . substring ( 0 , 1 ) + "" ▁ "" + s . substring ( 1 ) ) ; }   t -- ; } } } +","t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) s = input ( ) if n == 2 : if int ( s [ 0 ] ) >= int ( s [ 1 ] ) : print ( "" NO "" ) else : print ( "" YES "" ) print ( 2 ) print ( s [ 0 ] , s [ 1 ] ) else : print ( "" YES "" ) print ( 2 ) print ( s [ 0 ] , s [ 1 : ] ) NEW_LINE +" +E262,"import java . util . * ; public class Pangram { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; String str = s . next ( ) ; if ( n < 26 ) { System . out . println ( "" NO "" ) ; } else { int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { char a = str . charAt ( i ) ; if ( a >= 65 && a <= 91 ) { arr [ a - 65 ] ++ ; } else if ( a >= 97 && a <= 122 ) { arr [ a - 97 ] ++ ; } } int flag = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] == 0 ) { System . out . println ( "" NO "" ) ; flag = 1 ; break ; } } if ( flag == 0 ) { System . out . println ( "" YES "" ) ; } } } } +","n = int ( input ( ) ) s = input ( ) t = s . upper ( ) if len ( set ( t ) ) == 26 : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E263,"import java . util . * ; import java . io . * ; import java . math . * ; public class Main { +","a = input ( ) . rjust ( 10 ** 6 , ""0"" ) b = input ( ) . rjust ( 10 ** 6 , ""0"" ) if a > b : print ( "" > "" ) elif a < b : print ( "" < "" ) elif a == b : print ( "" = "" ) NEW_LINE +" +E264,"import java . util . * ; import java . io . * ; public class A { static FastReader in = new FastReader ( ) ; static final Random random = new Random ( ) ; static long mod = 1000000007L ; static HashMap < Integer , Integer > map = new HashMap < > ( ) ;   public static void main ( String args [ ] ) throws IOException { int t = 1 ; +","n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c = 1 ans = 0 for i in range ( n - 1 ) : if 2 * l [ i ] >= l [ i + 1 ] : c = c + 1 else : ans = max ( c , ans ) c = 1 ans = max ( ans , c ) print ( ans ) NEW_LINE +" +E265,"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B911 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) {   int tc = 1 ; +","'''   ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Online ▁ Python ▁ Compiler . ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Code , ▁ Compile , ▁ Run ▁ and ▁ Debug ▁ python ▁ program ▁ online . Write ▁ your ▁ code ▁ in ▁ this ▁ editor ▁ and ▁ press ▁ "" Run "" ▁ button ▁ to ▁ execute ▁ it .   '''   n , a , b = map ( int , input ( ) . split ( ) ) mnn = - 1 for i in range ( 1 , n ) : k = n - i p = a // i q = b // k mn = min ( p , q ) NEW_LINE +" +E266,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . ArrayList ; import java . util . TreeSet ; import java . util . Collections ; import java . util . List ; public class Hello { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; +","s = input ( ) n = len ( s ) sett = { }   for i in range ( n ) : if s [ i ] not in sett : sett [ s [ i ] ] = [ ] sett [ s [ i ] ] . append ( s [ i + 1 : ] + s [ : i ] ) ans = 0   NEW_LINE +" +E267,"import java . util . * ; import java . io . * ; import java . math . * ; public class Main { +","a = list ( input ( ) ) x = a . index ( "" ^ "" ) l = 0 r = 0 for i , j in enumerate ( a ) : if i < x and j != "" = "" : l += int ( j ) * ( x - i ) if i > x and j != "" = "" : r += int ( j ) * ( i - x ) if l > r : print ( "" left "" ) elif r > l : print ( "" right "" ) else : print ( "" balance "" ) NEW_LINE +" +E268,"import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; for ( int i = 1 ; i <= q ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int d = sc . nextInt ( ) ;   int ans1 = ( l - 1 ) / d ; if ( ans1 > 0 ) { ans1 = d ; } else { ans1 = ( int ) ( Math . ceil ( ( r + 1 ) / ( double ) d ) ) * d ; } System . out . println ( ans1 ) ; }    }      public static long power ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = ans * a ; ans %= c ; } a = a * a ; a %= c ; b /= 2 ; } return ans ; }   public static long power1 ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = multiply ( ans , a , c ) ; } a = multiply ( a , a , c ) ; b /= 2 ;   } return ans ;   }   public static long multiply ( long a , long b , long c ) { long res = 0 ; a %= c ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res + a ) % c ; } a = ( a + a ) % c ; b /= 2 ; }   return res % c ;   }   public static long totient ( long n ) { long result = n ; for ( long i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { +","t = int ( input ( ) ) for _ in range ( t ) : a , b , c = map ( int , input ( ) . split ( ) ) if c < a : print ( c ) else : if b % c == 0 : print ( b + c ) else : print ( ( c + b ) - b % c ) NEW_LINE +" +E269,"import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int a ; int sum = 0 ; if ( x > y ) { sum += y ; a = x - y ; } else { sum += x ; a = y - x ; } if ( a <= z ) { sum = sum + ( a + z ) / 2 ; } else { sum = sum + z ; } sum *= 2 ; System . out . println ( sum ) ; } } +","l , r , a = map ( int , input ( ) . split ( ) ) while a > 0 : if l < r : l = l + 1 else : r = r + 1 a = a - 1 print ( min ( l , r ) * 2 ) NEW_LINE +" +E270,"import java . util . * ; import java . io . * ; public class Main { int a ; public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; int a [ ] = new int [ t ] ; int temp [ ] = new int [ 4 ] ; TreeMap < Integer , Integer > T = new TreeMap < > ( ) ; for ( int i = 0 ; i < t ; ++ i ) { a [ i ] = scan . nextInt ( ) ; temp [ a [ i ] ] ++ ; } Arrays . sort ( temp ) ; System . out . print ( temp [ 1 ] + temp [ 2 ] ) ; } } +","from statistics import moden = int ( input ( ) ) list_of_numbers = [ int ( x ) for x in input ( ) . split ( ) ] m = mode ( list_of_numbers ) print ( n - list_of_numbers . count ( m ) ) NEW_LINE +" +E271,"import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ;     public class Main { public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; int n , c ; n = input . nextInt ( ) ; c = input . nextInt ( ) ; long limak = 0 , Rad = 0 ; int a [ ] = new int [ n ] ; int t [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { t [ i ] = input . nextInt ( ) ; } long time = 0 ; for ( int i = 0 ; i < n ; i ++ ) { time += t [ i ] ; limak += Math . max ( 0 , a [ i ] - ( c * time ) ) ; } time = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { time += t [ i ] ; Rad += Math . max ( 0 , a [ i ] - ( c * time ) ) ; } +","def main ( ) : petya_score = 0 vigen_score = 0 petya_time = 0 vigen_time = 0 n , c = map ( int , input ( ) . split ( ) ) task_price = list ( map ( int , input ( ) . split ( ) ) ) task_time = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 0 , n ) : NEW_LINE +" +E272,"import java . io . * ; import java . util . * ;   public class Test {   static FastScanner sc ; static boolean [ ] visited ; static int four = 0 , seven = 0 ;   public static void main ( String args [ ] ) { sc = new FastScanner ( System . in ) ; solve ( ) ; }   public static void solve ( ) { int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; }   int a = 0 , b = 0 , c = 0 , d = 0 ; for ( int i = 1 ; i < arr . length ; i ++ ) { a = Math . min ( arr [ i - 1 ] , arr [ i ] ) ; b = Math . max ( arr [ i - 1 ] , arr [ i ] ) ;   for ( int j = i + 1 ; j < arr . length ; j ++ ) { c = Math . min ( arr [ j - 1 ] , arr [ j ] ) ; d = Math . max ( arr [ j - 1 ] , arr [ j ] ) ;   +","n = int ( input ( ) ) x = FalseA = [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( n - 2 ) : x1 , x2 = min ( A [ i ] , A [ i + 1 ] ) , max ( A [ i ] , A [ i + 1 ] ) for j in range ( i + 1 , n - 1 ) : X1 , X2 = min ( A [ j ] , A [ j + 1 ] ) , max ( A [ j ] , A [ j + 1 ] ) if ( x1 < X1 and X1 < x2 and x2 < X2 ) : x = True elif ( X1 < x1 and X2 > x1 and X2 < x2 ) : x = Trueif ( x ) : print ( "" yes "" ) else : print ( "" no "" ) NEW_LINE +" +E273,"import java . util . Scanner ;   public class pROBLEM39 {   public static void main ( String [ ] args ) { +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) R1 , R2 = map ( int , input ( ) . split ( ) ) print ( sum ( a [ R1 - 1 : R2 - 1 ] ) ) NEW_LINE +" +E274,"import java . util . Scanner ;   public class Holidays { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ;   int min = 0 ; int max = 0 ;   for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 7 == 0 || ( i + 1 ) % 7 == 0 ) { min ++ ; } if ( i % 7 == 1 || i % 7 == 2 ) { max ++ ; } }   System . out . println ( min ) ; System . out . println ( max ) ;   } } +","n = int ( input ( ) ) mx = n // 7 * 2 + min ( n % 7 , 2 ) mn = n // 7 * 2 + max ( n % 7 - 5 , 0 )   print ( mn , mx )     NEW_LINE +" +E275,"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int f = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { String s1 = sc . next ( ) ; if ( s1 . charAt ( 0 ) == s . charAt ( 0 ) || s1 . charAt ( 1 ) == s . charAt ( 1 ) ) { f = 1 ; } } if ( f == 1 ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } } +","tk = input ( ) m = tk [ 0 ] n = tk [ 1 ] flag = 0 inp2 = list ( map ( str , input ( ) . split ( ) ) )   for st in inp2 : if st [ 0 ] == m : print ( "" YES "" ) flag = 1 break elif st [ 1 ] == n : print ( "" YES "" ) flag = 1 break     if flag == 0 : print ( "" NO "" )                                   NEW_LINE +" +E276,"import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) +","def main ( ) : a = b = 1 for _ in range ( int ( input ( ) ) ) : s = input ( ) if s in ( "" UL "" , "" DR "" ) : a += 1 elif s in ( "" UR "" , "" DL "" ) : b += 1 elif s == "" ULDR "" : a += 1 b += 1 print ( a * b )     if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE +" +E277,"import java . io . File ; import java . io . FileNotFoundException ; import java . io . PrintWriter ; import java . util . * ;    public class LOL {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) {    int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { list . add ( sc . nextInt ( ) ) ; } SortedSet < Integer > sortedSet = new TreeSet < > ( list ) ; for ( Integer integer : sortedSet ) { if ( integer <= k + 1 ) { k = k + 1 ; } } System . out . println ( k ) ; } } } +","import sysfrom os import pathif ( path . exists ( ' input . txt ' ) and path . exists ( ' output . txt ' ) ) : sys . stdout = open ( ' output . txt ' , ' w ' ) sys . stdin = open ( ' input . txt ' , ' r ' )   NEW_LINE +" +E278,"import java . io . * ; import java . util . * ; public class Ishu { static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ; public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ; +","import io , osinput = io . BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readlinefrom collections import defaultdict , dequedef bfs ( node ) : vis [ node ] = 1 q = deque ( [ node ] ) while q : cur = q . popleft ( ) dict1 = { } for j in edge [ cur ] : if vis [ j ] == 0 : vis [ j ] = 1 q . append ( j ) if topic [ j - 1 ] == topic [ cur - 1 ] : return False if topic [ j - 1 ] < topic [ cur - 1 ] : dict1 [ topic [ j - 1 ] ] = 1 b = len ( dict1 . keys ( ) ) if b != topic [ cur - 1 ] - 1 : return False return Truen , m = list ( map ( int , input ( ) . split ( ) ) ) edge = defaultdict ( list ) for i in range ( m ) : u , v = list ( map ( int , input ( ) . split ( ) ) ) edge [ u ] . append ( v ) edge [ v ] . append ( u ) topic = list ( map ( int , input ( ) . split ( ) ) ) vis = [ 0 ] * ( n + 1 ) s = 0 for i in range ( 1 , n + 1 ) : if vis [ i ] == 0 : temp = bfs ( i ) if temp == False : s += 1 breakif s == 1 : print ( - 1 ) else : ans = [ ] for i in range ( n ) : ans . append ( [ topic [ i ] , i + 1 ] ) ans . sort ( key = lambda x : x [ 0 ] , reverse = False ) num = [ ] for i in range ( n ) : num . append ( ans [ i ] [ 1 ] ) print ( "" ▁ "" . join ( str ( x ) for x in num ) ) NEW_LINE +" +E279,"import java . util . * ;   public class _1437B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int zero = 0 , one = 0 ; for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == '1' && s . charAt ( i + 1 ) == '1' ) one ++ ; if ( s . charAt ( i ) == '0' && s . charAt ( i + 1 ) == '0' ) zero ++ ; } System . out . println ( Math . max ( zero , one ) ) ; } } } +","import sys , functools , collections , bisect , math , NEW_LINE INDENT heapqinput = sys . stdin . readline NEW_LINE DEDENT +" +E280,"import java . util . Scanner ; public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; while ( tc -- > 0 ) { int n = sc . nextInt ( ) ; if ( n % 2020 <= n / 2020 ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } sc . close ( ) ; } } +","def solve ( ) : n = int ( input ( ) ) NEW_LINE i = 0 NEW_LINE while 2021 * i <= n : if NEW_LINE ( n - ( i * 2021 ) ) % 2020 == 0 : NEW_LINE return True NEW_LINE i += 1 NEW_LINE return False       for t in range ( int ( input ( ) ) ) : if NEW_LINE solve ( ) : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE +" +E281,"import java . io . * ; import java . util . * ; public class Solution { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { boolean env = System . getProperty ( "" ONLINE _ JUDGE "" ) != null ; if ( ! env ) { try { br = new BufferedReader ( new FileReader ( "" src \\ input . txt "" ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } else 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 ; } } static FastReader sc = new FastReader ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; static long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } +","from collections import Counter     def gcd ( a , b ) : return a if b == 0 else gcd ( b , a % b )     n = int ( input ( ) ) count = Counter ( ) for e in map ( int , input ( ) . split ( ) ) : count [ e ] += 1 res = [ ] while sum ( count . values ( ) ) > 0 : cur = max ( count . keys ( ) ) count [ cur ] -= 1 if count [ cur ] == 0 : del count [ cur ] for e in res : g = gcd ( cur , e ) count [ g ] -= 2 if count [ g ] == 0 : del count [ g ] res . append ( cur ) print ( * res ) NEW_LINE +" +E282,"import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int x = sc . nextInt ( ) ; int i = 1 ; int s = 0 , count = 0 ; while ( s < x ) { s = s + i ; i ++ ; count ++ ; } int d = s - x ; if ( s == x ) System . out . println ( count ) ; else { if ( d == 1 ) System . out . println ( count + 1 ) ; else System . out . println ( count ) ; } } } } +","res = [ ]   for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE if n < 0 : NEW_LINE INDENT res . append ( - n ) else : NEW_LINE s = 0 NEW_LINE DEDENT i = 0 NEW_LINE while s < n : i += 1 NEW_LINE s += i NEW_LINE if s == n or s - n > 1 : NEW_LINE INDENT res . append ( i ) else : NEW_LINE res . append ( i + 1 )   for i in res : print ( i ) NEW_LINE DEDENT +" +E283,"   import java . io . * ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;    public class Main1 {   static class pair implements Comparable < pair > { int a ; int b ; public pair ( int a , int b ) { this . a = a ; this . b = b ; } @ Override public int compareTo ( pair o ) { +","s = input ( ) horizontal = - 1 vertical = - 1 v = [ ] h = [ ] for i in range ( len ( s ) ) : if s [ i ] == ""0"" : vertical += 1 vertical %= 2 if vertical == 0 : ans = 1 else : ans = 3 print ( ans , 1 ) else : horizontal += 1 horizontal %= 4 print ( horizontal + 1 , 2 ) NEW_LINE +" +E284,"import java . io . * ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; }   void run ( ) { long n = in . nextInt ( ) ; long n2 = n * n ; long result = 0 ; for ( long x = 0 ; x >= 1 - n ; x -- ) { long y2 = ( long ) Math . sqrt ( n2 - x * x ) - 1 ; while ( ( x - 1 ) * ( x - 1 ) + y2 * y2 > n2 ) { result += 1 ; y2 -= 1 ; } } result += n ; result *= 4 ;   if ( result <= 0 ) result = 1 ; out . println ( result ) ;   out . close ( ) ; }   +","import mathn = int ( input ( ) ) if ( n == 0 ) : print ( 1 ) elif ( n == 1 ) : print ( 4 ) elif ( n == 2 ) : print ( 8 ) elif ( n == 3 ) : print ( 16 ) else : k = 4 + 8 * ( int ( math . sqrt ( n * n / 2 ) ) ) p = int ( math . sqrt ( n * n / 2 ) ) if ( p * p + ( p + 1 ) * ( p + 1 ) > n * n ) : k -= 4 print ( k ) NEW_LINE +" +E285,"import java . io . BufferedReader ; import java . io . InputStreamReader ;   public class AandB { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { String [ ] inp = br . readLine ( ) . split ( "" ▁ "" ) ; long a = Long . parseLong ( inp [ 0 ] ) ; long b = Long . parseLong ( inp [ 1 ] ) ; if ( b > a ) { long tmp = b ; b = a ; a = tmp ; } long diff = a - b ; int i = 0 ; while ( true ) { long val = i * ( i + 1 ) ; if ( val >= 2 * diff && ( ( val / 2 ) - diff ) % 2 == 0 ) { break ; } i ++ ; } System . out . println ( i ) ; } } } +","import math as m   t = int ( input ( ) )   for i in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) mx , mn = max ( a , b ) , min ( a , b ) c = 2 * ( mx - mn ) d = 1 ** 2 + 4 * c ds = m . sqrt ( d ) n = ( ds - 1 ) / 2 n = int ( n ) if int ( n ) == n else int ( n ) + 1 n += ( n * ( n + 1 ) // 2 ) % 2 != ( mx - mn ) % 2 n += ( n * ( n + 1 ) // 2 ) % 2 != ( mx - mn ) % 2 print ( n )   NEW_LINE +" +E286,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int a1 = scanner . nextInt ( ) ; int a2 = scanner . nextInt ( ) ; int a3 = scanner . nextInt ( ) ; int b1 = scanner . nextInt ( ) ; int b2 = scanner . nextInt ( ) ; int b3 = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ;   int cups = ( int ) Math . ceil ( ( double ) ( a1 + a2 + a3 ) / 5 ) ; int medals = ( int ) Math . ceil ( ( double ) ( b1 + b2 + b3 ) / 10 ) ;   if ( cups + medals <= n ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ;   } } +","from collections import Counterimport math   def solve ( ) : a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) n = int ( input ( ) ) sum1 , sum2 = 0 , 0   for i in a : sum1 += i for i in b : sum2 += i   if math . ceil ( sum1 / 5 ) + math . ceil ( sum2 / 10 ) <= n : return "" YES ""   return "" NO ""         print ( solve ( ) ) NEW_LINE +" +E287,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class CF579A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int x = Integer . parseInt ( br . readLine ( ) ) ; int set_bits = 0 ; while ( x != 0 ) { set_bits += x & 1 ; x >>= 1 ; } System . out . print ( set_bits ) ; } } +","print ( bin ( int ( input ( ) ) ) . count ( '1' ) ) NEW_LINE +" +E288,"  import java . util . * ; import java . lang . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; int [ ] a1 = new int [ t - 1 ] ; int [ ] a2 = new int [ t - 1 ] ; int [ ] b = new int [ t ] ; int [ ] sum1 = new int [ t ] ; int sum = 0 ; int homer = 0 ; int marketr = 0 ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; StringTokenizer st1 = new StringTokenizer ( br . readLine ( ) ) ; StringTokenizer st2 = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < t ; i ++ ) { if ( i < t - 1 ) { a1 [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; a2 [ i ] = Integer . parseInt ( st1 . nextToken ( ) ) ; homer += a2 [ i ] ; } b [ i ] = Integer . parseInt ( st2 . nextToken ( ) ) ; } for ( int i = 0 ; i < t ; i ++ ) { sum = 0 ; if ( i != 0 ) { homer -= a2 [ i - 1 ] ; marketr += a1 [ i - 1 ] ; } sum = homer + marketr ; sum1 [ i ] = sum + b [ i ] ; } Arrays . sort ( sum1 ) ; System . out . println ( sum1 [ 0 ] + sum1 [ 1 ] ) ; } } +","I = lambda : list ( map ( int , input ( ) . split ( ) ) ) R = range ( I ( ) [ 0 ] ) a = I ( ) b = I ( ) c = I ( ) print ( min ( c [ i ] + c [ j ] + sum ( a [ : i ] + a [ : j ] + b [ i : ] + b [ j : ] ) for i in R for j in R if i != j ) ) NEW_LINE +" +E289,"import java . lang . * ; import java . util . * ; import java . io . * ;   public class Compressing { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Map < Integer , List < Integer > > map = new HashMap < Integer , List < Integer > > ( ) ; Map < Integer , List < Integer > > win = new HashMap < Integer , List < Integer > > ( ) ; List < Integer > temp ; int tot = n * ( n - 1 ) / 2 ; for ( int i = 0 ; i < tot - 1 ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( map . containsKey ( x ) ) map . get ( x ) . add ( y ) ; else { temp = new ArrayList < Integer > ( ) ; temp . add ( y ) ; map . put ( x , temp ) ; } if ( map . containsKey ( y ) ) map . get ( y ) . add ( x ) ; else { temp = new ArrayList < Integer > ( ) ; temp . add ( x ) ; map . put ( y , temp ) ; } if ( win . containsKey ( x ) ) win . get ( x ) . add ( y ) ; else { temp = new ArrayList < Integer > ( ) ; temp . add ( y ) ; win . put ( x , temp ) ; } } +","n = int ( input ( ) ) a = [ 0 ] * nb = [ 0 ] * nfor i in range ( n * ( n - 1 ) // 2 - 1 ) : c , d = list ( map ( int , input ( ) . split ( ) ) ) a [ c - 1 ] += 1 b [ c - 1 ] += 1 b [ d - 1 ] += 1 f = - 1 g = - 1 for i in range ( n ) : if b [ i ] == n - 2 : if f == - 1 : f = i + 1 else : g = i + 1 breakif a [ f - 1 ] > a [ g - 1 ] : print ( f , g ) else : print ( g , f ) NEW_LINE +" +E290,"import java . util . * ; import java . io . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , sum = 0 ; int [ ] arr = new int [ 6 ] ; for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; arr [ num ] += 1 ; } for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; arr [ num ] -= 1 ; } boolean flag = true ; for ( int i = 1 ; i < 6 ; i ++ ) { int num = Math . abs ( arr [ i ] ) ; if ( num % 2 != 0 ) { flag = false ; break ; } sum += num ; } if ( ! flag ) System . out . println ( - 1 ) ; else System . out . println ( ( sum / 2 ) / 2 ) ; } } +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) cnt = { } for x in a : cnt [ x ] = cnt . get ( x , 0 ) + 1 for x in b : cnt [ x ] = cnt . get ( x , 0 ) - 1 if any ( [ abs ( v ) % 2 == 1 for v in cnt . values ( ) ] ) : print ( - 1 ) else : ans = sum ( [ v for v in cnt . values ( ) if v > 0 ] ) // 2 print ( ans ) NEW_LINE +" +E291,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) throws Exception { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ;   Task task = new Task ( ) ; task . solve ( in , out ) ; out . close ( ) ;   } static class Rectangle { int x1 , y1 ; int x2 , y2 ; } static class Task { public void solve ( InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; +","from sys import stdout   first_rez = [ ]     def req ( x1 , y1 , x2 , y2 ) : print ( ' ? ' , x1 , y1 , x2 , y2 ) stdout . flush ( ) x = int ( input ( ) ) if first_rez : if x1 <= first_rez [ 0 ] <= first_rez [ 2 ] <= x2 and y1 <= first_rez [ 1 ] <= first_rez [ 3 ] <= y2 : x -= 1 NEW_LINE +" +E292,"import sysfrom collections import defaultdict as ddinput = sys . stdin . readlineI = lambda : list ( map ( int , input ( ) . split ( ) ) )   n , a , b = I ( ) l = I ( ) dic = dd ( int ) for i in range ( n ) : dic [ l [ i ] ] = 1 bs = [ ] pa = dd ( int ) for i in range ( n ) : if dic [ a - l [ i ] ] == 0 : bs . append ( l [ i ] ) else : pa [ l [ i ] ] = a - l [ i ] j = 0 while j < len ( bs ) : for i in range ( j , len ( bs ) ) : cr = bs [ i ] dic [ cr ] = 2 if dic [ b - cr ] == 0 : print ( "" NO "" ) ; exit ( ) dic [ b - cr ] = 2 if dic [ a - b + cr ] == 1 : dic [ a - b + cr ] = 2 bs . append ( a - b + cr ) j += 1 # ct = 0 ; vt = a - b + cr # while vt != pa [ pa [ vt ] ] : # vt = pa [ vt ] ; dic [ b - vt ] = 2 # dic [ vt ] = 2 an = [ 0 ] * nfor i in range ( n ) : an [ i ] = dic [ l [ i ] ] - 1 print ( "" YES "" ) print ( * an ) +","import sysfrom collections import defaultdict as ddinput = sys . stdin . readlineI = lambda : list ( map ( int , input ( ) . split ( ) ) )   n , a , b = I ( ) l = I ( ) dic = dd ( int ) for i in range ( n ) : dic [ l [ i ] ] = 1 bs = [ ] pa = dd ( int ) for i in range ( n ) : if dic [ a - l [ i ] ] == 0 : bs . append ( l [ i ] ) else : pa [ l [ i ] ] = a - l [ i ] j = 0 while j < len ( bs ) : for i in range ( j , len ( bs ) ) : cr = bs [ i ] dic [ cr ] = 2 if dic [ b - cr ] == 0 : print ( "" NO "" ) ; exit ( ) dic [ b - cr ] = 2 if dic [ a - b + cr ] == 1 : dic [ a - b + cr ] = 2 bs . append ( a - b + cr ) j += 1 NEW_LINE +" +E293,"import java . util . Scanner ;   public class _0678BalancedRatingChanges {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int countoddneg = 0 ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int temp = sc . nextInt ( ) ; arr [ i ] = temp ; if ( temp % 2 != 0 ) { if ( temp < 0 ) { countoddneg ++ ; } else { countoddneg -- ; } } } countoddneg = countoddneg / 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { System . out . println ( arr [ i ] / 2 ) ; } else { if ( arr [ i ] > 0 && countoddneg < 0 ) { System . out . println ( ( arr [ i ] / 2 ) + 1 ) ; countoddneg ++ ; } else if ( arr [ i ] < 0 && countoddneg > 0 ) { System . out . println ( ( arr [ i ] / 2 ) - 1 ) ; countoddneg -- ; } else { System . out . println ( arr [ i ] / 2 ) ; } } } }   } +","import mathn = int ( input ( ) )   arr = [ ]   for i in range ( n ) : arr . append ( int ( input ( ) ) )   res = [ ] flag = Falsefor i in arr : if i % 2 == 0 : res . append ( int ( i / 2 ) ) continue if flag : res . append ( math . floor ( i / 2 ) ) flag = False else : res . append ( math . ceil ( i / 2 ) ) flag = True for i in res : print ( i ) NEW_LINE +" +E294,"import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Locale ; import java . util . Scanner ;   public class A1495 {   public static void main ( String [ ] args ) { Locale . setDefault ( Locale . US ) ; Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; List < Integer > miners = new ArrayList < > ( N ) ; List < Integer > diamonds = new ArrayList < > ( N ) ; for ( int n = 0 ; n < 2 * N ; n ++ ) { int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; if ( x == 0 ) { miners . add ( Math . abs ( y ) ) ; } else { diamonds . add ( Math . abs ( x ) ) ; } } Collections . sort ( miners ) ; Collections . sort ( diamonds ) ; double answer = 0 ; for ( int n = 0 ; n < N ; n ++ ) { int x = diamonds . get ( n ) ; int y = miners . get ( n ) ; answer += Math . sqrt ( x * ( long ) x + y * ( long ) y ) ; } System . out . println ( answer ) ; } }   } +","from math import sqrtdef NEW_LINE dist ( a , b ) : NEW_LINE return ( sqrt ( a ** 2 + b ** 2 ) ) NEW_LINE def solve ( ) : n = int ( input ( ) ) NEW_LINE d = [ ] NEW_LINE m = [ ] NEW_LINE for p in range ( 2 * n ) : a , b = map ( int , input ( ) . split ( ) ) NEW_LINE if a == 0 : NEW_LINE INDENT m . append ( abs ( b ) ) else : NEW_LINE d . append ( abs ( a ) ) NEW_LINE DEDENT d . sort ( ) NEW_LINE m . sort ( ) NEW_LINE ans = 0 NEW_LINE for x in range ( n ) : ans += dist ( d [ x ] , m [ x ] ) NEW_LINE print ( ans ) NEW_LINE for _ in range ( int ( input ( ) ) ) : solve ( ) NEW_LINE +" +E295,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class A {   public static void main ( String [ ] args ) throws IOException {   FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; String str = sc . next ( ) ; int n = str . length ( ) ; +","years = { ""2013"" , ""2014"" , ""2015"" } base = set ( ) for i in range ( 1 , 29 ) : if i < 10 : base . add ( ""0"" + str ( i ) ) else : base . add ( str ( i ) ) info1 = base . copy ( ) info1 . add ( ""29"" ) info1 . add ( ""30"" ) info2 = info1 . copy ( ) info2 . add ( ""31"" ) months = { ""02"" : base } for i in [ 4 , 6 , 9 , 11 ] : if i < 10 : months [ ""0"" + str ( i ) ] = info1 else : months [ str ( i ) ] = info1for i in [ 1 , 3 , 5 , 7 , 8 , 10 , 12 ] : k = ( ""0"" + str ( i ) ) if i < 10 else str ( i ) months [ k ] = info2   s = input ( )   def solve ( s , years , months ) : maps = { } i = 0 while i < len ( s ) - 9 : if s [ i + 2 ] != "" - "" or s [ i + 5 ] != "" - "" : i += 1 continue d , m , y = s [ i : i + 2 ] , s [ i + 3 : i + 5 ] , s [ i + 6 : i + 10 ] if y in years and m in months and d in months [ m ] : k = s [ i : i + 10 ] maps [ k ] = maps . get ( k , 0 ) + 1 i += 1 ans , count = "" "" , 0 for k , v in maps . items ( ) : if count < v : ans , count = k , v return ans   ans = solve ( s , years , months ) print ( ans ) NEW_LINE +" +E296,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Main {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; long p = Long . parseLong ( st . nextToken ( ) ) ; long q = Long . parseLong ( st . nextToken ( ) ) ; long r = Long . parseLong ( st . nextToken ( ) ) ;   st = new StringTokenizer ( br . readLine ( ) ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Long . parseLong ( st . nextToken ( ) ) ; }   long [ ] pmax = new long [ n ] ; pmax [ 0 ] = p * arr [ 0 ] ;   for ( int i = 1 ; i < n ; i ++ ) { pmax [ i ] = Math . max ( pmax [ i - 1 ] , p * arr [ i ] ) ; } +","a = list ( map ( int , input ( ) . split ( ) ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) n = a [ 0 ] dp = [ [ 0 for i in range ( 4 ) ] for j in range ( n + 1 ) ] for i in range ( 4 ) : dp [ 0 ] [ i ] = ( - 10 ) ** ( 27 ) for i in range ( 1 , n + 1 ) : for j in range ( 1 , 4 ) : x = arr [ i - 1 ] * a [ j ] + dp [ i ] [ j - 1 ] y = dp [ i - 1 ] [ j ] dp [ i ] [ j ] = max ( x , y ) print ( dp [ n ] [ 3 ] ) NEW_LINE +" +E297,"import java . util . * ; import java . lang . * ; import java . io . * ;   public class sample { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , cnt = 0 ; int arr [ ] = new int [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ;   for ( int i = 1 ; i <= n - 2 ; i ++ ) { if ( arr [ i - 1 ] == 1 && arr [ i ] == 0 && arr [ i + 1 ] == 1 ) { cnt ++ ; arr [ i + 1 ] = 0 ; } }   System . out . println ( cnt ) ; } } +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = 0 for i in range ( 1 , n - 1 ) : if ( a [ i ] == 0 and a [ i - 1 ] == 1 and a [ i + 1 ] == 1 ) : a [ i + 1 ] = 0 c += 1 print ( c ) NEW_LINE +" +E298,"import java . util . * ; public class CodeForces1496B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; for ( int j = 0 ; j < t ; j ++ ) { int n = input . nextInt ( ) ; int k = input . nextInt ( ) ; Set < Integer > set = new HashSet < > ( ) ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int c = input . nextInt ( ) ; set . add ( c ) ; max = Math . max ( max , c ) ; } if ( k == 0 ) { System . out . println ( set . size ( ) ) ; continue ; } int min = 0 ; while ( set . contains ( min ) ) { min ++ ; } if ( min < max ) { int count = ( max + min + 1 ) / 2 ; set . add ( count ) ; System . out . println ( set . size ( ) ) ; } else { System . out . println ( set . size ( ) + k ) ; } } } } +","R = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE t , = R ( ) NEW_LINE exec ( t * ' n , k = R ( ) ; a = { * R ( ) } ; i = 0 \n while { i } & a : i + = 1 \n print ( n + ( k > 0 ) * ( k , i + max ( a ) + 1 > > 1not ▁ in ▁ a ) [ i < n ] ) \n ' ) NEW_LINE +" +E299,"  import java . io . * ; import java . util . * ; public class Main { static MyScanner sc = new MyScanner ( ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = init ( n + 1 ) ; int [ ] b = init ( m + 1 ) ; if ( n > m ) { if ( a [ 0 ] * b [ 0 ] < 0 ) out . print ( "" - "" ) ; out . println ( "" Infinity "" ) ; } else if ( n < m ) out . println ( ""0/1"" ) ; else { int high = gcd ( Math . abs ( a [ 0 ] ) , Math . abs ( b [ 0 ] ) ) ; if ( a [ 0 ] * b [ 0 ] < 0 ) out . print ( "" - "" ) ; out . println ( Math . abs ( a [ 0 ] ) / high + "" / "" + Math . abs ( b [ 0 ] ) / high ) ; } out . close ( ) ; } +","import mathn , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) q = list ( map ( int , input ( ) . split ( ) ) ) if m > n : print ( ""0/1"" ) elif n > m : if ( l [ 0 ] > 0 and q [ 0 ] > 0 ) or ( l [ 0 ] < 0 and q [ 0 ] < 0 ) : print ( "" Infinity "" ) else : print ( "" - Infinity "" )   else : a = abs ( l [ 0 ] ) b = abs ( q [ 0 ] ) while math . gcd ( a , b ) > 1 : c = math . gcd ( a , b ) a = a // c b = b // c if l [ 0 ] > 0 and q [ 0 ] > 0 : print ( str ( a ) + "" / "" + str ( b ) ) elif l [ 0 ] < 0 and q [ 0 ] < 0 : print ( str ( a ) + "" / "" + str ( b ) ) else : print ( "" - "" + str ( a ) + "" / "" + str ( b ) )   NEW_LINE +" +E300,"import java . util . * ; public class Main { public static Scanner ayah = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int t , n ; t = ayah . nextInt ( ) ; while ( t > 0 ) { n = ayah . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = ayah . nextInt ( ) ; int min = Math . abs ( arr [ 0 ] - arr [ 1 ] ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) { if ( j == i ) continue ; else { if ( Math . abs ( arr [ i ] - arr [ j ] ) <= min ) min = Math . abs ( arr [ i ] - arr [ j ] ) ; } } System . out . println ( min ) ; t -- ; } } } +","t = int ( input ( ) )   for tc in range ( t ) : n = int ( input ( ) )   athletes = [ int ( z ) for z in input ( ) . split ( ) ]   athletes . sort ( )   res = [ ]   for i in range ( 1 , n ) : a = athletes [ : i ] b = athletes [ i : ]   res . append ( abs ( max ( a ) - min ( b ) ) )   print ( min ( res ) ) NEW_LINE +" +E301,"import java . util . * ;   public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; +","n = int ( input ( ) ) arr = [ [ 0 , 0 ] for i in range ( n ) ]   for i in range ( n ) : arr [ i ] [ 0 ] , arr [ i ] [ 1 ] = map ( int , input ( ) . split ( ) )   NEW_LINE +" +E302,"import java . util . * ;   public class Test {   static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int t = Integer . parseInt ( sc . next ( ) ) ; while ( t -- > 0 ) solve ( ) ; }   static void solve ( ) { long n = sc . nextLong ( ) ; long k = sc . nextLong ( ) ;   long l = 2 , r = n , mid = 0 , x = 0 , y = 0 ;   while ( l <= r ) { mid = ( l + r ) / 2 ; x = ( mid - 1 ) * ( mid - 2 ) / 2 + 1 ; if ( x == k ) break ; else if ( x < k ) l = mid + 1 ; else r = mid - 1 ; } if ( x > k ) { mid -- ; x = ( mid - 1 ) * ( mid - 2 ) / 2 + 1 ; }   for ( y = 1 ; y < mid ; y ++ ) { if ( ( x + y - 1 ) == k ) break ; }   StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= n ; i ++ ) sb . append ( ' a ' ) ; sb . setCharAt ( ( int ) ( mid - 1 ) , ' b ' ) ; sb . setCharAt ( ( int ) ( y - 1 ) , ' b ' ) ; sb . reverse ( ) ;   System . out . println ( sb . toString ( ) ) ; } } +","def binary ( data , target , low , high ) : if low > high : return high else : mid = int ( ( low + high ) / 2 ) if data [ mid ] <= target : return binary ( data , target , mid + 1 , high ) else : return binary ( data , target , low , mid - 1 ) for _ in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) l = [ 1 ] n = 1 for i in range ( 1 , a - 1 ) : l . append ( l [ - 1 ] + n ) n += 1 result = [ "" a "" ] * a k = binary ( l , b , 0 , len ( l ) - 1 ) k += 1 result [ a - 1 - k ] = "" b "" result [ - 1 - ( b - l [ k - 1 ] ) ] = "" b "" print ( * result , sep = "" "" )   NEW_LINE +" +E303,"import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ;   int n = s . nextInt ( ) ; int t = s . nextInt ( ) ;   int [ ] [ ] intv = new int [ n ] [ 2 ] ;   for ( int i = 0 ; i < n ; i ++ ) { intv [ i ] [ 0 ] = s . nextInt ( ) ; intv [ i ] [ 1 ] = s . nextInt ( ) ; }   Arrays . sort ( intv , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ;   int res = 2 ; +","n , t = [ int ( item ) for item in input ( ) . split ( ' ▁ ' ) ] cont , ans = [ ] , 2 for i in range ( n ) : hcenter , hlen = [ float ( item ) for item in input ( ) . split ( ' ▁ ' ) ] NEW_LINE +" +E304,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; import java . util . StringTokenizer ;   public class Vany_and_Cubes { static class RealScanner { 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 ( ) ) ; } }   public static void main ( String [ ] args ) { RealScanner sc = new RealScanner ( ) ; int n = sc . nextInt ( ) ; List < Integer > l = new ArrayList < > ( ) ; l . add ( 1 ) ; int sum = 1 , k = 1 ; for ( int i = 1 ; i <= 10000 ; i ++ ) { sum += i + k ; l . add ( sum ) ; } int valSum = 0 , count = 0 ; if ( n == 1 ) { System . out . println ( 1 ) ; return ; } for ( int i = 1 ; i <= l . size ( ) ; i ++ ) { valSum += l . get ( i - 1 ) ; if ( valSum > n ) { break ; } count ++ ; }   System . out . println ( count ) ; } } +","n = int ( input ( ) ) x = 1 s = 1 while s <= n : x += 1 s += ( x * ( x + 1 ) ) // 2 print ( x - 1 ) NEW_LINE +" +E305,"import javafx . scene . layout . Priority ; import sun . reflect . generics . tree . Tree ;   import java . sql . Array ; import java . util . * ; import java . io . * ; import java . util . stream . Stream ;   import static java . lang . Math . * ; public class D { static InputReader in = new InputReader ( System . in ) ; static OutputWriter out = new OutputWriter ( System . out ) ; static StringBuilder sb = new StringBuilder ( ) ; static long MOD = ( long ) ( 998244353 ) ;   static TreeSet < Integer > [ ] graph ; static TreeSet < Integer > vertices ; static boolean visited [ ] ; static int n ; static int m ; static int size ;   public static void dfs ( int i ) { ArrayList < Integer > list = new ArrayList < > ( ) ; Iterator < Integer > itr = vertices . iterator ( ) ; while ( itr . hasNext ( ) ) { int j = itr . next ( ) ; if ( ! graph [ i ] . contains ( j ) ) { list . add ( j ) ; itr . remove ( ) ; } }   for ( int x : list ) dfs ( x ) ; }    +","n , m = map ( int , input ( ) . split ( ) ) adj = [ [ ] for i in range ( n ) ] used = [ 0 for i in range ( n ) ] mark = [ 0 for i in range ( n ) ] S = [ i for i in range ( n ) ]   for i in range ( m ) : u , v = map ( int , input ( ) . split ( ) ) u , v = u - 1 , v - 1 adj [ u ] . append ( v ) adj [ v ] . append ( u ) def dfs ( v ) : global S used [ v ] = 1 S2 , S3 = [ ] , [ ] for to in adj [ v ] : mark [ to ] = 1 for to in S : if mark [ to ] == 0 : S3 . append ( to ) else : S2 . append ( to ) for to in adj [ v ] : mark [ to ] = 0 S = S2 . copy ( ) for to in S3 : dfs ( to ) ans = - 1 for i in range ( n ) : if not used [ i ] : S . remove ( i ) ans += 1 dfs ( i )   print ( ans ) NEW_LINE +" +E306,"public class p1143B { public static void main ( String [ ] args ) { System . out . println ( max ( new java . util . Scanner ( System . in ) . nextInt ( ) ) ) ; } static int max ( int n ) { return n < 10 ? Math . max ( 1 , n ) : Math . max ( ( n % 10 ) * max ( n / 10 ) , 9 * max ( n / 10 - 1 ) ) ; } } +","def pod ( n ) : ans = 1 while n > 0 : ans *= ( n % 10 ) n = n // 10 return ansn = input ( ) ans = ( len ( n ) - 1 ) * 9 ans = max ( ans , pod ( int ( n ) ) ) sz = len ( n ) for i in range ( 1 , sz ) : ind = sz - i num = n [ : ind ] + '9' * ( sz - ind ) if int ( num ) > int ( n ) : if num [ ind - 1 ] == '0' : num = num [ : ind - 1 ] + '9' + num [ ind : ] else : num = num [ : ind - 1 ] + str ( int ( num [ ind - 1 ] ) - 1 ) + num [ ind : ] if int ( num ) <= int ( n ) : ans = max ( ans , pod ( int ( num ) ) ) print ( ans ) NEW_LINE +" +E307,"import java . util . * ; import java . io . * ; public class Main { public static int mod = 1000000007 ; public static void solve ( InputReader in ) { int n = in . readInt ( ) ; int m = in . readInt ( ) ; for ( int i = 0 ; i < 1130 ; i ++ ) { System . out . print ( 8 ) ; if ( i == 1129 ) System . out . print ( 9 ) ; } System . out . println ( ) ; for ( int i = 0 ; i < 1131 ; i ++ ) { System . out . print ( 1 ) ; } } public static void main ( String [ ] args ) { +","n , m = map ( int , input ( ) . split ( ) ) a = '9' * 200 + '0' * 199 + '1' b = '9' * 200 print ( a ) print ( b ) NEW_LINE +" +E308,"from sys import stdinfrom math import gcd    def main ( ) : input ( ) l = stdin . read ( ) . splitlines ( ) d = [ 3. , 1. , 2. , 2. , 2. , 1. ] * 16667 for i in range ( 4 , 100001 ) : for j in range ( i , 100001 , i ) : d [ j ] += 1. for i , s in enumerate ( l ) : a , b , c = map ( int , s . split ( ) ) k = gcd ( b , c ) ab = d [ gcd ( a , b ) ] ac = d [ gcd ( a , c ) ] bc = d [ k ] abc = d [ gcd ( a , k ) ] asz = d [ a ] - ab - ac + abc bsz = d [ b ] - bc - ab + abc csz = d [ c ] - ac - bc + abc absz = ab - abc bcsz = bc - abc acsz = ac - abc l [ i ] = ' % d ' % ( asz * bsz * csz + ( absz * ( asz + bsz ) * csz ) + ( bcsz * ( bsz + csz ) * asz ) + ( acsz * ( asz + csz ) * bsz ) + ( abc * ( asz * bsz + asz * csz + bsz * csz ) ) + ( abc * ( absz + bcsz + acsz ) * ( asz + bsz + csz ) ) + ( ( asz + bsz + csz + absz + bcsz + acsz ) * ( abc * ( abc + 1 ) * .5 ) ) + ( absz * bcsz * acsz ) + ( ( absz * ( absz + 1. ) * d [ c ] ) + ( bcsz * ( bcsz + 1. ) * d [ a ] ) + ( acsz * ( acsz + 1. ) * d [ b ] ) ) * .5 + ( ( asz + bsz + csz + abc ) * ( absz * acsz + absz * bcsz + bcsz * acsz ) ) + ( abc + ( abc * ( abc - 1. ) ) + ( abc * ( abc - 1. ) * ( abc - 2. ) / 6. ) ) ) print ( ' \n ' . join ( map ( str , l ) ) )    if __name__ == ' _ _ main _ _ ' : main ( ) +","from sys import stdinfrom math import gcd     def main ( ) : input ( ) l = stdin . read ( ) . splitlines ( ) d = [ 3. , 1. , 2. , 2. , 2. , 1. ] * 16667 for i in range ( 4 , 100001 ) : for j in range ( i , 100001 , i ) : d [ j ] += 1. for i , s in enumerate ( l ) : a , b , c = map ( int , s . split ( ) ) k = gcd ( b , c ) ab = d [ gcd ( a , b ) ] ac = d [ gcd ( a , c ) ] bc = d [ k ] abc = d [ gcd ( a , k ) ] asz = d [ a ] - ab - ac + abc bsz = d [ b ] - bc - ab + abc csz = d [ c ] - ac - bc + abc absz = ab - abc bcsz = bc - abc acsz = ac - abc l [ i ] = ' % d ' % ( asz * bsz * csz + ( absz * ( asz + bsz ) * csz ) + ( bcsz * ( bsz + csz ) * asz ) + ( acsz * ( asz + csz ) * bsz ) + ( abc * ( asz * bsz + asz * csz + bsz * csz ) ) + ( abc * ( absz + bcsz + acsz ) * ( asz + bsz + csz ) ) + ( ( asz + bsz + csz + absz + bcsz + acsz ) * ( abc * ( abc + 1 ) * .5 ) ) + ( absz * bcsz * acsz ) + ( ( absz * ( absz + 1. ) * d [ c ] ) + ( bcsz * ( bcsz + 1. ) * d [ a ] ) + ( acsz * ( acsz + 1. ) * d [ b ] ) ) * .5 + ( ( asz + bsz + csz + abc ) * ( absz * acsz + absz * bcsz + bcsz * acsz ) ) + ( abc + ( abc * ( abc - 1. ) ) + ( abc * ( abc - 1. ) * ( abc - 2. ) / 6. ) ) ) print ( ' \n ' . join ( map ( str , l ) ) )     if __name__ == ' _ _ main _ _ ' : main ( )         NEW_LINE +" +E309,"import java . util . Arrays ; import java . util . Collections ;   import java . util . Scanner ;   public class Problem36 {   public static void main ( String [ ] args ) { +","m = [ ] for _ in range ( int ( input ( ) ) ) : l = list ( map ( int , input ( ) . split ( ) ) ) x = sum ( l ) m . append ( x ) j = sorted ( m , reverse = True ) NEW_LINE +" +E310,"import java . util . * ; public class _274_A_k_multiple_free_set { +","from sys import stdin , stdoutfrom itertools import accumulatenmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) for _ in range ( 1 ) : NEW_LINE +" +E311,"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static FileWriter fw ; static long oo = Long . MAX_VALUE ; +","import sysimport itertoolsimport collections   n = int ( input ( ) ) A = [ int ( x ) for x in input ( ) . split ( ) ] perms = [ ]   def bits ( lst ) : a = [ ] for val in lst : s = [ ] for shift in range ( 29 , - 1 , - 1 ) : s += [ str ( val >> shift & 1 ) ] a += [ ' ' . join ( s [ : : - 1 ] ) ] return a   def calcCost ( perm ) : f = lambda a , b : ( ( a | b ) - b ) a = f ( perm [ 0 ] , perm [ 1 ] ) for i in range ( 2 , len ( perm ) ) : a = f ( a , perm [ i ] ) return a   def bruteForce ( ) : global perms for perm in list ( itertools . permutations ( A ) ) : perms += [ ( perm , calcCost ( perm ) ) ] print ( * perms , sep = "" \n "" )   NEW_LINE +" +E312,"   import java . util . * ;    public class dummycodes {   public static class data { int prevIndex ; int comDiff ; public data ( int i ) { prevIndex = i ; comDiff = 0 ; } } public static void solve ( int t , int s1 , int s2 , int e1 , int e2 , String s ) { int reqDirs [ ] = new int [ 26 ] ; if ( s1 < e1 ) reqDirs [ ' E ' - ' A ' ] = ( e1 - s1 ) ; else reqDirs [ ' W ' - ' A ' ] = ( s1 - e1 ) ; if ( s2 < e2 ) reqDirs [ ' N ' - ' A ' ] = ( e2 - s2 ) ; else reqDirs [ ' S ' - ' A ' ] = ( s2 - e2 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( reqDirs [ s . charAt ( i ) - ' A ' ] > 0 ) reqDirs [ s . charAt ( i ) - ' A ' ] -- ; if ( reqDirs [ ' N ' - ' A ' ] == 0 && reqDirs [ ' S ' - ' A ' ] == 0 && reqDirs [ ' E ' - ' A ' ] == 0 && reqDirs [ ' W ' - ' A ' ] == 0 ) { System . out . println ( i + 1 ) ; return ; } } System . out . println ( "" - 1"" ) ; }   public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; int s1 = sc . nextInt ( ) ; int s2 = sc . nextInt ( ) ; int e1 = sc . nextInt ( ) ; int e2 = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ;   solve ( t , s1 , s2 , e1 , e2 , s ) ;        } }   +","t , sx , sy , ex , ey = map ( int , input ( ) . split ( ) ) winds = list ( input ( ) ) def dist ( x , y ) : return abs ( x - ex ) + abs ( y - ey ) for zzz in range ( t ) : new_x , new_y = sx , sy if ( winds [ zzz ] == ' N ' ) : new_y += 1 if ( winds [ zzz ] == ' S ' ) : new_y -= 1 if ( winds [ zzz ] == ' E ' ) : new_x += 1 if ( winds [ zzz ] == ' W ' ) : new_x -= 1 if ( dist ( new_x , new_y ) < dist ( sx , sy ) ) : sx = new_x sy = new_y if ( sx == ex and sy == ey ) : if ( zzz + 1 <= t ) : print ( zzz + 1 ) breakelse : print ( - 1 ) NEW_LINE +" +E313,"import java . util . Scanner ;    public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int a , b ; int ans = 0 , p = 100 ; for ( int i = 0 ; i < n ; i ++ ) { a = in . nextInt ( ) ; b = in . nextInt ( ) ; p = Math . min ( p , b ) ; ans += p * a ; } System . out . println ( ans ) ;   } } +","days = int ( input ( ) ) dailyReq = [ ] dailyPrice = [ ] totalCost = 0 for day in range ( days ) : a , p = input ( ) . split ( ) dailyReq . append ( int ( a ) ) dailyPrice . append ( int ( p ) )   minPrice = dailyPrice [ 0 ] for day in range ( days ) : if ( dailyPrice [ day ] < minPrice ) : minPrice = dailyPrice [ day ] totalCost += dailyReq [ day ] * minPrice   print ( totalCost )   NEW_LINE +" +E314,"import java . io . * ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . StringTokenizer ; import java . util . * ; public class realfast implements Runnable { private static final int INF = ( int ) 1e9 ; long in = ( long ) Math . pow ( 10 , 9 ) + 7 ; long fac [ ] = new long [ 3000 ] ; public void solve ( ) throws IOException { String s = readString ( ) ; int n = s . length ( ) ; int last [ ] = new int [ s . length ( ) ] ; Arrays . fill ( last , n ) ; for ( int j = 1 ; j <= 9 ; j ++ ) { for ( int i = 0 ; i < n - 2 * j ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + j ) && s . charAt ( i + j ) == s . charAt ( i + 2 * j ) ) { last [ i ] = Math . min ( last [ i ] , i + 2 * j ) ; } } } for ( int i = n - 2 ; i >= 0 ; i -- ) { last [ i ] = Math . min ( last [ i ] , last [ i + 1 ] ) ; } long count = 0 ; for ( int i = 0 ; i < n ; i ++ ) count = count + n - last [ i ] ;   out . println ( count ) ; } public long pow ( long n , long p , long m ) { if ( p == 0 ) return 1 ; long val = pow ( n , p / 2 , m ) ; ; val = ( val * val ) % m ; if ( p % 2 == 0 ) return val ; else return ( val * n ) % m ; } +","import sysimport mathfrom collections import defaultdict , dequeimport heapqs = sys . stdin . readline ( ) [ : - 1 ] ans = 0 n = len ( s ) mink = nfor i in range ( n - 1 , - 1 , - 1 ) : k = 1 z = True while i + 2 * k < n and z : if s [ i ] == s [ i + k ] == s [ i + 2 * k ] : z = False continue k += 1 if not z : mink = min ( mink , i + 2 * k ) NEW_LINE +" +E315,"import java . io . * ; import java . util . * ;   public class Codeforces { int l , r , x ; int count ; void subsetSums ( int arr [ ] , int n ) { int total = 1 << n ; for ( int i = 0 ; i < total ; i ++ ) { long sum = 0 , min = Integer . MAX_VALUE , max = Integer . MIN_VALUE ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) { min = Math . min ( min , arr [ j ] ) ; max = Math . max ( max , arr [ j ] ) ; sum += arr [ j ] ; } } if ( sum >= l && sum <= r && max - min >= x ) { +","c = 0 def backtracking ( actuales , restantes , l , r , x ) : global c if sum ( actuales ) <= r and sum ( actuales ) >= l : if max ( actuales ) - min ( actuales ) >= x : c += 1 if restantes : for i in range ( len ( restantes ) ) : backtracking ( actuales + [ restantes [ i ] ] , restantes [ i + 1 : ] , l , r , x ) return 0 def main ( ) : n , l , r , x = input ( ) . split ( "" ▁ "" ) n , l , r , x = int ( n ) , int ( l ) , int ( r ) , int ( x ) difficulties = input ( ) . split ( "" ▁ "" ) for i in range ( len ( difficulties ) ) : difficulties [ i ] = int ( difficulties [ i ] ) difficulties . sort ( ) backtracking ( [ ] , difficulties , l , r , x ) global c return c if __name__ == "" _ _ main _ _ "" : print ( main ( ) ) NEW_LINE +" +E316,"import java . util . * ;    public class Main {    public static void main ( String [ ] args ) { int n , l = 0 , r ; int [ ] a = new int [ 1020 ] ; Scanner in = new Scanner ( System . in ) ; r = n = in . nextInt ( ) ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = in . nextInt ( ) ; }   while ( a [ l ] == l && l <= n ) l ++ ; while ( a [ r ] == r && r >= 1 ) r -- ;   if ( l == n + 1 && r == 0 ) { System . out . println ( ""0 ▁ 0"" ) ; return ; } for ( int i = l ; i < r ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { System . out . println ( ""0 ▁ 0"" ) ; return ; } } System . out . println ( l + "" ▁ "" + r ) ; }    } +","n = int ( input ( ) ) NEW_LINE start , end = 0 , 0 NEW_LINE flag = 0 l NEW_LINE s = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( 1 , ( n + 1 ) ) : if NEW_LINE ls [ i - 1 ] != i : start = i NEW_LINE breakfor NEW_LINE j in range ( n , i - 1 , - 1 ) : NEW_LINE if ls [ j - 1 ] != j : end = j NEW_LINE breakif NEW_LINE start == 0 and end == 0 : flag = 1 NEW_LINE print ( ""0 ▁ 0"" ) else : for i in range ( start - 1 , end - 1 ) : if NEW_LINE ls [ i ] < ls [ i + 1 ] : print ( ""0 ▁ 0"" ) NEW_LINE flag = 1 NEW_LINE breakif NEW_LINE flag == 0 : print ( str ( start ) + "" ▁ "" + str ( end ) ) NEW_LINE +" +E317,"import java . util . Scanner ;   public class Array_524 { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int n = sn . nextInt ( ) ; int m = sn . nextInt ( ) ; int x = sn . nextInt ( ) ; int y = sn . nextInt ( ) ; int [ ] N = new int [ n ] ; int [ ] M = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { N [ i ] = sn . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { M [ i ] = sn . nextInt ( ) ; }   int [ ] [ ] ans = solution ( N , M , x , y ) ; int total = 0 ;   for ( int i = 0 ; i < ans . length ; i ++ ) { if ( ans [ i ] [ 0 ] != 0 && ans [ i ] [ 1 ] != 0 ) { total ++ ; } }   System . out . println ( total ) ; for ( int i = 0 ; i < total ; i ++ ) { System . out . println ( ans [ i ] [ 0 ] + "" ▁ "" + ans [ i ] [ 1 ] ) ; } }   private static int [ ] [ ] solution ( int [ ] N , int [ ] M , int x , int y ) { int [ ] [ ] result = new int [ M . length ] [ 2 ] ; int resultIndex = 0 ; int i = 0 ; int j = 0 ; while ( i < N . length && j < M . length ) { int a = Math . max ( 0 , N [ i ] - x ) ; int b = N [ i ] + y ; if ( M [ j ] >= a && M [ j ] <= b ) { result [ resultIndex ] [ 0 ] = i + 1 ; result [ resultIndex ] [ 1 ] = j + 1 ; resultIndex ++ ; i ++ ; j ++ ; } else { if ( N [ i ] < M [ j ] ) { i ++ ; } else { j ++ ; } } } return result ; }   } +","n , m , x , y = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) outputs , l = [ ] , 0 for i in range ( n ) : minm = max ( 1 , a [ i ] - x ) while l < m and b [ l ] < minm : l += 1 if l < m and b [ l ] <= a [ i ] + y : outputs . append ( f ' { i + 1 } ▁ { l + 1 } ' ) l += 1 print ( len ( outputs ) ) for output in outputs : print ( output )   NEW_LINE +" +E318,"import java . io . * ; import java . util . * ;   public class A1008 { public static void main ( String [ ] args ) { InputStream inputReader = System . in ; OutputStream outputReader = System . out ; InputReader in = new InputReader ( inputReader ) ; +","import sys   window = set ( )   n , k , q = [ int ( x ) for x in input ( ) . split ( ) ] arr = [ int ( x ) for x in input ( ) . split ( ) ]   for i in range ( q ) : a , b = [ int ( x ) for x in input ( ) . split ( ) ] if ( a == 1 ) : if ( len ( window ) < k ) : window . add ( arr [ b - 1 ] ) else : window . add ( arr [ b - 1 ] ) m = min ( window ) window . remove ( m ) else : print ( "" YES "" if arr [ b - 1 ] in window else "" NO "" ) NEW_LINE +" +E319,"import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Shell { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException {   int k = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int left [ ] = { 1 , 2 , 2 , 1 , 0 , 0 } ; int right [ ] = { 2 , 1 , 0 , 0 , 1 , 2 } ; int middle [ ] = { 0 , 0 , 1 , 2 , 2 , 1 } ; int y = k % 6 ; if ( y > 0 ) { if ( left [ y - 1 ] == x ) System . out . println ( 0 ) ; if ( right [ y - 1 ] == x ) System . out . println ( 2 ) ; if ( middle [ y - 1 ] == x ) System . out . println ( 1 ) ; } else { if ( left [ 5 ] == x ) System . out . println ( 0 ) ; if ( right [ 5 ] == x ) System . out . println ( 2 ) ; if ( middle [ 5 ] == x ) System . out . println ( 1 ) ;   }   }   +","n = int ( input ( ) ) x = int ( input ( ) ) a = [ 0 ] * 3 a [ x ] = 1 for i in range ( n % 6 + 1 , 7 ) : if i % 2 == 1 : a [ 0 ] , a [ 1 ] = a [ 1 ] , a [ 0 ] else : a [ 1 ] , a [ 2 ] = a [ 2 ] , a [ 1 ] for i in range ( 3 ) : if a [ i ] == 1 : print ( i ) NEW_LINE +" +E320,"import java . util . Scanner ;   public class Queue_in_bus_stop {   public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int groupN = in . nextInt ( ) ; int count = 1 ; int j = m - groupN ; for ( int i = 1 ; i < n ; i ++ ) { groupN = in . nextInt ( ) ; if ( groupN > j ) { count ++ ; j = m - groupN ; } else { j -= groupN ; } } System . out . println ( count ) ; }   } +","n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) current , ans = 0 , 1 for x in a : if current + x <= m : current += x else : current = x ans += 1   print ( ans ) NEW_LINE +" +E321,"import java . util . Scanner ;   public class MikeAndPallindrome {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int lo = 0 ; int hi = str . length ( ) - 1 ; Check ( str , lo , hi ) ;   }   public static void Check ( String str , int lo , int hi ) { int check = 0 ; while ( lo < hi ) { if ( str . charAt ( lo ) != str . charAt ( hi ) ) { check ++ ; } hi -- ; lo ++ ; } if ( check == 1 || ( str . length ( ) % 2 != 0 && check == 0 ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } }   } +","s = input ( ) s1 = s [ : len ( s ) // 2 ] if len ( s ) % 2 == 0 : s2 = s [ len ( s ) // 2 : ] else : s2 = s [ len ( s ) // 2 + 1 : ]   s2 = s2 [ - 1 : : - 1 ] NEW_LINE +" +E322,"import java . io . * ; import java . math . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; sc . nextLine ( ) ; while ( T -- > 0 ) { String x = sc . nextLine ( ) ; +","for _ in range ( int ( input ( ) ) ) : S = input ( ) if S . count ( ""1"" ) == 0 : print ( 0 ) else : A = S [ S . index ( ""1"" ) : S . rfind ( ""1"" ) + 1 ] print ( A . count ( ""0"" ) ) NEW_LINE +" +E323,"import java . io . InputStream ; import java . io . OutputStream ; import java . io . IOException ; import java . util . ArrayList ; import java . io . InputStream ; import java . io . BufferedWriter ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . io . IOException ; import java . util . InputMismatchException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . io . OutputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; OutputWriter out = new OutputWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { double special ( int [ ] loyalties , int [ ] levels , int playerlevelsum ) { int poss = 1 << loyalties . length ; double res = 0 ; for ( int pos = 0 ; pos < poss ; pos ++ ) { double occurs = 1 ; int happy = 0 ; int badlevelssum = 0 ; for ( int i = 0 ; i < loyalties . length ; i ++ ) { if ( ( ( pos >> i ) & 1 ) == 1 ) { +","import itertools as it   def powerset ( iterable ) : "" powerset ( [1,2,3 ] ) ▁ - - > ▁ ( ) ▁ ( 1 , ) ▁ ( 2 , ) ▁ ( 3 , ) ▁ ( 1,2 ) ▁ ( 1,3 ) ▁ ( 2,3 ) ▁ ( 1,2,3 ) "" s = list ( iterable ) return it . chain . from_iterable ( it . combinations ( s , r ) \ for r in range ( len ( s ) + 1 ) )     n , k , A = map ( int , input ( ) . split ( ) )   best_result = 0   missing = 0   senators = [ ] for _ in range ( n ) : level , loyality = map ( int , input ( ) . split ( ) ) senators += [ [ level , loyality ] ] missing += 10 - loyality // 10   k = min ( [ k , missing ] ) NEW_LINE +" +E324,"import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; Point c = new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ; Point [ ] arr = new Point [ n ] ; double INF = 1e16 ; double minr = INF , maxr = - INF ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = new Point ( sc . nextInt ( ) , sc . nextInt ( ) ) ; maxr = Math . max ( maxr , arr [ i ] . dist ( c ) ) ; } for ( int i = 0 ; i < n ; i ++ ) minr = Math . min ( minr , Point . distToLineSegment ( c , arr [ i ] , arr [ ( i + 1 ) % n ] ) ) ; out . println ( Math . PI * ( maxr * maxr - minr * minr ) ) ; out . close ( ) ; }   static class Vector {   double x , y ;   Vector ( double a , double b ) { x = a ; y = b ; }   Vector ( Point a , Point b ) { this ( b . x - a . x , b . y - a . y ) ; }   Vector scale ( double s ) { return new Vector ( x * s , y * s ) ; } +","PI = 3.141592653589793 n , a , b = map ( int , input ( ) . split ( ) ) arr , res = [ ] , [ ] for _ in range ( n ) : u , v = input ( ) . split ( ) arr . append ( ( int ( u ) - a , int ( v ) - b ) ) x0 , y0 = arr [ - 1 ] for x1 , y1 in arr : res . append ( x1 * x1 + y1 * y1 ) dx , dy = x1 - x0 , y1 - y0 if ( x0 * dx + y0 * dy ) * ( x1 * dx + y1 * dy ) < 0 : x0 = x0 * y1 - x1 * y0 res . append ( ( x0 * x0 ) / ( dx * dx + dy * dy ) ) x0 , y0 = x1 , y1print ( ( max ( res ) - min ( res ) ) * PI ) NEW_LINE +" +E325,"import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int N = stdin . nextInt ( ) ; int K = stdin . nextInt ( ) ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = stdin . nextInt ( ) ; } Arrays . sort ( arr ) ; int k = arr [ N - K ] ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= k && arr [ i ] > 0 ) { ans = N - i ; break ; } } System . out . println ( ans ) ; } } +","n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = 0 for i in a : if i > 0 and i >= a [ k - 1 ] : c = c + 1 print ( c ) NEW_LINE +" +E326,"import java . util . * ; public class contest14 { static Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scn . nextInt ( ) ; int A = scn . nextInt ( ) ; int B = scn . nextInt ( ) ; Integer [ ] arr = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = scn . nextInt ( ) ; if ( A == B ) { System . out . println ( n - 1 ) ; return ; } int s1 = arr [ 0 ] ; Arrays . sort ( arr , Collections . reverseOrder ( ) ) ; int S = 0 ; for ( int val : arr ) S += val ; boolean is_s1 = false ; int block = 0 ; if ( ( s1 * A ) / S >= B ) { System . out . println ( block ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == s1 && ! is_s1 ) { is_s1 = true ; continue ; } S = S - arr [ i ] ; block ++ ; if ( ( s1 * A ) / S >= B ) { System . out . println ( block ) ; return ; } } } }   +","holes , water_have , water_plant = map ( int , input ( ) . split ( ) ) hole_ratio = list ( map ( int , input ( ) . split ( ) ) ) plant_A = hole_ratio [ 0 ] hole_ratio = hole_ratio [ 1 : ] hole_ratio . sort ( ) hole_ratio . reverse ( ) blocked = 0 sum_non_blocked = sum ( hole_ratio ) + plant_A   for each in hole_ratio : if ( water_have * plant_A / sum_non_blocked >= water_plant ) : break sum_non_blocked -= each blocked += 1 print ( blocked )   NEW_LINE +" +E327,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . StringTokenizer ;   public class B { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int t = fs . nextInt ( ) ; while ( t -- > 0 ) { int n = fs . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; int ans = 0 , one = 0 , two = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int b = fs . nextInt ( ) ; if ( b % 3 == 0 ) ans ++ ; else if ( b % 3 == 1 ) { one ++ ; } else two ++ ; } int e = Math . min ( one , two ) ; one -= e ; two -= e ; ans += e + ( one ) / 3 + ( two ) / 3 ; System . out . println ( ans ) ; } } static class FastScanner { 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 ( ) ) ; } } } +","''' a = [ int ( i ) ▁ for ▁ i ▁ in ▁ input ( ) . split ( ) ] x = a [ 0 ] y = a [ 1 ] z = a [ 2 ] if ▁ y = = x ▁ and ▁ z = = 0 : ▁ ▁ ▁ ▁ print ( '0 ' ) elif ▁ x > y + z : ▁ ▁ ▁ ▁ print ( ' + ' ) elif ▁ y > x + z : ▁ ▁ ▁ ▁ print ( ' - ' ) else : ▁ ▁ ▁ ▁ print ( ' ? ' ) n = int ( input ( ) ) z = [ int ( i ) ▁ for ▁ i ▁ in ▁ input ( ) . split ( ) ] x = [ ] d = 0v = ' ' for ▁ i ▁ in ▁ range ( n ) : ▁ ▁ ▁ ▁ c = 0 ▁ ▁ ▁ ▁ e = 0 ▁ ▁ ▁ ▁ for ▁ f ▁ in ▁ range ( len ( z ) ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ z [ f ] > c ▁ and ▁ f + 1 ▁ not ▁ in ▁ x : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ c = z [ f ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ e = f + 1 ▁ ▁ ▁ ▁ d + = ( i * c ) + 1 ▁ ▁ ▁ ▁ x . append ( e ) print ( d ) for ▁ i ▁ in ▁ x : ▁ ▁ ▁ ▁ v + = str ( i ) ▁ ▁ ▁ ▁ v + = ' ▁ ' print ( v )  f = int ( input ( ) ) g = [ int ( i ) ▁ for ▁ i ▁ in ▁ input ( ) . split ( ) ] for ▁ i ▁ in ▁ range ( len ( g ) -1 ) : ▁ ▁ ▁ ▁ for ▁ f ▁ in ▁ range ( len ( g ) -1 - i ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ g [ f ] > g [ f + 1 ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ��� ▁ ▁ ▁ g [ f ] , g [ f + 1 ] = g [ f + 1 ] , g [ f ] if ▁ g [ 0 ] * g [ 1 ] > g [ -2 ] * g [ -3 ] ▁ and ▁ g [ -1 ] > 0 : ▁ ▁ ▁ ▁ print ( g [ -1 ] * g [ 0 ] * g [ 1 ] ) else : ▁ ▁ ▁ ▁ print ( g [ -1 ] * g [ -2 ] * g [ -3 ] ) for ▁ u ▁ in ▁ range ( int ( input ( ) ) ) : ▁ ▁ ▁ ▁ z = int ( input ( ) ) ▁ ▁ ▁ ▁ y = [ int ( f ) ▁ for ▁ f ▁ in ▁ input ( ) . split ( ) ] ▁ ▁ ▁ ▁ y . sort ( ) ▁ ▁ ▁ ▁ d = 0 ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ y : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ d + = i ▁ ▁ ▁ ▁ if ▁ d < 2048 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' No ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ continue ▁ ▁ ▁ ▁ if ▁ 2048 ▁ in ▁ y : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' yes ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ continue ▁ ▁ ▁ ▁ for ▁ x ▁ in ▁ range ( z + 1 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ 2048 ▁ in ▁ y : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' yes ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ break ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( len ( y ) -1 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ y [ i ] = = y [ i + 1 ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ y [ i + 1 ] = y [ i ] *2 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ y . pop ( i ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i > len ( y ) -3 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ break ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ y . sort ( ) ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' no ' ) n = int ( input ( ) ) x = [ ] for ▁ i ▁ in ▁ range ( 1 , ( ( n * *2 ) / /2 ) + 1 ) : ▁ ▁ ▁ ▁ x . append ( n * *2 + 1 - i ) ▁ ▁ ▁ ▁ x . append ( i ) ▁ ▁ ▁ ▁ if ▁ len ( x ) = = n : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( * x ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ x = [ ] ''' for z in range ( int ( input ( ) ) ) : z = int ( input ( ) ) x = [ int ( i ) for i in input ( ) . split ( ) ] f = 0 o = 0 t = 0 for i in range ( z ) : if x [ i ] % 3 == 0 : f += 1 elif x [ i ] % 3 == 1 : o += 1 else : t += 1 if o < t : print ( f + o + ( t - o ) // 3 ) else : print ( f + t + ( o - t ) // 3 ) NEW_LINE +" +E328,"import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; long price [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { price [ i ] = input . nextLong ( ) ; } int front [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { front [ i ] = input . nextInt ( ) ; } int back [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { back [ i ] = input . nextInt ( ) ; } HashMap < Integer , TreeMap < Long , Integer > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! map . containsKey ( front [ i ] ) ) { TreeMap < Long , Integer > lol = new TreeMap < > ( ) ; map . put ( front [ i ] , lol ) ; } if ( front [ i ] != back [ i ] ) map . get ( front [ i ] ) . put ( price [ i ] , back [ i ] ) ; if ( ! map . containsKey ( back [ i ] ) ) { TreeMap < Long , Integer > lol = new TreeMap < > ( ) ; map . put ( back [ i ] , lol ) ; } if ( front [ i ] == back [ i ] ) map . get ( back [ i ] ) . put ( price [ i ] , 0 ) ; else map . get ( back [ i ] ) . put ( price [ i ] , front [ i ] ) ; } +","import heapqn = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) f = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) choice = list ( map ( int , input ( ) . split ( ) ) ) dic = { } dic [ 1 ] = [ ] dic [ 2 ] = [ ] dic [ 3 ] = [ ] pdic = { }   for i in range ( n ) : pdic [ p [ i ] ] = 0 dic [ f [ i ] ] . append ( p [ i ] ) dic [ b [ i ] ] . append ( p [ i ] ) heapq . heapify ( dic [ 1 ] ) heapq . heapify ( dic [ 2 ] ) heapq . heapify ( dic [ 3 ] ) for i in range ( m ) : try : z = heapq . heappop ( dic [ choice [ i ] ] ) while pdic [ z ] != 0 : z = heapq . heappop ( dic [ choice [ i ] ] ) pdic [ z ] = 1 print ( z , end = ' ▁ ' ) except : print ( - 1 , end = ' ▁ ' )   NEW_LINE +" +E329,"import java . util . * ;   public class P3 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap ( ) ; int c = 0 ; while ( t -- > 0 ) { String breed = sc . next ( ) ; String color = sc . next ( ) ; String m = breed + ' . ' + color ; if ( ! map . containsKey ( m ) ) { map . put ( m , 1 ) ; c ++ ; } } System . out . println ( c ) ; } } +","n = int ( input ( ) ) arr = [ ] ans = 0 for i in range ( n ) : s = input ( ) if s not in arr : arr . append ( s ) ans += 1 print ( ans ) NEW_LINE +" +E330,"import java . util . Scanner ;   public class SentimentReplace { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) ;   if ( k == 1 ) { int i , a [ ] = new int [ n ] ; String o = "" No "" ; for ( i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; int b = in . nextInt ( ) ;   for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) a [ i ] = b ; if ( i > 0 ) if ( a [ i ] <= a [ i - 1 ] ) o = "" Yes "" ; } System . out . println ( o ) ; } else { System . out . println ( "" Yes "" ) ; } in . close ( ) ; } } +","n , m = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) ab = list ( map ( int , input ( ) . split ( ) ) ) ab . sort ( reverse = True ) for i in range ( n ) : if arr [ i ] == 0 : arr [ i ] = ab . pop ( 0 )   if arr == sorted ( arr ) : print ( "" NO "" ) else : print ( "" YES "" ) NEW_LINE +" +E331,"import java . io . * ; import java . util . * ;   public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int t = reverse ( m ) ; System . out . println ( t + n ) ; +","a , b = input ( ) . split ( ) print ( int ( a ) + int ( str ( b ) [ : : - 1 ] ) ) NEW_LINE +" +E332,"import java . util . Scanner ;   public class LuckyTicket {   public static void main ( String [ ] argus ) { Scanner scanner = new Scanner ( System . in ) ; int size = scanner . nextInt ( ) ; String value = scanner . next ( ) ; int domain = size / 2 ; boolean res = true ; int sum1 = 0 ; int sum2 = 0 ; for ( int i = 0 ; i < size ; i ++ ) { char myChar = value . charAt ( i ) ; if ( myChar != '4' && myChar != '7' ) { res = false ; break ; } int newMyChar = Integer . parseInt ( myChar + "" "" ) ; if ( i < domain ) { sum1 += newMyChar ; } else { sum2 += newMyChar ; } } if ( res && sum1 == sum2 ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } }   } +","n = int ( input ( ) ) t = list ( input ( ) ) A = 0 B = 0 r = 1 for i in t : if int ( i ) != 7 and int ( i ) != 4 : r = 0 if r > 0 : i = ( int ( n / 2 ) ) - 1 j = int ( n / 2 )   while i >= 0 : A = A + int ( t [ i ] ) B = B + int ( t [ j ] ) i -= 1 j += 1 if r == 1 and A == B : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E333,"import java . util . * ; import java . io . * ; public class problem2 { public static void primeFactors ( int n , ArrayList < Integer > arr ) { +","l , s , l = input ( ) , ' ' , list ( map ( int , input ( ) . split ( ) ) ) for i in range ( len ( l ) ) : if l [ i ] != 0 : if ( len ( s ) < 2 or s [ - 1 ] == ' R ' ) and l [ i ] == 1 : s += ' PR ' else : if i != 0 : s += ' PLR ' * l [ i ] else : s += ' PRL ' * l [ i ] s += ' R ' else : s += ' R ' print ( s [ : - 1 ] ) NEW_LINE +" +E334,"import java . util . Scanner ;   public class problem54 {   public static void main ( String [ ] args ) { +","s = input ( ) print ( s + s [ : : - 1 ] ) NEW_LINE +" +E335,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BigInteger n = new BigInteger ( bf . readLine ( ) . trim ( ) ) ; int in = n . intValue ( ) , L = 0 ; while ( ( in & 1 ) == 0 ) { in >>= 1 ; L ++ ; } if ( in == 1 ) { System . out . printf ( "" % d / 1 \n "" , L ) ; return ; } n = new BigInteger ( String . valueOf ( in ) ) ; BigInteger s = BigInteger . ONE , t = BigInteger . ONE , two = new BigInteger ( ""2"" ) ; int m = 0 ; for ( int i = 0 ; i < in ; i ++ ) { s = s . multiply ( two ) ; t = t . multiply ( two ) . mod ( n ) ; if ( t . equals ( BigInteger . ONE ) ) { m = i + 1 ; break ; } } t = s . multiply ( n ) ; BigInteger r = s , ans = BigInteger . ZERO ; int i = L ; while ( r . compareTo ( BigInteger . ONE ) > 0 ) { i ++ ; t = t . divide ( two ) ; if ( r . compareTo ( t ) > 0 ) { r = r . subtract ( t ) ; ans = ans . add ( t . multiply ( new BigInteger ( String . valueOf ( i ) ) ) ) ; } } ans = ans . add ( new BigInteger ( String . valueOf ( m ) ) ) ; s = s . subtract ( BigInteger . ONE ) ; BigInteger d = ans . gcd ( s ) ; System . out . printf ( "" % s / % s \n "" , ans . divide ( d ) , s . divide ( d ) ) ; } } +","import math NEW_LINE def simply ( a , b ) : NEW_LINE INDENT g = math . gcd ( a , b ) NEW_LINE a = a // g NEW_LINE b = b // g NEW_LINE return ( a , b ) NEW_LINE DEDENT def mul ( a , b , c , d ) : NEW_LINE INDENT return simply ( a * c , b * d ) NEW_LINE DEDENT def add ( a , b , c , d ) : NEW_LINE INDENT return simply ( a * d + b * c , b * d ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE nxt = 0 NEW_LINE depth = 0 NEW_LINE node = 1 NEW_LINE total_node = 1 NEW_LINE p = 0 NEW_LINE q = 1 NEW_LINE while ( n % 2 == 0 ) : NEW_LINE INDENT depth = depth + 1 NEW_LINE n = n // 2 NEW_LINE DEDENT nxt = depth NEW_LINE if ( n == 1 ) : NEW_LINE INDENT print ( str ( depth ) + "" / 1"" ) NEW_LINE return NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT node = node * 2 NEW_LINE total_node = total_node * 2 NEW_LINE depth = depth + 1 NEW_LINE p = p * 2 NEW_LINE q = q * 2 NEW_LINE if ( node >= n ) : NEW_LINE INDENT p = p + n * depth NEW_LINE node -= n NEW_LINE DEDENT if ( node == 1 ) : NEW_LINE INDENT nxt = depth - nxt NEW_LINE break NEW_LINE DEDENT DEDENT p , q = mul ( p , q , total_node , total_node - 1 ) NEW_LINE s , t = ( total_node - 1 ) * nxt * total_node * total_node , total_node * total_node * ( total_node - 1 ) * ( total_node - 1 ) NEW_LINE s , t = simply ( s , t ) NEW_LINE x , y = add ( p , q , s , t ) NEW_LINE print ( str ( x ) + "" / "" + str ( y ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E336,"  import java . lang . reflect . Array ; import java . text . CollationElementIterator ; import java . util . * ; import java . util . Map . Entry ; import java . io . * ; import java . lang . Math . * ; import java . math . BigInteger ;   import static java . lang . System . * ; import static java . util . Arrays . fill ; import static java . lang . Math . log ; import static java . lang . Math . abs ; import static java . lang . Math . pow ; import static java . lang . Math . sqrt ; import static java . lang . Math . floor ; import static java . lang . Math . ceil ; import static java . lang . Math . sin ; import static java . lang . Math . cos ; import static java . lang . Math . tan ; import static java . util . Arrays . spliterator ; public class ContestMain implements Runnable { private static Reader in = new Reader ( ) ; private static StringBuilder ans = new StringBuilder ( ) ; private static long MOD = 998244353 ; private static final int N = ( int ) ( 2e5 + 7 ) ; +","from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect   NEW_LINE +" +E337,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class NewClass {   public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int len = Integer . parseInt ( reader . readLine ( ) ) ; String str = reader . readLine ( ) ; int conuterOnces = 0 , counterZeros = 0 ;   +","num = int ( input ( ) ) s = input ( ) s1 = s . count ( '1' ) s0 = s . count ( '0' ) output = abs ( s1 - s0 ) print ( output ) NEW_LINE +" +E338,"import java . io . * ; import java . util . Arrays ; import java . util . Iterator ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws IOException { PrintWriter out = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; StreamTokenizer sc = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; +","t = int ( input ( ) ) for _ in range ( t ) : n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) p = list ( map ( int , input ( ) . split ( ) ) ) p = set ( p ) while ( 1 ) : f = 0 for i in range ( n - 1 ) : if a [ i ] > a [ i + 1 ] and i + 1 in p : a [ i ] , a [ i + 1 ] = a [ i + 1 ] , a [ i ] f = 1 if not f : break if a == sorted ( a ) : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E339,"import java . util . * ; import java . io . * ; public class helloworld { static long fact [ ] ; static long max ; static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ; public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ; +","import sysinput = sys . stdin . readline   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) adj = [ [ ] for i in range ( n ) ] for i in range ( n - 1 ) : u , v , w = map ( int , input ( ) . split ( ) ) u -= 1 v -= 1 adj [ u ] . append ( ( v , w ) ) adj [ v ] . append ( ( u , w ) ) best = [ 0 ] * nans = 0   def dfs ( u ) : stack = list ( ) visit = [ False ] * n stack . append ( ( u , - 1 ) ) while stack : u , par = stack [ - 1 ] if not visit [ u ] : visit [ u ] = True for v , w in adj [ u ] : if v != par : stack . append ( ( v , u ) ) else : cand = [ ] for v , w in adj [ u ] : if v != par : cand . append ( best [ v ] + a [ v ] - w ) cand . sort ( reverse = True ) cur = a [ u ] for i in range ( 2 ) : if i < len ( cand ) and cand [ i ] > 0 : cur += cand [ i ] global ans ans = max ( ans , cur ) best [ u ] = cand [ 0 ] if len ( cand ) > 0 and cand [ 0 ] > 0 else 0 stack . pop ( )   dfs ( 0 ) print ( ans ) NEW_LINE +" +E340,"import java . io . * ; import java . util . * ;   public class task1 { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) . trim ( ) ; int k = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; int len = str . length ( ) ; int st = 0 ; int ct = 0 ; if ( len % k != 0 ) { System . out . println ( "" NO "" ) ; return ; } k = len / k ; while ( st < len ) { +","s = input ( ) k = int ( input ( ) ) l = len ( s )   if l % k : print ( "" NO "" ) else : f = True t = l // k for i in range ( 0 , l , t ) : sub = s [ i : i + t ] if sub != sub [ : : - 1 ] : f = False break   print ( "" YES "" if f else "" NO "" )       NEW_LINE +" +E341,"import java . io . * ; import java . lang . * ; import java . util . * ;   public class Training3_C { public static void main ( String [ ] args ) throws IOException { StringTokenizer st ; BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( f . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int m = Integer . parseInt ( st . nextToken ( ) ) ; int ta = Integer . parseInt ( st . nextToken ( ) ) ; int tb = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; long [ ] arr = new long [ n ] ; long [ ] arr1 = new long [ m ] ; st = new StringTokenizer ( f . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Long . parseLong ( st . nextToken ( ) ) ; } st = new StringTokenizer ( f . readLine ( ) ) ; for ( int i = 0 ; i < m ; i ++ ) { arr1 [ i ] = Long . parseLong ( st . nextToken ( ) ) ; }   f . close ( ) ; long start = arr [ k - 1 ] + ta ; int end = - 1 ; for ( int i = 0 ; i < m ; i ++ ) { if ( arr1 [ i ] >= start ) { end = i ; } } if ( end == - 1 ) { System . out . println ( - 1 ) ; return ; } long best = - 1 ; for ( int i = k ; i > - 1 ; i -- ) { int index = k ; if ( k >= n ) { int r = k - n ; best = Math . min ( best , arr1 [ r ] + tb ) ; } else { index = Arrays . binarySearch ( arr1 , arr [ i ] + ta ) ; if ( index < 0 ) { index = Math . abs ( index + 1 ) + ( k - i ) ; } +","from bisect import bisect_left   n , m , ta , tb , k = map ( int , input ( ) . split ( ) ) a = [ int ( X ) + ta for X in input ( ) . split ( ) ] b = [ int ( X ) for X in input ( ) . split ( ) ] an = - 1 NEW_LINE +" +E342,"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 . HashSet ; import java . util . Scanner ; import java . util . Set ; import java . util . StringTokenizer ; import java . util . TreeSet ; import javafx . scene . shape . TriangleMesh ;   public class Cf { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static class BufPrint { final BufferedWriter bw ; public BufPrint ( ) { this . bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; } public void print ( Object object ) throws IOException { bw . append ( "" "" + object ) ; } public void println ( Object object ) throws IOException { print ( object ) ; bw . append ( "" \n "" ) ; } public void close ( ) throws IOException { bw . close ( ) ; } }   public static int GCD ( int l , int r ) { int gcd = 1 ; for ( int i = 1 ; i <= l && i <= r ; ++ i ) { +","for i in range ( int ( input ( ) ) ) : print ( max ( 0 , int ( input ( ) ) - 2 ) ) NEW_LINE +" +E343,"import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] sum = new int [ k ] ; int min = Integer . MAX_VALUE , res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum [ i % k ] += sc . nextInt ( ) ; } for ( int i = 0 ; i < k ; i ++ ) { if ( sum [ i ] < min ) { res = i ; min = sum [ i ] ; } } System . out . println ( res + 1 ) ; } } +","a , b = map ( int , input ( ) . split ( ) ) c = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 mini = sum ( c ) for i in range ( b ) : d = i su = 0 while ( d < a ) :   su += c [ d ] d += b if su < mini :   mini = su ans = iprint ( ans + 1 ) NEW_LINE +" +E344,"import java . util . * ; import java . io . * ; public final class Example { public static void main ( String [ ] args ) { Map < Integer , List < Integer > > map = new HashMap < > ( ) ; try { BufferedReader buffer = new BufferedReader ( new InputStreamReader ( System . in ) ) ; args = buffer . readLine ( ) . split ( "" ▁ "" ) ; int n = Integer . parseInt ( args [ 0 ] ) ; int x = Integer . parseInt ( args [ 1 ] ) ; args = buffer . readLine ( ) . split ( "" ▁ "" ) ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { arr [ i ] = Integer . parseInt ( args [ i - 1 ] ) ; } for ( int i = 1 ; i <= n ; i ++ ) { int y = arr [ i ] ; if ( ! map . containsKey ( y ) ) { map . put ( y , new ArrayList < Integer > ( ) ) ; } map . get ( y ) . add ( arr [ i ] ) ; if ( x == 0 ) { continue ; } y = y ^ x ; if ( ! map . containsKey ( y ) ) { map . put ( y , new ArrayList < Integer > ( ) ) ; } map . get ( y ) . add ( arr [ i ] ) ; } long counter = 0 ; if ( x == 0 ) { for ( int key : map . keySet ( ) ) { long m = map . get ( key ) . size ( ) ; counter += ( m * ( m - 1 ) ) / 2 ; } } else { for ( int key : map . keySet ( ) ) { +","n , x = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) dp = [ 0 ] * ( 1 << 18 ) ans = 0 NEW_LINE +" +E345,"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class A187 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) {   int tc = 1 ; +","x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) x , y = map ( int , input ( ) . split ( ) ) if ( x2 - x1 ) % x == 0 and ( y2 - y1 ) % y == 0 : if ( ( x2 - x1 ) // x + ( y2 - y1 ) // y ) % 2 == 0 : print ( "" YES "" ) else : print ( "" NO "" ) else : print ( "" NO "" ) NEW_LINE +" +E346,"import java . util . LinkedHashSet ; import java . util . Scanner ; public class A { public static int sol ( int x ) { x += 1 ; while ( x % 10 == 0 ) { x /= 10 ; } return x ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; LinkedHashSet < Integer > h = new LinkedHashSet < > ( ) ; while ( ! h . contains ( n ) ) { h . add ( n ) ; n = sol ( n ) ; } +","def new ( n ) : while n % 10 == 0 : n = n // 10 return n if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) d = dict ( ) c = 1 flag = 1 d . setdefault ( n , 1 ) while flag == 1 : n = n + 1 n = new ( n ) d . setdefault ( n , 0 ) if d [ n ] == 0 : d [ n ] = 1 c += 1 else : flag = 0 print ( c ) NEW_LINE +" +E347,"import java . io . * ;   public class Main { static long a , b , x , y , z ; static StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   public static void main ( String [ ] args ) throws IOException { st . nextToken ( ) ; a = ( int ) st . nval ; st . nextToken ( ) ; b = ( int ) st . nval ; st . nextToken ( ) ; x = ( int ) st . nval ; st . nextToken ( ) ; y = ( int ) st . nval ; st . nextToken ( ) ; z = ( int ) st . nval ; a = 2 * x + y - a ; b = 3 * z + y - b ; if ( a < 1 ) { a = 0 ; } if ( b < 1 ) { b = 0 ; } bw . write ( a + b + "" "" ) ; bw . close ( ) ; } } +","T_ON = 0 DEBUG_ON = 0 MOD = 998244353     def solve ( ) : a , b = read_ints ( ) x , y , z = read_ints ( ) print ( max ( 0 , 2 * x + y - a ) + max ( 0 , y + 3 * z - b ) )     def main ( ) : T = read_int ( ) if T_ON else 1 for i in range ( T ) : solve ( )     def debug ( * xargs ) : if DEBUG_ON : print ( * xargs )     from collections import * import math     NEW_LINE +" +E348,"import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ;   public class Div1_453B {   static int n ;   public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter printer = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] prev = new int [ n + 1 ] ; int [ ] cur = new int [ n + 1 ] ; prev [ 0 ] = 1 ; cur [ 1 ] = 1 ;   for ( int i = 1 ; i < n ; i ++ ) { int [ ] nxt = add ( prev , lShift ( cur ) ) ; prev = cur ; cur = nxt ; } printer . println ( n ) ; for ( int i = 0 ; i <= n ; i ++ ) { printer . print ( cur [ i ] + "" ▁ "" ) ; } printer . println ( ) ; printer . println ( n - 1 ) ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { printer . print ( prev [ i ] + "" ▁ "" ) ; } printer . println ( ) ; printer . close ( ) ; }   static int [ ] add ( int [ ] a , int [ ] b ) { int [ ] ret = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { ret [ i ] = ( a [ i ] + b [ i ] ) % 2 ; } return ret ; }   static int [ ] lShift ( int [ ] items ) { int [ ] ret = new int [ n + 1 ] ; for ( int i = n ; i >= 1 ; i -- ) { ret [ i ] = items [ i - 1 ] ; } return ret ; }   } +","n = input ( )   p0 = [ 1 ] p1 = [ 0 , 1 ]   if n == 1 : print 1 print 0 , 1 print 0 print 1 exit ( )   for i in xrange ( 2 , n + 1 ) : p = [ 0 for j in xrange ( i + 1 ) ]   for j in xrange ( len ( p1 ) ) : p [ j + 1 ] = p1 [ j ] for j in xrange ( len ( p0 ) ) : p [ j ] += p0 [ j ]   for j in xrange ( len ( p ) ) : p [ j ] %= 2   if i == n : print i print ' ▁ ' . join ( map ( str , p ) ) print i - 1 print ' ▁ ' . join ( map ( str , p1 ) )   p0 = [ p1 [ j ] for j in xrange ( len ( p1 ) ) ] p1 = [ p [ j ] for j in xrange ( len ( p ) ) ] NEW_LINE +" +E349,"import java . util . * ; public class Solution { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String first = sc . next ( ) . toLowerCase ( ) ; String second = sc . next ( ) . toLowerCase ( ) ; int c1 = 0 , c2 = 0 ; if ( first . compareTo ( second ) == 0 ) { System . out . println ( ""0"" ) ; } if ( first . compareTo ( second ) > 0 ) { System . out . println ( ""1"" ) ; } if ( first . compareTo ( second ) < 0 ) { System . out . println ( "" - 1"" ) ; } } } +","x = input ( ) . lower ( ) y = input ( ) . lower ( ) if ( x < y ) : print ( "" - 1"" ) elif ( x > y ) : print ( ""1"" ) else : print ( ""0"" ) NEW_LINE +" +E350,"import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ;   public final class PermutationGamesCF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int arr [ ] = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int ans [ ] = new int [ n + 1 ] ; Arrays . fill ( ans , - 1 ) ; boolean vis [ ] = new boolean [ n + 1 ] ; boolean isTrue = true ; for ( int i = 0 ; i < m - 1 ; i ++ ) { int src = arr [ i ] ; int dest = arr [ i + 1 ] ; if ( dest > src ) { int val = dest - src ; +","n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) used = [ 0 ] * ( n + 1 ) ans = [ 0 ] * ( n + 1 )   for x , y in zip ( a , a [ 1 : ] ) : z = ( y - x ) % n or n if ans [ x ] == 0 and used [ z ] or ans [ x ] != 0 and ans [ x ] != z : print ( - 1 ) exit ( ) used [ z ] = 1 ans [ x ] = z   i = 1 for j in range ( 1 , n + 1 ) : if ans [ j ] == 0 : while used [ i ] : i += 1 ans [ j ] = i i += 1   print ( * ans [ 1 : ] ) NEW_LINE +" +E351,"import java . util . Scanner ; import java . util . Arrays ; import java . util . Vector ; import java . util . Collections ;    public class Problem_Solving1 { public static void main ( String [ ] args ) { +","n , m = map ( int , input ( ) . split ( ) ) while n > 0 and m > 0 : if n >= 2 * m : n = n % ( 2 * m ) elif m >= 2 * n : m = m % ( 2 * n ) else : breakprint ( n , m , sep = "" ▁ "" )   NEW_LINE +" +E352,"import java . util . * ; import java . io . * ; public class Solve {   static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringTokenizer st ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { String s = readLine ( ) ; Map < Character , Integer > mp = new HashMap ( ) ; mp . put ( ' f ' , 1 ) ; mp . put ( ' e ' , 2 ) ; mp . put ( ' d ' , 3 ) ; mp . put ( ' a ' , 4 ) ; mp . put ( ' b ' , 5 ) ; mp . put ( ' c ' , 6 ) ; char col = s . charAt ( s . length ( ) - 1 ) ; long row = Long . parseLong ( s . substring ( 0 , s . length ( ) - 1 ) ) ; long ans = 0 ; ans += 1L * ( row - 1 ) / 4 * 16 ; if ( row % 2 == 0 ) { ans += 7 ; ans += mp . get ( col ) ; } else ans += mp . get ( col ) ; println ( ans ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( input . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } static long readLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } static int readInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double readDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } static char readChar ( ) throws IOException { return next ( ) . charAt ( 0 ) ; } static String readLine ( ) throws IOException { return input . readLine ( ) . trim ( ) ; } static void print ( Object b ) { System . out . print ( b ) ; } static void println ( Object b ) { System . out . println ( b ) ; } static void println ( ) { System . out . println ( ) ; } } +","inp = input ( )   n = int ( inp [ 0 : ( len ( inp ) - 1 ) ] )   n -= 1   base = ( n // 4 ) * 16 + ( n % 2 ) * 7   def cnt ( s ) : if s == ' f ' : return 1 if s == ' e ' : return 2 if s == ' d ' : return 3 if s == ' a ' : return 4 if s == ' b ' : return 5 if s == ' c ' : return 6   print ( base + cnt ( inp [ len ( inp ) - 1 ] ) ) NEW_LINE +" +E353,"import java . io . * ; import java . util . StringTokenizer ; +","n = int ( input ( ) ) arr = [ i for i in range ( n ) ] NEW_LINE +" +E354,"import java . util . * ; public class CF_357B {   public static void main ( String [ ] args ) { +","import sysfrom collections import Counterdef fmax ( n , m , a ) : c = [ 0 ] * m b = [ 0 ] * n   if n == 3 * m : for i in range ( n // 3 ) : for j in range ( 3 ) : b [ a [ i ] [ j ] - 1 ] = j + 1 for i in range ( m ) : flag = 1 for j in range ( 3 ) : if b [ a [ i ] [ j ] - 1 ] != 0 : index = b [ a [ i ] [ j ] - 1 ] if j == 0 and index == 1 : continue b [ a [ i ] [ index - 1 ] - 1 ] = j + 1 continue b [ a [ i ] [ j ] - 1 ] = j + 1 return b if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) n = data [ 0 ] m = data [ 1 ] l = 0 a = [ ] for i in range ( m ) : a . append ( list ( map ( int , ( data [ l + 2 : l + 5 ] ) ) ) ) l = l + 3 print ( * fmax ( n , m , a ) ) NEW_LINE +" +E355,"   import java . util . * ;    public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; if ( n == 1 || n == 2 ) { System . out . println ( 1 ) ; System . out . println ( 1 ) ; } else if ( n == 3 ) { System . out . println ( 2 ) ; System . out . println ( 1 + "" ▁ "" + 3 ) ; } else if ( n == 4 ) { System . out . println ( 4 ) ; System . out . println ( 3 + "" ▁ "" + 1 + "" ▁ "" + 4 + "" ▁ "" + 2 ) ; } else { int a [ ] = new int [ n ] ; System . out . println ( n ) ; int j = 0 ; int i ; for ( i = 0 ; j < n ; i ++ ) { a [ j ] = i + 1 ; j += 2 ; } i ++ ; j = 1 ; for ( ; j < n ; i ++ ) { a [ j ] = i ; j += 2 ; } for ( int k = 0 ; k < n ; k ++ ) { System . out . print ( a [ k ] + "" ▁ "" ) ; } System . out . println ( "" "" ) ; } } }   +","def odd ( lst , n ) : for i in range ( 1 , n + 1 , 2 ) : lst . append ( i ) def even ( lst , n ) : start = 2 if len ( lst ) == 1 or n == 3 : start = 4 for j in range ( start , n + 1 , 2 ) : lst . append ( j )   n = int ( input ( ) ) lst = [ ]   if n % 2 == 0 and n > 2 : even ( lst , n ) odd ( lst , n ) else : odd ( lst , n ) even ( lst , n ) print ( len ( lst ) ) print ( * lst ) NEW_LINE +" +E356,"import java . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; public class B { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; +","def count ( x1 , y1 , z1 , x2 , y2 , z2 ) : if x2 == 0 and a != 0 or y2 == 0 and b != 0 or z2 == 0 and c != 0 : return False if x2 == 0 : x2 = 1 if y2 == 0 : y2 = 1 if z2 == 0 : z2 = 1 return ( x1 / x2 ) ** a * ( y1 / y2 ) ** b * ( z1 / z2 ) ** c < 1     n = int ( input ( ) ) a , b , c = map ( int , input ( ) . split ( ) ) l1 , r1 = 0 , nfor i in range ( 200 ) : x1 = l1 + ( r1 - l1 ) / 3 l2 , r2 = 0 , n - x1 for j in range ( 200 ) : y1 = l2 + ( r2 - l2 ) / 3 y2 = r2 - ( r2 - l2 ) / 3 if count ( x1 , y1 , n - x1 - y1 , x1 , y2 , n - x1 - y2 ) : l2 = y1 else : r2 = y2 y11 = l2 x2 = r1 - ( r1 - l1 ) / 3 l2 , r2 = 0 , n - x2 for j in range ( 200 ) : y1 = l2 + ( r2 - l2 ) / 3 y2 = r2 - ( r2 - l2 ) / 3 if count ( x2 , y1 , n - x2 - y1 , x2 , y2 , n - x2 - y2 ) : l2 = y1 else : r2 = y2 y22 = l2 if count ( x1 , y11 , n - x1 - y11 , x2 , y22 , n - x2 - y22 ) : l1 = x1 p = y11 else : r1 = x2 p = y22print ( l1 , p , n - l1 - p ) NEW_LINE +" +E357,"import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; +","s = input ( ) n = len ( s ) ans = s [ - 1 ] for i in range ( n - 2 , - 1 , - 1 ) : if s [ i ] >= ans [ - 1 ] : ans += s [ i ] print ( ans [ : : - 1 ] ) NEW_LINE +" +E358,"  import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ;    public class file {    +","n , k = map ( int , input ( ) . split ( ) ) lst = sorted ( [ int ( i ) % k for i in input ( ) . split ( ) ] ) low , high = 0 , n - 1 count = 0   while low < high : if lst [ low ] + lst [ high ] == k : low += 1 high -= 1 count += 2 elif lst [ low ] + lst [ high ] < k : low += 1 else : high -= 1   print ( count + 2 * ( lst . count ( 0 ) // 2 ) ) NEW_LINE +" +E359,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; public class Template { private static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static String readln ( ) throws IOException { String line = input . readLine ( ) ; return line ; } public static void main ( String [ ] args ) throws IOException { solution ( ) ; } public static void test ( ) throws IOException { int t = Integer . parseInt ( readln ( ) ) ; } public static void solution ( ) throws IOException { String [ ] nm = readln ( ) . split ( "" ▁ "" ) ; int n = Integer . parseInt ( nm [ 0 ] ) ; int m = Integer . parseInt ( nm [ 1 ] ) ; int cur = 1 ; while ( m > 0 ) { if ( m >= cur ) { m -= cur ; } else { System . out . println ( m ) ; return ; } if ( cur != n ) { cur ++ ; } else { cur = 1 ; } } System . out . println ( m ) ; } } +","import sys NEW_LINE def main ( ) : NEW_LINE INDENT n , m = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) NEW_LINE m %= ( 1 + n ) * n // 2 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT m -= i NEW_LINE if not m : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif m < 0 : NEW_LINE INDENT return m + i NEW_LINE DEDENT DEDENT DEDENT print ( main ( ) ) NEW_LINE +" +E360,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = false ; long [ ] res ;   void solve ( FastScanner in , PrintWriter out , int testNumber ) { n = in . nextInt ( ) ; int a , b ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; Set < Integer > p = new HashSet < > ( ) ; for ( int i = 0 ; i < a ; i ++ ) { p . add ( in . nextInt ( ) ) ; } Set < Integer > q = new HashSet < > ( ) ; for ( int i = 0 ; i < b ; i ++ ) { q . add ( in . nextInt ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( p . contains ( i + 1 ) ) { out . print ( ""1 ▁ "" ) ; } else if ( q . contains ( i + 1 ) ) { out . print ( ""2 ▁ "" ) ; } } out . println ( ) ; }   +","a , b , c = map ( int , input ( ) . split ( ) ) data = list ( map ( int , input ( ) . split ( ) ) ) datb = list ( map ( int , input ( ) . split ( ) ) ) res = [ ] for i in range ( 1 , a + 1 ) : if i in data : res . append ( ""1"" ) else : res . append ( ""2"" ) print ( "" ▁ "" . join ( res ) ) NEW_LINE +" +E361,"import java . util . Arrays ; import java . util . Scanner ;   public class A1445 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int X = in . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { A [ n ] = in . nextInt ( ) ; } int [ ] B = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { B [ n ] = in . nextInt ( ) ; } Arrays . sort ( A ) ; Arrays . sort ( B ) ; boolean ok = true ; for ( int n = 0 ; n < N ; n ++ ) { if ( A [ n ] + B [ N - 1 - n ] > X ) { ok = false ; break ; } } System . out . println ( ok ? "" Yes "" : "" No "" ) ; } }   } +","n = int ( input ( ) ) NEW_LINE for p in range ( n ) : n1 , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) [ : : - 1 ] NEW_LINE if p != n - 1 : z = input ( ) NEW_LINE for x in range ( n1 ) : if NEW_LINE a [ x ] + b [ x ] > k : print ( ' No ' ) NEW_LINE break else : print ( ' Yes ' ) NEW_LINE +" +E362,"import java . io . * ; import java . lang . reflect . Array ; import java . util . * ; import java . math . * ; import java . lang . * ; import static java . lang . Math . * ;   public class TaskB implements Runnable { ArrayList < Integer > prime ; boolean is_prime [ ] ; InputReader c ; PrintWriter w ;   long m = ( int ) 1e9 + 7 ; long MAXN = 4294967295L ;   public void run ( ) { c = new InputReader ( System . in ) ; w = new PrintWriter ( System . out ) ;   HashSet < Character > hs = new HashSet < > ( ) ; hs . add ( ' ! ' ) ; hs . add ( ' . ' ) ; hs . add ( ' ? ' ) ; int k = Integer . parseInt ( c . nextLine ( ) ) ; String s = c . nextLine ( ) ; int prev = 0 ; ArrayList < String > str = new ArrayList < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( hs . contains ( s . charAt ( i ) ) ) { str . add ( s . substring ( prev , i + 1 ) ) ; prev = i + 2 ; } } +","import ren = int ( input ( ) ) NEW_LINE ans , sumL = 1 , 0 NEW_LINE for s in re . split ( "" [ . ? ! ] "" , input ( ) ) : s = s . strip ( ) + ' . ' NEW_LINE L = len ( s ) NEW_LINE if L > 1 : if NEW_LINE L > n : print ( "" Impossible "" ) NEW_LINE exit ( ) NEW_LINE if sumL + L + ( sumL > 0 ) > n : ans += 1 NEW_LINE sumL = L else : sumL = sumL + L + ( sumL > 0 ) NEW_LINE print ( ans ) NEW_LINE +" +E363,"import java . util . * ; import java . io . * ; import java . math . BigInteger ;   public class tr0 { static PrintWriter out ; static StringBuilder sb ; static int mod = 1000000007 ; static long inf = ( long ) 1e16 ; static int n , m ; static ArrayList < Integer > [ ] ad ; static long [ ] [ ] [ ] memo ; static boolean f ; static boolean vis [ ] ; static int [ ] sub ; static char [ ] a ; static ArrayList < Long > ar ;   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; out = new PrintWriter ( System . out ) ; long k = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long t = sc . nextLong ( ) ; if ( k % d == 0 || t <= k ) { System . out . println ( ( double ) t ) ; } else { double w = k + ( d - k % d ) / 2d ; double w1 = k + ( d - k % d ) ; +","k , d , t = map ( int , input ( ) . split ( ) ) d = ( ( k + d - 1 ) // d ) * dn = 2 * t // ( d + k ) x = 2 * t % ( d + k ) if ( x <= 2 * k ) : ans = x / 2 + d * nelse : ans = x - k + d * nprint ( ans ) NEW_LINE +" +E364,"import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; String AnsName = "" "" ; long maxAns = Long . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { long sum = 0 ; String s = input . next ( ) ; int succesHack = input . nextInt ( ) ; int unsuccess = input . nextInt ( ) ; for ( int j = 0 ; j < 5 ; j ++ ) { sum += input . nextInt ( ) ; } sum = sum + ( 100 * succesHack ) - ( 50 * unsuccess ) ; if ( sum > maxAns ) { maxAns = sum ; AnsName = s ; } } System . out . println ( AnsName ) ; }   static class FastScanner { 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 ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   } +","n = int ( input ( ) ) NEW_LINE r = lambda : list ( map ( str , input ( ) . split ( ) ) ) NEW_LINE ans = - float ( ' inf ' ) NEW_LINE winner = "" xx "" NEW_LINE for _ in range ( n ) : name , * score = r ( ) NEW_LINE point = 0 NEW_LINE for i in score [ 2 : ] : point += int ( i )     NEW_LINE +" +E365,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; +","def prime ( n ) : c = 0 for i in range ( 2 , int ( pow ( n , 0.5 ) ) + 1 ) : if ( n % i == 0 ) : c = 1 break return c       n = int ( input ( ) ) if ( n == 1 ) : print ( 3 ) elif ( n == 2 ) : print ( 4 ) else : for i in range ( 1 , n + 1 ) : c1 = prime ( n * i + 1 ) if ( c1 == 1 ) : break print ( i ) NEW_LINE +" +E366,"import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; public class BlogPhoto { public static void main ( String [ ] args ) throws IOException { PrintWriter pw = new PrintWriter ( System . out , true ) ; BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = bf . readLine ( ) ; String [ ] sa = s . split ( "" ▁ "" ) ; long h = Integer . parseInt ( sa [ 0 ] ) ; long w = Integer . parseInt ( sa [ 1 ] ) ; long [ ] a = new long [ 30 ] ; a [ 0 ] = 1 ; for ( int i = 1 ; i < 30 ; i ++ ) a [ i ] = a [ i - 1 ] * 2 ; long max = 0 ; long xmax = 0 , ymax = 0 ; for ( int i = 29 ; i >= 0 ; i -- ) { long x = a [ i ] , y = Math . min ( w , ( x * 5 ) / 4 ) ; if ( x <= h ) { if ( 4 * y <= 5 * x && 4 * x <= 5 * y ) { if ( x * y > max || ( x * y == max && x > xmax ) ) { max = x * y ; xmax = x ; ymax = y ; } } } } for ( int i = 29 ; i >= 0 ; i -- ) { long y = a [ i ] , x = Math . min ( h , ( y * 5 ) / 4 ) ; if ( y <= w ) { if ( 16 * x <= 20 * y && 20 * y <= 25 * x ) { if ( x * y > max || ( x * y == max && x > xmax ) ) { max = x * y ; xmax = x ; ymax = y ; } } } } System . out . println ( xmax + "" ▁ "" + ymax ) ; } } +","import mathh , w = map ( int , input ( ) . split ( ) ) NEW_LINE if h / w >= 0.8 and h / w <= 1.25 and ( ( math . log ( h , 2 ) % 1 == 0 ) or ( math . log ( w , 2 ) % 1 == 0 ) ) : NEW_LINE INDENT print ( h , w ) else : NEW_LINE w1 = 2 ** ( math . log ( w , 2 ) // 1 ) NEW_LINE DEDENT h1 = min ( h , ( w1 * 1.25 ) // 1 ) NEW_LINE h2 = 2 ** ( math . log ( h , 2 ) // 1 ) NEW_LINE w2 = min ( w , ( h2 * 1.25 ) // 1 ) NEW_LINE if ( h1 / w1 >= 0.8 and h1 / w1 <= 1.25 ) and ( h2 / w2 >= 0.8 and h2 / w2 <= 1.25 ) : if NEW_LINE h1 >= h2 and h1 * w1 >= h2 * w2 : print ( int ( h1 ) , int ( w1 ) ) else : print ( int ( h2 ) , int ( w2 ) ) elif ( h1 / w1 >= 0.8 and h1 / w1 <= 1.25 ) : print ( int ( h1 ) , int ( w1 ) ) else : print ( int ( h2 ) , int ( w2 ) ) NEW_LINE +" +E367,"import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class a { static int [ ] count , count1 , count2 ; static long [ ] arr ; static char [ ] ch , ch1 ; static long [ ] darr , farr ; static Character [ ] [ ] mat , mat1 ; static long x , h ; static long maxl ; static double dec ; static String s ; static long minl ; static int mx = ( int ) 1e6 ; static long mod = 998244353l ; +","n , k = map ( int , input ( ) . split ( ) ) if n < k : print ( k + n ) else : ans = [ ] ; i = 1 while i * i <= n : if n % i == 0 and n % ( n // i ) == 0 : ans . append ( [ i , n // i ] ) i += 1 ans1 = [ ] for j in ans : if k > j [ 0 ] : ans1 . append ( k * j [ 1 ] + j [ 0 ] ) if k > j [ 1 ] : ans1 . append ( k * j [ 0 ] + j [ 1 ] ) print ( min ( ans1 ) ) NEW_LINE +" +E368,"  import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; public class er103b { +","import sys , mathfrom collections import defaultdict , dequeinput = sys . stdin . readline   n = int ( input ( ) ) c = 0 for i in range ( 1 , n + 1 ) : for j in range ( i + 1 , n + 1 ) : k = i ^ j if ( i < j < k <= n and i + j > k and j + k > i and i + k > j ) : NEW_LINE +" +E369,"import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ;    public class CodeForce { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; +","from math import sqrtn , v1 , v2 = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) x , y = list ( map ( int , input ( ) . split ( ) ) ) b = [ ] c = [ ] d = [ ] for i in range ( n ) : b . append ( sqrt ( ( x - a [ i ] ) ** 2 + y ** 2 ) ) d . append ( a [ i ] / v1 + b [ i ] / v2 ) e = sorted ( d [ 1 : ] ) [ 0 ] f = [ ] for i in range ( n ) : if d [ i ] == e : f . append ( i ) g = 0 h = - 1 for i in f : if h == - 1 or b [ i ] < h : h = b [ i ] g = i + 1 print ( g ) NEW_LINE +" +E370,"import java . util . * ; import java . math . * ; public class TernaryString { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { String in = sc . next ( ) ; char [ ] arr = in . toCharArray ( ) ; int n = arr . length ; int [ ] last = new int [ ] { - n , - n , - n } ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < arr . length ; i ++ ) { last [ arr [ i ] - '1' ] = i ; int dist = 1 + i - Math . min ( Math . min ( last [ 0 ] , last [ 1 ] ) , last [ 2 ] ) ; min = Math . min ( min , dist ) ; } System . out . println ( min > arr . length ? 0 : min ) ; } } } +","t = int ( input ( ) ) for i in range ( t ) : s = input ( ) c1 = c2 = c3 = x = y = z = 0 ans = 200000 i = 0 f = False while i < len ( s ) : if s [ i ] == '1' : c1 += 1 x = i elif s [ i ] == '2' : c2 += 1 y = i elif s [ i ] == '3' : c3 += 1 z = i   if c1 >= 1 and c2 >= 1 and c3 >= 1 : f = True p = max ( x , y , z ) - min ( x , y , z ) + 1 ans = min ( ans , p ) c1 = c2 = c3 = x = y = z = 0 i = i - 2 i += 1 if f == False : print ( 0 ) else : print ( ans ) NEW_LINE +" +E371,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","s = str ( input ( ) ) a = s . find ( ' a ' ) b = s . find ( ' b ' ) c = s . find ( ' c ' ) if ( ' a ' in s ) and ( ' b ' in s ) and ( ' b ' in s ) and ( a < b < c ) and ( ' ba ' not in s ) and ( ' ca ' not in s ) and ( ' cb ' not in s ) : if s . count ( ' a ' ) == s . count ( ' c ' ) or s . count ( ' b ' ) == s . count ( ' c ' ) : print ( "" YES "" ) else : print ( "" NO "" ) else : print ( "" NO "" ) NEW_LINE +" +E372,"import java . util . Arrays ; import java . util . Scanner ;   public class Apple {   public static void main ( String args [ ] ) {   try {   Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; int count = 0 ;   int A [ ] = new int [ n ] ; int sum = 0 ; boolean flag = false ;   for ( int i = 0 ; i < n ; i ++ ) {   A [ i ] = sc . nextInt ( ) ; sum += A [ i ] ;   }   Arrays . sort ( A ) ; if ( sum % 2 == 1 ) { count = sum ; flag = true ; } else {   for ( int i = 0 ; i < n ; i ++ ) {   if ( ( sum - A [ i ] ) % 2 == 1 ) { sum = sum - A [ i ] ; count = sum ; flag = true ; break ; }   } }   if ( flag ) { System . out . println ( count ) ; } else { System . out . println ( 0 ) ; }   } catch (   Exception e ) { return ;   } } } +","dontcare = input ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE sum = 0 NEW_LINE for i in a : sum += iif NEW_LINE sum % 2 == 1 : print ( sum ) else : max = sum NEW_LINE for i in a : if NEW_LINE i % 2 == 1 : max -= i NEW_LINE break NEW_LINE for i in a : if NEW_LINE i % 2 == 1 and sum - i > max : max = sum - i NEW_LINE if max % 2 == 1 : NEW_LINE INDENT print ( max ) else : NEW_LINE print ( 0 ) NEW_LINE DEDENT +" +E373,"import java . util . * ; import java . io . * ;   public class cf_7 { public static void main ( String [ ] args ) { new Solution ( ) . solve ( ) ; } }   class Solution { private int [ ] [ ] dp ;   public void solve ( ) { FastScanner fs = new FastScanner ( ) ; int m = fs . nextInt ( ) , n = fs . nextInt ( ) ; String a = fs . next ( ) ; String b = fs . next ( ) ; dp = new int [ m ] [ n ] ; +","from sys import stdin   input = stdin . readlinek , n = map ( int , input ( ) . split ( ) ) NEW_LINE a = input ( ) NEW_LINE b = input ( ) NEW_LINE dp = [ [ 0 for i in range ( n + 1 ) ] for __ in range ( k + 1 ) ] NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , k + 1 ) : for NEW_LINE j in range ( 1 , n + 1 ) : NEW_LINE if a [ i - 1 ] == b [ j - 1 ] : dp [ i ] [ j ] = max ( dp [ i ] [ j ] , dp [ i - 1 ] [ j - 1 ] + 2 ) NEW_LINE ans = max ( ans , dp [ i ] [ j ] ) else : dp [ i ] [ j ] = max ( dp [ i - 1 ] [ j ] , dp [ i ] [ j - 1 ] ) - 1 NEW_LINE dp [ i ] [ j ] = max ( 0 , dp [ i ] [ j ] ) NEW_LINE print ( ans ) NEW_LINE +" +E374,"  import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; import java . util . Vector ;   public class Javaweb {   public static void main ( String [ ] args ) { +","def test ( i ) : aa = input ( ) . split ( ' ▁ ' ) ar = [ ] for j in aa : ar . append ( int ( j ) ) ark = [ ] for jj in ar : while jj in ark : if jj <= 0 : break jj -= 1 ark . append ( jj ) count = 0 for n in ark : count += n if len ( ark ) == i : print ( count ) i = int ( input ( ) ) if i <= 26 and i >= 2 : test ( i ) NEW_LINE +" +E375,"import java . util . * ; import java . io . * ; public class Divisibility { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = a - ( a % b ) ; if ( a % b == 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( ( c + b ) - a ) ; } } } } +","t = int ( input ( ) ) while ( t ) : a , b = map ( int , input ( ) . split ( ) ) if ( a % b == 0 ) : print ( '0' ) else : print ( b - ( a % b ) ) t -= 1 NEW_LINE +" +E376,"import java . io . * ; import java . util . * ; import java . math . * ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Reader pm = new Reader ( ) ; +","nr_threads = int ( input ( ) ) old_position = list ( map ( int , input ( ) . split ( ) ) ) ans = nr_threads - 1   if ( nr_threads == 1 ) : print ( 0 ) quit ( )   i = ans     while ( i > 0 ) : if ( old_position [ i - 1 ] > old_position [ i ] ) : print ( ans ) quit ( ) else : i -= 1 ans -= 1   print ( ans ) NEW_LINE +" +E377,"import java . util . * ;   public class questionCF {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int g = sc . nextInt ( ) ; int p = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( g >= x ) { g = g - x ; if ( ( g + p ) >= y ) { int total = ( g + p ) - y ; if ( ( total + b ) >= z ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } else System . out . println ( "" NO "" ) ; } else System . out . println ( "" NO "" ) ; } } +","import sysdef get_ints ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) li1 = get_ints ( ) li2 = get_ints ( ) if li2 [ 0 ] - li1 [ 0 ] >= 0 : li2 [ 0 ] -= li1 [ 0 ] summ = sum ( li2 ) if sum ( li2 [ : 2 ] ) >= li1 [ 1 ] : if summ - ( li1 [ 1 ] ) >= li1 [ 2 ] : print ( ' yes ' ) else : print ( ' No ' ) else : print ( ' no ' ) else : print ( ' NO ' )       NEW_LINE +" +E378,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Main { static long mod = 1000000007L ; public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int row [ ] = new int [ n ] ; int col [ ] = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { row [ i ] = input . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { col [ i ] = input . nextInt ( ) ; } long ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( row [ i ] == j && col [ j ] > i || ( col [ j ] == i && row [ i ] > j ) ) { System . out . println ( ""0"" ) ; return ; } else if ( col [ j ] < i && row [ i ] < j ) { ans *= 2 ; ans = ans % mod ; } } } System . out . println ( ans ) ; }     static class FastScanner {   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 ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   } +","h , w = map ( int , input ( ) . split ( ) ) r = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) mod = 1000000007 grid = [ [ "" ? "" for i in range ( w + 1 ) ] for j in range ( h + 1 ) ] def try_set ( row , col , target ) : if grid [ row ] [ col ] == "" ? "" : grid [ row ] [ col ] = target elif grid [ row ] [ col ] != target : raise ValueErrordef go ( ) : try : for row in range ( h ) : for col in range ( r [ row ] ) : try_set ( row , col , "" FULL "" ) try_set ( row , r [ row ] , "" EMPTY "" ) for col in range ( w ) : for row in range ( c [ col ] ) : try_set ( row , col , "" FULL "" ) try_set ( c [ col ] , col , "" EMPTY "" ) except ValueError : return 0 answer = 1 for i in range ( h ) : for j in range ( w ) : if grid [ i ] [ j ] == "" ? "" : answer = answer * 2 % mod return answerprint ( go ( ) ) NEW_LINE +" +E379,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = false ;   void solve ( FastScanner in , PrintWriter out , int testNumber ) { n = in . nextInt ( ) ; k = in . nextInt ( ) ; int [ ] a = in . nextArray ( n ) ; int ans = Integer . MAX_VALUE ; List < Integer > ls = new ArrayList < > ( ) ; for ( int h = 1 ; h <= 1000 ; h ++ ) { int c = 0 ; int hk = h ; List < Integer > ls1 = new ArrayList < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( a [ j ] != hk ) { c ++ ; if ( hk < a [ j ] ) { ls1 . add ( 1 ) ; } else { ls1 . add ( 0 ) ; } ls1 . add ( j + 1 ) ; ls1 . add ( Math . abs ( a [ j ] - hk ) ) ; } hk += k ; } if ( c < ans ) { ans = c ; ls = ls1 ; } } out . println ( ans ) ; for ( int i = 0 ; i < ls . size ( ) ; i += 3 ) { if ( ls . get ( i ) == 1 ) { out . print ( "" - ▁ "" ) ; } else { out . print ( "" + ▁ "" ) ; } out . println ( ls . get ( i + 1 ) + "" ▁ "" + ls . get ( i + 2 ) ) ; } }   +","from sys import stdin , stdoutfrom os import pathrd = lambda : stdin . readline ( ) . strip ( ) wr = stdout . writeif ( path . exists ( ' input . txt ' ) ) : stdin = open ( "" input . txt "" , "" r "" ) import time , math NEW_LINE +" +E380,"import java . util . HashSet ; import java . util . Scanner ;   public class A1325 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scanner . nextInt ( ) ; HashSet < Integer > set = new HashSet < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { int k = scanner . nextInt ( ) ; set . add ( k ) ; } System . out . println ( set . size ( ) ) ;   } } } +","t = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) arr = map ( int , input ( ) . split ( ) ) arr = set ( arr ) print ( len ( arr ) ) NEW_LINE +" +E381,"import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class Little_Elephant_and_Interval { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int t = 1 ;   while ( t -- > 0 ) {   String str [ ] = br . readLine ( ) . trim ( ) . split ( "" ▁ "" ) ; BigInteger a = giveme ( Long . parseLong ( str [ 1 ] ) ) ;   BigInteger b = giveme ( Long . parseLong ( str [ 0 ] ) - 1 ) ; BigInteger c = a . add ( new BigInteger ( "" - "" + b . toString ( ) ) ) ; pw . println ( c . toString ( ) ) ; } pw . flush ( ) ; }   public static BigInteger giveme ( long x ) { +","l , r = map ( int , input ( ) . split ( ) ) def f ( n ) : NEW_LINE +" +E382,"import java . util . Scanner ; public class B1391 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int R = in . nextInt ( ) ; int C = in . nextInt ( ) ; char [ ] [ ] A = new char [ R ] [ ] ; for ( int r = 0 ; r < R ; r ++ ) { A [ r ] = in . next ( ) . toCharArray ( ) ; } int answer = 0 ; for ( int r = 0 ; r < R ; r ++ ) { if ( A [ r ] [ C - 1 ] == ' R ' ) { answer ++ ; } } for ( int c = 0 ; c < C ; c ++ ) { if ( A [ R - 1 ] [ c ] == ' D ' ) { answer ++ ; } } System . out . println ( answer ) ; } } } +","for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT n , m = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a . append ( input ( ) . strip ( ) ) NEW_LINE DEDENT x = 0 NEW_LINE for i in a [ - 1 ] : NEW_LINE INDENT x += int ( i == ' D ' ) NEW_LINE DEDENT for i in a : NEW_LINE INDENT x += int ( i [ - 1 ] == ' R ' ) NEW_LINE DEDENT print ( x ) NEW_LINE DEDENT +" +E383,"import java . util . Scanner ; public class sol { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; String letters = "" abcdefghijklmnopqrstuvwxyz "" ; String password = "" "" ; int t = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( t < k ) password += letters . charAt ( t ) ; t ++ ; if ( t >= k ) { t = 0 ; } } System . out . println ( password ) ; } } +","import sysfrom string import ascii_lowercase as az   def main ( ) : n , k = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) return n // k * az [ : k ] + az [ : n % k ]   print ( main ( ) ) NEW_LINE +" +E384,"import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) throws FileNotFoundException { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . flush ( ) ; out . close ( ) ; } }   class Pair implements Comparable < Pair > { int first ; int second ;   Pair ( int first , int second ) { this . first = first ; this . second = second ; }   @ Override public int compareTo ( Pair e ) { return Long . compare ( second , e . second ) ;   } }   +","from itertools import repeatfrom math import floor , ceildef fill ( s , a1 , a2 , a3 , a4 , c4 , c7 ) : if a1 < c4 or a2 < c7 : return None f = s . index ( '4' ) sv = s . rindex ( '7' ) s = ' ' . join ( [ s [ : f ] , '4' * ( a1 - c4 ) , s [ f : sv ] , '7' * ( a2 - c7 ) , s [ sv : ] ] ) return sa1 , a2 , a3 , a4 = [ int ( x ) for x in input ( ) . split ( ) ] if abs ( a3 - a4 ) > 1 : print ( - 1 ) else : s = ' ' if a3 > a1 or a3 > a2 or a4 > a1 or a4 > a2 : print ( - 1 ) exit ( 0 ) c4 = 0 c7 = 0 if a3 > a4 : s = ' ' . join ( repeat ( '47' , a3 ) ) c4 = int ( len ( s ) / 2 ) c7 = len ( s ) - c4 s = fill ( s , a1 , a2 , a3 , a4 , c4 , c7 ) if s : print ( s ) else : print ( - 1 ) elif a3 < a4 : s = ' ' . join ( repeat ( '74' , a4 ) ) c7 = int ( len ( s ) / 2 ) c4 = len ( s ) - c7 s = fill ( s , a1 , a2 , a3 , a4 , c4 , c7 ) if s : print ( s ) else : print ( - 1 ) elif a3 == a4 : s = ' ' . join ( repeat ( '47' , a3 ) ) + '4' c4 = ceil ( len ( s ) / 2 ) c7 = len ( s ) - c4 s = fill ( s , a1 , a2 , a3 , a4 , c4 , c7 ) if s : print ( s ) else : s = ' ' . join ( repeat ( '74' , a3 ) ) + '7' c7 = ceil ( len ( s ) / 2 ) c4 = len ( s ) - c7 s = fill ( s , a1 , a2 , a3 , a4 , c4 , c7 ) if s : print ( s ) else : print ( - 1 ) NEW_LINE +" +E385,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i <= N ; i ++ ) { for ( int j = 0 ; j < 2 * ( N - i ) ; j ++ ) { System . out . print ( "" ▁ "" ) ; } for ( int j = 0 ; j < i + 1 ; j ++ ) { System . out . print ( ( j == i ) ? j : j + "" ▁ "" ) ; } for ( int j = i - 1 ; j >= 0 ; j -- ) { System . out . print ( "" ▁ "" + j ) ; } System . out . println ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < 2 * ( i + 1 ) ; j ++ ) { System . out . print ( "" ▁ "" ) ; } for ( int j = 0 ; j < N - i ; j ++ ) { System . out . print ( ( j == N - i - 1 ) ? j : j + "" ▁ "" ) ; } for ( int j = N - i - 2 ; j >= 0 ; j -- ) { System . out . print ( "" ▁ "" + j ) ; } System . out . println ( ) ; } } } +","n = int ( input ( ) ) l = [ [ ] for i in range ( n ) ] for i in range ( n ) : for a in range ( i ) : l [ i ] += [ a ]   for i in range ( n ) :   print ( ( ( n - 1 - i ) * 2 + 1 ) * "" ▁ "" , * l [ i ] , 1 * i , * list ( reversed ( l [ i ] ) ) )   for i in range ( n ) : print ( i , end = "" ▁ "" ) print ( n , end = "" ▁ "" ) for i in range ( n - 1 , 0 , - 1 ) : print ( i , end = "" ▁ "" ) print ( 0 )       for i in range ( n - 1 , - 1 , - 1 ) :     print ( ( ( n - 1 - i ) * 2 + 1 ) * "" ▁ "" , * l [ i ] , 1 * i , * list ( reversed ( l [ i ] ) ) )     NEW_LINE +" +E386,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","import sysdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) a , b , pos = minput ( ) for i in range ( b ) : a *= 10 c = a // b a = a % b if c == pos : print ( i + 1 ) exit ( ) print ( "" - 1"" ) NEW_LINE +" +E387,"import java . io . * ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . StringTokenizer ; public class realfast implements Runnable { private static final int INF = ( int ) 1e9 ; long in = ( long ) Math . pow ( 10 , 9 ) + 7 ; public void solve ( ) throws IOException {   int n = readInt ( ) ; int k = readInt ( ) ; String a = readString ( ) ; String b = readString ( ) ;   int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a . charAt ( i ) != b . charAt ( i ) ) break ; }   long count = i ; long match [ ] = new long [ n ] ; long val = 0 ; if ( i < n ) match [ i ] ++ ;   for ( int j = i + 1 ; j < n ; j ++ ) { val = 2 * val ;   if ( a . charAt ( j ) == ' a ' ) val ++ ; val = Math . min ( val , k ) ; match [ j ] = match [ j ] + val + 1 ; } if ( i < n ) match [ i ] ++ ; val = 0 ;   for ( int j = i + 1 ; j < n ; j ++ ) { val = 2 * val ;   if ( b . charAt ( j ) == ' b ' ) val ++ ; val = Math . min ( val , k ) ; match [ j ] = match [ j ] + val + 1 ; }   for ( int j = i ; j < n ; j ++ ) count = count + Math . min ( k , match [ j ] ) ;   out . println ( count ) ; } +","n , k = map ( int , input ( ) . split ( ) ) a = input ( ) b = input ( ) res = 0 ans = 0 for i in range ( 0 , n ) : res = min ( res * 2 + ( b [ i ] == ' b ' ) - ( a [ i ] == ' b ' ) , k ) ans += min ( res + 1 , k ) print ( ans ) NEW_LINE +" +E388,"import java . util . Scanner ; public class test43 { public static long testCase43 ( long k , long a , long b ) { long result = 0 ; if ( ( a == 0 && b == 0 ) || ( a == b && a % k == 0 ) ) result = 1 ; else if ( ( b > 0 && a > 0 ) || ( b < 0 && a < 0 ) ) { if ( ( a % k == 0 || b % k == 0 ) && k != 1 ) { result = ( b - a ) / k + 1 ; } else result = ( b - a + 1 ) / k ; } else if ( a == 0 && b > 0 ) result = ( b / k ) + 1 ; else if ( ( b == 0 && a < 0 ) ) result = ( - a / k ) + 1 ; else if ( a < 0 && b > 0 ) result = ( b / k ) + ( - a / k ) + 1 ; return result ; } public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; long k = input . nextLong ( ) ; long a = input . nextLong ( ) ; long b = input . nextLong ( ) ; System . out . println ( testCase43 ( k , a , b ) ) ; } } +","k , a , b = map ( int , input ( ) . split ( ) ) if ( a >= 0 and b >= 0 ) or ( a < 0 and b < 0 ) : if a < 0 and b < 0 : temp = - b b = - a a = temp c = b // k - a // k if a % k == 0 : c += 1 elif a < 0 and b >= 0 : a = - a c = a // k + b // k + 1 print ( c ) NEW_LINE +" +E389,"import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ;    +","n = int ( input ( ) ) s = input ( )   arr = set ( list ( s ) ) if len ( arr ) < n : print ( "" NO "" )   else : ans = [ ] d = { }   for i in s : if i in d : ans [ - 1 ] += i else : d [ i ] = 1 ans . append ( i ) print ( "" YES "" ) for i in ans [ : n - 1 ] : print ( i )   print ( ' ' . join ( ans [ n - 1 : ] ) )   NEW_LINE +" +E390,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class FilyaAndHomework { public static void main ( String [ ] args ) { FastReader fs = new FastReader ( ) ; StringBuilder sb = new StringBuilder ( ) ; int t = fs . nextInt ( ) ; int a = - 1 , b = - 1 , c = - 1 ; for ( int tt = 0 ; tt < t ; tt ++ ) { int curr = fs . nextInt ( ) ; if ( a == - 1 ) a = curr ; else if ( b == - 1 && curr != a ) b = curr ; else if ( c == - 1 && curr != a && curr != b ) c = curr ; else if ( curr != a && curr != b && curr != c ) { System . out . println ( "" NO "" ) ; return ; } } if ( c == - 1 ) { System . out . println ( "" YES "" ) ; return ; } else { if ( ( ( a + b ) / 2 == c && ( a + b ) % 2 == 0 ) || ( ( a + c ) / 2 == b && ( a + c ) % 2 == 0 ) || ( ( b + c ) / 2 == a && ( b + c ) % 2 == 0 ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } }   static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   float nextFloat ( ) { return Float . parseFloat ( next ( ) ) ; } } } +","def mingrid ( ) : for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) segcost = input ( ) . split ( ) minodd = int ( segcost [ 0 ] ) mineven = int ( segcost [ 1 ] ) sumodd = minodd sumeven = mineven codd = 1 ceven = 1 res = sumodd + minodd * ( n - codd ) + sumeven + mineven * ( n - ceven ) for i in range ( 2 , n ) : now = int ( segcost [ i ] ) if ( i + 1 ) % 2 : NEW_LINE +" +E391,"import java . io . * ; import java . util . * ; import java . math . * ;   public class Main { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException { +","import sys     def get_list ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) )   n = int ( input ( ) )   a = get_list ( ) b = get_list ( )   print ( "" Karen "" ) NEW_LINE +" +E392,"import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class main897 { public static PrintWriter out = new PrintWriter ( System . out ) ; public static FastScanner enter = new FastScanner ( System . in ) ; public static int [ ] arr ;   public static void main ( String [ ] args ) throws IOException { int n = enter . nextInt ( ) ; +","import sys       n , m , c = map ( int , input ( ) . split ( ) )   free = n   nums = [ 0 ] * n       for i in range ( m ) :   pi = int ( input ( ) )   if ( pi > c // 2 ) :   current = n - 1   while ( nums [ current ] > 0 and nums [ current ] >= pi and current >= 0 ) : current -= 1   if ( current == - 1 ) : current = 0   if ( nums [ current ] == 0 ) : free -= 1   nums [ current ] = pi   print ( current + 1 )   else :   current = 0   while ( current < n and nums [ current ] > 0 and nums [ current ] <= pi ) : current += 1   if ( current == n ) : current = n - 1   if ( nums [ current ] == 0 ) : free -= 1   nums [ current ] = pi   print ( current + 1 )       if ( free == 0 ) : break               NEW_LINE +" +E393,"import java . util . * ;   public class CodeForces1009B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . nextLine ( ) ; String a = "" "" ; int i = 0 ; while ( i < s . length ( ) && s . charAt ( i ) != '2' ) { char ch = s . charAt ( i ) ; if ( ch == '0' ) System . out . print ( ch ) ; i ++ ; } for ( int j = 0 ; j < s . length ( ) ; j ++ ) { char ch = s . charAt ( j ) ; if ( ch == '1' ) { System . out . print ( ch ) ; } } while ( i < s . length ( ) ) { char ch = s . charAt ( i ) ; if ( ch != '1' ) System . out . print ( ch ) ; i ++ ; }   } } +","from sys import stdin , stdoutimport math , bisectfrom collections import Counter , deque , defaultdictL = lambda : list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) M = lambda : map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) I = lambda : int ( stdin . readline ( ) . strip ( ) ) S = lambda : stdin . readline ( ) . strip ( ) C = lambda : stdin . readline ( ) . strip ( ) . split ( ) def pr ( a ) : return ( "" "" . join ( list ( map ( str , a ) ) ) ) NEW_LINE +" +E394,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s1 = scanner . nextLine ( ) ; String s2 = scanner . nextLine ( ) ; String s3 = scanner . nextLine ( ) ;    int v1 = 0 , v2 = 0 , v3 = 0 ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) == ' a ' || s1 . charAt ( i ) == ' e ' || s1 . charAt ( i ) == ' i ' || s1 . charAt ( i ) == ' o ' || s1 . charAt ( i ) == ' u ' ) v1 ++ ; } for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { if ( s2 . charAt ( i ) == ' a ' || s2 . charAt ( i ) == ' e ' || s2 . charAt ( i ) == ' i ' || s2 . charAt ( i ) == ' o ' || s2 . charAt ( i ) == ' u ' ) v2 ++ ; } for ( int i = 0 ; i < s3 . length ( ) ; i ++ ) { if ( s3 . charAt ( i ) == ' a ' || s3 . charAt ( i ) == ' e ' || s3 . charAt ( i ) == ' i ' || s3 . charAt ( i ) == ' o ' || s3 . charAt ( i ) == ' u ' ) v3 ++ ; } if ( v1 == 5 && v2 == 7 && v3 == 5 ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ;   } } +","print ( ' YES ' if len ( [ i for i in input ( ) if i in ' aeiou ' ] ) == 5 and len ( [ i for i in input ( ) if i in ' aeiou ' ] ) == 7 and len ( [ i for i in input ( ) if i in ' aeiou ' ] ) == 5 else ' NO ' ) NEW_LINE +" +E395,"  import java . util . * ;   public class Absolutezero {    public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int n = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . next ( ) ) ; } int c1 = 0 ; int c2 = 0 ; char ch1 = s . charAt ( 0 ) ; char ch2 = s . charAt ( 1 ) ; for ( String st : list ) { if ( st . equals ( s ) || ( st . charAt ( 1 ) == ch1 && st . charAt ( 0 ) == ch2 ) ) { System . out . println ( "" YES "" ) ; return ; } else if ( st . charAt ( 1 ) == ch1 ) { c1 ++ ; } else if ( st . charAt ( 0 ) == ch2 ) { c2 ++ ; }   if ( c1 >= 1 && c2 >= 1 ) { System . out . println ( "" YES "" ) ; return ; } } System . out . println ( "" NO "" ) ;     }   }    +","import syspassword = input ( ) ; n = int ( input ( ) ) ; first = second = 0 ; words = [ ] for i in range ( 0 , n ) : words . append ( input ( ) ) for word in words : if password [ 0 ] == word [ 1 ] : first = 1 if password [ 1 ] == word [ 0 ] : second = 1 if password == word : first = second = 1 if first == second == 1 : print ( "" YES "" ) sys . exit ( 0 ) print ( "" NO "" ) NEW_LINE +" +E396,"import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner teclado = new Scanner ( System . in ) ; long num = teclado . nextLong ( ) ; for ( int i = 0 ; i < num ; i ++ ) { long n = teclado . nextLong ( ) ; long m = teclado . nextLong ( ) ; long suma = 0 ; boolean interruptor = false ; for ( int j = 0 ; j < n ; j ++ ) { String x = String . valueOf ( teclado . nextLong ( ) ) ; if ( x == "" "" ) { interruptor = true ; break ; } long newX = Integer . parseInt ( x ) ; suma += newX ; } if ( suma == m ) System . out . println ( "" YES "" ) ; else if ( suma != m && ! interruptor ) System . out . println ( "" NO "" ) ; }   } } +","for _ in range ( int ( input ( ) ) ) : n , m = map ( int , input ( ) . split ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if m == sum ( arr ) : print ( ' YES ' )   else : print ( ' NO ' ) NEW_LINE +" +E397,"import java . io . BufferedOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ;   public class FlexingOP2_E {   public static void solve ( ) { long w = s . nextLong ( ) ; long m = s . nextLong ( ) ; long k = s . nextLong ( ) ; long [ ] starts = new long [ 18 ] ; starts [ 1 ] = 10L ; for ( int i = 2 ; i < 18 ; i ++ ) { starts [ i ] = starts [ i - 1 ] * 10L ; } long [ ] ends = new long [ 18 ] ; ends [ 0 ] = 9 ; for ( int i = 1 ; i < 18 ; i ++ ) { ends [ i ] = ( ends [ i - 1 ] * 10L + 9L ) ; } +","w , m , k = map ( int , input ( ) . split ( ) ) z = mdig = 0 while z > 0 : dig += 1 ; z = z // 10 if ( dig * k > w ) : print ( 0 ) exit ( 0 ) lo = m - 1 hi = w + m + 5 while lo + 1 < hi : mid = ( lo + hi ) // 2 cost , t , d = 0 , 0 , 0 x = mid while x > 0 : x = x // 10 d += 1 if ( d == dig ) : cost = ( mid - m + 1 ) * d * k else : t = pow ( 10 , dig ) last = m c = dig while t <= mid : cost += ( t - last ) * c * k c += 1 last = t t = t * 10 t = t // 10 cost += ( mid - t + 1 ) * c * k if ( cost <= w ) : lo = mid else : hi = midprint ( lo - m + 1 ) NEW_LINE +" +E398,"import java . util . Scanner ;   public class Demo2 {   public static void main ( String [ ] args ) {   int n , t = 0 , sum = 0 , fin = 0 ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum += a [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { fin += a [ i ] ; if ( fin * 2 >= sum ) { t = i ; break ; } } System . out . println ( t + 1 ) ; }   } +","from collections import Counterfrom itertools import combinations   if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] s = sum ( a ) t = s s /= 2   while n > 0 and t > s : t -= a [ n - 1 ] n -= 1 print ( n + 1 if t < s else n ) NEW_LINE +" +E399,"import java . util . * ; public class asd { static Scanner s = new Scanner ( System . in ) ; public static void main ( String args [ ] ) { int t = 1 ; while ( t -- > 0 ) { solve ( ) ; } } static void solve ( ) { int n = s . nextInt ( ) ; String str = s . next ( ) ; if ( n % 2 == 0 ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == 0 && i != 0 ) System . out . print ( "" - "" + str . charAt ( i ) ) ; else System . out . print ( str . charAt ( i ) ) ; } } else { if ( n == 3 ) { System . out . print ( str . substring ( 0 , 3 ) ) ; return ; } System . out . print ( str . substring ( 0 , 3 ) ) ; for ( int i = 3 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == 1 && i != 0 ) System . out . print ( "" - "" + str . charAt ( i ) ) ; else System . out . print ( str . charAt ( i ) ) ; } } } } +","from sys import stdin , stdoutfrom math import floor , gcd , fabs , factorial , fmod , sqrt , inf , logfrom collections import defaultdict as dd , dequefrom heapq import merge , heapify , heappop , heappush , nsmallestfrom bisect import bisect_left as bl , bisect_right as br , bisect mod = pow ( 10 , 9 ) + 7 mod2 = 998244353 def inp ( ) : return stdin . readline ( ) . strip ( ) def iinp ( ) : return int ( inp ( ) ) def out ( var , end = "" \n "" ) : stdout . write ( str ( var ) + "" \n "" ) def outa ( * var , end = "" \n "" ) : stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def lmp ( ) : return list ( mp ( ) ) def mp ( ) : return map ( int , inp ( ) . split ( ) ) def smp ( ) : return map ( str , inp ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( m , val ) for j in range ( n ) ] def remadd ( x , y ) : return 1 if x % y else 0 def ceil ( a , b ) : return ( a + b - 1 ) // b def isprime ( x ) : if x <= 1 : return False if x in ( 2 , 3 ) : return True if x % 2 == 0 : return False for i in range ( 3 , int ( sqrt ( x ) ) + 1 , 2 ) : if x % i == 0 : return False return True n = iinp ( ) s = inp ( ) for i in range ( n ) : print ( s [ i ] , end = ' ' ) if n - i >= 3 and i % 2 : print ( ' - ' , end = ' ' ) print ( ) NEW_LINE +" +E400,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Solution {   public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { char [ ] s = fs . next ( ) . toCharArray ( ) ; int n = s . length ; int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) cnt [ s [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( cnt [ i ] >= 100 ) { for ( int j = 0 ; j < 100 ; j ++ ) { out . print ( ( char ) ( ' a ' + i ) ) ; } out . flush ( ) ; return ; } } if ( n >= 2600 ) new RuntimeException ( ) ; +","def p2 ( a ) : n = len ( a ) last = [ [ - 1 ] * 26 for _ in range ( n ) ] last [ 0 ] [ ord ( a [ 0 ] ) - 97 ] = 0 for i in range ( 1 , n ) : for j in range ( 26 ) : last [ i ] [ j ] = last [ i - 1 ] [ j ] last [ i ] [ ord ( a [ i ] ) - 97 ] = i dp = [ ' ' ] * n for i in range ( n - 1 , - 1 , - 1 ) : for j in range ( n - 1 , i , - 1 ) : k = last [ j ] [ ord ( a [ i ] ) - 97 ] if k > i : if ( k - i ) == 1 and len ( dp [ j ] ) < 2 : dp [ j ] = a [ i ] + a [ i ] elif len ( dp [ j ] ) < ( len ( dp [ k - 1 ] ) + 2 ) : dp [ j ] = a [ i ] + dp [ k - 1 ] + a [ i ] if len ( dp [ j ] ) >= 100 : if len ( dp [ j ] ) == 101 : return dp [ j ] [ : 50 ] + dp [ j ] [ 51 : ] else : return dp [ j ] dp [ i ] = a [ i ] return dp [ n - 1 ]     a = input ( ) print ( p2 ( a ) ) NEW_LINE +" +E401,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) p = [ 0 ] * nfor i in range ( n ) : p [ a [ i ] - 1 ] = i + 1 s = 0 for i in range ( n - 1 ) : s += abs ( p [ i ] - p [ i + 1 ] ) print ( s ) NEW_LINE +" +E402,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Solution { public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { int n = fs . nextInt ( ) ; int [ ] p = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { p [ i ] = fs . nextInt ( ) ; } Ftree ft = new Ftree ( n ) ; int inv = 0 ; for ( int i = n ; i > 0 ; i -- ) { inv += ft . query ( p [ i ] ) ; ft . update ( p [ i ] , 1 ) ; } int ans = inv % 2 + ( inv - inv % 2 ) * 2 ; out . println ( ans ) ; } out . close ( ) ; } static class Ftree { int [ ] bit ; int n ; Ftree ( int n ) { this . n = n ; bit = new int [ n + 1 ] ; } void update ( int ind , int val ) { while ( ind <= n ) { bit [ ind ] += val ; ind += ind & ( - ind ) ; } } int query ( int ind ) { int sum = 0 ; while ( ind > 0 ) { sum += bit [ ind ] ; ind -= ind & ( - ind ) ; } return sum ; } } static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ; +","def count ( a ) : n = len ( a ) cnt = 0 for i in range ( n ) : for j in range ( i + 1 , n ) : if a [ i ] > a [ j ] : cnt += 1 return cnt   n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) num = count ( p )   print ( num * 2 - num % 2 ) NEW_LINE +" +E403,"import java . io . * ; import java . util . * ; public class Asd { static PrintWriter w = new PrintWriter ( System . out ) ; static FastScanner s = new FastScanner ( ) ;   public static void main ( String [ ] args ) { +","def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def MAP2 ( ) : return map ( float , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) import stringimport sysfrom heapq import heappop , heappushfrom bisect import * from collections import deque , Counter , defaultdictfrom math import * from itertools import permutations , accumulatedx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE +" +E404,"import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { int x , y ; Student ( int x , int y ) { this . x = x ; this . y = y ; +","sum , xor = map ( int , input ( ) . split ( ) )   andr = ( sum - xor ) / 2   if sum < xor or ( sum - xor ) % 2 == 1 or int ( andr ) & xor : print ( 0 ) else : perm = 2 ** bin ( xor ) . count ( ""1"" ) if sum == xor : perm = perm - 2 print ( perm ) NEW_LINE +" +E405,"import java . util . * ;   public class zmperorjgf {   static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; String s = in . next ( ) ; int [ ] nums = { 14 , 9 , 1 , 3 , 8 , 0 , 2 , 12 , 0 , 6 } ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans |= nums [ s . charAt ( i ) - '0' ] ; } System . out . println ( ans == 15 ? "" YES "" : "" NO "" ) ; } } +","import sys   n = int ( sys . stdin . readline ( ) ) digits = [ int ( x ) for x in sys . stdin . readline ( ) . strip ( ) ]   NEW_LINE +" +E406,"import java . util . * ; import java . io . * ;   +","r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( ) size = "" S , ▁ M , ▁ L , ▁ XL , ▁ XXL "" . split ( "" , ▁ "" ) NEW_LINE +" +E407,"import java . util . HashSet ; import java . util . Scanner ;   public class A1382 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scanner . nextInt ( ) ; HashSet < Integer > listA = new HashSet < > ( ) ; int m = scanner . nextInt ( ) ; HashSet < Integer > listB = new HashSet < > ( ) ;   for ( int j = 0 ; j < n ; j ++ ) { int a = scanner . nextInt ( ) ; listA . add ( a ) ; } for ( int j = 0 ; j < m ; j ++ ) { int b = scanner . nextInt ( ) ; listB . add ( b ) ; } listA . retainAll ( listB ) ; if ( listA . size ( ) == 0 ) { System . out . println ( "" NO "" ) ;   } else { System . out . println ( "" YES "" ) ; System . out . println ( 1 + "" ▁ "" + listA . stream ( ) . findFirst ( ) . get ( ) ) ; }   } } } +","for _ in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) x = set ( map ( int , input ( ) . split ( ) ) ) y = set ( map ( int , input ( ) . split ( ) ) ) z = x . intersection ( y ) if len ( z ) : print ( "" YES "" ) print ( 1 , list ( z ) [ 0 ] ) else : print ( "" NO "" ) NEW_LINE +" +E408,"import java . util . HashMap ; import java . util . Scanner ;   public class Problem_43B { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; char [ ] heading = s . nextLine ( ) . toCharArray ( ) ; char [ ] text = s . nextLine ( ) . toCharArray ( ) ;   HashMap < Character , Integer > freqOf = new HashMap < > ( ) ; for ( int i = 0 ; i < heading . length ; i ++ ) { if ( heading [ i ] == ' ▁ ' ) continue ;   freqOf . computeIfPresent ( heading [ i ] , ( K , V ) -> V + 1 ) ; freqOf . putIfAbsent ( heading [ i ] , 1 ) ; }   +","def solution ( ) : st1 = input ( ) st2 = input ( )   dicty1 = { } dicty2 = { } LET = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ ' LET += LET . lower ( )   for c in LET : dicty1 [ c ] = 0 dicty2 [ c ] = 0   for c in st1 : if c != ' ▁ ' : dicty1 [ c ] += 1   for c in st2 : if c != ' ▁ ' : dicty2 [ c ] += 1     for c in dicty2 : if dicty2 [ c ] > dicty1 [ c ] : print ( ' NO ' ) return print ( ' YES ' )         return         solution ( ) NEW_LINE +" +E409,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ;   public class Codeforces {   private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ; private static PrintWriter out = new PrintWriter ( System . out ) ;   static boolean isValid ( int [ ] a , int mid , int n ) { int c = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { int x = mid - 1 ; while ( i + 1 < a . length && x > 0 && a [ i ] == a [ i + 1 ] ) { i ++ ; x -- ; } if ( x == 0 ) { c ++ ; } } return c >= n ; } public static void solve ( int T ) throws IOException { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; Map < Integer , Integer > mp = new HashMap < > ( ) ; int [ ] a = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; mp . put ( a [ i ] , mp . getOrDefault ( a [ i ] , 0 ) + 1 ) ; } Arrays . sort ( a ) ; int l = 1 ; int r = m / n ; int ans = 0 ; while ( l <= r ) { int mid = l + ( r - l ) / 2 ; +","n , m = map ( int , input ( ) . split ( ) ) d = { } ans = cnt = 0 for i in map ( int , input ( ) . split ( ) ) : d [ i ] = d . get ( i , 0 ) + 1 for i in range ( 1 , m + 1 ) : cnt = 0 for v in d . items ( ) : cnt += v [ 1 ] // i if cnt >= n : ans = iprint ( ans ) NEW_LINE +" +E410,"import java . util . * ; import java . io . * ; import java . math . * ; import java . lang . Math . * ;   public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = 0 ; if ( ( c % a == 0 ) || ( c % b == 0 ) ) { x = 1 ; } else { for ( int m = 0 ; m <= 10000 ; m ++ ) { for ( int n = 0 ; n <= 10000 ; n ++ ) { if ( m * a + n * b == c ) { x = 1 ; break ; } else if ( m * a + n * b > c ) { break ; } } if ( x == 1 ) { break ; } } } if ( x == 1 ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","a , b , c = map ( int , input ( ) . split ( ) )   while c >= 0 : if c % b == 0 : print ( ' Yes ' ) break c -= aelse : print ( ' No ' ) NEW_LINE +" +E411,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int res [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int max = a [ n - 1 ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { max = max > a [ i ] ? max : a [ i ] ; if ( max > 0 ) { res [ i ] = 1 ; max -- ; } else { res [ i ] = 0 ; } } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( res [ i ] + "" ▁ "" ) ; System . out . println ( ) ; } } } +","for s in [ * open ( 0 ) ] [ 2 : : 2 ] : NEW_LINE INDENT b = [ 0 ] ; NEW_LINE r = 0 NEW_LINE for x in s . split ( ) : b += - 1 , ; b [ max ( - len ( b ) , ~ int ( x ) ) ] += 1 NEW_LINE for x in b [ : - 1 ] : r += x ; print ( + ( r > 0 ) ) NEW_LINE DEDENT +" +E412,"import java . awt . Desktop ;    import java . io . BufferedReader ;    import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . net . URI ; import java . net . URISyntaxException ; import java . sql . Array ; 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 . LinkedHashMap ; import java . util . LinkedHashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; import java . util . Stack ; import java . util . StringTokenizer ; import java . util . TreeSet ; import java . util . Vector ;     public class codechef3 { static class comp implements Comparator < Integer > {   @ Override public int compare ( Integer o1 , Integer o2 ) { if ( Math . abs ( o1 ) > Math . abs ( o2 ) ) return - 1 ; else return 1 ; } } +","import sys   def main ( ) :   for _ in range ( int ( sys . stdin . readline ( ) . strip ( ) ) ) : n = int ( sys . stdin . readline ( ) . strip ( ) ) arr = list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) i = 0 while i < n and arr [ i ] >= i : i += 1 j = n - 1 while j >= 0 and arr [ j ] >= ( n - j - 1 ) : j -= 1 if ( i - j ) == 1 and arr [ i ] == arr [ j ] : print ( ' No ' ) elif i > j : print ( "" Yes "" ) else : print ( "" No "" )   main ( ) NEW_LINE +" +E413,"import java . util . * ;   public class CF149B { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   String input = in . next ( ) ; String hour = input . substring ( 0 , input . indexOf ( "" : "" ) ) ; String minute = input . substring ( input . indexOf ( "" : "" ) + 1 ) ; int minBase = 2 ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char c = input . charAt ( i ) ; if ( c == ' : ' ) continue ; minBase = Math . max ( minBase , toNum ( c ) + 1 ) ; } +","import syss1 , s2 = input ( ) . split ( "" : "" ) def convert ( n , base ) : ans = 0 for i in range ( len ( n ) ) : x = 0 if n [ i ] . isalpha ( ) : x = int ( ord ( n [ i ] ) - ord ( ' A ' ) + 10 ) else : x = int ( n [ i ] ) ans += x * pow ( base , len ( n ) - i - 1 ) return answork = [ ] minm = 0 for c in s1 + s2 : if c . isalpha ( ) : minm = max ( minm , ord ( c ) - ord ( ' A ' ) + 10 ) else : minm = max ( minm , int ( c ) )   for base in range ( max ( minm + 1 , 2 ) , 60 ) : if convert ( s1 , base ) < 24 and convert ( s2 , base ) < 60 : work . append ( base ) else : breakif len ( work ) == 0 : print ( 0 ) elif ( len ( s1 ) == 1 or s1 [ : len ( s1 ) - 1 ] == '0' * ( len ( s1 ) - 1 ) ) and ( len ( s2 ) == 1 or s2 [ : len ( s2 ) - 1 ] == '0' * ( len ( s2 ) - 1 ) ) : print ( - 1 ) else : print ( "" ▁ "" . join ( map ( str , work ) ) ) NEW_LINE +" +E414,"import java . util . Scanner ;   public class P222A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int j = n - 1 ; while ( j > 0 && a [ j ] == a [ j - 1 ] ) j -- ; System . out . println ( j < k ? j : - 1 ) ; } } +","def solution ( ) : n , k = map ( int , input ( ) . split ( ) )   arr = list ( map ( int , input ( ) . split ( ) ) )   k -= 1 num = arr [ k ] for i in range ( k , n ) : if arr [ i ] != num : print ( - 1 ) return   curr = k - 1 while curr >= 0 and arr [ curr ] == num : curr -= 1     print ( curr + 1 )     return         solution ( ) NEW_LINE +" +E415,"import java . util . Scanner ;   public class P3A { private static int ans = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String d = sc . nextLine ( ) ; int n1 = s . charAt ( 0 ) - d . charAt ( 0 ) ; int n2 = s . charAt ( 1 ) - d . charAt ( 1 ) ; System . out . println ( Math . max ( Math . abs ( n1 ) , Math . abs ( n2 ) ) ) ; while ( n1 != 0 || n2 != 0 ) { String path = "" "" ; if ( n1 > 0 ) { path += "" L "" ; n1 -- ; } if ( n1 < 0 ) { path += "" R "" ; n1 ++ ; } if ( n2 > 0 ) { path += "" D "" ; n2 -- ; } if ( n2 < 0 ) { path += "" U "" ; n2 ++ ; } System . out . println ( path ) ; } }    } +","a = input ( ) b = input ( ) c = 8   print ( max ( max ( ord ( a [ 0 ] ) , ord ( b [ 0 ] ) ) - min ( ord ( a [ 0 ] ) , ord ( b [ 0 ] ) ) , max ( int ( a [ 1 ] ) , int ( b [ 1 ] ) ) - min ( int ( a [ 1 ] ) , int ( b [ 1 ] ) ) ) ) d = ord ( a [ 0 ] ) - ord ( b [ 0 ] ) e = int ( a [ 1 ] ) - int ( b [ 1 ] ) while c > 0 : c -= 1 if d < 0 : if d != 0 : d += 1 print ( "" R "" , end = "" "" ) if d > 0 : print ( "" L "" , end = "" "" ) d -= 1 if e < 0 : print ( "" U "" , end = "" "" ) e += 1 if e > 0 : e -= 1 print ( "" D "" , end = "" "" ) print ( )       NEW_LINE +" +E416,"  import java . util . Scanner ;   public class b { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; System . out . println ( scan . nextDouble ( ) * Math . pow ( 1.000000011 , scan . nextDouble ( ) ) ) ; } } +","def f ( t ) : z = 1.000000011 p = 1 while t : if t % 2 : t -= 1 p *= z else : t //= 2 z *= z return pn , t = map ( int , input ( ) . split ( ) ) print ( n * f ( t ) ) NEW_LINE +" +E417,"import java . util . * ; import java . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; int m = sc . nextInt ( ) ; +","n , m = map ( int , input ( ) . split ( ) ) ; a = list ( map ( int , input ( ) . split ( ) ) )   b = [ ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( m ) ]   count = 0 for i in range ( m ) : sum = 0 ; for j in range ( b [ i ] [ 0 ] - 1 , b [ i ] [ 1 ] ) : sum += a [ j ]   if ( sum > 0 ) : count += sum     print ( count ) NEW_LINE +" +E418,"import java . util . * ;   public class Solution { public static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = 15000001 ; int prime [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) prime [ i ] = i ; for ( int p = 2 ; p * p <= n ; p ++ ) { +","n = int ( input ( ) ) m = list ( map ( int , input ( ) . split ( ) ) ) gc = m [ 0 ] import mathfor i in range ( 1 , n ) : gc = math . gcd ( gc , m [ i ] ) k = max ( m ) prime = [ 0 ] * ( k + 1 ) pfac = [ 0 ] * ( k + 1 ) for i in range ( 2 , k + 1 ) : if prime [ i ] == 0 : for j in range ( i * i , k + 1 , i ) : prime [ j ] = ifor i in range ( 1 , k + 1 ) : if not prime [ i ] : prime [ i ] = ifor i in range ( n ) : v = m [ i ] // gc while v > 1 : fac = prime [ v ] pfac [ fac ] += 1 while v % fac == 0 : v //= facma = 0 ma = max ( pfac ) if ma : print ( n - ma ) else : print ( - 1 ) NEW_LINE +" +E419,"import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) { int N = in . nextInt ( ) ; int K = in . nextInt ( ) ;   if ( K == 1 ) { out . println ( N ) ; return ; }   List < Integer > fac = new ArrayList < > ( ) ;   for ( int p = 2 ; p * p <= N ; p ++ ) { while ( N > 1 && N % p == 0 ) { fac . add ( p ) ; N /= p ; } } if ( N > 1 ) fac . add ( N ) ;   if ( fac . size ( ) < K ) { out . println ( - 1 ) ; return ; }   for ( int i = 0 ; i < K - 1 ; i ++ ) { out . print ( fac . get ( i ) + "" ▁ "" ) ; } long t = 1 ; for ( int i = K - 1 ; i < fac . size ( ) ; i ++ ) { t *= fac . get ( i ) ; } out . println ( t ) ;   }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; }   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 ( ) ) ; } } } +","import mathn , k = map ( int , input ( ) . split ( ) )   result = [ ]   while ( n % 2 == 0 ) : result . append ( 2 ) n = n // 2   NEW_LINE +" +E420,"import java . io . * ; import java . lang . Math ; import java . util . * ;   public class Main {   public BufferedReader in ; public PrintStream out ;   public boolean log_enabled = false ; public boolean multiply_tests = true ;   public static boolean do_gen_test = false ; public void gen_test ( ) { } private class TestCase {   public Object solve ( ) { int n = readInt ( ) ; String s = readLn ( ) ; int first = - 1 ; int second = - 1 ; int c ; for ( int i = 0 ; i < n ; i ++ ) { c = s . charAt ( i ) - '0' ; if ( c % 2 == 1 ) { if ( first == - 1 ) { first = i ; } else if ( second == - 1 ) { second = i ; break ; } } } if ( second > - 1 ) { return s . substring ( first , second + 1 ) ; } else { return - 1 ; } +","for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) li = list ( map ( int , input ( ) ) ) od = 0 ev = 0 res = [ ] cnt = 0 for i in range ( n ) : if li [ i ] % 2 == 0 : res . append ( li [ i ] ) else : cnt += 1 res . append ( li [ i ] ) if cnt == 2 : break if res [ - 1 ] % 2 != 0 and cnt >= 2 : print ( * res , sep = ' ' ) else : print ( - 1 )   NEW_LINE +" +E421,"import java . io . * ; import java . util . * ; import java . math . * ;     public class Test {   static boolean [ ] visited ; static boolean [ ] [ ] [ ] graph ;   public static boolean dfs ( int a , int b , int color ) { visited [ a ] = true ; if ( a == b ) { return true ; } boolean ans = false ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( graph [ a ] [ i ] [ color ] && ! visited [ i ] ) { ans = ans || dfs ( i , b , color ) ; } } return ans ; }   public static void process ( ) throws IOException { int n = ni ( ) ; int m = ni ( ) ; graph = new boolean [ 101 ] [ 101 ] [ 101 ] ; for ( int i = 0 ; i < m ; i ++ ) { int u = ni ( ) ; int v = ni ( ) ; int color = ni ( ) ; graph [ u ] [ v ] [ color ] = true ; graph [ v ] [ u ] [ color ] = true ; } int q = ni ( ) ; while ( q -- > 0 ) { int count = 0 ; int a = ni ( ) ; int b = ni ( ) ; for ( int j = 0 ; j <= 100 ; j ++ ) { visited = new boolean [ 102 ] ; if ( dfs ( a , b , j ) ) { count ++ ; } } pn ( count ) ; }   }    static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ;   +","import osimport sysfrom io import BytesIO , IOBaseBUFSIZE = 8192 class FastIO ( IOBase ) : newlines = 0 def __init__ ( self , file ) : self . _fd = file . fileno ( ) self . buffer = BytesIO ( ) self . writable = "" x "" in file . mode or "" r "" not in file . mode self . write = self . buffer . write if self . writable else None def read ( self ) : while True : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) if not b : break ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines = 0 return self . buffer . read ( ) def readline ( self ) : while self . newlines == 0 : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) self . newlines = b . count ( b "" \n "" ) + ( not b ) ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines -= 1 return self . buffer . readline ( ) def flush ( self ) : if self . writable : os . write ( self . _fd , self . buffer . getvalue ( ) ) self . buffer . truncate ( 0 ) , self . buffer . seek ( 0 ) class IOWrapper ( IOBase ) : def __init__ ( self , file ) : self . buffer = FastIO ( file ) self . flush = self . buffer . flush self . writable = self . buffer . writable self . write = lambda s : self . buffer . write ( s . encode ( "" ascii "" ) ) self . read = lambda : self . buffer . read ( ) . decode ( "" ascii "" ) self . readline = lambda : self . buffer . readline ( ) . decode ( "" ascii "" ) sys . stdin , sys . stdout = IOWrapper ( sys . stdin ) , IOWrapper ( sys . stdout ) input = lambda : sys . stdin . readline ( ) . rstrip ( "" \n "" ) NEW_LINE +" +E422,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ;    public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( InputReader in , PrintWriter out ) { int n = in . nextInt ( ) - 1 ; out . print ( 1 + "" ▁ "" ) ; for ( int i = 1 ; i <= n ; i ++ ) { int j = n - i ; if ( i % 3 != 0 && j % 3 != 0 ) { out . print ( i + "" ▁ "" + j ) ; break ; } } } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreElements ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } +","n = int ( input ( ) ) q = n // 3 r = n % 3 if ( r == 0 ) : if ( q % 3 != 0 ) : print ( q , q , q ) else : print ( q + 2 , q - 1 , q - 1 ) elif ( r == 1 ) : if ( q % 3 != 0 and ( q + 1 ) % 3 != 0 ) : print ( q , q , q + 1 ) elif ( q % 3 != 0 and ( q + 1 ) % 3 == 0 ) : print ( q - 1 , q , q + 2 ) elif ( q % 3 == 0 and ( q + 1 ) % 3 != 0 ) : print ( q - 1 , q + 1 , q + 1 ) else : if ( q % 3 != 0 and ( q + 2 ) % 3 != 0 ) : print ( q , q , q + 2 ) elif ( q % 3 != 0 and ( q + 2 ) % 3 == 0 ) : print ( q , q + 1 , q + 1 ) elif ( q % 3 == 0 and ( q + 2 ) % 3 != 0 ) : print ( q - 1 , q + 1 , q + 2 ) NEW_LINE +" +E423,"import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; StringBuilder ans = new StringBuilder ( ) ; String NotB = "" "" ; int zero = 0 ; int flag = 0 ; int totalZeroCount = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String value = input . next ( ) ; if ( flag == 0 ) { long count = value . chars ( ) . filter ( ch -> ch == '1' ) . count ( ) ; if ( count > 1 ) { NotB += value ; flag = 1 ; continue ; } else { for ( char j = '2' ; j <= '9' ; j ++ ) { if ( value . contains ( j + "" "" ) ) { NotB += value ; flag = 1 ; break ; } } if ( flag == 1 ) continue ; } } if ( value . length ( ) == 1 && value . equals ( ""0"" ) ) { System . out . println ( ""0"" ) ; return ; } else { totalZeroCount += ( value . length ( ) - 1 ) ; } } while ( totalZeroCount -- > 0 ) { ans . append ( ""0"" ) ; } System . out . println ( ( ( NotB . isEmpty ( ) ) ? ""1"" : NotB ) + ans ) ; } } +","n = int ( input ( ) ) p , s , t = 1 , 0 , ""1"" for x in input ( ) . split ( ) : if x == ""0"" : print ( 0 ) quit ( ) elif x == ""1"" + ""0"" * ( len ( x ) - 1 ) : s += len ( x ) - 1 else : t = str ( x ) print ( t + ""0"" * s ) NEW_LINE +" +E424,"import java . util . Scanner ;   public class A1325 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; for ( int i = t ; i > 0 ; i -- ) { int x = scanner . nextInt ( ) ; System . out . println ( 1 + "" ▁ "" + ( x - 1 ) ) ; } } } +","for i in [ * open ( 0 ) ] [ 1 : ] : print ( int ( i ) - 1 , 1 ) NEW_LINE +" +E425,"import java . awt . Desktop ;    import java . io . BufferedReader ;    import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . net . URI ; import java . net . URISyntaxException ; import java . sql . Array ; 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 . LinkedHashMap ; import java . util . LinkedHashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; import java . util . Stack ; import java . util . StringTokenizer ; import java . util . TreeSet ; import java . util . Vector ;     public class codechef3 { static class comp implements Comparator < Integer > {   @ Override public int compare ( Integer o1 , Integer o2 ) { if ( Math . abs ( o1 ) > Math . abs ( o2 ) ) return - 1 ; else return 1 ; } } +","import mathfrom collections import deque     def Work ( ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) IDX = [ 0 ] * n   for i in range ( n ) : IDX [ a [ i ] - 1 ] = i   l , r = n , 0 s = "" ""   for i in range ( n ) : l , r = min ( l , IDX [ i ] ) , max ( r , IDX [ i ] ) s += '1' if r - l == i else '0'   print ( s )     if __name__ == "" _ _ main _ _ "" : t = int ( input ( ) ) for _ in range ( t ) : Work ( ) NEW_LINE +" +E426,"import java . util . * ; import java . io . * ;   public class Codeforces { InputStream is ; PrintWriter out ; String INPUT = "" "" ;   +","( k , n , m ) = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ ] NEW_LINE for i in range ( k ) : s = input ( ) NEW_LINE a . append ( [ ] ) NEW_LINE for j in range ( n ) : a [ - 1 ] . append ( list ( input ( ) ) ) NEW_LINE s = input ( ) ( x , y ) = map ( int , input ( ) . split ( ) ) NEW_LINE x -= 1 NEW_LINE y -= 1   start = ( 0 , x , y ) NEW_LINE sosed = set ( ) NEW_LINE sosed . add ( start ) NEW_LINE posetil = set ( ) NEW_LINE posetil . add ( start ) NEW_LINE while len ( sosed ) > 0 : sosed2 = set ( ) NEW_LINE for i in sosed : for NEW_LINE dk in [ - 1 , 0 , 1 ] : NEW_LINE for dx in [ - 1 , 0 , 1 ] : for NEW_LINE dy in [ - 1 , 0 , 1 ] : NEW_LINE if abs ( dk ) + abs ( dx ) + abs ( dy ) == 1 : if NEW_LINE ( i [ 0 ] + dk < k ) and ( i [ 0 ] + dk >= 0 ) and ( i [ 1 ] + dx < n ) and ( i [ 1 ] + dx >= 0 ) and ( i [ 2 ] + dy < m ) and ( i [ 2 ] + dy >= 0 ) : NEW_LINE if a [ i [ 0 ] + dk ] [ i [ 1 ] + dx ] [ i [ 2 ] + dy ] == ' . ' : if NEW_LINE ( i [ 0 ] + dk , i [ 1 ] + dx , i [ 2 ] + dy ) in posetil : NEW_LINE continue else : posetil . add ( ( i [ 0 ] + dk , i [ 1 ] + dx , i [ 2 ] + dy ) ) NEW_LINE sosed2 . add ( ( i [ 0 ] + dk , i [ 1 ] + dx , i [ 2 ] + dy ) ) NEW_LINE sosed = sosed2 . copy ( ) NEW_LINE print ( len ( posetil ) ) NEW_LINE +" +E427,"import java . util . Arrays ; import java . util . Scanner ;   public class _0695ShuffleHashing {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cases = sc . nextInt ( ) ; sc . nextLine ( ) ; while ( cases > 0 ) { String p = sc . nextLine ( ) ; String h = sc . nextLine ( ) ; boolean flag = false ; char [ ] ori = p . toCharArray ( ) ; Arrays . sort ( ori ) ; p = new String ( ori ) ; a : { for ( int i = 0 ; i <= h . length ( ) - p . length ( ) ; i ++ ) { String temp = h . substring ( i , i + p . length ( ) ) ; char [ ] first = temp . toCharArray ( ) ; Arrays . sort ( first ) ; if ( new String ( first ) . equals ( p ) ) { flag = true ; +","t = int ( input ( ) )   for i in range ( t ) : p = input ( ) h = input ( ) cnts = { } for c in p : cnts [ c ] = cnts . get ( c , 0 ) + 1 yes = False for i in range ( len ( h ) ) : seq = { } for c in h [ i : ] : yes |= seq == cnts if c not in cnts : seq = { } else : seq [ c ] = seq . get ( c , 0 ) + 1 yes |= seq == cnts print ( "" YES "" if yes else "" NO "" ) NEW_LINE +" +E428,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","v1 , v2 = map ( int , input ( ) . split ( ) ) t , d = map ( int , input ( ) . split ( ) ) t -= 1 u = [ 0 ] * ( t + 1 ) u [ 0 ] = v1for i in range ( 1 , t + 1 ) : u [ i ] = min ( u [ i - 1 ] + d , v2 + ( t - i ) * d ) ans = 0 for i in range ( 0 , t + 1 ) : ans += u [ i ] print ( ans ) NEW_LINE +" +E429,"import java . util . * ; import java . lang . * ; import java . io . * ;   public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) { +","n = int ( input ( ) ) a = sorted ( [ int ( x ) for x in input ( ) . split ( ) ] ) s = sum ( a ) if a [ 0 ] != 0 : print ( - 1 ) exit ( 0 ) if s % 3 != 0 : for x in a : if x % 3 == s % 3 : a . remove ( x ) break else : for x in a : if x % 3 : a . remove ( x ) break for x in a : if x % 3 : a . remove ( x ) breakwhile len ( a ) > 1 and a [ - 1 ] == 0 : a . pop ( ) a = a [ : : - 1 ] print ( ' ' . join ( str ( x ) for x in a ) ) NEW_LINE +" +E430,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class worldCup1 { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int i = 0 ; while ( a != b ) { a = ( int ) Math . ceil ( a / 2.0 ) ; b = ( int ) Math . ceil ( b / 2.0 ) ; i ++ ; } if ( Math . pow ( 2 , i ) == n ) { System . out . println ( "" Final ! "" ) ; } else { System . out . println ( i ) ; } } } +","import math   n , a , b = map ( int , input ( ) . split ( ' ▁ ' ) ) rounds = math . log ( n , 2 ) r = int ( rounds ) for i in range ( 1 , int ( rounds ) + 1 ) : a = math . ceil ( a / 2 ) b = math . ceil ( b / 2 ) if ( a == b ) : if ( i == r ) : print ( ' Final ! ' ) break else : print ( i ) break NEW_LINE +" +E431,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class CF1371A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { System . out . println ( ( Integer . parseInt ( br . readLine ( ) ) + 1 ) / 2 ) ; } } } +","for x in range ( int ( input ( ) ) ) : n = int ( input ( ) ) if n % 2 == 0 : print ( n // 2 ) else : print ( ( n // 2 ) + 1 ) NEW_LINE +" +E432,"import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String a [ ] = new String [ 8 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { a [ i ] = input . next ( ) ; } boolean check = true ; int whitemin = 100 ; int blackmin = 100 ; for ( int i = 0 ; i < 8 ; i ++ ) { for ( int j = 0 ; j < 8 ; j ++ ) { check = true ; if ( a [ i ] . charAt ( j ) == ' B ' ) { for ( int k = i + 1 ; k < 8 ; k ++ ) { if ( a [ k ] . charAt ( j ) == ' W ' ) check = false ; } if ( check ) { blackmin = Math . min ( blackmin , 7 - i ) ; } } else if ( a [ i ] . charAt ( j ) == ' W ' ) { check = true ; if ( a [ i ] . charAt ( j ) == ' W ' ) { for ( int k = 0 ; k < i ; k ++ ) { if ( a [ k ] . charAt ( j ) == ' B ' ) check = false ; } if ( check ) { whitemin = Math . min ( whitemin , i ) ; } } } } } if ( whitemin <= blackmin ) System . out . println ( "" A "" ) ; else System . out . println ( "" B "" ) ; } } +","if __name__ == ' _ _ main _ _ ' : cin = input a = [ cin ( ) for i in range ( 8 ) ] mw , mb = 8 , 8   for c in range ( 8 ) : for r in range ( 8 ) : if a [ r ] [ c ] == "" W "" : mw = min ( mw , r ) if a [ r ] [ c ] != "" . "" : break for r in range ( 7 , - 1 , - 1 ) : if a [ r ] [ c ] == "" B "" : mb = min ( mb , 7 - r ) if a [ r ] [ c ] != "" . "" : break print ( "" AB "" [ mb < mw ] ) NEW_LINE +" +E433,"import java . util . * ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long sz = 1 ; +","while True : try : n , m = list ( map ( int , input ( ) . split ( ) ) ) res = 1 while m % 2 == 0 : res += 1 m /= 2 print ( res ) except : break NEW_LINE +" +E434,"import java . util . Arrays ; import java . util . Scanner ;   public class NewYear { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int testcases = sc . nextInt ( ) ; sc . nextLine ( ) ;   for ( int i = 0 ; i < testcases ; i ++ ) { String array = sc . nextLine ( ) ; int [ ] stream = Arrays . stream ( array . split ( "" ▁ "" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; System . out . println ( output ( stream ) ) ; } }   private static int output ( int [ ] stream ) { int out = 0 ; int hours = 23 - stream [ 0 ] ; int minutes = 60 - stream [ 1 ] ; out += minutes ; out += 60 * hours ; return out ; +","for _ in range ( int ( input ( ) ) ) : h , m = map ( int , input ( ) . split ( ) ) s = 0 s = ( 24 - h - 1 ) * 60 + ( 60 - m ) print ( s ) NEW_LINE +" +E435,"import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int f = Math . max ( x , a - x - 1 ) ; int sum = f * b ; int s = Math . max ( y , b - y - 1 ) ; int sum2 = s * a ; int r = Math . max ( sum2 , sum ) ; System . out . println ( r ) ; }   } } +","def solve ( a , b , p , q ) : area1 = a * q area2 = a * ( b - q - 1 ) area3 = b * p area4 = b * ( a - p - 1 ) return max ( area1 , area2 , area3 , area4 ) if __name__ == ' _ _ main _ _ ' : S = int ( input ( ) ) for s in range ( S ) : a , b , p , q = tuple ( map ( int , input ( ) . split ( ) ) ) print ( solve ( a , b , p , q ) ) NEW_LINE +" +E436,"import java . io . * ; import java . util . * ; import java . lang . * ;   public class B { public static char [ ] [ ] board ; public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) , m = in . nextInt ( ) ; board = new char [ n ] [ m ] ; int [ ] [ ] cost = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { board [ i ] = in . next ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( board [ i ] [ j ] != ' B ' ) continue ; for ( int l = i ; l < n ; l ++ ) { for ( int r = 0 ; r < m ; r ++ ) { if ( i == l && j == r ) continue ; if ( board [ l ] [ r ] != ' B ' ) continue ; if ( ! check ( i , j , l , r ) ) { +","import sys   input = sys . stdin . readline   def check ( x , y ) : for i in range ( min ( x [ 0 ] , y [ 0 ] ) , max ( x [ 0 ] , y [ 0 ] ) + 1 ) : if not plan [ i ] [ x [ 1 ] ] == "" B "" : return False for i in range ( min ( x [ 1 ] , y [ 1 ] ) , max ( x [ 1 ] , y [ 1 ] ) + 1 ) : if not plan [ y [ 0 ] ] [ i ] == "" B "" : return False return True   n , m = map ( int , input ( ) . split ( ) ) plan = tuple ( tuple ( i for i in input ( ) . strip ( ) ) for j in range ( n ) ) start = [ ( i , j ) for i in range ( n ) for j in range ( m ) if plan [ i ] [ j ] == "" B "" ] for i in range ( len ( start ) ) : for j in range ( i + 1 , len ( start ) ) : if not check ( start [ i ] , start [ j ] ) and not check ( start [ j ] , start [ i ] ) : print ( "" NO "" ) sys . exit ( ) print ( "" YES "" ) NEW_LINE +" +E437,"import java . util . * ;   public class problem967A { private static Scanner in = new Scanner ( System . in ) ; private static int n = 0 , s = 0 ; private static ArrayList < Time > schedule = new ArrayList < Time > ( ) ; public static void main ( String [ ] args ) { n = in . nextInt ( ) ; s = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Time time = new Time ( in . nextInt ( ) , in . nextInt ( ) ) ; schedule . add ( time ) ; } schedule . add ( new Time ( 0 , 0 ) ) ; Collections . sort ( schedule , new SortByTime ( ) ) ; +","I = lambda : map ( int , input ( ) . split ( ) ) n , s = I ( ) l = [ 0 ] for i in range ( n ) : q , w = I ( ) q = q * 60 + w l += [ q ] if l [ 1 ] - l [ 0 ] > s : exit ( print ( 0 , 0 ) ) for i in range ( n ) : if l [ i + 1 ] - l [ i ] > 2 * s + 1 : l [ i ] += s + 1 exit ( print ( l [ i ] // 60 , l [ i ] % 60 ) ) l [ - 1 ] += s + 1 print ( l [ - 1 ] // 60 , l [ - 1 ] % 60 ) NEW_LINE +" +E438,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; StringBuilder s = new StringBuilder ( input . next ( ) ) ; if ( s . indexOf ( "" http "" ) == 0 ) { s . insert ( s . indexOf ( "" http "" ) + 4 , "" : // "" ) ; } else { s . insert ( s . indexOf ( "" ftp "" ) + 3 , "" : // "" ) ; } int ruindex = - 1 ; for ( int i = 1 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == ' r ' && s . charAt ( i + 1 ) == ' u ' && s . charAt ( i - 1 ) != ' / ' ) { ruindex = i ; break ; } } +","s = input ( ) ans = "" "" if s . startswith ( ' http ' ) : s = s [ 4 : ] ans = ' http : / / ' else : ans = "" ftp : / / "" s = s [ 3 : ]   if s . count ( ' ru ' ) > 1 and s . index ( ' ru ' ) == 0 : x = s [ 1 : ] . index ( ' ru ' ) + 1 else : x = s . index ( ' ru ' )     ans += s [ : x ] + ' . ' + ' ru ' s = s [ x + 2 : ] if s : ans += ' / ' + s   print ( ans )     NEW_LINE +" +E439,"import java . util . Arrays ; import java . util . Locale ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long l = sc . nextLong ( ) ; String s = sc . next ( ) ; try { int j = 0 ; for ( ; s . charAt ( j ) != '8' ; j ++ ) { } if ( s . length ( ) - j < 11 ) { System . out . println ( "" NO "" ) ; } else { System . out . println ( "" YES "" ) ; }   } catch ( Exception Arrayindexoutofbounds ) { System . out . println ( "" NO "" ) ; continue ; }    } } } +","tests = int ( input ( ) ) t = 0 for t in range ( 0 , tests ) : n = int ( input ( ) ) s = input ( ) bol = False for i in range ( 0 , len ( s ) ) : if s [ i ] == '8' : bol = True cnt = i break if ( bol ) : if n - cnt >= 11 : print ( ' YES ' ) else : print ( ' NO ' ) else : print ( "" NO "" ) NEW_LINE +" +E440,"import java . util . Scanner ;   public class AdjacentReplacement {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   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 ) { a [ i ] -- ; }   System . out . print ( a [ i ] + "" ▁ "" ) ; }   }   } +","def solve ( arr ) : for i in range ( len ( arr ) ) : if arr [ i ] % 2 == 0 : arr [ i ] -= 1 return "" ▁ "" . join ( str ( i ) for i in arr )   input ( ) arr = list ( map ( int , input ( ) . split ( ) ) ) print ( solve ( arr ) ) NEW_LINE +" +E441,"import java . util . * ;   import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) {   +","from collections import defaultdictfrom sys import stdin   def put ( ) : return map ( int , stdin . readline ( ) . split ( ) )   def dfs ( ) : s = [ ( 1 , 0 ) ] ans = 0 vis = [ 0 ] * ( n + 1 ) while s : i , p = s . pop ( ) if vis [ i ] == 0 : vis [ i ] = 1 s . append ( ( i , p ) ) for j in tree [ i ] : if j != p : s . append ( ( j , i ) ) elif vis [ i ] == 1 : vis [ i ] = 2 for j in tree [ i ] : if j != p : mark [ i ] += mark [ j ] ans += min ( mark [ i ] , 2 * k - mark [ i ] ) print ( ans )         n , k = put ( ) l = list ( put ( ) )   edge = defaultdict ( ) tree = [ [ ] for i in range ( n + 1 ) ] mark = [ 0 ] * ( n + 1 ) for i in l : mark [ i ] = 1 for _ in range ( n - 1 ) : x , y = put ( ) tree [ x ] . append ( y ) tree [ y ] . append ( x ) dfs ( ) NEW_LINE +" +E442,"import java . util . * ; import java . io . * ;   public class threestrings { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int T = in . nextInt ( ) ; for ( int tt = 0 ; tt < T ; tt ++ ) { String a = in . nextLine ( ) ; String b = in . nextLine ( ) ; String c = in . nextLine ( ) ; boolean swappable = true ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == c . charAt ( i ) || b . charAt ( i ) == c . charAt ( i ) ) swappable = true ; else { swappable = false ; break ; }   } if ( swappable ) out . println ( "" YES "" ) ; else out . println ( "" NO "" ) ;   } out . close ( ) ; }   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } +","for _ in range ( int ( input ( ) ) ) : a = input ( ) b = input ( ) c = input ( ) case = True for i in range ( len ( a ) ) : if a [ i ] != c [ i ] and b [ i ] != c [ i ] : case = False print ( "" NO "" ) break if case : print ( "" YES "" ) NEW_LINE +" +E443,"from collections import defaultdictfrom collections import dequen , m = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( list ) for i in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) d [ x ] . append ( y ) d [ y ] . append ( x ) c = { } f = 0 visited = [ 0 ] * ( n + 1 ) for i in range ( 1 , n + 1 ) : if visited [ i ] == 0 : q = deque ( ) q . append ( i ) visited [ i ] = 1 while q : j = q . popleft ( ) co = c . get ( j , 0 ) if co == 0 : c [ j ] = ' a ' co = ' a ' for k in d [ j ] : if visited [ k ] == 0 : coo = c . get ( k , 0 ) if coo == 0 : c [ k ] = ' a ' if co == ' b ' else ' b ' q . append ( k ) visited [ k ] = 1f or i in d : co = c [ i ] for j in d [ i ] : coo = c [ j ] if co == coo : f = 1 break if f : breakif f : print ( - 1 ) else : a , b = [ ] , [ ] for i in range ( 1 , n + 1 ) : co = c . get ( i , 0 ) if co == ' a ' : a . append ( i ) elif co == ' b ' : b . append ( i ) print ( len ( a ) ) print ( * a ) print ( len ( b ) ) print ( * b ) +","n , m = map ( int , input ( ) . split ( ) ) g = [ set ( ) for i in range ( n ) ] for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) g [ a - 1 ] . add ( b - 1 ) g [ b - 1 ] . add ( a - 1 ) a = [ ] p = [ - 1 ] * nfor i in range ( n ) : if p [ i ] != - 1 : continue p [ i ] = 0 a . append ( i ) while a : x = a . pop ( ) for node in g [ x ] : if p [ node ] == p [ x ] : print ( - 1 ) exit ( ) if p [ node ] == - 1 : p [ node ] = not p [ x ] a . append ( node ) print ( p . count ( 0 ) ) for i in range ( n ) : if p [ i ] == 0 : print ( i + 1 , end = "" ▁ "" ) print ( ) print ( p . count ( 1 ) ) for i in range ( n ) : if p [ i ] == 1 : print ( i + 1 , end = "" ▁ "" ) print ( ) NEW_LINE +" +E444,"import java . util . * ; import java . lang . * ; import java . io . * ; public class Main {    public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; if ( ( x1 != x2 ) && ( y1 != y2 ) && Math . abs ( x1 - x2 ) != Math . abs ( y1 - y2 ) ) { System . out . println ( "" - 1"" ) ; } else if ( x1 == x2 ) { System . out . println ( ( x1 + Math . abs ( y2 - y1 ) ) + "" ▁ "" + y1 + "" ▁ "" + ( x2 + Math . abs ( y2 - y1 ) ) + "" ▁ "" + y2 ) ; } else if ( y1 == y2 ) { System . out . println ( x1 + "" ▁ "" + ( y1 + Math . abs ( x2 - x1 ) ) + "" ▁ "" + x2 + "" ▁ "" + ( y2 + Math . abs ( x2 - x1 ) ) ) ; } else { System . out . println ( x1 + "" ▁ "" + y2 + "" ▁ "" + x2 + "" ▁ "" + y1 ) ; } } } +","x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) )   if x1 == x2 : x3 = x1 + abs ( y2 - y1 ) x4 = x3 y3 = y1 y4 = y2 NEW_LINE +" +E445,"import java . util . * ; import java . lang . * ; import java . io . * ; public class African_Crossword {   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 n = Integer . parseInt ( st . nextToken ( ) ) , m = Integer . parseInt ( st . nextToken ( ) ) ; char c [ ] [ ] = new char [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = br . readLine ( ) ; for ( int j = 0 ; j < m ; j ++ ) { c [ i ] [ j ] = s . charAt ( j ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { boolean ok = false ; for ( int k = 0 ; k < m ; k ++ ) { if ( c [ i ] [ j ] == c [ i ] [ k ] && j != k ) { ok = true ; break ; } } if ( ! ok ) { for ( int k = 0 ; k < n ; k ++ ) { if ( c [ i ] [ j ] == c [ k ] [ j ] && i != k ) { ok = true ; break ; } } } if ( ! ok ) System . out . print ( c [ i ] [ j ] ) ; } }   }   } +","def checkRow ( i , c ) : cnt = 0 NEW_LINE for j in range ( m ) : if NEW_LINE g [ i ] [ j ] == c : cnt += 1   if cnt >= 2 : return True NEW_LINE return False     NEW_LINE def checkCol ( j , c ) : cnt = 0 NEW_LINE for i in range ( n ) : if NEW_LINE g [ i ] [ j ] == c : cnt += 1   if cnt >= 2 : return True NEW_LINE return False   n , m = map ( int , input ( ) . split ( ) )   g = [ ]   for i in range ( n ) : g . append ( list ( input ( ) ) )     res = [ [ 0 ] * m for i in range ( n ) ] NEW_LINE for i in range ( n ) : for NEW_LINE j in range ( m ) : NEW_LINE if ( checkRow ( i , g [ i ] [ j ] ) ) or checkCol ( j , g [ i ] [ j ] ) : res [ i ] [ j ] = 1     for i in range ( n ) : for NEW_LINE j in range ( m ) : NEW_LINE if res [ i ] [ j ] == 0 : print ( g [ i ] [ j ] , end = ' ' )         NEW_LINE +" +E446,"  import java . util . ArrayList ; import java . util . Scanner ;   public class B {   public static void main ( String [ ] args ) {   Scanner nik = new Scanner ( System . in ) ; int n = nik . nextInt ( ) ; int m = nik . nextInt ( ) ;   int [ ] a = new int [ n + 2 ] ;   int max = 0 ;   for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = nik . nextInt ( ) ; } a [ 0 ] = 0 ; a [ n + 1 ] = m ;   +","n , M = map ( int , input ( ) . strip ( ) . split ( ) ) a = list ( map ( int , input ( ) . strip ( ) . split ( ) ) )   a . insert ( 0 , 0 ) n += 1   lit = [ 0 ] * ( n + 1 ) for i in range ( 1 , n ) : if i % 2 == 0 : lit [ i ] = lit [ i - 1 ] else : lit [ i ] = lit [ i - 1 ] + a [ i ] - a [ i - 1 ] if n % 2 == 0 : lit [ n ] = lit [ n - 1 ] else : lit [ n ] = lit [ n - 1 ] + M - a [ n - 1 ] NEW_LINE +" +E447,"import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ;    public class CodeForce {   static boolean flag = false ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; mp [ ] arr = new mp [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] sr = br . readLine ( ) . split ( "" ▁ "" ) ; int x = Integer . parseInt ( sr [ 0 ] ) ; arr [ i ] = new mp ( x , sr [ 1 ] ) ; } long total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( total == 0 ) && ( ! arr [ i ] . sr . equals ( "" South "" ) ) ) { System . out . println ( "" NO "" ) ; return ; } if ( ( total == 20000 ) && ( ! arr [ i ] . sr . equals ( "" North "" ) ) ) { System . out . println ( "" NO "" ) ; return ; } if ( arr [ i ] . sr . equals ( "" North "" ) ) { total -= arr [ i ] . dist ; if ( total < 0 ) { System . out . println ( "" NO "" ) ; return ; } } if ( arr [ i ] . sr . equals ( "" South "" ) ) { total += arr [ i ] . dist ; ; if ( total > 20000 ) { System . out . println ( "" NO "" ) ; return ; } } } if ( total != 0 ) { System . out . println ( "" NO "" ) ; return ; } System . out . println ( "" YES "" ) ;    } } class mp { int dist ; String sr ; mp ( int a , String s ) { dist = a ; sr = s ; } }   +","import sysdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) c = 0 for _ in range ( iinput ( ) ) : km , dirr = map ( str , input ( ) . split ( ) ) km = int ( km ) if dirr == ' North ' : c -= km elif dirr == ' South ' : c += km elif c == 0 or c == 20000 : print ( "" NO "" ) exit ( ) if c < 0 or c > 20000 : print ( "" NO "" ) exit ( ) if c == 0 : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E448,"import java . util . Scanner ;   public class MidBalls { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ;   StringBuilder ans = new StringBuilder ( ) ;   if ( m % 2 != 0 ) { while ( n > 0 ) { int left = ( m + 1 ) / 2 - 1 ; int right = left + 1 ;   while ( ( left > 0 || right <= m ) && n > 0 ) { ans . append ( right + "" \n "" ) ; right ++ ; n -- ;   if ( left == 0 || n == 0 ) continue ; ans . append ( left + "" \n "" ) ; left -- ; n -- ; } } } else { while ( n > 0 ) { int left = m / 2 ; int right = left + 1 ;   while ( ( left > 0 || right <= m ) && n > 0 ) { ans . append ( left + "" \n "" ) ; left -- ; n -- ;   if ( right > m || n == 0 ) continue ; ans . append ( right + "" \n "" ) ; right ++ ; n -- ; } } } System . out . println ( ans ) ; } } +","n , m = list ( map ( int , input ( ) . split ( "" ▁ "" ) ) )   if m % 2 != 0 : mid = int ( ( m + 1 ) / 2 ) i = mid j = mid       else :   mid = int ( ( m / 2 ) ) i = mid j = mid + 1     detector = 1 if m == 1 : for x in range ( n ) : print ( 1 ) else : for _ in range ( n ) : if i == j : print ( mid ) i -= 1 j += 1 detector = 1 continue if m % 2 != 0 : if detector == - 1 : print ( j ) j += 1 if j == m + 1 : j = mid detector *= - 1 elif detector == 1 : print ( i ) i -= 1 if i == 0 : i = mid detector *= - 1   elif m % 2 == 0 : if detector == 1 : print ( i ) i -= 1 if i == 0 : i = mid detector *= - 1 elif detector == - 1 : print ( j )   j += 1 if j == m + 1 : j = mid + 1 detector *= - 1     NEW_LINE +" +E449,"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long p = ( long ) Math . ceil ( ( double ) n * ( double ) ( y ) / ( double ) 100 ) ; if ( p - x <= 0 ) System . out . print ( 0 ) ; else System . out . print ( p - x ) ; } } +","import mathfrom math import gcd , floor , sqrt , logdef iin ( ) : return int ( input ( ) ) def sin ( ) : return input ( ) . strip ( ) def listin ( ) : return list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) def liststr ( ) : return list ( map ( str , input ( ) . strip ( ) . split ( ) ) ) def ceill ( x ) : return int ( x ) if ( x == int ( x ) ) else int ( x ) + 1 def ceilldiv ( x , d ) : return x // d if ( x % d == 0 ) else x // d + 1 def LCM ( a , b ) : return ( a * b ) // gcd ( a , b )     def solve ( ) : n , x , y = listin ( ) wiz = x people = n - x req = ceill ( ( y / 100 ) * n ) print ( max ( 0 , req - wiz ) ) t = 1 NEW_LINE +" +E450,"import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Equalize { static public class Pair { int i ; int j ; public Pair ( int i , int j ) { this . i = i ; this . j = j ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; sum += ar [ i ] ; } if ( ar [ 0 ] == 0 || sum < n - 1 ) System . out . println ( - 1 ) ; else { List < Pair > list = new ArrayList < Pair > ( ) ; int i = 0 , j = 1 ; while ( i < n ) { while ( j < n && ar [ j ] == 0 ) j ++ ; if ( j == n ) { i = j ; break ; } list . add ( new Pair ( i + 1 , j + 1 ) ) ; ar [ i ] -- ; if ( ar [ i ] == 0 ) ar [ i ] = 1001 ; i = j ; j += 1 ; } i = 1 ; j = 0 ; +","n = int ( input ( ) ) vals = list ( map ( int , input ( ) . split ( ) ) ) vals = [ ( i , vals [ i ] ) for i in range ( n ) ] vals = [ vals [ 0 ] ] + sorted ( vals [ 1 : ] , key = lambda x : x [ 1 ] , reverse = True ) most_left_idx = 0 count = 0 output = ' ' for i in range ( n ) : if ( most_left_idx >= i ) : for j in range ( 1 , vals [ i ] [ 1 ] + 1 ) : if ( most_left_idx + j < n ) : count += 1 output += ' { } ▁ { } ▁ \n ' . format ( vals [ i ] [ 0 ] + 1 , vals [ most_left_idx + j ] [ 0 ] + 1 ) most_left_idx += vals [ i ] [ 1 ] if ( most_left_idx >= n - 1 ) : print ( count ) print ( output ) else : print ( - 1 ) NEW_LINE +" +E451,"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int k = s . nextInt ( ) ; s . nextLine ( ) ; String s1 = s . nextLine ( ) ; int [ ] last = new int [ 26 ] ; boolean c [ ] = new boolean [ 26 ] ; +","l = [ - 1 ] * 122 g = [ - 1 ] * 122 r = 0 ch = 0 n , k = map ( int , input ( ) . split ( ) ) s = input ( ) j = nfor i in range ( 0 , n ) : j -= 1 indf = ord ( s [ i ] ) indb = ord ( s [ j ] ) if ( l [ indf ] != - 1 ) : pass else : l [ indf ] = i if ( g [ indb ] != - 1 ) : pass else : g [ indb ] = j   for i in range ( 0 , n ) : indx = ord ( s [ i ] ) if ( l [ indx ] == i ) : r += 1 if ( r > k ) : ch = 1 break if ( g [ indx ] == i ) : r -= 1 if ( ch == 1 ) : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E452,"import java . util . * ;    public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; double ans = ( Math . pow ( l , 2 ) - Math . pow ( h , 2 ) ) / ( 2 * h ) ; System . out . println ( ans ) ;    }    public static int getAns ( int i , int [ ] e , int [ ] dp ) { if ( i < 0 ) { return Integer . MIN_VALUE ; } if ( i == 0 && e [ i ] == 1 ) { return 1 ; } if ( dp [ i ] != - 1 ) { return dp [ i ] ; }   dp [ i ] = Math . max ( 1 + getAns ( i - ( e [ i ] ) , e , dp ) , getAns ( i - 1 , e , dp ) ) ; return dp [ i ] ;    }    public static long power ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = ans * a ; ans %= c ; } a = a * a ; a %= c ; b /= 2 ; } return ans ; }   public static long power1 ( long a , long b , long c ) { long ans = 1 ; while ( b != 0 ) { if ( b % 2 == 1 ) { ans = multiply ( ans , a , c ) ; } a = multiply ( a , a , c ) ; b /= 2 ;   } return ans ;   }   public static long multiply ( long a , long b , long c ) { long res = 0 ; a %= c ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res + a ) % c ; } a = ( a + a ) % c ; b /= 2 ; }   return res % c ;   }   public static long totient ( long n ) { long result = n ; for ( long i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { +","a , b = list ( map ( int , input ( ) . split ( ) ) ) print ( format ( ( ( b * b ) - ( a * a ) ) / ( a * 2 ) , ' . 12f ' ) ) NEW_LINE +" +E453,"import java . util . * ; import java . util . stream . IntStream ;     public class Main { static boolean isvalid ( String s ) { if ( s . equals ( ""0"" ) || s . equals ( ""1000000"" ) ) return true ; if ( s . charAt ( 0 ) == '0' || s . length ( ) > 6 ) return false ; return true ; }   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ;   int mx = - 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) for ( int j = i + 1 ; j < s . length ( ) ; j ++ ) { String s1 = s . substring ( 0 , i ) ; String s2 = s . substring ( i , j ) ; String s3 = s . substring ( j ) ;   if ( isvalid ( s1 ) && isvalid ( s2 ) && isvalid ( s3 ) ) { int a = Integer . parseInt ( s1 ) ; int b = Integer . parseInt ( s2 ) ; int c = Integer . parseInt ( s3 ) ;   mx = Math . max ( mx , a + b + c ) ; } } System . out . println ( mx ) ; } }   +","s = input ( ) w = len ( s ) q = - 1 for i in range ( w - 2 ) : for j in range ( i + 1 , w - 1 ) : a , b , c = s [ : i + 1 ] , s [ i + 1 : j + 1 ] , s [ j + 1 : ] if len ( a ) == len ( str ( int ( a ) ) ) and len ( b ) == len ( str ( int ( b ) ) ) and len ( c ) == len ( str ( int ( c ) ) ) : if int ( a ) <= 10 ** 6 and int ( b ) <= 10 ** 6 and int ( c ) <= 10 ** 6 : q = max ( q , int ( a ) + int ( b ) + int ( c ) ) print ( q ) NEW_LINE +" +E454,"import java . awt . Desktop ;    import java . io . BufferedReader ;    import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . net . URI ; import java . net . URISyntaxException ; import java . sql . Array ; 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 . LinkedHashMap ; import java . util . LinkedHashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . PriorityQueue ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; import java . util . Stack ; import java . util . StringTokenizer ; import java . util . TreeSet ; import java . util . Vector ;     public class codechef3 { static class comp implements Comparator < Integer > {   @ Override public int compare ( Integer o1 , Integer o2 ) { if ( Math . abs ( o1 ) > Math . abs ( o2 ) ) return - 1 ; else return 1 ; } } +","x = int ( input ( ) ) for i in range ( x ) : n , m = [ int ( a ) for a in input ( ) . split ( ) ] if ( 2 * min ( n , m ) < max ( m , n ) or ( n + m ) % 3 ) : print ( "" NO "" ) else : print ( "" YES "" ) NEW_LINE +" +E455,"import java . io . * ; import java . util . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { FastReader fr = new FastReader ( ) ; int n = fr . nextInt ( ) ; long a [ ] [ ] = new long [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = fr . nextLong ( ) ; } } long a0 = ( a [ 0 ] [ 1 ] * a [ 0 ] [ 2 ] ) / a [ 1 ] [ 2 ] ; a0 = ( long ) Math . sqrt ( a0 ) ; long res [ ] = new long [ n ] ; res [ 0 ] = a0 ; for ( int i = 1 ; i < n ; i ++ ) { res [ i ] = ( a [ 0 ] [ i ] / a0 ) ; } for ( long i : res ) System . out . print ( i + "" ▁ "" ) ; +","from sys import * ; from math import * ; from collections import * ; from bisect import * ; from itertools import * INF = maxsizedef get_ints ( ) : return map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) def get_array ( ) : return list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) def input ( ) : return stdin . readline ( ) . strip ( ) mod = 1000000007   n = int ( input ( ) ) arr = [ ] for i in range ( n ) : temp = get_array ( ) arr . append ( temp ) for i in range ( n ) : ans = ( arr [ i ] [ ( i + 1 ) % n ] * arr [ i ] [ ( i + 2 ) % n ] ) // arr [ ( i + 1 ) % n ] [ ( i + 2 ) % n ] print ( int ( sqrt ( ans ) ) , end = ' ▁ ' ) NEW_LINE +" +E456,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Scanner ;   public class Nicho { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; int [ ] rong1 = Arrays . stream ( br . readLine ( ) . split ( "" \\ s "" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int max = Integer . MIN_VALUE , maxindex = 0 , min = Integer . MAX_VALUE , minindex = 0 ; for ( int i = 0 ; i < rong1 . length ; i ++ ) { if ( rong1 [ i ] > max ) { max = rong1 [ i ] ; maxindex = i ; } if ( rong1 [ i ] < min ) { min = rong1 [ i ] ; minindex = i ; } } if ( minindex == maxindex ) { System . out . println ( ""0"" ) ; } else if ( maxindex == 0 && minindex == rong1 . length - 1 ) { System . out . println ( rong1 . length - 1 ) ; } else if ( minindex == 0 && maxindex == rong1 . length - 1 ) { System . out . println ( rong1 . length - 1 ) ; } else if ( minindex < maxindex ) { System . out . println ( Math . max ( rong1 . length - minindex - 1 , maxindex ) ) ; } else if ( maxindex < minindex ) { System . out . println ( Math . max ( rong1 . length - maxindex - 1 , minindex ) ) ; } }   } +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) [ : n ] res = [ a . index ( 1 ) , a . index ( n ) ] print ( max ( max ( res ) , n - min ( res ) - 1 ) ) NEW_LINE +" +E457,"import java . util . * ; import java . io . * ;   public class CFA { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; private static final long MOD = 1000L * 1000L * 1000L + 7 ; private static final int [ ] dx = { 0 , - 1 , 0 , 1 } ; private static final int [ ] dy = { 1 , 0 , - 1 , 0 } ; private static final String yes = "" Yes "" ; private static final String no = "" No "" ;   void solve ( ) { +","n = int ( input ( ) ) num = [ int ( i ) for i in input ( ) . split ( "" ▁ "" ) ]   odd = 0 even = 0   for i in num : if even and odd : break if i % 2 == 0 : even = 1 else : odd = 1 if even and odd : num = sorted ( num ) s = "" "" for i in range ( 0 , len ( num ) ) : s += str ( num [ i ] ) + "" ▁ "" print ( s ) NEW_LINE +" +E458,"import java . util . Scanner ; public class Main { static Scanner r = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n ; n = r . nextInt ( ) ; int [ ] x = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { x [ i ] = r . nextInt ( ) ; } boolean [ ] vis = new boolean [ n + 1 ] ; int c = n ; for ( int i = 1 ; i <= n ; i ++ ) { vis [ x [ i ] ] = true ; while ( vis [ c ] && c > 0 ) System . out . print ( c -- + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; } } } +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) k = ns = set ( ) for i in a : s . add ( i ) while k in s : print ( k , end = ' ▁ ' ) k -= 1 print ( ) NEW_LINE +" +E459,"import java . util . * ; public class puzzle { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; for ( int j = 0 ; j < t ; j ++ ) { int n = input . nextInt ( ) ; String s = input . next ( ) ; int c = ( s . charAt ( 0 ) - '0' ) + 1 ; System . out . print ( ""1"" ) ; for ( int i = 1 ; i < n ; i ++ ) { int ch = s . charAt ( i ) - '0' ; if ( ch + 1 != c ) { System . out . print ( ""1"" ) ; c = ch + 1 ; } else { System . out . print ( ""0"" ) ; c = ch ; } } System . out . println ( ) ; } }   }   +","for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE b = input ( ) NEW_LINE a = ' ' NEW_LINE d = ' ' NEW_LINE for i in b : try : if 1 + int ( i ) == int ( d [ - 1 ] ) : NEW_LINE INDENT a += '0' else : NEW_LINE a += '1' except : a = '1' NEW_LINE DEDENT d = str ( int ( a [ - 1 ] ) + int ( i ) ) NEW_LINE print ( a ) NEW_LINE +" +E460,"  import java . util . * ; import java . io . * ; import java . math . * ;   public class Main { long MOD = 1000000007 ; InputReader in ; BufferedReader br ; PrintWriter out ; public static void main ( String [ ] args ) throws java . lang . Exception { Main solver = new Main ( ) ; solver . in = new InputReader ( System . in ) ; solver . br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; solver . out = new PrintWriter ( System . out ) ; solver . solve ( ) ; solver . out . flush ( ) ; solver . out . close ( ) ; }   public void solve ( ) { int tc = 1 ; +","from math import ceiln , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) m = 10 ** ( k - 1 ) ans = 1 for i in range ( n // k ) : an = ( 10 ** k - 1 ) // a [ i ] + 1 l = b [ i ] * m r = ( b [ i ] + 1 ) * m - 1 count = r // a [ i ] - ceil ( l / a [ i ] ) + 1 ans = ( ans * ( an - count ) ) % ( 10 ** 9 + 7 ) print ( ans ) NEW_LINE +" +E461,"import java . util . * ; public class MeasuringLengthsInBaden { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int inches = ( n + 1 ) / 3 ; int feets = inches / 12 ; System . out . println ( feets + "" ▁ "" + ( inches - 12 * feets ) ) ; } } +","x = ( int ( input ( ) ) + 1 ) // 3 print ( x // 12 , x % 12 ) NEW_LINE +" +E462,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;    public class MainCP {   public static void main ( String [ ] args ) { FastReader s = new FastReader ( ) ; int n = s . nextInt ( ) ; int b = s . nextInt ( ) ; int d = s . nextInt ( ) ; int [ ] a = new int [ n ] ; int sum = 0 , c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = s . nextInt ( ) ; if ( x <= b ) { a [ i ] = x ; } } for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( sum > d ) { sum = 0 ; c ++ ; }   } System . out . println ( c ) ; } +","n , b , d = map ( int , input ( ) . split ( ) ) summa = 0 ans = 0 a = [ int ( i ) for i in input ( ) . split ( ) ] for i in a : if i <= b : summa += i if summa > d : summa = 0 ans += 1 print ( ans ) NEW_LINE +" +E463,"import java . io . * ; import java . util . * ; public class CF0543A {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; int M = Integer . parseInt ( st . nextToken ( ) ) ; int B = Integer . parseInt ( st . nextToken ( ) ) ; int MOD = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] a = new int [ N ] ; st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } +","n , m , b , mod = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) )   A = [ [ 0 for i in range ( m + 1 ) ] for j in range ( b + 1 ) ]   A [ 0 ] [ 0 ] = 1   for i in range ( n ) : for j in range ( a [ i ] , b + 1 ) : for k in range ( m ) : A [ j ] [ k + 1 ] = ( A [ j ] [ k + 1 ] + A [ j - a [ i ] ] [ k ] ) % mod NEW_LINE +" +E464,"from math import sqrt   a = map ( int , list ( raw_input ( ) ) [ :: - 1 ] ) b = map ( int , list ( raw_input ( ) ) [ :: - 1 ] )   i = max ( len ( a ) , len ( b ) )   a += [ 0 ] * ( i - len ( a ) ) b += [ 0 ] * ( i - len ( b ) )   i -= 1 while i >= 2 : while a [ i ] == b [ i ] : i -= 1 if i == - 1 : print "" = "" exit ( 0 ) if a [ i ] == 1 : a [ i - 1 ] += 1 - b [ i - 1 ] a [ i - 2 ] += 1 - b [ i - 2 ] b [ i - 1 ] = b [ i - 2 ] = 0 if a [ i - 1 ] == 2 or a [ i - 2 ] == 2 : print "" > "" exit ( 0 ) else : b [ i - 1 ] += 1 - a [ i - 1 ] b [ i - 2 ] += 1 - a [ i - 2 ] a [ i - 1 ] = a [ i - 2 ] = 0 if b [ i - 1 ] == 2 or b [ i - 2 ] == 2 : print "" < "" exit ( 0 ) i -= 1   a . append ( 0 ) b . append ( 0 ) ans = ( a [ 0 ] - b [ 0 ] ) + ( a [ 1 ] - b [ 1 ] ) * ( 1 + sqrt ( 5 ) ) / 2 if ans > 0 : print "" > "" elif ans < 0 : print "" < "" else : print "" = "" +","def clean ( d ) : ans = [ '0' ] for c in list ( d ) : ans . append ( c ) i = len ( ans ) - 1 NEW_LINE +" +E465,"import java . util . * ; import java . io . * ;   public class ATwistyMovement { +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = [ 0 ] * 4 for i in a : if i == 1 : d [ 0 ] += 1 d [ 2 ] = max ( d [ 2 ] + 1 , d [ 1 ] + 1 ) else : d [ 1 ] = max ( d [ 1 ] + 1 , d [ 0 ] + 1 ) d [ 3 ] = max ( d [ 3 ] + 1 , d [ 2 ] + 1 ) print ( max ( d ) ) NEW_LINE +" +E466,"import javax . swing . plaf . IconUIResource ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class codeforces { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ;   +","n , m = map ( int , input ( ) . split ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] b = [ 0 ] * ( 10 ** 5 + 1 ) p = [ 0 ] * n + [ 0 ] for i in range ( len ( a ) - 1 , - 1 , - 1 ) : if b [ a [ i ] ] == 0 : b [ a [ i ] ] += 1 p [ i ] = p [ i + 1 ] + 1 else : p [ i ] = p [ i + 1 ] for i in range ( m ) : k = int ( input ( ) ) print ( p [ k - 1 ] ) NEW_LINE +" +E467,"import java . util . * ; import java . io . * ; public class Main { public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter so = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; String s = in . next ( ) ; String str = in . next ( ) ; if ( s . equals ( str ) ) so . println ( s ) ; else so . println ( ""1"" ) ; so . flush ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   int [ ] readIntArray ( int n ) { int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; }   long [ ] readLongArray ( int n ) { long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; }   String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } +","a , b = map ( int , input ( ) . split ( ) ) if a == b : print ( a ) else : print ( ""1"" ) NEW_LINE +" +E468,"import java . io . * ; import java . math . * ; import java . math . BigInteger ; import java . util . * ;   public class Main { static int bool [ ] [ ] = new int [ 3005 ] [ 3005 ] ; +","from sys import stdin , stdoutn = int ( input ( ) ) arr = [ ] d = dict ( ) for i in range ( n ) : x = tuple ( [ int ( x ) for x in stdin . readline ( ) . split ( ) ] ) d [ x ] = 1 arr . append ( x ) cnt = 0 for i in range ( n - 1 ) : for j in range ( i + 1 , n ) : sum1 = arr [ i ] [ 0 ] + arr [ j ] [ 0 ] sum2 = arr [ i ] [ 1 ] + arr [ j ] [ 1 ] if ( sum1 / 2 == sum1 // 2 ) and ( sum2 / 2 == sum2 // 2 ) : tup = ( sum1 // 2 , sum2 // 2 ) if d . get ( tup ) : cnt += 1 ; print ( cnt ) NEW_LINE +" +E469,"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B215 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) {   int tc = 1 ; +","import sys     def ints_input ( ) : return [ int ( i ) for i in sys . stdin . readline ( ) . strip ( "" \n "" ) . split ( "" ▁ "" ) ]     def print_list ( arr ) : sys . stdout . writelines ( str ( x ) + "" ▁ "" for x in arr ) sys . stdout . write ( "" \n "" )     def fast_input ( type = str ) : return type ( sys . stdin . readline ( ) . strip ( "" \n "" ) )     X = ints_input ( ) n , x = X [ 0 ] , X [ 1 : ] Y = ints_input ( ) m , y = Y [ 0 ] , Y [ 1 : ]   Z = ints_input ( ) p , z = Z [ 0 ] , Z [ 1 : ]   a , b = ints_input ( ) r2 = max ( x ) * ( b * max ( y ) / ( a * min ( z ) + b * max ( y ) ) ) ** 0.5 print ( r2 ) NEW_LINE +" +E470,"import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { +","def lower_bound ( arr , left , right , target ) : if arr [ right ] < target : return right + 1 while left < right : mid = ( left + right ) >> 1 if arr [ mid ] >= target : right = mid else : left = mid + 1 return left   T = int ( input ( ) ) arr = [ 0 ] * Tdp = [ 0 ] * ( T + 1 ) for i in range ( T ) : arr [ i ] = int ( input ( ) ) for i in range ( T ) : dp [ i + 1 ] = dp [ i ] + 20 dp [ i + 1 ] = min ( dp [ i + 1 ] , dp [ lower_bound ( arr , 0 , T - 1 , arr [ i ] - 89 ) ] + 50 ) dp [ i + 1 ] = min ( dp [ i + 1 ] , dp [ lower_bound ( arr , 0 , T - 1 , arr [ i ] - 1439 ) ] + 120 ) print ( dp [ i + 1 ] - dp [ i ] ) NEW_LINE +" +E471,"    import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ; import javafx . util . Pair ;   public class CodeForce { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringBuilder sb = new StringBuilder ( ) ;   static boolean flag = false ; static int next ( String [ ] sr , int ind ) { return Integer . parseInt ( sr [ ind ] ) ; }   public static void main ( String [ ] args ) throws IOException { String [ ] sr = br . readLine ( ) . split ( "" ▁ "" ) ; int n = next ( sr , 0 ) ; int m = next ( sr , 1 ) ; int [ ] [ ] arr = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { sr = br . readLine ( ) . split ( "" ▁ "" ) ; for ( int j = 0 ; j < m ; j ++ ) { arr [ i ] [ j ] = next ( sr , j ) ; } } long total = 0l ; for ( int i = 0 ; i < n ; i ++ ) { long count = 0 , count1 = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( arr [ i ] [ j ] == 0 ) count ++ ; else count1 ++ ; } total += ( long ) Math . pow ( 2 , count ) - count - 1 ; total += ( long ) Math . pow ( 2 , count1 ) - count1 - 1 ; } for ( int i = 0 ; i < m ; i ++ ) { long count = 0 , count1 = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] [ i ] == 0 ) count ++ ; else count1 ++ ; } total += ( long ) Math . pow ( 2 , count ) - count - 1 ; total += ( long ) Math . pow ( 2 , count1 ) - count1 - 1 ; } total += n * m ; System . out . println ( total ) ;   } }        +","import math as mtimport sys , stringfrom collections import Counter , defaultdictinput = sys . stdin . readline MOD = 1000000007 I = lambda : int ( input ( ) ) M = lambda : map ( int , input ( ) . split ( ) ) Ms = lambda : map ( str , input ( ) . split ( ) ) ARR = lambda : list ( map ( int , input ( ) . split ( ) ) ) def solve ( ) : n , m = M ( ) mat = [ ARR ( ) for _ in range ( n ) ]   setLengths = [ ] for i in range ( n ) : black , white = 0 , 0 for j in range ( m ) : if mat [ i ] [ j ] == 0 : black += 1 elif mat [ i ] [ j ] == 1 : white += 1 if white > 0 : setLengths . append ( white ) if black > 0 : setLengths . append ( black )   for j in range ( m ) : black , white = 0 , 0 for i in range ( n ) : if mat [ i ] [ j ] == 0 : black += 1 elif mat [ i ] [ j ] == 1 : white += 1 if white > 0 : setLengths . append ( white ) if black > 0 : setLengths . append ( black )   ans = n * m for e in setLengths : ans += ( 1 << e ) ans -= ( e + 1 ) print ( ans )     tc = 1 NEW_LINE +" +E472,"import java . util . * ;   public class Game { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; System . out . println ( arr [ ( arr . length - 1 ) / 2 ] ) ; } } +","n = int ( input ( ) ) print ( sorted ( map ( int , input ( ) . split ( ) ) ) [ ( n - 1 ) // 2 ] ) NEW_LINE +" +E473,"import java . util . * ; import java . io . * ; public class Message { public static void main ( String [ ] args ) throws Exception { +","import java . util . * ;   public class aerg {   static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String s = in . next ( ) ; String u = in . next ( ) ; int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i + + ) { for ( int j = 0 ; j < u . length ( ) ; j + + ) { int k = 0 ; if ( s . charAt ( i ) == u . charAt ( j ) ) { k + + ; for ( int z = j + 1 , t = i + 1 ; z < u . length ( ) & & t < s . length ( ) ; z + + , t + + ) { if ( s . charAt ( t ) == u . charAt ( z ) ) { k + + ; } } // System . out . println ( i + "" ▁ "" + k ) ; } ans = Math . max ( ans , k ) ; } if ( ans > s . length ( ) - i ) break ; } // System . out . println ( u . length ( ) ) ; System . out . println ( u . length ( ) - ans ) ; } } NEW_LINE +" +E474,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ;   public class kaka {   public static void main ( String [ ] args ) throws IOException { BufferedReader s = new BufferedReader ( new InputStreamReader ( System . in ) ) ; ArrayList < String > strs = new ArrayList < > ( ) ; while ( true ) { String line = s . readLine ( ) ; if ( line == null ) { break ; } strs . add ( line ) ; } ArrayList < String > res = new ArrayList < > ( ) ; StringBuffer comp = new StringBuffer ( ) ; boolean agaramp = true ; for ( int i = 0 ; i < strs . size ( ) ; i ++ ) { String l = strs . get ( i ) ; int len = l . length ( ) ; boolean nonspace = false ; boolean foundhash = false ; for ( int j = 0 ; j < len ; j ++ ) { if ( l . charAt ( j ) == ' # ' ) { foundhash = true ; break ; } else if ( l . charAt ( j ) != ' ▁ ' ) { nonspace = true ; } } if ( ! nonspace && foundhash ) { if ( ! agaramp ) { if ( comp . length ( ) >= 1 ) { res . add ( comp . toString ( ) ) ; comp = new StringBuffer ( ) ; } else { res . add ( "" "" ) ; } } agaramp = true ; res . add ( l ) ; } else { agaramp = false ; for ( int j = 0 ; j < len ; j ++ ) { if ( l . charAt ( j ) != ' ▁ ' ) { comp . append ( l . charAt ( j ) ) ; } } } } if ( ! agaramp ) { if ( comp . length ( ) >= 1 ) { res . add ( comp . toString ( ) ) ; } else { res . add ( "" "" ) ; } }   for ( String line : res ) { System . out . println ( line ) ; } } } +","import syskek = "" "" bol = 1 for s in sys . stdin : ok = 0 for i in range ( len ( s ) ) : if s [ i ] == ' ▁ ' : continue if s [ i ] == ' # ' : ok = 1 else : ok = 0 break kekw = ( bol == 0 and ok == 0 ) for j in range ( len ( kek ) - kekw ) : if bol == 1 or kek [ j ] != ' ▁ ' : sys . stdout . write ( kek [ j ] ) kek = s bol = ok   for j in range ( len ( kek ) ) : if bol == 1 or kek [ j ] != ' ▁ ' : sys . stdout . write ( kek [ j ] ) NEW_LINE +" +E475,"import java . io . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; +","from sys import stdin , stdout n , m , k = map ( int , input ( ) . split ( ) ) l = [ [ 0 ] * m ] * n for i in range ( n ) : l [ i ] = list ( map ( int , stdin . readline ( ) . split ( ) ) ) t = [ [ 0 ] * 2 ] * ke = [ 0 ] * nc = [ 0 ] * m for i in range ( k ) : t0 , t1 = map ( int , stdin . readline ( ) . split ( ) ) e [ t0 - 1 ] -= 1 c [ t1 - 1 ] += 1 p = [ "" "" ] * nfor i in range ( n ) : for j in range ( m ) : e [ i ] = e [ i ] + c [ j ] * l [ i ] [ j ] p [ i ] = str ( e [ i ] ) stdout . write ( "" ▁ "" . join ( p ) ) NEW_LINE +" +E476,"import java . io . * ; import java . util . * ; import java . math . * ;      public class spoj { InputStream is ; static PrintWriter out ; static int dp [ ] = new int [ 10001 ] ; static int solver ( int left , int c , int d , int n ) { if ( left <= 0 ) return 0 ; if ( dp [ left ] != - 1 ) return dp [ left ] ; return dp [ left ] = Math . min ( c + solver ( left - n , c , d , n ) , d + solver ( left - 1 , c , d , n ) ) ; } void solve ( ) { int c = ni ( ) , d = ni ( ) ; int n = ni ( ) , m = ni ( ) ; Arrays . fill ( dp , - 1 ) ; int k = ni ( ) ; int left = n * m - k ; out . println ( solver ( left , c , d , n ) ) ; } +","c , d = [ int ( i ) for i in input ( ) . split ( "" ▁ "" ) ] n , m = [ int ( i ) for i in input ( ) . split ( "" ▁ "" ) ] k = int ( input ( ) )   s = n * m - ks = max ( s , 0 )   if c < d * n : stuff = s // n try1 = c * stuff + d * ( s - n * stuff ) try2 = c * ( stuff + 1 ) print ( min ( try1 , try2 ) ) else : print ( d * s ) NEW_LINE +" +E477,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; +","a , b = map ( int , input ( ) . split ( ) )   s = input ( )   obs = b * ' # ' if obs in s : print ( "" NO "" ) else : print ( "" YES "" ) NEW_LINE +" +E478,"import java . util . Scanner ; public class Cp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; +","na , ma = map ( int , input ( ) . split ( ) ) a = [ list ( map ( int , input ( ) ) ) for _ in range ( na ) ] nb , mb = map ( int , input ( ) . split ( ) ) b = [ list ( map ( int , input ( ) ) ) for _ in range ( nb ) ]   best = 0 points = ( 0 , 0 ) for x in range ( - 50 , 51 ) : for y in range ( - 50 , 51 ) : ct = 0 for i in range ( na ) : if x + i < 0 : continue if x + i >= nb : break for j in range ( ma ) : if y + j < 0 : continue if y + j >= mb : break ct += a [ i ] [ j ] * b [ i + x ] [ j + y ] if ct >= best : best = ct points = ( x , y ) print ( points [ 0 ] , points [ 1 ] ) NEW_LINE +" +E479,"import java . io . * ; import java . util . * ;   public class P1 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ n - k ] ) ; } } +","n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) print ( l [ ( - 1 ) * m ] ) NEW_LINE +" +E480,"import java . util . * ; public class Main { public static void main ( String [ ] args ) { long n1 , bx , n2 , by , temp ; long x = 0 , y = 0 ; Scanner sc = new Scanner ( System . in ) ; n1 = sc . nextInt ( ) ; bx = sc . nextInt ( ) ; while ( n1 != 0 ) { n1 -- ; temp = sc . nextInt ( ) ; x = x * bx + temp ; } n2 = sc . nextInt ( ) ; by = sc . nextInt ( ) ; while ( n2 != 0 ) { n2 -- ; temp = sc . nextInt ( ) ; y = y * by + temp ; } if ( x > y ) System . out . print ( "" > "" ) ; else if ( x < y ) System . out . print ( "" < "" ) ; else System . out . print ( "" = "" ) ; } }   +","n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) first = int ( 0 ) second = int ( 0 ) now = int ( 1 ) for i in range ( len ( l ) - 1 , - 1 , - 1 ) : first = first + now * l [ i ] now = now * m   n1 , m1 = map ( int , input ( ) . split ( ) ) l1 = list ( map ( int , input ( ) . split ( ) ) )   now = 1 for i in range ( len ( l1 ) - 1 , - 1 , - 1 ) : second = second + now * l1 [ i ] now = now * m1   if second == first : print ( ' = ' ) elif second > first : print ( ' < ' ) else : print ( ' > ' ) NEW_LINE +" +E481,"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int maxN = ( int ) 1e6 ; +","l = int ( input ( ) ) a = [ int ( bruh ) for bruh in input ( ) . split ( ) ]   a1 = sorted ( a )   cnt = 0 for x in range ( l ) : if a [ x ] != a1 [ x ] : cnt += 1   if cnt <= 2 : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E482,"n = int ( input ( ) ) stones = list ( map ( lambda t : int ( t ) , input ( ) . split ( ) ) ) q = int ( input ( ) ) queries = list ( map ( lambda t : int ( t ) , input ( ) . split ( ) ) )   stones . sort ( )   added_stones = [ ] added_stones . append ( stones [ 0 ] ) for i in range ( 1 , n , 1 ) : added_stones . append ( stones [ i ] + added_stones [ i - 1 ] )   computed_queries = { }   for qidx , qq in enumerate ( queries ) : if qq in computed_queries : queries [ qidx ] = computed_queries [ qq ] continue   i = n - 2 multiplier = 1 cost = 0 while i >= 0 : pp = pow ( qq , multiplier ) nexti = i - pp if nexti < 0 : cost += added_stones [ i ] * multiplier break cost += ( added_stones [ i ] - added_stones [ nexti ] ) * multiplier multiplier += 1 i = nexti queries [ qidx ] = cost computed_queries [ qq ] = cost   print ( * queries , sep = ' ▁ ' ) +","class CodeforcesTask226BSolution : def __init__ ( self ) : self . result = ' ' self . n = 0 self . piles = [ ] self . q = 0 self . variants = [ ]   def read_input ( self ) : self . n = int ( input ( ) ) self . piles = [ int ( x ) for x in input ( ) . split ( "" ▁ "" ) ] self . q = int ( input ( ) ) self . variants = [ int ( x ) for x in input ( ) . split ( "" ▁ "" ) ]   def process_task ( self ) : self . piles . sort ( reverse = True ) sums = [ 0 ] * self . n sums [ 0 ] = self . piles [ 0 ] for x in range ( self . n - 1 ) : sums [ x + 1 ] = self . piles [ x + 1 ] + sums [ x ] anwsers = { } results = [ ] for query in self . variants : if query in anwsers . keys ( ) : results . append ( anwsers [ query ] ) else : anwser = 0 factor = 1 k = 1 width = query x = 1 while x + width < self . n : anwser += ( sums [ x + width - 1 ] - sums [ x - 1 ] ) * factor factor += 1 x += width k += 1 width = query ** k anwser += ( sums [ - 1 ] - sums [ x - 1 ] ) * factor results . append ( anwser ) anwsers [ query ] = anwser self . result = "" ▁ "" . join ( [ str ( x ) for x in results ] )   def get_result ( self ) : return self . result     if __name__ == "" _ _ main _ _ "" : Solution = CodeforcesTask226BSolution ( ) Solution . read_input ( ) Solution . process_task ( ) print ( Solution . get_result ( ) ) NEW_LINE +" +E483,"import java . util . * ;   public class Unary_B {   public static void main ( String [ ] args ) { +","def binaryToDecimal ( n ) : return int ( n , 2 ) s = input ( ) s = s . replace ( "" > "" , ""1000"" ) s = s . replace ( "" < "" , ""1001"" ) s = s . replace ( "" + "" , ""1010"" ) s = s . replace ( "" - "" , ""1011"" ) s = s . replace ( "" . "" , ""1100"" ) s = s . replace ( "" , "" , ""1101"" ) s = s . replace ( "" [ "" , ""1110"" ) s = s . replace ( "" ] "" , ""1111"" ) p = binaryToDecimal ( s ) ans = p % ( ( 10 ** 6 ) + 3 ) print ( ans ) NEW_LINE +" +E484,"import java . io . * ; import java . util . * ;   public class Main { public static void main ( String args [ ] ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int M [ ] = new int [ 20 ] ; int R [ ] = new int [ 20 ] ; for ( int i = 0 ; i < n ; ++ i ) M [ i ] = input . nextInt ( ) ; for ( int i = 0 ; i < n ; ++ i ) R [ i ] = input . nextInt ( ) ; int range = 720720 , cnt = 0 ; for ( int x = 0 ; x < range ; ++ x ) { int bj = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( x % M [ i ] == R [ i ] ) { bj = 1 ; break ; } if ( bj == 1 ) cnt ++ ; } System . out . printf ( "" % .6f \n "" , ( double ) cnt / range ) ; } } +","def gcd ( a , b ) : a , b = max ( a , b ) , min ( a , b ) while a % b != 0 : a %= b a , b = b , a return b   def gsd ( a , b ) : return a * b // gcd ( a , b )   n = int ( input ( ) ) m = list ( map ( int , input ( ) . split ( ) ) ) r = list ( map ( int , input ( ) . split ( ) ) ) x = m [ 0 ] for i in range ( 1 , n ) : x = gsd ( x , m [ i ] ) count = 0 for i in range ( x ) : for j in range ( n ) : if i % m [ j ] == r [ j ] : count += 1 breakprint ( count / x ) NEW_LINE +" +E485,"import java . util . Scanner ;   public class A644 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int R = in . nextInt ( ) ; int C = in . nextInt ( ) ; if ( N > R * C ) { System . out . println ( "" - 1"" ) ; } else { int [ ] [ ] A = new int [ R ] [ C ] ; for ( int n = 0 ; n < N ; n ++ ) { int r = n / C ; int c = n % C ; if ( r % 2 != 0 ) { c = C - 1 - c ; } A [ r ] [ c ] = n + 1 ; } StringBuilder output = new StringBuilder ( ) ; for ( int r = 0 ; r < R ; r ++ ) { for ( int c = 0 ; c < C ; c ++ ) { output . append ( A [ r ] [ c ] ) . append ( ' ▁ ' ) ; } output . append ( ' \n ' ) ; } System . out . print ( output ) ; } }   } +","n , a , b = map ( int , input ( ) . split ( ) ) if n > a * b : print ( - 1 ) else : arr = [ [ 0 ] * b for _ in range ( a ) ] x = 1 y = 2   for i in range ( a ) : for j in range ( b ) :   if ( i + j ) % 2 == 0 : if x <= n : arr [ i ] [ j ] = x x += 2 else : if y <= n : arr [ i ] [ j ] = y y += 2 NEW_LINE +" +E486,"import java . util . * ;   public class Example { static long [ ] [ ] dp ; +","s = input ( ) t = input ( ) v = [ ' a ' , ' e ' , ' i ' , ' o ' , ' u ' ] if len ( s ) == len ( t ) : for i in range ( len ( s if len ( s ) < len ( t ) else t ) ) : if s [ i ] in v and t [ i ] in v : continue elif s [ i ] in v or t [ i ] in v : print ( "" NO "" ) exit ( ) else : continue print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE +" +E487,"import java . io . * ; import java . util . * ;   public class a { static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ; public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; } public String next ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ; +","import sysinput = sys . stdin . readlinefrom collections import defaultdict as dcfrom collections import Counterfrom bisect import bisect_right , bisect_leftimport mathfrom operator import itemgetterfrom heapq import heapify , heappop , heappushfrom queue import PriorityQueue as pqfor _ in range ( int ( input ( ) ) ) : n , d = map ( int , input ( ) . split ( ) ) f = 0 s = math . ceil ( math . sqrt ( d ) ) i = s while ( i > 0 and f == 0 ) : if i + math . ceil ( d / ( i + 1 ) ) <= n : f = 1 break i -= 1 if f or d <= n : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E488,"import java . lang . * ; import java . util . * ; import java . io . * ; public class Codechef {   public void solve ( ) throws IOException { FastScanner fs = new FastScanner ( ) ; StringBuilder ans = new StringBuilder ( "" "" ) ; +","  n = int ( input ( ) ) lis = list ( map ( int , input ( ) . split ( ) ) ) m = int ( input ( ) ) edges = [ ] for d in range ( m ) : edges . append ( list ( map ( int , input ( ) . split ( ) ) ) ) edges . sort ( key = lambda x : x [ 2 ] ) visited = [ ] count = 0 for i in range ( m ) : if edges [ i ] [ 1 ] not in visited : visited . append ( edges [ i ] [ 1 ] ) count += edges [ i ] [ 2 ]   if len ( visited ) == n - 1 : print ( count ) else : print ( - 1 ) NEW_LINE +" +E489,"import java . util . Scanner ;   public class Codeforces {   public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ;   +","Into = str ( input ( ) ) NEW_LINE Into = list ( Into ) NEW_LINE hello = [ ' h ' , ' e ' , ' l ' , ' l ' , ' o ' ] NEW_LINE cur = 0 l NEW_LINE ist1 = [ ] NEW_LINE for i in Into : if NEW_LINE i == hello [ cur ] : list1 . append ( i ) NEW_LINE cur += 1 NEW_LINE if len ( list1 ) == 5 : breakif NEW_LINE list1 == hello : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE +" +E490,"import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } Arrays . sort ( a ) ; int i = n - 1 ; int count = 0 ; while ( m > 0 ) { count ++ ; m -= a [ i ] ; i -- ; } System . out . println ( count ) ; } } +","n = int ( input ( ) ) m = int ( input ( ) ) l = [ ] for i in range ( n ) : l . append ( int ( input ( ) ) ) l . sort ( reverse = True ) s = 0 for i in range ( n ) : s += l [ i ] if s >= m : print ( i + 1 ) break NEW_LINE +" +E491,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class RomaAndChangingSigns {   public static void main ( String [ ] args ) { FastReader reader = new FastReader ( ) ;   int n = reader . nextInt ( ) ; int k = reader . nextInt ( ) ; int ed = n - 1 , st = 0 ; int a [ ] = new int [ n ] ; long sum = 0 ;   for ( int i = 0 ; i < n ; i ++ ) a [ i ] = reader . nextInt ( ) ;   while ( st < ed ) { if ( a [ st ] < 0 && Math . abs ( a [ st ] ) >= a [ ed ] && k > 0 ) { k -- ; sum += Math . abs ( a [ st ++ ] ) ; } else { sum += a [ ed -- ] ; } }   for ( int i = st ; i <= ed ; i ++ ) { sum += a [ i ] ; }   if ( k > 0 ) { sum -= a [ ed ] ; sum += ( k % 2 == 0 ) ? a [ ed ] : a [ ed ] * - 1 ; } System . out . println ( sum ) ; }   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } +","n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) i = 0 while i < n and k > 0 and a [ i ] < 0 : a [ i ] = - 1 * a [ i ] i += 1 k -= 1 a = sorted ( a ) if k % 2 == 1 : a [ 0 ] = - 1 * a [ 0 ] print ( sum ( a ) ) NEW_LINE +" +E492,"import java . util . Scanner ;   public class Hate_A {   public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ;   int x = in . nextInt ( ) ; in . nextLine ( ) ; String s = in . nextLine ( ) ;   char ch [ ] = s . toCharArray ( ) ; int countS = 0 ; int countF = 0 ; for ( int i = 1 ; i < x ; i ++ ) { if ( ch [ i - 1 ] != ch [ i ] ) { if ( ch [ i ] == ' F ' ) { countF ++ ; } else { countS ++ ; } } } System . out . println ( ( countF > countS && countF != 0 ) ? "" YES "" : "" NO "" ) ;   } } +","n = int ( input ( ) ) S = input ( ) A = S . count ( "" SF "" ) B = S . count ( "" FS "" ) if A > B : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E493,"import java . io . * ;   public class Main { static int n ; static String str ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( new FileInputStream ( "" input . txt "" ) ) ) ; bw = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( "" output . txt "" ) ) ) ; n = Integer . parseInt ( br . readLine ( ) ) ; str = br . readLine ( ) ; int i = 0 ; while ( i < n && str . charAt ( i ) == '0' ) { ++ i ; } int k = 0 ; boolean flag = true ; for ( int j = i + 1 ; j < n ; ++ j ) { if ( str . charAt ( j ) == '1' ) { if ( k == 0 ) { k = j - i ; } else if ( k != j - i ) { flag = false ; break ; } i = j ; } } bw . write ( flag ? "" YES "" : "" NO "" ) ; bw . close ( ) ; } } +","with open ( ' input . txt ' , ' r ' ) as f : fs = f . read ( ) . strip ( ) . split ( ' \n ' )   n = [ int ( i ) for i in fs [ 1 ] ] c = - 1 i , ans = 0 , "" YES "" while i < len ( n ) : if n [ i ] == 1 : count = 0 while i + 1 < len ( n ) : if n [ i + 1 ] == 1 : break count += 1 i += 1 else : count = c if c == - 1 : c = count elif c != count : ans = "" NO "" break i += 1   with open ( ' output . txt ' , ' w ' ) as f : f . write ( ans ) NEW_LINE +" +E494,"import java . util . * ;   public class AutomaticDoor {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long n = scan . nextLong ( ) ; int m = scan . nextInt ( ) ; long a = scan . nextLong ( ) ; long d = scan . nextLong ( ) ; long [ ] arr = new long [ m ] ; for ( int i = 0 ; i < m ; i ++ ) arr [ i ] = scan . nextLong ( ) ; int count = 0 ; long time = 0 ; long x = d / a + 1 ; long y = d - ( x - 1 ) * a ; if ( y < 0 ) y = 0 ; long last = 0 ; for ( int i = 0 ; i < m ; ) { long b = Math . max ( Math . min ( ( arr [ i ] - 1 ) / a , n ) , 0 ) ; long c = b - time ; long k = c / x ; count += k ; time += k * x ; if ( k != 0 ) { while ( i < m && arr [ i ] <= time * a + y ) { i ++ ; } } if ( i >= m ) break ; count ++ ; last = arr [ i ] + d ; if ( time < n ) last = Math . min ( last , ( time + 1 ) * a + d ) ; while ( i < m && arr [ i ] <= last ) i ++ ; time = Math . max ( time , Math . min ( n , last / a ) ) ; } if ( time < n ) { count += ( n - time + x - 1 ) / x ; } System . out . println ( count ) ; } } +","BigNum = 10 ** 20   n , m , a , d = map ( int , input ( ) . split ( ' ▁ ' ) ) ts = [ 0 ] + list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) + [ BigNum ]   def empsInRange ( l , r ) : em1 = l // a + 1 em2 = r // a return ( em1 , min ( em2 , n ) )   empDoorGroup = d // a + 1   def moveEmps ( emps , last ) : em1 , em2 = emps if em1 > em2 : return last , 0 if em1 * a <= last + d : gr1 = ( last + d - em1 * a ) // a em1 += 1 + gr1 if em1 > em2 : return last , 0   doorGroups = ( em2 - em1 + 1 + empDoorGroup - 1 ) // empDoorGroup last = ( em1 + empDoorGroup * ( doorGroups - 1 ) ) * a   return last , doorGroups   res = 0 last = - BigNum   for i in range ( 1 , len ( ts ) ) : NEW_LINE +" +E495,"import java . util . * ;   public class Example { static int [ ] dp ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; int [ ] [ ] arr = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] [ 0 ] = sc . nextInt ( ) ; arr [ i ] [ 1 ] = sc . nextInt ( ) ;   } int [ ] fi = new int [ n ] ; fi [ 0 ] = Math . max ( arr [ 0 ] [ 1 ] , arr [ 0 ] [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( Math . max ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) <= fi [ i - 1 ] ) { fi [ i ] = Math . max ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } else { fi [ i ] = Math . min ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( fi [ i + 1 ] > fi [ i ] ) { System . out . println ( "" NO "" ) ; return ;   } } System . out . println ( "" YES "" ) ;    }    }     +","n = int ( input ( ) ) ans = "" YES "" num = 0 for i in range ( n ) : w , h = map ( int , input ( ) . split ( ) ) if i == 0 : num = max ( w , h ) else : if max ( w , h ) <= num : num = max ( w , h ) elif min ( w , h ) <= num : num = min ( w , h ) else : ans = "" NO "" print ( ans ) NEW_LINE +" +E496,"  import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; long n = sc . nextLong ( ) ; int m = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; long p [ ] = new long [ m ] ; for ( int i = 0 ; i < m ; i ++ ) p [ i ] = sc . nextLong ( ) ; int cnt = 0 ; int special = 0 ; for ( int i = 0 ; i < m ; i ++ ) { +","n , m , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans , result = 0 , 0 page , new_result = None , 1 for i in range ( m ) : if ( a [ i ] - result ) // k != page : ans += 1 result = new_result page = ( a [ i ] - result ) // k new_result += 1 print ( ans ) NEW_LINE +" +E497,"import java . util . Scanner ; public class B { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; String s = in . next ( ) ; System . out . println ( result ( n , k , s ) ) ; } } private static int result ( int n , int k , String s ) { int firstIndex = s . indexOf ( ' * ' ) ; int lastIndex = s . lastIndexOf ( ' * ' ) ; if ( firstIndex == lastIndex ) { return 1 ; } int res = 2 ; while ( firstIndex != lastIndex ) { int middleIndex = firstIndex + k ; if ( middleIndex >= lastIndex ) { return res ; } while ( s . charAt ( middleIndex ) != ' * ' ) { middleIndex -- ; } res ++ ; firstIndex = middleIndex ; } return res ; } } +","import math NEW_LINE cases = int ( input ( ) ) NEW_LINE for c in range ( cases ) : NEW_LINE INDENT length , k = map ( int , input ( ) . split ( ) ) NEW_LINE string = input ( ) NEW_LINE start = string . index ( ' * ' ) NEW_LINE end = length - 1 - string [ : : - 1 ] . index ( ' * ' ) NEW_LINE count = 1 NEW_LINE while start < end : NEW_LINE INDENT ind = start + k NEW_LINE if ind >= end : NEW_LINE INDENT count += 1 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT while ind > start : NEW_LINE INDENT if string [ ind ] == ' * ' : NEW_LINE INDENT count += 1 NEW_LINE break NEW_LINE DEDENT ind -= 1 NEW_LINE DEDENT DEDENT start = ind NEW_LINE DEDENT print ( count ) NEW_LINE DEDENT +" +E498,"import java . util . * ; public class Main { static int vis [ ] = new int [ 1000 ] ; public static void main ( String args [ ] ) { Scanner input = new Scanner ( System . in ) ; int n , A , B , C , T ; n = input . nextInt ( ) ; A = input . nextInt ( ) ; B = input . nextInt ( ) ; C = input . nextInt ( ) ; T = input . nextInt ( ) ; for ( int i = 1 ; i <= T ; i ++ ) vis [ i ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int x = input . nextInt ( ) ; vis [ x ] ++ ; } if ( C <= B ) { System . out . println ( n * A ) ; } else { int get = n * A ; int cost = 0 ; int num = 0 ; for ( int i = 1 ; i <= T ; i ++ ) { get += num * C ; cost -= num * B ; num += vis [ i ] ; } System . out . println ( get + cost ) ; } } }   +","n , a , b , c , T = map ( int , input ( ) . split ( ) ) ts = list ( map ( int , input ( ) . split ( ) ) ) ts . sort ( ) ans = 0 for t in ts : temp = - 10 ** 18 for u in range ( t , T + 1 ) : temp = max ( temp , c * ( u - t ) + a - b * ( u - t ) ) NEW_LINE +" +E499,"import java . util . * ;   public class Main {   public static int solution ( int [ ] games , ArrayList < Set < Integer > > dep , int position , Set < Integer > completed , int left ) { int completedThisComp = 0 ;   boolean taken = true ; while ( taken ) { taken = false ; for ( int i = 0 ; i < games . length ; i ++ ) { if ( completed . contains ( i ) ) continue ;   if ( games [ i ] != position ) continue ;   boolean canComplete = true ; for ( Integer d : dep . get ( i ) ) { if ( completed . contains ( d ) ) continue ; canComplete = false ; }   if ( canComplete ) { taken = true ; completed . add ( i ) ; completedThisComp += 1 ; } } }   if ( completedThisComp == left ) return 0 ;   if ( position == 0 ) { return 1 + solution ( games , dep , 1 , completed , left - completedThisComp ) ; } if ( position == 1 ) { return 1 + solution ( games , dep , 2 , completed , left - completedThisComp ) ; }   return 1 + solution ( games , dep , 0 , completed , left - completedThisComp ) ; } +","f = lambda : [ int ( q ) - 1 for q in input ( ) . split ( ) ] def g ( ) : for i in p : if h [ i ] == k and not v [ i ] : return i   r = range ( int ( input ( ) ) ) t , h = 1e9 , f ( ) u = [ set ( f ( ) [ 1 : ] ) for i in r ]   for k in ( 0 , 1 , 2 ) : p = list ( r ) d = - 1 v = [ q . copy ( ) for q in u ]   while p : i = g ( ) while i != None : d += 1 p . remove ( i ) for q in v : q . discard ( i ) i = g ( ) k = ( k + 1 ) % 3 d += 1   t = min ( d , t )   print ( t ) NEW_LINE +" +E500,"import java . util . Scanner ;   public class Solution { public static String solve ( String sentence ) { String [ ] words = sentence . split ( "" ▁ "" ) ; int gender = - 1 ; boolean noun = false , vers = false ; if ( words . length == 0 ) return "" NO "" ; int firstCode = encode ( words [ 0 ] ) ; if ( firstCode == - 1 ) return "" NO "" ; if ( words . length == 1 ) return "" YES "" ; noun = firstCode / 2 == 1 ; vers = firstCode / 2 == 2 ; gender = firstCode % 2 ; for ( int i = 1 ; i < words . length ; i ++ ) { int code = encode ( words [ i ] ) ; if ( code % 2 != gender || code == - 1 ) return "" NO "" ; if ( code / 2 < 2 && vers ) return "" NO "" ; if ( noun ) { if ( code / 2 == 0 || code / 2 == 1 ) return "" NO "" ; vers = true ; } else { if ( code / 2 == 2 ) return "" NO "" ; if ( code / 2 == 1 ) noun = true ; } } return noun ? "" YES "" : "" NO "" ; } private static int encode ( String word ) { if ( word . endsWith ( "" lios "" ) ) { return 0 ; } else if ( word . endsWith ( "" liala "" ) ) { return 1 ; } else if ( word . endsWith ( "" etr "" ) ) { return 2 ; } else if ( word . endsWith ( "" etra "" ) ) { return 3 ; } else if ( word . endsWith ( "" initis "" ) ) { return 4 ; } else if ( word . endsWith ( "" inites "" ) ) { return 5 ; } else { return - 1 ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; System . out . println ( solve ( str ) ) ;   } } +","def cc ( w , me , fe ) : global m , f if w . endswith ( me ) : m = True return True elif w . endswith ( fe ) : f = True return True else : return Falsedef ad ( w ) : return cc ( w , ' lios ' , ' liala ' ) def nn ( w ) : return cc ( w , ' etr ' , ' etra ' ) def vb ( w ) : return cc ( w , ' initis ' , ' inites ' ) s , n , m , f = input ( ) . split ( ) , False , False , False for w in s : if not n : if ad ( w ) or vb ( w ) and len ( s ) == 1 : pass elif nn ( w ) : n = True else : print ( "" NO "" ) exit ( ) elif not vb ( w ) : print ( "" NO "" ) exit ( ) print ( ' YES ' if len ( s ) == 1 or ( n and ( m ^ f ) ) else ' NO ' ) NEW_LINE +" +E501,"import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ;   public class Anton_and_Letters { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; s = s . replace ( "" { "" , "" "" ) ; s = s . replace ( "" } "" , "" "" ) ; s = s . replaceAll ( "" , ▁ "" , "" "" ) ; s = s . trim ( ) ; Set < Character > characterSet = new LinkedHashSet < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { characterSet . add ( s . charAt ( i ) ) ; } System . out . println ( characterSet . size ( ) ) ; } } +","letters = list ( map ( str , input ( ) ) ) c = set ( ) for letter in letters : if letter . isalpha ( ) : c . add ( letter ) print ( len ( c ) ) NEW_LINE +" +E502,"import java . util . Scanner ;   public class MeetOldFriend { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; long l1 = in . nextLong ( ) , r1 = in . nextLong ( ) , l2 = in . nextLong ( ) , r2 = in . nextLong ( ) , k = in . nextLong ( ) , l = Math . max ( l1 , l2 ) , r = Math . min ( r1 , r2 ) ;   in . close ( ) ; System . out . println ( l <= r ? k >= l && k <= r ? r - l : r - l + 1 : 0 ) ; } } +","if __name__ == "" _ _ main _ _ "" : a , b , c , d , k = map ( int , input ( ) . split ( ) ) start = max ( a , c ) end = min ( b , d ) ans = end - start if ans < 0 : ans = 0 elif k < start or k > end : ans = ans + 1 print ( ans ) NEW_LINE +" +E503,"import java . io . * ; import java . util . * ;   public class a { public static void main ( String [ ] args ) throws IOException { FastReader scan = new FastReader ( ) ; +","def main ( ) : start , end , t = map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) people = [ ] if n != 0 : people = list ( map ( int , input ( ) . split ( ) ) ) time = start ans = 1e16 answer = 0 for p in people : if p + t > end : break if p - 1 >= 0 : if ans > max ( 0 , time - ( p - 1 ) ) : ans = max ( 0 , time - ( p - 1 ) ) answer = p - 1   time = max ( time , p ) + t   if time + t > end : break   if time + t <= end : answer = time print ( answer )   main ( ) NEW_LINE +" +E504,"import java . util . Scanner ;     public class Boredom { public static void main ( final String [ ] parameters ) { Scanner input = new Scanner ( System . in ) ;   String string = input . next ( ) ; String result = "" NO "" ; boolean foundAB = false ; boolean foundBA = false ;   for ( int index = 1 ; index < string . length ( ) ; index ++ ) { if ( ! foundAB && string . charAt ( index ) == ' B ' && string . charAt ( index - 1 ) == ' A ' ) { foundAB = true ; index ++ ; } else if ( foundAB && string . charAt ( index ) == ' A ' && string . charAt ( index - 1 ) == ' B ' ) { result = "" YES "" ; break ; } }   if ( ! result . equals ( "" YES "" ) ) { for ( int index = 1 ; index < string . length ( ) ; index ++ ) { if ( ! foundBA && string . charAt ( index ) == ' A ' && string . charAt ( index - 1 ) == ' B ' ) { foundBA = true ; index ++ ; } else if ( foundBA && string . charAt ( index ) == ' B ' && string . charAt ( index - 1 ) == ' A ' ) { result = "" YES "" ; break ; } } }   System . out . println ( result ) ; } } +","s = input ( ) if ( s . find ( "" AB "" ) != - 1 and s . find ( "" BA "" ) != - 1 and ( s . find ( "" AB "" ) + 1 < s . rfind ( "" BA "" ) or s . find ( "" BA "" ) + 1 < s . rfind ( "" AB "" ) ) ) : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E505,"import java . util . Scanner ;   public class LightOnNight { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int n = scan . nextInt ( ) * scan . nextInt ( ) ; int count = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { int sum = scan . nextInt ( ) + scan . nextInt ( ) ;   if ( sum > 0 ) count ++ ; } System . out . println ( count ) ; } } +","c = 0 for i in range ( int ( input ( ) . split ( ) [ 0 ] ) ) : a = input ( ) . split ( ) while len ( a ) : if '1' in [ a . pop ( ) , a . pop ( ) ] : c += 1 print ( c ) NEW_LINE +" +E506,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int ans = ( n / 2 ) * 3 ; System . out . println ( ans ) ;   } } +","n = int ( input ( ) ) NEW_LINE print ( n // 2 * 3 ) NEW_LINE +" +E507,"import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = 0 ; while ( n / 10 > 0 ) { while ( n > 0 ) { s = s + n % 10 ; n = n / 10 ; } n = s ; s = 0 ; } System . out . println ( n ) ; } } +","print ( ( int ( input ( ) ) - 1 ) % 9 + 1 ) NEW_LINE +" +E508,"import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ;   int squareSide = Math . max ( Math . max ( a , b ) , 2 * Math . min ( a , b ) ) ; System . out . println ( squareSide * squareSide ) ; } }    }      +","a = int ( input ( ) ) for i in range ( a ) : c , d = map ( int , input ( ) . split ( ) ) c , d = min ( c , d ) , max ( c , d ) if ( 2 * c > d ) : print ( 2 * 2 * c * c ) else : print ( d * d ) NEW_LINE +" +E509,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;    public class winner {   static class Fs { private BufferedReader reader ; private StringTokenizer stt ; public Fs ( ) { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { return null ; } } public String nextString ( ) { while ( stt == null || ! stt . hasMoreTokens ( ) ) { stt = new StringTokenizer ( nextLine ( ) ) ; } return stt . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextString ( ) ) ; } }   static Fs scan = new Fs ( ) ;   public static void main ( String [ ] args ) { int n = scan . nextInt ( ) ; long arr [ ] = new long [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = scan . nextInt ( ) ; arr [ x ] = i ; } long Lside = 0 ; long Rside = 0 ; int x = scan . nextInt ( ) ; for ( int i = 0 ; i < x ; i ++ ) { int num = scan . nextInt ( ) ; long index = arr [ num ] + 1 ; Lside += index ; Rside += ( n - index ) + 1 ; } System . out . print ( Lside + "" ▁ "" + Rside ) ;   }   } +","n = int ( input ( ) )   a = [ int ( i ) for i in input ( ) . split ( ' ▁ ' ) ]   m = int ( input ( ) ) b = [ int ( i ) for i in input ( ) . split ( ' ▁ ' ) ]     store = { } vasya , petya = 0 , 0   max_stored = 0   for bi in b :   if bi not in store :   i = max_stored while bi not in store : store [ a [ i ] ] = ( i + 1 , n - i ) i += 1 max_stored = i vasya += store [ bi ] [ 0 ] petya += store [ bi ] [ 1 ]   print ( vasya , petya ) NEW_LINE +" +E510,"import java . util . * ; import java . io . * ; public class Solution { public static void main ( String [ ] args ) throws IOException { +","n = int ( input ( ) ) b = [ 0 ] * 26 result = 0 for i in range ( n ) : s = input ( ) b [ ord ( s [ 0 ] ) - 97 ] += 1 for i in b : result += ( ( i // 2 ) * ( i // 2 - 1 ) ) // 2 result += ( ( i - i // 2 ) * ( i - i // 2 - 1 ) ) // 2 print ( result ) NEW_LINE +" +E511,"import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static FileWriter fw ; static long oo = Long . MAX_VALUE ; +","def find_company ( friends , d ) :   def mergesort_tuples ( tuples , index ) :   def merge ( A , B ) : i , j = 0 , 0 result = [ ] while i < len ( A ) and j < len ( B ) : if A [ i ] [ index ] < B [ j ] [ index ] : result . append ( A [ i ] ) i += 1 else : result . append ( B [ j ] ) j += 1   result += A [ i : ] result += B [ j : ]   return result   def divide ( tuples ) : if len ( tuples ) > 1 : middle = len ( tuples ) // 2 return merge ( divide ( tuples [ : middle ] ) , divide ( tuples [ middle : ] ) )   return tuples   return divide ( tuples )   def solve ( friends , d ) : friends = mergesort_tuples ( friends , 0 ) left_ptr = 0 right_ptr = 0 current_friendship = 0 max_friendship = 0 while right_ptr < len ( friends ) : if friends [ right_ptr ] [ 0 ] - friends [ left_ptr ] [ 0 ] < d : current_friendship += friends [ right_ptr ] [ 1 ] right_ptr += 1 else : max_friendship = max ( current_friendship , max_friendship ) current_friendship -= friends [ left_ptr ] [ 1 ] left_ptr += 1   max_friendship = max ( current_friendship , max_friendship )   return max_friendship   return solve ( friends , d )     if __name__ == "" _ _ main _ _ "" : n , d = [ int ( x ) for x in input ( ) . split ( ) ] friends = [ ] for _ in range ( n ) : friends . append ( tuple ( [ int ( x ) for x in input ( ) . split ( ) ] ) ) print ( find_company ( friends , d ) ) NEW_LINE +" +E512,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ;   int aWin = 0 , draw = 0 , bWin = 0 ; for ( int i = 1 ; i <= 6 ; i ++ ) { int d1 = Math . abs ( a - i ) ; int d2 = Math . abs ( b - i ) ; if ( d1 < d2 ) aWin ++ ; else if ( d2 < d1 ) bWin ++ ; else draw ++ ; } System . out . println ( aWin + "" ▁ "" + draw + "" ▁ "" + bWin ) ;   } } +","a , b = map ( int , input ( ) . split ( ) ) first = 0 second = 0 draw = 0 for i in range ( 1 , 7 ) : if abs ( a - i ) > abs ( b - i ) : second += 1 elif abs ( a - i ) < abs ( b - i ) : first += 1 else : draw += 1 print ( first , draw , second ) NEW_LINE +" +E513,"import java . util . Scanner ;   public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < t ; i ++ ) { long a = sc . nextLong ( ) ; +","from math import ceil   for t in range ( int ( input ( ) ) ) : a , b , c , d = map ( int , input ( ) . split ( ) ) if b >= a : print ( b ) continue if c - d <= 0 : print ( - 1 ) continue s = b + ceil ( ( a - b ) / ( c - d ) ) * c if s > a : print ( s ) else : print ( - 1 ) NEW_LINE +" +E514,"import java . util . * ;   public class bs { static int [ ] [ ] psum ; public static void precal ( String str ) {   for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; psum [ i + 1 ] [ ch - ' a ' ] ++ ;   for ( int j = 0 ; j < 26 ; j ++ ) { psum [ i + 1 ] [ j ] += psum [ i ] [ j ] ; } } } public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; +","def read ( ) : return list ( map ( int , input ( ) . split ( ) ) )     [ n ] = read ( ) s = input ( ) indices = [ [ ] for i in range ( 26 ) ] for i in range ( n ) : indices [ ord ( s [ i ] ) - ord ( ' a ' ) ] += [ i + 1 ]     def run ( ) : s = input ( ) a = [ 0 for _ in range ( 26 ) ] for i in range ( len ( s ) ) : a [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1 ans = 0 for i in range ( 26 ) : if a [ i ] >= 1 : ans = max ( ans , indices [ i ] [ a [ i ] - 1 ] ) return ans     [ t ] = read ( ) for i in range ( t ) : print ( run ( ) ) NEW_LINE +" +E515,"import java . util . Scanner ;   public class A894 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String word = scanner . next ( ) ; int res = 0 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) {   if ( word . charAt ( i ) == ' A ' ) { int l = 0 , r = 0 ; for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( word . charAt ( j ) == ' Q ' ) l ++ ; } for ( int j = i + 1 ; j < word . length ( ) ; j ++ ) { if ( word . charAt ( j ) == ' Q ' ) r ++ ; } res += l * r ; } } System . out . println ( res ) ; } } +","s = input ( ) a , b , c = 0 , 0 , 0 for i in s : if i == "" Q "" : c += b a += 1 elif i == "" A "" : b += aprint ( c ) NEW_LINE +" +E516,"import java . util . Scanner ;   public class B172 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int M = in . nextInt ( ) ; int x = in . nextInt ( ) ; int [ ] seen = new int [ M ] ; int index = 1 ; while ( seen [ x ] == 0 ) { seen [ x ] = index ; index ++ ; x = ( A * x + B ) % M ; } int answer = index - seen [ x ] ; System . out . println ( answer ) ; }   } +","a , b , m , r = map ( int , input ( ) . split ( ) ) d = { } i = 1 while 1 : r = ( a * r + b ) % m ; t = d . get ( r , 0 ) if t : i -= t ; break d [ r ] = i ; i += 1 print ( ) print ( i ) NEW_LINE +" +E517,"import java . util . * ; public class drazil_date { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int s = in . nextInt ( ) ; int min = Math . abs ( x ) + Math . abs ( y ) ; if ( s < min || ( s - min ) % 2 != 0 ) System . out . println ( "" No "" ) ; else System . out . println ( "" Yes "" ) ; }   } +","a , b , c = map ( int , input ( ) . split ( ) ) if abs ( a ) + abs ( b ) <= c : if ( c - ( abs ( a ) + abs ( b ) ) ) % 2 == 0 : print ( ' Yes ' ) else : print ( "" No "" ) else : print ( "" No "" ) NEW_LINE +" +E518,"import java . util . Scanner ;   public class IsYourHorseShoeOnOtherRoof {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean visited [ ] = new boolean [ 4 ] ; long arr [ ] = new long [ 4 ] ; int repeated = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) arr [ i ] = sc . nextLong ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { long j = arr [ i ] ; for ( int k = i + 1 ; k < 4 ; k ++ ) { if ( j == arr [ k ] && visited [ k ] == false ) { visited [ k ] = true ; repeated ++ ; } } } System . out . println ( repeated ) ; } } +","print ( 4 - len ( { * input ( ) . split ( ) } ) ) NEW_LINE +" +E519,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; String s = in . next ( ) ; int ans = 0 ; for ( int i = 3 ; i < s . length ( ) ; i ++ ) { if ( i % n == 0 && s . charAt ( i - 1 ) == s . charAt ( i - 2 ) && s . charAt ( i - 1 ) == s . charAt ( i - 3 ) ) ans ++ ; } out . println ( ans ) ; }   }   static class InputReader { private StringTokenizer tokenizer ; private BufferedReader reader ;   public InputReader ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; }   private void fillTokenizer ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } }   public String next ( ) { fillTokenizer ( ) ; return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }   +","n = int ( input ( ) ) s = input ( ) c = 0 for i in range ( n , len ( s ) , n ) : tmp = s [ i - 3 : i ] if ' a ' in tmp and ' b ' in tmp : continue c += 1 print ( c ) NEW_LINE +" +E520,"import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . BigDecimal ;   public class R108C { public static void main ( String [ ] args ) throws java . lang . Exception { InputReader in = new InputReader ( System . in ) ; PrintWriter w = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) , q = in . nextInt ( ) ; char [ ] ca1 = in . next ( ) . toCharArray ( ) ;   while ( q -- > 0 ) { int l = in . nextInt ( ) - 1 , r = in . nextInt ( ) - 1 ; char [ ] ca = Arrays . copyOfRange ( ca1 , 0 , n ) ; int cur = l , d = 1 ; int [ ] a = new int [ 10 ] ; int prev = - 1 ; while ( cur >= l && cur <= r ) { +","n , Q = map ( int , input ( ) . strip ( ) . split ( ) )   s = input ( ) d = 1   for q in range ( Q ) : arr = [ 0 ] * ( 10 )   l , r = map ( int , input ( ) . strip ( ) . split ( ) )   su = "" "" for i in range ( l - 1 , r ) : su += s [ i ] su = list ( su ) i = 0 d = 1 NEW_LINE +" +E521,"import java . io . * ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; PrintWriter out = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int n = in . nextInt ( ) , m = 0 , mx = 0 ; int [ ] digits = new int [ 10 ] ; while ( n > 0 ) { int cur = n % 10 ; mx = Math . max ( mx , cur ) ; digits [ m ++ ] = cur ; n /= 10 ; }   out . println ( mx ) ; while ( true ) { int num = 0 ; boolean flag = false ; for ( int i = 0 , j = 1 ; i < m ; i ++ , j *= 10 ) { if ( digits [ i ] > 0 ) { flag = true ; digits [ i ] -- ; num += j ; } } if ( ! flag ) break ; out . print ( num + "" ▁ "" ) ; }   out . flush ( ) ; out . close ( ) ; in . close ( ) ; } } +","''' import ▁ syssys . stdin = open ( "" input . txt "" , "" r "" ) sys . stdout = open ( "" output . txt "" , "" w "" ) '''   n = input ( ) ans = list ( ) while int ( n ) > 0 : s = "" "" for c in n : if c != '0' : s += '1' else : s += '0' n = str ( int ( n ) - int ( s ) ) ans . append ( s ) print ( len ( ans ) ) for a in ans : print ( a , end = "" ▁ "" ) NEW_LINE +" +E522,"import java . io . * ; import java . util . * ; import java . math . BigInteger ;   public class test1 { static class sort implements Comparator < int [ ] > { public int compare ( int [ ] a , int [ ] b ) { +","s = input ( ) t = input ( ) arr = [ x - 1 for x in map ( int , input ( ) . split ( ) ) ] l = 0 r = len ( s ) - 1     def check ( sa , sb ) : j = 0 for i in range ( len ( sb ) ) : while j < len ( sa ) and sa [ j ] != sb [ i ] : j += 1 if j == len ( sa ) : return False j += 1 return True     while l < r : mid = ( l + r + 1 ) >> 1 d = list ( s ) for i in range ( mid ) : d [ arr [ i ] ] = ' ' if check ( "" "" . join ( d ) , t ) : l = mid else : r = mid - 1 print ( l ) NEW_LINE +" +E523,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ;   import java . util . * ; import javafx . util . Pair ;   public class Main {   public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; String s = input . next ( ) ; int ans = 0 ; LinkedList < Character > q = new LinkedList < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( q . isEmpty ( ) ) { q . add ( s . charAt ( i ) ) ; } else if ( q . peekLast ( ) == ' ( ' && s . charAt ( i ) == ' ) ' ) { ans += 2 ; q . pollLast ( ) ; } else q . add ( s . charAt ( i ) ) ; } System . out . println ( ans ) ; }   static class FastScanner {   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 ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   } +","from __future__ import division , print_functionfrom collections import * from math import * from itertools import * from time import timeimport osimport sysfrom io import BytesIO , IOBase if sys . version_info [ 0 ] < 3 : from __builtin__ import xrange as range from future_builtins import ascii , filter , hex , map , oct , zip ''' Notes : k ▁ first ▁ latin ▁ lettersn ▁ = ▁ length ▁ of ▁ the ▁ string ▁ s '''   def main ( ) : s = input ( ) st = [ ] res = 0 for i in s : if i == "" ( "" : st . append ( i ) continue if not st and i == "" ) "" : continue if st [ - 1 ] == "" ( "" and i == "" ) "" : st . pop ( ) res += 2 else : continue print ( res )     NEW_LINE +" +E524,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Arrays ;    public class CF677BVanyaAndFoodProcessor {   static BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static PrintWriter out = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) throws IOException { int [ ] l1 = readArray ( ) ; int n = l1 [ 0 ] ; int h = l1 [ 1 ] ; int k = l1 [ 2 ] ; int [ ] pieces = readArray ( ) ; long seconds = 0 ; int content = 0 ; int i = 0 ; while ( true ) { while ( i < n && content + pieces [ i ] <= h ) { content += pieces [ i ++ ] ; } if ( i == n ) { seconds += Math . ceil ( ( double ) content / ( double ) k ) ; break ; } else if ( content < k ) { seconds ++ ; content = 0 ; } else { seconds += ( long ) ( content / k ) ; content %= k ; }   }   out . println ( seconds ) ; out . close ( ) ; }   private static String read ( ) throws IOException { return in . readLine ( ) ; }   private static int readInt ( ) throws IOException { return Integer . parseInt ( in . readLine ( ) ) ; }   private static int [ ] readArray ( ) throws IOException { String [ ] line = in . readLine ( ) . split ( "" \\ s "" ) ; int [ ] a = Arrays . stream ( line ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; return a ; }   private static int [ ] readSortedArray ( ) throws IOException { String [ ] line = in . readLine ( ) . split ( "" \\ s "" ) ; int [ ] a = Arrays . stream ( line ) . mapToInt ( Integer :: parseInt ) . sorted ( ) . toArray ( ) ; return a ; } } +","n , h , k = [ int ( i ) for i in input ( ) . split ( ) ] H = [ int ( i ) for i in input ( ) . split ( ) ]   curr = 0 t = 0   for i in range ( n ) : if curr + H [ i ] <= h : curr += H [ i ] t += curr // k curr %= k else : t += 1 curr = H [ i ] % k t += H [ i ] // k   if curr != 0 : t += 1 print ( t )   NEW_LINE +" +E525,"import javax . print . attribute . standard . PrinterMessageFromOperator ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . net . Inet4Address ; import java . util . * ; public class Main { static long dp [ ] [ ] = new long [ 300 ] [ 300 ] ;   static long ways ( int i , int n , int cuts ) { if ( i > n ) return 0 ; if ( cuts == 0 ) return 1 ; if ( dp [ i ] [ cuts ] != 0 ) return dp [ i ] [ cuts ] ; long ans = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) { ans += ( ways ( j , n , cuts - 1 ) ) ; } return dp [ i ] [ cuts ] = ans ; }   public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; +","def solve ( ) : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) x , ct , max_ct = 0 , 0 , 0 for i in range ( 0 , n ) : if ( x < l [ i ] ) : x = l [ i ] for i in range ( 0 , n ) : if ( l [ i ] == x ) : ct += 1 else : max_ct = max ( ct , max_ct ) ct = 0 max_ct = max ( ct , max_ct ) print ( max_ct ) solve ( ) NEW_LINE +" +E526,"import java . lang . * ; import java . util . * ;   public class Abhishek {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; char [ ] arr = new char [ 4 ] ; String t = "" ! "" + s ; for ( int i = 1 ; i <= s . length ( ) ; i ++ ) { if ( t . charAt ( i ) != ' ! ' ) { arr [ i % 4 ] = t . charAt ( i ) ; } }   int r = 0 , b = 0 , y = 0 , g = 0 ; for ( int i = 1 ; i <= s . length ( ) ; i ++ ) { if ( t . charAt ( i ) == ' ! ' ) { char k = arr [ i % 4 ] ; switch ( k ) { case ' Y ' : y ++ ; break ; case ' B ' : b ++ ; break ; case ' R ' : r ++ ; break ; case ' G ' : g ++ ; break ; } } } System . out . println ( r + "" ▁ "" + b + "" ▁ "" + y + "" ▁ "" + g ) ; } } +","s = input ( ) if s . count ( ' ! ' ) == 0 : print ( ""0 ▁ 0 ▁ 0 ▁ 0"" ) else : kr = kb = ky = kg = 0 l = len ( s ) k = [ 0 , 0 , 0 , 0 ] for i in range ( l ) : if s [ i ] != ' ! ' : j = i % 4 k [ j ] = s [ i ] for i in range ( l ) : if s [ i ] == ' ! ' : j = k [ i % 4 ] if j == ' R ' : kr += 1 if j == ' B ' : kb += 1 if j == ' Y ' : ky += 1 if j == ' G ' : kg += 1 print ( "" { } ▁ { } ▁ { } ▁ { } "" . format ( kr , kb , ky , kg ) )   NEW_LINE +" +E527,"import java . util . * ; import java . math . * ; public class AlyonaAndNumbers { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long out = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { long num = i + m ; out += ( long ) num / 5 - i / 5 ; } System . out . println ( out ) ; } } +","a , b = map ( int , input ( ) . split ( "" ▁ "" ) ) m = min ( a , b ) n = max ( a , b ) c = 0 for i in range ( 1 , m + 1 ) : num = i % 5 if num == 0 : num = 5 init = abs ( 5 - num ) ans = ( abs ( n - init ) ) // 5 if num != 5 and num + n >= 5 : ans += 1 c += ansprint ( c ) NEW_LINE +" +E528,"import java . io . BufferedReader ; import java . io . InputStreamReader ;   public class SherlockAndGF { static int n = 1000000 ;   static int [ ] sieve = new int [ n + 1 ] ;   static void createSieve ( ) { sieve [ 0 ] = sieve [ 1 ] = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { sieve [ i ] = 1 ; } for ( int i = 2 ; i * i <= n ; i ++ ) { if ( sieve [ i ] == 1 ) { for ( int j = i * i ; j <= n ; j = j + i ) { sieve [ j ] = 0 ; } } } } public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { StringBuilder sb = new StringBuilder ( ) ; createSieve ( ) ; int X = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; int nonPrime = 0 ; int prime = 0 ; for ( int i = 2 ; i <= X + 1 ; i ++ ) { if ( sieve [ i ] == 1 ) { prime ++ ; } else { nonPrime ++ ; } } if ( nonPrime == 0 ) { System . out . println ( 1 ) ; } else { System . out . println ( 2 ) ; } for ( int i = 2 ; i <= X + 1 ; i ++ ) { if ( sieve [ i ] == 1 ) { System . out . print ( 1 + "" ▁ "" ) ; } else { System . out . print ( 2 + "" ▁ "" ) ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; }   }   } +","import math   n = int ( input ( ) ) answer = "" "" if n < 3 : print ( 1 ) else : print ( 2 )   m = n + 2 numbers = [ True ] * mnumbers [ 0 ] = Falsenumbers [ 1 ] = False   for i in range ( 2 , int ( math . sqrt ( m ) ) + 1 ) : j = 0 while i ** 2 + j * i < m : numbers [ i ** 2 + j * i ] = False j += 1   for i in range ( 2 , m ) : if numbers [ i ] : answer += ""1 ▁ "" else : answer += ""2 ▁ ""   answer = answer [ : - 1 ] print ( answer ) NEW_LINE +" +E529,"import java . util . Scanner ;   public class LocalExtrema { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int count = 0 ; int n1 [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { n1 [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( n1 [ i ] < n1 [ i - 1 ] && n1 [ i ] < n1 [ i + 1 ] || n1 [ i ] > n1 [ i - 1 ] && n1 [ i ] > n1 [ i + 1 ] ) count ++ ; } System . out . println ( count ) ; } } +","n = int ( input ( ) ) arr = [ int ( num ) for num in input ( ) . split ( ) ] count = 0 for i in range ( 1 , len ( arr ) - 1 ) : if ( arr [ i - 1 ] < arr [ i ] and arr [ i + 1 ] < arr [ i ] or arr [ i - 1 ] > arr [ i ] and arr [ i + 1 ] > arr [ i ] ) : count += 1 print ( count ) NEW_LINE +" +E530,"import java . util . Scanner ;   public class RobotTask { public static int testCase ( int n , int a [ ] ) { int collected = 0 ; int direction = - 1 ; boolean b [ ] = new boolean [ a . length ] ; while ( collected < n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] <= collected && b [ i ] != true ) { collected ++ ; b [ i ] = true ; } if ( i == n - 1 ) { direction ++ ; } } if ( collected != n ) for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] <= collected && b [ i ] != true ) { collected ++ ; b [ i ] = true ; } if ( i == 0 ) { direction ++ ; } } } return direction ; } 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 ( ) ; } System . out . println ( testCase ( n , a ) ) ; } } +","    n = int ( input ( ) )   t = list ( map ( int , input ( ) . split ( ) ) )     c = 0     a = [ ] p = 0 m = 0 while len ( a ) + len ( t ) != 0 : if len ( a ) == 0 and len ( t ) != 0 : while len ( t ) != 0 : x = t . pop ( 0 ) if x <= c : c += 1 else : a . append ( x ) m += 1 else :   while len ( a ) != 0 : v = a . pop ( ) if v <= c : c += 1 else : t = [ v ] + t m += 1   print ( m - 1 ) NEW_LINE +" +E531,"import java . util . * ; public class java1 { public static void main ( String [ ] agrs ) { int [ ] t = new int [ 2 ] ; t [ 0 ] = 0 ; t [ 1 ] = 0 ; Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) t [ in . nextInt ( ) ] = i ; System . out . println ( t [ 0 ] < t [ 1 ] ? t [ 0 ] : t [ 1 ] ) ; } } +","import sys   def main ( ) : _ , s = sys . stdin . read ( ) . strip ( ) . split ( ' \n ' ) t = s . replace ( ' ▁ ' , ' ' ) . rstrip ( s [ - 1 ] ) return len ( t ) print ( main ( ) ) NEW_LINE +" +E532,"import java . util . Arrays ; import java . util . Scanner ;   public class Bookshelf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int testcases = sc . nextInt ( ) ; sc . nextLine ( ) ;   for ( int i = 0 ; i < testcases ; i ++ ) { int n = sc . nextInt ( ) ; sc . nextLine ( ) ; String array = sc . nextLine ( ) ; int [ ] stream = Arrays . stream ( array . split ( "" ▁ "" ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; output ( n , stream ) ; } }   private static void output ( int n , int [ ] stream ) { int first = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( stream [ i ] == 1 ) { first = i ; i = n ; } } int last = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( stream [ i ] == 1 ) { last = i ; i = 0 ; } } int count = 0 ; if ( first == last ) { count = 0 ; } else { for ( int i = first ; i < last ; i ++ ) if ( stream [ i ] == 0 ) count ++ ; } System . out . println ( count ) ; } } +","t = int ( input ( ) ) NEW_LINE ans = [ ]   for _ in range ( t ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( str , input ( ) . split ( ) ) )   ind = [ ] NEW_LINE c = 0   for i in range ( len ( a ) ) : if NEW_LINE a [ i ] == '1' : ind . append ( i )   for i in range ( 0 , len ( ind ) - 1 ) : c += ind [ i + 1 ] - ind [ i ] - 1   ans . append ( c )   for i in ans : print ( i ) NEW_LINE +" +E533,"import java . io . * ; import java . util . * ; public class Practice1 { public static void main ( String args [ ] ) { FastReader input = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int T = input . nextInt ( ) ; while ( T -- > 0 ) { long a = input . nextInt ( ) ; long b = input . nextInt ( ) ; long p = a * b ; long c = ( long ) Math . cbrt ( p ) ; long p1 = ( c * c * c ) ; if ( p1 != p ) { out . println ( "" NO "" ) ; } else { if ( a % c == 0 && b % c == 0 ) { out . println ( "" YES "" ) ; } else { out . println ( "" NO "" ) ; } } } out . close ( ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) {   return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = "" "" ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } +","import sys , os , iofrom sys import stdinfrom math import log , gcd , ceilfrom collections import defaultdict , deque , Counterfrom heapq import heappush , heappop , heapifyfrom bisect import bisect_left , bisect_rightimport math def ii ( ) : return int ( input ( ) ) def li ( ) : return list ( map ( int , input ( ) . split ( ) ) ) if ( os . path . exists ( ' input . txt ' ) ) : sys . stdin = open ( "" input . txt "" , "" r "" ) ; sys . stdout = open ( "" output . txt "" , "" w "" ) else : input = io . BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readline   no = "" No "" yes = "" Yes ""     def solve ( ) : a , b = li ( ) x = ( pow ( a * b , 1 / 3 ) ) x = round ( x ) if x * x * x == a * b and a % x == b % x == 0 : print ( yes ) else : print ( no )         t = 1 t = int ( input ( ) ) for _ in range ( t ) : solve ( ) NEW_LINE +" +E534,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class C { static class FastScanner { 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 [ ] nextArray ( 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 ( ) ) ; } } static class FastWriter extends PrintWriter { FastWriter ( ) { super ( System . out ) ; }   void println ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + "" ▁ "" ) ; } println ( ) ; }   void println ( long [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { print ( array [ i ] + "" ▁ "" ) ; } println ( ) ; } } public static void main ( String [ ] args ) { +","s1 = input ( ) s2 = input ( ) s3 = input ( )   if ( s1 == s3 [ : : - 1 ] ) and ( s2 [ 0 ] == s2 [ 2 ] ) : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E535,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Random ; import java . util . StringTokenizer ;   public class Main implements Runnable {   long INF = ( long ) 1e9 + 9 ;   private void solve ( ) throws IOException { int n = nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = nextInt ( ) ; } +","import sysinput = sys . stdin . readlinen = int ( input ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) dic = { } li = [ ] for i in range ( n ) : xx = [ ] for j in range ( n - i ) : xx . append ( 0 ) li . append ( xx . copy ( ) ) for i in range ( n ) : for j in range ( n - i ) : if ( i == 0 ) : li [ i ] [ j ] = ar [ j ] else : li [ i ] [ j ] = li [ i - 1 ] [ j ] ^ li [ i - 1 ] [ j + 1 ] for i in range ( 1 , n ) : for j in range ( n - i ) : li [ i ] [ j ] = max ( li [ i ] [ j ] , li [ i - 1 ] [ j ] , li [ i - 1 ] [ j + 1 ] ) for _ in range ( int ( input ( ) ) ) : l , r = map ( int , input ( ) . split ( ) ) print ( li [ r - l ] [ l - 1 ] ) NEW_LINE +" +E536,"import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; public class Cat_Furrier { public static void main ( String [ ] args ) { +","def bs ( l , h ) : while l < h : m = ( l + h + 1 ) // 2 if a [ m ] < i : l = m else : h = m - 1 return l   n , m = map ( int , input ( ) . split ( ) ) c , t = map ( int , input ( ) . split ( ) ) l = c * ta = [ 0 ] for _ in range ( n - 1 ) : c , t = map ( int , input ( ) . split ( ) ) a . append ( l ) l = a [ - 1 ] + c * tb = map ( int , input ( ) . split ( ) ) for i in b : print ( bs ( 0 , n - 1 ) + 1 ) NEW_LINE +" +E537,"import java . util . * ; import java . io . * ;   public class solution { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) , k = s . nextInt ( ) ; int freq [ ] = new int [ k + 1 ] ; for ( int i = 0 ; i <= k ; i ++ ) freq [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = s . nextInt ( ) ; freq [ temp ] ++ ; } int cnt = 0 , ans = 0 ; int ava = ( int ) Math . ceil ( ( double ) n / 2 ) ; for ( int i = 1 ; i <= k ; i ++ ) { if ( ( freq [ i ] & 1 ) == 0 ) ans += freq [ i ] ; else { ans += freq [ i ] - 1 ; cnt ++ ; } } ans = ans + ( int ) Math . ceil ( ( double ) cnt / 2 ) ; System . out . println ( ans ) ;    } } +","n , k = map ( int , input ( ) . split ( ) ) A = [ int ( input ( ) ) for i in range ( n ) ] from collections import CounterC = Counter ( A ) B = [ ] ans = 0 r = 0 for k , v in C . items ( ) : if v % 2 == 0 : ans += v else : ans += v - 1 r += 1 ans += ( r + 1 ) // 2 print ( ans ) NEW_LINE +" +E538,"import java . util . * ; import java . io . * ; import java . math . * ;   public class Practice   { static FastReader sc = new FastReader ( ) ; public static void main ( String [ ] args ) { int ttt = 1 ; +","import sysfrom collections import dequeimport mathinput_ = lambda : sys . stdin . readline ( ) . strip ( "" \n "" ) ii = lambda : int ( input_ ( ) ) il = lambda : list ( map ( int , input_ ( ) . split ( ) ) ) ilf = lambda : list ( map ( float , input_ ( ) . split ( ) ) ) ip = lambda : input_ ( ) fi = lambda : float ( input_ ( ) ) li = lambda : list ( input_ ( ) ) pr = lambda x : print ( x ) f = lambda : sys . stdout . flush ( )   a , b , c , d = il ( ) print ( 2 * ( a + b + d + 2 ) ) NEW_LINE +" +E539,"import java . util . Scanner ;   public class A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; char ch [ ] = s . toCharArray ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { count ++ ; if ( s . charAt ( i ) == ' a ' ) { ch [ i ] = ' b ' ; } else { ch [ i ] = ' a ' ; } } else { continue ; } } System . out . println ( count ) ; System . out . println ( ch ) ; } } +","n = int ( input ( ) ) s = input ( ) t , i , count = ' ' , 0 , 0 while i < n - 1 : if s [ i : i + 2 ] != ' ab ' and s [ i : i + 2 ] != ' ba ' : t += ' ab ' count += 1 else : t += s [ i : i + 2 ] i += 2 print ( count ) print ( t ) NEW_LINE +" +E540,"import java . util . * ; import java . io . * ; import java . math . BigInteger ;   public class StadiumandGames { static BigInteger isPerfectSq ( BigInteger n ) { BigInteger lo = BigInteger . ONE ; BigInteger hi = new BigInteger ( n . toString ( ) ) ; BigInteger sqrt = BigInteger . ZERO ; while ( lo . compareTo ( hi ) <= 0 ) { BigInteger mid = lo . add ( hi ) ; mid = mid . divide ( BigInteger . valueOf ( 2 ) ) ; if ( mid . multiply ( mid ) . compareTo ( n ) > 0 ) hi = mid . subtract ( BigInteger . ONE ) ; else { lo = mid . add ( BigInteger . ONE ) ; sqrt = mid ; } } return sqrt . multiply ( sqrt ) . equals ( n ) ? sqrt : BigInteger . ZERO ; } private static void solve ( ) { long X = nextLong ( ) ; TreeSet < BigInteger > ans = new TreeSet < > ( ) ; for ( int i = 0 ; i < 70 ; i ++ ) { BigInteger term1 = BigInteger . valueOf ( 2 ) . pow ( i + 1 ) . subtract ( BigInteger . valueOf ( 3 ) ) ; BigInteger term2 = isPerfectSq ( term1 . multiply ( term1 ) . add ( BigInteger . valueOf ( 8L * X ) ) ) ;   BigInteger numer = term2 . subtract ( term1 ) ; BigInteger div [ ] = numer . divideAndRemainder ( BigInteger . valueOf ( 2 ) ) ; if ( ! term2 . equals ( BigInteger . ZERO ) && numer . compareTo ( BigInteger . ZERO ) >= 0 && div [ 1 ] . equals ( BigInteger . ZERO ) ) { BigInteger m = div [ 0 ] ; BigInteger answer = m . multiply ( BigInteger . valueOf ( 2 ) . pow ( i ) ) ; +","n = int ( input ( ) ) x = 1 res = [ ] for i in range ( 64 ) : lo , hi = 0 , int ( 1e15 ) f = 0 ans = 0 while lo + 1 < hi : mid = ( lo + hi ) // 2 v = ( x - 1 ) * mid + ( mid * mid - mid ) // 2 if ( v == n ) : f = 1 ; ans = mid break ; if ( v > n ) : hi = mid else : lo = mid if ( f and ans % 2 == 1 ) : res . append ( ans * x ) x = x * 2 if ( len ( res ) == 0 ) : print ( - 1 ) ; exit ( 0 ) for x in res : print ( int ( x ) ) NEW_LINE +" +E541,"import java . util . * ;   public class EduRound25B { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] [ ] a = new char [ 10 ] [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { a [ i ] = scanner . next ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { if ( a [ i ] [ j ] != ' . ' ) continue ; a [ i ] [ j ] = ' X ' ; int countX = 0 ; int countY = 0 ; for ( int k = 0 ; k < 10 ; k ++ ) { if ( a [ i ] [ k ] == ' X ' ) { countX ++ ; } else { countX = 0 ; } if ( a [ k ] [ j ] == ' X ' ) { countY ++ ; } else { countY = 0 ; } if ( countX == 5 || countY == 5 ) { System . out . println ( "" YES "" ) ; return ; } } int count = 0 ; for ( int k = - 5 ; k < 5 ; k ++ ) { int r = i + k ; int c = j + k ; if ( r < 0 || c < 0 ) continue ; if ( r > 9 || c > 9 ) break ; if ( a [ r ] [ c ] == ' X ' ) { count ++ ; } else { count = 0 ; } if ( count == 5 ) { System . out . println ( "" YES "" ) ; return ; } } count = 0 ; for ( int k = - 5 ; k < 5 ; k ++ ) { int r = i - k ; int c = j + k ; if ( r > 9 || c < 0 ) continue ; if ( r < 0 || c > 9 ) break ; if ( a [ r ] [ c ] == ' X ' ) { count ++ ; } else { count = 0 ; } if ( count == 5 ) { System . out . println ( "" YES "" ) ; return ; } } a [ i ] [ j ] = ' . ' ; } } System . out . println ( "" NO "" ) ; } } +","def checkhor ( x , y ) : c = 0 cy = y + 1 while ( cy < n and grid [ x ] [ cy ] == ' X ' ) : cy += 1 c += 1 if ( c >= 4 ) : return True cy = y - 1 while ( cy >= 0 and grid [ x ] [ cy ] == ' X ' ) : cy -= 1 c += 1 NEW_LINE +" +E542,"import java . io . * ; import java . util . * ; public class Asd { static PrintWriter w = new PrintWriter ( System . out ) ; static FastScanner s = new FastScanner ( ) ;   public static void main ( String [ ] args ) { +","import math   def gcd ( a , b ) : if a < b : a , b = b , a while a % b != 0 : a , b = b , a % b return b   n , k , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   r = { } for i in range ( n ) : e = a [ i ] % m if e in r : r [ e ] . append ( a [ i ] ) else : r [ e ] = [ a [ i ] ]   for key in r : if len ( r [ key ] ) >= k : print ( "" Yes "" ) for i in range ( k ) : print ( r [ key ] [ i ] , end = "" ▁ "" ) breakelse : print ( "" No "" )   NEW_LINE +" +E543,"import java . util . ArrayList ; import java . util . Scanner ;   public class A1462 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scanner . nextInt ( ) ; for ( int j = 0 ; j < n ; j ++ ) { int b = scanner . nextInt ( ) ; list . add ( b ) ; } if ( n % 2 == 0 ) { for ( int j = 0 ; j < n / 2 ; j ++ ) { System . out . print ( list . get ( j ) + "" ▁ "" + list . get ( n - 1 - j ) + "" ▁ "" ) ; } System . out . print ( "" \n "" ) ; } else { for ( int j = 0 ; j < n / 2 ; j ++ ) { System . out . print ( list . get ( j ) + "" ▁ "" + list . get ( n - 1 - j ) + "" ▁ "" ) ; } System . out . print ( list . get ( n / 2 ) + "" \n "" ) ; } list . clear ( ) ; } } } +","t = int ( input ( ) ) NEW_LINE for j in range ( t ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE for i in range ( n ) : new = [ ] NEW_LINE if i % 2 == 0 : NEW_LINE INDENT new . append ( a [ count ] ) else : NEW_LINE new . append ( a [ n - count - 1 ] ) NEW_LINE DEDENT count += 1 NEW_LINE print ( * new , end = "" ▁ "" ) NEW_LINE +" +E544,"import java . util . Scanner ;   public class Solution { 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 ( n > 1 ) { for ( int i = 0 ; i < n ; i ++ ) { int minIdx = i ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( a [ minIdx ] > a [ j ] ) { minIdx = j ; } } int temp = a [ i ] ; a [ i ] = a [ minIdx ] ; a [ minIdx ] = temp ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] + "" ▁ "" ) ; } } }   +","n = int ( input ( ) ) i = 0 a = [ ] a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) while i < len ( a ) : print ( a [ i ] ) i = i + 1 NEW_LINE +" +E545,"import java . util . * ; import java . io . * ; public class MyClass { public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int count0left = 0 ; int count1left = 0 ; int count0right = 0 ; int count1right = 0 ; while ( n -- > 0 ) { String s [ ] = br . readLine ( ) . split ( "" ▁ "" ) ; int l = Integer . parseInt ( s [ 0 ] ) ; int r = Integer . parseInt ( s [ 1 ] ) ; if ( l == 0 ) { count0left = count0left + 1 ; } else if ( l == 1 ) { count1left = count1left + 1 ; } if ( r == 0 ) { count0right = count0right + 1 ; } else if ( r == 1 ) { count1right = count1right + 1 ; } } int rs = Math . min ( count0left , count1left ) + Math . min ( count0right , count1right ) ; System . out . println ( rs ) ; } } +","n = int ( input ( ) ) L = [ ] R = [ ]   for _ in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) L . append ( l ) R . append ( r )   l0 = L . count ( 0 ) l1 = n - l0   r0 = R . count ( 0 ) r1 = n - r0   t = 0   if r0 > r1 : t += r1else : t += r0   if l0 > l1 : t += l1else : t += l0   print ( t ) NEW_LINE +" +E546,"import java . io . * ; import java . util . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer stt ; int n = Integer . parseInt ( br . readLine ( ) ) ; int records [ ] = new int [ n ] , succ_records [ ] = new int [ n ] , unsucc_records [ ] = new int [ n ] , count = Integer . MIN_VALUE , count_zero = 0 , count_one = 0 ; stt = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { records [ i ] = Integer . parseInt ( stt . nextToken ( ) ) ; count_zero = ( records [ i ] == 0 ) ? count_zero + 1 : count_zero ; unsucc_records [ i ] = count_zero ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { count_one = ( records [ i ] == 1 ) ? count_one + 1 : count_one ; succ_records [ i ] = count_one ; } count = count_one ; for ( int i = 0 ; i < n - 1 ; i ++ ) count = ( count < unsucc_records [ i ] + succ_records [ i + 1 ] ) ? unsucc_records [ i ] + succ_records [ i + 1 ] : count ; count = ( count < unsucc_records [ n - 1 ] ) ? unsucc_records [ n - 1 ] : count ; System . out . println ( count ) ; return ; } } +","n = int ( input ( ) ) string = ' ' . join ( map ( str , input ( ) . split ( ) ) ) maxx = 0 for i in range ( n + 1 ) : maxx = max ( maxx , string [ : i ] . count ( '0' ) + string [ i : ] . count ( '1' ) ) print ( maxx ) NEW_LINE +" +E547,"import java . lang . * ; import java . util . * ;   public class Abhishek {   public static void main ( String [ ] args ) throws Exception { 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 [ ] psum = new int [ n ] ; psum [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { psum [ i ] = psum [ i - 1 ] + a [ i ] ; } int m = sc . nextInt ( ) ; +","def search ( a , x ) : l , r = 0 , len ( a ) - 1 while l <= r : mid = ( l + r ) // 2 if a [ mid ] >= x and a [ mid - 1 ] < x : return mid elif a [ mid ] < x : l = mid + 1 else : r = mid - 1 return 0   n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 1 , n ) : a [ i ] += a [ i - 1 ]   q = int ( input ( ) ) qu = list ( map ( int , input ( ) . split ( ) ) ) for x in qu : print ( search ( a , x ) + 1 ) NEW_LINE +" +E548,"import java . util . * ;   public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder n = new StringBuilder ( sc . next ( ) ) ; String ans = n + n . reverse ( ) . toString ( ) ; System . out . println ( ans ) ;    }    public static int getAns ( String s , int k , int start1 , int end1 ) { +","n = input ( ) print ( n + n [ : : - 1 ] ) NEW_LINE +" +E549,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Main {   public static int countone ( String s ) { int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '0' ) { count ++ ; } } return count ; }   public static void main ( String [ ] args ) throws IOException {   FastScanner input = new FastScanner ( ) ; int tc = input . nextInt ( ) ; while ( tc -- > 0 ) { int zero = 0 ; int n = input . nextInt ( ) ; boolean check = false ; for ( int i = 0 ; i < n ; i ++ ) { String s = input . next ( ) ; int one = 0 ; if ( s . length ( ) % 2 == 1 ) { check = true ; continue ; } zero += ( countone ( s ) ) ;   } if ( ! check && zero % 2 == 1 ) { System . out . println ( n - 1 ) ; } else { System . out . println ( n ) ; } }   }   static class FastScanner {   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 ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   } +","for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) odd_str = 0 good_str = 0 bad_str = 0 for i in range ( n ) : s = input ( ) if len ( s ) % 2 != 0 : odd_str += 1 else : if s . count ( '0' ) % 2 == 0 and s . count ( '1' ) % 2 == 0 : good_str += 1 else : bad_str += 1 if bad_str % 2 != 0 and not odd_str : print ( n - 1 ) else : print ( n )       NEW_LINE +" +E550,"import java . util . * ; import java . io . * ; public class A { static FastReader in = new FastReader ( ) ; static final Random random = new Random ( ) ; static long mod = 1000000007L ; public static void main ( String args [ ] ) throws IOException { int t = 1 ; +","n , k = [ int ( x ) for x in input ( ) . split ( ) ] cards = input ( )   frequency = { } for card in cards : if card not in frequency : frequency [ card ] = 0 frequency [ card ] += 1   frequent = list ( sorted ( frequency . values ( ) , reverse = True ) )     amount = frequent [ 0 ] leftover = max ( k - amount , 0 ) coins = ( k - leftover ) * ( k - leftover ) i = 1 while leftover > 0 and i >= 0 : temp = min ( leftover , frequent [ i ] ) coins = coins + ( temp * temp ) leftover = leftover - temp i += 1   print ( coins ) NEW_LINE +" +E551,"import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStreamWriter ; import java . math . BigDecimal ;    import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . Map . Entry ; import java . util . PriorityQueue ; import java . util . TreeSet ;     public final class CF_115_B { static boolean verb = true ; static void log ( Object X ) { if ( verb ) System . err . println ( X ) ; } static void log ( Object [ ] X ) { if ( verb ) { for ( Object U : X ) System . err . print ( U + "" ▁ "" ) ; System . err . println ( "" "" ) ; } } static void log ( int [ ] X ) { if ( verb ) { for ( int U : X ) System . err . print ( U + "" ▁ "" ) ; System . err . println ( "" "" ) ; } } static void logWln ( Object X ) { if ( verb ) System . err . print ( X ) ; } static void info ( Object o ) { System . out . println ( o ) ; } static void output ( Object o ) { outputWln ( "" "" + o + "" \n "" ) ; } static void outputWln ( Object o ) { try { out . write ( "" "" + o ) ; } catch ( Exception e ) { } }    static int MX = Integer . MAX_VALUE ; static class Composite implements Comparable < Composite > { int idx ; int v ; String name ; public int compareTo ( Composite X ) { if ( v != X . v ) return X . v - v ; return idx - X . idx ; }   public Composite ( int idx , int v , String name ) { this . idx = idx ; this . v = v ; this . name = name ; }   }      +","from collections import defaultdictfrom bisect import bisect_leftp , n = defaultdict ( int ) , int ( input ( ) ) for i in range ( n ) : a , b = input ( ) . split ( ) p [ a ] = max ( p [ a ] , int ( b ) ) p , n = sorted ( ( b , a ) for a , b in p . items ( ) ) , len ( p ) t = [ 0 ] + [ bisect_left ( p , ( p [ n - 1 - n // k ] [ 0 ] , ' ' ) ) for k in [ 2 , 5 , 10 , 100 ] ] + [ n ] s = [ ' noob ' , ' random ' , ' average ' , ' hardcore ' , ' pro ' ] for i in range ( 1 , len ( t ) ) : d = s [ i - 1 ] for j in range ( t [ i - 1 ] , t [ i ] ) : p [ j ] = p [ j ] [ 1 ] + ' ▁ ' + dprint ( n ) print ( ' \n ' . join ( p ) ) NEW_LINE +" +E552,"import java . util . * ;   public class Combination_B {   public static void main ( String [ ] args ) { +","n = int ( input ( ) ) x = [ ] for i in range ( n ) : a = list ( map ( int , input ( ) . split ( ) ) ) x . append ( a ) c = 1 x . sort ( key = lambda i : i [ 0 ] , reverse = True ) x . sort ( key = lambda i : i [ 1 ] , reverse = True ) p = 0 for i in x : c -= 1 c += i [ 1 ] p += i [ 0 ] if c == 0 : breakprint ( p ) NEW_LINE +" +E553,"# include < bits / stdc ++ . h > using namespace std ; int u [ 10 ] , k [ 2000001 ] ; int a [ 2000005 ] ; int b [ 2000005 ] ; void fake ( ) { b [ 1 ] = 1 ; int cnt = 0 ; for ( int i = 2 ; i < 2000005 ; i ++ ) { if ( ! b [ i ] ) a [ cnt ++ ] = i ; for ( int j = 0 ; j < cnt && i * a [ j ] < 2000005 ; j ++ ) { b [ i * a [ j ] ] = 1 ; if ( i % a [ j ] == 0 ) break ; } } } int main ( ) { int i , j , p , q , n ; cin >> p >> q ; n = 2000005 ; fake ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { b [ i ] = 1 - b [ i ] ; b [ i ] += b [ i - 1 ] ; int y = i , f = 0 ; while ( y != 0 ) { u [ f ] = y % 10 ; y /= 10 ; f ++ ; } for ( j = 0 ; j <= f ; j ++ ) if ( u [ j ] != u [ f - 1 - j ] ) break ; if ( j == f + 1 ) k [ i ] = k [ i - 1 ] + 1 ; else k [ i ] = k [ i - 1 ] ; } int ans ; for ( int i = 1 ; i <= 2000005 ; i ++ ) if ( b [ i ] * q <= p * k [ i ] ) ans = i ; cout << ans << endl ; return 0 ; } +","def f ( s ) : for i in range ( len ( s ) // 2 + 1 ) : if s [ i ] != s [ - 1 - i ] : return False return Truez = 1200000 arr = [ 1 ] * zarr [ 0 ] , arr [ 1 ] = 0 , 0 for i in range ( 2 , 1096 ) : for j in range ( i * i , z , i ) : arr [ j ] = 0 cntpal = cntprm = 0 i = 1 p , q = map ( int , input ( ) . split ( ) ) k = p / qm = kwhile i < 1200000 : if f ( str ( i ) ) : cntpal += 1 if arr [ i ] : cntprm += 1 if cntprm / cntpal <= k : n = i i += 1 print ( n ) NEW_LINE +" +E554,"import java . util . * ;   public class Test {   public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int x = in . nextInt ( ) ; if ( x > Math . min ( ( n + 1 ) / 2 , ( m + 1 ) / 2 ) ) { System . out . println ( 0 ) ; return ; } n = n - 2 * x + 2 ; m = m - 2 * x + 2 ; int n1 = Math . max ( n - 2 , 0 ) ; int m1 = Math . max ( m - 2 , 0 ) ; int ans = n * m - n1 * m1 ; System . out . println ( ( ans + 1 ) / 2 ) ; } } +","def calculate_sides ( n , m ) : if n == 1 : return m // 2 if m % 2 == 0 else m // 2 + 1 if m == 1 : return n // 2 if n % 2 == 0 else n // 2 + 1   left , right , top , bottom = 0 , 0 , 0 , 0 top = m // 2 if m % 2 == 0 else m // 2 + 1 bottom = top if n % 2 != 0 else m // 2 n -= 2 m -= 2 left = n // 2 if m > 0 : right = left if m % 2 != 0 else n // 2 if n % 2 == 0 else n // 2 + 1   return top + bottom + left + right     n , m = list ( map ( int , input ( ) . split ( ) ) ) x = int ( input ( ) ) dict = dict ( ) times = 1 while n > 0 and m > 0 : quantity = calculate_sides ( n , m ) dict [ times ] = quantity times += 1 n -= 2 m -= 2 print ( dict [ x ] if x in dict else 0 ) NEW_LINE +" +E555,"import java . util . Arrays ; import java . util . Scanner ; import java . util . Vector ;   public class Main {   public static void main ( String [ ] args ) {   Scanner scan = new Scanner ( System . in ) ;   int t = scan . nextInt ( ) ;   for ( int h = 0 ; h < t ; h ++ ) {   int n = scan . nextInt ( ) ;   int [ ] s = new int [ n ] ;   int ans = - 1 ;   for ( int i = 0 ; i < n ; i ++ ) {   s [ i ] = scan . nextInt ( ) ;   }   boolean exit = false ;   for ( int i = 1 ; i < 1024 && ! exit ; i ++ ) {   for ( int j = 0 ; j < n ; j ++ ) {   boolean flag = false ;   for ( int k = 0 ; k < n ; k ++ ) {   if ( ( s [ j ] ^ i ) == s [ k ] ) {   flag = true ;   break ;   }   }   if ( ! flag ) {   break ;   }   else if ( j == n - 1 ) {   ans = i ;   exit = true ;   }   }   }   System . out . println ( ans ) ;   }   }   } +","for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) s = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) k = - 1 for i in range ( 1 , 1025 ) : temp = [ ] for j in s : temp . append ( j ^ i ) if sorted ( temp ) == s : k = i break print ( k ) NEW_LINE +" +E556,"  import java . math . * ; import java . util . * ; import java . io . * ; public class gr13b { +","if __name__ == ' _ _ main _ _ ' :   n = int ( input ( ) ) node = [ [ ] for _ in range ( n ) ] for i in range ( n - 1 ) : node [ int ( input ( ) ) - 1 ] . append ( i + 2 ) NEW_LINE +" +E557,"import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int x = sc . nextInt ( ) ; int candies [ ] = new int [ x ] ; int oranges [ ] = new int [ x ] ; int mincandies = Integer . MAX_VALUE ; int minoranges = Integer . MAX_VALUE ; for ( int i = 0 ; i < x ; i ++ ) { candies [ i ] = sc . nextInt ( ) ; mincandies = Math . min ( candies [ i ] , mincandies ) ; } for ( int i = 0 ; i < x ; i ++ ) { oranges [ i ] = sc . nextInt ( ) ; minoranges = Math . min ( oranges [ i ] , minoranges ) ; } long tot = 0 ; for ( int i = 0 ; i < x ; i ++ ) { if ( candies [ i ] > mincandies | oranges [ i ] > minoranges ) { tot += ( Math . min ( candies [ i ] - mincandies , oranges [ i ] - minoranges ) ) ; tot += ( Math . max ( candies [ i ] - mincandies , oranges [ i ] - minoranges ) - Math . min ( candies [ i ] - mincandies , oranges [ i ] - minoranges ) ) ; } } System . out . println ( tot ) ; } } } ; +","for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT sum1 = 0 NEW_LINE n = int ( input ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE x1 , y1 = min ( x ) , min ( y ) NEW_LINE for j in range ( n ) : NEW_LINE INDENT sum1 = sum1 + max ( x [ j ] - x1 , y [ j ] - y1 ) NEW_LINE DEDENT print ( sum1 ) NEW_LINE DEDENT +" +E558,"import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B678 {   public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int tc = 1 ; +","from math import gcddef getDays ( n ) : if n % 100 == 0 and n % 400 == 0 : return 366 if n % 100 != 0 and n % 4 == 0 : return 366 return 365 y = int ( input ( ) ) v = getDays ( y ) sd = getDays ( y ) while True : y += 1 if getDays ( y ) == v and sd % 7 == 0 : print ( y ) break sd += getDays ( y )   NEW_LINE +" +E559,"import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int h1 = scan . nextInt ( ) ; int a1 = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int h2 = scan . nextInt ( ) ; int a2 = scan . nextInt ( ) ; int i = 0 , heal = 0 , strike = 0 ; while ( h2 > 0 ) { if ( h1 <= a2 ) { if ( h2 <= a1 ) { h2 -= a1 ; strike ++ ; } else { h1 = h1 - a2 + c ; heal ++ ; } } else { h2 -= a1 ; h1 -= a2 ; strike ++ ; } i ++ ; } System . out . println ( i ) ; for ( i = 0 ; i < heal ; i ++ ) System . out . println ( "" HEAL "" ) ; for ( i = 0 ; i < strike ; i ++ ) System . out . println ( "" STRIKE "" ) ; } } +","h1 , a1 , c1 = map ( int , input ( ) . split ( ) ) h2 , a2 = map ( int , input ( ) . split ( ) ) i = 1 ans = 0 ans1 = [ ] while h2 > 0 : if i == 1 : if h1 - a2 > 0 : h2 -= a1 ans1 . append ( "" STRIKE "" ) ans += 1 elif h2 - a1 <= 0 : h2 -= a1 ans1 . append ( "" STRIKE "" ) ans += 1 else : h1 += c1 ans1 . append ( "" HEAL "" ) ans += 1 i = 0 elif i == 0 : h1 -= a2 i = 1 print ( ans ) for x in ans1 : print ( x ) NEW_LINE +" +E560,"import java . io . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( in . readLine ( ) ) ; long a = Integer . parseInt ( st . nextToken ( ) ) ; long b = Integer . parseInt ( st . nextToken ( ) ) ; long m = Integer . parseInt ( st . nextToken ( ) ) ;   a = Math . min ( m , a ) ; for ( long i = 0 ; i <= a ; i ++ ) { long q = ( m - ( ( ( long ) 1e9 * i ) % m ) ) % m ; if ( q > b ) { out . println ( ""1 ▁ "" + String . format ( "" % 09d "" , i ) ) ; out . close ( ) ; return ; } } out . println ( ""2"" ) ; out . close ( ) ; }   } +","a , b , m = map ( int , input ( ) . split ( ) ) c = ( 10 ** 9 ) % mans = - 1 for x in range ( 1 , min ( a + 1 , m ) ) : z = ( x * c ) % m if z == 0 : continue if z + b < m : ans = x breakif ans == - 1 : print ( 2 ) else : s = str ( ans ) s = ( '0' * 9 + s ) [ - 9 : ] print ( 1 , s ) NEW_LINE +" +E561,"import javax . xml . crypto . dsig . spec . XSLTTransformParameterSpec ; import java . util . * ;   public class Example { static int [ ] dp ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int t = sc . nextInt ( ) ; while ( t > 0 ) { t -- ; int n = sc . nextInt ( ) ; +","for i in range ( int ( input ( ) ) ) : n = int ( input ( ) ) l1 = list ( map ( int , input ( ) . split ( ) ) ) l2 = l1 . copy ( ) l2 = l2 [ : : - 1 ] c = 0 for i in range ( n ) : if ( l1 . count ( l1 [ i ] ) > 1 ) : index = n - l2 . index ( l1 [ i ] ) - 1 if ( index != i + 1 and index != i ) : c = 1 if ( c == 1 ) : print ( "" YES "" ) else : print ( "" NO "" ) NEW_LINE +" +E562,"import java . util . * ; import java . lang . * ; import java . math . * ; import java . awt . image . ConvolveOp ; import java . io . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; import java . util . * ; public class Codeforces { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader sc = new FastReader ( ) ; static int pInf = Integer . MAX_VALUE ; static int nInf = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int test = 1 ; +","n , m = map ( int , input ( ) . split ( ) ) s = [ list ( input ( ) ) for i in range ( n ) ] cnt = [ [ 0 ] * ( m + 1 ) for i in range ( n + 1 ) ] for i in range ( n ) : for j in range ( m ) : if s [ i ] [ j ] == ""1"" : cnt [ i + 1 ] [ j + 1 ] += 1 for i in range ( n ) : for j in range ( m + 1 ) : cnt [ i + 1 ] [ j ] += cnt [ i ] [ j ] for i in range ( n + 1 ) : for j in range ( m ) : cnt [ i ] [ j + 1 ] += cnt [ i ] [ j ] ans = 0 for l in range ( m + 1 ) : for r in range ( l + 1 , m + 1 ) : for u in range ( n + 1 ) : for d in range ( u + 1 , n + 1 ) : c = cnt [ d ] [ r ] - cnt [ d ] [ l ] - cnt [ u ] [ r ] + cnt [ u ] [ l ] if c == 0 : ans = max ( ans , ( r - l ) * 2 + ( d - u ) * 2 ) print ( ans ) NEW_LINE +" +E563,"import java . util . * ; import java . awt . Point ; import java . lang . Math ; import java . util . Arrays ; import java . util . Scanner ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . OutputStream ; import java . util . Comparator ; import java . math . BigInteger ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . stream . IntStream ; import java . io . IOException ; import java . util . ArrayList ; import java . math . BigInteger ; import java . util . Collections ; import java . util . StringTokenizer ; public class S { public static void main ( String [ ] args ) throws java . lang . Exception { FastScanner in = new FastScanner ( ) ; int t = in . ni ( ) ; while ( t -- > 0 ) { long n = in . nl ( ) ; long k = in . nl ( ) ; if ( n % 2 == 0 ) { n += ( 2 * k ) ; } else { long d = 0 ; while ( k > 0 ) { d = div ( n ) ; n += d ; k -- ; if ( n % 2 == 0 ) { break ; } } n = k > 0 ? n + ( 2 * k ) : n ; } System . out . println ( n ) ; } } static long div ( long n ) { long s = 3 ; while ( n % s != 0 ) { s ++ ; } return s ; } static class sortByFirst implements Comparator < Pair > {   public int compare ( Pair a , Pair b ) { return a . x - b . x ; } } static class Pair { int x ; int y ;   public Pair ( int a , int b ) { this . x = a ; this . y = b ; } }   +","import matht = int ( input ( ) ) for _ in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) num = - 1 for i in range ( 2 , math . ceil ( math . sqrt ( n ) ) + 1 ) : if ( n % i == 0 ) : num = i break k -= 1 if ( num == - 1 ) : num = n NEW_LINE +" +E564,"import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException , InterruptedException { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; for ( int i = 1 ; i < n ; i ++ ) out . print ( h * Math . sqrt ( 1.0 * i / n ) + "" ▁ "" ) ; out . close ( ) ; }   static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public Scanner ( String s ) throws FileNotFoundException { br = new BufferedReader ( new FileReader ( 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 int [ ] nextIntArray ( int n ) throws IOException { int [ ] ans = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ans [ i ] = nextInt ( ) ; return ans ; }   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 ( ) ; }   } } +","import mathn , h = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] for i in range ( n - 1 ) : print ( math . sqrt ( ( i + 1 ) / ( n ) ) * h , end = "" ▁ "" ) print ( ) NEW_LINE +" +E565,"import java . util . Scanner ; public class Solution { public static void main ( String [ ] args ) { int n , m ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { if ( i % 4 == 0 && j == 1 ) { System . out . print ( "" # "" ) ; } else if ( i % 4 == 0 ) { System . out . print ( "" . "" ) ; } else if ( i % 2 == 0 && j == m ) { System . out . print ( "" # "" ) ; } else if ( i % 2 == 0 ) { System . out . print ( "" . "" ) ; } else System . out . print ( "" # "" ) ; } System . out . println ( ) ; } } } +","a , b = map ( int , input ( ) . split ( ) ) s = ' # ' t = ' . ' flag = 0 for i in range ( a ) : if i % 2 == 0 : print ( s * b ) else : if flag == 0 : print ( t * ( b - 1 ) + s ) flag = 1 elif flag == 1 : print ( s + t * ( b - 1 ) ) flag = 0 NEW_LINE +" +E566,"import java . util . * ; import java . io . * ;   public class CFA { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; private static final long MOD = 1000L * 1000L * 1000L + 7 ; private static final int [ ] dx = { 0 , - 1 , 0 , 1 } ; private static final int [ ] dy = { 1 , 0 , - 1 , 0 } ; private static final String yes = "" Yes "" ; private static final String no = "" No "" ;   void solve ( ) { +","a00 , a01 , a10 , a11 = list ( map ( int , input ( ) . split ( ) ) ) if sum ( [ a00 , a01 , a10 , a11 ] ) == 0 : print ( 0 ) exit ( 0 ) z , j = 0 , 0 if a01 != 0 or a10 != 0 : z = j = 1 while z * ( z - 1 ) // 2 < a00 : z += 1 while j * ( j - 1 ) // 2 < a11 : j += 1 if any ( [ z * ( z - 1 ) // 2 != a00 , j * ( j - 1 ) // 2 != a11 , z * j != a10 + a01 ] ) : print ( ' Impossible ' ) exit ( 0 ) n = z + jfor i in range ( n ) : if z > 0 and a01 >= j : print ( '0' , end = ' ' ) a01 -= j z -= 1 else : print ( '1' , end = ' ' ) j -= 1 NEW_LINE +" +E567,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Reposts_522A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ;   Map < String , List < String > > adj = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] l = br . readLine ( ) . split ( "" \\ s "" ) ; String a = l [ 0 ] . toLowerCase ( ) ; String b = l [ 2 ] . toLowerCase ( ) ; if ( ! adj . containsKey ( a ) ) { adj . put ( a , new ArrayList < > ( ) ) ; } if ( ! adj . containsKey ( b ) ) { adj . put ( b , new ArrayList < > ( ) ) ; } adj . get ( b ) . add ( a ) ; +","d = { ' polycarp ' : 1 } for _ in range ( int ( input ( ) ) ) : a , b , c = input ( ) . lower ( ) . split ( ) ; d [ a ] = d [ c ] + 1 print ( max ( d . values ( ) ) ) NEW_LINE +" +E568,"import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { PrintWriter out ; FastReader sc ; long mod = ( long ) ( 1e9 + 7 ) ; long maxlong = Long . MAX_VALUE ; long minlong = Long . MIN_VALUE ; public void sol ( ) { int n = ni ( ) ; String [ ] s = new String [ n ] ; HashMap < String , ArrayList < Integer > > h = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = rl1 ( ) ; if ( h . get ( s [ i ] ) == null ) { ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( i ) ; h . put ( s [ i ] , list ) ; } else { h . get ( s [ i ] ) . add ( i ) ; } } int ans = 0 ; String [ ] ss = new String [ n ] ; HashSet < Character > has = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { has . add ( s [ i ] . charAt ( 0 ) ) ; } +","from collections import defaultdictfor _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) count = 0 l = [ ] for i in range ( n ) : l . append ( input ( ) . strip ( ) ) res = [ ] count = 0 for i in l : if i not in res : res . append ( i ) else : for j in range ( 10 ) : x = str ( j ) + i [ 1 : ] if x not in res and x not in l : count += 1 res . append ( x ) break print ( count ) for i in res : print ( i ) NEW_LINE +" +E569,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class VisitingAFriend { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int m = Integer . parseInt ( st . nextToken ( ) ) ; boolean reachable [ ] = new boolean [ 101 ] ; reachable [ 0 ] = true ; for ( int i = 0 ; i < n ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; for ( int j = a + 1 ; j <= b ; j ++ ) reachable [ j ] = true ; } for ( int i = 0 ; i <= m ; i ++ ) { if ( ! reachable [ i ] ) { pw . print ( "" NO "" ) ; pw . flush ( ) ; pw . close ( ) ; return ; } }   pw . print ( "" YES "" ) ; pw . flush ( ) ; pw . close ( ) ; } } +","n , m = map ( int , input ( ) . split ( ) ) cur_pos = 0 for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) if ( a <= cur_pos ) : if ( b > cur_pos ) : cur_pos = bif ( cur_pos == m ) : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE +" +E570,"import java . util . * ; public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { +","num = int ( input ( ) ) a = [ i for i in range ( 45 ) ] s = 1 idx = 1 while True : idx += 1 if ( s + idx > num ) : n = idx - 1 break   s += idx   left = num - s   a [ n ] += leftprint ( n ) for i in range ( 1 , n + 1 ) : print ( a [ i ] , end = "" ▁ "" ) print ( ) NEW_LINE +" +E571,"import java . util . * ; import java . util . Map . Entry ;    import java . io . * ; import java . math . * ; import static java . util . stream . Collectors . * ; import static java . util . Map . Entry . * ;   public class Main { static int k ; public static void main ( String [ ] args ) throws IOException { final long mod = ( long ) ( 1e9 + 7 ) ; Reader s = new Reader ( ) ; PrintWriter pt = new PrintWriter ( System . out ) ; +","a , b = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) a = a % 2 ans = 0 i = 1 for n in arr : x = n * a ** ( b - i ) ans += x i += 1     if ans % 2 == 1 : print ( "" odd "" ) else : print ( "" even "" ) NEW_LINE +" +E572,"import java . io . * ; import java . util . * ; public class Asd { static PrintWriter w = new PrintWriter ( System . out ) ; static FastScanner s = new FastScanner ( ) ; static HashSet < Long > list = new HashSet < > ( ) ; public static void main ( String [ ] args ) { +","lis = list ( map ( int , input ( ) . split ( ) ) ) sumall = 0 dic = { }   modulo = 1073741824 def number_of_divisors ( a ) : if a in dic : return dic [ a ] res , i , t = 1 , 2 , a while i * i <= a : r = 1 while a % i == 0 : a /= i r += 1 res = ( res * r ) % modulo i += 1 if a > 1 : res = ( res * 2 ) % modulo dic [ t ] = res return res     for i in range ( 1 , lis [ 0 ] + 1 ) : for j in range ( 1 , lis [ 1 ] + 1 ) : for k in range ( 1 , lis [ 2 ] + 1 ) : s = ( i , j , k ) sumall += number_of_divisors ( i * j * k ) print ( sumall % modulo ) NEW_LINE +" +E573,"import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   +","import sysinput = sys . stdin . readlinefrom collections import defaultdict as dcfrom collections import Counterfrom bisect import bisect_right , bisect_leftimport mathfrom operator import itemgetterfrom heapq import heapify , heappop , heappushfrom queue import PriorityQueue as pqn = int ( input ( ) ) s = input ( ) [ : - 1 ] if int ( s , 2 ) == 0 : print ( s ) else : c = 0 for i in s : if i == '0' : c += 1 l = [ '1' ] + [ '0' ] * c print ( ' ' . join ( l ) ) NEW_LINE +" +E574,"    import java . io . * ; import java . util . ArrayDeque ; import java . util . Arrays ; import java . util . InputMismatchException ; import java . util . Queue ; import java . io . * ; import java . lang . reflect . Array ; import java . math . BigInteger ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . util . Collections ; import java . io . InputStreamReader ; import java . util . logging . SimpleFormatter ;    public class Main1 {   +","n , k = map ( int , input ( ) . split ( ) )     def printDivisors ( n ) : l = [ ] i = 1 while ( i * i < n ) : if ( n % i == 0 ) : l . append ( i ) if ( len ( l ) >= k ) : break i += 1   for i in range ( int ( n ** 0.5 ) , 0 , - 1 ) : if ( n % i == 0 ) : l . append ( n // i ) if ( len ( l ) >= k ) : break return l     res = printDivisors ( n ) if len ( res ) >= k : print ( res [ k - 1 ] ) else : print ( - 1 ) NEW_LINE +" +E575,"import java . util . Scanner ;   public class problem102 {   public static void main ( String [ ] args ) { +","a = input ( ) b = input ( )   f = True   for i , j in zip ( a , b ) : if j > i : f = False break   if f : print ( b )   else : print ( - 1 ) NEW_LINE +" +E576,"import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStreamReader ; import java . nio . file . Paths ; import java . util . ArrayList ; import java . util . List ; import java . util . Stack ; import java . util . StringTokenizer ;   public class Main {   public Main ( ) throws FileNotFoundException {   +","def xuli ( ) : n = int ( input ( ) ) s = input ( ) dem1 = 0 dem2 = 0 for i in s : if i != '0' : break dem1 += 1 for i in reversed ( s ) : if i != '1' : break dem2 += 1 for i in range ( dem1 + ( dem1 + dem2 < n ) ) : print ( 0 , end = ' ' ) for i in range ( dem2 ) : print ( 1 , end = ' ' ) print ( ' ' )       t = int ( input ( ) ) while ( t > 0 ) : xuli ( ) t -= 1 NEW_LINE +" +E577,"import java . util . Scanner ;   public class SastaCoder { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int [ ] m = new int [ 5 ] ; int [ ] w = new int [ 5 ] ;   for ( int i = 0 ; i < 5 ; i ++ ) m [ i ] = scan . nextInt ( ) ; for ( int i = 0 ; i < 5 ; i ++ ) w [ i ] = scan . nextInt ( ) ;   int sum = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { sum += Math . max ( 150 * ( i + 1 ) , ( 250 - m [ i ] ) * 2 * ( i + 1 ) - 50 * w [ i ] ) ; } sum += 100 * scan . nextInt ( ) - 50 * scan . nextInt ( ) ;   System . out . println ( sum ) ; } } +","r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( ) w = r ( ) hacks = r ( )   score = 0 for i in range ( 5 ) : tot = ( 500 * ( i + 1 ) ) score += max ( 0.3 * tot , tot * ( 1 - arr [ i ] / 250 ) - 50 * w [ i ] )     score += 100 * hacks [ 0 ] score -= 50 * hacks [ 1 ]     print ( int ( score ) )   NEW_LINE +" +E578,"import java . util . * ; import java . lang . * ; import java . io . * ;   public class FastIO { BufferedReader br ; StringTokenizer st ; public FastIO ( ) { +","n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) flag = 0 for i in range ( n ) : for j in range ( n ) : if ( i == j ) : continue for k in range ( n ) : if ( i == k or j == k ) : continue if ( arr [ i ] == arr [ j ] + arr [ k ] ) : flag = 1 print ( i + 1 , j + 1 , k + 1 ) break if ( flag ) : break if ( flag ) : breakif ( flag == 0 ) : print ( - 1 ) NEW_LINE +" +E579,"import java . util . Arrays ; import java . util . Scanner ; public class B10 { static int distance ( int xc , int yc , int x , int left , int right ) { int result = 0 ; for ( int i = left ; i <= right ; i ++ ) { result += ( Math . abs ( xc - x ) + Math . abs ( yc - i ) ) ; } return result ; } public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int N = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int [ ] [ ] cinema = new int [ K ] [ K ] ; int xc = K / 2 + 1 ; int yc = xc ; int seats , min , right , left ; int [ ] request = new int [ N ] ; +","n , k = map ( int , input ( ) . split ( ) ) group = list ( map ( int , input ( ) . split ( ) ) ) available = [ [ k , 1 ] for i in range ( k + 1 ) ] center = ( k + 1 ) // 2 def calc ( center , row , col , num ) : end_col = col + num - 1 distance = abs ( center - row ) * num if col >= center : distance += ( col - center ) * num + ( num - 1 ) * num // 2 elif end_col <= center : distance += ( center - end_col ) * num + ( num - 1 ) * num // 2 else : distance += ( center - col ) * ( center - col + 1 ) // 2 + ( end_col - center ) * ( end_col - center + 1 ) // 2 return distancefor m in group : close , best_row , best_col = 10 ** 9 , - 1 , - 1 for row in range ( 1 , k + 1 ) : col = 0 if available [ row ] [ 0 ] < m and k - available [ row ] [ 1 ] + 1 < m : continue if available [ row ] [ 0 ] == k : col = center - m // 2 elif center - available [ row ] [ 0 ] <= available [ row ] [ 1 ] - center : col = available [ row ] [ 0 ] - m + 1 else : col = available [ row ] [ 1 ] distance = calc ( center , row , col , m ) if distance < close : close = distance best_row = row best_col = col if close == 10 ** 9 : print ( - 1 ) else : print ( best_row , best_col , best_col + m - 1 ) available [ best_row ] [ 0 ] = min ( available [ best_row ] [ 0 ] , best_col - 1 ) available [ best_row ] [ 1 ] = max ( available [ best_row ] [ 1 ] , best_col + m ) NEW_LINE +" +E580,"import java . util . Scanner ;   public class Fafa_And_His_Company {   public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ; +","def main ( ) : n = int ( input ( ) ) count = 0 for i in range ( 1 , n // 2 + 1 ) : if n % i == 0 : count += 1 print ( count )     if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE +" +E581,"import java . util . * ; public class p1486B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int t = sc . nextInt ( ) ; t -- > 0 ; ) { int n = sc . nextInt ( ) , x [ ] = new int [ n ] , y [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } Arrays . sort ( x ) ; Arrays . sort ( y ) ; System . out . println ( n % 2 == 1 ? 1 : ( x [ n / 2 ] - x [ n / 2 - 1 ] + 1 ) * ( long ) ( y [ n / 2 ] - y [ n / 2 - 1 ] + 1 ) ) ; } } } +","I = input NEW_LINE exec ( int ( I ( ) ) * ' n = int ( I ( ) ) ; k , m = ( 1 + x [ n > > 1 ] - x [ n - 1 > > 1 ] for ▁ x ▁ in ▁ map ( sorted , zip ( * ( map ( int , I ( ) . split ( ) ) for ▁ _ ▁ in [ 0 ] * n ) ) ) ) ; print ( k * m ) ; ' ) NEW_LINE +" +E582,"import java . util . Scanner ;   public class Main { static char c [ ] [ ] ; static int num ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; c = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = sc . next ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( c [ i ] [ j ] == ' C ' ) { count ++ ; } } for ( int j = count - 1 ; j > 0 ; j -- ) { num += j ; } } for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( c [ j ] [ i ] == ' C ' ) { count ++ ; } } for ( int j = count - 1 ; j > 0 ; j -- ) { num += j ; }   } System . out . println ( num ) ; }   } +","def fact ( n ) : if n <= 1 : return 1 else : return n * fact ( n - 1 )   def c ( n , r ) : return fact ( n ) // ( fact ( r ) * fact ( n - r ) )   n = int ( input ( ) ) arr = [ ] h = 0 for _ in range ( n ) : arr . append ( list ( input ( ) ) ) for i in arr : if i . count ( "" C "" ) >= 2 : h += c ( i . count ( "" C "" ) , 2 ) arr = list ( map ( list , zip ( * arr ) ) )   for i in arr : if i . count ( "" C "" ) >= 2 : h += c ( i . count ( "" C "" ) , 2 ) print ( h ) NEW_LINE +" +E583,"import java . awt . * ; import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . UncheckedIOException ; import java . io . Closeable ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . lang . reflect . Array ; import java . util . Arrays ;   public class water { public static long sum = 0 ; public static boolean ok = true ; public static int dps ( int a [ ] [ ] , int sx [ ] , int x , int poi ) { int add = - 1 ; if ( sx [ poi ] != - 1 && sx [ poi ] < x ) { ok = false ; } else if ( sx [ poi ] >= x ) { add = sx [ poi ] - x ; sum += add ; x = sx [ poi ] ; }   if ( a [ poi ] . length == 1 ) {   } else { int add2 = - 1 ; int lon = a [ poi ] . length - 2 ; for ( int i = 1 ; i < a [ poi ] . length ; i ++ ) { int add3 = dps ( a , sx , x , a [ poi ] [ i ] ) ; if ( add3 == - 1 ) { lon -- ; } else if ( add2 == - 1 ) { add2 = add3 ; } else if ( add3 < add2 ) add2 = add3 ; } if ( add2 >= 0 && add == - 1 ) { +","from collections import defaultdict   n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) )   clds , pars = defaultdict ( list ) , [ 0 ] * ( n + 1 ) for i in range ( n - 1 ) : cur , par = i + 2 , p [ i ] clds [ p [ i ] ] . append ( cur ) pars [ cur ] = par   ans , ok = s [ 0 ] , Truei , q = 0 , [ 1 ] while i < len ( q ) : cur = q [ i ] i += 1 par_v = s [ pars [ cur ] - 1 ] if cur in clds : mmin , summ , k = float ( ' inf ' ) , 0 , 0 for item in clds [ cur ] : mmin = min ( mmin , s [ item - 1 ] ) summ += s [ item - 1 ] k += 1 q . append ( item ) if s [ cur - 1 ] != - 1 : continue if mmin < par_v : ok = False break ans -= par_v ans += ( summ - ( k - 1 ) * mmin ) if ok : print ( ans ) else : print ( - 1 ) NEW_LINE +" +E584,"import java . util . Scanner ;   public class _0853KindAnton {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int n = sc . nextInt ( ) ; boolean pos = false ; boolean neg = false ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < n ; j ++ ) { b [ j ] = sc . nextInt ( ) ; } boolean fsuc = true ; a : { for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { if ( a [ i ] != b [ i ] ) { fsuc = false ; break a ; } } if ( a [ i ] == b [ i ] ) { if ( a [ i ] == 1 ) pos = true ; if ( a [ i ] == - 1 ) neg = true ; continue ; } else { if ( b [ i ] == 0 ) { if ( a [ i ] == 1 && neg == false || a [ i ] == - 1 && pos == false ) { fsuc = false ; break a ; } } else if ( b [ i ] > 0 ) { if ( ! pos ) { fsuc = false ; break a ; } } else { if ( ! neg ) { fsuc = false ; break a ; } } } if ( a [ i ] == 1 ) pos = true ; if ( a [ i ] == - 1 ) neg = true ; } } if ( fsuc ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } t -- ; } }   } +","for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) ans = "" YES "" s = set ( ) for i in range ( n ) : if ( b [ i ] > a [ i ] and ( 1 not in s ) or b [ i ] < a [ i ] and ( - 1 not in s ) ) : ans = "" NO "" break s . add ( a [ i ] ) print ( ans ) NEW_LINE +" +E585,"import java . io . * ;   public class Main { static String str ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   static boolean judge ( char x ) { return x >= ' A ' && x <= ' Z ' || x >= ' a ' && x <= ' z ' || x >= '0' && x <= '9' || x == ' _ ' ; }   public static void main ( String [ ] args ) throws IOException { +","def check ( txt : str ) -> bool : ln = len ( txt ) if ln == 0 or ln > 16 : return False for item in txt : if not ( ' a ' <= item <= ' z ' or ' A ' <= item <= ' Z ' or '0' <= item <= '9' or item == ' _ ' ) : return False return True     def checkHost ( hostName : str ) -> bool : hostLen = len ( hostName ) if hostLen == 0 or hostLen > 32 : return False for token in hostName . split ( ' . ' ) : if not check ( token ) : return False return True     mail = input ( ) isUser , isHost , isRes = False , False , Falseif ' @ ' in mail : atIndex = mail . index ( ' @ ' ) slashInd = mail . index ( ' / ' ) if ' / ' in mail else - 1 userName = mail [ : atIndex ] isUser = check ( userName ) hostName = mail [ atIndex + 1 : slashInd ] if slashInd != - 1 else mail [ atIndex + 1 : ] isHost = checkHost ( hostName ) if slashInd == - 1 : isRes = True else : resource = mail [ slashInd + 1 : ] isRes = check ( resource ) ''' if ▁ isUser ▁ and ▁ isHost ▁ and ▁ isRes : ▁ ▁ ▁ ▁ print ( ' YES ' ) else : ▁ ▁ ▁ ▁ print ( ' NO ' ) ''' print ( ' YES ' if isUser and isHost and isRes else ' NO ' ) NEW_LINE +" +E586,"import java . util . Scanner ;   public class A1428 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int X1 = in . nextInt ( ) ; int Y1 = in . nextInt ( ) ; int X2 = in . nextInt ( ) ; int Y2 = in . nextInt ( ) ; int dx = Math . abs ( X2 - X1 ) ; int dy = Math . abs ( Y2 - Y1 ) ; int answer = dx + dy ; if ( dx != 0 && dy != 0 ) { answer += 2 ; } System . out . println ( answer ) ; } }   } +","for _ in range ( int ( input ( ) ) ) : x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) )   if x1 == x2 : print ( abs ( y2 - y1 ) )   elif y1 == y2 : print ( abs ( x2 - x1 ) )   else : print ( abs ( x2 - x1 ) + 2 + abs ( y2 - y1 ) ) NEW_LINE +" +E587,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; a65 solver = new a65 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class a65 { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; int e = in . nextInt ( ) ; int f = in . nextInt ( ) ; int next = b * d * f ; int prev = a * c * e ; if ( c == 0 && d > 0 ) { out . println ( "" Ron "" ) ; return ; } if ( a == 0 && b > 0 && d > 0 ) { out . println ( "" Ron "" ) ; return ; } if ( prev >= next ) { out . println ( "" Hermione "" ) ; return ; } out . println ( "" Ron "" ) ; }   }   static class InputReader { private BufferedReader reader ; private StringTokenizer stt ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; }   public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { return null ; } }   public String next ( ) { while ( stt == null || ! stt . hasMoreTokens ( ) ) { stt = new StringTokenizer ( nextLine ( ) ) ; } return stt . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }   +","oro_infinito = False   datos = input ( ) . split ( ) NEW_LINE a = int ( datos [ 0 ] ) NEW_LINE b = int ( datos [ 1 ] ) NEW_LINE c = int ( datos [ 2 ] ) NEW_LINE d = int ( datos [ 3 ] ) NEW_LINE e = int ( datos [ 4 ] ) NEW_LINE f = int ( datos [ 5 ] )   if a != 0 and b != 0 and c != 0 and d != 0 and e != 0 and f != 0 : if NEW_LINE ( b / a ) * ( d / c ) * ( f / e ) > 1 : oro_infinito = Trueelse : if c == 0 and d > 0 : NEW_LINE INDENT oro_infinito = True elif a == 0 and b > 0 and c > 0 and d > 0 : NEW_LINE oro_infinito = True elif e == 0 and f > 0 and a > 0 and b > 0 and c > 0 and d > 0 : NEW_LINE oro_infinito = True   if oro_infinito : NEW_LINE print ( ' Ron ' ) else : NEW_LINE print ( ' Hermione ' ) NEW_LINE DEDENT +" +E588,"import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   long n = in . nextLong ( ) ;   if ( n == 1 ) { System . out . println ( - 1 ) ; return ; }   long even ; long odd ; if ( n % 2 == 0 ) { even = n * ( 2 + n ) / 4 ; odd = n * n / 4 ; } else { even = n / 2 * ( 2 + n - 1 ) / 2 ; odd = ( n / 2 + 1 ) * ( 1 + n ) / 2 ; } System . out . println ( even - odd ) ; } } +","n = int ( input ( ) ) if n % 2 == 0 : print ( n // 2 ) else : print ( ( n // 2 + 1 ) * ( - 1 ) )   NEW_LINE +" +E589,"  import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class experiment { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ;   +","m = input ( ) l = list ( m ) s = list ( set ( l ) ) z = 0   if ( m [ 0 ] == '4' ) : z = 1 elif ( '444' in m ) : z = 1 for i in s : if ( i == '4' or i == '1' ) : pass else : z = 1 break   if ( z == 1 ) : print ( "" NO "" ) else : print ( "" YES "" ) NEW_LINE +" +E590,"import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ;   public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gn = sc . next ( ) ; String h = sc . next ( ) ; String p = sc . next ( ) ; char [ ] a = ( gn + h ) . toCharArray ( ) ; char [ ] b = p . toCharArray ( ) ; HashMap < Character , Integer > hm1 = new HashMap ( ) ; HashMap < Character , Integer > hm2 = new HashMap < > ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int count = 1 ; if ( hm1 . containsKey ( a [ i ] ) ) { count = hm1 . get ( a [ i ] ) ; count ++ ; } hm1 . put ( a [ i ] , count ) ; } for ( int j = 0 ; j < b . length ; j ++ ) { int count = 1 ; if ( hm2 . containsKey ( b [ j ] ) ) { count = hm2 . get ( b [ j ] ) ; count ++ ; } hm2 . put ( b [ j ] , count ) ; } if ( hm1 . equals ( hm2 ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; }    } } +","a = [ i for i in input ( ) ] b = [ i for i in input ( ) ]   ab = [ i for i in input ( ) ]   c = a + b   ab . sort ( ) c . sort ( )   if ab == c : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE +" +E591,"import java . io . * ; import java . math . * ; import java . util . * ;     public class Main {   private static int dx [ ] = { 1 , 0 , - 1 , 0 } ; private static int dy [ ] = { 0 , - 1 , 0 , 1 } ;   private static final long INF = Long . MAX_VALUE ; private static final int INT_INF = Integer . MAX_VALUE ; private static final long NEG_INF = Long . MIN_VALUE ; private static final int NEG_INT_INF = Integer . MIN_VALUE ; private static final double EPSILON = 1e-10 ;   private static final int MAX = 2000007 ; private static final long MOD = 1000000007 ;   private static final int MAXN = 100007 ; private static final int MAXA = 10000009 ; private static final int MAXLOG = 22 ;   public static void main ( String [ ] args ) throws IOException {   InputReader in = new InputReader ( System . in ) ; +","def equal ( a , b ) : for i in range ( len ( a ) ) : if a [ i ] != b [ i ] and a [ i ] != "" * "" and b [ i ] != "" * "" : return False return True   string , k , best = input ( ) . strip ( ) , int ( input ( ) ) , 0 string += "" * "" * kfor i in range ( len ( string ) + 1 ) : for j in range ( i + 1 , len ( string ) + 1 ) : if not ( j - i ) % 2 : if equal ( string [ i : ( i + j ) // 2 ] , string [ ( i + j ) // 2 : j ] ) : best = max ( best , j - i ) print ( best ) NEW_LINE +" +E592,"import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } long sum = ar [ n - 1 ] ; long thresh = ar [ n - 1 ] - 1 ; for ( int j = n - 2 ; j >= 0 ; j -- ) {   if ( thresh <= 0 ) { break ; } sum = sum + Math . min ( ar [ j ] , thresh ) ; thresh = Math . min ( ar [ j ] , thresh ) - 1 ;    } System . out . println ( sum ) ;    }   public static void Mybfs ( List < List < Integer > > lists , int source , int [ ] dist , boolean [ ] visited ) { dist [ source ] = 0 ; +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) res = 0 for j in range ( n - 2 , - 1 , - 1 ) : if a [ j ] >= a [ j + 1 ] : a [ j ] = max ( 0 , a [ j + 1 ] - 1 ) print ( sum ( a ) ) NEW_LINE +" +E593,"import java . io . * ; import java . util . * ; import java . lang . * ;   public class B {   public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) ; if ( false ) out . println ( "" NO "" ) ; else { char [ ] [ ] board = new char [ 4 ] [ n ] ; for ( int i = 0 ; i < 4 ; i ++ ) Arrays . fill ( board [ i ] , ' . ' ) ; out . println ( "" YES "" ) ; for ( int i = 1 ; i < ( n / 2 ) ; i ++ ) { if ( k < 2 ) break ; board [ 1 ] [ i ] = ' # ' ; board [ 1 ] [ n - 1 - i ] = ' # ' ; k -= 2 ; } for ( int i = 1 ; i < ( n / 2 ) ; i ++ ) { if ( k < 2 ) break ; board [ 2 ] [ i ] = ' # ' ; board [ 2 ] [ n - 1 - i ] = ' # ' ; k -= 2 ; } if ( k % 2 != 0 ) { if ( board [ 1 ] [ n / 2 ] == ' . ' ) board [ 1 ] [ n / 2 ] = ' # ' ; else board [ 2 ] [ n / 2 ] = ' + ' ; } else if ( k != 0 ) { board [ 1 ] [ n / 2 ] = ' # ' ; board [ 2 ] [ n / 2 ] = ' # ' ; } for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) out . print ( board [ i ] [ j ] ) ; out . println ( ) ; } } out . close ( ) ; }   static final Random random = new Random ( ) ; +","n , k = map ( int , input ( ) . split ( ) ) if ( k % 2 == 0 ) : print ( "" YES "" ) print ( ' . ' * n ) print ( ' . ' + ' # ' * ( k // 2 ) + ' . ' * ( n - 1 - k // 2 ) ) print ( ' . ' + ' # ' * ( k // 2 ) + ' . ' * ( n - 1 - k // 2 ) ) print ( ' . ' * n ) else : print ( "" YES "" ) print ( ' . ' * n ) if ( k <= n - 2 ) : print ( ' . ' * ( ( n - k ) // 2 ) + ' # ' * k + ' . ' * ( ( n - k ) // 2 ) ) print ( ' . ' * n ) else : print ( ' . ' + ' # ' * ( n - 2 ) + ' . ' ) print ( ' . ' + ' # ' * ( ( k - n + 2 ) // 2 ) + ' . ' * ( n - 2 - k + n - 2 ) + ' # ' * ( ( k - n + 2 ) // 2 ) + ' . ' ) print ( ' . ' * n ) NEW_LINE +" +E594,"import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskA { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int T = 1 ; while ( T -- > 0 ) { solveOne ( in , out ) ; } }   private void solveOne ( Scanner in , PrintWriter out ) { int k = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int v = in . nextInt ( ) ;   int box = 0 ; while ( a > 0 ) { int divisor = 0 ; if ( b > 0 ) { divisor = Math . min ( k - 1 , b ) ; b -= k - 1 ; } int sections = 1 + divisor ; a -= sections * v ; box ++ ; } out . println ( box ) ;    }   } }   +","sections , a , divisors , cap = map ( int , input ( ) . split ( ) )   NEW_LINE +" +E595,"import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; long ans = 1L ; if ( b - a >= 10 ) { System . out . println ( ""0"" ) ; } else { for ( long i = a + 1 ; i <= b ; i ++ ) { ans = ans * ( i % 10 ) ; } ans = ans % 10 ; System . out . println ( ans ) ; } } } +","a , b = [ int ( x ) for x in input ( ) . split ( ) ]   x = b % 10 mul = 1 for i in range ( b , a , - 1 ) : mul *= x x -= 1 if x < 0 and i > a : print ( ""0"" ) mul = - 1 breakif mul != - 1 : mul = mul % 10 print ( mul ) NEW_LINE +" +E596,"import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . LinkedHashMap ; import java . util . Map ; import java . util . Scanner ; import java . util . * ; import java . util . stream . Collectors ;   public class absolute {   public static void main ( String [ ] args ) { +","n = int ( input ( ) ) a = pow ( 1 , n , 5 ) b = pow ( 2 , n , 5 ) c = pow ( 3 , n , 5 ) d = pow ( 4 , n , 5 ) print ( ( a + b + c + d ) % 5 )   NEW_LINE +" +E597,"import java . util . Scanner ;   public class TemporarilyUnavailable { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int testCase = scanner . nextInt ( ) ; for ( int i = 0 ; i < testCase ; i ++ ) { System . out . println ( solve ( scanner . nextInt ( ) , scanner . nextInt ( ) , scanner . nextInt ( ) , scanner . nextInt ( ) ) ) ; } }   public static int solve ( int a , int b , int c , int r ) {   if ( a == b ) return 0 ;   int min , max ; if ( a > b ) { max = a ; min = b ; } else { max = b ; min = a ; } int result = Math . abs ( a - b ) ; int plus = c + r ; int minus = c - r ;   if ( min <= minus && plus <= max ) return result - 2 * r ; if ( min >= plus || max <= minus ) return result ; if ( min > minus ) { if ( plus < max ) return result - ( plus - min ) ; else return 0 ; } else return result - ( max - minus ) ; } } +","cases = int ( input ( ) ) while cases : cases -= 1 a , b , c , r = map ( int , input ( ) . split ( ) )   if a > b : a , b = b , a   pot = b - a   cl = c - r cr = c + r   if a <= cl <= cr <= b : ans = b - a - ( cr - cl ) elif cl <= a <= cr <= b : ans = b - cr elif a <= cl <= b <= cr : ans = cl - a elif cl <= a <= b <= cr : ans = 0 else : ans = b - a   print ( ans ) NEW_LINE +" +E598,"import java . lang . reflect . Array ; import java . util . * ;   public class Main { private static Scanner in = new Scanner ( System . in ) ;   +","import mathimport collections def solve ( n , l ) : return max ( l ) - ( sum ( l ) - max ( l ) ) + 1   n = int ( input ( ) ) l = [ int ( s ) for s in input ( ) . split ( ) ] result = solve ( n , l ) print ( result ) NEW_LINE +" +E599,"import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ;   Set < Integer > set = new HashSet < > ( ) ; PriorityQueue < Integer > pq = new PriorityQueue ( Collections . reverseOrder ( ) ) ; int n = s . nextInt ( ) ;   int i = 0 ; while ( pq . size ( ) != 2 && i < n ) { int x = s . nextInt ( ) ; if ( ! set . contains ( x ) ) { set . add ( x ) ; pq . offer ( x ) ; } i ++ ; }   while ( i < n ) { int x = s . nextInt ( ) ; if ( ! set . contains ( x ) ) { set . add ( x ) ; if ( x < pq . peek ( ) ) { pq . offer ( x ) ; pq . poll ( ) ; } } i ++ ; }   if ( set . size ( ) <= 1 ) System . out . println ( "" NO "" ) ; else { System . out . println ( pq . peek ( ) ) ; }   s . close ( ) ; } } +","def main_funtion ( ) : n = int ( input ( ) ) s = [ int ( i ) for i in input ( ) . split ( "" ▁ "" ) ] minimum = min ( s ) the_val = 10000000000000 for i in s : if i > minimum and i < the_val : the_val = i if the_val == 10000000000000 : return "" NO "" return the_val     print ( main_funtion ( ) ) NEW_LINE +" +E600,"import java . util . * ; public class PolycarpTraining { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int size = sc . nextInt ( ) ; Integer [ ] arr = new Integer [ size ] ; for ( int i = 0 ; i < size ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; int index = 1 ; for ( int i = 0 ; i < size ; i ++ ) { if ( arr [ i ] >= index ) { index ++ ; } } System . out . println ( index - 1 ) ; } } +","n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) cur = 1 for i in range ( n ) : if a [ i ] >= cur : cur += 1 print ( cur - 1 ) NEW_LINE +" +E601,"import java . io . * ; import java . util . * ;   public class ProblemA {   BufferedReader in ; PrintWriter out ; StringTokenizer ss ;   String _token ( ) throws IOException { while ( ! ss . hasMoreTokens ( ) ) ss = new StringTokenizer ( in . readLine ( ) ) ; return ss . nextToken ( ) ; }   int _int ( ) throws IOException { return Integer . parseInt ( _token ( ) ) ; }   void RUN ( ) throws IOException { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; ss = new StringTokenizer ( "" ▁ "" ) ;   int n = _int ( ) ; int k = _int ( ) ; int c = _int ( ) ; int a [ ] = new int [ 366 ] ; a [ 0 ] = 1 ; for ( int i = 0 ; i < c ; i ++ ) a [ _int ( ) ] ++ ; int it = 0 ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( a [ i ] != 0 ) { it = 0 ; ans ++ ; } else { it ++ ; }   if ( it == k ) { it = 0 ; ans ++ ; } } out . println ( ans ) ; out . close ( ) ; }   public static void main ( String [ ] args ) throws Exception { try { new ProblemA ( ) . RUN ( ) ; } catch ( Exception e ) { System . out . println ( "" RE "" ) ; } }   } +","entrada1 = input ( ) . split ( ) NEW_LINE n , k = int ( entrada1 [ 0 ] ) , int ( entrada1 [ 1 ] )   entrada2 = input ( ) . split ( ) NEW_LINE c = int ( entrada2 [ 0 ] ) NEW_LINE festivos = [ ] NEW_LINE for i in range ( c ) : festivos . append ( int ( entrada2 [ i + 1 ] ) )   regalos = 0 NEW_LINE k_esimo = 0 NEW_LINE f = 0   i = 1 NEW_LINE while i <= n : if NEW_LINE f < c and i == festivos [ f ] : regalos = regalos + 1 NEW_LINE f = f + 1 NEW_LINE k_esimo = 0 else : k_esimo = k_esimo + 1 NEW_LINE if k_esimo == k : regalos = regalos + 1 NEW_LINE k_esimo = 0 NEW_LINE i = i + 1 NEW_LINE print ( regalos ) NEW_LINE +" +E602,"n , k = map ( int , input ( ) . split ( ) ) if ( n == k ) : print ( ""1"" * n ) exit ( ) a = ( n - k ) >> 1 i = 0 Ans = "" "" while ( i < n ) : Ans += ""0"" * ( a ) i += a if ( i > n - 1 ) : break Ans += ""1"" i += 1 if ( i > n - 1 ) : breakprint ( Ans [ : n ] ) +","n , k = map ( int , input ( ) . split ( ) ) e = ( n - k ) // 2 c = ""0"" * e + ""1"" while ( len ( c ) <= n ) : c = c + cprint ( c [ : n ] ) NEW_LINE +" +E603,"import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; char [ ] ch = sc . next ( ) . toCharArray ( ) ; boolean f = true ; for ( int i = k ; i < n ; i ++ ) { if ( ch [ i ] == ' ? ' || ch [ i ] == ch [ i % k ] ) continue ; else if ( ch [ i % k ] == ' ? ' ) { ch [ i % k ] = ch [ i ] ; } else { f = false ; break ; } } if ( ! f ) { System . out . println ( "" NO "" ) ; continue ; } else { int s0 = 0 , s1 = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( ch [ i ] == '0' ) s0 ++ ; else if ( ch [ i ] == '1' ) s1 ++ ; } if ( s0 > k / 2 || s1 > k / 2 ) { System . out . println ( "" NO "" ) ; } else { System . out . println ( "" YES "" ) ; } } } } }   +","for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) ; s = input ( ) ; l = [ 0 ] * k ; f = k NEW_LINE for i in range ( k ) : v = [ ] ; c = 0 NEW_LINE for j in s [ i : : k ] : if NEW_LINE j != ' ? ' : NEW_LINE if j not in v : v += [ j ] ; c += 1 NEW_LINE if c > 1 : NEW_LINE INDENT break else : NEW_LINE if NEW_LINE DEDENT v : l [ i ] = ( - 1 ) ** int ( v [ 0 ] ) ; NEW_LINE f -= 1 NEW_LINE continue NEW_LINE break else : print ( [ "" NO "" , "" YES "" ] [ abs ( sum ( l ) ) <= f ] ) ; NEW_LINE continue NEW_LINE print ( "" NO "" ) NEW_LINE +" +E604,"import java . io . * ; import java . util . * ;    public class test { int INF = ( int ) 1e9 ; long MOD = 1000000007 ; void solve ( InputReader in , PrintWriter out ) throws IOException { long p = in . nextLong ( ) ; long k = in . nextInt ( ) ; ArrayList < Long > rs = new ArrayList < > ( ) ; while ( p != 0 ) { long r = p % k ; if ( r < 0 ) r += k ; rs . add ( r % k ) ; p -= ( r % k ) ; p /= k ; p *= - 1 ; } out . println ( rs . size ( ) ) ; for ( long x : rs ) out . print ( x + "" ▁ "" ) ; out . println ( ) ; } public static void main ( String [ ] args ) throws IOException { if ( args . length > 0 && args [ 0 ] . equalsIgnoreCase ( "" d "" ) ) { DEBUG_FLAG = true ; } InputReader in = new InputReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int t = 1 ; +","p , k = input ( ) . split ( ) p , k = int ( p ) , int ( k ) s = k - 1 ls = [ 0 ] while s < p : ls . append ( 0 ) ls . append ( 0 ) s = s * k * k + k - 1 n = len ( ls ) for i in range ( n ) : if ( i & 1 ) == 0 : ls [ i ] = k - 1 res = s - pfor i in range ( n ) : t = res % k if i & 1 : ls [ i ] += t else : ls [ i ] -= t res //= kprint ( n ) print ( "" ▁ "" . join ( str ( x ) for x in ls ) )   NEW_LINE +" +E605,"import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] a = new int [ n ] ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; String s = Integer . toString ( a [ i ] ) ; int cnt = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( j ) == '4' || s . charAt ( j ) == '7' ) { cnt ++ ; } } if ( cnt <= k ) ans ++ ; } System . out . println ( ans ) ;    } } +","def insertion_sort ( l ) : for i in range ( len ( l ) ) : for j in ( range ( i ) ) : k = i - j if l [ k ] >= l [ k - 1 ] : l [ k - 1 ] , l [ k ] = l [ k ] , l [ k - 1 ] else : break return l       def selection_sort ( l ) : for i in range ( len ( l ) ) : min_ind = i min_val = l [ i ] for j in range ( i , len ( l ) ) : if min_val > l [ j ] : min_val = l [ j ] min_ind = j l [ i ] , l [ min_ind ] = l [ min_ind ] , l [ i ] return l     def bubble_sort ( l ) : for i in range ( len ( l ) - 1 ) : for j in range ( len ( l ) - 1 - i ) : if l [ j ] > l [ j + 1 ] : l [ j ] , l [ j + 1 ] = l [ j + 1 ] , l [ j ] return l     NEW_LINE +" +E606,"import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . List ; import java . util . StringTokenizer ;   public class VasyaAndWrestling { public static void main ( String [ ] args ) { FastReader ( ) ; int t = 1 ; while ( t > 0 ) { solve ( ) ; -- t ; } write . flush ( ) ; write . close ( ) ; } static void solve ( ) { int n = ni ( ) ; int m = ni ( ) ; int a [ ] = ina ( n ) ; int b [ ] = ina ( m ) ; int i = 0 , j = 0 ; while ( i < n && j < m ) { if ( a [ i ] <= b [ j ] ) { ++ i ; ++ j ; } else { ++ j ; } } out ( n - i ) ; } +","import sysinput = sys . stdin . readlinedef inp ( ) : return ( int ( input ( ) ) ) def inlt ( ) : return ( list ( map ( int , input ( ) . split ( ) ) ) ) def insr ( ) : s = input ( ) return ( list ( s [ : len ( s ) - 1 ] ) ) def invr ( ) : return ( map ( int , input ( ) . split ( ) ) )   inp = invr ( ) inp = [ x for x in inp ] req = inlt ( ) prepared = inlt ( )     j = 0 i = 0 while i < inp [ 0 ] and j < inp [ 1 ] : if req [ i ] <= prepared [ j ] : i += 1 j += 1 print ( inp [ 0 ] - i )     NEW_LINE +" +E607,"import java . math . BigInteger ; import java . util . * ; public class _1238A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { BigInteger x = new BigInteger ( sc . next ( ) ) ; BigInteger y = new BigInteger ( sc . next ( ) ) ; if ( ( x . subtract ( y ) ) . equals ( BigInteger . ONE ) ) System . out . println ( "" NO "" ) ; else System . out . println ( "" YES "" ) ; } } } +","in_tests = int ( input ( ) )   for i in range ( in_tests ) : [ x , y ] = input ( ) . split ( ) if int ( x ) - int ( y ) == 1 : print ( ' NO ' ) else : print ( ' YES ' )   NEW_LINE +" +E608,"import java . io . IOException ; import java . io . InputStream ; import java . util . StringTokenizer ;    import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; public class Main { static int maxn = ( int ) ( 1e5 + 5 ) ; static int [ ] t = new int [ maxn ] ; static int [ ] l = new int [ maxn ] ; static int [ ] r = new int [ maxn ] ; public static void main ( String [ ] args ) { InputStream inputStream = System . in ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int s = in . nextInt ( ) ; int f = in . nextInt ( ) ; for ( int i = 1 ; i <= m ; ++ i ) { t [ i ] = in . nextInt ( ) ; l [ i ] = in . nextInt ( ) ; r [ i ] = in . nextInt ( ) ; } int pos = s , p = 0 ; for ( int i = 1 ; pos != f ; ++ i ) { while ( p <= m && t [ p ] < i ) { ++ p ; } if ( pos < f ) { if ( p > m || t [ p ] != i || ( t [ p ] == i && ( l [ p ] > pos + 1 || r [ p ] < pos ) ) ) { out . print ( ' R ' ) ; ++ pos ; } else { out . print ( ' X ' ) ; } } else { if ( p > m || t [ p ] != i || ( t [ p ] == i && ( l [ p ] > pos || r [ p ] < pos - 1 ) ) ) { out . print ( ' L ' ) ; -- pos ; } else { out . print ( ' X ' ) ; } } } out . flush ( ) ; out . close ( ) ; +","n , m , s , f = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( m ) : t , c , r = map ( int , input ( ) . split ( ) ) l . append ( [ t , c , r ] ) if s > f : st = "" "" t = 1 i = 0 while ( i < m ) : if t == l [ i ] [ 0 ] : if ( s < l [ i ] [ 1 ] or s > l [ i ] [ 2 ] ) and ( s - 1 < l [ i ] [ 1 ] or s - 1 > l [ i ] [ 2 ] ) : s -= 1 st += "" L "" else : st += "" X "" i += 1 if s == f : break else : st += ' L ' s -= 1 if s == f : break t += 1 while ( s > f ) : s -= 1 st += ' L ' print ( st ) if s < f : st = "" "" t = 1 i = 0 while ( i < m ) : if t == l [ i ] [ 0 ] : if ( s < l [ i ] [ 1 ] or s > l [ i ] [ 2 ] ) and ( s + 1 < l [ i ] [ 1 ] or s + 1 > l [ i ] [ 2 ] ) : s += 1 st += "" R "" else : st += "" X "" i += 1 if s == f : break else : st += ' R ' s += 1 if s == f : break t += 1 while ( s < f ) : s += 1 st += ' R ' print ( st ) NEW_LINE +" +E609,"n , m = map ( int , input ( ) . split ( ) ) a = [ 10 * * 9 for _ in range ( n ) ] extra = [ 0 for _ in range ( n ) ] query = list ( ) for _ in range ( m ) : t , l , r , x = map ( int , input ( ) . split ( ) ) l -= 1 r -= 1 query . append ( ( t , l , r , x ) ) if t == 1 : for j in range ( l , r + 1 ) : extra [ j ] += x else : for j in range ( l , r + 1 ) : a [ j ] = min ( a [ j ] , x - extra [ j ] ) extra = a . copy ( ) for t , l , r , x in query : if t == 1 : for j in range ( l , r + 1 ) : a [ j ] += x else : val = - 10 * * 9 for j in range ( l , r + 1 ) : val = max ( val , a [ j ] ) if not val == x : print ( ' NO ' ) exit ( 0 )   print ( ' YES ' ) for x in extra : print ( x , end = ' ▁ ' ) +","n , m = map ( int , input ( ) . split ( ) ) a = [ 10 ** 9 for _ in range ( n ) ] extra = [ 0 for _ in range ( n ) ] query = list ( ) for _ in range ( m ) : t , l , r , x = map ( int , input ( ) . split ( ) ) l -= 1 r -= 1 query . append ( ( t , l , r , x ) ) if t == 1 : for j in range ( l , r + 1 ) : extra [ j ] += x else : for j in range ( l , r + 1 ) : a [ j ] = min ( a [ j ] , x - extra [ j ] ) extra = a . copy ( ) for t , l , r , x in query : if t == 1 : for j in range ( l , r + 1 ) : a [ j ] += x else : val = - 10 ** 9 for j in range ( l , r + 1 ) : val = max ( val , a [ j ] ) if not val == x : print ( ' NO ' ) exit ( 0 )   print ( ' YES ' ) for x in extra : print ( x , end = ' ▁ ' ) NEW_LINE +" +E610,"import java . util . * ;   public class TestCodeforces {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   String s = scanner . nextLine ( ) ; String s2 = scanner . nextLine ( ) ;   int i = s . length ( ) - 1 , j = s2 . length ( ) - 1 ;   while ( i >= 0 && j >= 0 ) { if ( s . charAt ( i ) == s2 . charAt ( j ) ) { i -- ; j -- ; } else break ; } System . out . println ( i + j + 2 ) ;   scanner . close ( ) ; }   } +","a = input ( ) b = input ( ) res = 0 la = len ( a ) lb = len ( b ) sum = la + lb   if la > lb : for i in range ( lb - 1 , - 1 , - 1 ) : la = la - 1 if b [ i ] == a [ la ] : res = res + 1 else : break res = sum - 2 * res print ( res ) else : for i in range ( la - 1 , - 1 , - 1 ) : lb = lb - 1 if a [ i ] == b [ lb ] : res = res + 1 else : break res = sum - 2 * res print ( res )   NEW_LINE +" +E611,"import java . io . * ;   public class CF { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long [ ] sequence = { 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8092 , 16184 , 32368 , 64736 , 129472 , 258944 , 517888 , 1035776 , 2071552 , 4143104 , 8286208 , 16572416 , 33144832 , 66289664 , 132579328 , 265158656 , 530317312 , 1060634624 , 2121269248 , 4242538496L , 8485076992L , 16970153984L , 33940307968L } ; System . out . println ( sequence [ Integer . parseInt ( br . readLine ( ) ) ] ) ; } }   +","n = int ( input ( ) ) print ( int ( 2 ** n - ( n > 12 ) * 2 ** ( n - 13 ) * 100 ) ) NEW_LINE +" +E612,"import java . util . Arrays ; import java . util . Scanner ;   public class _0833IlyaandQueries { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . nextLine ( ) . toCharArray ( ) ; long [ ] oriArr = new long [ str . length + 1 ] ; oriArr [ 1 ] = 1 ; for ( int i = 1 ; i < str . length ; i ++ ) { if ( str [ i ] == str [ i - 1 ] ) { oriArr [ i + 1 ] = oriArr [ i ] + 1 ; } else { oriArr [ i + 1 ] = oriArr [ i ] ; } } int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; System . out . println ( oriArr [ r ] - oriArr [ l ] ) ; } }   } +","l = lenimport sysc = sys . stdin . readline ( ) d = [ 0 ] * l ( c ) p = c [ 0 ] for i , t in enumerate ( c [ 1 : ] ) : d [ i + 1 ] = d [ i ] + 1 * ( t == p ) p = tfor _ in range ( int ( sys . stdin . readline ( ) ) ) : l , r = map ( int , sys . stdin . readline ( ) . split ( ) ) sys . stdout . write ( str ( d [ r - 1 ] - d [ l - 1 ] ) + "" \n "" ) NEW_LINE +" +E613,"import java . util . * ;   public class Example { static int [ ] dp ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; +","N , M = ( int ( x ) for x in input ( ) . split ( ) ) A = [ int ( x ) for x in input ( ) . split ( ) ] t = 0 prev = 1   for i , task in enumerate ( A ) : if not task < prev : t += task - prev prev = task else : t += N - prev t += task prev = taskprint ( t ) NEW_LINE +" +E614,"import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { int x , y , z ; Student ( int x , int y , int z ) { this . x = x ; this . y = y ; this . z = z ; } } static int prime [ ] ; static void sieveOfEratosthenes ( int n ) { +","import queue   class Query : def __init__ ( self , t , d , id ) : self . t = t self . d = d self . id = id   n , b = map ( int , input ( ) . split ( ) ) a = [ ] for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) a . append ( Query ( x , y , i ) )   i = 0 cur_time = 0 q = queue . Queue ( ) result = [ 0 ] * nwhile i < n : while i < n and a [ i ] . t < cur_time and q . qsize ( ) < b : q . put ( a [ i ] ) i += 1 while i < n and a [ i ] . t < cur_time and q . qsize ( ) == b : result [ i ] = - 1 i += 1 if not q . empty ( ) : processed_query = q . get ( ) cur_time += processed_query . d result [ processed_query . id ] = cur_time else : if i < n : cur_time = a [ i ] . t + a [ i ] . d result [ a [ i ] . id ] = cur_time i += 1 while not q . empty ( ) : processed_query = q . get ( ) cur_time += processed_query . d result [ processed_query . id ] = cur_time for i in range ( n ) : print ( result [ i ] , end = ' ▁ ' ) NEW_LINE +" +E615,"import java . util . Scanner ;   public class PoloPenguinStringMaker { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int k = scan . nextInt ( ) ;   if ( k == 1 ) { if ( n == 1 ) { System . out . println ( "" a "" ) ; } else System . out . println ( - 1 ) ; return ; } if ( k > n ) { System . out . println ( - 1 ) ; return ; } StringBuilder ans = new StringBuilder ( ) ;   for ( int i = 0 ; i < n - k + 2 ; i ++ ) { if ( i % 2 == 0 ) ans . append ( ' a ' ) ; else ans . append ( ' b ' ) ; }   char c = ' c ' ; for ( int i = 0 ; i < k - 2 ; i ++ ) { ans . append ( c ) ; c ++ ; }   System . out . println ( ans ) ; } } +","import sys   n , k = map ( int , sys . stdin . readline ( ) . split ( ) ) if k > n or ( k == 1 and n != 1 ) : print ( - 1 ) else : l = [ "" ▁ "" for i in range ( n ) ] last = ord ( "" a "" ) + k - 1 m = n - 1 for i in range ( k - 2 ) : l [ m ] = chr ( last - i ) m -= 1 start = ord ( "" a "" ) for i in range ( n ) : if l [ i ] != "" ▁ "" : break else : l [ i ] = chr ( start ) if i % 2 == 1 : start -= 1 else : start += 1 print ( "" "" . join ( l ) ) NEW_LINE +" +E616,"import java . util . Scanner ;   public class mahmoudAndLongestUncommonSubsequence { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String value1 = sc . next ( ) ; String value2 = sc . next ( ) ; if ( value1 . equals ( value2 ) ) { System . out . println ( - 1 ) ; } else if ( value1 . length ( ) > value2 . length ( ) ) { System . out . println ( value1 . length ( ) ) ; } else { System . out . println ( value2 . length ( ) ) ; } } } +",""""""" ▁ Created ▁ by ▁ Henrikh ▁ Kantuni ▁ on ▁ 2/7/17 ▁ """"""   a = input ( ) b = input ( ) ans = - 1 if a == b else max ( len ( a ) , len ( b ) ) print ( ans ) NEW_LINE +" +E617,"import java . io . * ; import java . util . * ; import java . util . Scanner ; import java . util . Arrays ;   public class cas { public static void main ( String [ ] args ) { +","print ( * input ( ) . split ( ' WUB ' ) ) NEW_LINE +" +E618,"import java . lang . * ; import java . util . * ; class GFG { static long findSum ( int n ) { long sum2 , sum5 , sum10 ; sum2 = ( ( n / 2 ) * ( 4 + ( n / 2 - 1 ) * 2 ) ) / 2 ; sum5 = ( ( n / 5 ) * ( 10 + ( n / 5 - 1 ) * 5 ) ) / 2 ; sum10 = ( ( n / 10 ) * ( 20 + ( n / 10 - 1 ) * 10 ) ) / 2 ; return sum2 + sum5 - sum10 ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( findSum ( n ) ) ; } } +","def findSum ( n ) : NEW_LINE INDENT sum2 = ( ( n // 2 ) * ( 4 + ( n // 2 - 1 ) * 2 ) ) // 2 NEW_LINE sum5 = ( ( n // 5 ) * ( 10 + ( n // 5 - 1 ) * 5 ) ) // 2 NEW_LINE sum10 = ( ( n // 10 ) * ( 20 + ( n // 10 - 1 ) * 10 ) ) // 2 NEW_LINE return sum2 + sum5 - sum10 ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE print ( int ( findSum ( n ) ) ) NEW_LINE DEDENT +" +E619,"class GFG { static int waysToSplit ( String s ) { int n = s . length ( ) ; int answer = 0 ; int prefix [ ] = new int [ n ] ; int suffix [ ] = new int [ n ] ; int seen [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { int prev = ( i - 1 >= 0 ? prefix [ i - 1 ] : 0 ) ; if ( seen [ s . charAt ( i ) - ' a ' ] == 0 ) { prefix [ i ] += ( prev + 1 ) ; } else prefix [ i ] = prev ; seen [ s . charAt ( i ) - ' a ' ] = 1 ; } for ( int i = 0 ; i < 26 ; i ++ ) seen [ i ] = 0 ; suffix [ n - 1 ] = 0 ; for ( int i = n - 1 ; i >= 1 ; i -- ) { int prev = suffix [ i ] ; if ( seen [ s . charAt ( i ) - ' a ' ] == 0 ) { suffix [ i - 1 ] += ( prev + 1 ) ; } else suffix [ i - 1 ] = prev ; seen [ s . charAt ( i ) - ' a ' ] = 1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( prefix [ i ] == suffix [ i ] ) answer ++ ; } return answer ; } public static void main ( String [ ] args ) { String s = "" ababa "" ; System . out . println ( waysToSplit ( s ) ) ; } } +","def waysToSplit ( s ) : NEW_LINE INDENT n = len ( s ) ; NEW_LINE answer = 0 ; NEW_LINE prefix = [ 0 ] * n ; NEW_LINE suffix = [ 0 ] * n ; NEW_LINE seen = [ 0 ] * 26 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT prev = prefix [ i - 1 ] if ( i - 1 >= 0 ) else 0 ; NEW_LINE if ( seen [ ord ( s [ i ] ) - ord ( ' a ' ) ] == 0 ) : NEW_LINE INDENT prefix [ i ] += ( prev + 1 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT prefix [ i ] = prev ; NEW_LINE DEDENT seen [ ord ( s [ i ] ) - ord ( ' a ' ) ] = 1 ; NEW_LINE DEDENT seen = [ 0 ] * len ( seen ) ; NEW_LINE suffix [ n - 1 ] = 0 ; NEW_LINE for i in range ( n - 1 , 0 , - 1 ) : NEW_LINE INDENT prev = suffix [ i ] ; NEW_LINE if ( seen [ ord ( s [ i ] ) - ord ( ' a ' ) ] == 0 ) : NEW_LINE INDENT suffix [ i - 1 ] += ( prev + 1 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT suffix [ i - 1 ] = prev ; NEW_LINE DEDENT seen [ ord ( s [ i ] ) - ord ( ' a ' ) ] = 1 ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( prefix [ i ] == suffix [ i ] ) : NEW_LINE INDENT answer += 1 ; NEW_LINE DEDENT DEDENT return answer ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" ababa "" ; NEW_LINE print ( waysToSplit ( s ) ) ; NEW_LINE DEDENT +" +E620,"public class GFG { static boolean check ( int a [ ] , int n ) { if ( n % 2 == 1 ) return false ; for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( a [ i ] != a [ i + ( n / 2 ) ] ) return false ; } return true ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 4 , 1 , 4 } ; int n = a . length ; if ( check ( a , n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","def check ( a , n ) : NEW_LINE INDENT if n % 2 == 1 : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( n // 2 ) : NEW_LINE INDENT if a [ i ] != a [ i + ( n // 2 ) ] : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , 4 , 1 , 4 ] NEW_LINE n = len ( a ) NEW_LINE if check ( a , n ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E621,"import java . io . * ; class GFG { static boolean solve ( int n , int k ) { if ( n >= ( k * ( k + 1 ) ) / 2 ) { return true ; } return false ; } public static void main ( String [ ] args ) { int n = 12 , k = 4 ; if ( solve ( n , k ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def solve ( n , k ) : NEW_LINE INDENT if ( n >= ( k * ( k + 1 ) ) // 2 ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 12 NEW_LINE k = 4 NEW_LINE if ( solve ( n , k ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E622,"import java . io . * ; import java . util . * ; class GFG { static void numbersWith3Divisors ( int n ) { boolean [ ] prime = new boolean [ n + 1 ] ; Arrays . fill ( prime , true ) ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } System . out . println ( "" Numbers ▁ with ▁ 3 ▁ divisors ▁ : ▁ "" ) ; for ( int i = 0 ; i * i <= n ; i ++ ) if ( prime [ i ] ) System . out . print ( i * i + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int n = 96 ; numbersWith3Divisors ( n ) ; } } +","def numbersWith3Divisors ( n ) : NEW_LINE INDENT prime = [ True ] * ( n + 1 ) ; NEW_LINE prime [ 0 ] = prime [ 1 ] = False ; NEW_LINE p = 2 ; NEW_LINE while ( p * p <= n ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * 2 , n + 1 , p ) : NEW_LINE INDENT prime [ i ] = False ; NEW_LINE DEDENT DEDENT p += 1 ; NEW_LINE DEDENT print ( "" Numbers ▁ with ▁ 3 ▁ divisors ▁ : "" ) ; NEW_LINE i = 0 ; NEW_LINE while ( i * i <= n ) : NEW_LINE INDENT if ( prime [ i ] ) : NEW_LINE INDENT print ( i * i , end = "" ▁ "" ) ; NEW_LINE DEDENT i += 1 ; NEW_LINE DEDENT DEDENT n = 96 ; NEW_LINE numbersWith3Divisors ( n ) ; NEW_LINE +" +E623,"import java . util . * ; class GFG { static int countWays ( int A , int B , int C ) { int minAddA = Math . max ( 0 , ( C + B - A + 2 ) / 2 ) ; int count_ways = Math . max ( C - minAddA + 1 , 0 ) ; return count_ways ; } public static void main ( String args [ ] ) { int A = 3 , B = 5 , C = 5 ; System . out . println ( countWays ( A , B , C ) ) ; } } +","def countWays ( A , B , C ) : NEW_LINE INDENT minAddA = max ( 0 , ( C + B - A + 2 ) // 2 ) NEW_LINE count_ways = max ( C - minAddA + 1 , 0 ) NEW_LINE return count_ways NEW_LINE DEDENT A = 3 NEW_LINE B = 5 NEW_LINE C = 5 NEW_LINE print ( countWays ( A , B , C ) ) NEW_LINE +" +E624,"import java . util . * ; class GFG { static boolean isOperand ( char x ) { return ( x >= ' a ' && x <= ' z ' ) || ( x >= ' A ' && x <= ' Z ' ) ; } static String getInfix ( String exp ) { Stack < String > s = new Stack < String > ( ) ; for ( int i = 0 ; i < exp . length ( ) ; i ++ ) { if ( isOperand ( exp . charAt ( i ) ) ) { s . push ( exp . charAt ( i ) + "" "" ) ; } else { String op1 = s . peek ( ) ; s . pop ( ) ; String op2 = s . peek ( ) ; s . pop ( ) ; s . push ( "" ( "" + op2 + exp . charAt ( i ) + op1 + "" ) "" ) ; } } return s . peek ( ) ; } public static void main ( String args [ ] ) { String exp = "" ab * c + "" ; System . out . println ( getInfix ( exp ) ) ; } } +","def isOperand ( x ) : NEW_LINE INDENT return ( ( x >= ' a ' and x <= ' z ' ) or ( x >= ' A ' and x <= ' Z ' ) ) NEW_LINE DEDENT def getInfix ( exp ) : NEW_LINE INDENT s = [ ] NEW_LINE for i in exp : NEW_LINE INDENT if ( isOperand ( i ) ) : NEW_LINE INDENT s . insert ( 0 , i ) NEW_LINE DEDENT else : NEW_LINE INDENT op1 = s [ 0 ] NEW_LINE s . pop ( 0 ) NEW_LINE op2 = s [ 0 ] NEW_LINE s . pop ( 0 ) NEW_LINE s . insert ( 0 , "" ( "" + op2 + i + op1 + "" ) "" ) NEW_LINE DEDENT DEDENT return s [ 0 ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT exp = "" ab * c + "" NEW_LINE print ( getInfix ( exp . strip ( ) ) ) NEW_LINE DEDENT +" +E625,"import java . * ; public class GFG { static int countPairs ( int arr [ ] , int n ) { int twoCount = 0 , twoGrCount = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 2 ) twoCount ++ ; else if ( arr [ i ] > 2 ) twoGrCount ++ ; } return twoCount * twoGrCount + ( twoGrCount * ( twoGrCount - 1 ) ) / 2 ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 4 , 5 } ; int n = arr . length ; System . out . println ( countPairs ( arr , n ) ) ; } } +","def CountPairs ( arr , n ) : NEW_LINE INDENT twoCount = 0 NEW_LINE twoGrCount = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( arr [ i ] == 2 ) : NEW_LINE INDENT twoCount += 1 NEW_LINE DEDENT elif ( arr [ i ] > 2 ) : NEW_LINE INDENT twoGrCount += 1 NEW_LINE DEDENT DEDENT return ( ( twoCount * twoGrCount ) + ( twoGrCount * ( twoGrCount - 1 ) ) / 2 ) NEW_LINE DEDENT arr = [ 3 , 4 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE print ( CountPairs ( arr , n ) ) NEW_LINE +" +E626,"import java . util . regex . * ; class GFG { public static boolean isValidTime ( String time ) { String regexPattern = "" ( 1[012 ] | [ 1-9 ] ) : "" + "" [ 0-5 ] [ 0-9 ] ( \\ s ) "" + "" ? ( ? i ) ( am | pm ) "" ; Pattern compiledPattern = Pattern . compile ( regexPattern ) ; if ( time == null ) { return false ; } Matcher m = compiledPattern . matcher ( time ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = ""12:15 ▁ AM "" ; System . out . println ( isValidTime ( str1 ) ) ; String str2 = ""9:45PM "" ; System . out . println ( isValidTime ( str2 ) ) ; String str3 = ""1:15"" ; System . out . println ( isValidTime ( str3 ) ) ; String str4 = ""17:30"" ; System . out . println ( isValidTime ( str4 ) ) ; } } +","import re NEW_LINE def isValidTime ( time ) : NEW_LINE INDENT regexPattern = "" ( 1[012 ] | [ 1-9 ] ) : "" + "" [ 0-5 ] [ 0-9 ] ( \\s ) "" + "" ? ( ? i ) ( am | pm ) "" ; NEW_LINE compiledPattern = re . compile ( regexPattern ) ; NEW_LINE if ( time == None ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT if re . search ( compiledPattern , time ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = ""12:15 ▁ AM "" ; NEW_LINE print ( isValidTime ( str1 ) ) ; NEW_LINE str2 = ""9:45PM "" ; NEW_LINE print ( isValidTime ( str2 ) ) ; NEW_LINE str3 = ""1:15"" ; NEW_LINE print ( isValidTime ( str3 ) ) ; NEW_LINE str4 = ""17:30"" ; NEW_LINE print ( isValidTime ( str4 ) ) ; NEW_LINE DEDENT +" +E627,"import java . util . Arrays ; class GFG { static int minXOR ( int arr [ ] , int n ) { Arrays . parallelSort ( arr ) ; int minXor = Integer . MAX_VALUE ; int val = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { val = arr [ i ] ^ arr [ i + 1 ] ; minXor = Math . min ( minXor , val ) ; } return minXor ; } public static void main ( String args [ ] ) { int arr [ ] = { 9 , 5 , 3 } ; int n = arr . length ; System . out . println ( minXOR ( arr , n ) ) ; } } +","import sys NEW_LINE def minXOR ( arr , n ) : NEW_LINE INDENT arr . sort ( ) NEW_LINE minXor = int ( sys . float_info . max ) NEW_LINE val = 0 NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT val = arr [ i ] ^ arr [ i + 1 ] ; NEW_LINE minXor = min ( minXor , val ) ; NEW_LINE DEDENT return minXor NEW_LINE DEDENT arr = [ 9 , 5 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE print ( minXOR ( arr , n ) ) NEW_LINE +" +E628,"class GFG { static int sum ( int m , int n ) { return 8 * m * n - 6 * m - 6 * n + 4 ; } public static void main ( String [ ] args ) { int m = 3 , n = 2 ; System . out . println ( sum ( m , n ) ) ; } } +","def summ ( m , n ) : NEW_LINE INDENT return 8 * m * n - 6 * m - 6 * n + 4 NEW_LINE DEDENT m = 3 NEW_LINE n = 2 NEW_LINE print ( summ ( m , n ) ) NEW_LINE +" +E629,"import java . util . * ; class GFG { static boolean isPossible ( char [ ] str ) { Map < Character , Integer > freq = new HashMap < > ( ) ; int max_freq = 0 ; for ( int j = 0 ; j < ( str . length ) ; j ++ ) { if ( freq . containsKey ( str [ j ] ) ) { freq . put ( str [ j ] , freq . get ( str [ j ] ) + 1 ) ; if ( freq . get ( str [ j ] ) > max_freq ) max_freq = freq . get ( str [ j ] ) ; } else { freq . put ( str [ j ] , 1 ) ; if ( freq . get ( str [ j ] ) > max_freq ) max_freq = freq . get ( str [ j ] ) ; } } if ( max_freq <= ( str . length - max_freq + 1 ) ) return true ; return false ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; if ( isPossible ( str . toCharArray ( ) ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isPossible ( Str ) : NEW_LINE INDENT freq = dict ( ) NEW_LINE max_freq = 0 NEW_LINE for j in range ( len ( Str ) ) : NEW_LINE INDENT freq [ Str [ j ] ] = freq . get ( Str [ j ] , 0 ) + 1 NEW_LINE if ( freq [ Str [ j ] ] > max_freq ) : NEW_LINE INDENT max_freq = freq [ Str [ j ] ] NEW_LINE DEDENT DEDENT if ( max_freq <= ( len ( Str ) - max_freq + 1 ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT Str = "" geeksforgeeks "" NEW_LINE if ( isPossible ( Str ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E630,"class GFG { static boolean isVowel ( char c ) { return ( c == ' a ' || c == ' A ' || c == ' e ' || c == ' E ' || c == ' i ' || c == ' I ' || c == ' o ' || c == ' O ' || c == ' u ' || c == ' U ' ) ; } static String reverseVowel ( String str ) { int i = 0 ; int j = str . length ( ) - 1 ; char [ ] str1 = str . toCharArray ( ) ; while ( i < j ) { if ( ! isVowel ( str1 [ i ] ) ) { i ++ ; continue ; } if ( ! isVowel ( str1 [ j ] ) ) { j -- ; continue ; } char t = str1 [ i ] ; str1 [ i ] = str1 [ j ] ; str1 [ j ] = t ; i ++ ; j -- ; } String str2 = String . copyValueOf ( str1 ) ; return str2 ; } public static void main ( String [ ] args ) { String str = "" hello ▁ world "" ; System . out . println ( reverseVowel ( str ) ) ; } } +","def isVowel ( c ) : NEW_LINE INDENT return ( c == ' a ' or c == ' A ' or c == ' e ' or c == ' E ' or c == ' i ' or c == ' I ' or c == ' o ' or c == ' O ' or c == ' u ' or c == ' U ' ) NEW_LINE DEDENT def reverseVowel ( str ) : NEW_LINE INDENT i = 0 NEW_LINE j = len ( str ) - 1 NEW_LINE while ( i < j ) : NEW_LINE INDENT if not isVowel ( str [ i ] ) : NEW_LINE INDENT i += 1 NEW_LINE continue NEW_LINE DEDENT if ( not isVowel ( str [ j ] ) ) : NEW_LINE INDENT j -= 1 NEW_LINE continue NEW_LINE DEDENT str [ i ] , str [ j ] = str [ j ] , str [ i ] NEW_LINE i += 1 NEW_LINE j -= 1 NEW_LINE DEDENT return str NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" hello ▁ world "" NEW_LINE print ( * reverseVowel ( list ( str ) ) , sep = "" "" ) NEW_LINE DEDENT +" +E631,"import java . lang . System . * ; class GFG { static int findBucketNo ( int p ) { return ( int ) Math . ceil ( ( Math . sqrt ( 8 * p + 1 ) - 1 ) / 2 ) ; } public static void main ( String [ ] args ) { int p = 10 ; System . out . println ( findBucketNo ( p ) ) ; } } +","import math NEW_LINE def findBucketNo ( p ) : NEW_LINE INDENT return math . ceil ( ( math . sqrt ( 8 * p + 1 ) - 1 ) / 2 ) NEW_LINE DEDENT p = 10 NEW_LINE print ( findBucketNo ( p ) ) NEW_LINE +" +E632,"class GFG { static class Node { int data ; Node left ; Node right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } static Node insert ( Node node , int data ) { if ( node == null ) return ( newNode ( data ) ) ; else { if ( data <= node . data ) node . left = insert ( node . left , data ) ; else node . right = insert ( node . right , data ) ; return node ; } } static int minValue ( Node node ) { if ( node . left == null ) return node . data ; return minValue ( node . left ) ; } public static void main ( String args [ ] ) { Node root = null ; root = insert ( root , 4 ) ; insert ( root , 2 ) ; insert ( root , 1 ) ; insert ( root , 3 ) ; insert ( root , 6 ) ; insert ( root , 5 ) ; System . out . println ( minValue ( root ) ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def insert ( node , data ) : NEW_LINE INDENT if node is None : NEW_LINE INDENT return Node ( data ) NEW_LINE DEDENT else : NEW_LINE INDENT if data <= node . data : NEW_LINE INDENT node . left = insert ( node . left , data ) NEW_LINE DEDENT else : NEW_LINE INDENT node . right = insert ( node . right , data ) NEW_LINE DEDENT return node NEW_LINE DEDENT DEDENT def minValue ( node ) : NEW_LINE INDENT if node . left == None : NEW_LINE INDENT return node . data NEW_LINE DEDENT return minValue ( node . left ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT root = None NEW_LINE root = insert ( root , 4 ) NEW_LINE insert ( root , 2 ) NEW_LINE insert ( root , 1 ) NEW_LINE insert ( root , 3 ) NEW_LINE insert ( root , 6 ) NEW_LINE insert ( root , 5 ) NEW_LINE print ( minValue ( root ) ) NEW_LINE DEDENT +" +E633,"import java . util . * ; class solution { static void removeZeros ( int [ ] a , int n ) { int ind = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != 0 ) { ind = i ; break ; } } if ( ind == - 1 ) { System . out . print ( "" Array ▁ has ▁ leading ▁ zeros ▁ only "" ) ; return ; } int [ ] b = new int [ n - ind ] ; for ( int i = 0 ; i < n - ind ; i ++ ) b [ i ] = a [ ind + i ] ; for ( int i = 0 ; i < n - ind ; i ++ ) System . out . print ( b [ i ] + "" ▁ "" ) ; } public static void main ( String args [ ] ) { int [ ] a = { 0 , 0 , 0 , 1 , 2 , 0 , 3 } ; int n = a . length ; removeZeros ( a , n ) ; } } +","def removeZeros ( a , n ) : NEW_LINE INDENT ind = - 1 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] != 0 ) : NEW_LINE INDENT ind = i ; NEW_LINE break ; NEW_LINE DEDENT DEDENT if ( ind == - 1 ) : NEW_LINE INDENT print ( "" Array ▁ has ▁ leading ▁ zeros ▁ only "" ) ; NEW_LINE return ; NEW_LINE DEDENT b = [ 0 ] * ( n - ind ) ; NEW_LINE for i in range ( n - ind ) : NEW_LINE INDENT b [ i ] = a [ ind + i ] ; NEW_LINE DEDENT for i in range ( n - ind ) : NEW_LINE INDENT print ( b [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT a = [ 0 , 0 , 0 , 1 , 2 , 0 , 3 ] ; NEW_LINE n = len ( a ) ; NEW_LINE removeZeros ( a , n ) ; NEW_LINE +" +E634,"class GFG { static int countCoins ( int n ) { int c = 0 ; if ( n < 10 ) { return n ; } if ( n > 9 && n < 25 ) { c = n / 10 + n % 10 ; return c ; } if ( n > 24 ) { c = n / 25 ; if ( n % 25 < 10 ) { c = c + n % 25 ; return c ; } if ( n % 25 > 9 ) { c = c + ( n % 25 ) / 10 + ( n % 25 ) % 10 ; return c ; } } return c ; } public static void main ( String [ ] args ) { int n = 14 ; System . out . println ( countCoins ( n ) ) ; } } +","def countCoins ( n ) : NEW_LINE INDENT c = 0 NEW_LINE if ( n < 10 ) : NEW_LINE INDENT return n NEW_LINE DEDENT if ( n > 9 and n < 25 ) : NEW_LINE INDENT c = n // 10 + n % 10 NEW_LINE return c NEW_LINE DEDENT if ( n > 24 ) : NEW_LINE INDENT c = n // 25 NEW_LINE if ( n % 25 < 10 ) : NEW_LINE INDENT c = c + n % 25 NEW_LINE return c NEW_LINE DEDENT if ( n % 25 > 9 ) : NEW_LINE INDENT c = ( c + ( n % 25 ) // 10 + ( n % 25 ) % 10 ) NEW_LINE return c NEW_LINE DEDENT DEDENT DEDENT n = 14 NEW_LINE print ( countCoins ( n ) ) NEW_LINE +" +E635,"import java . util . * ; class GFG { static boolean isVowel ( char ch ) { if ( ch == ' a ' || ch == ' e ' || ch == ' i ' || ch == ' o ' || ch == ' u ' ) return true ; return false ; } static String createAltStr ( String str1 , String str2 , int start , int l ) { String finalStr = "" "" ; for ( int i = 0 , j = start ; j < l ; i ++ , j ++ ) finalStr = ( finalStr + str1 . charAt ( i ) ) + str2 . charAt ( j ) ; return finalStr ; } static String findAltStr ( String str ) { int nv = 0 , nc = 0 ; String vstr = "" "" , cstr = "" "" ; int l = str . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { char ch = str . charAt ( i ) ; if ( isVowel ( ch ) ) { nv ++ ; vstr = vstr + ch ; } else { nc ++ ; cstr = cstr + ch ; } } if ( Math . abs ( nv - nc ) >= 2 ) return "" no ▁ such ▁ string "" ; if ( nv > nc ) return ( vstr . charAt ( 0 ) + createAltStr ( cstr , vstr , 1 , nv ) ) ; if ( nc > nv ) return ( cstr . charAt ( 0 ) + createAltStr ( vstr , cstr , 1 , nc ) ) ; if ( cstr . charAt ( 0 ) < vstr . charAt ( 0 ) ) return createAltStr ( cstr , vstr , 0 , nv ) ; return createAltStr ( vstr , cstr , 0 , nc ) ; } public static void main ( String args [ ] ) { String str = "" geeks "" ; System . out . println ( findAltStr ( str ) ) ; } } +","def isVowel ( ch ) : NEW_LINE INDENT if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def createAltStr ( str1 , str2 , start , l ) : NEW_LINE INDENT finalStr = "" "" NEW_LINE i = 0 NEW_LINE for j in range ( start , l ) : NEW_LINE INDENT finalStr = ( finalStr + str1 [ i ] ) + str2 [ j ] NEW_LINE i + 1 NEW_LINE DEDENT return finalStr NEW_LINE DEDENT def findAltStr ( str1 ) : NEW_LINE INDENT nv = 0 NEW_LINE nc = 0 NEW_LINE vstr = "" "" NEW_LINE cstr = "" "" NEW_LINE l = len ( str1 ) NEW_LINE for i in range ( 0 , l ) : NEW_LINE INDENT if ( isVowel ( str1 [ i ] ) ) : NEW_LINE INDENT nv += 1 NEW_LINE vstr = vstr + str1 [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT nc += 1 NEW_LINE cstr = cstr + str1 [ i ] NEW_LINE DEDENT DEDENT if ( abs ( nv - nc ) >= 2 ) : NEW_LINE INDENT return "" no ▁ such ▁ string "" NEW_LINE DEDENT if ( nv > nc ) : NEW_LINE INDENT return ( vstr [ 0 ] + createAltStr ( cstr , vstr , 1 , nv ) ) NEW_LINE DEDENT if ( nc > nv ) : NEW_LINE INDENT return ( cstr [ 0 ] + createAltStr ( vstr , cstr , 1 , nc ) ) NEW_LINE DEDENT if ( cstr [ 0 ] < vstr [ 0 ] ) : NEW_LINE INDENT return createAltStr ( cstr , vstr , 0 , nv ) NEW_LINE DEDENT return createAltStr ( vstr , cstr , 0 , nc ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = "" geeks "" NEW_LINE print ( findAltStr ( str1 ) ) NEW_LINE DEDENT +" +E636,"import java . util . * ; class GFG { static int [ ] [ ] dp = new int [ 15 ] [ 2 ] ; static String convertToString ( int num ) { return String . valueOf ( num ) ; } static int calculate ( int pos , int tight , int D [ ] , int sz , String num ) { if ( pos == num . length ( ) ) return 1 ; if ( dp [ pos ] [ tight ] != - 1 ) return dp [ pos ] [ tight ] ; int val = 0 ; if ( tight == 0 ) { for ( int i = 0 ; i < sz ; i ++ ) { if ( D [ i ] < ( num . charAt ( pos ) - '0' ) ) { val += calculate ( pos + 1 , 1 , D , sz , num ) ; } else if ( D [ i ] == num . charAt ( pos ) - '0' ) val += calculate ( pos + 1 , tight , D , sz , num ) ; } } else { for ( int i = 0 ; i < sz ; i ++ ) { val += calculate ( pos + 1 , tight , D , sz , num ) ; } } return dp [ pos ] [ tight ] = val ; } static int countNumbers ( int D [ ] , int N , int sz ) { String num = convertToString ( N ) ; int len = num . length ( ) ; for ( int i = 0 ; i < 15 ; i ++ ) for ( int j = 0 ; j < 2 ; j ++ ) dp [ i ] [ j ] = - 1 ; int ans = calculate ( 0 , 0 , D , sz , num ) ; for ( int i = 1 ; i < len ; i ++ ) ans += calculate ( i , 1 , D , sz , num ) ; return ans ; } public static void main ( String [ ] args ) { int sz = 3 ; int D [ ] = { 1 , 4 , 9 } ; int N = 10 ; System . out . print ( countNumbers ( D , N , sz ) ) ; } } +","import numpy as np ; NEW_LINE dp = np . ones ( ( 15 , 2 ) ) * - 1 ; NEW_LINE def convertToString ( num ) : NEW_LINE INDENT return str ( num ) ; NEW_LINE DEDENT def calculate ( pos , tight , D , sz , num ) : NEW_LINE INDENT if ( pos == len ( num ) ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT if ( dp [ pos ] [ tight ] != - 1 ) : NEW_LINE INDENT return dp [ pos ] [ tight ] ; NEW_LINE DEDENT val = 0 ; NEW_LINE if ( tight == 0 ) : NEW_LINE INDENT for i in range ( sz ) : NEW_LINE INDENT if ( D [ i ] < ( ord ( num [ pos ] ) - ord ( '0' ) ) ) : NEW_LINE INDENT val += calculate ( pos + 1 , 1 , D , sz , num ) ; NEW_LINE DEDENT elif ( D [ i ] == ord ( num [ pos ] ) - ord ( '0' ) ) : NEW_LINE INDENT val += calculate ( pos + 1 , tight , D , sz , num ) ; NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in range ( sz ) : NEW_LINE INDENT val += calculate ( pos + 1 , tight , D , sz , num ) ; NEW_LINE DEDENT DEDENT dp [ pos ] [ tight ] = val ; NEW_LINE return dp [ pos ] [ tight ] ; NEW_LINE DEDENT def countNumbers ( D , N , sz ) : NEW_LINE INDENT num = convertToString ( N ) ; NEW_LINE length = len ( num ) ; NEW_LINE ans = calculate ( 0 , 0 , D , sz , num ) ; NEW_LINE for i in range ( 1 , length ) : NEW_LINE INDENT ans += calculate ( i , 1 , D , sz , num ) ; NEW_LINE DEDENT return ans ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT sz = 3 ; NEW_LINE D = [ 1 , 4 , 9 ] ; NEW_LINE N = 10 ; NEW_LINE print ( countNumbers ( D , N , sz ) ) ; NEW_LINE DEDENT +" +E637,"import java . util . * ; import java . lang . * ; class GFG { public static int summation ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum ; } public static void main ( String args [ ] ) { int n = 2 ; System . out . println ( summation ( n ) ) ; } } +","def summation ( n ) : NEW_LINE INDENT return sum ( [ i ** 2 for i in range ( 1 , n + 1 ) ] ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 2 NEW_LINE print ( summation ( n ) ) NEW_LINE DEDENT +" +E638,"import java . util . * ; class GFG { static int countPairs ( int arr [ ] , int n ) { HashMap < Integer , Integer > frequency = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( frequency . containsKey ( arr [ i ] ) ) { frequency . put ( arr [ i ] , frequency . get ( arr [ i ] ) + 1 ) ; } else { frequency . put ( arr [ i ] , 1 ) ; } } int count = 0 ; for ( Map . Entry < Integer , Integer > x : frequency . entrySet ( ) ) { int f = x . getValue ( ) ; count += f * ( f - 1 ) / 2 ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 } ; int n = arr . length ; System . out . print ( countPairs ( arr , n ) ) ; } } +","from collections import defaultdict NEW_LINE def countPairs ( a , n ) : NEW_LINE INDENT frequency = defaultdict ( int ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT frequency [ a [ i ] ] += 1 NEW_LINE DEDENT count = 0 NEW_LINE for x in frequency . keys ( ) : NEW_LINE INDENT f = frequency [ x ] NEW_LINE count += f * ( f - 1 ) // 2 NEW_LINE DEDENT return count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 1 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countPairs ( arr , n ) ) NEW_LINE DEDENT +" +E639,"class GFG { static int a [ ] ; static int search ( int a [ ] , int k , int x ) { int j ; for ( j = k - 1 ; j > - 1 ; j -- ) { if ( a [ j ] == x ) return j ; } return - 1 ; } static void genArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( search ( arr , i , arr [ i ] ) == - 1 ) arr [ i + 1 ] = 0 ; else arr [ i + 1 ] = ( i - search ( arr , i , arr [ i ] ) ) ; } } public static void main ( String [ ] args ) { int N = 5 ; int size = N + 1 ; int a [ ] = new int [ N ] ; genArray ( a , N ) ; for ( int i = 0 ; i < N ; i ++ ) System . out . print ( a [ i ] + "" ▁ "" ) ; } } +","def search ( a , k , x ) : NEW_LINE INDENT for j in range ( k - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( a [ j ] == x ) : NEW_LINE INDENT return j NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT def genArray ( arr , N ) : NEW_LINE INDENT for i in range ( 0 , N - 1 , 1 ) : NEW_LINE INDENT if ( search ( arr , i , arr [ i ] ) == - 1 ) : NEW_LINE INDENT arr [ i + 1 ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT arr [ i + 1 ] = ( i - search ( arr , i , arr [ i ] ) ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 5 NEW_LINE size = N + 1 NEW_LINE a = [ 0 ] * N NEW_LINE genArray ( a , N ) NEW_LINE print ( a ) NEW_LINE DEDENT +" +E640,"class GFG { static int maxN = 20 ; static int maxM = 64 ; static int cntSplits ( String s ) { if ( s . charAt ( s . length ( ) - 1 ) == '1' ) return 0 ; int c_zero = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) c_zero += ( s . charAt ( i ) == '0' ) ? 1 : 0 ; return ( int ) Math . pow ( 2 , c_zero - 1 ) ; } public static void main ( String [ ] args ) { String s = ""10010"" ; System . out . println ( cntSplits ( s ) ) ; } } +","def cntSplits ( s ) : NEW_LINE INDENT if ( s [ len ( s ) - 1 ] == '1' ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT c_zero = 0 ; NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT c_zero += ( s [ i ] == '0' ) ; NEW_LINE DEDENT return int ( pow ( 2 , c_zero - 1 ) ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = ""10010"" ; NEW_LINE print ( cntSplits ( s ) ) ; NEW_LINE DEDENT +" +E641,"import java . io . * ; class GFG { static int MAX = 100 ; static void middlesum ( int mat [ ] [ ] , int n ) { int row_sum = 0 , col_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) row_sum += mat [ n / 2 ] [ i ] ; System . out . println ( "" Sum ▁ of ▁ middle ▁ row ▁ = ▁ "" + row_sum ) ; for ( int i = 0 ; i < n ; i ++ ) col_sum += mat [ i ] [ n / 2 ] ; System . out . println ( "" Sum ▁ of ▁ middle ▁ column ▁ = ▁ "" + col_sum ) ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 2 , 5 , 7 } , { 3 , 7 , 2 } , { 5 , 6 , 9 } } ; middlesum ( mat , 3 ) ; } } +","def middlesum ( mat , n ) : NEW_LINE INDENT row_sum = 0 NEW_LINE col_sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT row_sum += mat [ n // 2 ] [ i ] NEW_LINE DEDENT print ( "" Sum ▁ of ▁ middle ▁ row ▁ = ▁ "" , row_sum ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT col_sum += mat [ i ] [ n // 2 ] NEW_LINE DEDENT print ( "" Sum ▁ of ▁ middle ▁ column ▁ = ▁ "" , col_sum ) NEW_LINE DEDENT mat = [ [ 2 , 5 , 7 ] , [ 3 , 7 , 2 ] , [ 5 , 6 , 9 ] ] NEW_LINE middlesum ( mat , 3 ) NEW_LINE +" +E642,"class GFG { static void Vertices ( int x , int y ) { int val = Math . abs ( x ) + Math . abs ( y ) ; System . out . print ( val * ( x < 0 ? - 1 : 1 ) + "" ▁ 0 ▁ "" ) ; System . out . print ( ""0 ▁ "" + val * ( y < 0 ? - 1 : 1 ) ) ; } public static void main ( String [ ] args ) { int x = 3 , y = 3 ; Vertices ( x , y ) ; } } +","def Vertices ( x , y ) : NEW_LINE INDENT val = abs ( x ) + abs ( y ) ; NEW_LINE if x < 0 : NEW_LINE INDENT x = - 1 NEW_LINE DEDENT else : NEW_LINE INDENT x = 1 NEW_LINE DEDENT print ( val * x , ""0"" , end = "" ▁ "" ) ; NEW_LINE if y < 0 : NEW_LINE INDENT y = - 1 NEW_LINE DEDENT else : NEW_LINE INDENT y = 1 NEW_LINE DEDENT print ( ""0"" , val * y ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT x = 3 ; y = 3 ; NEW_LINE Vertices ( x , y ) ; NEW_LINE DEDENT +" +E643,"class GFG { static boolean isPrime ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } static void printMinCountPrime ( int N ) { int minCount ; if ( isPrime ( N ) ) { minCount = 1 ; } else if ( N % 2 == 0 ) { minCount = 2 ; } else { if ( isPrime ( N - 2 ) ) { minCount = 2 ; } else { minCount = 3 ; } } System . out . print ( minCount + "" \n "" ) ; } public static void main ( String [ ] args ) { int N = 100 ; printMinCountPrime ( N ) ; } } +","def isPrime ( n ) : NEW_LINE INDENT for i in range ( 2 , int ( n ** ( 1 / 2 ) ) + 1 ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT return True ; NEW_LINE DEDENT def printMinCountPrime ( N ) : NEW_LINE INDENT if ( isPrime ( N ) ) : NEW_LINE INDENT minCount = 1 ; NEW_LINE DEDENT elif ( N % 2 == 0 ) : NEW_LINE INDENT minCount = 2 ; NEW_LINE DEDENT else : NEW_LINE INDENT if ( isPrime ( N - 2 ) ) : NEW_LINE INDENT minCount = 2 ; NEW_LINE DEDENT else : NEW_LINE INDENT minCount = 3 ; NEW_LINE DEDENT DEDENT print ( minCount ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 100 ; NEW_LINE printMinCountPrime ( N ) ; NEW_LINE DEDENT +" +E644,"import java . io . * ; import java . math . * ; class GFG { static int findCount ( int d ) { return 9 * ( int ) ( ( Math . pow ( 10 , d - 1 ) - Math . pow ( 9 , d - 1 ) ) ) ; } static int findCountUpto ( int d ) { int totalCount = 0 ; for ( int i = 1 ; i <= d ; i ++ ) totalCount += findCount ( i ) ; return totalCount ; } public static void main ( String args [ ] ) { int d = 1 ; System . out . println ( findCountUpto ( d ) ) ; d = 2 ; System . out . println ( findCountUpto ( d ) ) ; d = 4 ; System . out . println ( findCountUpto ( d ) ) ; } } +","import math NEW_LINE def findCountUpto ( d ) : NEW_LINE INDENT GP1_Sum = 9 * ( ( int ) ( ( math . pow ( 10 , d ) ) - 1 ) // 9 ) NEW_LINE GP2_Sum = 9 * ( ( int ) ( ( math . pow ( 9 , d ) ) - 1 ) // 8 ) NEW_LINE return GP1_Sum - GP2_Sum NEW_LINE DEDENT d = 1 NEW_LINE print ( findCountUpto ( d ) ) NEW_LINE d = 2 NEW_LINE print ( findCountUpto ( d ) ) NEW_LINE d = 4 NEW_LINE print ( findCountUpto ( d ) ) NEW_LINE +" +E645,"import java . util . * ; class GFG { static int two_sets ( int a [ ] , int n ) { Arrays . sort ( a ) ; return a [ n / 2 ] - a [ ( n / 2 ) - 1 ] ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 4 , 4 , 6 , 7 , 9 } ; int n = a . length ; System . out . println ( two_sets ( a , n ) ) ; } } +","def two_sets ( a , n ) : NEW_LINE INDENT a . sort ( ) ; NEW_LINE return ( a [ n // 2 ] - a [ ( n // 2 ) - 1 ] ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , 4 , 4 , 6 , 7 , 9 ] ; NEW_LINE n = len ( a ) ; NEW_LINE print ( two_sets ( a , n ) ) ; NEW_LINE DEDENT +" +E646,"import java . util . * ; class GFG { static void maximumArea ( int l , int b , int x , int y ) { int left , right , above , below ; left = x * b ; right = ( l - x - 1 ) * b ; above = l * y ; below = ( b - y - 1 ) * l ; System . out . print ( Math . max ( Math . max ( left , right ) , Math . max ( above , below ) ) ) ; } public static void main ( String [ ] args ) { int L = 8 , B = 8 ; int X = 0 , Y = 0 ; maximumArea ( L , B , X , Y ) ; } } +","def maximumArea ( l , b , x , y ) : NEW_LINE INDENT left , right , above , below = 0 , 0 , 0 , 0 NEW_LINE left = x * b NEW_LINE right = ( l - x - 1 ) * b NEW_LINE above = l * y NEW_LINE below = ( b - y - 1 ) * l NEW_LINE print ( max ( max ( left , right ) , max ( above , below ) ) ) NEW_LINE DEDENT l = 8 NEW_LINE b = 8 NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE maximumArea ( l , b , x , y ) NEW_LINE +" +E647,"import java . util . * ; class GFG { static boolean check ( int arr [ ] , int N , int K ) { HashSet < Integer > unique = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) unique . add ( arr [ i ] ) ; if ( unique . size ( ) == K ) return true ; return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 3 } ; int N = arr . length ; int K = 3 ; if ( check ( arr , N , K ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def check ( arr , N , K ) : NEW_LINE INDENT unique = dict ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT unique [ arr [ i ] ] = 1 NEW_LINE DEDENT if len ( unique ) == K : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT arr = [ 1 , 1 , 2 , 3 ] NEW_LINE N = len ( arr ) NEW_LINE K = 3 NEW_LINE if ( check ( arr , N , K ) == True ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E648,"import java . io . * ; class GFG { static int russianPeasant ( int a , int b ) { int res = 0 ; while ( b > 0 ) { if ( ( b & 1 ) != 0 ) res = res + a ; a = a << 1 ; b = b >> 1 ; } return res ; } public static void main ( String [ ] args ) { System . out . println ( russianPeasant ( 18 , 1 ) ) ; System . out . println ( russianPeasant ( 20 , 12 ) ) ; } } +","def russianPeasant ( a , b ) : NEW_LINE INDENT res = 0 NEW_LINE while ( b > 0 ) : NEW_LINE INDENT if ( b & 1 ) : NEW_LINE INDENT res = res + a NEW_LINE DEDENT a = a << 1 NEW_LINE b = b >> 1 NEW_LINE DEDENT return res NEW_LINE DEDENT print ( russianPeasant ( 18 , 1 ) ) NEW_LINE print ( russianPeasant ( 20 , 12 ) ) NEW_LINE +" +E649,"import java . util . * ; class GfG { static int FindMinimumCost ( int ind , int a [ ] , int n , int k , int dp [ ] ) { if ( ind == ( n - 1 ) ) return 0 ; else if ( dp [ ind ] != - 1 ) return dp [ ind ] ; else { int ans = Integer . MAX_VALUE ; for ( int i = 1 ; i <= k ; i ++ ) { if ( ind + i < n ) ans = Math . min ( ans , Math . abs ( a [ ind + i ] - a [ ind ] ) + FindMinimumCost ( ind + i , a , n , k , dp ) ) ; else break ; } return dp [ ind ] = ans ; } } public static void main ( String [ ] args ) { int a [ ] = { 10 , 30 , 40 , 50 , 20 } ; int k = 3 ; int n = a . length ; int dp [ ] = new int [ n ] ; Arrays . fill ( dp , - 1 ) ; System . out . println ( FindMinimumCost ( 0 , a , n , k , dp ) ) ; } } +","import sys NEW_LINE def FindMinimumCost ( ind , a , n , k , dp ) : NEW_LINE INDENT if ( ind == ( n - 1 ) ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif ( dp [ ind ] != - 1 ) : NEW_LINE INDENT return dp [ ind ] NEW_LINE DEDENT else : NEW_LINE INDENT ans = sys . maxsize NEW_LINE for i in range ( 1 , k + 1 ) : NEW_LINE INDENT if ( ind + i < n ) : NEW_LINE INDENT ans = min ( ans , abs ( a [ ind + i ] - a [ ind ] ) + FindMinimumCost ( ind + i , a , n , k , dp ) ) NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT dp [ ind ] = ans NEW_LINE return ans NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 10 , 30 , 40 , 50 , 20 ] NEW_LINE k = 3 NEW_LINE n = len ( a ) NEW_LINE dp = [ - 1 for i in range ( n ) ] NEW_LINE print ( FindMinimumCost ( 0 , a , n , k , dp ) ) NEW_LINE DEDENT +" +E650,"class GFG { static int max ( int x , int y ) { return ( x > y ) ? x : y ; } static int longestPalindromic ( String str , int i , int j , int count ) { if ( i > j ) return count ; if ( i == j ) return ( count + 1 ) ; if ( str . charAt ( i ) == str . charAt ( j ) ) { count = longestPalindromic ( str , i + 1 , j - 1 , count + 2 ) ; return max ( count , max ( longestPalindromic ( str , i + 1 , j , 0 ) , longestPalindromic ( str , i , j - 1 , 0 ) ) ) ; } return Math . max ( longestPalindromic ( str , i + 1 , j , 0 ) , longestPalindromic ( str , i , j - 1 , 0 ) ) ; } static int longest_palindromic_substr ( String str ) { return longestPalindromic ( str , 0 , str . length ( ) - 1 , 0 ) ; } public static void main ( String [ ] args ) { String str = "" aaaabbaa "" ; System . out . print ( longest_palindromic_substr ( str ) ) ; } } +","def maxi ( x , y ) : NEW_LINE INDENT if x > y : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return y NEW_LINE DEDENT DEDENT def longestPalindromic ( strn , i , j , count ) : NEW_LINE INDENT if i > j : NEW_LINE INDENT return count NEW_LINE DEDENT if i == j : NEW_LINE INDENT return ( count + 1 ) NEW_LINE DEDENT if strn [ i ] == strn [ j ] : NEW_LINE INDENT count = longestPalindromic ( strn , i + 1 , j - 1 , count + 2 ) NEW_LINE return maxi ( count , maxi ( longestPalindromic ( strn , i + 1 , j , 0 ) , longestPalindromic ( strn , i , j - 1 , 0 ) ) ) NEW_LINE DEDENT return maxi ( longestPalindromic ( strn , i + 1 , j , 0 ) , longestPalindromic ( strn , i , j - 1 , 0 ) ) NEW_LINE DEDENT def longest_palindromic_substr ( strn ) : NEW_LINE INDENT k = len ( strn ) - 1 NEW_LINE return longestPalindromic ( strn , 0 , k , 0 ) NEW_LINE DEDENT strn = "" aaaabbaa "" NEW_LINE print ( longest_palindromic_substr ( strn ) ) NEW_LINE +" +E651,"class Test { static final int MAX_CHAR = 26 ; static int countPairs ( String str ) { int result = 0 ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 1 ; ( i + j ) < n && j <= MAX_CHAR ; j ++ ) if ( ( Math . abs ( str . charAt ( i + j ) - str . charAt ( i ) ) == j ) ) result ++ ; return result ; } public static void main ( String args [ ] ) { String str = "" geeksforgeeks "" ; System . out . println ( countPairs ( str ) ) ; } } +","MAX_CHAR = 26 NEW_LINE def countPairs ( str1 ) : NEW_LINE INDENT result = 0 ; NEW_LINE n = len ( str1 ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 1 , MAX_CHAR + 1 ) : NEW_LINE INDENT if ( ( i + j ) < n ) : NEW_LINE INDENT if ( ( abs ( ord ( str1 [ i + j ] ) - ord ( str1 [ i ] ) ) == j ) ) : NEW_LINE INDENT result += 1 ; NEW_LINE DEDENT DEDENT DEDENT DEDENT return result NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = "" geeksforgeeks "" ; NEW_LINE print ( countPairs ( str1 ) ) NEW_LINE DEDENT +" +E652,"import java . io . * ; class GFG { static int countSetBits ( int n ) { long count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return ( int ) count ; } static int countOfOddsPascal ( int n ) { int c = countSetBits ( n ) ; return ( int ) Math . pow ( 2 , c ) ; } public static void main ( String [ ] args ) { int n = 20 ; System . out . println ( countOfOddsPascal ( n ) ) ; } } +","def countSetBits ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while n : NEW_LINE INDENT count += n & 1 NEW_LINE n >>= 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def countOfOddPascal ( n ) : NEW_LINE INDENT c = countSetBits ( n ) NEW_LINE return pow ( 2 , c ) NEW_LINE DEDENT n = 20 NEW_LINE print ( countOfOddPascal ( n ) ) NEW_LINE +" +E653,"class GFG { static void rearrange ( int arr [ ] , int n ) { int i = - 1 , j = n ; while ( i < j ) { while ( arr [ ++ i ] > 0 ) ; while ( arr [ -- j ] < 0 ) ; if ( i < j ) swap ( arr , i , j ) ; } if ( i == 0 || i == n ) return ; int k = 0 ; while ( k < n && i < n ) { swap ( arr , k , i ) ; i = i + 1 ; k = k + 2 ; } } static void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; System . out . println ( "" "" ) ; } static void swap ( int arr [ ] , int index1 , int index2 ) { int c = arr [ index1 ] ; arr [ index1 ] = arr [ index2 ] ; arr [ index2 ] = c ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , - 4 , - 1 , 6 , - 9 } ; int n = arr . length ; System . out . println ( "" Given ▁ array ▁ is ▁ "" ) ; printArray ( arr , n ) ; rearrange ( arr , n ) ; System . out . println ( "" Rearranged ▁ array ▁ is ▁ "" ) ; printArray ( arr , n ) ; } } +","def rearrange ( arr , n ) : NEW_LINE INDENT i = 0 NEW_LINE j = n - 1 NEW_LINE while ( i < j ) : NEW_LINE INDENT while ( arr [ i ] > 0 ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT while ( arr [ j ] < 0 ) : NEW_LINE INDENT j -= 1 NEW_LINE DEDENT if ( i < j ) : NEW_LINE INDENT temp = arr [ i ] NEW_LINE arr [ i ] = arr [ j ] NEW_LINE arr [ j ] = temp NEW_LINE DEDENT DEDENT if ( i == 0 or i == n ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT k = 0 NEW_LINE while ( k < n and i < n ) : NEW_LINE INDENT temp = arr [ k ] NEW_LINE arr [ k ] = arr [ i ] NEW_LINE arr [ i ] = temp NEW_LINE i = i + 1 NEW_LINE k = k + 2 NEW_LINE DEDENT DEDENT def printArray ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( "" \n "" ) NEW_LINE DEDENT arr = [ 2 , 3 , - 4 , - 1 , 6 , - 9 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Given ▁ array ▁ is "" ) NEW_LINE printArray ( arr , n ) NEW_LINE rearrange ( arr , n ) NEW_LINE print ( "" Rearranged ▁ array ▁ is "" ) NEW_LINE printArray ( arr , n ) NEW_LINE +" +E654,"import java . io . * ; class GFG { static int countDivisibles ( int A , int B , int M ) { if ( A % M == 0 ) return ( B / M ) - ( A / M ) + 1 ; return ( B / M ) - ( A / M ) ; } public static void main ( String [ ] args ) { int A = 30 , B = 100 , M = 30 ; System . out . println ( countDivisibles ( A , B , M ) ) ; } } +","def countDivisibles ( A , B , M ) : NEW_LINE INDENT if ( A % M == 0 ) : NEW_LINE INDENT return ( ( B / M ) - ( A / M ) ) + 1 NEW_LINE DEDENT return ( ( B / M ) - ( A / M ) ) NEW_LINE DEDENT A = 30 NEW_LINE B = 70 NEW_LINE M = 10 NEW_LINE print ( countDivisibles ( A , B , M ) ) NEW_LINE +" +E655,"class GFG { public static int findMissing ( int arr [ ] , int n ) { int l = 0 , h = n - 1 ; int mid ; while ( h > l ) { mid = l + ( h - l ) / 2 ; if ( arr [ mid ] - mid == arr [ 0 ] ) { if ( arr [ mid + 1 ] - arr [ mid ] > 1 ) return arr [ mid ] + 1 ; else { l = mid + 1 ; } } else { if ( arr [ mid ] - arr [ mid - 1 ] > 1 ) return arr [ mid ] - 1 ; else { h = mid - 1 ; } } } return - 1 ; } public static void main ( String args [ ] ) { int arr [ ] = { - 9 , - 8 , - 7 , - 5 , - 4 , - 3 , - 2 , - 1 , 0 } ; int n = arr . length ; System . out . print ( findMissing ( arr , n ) ) ; } } +","def findMissing ( arr , n ) : NEW_LINE INDENT l , h = 0 , n - 1 NEW_LINE mid = 0 NEW_LINE while ( h > l ) : NEW_LINE INDENT mid = l + ( h - l ) // 2 NEW_LINE if ( arr [ mid ] - mid == arr [ 0 ] ) : NEW_LINE INDENT if ( arr [ mid + 1 ] - arr [ mid ] > 1 ) : NEW_LINE INDENT return arr [ mid ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT l = mid + 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( arr [ mid ] - arr [ mid - 1 ] > 1 ) : NEW_LINE INDENT return arr [ mid ] - 1 NEW_LINE DEDENT else : NEW_LINE INDENT h = mid - 1 NEW_LINE DEDENT DEDENT DEDENT return - 1 NEW_LINE DEDENT arr = [ - 9 , - 8 , - 7 , - 5 , - 4 , - 3 , - 2 , - 1 , 0 ] NEW_LINE n = len ( arr ) NEW_LINE print ( findMissing ( arr , n ) ) NEW_LINE +" +E656,"import java . util . Arrays ; class GFG { static int maxSum ( int a [ ] , int n ) { Arrays . sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i += 2 ) { sum += a [ i ] ; } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 2 , 1 , 4 , 5 } ; int n = arr . length ; System . out . println ( maxSum ( arr , n ) ) ; } } +","def maxSum ( a , n ) : NEW_LINE INDENT a . sort ( ) ; NEW_LINE sum = 0 ; NEW_LINE for i in range ( 0 , n - 1 , 2 ) : NEW_LINE INDENT sum += a [ i ] ; NEW_LINE DEDENT return sum ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 3 , 2 , 1 , 4 , 5 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( maxSum ( arr , n ) ) ; NEW_LINE DEDENT +" +E657,"class GFG { static int trailing_zeros ( int N ) { int count_of_two = 0 , count_of_five = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { int val = i ; while ( val % 2 == 0 && val > 0 ) { val /= 2 ; count_of_two += i ; } while ( val % 5 == 0 && val > 0 ) { val /= 5 ; count_of_five += i ; } } int ans = Math . min ( count_of_two , count_of_five ) ; return ans ; } public static void main ( String [ ] args ) { int N = 12 ; System . out . println ( trailing_zeros ( N ) ) ; } } +","def trailing_zeros ( N ) : NEW_LINE INDENT count_of_two = 0 NEW_LINE count_of_five = 0 NEW_LINE for i in range ( 1 , N + 1 , 1 ) : NEW_LINE INDENT val = i NEW_LINE while ( val % 2 == 0 and val > 0 ) : NEW_LINE INDENT val /= 2 NEW_LINE count_of_two += i NEW_LINE DEDENT while ( val % 5 == 0 and val > 0 ) : NEW_LINE INDENT val /= 5 NEW_LINE count_of_five += i NEW_LINE DEDENT DEDENT ans = min ( count_of_two , count_of_five ) NEW_LINE return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 12 NEW_LINE print ( trailing_zeros ( N ) ) NEW_LINE DEDENT +" +E658,"import java . util . Arrays ; class GFG { public static int sumOfSubstrings ( String num ) { int n = num . length ( ) ; int sumofdigit [ ] = new int [ n ] ; sumofdigit [ 0 ] = num . charAt ( 0 ) - '0' ; int res = sumofdigit [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { int numi = num . charAt ( i ) - '0' ; sumofdigit [ i ] = ( i + 1 ) * numi + 10 * sumofdigit [ i - 1 ] ; res += sumofdigit [ i ] ; } return res ; } public static void main ( String [ ] args ) { String num = ""1234"" ; System . out . println ( sumOfSubstrings ( num ) ) ; } } +","def sumOfSubstrings ( num ) : NEW_LINE INDENT n = len ( num ) NEW_LINE sumofdigit = [ ] NEW_LINE sumofdigit . append ( int ( num [ 0 ] ) ) NEW_LINE res = sumofdigit [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT numi = int ( num [ i ] ) NEW_LINE sumofdigit . append ( ( i + 1 ) * numi + 10 * sumofdigit [ i - 1 ] ) NEW_LINE res += sumofdigit [ i ] NEW_LINE DEDENT return res NEW_LINE DEDENT num = ""1234"" NEW_LINE print ( sumOfSubstrings ( num ) ) NEW_LINE +" +E659,"import java . util . * ; class GFG { static int sumOfDiv ( int x ) { int sum = 1 ; for ( int i = 2 ; i <= Math . sqrt ( x ) ; i ++ ) { if ( x % i == 0 ) { sum += i ; if ( x / i != i ) sum += x / i ; } } return sum ; } static boolean isAmicable ( int a , int b ) { return ( sumOfDiv ( a ) == b && sumOfDiv ( b ) == a ) ; } static int countPairs ( int arr [ ] , int n ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) s . add ( arr [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . contains ( sumOfDiv ( arr [ i ] ) ) ) { int sum = sumOfDiv ( arr [ i ] ) ; if ( isAmicable ( arr [ i ] , sum ) ) count ++ ; } } return count / 2 ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 220 , 284 , 1184 , 1210 , 2 , 5 } ; int n1 = arr1 . length ; System . out . println ( countPairs ( arr1 , n1 ) ) ; int arr2 [ ] = { 2620 , 2924 , 5020 , 5564 , 6232 , 6368 } ; int n2 = arr2 . length ; System . out . println ( countPairs ( arr2 , n2 ) ) ; } } +","import math NEW_LINE def sumOfDiv ( x ) : NEW_LINE INDENT sum = 1 ; NEW_LINE for i in range ( 2 , int ( math . sqrt ( x ) ) ) : NEW_LINE INDENT if x % i == 0 : NEW_LINE INDENT sum += i NEW_LINE if i != x / i : NEW_LINE INDENT sum += x / i NEW_LINE DEDENT DEDENT DEDENT return int ( sum ) ; NEW_LINE DEDENT def isAmbicle ( a , b ) : NEW_LINE INDENT return ( sumOfDiv ( a ) == b and sumOfDiv ( b ) == a ) NEW_LINE DEDENT def countPairs ( arr , n ) : NEW_LINE INDENT s = set ( ) NEW_LINE count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT s . add ( arr [ i ] ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if sumOfDiv ( arr [ i ] ) in s : NEW_LINE INDENT sum = sumOfDiv ( arr [ i ] ) NEW_LINE if isAmbicle ( arr [ i ] , sum ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return int ( count / 2 ) ; NEW_LINE DEDENT arr1 = [ 220 , 284 , 1184 , 1210 , 2 , 5 ] NEW_LINE n1 = len ( arr1 ) NEW_LINE print ( countPairs ( arr1 , n1 ) ) NEW_LINE arr2 = [ 2620 , 2924 , 5020 , 5564 , 6232 , 6368 ] NEW_LINE n2 = len ( arr2 ) NEW_LINE print ( countPairs ( arr2 , n2 ) ) NEW_LINE +" +E660,"class GFG { static int grayCode ( int n ) { return n ^ ( n >> 1 ) ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( grayCode ( n ) ) ; } } +","def grayCode ( n ) : NEW_LINE INDENT return n ^ ( n >> 1 ) NEW_LINE DEDENT n = 10 NEW_LINE print ( grayCode ( n ) ) NEW_LINE +" +E661,"import java . io . * ; import java . math . * ; class GFG { static void printNonSquare ( int n ) { int curr_count = 2 , num = 2 , count = 0 ; while ( count < n ) { for ( int i = 0 ; i < curr_count && count < n ; i ++ ) { System . out . print ( num + "" ▁ "" ) ; count ++ ; num ++ ; } num ++ ; curr_count += 2 ; } } public static void main ( String args [ ] ) { int n = 10 ; printNonSquare ( n ) ; } } +","import math NEW_LINE def printNonSquare ( n ) : NEW_LINE INDENT curr_count = 2 NEW_LINE num = 2 NEW_LINE count = 0 NEW_LINE while ( count < n ) : NEW_LINE INDENT i = 0 NEW_LINE while ( i < curr_count and count < n ) : NEW_LINE INDENT print ( num , end = "" ▁ "" ) NEW_LINE count = count + 1 NEW_LINE num = num + 1 NEW_LINE i = i + 1 NEW_LINE DEDENT num = num + 1 NEW_LINE curr_count = curr_count + 2 NEW_LINE DEDENT DEDENT n = 10 NEW_LINE printNonSquare ( n ) NEW_LINE +" +E662,"import java . util . * ; class Node { static void sortWithSetbits ( int arr [ ] , int n , int k ) { Vector < Integer > v1 = new Vector < > ( ) , v2 = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( Integer . bitCount ( arr [ i ] ) == k ) { v1 . add ( i ) ; v2 . add ( arr [ i ] ) ; } } Collections . sort ( v2 ) ; for ( int i = 0 ; i < v1 . size ( ) ; i ++ ) { arr [ v1 . get ( i ) ] = v2 . get ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 14 , 255 , 1 , 7 , 13 } ; int n = arr . length ; int k = 3 ; sortWithSetbits ( arr , n , k ) ; } } +","def sortWithSetbits ( arr , n , k ) : NEW_LINE INDENT v1 = [ ] NEW_LINE v2 = [ ] NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( bin ( arr [ i ] ) . count ( '1' ) == k ) : NEW_LINE INDENT v1 . append ( i ) NEW_LINE v2 . append ( arr [ i ] ) NEW_LINE DEDENT DEDENT v2 . sort ( reverse = False ) NEW_LINE for i in range ( 0 , len ( v1 ) , 1 ) : NEW_LINE INDENT arr [ v1 [ i ] ] = v2 [ i ] NEW_LINE DEDENT for i in range ( 0 , n , 1 ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 14 , 255 , 1 , 7 , 13 ] NEW_LINE n = len ( arr ) NEW_LINE k = 3 NEW_LINE sortWithSetbits ( arr , n , k ) NEW_LINE DEDENT +" +E663,"class GFG { static boolean isRotation ( long x , long y ) { long x64 = x | ( x << 32 ) ; while ( x64 >= y ) { if ( x64 == y ) { return true ; } x64 >>= 1 ; } return false ; } public static void main ( String [ ] args ) { long x = 122 ; long y = 2147483678L ; if ( isRotation ( x , y ) == false ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","def isRotation ( x , y ) : NEW_LINE INDENT x64 = x | ( x << 32 ) NEW_LINE while ( x64 >= y ) : NEW_LINE INDENT if ( ( x64 ) == y ) : NEW_LINE INDENT return True NEW_LINE DEDENT x64 >>= 1 NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT x = 122 NEW_LINE y = 2147483678 NEW_LINE if ( isRotation ( x , y ) == False ) : NEW_LINE INDENT print ( "" yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" no "" ) NEW_LINE DEDENT DEDENT +" +E664,"import java . util . * ; class GFG { static int findXorSum ( int arr [ ] , int n ) { int sum = 0 ; int mul = 1 ; for ( int i = 0 ; i < 30 ; i ++ ) { int c_odd = 0 ; boolean odd = false ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) odd = ( ! odd ) ; if ( odd ) c_odd ++ ; } for ( int j = 0 ; j < n ; j ++ ) { sum += ( mul * c_odd ) ; if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) c_odd = ( n - j - c_odd ) ; } mul *= 2 ; } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 8 , 13 } ; int n = arr . length ; System . out . println ( findXorSum ( arr , n ) ) ; } } +","def findXorSum ( arr , n ) : NEW_LINE INDENT Sum = 0 NEW_LINE mul = 1 NEW_LINE for i in range ( 30 ) : NEW_LINE INDENT c_odd = 0 NEW_LINE odd = 0 NEW_LINE for j in range ( n ) : NEW_LINE INDENT if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) : NEW_LINE INDENT odd = ( ~ odd ) NEW_LINE DEDENT if ( odd ) : NEW_LINE INDENT c_odd += 1 NEW_LINE DEDENT DEDENT for j in range ( n ) : NEW_LINE INDENT Sum += ( mul * c_odd ) NEW_LINE if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) : NEW_LINE INDENT c_odd = ( n - j - c_odd ) NEW_LINE DEDENT DEDENT mul *= 2 NEW_LINE DEDENT return Sum NEW_LINE DEDENT arr = [ 3 , 8 , 13 ] NEW_LINE n = len ( arr ) NEW_LINE print ( findXorSum ( arr , n ) ) NEW_LINE +" +E665,"import java . io . * ; class GFG { static double calTime ( double arr [ ] , int n ) { double work = 0 ; for ( int i = 0 ; i < n ; i ++ ) work += 1 / arr [ i ] ; return 1 / work ; } public static void main ( String [ ] args ) { double arr [ ] = { 6.0 , 3.0 , 4.0 } ; int n = arr . length ; System . out . println ( calTime ( arr , n ) + "" ▁ Hours "" ) ; } } +","def calTime ( arr , n ) : NEW_LINE INDENT work = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT work += 1 / arr [ i ] NEW_LINE DEDENT return 1 / work NEW_LINE DEDENT arr = [ 6.0 , 3.0 , 4.0 ] NEW_LINE n = len ( arr ) NEW_LINE print ( calTime ( arr , n ) , "" Hours "" ) NEW_LINE +" +E666,"class GFG { static int GetMinSubarrayLength ( int a [ ] , int n ) { int ans = Math . max ( a [ 0 ] , a [ n - 1 ] ) ; int lo = 0 , hi = n - 1 ; while ( lo < n && a [ lo ] % ans == 0 ) lo ++ ; while ( hi > lo && a [ hi ] % ans == 0 ) hi -- ; return ( hi - lo + 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 8 , 2 , 1 , 4 } ; int N = arr . length ; int Length = GetMinSubarrayLength ( arr , N ) ; System . out . println ( Length ) ; } } +","def GetMinSubarrayLength ( a , n ) : NEW_LINE INDENT ans = max ( a [ 0 ] , a [ n - 1 ] ) NEW_LINE lo = 0 NEW_LINE hi = n - 1 NEW_LINE while ( lo < n and a [ lo ] % ans == 0 ) : NEW_LINE INDENT lo += 1 NEW_LINE DEDENT while ( hi > lo and a [ hi ] % ans == 0 ) : NEW_LINE INDENT hi -= 1 NEW_LINE DEDENT return ( hi - lo + 1 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 4 , 8 , 2 , 1 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE length = GetMinSubarrayLength ( arr , N ) NEW_LINE print ( length ) NEW_LINE DEDENT +" +E667,"class GFG { static int maxSumBitonicSubArr ( int arr [ ] , int n ) { int [ ] msis = new int [ n ] ; int [ ] msds = new int [ n ] ; int max_sum = Integer . MIN_VALUE ; msis [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] > arr [ i - 1 ] ) msis [ i ] = msis [ i - 1 ] + arr [ i ] ; else msis [ i ] = arr [ i ] ; msds [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) if ( arr [ i ] > arr [ i + 1 ] ) msds [ i ] = msds [ i + 1 ] + arr [ i ] ; else msds [ i ] = arr [ i ] ; for ( int i = 0 ; i < n ; i ++ ) if ( max_sum < ( msis [ i ] + msds [ i ] - arr [ i ] ) ) max_sum = msis [ i ] + msds [ i ] - arr [ i ] ; return max_sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 3 , 9 , 2 , 7 , 6 , 4 } ; int n = arr . length ; System . out . println ( "" Maximum ▁ Sum ▁ = ▁ "" + maxSumBitonicSubArr ( arr , n ) ) ; } } +","def maxSumBitonicSubArr ( arr , n ) : NEW_LINE INDENT msis = [ None ] * n NEW_LINE msds = [ None ] * n NEW_LINE max_sum = 0 NEW_LINE msis [ 0 ] = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i ] > arr [ i - 1 ] ) : NEW_LINE INDENT msis [ i ] = msis [ i - 1 ] + arr [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT msis [ i ] = arr [ i ] NEW_LINE DEDENT DEDENT msds [ n - 1 ] = arr [ n - 1 ] NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT if ( arr [ i ] > arr [ i + 1 ] ) : NEW_LINE INDENT msds [ i ] = msds [ i + 1 ] + arr [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT msds [ i ] = arr [ i ] NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT if ( max_sum < ( msis [ i ] + msds [ i ] - arr [ i ] ) ) : NEW_LINE INDENT max_sum = ( msis [ i ] + msds [ i ] - arr [ i ] ) NEW_LINE DEDENT DEDENT return max_sum NEW_LINE DEDENT arr = [ 5 , 3 , 9 , 2 , 7 , 6 , 4 ] ; NEW_LINE n = len ( arr ) NEW_LINE print ( "" Maximum ▁ Sum ▁ = ▁ "" + str ( maxSumBitonicSubArr ( arr , n ) ) ) NEW_LINE +" +E668,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { public static int minimumDeletions ( char [ ] s ) { int [ ] freqOfLetter ; freqOfLetter = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) freqOfLetter [ i ] = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { freqOfLetter [ s [ i ] - ' a ' ] ++ ; } Map < Integer , Integer > LetterFreqMap = new TreeMap < Integer , Integer > ( Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freqOfLetter [ i ] != 0 ) { if ( LetterFreqMap . containsKey ( freqOfLetter [ i ] ) ) { LetterFreqMap . put ( freqOfLetter [ i ] , LetterFreqMap . get ( freqOfLetter [ i ] ) + 1 ) ; } else LetterFreqMap . put ( freqOfLetter [ i ] , 1 ) ; } } int deletions = 0 ; Set < Map . Entry < Integer , Integer > > set = LetterFreqMap . entrySet ( ) ; for ( Map . Entry < Integer , Integer > me : set ) { if ( me . getKey ( ) == 0 ) break ; while ( me . getValue ( ) > 1 ) { deletions ++ ; LetterFreqMap . put ( me . getKey ( ) , LetterFreqMap . get ( me . getKey ( ) ) - 1 ) ; if ( LetterFreqMap . containsKey ( me . getKey ( ) - 1 ) ) { LetterFreqMap . put ( me . getKey ( ) - 1 , LetterFreqMap . get ( me . getKey ( ) - 1 ) + 1 ) ; } else LetterFreqMap . put ( me . getKey ( ) - 1 , 1 ) ; } } return deletions ; } public static void main ( String [ ] args ) throws java . lang . Exception { String s = "" geeksforgeeks "" ; System . out . println ( minimumDeletions ( s . toCharArray ( ) ) ) ; } } +","def minimumDeletions ( s ) : NEW_LINE INDENT freqOfLetter = [ 0 ] * 26 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT freqOfLetter [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT LetterFreqMap = dict ( ) NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT if ( freqOfLetter [ i ] != 0 ) : NEW_LINE INDENT LetterFreqMap [ freqOfLetter [ i ] ] = \ NEW_LINE LetterFreqMap . get ( freqOfLetter [ i ] , 0 ) + 1 NEW_LINE DEDENT DEDENT deletions = 0 NEW_LINE a = list ( LetterFreqMap . keys ( ) ) NEW_LINE a = a [ : : - 1 ] NEW_LINE a . sort ( ) NEW_LINE while len ( a ) > 0 : NEW_LINE INDENT it = a . pop ( ) NEW_LINE if ( it == 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT while ( LetterFreqMap [ it ] > 1 ) : NEW_LINE INDENT deletions += 1 NEW_LINE LetterFreqMap [ it ] -= 1 NEW_LINE if ( it - 1 ) in LetterFreqMap . keys ( ) : NEW_LINE INDENT LetterFreqMap [ it - 1 ] += 1 NEW_LINE DEDENT elif ( it - 1 ) > 0 : NEW_LINE INDENT a . insert ( 0 , it - 1 ) NEW_LINE LetterFreqMap [ it - 1 ] = 1 NEW_LINE DEDENT DEDENT DEDENT return deletions NEW_LINE DEDENT s = "" geeksforgeeks "" NEW_LINE print ( minimumDeletions ( s ) ) NEW_LINE +" +E669,"import java . io . * ; class GFG { static void findMax ( int [ ] arr , int n ) { int maxFirst = Integer . MIN_VALUE ; int mid = n / 2 ; for ( int i = 0 ; i < mid ; i ++ ) { maxFirst = Math . max ( maxFirst , arr [ i ] ) ; } if ( n % 2 == 1 ) { maxFirst = Math . max ( maxFirst , arr [ mid ] ) ; } int maxSecond = Integer . MIN_VALUE ; for ( int i = mid ; i < n ; i ++ ) { maxSecond = Math . max ( maxSecond , arr [ i ] ) ; } System . out . print ( maxFirst + "" , ▁ "" + maxSecond ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 12 , 14 , 5 } ; int n = arr . length ; findMax ( arr , n ) ; } } +","import sys NEW_LINE def findMax ( arr , n ) : NEW_LINE INDENT maxFirst = - sys . maxsize - 1 NEW_LINE mid = n // 2 ; NEW_LINE for i in range ( 0 , mid ) : NEW_LINE INDENT maxFirst = max ( maxFirst , arr [ i ] ) NEW_LINE DEDENT if ( n % 2 == 1 ) : NEW_LINE INDENT maxFirst = max ( maxFirst , arr [ mid ] ) NEW_LINE DEDENT maxSecond = - sys . maxsize - 1 NEW_LINE for i in range ( mid , n ) : NEW_LINE INDENT maxSecond = max ( maxSecond , arr [ i ] ) NEW_LINE DEDENT print ( maxFirst , "" , "" , maxSecond ) NEW_LINE DEDENT arr = [ 1 , 12 , 14 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE findMax ( arr , n ) NEW_LINE +" +E670,"public class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int a , int b ) { return ( a * b ) / gcd ( a , b ) ; } static void printSum ( int num1 , int den1 , int num2 , int den2 ) { int lcd = lcm ( den1 , den2 ) ; num1 *= ( lcd / den1 ) ; num2 *= ( lcd / den2 ) ; int res_num = num1 + num2 ; System . out . print ( res_num + "" / "" + lcd ) ; } public static void main ( String args [ ] ) { int num1 = 1 , den1 = 6 ; int num2 = 7 , den2 = 15 ; printSum ( num1 , den1 , num2 , den2 ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 ) : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b % a , a ) NEW_LINE DEDENT def lcm ( a , b ) : NEW_LINE INDENT return ( a * b ) / gcd ( a , b ) NEW_LINE DEDENT def printSum ( num1 , den1 , num2 , den2 ) : NEW_LINE INDENT lcd = lcm ( den1 , den2 ) ; NEW_LINE num1 *= ( lcd / den1 ) NEW_LINE num2 *= ( lcd / den2 ) NEW_LINE res_num = num1 + num2 ; NEW_LINE print ( int ( res_num ) , "" / "" , int ( lcd ) ) NEW_LINE DEDENT num1 = 1 NEW_LINE den1 = 6 NEW_LINE num2 = 7 NEW_LINE den2 = 15 NEW_LINE printSum ( num1 , den1 , num2 , den2 ) ; NEW_LINE +" +E671,"import java . io . * ; class GFG { static boolean maxProduct ( int arr [ ] , int n , int p ) { int minVal = arr [ 0 ] ; int maxVal = arr [ 0 ] ; int maxProduct = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) { int temp = maxVal ; maxVal = minVal ; minVal = temp ; } maxVal = Math . max ( arr [ i ] , maxVal * arr [ i ] ) ; minVal = Math . min ( arr [ i ] , minVal * arr [ i ] ) ; if ( minVal == p || maxVal == p ) { return true ; } maxProduct = Math . max ( maxProduct , maxVal ) ; } return false ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , - 5 , - 4 } ; int product = - 10 ; int n = arr . length ; if ( maxProduct ( arr , n , product ) ) { System . out . println ( "" YES "" ) ; } else System . out . println ( "" NO "" ) ; } } +","def maxProduct ( arr , n , p ) : NEW_LINE INDENT minVal = arr [ 0 ] NEW_LINE maxVal = arr [ 0 ] NEW_LINE maxProduct = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i ] < 0 ) : NEW_LINE INDENT maxVal , minVal = minVal , maxVal NEW_LINE DEDENT maxVal = max ( arr [ i ] , maxVal * arr [ i ] ) NEW_LINE minVal = min ( arr [ i ] , minVal * arr [ i ] ) NEW_LINE if ( minVal == p or maxVal == p ) : NEW_LINE INDENT return True NEW_LINE DEDENT maxProduct = max ( maxProduct , maxVal ) NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , - 5 , - 4 ] NEW_LINE product = - 10 NEW_LINE n = len ( arr ) NEW_LINE if ( maxProduct ( arr , n , product ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E672,"class GFG { static int solve ( double M , double N , double s ) { int ans = ( ( int ) ( Math . ceil ( M / s ) ) * ( int ) ( Math . ceil ( N / s ) ) ) ; return ans ; } public static void main ( String [ ] args ) { double N = 12 , M = 13 , s = 4 ; System . out . println ( solve ( M , N , s ) ) ; } } +","import math NEW_LINE def solve ( M , N , s ) : NEW_LINE INDENT ans = ( ( math . ceil ( M / s ) ) * ( math . ceil ( N / s ) ) ) ; NEW_LINE return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 12 NEW_LINE M = 13 NEW_LINE s = 4 NEW_LINE print ( solve ( M , N , s ) ) NEW_LINE DEDENT +" +E673,"import java . util . * ; class GFG { static void IfExists ( int arr [ ] , int n ) { int sum [ ] = new int [ n ] ; Arrays . sort ( arr ) ; sum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) sum [ i ] = sum [ i - 1 ] + arr [ i ] ; int max = arr [ n - 1 ] ; boolean flag = false ; for ( int i = 1 ; i <= max ; i ++ ) { int findex = 0 ; int lindex = 0 ; int l = 0 ; int r = n - 1 ; while ( l <= r ) { int m = ( l + r ) / 2 ; if ( arr [ m ] < i ) { findex = m ; l = m + 1 ; } else r = m - 1 ; } l = 1 ; r = n ; flag = false ; while ( l <= r ) { int m = ( r + l ) / 2 ; if ( arr [ m ] > i ) { lindex = m ; r = m - 1 ; } else l = m + 1 ; } if ( sum [ findex ] == sum [ n - 1 ] - sum [ lindex - 1 ] ) { flag = true ; break ; } } if ( flag ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 2 , 5 } ; int n = arr . length ; IfExists ( arr , n ) ; } } +","def IfExists ( arr , n ) : NEW_LINE INDENT sum = [ 0 ] * n ; NEW_LINE arr . sort ( ) ; NEW_LINE sum [ 0 ] = arr [ 0 ] ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT sum [ i ] = sum [ i - 1 ] + arr [ i ] ; NEW_LINE DEDENT max = arr [ n - 1 ] ; NEW_LINE flag = False ; NEW_LINE for i in range ( 1 , max + 1 ) : NEW_LINE INDENT findex = 0 ; NEW_LINE lindex = 0 ; NEW_LINE l = 0 ; NEW_LINE r = n - 1 ; NEW_LINE while ( l <= r ) : NEW_LINE INDENT m = ( l + r ) // 2 ; NEW_LINE if ( arr [ m ] < i ) : NEW_LINE INDENT findex = m ; NEW_LINE l = m + 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT r = m - 1 ; NEW_LINE DEDENT DEDENT l = 1 ; NEW_LINE r = n ; NEW_LINE flag = False ; NEW_LINE while ( l <= r ) : NEW_LINE INDENT m = ( r + l ) // 2 ; NEW_LINE if ( arr [ m ] > i ) : NEW_LINE INDENT lindex = m ; NEW_LINE r = m - 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT l = m + 1 ; NEW_LINE DEDENT DEDENT if ( sum [ findex ] == sum [ n - 1 ] - sum [ lindex - 1 ] ) : NEW_LINE INDENT flag = True ; NEW_LINE break ; NEW_LINE DEDENT DEDENT if ( flag ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 2 , 5 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE IfExists ( arr , n ) ; NEW_LINE DEDENT +" +E674,"class demo { public static double sumOfTheSeries ( int n ) { return ( double ) n / ( n + 1 ) ; } public static void main ( String args [ ] ) { int n = 10 ; System . out . println ( sumOfTheSeries ( n ) ) ; } } +","def sumOfTheSeries ( n ) : NEW_LINE INDENT return ( float ( n ) / ( n + 1 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 NEW_LINE ans = sumOfTheSeries ( n ) NEW_LINE print ( round ( ans , 6 ) ) NEW_LINE DEDENT +" +E675,"import java . io . * ; import java . util . * ; import java . lang . Math ; class CloseSum { static void printClosest ( int arr [ ] , int n , int x ) { int res_l = 0 , res_r = 0 ; int l = 0 , r = n - 1 , diff = Integer . MAX_VALUE ; while ( r > l ) { if ( Math . abs ( arr [ l ] + arr [ r ] - x ) < diff ) { res_l = l ; res_r = r ; diff = Math . abs ( arr [ l ] + arr [ r ] - x ) ; } if ( arr [ l ] + arr [ r ] > x ) r -- ; else l ++ ; } System . out . println ( "" ▁ The ▁ closest ▁ pair ▁ is ▁ "" + arr [ res_l ] + "" ▁ and ▁ "" + arr [ res_r ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 22 , 28 , 29 , 30 , 40 } , x = 54 ; int n = arr . length ; printClosest ( arr , n , x ) ; } } +","MAX_VAL = 1000000000 NEW_LINE def printClosest ( arr , n , x ) : NEW_LINE INDENT res_l , res_r = 0 , 0 NEW_LINE l , r , diff = 0 , n - 1 , MAX_VAL NEW_LINE while r > l : NEW_LINE INDENT if abs ( arr [ l ] + arr [ r ] - x ) < diff : NEW_LINE INDENT res_l = l NEW_LINE res_r = r NEW_LINE diff = abs ( arr [ l ] + arr [ r ] - x ) NEW_LINE DEDENT if arr [ l ] + arr [ r ] > x : NEW_LINE INDENT r -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT l += 1 NEW_LINE DEDENT DEDENT print ( ' The ▁ closest ▁ pair ▁ is ▁ { } ▁ and ▁ { } ' . format ( arr [ res_l ] , arr [ res_r ] ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 10 , 22 , 28 , 29 , 30 , 40 ] NEW_LINE n = len ( arr ) NEW_LINE x = 54 NEW_LINE printClosest ( arr , n , x ) NEW_LINE DEDENT +" +E676,"class GFG { static int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static int power ( int x , int y ) { int res = 1 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = res * x ; y = y >> 1 ; x = x * x ; } return res ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void FindProbability ( int n ) { int up = binomialCoeff ( 2 * n , n ) ; int down = power ( 2 , 2 * n ) ; int g = gcd ( up , down ) ; up /= g ; down /= g ; System . out . println ( up + "" / "" + down ) ; } public static void main ( String [ ] args ) { int N = 8 ; FindProbability ( N ) ; } } +","import math NEW_LINE def binomialCoeff ( n , k ) : NEW_LINE INDENT res = 1 NEW_LINE if ( k > n - k ) : NEW_LINE INDENT k = n - k NEW_LINE DEDENT for i in range ( 0 , k ) : NEW_LINE INDENT res = res * ( n - i ) NEW_LINE res = res // ( i + 1 ) NEW_LINE DEDENT return res NEW_LINE DEDENT def power ( x , y ) : NEW_LINE INDENT res = 1 NEW_LINE while ( y > 0 ) : NEW_LINE INDENT if ( y & 1 ) : NEW_LINE INDENT res = res * x NEW_LINE DEDENT y = y // 2 NEW_LINE x = x * x NEW_LINE DEDENT return res NEW_LINE DEDENT def FindProbability ( n ) : NEW_LINE INDENT up = binomialCoeff ( 2 * n , n ) NEW_LINE down = power ( 2 , 2 * n ) NEW_LINE g = math . gcd ( up , down ) NEW_LINE up = up // g NEW_LINE down = down // g NEW_LINE print ( up , "" / "" , down ) NEW_LINE DEDENT N = 8 NEW_LINE FindProbability ( N ) NEW_LINE +" +E677,"import java . util . * ; class GFG { static class Node { int key ; Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static void inorder ( Node root ) { if ( root != null ) { inorder ( root . left ) ; System . out . print ( root . key + "" ▁ "" ) ; inorder ( root . right ) ; } } static Node createTree ( int parent [ ] , int n ) { HashMap < Integer , Node > m = new HashMap < > ( ) ; Node root = new Node ( ) , temp = new Node ( ) ; int i ; for ( i = 0 ; i < n ; i ++ ) { if ( m . get ( i ) == null ) { temp = newNode ( i ) ; m . put ( i , temp ) ; } if ( parent [ i ] == - 1 ) root = m . get ( i ) ; else if ( m . get ( parent [ i ] ) == null ) { temp = newNode ( parent [ i ] ) ; temp . left = m . get ( i ) ; m . put ( parent [ i ] , temp ) ; } else { if ( m . get ( parent [ i ] ) . left == null ) m . get ( parent [ i ] ) . left = m . get ( i ) ; else m . get ( parent [ i ] ) . right = m . get ( i ) ; } } return root ; } public static void main ( String args [ ] ) { int parent [ ] = { - 1 , 0 , 0 , 1 , 1 , 3 , 5 } ; int n = parent . length ; Node root = createTree ( parent , n ) ; System . out . print ( "" Inorder ▁ Traversal ▁ of ▁ coned ▁ tree \n "" ) ; inorder ( root ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . key = 0 NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def newNode ( key : int ) -> Node : NEW_LINE INDENT temp = Node ( ) NEW_LINE temp . key = key NEW_LINE temp . left = None NEW_LINE temp . right = None NEW_LINE return temp NEW_LINE DEDENT def inorder ( root : Node ) : NEW_LINE INDENT if root is not None : NEW_LINE INDENT inorder ( root . left ) NEW_LINE print ( root . key , end = "" ▁ "" ) NEW_LINE inorder ( root . right ) NEW_LINE DEDENT DEDENT def createTree ( parent : list , n : int ) -> Node : NEW_LINE INDENT m = dict ( ) NEW_LINE root = Node ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i not in m : NEW_LINE INDENT temp = newNode ( i ) NEW_LINE m [ i ] = temp NEW_LINE DEDENT if parent [ i ] == - 1 : NEW_LINE INDENT root = m [ i ] NEW_LINE DEDENT elif parent [ i ] not in m : NEW_LINE INDENT temp = newNode ( parent [ i ] ) NEW_LINE temp . left = m [ i ] NEW_LINE m [ parent [ i ] ] = temp NEW_LINE DEDENT else : NEW_LINE INDENT if m [ parent [ i ] ] . left is None : NEW_LINE INDENT m [ parent [ i ] ] . left = m [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT m [ parent [ i ] ] . right = m [ i ] NEW_LINE DEDENT DEDENT DEDENT return root NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT parent = [ - 1 , 0 , 0 , 1 , 1 , 3 , 5 ] NEW_LINE n = len ( parent ) NEW_LINE root = createTree ( parent , n ) NEW_LINE print ( "" Inorder ▁ Traversal ▁ of ▁ constructed ▁ tree "" ) NEW_LINE inorder ( root ) NEW_LINE DEDENT +" +E678,"class GFG { static int findExtra ( int arr1 [ ] , int arr2 [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return i ; return n ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 2 , 4 , 6 , 8 , 10 , 12 , 13 } ; int arr2 [ ] = { 2 , 4 , 6 , 8 , 10 , 12 } ; int n = arr2 . length ; System . out . println ( findExtra ( arr1 , arr2 , n ) ) ; } } +","def findExtra ( arr1 , arr2 , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT if ( arr1 [ i ] != arr2 [ i ] ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT return n NEW_LINE DEDENT arr1 = [ 2 , 4 , 6 , 8 , 10 , 12 , 13 ] NEW_LINE arr2 = [ 2 , 4 , 6 , 8 , 10 , 12 ] NEW_LINE n = len ( arr2 ) NEW_LINE print ( findExtra ( arr1 , arr2 , n ) ) NEW_LINE +" +E679,"class GFG { static int CountPairs ( int n ) { int k = n ; int imin = 1 ; int ans = 0 ; while ( imin <= n ) { int imax = n / k ; ans += k * ( imax - imin + 1 ) ; imin = imax + 1 ; k = n / imin ; } return ans ; } public static void main ( String [ ] args ) { System . out . println ( CountPairs ( 1 ) ) ; System . out . println ( CountPairs ( 2 ) ) ; System . out . println ( CountPairs ( 3 ) ) ; } } +","def CountPairs ( n ) : NEW_LINE INDENT k = n NEW_LINE imin = 1 NEW_LINE ans = 0 NEW_LINE while ( imin <= n ) : NEW_LINE INDENT imax = n / k NEW_LINE ans += k * ( imax - imin + 1 ) NEW_LINE imin = imax + 1 NEW_LINE k = n / imin NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( CountPairs ( 1 ) ) NEW_LINE print ( CountPairs ( 2 ) ) NEW_LINE print ( CountPairs ( 3 ) ) NEW_LINE +" +E680,"class GFG { static void find3Numbers ( int arr [ ] , int n ) { int small = + 2147483647 , large = + 2147483647 ; int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] <= small ) small = arr [ i ] ; else if ( arr [ i ] <= large ) large = arr [ i ] ; else break ; } if ( i == n ) { System . out . print ( "" No ▁ such ▁ triplet ▁ found "" ) ; return ; } for ( int j = 0 ; j <= i ; j ++ ) { if ( arr [ j ] < large ) { small = arr [ j ] ; break ; } } System . out . print ( small + "" ▁ "" + large + "" ▁ "" + arr [ i ] ) ; return ; } public static void main ( String arg [ ] ) { int arr [ ] = { 5 , 7 , 4 , 8 } ; int n = arr . length ; find3Numbers ( arr , n ) ; } } +","def find3Numbers ( arr , n ) : NEW_LINE INDENT small = + 2147483647 NEW_LINE large = + 2147483647 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] <= small ) : NEW_LINE INDENT small = arr [ i ] NEW_LINE DEDENT elif ( arr [ i ] <= large ) : NEW_LINE INDENT large = arr [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( i == n ) : NEW_LINE INDENT print ( "" No ▁ such ▁ triplet ▁ found "" ) NEW_LINE return NEW_LINE DEDENT for j in range ( i + 1 ) : NEW_LINE INDENT if ( arr [ j ] < large ) : NEW_LINE INDENT small = arr [ j ] NEW_LINE break NEW_LINE DEDENT DEDENT print ( small , "" ▁ "" , large , "" ▁ "" , arr [ i ] ) NEW_LINE return NEW_LINE DEDENT arr = [ 5 , 7 , 4 , 8 ] NEW_LINE n = len ( arr ) NEW_LINE find3Numbers ( arr , n ) NEW_LINE +" +E681,"import java . io . * ; public class GFG { static void countCharacterType ( String str ) { int vowels = 0 , consonant = 0 , specialChar = 0 , digit = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; if ( ( ch >= ' a ' && ch <= ' z ' ) || ( ch >= ' A ' && ch <= ' Z ' ) ) { ch = Character . toLowerCase ( ch ) ; ; if ( ch == ' a ' || ch == ' e ' || ch == ' i ' || ch == ' o ' || ch == ' u ' ) vowels ++ ; else consonant ++ ; } else if ( ch >= '0' && ch <= '9' ) digit ++ ; else specialChar ++ ; } System . out . println ( "" Vowels : ▁ "" + vowels ) ; System . out . println ( "" Consonant : ▁ "" + consonant ) ; System . out . println ( "" Digit : ▁ "" + digit ) ; System . out . println ( "" Special ▁ Character : ▁ "" + specialChar ) ; } static public void main ( String [ ] args ) { String str = "" geeks ▁ for ▁ geeks121"" ; countCharacterType ( str ) ; } } +","def countCharacterType ( str ) : NEW_LINE INDENT vowels = 0 NEW_LINE consonant = 0 NEW_LINE specialChar = 0 NEW_LINE digit = 0 NEW_LINE for i in range ( 0 , len ( str ) ) : NEW_LINE INDENT ch = str [ i ] NEW_LINE if ( ( ch >= ' a ' and ch <= ' z ' ) or ( ch >= ' A ' and ch <= ' Z ' ) ) : NEW_LINE INDENT ch = ch . lower ( ) NEW_LINE if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) : NEW_LINE INDENT vowels += 1 NEW_LINE DEDENT else : NEW_LINE INDENT consonant += 1 NEW_LINE DEDENT DEDENT elif ( ch >= '0' and ch <= '9' ) : NEW_LINE INDENT digit += 1 NEW_LINE DEDENT else : NEW_LINE INDENT specialChar += 1 NEW_LINE DEDENT DEDENT print ( "" Vowels : "" , vowels ) NEW_LINE print ( "" Consonant : "" , consonant ) NEW_LINE print ( "" Digit : "" , digit ) NEW_LINE print ( "" Special ▁ Character : "" , specialChar ) NEW_LINE DEDENT str = "" geeks ▁ for ▁ geeks121"" NEW_LINE countCharacterType ( str ) NEW_LINE +" +E682,"import java . io . * ; class GFG { static int calculateSum ( int n ) { return 2 * ( n * ( n + 1 ) * ( 2 * n + 1 ) / 6 ) + n * ( n + 1 ) / 2 + 2 * ( n ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( "" Sum ▁ = ▁ "" + calculateSum ( n ) ) ; } } +","def calculateSum ( n ) : NEW_LINE INDENT return ( 2 * ( n * ( n + 1 ) * ( 2 * n + 1 ) // 6 ) + n * ( n + 1 ) // 2 + 2 * ( n ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 3 NEW_LINE print ( "" Sum ▁ = "" , calculateSum ( n ) ) NEW_LINE DEDENT +" +E683,"import java . util . * ; class solution { static long countPairs ( int arr [ ] , int n ) { long count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] * arr [ j ] > arr [ i ] + arr [ j ] ) count ++ ; } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 0 , 3 , 1 , 2 } ; int n = arr . length ; System . out . println ( countPairs ( arr , n ) ) ; } } +","import math as mt NEW_LINE def countPairs ( arr , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if arr [ i ] * arr [ j ] > arr [ i ] + arr [ j ] : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 5 , 0 , 3 , 1 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countPairs ( arr , n ) ) NEW_LINE +" +E684,"import java . io . * ; class GFG { static double PI = ( 3.14159 / 180 ) ; static float areaOfKite ( int a , int b , double angle ) { angle = angle * PI ; double area = a * b * Math . sin ( angle ) ; return ( float ) area ; } public static void main ( String [ ] args ) { int a = 4 , b = 7 , angle = 78 ; System . out . println ( "" Area ▁ of ▁ Kite ▁ = ▁ "" + areaOfKite ( a , b , angle ) ) ; } } +","import math NEW_LINE PI = 3.14159 / 180 ; NEW_LINE def areaOfKite ( a , b , angle ) : NEW_LINE INDENT angle = angle * PI ; NEW_LINE area = a * b * math . sin ( angle ) ; NEW_LINE return area ; NEW_LINE DEDENT a = 4 ; b = 7 ; angle = 78 ; NEW_LINE print ( "" Area ▁ of ▁ Kite ▁ = ▁ "" , areaOfKite ( a , b , angle ) ) ; NEW_LINE +" +E685,"class GFG { public static void main ( String [ ] args ) { int target = 93 ; int [ ] arr = { 1 , 31 , 3 , 1 , 93 , 3 , 31 , 1 , 93 } ; int length = arr . length ; int totalCount = 0 ; for ( int i = 0 ; i < length - 2 ; i ++ ) { if ( target % arr [ i ] == 0 ) { for ( int j = i + 1 ; j < length - 1 ; j ++ ) { if ( target % ( arr [ i ] * arr [ j ] ) == 0 ) { int toFind = target / ( arr [ i ] * arr [ j ] ) ; for ( int k = j + 1 ; k < length ; k ++ ) { if ( arr [ k ] == toFind ) { totalCount ++ ; } } } } } } System . out . println ( "" Total ▁ number ▁ of ▁ triplets ▁ found ▁ : ▁ "" + totalCount ) ; } } +","target = 93 NEW_LINE arr = [ 1 , 31 , 3 , 1 , 93 , 3 , 31 , 1 , 93 ] NEW_LINE length = len ( arr ) NEW_LINE totalCount = 0 NEW_LINE for i in range ( length - 2 ) : NEW_LINE INDENT if target % arr [ i ] == 0 : NEW_LINE INDENT for j in range ( i + 1 , length - 1 ) : NEW_LINE INDENT if target % ( arr [ i ] * arr [ j ] ) == 0 : NEW_LINE INDENT toFind = target // ( arr [ i ] * arr [ j ] ) NEW_LINE for k in range ( j + 1 , length ) : NEW_LINE INDENT if arr [ k ] == toFind : NEW_LINE INDENT totalCount += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT print ( ' Total ▁ number ▁ of ▁ triplets ▁ found : ▁ ' , totalCount ) NEW_LINE +" +E686,"class GFG { static boolean checkSpecialPrime ( boolean [ ] sieve , int num ) { while ( num != 0 ) { if ( ! sieve [ num ] ) { return false ; } num /= 10 ; } return true ; } static void findSpecialPrime ( int N ) { boolean [ ] sieve = new boolean [ N + 10 ] ; sieve [ 0 ] = sieve [ 1 ] = false ; for ( int i = 0 ; i < N + 10 ; i ++ ) sieve [ i ] = true ; for ( int i = 2 ; i <= N ; i ++ ) { if ( sieve [ i ] ) { for ( int j = i * i ; j <= N ; j += i ) { sieve [ j ] = false ; } } } while ( true ) { if ( checkSpecialPrime ( sieve , N ) ) { System . out . println ( N ) ; break ; } else N -- ; } } public static void main ( String [ ] args ) { findSpecialPrime ( 379 ) ; findSpecialPrime ( 100 ) ; } } +","def checkSpecialPrime ( sieve , num ) : NEW_LINE INDENT while ( num ) : NEW_LINE INDENT if ( not sieve [ num ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT num //= 10 NEW_LINE DEDENT return True NEW_LINE DEDENT def findSpecialPrime ( N ) : NEW_LINE INDENT sieve = [ True ] * ( N + 10 ) NEW_LINE sieve [ 0 ] = sieve [ 1 ] = False ; NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT if ( sieve [ i ] ) : NEW_LINE INDENT for j in range ( i * i , N + 1 , i ) : NEW_LINE INDENT sieve [ j ] = False NEW_LINE DEDENT DEDENT DEDENT while ( True ) : NEW_LINE INDENT if ( checkSpecialPrime ( sieve , N ) ) : NEW_LINE INDENT print ( N ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT N -= 1 NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT findSpecialPrime ( 379 ) NEW_LINE findSpecialPrime ( 100 ) NEW_LINE DEDENT +" +E687,"import java . util . * ; class GFG { static int MAX = 1000005 ; static int [ ] fibUpto = new int [ MAX + 1 ] ; static void compute ( int sz ) { boolean [ ] isFib = new boolean [ sz + 1 ] ; int prev = 0 , curr = 1 ; isFib [ prev ] = isFib [ curr ] = true ; while ( curr <= sz ) { int temp = curr + prev ; if ( temp <= sz ) isFib [ temp ] = true ; prev = curr ; curr = temp ; } fibUpto [ 0 ] = 1 ; for ( int i = 1 ; i <= sz ; i ++ ) { fibUpto [ i ] = fibUpto [ i - 1 ] ; if ( isFib [ i ] ) fibUpto [ i ] ++ ; } } static int countOfNumbers ( int N , int K ) { compute ( N ) ; int low = 1 , high = N , ans = 0 ; while ( low <= high ) { int mid = ( low + high ) >> 1 ; if ( mid - fibUpto [ mid ] >= K ) { ans = mid ; high = mid - 1 ; } else low = mid + 1 ; } return ( ans > 0 ? N - ans + 1 : 0 ) ; } public static void main ( String [ ] args ) { int N = 10 , K = 3 ; System . out . print ( countOfNumbers ( N , K ) ) ; } } +","MAX = 1000005 NEW_LINE fibUpto = [ 0 ] * ( MAX + 1 ) NEW_LINE def compute ( sz ) : NEW_LINE INDENT isFib = [ False ] * ( sz + 1 ) NEW_LINE prev = 0 NEW_LINE curr = 1 NEW_LINE isFib [ prev ] = True NEW_LINE isFib [ curr ] = True NEW_LINE while ( curr <= sz ) : NEW_LINE INDENT temp = curr + prev NEW_LINE if ( temp <= sz ) : NEW_LINE INDENT isFib [ temp ] = True NEW_LINE DEDENT prev = curr NEW_LINE curr = temp NEW_LINE DEDENT fibUpto [ 0 ] = 1 NEW_LINE for i in range ( 1 , sz + 1 ) : NEW_LINE INDENT fibUpto [ i ] = fibUpto [ i - 1 ] NEW_LINE if ( isFib [ i ] ) : NEW_LINE INDENT fibUpto [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT def countOfNumbers ( N , K ) : NEW_LINE INDENT compute ( N ) NEW_LINE low , high , ans = 1 , N , 0 NEW_LINE while ( low <= high ) : NEW_LINE INDENT mid = ( low + high ) >> 1 NEW_LINE if ( mid - fibUpto [ mid ] >= K ) : NEW_LINE INDENT ans = mid NEW_LINE high = mid - 1 NEW_LINE DEDENT else : NEW_LINE INDENT low = mid + 1 NEW_LINE DEDENT DEDENT if ( ans ) : NEW_LINE INDENT return ( N - ans + 1 ) NEW_LINE DEDENT return 0 NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 10 NEW_LINE K = 3 NEW_LINE print ( countOfNumbers ( N , K ) ) NEW_LINE DEDENT +" +E688,"class GFG { static int setBitNumber ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; n = n + 1 ; return ( n >> 1 ) ; } public static void main ( String arg [ ] ) { int n = 273 ; System . out . print ( setBitNumber ( n ) ) ; } } +","def setBitNumber ( n ) : NEW_LINE INDENT n |= n >> 1 NEW_LINE n |= n >> 2 NEW_LINE n |= n >> 4 NEW_LINE n |= n >> 8 NEW_LINE n |= n >> 16 NEW_LINE n = n + 1 NEW_LINE return ( n >> 1 ) NEW_LINE DEDENT n = 273 NEW_LINE print ( setBitNumber ( n ) ) NEW_LINE +" +E689,"class GFG { static boolean isHeterogram ( String s , int n ) { int hash [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) != ' ▁ ' ) { if ( hash [ s . charAt ( i ) - ' a ' ] == 0 ) hash [ s . charAt ( i ) - ' a ' ] = 1 ; else return false ; } } return true ; } public static void main ( String [ ] args ) { String s = "" the ▁ big ▁ dwarf ▁ only ▁ jumps "" ; int n = s . length ( ) ; if ( isHeterogram ( s , n ) ) System . out . print ( "" YES "" ) ; else System . out . print ( "" NO "" ) ; } } +","def isHeterogram ( s , n ) : NEW_LINE INDENT hash = [ 0 ] * 26 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if s [ i ] != ' ▁ ' : NEW_LINE INDENT if hash [ ord ( s [ i ] ) - ord ( ' a ' ) ] == 0 : NEW_LINE INDENT hash [ ord ( s [ i ] ) - ord ( ' a ' ) ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT return True NEW_LINE DEDENT s = "" the ▁ big ▁ dwarf ▁ only ▁ jumps "" NEW_LINE n = len ( s ) NEW_LINE print ( "" YES "" if isHeterogram ( s , n ) else "" NO "" ) NEW_LINE +" +E690,"import java . util . Arrays ; class GFG { static int findgcd ( int a , int b ) { if ( b == 0 ) return a ; return findgcd ( b , a % b ) ; } static int minimumCuts ( int a [ ] , int n ) { Arrays . sort ( a ) ; int gcd = a [ 1 ] - a [ 0 ] ; int s = gcd ; for ( int i = 2 ; i < n ; i ++ ) { gcd = findgcd ( gcd , a [ i ] - a [ i - 1 ] ) ; s += a [ i ] - a [ i - 1 ] ; } if ( 360 - s > 0 ) gcd = findgcd ( gcd , 360 - s ) ; return ( 360 / gcd ) - n ; } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 30 , 60 , 180 } ; int n = arr . length ; System . out . println ( minimumCuts ( arr , n ) ) ; } } +","import math NEW_LINE def minimumCuts ( a , n ) : NEW_LINE INDENT a . sort ( ) NEW_LINE gcd = a [ 1 ] - a [ 0 ] NEW_LINE s = gcd NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT gcd = math . gcd ( gcd , a [ i ] - a [ i - 1 ] ) NEW_LINE s += a [ i ] - a [ i - 1 ] NEW_LINE DEDENT if ( 360 - s > 0 ) : NEW_LINE INDENT gcd = math . gcd ( gcd , 360 - s ) NEW_LINE DEDENT return ( 360 // gcd ) - n NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 30 , 60 , 180 ] NEW_LINE n = len ( arr ) NEW_LINE print ( minimumCuts ( arr , n ) ) NEW_LINE DEDENT +" +E691,"import java . util . Vector ; public class GFG { static final int MAX = 1005 ; static void SieveOfEratosthenes ( Vector < Integer > primes ) { boolean prime [ ] = new boolean [ MAX ] ; for ( int i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) { prime [ i ] = false ; } } } for ( int p = 2 ; p < MAX ; p ++ ) { if ( prime [ p ] ) { primes . add ( primes . size ( ) , p ) ; } } } static int minimumSquareFreeDivisors ( int N ) { Vector < Integer > primes = new Vector < > ( ) ; SieveOfEratosthenes ( primes ) ; int max_count = 0 ; for ( int i = 0 ; i < primes . size ( ) && primes . get ( i ) * primes . get ( i ) <= N ; i ++ ) { if ( N % primes . get ( i ) == 0 ) { int tmp = 0 ; while ( N % primes . get ( i ) == 0 ) { tmp ++ ; N /= primes . get ( i ) ; } max_count = Math . max ( max_count , tmp ) ; } } if ( max_count == 0 ) { max_count = 1 ; } return max_count ; } public static void main ( String [ ] args ) { int N = 24 ; System . out . println ( "" Minimum ▁ Number ▁ of ▁ Square ▁ Free ▁ Divisors ▁ is ▁ "" + minimumSquareFreeDivisors ( N ) ) ; N = 6 ; System . out . println ( "" Minimum ▁ Number ▁ of ▁ Square ▁ Free ▁ Divisors ▁ is ▁ "" + minimumSquareFreeDivisors ( N ) ) ; } } +","from math import sqrt NEW_LINE MAX = 1005 NEW_LINE def SieveOfEratosthenes ( primes ) : NEW_LINE INDENT prime = [ True for i in range ( MAX ) ] NEW_LINE for p in range ( 2 , int ( sqrt ( MAX ) ) + 1 , 1 ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * 2 , MAX , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT for p in range ( 2 , MAX , 1 ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT primes . append ( p ) NEW_LINE DEDENT DEDENT return primes NEW_LINE DEDENT def minimumSquareFreeDivisors ( N ) : NEW_LINE INDENT prime = [ ] NEW_LINE primes = [ ] NEW_LINE primes = SieveOfEratosthenes ( prime ) NEW_LINE max_count = 0 NEW_LINE i = 0 NEW_LINE while ( len ( primes ) and primes [ i ] * primes [ i ] <= N ) : NEW_LINE INDENT if ( N % primes [ i ] == 0 ) : NEW_LINE INDENT tmp = 0 NEW_LINE while ( N % primes [ i ] == 0 ) : NEW_LINE INDENT tmp += 1 NEW_LINE N /= primes [ i ] NEW_LINE DEDENT max_count = max ( max_count , tmp ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if ( max_count == 0 ) : NEW_LINE INDENT max_count = 1 NEW_LINE DEDENT return max_count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 24 NEW_LINE print ( "" Minimum ▁ Number ▁ of ▁ Square ▁ Free ▁ Divisors ▁ is "" , minimumSquareFreeDivisors ( N ) ) NEW_LINE N = 6 NEW_LINE print ( "" Minimum ▁ Number ▁ of ▁ Square ▁ Free ▁ Divisors ▁ is "" , minimumSquareFreeDivisors ( N ) ) NEW_LINE DEDENT +" +E692,"import java . io . * ; class GFG { static int calculateSum ( int n ) { return ( int ) Math . pow ( n * ( n + 1 ) / 2 , 2 ) ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( calculateSum ( n ) ) ; } } +","def calculateSum ( n ) : NEW_LINE INDENT return ( n * ( n + 1 ) / 2 ) ** 2 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 4 NEW_LINE print ( calculateSum ( n ) ) NEW_LINE DEDENT +" +E693,"import java . util . Stack ; public class GFG { static Stack < Integer > st = new Stack < > ( ) ; static void push_digits ( int number ) { while ( number != 0 ) { st . push ( number % 10 ) ; number = number / 10 ; } } static int reverse_number ( int number ) { push_digits ( number ) ; int reverse = 0 ; int i = 1 ; while ( ! st . isEmpty ( ) ) { reverse = reverse + ( st . peek ( ) * i ) ; st . pop ( ) ; i = i * 10 ; } return reverse ; } public static void main ( String [ ] args ) { int number = 39997 ; System . out . println ( reverse_number ( number ) ) ; } } +","st = [ ] ; NEW_LINE def push_digits ( number ) : NEW_LINE INDENT while ( number != 0 ) : NEW_LINE INDENT st . append ( number % 10 ) ; NEW_LINE number = int ( number / 10 ) ; NEW_LINE DEDENT DEDENT def reverse_number ( number ) : NEW_LINE INDENT push_digits ( number ) ; NEW_LINE reverse = 0 ; NEW_LINE i = 1 ; NEW_LINE while ( len ( st ) > 0 ) : NEW_LINE INDENT reverse = reverse + ( st [ len ( st ) - 1 ] * i ) ; NEW_LINE st . pop ( ) ; NEW_LINE i = i * 10 ; NEW_LINE DEDENT return reverse ; NEW_LINE DEDENT number = 39997 ; NEW_LINE print ( reverse_number ( number ) ) ; NEW_LINE +" +E694,"import java . util . * ; class GFG { static boolean inProportion ( int [ ] arr ) { int n = 4 ; Arrays . sort ( arr ) ; long extremes = ( long ) arr [ 0 ] * ( long ) arr [ 3 ] ; long means = ( long ) arr [ 1 ] * ( long ) arr [ 2 ] ; if ( extremes == means ) return true ; return false ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 4 , 2 } ; if ( inProportion ( arr ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def inProportion ( arr ) : NEW_LINE INDENT n = 4 ; NEW_LINE arr . sort ( ) NEW_LINE extremes = arr [ 0 ] * arr [ 3 ] ; NEW_LINE means = arr [ 1 ] * arr [ 2 ] ; NEW_LINE if ( extremes == means ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT return False ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 2 ] ; NEW_LINE if ( inProportion ( arr ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E695,"import java . io . * ; class GFG { static int M = 100 ; static int memo [ ] [ ] = new int [ M ] [ M ] ; static int numberOfPermWithKInversion ( int N , int K ) { if ( N == 0 ) return 0 ; if ( K == 0 ) return 1 ; if ( memo [ N ] [ K ] != 0 ) return memo [ N ] [ K ] ; int sum = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { if ( i <= N - 1 ) sum += numberOfPermWithKInversion ( N - 1 , K - i ) ; } memo [ N ] [ K ] = sum ; return sum ; } public static void main ( String [ ] args ) { int N = 4 ; int K = 2 ; System . out . println ( numberOfPermWithKInversion ( N , K ) ) ; } } +","M = 100 NEW_LINE memo = [ [ 0 for i in range ( M ) ] for j in range ( M ) ] NEW_LINE def numberOfPermWithKInversion ( N , K ) : NEW_LINE INDENT if ( N == 0 ) : return 0 NEW_LINE if ( K == 0 ) : return 1 NEW_LINE if ( memo [ N ] [ K ] != 0 ) : NEW_LINE INDENT return memo [ N ] [ K ] NEW_LINE DEDENT sum = 0 NEW_LINE for i in range ( K + 1 ) : NEW_LINE INDENT if ( i <= N - 1 ) : NEW_LINE INDENT sum += numberOfPermWithKInversion ( N - 1 , K - i ) NEW_LINE DEDENT DEDENT memo [ N ] [ K ] = sum NEW_LINE return sum NEW_LINE DEDENT N = 4 ; K = 2 NEW_LINE print ( numberOfPermWithKInversion ( N , K ) ) NEW_LINE +" +E696,"import java . util . * ; class GFG { static void findkth ( int n , int k ) { Vector < Integer > v1 = new Vector < Integer > ( ) ; Vector < Integer > v2 = new Vector < Integer > ( ) ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v1 . add ( i ) ; if ( i != Math . sqrt ( n ) ) v2 . add ( n / i ) ; } } Collections . reverse ( v2 ) ; if ( k > ( v1 . size ( ) + v2 . size ( ) ) ) System . out . print ( "" Doesn ' t ▁ Exist "" ) ; else { if ( k <= v1 . size ( ) ) System . out . print ( v1 . get ( k - 1 ) ) ; else System . out . print ( v2 . get ( k - v1 . size ( ) - 1 ) ) ; } } public static void main ( String [ ] args ) { int n = 15 , k = 2 ; findkth ( n , k ) ; } } +","import math as mt NEW_LINE def findkth ( n , k ) : NEW_LINE INDENT v1 = list ( ) NEW_LINE v2 = list ( ) NEW_LINE for i in range ( 1 , mt . ceil ( n ** ( .5 ) ) ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT v1 . append ( i ) NEW_LINE if ( i != mt . ceil ( mt . sqrt ( n ) ) ) : NEW_LINE INDENT v2 . append ( n // i ) NEW_LINE DEDENT DEDENT DEDENT v2 [ : : - 1 ] NEW_LINE if ( k > ( len ( v1 ) + len ( v2 ) ) ) : NEW_LINE INDENT print ( "" Doesn ' t ▁ Exist "" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT if ( k <= len ( v1 ) ) : NEW_LINE INDENT print ( v1 [ k - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( v2 [ k - len ( v1 ) - 1 ] ) NEW_LINE DEDENT DEDENT DEDENT n = 15 NEW_LINE k = 2 NEW_LINE findkth ( n , k ) NEW_LINE +" +E697,"import java . util . * ; class GFG { static int maxSubArraySum ( int a [ ] , int size ) { int max_so_far = Integer . MIN_VALUE , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } static double minimizedSum ( int a [ ] , int n , int K ) { int sum = maxSubArraySum ( a , n ) ; double totalSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) totalSum += a [ i ] ; if ( sum < 0 ) return totalSum ; totalSum = totalSum - sum + ( double ) sum / ( double ) K ; return totalSum ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , - 2 , 3 } ; int n = a . length ; int K = 2 ; System . out . println ( minimizedSum ( a , n , K ) ) ; } } +","import sys NEW_LINE def maxSubArraySum ( a , size ) : NEW_LINE INDENT max_so_far = - ( sys . maxsize - 1 ) ; NEW_LINE max_ending_here = 0 ; NEW_LINE for i in range ( size ) : NEW_LINE INDENT max_ending_here = max_ending_here + a [ i ] ; NEW_LINE if ( max_so_far < max_ending_here ) : NEW_LINE INDENT max_so_far = max_ending_here ; NEW_LINE DEDENT if ( max_ending_here < 0 ) : NEW_LINE INDENT max_ending_here = 0 ; NEW_LINE DEDENT DEDENT return max_so_far ; NEW_LINE DEDENT def minimizedSum ( a , n , K ) : NEW_LINE INDENT sum = maxSubArraySum ( a , n ) ; NEW_LINE totalSum = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT totalSum += a [ i ] ; NEW_LINE DEDENT if ( sum < 0 ) : NEW_LINE INDENT return totalSum ; NEW_LINE DEDENT totalSum = totalSum - sum + sum / K ; NEW_LINE return totalSum ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , - 2 , 3 ] ; NEW_LINE n = len ( a ) ; NEW_LINE K = 2 ; NEW_LINE print ( minimizedSum ( a , n , K ) ) ; NEW_LINE DEDENT +" +E698,"import java . util . * ; class GFG { static int countSetBits ( int n ) { int cnt = 0 ; int [ ] setBits = new int [ n + 1 ] ; setBits [ 0 ] = 0 ; setBits [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { setBits [ i ] = setBits [ i / 2 ] ; } else { setBits [ i ] = setBits [ i - 1 ] + 1 ; } } for ( int i = 0 ; i <= n ; i ++ ) { cnt = cnt + setBits [ i ] ; } return cnt ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( countSetBits ( n ) ) ; } } +","def countSetBits ( n ) : NEW_LINE INDENT cnt = 0 NEW_LINE setBits = [ 0 for x in range ( n + 1 ) ] NEW_LINE setBits [ 0 ] = 0 NEW_LINE setBits [ 1 ] = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( i % 2 == 0 ) : NEW_LINE INDENT setBits [ i ] = setBits [ i // 2 ] NEW_LINE DEDENT else : NEW_LINE INDENT setBits [ i ] = setBits [ i - 1 ] + 1 NEW_LINE DEDENT DEDENT for i in range ( 0 , n + 1 ) : NEW_LINE INDENT cnt = cnt + setBits [ i ] NEW_LINE DEDENT return cnt NEW_LINE DEDENT n = 6 NEW_LINE print ( countSetBits ( n ) ) NEW_LINE +" +E699,"class GFG { static double areaCircle ( double b ) { double area = ( double ) 3.1415926 * b * b ; return area ; } public static void main ( String args [ ] ) { float a = 10 , b = 8 ; System . out . println ( areaCircle ( b ) ) ; } } +","import math NEW_LINE def areaCircle ( b ) : NEW_LINE INDENT area = math . pi * b * b NEW_LINE return area NEW_LINE DEDENT a = 10 NEW_LINE b = 8 NEW_LINE print ( areaCircle ( b ) ) NEW_LINE +" +E700,"import java . util . * ; class GFG { static class Node { int data ; Node next ; } ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } static void printList ( Node head ) { while ( head != null ) { System . out . print ( head . data + "" - > "" ) ; head = head . next ; } } static void sortlist ( int arr [ ] , int N , Node head ) { HashMap < Integer , Integer > hash = new HashMap < Integer , Integer > ( ) ; Node temp = head ; while ( temp != null ) { if ( hash . containsKey ( temp . data ) ) hash . put ( temp . data , hash . get ( temp . data ) + 1 ) ; else hash . put ( temp . data , 1 ) ; temp = temp . next ; } temp = head ; for ( int i = 0 ; i < N ; i ++ ) { int frequency = hash . get ( arr [ i ] ) ; while ( frequency -- > 0 ) { temp . data = arr [ i ] ; temp = temp . next ; } } } public static void main ( String [ ] args ) { Node head = null ; int arr [ ] = { 5 , 1 , 3 , 2 , 8 } ; int N = arr . length ; head = push ( head , 3 ) ; head = push ( head , 2 ) ; head = push ( head , 5 ) ; head = push ( head , 8 ) ; head = push ( head , 5 ) ; head = push ( head , 2 ) ; head = push ( head , 1 ) ; sortlist ( arr , N , head ) ; System . out . print ( "" Sorted ▁ List : "" + "" \n "" ) ; printList ( head ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . data = 0 NEW_LINE self . next = None NEW_LINE DEDENT DEDENT def push ( head_ref , new_data ) : NEW_LINE INDENT new_node = Node ( ) NEW_LINE new_node . data = new_data NEW_LINE new_node . next = head_ref NEW_LINE head_ref = new_node NEW_LINE return head_ref NEW_LINE DEDENT def printList ( head ) : NEW_LINE INDENT while ( head != None ) : NEW_LINE INDENT print ( head . data , end = "" - > "" ) NEW_LINE head = head . next NEW_LINE DEDENT DEDENT def sortlist ( arr , N , head ) : NEW_LINE INDENT hash = dict ( ) NEW_LINE temp = head NEW_LINE while ( temp != None ) : NEW_LINE INDENT hash [ temp . data ] = hash . get ( temp . data , 0 ) + 1 NEW_LINE temp = temp . next NEW_LINE DEDENT temp = head NEW_LINE for i in range ( N ) : NEW_LINE INDENT frequency = hash . get ( arr [ i ] , 0 ) NEW_LINE while ( frequency > 0 ) : NEW_LINE INDENT frequency = frequency - 1 NEW_LINE temp . data = arr [ i ] NEW_LINE temp = temp . next NEW_LINE DEDENT DEDENT DEDENT head = None NEW_LINE arr = [ 5 , 1 , 3 , 2 , 8 ] NEW_LINE N = len ( arr ) NEW_LINE head = push ( head , 3 ) NEW_LINE head = push ( head , 2 ) NEW_LINE head = push ( head , 5 ) NEW_LINE head = push ( head , 8 ) NEW_LINE head = push ( head , 5 ) NEW_LINE head = push ( head , 2 ) NEW_LINE head = push ( head , 1 ) NEW_LINE sortlist ( arr , N , head ) NEW_LINE print ( "" Sorted ▁ List : "" ) NEW_LINE printList ( head ) NEW_LINE +" +E701,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void printPattern ( int N ) { for ( int i = 1 ; i <= N ; i ++ ) { System . out . print ( "" ▁ "" + ( ( i % 2 == 0 ) ? ( i - 1 ) : ( i + 1 ) ) ) ; } } public static void main ( String args [ ] ) { int N = 10 ; printPattern ( N ) ; } } +","def printPattern ( N ) : NEW_LINE INDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( i - 1 if i % 2 == 0 else i + 1 , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT N = 10 NEW_LINE printPattern ( N ) NEW_LINE +" +E702,"import java . util . LinkedList ; import java . util . Queue ; class GFG { public static int minIndex ( Queue < Integer > list , int sortIndex ) { int min_index = - 1 ; int min_value = Integer . MAX_VALUE ; int s = list . size ( ) ; for ( int i = 0 ; i < s ; i ++ ) { int current = list . peek ( ) ; list . poll ( ) ; if ( current <= min_value && i <= sortIndex ) { min_index = i ; min_value = current ; } list . add ( current ) ; } return min_index ; } public static void insertMinToRear ( Queue < Integer > list , int min_index ) { int min_value = 0 ; int s = list . size ( ) ; for ( int i = 0 ; i < s ; i ++ ) { int current = list . peek ( ) ; list . poll ( ) ; if ( i != min_index ) list . add ( current ) ; else min_value = current ; } list . add ( min_value ) ; } public static void sortQueue ( Queue < Integer > list ) { for ( int i = 1 ; i <= list . size ( ) ; i ++ ) { int min_index = minIndex ( list , list . size ( ) - i ) ; insertMinToRear ( list , min_index ) ; } } public static void main ( String [ ] args ) { Queue < Integer > list = new LinkedList < Integer > ( ) ; list . add ( 30 ) ; list . add ( 11 ) ; list . add ( 15 ) ; list . add ( 4 ) ; sortQueue ( list ) ; while ( list . isEmpty ( ) == false ) { System . out . print ( list . peek ( ) + "" ▁ "" ) ; list . poll ( ) ; } } } +","from queue import Queue NEW_LINE def minIndex ( q , sortedIndex ) : NEW_LINE INDENT min_index = - 1 NEW_LINE min_val = 999999999999 NEW_LINE n = q . qsize ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT curr = q . queue [ 0 ] NEW_LINE q . get ( ) NEW_LINE if ( curr <= min_val and i <= sortedIndex ) : NEW_LINE INDENT min_index = i NEW_LINE min_val = curr NEW_LINE DEDENT q . put ( curr ) NEW_LINE DEDENT return min_index NEW_LINE DEDENT def insertMinToRear ( q , min_index ) : NEW_LINE INDENT min_val = None NEW_LINE n = q . qsize ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT curr = q . queue [ 0 ] NEW_LINE q . get ( ) NEW_LINE if ( i != min_index ) : NEW_LINE INDENT q . put ( curr ) NEW_LINE DEDENT else : NEW_LINE INDENT min_val = curr NEW_LINE DEDENT DEDENT q . put ( min_val ) NEW_LINE DEDENT def sortQueue ( q ) : NEW_LINE INDENT for i in range ( 1 , q . qsize ( ) + 1 ) : NEW_LINE INDENT min_index = minIndex ( q , q . qsize ( ) - i ) NEW_LINE insertMinToRear ( q , min_index ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT q = Queue ( ) NEW_LINE q . put ( 30 ) NEW_LINE q . put ( 11 ) NEW_LINE q . put ( 15 ) NEW_LINE q . put ( 4 ) NEW_LINE sortQueue ( q ) NEW_LINE while ( q . empty ( ) == False ) : NEW_LINE INDENT print ( q . queue [ 0 ] , end = "" ▁ "" ) NEW_LINE q . get ( ) NEW_LINE DEDENT DEDENT +" +E703,"class GFG { static int cntRotations ( String s , int n ) { String str = s + s ; int pre [ ] = new int [ 2 * n ] ; for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( i != 0 ) pre [ i ] += pre [ i - 1 ] ; if ( str . charAt ( i ) == ' a ' || str . charAt ( i ) == ' e ' || str . charAt ( i ) == ' i ' || str . charAt ( i ) == ' o ' || str . charAt ( i ) == ' u ' ) { pre [ i ] ++ ; } } int ans = 0 ; for ( int i = n - 1 ; i < 2 * n - 1 ; i ++ ) { int r = i , l = i - n ; int x1 = pre [ r ] ; if ( l >= 0 ) x1 -= pre [ l ] ; r = i - n / 2 ; int left = pre [ r ] ; if ( l >= 0 ) left -= pre [ l ] ; int right = x1 - left ; if ( left > right ) { ans ++ ; } } return ans ; } public static void main ( String args [ ] ) { String s = "" abecidft "" ; int n = s . length ( ) ; System . out . println ( cntRotations ( s , n ) ) ; } } +","def cntRotations ( s , n ) : NEW_LINE INDENT str = s + s ; NEW_LINE pre = [ 0 ] * ( 2 * n ) ; NEW_LINE for i in range ( 2 * n ) : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT pre [ i ] += pre [ i - 1 ] ; NEW_LINE DEDENT if ( str [ i ] == ' a ' or str [ i ] == ' e ' or str [ i ] == ' i ' or str [ i ] == ' o ' or str [ i ] == ' u ' ) : NEW_LINE INDENT pre [ i ] += 1 ; NEW_LINE DEDENT DEDENT ans = 0 ; NEW_LINE for i in range ( n - 1 , 2 * n - 1 , 1 ) : NEW_LINE INDENT r = i ; l = i - n ; NEW_LINE x1 = pre [ r ] ; NEW_LINE if ( l >= 0 ) : NEW_LINE INDENT x1 -= pre [ l ] ; NEW_LINE DEDENT r = ( int ) ( i - n / 2 ) ; NEW_LINE left = pre [ r ] ; NEW_LINE if ( l >= 0 ) : NEW_LINE INDENT left -= pre [ l ] ; NEW_LINE DEDENT right = x1 - left ; NEW_LINE if ( left > right ) : NEW_LINE INDENT ans += 1 ; NEW_LINE DEDENT DEDENT return ans ; NEW_LINE DEDENT s = "" abecidft "" ; NEW_LINE n = len ( s ) ; NEW_LINE print ( cntRotations ( s , n ) ) ; NEW_LINE +" +E704,"import java . io . * ; class GFG { static int MSBPosition ( long N ) { int msb_p = - 1 ; while ( N > 0 ) { N = N >> 1 ; msb_p ++ ; } return msb_p ; } static long findBitwiseOR ( long L , long R ) { long res = 0 ; int msb_p1 = MSBPosition ( L ) ; int msb_p2 = MSBPosition ( R ) ; while ( msb_p1 == msb_p2 ) { long res_val = ( 1 << msb_p1 ) ; res += res_val ; L -= res_val ; R -= res_val ; msb_p1 = MSBPosition ( L ) ; msb_p2 = MSBPosition ( R ) ; } msb_p1 = Math . max ( msb_p1 , msb_p2 ) ; for ( int i = msb_p1 ; i >= 0 ; i -- ) { long res_val = ( 1 << i ) ; res += res_val ; } return res ; } public static void main ( String [ ] args ) { int L = 12 , R = 18 ; System . out . println ( findBitwiseOR ( L , R ) ) ; } } +","def MSBPosition ( N ) : NEW_LINE INDENT msb_p = - 1 NEW_LINE while ( N ) : NEW_LINE INDENT N = N >> 1 NEW_LINE msb_p += 1 NEW_LINE DEDENT return msb_p NEW_LINE DEDENT def findBitwiseOR ( L , R ) : NEW_LINE INDENT res = 0 NEW_LINE msb_p1 = MSBPosition ( L ) NEW_LINE msb_p2 = MSBPosition ( R ) NEW_LINE while ( msb_p1 == msb_p2 ) : NEW_LINE INDENT res_val = ( 1 << msb_p1 ) NEW_LINE res += res_val NEW_LINE L -= res_val NEW_LINE R -= res_val NEW_LINE msb_p1 = MSBPosition ( L ) NEW_LINE msb_p2 = MSBPosition ( R ) NEW_LINE DEDENT msb_p1 = max ( msb_p1 , msb_p2 ) NEW_LINE for i in range ( msb_p1 , - 1 , - 1 ) : NEW_LINE INDENT res_val = ( 1 << i ) NEW_LINE res += res_val NEW_LINE DEDENT return res NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT L , R = 12 , 18 NEW_LINE print ( findBitwiseOR ( L , R ) ) NEW_LINE DEDENT +" +E705,"class GFG { static void sieve ( boolean [ ] prime , int n ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } static int sumPrime ( int d ) { int i ; int maxVal = ( int ) Math . pow ( 10 , d ) - 1 ; boolean prime [ ] = new boolean [ maxVal + 1 ] ; for ( i = 0 ; i < maxVal + 1 ; i ++ ) prime [ i ] = true ; sieve ( prime , maxVal ) ; int sum = 0 ; for ( i = 2 ; i <= maxVal ; i ++ ) { if ( prime [ i ] ) { sum += i ; } } return sum ; } public static void main ( String [ ] args ) { int d = 3 ; System . out . println ( sumPrime ( d ) ) ; } } +","from math import sqrt NEW_LINE def sieve ( prime , n ) : NEW_LINE INDENT prime [ 0 ] = False ; NEW_LINE prime [ 1 ] = False ; NEW_LINE for p in range ( 2 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * p , n + 1 , p ) : NEW_LINE INDENT prime [ i ] = False ; NEW_LINE DEDENT DEDENT DEDENT DEDENT def sumPrime ( d ) : NEW_LINE INDENT maxVal = ( 10 ** d ) - 1 ; NEW_LINE prime = [ True ] * ( maxVal + 1 ) ; NEW_LINE sieve ( prime , maxVal ) ; NEW_LINE sum = 0 ; NEW_LINE for i in range ( 2 , maxVal + 1 ) : NEW_LINE INDENT if ( prime [ i ] ) : NEW_LINE INDENT sum += i ; NEW_LINE DEDENT DEDENT return sum ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT d = 3 ; NEW_LINE print ( sumPrime ( d ) ) ; NEW_LINE DEDENT +" +E706,"import java . util . Arrays ; class GFG { public static int MAX_CHAR = 256 ; static int kthNonRepeating ( String str , int k ) { int n = str . length ( ) ; int [ ] count = new int [ MAX_CHAR ] ; int [ ] index = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { count [ i ] = 0 ; index [ i ] = n ; } for ( int i = 0 ; i < n ; i ++ ) { char x = str . charAt ( i ) ; ++ count [ x ] ; if ( count [ x ] == 1 ) index [ x ] = i ; if ( count [ x ] == 2 ) index [ x ] = n ; } Arrays . sort ( index ) ; return ( index [ k - 1 ] != n ) ? index [ k - 1 ] : - 1 ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int k = 3 ; int res = kthNonRepeating ( str , k ) ; System . out . println ( res == - 1 ? "" There ▁ are ▁ less ▁ than ▁ k ▁ non - repeating ▁ characters "" : "" k ' th ▁ non - repeating ▁ character ▁ is ▁ ▁ "" + str . charAt ( res ) ) ; } } +","MAX_CHAR = 256 NEW_LINE def kthNonRepeating ( str , k ) : NEW_LINE INDENT n = len ( str ) NEW_LINE count = [ 0 ] * MAX_CHAR NEW_LINE index = [ 0 ] * MAX_CHAR NEW_LINE for i in range ( MAX_CHAR ) : NEW_LINE INDENT count [ i ] = 0 NEW_LINE index [ i ] = n NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT x = str [ i ] NEW_LINE count [ ord ( x ) ] += 1 NEW_LINE if ( count [ ord ( x ) ] == 1 ) : NEW_LINE INDENT index [ ord ( x ) ] = i NEW_LINE DEDENT if ( count [ ord ( x ) ] == 2 ) : NEW_LINE INDENT index [ ord ( x ) ] = n NEW_LINE DEDENT DEDENT index . sort ( ) NEW_LINE return index [ k - 1 ] if ( index [ k - 1 ] != n ) else - 1 NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" geeksforgeeks "" NEW_LINE k = 3 NEW_LINE res = kthNonRepeating ( str , k ) NEW_LINE if ( res == - 1 ) : NEW_LINE INDENT print ( "" There ▁ are ▁ less ▁ than ▁ k "" , "" non - repeating ▁ characters "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" k ' th ▁ non - repeating ▁ character ▁ is "" , str [ res ] ) NEW_LINE DEDENT DEDENT +" +E707,"class GFG { static int squareDigitSum ( String number ) { int summ = 0 ; int num = Integer . parseInt ( number ) ; int squareNum = num * num ; while ( squareNum > 0 ) { summ = summ + ( squareNum % 10 ) ; squareNum = squareNum / 10 ; } return summ ; } public static void main ( String [ ] args ) { String N = ""1111"" ; System . out . println ( squareDigitSum ( N ) ) ; } } +","def squareDigitSum ( num ) : NEW_LINE INDENT summ = 0 NEW_LINE num = int ( num ) NEW_LINE squareNum = num * num NEW_LINE while squareNum > 0 : NEW_LINE INDENT summ = summ + ( squareNum % 10 ) NEW_LINE squareNum = squareNum // 10 NEW_LINE DEDENT return summ NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = ""1111"" NEW_LINE print ( squareDigitSum ( N ) ) NEW_LINE DEDENT +" +E708,"public class GFG { static int maxCost ( int a [ ] , int n , int l , int r ) { int mx = 0 , k ; for ( int i = 0 ; i < n ; ++ i ) mx = Math . max ( mx , a [ i ] ) ; int [ ] count = new int [ mx + 1 ] ; for ( int i = 0 ; i < count . length ; i ++ ) count [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) count [ a [ i ] ] ++ ; int [ ] res = new int [ mx + 1 ] ; res [ 0 ] = 0 ; l = Math . min ( l , r ) ; for ( int num = 1 ; num <= mx ; num ++ ) { k = Math . max ( num - l - 1 , 0 ) ; res [ num ] = Math . max ( res [ num - 1 ] , num * count [ num ] + res [ k ] ) ; } return res [ mx ] ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 1 , 2 , 3 , 2 , 2 , 1 } , l = 1 , r = 1 ; int n = a . length ; System . out . println ( maxCost ( a , n , l , r ) ) ; } } +","def maxCost ( a , n , l , r ) : NEW_LINE INDENT mx = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT mx = max ( mx , a [ i ] ) NEW_LINE DEDENT count = [ 0 ] * ( mx + 1 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT count [ a [ i ] ] += 1 NEW_LINE DEDENT res = [ 0 ] * ( mx + 1 ) NEW_LINE res [ 0 ] = 0 NEW_LINE l = min ( l , r ) NEW_LINE for num in range ( 1 , mx + 1 ) : NEW_LINE INDENT k = max ( num - l - 1 , 0 ) NEW_LINE res [ num ] = max ( res [ num - 1 ] , num * count [ num ] + res [ k ] ) NEW_LINE DEDENT return res [ mx ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 2 , 1 , 2 , 3 , 2 , 2 , 1 ] NEW_LINE l , r = 1 , 1 NEW_LINE n = len ( a ) NEW_LINE print ( maxCost ( a , n , l , r ) ) NEW_LINE DEDENT +" +E709,"class GFG { public static int findPosition ( int k , int n ) { long f1 = 0 , f2 = 1 , f3 ; int i = 2 ; while ( i != 0 ) { f3 = f1 + f2 ; f1 = f2 ; f2 = f3 ; if ( f2 % k == 0 ) { return n * i ; } i ++ ; } return 0 ; } public static void main ( String [ ] args ) { int n = 5 ; int k = 4 ; System . out . print ( "" Position ▁ of ▁ n ' th ▁ multiple "" + "" ▁ of ▁ k ▁ in ▁ Fibonacci ▁ Series ▁ is ▁ "" ) ; System . out . println ( findPosition ( k , n ) ) ; } } +","def findPosition ( k , n ) : NEW_LINE INDENT f1 = 0 NEW_LINE f2 = 1 NEW_LINE i = 2 ; NEW_LINE while i != 0 : NEW_LINE INDENT f3 = f1 + f2 ; NEW_LINE f1 = f2 ; NEW_LINE f2 = f3 ; NEW_LINE if f2 % k == 0 : NEW_LINE INDENT return n * i NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return NEW_LINE DEDENT n = 5 ; NEW_LINE k = 4 ; NEW_LINE print ( "" Position ▁ of ▁ n ' th ▁ multiple ▁ of ▁ k ▁ in "" "" Fibonacci ▁ Seires ▁ is "" , findPosition ( k , n ) ) ; NEW_LINE +" +E710,"import java . util . * ; class GFG { static void printTheArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } System . out . println ( ) ; } static void generateAllBinaryStrings ( int n , int arr [ ] , int i ) { if ( i == n ) { printTheArray ( arr , n ) ; return ; } arr [ i ] = 0 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; arr [ i ] = 1 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; } public static void main ( String args [ ] ) { int n = 4 ; int [ ] arr = new int [ n ] ; generateAllBinaryStrings ( n , arr , 0 ) ; } } +","def printTheArray ( arr , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT def generateAllBinaryStrings ( n , arr , i ) : NEW_LINE INDENT if i == n : NEW_LINE INDENT printTheArray ( arr , n ) NEW_LINE return NEW_LINE DEDENT arr [ i ] = 0 NEW_LINE generateAllBinaryStrings ( n , arr , i + 1 ) NEW_LINE arr [ i ] = 1 NEW_LINE generateAllBinaryStrings ( n , arr , i + 1 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 4 NEW_LINE arr = [ None ] * n NEW_LINE generateAllBinaryStrings ( n , arr , 0 ) NEW_LINE DEDENT +" +E711,"class GFG { static String X = "" AGGT12"" ; static String Y = ""12TXAYB "" ; static String Z = ""12XBA "" ; static int [ ] [ ] [ ] dp = new int [ 100 ] [ 100 ] [ 100 ] ; static int lcsOf3 ( int i , int j , int k ) { if ( i == - 1 || j == - 1 || k == - 1 ) { return 0 ; } if ( dp [ i ] [ j ] [ k ] != - 1 ) { return dp [ i ] [ j ] [ k ] ; } if ( X . charAt ( i ) == Y . charAt ( j ) && Y . charAt ( j ) == Z . charAt ( k ) ) { return dp [ i ] [ j ] [ k ] = 1 + lcsOf3 ( i - 1 , j - 1 , k - 1 ) ; } else { return dp [ i ] [ j ] [ k ] = Math . max ( Math . max ( lcsOf3 ( i - 1 , j , k ) , lcsOf3 ( i , j - 1 , k ) ) , lcsOf3 ( i , j , k - 1 ) ) ; } } public static void main ( String [ ] args ) { for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { for ( int k = 0 ; k < 100 ; k ++ ) { dp [ i ] [ j ] [ k ] = - 1 ; } } } int m = X . length ( ) ; int n = Y . length ( ) ; int o = Z . length ( ) ; System . out . print ( "" Length ▁ of ▁ LCS ▁ is ▁ "" + lcsOf3 ( m - 1 , n - 1 , o - 1 ) ) ; } } +","X = "" AGGT12"" NEW_LINE Y = ""12TXAYB "" NEW_LINE Z = ""12XBA "" NEW_LINE dp = [ [ [ - 1 for i in range ( 100 ) ] for j in range ( 100 ) ] for k in range ( 100 ) ] NEW_LINE def lcsOf3 ( i , j , k ) : NEW_LINE INDENT if ( i == - 1 or j == - 1 or k == - 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( dp [ i ] [ j ] [ k ] != - 1 ) : NEW_LINE INDENT return dp [ i ] [ j ] [ k ] NEW_LINE DEDENT if ( X [ i ] == Y [ j ] and Y [ j ] == Z [ k ] ) : NEW_LINE INDENT dp [ i ] [ j ] [ k ] = 1 + lcsOf3 ( i - 1 , j - 1 , k - 1 ) NEW_LINE return dp [ i ] [ j ] [ k ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] [ k ] = max ( max ( lcsOf3 ( i - 1 , j , k ) , lcsOf3 ( i , j - 1 , k ) ) , lcsOf3 ( i , j , k - 1 ) ) NEW_LINE return dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT m = len ( X ) NEW_LINE n = len ( Y ) NEW_LINE o = len ( Z ) NEW_LINE print ( "" Length ▁ of ▁ LCS ▁ is "" , lcsOf3 ( m - 1 , n - 1 , o - 1 ) ) NEW_LINE DEDENT +" +E712,"import java . util . * ; class GFG { static boolean checkTriangularSumRepresentation ( int n ) { HashSet < Integer > tri = new HashSet < > ( ) ; int i = 1 ; while ( true ) { int x = i * ( i + 1 ) / 2 ; if ( x >= n ) { break ; } tri . add ( x ) ; i ++ ; } for ( Integer tm : tri ) { if ( tri . contains ( n - tm ) && ( n - tm ) != ( int ) tri . toArray ( ) [ tri . size ( ) - 1 ] ) { return true ; } } return false ; } public static void main ( String [ ] args ) { int n = 24 ; if ( checkTriangularSumRepresentation ( n ) ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","def checkTriangularSumRepresentation ( n ) : NEW_LINE INDENT tri = list ( ) ; NEW_LINE i = 1 ; NEW_LINE while ( 1 ) : NEW_LINE INDENT x = i * ( i + 1 ) // 2 ; NEW_LINE if ( x >= n ) : NEW_LINE INDENT break ; NEW_LINE DEDENT tri . append ( x ) ; NEW_LINE i += 1 ; NEW_LINE DEDENT for tm in tri : NEW_LINE INDENT if n - tm in tri : NEW_LINE INDENT return True ; NEW_LINE DEDENT DEDENT return False ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 24 ; NEW_LINE if checkTriangularSumRepresentation ( n ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E713,"public class GFG { final static double eps = ( double ) 1e-6 ; static double getArea ( double base , double hypotenuse ) { double height = Math . sqrt ( hypotenuse * hypotenuse - base * base ) ; return 0.5 * base * height ; } static void printRightAngleTriangle ( int hypotenuse , int area ) { int hsquare = hypotenuse * hypotenuse ; double sideForMaxArea = Math . sqrt ( hsquare / 2.0 ) ; double maxArea = getArea ( sideForMaxArea , hypotenuse ) ; if ( area > maxArea ) { System . out . print ( "" Not ▁ possible "" ) ; return ; } double low = 0.0 ; double high = sideForMaxArea ; double base = 0 ; while ( Math . abs ( high - low ) > eps ) { base = ( low + high ) / 2.0 ; if ( getArea ( base , hypotenuse ) >= area ) { high = base ; } else { low = base ; } } double height = Math . sqrt ( hsquare - base * base ) ; System . out . println ( Math . round ( base ) + "" ▁ "" + Math . round ( height ) ) ; } static public void main ( String [ ] args ) { int hypotenuse = 5 ; int area = 6 ; printRightAngleTriangle ( hypotenuse , area ) ; } } +","import math NEW_LINE def getArea ( base , hypotenuse ) : NEW_LINE INDENT height = math . sqrt ( hypotenuse * hypotenuse - base * base ) ; NEW_LINE return 0.5 * base * height NEW_LINE DEDENT def printRightAngleTriangle ( hypotenuse , area ) : NEW_LINE INDENT hsquare = hypotenuse * hypotenuse NEW_LINE sideForMaxArea = math . sqrt ( hsquare / 2.0 ) NEW_LINE maxArea = getArea ( sideForMaxArea , hypotenuse ) NEW_LINE if ( area > maxArea ) : NEW_LINE INDENT print ( "" Not ▁ possiblen "" ) NEW_LINE return NEW_LINE DEDENT low = 0.0 NEW_LINE high = sideForMaxArea NEW_LINE while ( abs ( high - low ) > 1e-6 ) : NEW_LINE INDENT base = ( low + high ) / 2.0 NEW_LINE if ( getArea ( base , hypotenuse ) >= area ) : NEW_LINE INDENT high = base NEW_LINE DEDENT else : NEW_LINE INDENT low = base NEW_LINE DEDENT DEDENT height = math . ceil ( math . sqrt ( hsquare - base * base ) ) NEW_LINE base = math . floor ( base ) NEW_LINE print ( base , height ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT hypotenuse = 5 NEW_LINE area = 6 NEW_LINE printRightAngleTriangle ( hypotenuse , area ) NEW_LINE DEDENT +" +E714,"class GFG { static int Remainder ( String str , int R ) { int len = str . length ( ) ; int Num , Rem = 0 ; for ( int i = 0 ; i < len ; i ++ ) { Num = Rem * 10 + ( str . charAt ( i ) - '0' ) ; Rem = Num % R ; } return Rem ; } public static void main ( String [ ] args ) { String str = ""13589234356546756"" ; int R = 13 ; System . out . println ( Remainder ( str , R ) ) ; } } +","def Remainder ( str , R ) : NEW_LINE INDENT l = len ( str ) NEW_LINE Rem = 0 NEW_LINE for i in range ( l ) : NEW_LINE INDENT Num = Rem * 10 + ( ord ( str [ i ] ) - ord ( '0' ) ) NEW_LINE Rem = Num % R NEW_LINE DEDENT return Rem NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = ""13589234356546756"" NEW_LINE R = 13 NEW_LINE print ( Remainder ( str , R ) ) NEW_LINE DEDENT +" +E715,"import java . util . * ; class GFG { static int xorGivenSetBits ( int arr [ ] , int n , int k ) { Vector < Integer > v = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( Integer . bitCount ( arr [ i ] ) == k ) { v . add ( arr [ i ] ) ; } } int result = v . get ( 0 ) ; for ( int i = 1 ; i < v . size ( ) ; i ++ ) { result = result ^ v . get ( i ) ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 13 , 1 , 19 , 7 } ; int n = arr . length ; int k = 3 ; System . out . println ( xorGivenSetBits ( arr , n , k ) ) ; } } +","def xorGivenSetBits ( arr , n , k ) : NEW_LINE INDENT v = [ ] NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( bin ( arr [ i ] ) . count ( '1' ) == k ) : NEW_LINE INDENT v . append ( arr [ i ] ) NEW_LINE DEDENT DEDENT result = v [ 0 ] NEW_LINE for i in range ( 1 , len ( v ) , 1 ) : NEW_LINE INDENT result = result ^ v [ i ] NEW_LINE DEDENT return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 2 , 13 , 1 , 19 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE k = 3 NEW_LINE print ( xorGivenSetBits ( arr , n , k ) ) NEW_LINE DEDENT +" +E716,"class GFG { static String addBinaryUtil ( String a , String b ) { String result = "" "" ; int s = 0 ; int i = a . length ( ) - 1 , j = b . length ( ) - 1 ; while ( i >= 0 || j >= 0 || s == 1 ) { s += ( ( i >= 0 ) ? a . charAt ( i ) - '0' : 0 ) ; s += ( ( j >= 0 ) ? b . charAt ( j ) - '0' : 0 ) ; result = s % 2 + result ; s /= 2 ; i -- ; j -- ; } return result ; } static String addBinary ( String arr [ ] , int n ) { String result = "" "" ; for ( int i = 0 ; i < n ; i ++ ) { result = addBinaryUtil ( result , arr [ i ] ) ; } return result ; } public static void main ( String [ ] args ) { String arr [ ] = { ""1"" , ""10"" , ""11"" } ; int n = arr . length ; System . out . println ( addBinary ( arr , n ) ) ; } } +","def addBinaryUtil ( a , b ) : NEW_LINE INDENT result = "" "" ; NEW_LINE s = 0 ; NEW_LINE i = len ( a ) - 1 ; NEW_LINE j = len ( b ) - 1 ; NEW_LINE while ( i >= 0 or j >= 0 or s == 1 ) : NEW_LINE INDENT s += ( ord ( a [ i ] ) - ord ( '0' ) ) if ( i >= 0 ) else 0 ; NEW_LINE s += ( ord ( b [ j ] ) - ord ( '0' ) ) if ( j >= 0 ) else 0 ; NEW_LINE result = chr ( s % 2 + ord ( '0' ) ) + result ; NEW_LINE s //= 2 ; NEW_LINE i -= 1 ; NEW_LINE j -= 1 ; NEW_LINE DEDENT return result ; NEW_LINE DEDENT def addBinary ( arr , n ) : NEW_LINE INDENT result = "" "" ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT result = addBinaryUtil ( result , arr [ i ] ) ; NEW_LINE DEDENT return result ; NEW_LINE DEDENT arr = [ ""1"" , ""10"" , ""11"" ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( addBinary ( arr , n ) ) ; NEW_LINE +" +E717,"class GFG { static void relativeComplement ( int arr1 [ ] , int arr2 [ ] , int n , int m ) { int i = 0 , j = 0 ; while ( i < n && j < m ) { if ( arr1 [ i ] < arr2 [ j ] ) { System . out . print ( arr1 [ i ] + "" ▁ "" ) ; i ++ ; } else if ( arr1 [ i ] > arr2 [ j ] ) { j ++ ; } else if ( arr1 [ i ] == arr2 [ j ] ) { i ++ ; j ++ ; } } while ( i < n ) System . out . print ( arr1 [ i ] + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 3 , 6 , 10 , 12 , 15 } ; int arr2 [ ] = { 1 , 3 , 5 , 10 , 16 } ; int n = arr1 . length ; int m = arr2 . length ; relativeComplement ( arr1 , arr2 , n , m ) ; } } +","def relativeComplement ( arr1 , arr2 , n , m ) : NEW_LINE INDENT i = 0 NEW_LINE j = 0 NEW_LINE while ( i < n and j < m ) : NEW_LINE INDENT if ( arr1 [ i ] < arr2 [ j ] ) : NEW_LINE INDENT print ( arr1 [ i ] , "" ▁ "" , end = "" "" ) NEW_LINE i += 1 NEW_LINE DEDENT elif ( arr1 [ i ] > arr2 [ j ] ) : NEW_LINE INDENT j += 1 NEW_LINE DEDENT elif ( arr1 [ i ] == arr2 [ j ] ) : NEW_LINE INDENT i += 1 NEW_LINE j += 1 NEW_LINE DEDENT DEDENT while ( i < n ) : NEW_LINE INDENT print ( arr1 [ i ] , "" ▁ "" , end = "" "" ) NEW_LINE DEDENT DEDENT arr1 = [ 3 , 6 , 10 , 12 , 15 ] NEW_LINE arr2 = [ 1 , 3 , 5 , 10 , 16 ] NEW_LINE n = len ( arr1 ) NEW_LINE m = len ( arr2 ) NEW_LINE relativeComplement ( arr1 , arr2 , n , m ) NEW_LINE +" +E718,"public class Improve { public static void main ( String args [ ] ) { String s = "" ABCdcba "" ; int u [ ] = new int [ 26 ] ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( Character . isUpperCase ( s . charAt ( i ) ) ) { u [ s . charAt ( i ) - 65 ] += 1 ; } else { u [ s . charAt ( i ) - 97 ] -= 1 ; } } boolean f1 = true ; int po = 0 ; int ne = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( u [ i ] > 0 ) po += u [ i ] ; if ( u [ i ] < 0 ) ne += u [ i ] ; } if ( po == 0 && ne == 0 ) System . out . println ( "" YES "" ) ; else if ( po == 1 && ne == 0 ) System . out . println ( "" YES "" ) ; else if ( po == 0 && ne == - 1 ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","s = "" ABCdcba "" NEW_LINE u = [ 0 ] * 26 NEW_LINE n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( s [ i ] . isupper ( ) ) : NEW_LINE INDENT u [ ord ( s [ i ] ) - 65 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT u [ ord ( s [ i ] ) - 97 ] -= 1 NEW_LINE DEDENT DEDENT fl = True NEW_LINE po = 0 NEW_LINE ne = 0 NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT if ( u [ i ] > 0 ) : NEW_LINE INDENT po += u [ i ] NEW_LINE DEDENT if ( u [ i ] < 0 ) : NEW_LINE INDENT ne += u [ i ] NEW_LINE DEDENT DEDENT if ( po == 0 and ne == 0 ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT elif ( po == 1 and ne == 0 ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT elif ( po == 0 and ne == - 1 ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT +" +E719,"class GFG { static boolean isPalindrome ( String s ) { int i = 0 ; int j = s . length ( ) - 1 ; while ( i < j ) { if ( s . charAt ( i ) != s . charAt ( j ) ) return false ; i ++ ; j -- ; } return true ; } static int getIndex ( String S1 , String S2 , int n ) { String S = "" "" ; for ( int i = 0 ; i < n ; i ++ ) { S = S + S1 . charAt ( i ) ; String Temp = "" "" ; for ( int j = i + 1 ; j < n ; j ++ ) Temp += S2 . charAt ( j ) ; if ( isPalindrome ( S + Temp ) ) { return i ; } } return - 1 ; } public static void main ( String [ ] args ) { String S1 = "" abcdf "" , S2 = "" sfgba "" ; int n = S1 . length ( ) ; System . out . println ( getIndex ( S1 , S2 , n ) ) ; } } +","def isPalindrome ( s ) : NEW_LINE INDENT i = 0 ; NEW_LINE j = len ( s ) - 1 ; NEW_LINE while ( i < j ) : NEW_LINE INDENT if ( s [ i ] is not s [ j ] ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT i += 1 ; NEW_LINE j -= 1 ; NEW_LINE DEDENT return True ; NEW_LINE DEDENT def getIndex ( S1 , S2 , n ) : NEW_LINE INDENT S = "" "" ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT S = S + S1 [ i ] ; NEW_LINE Temp = "" "" ; NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT Temp += S2 [ j ] ; NEW_LINE DEDENT if ( isPalindrome ( S + Temp ) ) : NEW_LINE INDENT return i ; NEW_LINE DEDENT DEDENT return - 1 ; NEW_LINE DEDENT S1 = "" abcdf "" ; S2 = "" sfgba "" ; NEW_LINE n = len ( S1 ) ; NEW_LINE print ( getIndex ( S1 , S2 , n ) ) ; NEW_LINE +" +E720,"class GFG { static int XorSum ( int arr [ ] , int n ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 != 0 ) result += arr [ i ] ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 6 , 3 , 4 , 5 } ; int n = arr . length ; System . out . println ( XorSum ( arr , n ) ) ; } } +","def XorSum ( arr , n ) : NEW_LINE INDENT result = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] % 2 != 0 ) : NEW_LINE INDENT result += arr [ i ] NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT arr = [ 1 , 2 , 6 , 3 , 4 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE print ( XorSum ( arr , n ) ) NEW_LINE +" +E721,"import java . util . * ; class solution { static long count ( int arr [ ] , int n , int x ) { if ( x == 1 ) { long ans = ( long ) Math . pow ( 2 , n ) - 1 ; return ans ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % x == 0 ) count ++ ; } long ans = ( long ) Math . pow ( 2 , count ) - 1 ; return ans ; } public static void main ( String args [ ] ) { int [ ] arr = { 2 , 4 , 3 , 5 } ; int n = arr . length ; int x = 1 ; System . out . println ( count ( arr , n , x ) ) ; } } +","def count ( arr , n , x ) : NEW_LINE INDENT if ( x == 1 ) : NEW_LINE INDENT ans = pow ( 2 , n ) - 1 NEW_LINE return ans ; NEW_LINE DEDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] % x == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT ans = pow ( 2 , count ) - 1 NEW_LINE return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 4 , 3 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE x = 1 NEW_LINE print ( count ( arr , n , x ) ) NEW_LINE DEDENT +" +E722,"class GFG { static void removeSpecialCharacter ( String str ) { char [ ] s = str . toCharArray ( ) ; int j = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( ( s [ i ] >= ' A ' && s [ i ] <= ' Z ' ) || ( s [ i ] >= ' a ' && s [ i ] <= ' z ' ) ) { s [ j ] = s [ i ] ; j ++ ; } } System . out . println ( String . valueOf ( s ) . substring ( 0 , j ) ) ; } public static void main ( String [ ] args ) { String s = "" $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? "" ; removeSpecialCharacter ( s ) ; } } +","def removeSpecialCharacter ( s ) : NEW_LINE INDENT t = "" "" NEW_LINE for i in s : NEW_LINE INDENT if ( i >= ' A ' and i <= ' Z ' ) or ( i >= ' a ' and i <= ' z ' ) : NEW_LINE INDENT t += i NEW_LINE DEDENT DEDENT print ( t ) NEW_LINE DEDENT s = "" $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? "" NEW_LINE removeSpecialCharacter ( s ) NEW_LINE +" +E723,"import java . io . * ; class GFG { static void calculate ( int a [ ] , int b [ ] , int n , int m ) { int mul = 1 ; for ( int i = 0 ; i < m ; i ++ ) if ( b [ i ] != 0 ) mul = mul * b [ i ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = ( int ) Math . floor ( a [ i ] / mul ) ; System . out . print ( x + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int a [ ] = { 5 , 100 , 8 } ; int b [ ] = { 2 , 3 } ; int n = a . length ; int m = b . length ; calculate ( a , b , n , m ) ; } } +","import math NEW_LINE def calculate ( a , b , n , m ) : NEW_LINE INDENT mul = 1 NEW_LINE for i in range ( m ) : NEW_LINE INDENT if ( b [ i ] != 0 ) : NEW_LINE INDENT mul = mul * b [ i ] NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT x = math . floor ( a [ i ] / mul ) NEW_LINE print ( x , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT a = [ 5 , 100 , 8 ] NEW_LINE b = [ 2 , 3 ] NEW_LINE n = len ( a ) NEW_LINE m = len ( b ) NEW_LINE calculate ( a , b , n , m ) NEW_LINE +" +E724,"import java . util . Arrays ; class GFG { static void sieve ( int maxEle , int prime [ ] ) { prime [ 0 ] = prime [ 1 ] = 1 ; for ( int i = 2 ; i * i <= maxEle ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = 2 * i ; j <= maxEle ; j += i ) prime [ j ] = 1 ; } } } static int digitSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += n % 10 ; n = n / 10 ; } return sum ; } static void printAdditivePrime ( int arr [ ] , int n ) { int maxEle = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; int prime [ ] = new int [ maxEle + 1 ] ; sieve ( maxEle , prime ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] == 0 ) { int sum = digitSum ( arr [ i ] ) ; if ( prime [ sum ] == 0 ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } public static void main ( String [ ] args ) { int a [ ] = { 2 , 4 , 6 , 11 , 12 , 18 , 7 } ; int n = a . length ; printAdditivePrime ( a , n ) ; } } +","from math import sqrt NEW_LINE def sieve ( maxEle , prime ) : NEW_LINE INDENT prime [ 0 ] , prime [ 1 ] = 1 , 1 NEW_LINE for i in range ( 2 , int ( sqrt ( maxEle ) ) + 1 ) : NEW_LINE INDENT if ( not prime [ i ] ) : NEW_LINE INDENT for j in range ( 2 * i , maxEle + 1 , i ) : NEW_LINE INDENT prime [ j ] = 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT def digitSum ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE while ( n ) : NEW_LINE INDENT sum += n % 10 NEW_LINE n = n // 10 NEW_LINE DEDENT return sum NEW_LINE DEDENT def printAdditivePrime ( arr , n ) : NEW_LINE INDENT maxEle = max ( arr ) NEW_LINE prime = [ 0 ] * ( maxEle + 1 ) NEW_LINE sieve ( maxEle , prime ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( prime [ arr [ i ] ] == 0 ) : NEW_LINE INDENT sum = digitSum ( arr [ i ] ) NEW_LINE if ( prime [ sum ] == 0 ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 2 , 4 , 6 , 11 , 12 , 18 , 7 ] NEW_LINE n = len ( a ) NEW_LINE printAdditivePrime ( a , n ) NEW_LINE DEDENT +" +E725,"class GFG { static int check ( int n , int m ) { if ( m % n == 0 ) { System . out . print ( "" YES "" ) ; } else { System . out . print ( "" NO "" ) ; } return 0 ; } public static void main ( String [ ] args ) { int n = 5 ; int m = 10 ; check ( n , m ) ; } } +","def check ( n , m ) : NEW_LINE INDENT if ( m % n == 0 ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT n = 5 NEW_LINE m = 10 NEW_LINE check ( n , m ) NEW_LINE +" +E726,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int findPowerOfP ( int N , int p ) { int count = 0 ; int r = p ; while ( r <= N ) { count += ( N / r ) ; r = r * p ; } return count ; } static Vector < pair > primeFactorsofB ( int B ) { Vector < pair > ans = new Vector < pair > ( ) ; for ( int i = 2 ; B != 1 ; i ++ ) { if ( B % i == 0 ) { int count = 0 ; while ( B % i == 0 ) { B = B / i ; count ++ ; } ans . add ( new pair ( i , count ) ) ; } } return ans ; } static int largestPowerOfB ( int N , int B ) { Vector < pair > vec = new Vector < pair > ( ) ; vec = primeFactorsofB ( B ) ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < vec . size ( ) ; i ++ ) ans = Math . min ( ans , findPowerOfP ( N , vec . get ( i ) . first ) / vec . get ( i ) . second ) ; return ans ; } public static void main ( String [ ] args ) { System . out . println ( largestPowerOfB ( 5 , 2 ) ) ; System . out . println ( largestPowerOfB ( 6 , 9 ) ) ; } } +","import sys NEW_LINE def findPowerOfP ( N , p ) : NEW_LINE INDENT count = 0 NEW_LINE r = p NEW_LINE while ( r <= N ) : NEW_LINE INDENT count += int ( N / r ) NEW_LINE r = r * p NEW_LINE DEDENT return count NEW_LINE DEDENT def primeFactorsofB ( B ) : NEW_LINE INDENT ans = [ ] NEW_LINE i = 2 NEW_LINE while ( B != 1 ) : NEW_LINE INDENT if ( B % i == 0 ) : NEW_LINE INDENT count = 0 NEW_LINE while ( B % i == 0 ) : NEW_LINE INDENT B = int ( B / i ) NEW_LINE count += 1 NEW_LINE DEDENT ans . append ( ( i , count ) ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return ans NEW_LINE DEDENT def largestPowerOfB ( N , B ) : NEW_LINE INDENT vec = [ ] NEW_LINE vec = primeFactorsofB ( B ) NEW_LINE ans = sys . maxsize NEW_LINE ans = min ( ans , int ( findPowerOfP ( N , vec [ 0 ] [ 0 ] ) / vec [ 0 ] [ 1 ] ) ) NEW_LINE return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( largestPowerOfB ( 5 , 2 ) ) NEW_LINE print ( largestPowerOfB ( 6 , 9 ) ) NEW_LINE DEDENT +" +E727,"class GFG { static void printCombination ( int n ) { System . out . print ( 1 + "" ▁ "" ) ; if ( ( n - 2 ) % 3 == 0 ) System . out . print ( 2 + "" ▁ "" + ( n - 3 ) ) ; else System . out . print ( 1 + "" ▁ "" + ( n - 2 ) ) ; } public static void main ( String [ ] args ) { int n = 233 ; printCombination ( n ) ; } } +","def printCombination ( n ) : NEW_LINE INDENT print ( ""1 ▁ "" , end = "" "" ) ; NEW_LINE if ( ( n - 2 ) % 3 == 0 ) : NEW_LINE INDENT print ( ""2"" , n - 3 , end = "" "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( ""1"" , ( n - 2 ) , end = "" "" ) ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 233 ; NEW_LINE printCombination ( n ) ; NEW_LINE DEDENT +" +E728,"import java . util . * ; class GFG { static void createHash ( HashSet < Integer > hash , int maxElement ) { int prev = 0 , curr = 1 ; hash . add ( prev ) ; hash . add ( curr ) ; while ( curr <= maxElement ) { int temp = curr + prev ; hash . add ( temp ) ; prev = curr ; curr = temp ; } } static int countFibonacciDivisors ( int n ) { HashSet < Integer > hash = new HashSet < Integer > ( ) ; createHash ( hash , n ) ; int cnt = 0 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( ( n / i == i ) && ( hash . contains ( n / i ) ) ) cnt ++ ; else { if ( hash . contains ( n / i ) ) cnt ++ ; if ( hash . contains ( n / ( n / i ) ) ) cnt ++ ; } } } return cnt ; } public static void main ( String [ ] args ) { int n = 12 ; System . out . print ( countFibonacciDivisors ( n ) ) ; } } +","from math import sqrt , ceil , floor NEW_LINE def createHash ( maxElement ) : NEW_LINE INDENT prev = 0 NEW_LINE curr = 1 NEW_LINE d = dict ( ) NEW_LINE d [ prev ] = 1 NEW_LINE d [ curr ] = 1 NEW_LINE while ( curr <= maxElement ) : NEW_LINE INDENT temp = curr + prev NEW_LINE d [ temp ] = 1 NEW_LINE prev = curr NEW_LINE curr = temp NEW_LINE DEDENT return d NEW_LINE DEDENT def countFibonacciDivisors ( n ) : NEW_LINE INDENT hash = createHash ( n ) NEW_LINE cnt = 0 NEW_LINE for i in range ( 1 , ceil ( sqrt ( n ) ) ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT if ( ( n // i == i ) and ( n // i in hash ) ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if ( n // i in hash ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT if ( n // ( n // i ) in hash ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT return cnt NEW_LINE DEDENT n = 12 NEW_LINE print ( countFibonacciDivisors ( n ) ) NEW_LINE +" +E729,"public class GFG { static int MAX = 1000000 ; static boolean prime [ ] = new boolean [ MAX + 1 ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } prime [ 1 ] = false ; prime [ 0 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) { prime [ i ] = false ; } } } } static void SumOfKthPrimes ( int arr [ ] , int n , int k ) { int c = 0 ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { c ++ ; if ( c % k == 0 ) { sum += arr [ i ] ; c = 0 ; } } } System . out . println ( sum ) ; } public static void main ( String [ ] args ) { SieveOfEratosthenes ( ) ; int arr [ ] = { 2 , 3 , 5 , 7 , 11 } ; int n = arr . length ; int k = 2 ; SumOfKthPrimes ( arr , n , k ) ; } } +","MAX = 100000 ; NEW_LINE prime = [ True ] * ( MAX + 1 ) ; NEW_LINE def SieveOfEratosthenes ( ) : NEW_LINE INDENT prime [ 1 ] = False ; NEW_LINE prime [ 0 ] = False ; NEW_LINE p = 2 ; NEW_LINE while ( p * p <= MAX ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT i = p * 2 ; NEW_LINE while ( i <= MAX ) : NEW_LINE INDENT prime [ i ] = False ; NEW_LINE i += p ; NEW_LINE DEDENT DEDENT p += 1 ; NEW_LINE DEDENT DEDENT def SumOfKthPrimes ( arr , n , k ) : NEW_LINE INDENT c = 0 ; NEW_LINE sum = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( prime [ arr [ i ] ] ) : NEW_LINE INDENT c += 1 ; NEW_LINE if ( c % k == 0 ) : NEW_LINE INDENT sum += arr [ i ] ; NEW_LINE c = 0 ; NEW_LINE DEDENT DEDENT DEDENT print ( sum ) ; NEW_LINE DEDENT SieveOfEratosthenes ( ) ; NEW_LINE arr = [ 2 , 3 , 5 , 7 , 11 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE k = 2 ; NEW_LINE SumOfKthPrimes ( arr , n , k ) ; NEW_LINE +" +E730,"class GFG { static void sieveOfEratosthenes ( int N , int s [ ] ) { boolean [ ] prime = new boolean [ N + 1 ] ; for ( int i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j * i <= N ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } static void generatePrimeFactors ( int N ) { int [ ] s = new int [ N + 1 ] ; sieveOfEratosthenes ( N , s ) ; System . out . println ( "" Factor ▁ Power "" ) ; int curr = s [ N ] ; int cnt = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( curr == s [ N ] ) { cnt ++ ; continue ; } System . out . println ( curr + "" \t "" + cnt ) ; curr = s [ N ] ; cnt = 1 ; } } public static void main ( String [ ] args ) { int N = 360 ; generatePrimeFactors ( N ) ; } } +","def sieveOfEratosthenes ( N , s ) : NEW_LINE INDENT prime = [ False ] * ( N + 1 ) NEW_LINE for i in range ( 2 , N + 1 , 2 ) : NEW_LINE INDENT s [ i ] = 2 NEW_LINE DEDENT for i in range ( 3 , N + 1 , 2 ) : NEW_LINE INDENT if ( prime [ i ] == False ) : NEW_LINE INDENT s [ i ] = i NEW_LINE for j in range ( i , int ( N / i ) + 1 , 2 ) : NEW_LINE INDENT if ( prime [ i * j ] == False ) : NEW_LINE INDENT prime [ i * j ] = True NEW_LINE s [ i * j ] = i NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT def generatePrimeFactors ( N ) : NEW_LINE INDENT s = [ 0 ] * ( N + 1 ) NEW_LINE sieveOfEratosthenes ( N , s ) NEW_LINE print ( "" Factor ▁ Power "" ) NEW_LINE curr = s [ N ] NEW_LINE cnt = 1 NEW_LINE while ( N > 1 ) : NEW_LINE INDENT N //= s [ N ] NEW_LINE if ( curr == s [ N ] ) : NEW_LINE INDENT cnt += 1 NEW_LINE continue NEW_LINE DEDENT print ( str ( curr ) + "" \t "" + str ( cnt ) ) NEW_LINE curr = s [ N ] NEW_LINE cnt = 1 NEW_LINE DEDENT DEDENT N = 360 NEW_LINE generatePrimeFactors ( N ) NEW_LINE +" +E731,"class GFG { static int nearest ( int n ) { int prevSquare = ( int ) Math . sqrt ( n ) ; int nextSquare = prevSquare + 1 ; prevSquare = prevSquare * prevSquare ; nextSquare = nextSquare * nextSquare ; int ans = ( n - prevSquare ) < ( nextSquare - n ) ? ( prevSquare - n ) : ( nextSquare - n ) ; return ans ; } public static void main ( String [ ] args ) { int n = 14 ; System . out . println ( nearest ( n ) ) ; n = 16 ; System . out . println ( nearest ( n ) ) ; n = 18 ; System . out . println ( nearest ( n ) ) ; } } +","from math import sqrt NEW_LINE def nearest ( n ) : NEW_LINE INDENT prevSquare = int ( sqrt ( n ) ) ; NEW_LINE nextSquare = prevSquare + 1 ; NEW_LINE prevSquare = prevSquare * prevSquare ; NEW_LINE nextSquare = nextSquare * nextSquare ; NEW_LINE ans = ( prevSquare - n ) if ( n - prevSquare ) < ( nextSquare - n ) else ( nextSquare - n ) ; NEW_LINE return ans ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 14 ; NEW_LINE print ( nearest ( n ) ) ; NEW_LINE n = 16 ; NEW_LINE print ( nearest ( n ) ) ; NEW_LINE n = 18 ; NEW_LINE print ( nearest ( n ) ) ; NEW_LINE DEDENT +" +E732,"import java . io . * ; class GFG { static void checkIfSortRotated ( int arr [ ] , int n ) { int minEle = Integer . MAX_VALUE ; int maxEle = Integer . MIN_VALUE ; int minIndex = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < minEle ) { minEle = arr [ i ] ; minIndex = i ; } } boolean flag1 = true ; for ( int i = 1 ; i < minIndex ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag1 = false ; break ; } } boolean flag2 = true ; for ( int i = minIndex + 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag2 = false ; break ; } } if ( minIndex == 0 ) { System . out . print ( "" NO "" ) ; return ; } if ( flag1 && flag2 && ( arr [ n - 1 ] < arr [ minIndex - 1 ] ) ) System . out . println ( "" YES "" ) ; else System . out . print ( "" NO "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 5 , 1 , 2 } ; int n = arr . length ; checkIfSortRotated ( arr , n ) ; } } +","import sys NEW_LINE def checkIfSortRotated ( arr , n ) : NEW_LINE INDENT minEle = sys . maxsize NEW_LINE maxEle = - sys . maxsize - 1 NEW_LINE minIndex = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] < minEle : NEW_LINE INDENT minEle = arr [ i ] NEW_LINE minIndex = i NEW_LINE DEDENT DEDENT flag1 = 1 NEW_LINE for i in range ( 1 , minIndex ) : NEW_LINE INDENT if arr [ i ] < arr [ i - 1 ] : NEW_LINE INDENT flag1 = 0 NEW_LINE break NEW_LINE DEDENT DEDENT flag2 = 2 NEW_LINE for i in range ( minIndex + 1 , n ) : NEW_LINE INDENT if arr [ i ] < arr [ i - 1 ] : NEW_LINE INDENT flag2 = 0 NEW_LINE break NEW_LINE DEDENT DEDENT if ( flag1 and flag2 and arr [ n - 1 ] < arr [ minIndex - 1 ] ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT arr = [ 3 , 4 , 5 , 1 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE checkIfSortRotated ( arr , n ) NEW_LINE +" +E733,"import java . io . * ; class GFG { static void printSquares ( int n ) { int square = 0 , prev_x = 0 ; for ( int x = 0 ; x < n ; x ++ ) { square = ( square + x + prev_x ) ; System . out . print ( square + "" ▁ "" ) ; prev_x = x ; } } public static void main ( String [ ] args ) { int n = 5 ; printSquares ( n ) ; } } +","def printSquares ( n ) : NEW_LINE INDENT square = 0 ; prev_x = 0 ; NEW_LINE for x in range ( 0 , n ) : NEW_LINE INDENT square = ( square + x + prev_x ) NEW_LINE print ( square , end = "" ▁ "" ) NEW_LINE prev_x = x NEW_LINE DEDENT DEDENT n = 5 ; NEW_LINE printSquares ( n ) ; NEW_LINE +" +E734,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static void solveProportion ( int a , int b1 , int b2 , int c ) { int A = a * b2 ; int B = b1 * b2 ; int C = b1 * c ; int gcd = __gcd ( __gcd ( A , B ) , C ) ; System . out . print ( A / gcd + "" : "" + B / gcd + "" : "" + C / gcd ) ; } public static void main ( String args [ ] ) { int a , b1 , b2 , c ; a = 3 ; b1 = 4 ; b2 = 8 ; c = 9 ; solveProportion ( a , b1 , b2 , c ) ; } } +","import math NEW_LINE def solveProportion ( a , b1 , b2 , c ) : NEW_LINE INDENT A = a * b2 NEW_LINE B = b1 * b2 NEW_LINE C = b1 * c NEW_LINE gcd1 = math . gcd ( math . gcd ( A , B ) , C ) NEW_LINE print ( str ( A // gcd1 ) + "" : "" + str ( B // gcd1 ) + "" : "" + str ( C // gcd1 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 3 NEW_LINE b1 = 4 NEW_LINE b2 = 8 NEW_LINE c = 9 NEW_LINE solveProportion ( a , b1 , b2 , c ) NEW_LINE DEDENT +" +E735,"import java . util . * ; class GFG { static void countPairs ( int arr [ ] , int N ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } int maxFreq = 0 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { maxFreq = Math . max ( maxFreq , it . getValue ( ) ) ; } System . out . print ( N - maxFreq + "" \n "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 8 , 5 , 9 , 8 , 8 , 7 , 7 , 5 , 7 , 7 } ; int N = arr . length ; countPairs ( arr , N ) ; } } +","def countPairs ( arr , N ) : NEW_LINE INDENT M = dict . fromkeys ( arr , 0 ) ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT M [ arr [ i ] ] += 1 ; NEW_LINE DEDENT maxFreq = 0 ; NEW_LINE for it in M . values ( ) : NEW_LINE INDENT maxFreq = max ( maxFreq , it ) ; NEW_LINE DEDENT print ( N - maxFreq ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 8 , 5 , 9 , 8 , 8 , 7 , 7 , 5 , 7 , 7 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE countPairs ( arr , N ) ; NEW_LINE DEDENT +" +E736,"import java . util . * ; class GFG { static void numberOfSubarrays ( int arr [ ] , int n ) { int [ ] v = new int [ n + 1 ] ; v [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { v [ i + 1 ] = v [ i ] + arr [ i ] ; } HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; int begin = 0 , end = 0 , answer = 0 ; mp . put ( 0 , 1 ) ; while ( begin < n ) { while ( end < n && ! mp . containsKey ( v [ end + 1 ] ) ) { end ++ ; mp . put ( v [ end ] , 1 ) ; } answer = answer + end - begin ; mp . remove ( v [ begin ] ) ; begin ++ ; } System . out . print ( answer + "" \n "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , - 6 } ; int size = arr . length ; numberOfSubarrays ( arr , size ) ; } } +","def numberOfSubarrays ( arr , n ) : NEW_LINE INDENT v = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT v [ i + 1 ] = v [ i ] + arr [ i ] NEW_LINE DEDENT mp = { } NEW_LINE begin , end , answer = 0 , 0 , 0 NEW_LINE mp [ 0 ] = 1 NEW_LINE while ( begin < n ) : NEW_LINE INDENT while ( end < n and ( v [ end + 1 ] ) not in mp ) : NEW_LINE INDENT end += 1 NEW_LINE mp [ v [ end ] ] = 1 NEW_LINE DEDENT answer = answer + end - begin NEW_LINE del mp [ v [ begin ] ] NEW_LINE begin += 1 NEW_LINE DEDENT print ( answer ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 4 , - 6 ] NEW_LINE size = len ( arr ) NEW_LINE numberOfSubarrays ( arr , size ) NEW_LINE DEDENT +" +E737,"import java . util . * ; class GFG { static int minimizeDiff ( int [ ] arr , int n , int k ) { int max = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; int min = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; if ( ( max - min ) <= k ) { return ( max - min ) ; } int avg = ( max + min ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > avg ) { arr [ i ] -= k ; } else { arr [ i ] += k ; } } max = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; min = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; return ( max - min ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 16 , 12 , 9 , 20 } ; int n = 5 ; int k = 3 ; System . out . println ( "" Max ▁ height ▁ difference ▁ = ▁ "" + minimizeDiff ( arr , n , k ) ) ; } } +","def minimizeDiff ( arr , n , k ) : NEW_LINE INDENT max_element = max ( arr ) NEW_LINE min_element = min ( arr ) NEW_LINE if ( ( max_element - min_element ) <= k ) : NEW_LINE INDENT return ( max_element - min_element ) NEW_LINE DEDENT avg = ( max_element + min_element ) // 2 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] > avg ) : NEW_LINE INDENT arr [ i ] -= k NEW_LINE DEDENT else : NEW_LINE INDENT arr [ i ] += k NEW_LINE DEDENT DEDENT max_element = max ( arr ) NEW_LINE min_element = min ( arr ) NEW_LINE return ( max_element - min_element ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 3 , 16 , 12 , 9 , 20 ] NEW_LINE n = 5 NEW_LINE k = 3 NEW_LINE print ( "" Max ▁ height ▁ difference ▁ = "" , minimizeDiff ( arr , n , k ) ) NEW_LINE DEDENT +" +E738,"import java . io . * ; import java . util . * ; class Graph { private int V ; private LinkedList < Integer > adj [ ] ; Graph ( int v ) { V = v ; adj = new LinkedList [ v ] ; for ( int i = 0 ; i < v ; ++ i ) adj [ i ] = new LinkedList ( ) ; } void addEdge ( int v , int w ) { adj [ v ] . add ( w ) ; } void BFS ( int s ) { boolean visited [ ] = new boolean [ V ] ; LinkedList < Integer > queue = new LinkedList < Integer > ( ) ; visited [ s ] = true ; queue . add ( s ) ; while ( queue . size ( ) != 0 ) { s = queue . poll ( ) ; System . out . print ( s + "" ▁ "" ) ; Iterator < Integer > i = adj [ s ] . listIterator ( ) ; while ( i . hasNext ( ) ) { int n = i . next ( ) ; if ( ! visited [ n ] ) { visited [ n ] = true ; queue . add ( n ) ; } } } } public static void main ( String args [ ] ) { Graph g = new Graph ( 4 ) ; g . addEdge ( 0 , 1 ) ; g . addEdge ( 0 , 2 ) ; g . addEdge ( 1 , 2 ) ; g . addEdge ( 2 , 0 ) ; g . addEdge ( 2 , 3 ) ; g . addEdge ( 3 , 3 ) ; System . out . println ( "" Following ▁ is ▁ Breadth ▁ First ▁ Traversal ▁ "" + "" ( starting ▁ from ▁ vertex ▁ 2 ) "" ) ; g . BFS ( 2 ) ; } } +","from collections import defaultdict NEW_LINE class Graph : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . graph = defaultdict ( list ) NEW_LINE DEDENT def addEdge ( self , u , v ) : NEW_LINE INDENT self . graph [ u ] . append ( v ) NEW_LINE DEDENT def BFS ( self , s ) : NEW_LINE INDENT visited = [ False ] * ( len ( self . graph ) ) NEW_LINE queue = [ ] NEW_LINE queue . append ( s ) NEW_LINE visited [ s ] = True NEW_LINE while queue : NEW_LINE INDENT s = queue . pop ( 0 ) NEW_LINE print ( s , end = "" ▁ "" ) NEW_LINE for i in self . graph [ s ] : NEW_LINE INDENT if visited [ i ] == False : NEW_LINE INDENT queue . append ( i ) NEW_LINE visited [ i ] = True NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT g = Graph ( ) NEW_LINE g . addEdge ( 0 , 1 ) NEW_LINE g . addEdge ( 0 , 2 ) NEW_LINE g . addEdge ( 1 , 2 ) NEW_LINE g . addEdge ( 2 , 0 ) NEW_LINE g . addEdge ( 2 , 3 ) NEW_LINE g . addEdge ( 3 , 3 ) NEW_LINE print ( "" Following ▁ is ▁ Breadth ▁ First ▁ Traversal "" "" ▁ ( starting ▁ from ▁ vertex ▁ 2 ) "" ) NEW_LINE g . BFS ( 2 ) NEW_LINE +" +E739,"class GFG { static int cal ( int n ) { double res = Math . pow ( Math . ceil ( ( Math . pow ( Math . pow ( 10 , ( n - 1 ) ) , 1 / 4 ) ) ) , 4 ) ; return ( int ) res ; } public static void main ( String [ ] args ) { int n = 1 ; System . out . println ( cal ( n ) ) ; } } +","from math import * NEW_LINE def cal ( n ) : NEW_LINE INDENT res = pow ( ceil ( ( pow ( pow ( 10 , ( n - 1 ) ) , 1 / 4 ) ) ) , 4 ) NEW_LINE return int ( res ) NEW_LINE DEDENT n = 1 NEW_LINE print ( cal ( n ) ) NEW_LINE +" +E740,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int bit ( int n ) { int count = 0 ; while ( n > 0 ) { count ++ ; n = n & ( n - 1 ) ; } return count ; } static int maxSumOfBits ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = bit ( arr [ i ] ) ; } int incl = arr [ 0 ] ; int excl = 0 ; int excl_new ; for ( int i = 1 ; i < n ; i ++ ) { excl_new = ( incl > excl ) ? incl : excl ; incl = excl + arr [ i ] ; excl = excl_new ; } return ( ( incl > excl ) ? incl : excl ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 4 , 5 , 6 , 7 , 20 , 25 } ; int n = arr . length ; System . out . print ( maxSumOfBits ( arr , n ) ) ; } } +","def bit ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while ( n ) : NEW_LINE INDENT count += 1 NEW_LINE n = n & ( n - 1 ) NEW_LINE DEDENT return count NEW_LINE DEDENT def maxSumOfBits ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT arr [ i ] = bit ( arr [ i ] ) NEW_LINE DEDENT incl = arr [ 0 ] NEW_LINE excl = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if incl > excl : NEW_LINE INDENT excl_new = incl NEW_LINE DEDENT else : NEW_LINE INDENT excl_new = excl NEW_LINE DEDENT incl = excl + arr [ i ] ; NEW_LINE excl = excl_new NEW_LINE DEDENT if incl > excl : NEW_LINE INDENT return incl NEW_LINE DEDENT else : NEW_LINE INDENT return excl NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 5 , 6 , 7 , 20 , 25 ] NEW_LINE n = len ( arr ) NEW_LINE print ( maxSumOfBits ( arr , n ) ) NEW_LINE DEDENT +" +E741,"import java . util . * ; class GFG { static int subsetXOR ( int arr [ ] , int n , int K ) { int max_ele = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) if ( arr [ i ] > max_ele ) max_ele = arr [ i ] ; int m = ( 1 << ( int ) ( Math . log ( max_ele ) / Math . log ( 2 ) + 1 ) ) - 1 ; int [ ] [ ] [ ] dp = new int [ n + 1 ] [ m + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= m ; j ++ ) for ( int k = 0 ; k <= n ; k ++ ) dp [ i ] [ j ] [ k ] = 0 ; for ( int i = 0 ; i <= n ; i ++ ) dp [ i ] [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { for ( int k = 0 ; k <= n ; k ++ ) { dp [ i ] [ j ] [ k ] = dp [ i - 1 ] [ j ] [ k ] ; if ( k != 0 ) { dp [ i ] [ j ] [ k ] += k * dp [ i - 1 ] [ j ^ arr [ i - 1 ] ] [ k - 1 ] ; } } } } int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { ans += dp [ n ] [ K ] [ i ] ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 } ; int k = 1 ; int n = arr . length ; System . out . println ( subsetXOR ( arr , n , k ) ) ; } } +","from math import log2 NEW_LINE def subsetXOR ( arr , n , K ) : NEW_LINE INDENT max_ele = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i ] > max_ele ) : NEW_LINE INDENT max_ele = arr [ i ] NEW_LINE DEDENT DEDENT m = ( 1 << int ( log2 ( max_ele ) + 1 ) ) - 1 NEW_LINE dp = [ [ [ 0 for i in range ( n + 1 ) ] for j in range ( m + 1 ) ] for k in range ( n + 1 ) ] NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT for j in range ( m + 1 ) : NEW_LINE INDENT for k in range ( n + 1 ) : NEW_LINE INDENT dp [ i ] [ j ] [ k ] = 0 NEW_LINE DEDENT DEDENT DEDENT for i in range ( n + 1 ) : NEW_LINE INDENT dp [ i ] [ 0 ] [ 0 ] = 1 NEW_LINE DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( m + 1 ) : NEW_LINE INDENT for k in range ( n + 1 ) : NEW_LINE INDENT dp [ i ] [ j ] [ k ] = dp [ i - 1 ] [ j ] [ k ] NEW_LINE if ( k != 0 ) : NEW_LINE INDENT dp [ i ] [ j ] [ k ] += k * dp [ i - 1 ] [ j ^ arr [ i - 1 ] ] [ k - 1 ] NEW_LINE DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ans += dp [ n ] [ K ] [ i ] NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 ] NEW_LINE k = 1 NEW_LINE n = len ( arr ) NEW_LINE print ( subsetXOR ( arr , n , k ) ) NEW_LINE DEDENT +" +E742,"import java . io . * ; class GFG { static int MaximumHeight ( int [ ] a , int n ) { int result = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { int y = ( i * ( i + 1 ) ) / 2 ; if ( y < n ) result = i ; else break ; } return result ; } public static void main ( String [ ] args ) { int [ ] arr = { 40 , 100 , 20 , 30 } ; int n = arr . length ; System . out . println ( MaximumHeight ( arr , n ) ) ; } } +","def MaximumHeight ( a , n ) : NEW_LINE INDENT result = 1 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT y = ( i * ( i + 1 ) ) / 2 NEW_LINE if ( y < n ) : NEW_LINE INDENT result = i NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT arr = [ 40 , 100 , 20 , 30 ] NEW_LINE n = len ( arr ) NEW_LINE print ( MaximumHeight ( arr , n ) ) NEW_LINE +" +E743,"class GFG { static String toNegativeBase ( int n , int negBase ) { if ( n == 0 ) return ""0"" ; String converted = "" "" ; while ( n != 0 ) { int remainder = n % negBase ; n /= negBase ; if ( remainder < 0 ) { remainder += ( - negBase ) ; n += 1 ; } converted = String . valueOf ( remainder ) + converted ; } return converted ; } public static void main ( String [ ] args ) { int n = 13 ; int negBase = - 2 ; System . out . print ( toNegativeBase ( n , negBase ) ) ; } } +","def toNegativeBase ( n , negBase ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return ""0"" NEW_LINE DEDENT converted = ""01"" NEW_LINE while ( n != 0 ) : NEW_LINE INDENT remainder = n % ( negBase ) NEW_LINE n = int ( n / negBase ) NEW_LINE if ( remainder < 0 ) : NEW_LINE INDENT remainder += ( ( - 1 ) * negBase ) NEW_LINE n += 1 NEW_LINE DEDENT converted = str ( remainder ) + converted NEW_LINE DEDENT return converted NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 13 NEW_LINE negBase = - 2 NEW_LINE print ( toNegativeBase ( n , negBase ) ) NEW_LINE DEDENT +" +E744,"class GFG { static int m = 6 , n = 4 ; static int compareRow ( int a1 [ ] , int a2 [ ] ) { for ( int i = 0 ; i < n ; i ++ ) { if ( a1 [ i ] < a2 [ i ] ) return 1 ; else if ( a1 [ i ] > a2 [ i ] ) return - 1 ; } return 0 ; } static int binaryCheck ( int ar [ ] [ ] , int arr [ ] ) { int l = 0 , r = m - 1 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; int temp = compareRow ( ar [ mid ] , arr ) ; if ( temp == 0 ) return mid + 1 ; else if ( temp == 1 ) l = mid + 1 ; else r = mid - 1 ; } return - 1 ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 0 , 0 , 1 , 0 } , { 10 , 9 , 22 , 23 } , { 40 , 40 , 40 , 40 } , { 43 , 44 , 55 , 68 } , { 81 , 73 , 100 , 132 } , { 100 , 75 , 125 , 133 } } ; int row [ ] = { 10 , 9 , 22 , 23 } ; System . out . println ( binaryCheck ( mat , row ) ) ; } } +","m = 6 ; NEW_LINE n = 4 ; NEW_LINE def compareRow ( a1 , a2 ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if ( a1 [ i ] < a2 [ i ] ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT elif ( a1 [ i ] > a2 [ i ] ) : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT DEDENT return 0 ; NEW_LINE DEDENT def binaryCheck ( ar , arr ) : NEW_LINE INDENT l = 0 ; r = m - 1 ; NEW_LINE while ( l <= r ) : NEW_LINE INDENT mid = ( l + r ) // 2 ; NEW_LINE temp = compareRow ( ar [ mid ] , arr ) ; NEW_LINE if ( temp == 0 ) : NEW_LINE INDENT return mid + 1 ; NEW_LINE DEDENT elif ( temp == 1 ) : NEW_LINE INDENT l = mid + 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT r = mid - 1 ; NEW_LINE DEDENT DEDENT return - 1 ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT mat = [ [ 0 , 0 , 1 , 0 ] , [ 10 , 9 , 22 , 23 ] , [ 40 , 40 , 40 , 40 ] , [ 43 , 44 , 55 , 68 ] , [ 81 , 73 , 100 , 132 ] , [ 100 , 75 , 125 , 133 ] ] ; NEW_LINE row = [ 10 , 9 , 22 , 23 ] ; NEW_LINE print ( binaryCheck ( mat , row ) ) ; NEW_LINE DEDENT +" +E745,"class GFG { static int longestSubArray ( int arr [ ] , int n ) { boolean isZeroPresent = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) { isZeroPresent = true ; break ; } } if ( isZeroPresent ) return n ; return 0 ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 3 , 0 , 1 , 2 , 0 } ; int n = arr . length ; System . out . print ( longestSubArray ( arr , n ) ) ; } } +","def longestSubArray ( arr , n ) : NEW_LINE INDENT isZeroPresent = False NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( arr [ i ] == 0 ) : NEW_LINE INDENT isZeroPresent = True NEW_LINE break NEW_LINE DEDENT DEDENT if ( isZeroPresent ) : NEW_LINE INDENT return n NEW_LINE DEDENT return 0 NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 0 , 1 , 2 , 0 ] NEW_LINE n = len ( arr ) NEW_LINE print ( longestSubArray ( arr , n ) ) NEW_LINE +" +E746,"class GFG { static void PrintMinNumberForPattern ( String arr ) { int curr_max = 0 ; int last_entry = 0 ; int j ; for ( int i = 0 ; i < arr . length ( ) ; i ++ ) { int noOfNextD = 0 ; switch ( arr . charAt ( i ) ) { case ' I ' : j = i + 1 ; while ( j < arr . length ( ) && arr . charAt ( j ) == ' D ' ) { noOfNextD ++ ; j ++ ; } if ( i == 0 ) { curr_max = noOfNextD + 2 ; System . out . print ( "" ▁ "" + ++ last_entry ) ; System . out . print ( "" ▁ "" + curr_max ) ; last_entry = curr_max ; } else { curr_max = curr_max + noOfNextD + 1 ; last_entry = curr_max ; System . out . print ( "" ▁ "" + last_entry ) ; } for ( int k = 0 ; k < noOfNextD ; k ++ ) { System . out . print ( "" ▁ "" + -- last_entry ) ; i ++ ; } break ; case ' D ' : if ( i == 0 ) { j = i + 1 ; while ( j < arr . length ( ) && arr . charAt ( j ) == ' D ' ) { noOfNextD ++ ; j ++ ; } curr_max = noOfNextD + 2 ; System . out . print ( "" ▁ "" + curr_max + "" ▁ "" + ( curr_max - 1 ) ) ; last_entry = curr_max - 1 ; } else { System . out . print ( "" ▁ "" + ( last_entry - 1 ) ) ; last_entry -- ; } break ; } } System . out . println ( ) ; } public static void main ( String [ ] args ) { PrintMinNumberForPattern ( "" IDID "" ) ; PrintMinNumberForPattern ( "" I "" ) ; PrintMinNumberForPattern ( "" DD "" ) ; PrintMinNumberForPattern ( "" II "" ) ; PrintMinNumberForPattern ( "" DIDI "" ) ; PrintMinNumberForPattern ( "" IIDDD "" ) ; PrintMinNumberForPattern ( "" DDIDDIID "" ) ; } } +","def PrintMinNumberForPattern ( arr ) : NEW_LINE INDENT curr_max = 0 NEW_LINE last_entry = 0 NEW_LINE i = 0 NEW_LINE while i < len ( arr ) : NEW_LINE INDENT noOfNextD = 0 NEW_LINE if arr [ i ] == "" I "" : NEW_LINE INDENT j = i + 1 NEW_LINE while j < len ( arr ) and arr [ j ] == "" D "" : NEW_LINE INDENT noOfNextD += 1 NEW_LINE j += 1 NEW_LINE DEDENT if i == 0 : NEW_LINE INDENT curr_max = noOfNextD + 2 NEW_LINE last_entry += 1 NEW_LINE print ( "" "" , last_entry , end = "" "" ) NEW_LINE print ( "" "" , curr_max , end = "" "" ) NEW_LINE last_entry = curr_max NEW_LINE DEDENT else : NEW_LINE INDENT curr_max += noOfNextD + 1 NEW_LINE last_entry = curr_max NEW_LINE print ( "" "" , last_entry , end = "" "" ) NEW_LINE DEDENT for k in range ( noOfNextD ) : NEW_LINE INDENT last_entry -= 1 NEW_LINE print ( "" "" , last_entry , end = "" "" ) NEW_LINE i += 1 NEW_LINE DEDENT DEDENT elif arr [ i ] == "" D "" : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT j = i + 1 NEW_LINE while j < len ( arr ) and arr [ j ] == "" D "" : NEW_LINE INDENT noOfNextD += 1 NEW_LINE j += 1 NEW_LINE DEDENT curr_max = noOfNextD + 2 NEW_LINE print ( "" "" , curr_max , curr_max - 1 , end = "" "" ) NEW_LINE last_entry = curr_max - 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" "" , last_entry - 1 , end = "" "" ) NEW_LINE last_entry -= 1 NEW_LINE DEDENT DEDENT i += 1 NEW_LINE DEDENT print ( ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT PrintMinNumberForPattern ( "" IDID "" ) NEW_LINE PrintMinNumberForPattern ( "" I "" ) NEW_LINE PrintMinNumberForPattern ( "" DD "" ) NEW_LINE PrintMinNumberForPattern ( "" II "" ) NEW_LINE PrintMinNumberForPattern ( "" DIDI "" ) NEW_LINE PrintMinNumberForPattern ( "" IIDDD "" ) NEW_LINE PrintMinNumberForPattern ( "" DDIDDIID "" ) NEW_LINE DEDENT +" +E747,"class GFG { static void findNumbers ( int n ) { int i = 1 ; while ( i <= n ) { System . out . print ( ( 3 * i * ( i - 1 ) + 1 ) + "" ▁ "" ) ; i ++ ; } } public static void main ( String [ ] args ) { int n = 4 ; findNumbers ( n ) ; } } +","def findNumbers ( n ) : NEW_LINE INDENT i = 1 NEW_LINE while ( i <= n ) : NEW_LINE INDENT print ( ( 3 * i * ( i - 1 ) + 1 ) , end = "" ▁ "" ) NEW_LINE i += 1 NEW_LINE DEDENT DEDENT n = 4 NEW_LINE findNumbers ( n ) NEW_LINE +" +E748,"class GFG { static final int MOD = 1000000007 ; static int number_of_ways ( int arr [ ] , int n , int k ) { if ( k == 1 ) return 1 ; int dp [ ] = new int [ k + 1 ] ; int i ; for ( i = 0 ; i < k + 1 ; i ++ ) dp [ i ] = - 1 ; for ( i = 0 ; i < n ; i ++ ) dp [ arr [ i ] ] = 0 ; dp [ 0 ] = 1 ; dp [ 1 ] = ( dp [ 1 ] == - 1 ) ? 1 : dp [ 1 ] ; for ( i = 2 ; i <= k ; ++ i ) { if ( dp [ i ] == 0 ) continue ; dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] ; dp [ i ] %= MOD ; } return dp [ k ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 } ; int n = arr . length ; int k = 6 ; System . out . println ( number_of_ways ( arr , n , k ) ) ; } } +","MOD = 1000000007 ; NEW_LINE def number_of_ways ( arr , n , k ) : NEW_LINE INDENT if ( k == 1 ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT dp = [ - 1 ] * ( k + 1 ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT dp [ arr [ i ] ] = 0 ; NEW_LINE DEDENT dp [ 0 ] = 1 ; NEW_LINE dp [ 1 ] = 1 if ( dp [ 1 ] == - 1 ) else dp [ 1 ] ; NEW_LINE for i in range ( 2 , k + 1 ) : NEW_LINE INDENT if ( dp [ i ] == 0 ) : NEW_LINE INDENT continue ; NEW_LINE DEDENT dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] ; NEW_LINE dp [ i ] %= MOD ; NEW_LINE DEDENT return dp [ k ] ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 3 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE k = 6 ; NEW_LINE print ( number_of_ways ( arr , n , k ) ) ; NEW_LINE DEDENT +" +E749,"import java . io . * ; class GFG { static int maxProfit ( int price [ ] , int n , int k ) { int profit [ ] [ ] = new int [ k + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= k ; i ++ ) profit [ i ] [ 0 ] = 0 ; for ( int j = 0 ; j <= n ; j ++ ) profit [ 0 ] [ j ] = 0 ; for ( int i = 1 ; i <= k ; i ++ ) { int prevDiff = Integer . MIN_VALUE ; for ( int j = 1 ; j < n ; j ++ ) { prevDiff = Math . max ( prevDiff , profit [ i - 1 ] [ j - 1 ] - price [ j - 1 ] ) ; profit [ i ] [ j ] = Math . max ( profit [ i ] [ j - 1 ] , price [ j ] + prevDiff ) ; } } return profit [ k ] [ n - 1 ] ; } public static void main ( String [ ] args ) { int k = 3 ; int price [ ] = { 12 , 14 , 17 , 10 , 14 , 13 , 12 , 15 } ; int n = price . length ; System . out . println ( "" Maximum ▁ profit ▁ is : ▁ "" + maxProfit ( price , n , k ) ) ; } } +","def maxProfit ( price , n , k ) : NEW_LINE INDENT profit = [ [ 0 for i in range ( n + 1 ) ] for j in range ( k + 1 ) ] NEW_LINE for i in range ( 1 , k + 1 ) : NEW_LINE INDENT prevDiff = float ( ' - inf ' ) NEW_LINE for j in range ( 1 , n ) : NEW_LINE INDENT prevDiff = max ( prevDiff , profit [ i - 1 ] [ j - 1 ] - price [ j - 1 ] ) NEW_LINE profit [ i ] [ j ] = max ( profit [ i ] [ j - 1 ] , price [ j ] + prevDiff ) NEW_LINE DEDENT DEDENT return profit [ k ] [ n - 1 ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT k = 3 NEW_LINE price = [ 12 , 14 , 17 , 10 , 14 , 13 , 12 , 15 ] NEW_LINE n = len ( price ) NEW_LINE print ( "" Maximum ▁ profit ▁ is : "" , maxProfit ( price , n , k ) ) NEW_LINE DEDENT +" +E750,"import java . util . Vector ; class GFG { static void originalArray ( int greater [ ] , int n ) { Vector < Integer > temp = new Vector < Integer > ( ) ; for ( int i = 0 ; i <= n ; i ++ ) temp . add ( i ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int k = n - greater [ i ] - i ; arr [ i ] = temp . get ( k ) ; temp . remove ( k ) ; } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int Arr [ ] = { 6 , 3 , 2 , 1 , 0 , 1 , 0 } ; int n = Arr . length ; originalArray ( Arr , n ) ; } } +","def originalArray ( greater , n ) : NEW_LINE INDENT temp = [ ] NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT temp . append ( i ) NEW_LINE DEDENT arr = [ 0 for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT k = n - greater [ i ] - i NEW_LINE arr [ i ] = temp [ k ] NEW_LINE del temp [ k ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 6 , 3 , 2 , 1 , 0 , 1 , 0 ] NEW_LINE n = len ( arr ) NEW_LINE originalArray ( arr , n ) NEW_LINE +" +E751,"import java . util . * ; class GFG { static int MAX = 1000 ; static int f [ ] ; public static int fib ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 || n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] != 0 ) return f [ n ] ; int k = ( n & 1 ) == 1 ? ( n + 1 ) / 2 : n / 2 ; f [ n ] = ( n & 1 ) == 1 ? ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) : ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } public static void main ( String [ ] args ) { int n = 9 ; f = new int [ MAX ] ; System . out . println ( fib ( n ) ) ; } } +","MAX = 1000 NEW_LINE f = [ 0 ] * MAX NEW_LINE def fib ( n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( n == 1 or n == 2 ) : NEW_LINE INDENT f [ n ] = 1 NEW_LINE return ( f [ n ] ) NEW_LINE DEDENT if ( f [ n ] ) : NEW_LINE INDENT return f [ n ] NEW_LINE DEDENT if ( n & 1 ) : NEW_LINE INDENT k = ( n + 1 ) // 2 NEW_LINE DEDENT else : NEW_LINE INDENT k = n // 2 NEW_LINE DEDENT if ( ( n & 1 ) ) : NEW_LINE INDENT f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) NEW_LINE DEDENT return f [ n ] NEW_LINE DEDENT n = 9 NEW_LINE print ( fib ( n ) ) NEW_LINE +" +E752,"import java . util . * ; class GFG { static int getCount ( int l , int r , int p ) { int cnt = 0 ; int val = p ; while ( true ) { int a = r / val ; int b = ( l - 1 ) / val ; val *= p ; if ( ( a - b ) > 0 ) { cnt += ( a - b ) ; } else break ; } return cnt ; } public static void main ( String [ ] args ) { int l = 2 , r = 8 , p = 2 ; System . out . println ( getCount ( l , r , p ) ) ; } } +","def getCount ( l , r , p ) : NEW_LINE INDENT cnt = 0 ; NEW_LINE val = p ; NEW_LINE while ( True ) : NEW_LINE INDENT a = r // val ; NEW_LINE b = ( l - 1 ) // val ; NEW_LINE val *= p ; NEW_LINE if ( a - b ) : NEW_LINE INDENT cnt += ( a - b ) ; NEW_LINE DEDENT else : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT return int ( cnt ) ; NEW_LINE DEDENT l = 2 ; NEW_LINE r = 8 ; NEW_LINE p = 2 ; NEW_LINE print ( getCount ( l , r , p ) ) ; NEW_LINE +" +E753,"import java . util . Stack ; class Test { static int findMaxLen ( String str ) { int n = str . length ( ) ; Stack < Integer > stk = new Stack < > ( ) ; stk . push ( - 1 ) ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) stk . push ( i ) ; else { stk . pop ( ) ; if ( ! stk . empty ( ) ) result = Math . max ( result , i - stk . peek ( ) ) ; else stk . push ( i ) ; } } return result ; } public static void main ( String [ ] args ) { String str = "" ( ( ( ) ( ) "" ; System . out . println ( findMaxLen ( str ) ) ; str = "" ( ) ( ( ) ) ) ) ) "" ; System . out . println ( findMaxLen ( str ) ) ; } } +","def findMaxLen ( string ) : NEW_LINE INDENT n = len ( string ) NEW_LINE stk = [ ] NEW_LINE stk . append ( - 1 ) NEW_LINE result = 0 NEW_LINE for i in xrange ( n ) : NEW_LINE INDENT if string [ i ] == ' ( ' : NEW_LINE INDENT stk . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT stk . pop ( ) NEW_LINE if len ( stk ) != 0 : NEW_LINE INDENT result = max ( result , i - stk [ len ( stk ) - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT stk . append ( i ) NEW_LINE DEDENT DEDENT DEDENT return result NEW_LINE DEDENT string = "" ( ( ( ) ( ) "" NEW_LINE print findMaxLen ( string ) NEW_LINE string = "" ( ) ( ( ) ) ) ) ) "" NEW_LINE print findMaxLen ( string ) NEW_LINE +" +E754,"import java . io . * ; class GFG { static void printbinomial ( int max ) { for ( int m = 0 ; m <= max ; m ++ ) { System . out . print ( m + "" ▁ "" ) ; int binom = 1 ; for ( int x = 0 ; x <= m ; x ++ ) { if ( m != 0 && x != 0 ) binom = binom * ( m - x + 1 ) / x ; System . out . print ( binom + "" ▁ "" ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int max = 10 ; printbinomial ( max ) ; } } +","def printbinomial ( max ) : NEW_LINE INDENT for m in range ( max + 1 ) : NEW_LINE INDENT print ( ' % ▁ 2d ' % m , end = ' ▁ ' ) NEW_LINE binom = 1 NEW_LINE for x in range ( m + 1 ) : NEW_LINE INDENT if m != 0 and x != 0 : NEW_LINE INDENT binom = binom * ( m - x + 1 ) / x NEW_LINE DEDENT print ( ' % ▁ 4d ' % binom , end = ' ▁ ' ) NEW_LINE DEDENT print ( "" \n "" , end = ' ' ) NEW_LINE DEDENT DEDENT max = 10 NEW_LINE printbinomial ( max ) NEW_LINE +" +E755,"import java . util . * ; class GFG { static void getmax ( int arr [ ] , int n , int x ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s = s + arr [ i ] ; } System . out . print ( Math . min ( s , x ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int x = 5 ; int arr_size = arr . length ; getmax ( arr , arr_size , x ) ; } } +","def getmax ( arr , n , x ) : NEW_LINE INDENT s = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT s = s + arr [ i ] NEW_LINE DEDENT print ( min ( s , x ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE x = 5 NEW_LINE arr_size = len ( arr ) NEW_LINE getmax ( arr , arr_size , x ) NEW_LINE DEDENT +" +E756,"class GFG { static boolean isPossible ( int w , int h , int x , int y ) { if ( x * 2 == w && y * 2 == h ) return true ; return false ; } public static void main ( String [ ] args ) { int w = 1 , h = 2 , x = 1 , y = 2 ; if ( isPossible ( w , h , x , y ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def isPossible ( w , h , x , y ) : NEW_LINE INDENT if ( x * 2 == w and y * 2 == h ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT w = 1 NEW_LINE h = 2 NEW_LINE x = 1 NEW_LINE y = 2 NEW_LINE if ( isPossible ( w , h , x , y ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E757,"class GFG { static double dydx ( double x , double y ) { return ( x + y - 2 ) ; } static double rungeKutta ( double x0 , double y0 , double x , double h ) { int n = ( int ) ( ( x - x0 ) / h ) ; double k1 , k2 ; double y = y0 ; for ( int i = 1 ; i <= n ; i ++ ) { k1 = h * dydx ( x0 , y ) ; k2 = h * dydx ( x0 + 0.5 * h , y + 0.5 * k1 ) ; y = y + ( 1.0 / 6.0 ) * ( k1 + 2 * k2 ) ; x0 = x0 + h ; } return y ; } public static void main ( String [ ] args ) { double x0 = 0 , y = 1 , x = 2 , h = 0.2 ; System . out . println ( rungeKutta ( x0 , y , x , h ) ) ; } } +","def dydx ( x , y ) : NEW_LINE INDENT return ( x + y - 2 ) ; NEW_LINE DEDENT def rungeKutta ( x0 , y0 , x , h ) : NEW_LINE INDENT n = round ( ( x - x0 ) / h ) ; NEW_LINE y = y0 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT k1 = h * dydx ( x0 , y ) ; NEW_LINE k2 = h * dydx ( x0 + 0.5 * h , y + 0.5 * k1 ) ; NEW_LINE y = y + ( 1.0 / 6.0 ) * ( k1 + 2 * k2 ) ; NEW_LINE x0 = x0 + h ; NEW_LINE DEDENT return y ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT x0 = 0 ; y = 1 ; NEW_LINE x = 2 ; h = 0.2 ; NEW_LINE print ( "" y ( x ) ▁ = "" , rungeKutta ( x0 , y , x , h ) ) ; NEW_LINE DEDENT +" +E758,"class GFG { final static int MAX_CHAR = 26 ; static int countPalindrome ( String str ) { int n = str . length ( ) ; int sum = 0 ; int hashTable [ ] = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { hashTable [ str . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( hashTable [ i ] != 0 ) { sum += ( hashTable [ i ] * ( hashTable [ i ] + 1 ) / 2 ) ; } } return sum ; } public static void main ( String [ ] args ) { String str = "" ananananddd "" ; System . out . println ( countPalindrome ( str ) ) ; } } +","MAX_CHAR = 26 NEW_LINE def countPalindrome ( str ) : NEW_LINE INDENT n = len ( str ) NEW_LINE sum = 0 NEW_LINE hashTable = [ 0 ] * MAX_CHAR NEW_LINE for i in range ( n ) : NEW_LINE INDENT hashTable [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT for i in range ( 26 ) : NEW_LINE INDENT if ( hashTable [ i ] ) : NEW_LINE INDENT sum += ( hashTable [ i ] * ( hashTable [ i ] + 1 ) // 2 ) NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" ananananddd "" NEW_LINE print ( countPalindrome ( str ) ) NEW_LINE DEDENT +" +E759,"import java . io . * ; class GFG { static int __gcd ( int a , int b ) { if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return __gcd ( a - b , b ) ; return __gcd ( a , b - a ) ; } static int NumberOfSquares ( int x , int y ) { int s = __gcd ( x , y ) ; int ans = ( x * y ) / ( s * s ) ; return ans ; } public static void main ( String [ ] args ) { int m = 385 , n = 60 ; System . out . println ( NumberOfSquares ( m , n ) ) ; } } +","def __gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 or b == 0 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT if ( a == b ) : NEW_LINE INDENT return a ; NEW_LINE DEDENT if ( a > b ) : NEW_LINE INDENT return __gcd ( a - b , b ) ; NEW_LINE DEDENT return __gcd ( a , b - a ) ; NEW_LINE DEDENT def NumberOfSquares ( x , y ) : NEW_LINE INDENT s = __gcd ( x , y ) ; NEW_LINE ans = ( x * y ) / ( s * s ) ; NEW_LINE return int ( ans ) ; NEW_LINE DEDENT m = 385 ; NEW_LINE n = 60 ; NEW_LINE print ( NumberOfSquares ( m , n ) ) ; NEW_LINE +" +E760,"import java . io . * ; import java . util . * ; class GFG { static void divisibilityCheck ( List < Integer > arr , int n ) { List < Integer > s = new ArrayList < Integer > ( ) ; int max_ele = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { s . add ( arr . get ( i ) ) ; max_ele = Math . max ( max_ele , arr . get ( i ) ) ; } LinkedHashSet < Integer > res = new LinkedHashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr . get ( i ) != 0 ) for ( int j = arr . get ( i ) * 2 ; j <= max_ele ; j += arr . get ( i ) ) { if ( s . contains ( j ) ) res . add ( j ) ; } } List < Integer > list = new ArrayList < Integer > ( res ) ; Collections . reverse ( list ) ; for ( Integer temp : list ) System . out . print ( temp + "" ▁ "" ) ; } public static void main ( String args [ ] ) { List < Integer > arr = Arrays . asList ( 2 , 3 , 8 , 6 , 9 , 10 ) ; int n = arr . size ( ) ; divisibilityCheck ( arr , n ) ; } } +","import math as mt NEW_LINE def divisibilityCheck ( arr , n ) : NEW_LINE INDENT s = dict ( ) NEW_LINE max_ele = - 10 ** 9 NEW_LINE for i in range ( n ) : NEW_LINE INDENT s [ arr [ i ] ] = 1 NEW_LINE max_ele = max ( max_ele , arr [ i ] ) NEW_LINE DEDENT res = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] != 0 ) : NEW_LINE INDENT for j in range ( arr [ i ] * 2 , max_ele + 1 , arr [ i ] ) : NEW_LINE INDENT if ( j in s . keys ( ) ) : NEW_LINE INDENT res [ j ] = 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for x in res : NEW_LINE INDENT print ( x , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 2 , 3 , 8 , 6 , 9 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE divisibilityCheck ( arr , n ) NEW_LINE +" +E761,"class RotateArray { void leftRotate ( int arr [ ] , int d , int n ) { d = d % n ; int i , j , k , temp ; int g_c_d = gcd ( d , n ) ; for ( i = 0 ; i < g_c_d ; i ++ ) { temp = arr [ i ] ; j = i ; while ( true ) { k = j + d ; if ( k >= n ) k = k - n ; if ( k == i ) break ; arr [ j ] = arr [ k ] ; j = k ; } arr [ j ] = temp ; } } void printArray ( int arr [ ] , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } int gcd ( int a , int b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { RotateArray rotate = new RotateArray ( ) ; int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; rotate . leftRotate ( arr , 2 , 7 ) ; rotate . printArray ( arr , 7 ) ; } } +","def leftRotate ( arr , d , n ) : NEW_LINE INDENT d = d % n NEW_LINE g_c_d = gcd ( d , n ) NEW_LINE for i in range ( g_c_d ) : NEW_LINE INDENT temp = arr [ i ] NEW_LINE j = i NEW_LINE while 1 : NEW_LINE INDENT k = j + d NEW_LINE if k >= n : NEW_LINE INDENT k = k - n NEW_LINE DEDENT if k == i : NEW_LINE INDENT break NEW_LINE DEDENT arr [ j ] = arr [ k ] NEW_LINE j = k NEW_LINE DEDENT arr [ j ] = temp NEW_LINE DEDENT DEDENT def printArray ( arr , size ) : NEW_LINE INDENT for i in range ( size ) : NEW_LINE INDENT print ( "" % ▁ d "" % arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a ; NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( b , a % b ) NEW_LINE DEDENT DEDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE d = 2 NEW_LINE leftRotate ( arr , d , n ) NEW_LINE printArray ( arr , n ) NEW_LINE +" +E762,"import java . io . * ; class GFG { static boolean isCorrectOrder ( int n ) { boolean flag = true ; int prev = - 1 ; int type = - 1 ; while ( n != 0 ) { if ( type == - 1 ) { if ( prev == - 1 ) { prev = n % 10 ; n = n / 10 ; continue ; } if ( prev == n % 10 ) { flag = false ; break ; } if ( prev > n % 10 ) { type = 1 ; prev = n % 10 ; n = n / 10 ; continue ; } prev = n % 10 ; n = n / 10 ; } else { if ( prev == n % 10 ) { flag = false ; break ; } if ( prev < n % 10 ) { flag = false ; break ; } prev = n % 10 ; n = n / 10 ; } } return flag ; } public static void main ( String [ ] args ) { int n = 123454321 ; if ( isCorrectOrder ( n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","def isCorrectOrder ( n ) : NEW_LINE INDENT flag = True ; NEW_LINE prev = - 1 ; NEW_LINE type = - 1 ; NEW_LINE while ( n != 0 ) : NEW_LINE INDENT if ( type == - 1 ) : NEW_LINE INDENT if ( prev == - 1 ) : NEW_LINE INDENT prev = n % 10 ; NEW_LINE n = int ( n / 10 ) ; NEW_LINE continue ; NEW_LINE DEDENT if ( prev == n % 10 ) : NEW_LINE INDENT flag = False ; NEW_LINE break ; NEW_LINE DEDENT if ( prev > n % 10 ) : NEW_LINE INDENT type = 1 ; NEW_LINE prev = n % 10 ; NEW_LINE n = int ( n / 10 ) ; NEW_LINE continue ; NEW_LINE DEDENT prev = n % 10 ; NEW_LINE n = int ( n / 10 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT if ( prev == n % 10 ) : NEW_LINE INDENT flag = False ; NEW_LINE break ; NEW_LINE DEDENT if ( prev < n % 10 ) : NEW_LINE INDENT flag = False ; NEW_LINE break ; NEW_LINE DEDENT prev = n % 10 ; NEW_LINE n = int ( n / 10 ) ; NEW_LINE DEDENT DEDENT return flag ; NEW_LINE DEDENT n = 123454321 ; NEW_LINE if ( isCorrectOrder ( n ) ) : NEW_LINE INDENT print ( "" YES "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) ; NEW_LINE DEDENT +" +E763,"import java . util . * ; class GFG { static void K_multiple ( int a [ ] , int n , int k ) { Arrays . sort ( a ) ; HashSet < Integer > s = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] % k == 0 && ! s . contains ( a [ i ] / k ) ) || a [ i ] % k != 0 ) s . add ( a [ i ] ) ; } for ( Integer i : s ) System . out . print ( i + "" ▁ "" ) ; } public static void main ( String args [ ] ) { int a [ ] = { 2 , 3 , 4 , 5 , 6 , 10 } ; int k = 2 ; int n = a . length ; K_multiple ( a , n , k ) ; } } +","def K_multiple ( a , n , k ) : NEW_LINE INDENT a . sort ( ) ; NEW_LINE s = set ( ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( ( a [ i ] % k == 0 and a [ i ] // k not in s ) or a [ i ] % k != 0 ) : NEW_LINE INDENT s . add ( a [ i ] ) ; NEW_LINE DEDENT DEDENT for i in s : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 2 , 3 , 4 , 5 , 6 , 10 ] ; NEW_LINE k = 2 ; NEW_LINE n = len ( a ) ; NEW_LINE K_multiple ( a , n , k ) ; NEW_LINE DEDENT +" +E764,"class GFG { static int maxN = 20 ; static int maxM = 10 ; static int [ ] [ ] dp = new int [ maxN ] [ maxM ] ; static boolean [ ] [ ] v = new boolean [ maxN ] [ maxM ] ; static int findCnt ( int [ ] arr , int i , int curr , int n , int m ) { if ( i == n ) { if ( curr == 0 ) return 1 ; else return 0 ; } if ( v [ i ] [ curr ] ) return dp [ i ] [ curr ] ; v [ i ] [ curr ] = true ; return dp [ i ] [ curr ] = findCnt ( arr , i + 1 , curr , n , m ) + findCnt ( arr , i + 1 , ( curr + arr [ i ] ) % m , n , m ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 3 , 3 , 3 } ; int n = arr . length ; int m = 6 ; System . out . println ( findCnt ( arr , 0 , 0 , n , m ) - 1 ) ; } } +","maxN = 20 NEW_LINE maxM = 10 NEW_LINE dp = [ [ 0 for i in range ( maxN ) ] for i in range ( maxM ) ] NEW_LINE v = [ [ 0 for i in range ( maxN ) ] for i in range ( maxM ) ] NEW_LINE def findCnt ( arr , i , curr , n , m ) : NEW_LINE INDENT if ( i == n ) : NEW_LINE INDENT if ( curr == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT if ( v [ i ] [ curr ] ) : NEW_LINE INDENT return dp [ i ] [ curr ] NEW_LINE DEDENT v [ i ] [ curr ] = 1 NEW_LINE dp [ i ] [ curr ] = findCnt ( arr , i + 1 , curr , n , m ) + \ NEW_LINE INDENT findCnt ( arr , i + 1 , ( curr + arr [ i ] ) % m , n , m ) NEW_LINE DEDENT return dp [ i ] [ curr ] NEW_LINE DEDENT arr = [ 3 , 3 , 3 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE m = 6 NEW_LINE print ( findCnt ( arr , 0 , 0 , n , m ) - 1 ) NEW_LINE +" +E765,"import java . util . * ; class GFG { static int minSteps ( String str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) - 2 ; i ++ ) { if ( ( ( int ) str . charAt ( i ) ) == '0' ) { if ( str . charAt ( i + 1 ) == '1' ) { if ( str . charAt ( i + 2 ) == '0' ) { count ++ ; i += 2 ; } } } } return count ; } public static void main ( String args [ ] ) { String str = ""0101010"" ; System . out . println ( minSteps ( str ) ) ; } } +","def minSteps ( str ) : NEW_LINE INDENT count = 0 NEW_LINE i = 0 NEW_LINE while i < len ( str ) - 2 : NEW_LINE INDENT if str [ i ] == '0' : NEW_LINE INDENT if ( str [ i + 1 ] == '1' ) : NEW_LINE INDENT if ( str [ i + 2 ] == '0' ) : NEW_LINE INDENT count = count + 1 NEW_LINE i = i + 2 NEW_LINE DEDENT DEDENT DEDENT i = i + 1 NEW_LINE DEDENT return count NEW_LINE DEDENT str = ""0101010"" NEW_LINE print ( minSteps ( str ) ) NEW_LINE +" +E766,"class GFG { static int checkSemiprime ( int num ) { int cnt = 0 ; for ( int i = 2 ; cnt < 2 && i * i <= num ; ++ i ) while ( num % i == 0 ) { num /= i ; ++ cnt ; } if ( num > 1 ) ++ cnt ; return cnt == 2 ? 1 : 0 ; } static void semiprime ( int n ) { if ( checkSemiprime ( n ) != 0 ) System . out . printf ( "" True \n "" ) ; else System . out . printf ( "" False \n "" ) ; } public static void main ( String [ ] args ) { int n = 6 ; semiprime ( n ) ; n = 8 ; semiprime ( n ) ; } } +","import math NEW_LINE def checkSemiprime ( num ) : NEW_LINE INDENT cnt = 0 NEW_LINE for i in range ( 2 , int ( math . sqrt ( num ) ) + 1 ) : NEW_LINE INDENT while num % i == 0 : NEW_LINE INDENT num /= i NEW_LINE cnt += 1 NEW_LINE DEDENT if cnt >= 2 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( num > 1 ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT return cnt == 2 NEW_LINE DEDENT def semiprime ( n ) : NEW_LINE INDENT if checkSemiprime ( n ) == True : NEW_LINE INDENT print ( "" True "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" False "" ) NEW_LINE DEDENT DEDENT n = 6 NEW_LINE semiprime ( n ) NEW_LINE n = 8 NEW_LINE semiprime ( n ) ; NEW_LINE +" +E767,"import java . util . * ; class solution { static double [ ] XandYandZintercept ( double A , double B , double C , double D ) { double [ ] rslt = new double [ 3 ] ; double x = - D / A ; double y = - D / B ; double z = - D / C ; rslt [ 0 ] = x ; rslt [ 1 ] = y ; rslt [ 2 ] = z ; return rslt ; } static void equation_plane ( int [ ] p , int [ ] q , int [ ] r ) { int x1 = p [ 0 ] ; int y1 = p [ 1 ] ; int z1 = p [ 2 ] ; int x2 = q [ 0 ] ; int y2 = q [ 1 ] ; int z2 = q [ 2 ] ; int x3 = r [ 0 ] ; int y3 = r [ 1 ] ; int z3 = r [ 2 ] ; int a1 = x2 - x1 ; int b1 = y2 - y1 ; int c1 = z2 - z1 ; int a2 = x3 - x1 ; int b2 = y3 - y1 ; int c2 = z3 - z1 ; int A = b1 * c2 - b2 * c1 ; int B = a2 * c1 - a1 * c2 ; int C = a1 * b2 - b1 * a2 ; int D = ( - A * x1 - B * y1 - C * z1 ) ; double [ ] rslt = XandYandZintercept ( A , B , C , D ) ; for ( int i = 0 ; i < 3 ; i ++ ) { System . out . printf ( rslt [ i ] + "" ▁ "" ) ; } } public static void main ( String args [ ] ) { int x1 = - 1 ; int y1 = 2 ; int z1 = 1 ; int x2 = 0 ; int y2 = - 3 ; int z2 = 2 ; int x3 = 1 ; int y3 = 1 ; int z3 = - 4 ; int [ ] p = { x1 , y1 , z1 } ; int [ ] q = { x2 , y2 , z2 } ; int [ ] r = { x3 , y3 , z3 } ; equation_plane ( p , q , r ) ; } } +","def XandYandZintercept ( A , B , C , D ) : NEW_LINE INDENT x = - D / A NEW_LINE y = - D / B NEW_LINE z = - D / C NEW_LINE return [ x , y , z ] NEW_LINE DEDENT def equation_plane ( p , q , r ) : NEW_LINE INDENT x1 = p [ 0 ] NEW_LINE y1 = p [ 1 ] NEW_LINE z1 = p [ 2 ] NEW_LINE x2 = q [ 0 ] NEW_LINE y2 = q [ 1 ] NEW_LINE z2 = q [ 2 ] NEW_LINE x3 = r [ 0 ] NEW_LINE y3 = r [ 1 ] NEW_LINE z3 = r [ 2 ] NEW_LINE a1 = x2 - x1 NEW_LINE b1 = y2 - y1 NEW_LINE c1 = z2 - z1 NEW_LINE a2 = x3 - x1 NEW_LINE b2 = y3 - y1 NEW_LINE c2 = z3 - z1 NEW_LINE A = b1 * c2 - b2 * c1 NEW_LINE B = a2 * c1 - a1 * c2 NEW_LINE C = a1 * b2 - b1 * a2 NEW_LINE D = ( - A * x1 - B * y1 - C * z1 ) NEW_LINE print ( XandYandZintercept ( A , B , C , D ) ) NEW_LINE DEDENT x1 = - 1 NEW_LINE y1 = 2 NEW_LINE z1 = 1 NEW_LINE x2 = 0 NEW_LINE y2 = - 3 NEW_LINE z2 = 2 NEW_LINE x3 = 1 NEW_LINE y3 = 1 NEW_LINE z3 = - 4 NEW_LINE equation_plane ( ( x1 , y1 , z1 ) , ( x2 , y2 , z2 ) , ( x3 , y3 , z3 ) ) NEW_LINE +" +E768,"class GFG { static long mulmod ( long a , long b , long mod ) { long res = 0 ; a = a % mod ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res + a ) % mod ; } a = ( a * 2 ) % mod ; b /= 2 ; } return res % mod ; } public static void main ( String [ ] args ) { long a = 9223372036854775807L , b = 9223372036854775807L ; System . out . println ( mulmod ( a , b , 100000000000L ) ) ; } } +","def mulmod ( a , b , mod ) : NEW_LINE INDENT res = 0 ; NEW_LINE a = a % mod ; NEW_LINE while ( b > 0 ) : NEW_LINE INDENT if ( b % 2 == 1 ) : NEW_LINE INDENT res = ( res + a ) % mod ; NEW_LINE DEDENT a = ( a * 2 ) % mod ; NEW_LINE b //= 2 ; NEW_LINE DEDENT return res % mod ; NEW_LINE DEDENT a = 9223372036854775807 ; NEW_LINE b = 9223372036854775807 ; NEW_LINE print ( mulmod ( a , b , 100000000000 ) ) ; NEW_LINE +" +E769,"public class SortString { static final int MAX_CHAR = 26 ; static void sortString ( String str ) { int letters [ ] = new int [ MAX_CHAR ] ; for ( char x : str . toCharArray ( ) ) { letters [ x - ' a ' ] ++ ; } for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { for ( int j = 0 ; j < letters [ i ] ; j ++ ) { System . out . print ( ( char ) ( i + ' a ' ) ) ; } } } public static void main ( String [ ] args ) { sortString ( "" geeksforgeeks "" ) ; } } +","MAX_CHAR = 26 NEW_LINE def sortString ( str ) : NEW_LINE INDENT charCount = [ 0 for i in range ( MAX_CHAR ) ] NEW_LINE for i in range ( 0 , len ( str ) , 1 ) : NEW_LINE INDENT charCount [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT for i in range ( 0 , MAX_CHAR , 1 ) : NEW_LINE INDENT for j in range ( 0 , charCount [ i ] , 1 ) : NEW_LINE INDENT print ( chr ( ord ( ' a ' ) + i ) , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "" geeksforgeeks "" NEW_LINE sortString ( s ) NEW_LINE DEDENT +" +E770,"import java . io . * ; class GFG { static int pentagon_pyramidal ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int p = ( 3 * i * i - i ) / 2 ; sum = sum + p ; } return sum ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( pentagon_pyramidal ( n ) ) ; } } +","def pentagon_pyramidal ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT p = ( 3 * i * i - i ) / 2 NEW_LINE sum = sum + p NEW_LINE DEDENT return sum NEW_LINE DEDENT n = 4 NEW_LINE print ( int ( pentagon_pyramidal ( n ) ) ) NEW_LINE +" +E771,"import java . util . Arrays ; class GFG { static int count ( int n ) { int table [ ] = new int [ n + 1 ] , i ; Arrays . fill ( table , 0 ) ; table [ 0 ] = 1 ; for ( i = 3 ; i <= n ; i ++ ) table [ i ] += table [ i - 3 ] ; for ( i = 5 ; i <= n ; i ++ ) table [ i ] += table [ i - 5 ] ; for ( i = 10 ; i <= n ; i ++ ) table [ i ] += table [ i - 10 ] ; return table [ n ] ; } public static void main ( String [ ] args ) { int n = 20 ; System . out . println ( "" Count ▁ for ▁ "" + n + "" ▁ is ▁ "" + count ( n ) ) ; n = 13 ; System . out . println ( "" Count ▁ for ▁ "" + n + "" ▁ is ▁ "" + count ( n ) ) ; } } +","def count ( n ) : NEW_LINE INDENT table = [ 0 for i in range ( n + 1 ) ] NEW_LINE table [ 0 ] = 1 NEW_LINE for i in range ( 3 , n + 1 ) : NEW_LINE INDENT table [ i ] += table [ i - 3 ] NEW_LINE DEDENT for i in range ( 5 , n + 1 ) : NEW_LINE INDENT table [ i ] += table [ i - 5 ] NEW_LINE DEDENT for i in range ( 10 , n + 1 ) : NEW_LINE INDENT table [ i ] += table [ i - 10 ] NEW_LINE DEDENT return table [ n ] NEW_LINE DEDENT n = 20 NEW_LINE print ( ' Count ▁ for ' , n , ' is ' , count ( n ) ) NEW_LINE n = 13 NEW_LINE print ( ' Count ▁ for ' , n , ' is ' , count ( n ) ) NEW_LINE +" +E772,"class GFG { final static int MAX = 26 ; static int max_element ( int freq [ ] ) { int max_ele = freq [ 0 ] ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( max_ele < freq [ i ] ) max_ele = freq [ i ] ; } return max_ele ; } static int minimumAddition ( String str , int len ) { int freq [ ] = new int [ MAX ] ; for ( int i = 0 ; i < len ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } int maxFreq = max_element ( freq ) ; int minAddition = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] > 0 ) { minAddition += Math . abs ( maxFreq - freq [ i ] ) ; } } return minAddition ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int len = str . length ( ) ; System . out . println ( minimumAddition ( str , len ) ) ; } } +","MAX = 26 NEW_LINE def minimumAddition ( str1 , Len ) : NEW_LINE INDENT freq = [ 0 for i in range ( MAX ) ] NEW_LINE for i in range ( Len ) : NEW_LINE INDENT freq [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT maxFreq = max ( freq ) NEW_LINE minAddition = 0 NEW_LINE for i in range ( MAX ) : NEW_LINE INDENT if ( freq [ i ] > 0 ) : NEW_LINE INDENT minAddition += abs ( maxFreq - freq [ i ] ) NEW_LINE DEDENT DEDENT return minAddition NEW_LINE DEDENT str1 = "" geeksforgeeks "" NEW_LINE Len = len ( str1 ) NEW_LINE print ( minimumAddition ( str1 , Len ) ) NEW_LINE +" +E773,"import java . util . * ; class GFG { static final int N = 9 ; static void addEgde ( List < Integer > [ ] adj , int u , int v ) { adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } static void DFS ( int node , int parent , int G , int leaf , int val [ ] , List < Integer > [ ] adj ) { if ( node == leaf ) { G = __gcd ( G , val [ node ] ) ; System . out . print ( G ) ; return ; } for ( int it : adj [ node ] ) { if ( it != parent ) DFS ( it , node , __gcd ( G , val [ it ] ) , leaf , val , adj ) ; } } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int n = 8 ; List < Integer > [ ] adj = new LinkedList [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) adj [ i ] = new LinkedList < Integer > ( ) ; addEgde ( adj , 1 , 2 ) ; addEgde ( adj , 2 , 4 ) ; addEgde ( adj , 1 , 3 ) ; addEgde ( adj , 3 , 5 ) ; addEgde ( adj , 3 , 6 ) ; addEgde ( adj , 6 , 7 ) ; addEgde ( adj , 6 , 8 ) ; int leaf = 5 ; int val [ ] = { - 1 , 6 , 2 , 6 , 3 , 4 , 12 , 10 , 18 } ; int G = val [ 1 ] ; DFS ( 1 , - 1 , G , leaf , val , adj ) ; } } +","from math import gcd NEW_LINE N = 9 NEW_LINE def addEgde ( adj , u , v ) : NEW_LINE INDENT adj [ u ] . append ( v ) NEW_LINE adj [ v ] . append ( u ) NEW_LINE DEDENT def DFS ( node , parent , G , leaf , val , adj ) : NEW_LINE INDENT if ( node == leaf ) : NEW_LINE INDENT G = gcd ( G , val [ node ] ) NEW_LINE print ( G , end = "" "" ) NEW_LINE return NEW_LINE DEDENT for it in adj [ node ] : NEW_LINE INDENT if ( it != parent ) : NEW_LINE INDENT DFS ( it , node , gcd ( G , val [ it ] ) , leaf , val , adj ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 8 NEW_LINE adj = [ [ 0 for i in range ( n + 1 ) ] for j in range ( n + 1 ) ] NEW_LINE addEgde ( adj , 1 , 2 ) NEW_LINE addEgde ( adj , 2 , 4 ) NEW_LINE addEgde ( adj , 1 , 3 ) NEW_LINE addEgde ( adj , 3 , 5 ) NEW_LINE addEgde ( adj , 3 , 6 ) NEW_LINE addEgde ( adj , 6 , 7 ) NEW_LINE addEgde ( adj , 6 , 8 ) NEW_LINE leaf = 5 NEW_LINE val = [ - 1 , 6 , 2 , 6 , 3 , 4 , 12 , 10 , 18 ] NEW_LINE G = val [ 1 ] NEW_LINE DFS ( 1 , - 1 , G , leaf , val , adj ) NEW_LINE DEDENT +" +E774,"class GFG { static int countNums ( int l , int r ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { int lastDigit = ( i % 10 ) ; if ( ( lastDigit % 10 ) == 2 || ( lastDigit % 10 ) == 3 || ( lastDigit % 10 ) == 9 ) { cnt ++ ; } } return cnt ; } public static void main ( String [ ] args ) { int l = 11 , r = 33 ; System . out . print ( countNums ( l , r ) ) ; } } +","def countNums ( l , r ) : NEW_LINE INDENT cnt = 0 ; NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT lastDigit = ( i % 10 ) ; NEW_LINE if ( ( lastDigit % 10 ) == 2 or ( lastDigit % 10 ) == 3 or ( lastDigit % 10 ) == 9 ) : NEW_LINE INDENT cnt += 1 ; NEW_LINE DEDENT DEDENT return cnt ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT l = 11 ; r = 33 ; NEW_LINE print ( countNums ( l , r ) ) ; NEW_LINE DEDENT +" +E775,"class gfg { static int countMaxSetBits ( int left , int right ) { int max_count = - 1 , num = 0 ; for ( int i = left ; i <= right ; ++ i ) { int temp = i , cnt = 0 ; while ( temp > 0 ) { if ( temp % 2 == 1 ) ++ cnt ; temp >>= 1 ; } if ( cnt > max_count ) { max_count = cnt ; num = i ; } } return num ; } public static void main ( String [ ] args ) { int l = 1 , r = 5 ; System . out . println ( countMaxSetBits ( l , r ) ) ; l = 1 ; r = 10 ; System . out . print ( countMaxSetBits ( l , r ) ) ; } } +","def countMaxSetBits ( left , right ) : NEW_LINE INDENT max_count = - 1 NEW_LINE for i in range ( left , right + 1 ) : NEW_LINE INDENT temp = i NEW_LINE cnt = 0 NEW_LINE while temp : NEW_LINE INDENT if temp & 1 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT temp = temp >> 1 NEW_LINE DEDENT if cnt > max_count : NEW_LINE INDENT max_count = cnt NEW_LINE num = i NEW_LINE DEDENT DEDENT return num NEW_LINE DEDENT l = 1 NEW_LINE r = 5 NEW_LINE print ( countMaxSetBits ( l , r ) ) NEW_LINE l = 1 NEW_LINE r = 10 NEW_LINE print ( countMaxSetBits ( l , r ) ) NEW_LINE +" +E776,"import java . io . * ; class GFG { static boolean checkPerfectcube ( int n ) { int d = ( int ) Math . cbrt ( n ) ; if ( d * d * d == n ) return true ; return false ; } static int smallestPerfectCube ( int a [ ] , int n ) { int mini = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( checkPerfectcube ( a [ i ] ) ) { mini = Math . min ( a [ i ] , mini ) ; } } return mini ; } public static void main ( String [ ] args ) { int a [ ] = { 16 , 8 , 25 , 2 , 3 , 10 } ; int n = a . length ; System . out . print ( smallestPerfectCube ( a , n ) ) ; } } +","import sys NEW_LINE def checkPerfectcube ( n ) : NEW_LINE INDENT d = int ( n ** ( 1 / 3 ) ) ; NEW_LINE if ( d * d * d == n ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT return False ; NEW_LINE DEDENT def smallestPerfectCube ( a , n ) : NEW_LINE INDENT mini = sys . maxsize ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( checkPerfectcube ( a [ i ] ) ) : NEW_LINE INDENT mini = min ( a [ i ] , mini ) ; NEW_LINE DEDENT DEDENT return mini ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 16 , 8 , 25 , 2 , 3 , 10 ] ; NEW_LINE n = len ( a ) ; NEW_LINE print ( smallestPerfectCube ( a , n ) ) ; NEW_LINE DEDENT +" +E777,"import java . util . * ; class GFG { static int exclude ( int a [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int s = 0 ; int maximum = 0 ; for ( int j = i ; j < Math . min ( n , i + 60 ) ; j ++ ) { s += a [ j ] ; maximum = Math . max ( a [ j ] , maximum ) ; if ( s % 2 == 0 && 2 * maximum > s ) count ++ ; } } return count ; } static int countSubarrays ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) a [ i ] = Integer . bitCount ( a [ i ] ) ; int [ ] pre = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { pre [ i ] = a [ i ] ; if ( i != 0 ) pre [ i ] += pre [ i - 1 ] ; } int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( pre [ i ] % 2 == 1 ) odd ++ ; } even = n - odd ; even ++ ; int answer = ( odd * ( odd - 1 ) / 2 ) + ( even * ( even - 1 ) / 2 ) ; System . out . println ( answer ) ; answer = answer - exclude ( a , n ) ; return answer ; } public static void main ( String [ ] args ) { int a [ ] = { 6 , 7 , 14 } ; int n = a . length ; System . out . println ( countSubarrays ( a , n ) ) ; } } +","def exclude ( a , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT s = 0 NEW_LINE maximum = 0 NEW_LINE for j in range ( i , min ( n , i + 60 ) ) : NEW_LINE INDENT s += a [ j ] NEW_LINE maximum = max ( a [ j ] , maximum ) NEW_LINE if s % 2 == 0 and 2 * maximum > s : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT def countSubarrays ( a , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT a [ i ] = bin ( a [ i ] ) . count ( '1' ) NEW_LINE DEDENT pre = [ None ] * n NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT pre [ i ] = a [ i ] NEW_LINE if i != 0 : NEW_LINE INDENT pre [ i ] += pre [ i - 1 ] NEW_LINE DEDENT DEDENT odd , even = 0 , 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if pre [ i ] & 1 : NEW_LINE INDENT odd += 1 NEW_LINE DEDENT DEDENT even = n - odd NEW_LINE even += 1 NEW_LINE answer = ( ( odd * ( odd - 1 ) // 2 ) + ( even * ( even - 1 ) // 2 ) ) NEW_LINE print ( answer ) NEW_LINE answer = answer - exclude ( a , n ) NEW_LINE return answer NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 6 , 7 , 14 ] NEW_LINE n = len ( a ) NEW_LINE print ( countSubarrays ( a , n ) ) NEW_LINE DEDENT +" +E778,"import java . util . Vector ; class GFG { static void printPermutation ( int N , int K ) { Vector < Integer > res = new Vector < > ( ) ; int l = 1 , r = N , flag = 0 ; for ( int i = 0 ; i < K ; i ++ ) { if ( flag == 0 ) { res . add ( l ) ; l ++ ; } else { res . add ( r ) ; r -- ; } flag ^= 1 ; } if ( flag != 1 ) { for ( int i = r ; i >= l ; i -- ) { res . add ( i ) ; } } else { for ( int i = l ; i <= r ; i ++ ) { res . add ( i ) ; } } for ( Integer i : res ) { System . out . print ( i + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int N = 10 , K = 4 ; printPermutation ( N , K ) ; } } +","def printPermutation ( N , K ) : NEW_LINE INDENT res = list ( ) ; NEW_LINE l , r , flag = 1 , N , 0 NEW_LINE for i in range ( K ) : NEW_LINE INDENT if flag == False : NEW_LINE INDENT res . append ( l ) NEW_LINE l += 1 NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( r ) ; NEW_LINE r -= 1 ; NEW_LINE DEDENT flag = flag ^ 1 ; NEW_LINE DEDENT if flag == False : NEW_LINE INDENT for i in range ( r , 2 , - 1 ) : NEW_LINE INDENT res . append ( i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( l , r ) : NEW_LINE INDENT res . append ( i ) NEW_LINE DEDENT DEDENT for i in res : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT N , K = 10 , 4 NEW_LINE printPermutation ( N , K ) NEW_LINE +" +E779,"class GFG { static int solve ( int A [ ] , int B [ ] , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i ; j < n ; j ++ ) if ( Integer . bitCount ( A [ i ] | A [ j ] ) == B [ j ] ) { cnt ++ ; } return cnt ; } public static void main ( String args [ ] ) { int A [ ] = { 5 , 3 , 2 , 4 , 6 , 1 } ; int B [ ] = { 2 , 2 , 1 , 4 , 2 , 3 } ; int size = A . length ; System . out . println ( solve ( A , B , size ) ) ; } } +","def solve ( A , B , n ) : NEW_LINE INDENT cnt = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i , n ) : NEW_LINE INDENT if ( bin ( A [ i ] | A [ j ] ) . count ( '1' ) == B [ j ] ) : NEW_LINE INDENT cnt += 1 ; NEW_LINE DEDENT DEDENT DEDENT return cnt NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 5 , 3 , 2 , 4 , 6 , 1 ] ; NEW_LINE B = [ 2 , 2 , 1 , 4 , 2 , 3 ] ; NEW_LINE size = len ( A ) ; NEW_LINE print ( solve ( A , B , size ) ) ; NEW_LINE DEDENT +" +E780,"import java . io . * ; class GFG { static double sum ( int n ) { double i , s = 0.0 ; for ( i = 1 ; i <= n ; i ++ ) s = s + 1 / i ; return s ; } public static void main ( String args [ ] ) { int n = 5 ; System . out . printf ( "" Sum ▁ is ▁ % f "" , sum ( n ) ) ; } } +","def sum ( n ) : NEW_LINE INDENT i = 1 NEW_LINE s = 0.0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT s = s + 1 / i ; NEW_LINE DEDENT return s ; NEW_LINE DEDENT n = 5 NEW_LINE print ( "" Sum ▁ is "" , round ( sum ( n ) , 6 ) ) NEW_LINE +" +E781,"import java . io . * ; class GFG { static int M = 3 ; static int N = 2 ; static void getIndex ( int n , int shuffle [ ] [ ] ) { for ( int i = 0 ; i < 3 ; i ++ ) { if ( shuffle [ i ] [ 0 ] == n ) n = shuffle [ i ] [ 1 ] ; else if ( shuffle [ i ] [ 1 ] == n ) n = shuffle [ i ] [ 0 ] ; } System . out . println ( n ) ; } public static void main ( String [ ] args ) { int n = 3 ; int shuffle [ ] [ ] = { { 3 , 1 } , { 2 , 1 } , { 1 , 2 } } ; getIndex ( n , shuffle ) ; } } +","M = 3 ; N = 2 ; NEW_LINE def getIndex ( n , shuffle ) : NEW_LINE INDENT for i in range ( 3 ) : NEW_LINE INDENT if ( shuffle [ i ] [ 0 ] == n ) : NEW_LINE INDENT n = shuffle [ i ] [ 1 ] ; NEW_LINE DEDENT elif ( shuffle [ i ] [ 1 ] == n ) : NEW_LINE INDENT n = shuffle [ i ] [ 0 ] ; NEW_LINE DEDENT DEDENT print ( n ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 3 ; NEW_LINE shuffle = [ [ 3 , 1 ] , [ 2 , 1 ] , [ 1 , 2 ] ] ; NEW_LINE getIndex ( n , shuffle ) ; NEW_LINE DEDENT +" +E782,"import java . util . * ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } static void findArrangement ( int arr [ ] , int n ) { if ( n < 2 ) { System . out . print ( "" - 1"" ) ; return ; } int minVal = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == minVal ) { swap ( arr , i , n - 1 ) ; break ; } } int andVal = arr [ 0 ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { andVal &= arr [ i ] ; } if ( andVal == arr [ n - 1 ] ) printArr ( arr , n ) ; else System . out . print ( "" - 1"" ) ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 3 , 3 } ; int n = arr . length ; findArrangement ( arr , n ) ; } } +","def printArr ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT def findArrangement ( arr , n ) : NEW_LINE INDENT if ( n < 2 ) : NEW_LINE INDENT print ( "" - 1"" , end = "" "" ) ; NEW_LINE return ; NEW_LINE DEDENT minVal = min ( arr ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] == minVal ) : NEW_LINE INDENT arr [ i ] , arr [ n - 1 ] = arr [ n - 1 ] , arr [ i ] ; NEW_LINE break ; NEW_LINE DEDENT DEDENT andVal = arr [ 0 ] ; NEW_LINE for i in range ( 1 , n - 1 ) : NEW_LINE INDENT andVal &= arr [ i ] ; NEW_LINE DEDENT if ( andVal == arr [ n - 1 ] ) : NEW_LINE INDENT printArr ( arr , n ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" - 1"" ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 5 , 3 , 3 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE findArrangement ( arr , n ) ; NEW_LINE DEDENT +" +E783,"import java . util . * ; import java . lang . * ; public class GfG { public static int findOccurrences ( String str1 , String substr1 ) { int counter = 0 ; char [ ] str = str1 . toCharArray ( ) ; char [ ] substr = substr1 . toCharArray ( ) ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( str [ i ] == substr [ 0 ] ) { for ( int j = i + 1 ; j < str1 . length ( ) ; j ++ ) { if ( str [ j ] == substr [ 1 ] ) { for ( int k = j + 1 ; k < str1 . length ( ) ; k ++ ) { if ( str [ k ] == substr [ 2 ] ) counter ++ ; } } } } } return counter ; } public static void main ( String argc [ ] ) { String str = "" GFGFGYSYIOIWIN "" ; String substr = "" GFG "" ; System . out . println ( findOccurrences ( str , substr ) ) ; } } +","def findOccurrences ( str , substr ) : NEW_LINE INDENT counter = 0 NEW_LINE for i in range ( 0 , len ( str ) ) : NEW_LINE INDENT if ( str [ i ] == substr [ 0 ] ) : NEW_LINE INDENT for j in range ( i + 1 , len ( str ) ) : NEW_LINE INDENT if ( str [ j ] == substr [ 1 ] ) : NEW_LINE INDENT for k in range ( j + 1 , len ( str ) ) : NEW_LINE INDENT if ( str [ k ] == substr [ 2 ] ) : NEW_LINE INDENT counter = counter + 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT return counter NEW_LINE DEDENT str = "" GFGFGYSYIOIWIN "" NEW_LINE substr = "" GFG "" NEW_LINE print ( findOccurrences ( str , substr ) ) NEW_LINE +" +E784,"import java . util . * ; class GFG { static String decimalToBinary ( double num , int k_prec ) { String binary = "" "" ; int Integral = ( int ) num ; double fractional = num - Integral ; while ( Integral > 0 ) { int rem = Integral % 2 ; binary += ( ( char ) ( rem + '0' ) ) ; Integral /= 2 ; } binary = reverse ( binary ) ; binary += ( ' . ' ) ; while ( k_prec -- > 0 ) { fractional *= 2 ; int fract_bit = ( int ) fractional ; if ( fract_bit == 1 ) { fractional -= fract_bit ; binary += ( char ) ( 1 + '0' ) ; } else { binary += ( char ) ( 0 + '0' ) ; } } return binary ; } static String reverse ( String input ) { char [ ] temparray = input . toCharArray ( ) ; int left , right = 0 ; right = temparray . length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . valueOf ( temparray ) ; } public static void main ( String [ ] args ) { double n = 4.47 ; int k = 3 ; System . out . println ( decimalToBinary ( n , k ) ) ; n = 6.986 ; k = 5 ; System . out . println ( decimalToBinary ( n , k ) ) ; } } +","def decimalToBinary ( num , k_prec ) : NEW_LINE INDENT binary = "" "" NEW_LINE Integral = int ( num ) NEW_LINE fractional = num - Integral NEW_LINE while ( Integral ) : NEW_LINE INDENT rem = Integral % 2 NEW_LINE binary += str ( rem ) ; NEW_LINE Integral //= 2 NEW_LINE DEDENT binary = binary [ : : - 1 ] NEW_LINE binary += ' . ' NEW_LINE while ( k_prec ) : NEW_LINE INDENT fractional *= 2 NEW_LINE fract_bit = int ( fractional ) NEW_LINE if ( fract_bit == 1 ) : NEW_LINE INDENT fractional -= fract_bit NEW_LINE binary += '1' NEW_LINE DEDENT else : NEW_LINE INDENT binary += '0' NEW_LINE DEDENT k_prec -= 1 NEW_LINE DEDENT return binary NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 4.47 NEW_LINE k = 3 NEW_LINE print ( decimalToBinary ( n , k ) ) NEW_LINE n = 6.986 NEW_LINE k = 5 NEW_LINE print ( decimalToBinary ( n , k ) ) NEW_LINE DEDENT +" +E785,"import java . io . * ; class GFG { static int evenDecimalValue ( String str , int n ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int decimalValue = 0 ; int powerOf2 = 1 ; for ( int k = i ; k <= j ; k ++ ) { decimalValue += ( ( str . charAt ( k ) - '0' ) * powerOf2 ) ; powerOf2 *= 2 ; } if ( decimalValue % 2 == 0 ) result ++ ; } } return result ; } public static void main ( String [ ] args ) { String str = ""10010"" ; int n = 5 ; System . out . println ( evenDecimalValue ( str , n ) ) ; } } +","import math NEW_LINE def evenDecimalValue ( str , n ) : NEW_LINE INDENT result = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( i , n ) : NEW_LINE INDENT decimalValue = 0 ; NEW_LINE powerOf2 = 1 ; NEW_LINE for k in range ( i , j + 1 ) : NEW_LINE INDENT decimalValue += ( ( int ( str [ k ] ) - 0 ) * powerOf2 ) NEW_LINE powerOf2 *= 2 NEW_LINE DEDENT if ( decimalValue % 2 == 0 ) : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT DEDENT return result NEW_LINE DEDENT str = ""10010"" NEW_LINE n = 5 NEW_LINE print ( evenDecimalValue ( str , n ) ) NEW_LINE +" +E786,"import java . io . * ; class GFG { static boolean isSubSeqDivisible ( String str ) { int i , j , k , l = str . length ( ) ; int arr [ ] = new int [ l ] ; for ( i = 0 ; i < l ; i ++ ) arr [ i ] = str . charAt ( i ) - '0' ; for ( i = 0 ; i < l ; i ++ ) { for ( j = i ; j < l ; j ++ ) { for ( k = j ; k < l ; k ++ ) { if ( arr [ i ] % 8 == 0 ) return true ; else if ( ( arr [ i ] * 10 + arr [ j ] ) % 8 == 0 && i != j ) return true ; else if ( ( arr [ i ] * 100 + arr [ j ] * 10 + arr [ k ] ) % 8 == 0 && i != j && j != k && i != k ) return true ; } } } return false ; } public static void main ( String args [ ] ) { String str = ""3144"" ; if ( isSubSeqDivisible ( str ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isSubSeqDivisible ( st ) : NEW_LINE INDENT l = len ( st ) NEW_LINE arr = [ int ( ch ) for ch in st ] NEW_LINE for i in range ( 0 , l ) : NEW_LINE INDENT for j in range ( i , l ) : NEW_LINE INDENT for k in range ( j , l ) : NEW_LINE INDENT if ( arr [ i ] % 8 == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT elif ( ( arr [ i ] * 10 + arr [ j ] ) % 8 == 0 and i != j ) : NEW_LINE INDENT return True NEW_LINE DEDENT elif ( ( arr [ i ] * 100 + arr [ j ] * 10 + arr [ k ] ) % 8 == 0 and i != j and j != k and i != k ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT DEDENT return False NEW_LINE DEDENT st = ""3144"" NEW_LINE if ( isSubSeqDivisible ( st ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E787,"import java . util . * ; class GFG { static void sub_segments ( String str , int n ) { int l = str . length ( ) ; for ( int x = 0 ; x < l ; x += n ) { String newlist = str . substring ( x , x + n ) ; List < Character > arr = new ArrayList < Character > ( ) ; for ( char y : newlist . toCharArray ( ) ) { if ( ! arr . contains ( y ) ) arr . add ( y ) ; } for ( char y : arr ) System . out . print ( y ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { String str = "" geeksforgeeksgfg "" ; int n = 4 ; sub_segments ( str , n ) ; } } +","def sub_segments ( string , n ) : NEW_LINE INDENT l = len ( string ) NEW_LINE for x in range ( 0 , l , n ) : NEW_LINE INDENT newlist = string [ x : x + n ] NEW_LINE arr = [ ] NEW_LINE for y in newlist : NEW_LINE INDENT if y not in arr : NEW_LINE INDENT arr . append ( y ) NEW_LINE DEDENT DEDENT print ( ' ' . join ( arr ) ) NEW_LINE DEDENT DEDENT string = "" geeksforgeeksgfg "" NEW_LINE n = 4 NEW_LINE sub_segments ( string , n ) NEW_LINE +" +E788,"import java . util . * ; class GFG { static int remAnagram ( String str1 , String str2 ) { int count1 [ ] = new int [ 26 ] ; int count2 [ ] = new int [ 26 ] ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) count1 [ str1 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < str2 . length ( ) ; i ++ ) count2 [ str2 . charAt ( i ) - ' a ' ] ++ ; int result = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) result += Math . abs ( count1 [ i ] - count2 [ i ] ) ; return result ; } public static void main ( String [ ] args ) { String str1 = "" bcadeh "" , str2 = "" hea "" ; System . out . println ( remAnagram ( str1 , str2 ) ) ; } } +","CHARS = 26 NEW_LINE def remAnagram ( str1 , str2 ) : NEW_LINE INDENT count1 = [ 0 ] * CHARS NEW_LINE count2 = [ 0 ] * CHARS NEW_LINE i = 0 NEW_LINE while i < len ( str1 ) : NEW_LINE INDENT count1 [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE i += 1 NEW_LINE DEDENT i = 0 NEW_LINE while i < len ( str2 ) : NEW_LINE INDENT count2 [ ord ( str2 [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE i += 1 NEW_LINE DEDENT result = 0 NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT result += abs ( count1 [ i ] - count2 [ i ] ) NEW_LINE DEDENT return result NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = "" bcadeh "" NEW_LINE str2 = "" hea "" NEW_LINE print ( remAnagram ( str1 , str2 ) ) NEW_LINE DEDENT +" +E789,"import java . util . * ; class GFG { static int minOperations ( String s , String t , int n ) { int ct0 = 0 , ct1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) continue ; if ( s . charAt ( i ) == '0' ) ct0 ++ ; else ct1 ++ ; } return Math . max ( ct0 , ct1 ) ; } public static void main ( String args [ ] ) { String s = ""010"" , t = ""101"" ; int n = s . length ( ) ; System . out . println ( minOperations ( s , t , n ) ) ; } } +","def minOperations ( s , t , n ) : NEW_LINE INDENT ct0 = 0 NEW_LINE ct1 = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( s [ i ] == t [ i ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( s [ i ] == '0' ) : NEW_LINE INDENT ct0 += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ct1 += 1 NEW_LINE DEDENT DEDENT return max ( ct0 , ct1 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = ""010"" NEW_LINE t = ""101"" NEW_LINE n = len ( s ) NEW_LINE print ( minOperations ( s , t , n ) ) NEW_LINE DEDENT +" +E790,"import java . util . * ; import java . lang . * ; public class GfG { public static int toggleLastMBits ( int n , int m ) { int num = ( 1 << m ) - 1 ; return ( n ^ num ) ; } public static void main ( String argc [ ] ) { int n = 107 ; int m = 4 ; n = toggleLastMBits ( n , m ) ; System . out . println ( n ) ; } } +","def toggleLastMBits ( n , m ) : NEW_LINE INDENT num = ( 1 << m ) - 1 NEW_LINE return ( n ^ num ) NEW_LINE DEDENT n = 107 NEW_LINE m = 4 NEW_LINE print ( toggleLastMBits ( n , m ) ) NEW_LINE +" +E791,"import java . util . * ; class GFG { static void printmaxSubseq ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( i + 1 < n && arr [ i ] < arr [ i + 1 ] ) System . out . print ( arr [ i ] + "" ▁ "" ) ; else System . out . print ( arr [ i ] + "" \n "" ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 8 , 11 , 13 , 10 , 15 , 14 , 16 , 20 , 5 } ; int n = arr . length ; printmaxSubseq ( arr , n ) ; } } +","def printmaxSubseq ( arr , n ) : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT if ( arr [ i ] < arr [ i + 1 ] ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( arr [ i ] ) ; NEW_LINE DEDENT DEDENT print ( arr [ n - 1 ] ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 9 , 8 , 11 , 13 , 10 , 15 , 14 , 16 , 20 , 5 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE printmaxSubseq ( arr , n ) ; NEW_LINE DEDENT +" +E792,"class Test { static void printFibonacciNumbers ( int n ) { int f1 = 0 , f2 = 1 , i ; if ( n < 1 ) return ; for ( i = 1 ; i <= n ; i ++ ) { System . out . print ( f2 + "" ▁ "" ) ; int next = f1 + f2 ; f1 = f2 ; f2 = next ; } } public static void main ( String [ ] args ) { printFibonacciNumbers ( 7 ) ; } } +","def printFibonacciNumbers ( n ) : NEW_LINE INDENT f1 = 0 NEW_LINE f2 = 1 NEW_LINE if ( n < 1 ) : NEW_LINE INDENT return NEW_LINE DEDENT for x in range ( 0 , n ) : NEW_LINE INDENT print ( f2 , end = "" ▁ "" ) NEW_LINE next = f1 + f2 NEW_LINE f1 = f2 NEW_LINE f2 = next NEW_LINE DEDENT DEDENT printFibonacciNumbers ( 7 ) NEW_LINE +" +E793,"class GFG { static double cal_speed ( double dist , double time ) { System . out . print ( "" \n ▁ Distance ( km ) ▁ : ▁ "" + dist ) ; System . out . print ( "" \n ▁ Time ( hr ) ▁ : ▁ "" + time ) ; return dist / time ; } static double cal_dis ( double speed , double time ) { System . out . print ( "" \n ▁ Time ( hr ) ▁ : ▁ "" + time ) ; System . out . print ( "" \n ▁ Speed ( km ▁ / ▁ hr ) ▁ : ▁ "" + speed ) ; return speed * time ; } static double cal_time ( double dist , double speed ) { System . out . print ( "" \n ▁ Distance ( km ) ▁ : ▁ "" + dist ) ; System . out . print ( "" \n ▁ Speed ( km ▁ / ▁ hr ) ▁ : ▁ "" + speed ) ; return speed * dist ; } public static void main ( String [ ] args ) { System . out . println ( "" \n ▁ The ▁ calculated ▁ Speed ( km ▁ / ▁ hr ) ▁ is ▁ : ▁ "" + cal_speed ( 45.9 , 2.0 ) ) ; System . out . println ( "" \n ▁ The ▁ calculated ▁ Distance ( km ) ▁ : ▁ "" + cal_dis ( 62.9 , 2.5 ) ) ; System . out . println ( "" \n ▁ The ▁ calculated ▁ Time ( hr ) ▁ : ▁ "" + cal_time ( 48.0 , 4.5 ) ) ; } } +","def cal_speed ( dist , time ) : NEW_LINE INDENT print ( "" ▁ Distance ( km ) ▁ : "" , dist ) ; NEW_LINE print ( "" ▁ Time ( hr ) ▁ : "" , time ) ; NEW_LINE return dist / time ; NEW_LINE DEDENT def cal_dis ( speed , time ) : NEW_LINE INDENT print ( "" ▁ Time ( hr ) ▁ : "" , time ) ; NEW_LINE print ( "" ▁ Speed ( km ▁ / ▁ hr ) ▁ : "" , speed ) ; NEW_LINE return speed * time ; NEW_LINE DEDENT def cal_time ( dist , speed ) : NEW_LINE INDENT print ( "" ▁ Distance ( km ) ▁ : "" , dist ) ; NEW_LINE print ( "" ▁ Speed ( km ▁ / ▁ hr ) ▁ : "" , speed ) ; NEW_LINE return speed * dist ; NEW_LINE DEDENT print ( "" ▁ The ▁ calculated ▁ Speed ( km ▁ / ▁ hr ) ▁ is ▁ : "" , cal_speed ( 45.9 , 2.0 ) ) ; NEW_LINE print ( "" "" ) ; NEW_LINE print ( "" ▁ The ▁ calculated ▁ Distance ( km ) ▁ : "" , cal_dis ( 62.9 , 2.5 ) ) ; NEW_LINE print ( "" "" ) ; NEW_LINE print ( "" ▁ The ▁ calculated ▁ Time ( hr ) ▁ : "" , cal_time ( 48.0 , 4.5 ) ) ; NEW_LINE +" +E794,"class GFG { static void FermatFactors ( int n ) { if ( n <= 0 ) { System . out . print ( "" [ "" + n + "" ] "" ) ; return ; } if ( ( n & 1 ) == 0 ) { System . out . print ( "" [ "" + n / 2.0 + "" , "" + 2 + "" ] "" ) ; return ; } int a = ( int ) Math . ceil ( Math . sqrt ( n ) ) ; if ( a * a == n ) { System . out . print ( "" [ "" + a + "" , "" + a + "" ] "" ) ; return ; } int b ; while ( true ) { int b1 = a * a - n ; b = ( int ) ( Math . sqrt ( b1 ) ) ; if ( b * b == b1 ) break ; else a += 1 ; } System . out . print ( "" [ "" + ( a - b ) + "" , "" + ( a + b ) + "" ] "" ) ; return ; } public static void main ( String [ ] args ) { FermatFactors ( 6557 ) ; } } +","from math import ceil , sqrt NEW_LINE def FermatFactors ( n ) : NEW_LINE INDENT if ( n <= 0 ) : NEW_LINE INDENT return [ n ] NEW_LINE DEDENT if ( n & 1 ) == 0 : NEW_LINE INDENT return [ n / 2 , 2 ] NEW_LINE DEDENT a = ceil ( sqrt ( n ) ) NEW_LINE if ( a * a == n ) : NEW_LINE INDENT return [ a , a ] NEW_LINE DEDENT while ( True ) : NEW_LINE INDENT b1 = a * a - n NEW_LINE b = int ( sqrt ( b1 ) ) NEW_LINE if ( b * b == b1 ) : NEW_LINE INDENT break NEW_LINE DEDENT else : NEW_LINE INDENT a += 1 NEW_LINE DEDENT DEDENT return [ a - b , a + b ] NEW_LINE DEDENT print ( FermatFactors ( 6557 ) ) NEW_LINE +" +E795,"class GFG { static void perfectCube ( int N ) { int cube ; for ( int i = 0 ; i <= N ; i ++ ) { cube = i * i * i ; if ( cube == N ) { System . out . println ( "" Yes "" ) ; return ; } else if ( cube > N ) { System . out . println ( "" NO "" ) ; return ; } } } public static void main ( String [ ] args ) { int N = 216 ; perfectCube ( N ) ; } } +","def perfectCube ( N ) : NEW_LINE INDENT cube = 0 ; NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT cube = i * i * i ; NEW_LINE if ( cube == N ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE return ; NEW_LINE DEDENT elif ( cube > N ) : NEW_LINE INDENT print ( "" NO "" ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 216 ; NEW_LINE perfectCube ( N ) ; NEW_LINE DEDENT +" +E796,"import java . util . * ; class GFG { static String removeDuplicate ( char str [ ] , int n ) { int index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < i ; j ++ ) { if ( str [ i ] == str [ j ] ) { break ; } } if ( j == i ) { str [ index ++ ] = str [ i ] ; } } return String . valueOf ( Arrays . copyOf ( str , index ) ) ; } public static void main ( String [ ] args ) { char str [ ] = "" geeksforgeeks "" . toCharArray ( ) ; int n = str . length ; System . out . println ( removeDuplicate ( str , n ) ) ; } } +","def removeDuplicate ( str , n ) : NEW_LINE INDENT index = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 0 , i + 1 ) : NEW_LINE INDENT if ( str [ i ] == str [ j ] ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( j == i ) : NEW_LINE INDENT str [ index ] = str [ i ] NEW_LINE index += 1 NEW_LINE DEDENT DEDENT return "" "" . join ( str [ : index ] ) NEW_LINE DEDENT str = "" geeksforgeeks "" NEW_LINE n = len ( str ) NEW_LINE print ( removeDuplicate ( list ( str ) , n ) ) NEW_LINE +" +E797,"import java . util . * ; import java . lang . * ; import java . io . * ; class LexoSmallest { static boolean compareSeq ( char [ ] S , int x , int y , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( S [ x ] < S [ y ] ) return false ; else if ( S [ x ] > S [ y ] ) return true ; x = ( x + 1 ) % n ; y = ( y + 1 ) % n ; } return true ; } static int smallestSequence ( char [ ] S , int n ) { int index = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( compareSeq ( S , index , i , n ) ) index = i ; return index ; } static void printSmallestSequence ( String str , int n ) { char [ ] S = str . toCharArray ( ) ; int starting_index = smallestSequence ( S , n ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( S [ ( starting_index + i ) % n ] ) ; } public static void main ( String [ ] args ) { String S = "" DCACBCAA "" ; int n = 8 ; printSmallestSequence ( S , n ) ; } } +","import copy NEW_LINE def printSmallestSequence ( s ) : NEW_LINE INDENT m = copy . copy ( s ) NEW_LINE for i in range ( len ( s ) - 1 ) : NEW_LINE INDENT if m > s [ i : ] + s [ : i ] : NEW_LINE INDENT m = s [ i : ] + s [ : i ] NEW_LINE DEDENT DEDENT return m NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT st = ' DCACBCAA ' NEW_LINE print ( printSmallestSequence ( st ) ) NEW_LINE DEDENT +" +E798,"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void partSort ( int [ ] arr , int N , int a , int b ) { int l = Math . min ( a , b ) ; int r = Math . max ( a , b ) ; int [ ] temp = new int [ r - l + 1 ] ; int j = 0 ; for ( int i = l ; i <= r ; i ++ ) { temp [ j ] = arr [ i ] ; j ++ ; } Arrays . sort ( temp ) ; j = 0 ; for ( int i = l ; i <= r ; i ++ ) { arr [ i ] = temp [ j ] ; j ++ ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } public static void main ( String args [ ] ) { int [ ] arr = { 7 , 8 , 4 , 5 , 2 } ; int a = 1 , b = 4 ; int N = arr . length ; partSort ( arr , N , a , b ) ; } } +","def partSort ( arr , N , a , b ) : NEW_LINE INDENT l = min ( a , b ) NEW_LINE r = max ( a , b ) NEW_LINE temp = [ 0 for i in range ( r - l + 1 ) ] NEW_LINE j = 0 NEW_LINE for i in range ( l , r + 1 , 1 ) : NEW_LINE INDENT temp [ j ] = arr [ i ] NEW_LINE j += 1 NEW_LINE DEDENT temp . sort ( reverse = False ) NEW_LINE j = 0 NEW_LINE for i in range ( l , r + 1 , 1 ) : NEW_LINE INDENT arr [ i ] = temp [ j ] NEW_LINE j += 1 NEW_LINE DEDENT for i in range ( 0 , N , 1 ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 7 , 8 , 4 , 5 , 2 ] NEW_LINE a = 1 NEW_LINE b = 4 NEW_LINE N = len ( arr ) NEW_LINE partSort ( arr , N , a , b ) NEW_LINE DEDENT +" +E799,"class Test { static boolean checkYear ( int year ) { if ( year % 400 == 0 ) return true ; if ( year % 100 == 0 ) return false ; if ( year % 4 == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { int year = 2000 ; System . out . println ( checkYear ( 2000 ) ? "" Leap ▁ Year "" : "" Not ▁ a ▁ Leap ▁ Year "" ) ; } } +","def checkYear ( year ) : NEW_LINE INDENT if ( year % 4 ) == 0 : NEW_LINE INDENT if ( year % 100 ) == 0 : NEW_LINE INDENT if ( year % 400 ) == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT year = 2000 NEW_LINE if ( checkYear ( year ) ) : NEW_LINE INDENT print ( "" Leap ▁ Year "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Not ▁ a ▁ Leap ▁ Year "" ) NEW_LINE DEDENT +" +E800,"class GFG { static int countPairs ( int arr [ ] , int n ) { int count = 0 ; int right = 0 , left = 0 ; boolean visited [ ] = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) visited [ i ] = false ; while ( right < n ) { while ( right < n && ! visited [ arr [ right ] ] ) { count += ( right - left ) ; visited [ arr [ right ] ] = true ; right ++ ; } while ( left < right && ( right != n && visited [ arr [ right ] ] ) ) { visited [ arr [ left ] ] = false ; left ++ ; } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 4 , 2 , 4 , 3 , 2 } ; int n = arr . length ; System . out . println ( countPairs ( arr , n ) ) ; } } +","def countPairs ( arr , n ) : NEW_LINE INDENT count = 0 NEW_LINE right = 0 NEW_LINE left = 0 NEW_LINE visited = [ False for i in range ( n ) ] NEW_LINE while ( right < n ) : NEW_LINE INDENT while ( right < n and visited [ arr [ right ] ] == False ) : NEW_LINE INDENT count += ( right - left ) NEW_LINE visited [ arr [ right ] ] = True NEW_LINE right += 1 NEW_LINE DEDENT while ( left < right and ( right != n and visited [ arr [ right ] ] == True ) ) : NEW_LINE INDENT visited [ arr [ left ] ] = False NEW_LINE left += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 4 , 2 , 4 , 3 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countPairs ( arr , n ) ) NEW_LINE DEDENT +" +E801,"class BinarySearch { int binarySearch ( int arr [ ] , int x ) { int l = 0 , r = arr . length - 1 ; while ( l <= r ) { int m = l + ( r - l ) / 2 ; if ( arr [ m ] == x ) return m ; if ( arr [ m ] < x ) l = m + 1 ; else r = m - 1 ; } return - 1 ; } public static void main ( String args [ ] ) { BinarySearch ob = new BinarySearch ( ) ; int arr [ ] = { 2 , 3 , 4 , 10 , 40 } ; int n = arr . length ; int x = 10 ; int result = ob . binarySearch ( arr , x ) ; if ( result == - 1 ) System . out . println ( "" Element ▁ not ▁ present "" ) ; else System . out . println ( "" Element ▁ found ▁ at ▁ "" + "" index ▁ "" + result ) ; } } +","def binarySearch ( arr , l , r , x ) : NEW_LINE INDENT while l <= r : NEW_LINE INDENT mid = l + ( r - l ) // 2 ; NEW_LINE if arr [ mid ] == x : NEW_LINE INDENT return mid NEW_LINE DEDENT elif arr [ mid ] < x : NEW_LINE INDENT l = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT r = mid - 1 NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT arr = [ 2 , 3 , 4 , 10 , 40 ] NEW_LINE x = 10 NEW_LINE result = binarySearch ( arr , 0 , len ( arr ) - 1 , x ) NEW_LINE if result != - 1 : NEW_LINE INDENT print ( "" Element ▁ is ▁ present ▁ at ▁ index ▁ % ▁ d "" % result ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Element ▁ is ▁ not ▁ present ▁ in ▁ array "" ) NEW_LINE DEDENT +" +E802,"import java . io . * ; class Composite { static boolean isComposite ( int n ) { if ( n <= 1 ) System . out . println ( "" False "" ) ; if ( n <= 3 ) System . out . println ( "" False "" ) ; if ( n % 2 == 0 || n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } public static void main ( String args [ ] ) { System . out . println ( isComposite ( 11 ) ? "" true "" : "" false "" ) ; System . out . println ( isComposite ( 15 ) ? "" true "" : "" false "" ) ; } } +","def isComposite ( n ) : NEW_LINE INDENT if ( n <= 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( n <= 3 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( n % 2 == 0 or n % 3 == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT i = 5 NEW_LINE while ( i * i <= n ) : NEW_LINE INDENT if ( n % i == 0 or n % ( i + 2 ) == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT i = i + 6 NEW_LINE DEDENT return False NEW_LINE DEDENT print ( "" true "" ) if ( isComposite ( 11 ) ) else print ( "" false "" ) NEW_LINE print ( "" true "" ) if ( isComposite ( 15 ) ) else print ( "" false "" ) NEW_LINE +" +E803,"import java . io . * ; class GFG { static void decToBinary ( int n ) { int [ ] binaryNum = new int [ 32 ] ; int i = 0 ; while ( n > 0 ) { binaryNum [ i ] = n % 2 ; n = n / 2 ; i ++ ; } for ( int j = i - 1 ; j >= 0 ; j -- ) System . out . print ( binaryNum [ j ] ) ; } public static void main ( String [ ] args ) { int n = 17 ; decToBinary ( n ) ; } } +","def decToBinary ( n ) : NEW_LINE INDENT binaryNum = [ 0 ] * n ; NEW_LINE i = 0 ; NEW_LINE while ( n > 0 ) : NEW_LINE INDENT binaryNum [ i ] = n % 2 ; NEW_LINE n = int ( n / 2 ) ; NEW_LINE i += 1 ; NEW_LINE DEDENT for j in range ( i - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( binaryNum [ j ] , end = "" "" ) ; NEW_LINE DEDENT DEDENT n = 17 ; NEW_LINE decToBinary ( n ) ; NEW_LINE +" +E804,"import java . util . * ; class GFG { static int calculateSum ( int n ) { return ( n * ( ( int ) Math . pow ( n , 2 ) + 3 * n + 5 ) ) / 3 ; } public static void main ( String arr [ ] ) { int n = 25 ; System . out . println ( calculateSum ( n ) ) ; } } +","def findSum ( n ) : NEW_LINE INDENT return ( n * ( pow ( n , 2 ) + 3 * n + 5 ) ) / 3 NEW_LINE DEDENT n = 25 NEW_LINE print ( int ( findSum ( n ) ) ) NEW_LINE +" +E805,"public class GfG { static boolean isPerfectSquare ( int n ) { for ( int i = 1 ; i * i <= n ; i ++ ) { if ( ( n % i == 0 ) && ( n / i == i ) ) { return true ; } } return false ; } public static void main ( String [ ] args ) { int n = 36 ; if ( isPerfectSquare ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isPerfectSquare ( n ) : NEW_LINE INDENT i = 1 NEW_LINE while ( i * i <= n ) : NEW_LINE INDENT if ( ( n % i == 0 ) and ( n / i == i ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT i = i + 1 NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 36 NEW_LINE if ( isPerfectSquare ( n ) ) : NEW_LINE INDENT print ( "" Yes , ▁ it ▁ is ▁ a ▁ perfect ▁ square . "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No , ▁ it ▁ is ▁ not ▁ a ▁ perfect ▁ square . "" ) NEW_LINE DEDENT DEDENT +" +E806,"class GFG { static int N = 101 ; static int mod = ( int ) 1e9 + 7 ; static int exactsum [ ] [ ] [ ] = new int [ N ] [ N ] [ N ] ; static int exactnum [ ] [ ] [ ] = new int [ N ] [ N ] [ N ] ; static int getSum ( int x , int y , int z ) { int ans = 0 ; exactnum [ 0 ] [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i <= x ; ++ i ) { for ( int j = 0 ; j <= y ; ++ j ) { for ( int k = 0 ; k <= z ; ++ k ) { if ( i > 0 ) { exactsum [ i ] [ j ] [ k ] += ( exactsum [ i - 1 ] [ j ] [ k ] * 10 + 4 * exactnum [ i - 1 ] [ j ] [ k ] ) % mod ; exactnum [ i ] [ j ] [ k ] += exactnum [ i - 1 ] [ j ] [ k ] % mod ; } if ( j > 0 ) { exactsum [ i ] [ j ] [ k ] += ( exactsum [ i ] [ j - 1 ] [ k ] * 10 + 5 * exactnum [ i ] [ j - 1 ] [ k ] ) % mod ; exactnum [ i ] [ j ] [ k ] += exactnum [ i ] [ j - 1 ] [ k ] % mod ; } if ( k > 0 ) { exactsum [ i ] [ j ] [ k ] += ( exactsum [ i ] [ j ] [ k - 1 ] * 10 + 6 * exactnum [ i ] [ j ] [ k - 1 ] ) % mod ; exactnum [ i ] [ j ] [ k ] += exactnum [ i ] [ j ] [ k - 1 ] % mod ; } ans += exactsum [ i ] [ j ] [ k ] % mod ; ans %= mod ; } } } return ans ; } public static void main ( String [ ] args ) { int x = 1 , y = 1 , z = 1 ; System . out . println ( getSum ( x , y , z ) % mod ) ; } } +","import numpy as np NEW_LINE N = 101 ; NEW_LINE mod = int ( 1e9 ) + 7 ; NEW_LINE exactsum = np . zeros ( ( N , N , N ) ) ; NEW_LINE exactnum = np . zeros ( ( N , N , N ) ) ; NEW_LINE def getSum ( x , y , z ) : NEW_LINE INDENT ans = 0 ; NEW_LINE exactnum [ 0 ] [ 0 ] [ 0 ] = 1 ; NEW_LINE for i in range ( x + 1 ) : NEW_LINE INDENT for j in range ( y + 1 ) : NEW_LINE INDENT for k in range ( z + 1 ) : NEW_LINE INDENT if ( i > 0 ) : NEW_LINE INDENT exactsum [ i ] [ j ] [ k ] += ( exactsum [ i - 1 ] [ j ] [ k ] * 10 + 4 * exactnum [ i - 1 ] [ j ] [ k ] ) % mod ; NEW_LINE exactnum [ i ] [ j ] [ k ] += exactnum [ i - 1 ] [ j ] [ k ] % mod ; NEW_LINE DEDENT if ( j > 0 ) : NEW_LINE INDENT exactsum [ i ] [ j ] [ k ] += ( exactsum [ i ] [ j - 1 ] [ k ] * 10 + 5 * exactnum [ i ] [ j - 1 ] [ k ] ) % mod ; NEW_LINE exactnum [ i ] [ j ] [ k ] += exactnum [ i ] [ j - 1 ] [ k ] % mod ; NEW_LINE DEDENT if ( k > 0 ) : NEW_LINE INDENT exactsum [ i ] [ j ] [ k ] += ( exactsum [ i ] [ j ] [ k - 1 ] * 10 + 6 * exactnum [ i ] [ j ] [ k - 1 ] ) % mod ; NEW_LINE exactnum [ i ] [ j ] [ k ] += exactnum [ i ] [ j ] [ k - 1 ] % mod ; NEW_LINE DEDENT ans += exactsum [ i ] [ j ] [ k ] % mod ; NEW_LINE ans %= mod ; NEW_LINE DEDENT DEDENT DEDENT return ans ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT x = 1 ; y = 1 ; z = 1 ; NEW_LINE print ( ( getSum ( x , y , z ) % mod ) ) ; NEW_LINE DEDENT +" +E807,"import java . util . * ; class Sol { static int countPairs ( String s ) { Set < Character > st = new HashSet < Character > ( ) ; st . add ( ' a ' ) ; st . add ( ' e ' ) ; st . add ( ' i ' ) ; st . add ( ' o ' ) ; st . add ( ' u ' ) ; int count = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( st . contains ( s . charAt ( i ) ) && ! st . contains ( s . charAt ( i + 1 ) ) ) count ++ ; } return count ; } public static void main ( String args [ ] ) { String s = "" geeksforgeeks "" ; System . out . println ( countPairs ( s ) ) ; } } +","def countPairs ( s ) : NEW_LINE INDENT st = set ( ) ; NEW_LINE st . add ( ' a ' ) ; NEW_LINE st . add ( ' e ' ) ; NEW_LINE st . add ( ' i ' ) ; NEW_LINE st . add ( ' o ' ) ; NEW_LINE st . add ( ' u ' ) ; NEW_LINE count = 0 ; NEW_LINE n = len ( s ) ; NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( s [ i ] not in st and s [ i + 1 ] in st ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT return count ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" geeksforgeeks "" ; NEW_LINE print ( countPairs ( s ) ) ; NEW_LINE DEDENT +" +E808,"class GFG { static int MOD = ( int ) ( 1e9 + 7 ) ; static int modulo_13 ( String s , int n ) { long [ ] [ ] dp = new long [ n + 1 ] [ 13 ] ; dp [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { int nxt = s . charAt ( i ) - '0' ; if ( s . charAt ( i ) == ' ? ' ) nxt = j ; for ( int k = 0 ; k < 13 ; k ++ ) { int rem = ( 10 * k + nxt ) % 13 ; dp [ i + 1 ] [ rem ] += dp [ i ] [ k ] ; dp [ i + 1 ] [ rem ] %= MOD ; } if ( s . charAt ( i ) != ' ? ' ) break ; } } return ( int ) dp [ n ] [ 5 ] ; } public static void main ( String [ ] args ) { String s = "" ? 44"" ; int n = s . length ( ) ; System . out . println ( modulo_13 ( s , n ) ) ; } } +","import numpy as np NEW_LINE MOD = ( int ) ( 1e9 + 7 ) NEW_LINE def modulo_13 ( s , n ) : NEW_LINE INDENT dp = np . zeros ( ( n + 1 , 13 ) ) ; NEW_LINE dp [ 0 ] [ 0 ] = 1 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( 10 ) : NEW_LINE INDENT nxt = ord ( s [ i ] ) - ord ( '0' ) ; NEW_LINE if ( s [ i ] == ' ? ' ) : NEW_LINE INDENT nxt = j ; NEW_LINE DEDENT for k in range ( 13 ) : NEW_LINE INDENT rem = ( 10 * k + nxt ) % 13 ; NEW_LINE dp [ i + 1 ] [ rem ] += dp [ i ] [ k ] ; NEW_LINE dp [ i + 1 ] [ rem ] %= MOD ; NEW_LINE DEDENT if ( s [ i ] != ' ? ' ) : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT DEDENT return int ( dp [ n ] [ 5 ] ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" ? 44"" ; NEW_LINE n = len ( s ) ; NEW_LINE print ( modulo_13 ( s , n ) ) ; NEW_LINE DEDENT +" +E809,"import java . util . * ; class solution { static int max_profit ( int a [ ] , int b [ ] , int n , int fee ) { int i , j , profit ; int l , r , diff_day = 1 , sum = 0 ; b [ 0 ] = 0 ; b [ 1 ] = diff_day ; for ( i = 1 ; i < n ; i ++ ) { l = 0 ; r = diff_day ; sum = 0 ; for ( j = n - 1 ; j >= i ; j -- ) { profit = ( a [ r ] - a [ l ] ) - fee ; if ( profit > 0 ) { sum = sum + profit ; } l ++ ; r ++ ; } if ( b [ 0 ] < sum ) { b [ 0 ] = sum ; b [ 1 ] = diff_day ; } diff_day ++ ; } return 0 ; } public static void main ( String args [ ] ) { int arr [ ] = { 6 , 1 , 7 , 2 , 8 , 4 } ; int n = arr . length ; int [ ] b = new int [ 2 ] ; int tranFee = 2 ; max_profit ( arr , b , n , tranFee ) ; System . out . println ( b [ 0 ] + "" , ▁ "" + b [ 1 ] ) ; } } +","def max_profit ( a , b , n , fee ) : NEW_LINE INDENT i , j , profit = 1 , n - 1 , 0 NEW_LINE l , r , diff_day = 0 , 0 , 1 NEW_LINE b [ 0 ] = 0 NEW_LINE b [ 1 ] = diff_day NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT l = 0 NEW_LINE r = diff_day NEW_LINE Sum = 0 NEW_LINE for j in range ( n - 1 , i - 1 , - 1 ) : NEW_LINE INDENT profit = ( a [ r ] - a [ l ] ) - fee NEW_LINE if ( profit > 0 ) : NEW_LINE INDENT Sum = Sum + profit NEW_LINE DEDENT l += 1 NEW_LINE r += 1 NEW_LINE DEDENT if ( b [ 0 ] < Sum ) : NEW_LINE INDENT b [ 0 ] = Sum NEW_LINE b [ 1 ] = diff_day NEW_LINE DEDENT DEDENT diff_day += 1 NEW_LINE return 0 NEW_LINE DEDENT arr = [ 6 , 1 , 7 , 2 , 8 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE b = [ 0 for i in range ( 2 ) ] NEW_LINE tranFee = 2 NEW_LINE max_profit ( arr , b , n , tranFee ) NEW_LINE print ( b [ 0 ] , "" , "" , b [ 1 ] ) NEW_LINE +" +E810,"class GFG { static int MAX = 25 ; static int getMinSum ( int arr [ ] , int n ) { int bits_count [ ] = new int [ MAX ] , max_bit = 0 , sum = 0 , ans = 0 ; for ( int d = 0 ; d < n ; d ++ ) { int e = arr [ d ] , f = 0 ; while ( e > 0 ) { int rem = e % 2 ; e = e / 2 ; if ( rem == 1 ) { bits_count [ f ] += rem ; } f ++ ; } max_bit = Math . max ( max_bit , f ) ; } for ( int d = 0 ; d < max_bit ; d ++ ) { int temp = ( int ) Math . pow ( 2 , d ) ; if ( bits_count [ d ] > n / 2 ) ans = ans + temp ; } for ( int d = 0 ; d < n ; d ++ ) { arr [ d ] = arr [ d ] ^ ans ; sum = sum + arr [ d ] ; } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 , 7 , 11 , 15 } ; int n = arr . length ; System . out . println ( getMinSum ( arr , n ) ) ; } } +","MAX = 25 ; NEW_LINE def getMinSum ( arr , n ) : NEW_LINE INDENT bits_count = [ 0 ] * MAX NEW_LINE max_bit = 0 ; sum = 0 ; ans = 0 ; NEW_LINE for d in range ( n ) : NEW_LINE INDENT e = arr [ d ] ; f = 0 ; NEW_LINE while ( e > 0 ) : NEW_LINE INDENT rem = e % 2 ; NEW_LINE e = e // 2 ; NEW_LINE if ( rem == 1 ) : NEW_LINE INDENT bits_count [ f ] += rem ; NEW_LINE DEDENT f += 1 NEW_LINE DEDENT max_bit = max ( max_bit , f ) ; NEW_LINE DEDENT for d in range ( max_bit ) : NEW_LINE INDENT temp = pow ( 2 , d ) ; NEW_LINE if ( bits_count [ d ] > n // 2 ) : NEW_LINE INDENT ans = ans + temp ; NEW_LINE DEDENT DEDENT for d in range ( n ) : NEW_LINE INDENT arr [ d ] = arr [ d ] ^ ans ; NEW_LINE sum = sum + arr [ d ] ; NEW_LINE DEDENT return sum NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 3 , 5 , 7 , 11 , 15 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( getMinSum ( arr , n ) ) NEW_LINE DEDENT +" +E811,"class GFG { static void findNums ( int arr [ ] , int n ) { int S = 0 , X = 0 ; for ( int i = 0 ; i < n ; i ++ ) { S += arr [ i ] ; X ^= arr [ i ] ; } System . out . println ( X + "" ▁ "" + ( X + S ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 7 } ; int n = arr . length ; findNums ( arr , n ) ; } } +","def findNums ( arr , n ) : NEW_LINE INDENT S = 0 ; X = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT S += arr [ i ] ; NEW_LINE X ^= arr [ i ] ; NEW_LINE DEDENT print ( X , X + S ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 7 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE findNums ( arr , n ) ; NEW_LINE DEDENT +" +E812,"class GFG { static void bin ( Integer n ) { if ( n > 1 ) bin ( n >> 1 ) ; System . out . printf ( "" % d "" , n & 1 ) ; } public static void main ( String [ ] args ) { bin ( 131 ) ; System . out . printf ( "" \n "" ) ; bin ( 3 ) ; } } +","def bin ( n ) : NEW_LINE INDENT if ( n > 1 ) : NEW_LINE INDENT bin ( n >> 1 ) NEW_LINE DEDENT print ( n & 1 , end = "" "" ) NEW_LINE DEDENT bin ( 131 ) NEW_LINE print ( ) NEW_LINE bin ( 3 ) NEW_LINE +" +E813,"class GFG { static int Square ( int row , int column , int moves ) { int a = 0 , b = 0 , c = 0 , d = 0 , total = 0 ; a = row - moves ; b = row + moves ; c = column - moves ; d = column + moves ; if ( a < 1 ) a = 1 ; if ( c < 1 ) c = 1 ; if ( b > 8 ) b = 8 ; if ( d > 8 ) d = 8 ; total = ( b - a + 1 ) * ( d - c + 1 ) - 1 ; return total ; } public static void main ( String [ ] args ) { int R = 4 , C = 5 , M = 2 ; System . out . println ( Square ( R , C , M ) ) ; } } +","def Square ( row , column , moves ) : NEW_LINE INDENT a = 0 ; b = 0 ; c = 0 ; NEW_LINE d = 0 ; total = 0 ; NEW_LINE a = row - moves ; NEW_LINE b = row + moves ; NEW_LINE c = column - moves ; NEW_LINE d = column + moves ; NEW_LINE if ( a < 1 ) : NEW_LINE INDENT a = 1 ; NEW_LINE DEDENT if ( c < 1 ) : NEW_LINE INDENT c = 1 ; NEW_LINE DEDENT if ( b > 8 ) : NEW_LINE INDENT b = 8 ; NEW_LINE DEDENT if ( d > 8 ) : NEW_LINE INDENT d = 8 ; NEW_LINE DEDENT total = ( b - a + 1 ) * ( d - c + 1 ) - 1 ; NEW_LINE return total ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT R = 4 ; C = 5 ; M = 2 ; NEW_LINE print ( Square ( R , C , M ) ) ; NEW_LINE DEDENT +" +E814,"public class Digits { static long firstkdigits ( int n , int k ) { long product = 1 ; for ( int i = 0 ; i < n ; i ++ ) product *= n ; while ( ( int ) ( product / Math . pow ( 10 , k ) ) != 0 ) product = product / 10 ; return product ; } public static void main ( String [ ] args ) { int n = 15 ; int k = 4 ; System . out . println ( firstkdigits ( n , k ) ) ; } } +","def firstkdigits ( n , k ) : NEW_LINE INDENT product = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT product *= n NEW_LINE DEDENT while ( ( product // pow ( 10 , k ) ) != 0 ) : NEW_LINE INDENT product = product // 10 NEW_LINE DEDENT return product NEW_LINE DEDENT n = 15 NEW_LINE k = 4 NEW_LINE print ( firstkdigits ( n , k ) ) NEW_LINE +" +E815,"class GFG { static int solve ( String X , String Y , int N , int K ) { int [ ] count = new int [ N + 1 ] ; int sol = 0 ; count [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { count [ i ] = count [ i - 1 ] + Math . abs ( X . charAt ( i - 1 ) - Y . charAt ( i - 1 ) ) ; } int j = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { while ( ( count [ i ] - count [ j ] ) > K ) { j ++ ; } sol = Math . max ( sol , i - j ) ; } return sol ; } public static void main ( String [ ] args ) { int N = 4 ; String X = "" abcd "" , Y = "" bcde "" ; int K = 3 ; System . out . print ( solve ( X , Y , N , K ) + "" \n "" ) ; } } +","def solve ( X , Y , N , K ) : NEW_LINE INDENT count = [ 0 ] * ( N + 1 ) ; NEW_LINE sol = 0 ; NEW_LINE count [ 0 ] = 0 ; NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT count [ i ] = ( count [ i - 1 ] + abs ( ord ( X [ i - 1 ] ) - ord ( Y [ i - 1 ] ) ) ) ; NEW_LINE DEDENT j = 0 ; NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT while ( ( count [ i ] - count [ j ] ) > K ) : NEW_LINE INDENT j += 1 ; NEW_LINE DEDENT sol = max ( sol , i - j ) ; NEW_LINE DEDENT return sol ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 4 ; NEW_LINE X = "" abcd "" ; NEW_LINE Y = "" bcde "" ; NEW_LINE K = 3 ; NEW_LINE print ( solve ( X , Y , N , K ) ) ; NEW_LINE DEDENT +" +E816,"import java . util . * ; class GFG { static int MAX = 1000 ; static int [ ] f = new int [ MAX ] ; static int fib ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 || n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] != 0 ) return f [ n ] ; int k = 0 ; if ( ( n & 1 ) != 0 ) k = ( n + 1 ) / 2 ; else k = n / 2 ; if ( ( n & 1 ) != 0 ) f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) ; else f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int findLCMFibonacci ( int a , int b ) { return ( fib ( a ) * fib ( b ) ) / fib ( gcd ( a , b ) ) ; } public static void main ( String args [ ] ) { int a = 3 , b = 12 ; System . out . println ( findLCMFibonacci ( a , b ) ) ; } } +","MAX = 1000 NEW_LINE f = [ 0 ] * MAX NEW_LINE def fib ( n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( n == 1 or n == 2 ) : NEW_LINE INDENT f [ n ] = 1 NEW_LINE return f [ n ] NEW_LINE DEDENT if ( f [ n ] ) : NEW_LINE INDENT return f [ n ] NEW_LINE DEDENT k = ( n + 1 ) // 2 if ( n & 1 ) else n // 2 NEW_LINE if ( n & 1 ) : NEW_LINE INDENT f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) NEW_LINE DEDENT return f [ n ] NEW_LINE DEDENT def gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 ) : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b % a , a ) NEW_LINE DEDENT def findLCMFibonacci ( a , b ) : NEW_LINE INDENT return ( fib ( a ) * fib ( b ) ) // fib ( gcd ( a , b ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 3 NEW_LINE b = 12 NEW_LINE print ( findLCMFibonacci ( a , b ) ) NEW_LINE DEDENT +" +E817,"import java . io . * ; class GFG { static int find_digit ( String s , int n ) { int first_digit = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) < '0' || s . charAt ( i ) > '9' ) { first_digit = i ; break ; } } first_digit ++ ; int s_len = first_digit ; int num = 0 , pw = 1 ; int i = n - 1 ; while ( i >= 0 ) { if ( s . charAt ( i ) >= '0' && s . charAt ( i ) <= '9' ) { int digit = s . charAt ( i ) - '0' ; num = num + ( pw * digit ) ; if ( num >= s_len ) return - 1 ; pw = pw * 10 ; } i -- ; } num = num * 10 ; int req = s_len - num ; if ( req > 9 || req < 0 ) return - 1 ; return req ; } public static void main ( String [ ] args ) { String s = "" abcd0"" ; int n = s . length ( ) ; System . out . print ( find_digit ( s , n ) ) ; } } +","def find_digit ( s , n ) : NEW_LINE INDENT first_digit = - 1 NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if s [ i ] < '0' or s [ i ] > '9' : NEW_LINE INDENT first_digit = i NEW_LINE break NEW_LINE DEDENT DEDENT first_digit += 1 NEW_LINE s_len = first_digit NEW_LINE num = 0 NEW_LINE pw = 1 NEW_LINE i = n - 1 NEW_LINE while i >= 0 : NEW_LINE INDENT if s [ i ] >= '0' and s [ i ] <= '9' : NEW_LINE INDENT digit = ord ( s [ i ] ) - ord ( '0' ) NEW_LINE num = num + ( pw * digit ) NEW_LINE if num >= s_len : NEW_LINE INDENT return - 1 NEW_LINE DEDENT pw = pw * 10 NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT num = num * 10 NEW_LINE req = s_len - num NEW_LINE if req > 9 or req < 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return req NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" abcd0"" NEW_LINE n = len ( s ) NEW_LINE print ( find_digit ( s , n ) ) NEW_LINE DEDENT +" +E818,"import java . util . * ; class GFG { static int findNthNumber ( int A , int B , int N ) { int sum = 0 ; for ( int i = 2 ; i < N ; i ++ ) { sum = A + B ; A = B ; B = sum ; } return sum ; } public static void main ( String [ ] args ) { int A = 5 , B = 7 , N = 10 ; System . out . println ( findNthNumber ( A , B , N ) ) ; } } +","def findNthNumber ( A , B , N ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT sum = A + B NEW_LINE A = B NEW_LINE B = sum NEW_LINE DEDENT return sum NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = 5 NEW_LINE B = 7 NEW_LINE N = 10 NEW_LINE print ( findNthNumber ( A , B , N ) ) NEW_LINE DEDENT +" +E819,"import java . util . * ; class solution { static int calculateSum ( int n ) { return ( ( int ) Math . pow ( 10 , n + 1 ) * ( 9 * n - 1 ) + 10 ) / ( int ) Math . pow ( 9 , 3 ) - n * ( n + 1 ) / 18 ; } public static void main ( String ar [ ] ) { int n = 3 ; System . out . println ( "" Sum = ▁ "" + calculateSum ( n ) ) ; } } +","def solve_sum ( n ) : NEW_LINE INDENT return ( pow ( 10 , n + 1 ) * ( 9 * n - 1 ) + 10 ) / pow ( 9 , 3 ) - n * ( n + 1 ) / 18 NEW_LINE DEDENT n = 3 NEW_LINE print ( int ( solve_sum ( n ) ) ) NEW_LINE +" +E820,"import java . util . * ; import java . lang . * ; class GFG { public static int summation ( int n ) { return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } public static void main ( String args [ ] ) { int n = 10 ; System . out . println ( summation ( n ) ) ; } } +","def summation ( n ) : NEW_LINE INDENT return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 NEW_LINE print ( summation ( n ) ) NEW_LINE DEDENT +" +E821,"class GFG { static float mean ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum / n ; } static float SSD ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ; return ( float ) Math . sqrt ( sum / ( n - 1 ) ) ; } static float sampleError ( float arr [ ] , int n ) { return SSD ( arr , n ) / ( float ) Math . sqrt ( n ) ; } public static void main ( String [ ] args ) { float arr [ ] = { 78.53f , 79.62f , 80.25f , 81.05f , 83.21f , 83.46f } ; int n = arr . length ; System . out . println ( sampleError ( arr , n ) ) ; } } +","import math NEW_LINE def mean ( arr , n ) : NEW_LINE INDENT sm = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sm = sm + arr [ i ] NEW_LINE DEDENT return sm / n NEW_LINE DEDENT def SSD ( arr , n ) : NEW_LINE INDENT sm = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sm = sm + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) NEW_LINE DEDENT return ( math . sqrt ( sm / ( n - 1 ) ) ) NEW_LINE DEDENT def sampleError ( arr , n ) : NEW_LINE INDENT return SSD ( arr , n ) / ( math . sqrt ( n ) ) NEW_LINE DEDENT arr = [ 78.53 , 79.62 , 80.25 , 81.05 , 83.21 , 83.46 ] NEW_LINE n = len ( arr ) NEW_LINE print ( sampleError ( arr , n ) ) NEW_LINE +" +E822,"import java . util . * ; class GFG { static final int INFINITY_ = 9999999 ; static int sqrtByLongDivision ( int n ) { int i = 0 , udigit , j ; int cur_divisor = 0 ; int quotient_units_digit = 0 ; int cur_quotient = 0 ; int cur_dividend = 0 ; int cur_remainder = 0 ; int a [ ] = new int [ 10 ] ; while ( n > 0 ) { a [ i ] = n % 100 ; n = n / 100 ; i ++ ; } i -- ; for ( j = i ; j >= 0 ; j -- ) { cur_remainder = INFINITY_ ; cur_dividend = cur_dividend * 100 + a [ j ] ; for ( udigit = 0 ; udigit <= 9 ; udigit ++ ) { if ( cur_remainder >= cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) && cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) >= 0 ) { cur_remainder = cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) ; quotient_units_digit = udigit ; } } cur_quotient = cur_quotient * 10 + quotient_units_digit ; cur_divisor = cur_quotient * 2 ; cur_dividend = cur_remainder ; } return cur_quotient ; } public static void main ( String [ ] args ) { int x = 1225 ; System . out . print ( sqrtByLongDivision ( x ) + "" \n "" ) ; } } +","INFINITY_ = 9999999 NEW_LINE def sqrtByLongDivision ( n ) : NEW_LINE INDENT i = 0 NEW_LINE udigit , j = 0 , 0 NEW_LINE cur_divisor = 0 NEW_LINE quotient_units_digit = 0 NEW_LINE cur_quotient = 0 NEW_LINE cur_dividend = 0 NEW_LINE cur_remainder = 0 NEW_LINE a = [ 0 ] * 10 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT a [ i ] = n % 100 NEW_LINE n = n // 100 NEW_LINE i += 1 NEW_LINE DEDENT i -= 1 NEW_LINE for j in range ( i , - 1 , - 1 ) : NEW_LINE INDENT cur_remainder = INFINITY_ NEW_LINE cur_dividend = cur_dividend * 100 + a [ j ] NEW_LINE for udigit in range ( 10 ) : NEW_LINE INDENT if ( cur_remainder >= cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) and cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) >= 0 ) : NEW_LINE INDENT cur_remainder = cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) NEW_LINE quotient_units_digit = udigit NEW_LINE DEDENT DEDENT cur_quotient = cur_quotient * 10 + quotient_units_digit NEW_LINE cur_divisor = cur_quotient * 2 NEW_LINE cur_dividend = cur_remainder NEW_LINE DEDENT return cur_quotient NEW_LINE DEDENT x = 1225 NEW_LINE print ( sqrtByLongDivision ( x ) ) NEW_LINE +" +E823,"import java . io . * ; class GFG { static int CountAllPairs ( int N , int K ) { int count = 0 ; if ( N > K ) { count = N - K ; for ( int i = K + 1 ; i <= N ; i ++ ) count = count + ( ( N - K ) / i ) ; } return count ; } public static void main ( String [ ] args ) { int N = 11 , K = 5 ; System . out . println ( CountAllPairs ( N , K ) ) ; } } +","import math NEW_LINE def CountAllPairs ( N , K ) : NEW_LINE INDENT count = 0 NEW_LINE if ( N > K ) : NEW_LINE INDENT count = N - K NEW_LINE for i in range ( K + 1 , N + 1 ) : NEW_LINE INDENT count = count + ( ( N - K ) // i ) NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT N = 11 NEW_LINE K = 5 NEW_LINE print ( CountAllPairs ( N , K ) ) NEW_LINE +" +E824,"import java . io . * ; class GFG { static String checkNumber ( int N ) { int temp = N ; while ( temp > 0 ) { if ( temp % 1000 == 144 ) temp /= 1000 ; else if ( temp % 100 == 14 ) temp /= 100 ; else if ( temp % 10 == 1 ) temp /= 10 ; else { return "" NO "" ; } } return "" YES "" ; } public static void main ( String [ ] args ) { int N = 1414 ; System . out . println ( checkNumber ( N ) ) ; } } +","def checkNumber ( N ) : NEW_LINE INDENT temp = N NEW_LINE while ( temp > 0 ) : NEW_LINE INDENT if ( temp % 1000 == 144 ) : NEW_LINE INDENT temp /= 1000 NEW_LINE DEDENT elif ( temp % 100 == 14 ) : NEW_LINE INDENT temp /= 100 NEW_LINE DEDENT elif ( temp % 10 == 1 ) : NEW_LINE INDENT temp /= 10 NEW_LINE DEDENT else : NEW_LINE INDENT return "" YES "" NEW_LINE DEDENT DEDENT return "" NO "" NEW_LINE DEDENT N = 1414 ; NEW_LINE print ( checkNumber ( N ) ) ; NEW_LINE +" +E825,"class GFG { static void printNumbers ( int N ) { int flag = 1 ; int x = N ; if ( N > 0 ) { while ( x > 0 && flag == 1 ) { int digit = x % 10 ; if ( digit != 1 && digit != 3 ) { flag = 0 ; } x = x / 10 ; } if ( flag == 1 ) { System . out . print ( N + "" ▁ "" ) ; } printNumbers ( N - 1 ) ; } } public static void main ( String [ ] args ) { int N = 20 ; printNumbers ( N ) ; } } +","def printNumbers ( N ) : NEW_LINE INDENT flag = 1 NEW_LINE x = N NEW_LINE if ( N > 0 ) : NEW_LINE INDENT while ( x > 0 and flag == 1 ) : NEW_LINE INDENT digit = x % 10 NEW_LINE if ( digit != 1 and digit != 3 ) : NEW_LINE INDENT flag = 0 NEW_LINE DEDENT x = x // 10 NEW_LINE DEDENT if ( flag == 1 ) : NEW_LINE INDENT print ( N , end = "" ▁ "" ) NEW_LINE DEDENT printNumbers ( N - 1 ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 20 NEW_LINE printNumbers ( N ) NEW_LINE DEDENT +" +E826,"import java . util . * ; class solution { static int getPosition ( int a [ ] , int n , int m ) { for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = ( a [ i ] / m + ( a [ i ] % m ) ) ; } int ans = - 1 , max = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( max < a [ i ] ) { max = a [ i ] ; ans = i ; } } return ans + 1 ; } public static void main ( String args [ ] ) { int a [ ] = { 2 , 5 , 4 } ; int n = a . length ; int m = 2 ; System . out . println ( getPosition ( a , n , m ) ) ; } } +","import math as mt NEW_LINE def getPosition ( a , n , m ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT a [ i ] = ( a [ i ] // m + ( a [ i ] % m != 0 ) ) NEW_LINE DEDENT ans , maxx = - 1 , - 1 NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( maxx < a [ i ] ) : NEW_LINE INDENT maxx = a [ i ] NEW_LINE ans = i NEW_LINE DEDENT DEDENT return ans + 1 NEW_LINE DEDENT a = [ 2 , 5 , 4 ] NEW_LINE n = len ( a ) NEW_LINE m = 2 NEW_LINE print ( getPosition ( a , n , m ) ) NEW_LINE +" +E827,"import java . util . Arrays ; class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } static void sortArr ( int arr [ ] , int n , int k ) { int prev = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % k == 0 ) { if ( prev != - 1 ) Arrays . sort ( arr , prev + 1 , i ) ; prev = i ; } } printArr ( arr , n ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 13 , 3 , 7 , 8 , 21 , 13 , 12 } ; int n = arr . length ; int k = 2 ; sortArr ( arr , n , k ) ; } } +","def printArr ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT def sortArr ( arr , n , k ) : NEW_LINE INDENT prev = - 1 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] % k == 0 ) : NEW_LINE INDENT if ( prev != - 1 ) : NEW_LINE INDENT temp = arr [ prev + 1 : i ] ; NEW_LINE temp . sort ( ) ; NEW_LINE arr = arr [ : prev + 1 ] + temp + arr [ i : ] ; NEW_LINE DEDENT prev = i ; NEW_LINE DEDENT DEDENT printArr ( arr , n ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 1 , 13 , 3 , 7 , 8 , 21 , 13 , 12 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE k = 2 ; NEW_LINE sortArr ( arr , n , k ) ; NEW_LINE DEDENT +" +E828,"import java . util . LinkedList ; import java . util . Queue ; public class GFG { static int countOfBinaryNumberLessThanN ( int N ) { Queue < Integer > q = new LinkedList < > ( ) ; q . add ( 1 ) ; int cnt = 0 ; int t ; while ( q . size ( ) > 0 ) { t = q . peek ( ) ; q . remove ( ) ; if ( t <= N ) { cnt ++ ; q . add ( t * 10 ) ; q . add ( t * 10 + 1 ) ; } } return cnt ; } static public void main ( String [ ] args ) { int N = 200 ; System . out . println ( countOfBinaryNumberLessThanN ( N ) ) ; } } +","from collections import deque NEW_LINE def countOfBinaryNumberLessThanN ( N ) : NEW_LINE INDENT q = deque ( ) NEW_LINE q . append ( 1 ) NEW_LINE cnt = 0 NEW_LINE while ( q ) : NEW_LINE INDENT t = q . popleft ( ) NEW_LINE if ( t <= N ) : NEW_LINE INDENT cnt = cnt + 1 NEW_LINE q . append ( t * 10 ) NEW_LINE q . append ( t * 10 + 1 ) NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 200 NEW_LINE print ( countOfBinaryNumberLessThanN ( N ) ) NEW_LINE DEDENT +" +E829,"class GFG { static final int mod = ( int ) ( 1e9 + 7 ) ; static long power ( int p ) { long res = 1 ; for ( int i = 1 ; i <= p ; ++ i ) { res *= 2 ; res %= mod ; } return res % mod ; } static long subset_square_sum ( int A [ ] ) { int n = A . length ; long ans = 0 ; for ( int i : A ) { ans += ( 1 * i * i ) % mod ; ans %= mod ; } return ( 1 * ans * power ( n - 1 ) ) % mod ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 7 } ; System . out . println ( subset_square_sum ( A ) ) ; } } +","mod = 10 ** 9 + 7 NEW_LINE def power ( p ) : NEW_LINE INDENT res = 1 NEW_LINE for i in range ( 1 , p + 1 ) : NEW_LINE INDENT res *= 2 NEW_LINE res %= mod NEW_LINE DEDENT return res % mod NEW_LINE DEDENT def subset_square_sum ( A ) : NEW_LINE INDENT n = len ( A ) NEW_LINE ans = 0 NEW_LINE for i in A : NEW_LINE INDENT ans += i * i % mod NEW_LINE ans %= mod NEW_LINE DEDENT return ans * power ( n - 1 ) % mod NEW_LINE DEDENT A = [ 3 , 7 ] NEW_LINE print ( subset_square_sum ( A ) ) NEW_LINE +" +E830,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void performQueries ( int [ ] A , pair [ ] q ) { int n = A . length ; int [ ] pref_xor = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; ++ i ) { pref_xor [ i ] = pref_xor [ i - 1 ] ^ A [ i - 1 ] ; } for ( pair i : q ) { int L = i . first , R = i . second ; if ( L > R ) { int temp = L ; L = R ; R = temp ; } if ( L != R && pref_xor [ R ] == pref_xor [ L - 1 ] ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } static public void main ( String [ ] arg ) { int [ ] Arr = { 1 , 1 , 2 , 2 , 1 } ; pair [ ] q = { new pair ( 1 , 5 ) , new pair ( 1 , 4 ) , new pair ( 3 , 4 ) } ; performQueries ( Arr , q ) ; } } +","def performQueries ( A , q ) : NEW_LINE INDENT n = len ( A ) NEW_LINE pref_xor = [ 0 for i in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT pref_xor [ i ] = pref_xor [ i - 1 ] ^ A [ i - 1 ] NEW_LINE DEDENT for i in q : NEW_LINE INDENT L = i [ 0 ] NEW_LINE R = i [ 1 ] NEW_LINE if ( L > R ) : NEW_LINE INDENT L , R = R , L NEW_LINE DEDENT if ( L != R and pref_xor [ R ] == pref_xor [ L - 1 ] ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT DEDENT Arr = [ 1 , 1 , 2 , 2 , 1 ] NEW_LINE q = [ [ 1 , 5 ] , [ 1 , 4 ] , [ 3 , 4 ] ] NEW_LINE performQueries ( Arr , q ) ; NEW_LINE +" +E831,"class GFG { static String one [ ] = { "" "" , "" one ▁ "" , "" two ▁ "" , "" three ▁ "" , "" four ▁ "" , "" five ▁ "" , "" six ▁ "" , "" seven ▁ "" , "" eight ▁ "" , "" nine ▁ "" , "" ten ▁ "" , "" eleven ▁ "" , "" twelve ▁ "" , "" thirteen ▁ "" , "" fourteen ▁ "" , "" fifteen ▁ "" , "" sixteen ▁ "" , "" seventeen ▁ "" , "" eighteen ▁ "" , "" nineteen ▁ "" } ; static String ten [ ] = { "" "" , "" "" , "" twenty ▁ "" , "" thirty ▁ "" , "" forty ▁ "" , "" fifty ▁ "" , "" sixty ▁ "" , "" seventy ▁ "" , "" eighty ▁ "" , "" ninety ▁ "" } ; static String numToWords ( int n , String s ) { String str = "" "" ; if ( n > 19 ) { str += ten [ n / 10 ] + one [ n % 10 ] ; } else { str += one [ n ] ; } if ( n != 0 ) { str += s ; } return str ; } static String convertToWords ( long n ) { String out = "" "" ; out += numToWords ( ( int ) ( n / 10000000 ) , "" crore ▁ "" ) ; out += numToWords ( ( int ) ( ( n / 100000 ) % 100 ) , "" lakh ▁ "" ) ; out += numToWords ( ( int ) ( ( n / 1000 ) % 100 ) , "" thousand ▁ "" ) ; out += numToWords ( ( int ) ( ( n / 100 ) % 10 ) , "" hundred ▁ "" ) ; if ( n > 100 && n % 100 > 0 ) { out += "" and ▁ "" ; } out += numToWords ( ( int ) ( n % 100 ) , "" "" ) ; return out ; } public static void main ( String [ ] args ) { long n = 438237764 ; System . out . printf ( convertToWords ( n ) ) ; } } +","one = [ "" "" , "" one ▁ "" , "" two ▁ "" , "" three ▁ "" , "" four ▁ "" , "" five ▁ "" , "" six ▁ "" , "" seven ▁ "" , "" eight ▁ "" , "" nine ▁ "" , "" ten ▁ "" , "" eleven ▁ "" , "" twelve ▁ "" , "" thirteen ▁ "" , "" fourteen ▁ "" , "" fifteen ▁ "" , "" sixteen ▁ "" , "" seventeen ▁ "" , "" eighteen ▁ "" , "" nineteen ▁ "" ] ; NEW_LINE ten = [ "" "" , "" "" , "" twenty ▁ "" , "" thirty ▁ "" , "" forty ▁ "" , "" fifty ▁ "" , "" sixty ▁ "" , "" seventy ▁ "" , "" eighty ▁ "" , "" ninety ▁ "" ] ; NEW_LINE def numToWords ( n , s ) : NEW_LINE INDENT str = "" "" ; NEW_LINE if ( n > 19 ) : NEW_LINE INDENT str += ten [ n // 10 ] + one [ n % 10 ] ; NEW_LINE DEDENT else : NEW_LINE INDENT str += one [ n ] ; NEW_LINE DEDENT if ( n ) : NEW_LINE INDENT str += s ; NEW_LINE DEDENT return str ; NEW_LINE DEDENT def convertToWords ( n ) : NEW_LINE INDENT out = "" "" ; NEW_LINE out += numToWords ( ( n // 10000000 ) , "" crore ▁ "" ) ; NEW_LINE out += numToWords ( ( ( n // 100000 ) % 100 ) , "" lakh ▁ "" ) ; NEW_LINE out += numToWords ( ( ( n // 1000 ) % 100 ) , "" thousand ▁ "" ) ; NEW_LINE out += numToWords ( ( ( n // 100 ) % 10 ) , "" hundred ▁ "" ) ; NEW_LINE if ( n > 100 and n % 100 ) : NEW_LINE INDENT out += "" and ▁ "" ; NEW_LINE DEDENT out += numToWords ( ( n % 100 ) , "" "" ) ; NEW_LINE return out ; NEW_LINE DEDENT n = 438237764 ; NEW_LINE print ( convertToWords ( n ) ) ; NEW_LINE +" +E832,"class Test { static int factorial ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } public static void main ( String [ ] args ) { int num = 5 ; System . out . println ( "" Factorial ▁ of ▁ "" + num + "" ▁ is ▁ "" + factorial ( 5 ) ) ; } } +","def factorial ( n ) : NEW_LINE INDENT res = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT res *= i NEW_LINE DEDENT return res NEW_LINE DEDENT num = 5 ; NEW_LINE print ( "" Factorial ▁ of "" , num , "" is "" , factorial ( num ) ) NEW_LINE +" +E833,"class gfg { static int getMinCost ( int n , int m ) { int cost = ( n - 1 ) * m + ( m - 1 ) * n ; return cost ; } public static void main ( String [ ] args ) { int n = 4 , m = 5 ; System . out . println ( getMinCost ( n , m ) ) ; } } +","def getMinCost ( n , m ) : NEW_LINE INDENT cost = ( n - 1 ) * m + ( m - 1 ) * n NEW_LINE return cost NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n , m = 4 , 5 NEW_LINE print ( getMinCost ( n , m ) ) NEW_LINE DEDENT +" +E834,"import java . util . * ; import java . lang . * ; class GFG { public static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static void main ( String [ ] args ) { int a = 2 ; int b = 4 ; System . out . println ( gcd ( a , b ) ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if a == 0 : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b % a , a ) NEW_LINE DEDENT a = 2 NEW_LINE b = 4 NEW_LINE print ( gcd ( a , b ) ) NEW_LINE +" +E835,"public class GFG { static int calculateSum ( int n ) { return n * ( n + 1 ) / 2 + ( int ) Math . pow ( ( n * ( n + 1 ) / 2 ) , 2 ) ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . println ( "" Sum ▁ = ▁ "" + calculateSum ( n ) ) ; } } +","def calculateSum ( n ) : NEW_LINE INDENT return ( n * ( n + 1 ) // 2 + pow ( ( n * ( n + 1 ) // 2 ) , 2 ) ) NEW_LINE DEDENT n = 3 NEW_LINE print ( "" Sum ▁ = ▁ "" , calculateSum ( n ) ) NEW_LINE +" +E836,"import java . io . * ; class GFG { static int findLength ( String str ) { int n = str . length ( ) ; int maxlen = 0 ; int sum [ ] [ ] = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) sum [ i ] [ i ] = str . charAt ( i ) - '0' ; for ( int len = 2 ; len <= n ; len ++ ) { for ( int i = 0 ; i < n - len + 1 ; i ++ ) { int j = i + len - 1 ; int k = len / 2 ; sum [ i ] [ j ] = sum [ i ] [ j - k ] + sum [ j - k + 1 ] [ j ] ; if ( len % 2 == 0 && sum [ i ] [ j - k ] == sum [ ( j - k + 1 ) ] [ j ] && len > maxlen ) maxlen = len ; } } return maxlen ; } public static void main ( String [ ] args ) { String str = ""153803"" ; System . out . println ( "" Length ▁ of ▁ the ▁ substring ▁ is ▁ "" + findLength ( str ) ) ; } } +","def findLength ( string ) : NEW_LINE INDENT n = len ( string ) NEW_LINE maxlen = 0 NEW_LINE Sum = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT Sum [ i ] [ i ] = int ( string [ i ] ) NEW_LINE DEDENT for length in range ( 2 , n + 1 ) : NEW_LINE INDENT for i in range ( 0 , n - length + 1 ) : NEW_LINE INDENT j = i + length - 1 NEW_LINE k = length // 2 NEW_LINE Sum [ i ] [ j ] = ( Sum [ i ] [ j - k ] + Sum [ j - k + 1 ] [ j ] ) NEW_LINE if ( length % 2 == 0 and Sum [ i ] [ j - k ] == Sum [ ( j - k + 1 ) ] [ j ] and length > maxlen ) : NEW_LINE INDENT maxlen = length NEW_LINE DEDENT DEDENT DEDENT return maxlen NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = ""153803"" NEW_LINE print ( "" Length ▁ of ▁ the ▁ substring ▁ is "" , findLength ( string ) ) NEW_LINE DEDENT +" +E837,"class GFG { static int solve ( int a [ ] , int b [ ] , int n ) { int i ; int s = 0 ; for ( i = 0 ; i < n ; i ++ ) s += ( a [ i ] + b [ i ] ) ; if ( n == 1 ) return a [ 0 ] + b [ 0 ] ; if ( s % n != 0 ) return - 1 ; int x = s / n ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] > x ) return - 1 ; if ( i > 0 ) { a [ i ] += b [ i - 1 ] ; b [ i - 1 ] = 0 ; } if ( a [ i ] == x ) continue ; int y = a [ i ] + b [ i ] ; if ( i + 1 < n ) y += b [ i + 1 ] ; if ( y == x ) { a [ i ] = y ; b [ i ] = 0 ; continue ; } if ( a [ i ] + b [ i ] == x ) { a [ i ] += b [ i ] ; b [ i ] = 0 ; continue ; } if ( i + 1 < n && a [ i ] + b [ i + 1 ] == x ) { a [ i ] += b [ i + 1 ] ; b [ i + 1 ] = 0 ; continue ; } return - 1 ; } for ( i = 0 ; i < n ; i ++ ) if ( b [ i ] != 0 ) return - 1 ; return x ; } public static void main ( String [ ] args ) { int a [ ] = { 6 , 14 , 21 , 1 } ; int b [ ] = { 15 , 7 , 10 , 10 } ; int n = a . length ; System . out . println ( solve ( a , b , n ) ) ; } } +","def solve ( a , b , n ) : NEW_LINE INDENT s = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT s += a [ i ] + b [ i ] NEW_LINE DEDENT if n == 1 : NEW_LINE INDENT return a [ 0 ] + b [ 0 ] NEW_LINE DEDENT if s % n != 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT x = s // n NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if a [ i ] > x : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if i > 0 : NEW_LINE INDENT a [ i ] += b [ i - 1 ] NEW_LINE b [ i - 1 ] = 0 NEW_LINE DEDENT if a [ i ] == x : NEW_LINE INDENT continue NEW_LINE DEDENT y = a [ i ] + b [ i ] NEW_LINE if i + 1 < n : NEW_LINE INDENT y += b [ i + 1 ] NEW_LINE DEDENT if y == x : NEW_LINE INDENT a [ i ] = y NEW_LINE b [ i ] = 0 NEW_LINE if i + 1 < n : b [ i + 1 ] = 0 NEW_LINE continue NEW_LINE DEDENT if a [ i ] + b [ i ] == x : NEW_LINE INDENT a [ i ] += b [ i ] NEW_LINE b [ i ] = 0 NEW_LINE continue NEW_LINE DEDENT if i + 1 < n and a [ i ] + b [ i + 1 ] == x : NEW_LINE INDENT a [ i ] += b [ i + 1 ] NEW_LINE b [ i + 1 ] = 0 NEW_LINE continue NEW_LINE DEDENT return - 1 NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT if b [ i ] != 0 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT DEDENT return x NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 6 , 14 , 21 , 1 ] NEW_LINE b = [ 15 , 7 , 10 , 10 ] NEW_LINE n = len ( a ) NEW_LINE print ( solve ( a , b , n ) ) NEW_LINE DEDENT +" +E838,"class GFG { static double sumOfSeries ( int n ) { double res = 0.0 ; int sum = 0 , prod = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { sum += i ; prod *= i ; res += ( ( double ) sum / prod ) ; } return res ; } public static void main ( String arg [ ] ) { int n = 4 ; System . out . println ( sumOfSeries ( n ) ) ; } } +","def sumOfSeries ( n ) : NEW_LINE INDENT res = 0.0 NEW_LINE sum = 0 NEW_LINE prod = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT sum = sum + i NEW_LINE prod = prod * i NEW_LINE res = res + ( sum / prod ) NEW_LINE DEDENT return res NEW_LINE DEDENT n = 4 NEW_LINE print ( round ( sumOfSeries ( n ) , 5 ) ) NEW_LINE +" +E839,"import java . io . * ; class GFG { static int number_of_digits ( int n ) { int i ; int res ; int sum = 0 ; for ( i = 4 , res = 1 ; ; i *= 4 , res ++ ) { sum += i ; if ( sum >= n ) break ; } return res ; } public static void main ( String [ ] args ) { int n = 21 ; System . out . println ( number_of_digits ( n ) ) ; } } +","def number_of_digits ( n ) : NEW_LINE INDENT i = 4 ; NEW_LINE res = 1 ; NEW_LINE sum = 0 ; NEW_LINE while ( True ) : NEW_LINE INDENT i *= 4 ; NEW_LINE res += 1 ; NEW_LINE sum += i ; NEW_LINE if ( sum >= n ) : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT return res ; NEW_LINE DEDENT n = 21 ; NEW_LINE print ( number_of_digits ( n ) ) ; NEW_LINE +" +E840,"import java . io . * ; import java . math . * ; class GFG { static int nonsquare ( int n ) { return n + ( int ) ( 0.5 + ( Math . sqrt ( n ) ) ) ; } static void printNonSquare ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) System . out . print ( nonsquare ( i ) + "" ▁ "" ) ; } public static void main ( String args [ ] ) { int n = 10 ; printNonSquare ( n ) ; } } +","import math NEW_LINE def nonsquare ( n ) : NEW_LINE INDENT return n + ( int ) ( 0.5 + math . sqrt ( n ) ) NEW_LINE DEDENT def printNonSquare ( n ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT print ( nonsquare ( i ) , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT n = 10 NEW_LINE printNonSquare ( n ) NEW_LINE +" +E841,"class GFG { static double distance ( int x1 , int y1 , int x2 , int y2 ) { return Math . sqrt ( Math . pow ( x2 - x1 , 2 ) + Math . pow ( y2 - y1 , 2 ) * 1.0 ) ; } public static void main ( String [ ] args ) { System . out . println ( Math . round ( distance ( 3 , 4 , 4 , 3 ) * 100000.0 ) / 100000.0 ) ; } } +","import math NEW_LINE def distance ( x1 , y1 , x2 , y2 ) : NEW_LINE INDENT return math . sqrt ( math . pow ( x2 - x1 , 2 ) + math . pow ( y2 - y1 , 2 ) * 1.0 ) NEW_LINE DEDENT print ( "" % .6f "" % distance ( 3 , 4 , 4 , 3 ) ) NEW_LINE +" +E842,"class GFG { static void evenOddInsertionSort ( int arr [ ] , int n ) { for ( int i = 2 ; i < n ; i ++ ) { int j = i - 2 ; int temp = arr [ i ] ; if ( ( ( i + 1 ) & 1 ) == 1 ) { while ( j >= 0 && temp >= arr [ j ] ) { arr [ j + 2 ] = arr [ j ] ; j -= 2 ; } arr [ j + 2 ] = temp ; } else { while ( j >= 0 && temp <= arr [ j ] ) { arr [ j + 2 ] = arr [ j ] ; j -= 2 ; } arr [ j + 2 ] = temp ; } } } static void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . printf ( "" % d ▁ "" , arr [ i ] ) ; } System . out . printf ( "" \n "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 11 , 13 , 5 , 6 } ; int n = arr . length ; evenOddInsertionSort ( arr , n ) ; printArray ( arr , n ) ; } } +","def evenOddInsertionSort ( arr , n ) : NEW_LINE INDENT for i in range ( 2 , n ) : NEW_LINE INDENT j = i - 2 NEW_LINE temp = arr [ i ] NEW_LINE if ( ( i + 1 ) & 1 == 1 ) : NEW_LINE INDENT while ( temp >= arr [ j ] and j >= 0 ) : NEW_LINE INDENT arr [ j + 2 ] = arr [ j ] NEW_LINE j -= 2 NEW_LINE DEDENT arr [ j + 2 ] = temp NEW_LINE DEDENT else : NEW_LINE INDENT while ( temp <= arr [ j ] and j >= 0 ) : NEW_LINE INDENT arr [ j + 2 ] = arr [ j ] NEW_LINE j -= 2 NEW_LINE DEDENT arr [ j + 2 ] = temp NEW_LINE DEDENT DEDENT DEDENT def printArray ( arr , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 12 , 11 , 13 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE evenOddInsertionSort ( arr , n ) NEW_LINE printArray ( arr , n ) NEW_LINE +" +E843,"class GFG { static int search ( int arr [ ] , int l , int h , int key ) { if ( l > h ) return - 1 ; int mid = ( l + h ) / 2 ; if ( arr [ mid ] == key ) return mid ; if ( ( arr [ l ] == arr [ mid ] ) && ( arr [ h ] == arr [ mid ] ) ) { ++ l ; -- h ; } if ( arr [ l ] <= arr [ mid ] ) { if ( key >= arr [ l ] && key <= arr [ mid ] ) return search ( arr , l , mid - 1 , key ) ; return search ( arr , mid + 1 , h , key ) ; } if ( key >= arr [ mid ] && key <= arr [ h ] ) return search ( arr , mid + 1 , h , key ) ; return search ( arr , l , mid - 1 , key ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 3 , 1 , 2 , 3 , 3 } ; int n = arr . length ; int key = 3 ; System . out . println ( search ( arr , 0 , n - 1 , key ) ) ; } } +","def search ( arr , l , h , key ) : NEW_LINE INDENT if ( l > h ) : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT mid = ( l + h ) // 2 ; NEW_LINE if ( arr [ mid ] == key ) : NEW_LINE INDENT return mid ; NEW_LINE DEDENT if ( ( arr [ l ] == arr [ mid ] ) and ( arr [ h ] == arr [ mid ] ) ) : NEW_LINE INDENT l += 1 ; NEW_LINE h -= 1 ; NEW_LINE DEDENT if ( arr [ l ] <= arr [ mid ] ) : NEW_LINE INDENT if ( key >= arr [ l ] and key <= arr [ mid ] ) : NEW_LINE INDENT return search ( arr , l , mid - 1 , key ) ; NEW_LINE DEDENT return search ( arr , mid + 1 , h , key ) ; NEW_LINE DEDENT if ( key >= arr [ mid ] and key <= arr [ h ] ) : NEW_LINE INDENT return search ( arr , mid + 1 , h , key ) ; NEW_LINE DEDENT return search ( arr , l , mid - 1 , key ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 3 , 3 , 1 , 2 , 3 , 3 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE key = 3 ; NEW_LINE print ( search ( arr , 0 , n - 1 , key ) ) ; NEW_LINE DEDENT +" +E844,"import java . util . * ; class GFG { static boolean check ( String s1 , String s2 ) { Map < Character , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { mp . put ( s1 . charAt ( i ) , mp . get ( s1 . charAt ( i ) ) == null ? 1 : mp . get ( s1 . charAt ( i ) ) + 1 ) ; } for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { if ( mp . get ( s2 . charAt ( i ) ) > 0 ) { return true ; } } return false ; } public static void main ( String [ ] args ) { String s1 = "" geeksforgeeks "" , s2 = "" geeks "" ; boolean yes_or_no = check ( s1 , s2 ) ; if ( yes_or_no == true ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","def is_member ( List , key ) : NEW_LINE INDENT for i in range ( 0 , len ( List ) ) : NEW_LINE INDENT if key == List [ i ] : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT def overlap ( List1 , List2 ) : NEW_LINE INDENT for key in List1 : NEW_LINE INDENT if is_member ( List2 , key ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s1 = ' geeksforgeeks ' NEW_LINE s2 = ' geeks ' NEW_LINE List1 = list ( s1 ) NEW_LINE List2 = list ( s2 ) NEW_LINE yes_or_no = str ( overlap ( List1 , List2 ) ) NEW_LINE if ( yes_or_no ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E845,"public class GFG { static int nthTerm ( int n ) { return 2 * ( int ) Math . pow ( n , 2 ) + 3 * n - 5 ; } public static void main ( String args [ ] ) { int N = 4 ; System . out . println ( nthTerm ( N ) ) ; } } +","def nthTerm ( n ) : NEW_LINE INDENT return 2 * pow ( n , 2 ) + 3 * n - 5 NEW_LINE DEDENT N = 4 NEW_LINE print ( nthTerm ( N ) ) NEW_LINE +" +E846,"import java . util . * ; class GFG { static int [ ] arr = new int [ 33 ] ; static void balTernary ( int ter ) { int carry = 0 , base = 10 ; int i = 32 ; while ( ter > 0 ) { int rem = ter % base ; rem = rem + carry ; if ( rem == 0 ) { arr [ i -- ] = 0 ; carry = 0 ; } else if ( rem == 1 ) { arr [ i -- ] = 1 ; carry = 0 ; } else if ( rem == 2 ) { arr [ i -- ] = - 1 ; carry = 1 ; } else if ( rem == 3 ) { arr [ i -- ] = 0 ; carry = 1 ; } ter = ( int ) ( ter / base ) ; } if ( carry == 1 ) arr [ i ] = 1 ; } static int ternary ( int number ) { int ans = 0 , rem = 1 , base = 1 ; while ( number > 0 ) { rem = number % 3 ; ans = ans + rem * base ; number = ( int ) ( number / 3 ) ; base = base * 10 ; } return ans ; } public static void main ( String args [ ] ) { int number = 3056 ; int ter = ternary ( number ) ; Arrays . fill ( arr , 0 ) ; balTernary ( ter ) ; int i = 0 ; while ( arr [ i ] == 0 ) { i ++ ; } for ( int j = i ; j <= 32 ; j ++ ) { if ( arr [ j ] == - 1 ) System . out . print ( ' Z ' ) ; else System . out . print ( arr [ j ] ) ; } } } +","arr = [ 0 ] * 32 NEW_LINE def balTernary ( ter ) : NEW_LINE INDENT carry , base , i = 0 , 10 , 31 NEW_LINE while ter > 0 : NEW_LINE INDENT rem = ( ter % base ) + carry NEW_LINE if rem == 0 : NEW_LINE INDENT arr [ i ] = 0 NEW_LINE carry , i = 0 , i - 1 NEW_LINE DEDENT elif rem == 1 : NEW_LINE INDENT arr [ i ] = 1 NEW_LINE carry , i = 0 , i - 1 NEW_LINE DEDENT elif rem == 2 : NEW_LINE INDENT arr [ i ] = - 1 NEW_LINE carry , i = 1 , i - 1 NEW_LINE DEDENT elif rem == 3 : NEW_LINE INDENT arr [ i ] = 0 NEW_LINE carry , i = 1 , i - 1 NEW_LINE DEDENT ter = ter // base NEW_LINE DEDENT if carry == 1 : NEW_LINE INDENT arr [ i ] = 1 NEW_LINE DEDENT DEDENT def ternary ( number ) : NEW_LINE INDENT ans , rem , base = 0 , 1 , 1 NEW_LINE while number > 0 : NEW_LINE INDENT rem = number % 3 NEW_LINE ans = ans + rem * base NEW_LINE number //= 3 NEW_LINE base = base * 10 NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT number = 3056 NEW_LINE ter = ternary ( number ) NEW_LINE balTernary ( ter ) NEW_LINE i = 0 NEW_LINE while arr [ i ] == 0 : NEW_LINE INDENT i += 1 NEW_LINE DEDENT for j in range ( i , 32 ) : NEW_LINE INDENT if arr [ j ] == - 1 : NEW_LINE INDENT print ( ' Z ' , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( arr [ j ] , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT +" +E847,"import java . util . * ; class GFG { static class Node { int data ; Node left ; Node right ; Node ( int value ) { data = value ; left = null ; right = null ; } } ; static void specific_level_order_traversal ( Node root ) { Queue < Node > q = new LinkedList < > ( ) ; Stack < Vector < Integer > > s = new Stack < Vector < Integer > > ( ) ; q . add ( root ) ; int sz ; while ( q . size ( ) > 0 ) { Vector < Integer > v = new Vector < Integer > ( ) ; sz = q . size ( ) ; for ( int i = 0 ; i < sz ; ++ i ) { Node temp = q . peek ( ) ; q . remove ( ) ; v . add ( temp . data ) ; if ( temp . left != null ) q . add ( temp . left ) ; if ( temp . right != null ) q . add ( temp . right ) ; } s . push ( v ) ; } while ( s . size ( ) > 0 ) { Vector < Integer > v = s . peek ( ) ; s . pop ( ) ; for ( int i = 0 , j = v . size ( ) - 1 ; i < j ; ++ i ) { System . out . print ( v . get ( i ) + "" ▁ "" + v . get ( j ) + "" ▁ "" ) ; j -- ; } } System . out . println ( root . data ) ; } public static void main ( String args [ ] ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; System . out . println ( "" Specific ▁ Level ▁ Order ▁ traversal "" + "" ▁ of ▁ binary ▁ tree ▁ is "" ) ; specific_level_order_traversal ( root ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def specific_level_order_traversal ( root ) : NEW_LINE INDENT q = [ ] NEW_LINE s = [ ] NEW_LINE q . append ( root ) NEW_LINE sz = 0 NEW_LINE while ( len ( q ) > 0 ) : NEW_LINE INDENT v = [ ] NEW_LINE sz = len ( q ) NEW_LINE i = 0 NEW_LINE while ( i < sz ) : NEW_LINE INDENT temp = q [ 0 ] NEW_LINE q . pop ( 0 ) NEW_LINE v . append ( temp . data ) NEW_LINE if ( temp . left != None ) : NEW_LINE INDENT q . append ( temp . left ) NEW_LINE DEDENT if ( temp . right != None ) : NEW_LINE INDENT q . append ( temp . right ) NEW_LINE DEDENT i = i + 1 NEW_LINE DEDENT s . append ( v ) NEW_LINE DEDENT while ( len ( s ) > 0 ) : NEW_LINE INDENT v = s [ - 1 ] NEW_LINE s . pop ( ) NEW_LINE i = 0 NEW_LINE j = len ( v ) - 1 NEW_LINE while ( i < j ) : NEW_LINE INDENT print ( v [ i ] , "" ▁ "" , v [ j ] , end = "" ▁ "" ) NEW_LINE j = j - 1 NEW_LINE i = i + 1 NEW_LINE DEDENT DEDENT print ( root . data ) NEW_LINE DEDENT root = Node ( 1 ) NEW_LINE root . left = Node ( 2 ) NEW_LINE root . right = Node ( 3 ) NEW_LINE print ( "" Specific ▁ Level ▁ Order ▁ traversal ▁ of ▁ binary ▁ tree ▁ is "" ) NEW_LINE specific_level_order_traversal ( root ) NEW_LINE +" +E848,"class GFG { static int sum ( int h ) { return ( int ) Math . pow ( 2 , h - 1 ) ; } public static void main ( String [ ] args ) { int L = 3 ; System . out . println ( sum ( L ) ) ; } } +","def summ ( h ) : NEW_LINE INDENT return pow ( 2 , h - 1 ) NEW_LINE DEDENT L = 3 NEW_LINE print ( summ ( L ) ) NEW_LINE +" +E849,"import java . io . * ; class GFG { public static int countDivisors ( int N , int a , int b ) { int count1 = N / a ; int count2 = N / b ; int count3 = ( N / ( a * b ) ) ; return count1 + count2 - count3 ; } public static void main ( String [ ] args ) { int N = 1000 , a = 3 , b = 4 ; System . out . println ( countDivisors ( N , a , b ) ) ; } } +","def countDivisors ( N , a , b ) : NEW_LINE INDENT count1 = N // a NEW_LINE count2 = N // b NEW_LINE count3 = ( N // ( a * b ) ) NEW_LINE return count1 + count2 - count3 NEW_LINE DEDENT N = 1000 NEW_LINE a = 3 NEW_LINE b = 4 NEW_LINE print ( countDivisors ( N , a , b ) ) NEW_LINE +" +E850,"import java . io . * ; class GFG { static int number_cake ( int n ) { return ( n * n * n + 5 * n + 6 ) / 6 ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . println ( number_cake ( n ) ) ; n = 8 ; System . out . println ( number_cake ( n ) ) ; n = 25 ; System . out . println ( number_cake ( n ) ) ; } } +","def number_cake ( n ) : NEW_LINE INDENT return ( n * n * n + 5 * n + 6 ) // 6 NEW_LINE DEDENT n = 2 NEW_LINE print ( number_cake ( n ) ) NEW_LINE n = 8 NEW_LINE print ( number_cake ( n ) ) NEW_LINE n = 25 NEW_LINE print ( number_cake ( n ) ) NEW_LINE +" +E851,"class GFG { static final int MAX = 100000000 ; static boolean prime [ ] = new boolean [ MAX + 1 ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) { prime [ i ] = false ; } } } } static void find_Prime ( int sum ) { for ( int i = sum / 2 ; i > 1 ; i -- ) { if ( prime [ i ] && prime [ sum - i ] ) { System . out . println ( i + "" ▁ "" + ( sum - i ) ) ; return ; } } System . out . println ( "" Cannot ▁ be ▁ represented ▁ as ▁ sum ▁ of ▁ two ▁ primes "" ) ; } public static void main ( String [ ] args ) { SieveOfEratosthenes ( ) ; int sum = 1002 ; find_Prime ( sum ) ; } } +","from math import sqrt NEW_LINE def SieveOfEratosthenes ( ) : NEW_LINE INDENT MAX = 1000001 NEW_LINE prime = [ True for i in range ( MAX + 1 ) ] NEW_LINE prime [ 1 ] = False NEW_LINE for p in range ( 2 , int ( sqrt ( MAX ) ) + 1 , 1 ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * 2 , MAX + 1 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT return prime NEW_LINE DEDENT def find_Prime ( sum ) : NEW_LINE INDENT prime = SieveOfEratosthenes ( ) NEW_LINE i = int ( sum / 2 ) NEW_LINE while ( i > 1 ) : NEW_LINE INDENT if ( prime [ i ] and prime [ sum - i ] ) : NEW_LINE INDENT print ( i , ( sum - i ) ) NEW_LINE return NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT print ( "" Cannot ▁ be ▁ represented ▁ as ▁ sum "" , "" of ▁ two ▁ primes "" ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT sum = 1002 NEW_LINE find_Prime ( sum ) NEW_LINE DEDENT +" +E852,"import java . io . * ; class GFG { static void generateNumbers ( int factor [ ] , int n , int k ) { int next [ ] = new int [ k ] ; int output = 0 ; for ( int i = 0 ; i < n ; ) { int toincrement = 0 ; for ( int j = 0 ; j < k ; j ++ ) if ( next [ j ] < next [ toincrement ] ) toincrement = j ; if ( output != next [ toincrement ] ) { output = next [ toincrement ] ; System . out . print ( next [ toincrement ] + "" ▁ "" ) ; i ++ ; } next [ toincrement ] += factor [ toincrement ] ; } } public static void main ( String [ ] args ) { int factor [ ] = { 3 , 5 , 7 } ; int n = 10 ; int k = factor . length ; generateNumbers ( factor , n , k ) ; } } +","def generateNumbers ( factor , n , k ) : NEW_LINE INDENT next = [ 0 ] * k ; NEW_LINE output = 0 ; NEW_LINE i = 0 ; NEW_LINE while ( i < n ) : NEW_LINE INDENT toincrement = 0 ; NEW_LINE for j in range ( k ) : NEW_LINE INDENT if ( next [ j ] < next [ toincrement ] ) : NEW_LINE INDENT toincrement = j ; NEW_LINE DEDENT DEDENT if ( output != next [ toincrement ] ) : NEW_LINE INDENT output = next [ toincrement ] ; NEW_LINE print ( next [ toincrement ] , end = "" ▁ "" ) ; NEW_LINE i += 1 ; NEW_LINE DEDENT next [ toincrement ] += factor [ toincrement ] ; NEW_LINE DEDENT DEDENT factor = [ 3 , 5 , 7 ] ; NEW_LINE n = 10 ; NEW_LINE k = len ( factor ) ; NEW_LINE generateNumbers ( factor , n , k ) ; NEW_LINE +" +E853,"import java . util . * ; class GFG { static int lengthOfSmallestSubsequence ( int K , int [ ] v ) { Queue < Integer > pq = new PriorityQueue < Integer > ( Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < v . length ; i ++ ) { pq . add ( v [ i ] ) ; } int sum = 0 , count = 0 ; while ( ! pq . isEmpty ( ) && sum < K ) { sum += pq . peek ( ) ; pq . remove ( ) ; count ++ ; } if ( sum < K ) { return - 1 ; } return count ; } public static void main ( String [ ] args ) { int [ ] v = { 2 , 3 , 1 , 5 , 6 , 3 , 7 , 9 , 14 , 10 , 2 , 5 } ; int K = 35 ; System . out . print ( lengthOfSmallestSubsequence ( K , v ) ) ; } } +","def lengthOfSmallestSubsequence ( K , v ) : NEW_LINE INDENT pq = [ ] NEW_LINE for i in v : NEW_LINE INDENT pq . append ( i ) NEW_LINE DEDENT pq . sort ( ) NEW_LINE sum = 0 NEW_LINE count = 0 NEW_LINE while ( len ( pq ) > 0 and sum < K ) : NEW_LINE INDENT sum += pq [ - 1 ] NEW_LINE del pq [ - 1 ] NEW_LINE count += 1 NEW_LINE DEDENT if ( sum < K ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return count NEW_LINE DEDENT v = [ 2 , 3 , 1 , 5 , 6 , 3 , 7 , 9 , 14 , 10 , 2 , 5 ] NEW_LINE K = 35 NEW_LINE print ( lengthOfSmallestSubsequence ( K , v ) ) NEW_LINE +" +E854,"import java . io . * ; class GFG { static int search ( int arr [ ] , int n , int x ) { int i = 0 ; while ( i < n ) { if ( arr [ i ] == x ) return i ; i = i + Math . abs ( arr [ i ] - x ) ; } System . out . println ( "" number ▁ is ▁ not "" + "" ▁ present ! "" ) ; return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 7 , 6 , 7 , 6 , 5 , 4 , 3 , 2 , 3 , 4 , 3 } ; int n = arr . length ; int x = 3 ; System . out . println ( "" Element ▁ "" + x + "" ▁ is ▁ present ▁ at ▁ index ▁ "" + search ( arr , n , 3 ) ) ; } } +","def search ( arr , n , x ) : NEW_LINE INDENT i = 0 NEW_LINE while ( i < n ) : NEW_LINE INDENT if ( arr [ i ] == x ) : NEW_LINE INDENT return i NEW_LINE DEDENT i = i + abs ( arr [ i ] - x ) NEW_LINE DEDENT print ( "" number ▁ is ▁ not ▁ present ! "" ) NEW_LINE return - 1 NEW_LINE DEDENT arr = [ 8 , 7 , 6 , 7 , 6 , 5 , 4 , 3 , 2 , 3 , 4 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE x = 3 NEW_LINE print ( "" Element "" , x , "" ▁ is ▁ present ▁ at ▁ index ▁ "" , search ( arr , n , 3 ) ) NEW_LINE +" +E855,"import java . io . * ; class GFG { static boolean CheckArray ( int arr [ ] , int n ) { int prod = 1 ; for ( int i = 0 ; i < n ; ++ i ) prod *= arr [ i ] ; for ( int i = 0 ; i < n ; ++ i ) if ( arr [ i ] == prod / arr [ i ] ) return true ; return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 12 , 3 , 2 } ; int n = arr . length ; if ( CheckArray ( arr , n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","def CheckArray ( arr , n ) : NEW_LINE INDENT prod = 1 NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT prod *= arr [ i ] NEW_LINE DEDENT for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( arr [ i ] == prod / arr [ i ] ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 12 , 3 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE if ( CheckArray ( arr , n ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E856,"public class Main { static int minRemove ( int arr [ ] , int n ) { int LIS [ ] = new int [ n ] ; int len = 0 ; for ( int i = 0 ; i < n ; i ++ ) LIS [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ i ] > arr [ j ] && ( i - j ) <= ( arr [ i ] - arr [ j ] ) ) LIS [ i ] = Math . max ( LIS [ i ] , LIS [ j ] + 1 ) ; } len = Math . max ( len , LIS [ i ] ) ; } return n - len ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 6 , 5 , 4 } ; int n = arr . length ; System . out . println ( minRemove ( arr , n ) ) ; } } +","def minRemove ( arr , n ) : NEW_LINE INDENT LIS = [ 0 for i in range ( n ) ] NEW_LINE len = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT LIS [ i ] = 1 NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT if ( arr [ i ] > arr [ j ] and ( i - j ) <= ( arr [ i ] - arr [ j ] ) ) : NEW_LINE INDENT LIS [ i ] = max ( LIS [ i ] , LIS [ j ] + 1 ) NEW_LINE DEDENT DEDENT len = max ( len , LIS [ i ] ) NEW_LINE DEDENT return ( n - len ) NEW_LINE DEDENT arr = [ 1 , 2 , 6 , 5 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( minRemove ( arr , n ) ) NEW_LINE +" +E857,"class GFG { static int charVal ( String s , int i ) { if ( s . charAt ( i ) == '0' ) { return 0 ; } else if ( s . charAt ( i ) == '1' ) { return 1 ; } else { return 2 ; } } static int countMinimalReplacements ( String s , int i , int prev , int dp [ ] [ ] , int n ) { if ( i == n ) { return 0 ; } if ( dp [ i ] [ prev ] != - 1 ) { return dp [ i ] [ prev ] ; } int val = charVal ( s , i ) ; int ans = Integer . MAX_VALUE ; if ( val == prev ) { val = 0 ; for ( int cur = 0 ; cur <= 2 ; cur ++ ) { if ( cur == prev ) { continue ; } val = 1 + countMinimalReplacements ( s , i + 1 , cur , dp , n ) ; ans = Math . min ( ans , val ) ; } } else { ans = countMinimalReplacements ( s , i + 1 , val , dp , n ) ; } return dp [ i ] [ val ] = ans ; } public static void main ( String [ ] args ) { String s = ""201220211"" ; int n = s . length ( ) ; int dp [ ] [ ] = new int [ n ] [ 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } int val = charVal ( s , 0 ) ; System . out . println ( countMinimalReplacements ( s , 1 , val , dp , n ) ) ; } } +","import sys NEW_LINE def charVal ( s , i ) : NEW_LINE INDENT if ( s [ i ] == '0' ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif ( s [ i ] == '1' ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return 2 NEW_LINE DEDENT DEDENT def countMinimalReplacements ( s , i , prev , dp , n ) : NEW_LINE INDENT if ( i == n ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( dp [ i ] [ prev ] != - 1 ) : NEW_LINE INDENT return dp [ i ] [ prev ] NEW_LINE DEDENT val = charVal ( s , i ) NEW_LINE ans = sys . maxsize NEW_LINE if ( val == prev ) : NEW_LINE INDENT val = 0 NEW_LINE for cur in range ( 3 ) : NEW_LINE INDENT if ( cur == prev ) : NEW_LINE INDENT continue NEW_LINE DEDENT val = 1 + countMinimalReplacements ( s , i + 1 , cur , dp , n ) NEW_LINE ans = min ( ans , val ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans = countMinimalReplacements ( s , i + 1 , val , dp , n ) NEW_LINE DEDENT dp [ i ] [ val ] = ans NEW_LINE return dp [ i ] [ val ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = ""201220211"" NEW_LINE n = len ( s ) NEW_LINE dp = [ [ - 1 for i in range ( 3 ) ] for i in range ( n ) ] NEW_LINE val = charVal ( s , 0 ) NEW_LINE print ( countMinimalReplacements ( s , 1 , val , dp , n ) ) NEW_LINE DEDENT +" +E858,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static float discountPercentage ( float S , float M ) { float discount = M - S ; float disPercent = ( discount / M ) * 100 ; return disPercent ; } public static void main ( String args [ ] ) { int M , S ; M = 120 ; S = 100 ; System . out . printf ( "" % .2f "" , discountPercentage ( S , M ) ) ; System . out . println ( "" % "" ) ; M = 1000 ; S = 500 ; System . out . printf ( "" % .2f "" , discountPercentage ( S , M ) ) ; System . out . println ( "" % "" ) ; } } +","def discountPercentage ( S , M ) : NEW_LINE INDENT discount = M - S NEW_LINE disPercent = ( discount / M ) * 100 NEW_LINE return disPercent NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT M = 120 NEW_LINE S = 100 NEW_LINE print ( discountPercentage ( S , M ) , "" % "" ) NEW_LINE M = 1000 NEW_LINE S = 500 NEW_LINE print ( discountPercentage ( S , M ) , "" % "" ) NEW_LINE DEDENT +" +E859,"class GFG { static int sumOfSeries ( int n ) { return ( int ) ( 0.6172 * ( Math . pow ( 10 , n ) - 1 ) - 0.55 * n ) ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . println ( sumOfSeries ( n ) ) ; } } +","def sumOfSeries ( n ) : NEW_LINE INDENT return ( int ) ( 0.6172 * ( pow ( 10 , n ) - 1 ) - 0.55 * n ) NEW_LINE DEDENT n = 2 NEW_LINE print ( sumOfSeries ( n ) ) NEW_LINE +" +E860,"import java . io . * ; class GFG { static boolean Move ( int a , int x , int b ) { if ( ( ( ( b - a ) % x == 0 ) || ( ( b - a - 1 ) % x == 0 ) && a + 1 != b ) && b >= a ) return true ; return false ; } public static void main ( String [ ] args ) { int a = 3 , x = 2 , b = 7 ; if ( Move ( a , x , b ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def Move ( a , x , b ) : NEW_LINE INDENT if ( ( ( ( b - a ) % x == 0 ) or ( ( b - a - 1 ) % x == 0 ) and a + 1 != b ) and b >= a ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 3 NEW_LINE x = 2 NEW_LINE b = 7 NEW_LINE if ( Move ( a , x , b ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E861,"import java . io . * ; class GFG { static int No_Of_Pairs ( int N ) { int i = 1 ; while ( ( i * i * i ) + ( 2 * i * i ) + i <= N ) i ++ ; return ( i - 1 ) ; } static void print_pairs ( int pairs ) { int i = 1 , mul ; for ( i = 1 ; i <= pairs ; i ++ ) { mul = i * ( i + 1 ) ; System . out . println ( "" Pair ▁ no . ▁ "" + i + "" ▁ - - > ▁ ( "" + ( mul * i ) + "" , ▁ "" + mul * ( i + 1 ) + "" ) "" ) ; } } public static void main ( String [ ] args ) { int N = 500 , pairs , mul , i = 1 ; pairs = No_Of_Pairs ( N ) ; System . out . println ( "" No . ▁ of ▁ pairs ▁ = ▁ "" + pairs ) ; print_pairs ( pairs ) ; } } +","def No_Of_Pairs ( N ) : NEW_LINE INDENT i = 1 ; NEW_LINE while ( ( i * i * i ) + ( 2 * i * i ) + i <= N ) : NEW_LINE INDENT i += 1 ; NEW_LINE DEDENT return ( i - 1 ) ; NEW_LINE DEDENT def print_pairs ( pairs ) : NEW_LINE INDENT i = 1 ; NEW_LINE mul = 0 ; NEW_LINE for i in range ( 1 , pairs + 1 ) : NEW_LINE INDENT mul = i * ( i + 1 ) ; NEW_LINE print ( "" Pair ▁ no . "" , i , "" ▁ - - > ▁ ( "" , ( mul * i ) , "" , ▁ "" , mul * ( i + 1 ) , "" ) "" ) ; NEW_LINE DEDENT DEDENT N = 500 ; NEW_LINE i = 1 ; NEW_LINE pairs = No_Of_Pairs ( N ) ; NEW_LINE print ( "" No . ▁ of ▁ pairs ▁ = ▁ "" , pairs ) ; NEW_LINE print_pairs ( pairs ) ; NEW_LINE +" +E862,"class GFG { static int power ( int x , int a ) { int res = 1 ; while ( a > 0 ) { if ( ( a & 1 ) > 0 ) res = res * x ; x = x * x ; a >>= 1 ; } return res ; } static int breakInteger ( int N ) { if ( N == 2 ) return 1 ; if ( N == 3 ) return 2 ; int maxProduct = - 1 ; switch ( N % 3 ) { case 0 : maxProduct = power ( 3 , N / 3 ) ; break ; case 1 : maxProduct = 2 * 2 * power ( 3 , ( N / 3 ) - 1 ) ; break ; case 2 : maxProduct = 2 * power ( 3 , N / 3 ) ; break ; } return maxProduct ; } public static void main ( String [ ] args ) { int maxProduct = breakInteger ( 10 ) ; System . out . println ( maxProduct ) ; } } +","def power ( x , a ) : NEW_LINE INDENT res = 1 ; NEW_LINE while ( a ) : NEW_LINE INDENT if ( a & 1 ) : NEW_LINE INDENT res = res * x ; NEW_LINE DEDENT x = x * x ; NEW_LINE a >>= 1 ; NEW_LINE DEDENT return res ; NEW_LINE DEDENT def breakInteger ( N ) : NEW_LINE INDENT if ( N == 2 ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT if ( N == 3 ) : NEW_LINE INDENT return 2 ; NEW_LINE DEDENT maxProduct = 0 ; NEW_LINE if ( N % 3 == 0 ) : NEW_LINE INDENT maxProduct = power ( 3 , int ( N / 3 ) ) ; NEW_LINE return maxProduct ; NEW_LINE DEDENT elif ( N % 3 == 1 ) : NEW_LINE INDENT maxProduct = 2 * 2 * power ( 3 , int ( N / 3 ) - 1 ) ; NEW_LINE return maxProduct ; NEW_LINE DEDENT elif ( N % 3 == 2 ) : NEW_LINE INDENT maxProduct = 2 * power ( 3 , int ( N / 3 ) ) ; NEW_LINE return maxProduct ; NEW_LINE DEDENT DEDENT maxProduct = breakInteger ( 10 ) ; NEW_LINE print ( maxProduct ) ; NEW_LINE +" +E863,"import java . io . * ; class GFG { static void printTrib ( int n ) { int dp [ ] = new int [ n ] ; dp [ 0 ] = dp [ 1 ] = 0 ; dp [ 2 ] = 1 ; for ( int i = 3 ; i < n ; i ++ ) dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] + dp [ i - 3 ] ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( dp [ i ] + "" ▁ "" ) ; } public static void main ( String args [ ] ) { int n = 10 ; printTrib ( n ) ; } } +","def printTrib ( n ) : NEW_LINE INDENT dp = [ 0 ] * n NEW_LINE dp [ 0 ] = dp [ 1 ] = 0 ; NEW_LINE dp [ 2 ] = 1 ; NEW_LINE for i in range ( 3 , n ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] + dp [ i - 3 ] ; NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT print ( dp [ i ] , "" ▁ "" , end = "" "" ) NEW_LINE DEDENT DEDENT n = 10 NEW_LINE printTrib ( n ) NEW_LINE +" +E864,"import java . io . * ; class GFG { static int findCount ( int d ) { return 9 * ( ( int ) ( Math . pow ( 10 , d - 1 ) ) - ( int ) ( Math . pow ( 9 , d - 1 ) ) ) ; } public static void main ( String args [ ] ) { int d = 1 ; System . out . println ( findCount ( d ) ) ; d = 2 ; System . out . println ( findCount ( d ) ) ; d = 4 ; System . out . println ( findCount ( d ) ) ; } } +","import math NEW_LINE def findCount ( d ) : NEW_LINE INDENT return 9 * ( ( int ) ( math . pow ( 10 , d - 1 ) ) - ( int ) ( math . pow ( 9 , d - 1 ) ) ) ; NEW_LINE DEDENT d = 1 NEW_LINE print ( findCount ( d ) ) NEW_LINE d = 2 NEW_LINE print ( findCount ( d ) ) NEW_LINE d = 4 NEW_LINE print ( findCount ( d ) ) NEW_LINE +" +E865,"class GFG { static float Conversion ( float n ) { return ( n - 32.0f ) * 5.0f / 9.0f ; } public static void main ( String [ ] args ) { float n = 40 ; System . out . println ( Conversion ( n ) ) ; } } +","def Conversion ( n ) : NEW_LINE INDENT return ( n - 32.0 ) * 5.0 / 9.0 NEW_LINE DEDENT n = 40 NEW_LINE x = Conversion ( n ) NEW_LINE print ( x ) NEW_LINE +" +E866,"public class PalinPath { public static boolean isPalin ( String str ) { int len = str . length ( ) / 2 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( str . length ( ) - i - 1 ) ) return false ; } return true ; } public static void palindromicPath ( String str , char a [ ] [ ] , int i , int j , int m , int n ) { if ( j < m - 1 || i < n - 1 ) { if ( i < n - 1 ) palindromicPath ( str + a [ i ] [ j ] , a , i + 1 , j , m , n ) ; if ( j < m - 1 ) palindromicPath ( str + a [ i ] [ j ] , a , i , j + 1 , m , n ) ; } else { str = str + a [ n - 1 ] [ m - 1 ] ; if ( isPalin ( str ) ) System . out . println ( str ) ; } } public static void main ( String args [ ] ) { char arr [ ] [ ] = { { ' a ' , ' a ' , ' a ' , ' b ' } , { ' b ' , ' a ' , ' a ' , ' a ' } , { ' a ' , ' b ' , ' b ' , ' a ' } } ; String str = "" "" ; palindromicPath ( str , arr , 0 , 0 , 4 , 3 ) ; } } +","def isPalin ( str ) : NEW_LINE INDENT l = len ( str ) // 2 NEW_LINE for i in range ( l ) : NEW_LINE INDENT if ( str [ i ] != str [ len ( str ) - i - 1 ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def palindromicPath ( str , a , i , j , m , n ) : NEW_LINE INDENT if ( j < m - 1 or i < n - 1 ) : NEW_LINE INDENT if ( i < n - 1 ) : NEW_LINE INDENT palindromicPath ( str + a [ i ] [ j ] , a , i + 1 , j , m , n ) NEW_LINE DEDENT if ( j < m - 1 ) : NEW_LINE INDENT palindromicPath ( str + a [ i ] [ j ] , a , i , j + 1 , m , n ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT str = str + a [ n - 1 ] [ m - 1 ] NEW_LINE if isPalin ( str ) : NEW_LINE INDENT print ( str ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ [ ' a ' , ' a ' , ' a ' , ' b ' ] , [ ' b ' , ' a ' , ' a ' , ' a ' ] , [ ' a ' , ' b ' , ' b ' , ' a ' ] ] NEW_LINE str = "" "" NEW_LINE palindromicPath ( str , arr , 0 , 0 , 4 , 3 ) NEW_LINE DEDENT +" +E867,"import java . util . * ; class GFG { static int max_element ( int a [ ] ) { int m = a [ 0 ] ; for ( int i = 0 ; i < a . length ; i ++ ) m = Math . max ( a [ i ] , m ) ; return m ; } static boolean checkDivisors ( int a [ ] , int n ) { int X = max_element ( a ) ; Vector < Integer > b = new Vector < Integer > ( ) ; for ( int i = 1 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { b . add ( i ) ; if ( X / i != i ) b . add ( X / i ) ; } } if ( b . size ( ) != n ) return false ; Arrays . sort ( a ) ; Collections . sort ( b ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( b . get ( i ) != a [ i ] ) return false ; } return true ; } public static void main ( String args [ ] ) { int arr [ ] = { 8 , 1 , 2 , 12 , 48 , 6 , 4 , 24 , 16 , 3 } ; int N = arr . length ; if ( checkDivisors ( arr , N ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","from math import sqrt NEW_LINE def checkDivisors ( a , n ) : NEW_LINE INDENT X = max ( a ) NEW_LINE b = [ ] NEW_LINE for i in range ( 1 , int ( sqrt ( X ) ) + 1 ) : NEW_LINE INDENT if ( X % i == 0 ) : NEW_LINE INDENT b . append ( i ) NEW_LINE if ( X // i != i ) : NEW_LINE INDENT b . append ( X // i ) NEW_LINE DEDENT DEDENT DEDENT if ( len ( b ) != n ) : NEW_LINE INDENT return False NEW_LINE DEDENT a . sort ( reverse = False ) NEW_LINE b . sort ( reverse = False ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( b [ i ] != a [ i ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 8 , 1 , 2 , 12 , 48 , 6 , 4 , 24 , 16 , 3 ] NEW_LINE N = len ( arr ) NEW_LINE if ( checkDivisors ( arr , N ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E868,"import java . io . * ; import java . util . * ; class GFG { static void printAllAPTriplets ( int [ ] arr , int n ) { ArrayList < Integer > s = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int diff = arr [ j ] - arr [ i ] ; boolean exists = s . contains ( arr [ i ] - diff ) ; if ( exists ) System . out . println ( arr [ i ] - diff + "" ▁ "" + arr [ i ] + "" ▁ "" + arr [ j ] ) ; } s . add ( arr [ i ] ) ; } } public static void main ( String args [ ] ) { int [ ] arr = { 2 , 6 , 9 , 12 , 17 , 22 , 31 , 32 , 35 , 42 } ; int n = arr . length ; printAllAPTriplets ( arr , n ) ; } } +","def printAllAPTriplets ( arr , n ) : NEW_LINE INDENT s = [ ] ; NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT diff = arr [ j ] - arr [ i ] ; NEW_LINE if ( ( arr [ i ] - diff ) in arr ) : NEW_LINE INDENT print ( "" { } ▁ { } ▁ { } "" . format ( ( arr [ i ] - diff ) , arr [ i ] , arr [ j ] ) , end = "" \n "" ) ; NEW_LINE DEDENT DEDENT DEDENT s . append ( arr [ i ] ) ; NEW_LINE DEDENT arr = [ 2 , 6 , 9 , 12 , 17 , 22 , 31 , 32 , 35 , 42 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE printAllAPTriplets ( arr , n ) ; NEW_LINE +" +E869,"import java . util . * ; class GFG { static boolean isPowerOfTwo ( int x ) { if ( x == 0 ) return false ; if ( ( x & ( x - 1 ) ) == 0 ) return true ; else return false ; } static int countNum ( int a [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPowerOfTwo ( a [ i ] ) || isPowerOfTwo ( a [ i ] + 1 ) ) count ++ ; } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 6 , 9 , 3 , 1 } ; int n = arr . length ; System . out . println ( countNum ( arr , n ) ) ; } } +","def isPowerOfTwo ( x ) : NEW_LINE INDENT if ( x == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( ( x & ( x - 1 ) ) == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT def countNum ( a , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( isPowerOfTwo ( a [ i ] ) or isPowerOfTwo ( a [ i ] + 1 ) ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 5 , 6 , 9 , 3 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countNum ( arr , n ) ) NEW_LINE DEDENT +" +E870,"class GFG { static float pi = 3.14159f ; static float volume ( float r ) { float vol ; vol = ( ( float ) 4 / ( float ) 3 ) * ( pi * r * r * r ) ; return vol ; } static float surface_area ( float r ) { float sur_ar ; sur_ar = 4 * pi * r * r ; return sur_ar ; } public static void main ( String [ ] args ) { float radius = 12 ; float vol , sur_area ; vol = volume ( radius ) ; sur_area = surface_area ( radius ) ; System . out . println ( "" Volume ▁ Of ▁ Sphere ▁ : "" + vol ) ; System . out . println ( "" Surface ▁ Area ▁ Of ▁ Sphere ▁ : "" + sur_area ) ; } } +","import math NEW_LINE pi = math . pi NEW_LINE def volume ( r ) : NEW_LINE INDENT vol = ( 4 / 3 ) * pi * r * r * r NEW_LINE return vol NEW_LINE DEDENT def surfacearea ( r ) : NEW_LINE INDENT sur_ar = 4 * pi * r * r NEW_LINE return sur_ar NEW_LINE DEDENT radius = float ( 12 ) NEW_LINE print ( "" Volume ▁ Of ▁ Sphere ▁ : ▁ "" , volume ( radius ) ) NEW_LINE print ( "" Surface ▁ Area ▁ Of ▁ Sphere ▁ : ▁ "" , surfacearea ( radius ) ) NEW_LINE +" +E871,"public class Test { public static void main ( String [ ] args ) { System . out . println ( isPower ( 10 , 1 ) ? "" True "" : "" False "" ) ; System . out . println ( isPower ( 1 , 20 ) ? "" True "" : "" False "" ) ; System . out . println ( isPower ( 2 , 128 ) ? "" True "" : "" False "" ) ; System . out . println ( isPower ( 2 , 30 ) ? "" True "" : "" False "" ) ; } public static boolean isPower ( int x , int y ) { if ( x == 1 ) return ( y == 1 ) ; int pow = 1 ; while ( pow < y ) pow = pow * x ; return ( pow == y ) ; } } +","def isPower ( x , y ) : NEW_LINE INDENT if ( x == 1 ) : NEW_LINE INDENT return ( y == 1 ) NEW_LINE DEDENT pow = 1 NEW_LINE while ( pow < y ) : NEW_LINE INDENT pow = pow * x NEW_LINE DEDENT return ( pow == y ) NEW_LINE DEDENT if ( isPower ( 10 , 1 ) ) : print ( "" True "" ) NEW_LINE else : print ( "" False "" ) NEW_LINE if ( isPower ( 1 , 20 ) ) : print ( "" True "" ) NEW_LINE else : print ( "" False "" ) NEW_LINE if ( isPower ( 2 , 128 ) ) : print ( "" True "" ) NEW_LINE else : print ( "" False "" ) NEW_LINE if ( isPower ( 2 , 30 ) ) : print ( "" True "" ) NEW_LINE else : print ( "" False "" ) NEW_LINE +" +E872,"class GFG { static int getSum ( int [ ] BITree , int index ) { int sum = 0 ; while ( index > 0 ) { sum += BITree [ index ] ; index -= index & ( - index ) ; } return sum ; } static void updateBIT ( int [ ] BITree , int n , int index , int val ) { while ( index <= n ) { BITree [ index ] += val ; index += index & ( - index ) ; } } static int getInvCount ( int [ ] arr , int n ) { int invcount = 0 ; int maxElement = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( maxElement < arr [ i ] ) maxElement = arr [ i ] ; int [ ] BIT = new int [ maxElement + 1 ] ; for ( int i = 1 ; i <= maxElement ; i ++ ) BIT [ i ] = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { invcount += getSum ( BIT , arr [ i ] - 1 ) ; updateBIT ( BIT , maxElement , arr [ i ] , 1 ) ; } return invcount ; } public static void main ( String [ ] args ) { int [ ] arr = { 8 , 4 , 2 , 1 } ; int n = arr . length ; System . out . println ( "" Number ▁ of ▁ inversions ▁ are ▁ : ▁ "" + getInvCount ( arr , n ) ) ; } } +","def getSum ( BITree , index ) : NEW_LINE INDENT sum = 0 NEW_LINE while ( index > 0 ) : NEW_LINE INDENT sum += BITree [ index ] NEW_LINE index -= index & ( - index ) NEW_LINE DEDENT return sum NEW_LINE DEDENT def updateBIT ( BITree , n , index , val ) : NEW_LINE INDENT while ( index <= n ) : NEW_LINE INDENT BITree [ index ] += val NEW_LINE index += index & ( - index ) NEW_LINE DEDENT DEDENT def getInvCount ( arr , n ) : NEW_LINE INDENT invcount = 0 NEW_LINE maxElement = max ( arr ) NEW_LINE BIT = [ 0 ] * ( maxElement + 1 ) NEW_LINE for i in range ( 1 , maxElement + 1 ) : NEW_LINE INDENT BIT [ i ] = 0 NEW_LINE DEDENT for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT invcount += getSum ( BIT , arr [ i ] - 1 ) NEW_LINE updateBIT ( BIT , maxElement , arr [ i ] , 1 ) NEW_LINE DEDENT return invcount NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 8 , 4 , 2 , 1 ] NEW_LINE n = 4 NEW_LINE print ( "" Inversion ▁ Count ▁ : ▁ "" , getInvCount ( arr , n ) ) NEW_LINE DEDENT +" +E873,"import java . lang . * ; class GFG { static int calSum ( int n ) { int a = 3 , b = 0 , c = 2 ; if ( n == 0 ) return 3 ; if ( n == 1 ) return 3 ; if ( n == 2 ) return 5 ; int sum = 5 ; while ( n > 2 ) { int d = a + b ; sum += d ; a = b ; b = c ; c = d ; n -- ; } return sum ; } public static void main ( String [ ] args ) { int n = 9 ; System . out . print ( calSum ( n ) ) ; } } +","def calSum ( n ) : NEW_LINE INDENT a = 3 NEW_LINE b = 0 NEW_LINE c = 2 NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return 3 NEW_LINE DEDENT if ( n == 1 ) : NEW_LINE INDENT return 3 NEW_LINE DEDENT if ( n == 2 ) : NEW_LINE INDENT return 5 NEW_LINE DEDENT sum = 5 NEW_LINE while ( n > 2 ) : NEW_LINE INDENT d = a + b NEW_LINE sum = sum + d NEW_LINE a = b NEW_LINE b = c NEW_LINE c = d NEW_LINE n = n - 1 NEW_LINE DEDENT return sum NEW_LINE DEDENT n = 9 NEW_LINE print ( calSum ( n ) ) NEW_LINE +" +E874,"class GFG { static int steps ( int cur , int x , int n ) { if ( x == 0 ) return Integer . MAX_VALUE ; if ( x > 0 ) return Math . abs ( ( n - cur ) / x ) ; else return Math . abs ( ( cur - 1 ) / x ) ; } static int countSteps ( int curx , int cury , int n , int m , int [ ] [ ] moves ) { int count = 0 ; int k = moves . length ; for ( int i = 0 ; i < k ; i ++ ) { int x = moves [ i ] [ 0 ] ; int y = moves [ i ] [ 1 ] ; int stepct = Math . min ( steps ( curx , x , n ) , steps ( cury , y , m ) ) ; count += stepct ; curx += stepct * x ; cury += stepct * y ; } return count ; } public static void main ( String [ ] args ) { int n = 4 , m = 5 , x = 1 , y = 1 ; int [ ] [ ] moves = { { 1 , 1 } , { 1 , 1 } , { 0 , - 2 } } ; System . out . print ( countSteps ( x , y , n , m , moves ) ) ; } } +","def steps ( cur , x , n ) : NEW_LINE INDENT if x == 0 : NEW_LINE INDENT return float ( ' inf ' ) NEW_LINE DEDENT elif x > 0 : NEW_LINE INDENT return abs ( ( n - cur ) // x ) NEW_LINE DEDENT else : NEW_LINE INDENT return abs ( int ( ( cur - 1 ) / x ) ) NEW_LINE DEDENT DEDENT def countSteps ( curx , cury , n , m , moves ) : NEW_LINE INDENT count = 0 NEW_LINE k = len ( moves ) NEW_LINE for i in range ( 0 , k ) : NEW_LINE INDENT x = moves [ i ] [ 0 ] NEW_LINE y = moves [ i ] [ 1 ] NEW_LINE stepct = min ( steps ( curx , x , n ) , steps ( cury , y , m ) ) NEW_LINE count += stepct NEW_LINE curx += stepct * x NEW_LINE cury += stepct * y NEW_LINE DEDENT return count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n , m , x , y = 4 , 5 , 1 , 1 NEW_LINE moves = [ [ 1 , 1 ] , [ 1 , 1 ] , [ 0 , - 2 ] ] NEW_LINE print ( countSteps ( x , y , n , m , moves ) ) NEW_LINE DEDENT +" +E875,"class GFG { static int SUM ( int n , int m ) { if ( m == 1 ) return ( n * ( n + 1 ) / 2 ) ; int sum = SUM ( n , m - 1 ) ; return ( sum * ( sum + 1 ) / 2 ) ; } public static void main ( String [ ] args ) { int n = 5 ; int m = 3 ; System . out . println ( "" SUM ( "" + n + "" , ▁ "" + m + "" ) : ▁ "" + SUM ( n , m ) ) ; } } +","def SUM ( n , m ) : NEW_LINE INDENT if ( m == 1 ) : NEW_LINE INDENT return ( n * ( n + 1 ) / 2 ) NEW_LINE DEDENT sum = SUM ( n , m - 1 ) NEW_LINE return int ( sum * ( sum + 1 ) / 2 ) NEW_LINE DEDENT n = 5 NEW_LINE m = 3 NEW_LINE print ( "" SUM ( "" , n , "" , ▁ "" , m , "" ) : "" , SUM ( n , m ) ) NEW_LINE +" +E876,"import java . util . * ; class Initials { public static void printInitials ( String str ) { int len = str . length ( ) ; str = str . trim ( ) ; String t = "" "" ; for ( int i = 0 ; i < len ; i ++ ) { char ch = str . charAt ( i ) ; if ( ch != ' ▁ ' ) { t = t + ch ; } else { System . out . print ( Character . toUpperCase ( t . charAt ( 0 ) ) + "" . ▁ "" ) ; t = "" "" ; } } String temp = "" "" ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( j == 0 ) temp = temp + Character . toUpperCase ( t . charAt ( 0 ) ) ; else temp = temp + Character . toLowerCase ( t . charAt ( j ) ) ; } System . out . println ( temp ) ; } public static void main ( String [ ] args ) { String str = "" ishita ▁ bhuiya "" ; printInitials ( str ) ; } } +","def printInitials ( string : str ) : NEW_LINE INDENT length = len ( string ) NEW_LINE string . strip ( ) NEW_LINE t = "" "" NEW_LINE for i in range ( length ) : NEW_LINE INDENT ch = string [ i ] NEW_LINE if ch != ' ▁ ' : NEW_LINE INDENT t += ch NEW_LINE DEDENT else : NEW_LINE INDENT print ( t [ 0 ] . upper ( ) + "" . ▁ "" , end = "" "" ) NEW_LINE t = "" "" NEW_LINE DEDENT DEDENT temp = "" "" NEW_LINE for j in range ( len ( t ) ) : NEW_LINE INDENT if j == 0 : NEW_LINE INDENT temp += t [ 0 ] . upper ( ) NEW_LINE DEDENT else : NEW_LINE INDENT temp += t [ j ] . lower ( ) NEW_LINE DEDENT DEDENT print ( temp ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" ishita ▁ bhuiya "" NEW_LINE printInitials ( string ) NEW_LINE DEDENT +" +E877,"class IsDivisible { static boolean check ( String str ) { int n = str . length ( ) ; if ( n == 0 ) return false ; if ( n == 1 ) return ( ( str . charAt ( 0 ) - '0' ) % 8 == 0 ) ; if ( n == 2 ) return ( ( ( str . charAt ( n - 2 ) - '0' ) * 10 + ( str . charAt ( n - 1 ) - '0' ) ) % 8 == 0 ) ; int last = str . charAt ( n - 1 ) - '0' ; int second_last = str . charAt ( n - 2 ) - '0' ; int third_last = str . charAt ( n - 3 ) - '0' ; return ( ( third_last * 100 + second_last * 10 + last ) % 8 == 0 ) ; } public static void main ( String [ ] args ) { String str = ""76952"" ; if ( check ( str ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def check ( st ) : NEW_LINE INDENT n = len ( st ) NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( n == 1 ) : NEW_LINE INDENT return ( ( int ) ( st [ 0 ] ) % 8 == 0 ) NEW_LINE DEDENT if ( n == 2 ) : NEW_LINE INDENT return ( ( int ) ( st [ n - 2 ] ) * 10 + ( ( int ) ( str [ n - 1 ] ) % 8 == 0 ) ) NEW_LINE DEDENT last = ( int ) ( st [ n - 1 ] ) NEW_LINE second_last = ( int ) ( st [ n - 2 ] ) NEW_LINE third_last = ( int ) ( st [ n - 3 ] ) NEW_LINE return ( ( third_last * 100 + second_last * 10 + last ) % 8 == 0 ) NEW_LINE DEDENT st = ""76952"" NEW_LINE if ( check ( st ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No ▁ "" ) NEW_LINE DEDENT +" +E878,"import java . io . * ; class GfG { static Boolean check ( int n ) { int d = ( int ) Math . sqrt ( n ) ; if ( d * d == n ) return true ; return false ; } static int largestNonPerfectSquareNumber ( int a [ ] , int n ) { int maxi = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! check ( a [ i ] ) ) maxi = Math . max ( a [ i ] , maxi ) ; } return maxi ; } public static void main ( String [ ] args ) { int a [ ] = { 16 , 20 , 25 , 2 , 3 , 10 } ; int n = a . length ; System . out . println ( largestNonPerfectSquareNumber ( a , n ) ) ; } } +","import math NEW_LINE def check ( n ) : NEW_LINE INDENT d = int ( math . sqrt ( n ) ) NEW_LINE if ( d * d == n ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def largestNonPerfectSquareNumber ( a , n ) : NEW_LINE INDENT maxi = - 1 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( check ( a [ i ] ) == False ) : NEW_LINE INDENT maxi = max ( a [ i ] , maxi ) NEW_LINE DEDENT DEDENT return maxi NEW_LINE DEDENT a = [ 16 , 20 , 25 , 2 , 3 , 10 ] NEW_LINE n = len ( a ) NEW_LINE print ( largestNonPerfectSquareNumber ( a , n ) ) NEW_LINE +" +E879,"import java . io . * ; class GFG { static int findValueAtX ( int n ) { return ( n * n * n ) + n ; } public static void main ( String [ ] args ) { System . out . println ( findValueAtX ( 10 ) ) ; System . out . println ( findValueAtX ( 2 ) ) ; } } +","def findValueAtX ( n ) : NEW_LINE INDENT return ( n * n * n ) + n NEW_LINE DEDENT print ( findValueAtX ( 10 ) ) NEW_LINE print ( findValueAtX ( 2 ) ) NEW_LINE +" +E880,"public class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 || n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static boolean isThreeDisctFactors ( long n ) { int sq = ( int ) Math . sqrt ( n ) ; if ( 1L * sq * sq != n ) return false ; return isPrime ( sq ) ? true : false ; } public static void main ( String [ ] args ) { long num = 9 ; if ( isThreeDisctFactors ( num ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; num = 15 ; if ( isThreeDisctFactors ( num ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; num = 12397923568441L ; if ( isThreeDisctFactors ( num ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","from math import sqrt NEW_LINE def isPrime ( n ) : NEW_LINE INDENT if ( n <= 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( n <= 3 ) : NEW_LINE INDENT return True NEW_LINE DEDENT if ( n % 2 == 0 or n % 3 == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT k = int ( sqrt ( n ) ) + 1 NEW_LINE for i in range ( 5 , k , 6 ) : NEW_LINE INDENT if ( n % i == 0 or n % ( i + 2 ) == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def isThreeDisctFactors ( n ) : NEW_LINE INDENT sq = int ( sqrt ( n ) ) NEW_LINE if ( 1 * sq * sq != n ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( isPrime ( sq ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT num = 9 NEW_LINE if ( isThreeDisctFactors ( num ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT num = 15 NEW_LINE if ( isThreeDisctFactors ( num ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT num = 12397923568441 NEW_LINE if ( isThreeDisctFactors ( num ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E881,"import java . io . * ; class GFG { static int maxPartitions ( int arr [ ] , int n ) { int ans = 0 , max_so_far = 0 ; for ( int i = 0 ; i < n ; ++ i ) { max_so_far = Math . max ( max_so_far , arr [ i ] ) ; if ( max_so_far == i ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 0 , 2 , 3 , 4 } ; int n = arr . length ; System . out . println ( maxPartitions ( arr , n ) ) ; } } +","def maxPartitions ( arr , n ) : NEW_LINE INDENT ans = 0 ; max_so_far = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT max_so_far = max ( max_so_far , arr [ i ] ) NEW_LINE if ( max_so_far == i ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT arr = [ 1 , 0 , 2 , 3 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( maxPartitions ( arr , n ) ) NEW_LINE +" +E882,"class GFG { static void greaterK ( int n , int k ) { int [ ] p = new int [ String . valueOf ( n ) . length ( ) + 2 ] ; int index = 0 ; int x = n ; while ( x > 0 ) { p [ index ] = ( int ) ( x % k ) ; x /= k ; index ++ ; } int idx = 0 ; for ( int i = 0 ; i < p . length - 1 ; ++ i ) { if ( p [ i ] >= 2 ) { p [ i ] = 0 ; p [ i + 1 ] ++ ; for ( int j = idx ; j < i ; ++ j ) { p [ j ] = 0 ; } idx = i + 1 ; } if ( p [ i ] == k ) { p [ i ] = 0 ; p [ i + 1 ] ++ ; } } int j = p . length - 1 ; if ( p [ j ] >= 2 ) { p [ index ] = 1 ; index ++ ; } int ans = 0 ; for ( int i = p . length - 1 ; i >= 0 ; -- i ) { ans = ans * k + p [ i ] ; } System . out . print ( ans + "" \n "" ) ; } public static void main ( String [ ] args ) { int n = 29 , k = 7 ; greaterK ( n , k ) ; } } +","def greaterK ( n , k ) : NEW_LINE INDENT index = 0 NEW_LINE p = [ 0 for i in range ( n + 2 ) ] NEW_LINE x = n NEW_LINE while ( x > 0 ) : NEW_LINE INDENT p [ index ] = x % k NEW_LINE x //= k NEW_LINE index += 1 NEW_LINE DEDENT idx = 0 NEW_LINE for i in range ( 0 , len ( p ) - 1 , 1 ) : NEW_LINE INDENT if ( p [ i ] >= 2 ) : NEW_LINE INDENT p [ i ] = 0 NEW_LINE p [ i + 1 ] += 1 NEW_LINE for j in range ( idx , i , 1 ) : NEW_LINE INDENT p [ j ] = 0 NEW_LINE DEDENT idx = i + 1 NEW_LINE DEDENT if ( p [ i ] == k ) : NEW_LINE INDENT p [ i ] = 0 NEW_LINE p [ i + 1 ] += 1 NEW_LINE DEDENT DEDENT j = len ( p ) - 1 NEW_LINE if ( p [ j ] >= 2 ) : NEW_LINE INDENT p [ index ] = 1 NEW_LINE index += 1 NEW_LINE DEDENT ans = 0 NEW_LINE i = len ( p ) - 1 NEW_LINE while ( i >= 0 ) : NEW_LINE INDENT ans = ans * k + p [ i ] NEW_LINE i -= 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 29 NEW_LINE k = 7 NEW_LINE greaterK ( n , k ) NEW_LINE DEDENT +" +E883,"class GFG { static int longestPrefixSuffix ( String s ) { int n = s . length ( ) ; int lps [ ] = new int [ n ] ; lps [ 0 ] = 0 ; int len = 0 ; int i = 1 ; while ( i < n ) { if ( s . charAt ( i ) == s . charAt ( len ) ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } int res = lps [ n - 1 ] ; return ( res > n / 2 ) ? n / 2 : res ; } public static void main ( String [ ] args ) { String s = "" abcab "" ; System . out . println ( longestPrefixSuffix ( s ) ) ; } } +","def longestPrefixSuffix ( s ) : NEW_LINE INDENT n = len ( s ) NEW_LINE lps = [ 0 ] * n NEW_LINE l = 0 NEW_LINE i = 1 NEW_LINE while ( i < n ) : NEW_LINE INDENT if ( s [ i ] == s [ l ] ) : NEW_LINE INDENT l = l + 1 NEW_LINE lps [ i ] = l NEW_LINE i = i + 1 NEW_LINE DEDENT else : NEW_LINE INDENT if ( l != 0 ) : NEW_LINE INDENT l = lps [ l - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT lps [ i ] = 0 NEW_LINE i = i + 1 NEW_LINE DEDENT DEDENT DEDENT res = lps [ n - 1 ] NEW_LINE if ( res > n / 2 ) : NEW_LINE INDENT return n // 2 NEW_LINE DEDENT else : NEW_LINE INDENT return res NEW_LINE DEDENT DEDENT s = "" abcab "" NEW_LINE print ( longestPrefixSuffix ( s ) ) NEW_LINE +" +E884,"import java . io . * ; import java . util . * ; class GFG { static void printBracketNumber ( String exp , int n ) { int left_bnum = 1 ; Stack < Integer > right_bnum = new Stack < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( exp . charAt ( i ) == ' ( ' ) { System . out . print ( left_bnum + "" ▁ "" ) ; right_bnum . push ( left_bnum ) ; left_bnum ++ ; } else if ( exp . charAt ( i ) == ' ) ' ) { System . out . print ( right_bnum . peek ( ) + "" ▁ "" ) ; right_bnum . pop ( ) ; } } } public static void main ( String args [ ] ) { String exp = "" ( a + ( b * c ) ) + ( d / e ) "" ; int n = exp . length ( ) ; printBracketNumber ( exp , n ) ; } } +","def printBracketNumber ( exp , n ) : NEW_LINE INDENT left_bnum = 1 NEW_LINE right_bnum = list ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if exp [ i ] == ' ( ' : NEW_LINE INDENT print ( left_bnum , end = "" ▁ "" ) NEW_LINE right_bnum . append ( left_bnum ) NEW_LINE left_bnum += 1 NEW_LINE DEDENT elif exp [ i ] == ' ) ' : NEW_LINE INDENT print ( right_bnum [ - 1 ] , end = "" ▁ "" ) NEW_LINE right_bnum . pop ( ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT exp = "" ( a + ( b * c ) ) + ( d / e ) "" NEW_LINE n = len ( exp ) NEW_LINE printBracketNumber ( exp , n ) NEW_LINE DEDENT +" +E885,"import java . util . * ; class GFG { static int N = ( int ) 1E6 ; static boolean [ ] fourDiv = new boolean [ N + 1 ] ; static void fourDistinctFactors ( ) { boolean [ ] primeAll = new boolean [ N + 1 ] ; for ( int p = 2 ; p * p <= N ; p ++ ) { if ( primeAll [ p ] == false ) { for ( int i = p * 2 ; i <= N ; i += p ) primeAll [ i ] = true ; } } ArrayList < Integer > prime = new ArrayList < Integer > ( ) ; for ( int p = 2 ; p <= N ; p ++ ) if ( ! primeAll [ p ] ) prime . add ( p ) ; for ( int i = 0 ; i < prime . size ( ) ; ++ i ) { int p = prime . get ( i ) ; if ( 1L * p * p * p <= N ) fourDiv [ p * p * p ] = true ; for ( int j = i + 1 ; j < prime . size ( ) ; ++ j ) { int q = prime . get ( j ) ; if ( 1L * p * q > N ) break ; fourDiv [ p * q ] = true ; } } } public static void main ( String [ ] args ) { fourDistinctFactors ( ) ; int num = 10 ; if ( fourDiv [ num ] ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; num = 12 ; if ( fourDiv [ num ] ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","N = 1000001 ; NEW_LINE fourDiv = [ False ] * ( N + 1 ) ; NEW_LINE def fourDistinctFactors ( ) : NEW_LINE INDENT primeAll = [ True ] * ( N + 1 ) ; NEW_LINE p = 2 ; NEW_LINE while ( p * p <= N ) : NEW_LINE INDENT if ( primeAll [ p ] == True ) : NEW_LINE INDENT i = p * 2 ; NEW_LINE while ( i <= N ) : NEW_LINE INDENT primeAll [ i ] = False ; NEW_LINE i += p ; NEW_LINE DEDENT DEDENT p += 1 ; NEW_LINE DEDENT prime = [ ] ; NEW_LINE for p in range ( 2 , N + 1 ) : NEW_LINE INDENT if ( primeAll [ p ] ) : NEW_LINE INDENT prime . append ( p ) ; NEW_LINE DEDENT DEDENT for i in range ( len ( prime ) ) : NEW_LINE INDENT p = prime [ i ] ; NEW_LINE if ( 1 * p * p * p <= N ) : NEW_LINE INDENT fourDiv [ p * p * p ] = True ; NEW_LINE DEDENT for j in range ( i + 1 , len ( prime ) ) : NEW_LINE INDENT q = prime [ j ] ; NEW_LINE if ( 1 * p * q > N ) : NEW_LINE INDENT break ; NEW_LINE DEDENT fourDiv [ p * q ] = True ; NEW_LINE DEDENT DEDENT DEDENT fourDistinctFactors ( ) ; NEW_LINE num = 10 ; NEW_LINE if ( fourDiv [ num ] ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT num = 12 ; NEW_LINE if ( fourDiv [ num ] ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT +" +E886,"import java . io . * ; class GFG { static final int N = 3 ; static void scalarProductMat ( int mat [ ] [ ] , int k ) { for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) mat [ i ] [ j ] = mat [ i ] [ j ] * k ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int k = 4 ; scalarProductMat ( mat , k ) ; System . out . println ( "" Scalar ▁ Product ▁ Matrix ▁ is ▁ : ▁ "" ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) System . out . print ( mat [ i ] [ j ] + "" ▁ "" ) ; System . out . println ( ) ; } } } +","N = 3 NEW_LINE def scalarProductMat ( mat , k ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT mat [ i ] [ j ] = mat [ i ] [ j ] * k NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT mat = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] NEW_LINE k = 4 NEW_LINE scalarProductMat ( mat , k ) NEW_LINE print ( "" Scalar ▁ Product ▁ Matrix ▁ is ▁ : ▁ "" ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT +" +E887,"class GFG { public static void main ( String [ ] args ) { StringBuilder str = new StringBuilder ( "" geeksforgeeks "" ) ; str . reverse ( ) ; System . out . println ( str ) ; } } +","str = "" geeksforgeeks "" ; NEW_LINE str = "" "" . join ( reversed ( str ) ) NEW_LINE print ( str ) ; NEW_LINE +" +E888,"import java . util . * ; class GFG { public static int countDistinct ( int arr [ ] , int n ) { HashSet < Integer > hs = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { hs . add ( arr [ i ] ) ; } return hs . size ( ) ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { 6 , 10 , 5 , 4 , 9 , 120 , 4 , 6 , 10 } ; System . out . println ( countDistinct ( arr , arr . length ) ) ; } } +","def countDistinct ( arr , n ) : NEW_LINE INDENT s = set ( ) NEW_LINE res = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] not in s ) : NEW_LINE INDENT s . add ( arr [ i ] ) NEW_LINE res += 1 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT arr = [ 6 , 10 , 5 , 4 , 9 , 120 , 4 , 6 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countDistinct ( arr , n ) ) NEW_LINE +" +E889,"public class Test { static int x = 32 ; static String toggleCase ( char [ ] a ) { for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] ^= 32 ; } return new String ( a ) ; } public static void main ( String [ ] args ) { String str = "" CheRrY "" ; System . out . print ( "" Toggle ▁ case : ▁ "" ) ; str = toggleCase ( str . toCharArray ( ) ) ; System . out . println ( str ) ; System . out . print ( "" Original ▁ string : ▁ "" ) ; str = toggleCase ( str . toCharArray ( ) ) ; System . out . println ( str ) ; } } +","x = 32 ; NEW_LINE def toggleCase ( a ) : NEW_LINE INDENT for i in range ( len ( a ) ) : NEW_LINE INDENT a = a [ : i ] + chr ( ord ( a [ i ] ) ^ 32 ) + a [ i + 1 : ] ; NEW_LINE DEDENT return a ; NEW_LINE DEDENT str = "" CheRrY "" ; NEW_LINE print ( "" Toggle ▁ case : ▁ "" , end = "" "" ) ; NEW_LINE str = toggleCase ( str ) ; NEW_LINE print ( str ) ; NEW_LINE print ( "" Original ▁ string : ▁ "" , end = "" "" ) ; NEW_LINE str = toggleCase ( str ) ; NEW_LINE print ( str ) ; NEW_LINE +" +E890,"import java . util . * ; class GFG { static final int MAX = 1000000 ; static Vector < Integer > arr = new Vector < Integer > ( ) ; static boolean [ ] prime = new boolean [ MAX ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < MAX ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p < MAX ; p ++ ) if ( prime [ p ] ) arr . add ( p ) ; } static boolean isPrimorialPrime ( int n ) { if ( ! prime [ n ] ) return false ; long product = 1 ; int i = 0 ; while ( product < n ) { product = product * arr . get ( i ) ; if ( product + 1 == n || product - 1 == n ) return true ; i ++ ; } return false ; } public static void main ( String [ ] args ) { SieveOfEratosthenes ( ) ; int n = 31 ; if ( isPrimorialPrime ( n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","from math import sqrt NEW_LINE MAX = 100000 NEW_LINE prime = [ True ] * MAX NEW_LINE arr = [ ] NEW_LINE def SieveOfEratosthenes ( ) : NEW_LINE INDENT for p in range ( 2 , int ( sqrt ( MAX ) ) + 1 ) : NEW_LINE INDENT if prime [ p ] == True : NEW_LINE INDENT for i in range ( p * 2 , MAX , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT for p in range ( 2 , MAX ) : NEW_LINE INDENT if prime [ p ] : NEW_LINE INDENT arr . append ( p ) NEW_LINE DEDENT DEDENT DEDENT def isPrimorialPrime ( n ) : NEW_LINE INDENT if not prime [ n ] : NEW_LINE INDENT return False NEW_LINE DEDENT product , i = 1 , 0 NEW_LINE while product < n : NEW_LINE INDENT product *= arr [ i ] NEW_LINE if product + 1 == n or product - 1 == n : NEW_LINE INDENT return True NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT SieveOfEratosthenes ( ) NEW_LINE n = 31 NEW_LINE if ( isPrimorialPrime ( n ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E891,"class GFG { static int countNumbers ( int X , int Y , int N ) { int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( ( i % X == 0 ) && ( i % Y != 0 ) ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int X = 2 , Y = 3 , N = 10 ; System . out . println ( countNumbers ( X , Y , N ) ) ; } } +","def countNumbers ( X , Y , N ) : NEW_LINE INDENT count = 0 ; NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( ( i % X == 0 ) and ( i % Y != 0 ) ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT return count ; NEW_LINE DEDENT X = 2 ; NEW_LINE Y = 3 ; NEW_LINE N = 10 ; NEW_LINE print ( countNumbers ( X , Y , N ) ) ; NEW_LINE +" +E892,"import java . util . HashMap ; class geeks { public static long countSubseq ( int [ ] arr , int n ) { HashMap < Integer , Integer > um = new HashMap < > ( ) ; long count = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( um . get ( arr [ i ] ) != null ) { int a = um . get ( arr [ i ] ) ; um . put ( arr [ i ] , ++ a ) ; } else um . put ( arr [ i ] , 1 ) ; } for ( HashMap . Entry < Integer , Integer > entry : um . entrySet ( ) ) { count *= entry . getValue ( ) ; } return count ; } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 7 , 6 , 7 } ; int n = arr . length ; System . out . println ( "" Count ▁ = ▁ "" + countSubseq ( arr , n ) ) ; } } +","def countSubseq ( arr , n ) : NEW_LINE INDENT um = { i : 0 for i in range ( 8 ) } NEW_LINE count = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT um [ arr [ i ] ] += 1 NEW_LINE DEDENT for key , values in um . items ( ) : NEW_LINE INDENT if ( values > 0 ) : NEW_LINE INDENT count *= values NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 4 , 7 , 6 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Count ▁ = "" , countSubseq ( arr , n ) ) NEW_LINE DEDENT +" +E893,"class GFG { static boolean check ( long a , long b ) { long c = 0 ; while ( a != 0 ) { c = c + a % 10 ; a = a / 10 ; } return ( c == b ) ; } static long root ( long n ) { boolean found = false ; long mx = ( long ) 1E18 ; for ( long i = 0 ; i <= 90 ; i ++ ) { long s = i * i + 4 * n ; long sq = ( long ) Math . sqrt ( s ) ; if ( sq * sq == s && check ( ( sq - i ) / 2 , i ) ) { found = true ; mx = Math . min ( mx , ( sq - i ) / 2 ) ; } } if ( found ) return mx ; else return - 1 ; } public static void main ( String [ ] args ) { long n = 110 ; System . out . println ( root ( n ) ) ; } } +","import math NEW_LINE def check ( a , b ) : NEW_LINE INDENT c = 0 ; NEW_LINE while ( a != 0 ) : NEW_LINE INDENT c = c + a % 10 ; NEW_LINE a = int ( a / 10 ) ; NEW_LINE DEDENT return True if ( c == b ) else False ; NEW_LINE DEDENT def root ( n ) : NEW_LINE INDENT found = False ; NEW_LINE mx = 1000000000000000001 ; NEW_LINE for i in range ( 91 ) : NEW_LINE INDENT s = i * i + 4 * n ; NEW_LINE sq = int ( math . sqrt ( s ) ) ; NEW_LINE if ( sq * sq == s and check ( int ( ( sq - i ) / 2 ) , i ) ) : NEW_LINE INDENT found = True ; NEW_LINE mx = min ( mx , int ( ( sq - i ) / 2 ) ) ; NEW_LINE DEDENT DEDENT if ( found ) : NEW_LINE INDENT return mx ; NEW_LINE DEDENT else : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT DEDENT n = 110 ; NEW_LINE print ( root ( n ) ) ; NEW_LINE +" +E894,"import java . io . * ; import java . util . * ; class Fraction { int num , den ; Fraction ( int n , int d ) { num = n ; den = d ; } static Fraction maxFraction ( Fraction first , Fraction sec ) { int a = first . num ; int b = first . den ; int c = sec . num ; int d = sec . den ; int Y = a * d - b * c ; return ( Y > 0 ) ? first : sec ; } public static void main ( String [ ] args ) { Fraction first = new Fraction ( 3 , 2 ) ; Fraction sec = new Fraction ( 3 , 4 ) ; Fraction res = maxFraction ( first , sec ) ; System . out . println ( res . num + "" / "" + res . den ) ; } } +","def maxFraction ( first , sec ) : NEW_LINE INDENT a = first [ 0 ] ; b = first [ 1 ] NEW_LINE c = sec [ 0 ] ; d = sec [ 1 ] NEW_LINE Y = a * d - b * c NEW_LINE return first if Y else sec NEW_LINE DEDENT first = ( 3 , 2 ) NEW_LINE sec = ( 3 , 4 ) NEW_LINE res = maxFraction ( first , sec ) NEW_LINE print ( str ( res [ 0 ] ) + "" / "" + str ( res [ 1 ] ) ) NEW_LINE +" +E895,"class GFG { static void Permutation ( int n , int k ) { int [ ] p = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) p [ i ] = i ; for ( int i = 1 ; i < n - k ; i ++ ) p [ i + 1 ] = i ; p [ 1 ] = n - k ; for ( int i = 1 ; i <= n ; i ++ ) System . out . print ( p [ i ] + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int n = 5 , k = 2 ; Permutation ( n , k ) ; } } +","def Permutation ( n , k ) : NEW_LINE INDENT p = [ 0 for i in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT p [ i ] = i NEW_LINE DEDENT for i in range ( 1 , n - k ) : NEW_LINE INDENT p [ i + 1 ] = i NEW_LINE DEDENT p [ 1 ] = n - k NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT print ( p [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE k = 2 NEW_LINE Permutation ( n , k ) NEW_LINE DEDENT +" +E896,"import java . util . Arrays ; class GFG { static int reverse ( int x ) { int rev = 0 ; while ( x > 0 ) { rev = ( rev * 10 ) + x % 10 ; x = x / 10 ; } return rev ; } static void printEmirp ( int n ) { boolean prime [ ] = new boolean [ n + 1 ] ; Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { int rev = reverse ( p ) ; if ( p != rev && rev <= n && prime [ rev ] ) { System . out . print ( p + "" ▁ "" + rev + "" ▁ "" ) ; prime [ rev ] = false ; } } } } public static void main ( String [ ] args ) { int n = 100 ; printEmirp ( n ) ; } } +","def reverse ( x ) : NEW_LINE INDENT rev = 0 ; NEW_LINE while ( x > 0 ) : NEW_LINE INDENT rev = ( rev * 10 ) + x % 10 ; NEW_LINE x = int ( x / 10 ) ; NEW_LINE DEDENT return rev ; NEW_LINE DEDENT def printEmirp ( n ) : NEW_LINE INDENT prime = [ 1 ] * ( n + 1 ) ; NEW_LINE p = 2 ; NEW_LINE while ( p * p <= n ) : NEW_LINE INDENT if ( prime [ p ] == 1 ) : NEW_LINE INDENT for i in range ( p * 2 , n + 1 , p ) : NEW_LINE INDENT prime [ i ] = 0 ; NEW_LINE DEDENT DEDENT p += 1 ; NEW_LINE DEDENT for p in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( prime [ p ] == 1 ) : NEW_LINE INDENT rev = reverse ( p ) ; NEW_LINE if ( p != rev and rev <= n and prime [ rev ] == 1 ) : NEW_LINE INDENT print ( p , rev , end = "" ▁ "" ) ; NEW_LINE prime [ rev ] = 0 ; NEW_LINE DEDENT DEDENT DEDENT DEDENT n = 100 ; NEW_LINE printEmirp ( n ) ; NEW_LINE +" +E897,"import java . io . * ; import java . util . * ; class GFG { static int largest ( int [ ] arr , int n ) { Arrays . sort ( arr ) ; return arr [ n - 1 ] ; } static public void main ( String [ ] args ) { int [ ] arr = { 10 , 324 , 45 , 90 , 9808 } ; int n = arr . length ; System . out . println ( largest ( arr , n ) ) ; } } +","def largest ( arr , n ) : NEW_LINE INDENT return max ( arr ) NEW_LINE DEDENT arr = [ 10 , 324 , 45 , 90 , 9808 ] NEW_LINE n = len ( arr ) NEW_LINE print ( largest ( arr , n ) ) NEW_LINE +" +E898,"import java . util . * ; class GFG { static class Node { int data ; Node left , right ; } ; static int maxLevelProduct ( Node root ) { if ( root == null ) return 0 ; int result = root . data ; Queue < Node > q = new LinkedList < > ( ) ; q . add ( root ) ; while ( q . size ( ) > 0 ) { int count = q . size ( ) ; int product = 1 ; while ( count -- > 0 ) { Node temp = q . peek ( ) ; q . remove ( ) ; product = product * temp . data ; if ( temp . left != null ) q . add ( temp . left ) ; if ( temp . right != null ) q . add ( temp . right ) ; } result = Math . max ( product , result ) ; } return result ; } static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } public static void main ( String args [ ] ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . right = newNode ( 8 ) ; root . right . right . left = newNode ( 6 ) ; root . right . right . right = newNode ( 7 ) ; System . out . print ( "" Maximum ▁ level ▁ product ▁ is ▁ "" + maxLevelProduct ( root ) ) ; } } +","class newNode : NEW_LINE INDENT def __init__ ( self , key ) : NEW_LINE INDENT self . data = key NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def maxLevelProduct ( root ) : NEW_LINE INDENT if ( root == None ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT result = root . data NEW_LINE q = [ ] NEW_LINE q . append ( root ) NEW_LINE while ( len ( q ) ) : NEW_LINE INDENT count = len ( q ) NEW_LINE product = 1 NEW_LINE while ( count ) : NEW_LINE INDENT count -= 1 NEW_LINE temp = q [ 0 ] NEW_LINE q . pop ( 0 ) NEW_LINE product = product * temp . data NEW_LINE if ( temp . left != None ) : NEW_LINE INDENT q . append ( temp . left ) NEW_LINE DEDENT if ( temp . right != None ) : NEW_LINE INDENT q . append ( temp . right ) NEW_LINE DEDENT DEDENT result = max ( product , result ) NEW_LINE DEDENT return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT root = newNode ( 1 ) NEW_LINE root . left = newNode ( 2 ) NEW_LINE root . right = newNode ( 3 ) NEW_LINE root . left . left = newNode ( 4 ) NEW_LINE root . left . right = newNode ( 5 ) NEW_LINE root . right . right = newNode ( 8 ) NEW_LINE root . right . right . left = newNode ( 6 ) NEW_LINE root . right . right . right = newNode ( 7 ) NEW_LINE print ( "" Maximum ▁ level ▁ product ▁ is "" , maxLevelProduct ( root ) ) NEW_LINE DEDENT +" +E899,"import java . util . * ; class GFG { static int fact ( int n ) { int fact = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact *= i ; return fact ; } static int countStrings ( String str , int n ) { Set < Character > distinct_char = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { distinct_char . add ( str . charAt ( i ) ) ; } return fact ( distinct_char . size ( ) ) ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int n = str . length ( ) ; System . out . println ( countStrings ( str , n ) ) ; } } +","def fact ( n ) : NEW_LINE INDENT fact = 1 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT fact *= i ; NEW_LINE DEDENT return fact ; NEW_LINE DEDENT def countStrings ( string , n ) : NEW_LINE INDENT distinct_char = set ( ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT distinct_char . add ( string [ i ] ) ; NEW_LINE DEDENT return fact ( len ( distinct_char ) ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" geeksforgeeks "" ; NEW_LINE n = len ( string ) ; NEW_LINE print ( countStrings ( string , n ) ) ; NEW_LINE DEDENT +" +E900,"import java . util . * ; class GFG { static void printMaxValPair ( Vector < Long > v , int n ) { Collections . sort ( v ) ; long N = v . get ( ( int ) n - 1 ) ; if ( N % 2 == 1 ) { long first_maxima = N / 2 ; long second_maxima = first_maxima + 1 ; long ans1 = ( long ) 3e18 , ans2 = ( long ) 3e18 ; long from_left = - 1 , from_right = - 1 ; long from = - 1 ; for ( long i = 0 ; i < n ; ++ i ) { if ( v . get ( ( int ) i ) > first_maxima ) { from = i ; break ; } else { long diff = first_maxima - v . get ( ( int ) i ) ; if ( diff < ans1 ) { ans1 = diff ; from_left = v . get ( ( int ) i ) ; } } } from_right = v . get ( ( int ) from ) ; long diff1 = first_maxima - from_left ; long diff2 = from_right - second_maxima ; if ( diff1 < diff2 ) System . out . println ( N + "" ▁ "" + from_left ) ; else System . out . println ( N + "" ▁ "" + from_right ) ; } else { long maxima = N / 2 ; long ans1 = ( int ) 3e18 ; long R = - 1 ; for ( long i = 0 ; i < n - 1 ; ++ i ) { long diff = Math . abs ( v . get ( ( int ) i ) - maxima ) ; if ( diff < ans1 ) { ans1 = diff ; R = v . get ( ( int ) i ) ; } } System . out . println ( N + "" ▁ "" + R ) ; } } public static void main ( String args [ ] ) { long arr [ ] = { 1 , 1 , 2 , 3 , 6 , 1 } ; Vector < Long > v = new Vector < Long > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) v . add ( arr [ i ] ) ; int n = v . size ( ) ; printMaxValPair ( v , n ) ; } } +","def printMaxValPair ( v , n ) : NEW_LINE INDENT v . sort ( ) NEW_LINE N = v [ n - 1 ] NEW_LINE if N % 2 == 1 : NEW_LINE INDENT first_maxima = N // 2 NEW_LINE second_maxima = first_maxima + 1 NEW_LINE ans1 , ans2 = 3 * ( 10 ** 18 ) , 3 * ( 10 ** 18 ) NEW_LINE from_left , from_right = - 1 , - 1 NEW_LINE _from = - 1 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if v [ i ] > first_maxima : NEW_LINE INDENT _from = i NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT diff = first_maxima - v [ i ] NEW_LINE if diff < ans1 : NEW_LINE INDENT ans1 = diff NEW_LINE from_left = v [ i ] NEW_LINE DEDENT DEDENT DEDENT from_right = v [ _from ] NEW_LINE diff1 = first_maxima - from_left NEW_LINE diff2 = from_right - second_maxima NEW_LINE if diff1 < diff2 : NEW_LINE INDENT print ( N , from_left ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( N , from_right ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT maxima = N // 2 NEW_LINE ans1 = 3 * ( 10 ** 18 ) NEW_LINE R = - 1 NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT diff = abs ( v [ i ] - maxima ) NEW_LINE if diff < ans1 : NEW_LINE INDENT ans1 = diff NEW_LINE R = v [ i ] NEW_LINE DEDENT DEDENT print ( N , R ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT v = [ 1 , 1 , 2 , 3 , 6 , 1 ] NEW_LINE n = len ( v ) NEW_LINE printMaxValPair ( v , n ) NEW_LINE DEDENT +" +E901,"import java . util . * ; class GFG { static void triangle ( int n ) { int k = 2 * n - 2 ; int ch = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) System . out . print ( "" ▁ "" ) ; k = k - 1 ; for ( int j = 0 ; j <= i ; j ++ ) { System . out . print ( ch ++ + "" ▁ "" ) ; } System . out . println ( ) ; } } static int maxHeight ( int n ) { return ( ( ( int ) Math . sqrt ( 1 + 8.0 * n ) ) - 1 ) / 2 ; } public static void main ( String [ ] args ) { int N = 9 ; triangle ( maxHeight ( N ) ) ; } } +","from math import sqrt NEW_LINE def triangle ( n ) : NEW_LINE INDENT k = 2 * n - 2 ; NEW_LINE ch = 1 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( k ) : NEW_LINE INDENT print ( "" ▁ "" , end = "" "" ) ; NEW_LINE DEDENT k = k - 1 ; NEW_LINE for j in range ( i + 1 ) : NEW_LINE INDENT print ( ch , end = "" ▁ "" ) ; NEW_LINE ch += 1 ; NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT def maxHeight ( n ) : NEW_LINE INDENT ans = ( sqrt ( 1 + 8.0 * n ) - 1 ) // 2 ; NEW_LINE return int ( ans ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 9 ; NEW_LINE triangle ( maxHeight ( N ) ) ; NEW_LINE DEDENT +" +E902,"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static String longestInteger ( String str , int l ) { int count = 0 , max = 0 , pos = - 1 , pre_pos , pre_len , len = 0 ; for ( int i = 0 ; i < l ; i ++ ) { pre_pos = pos ; pre_len = len ; count = 0 ; len = 0 ; if ( Character . isDigit ( str . charAt ( i ) ) ) pos = i ; while ( Character . isDigit ( str . charAt ( i ) ) ) { count ++ ; i ++ ; len ++ ; } if ( count > max ) { max = count ; } else { pos = pre_pos ; len = pre_len ; } } return ( str . substring ( pos , pos + len ) ) ; } public static void main ( String [ ] args ) { String str = "" geeks100for1234geeks "" ; int l = str . length ( ) ; System . out . print ( longestInteger ( str , l ) ) ; } } +","def longestInteger ( s , length ) : NEW_LINE INDENT count = 0 NEW_LINE maximum = 0 NEW_LINE pos = - 1 NEW_LINE l = 0 NEW_LINE for i in range ( length ) : NEW_LINE INDENT pre_pos = pos NEW_LINE pre_len = l NEW_LINE count = 0 NEW_LINE l = 0 NEW_LINE if ( s [ i ] . isdecimal ( ) ) : NEW_LINE INDENT pos = i NEW_LINE DEDENT while ( s [ i ] . isdecimal ( ) ) : NEW_LINE INDENT count += 1 NEW_LINE i += 1 NEW_LINE l += 1 NEW_LINE DEDENT if ( count > maximum ) : NEW_LINE INDENT maximum = count NEW_LINE DEDENT else : NEW_LINE INDENT pos = pre_pos NEW_LINE l = pre_len NEW_LINE DEDENT DEDENT return ( s [ pos : pos + l ] ) NEW_LINE DEDENT s = "" geeks100for1234geeks "" NEW_LINE length = len ( s ) NEW_LINE print ( longestInteger ( s , length ) ) NEW_LINE +" +E903,"import java . io . * ; class GFG { static int findSum ( int n , int a , int b ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( i % a == 0 || i % b == 0 ) sum += i ; return sum ; } public static void main ( String [ ] args ) { int n = 10 , a = 3 , b = 5 ; System . out . println ( findSum ( n , a , b ) ) ; } } +","def findSum ( n , a , b ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( i % a == 0 or i % b == 0 ) : NEW_LINE INDENT sum += i NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 NEW_LINE a = 3 NEW_LINE b = 5 NEW_LINE print ( findSum ( n , a , b ) ) NEW_LINE DEDENT +" +E904,"import java . io . * ; class GFG { static int seriesSum ( int n ) { return ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( seriesSum ( n ) ) ; } } +","def seriesSum ( n ) : NEW_LINE INDENT return int ( ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ) NEW_LINE DEDENT n = 4 NEW_LINE print ( seriesSum ( n ) ) NEW_LINE +" +E905,"import java . util . * ; class GFG { static int find_count ( Vector < Integer > ele ) { int count = 0 ; for ( int i = 0 ; i < ele . size ( ) ; i ++ ) { Vector < Integer > p = new Vector < Integer > ( ) ; int c = 0 ; for ( int j = ele . size ( ) - 1 ; j >= ( ele . size ( ) - 1 - i ) && j >= 0 ; j -- ) { p . add ( ele . get ( j ) ) ; } int j = ele . size ( ) - 1 , k = 0 ; while ( j >= 0 ) { if ( ele . get ( j ) != p . get ( k ) ) { break ; } j -- ; k ++ ; if ( k == p . size ( ) ) { c ++ ; k = 0 ; } } count = Math . max ( count , c ) ; } return count ; } static void solve ( int n ) { int count = 1 ; Vector < Integer > ele = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( count + "" , ▁ "" ) ; ele . add ( count ) ; count = find_count ( ele ) ; } } public static void main ( String [ ] args ) { int n = 10 ; solve ( n ) ; } } +","def find_count ( ele ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( len ( ele ) ) : NEW_LINE INDENT p = [ ] NEW_LINE c = 0 NEW_LINE j = len ( ele ) - 1 NEW_LINE while j >= ( len ( ele ) - 1 - i ) and j >= 0 : NEW_LINE INDENT p . append ( ele [ j ] ) NEW_LINE j -= 1 NEW_LINE DEDENT j = len ( ele ) - 1 NEW_LINE k = 0 NEW_LINE while j >= 0 : NEW_LINE INDENT if ele [ j ] != p [ k ] : NEW_LINE INDENT break NEW_LINE DEDENT j -= 1 NEW_LINE k += 1 NEW_LINE if k == len ( p ) : NEW_LINE INDENT c += 1 NEW_LINE k = 0 NEW_LINE DEDENT DEDENT count = max ( count , c ) NEW_LINE DEDENT return count NEW_LINE DEDENT def solve ( n ) : NEW_LINE INDENT count = 1 NEW_LINE ele = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( count , end = "" ▁ "" ) NEW_LINE ele . append ( count ) NEW_LINE count = find_count ( ele ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 10 NEW_LINE solve ( n ) NEW_LINE DEDENT +" +E906,"class GFG { static int getMinimumOps ( int ar [ ] , int k ) { int n = ar . length ; int dp [ ] [ ] = new int [ n ] [ k + 1 ] ; dp [ 0 ] [ 1 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int maxGroups = Math . min ( k , i + 1 ) ; for ( int j = 1 ; j <= maxGroups ; j ++ ) { dp [ i ] [ j ] = Integer . MAX_VALUE ; if ( j == 1 ) { int freq [ ] = new int [ 100000 ] ; int freqOfMode = 0 ; for ( int it = 0 ; it <= i ; it ++ ) { freq [ ar [ it ] ] ++ ; int newElementFreq = freq [ ar [ it ] ] ; if ( newElementFreq > freqOfMode ) freqOfMode = newElementFreq ; } dp [ i ] [ 1 ] = ( i + 1 ) - freqOfMode ; } else { int freq [ ] = new int [ 100000 ] ; int freqOfMode = 0 ; for ( int it = i ; it >= j - 1 ; it -- ) { freq [ ar [ it ] ] ++ ; int newElementFreq = freq [ ar [ it ] ] ; if ( newElementFreq > freqOfMode ) freqOfMode = newElementFreq ; int elementsToChange = i - it + 1 ; elementsToChange -= freqOfMode ; dp [ i ] [ j ] = Math . min ( dp [ it - 1 ] [ j - 1 ] + elementsToChange , dp [ i ] [ j ] ) ; } } } } return dp [ n - 1 ] [ k ] ; } public static void main ( String args [ ] ) { int k = 3 ; int ar [ ] = { 3 , 1 , 3 , 3 , 2 , 1 , 8 , 5 } ; System . out . println ( getMinimumOps ( ar , k ) ) ; } } +","def getMinimumOps ( ar , k ) : NEW_LINE INDENT n = len ( ar ) NEW_LINE dp = [ [ 0 for i in range ( k + 1 ) ] for i in range ( n ) ] NEW_LINE dp [ 0 ] [ 1 ] = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT maxGroups = min ( k , i + 1 ) NEW_LINE for j in range ( 1 , maxGroups + 1 ) : NEW_LINE INDENT dp [ i ] [ j ] = 10 ** 9 NEW_LINE if ( j == 1 ) : NEW_LINE INDENT freq1 = dict ( ) NEW_LINE freqOfMode = 0 NEW_LINE for it in range ( 0 , i + 1 ) : NEW_LINE INDENT freq1 [ ar [ it ] ] = freq1 . get ( ar [ it ] , 0 ) + 1 NEW_LINE newElementFreq = freq1 [ ar [ it ] ] NEW_LINE if ( newElementFreq > freqOfMode ) : NEW_LINE INDENT freqOfMode = newElementFreq NEW_LINE DEDENT DEDENT dp [ i ] [ 1 ] = ( i + 1 ) - freqOfMode NEW_LINE DEDENT else : NEW_LINE INDENT freq = dict ( ) NEW_LINE freqOfMode = 0 NEW_LINE for it in range ( i , j - 2 , - 1 ) : NEW_LINE INDENT freq [ ar [ it ] ] = freq . get ( ar [ it ] , 0 ) + 1 NEW_LINE newElementFreq = freq [ ar [ it ] ] NEW_LINE if ( newElementFreq > freqOfMode ) : NEW_LINE INDENT freqOfMode = newElementFreq NEW_LINE DEDENT elementsToChange = i - it + 1 NEW_LINE elementsToChange -= freqOfMode NEW_LINE dp [ i ] [ j ] = min ( dp [ it - 1 ] [ j - 1 ] + elementsToChange , dp [ i ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return dp [ n - 1 ] [ k ] NEW_LINE DEDENT k = 3 NEW_LINE ar = [ 3 , 1 , 3 , 3 , 2 , 1 , 8 , 5 ] NEW_LINE print ( getMinimumOps ( ar , k ) ) NEW_LINE +" +E907,"import java . util . * ; class GFG { static int findCount ( int N ) { Vector list = new Vector ( ) ; int sum = 0 ; int i ; for ( i = 0 ; i < 20 ; i ++ ) { sum += Math . pow ( 2 , i ) ; list . add ( sum ) ; } for ( i = 0 ; i < 20 ; i ++ ) { if ( ( int ) list . get ( i ) > N ) return ( list . indexOf ( list . get ( i ) ) + 1 ) ; } return 0 ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . println ( findCount ( N ) ) ; } } +","def findCount ( N ) : NEW_LINE INDENT list = [ ] NEW_LINE sum = 0 NEW_LINE for i in range ( 0 , 20 ) : NEW_LINE INDENT sum += 2 ** i NEW_LINE list . append ( sum ) NEW_LINE DEDENT for value in list : NEW_LINE INDENT if ( value > N ) : NEW_LINE INDENT return ( list . index ( value ) + 1 ) NEW_LINE DEDENT DEDENT DEDENT N = 10 NEW_LINE print ( findCount ( N ) ) NEW_LINE +" +E908,"class GFG { static void farey ( int n ) { double x1 = 0 , y1 = 1 , x2 = 1 , y2 = n ; System . out . printf ( "" % .0f / % . 0f ▁ % .0f / % . 0f "" , x1 , y1 , x2 , y2 ) ; double x , y = 0 ; while ( y != 1.0 ) { x = Math . floor ( ( y1 + n ) / y2 ) * x2 - x1 ; y = Math . floor ( ( y1 + n ) / y2 ) * y2 - y1 ; System . out . printf ( "" ▁ % .0f / % . 0f "" , x , y ) ; x1 = x2 ; x2 = x ; y1 = y2 ; y2 = y ; } } public static void main ( String [ ] args ) { int n = 7 ; System . out . print ( "" Farey ▁ Sequence ▁ of ▁ order ▁ "" + n + "" ▁ is \n "" ) ; farey ( n ) ; } } +","import math NEW_LINE def farey ( n ) : NEW_LINE INDENT x1 = 0 ; NEW_LINE y1 = 1 ; NEW_LINE x2 = 1 ; NEW_LINE y2 = n ; NEW_LINE print ( x1 , end = "" "" ) NEW_LINE print ( "" / "" , end = "" "" ) NEW_LINE print ( y1 , x2 , end = "" "" ) NEW_LINE print ( "" / "" , end = "" "" ) NEW_LINE print ( y2 , end = "" ▁ "" ) ; NEW_LINE x = 0 ; NEW_LINE y = 0 ; NEW_LINE while ( y != 1.0 ) : NEW_LINE INDENT x = math . floor ( ( y1 + n ) / y2 ) * x2 - x1 ; NEW_LINE y = math . floor ( ( y1 + n ) / y2 ) * y2 - y1 ; NEW_LINE print ( x , end = "" "" ) NEW_LINE print ( "" / "" , end = "" "" ) NEW_LINE print ( y , end = "" ▁ "" ) ; NEW_LINE x1 = x2 ; NEW_LINE x2 = x ; NEW_LINE y1 = y2 ; NEW_LINE y2 = y ; NEW_LINE DEDENT DEDENT n = 7 ; NEW_LINE print ( "" Farey ▁ Sequence ▁ of ▁ order "" , n , "" is "" ) ; NEW_LINE farey ( n ) ; NEW_LINE +" +E909,"import java . io . * ; class GFG { static float focal_length ( float image_distance , float object_distance ) { return 1 / ( ( 1 / image_distance ) + ( 1 / object_distance ) ) ; } public static void main ( String [ ] args ) { float image_distance = 2 ; float object_distance = 50 ; System . out . println ( "" Focal ▁ length ▁ of ▁ a ▁ lens ▁ is ▁ "" + focal_length ( image_distance , object_distance ) + "" ▁ units . "" ) ; } } +","def focal_length ( image_distance , object_distance ) NEW_LINE INDENT : return 1 / ( ( 1 / image_distance ) + ( 1 / object_distance ) ) NEW_LINE DEDENT image_distance = 2 NEW_LINE object_distance = 50 NEW_LINE result = focal_length ( image_distance , object_distance ) NEW_LINE print ( "" Focal ▁ length ▁ of ▁ a ▁ lens ▁ is ▁ "" , result , "" ▁ units . "" ) NEW_LINE +" +E910,"class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } static int findModuloByM ( int X , int N , int M ) { if ( N < 6 ) { String temp = "" "" ; for ( int i = 0 ; i < N ; i ++ ) temp = temp + ( char ) ( X + 48 ) ; int res = Integer . parseInt ( temp ) % M ; return res ; } if ( N % 2 == 0 ) { int half = findModuloByM ( X , N / 2 , M ) % M ; int res = ( half * power ( 10 , N / 2 , M ) + half ) % M ; return res ; } else { int half = findModuloByM ( X , N / 2 , M ) % M ; int res = ( half * power ( 10 , N / 2 + 1 , M ) + half * 10 + X ) % M ; return res ; } } public static void main ( String [ ] args ) { int X = 6 , N = 14 , M = 9 ; System . out . println ( findModuloByM ( X , N , M ) ) ; } } +","def power ( x , y , p ) : NEW_LINE INDENT res = 1 ; NEW_LINE x = x % p ; NEW_LINE while ( y > 0 ) : NEW_LINE INDENT if ( y and 1 ) : NEW_LINE INDENT res = ( res * x ) % p ; NEW_LINE DEDENT y = y >> 1 ; NEW_LINE x = ( x * x ) % p ; NEW_LINE DEDENT return res ; NEW_LINE DEDENT def findModuloByM ( X , N , M ) : NEW_LINE INDENT if ( N < 6 ) : NEW_LINE INDENT temp = chr ( 48 + X ) * N NEW_LINE res = int ( temp ) % M ; NEW_LINE return res ; NEW_LINE DEDENT if ( N % 2 == 0 ) : NEW_LINE INDENT half = findModuloByM ( X , N // 2 , M ) % M ; NEW_LINE res = ( half * power ( 10 , N // 2 , M ) + half ) % M ; NEW_LINE return res ; NEW_LINE DEDENT else : NEW_LINE INDENT half = findModuloByM ( X , N // 2 , M ) % M ; NEW_LINE res = ( half * power ( 10 , N // 2 + 1 , M ) + half * 10 + X ) % M ; NEW_LINE return res ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT X = 6 ; N = 14 ; M = 9 ; NEW_LINE print ( findModuloByM ( X , N , M ) ) ; NEW_LINE DEDENT +" +E911,"public class GFG { static int getTotalXorOfSubarrayXors ( int arr [ ] , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = i ; j < N ; j ++ ) for ( int k = i ; k <= j ; k ++ ) res = res ^ arr [ k ] ; return res ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 5 , 2 , 4 , 6 } ; int N = arr . length ; System . out . println ( getTotalXorOfSubarrayXors ( arr , N ) ) ; } } +","def getTotalXorOfSubarrayXors ( arr , N ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT for j in range ( i , N ) : NEW_LINE INDENT for k in range ( i , j + 1 ) : NEW_LINE INDENT res = res ^ arr [ k ] NEW_LINE DEDENT DEDENT DEDENT return res NEW_LINE DEDENT arr = [ 3 , 5 , 2 , 4 , 6 ] NEW_LINE N = len ( arr ) NEW_LINE print ( getTotalXorOfSubarrayXors ( arr , N ) ) NEW_LINE +" +E912,"class GFG { static double innerCirclearea ( double radius ) { if ( radius < 0 ) { return - 1 ; } double r = radius / 2 ; double Area = ( 3.14 * Math . pow ( r , 2 ) ) ; return Area ; } public static void main ( String arr [ ] ) { double radius = 4 ; System . out . println ( "" Area ▁ of ▁ circle ▁ c2 ▁ = ▁ "" + innerCirclearea ( radius ) ) ; } } +","def innerCirclearea ( radius ) : NEW_LINE INDENT if ( radius < 0 ) : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT r = radius / 2 ; NEW_LINE Area = ( 3.14 * pow ( r , 2 ) ) ; NEW_LINE return Area ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT radius = 4 ; NEW_LINE print ( "" Area ▁ of ▁ circle ▁ c2 ▁ = "" , innerCirclearea ( radius ) ) ; NEW_LINE DEDENT +" +E913,"import java . io . * ; class GFG { public static void main ( String args [ ] ) { float P = 1 , R = 1 , T = 1 ; float SI = ( P * T * R ) / 100 ; System . out . println ( "" Simple ▁ interest ▁ = ▁ "" + SI ) ; } } +","P = 1 NEW_LINE R = 1 NEW_LINE T = 1 NEW_LINE SI = ( P * R * T ) / 100 NEW_LINE print ( "" simple ▁ interest ▁ is "" , SI ) NEW_LINE +" +E914,"class GFG { static void findSubArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( Math . abs ( arr [ i ] - arr [ i + 1 ] ) >= 2 ) { System . out . print ( arr [ i ] + "" ▁ "" + arr [ i + 1 ] ) ; return ; } } System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 , 6 , 7 } ; int n = arr . length ; findSubArr ( arr , n ) ; } } +","def findSubArr ( arr , n ) : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT if ( abs ( arr [ i ] - arr [ i + 1 ] ) >= 2 ) : NEW_LINE INDENT print ( arr [ i ] , arr [ i + 1 ] , end = "" "" ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT print ( - 1 ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 6 , 7 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE findSubArr ( arr , n ) ; NEW_LINE DEDENT +" +E915,"import java . util . * ; class GFG { public static double Min_glass ( int n , int k , int [ ] a ) { int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) sum += a [ i ] ; double ans = Math . ceil ( ( double ) sum / ( double ) 100 ) ; return ans ; } public static void main ( String [ ] args ) { int n = 4 ; int k = 3 ; int [ ] a = { 200 , 150 , 140 , 300 } ; Arrays . sort ( a ) ; System . out . println ( Min_glass ( n , k , a ) ) ; } } +","from math import ceil NEW_LINE def Min_glass ( n , k , a ) : NEW_LINE INDENT a . sort ( ) NEW_LINE return ceil ( sum ( a [ : k ] ) / 100 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n , k = 4 , 3 NEW_LINE a = [ 200 , 150 , 140 , 300 ] NEW_LINE print ( Min_glass ( n , k , a ) ) NEW_LINE DEDENT +" +E916,"import java . util . * ; class GFG { static void findModulo ( String s ) { int l = s . length ( ) ; int i , modulus = 0 ; if ( s . contains ( "" + "" ) ) { i = s . indexOf ( "" + "" ) ; } else { i = s . indexOf ( "" - "" ) ; } String real = s . substring ( 0 , i ) ; String imaginary = s . substring ( i + 1 , l - 1 ) ; int x = Integer . parseInt ( real ) ; int y = Integer . parseInt ( imaginary ) ; System . out . print ( Math . sqrt ( x * x + y * y ) + "" \n "" ) ; } public static void main ( String [ ] args ) { String s = ""3 + 4i "" ; findModulo ( s ) ; } } +","from math import sqrt NEW_LINE def findModulo ( s ) : NEW_LINE INDENT l = len ( s ) NEW_LINE modulus = 0 NEW_LINE if ( ' + ' in s ) : NEW_LINE INDENT i = s . index ( ' + ' ) NEW_LINE DEDENT else : NEW_LINE INDENT i = s . index ( ' - ' ) NEW_LINE DEDENT real = s [ 0 : i ] NEW_LINE imaginary = s [ i + 1 : l - 1 ] NEW_LINE x = int ( real ) NEW_LINE y = int ( imaginary ) NEW_LINE print ( int ( sqrt ( x * x + y * y ) ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = ""3 + 4i "" NEW_LINE findModulo ( s ) NEW_LINE DEDENT +" +E917,"class RepeatElement { void printRepeating ( int arr [ ] , int size ) { int i ; System . out . println ( "" The ▁ repeating ▁ elements ▁ are ▁ : ▁ "" ) ; for ( i = 0 ; i < size ; i ++ ) { if ( arr [ Math . abs ( arr [ i ] ) ] > 0 ) arr [ Math . abs ( arr [ i ] ) ] = - arr [ Math . abs ( arr [ i ] ) ] ; else System . out . print ( Math . abs ( arr [ i ] ) + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { RepeatElement repeat = new RepeatElement ( ) ; int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . length ; repeat . printRepeating ( arr , arr_size ) ; } } +","def printRepeating ( arr , size ) : NEW_LINE INDENT print ( "" ▁ The ▁ repeating ▁ elements ▁ are "" , end = "" ▁ "" ) NEW_LINE for i in range ( 0 , size ) : NEW_LINE INDENT if ( arr [ abs ( arr [ i ] ) ] > 0 ) : NEW_LINE INDENT arr [ abs ( arr [ i ] ) ] = ( - 1 ) * arr [ abs ( arr [ i ] ) ] NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( arr [ i ] ) , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 4 , 2 , 4 , 5 , 2 , 3 , 1 ] NEW_LINE arr_size = len ( arr ) NEW_LINE printRepeating ( arr , arr_size ) NEW_LINE +" +E918,"import java . io . * ; class GFG { static int countZeros ( int x ) { int y ; int n = 32 ; y = x >> 16 ; if ( y != 0 ) { n = n - 16 ; x = y ; } y = x >> 8 ; if ( y != 0 ) { n = n - 8 ; x = y ; } y = x >> 4 ; if ( y != 0 ) { n = n - 4 ; x = y ; } y = x >> 2 ; if ( y != 0 ) { n = n - 2 ; x = y ; } y = x >> 1 ; if ( y != 0 ) return n - 2 ; return n - x ; } public static void main ( String [ ] args ) { int x = 101 ; System . out . println ( countZeros ( x ) ) ; } } +","def countZeros ( x ) : NEW_LINE INDENT n = 32 ; NEW_LINE y = x >> 16 ; NEW_LINE if ( y != 0 ) : NEW_LINE INDENT n = n - 16 ; NEW_LINE x = y ; NEW_LINE DEDENT y = x >> 8 ; NEW_LINE if ( y != 0 ) : NEW_LINE INDENT n = n - 8 ; NEW_LINE x = y ; NEW_LINE DEDENT y = x >> 4 ; NEW_LINE if ( y != 0 ) : NEW_LINE INDENT n = n - 4 ; NEW_LINE x = y ; NEW_LINE DEDENT y = x >> 2 ; NEW_LINE if ( y != 0 ) : NEW_LINE INDENT n = n - 2 ; NEW_LINE x = y ; NEW_LINE DEDENT y = x >> 1 ; NEW_LINE if ( y != 0 ) : NEW_LINE INDENT return n - 2 ; NEW_LINE DEDENT return n - x ; NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT x = 101 ; NEW_LINE print ( countZeros ( x ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E919,"import java . io . * ; class GFG { static int pairORSum ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { int k1 = 0 ; int k0 = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) != 0 ) k1 ++ ; else k0 ++ ; } ans = ans + ( 1 << i ) * ( k1 * ( k1 - 1 ) / 2 ) + ( 1 << i ) * ( k1 * k0 ) ; } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = arr . length ; System . out . println ( pairORSum ( arr , n ) ) ; } } +","def pairORSum ( arr , n ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 0 , 32 ) : NEW_LINE INDENT k1 = 0 NEW_LINE k0 = 0 NEW_LINE for j in range ( 0 , n ) : NEW_LINE INDENT if ( ( arr [ j ] & ( 1 << i ) ) ) : NEW_LINE INDENT k1 = k1 + 1 NEW_LINE DEDENT else : NEW_LINE INDENT k0 = k0 + 1 NEW_LINE DEDENT DEDENT ans = ans + ( 1 << i ) * ( k1 * ( k1 - 1 ) // 2 ) + ( 1 << i ) * ( k1 * k0 ) NEW_LINE DEDENT return ans NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( pairORSum ( arr , n ) ) NEW_LINE +" +E920,"import java . io . * ; class GFG { static int binaryToDecimal ( String n ) { String num = n ; int dec_value = 0 ; int base = 1 ; int len = num . length ( ) ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( num . charAt ( i ) == '1' ) dec_value += base ; base = base * 2 ; } return dec_value ; } public static void main ( String [ ] args ) { String num = new String ( ""10101001"" ) ; System . out . println ( binaryToDecimal ( num ) ) ; } } +","def binaryToDecimal ( n ) : NEW_LINE INDENT num = n ; NEW_LINE dec_value = 0 ; NEW_LINE base1 = 1 ; NEW_LINE len1 = len ( num ) ; NEW_LINE for i in range ( len1 - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( num [ i ] == '1' ) : NEW_LINE INDENT dec_value += base1 ; NEW_LINE DEDENT base1 = base1 * 2 ; NEW_LINE DEDENT return dec_value ; NEW_LINE DEDENT num = ""10101001"" ; NEW_LINE print ( binaryToDecimal ( num ) ) ; NEW_LINE +" +E921,"class GFG { static int countStrings ( int n , int k ) { int dp [ ] [ ] [ ] = new int [ n + 1 ] [ k + 1 ] [ 2 ] ; dp [ 1 ] [ 0 ] [ 0 ] = 1 ; dp [ 1 ] [ 0 ] [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j < i && j < k + 1 ; j ++ ) { dp [ i ] [ j ] [ 0 ] = dp [ i - 1 ] [ j ] [ 0 ] + dp [ i - 1 ] [ j ] [ 1 ] ; dp [ i ] [ j ] [ 1 ] = dp [ i - 1 ] [ j ] [ 0 ] ; if ( j - 1 >= 0 ) { dp [ i ] [ j ] [ 1 ] += dp [ i - 1 ] [ j - 1 ] [ 1 ] ; } } } return dp [ n ] [ k ] [ 0 ] + dp [ n ] [ k ] [ 1 ] ; } public static void main ( String [ ] args ) { int n = 5 , k = 2 ; System . out . println ( countStrings ( n , k ) ) ; } } +","def countStrings ( n , k ) : NEW_LINE INDENT dp = [ [ [ 0 , 0 ] for __ in range ( k + 1 ) ] for _ in range ( n + 1 ) ] NEW_LINE dp [ 1 ] [ 0 ] [ 0 ] = 1 NEW_LINE dp [ 1 ] [ 0 ] [ 1 ] = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT for j in range ( k + 1 ) : NEW_LINE INDENT dp [ i ] [ j ] [ 0 ] = ( dp [ i - 1 ] [ j ] [ 0 ] + dp [ i - 1 ] [ j ] [ 1 ] ) NEW_LINE dp [ i ] [ j ] [ 1 ] = dp [ i - 1 ] [ j ] [ 0 ] NEW_LINE if j >= 1 : NEW_LINE INDENT dp [ i ] [ j ] [ 1 ] += dp [ i - 1 ] [ j - 1 ] [ 1 ] NEW_LINE DEDENT DEDENT DEDENT return dp [ n ] [ k ] [ 0 ] + dp [ n ] [ k ] [ 1 ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE k = 2 NEW_LINE print ( countStrings ( n , k ) ) NEW_LINE DEDENT +" +E922,"class GFG { public static void print2largest ( int arr [ ] , int arr_size ) { int i , first , second ; if ( arr_size < 2 ) { System . out . print ( "" ▁ Invalid ▁ Input ▁ "" ) ; return ; } first = second = Integer . MIN_VALUE ; for ( i = 0 ; i < arr_size ; i ++ ) { if ( arr [ i ] > first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second && arr [ i ] != first ) second = arr [ i ] ; } if ( second == Integer . MIN_VALUE ) System . out . print ( "" There ▁ is ▁ no ▁ second ▁ largest "" + "" ▁ element \n "" ) ; else System . out . print ( "" The ▁ second ▁ largest ▁ element "" + "" ▁ is ▁ "" + second ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 35 , 1 , 10 , 34 , 1 } ; int n = arr . length ; print2largest ( arr , n ) ; } } +","def print2largest ( arr , arr_size ) : NEW_LINE INDENT if ( arr_size < 2 ) : NEW_LINE INDENT print ( "" ▁ Invalid ▁ Input ▁ "" ) NEW_LINE return NEW_LINE DEDENT first = second = - 2147483648 NEW_LINE for i in range ( arr_size ) : NEW_LINE INDENT if ( arr [ i ] > first ) : NEW_LINE INDENT second = first NEW_LINE first = arr [ i ] NEW_LINE DEDENT elif ( arr [ i ] > second and arr [ i ] != first ) : NEW_LINE INDENT second = arr [ i ] NEW_LINE DEDENT DEDENT if ( second == - 2147483648 ) : NEW_LINE INDENT print ( "" There ▁ is ▁ no ▁ second ▁ largest ▁ element "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" The ▁ second ▁ largest ▁ element ▁ is "" , second ) NEW_LINE DEDENT DEDENT arr = [ 12 , 35 , 1 , 10 , 34 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE print2largest ( arr , n ) NEW_LINE +" +E923,"class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void print_gcd_online ( int n , int m , int [ ] [ ] query , int [ ] arr ) { int max_gcd = 0 ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) max_gcd = gcd ( max_gcd , arr [ i ] ) ; for ( i = 0 ; i < m ; i ++ ) { query [ i ] [ 0 ] -- ; arr [ query [ i ] [ 0 ] ] /= query [ i ] [ 1 ] ; max_gcd = gcd ( arr [ query [ i ] [ 0 ] ] , max_gcd ) ; System . out . println ( max_gcd ) ; } } public static void main ( String [ ] args ) { int n = 3 ; int m = 3 ; int [ ] [ ] query = new int [ m ] [ 2 ] ; int [ ] arr = new int [ ] { 36 , 24 , 72 } ; query [ 0 ] [ 0 ] = 1 ; query [ 0 ] [ 1 ] = 3 ; query [ 1 ] [ 0 ] = 3 ; query [ 1 ] [ 1 ] = 12 ; query [ 2 ] [ 0 ] = 2 ; query [ 2 ] [ 1 ] = 4 ; print_gcd_online ( n , m , query , arr ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if a == 0 : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b % a , a ) NEW_LINE DEDENT def print_gcd_online ( n , m , query , arr ) : NEW_LINE INDENT max_gcd = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT max_gcd = gcd ( max_gcd , arr [ i ] ) NEW_LINE DEDENT for i in range ( 0 , m ) : NEW_LINE INDENT query [ i ] [ 0 ] -= 1 NEW_LINE arr [ query [ i ] [ 0 ] ] //= query [ i ] [ 1 ] NEW_LINE max_gcd = gcd ( arr [ query [ i ] [ 0 ] ] , max_gcd ) NEW_LINE print ( max_gcd ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n , m = 3 , 3 NEW_LINE query = [ [ 1 , 3 ] , [ 3 , 12 ] , [ 2 , 4 ] ] NEW_LINE arr = [ 36 , 24 , 72 ] NEW_LINE print_gcd_online ( n , m , query , arr ) NEW_LINE DEDENT +" +E924,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int countSubstr ( String str , int n , char x , char y ) { int tot_count = 0 ; int count_x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == x ) count_x ++ ; if ( str . charAt ( i ) == y ) tot_count += count_x ; } return tot_count ; } public static void main ( String args [ ] ) { String str = "" abbcaceghcak "" ; int n = str . length ( ) ; char x = ' a ' , y = ' c ' ; System . out . print ( "" Count ▁ = ▁ "" + countSubstr ( str , n , x , y ) ) ; } } +","def countSubstr ( str , n , x , y ) : NEW_LINE INDENT tot_count = 0 NEW_LINE count_x = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if str [ i ] == x : NEW_LINE INDENT count_x += 1 NEW_LINE DEDENT if str [ i ] == y : NEW_LINE INDENT tot_count += count_x NEW_LINE DEDENT DEDENT return tot_count NEW_LINE DEDENT str = ' abbcaceghcak ' NEW_LINE n = len ( str ) NEW_LINE x , y = ' a ' , ' c ' NEW_LINE print ( ' Count ▁ = ' , countSubstr ( str , n , x , y ) ) NEW_LINE +" +E925,"import java . io . * ; class GFG { static int centered_cube ( int n ) { return ( 2 * n + 1 ) * ( n * n + n + 1 ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( n + "" th ▁ Centered "" + "" ▁ cube ▁ number : ▁ "" ) ; System . out . println ( centered_cube ( n ) ) ; n = 10 ; System . out . print ( n + "" th ▁ Centered "" + "" ▁ cube ▁ number : ▁ "" ) ; System . out . println ( centered_cube ( n ) ) ; } } +","def centered_cube ( n ) : NEW_LINE INDENT return ( 2 * n + 1 ) * ( n * n + n + 1 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE print ( n , "" th ▁ Centered ▁ cube ▁ "" + "" number ▁ : ▁ "" , centered_cube ( n ) ) NEW_LINE n = 10 NEW_LINE print ( n , "" th ▁ Centered ▁ cube ▁ "" + "" number ▁ : ▁ "" , centered_cube ( n ) ) NEW_LINE DEDENT +" +E926,"import java . util . * ; class GFG { static int MAX = 10000 ; static ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; static void sieveSundaram ( ) { boolean [ ] marked = new boolean [ MAX / 2 + 100 ] ; for ( int i = 1 ; i <= ( Math . sqrt ( MAX ) - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= MAX / 2 ; j = j + 2 * i + 1 ) marked [ j ] = true ; primes . add ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked [ i ] == false ) primes . add ( 2 * i + 1 ) ; } static void findPrimes ( int n ) { if ( n <= 2 || n % 2 != 0 ) { System . out . println ( "" Invalid ▁ Input ▁ "" ) ; return ; } for ( int i = 0 ; primes . get ( i ) <= n / 2 ; i ++ ) { int diff = n - primes . get ( i ) ; if ( primes . contains ( diff ) ) { System . out . println ( primes . get ( i ) + "" ▁ + ▁ "" + diff + "" ▁ = ▁ "" + n ) ; return ; } } } public static void main ( String [ ] args ) { sieveSundaram ( ) ; findPrimes ( 4 ) ; findPrimes ( 38 ) ; findPrimes ( 100 ) ; } } +","import math NEW_LINE MAX = 10000 ; NEW_LINE primes = [ ] ; NEW_LINE def sieveSundaram ( ) : NEW_LINE INDENT marked = [ False ] * ( int ( MAX / 2 ) + 100 ) ; NEW_LINE for i in range ( 1 , int ( ( math . sqrt ( MAX ) - 1 ) / 2 ) + 1 ) : NEW_LINE INDENT for j in range ( ( i * ( i + 1 ) ) << 1 , int ( MAX / 2 ) + 1 , 2 * i + 1 ) : NEW_LINE INDENT marked [ j ] = True ; NEW_LINE DEDENT DEDENT primes . append ( 2 ) ; NEW_LINE for i in range ( 1 , int ( MAX / 2 ) + 1 ) : NEW_LINE INDENT if ( marked [ i ] == False ) : NEW_LINE INDENT primes . append ( 2 * i + 1 ) ; NEW_LINE DEDENT DEDENT DEDENT def findPrimes ( n ) : NEW_LINE INDENT if ( n <= 2 or n % 2 != 0 ) : NEW_LINE INDENT print ( "" Invalid ▁ Input "" ) ; NEW_LINE return ; NEW_LINE DEDENT i = 0 ; NEW_LINE while ( primes [ i ] <= n // 2 ) : NEW_LINE INDENT diff = n - primes [ i ] ; NEW_LINE if diff in primes : NEW_LINE INDENT print ( primes [ i ] , "" + "" , diff , "" = "" , n ) ; NEW_LINE return ; NEW_LINE DEDENT i += 1 ; NEW_LINE DEDENT DEDENT sieveSundaram ( ) ; NEW_LINE findPrimes ( 4 ) ; NEW_LINE findPrimes ( 38 ) ; NEW_LINE findPrimes ( 100 ) ; NEW_LINE +" +E927,"class GFG { static int N = 100005 ; static int d [ ] = new int [ N ] , pre [ ] = new int [ N ] ; static void Positive_Divisors ( ) { for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { if ( j * j == i ) d [ i ] ++ ; else d [ i ] += 2 ; } } } int ans = 0 ; for ( int i = 2 ; i < N ; i ++ ) { if ( d [ i ] == d [ i - 1 ] ) ans ++ ; pre [ i ] = ans ; } } public static void main ( String [ ] args ) { Positive_Divisors ( ) ; int n = 15 ; System . out . println ( pre [ n ] ) ; } } +","from math import sqrt ; NEW_LINE N = 100005 NEW_LINE d = [ 0 ] * N NEW_LINE pre = [ 0 ] * N NEW_LINE def Positive_Divisors ( ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( 1 , int ( sqrt ( i ) ) + 1 ) : NEW_LINE INDENT if ( i % j == 0 ) : NEW_LINE INDENT if ( j * j == i ) : NEW_LINE INDENT d [ i ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT d [ i ] += 2 NEW_LINE DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT if ( d [ i ] == d [ i - 1 ] ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT pre [ i ] = ans NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT Positive_Divisors ( ) NEW_LINE n = 15 NEW_LINE print ( pre [ n ] ) NEW_LINE DEDENT +" +E928,"import java . io . * ; import java . math . * ; class GFG { static void LeibnizHarmonicTriangle ( int n ) { int C [ ] [ ] = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= Math . min ( i , n ) ; j ++ ) { if ( j == 0 || j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) System . out . print ( ""1 / "" + i * C [ i - 1 ] [ j - 1 ] + "" ▁ "" ) ; System . out . println ( ) ; } } public static void main ( String args [ ] ) { int n = 4 ; LeibnizHarmonicTriangle ( n ) ; } } +","def LeibnizHarmonicTriangle ( n ) : NEW_LINE INDENT C = [ [ 0 for x in range ( n + 1 ) ] for y in range ( n + 1 ) ] ; NEW_LINE for i in range ( 0 , n + 1 ) : NEW_LINE INDENT for j in range ( 0 , min ( i , n ) + 1 ) : NEW_LINE INDENT if ( j == 0 or j == i ) : NEW_LINE INDENT C [ i ] [ j ] = 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT C [ i ] [ j ] = ( C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ) ; NEW_LINE DEDENT DEDENT DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , i + 1 ) : NEW_LINE INDENT print ( ""1 / "" , end = "" "" ) ; NEW_LINE print ( i * C [ i - 1 ] [ j - 1 ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( ) ; NEW_LINE DEDENT DEDENT LeibnizHarmonicTriangle ( 4 ) ; NEW_LINE +" +E929,"import java . util . * ; class GFG { static void ansQueries ( int prefeven [ ] , int prefodd [ ] , int l , int r ) { if ( ( r - l + 1 ) % 2 == 0 ) System . out . println ( ""0"" ) ; else { if ( l % 2 == 0 ) System . out . println ( prefeven [ r ] ^ prefeven [ l - 1 ] ) ; else System . out . println ( prefodd [ r ] ^ prefodd [ l - 1 ] ) ; } } static void wrapper ( int arr [ ] , int n , int l [ ] , int r [ ] , int q ) { int prefodd [ ] = new int [ 100 ] ; int prefeven [ ] = new int [ 100 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ( i ) % 2 == 0 ) { prefeven [ i ] = arr [ i - 1 ] ^ prefeven [ i - 1 ] ; prefodd [ i ] = prefodd [ i - 1 ] ; } else { prefeven [ i ] = prefeven [ i - 1 ] ; prefodd [ i ] = prefodd [ i - 1 ] ^ arr [ i - 1 ] ; } } int i = 0 ; while ( i != q ) { ansQueries ( prefeven , prefodd , l [ i ] , r [ i ] ) ; i ++ ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . length ; int l [ ] = { 1 , 1 , 2 } ; int r [ ] = { 2 , 3 , 4 } ; int q = l . length ; wrapper ( arr , n , l , r , q ) ; } } +","N = 100 NEW_LINE def ansQueries ( prefeven , prefodd , l , r ) : NEW_LINE INDENT if ( ( r - l + 1 ) % 2 == 0 ) : NEW_LINE INDENT print ( ""0"" ) NEW_LINE DEDENT else : NEW_LINE INDENT if ( l % 2 == 0 ) : NEW_LINE INDENT print ( prefeven [ r ] ^ prefeven [ l - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( prefodd [ r ] ^ prefodd [ l - 1 ] ) NEW_LINE DEDENT DEDENT DEDENT def wrapper ( arr , n , l , r , q ) : NEW_LINE INDENT prefodd = [ 0 ] * N NEW_LINE prefeven = [ 0 ] * N NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( ( i ) % 2 == 0 ) : NEW_LINE INDENT prefeven [ i ] = arr [ i - 1 ] ^ prefeven [ i - 1 ] NEW_LINE prefodd [ i ] = prefodd [ i - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT prefeven [ i ] = prefeven [ i - 1 ] NEW_LINE prefodd [ i ] = prefodd [ i - 1 ] ^ arr [ i - 1 ] NEW_LINE DEDENT DEDENT i = 0 NEW_LINE while ( i != q ) : NEW_LINE INDENT ansQueries ( prefeven , prefodd , l [ i ] , r [ i ] ) NEW_LINE i += 1 NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE l = [ 1 , 1 , 2 ] NEW_LINE r = [ 2 , 3 , 4 ] NEW_LINE q = len ( l ) NEW_LINE wrapper ( arr , n , l , r , q ) NEW_LINE DEDENT +" +E930,"import java . io . * ; class GFG { static int squaresum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum ; } public static void main ( String args [ ] ) throws IOException { int n = 4 ; System . out . println ( squaresum ( n ) ) ; } } +","def squaresum ( n ) : NEW_LINE INDENT sm = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT sm = sm + ( i * i ) NEW_LINE DEDENT return sm NEW_LINE DEDENT n = 4 NEW_LINE print ( squaresum ( n ) ) NEW_LINE +" +E931,"class GFG { static int MAX = 10 ; static boolean isFactorion ( int n ) { int fact [ ] = new int [ MAX ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i < MAX ; i ++ ) fact [ i ] = i * fact [ i - 1 ] ; int org = n ; int sum = 0 ; while ( n > 0 ) { int d = n % 10 ; sum += fact [ d ] ; n /= 10 ; } if ( sum == org ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 40585 ; if ( isFactorion ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","MAX = 10 NEW_LINE def isFactorion ( n ) : NEW_LINE INDENT fact = [ 0 ] * MAX NEW_LINE fact [ 0 ] = 1 NEW_LINE for i in range ( 1 , MAX ) : NEW_LINE INDENT fact [ i ] = i * fact [ i - 1 ] NEW_LINE DEDENT org = n NEW_LINE sum = 0 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT d = n % 10 NEW_LINE sum += fact [ d ] NEW_LINE n = n // 10 NEW_LINE DEDENT if ( sum == org ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT n = 40585 NEW_LINE if ( isFactorion ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E932,"class GFG { static int minInsertions ( int [ ] H , int n , int K ) { int inser = 0 ; for ( int i = 1 ; i < n ; ++ i ) { float diff = Math . abs ( H [ i ] - H [ i - 1 ] ) ; if ( diff <= K ) continue ; else inser += Math . ceil ( diff / K ) - 1 ; } return inser ; } public static void main ( String [ ] args ) { int [ ] H = new int [ ] { 2 , 4 , 8 , 16 } ; int K = 3 ; int n = H . length ; System . out . println ( minInsertions ( H , n , K ) ) ; } } +","import math NEW_LINE def minInsertions ( H , n , K ) : NEW_LINE INDENT inser = 0 ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT diff = abs ( H [ i ] - H [ i - 1 ] ) ; NEW_LINE if ( diff <= K ) : NEW_LINE INDENT continue ; NEW_LINE DEDENT else : NEW_LINE INDENT inser += math . ceil ( diff / K ) - 1 ; NEW_LINE DEDENT DEDENT return inser ; NEW_LINE DEDENT H = [ 2 , 4 , 8 , 16 ] ; NEW_LINE K = 3 ; NEW_LINE n = len ( H ) ; NEW_LINE print ( minInsertions ( H , n , K ) ) ; NEW_LINE +" +E933,"import java . io . * ; class GFG { static void ReplaceElements ( int arr [ ] , int n ) { int X = 0 ; for ( int i = 0 ; i < n ; ++ i ) { X ^= arr [ i ] ; } for ( int i = 0 ; i < n ; ++ i ) { arr [ i ] = X ^ arr [ i ] ; } } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 3 , 5 , 5 } ; int n = arr . length ; ReplaceElements ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def ReplaceElements ( arr , n ) : NEW_LINE INDENT X = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT X ^= arr [ i ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT arr [ i ] = X ^ arr [ i ] NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 3 , 3 , 5 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE ReplaceElements ( arr , n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT +" +E934,"class GFG { static String makePalindrome ( char [ ] str ) { int i = 0 , j = str . length - 1 ; while ( i <= j ) { if ( str [ i ] == ' * ' && str [ j ] == ' * ' ) { str [ i ] = ' a ' ; str [ j ] = ' a ' ; } else if ( str [ j ] == ' * ' ) str [ j ] = str [ i ] ; else if ( str [ i ] == ' * ' ) str [ i ] = str [ j ] ; else if ( str [ i ] != str [ j ] ) return "" - 1"" ; i ++ ; j -- ; } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { char [ ] str = "" na * an "" . toCharArray ( ) ; System . out . println ( makePalindrome ( str ) ) ; } } +","def makePalindrome ( str1 ) : NEW_LINE INDENT i = 0 NEW_LINE j = len ( str1 ) - 1 NEW_LINE str1 = list ( str1 ) NEW_LINE while ( i <= j ) : NEW_LINE INDENT if ( str1 [ i ] == ' * ' and str1 [ j ] == ' * ' ) : NEW_LINE INDENT str1 [ i ] = ' a ' NEW_LINE str1 [ j ] = ' a ' NEW_LINE DEDENT elif ( str1 [ j ] == ' * ' ) : NEW_LINE INDENT str1 [ j ] = str1 [ i ] NEW_LINE DEDENT elif ( str1 [ i ] == ' * ' ) : NEW_LINE INDENT str1 [ i ] = str1 [ j ] NEW_LINE DEDENT elif ( str1 [ i ] != str1 [ j ] ) : NEW_LINE INDENT str1 = ' ' . join ( str1 ) NEW_LINE return "" - 1"" NEW_LINE DEDENT i += 1 NEW_LINE j -= 1 NEW_LINE DEDENT str1 = ' ' . join ( str1 ) NEW_LINE return str1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str1 = "" na * an "" NEW_LINE print ( makePalindrome ( str1 ) ) NEW_LINE DEDENT +" +E935,"import java . io . * ; import java . util . * ; class GFG { static int countSubstr ( String s ) { int n = s . length ( ) ; int [ ] auxArr = new int [ n ] ; if ( s . charAt ( 0 ) == '1' ) auxArr [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) auxArr [ i ] = auxArr [ i - 1 ] + 1 ; else auxArr [ i ] = auxArr [ i - 1 ] ; } int count = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) if ( s . charAt ( i ) == '1' ) count += auxArr [ i ] ; return count ; } public static void main ( String [ ] args ) { String s = ""1101"" ; System . out . println ( countSubstr ( s ) ) ; } } +","import math NEW_LINE def countSubstr ( s ) : NEW_LINE INDENT n = len ( s ) NEW_LINE auxArr = [ 0 for i in range ( n ) ] NEW_LINE if ( s [ 0 ] == '1' ) : NEW_LINE INDENT auxArr [ 0 ] = 1 NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT auxArr [ i ] = auxArr [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT auxArr [ i ] = auxArr [ i - 1 ] NEW_LINE DEDENT DEDENT count = 0 NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT count += auxArr [ i ] NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT s = ""1101"" NEW_LINE print ( countSubstr ( s ) ) NEW_LINE +" +E936,"import java . io . * ; import java . util . * ; class Graph { private int V ; private LinkedList < Integer > adj [ ] ; Graph ( int v ) { V = v ; adj = new LinkedList [ v ] ; for ( int i = 0 ; i < v ; ++ i ) adj [ i ] = new LinkedList ( ) ; } void addEdge ( int v , int w ) { adj [ v ] . add ( w ) ; } void BFS ( int s ) { boolean visited [ ] = new boolean [ V ] ; LinkedList < Integer > queue = new LinkedList < Integer > ( ) ; visited [ s ] = true ; queue . add ( s ) ; while ( queue . size ( ) != 0 ) { s = queue . poll ( ) ; System . out . print ( s + "" ▁ "" ) ; Iterator < Integer > i = adj [ s ] . listIterator ( ) ; while ( i . hasNext ( ) ) { int n = i . next ( ) ; if ( ! visited [ n ] ) { visited [ n ] = true ; queue . add ( n ) ; } } } } public static void main ( String args [ ] ) { Graph g = new Graph ( 4 ) ; g . addEdge ( 0 , 1 ) ; g . addEdge ( 0 , 2 ) ; g . addEdge ( 1 , 2 ) ; g . addEdge ( 2 , 0 ) ; g . addEdge ( 2 , 3 ) ; g . addEdge ( 3 , 3 ) ; System . out . println ( "" Following ▁ is ▁ Breadth ▁ First ▁ Traversal ▁ "" + "" ( starting ▁ from ▁ vertex ▁ 2 ) "" ) ; g . BFS ( 2 ) ; } } +","from collections import defaultdict NEW_LINE class Graph : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . graph = defaultdict ( list ) NEW_LINE DEDENT def addEdge ( self , u , v ) : NEW_LINE INDENT self . graph [ u ] . append ( v ) NEW_LINE DEDENT def BFS ( self , s ) : NEW_LINE INDENT visited = [ False ] * ( len ( self . graph ) ) NEW_LINE queue = [ ] NEW_LINE queue . append ( s ) NEW_LINE visited [ s ] = True NEW_LINE while queue : NEW_LINE INDENT s = queue . pop ( 0 ) NEW_LINE print ( s , end = "" ▁ "" ) NEW_LINE for i in self . graph [ s ] : NEW_LINE INDENT if visited [ i ] == False : NEW_LINE INDENT queue . append ( i ) NEW_LINE visited [ i ] = True NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT g = Graph ( ) NEW_LINE g . addEdge ( 0 , 1 ) NEW_LINE g . addEdge ( 0 , 2 ) NEW_LINE g . addEdge ( 1 , 2 ) NEW_LINE g . addEdge ( 2 , 0 ) NEW_LINE g . addEdge ( 2 , 3 ) NEW_LINE g . addEdge ( 3 , 3 ) NEW_LINE print ( "" Following ▁ is ▁ Breadth ▁ First ▁ Traversal "" "" ▁ ( starting ▁ from ▁ vertex ▁ 2 ) "" ) NEW_LINE g . BFS ( 2 ) NEW_LINE +" +E937,"import java . io . * ; import java . util . * ; public class Gfg { static int vowel_calc ( String s ) { int n = s . length ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) arr [ i ] = n ; else arr [ i ] = ( n - i ) + arr [ i - 1 ] - i ; } int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { char ch = s . charAt ( i ) ; if ( ch == ' a ' || ch == ' e ' || ch == ' i ' || ch == ' o ' || ch == ' u ' ) sum += arr [ i ] ; } return sum ; } public static void main ( String args [ ] ) { String s = "" daceh "" ; System . out . println ( vowel_calc ( s ) ) ; } } +","def sumVowel ( string ) : NEW_LINE INDENT n = len ( string ) NEW_LINE sum = 0 NEW_LINE string = string . lower ( ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT s = string [ i ] NEW_LINE if ( s == "" a "" or s == "" e "" or s == "" i "" or s == "" o "" or s == "" u "" ) : NEW_LINE INDENT sum += ( ( n - i ) * ( i + 1 ) ) NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT string = "" abhay "" NEW_LINE print ( vovel ( string ) ) NEW_LINE DEDENT +" +E938,"class GFG { static int findOddPair ( int A [ ] , int N ) { int i , count = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 0 ) count ++ ; } return count * ( N - count ) ; } public static void main ( String [ ] arg ) { int a [ ] = { 5 , 4 , 7 , 2 , 1 } ; int n = a . length ; System . out . println ( findOddPair ( a , n ) ) ; } } +","def findOddPair ( A , N ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT if ( A [ i ] % 2 == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count * ( N - count ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 5 , 4 , 7 , 2 , 1 ] NEW_LINE n = len ( a ) NEW_LINE print ( findOddPair ( a , n ) ) NEW_LINE DEDENT +" +E939,"import java . io . * ; class GFG { static int smallestDivisor ( int n ) { if ( n % 2 == 0 ) return 2 ; for ( int i = 3 ; i * i <= n ; i += 2 ) { if ( n % i == 0 ) return i ; } return n ; } public static void main ( String [ ] args ) { int n = 31 ; System . out . println ( smallestDivisor ( n ) ) ; } } +","def smallestDivisor ( n ) : NEW_LINE INDENT if ( n % 2 == 0 ) : NEW_LINE INDENT return 2 ; NEW_LINE DEDENT i = 3 ; NEW_LINE while ( i * i <= n ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT return i ; NEW_LINE DEDENT i += 2 ; NEW_LINE DEDENT return n ; NEW_LINE DEDENT n = 31 ; NEW_LINE print ( smallestDivisor ( n ) ) ; NEW_LINE +" +E940,"class GFG { static float areaOfKite ( int d1 , int d2 ) { float area = ( d1 * d2 ) / 2 ; return area ; } public static void main ( String [ ] args ) { int d1 = 4 , d2 = 6 ; System . out . println ( "" Area ▁ of ▁ Kite ▁ = ▁ "" + areaOfKite ( d1 , d2 ) ) ; } } +","def areaOfKite ( d1 , d2 ) : NEW_LINE INDENT area = ( d1 * d2 ) / 2 ; NEW_LINE return area ; NEW_LINE DEDENT d1 = 4 ; NEW_LINE d2 = 6 ; NEW_LINE print ( "" Area ▁ of ▁ Kite ▁ = ▁ "" , areaOfKite ( d1 , d2 ) ) ; NEW_LINE +" +E941,"import java . util . * ; class GFG { static boolean isPossible ( Vector < String > v , String str ) { str = sortString ( str ) ; for ( int i = 0 ; i < v . size ( ) - 1 ; i ++ ) { for ( int j = i + 1 ; j < v . size ( ) ; j ++ ) { String temp = v . get ( i ) + v . get ( j ) ; temp = sortString ( temp ) ; if ( temp . compareTo ( str ) == 0 ) { return true ; } } } return false ; } public static String sortString ( String inputString ) { char tempArray [ ] = inputString . toCharArray ( ) ; Arrays . sort ( tempArray ) ; return new String ( tempArray ) ; } public static void main ( String [ ] args ) { String str = "" amazon "" ; String [ ] arr = { "" fds "" , "" oxq "" , "" zoa "" , "" epw "" , "" amn "" } ; Vector < String > v = new Vector < String > ( Arrays . asList ( arr ) ) ; if ( isPossible ( v , str ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isPossible ( v , string ) : NEW_LINE INDENT char_list = list ( string ) NEW_LINE char_list . sort ( ) NEW_LINE for i in range ( len ( v ) - 1 ) : NEW_LINE INDENT for j in range ( len ( v ) ) : NEW_LINE INDENT temp = v [ i ] + v [ j ] ; NEW_LINE temp_list = list ( temp ) NEW_LINE temp_list . sort ( ) NEW_LINE if ( temp_list == char_list ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT DEDENT DEDENT return False ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" amazon "" ; NEW_LINE v = [ "" fds "" , "" oxq "" , "" zoa "" , "" epw "" , "" amn "" ] ; NEW_LINE if ( isPossible ( v , string ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E942,"import java . io . * ; class GFG { static double seriesSum ( int n ) { int i = 1 ; double res = 0.0 ; boolean sign = true ; while ( n > 0 ) { n -- ; if ( sign ) { sign = ! sign ; res = res + ( double ) ++ i / ++ i ; } else { sign = ! sign ; res = res - ( double ) ++ i / ++ i ; } } return res ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( seriesSum ( n ) ) ; } } +","def seriesSum ( n ) : NEW_LINE INDENT i = 1 ; NEW_LINE res = 0.0 ; NEW_LINE sign = True ; NEW_LINE while ( n > 0 ) : NEW_LINE INDENT n = n - 1 ; NEW_LINE if ( sign ) : NEW_LINE INDENT sign = False ; NEW_LINE res = res + ( i + 1 ) / ( i + 2 ) ; NEW_LINE i = i + 2 ; NEW_LINE DEDENT else : NEW_LINE INDENT sign = True ; NEW_LINE res = res - ( i + 1 ) / ( i + 2 ) ; NEW_LINE i = i + 2 ; NEW_LINE DEDENT DEDENT return res ; NEW_LINE DEDENT n = 5 ; NEW_LINE print ( round ( seriesSum ( n ) , 6 ) ) ; NEW_LINE +" +E943,"import java . io . * ; class GFG { static int MAX = 1000000 ; static int sieve_Prime [ ] = new int [ MAX + 4 ] ; static int sieve_count [ ] = new int [ MAX + 4 ] ; static void form_sieve ( ) { sieve_Prime [ 1 ] = 1 ; for ( int i = 2 ; i <= MAX ; i ++ ) { if ( sieve_Prime [ i ] == 0 ) { for ( int j = i * 2 ; j <= MAX ; j += i ) { if ( sieve_Prime [ j ] == 0 ) { sieve_Prime [ j ] = 1 ; sieve_count [ i ] ++ ; } } } } } public static void main ( String [ ] args ) { form_sieve ( ) ; int n = 2 ; System . out . println ( "" Count ▁ = ▁ "" + ( sieve_count [ n ] + 1 ) ) ; n = 3 ; System . out . println ( "" Count ▁ = ▁ "" + ( sieve_count [ n ] + 1 ) ) ; } } +","MAX = 1000000 NEW_LINE sieve_Prime = [ 0 for i in range ( MAX + 4 ) ] NEW_LINE sieve_count = [ 0 for i in range ( MAX + 4 ) ] NEW_LINE def form_sieve ( ) : NEW_LINE INDENT sieve_Prime [ 1 ] = 1 NEW_LINE for i in range ( 2 , MAX + 1 ) : NEW_LINE INDENT if sieve_Prime [ i ] == 0 : NEW_LINE INDENT for j in range ( i * 2 , MAX + 1 , i ) : NEW_LINE INDENT if sieve_Prime [ j ] == 0 : NEW_LINE INDENT sieve_Prime [ j ] = 1 NEW_LINE sieve_count [ i ] += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT form_sieve ( ) NEW_LINE n = 2 NEW_LINE print ( "" Count ▁ = "" , sieve_count [ n ] + 1 ) NEW_LINE n = 3 NEW_LINE print ( "" Count ▁ = "" , sieve_count [ n ] + 1 ) NEW_LINE +" +E944,"public class GFG { final static int N = 4 ; static int MaximumDecimalValue ( int mat [ ] [ ] , int n ) { int dp [ ] [ ] = new int [ n ] [ n ] ; if ( mat [ 0 ] [ 0 ] == 1 ) { dp [ 0 ] [ 0 ] = 1 ; } for ( int i = 1 ; i < n ; i ++ ) { if ( mat [ 0 ] [ i ] == 1 ) { dp [ 0 ] [ i ] = ( int ) ( dp [ 0 ] [ i - 1 ] + Math . pow ( 2 , i ) ) ; } else { dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] ; } } for ( int i = 1 ; i < n ; i ++ ) { if ( mat [ i ] [ 0 ] == 1 ) { dp [ i ] [ 0 ] = ( int ) ( dp [ i - 1 ] [ 0 ] + Math . pow ( 2 , i ) ) ; } else { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] ; } } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { if ( mat [ i ] [ j ] == 1 ) { dp [ i ] [ j ] = ( int ) ( Math . max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) + Math . pow ( 2 , i + j ) ) ; } else { dp [ i ] [ j ] = Math . max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) ; } } } return dp [ n - 1 ] [ n - 1 ] ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 1 , 0 , 1 } , { 0 , 1 , 1 , 0 } , { 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 } , } ; System . out . println ( MaximumDecimalValue ( mat , 4 ) ) ; } } +","N = 4 NEW_LINE def MaximumDecimalValue ( mat , n ) : NEW_LINE INDENT dp = [ [ 0 for i in range ( n ) ] for i in range ( n ) ] NEW_LINE if ( mat [ 0 ] [ 0 ] == 1 ) : NEW_LINE INDENT dp [ 0 ] [ 0 ] = 1 NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( mat [ 0 ] [ i ] == 1 ) : NEW_LINE INDENT dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + 2 ** i NEW_LINE DEDENT else : NEW_LINE INDENT dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] NEW_LINE DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( mat [ i ] [ 0 ] == 1 ) : NEW_LINE INDENT dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] + 2 ** i NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT for j in range ( 1 , n ) : NEW_LINE INDENT if ( mat [ i ] [ j ] == 1 ) : NEW_LINE INDENT dp [ i ] [ j ] = max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) + ( 2 ** ( i + j ) ) NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT return dp [ n - 1 ] [ n - 1 ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT mat = [ [ 1 , 1 , 0 , 1 ] , [ 0 , 1 , 1 , 0 ] , [ 1 , 0 , 0 , 1 ] , [ 1 , 0 , 1 , 1 ] ] NEW_LINE print ( MaximumDecimalValue ( mat , 4 ) ) NEW_LINE DEDENT +" +E945,"import java . io . * ; class GFG { static int MAX = 100 ; static boolean checkBisymmetric ( int m [ ] [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( m [ i ] [ j ] != m [ j ] [ i ] ) return false ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n - i ; j ++ ) if ( m [ i ] [ j ] != m [ n - j - 1 ] [ n - i - 1 ] ) return false ; return true ; } public static void main ( String [ ] args ) { int n = 3 ; int m [ ] [ ] = { { 1 , 2 , 3 } , { 2 , 5 , 2 } , { 3 , 2 , 1 } } ; if ( checkBisymmetric ( m , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def checkBisymmetric ( m , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 0 , i ) : NEW_LINE INDENT if ( m [ i ] [ j ] != m [ j ] [ i ] ) : NEW_LINE INDENT return false NEW_LINE DEDENT DEDENT DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 0 , n - i ) : NEW_LINE INDENT if ( m [ i ] [ j ] != m [ n - j - 1 ] [ n - i - 1 ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT return True ; NEW_LINE DEDENT n = 3 ; NEW_LINE m = [ [ 1 , 2 , 3 ] , [ 2 , 5 , 2 ] , [ 3 , 2 , 1 ] ] NEW_LINE if ( checkBisymmetric ( m , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E946,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int Divison ( int a [ ] , int n ) { int maxi = Integer . MIN_VALUE , mini = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { maxi = Math . max ( a [ i ] , maxi ) ; mini = Math . min ( a [ i ] , mini ) ; } return maxi / mini ; } public static void main ( String [ ] args ) throws java . lang . Exception { int a [ ] = { 3 , 7 , 9 , 3 , 11 } ; int n = a . length ; System . out . print ( Divison ( a , n ) ) ; } } +","def Divison ( a , n ) : NEW_LINE INDENT maxi = - 10 ** 9 NEW_LINE mini = 10 ** 9 NEW_LINE for i in a : NEW_LINE INDENT maxi = max ( i , maxi ) NEW_LINE mini = min ( i , mini ) NEW_LINE DEDENT return maxi // mini NEW_LINE DEDENT a = [ 3 , 7 , 9 , 3 , 11 ] NEW_LINE n = len ( a ) NEW_LINE print ( Divison ( a , n ) ) NEW_LINE +" +E947,"public class GFG { static int MAX = 10 ; static int F [ ] [ ] = new int [ MAX ] [ MAX ] ; static int C [ ] = new int [ MAX ] ; static int noOfAssignments ( String S , int n , int i , int c_x ) { if ( F [ i ] [ c_x ] != - 1 ) { return F [ i ] [ c_x ] ; } if ( i == n ) { if ( c_x == 1 ) { F [ i ] [ c_x ] = 0 ; } else { F [ i ] [ c_x ] = 1 ; } return F [ i ] [ c_x ] ; } int c_y = C [ i ] - c_x ; if ( S . charAt ( i ) == ' ( ' ) { F [ i ] [ c_x ] = noOfAssignments ( S , n , i + 1 , c_x + 1 ) + noOfAssignments ( S , n , i + 1 , c_x ) ; return F [ i ] [ c_x ] ; } F [ i ] [ c_x ] = 0 ; if ( c_x == 1 ) { F [ i ] [ c_x ] += noOfAssignments ( S , n , i + 1 , c_x - 1 ) ; } if ( c_y == 1 ) { F [ i ] [ c_x ] += noOfAssignments ( S , n , i + 1 , c_x ) ; } return F [ i ] [ c_x ] ; } public static void main ( String [ ] args ) { String S = "" ( ) "" ; int n = S . length ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { F [ i ] [ j ] = - 1 ; } } C [ 0 ] = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( S . charAt ( i ) == ' ( ' ) { C [ i + 1 ] = C [ i ] + 1 ; } else { C [ i + 1 ] = C [ i ] - 1 ; } } System . out . println ( noOfAssignments ( S , n , 0 , 0 ) ) ; } } +","MAX = 10 NEW_LINE F = [ [ - 1 for i in range ( MAX ) ] for j in range ( MAX ) ] NEW_LINE C = [ None ] * MAX NEW_LINE def noOfAssignments ( S , n , i , c_x ) : NEW_LINE INDENT if F [ i ] [ c_x ] != - 1 : NEW_LINE INDENT return F [ i ] [ c_x ] NEW_LINE DEDENT if i == n : NEW_LINE INDENT F [ i ] [ c_x ] = not c_x NEW_LINE return F [ i ] [ c_x ] NEW_LINE DEDENT c_y = C [ i ] - c_x NEW_LINE if S [ i ] == ' ( ' : NEW_LINE INDENT F [ i ] [ c_x ] = \ NEW_LINE INDENT noOfAssignments ( S , n , i + 1 , c_x + 1 ) + \ NEW_LINE noOfAssignments ( S , n , i + 1 , c_x ) NEW_LINE DEDENT return F [ i ] [ c_x ] NEW_LINE DEDENT F [ i ] [ c_x ] = 0 NEW_LINE if c_x : NEW_LINE INDENT F [ i ] [ c_x ] += \ NEW_LINE INDENT noOfAssignments ( S , n , i + 1 , c_x - 1 ) NEW_LINE DEDENT DEDENT if c_y : NEW_LINE INDENT F [ i ] [ c_x ] += \ NEW_LINE INDENT noOfAssignments ( S , n , i + 1 , c_x ) NEW_LINE DEDENT DEDENT return F [ i ] [ c_x ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT S = "" ( ) "" NEW_LINE n = len ( S ) NEW_LINE C [ 0 ] = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if S [ i ] == ' ( ' : NEW_LINE INDENT C [ i + 1 ] = C [ i ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT C [ i + 1 ] = C [ i ] - 1 NEW_LINE DEDENT DEDENT print ( noOfAssignments ( S , n , 0 , 0 ) ) NEW_LINE DEDENT +" +E948,"import java . io . * ; class GFG { static int nextPowerOf2 ( int n ) { int count = 0 ; if ( n > 0 && ( n & ( n - 1 ) ) == 0 ) return n ; while ( n != 0 ) { n >>= 1 ; count += 1 ; } return 1 << count ; } public static void main ( String args [ ] ) { int n = 0 ; System . out . println ( nextPowerOf2 ( n ) ) ; } } +","def nextPowerOf2 ( n ) : NEW_LINE INDENT count = 0 ; NEW_LINE if ( n and not ( n & ( n - 1 ) ) ) : NEW_LINE INDENT return n NEW_LINE DEDENT while ( n != 0 ) : NEW_LINE INDENT n >>= 1 NEW_LINE count += 1 NEW_LINE DEDENT return 1 << count ; NEW_LINE DEDENT n = 0 NEW_LINE print ( nextPowerOf2 ( n ) ) NEW_LINE +" +E949,"import java . io . * ; public class GFG { static int __gcd ( int a , int b ) { if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return __gcd ( a - b , b ) ; return __gcd ( a , b - a ) ; } static int nthElement ( int a , int b , int n ) { int lcm = ( a * b ) / __gcd ( a , b ) ; int l = 1 , r = Math . min ( a , b ) * n ; while ( l <= r ) { int mid = ( l + r ) >> 1 ; int val = mid / a + mid / b - mid / lcm ; if ( val == n ) return Math . max ( ( mid / a ) * a , ( mid / b ) * b ) ; if ( val < n ) l = mid + 1 ; else r = mid - 1 ; } return 0 ; } static public void main ( String [ ] args ) { int a = 5 , b = 3 , n = 5 ; System . out . println ( nthElement ( a , b , n ) ) ; } } +","import math NEW_LINE def nthElement ( a , b , n ) : NEW_LINE INDENT lcm = ( a * b ) / int ( math . gcd ( a , b ) ) NEW_LINE l = 1 NEW_LINE r = min ( a , b ) * n NEW_LINE while ( l <= r ) : NEW_LINE INDENT mid = ( l + r ) >> 1 NEW_LINE val = ( int ( mid / a ) + int ( mid / b ) - int ( mid / lcm ) ) NEW_LINE if ( val == n ) : NEW_LINE INDENT return int ( max ( int ( mid / a ) * a , int ( mid / b ) * b ) ) NEW_LINE DEDENT if ( val < n ) : NEW_LINE INDENT l = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT r = mid - 1 NEW_LINE DEDENT DEDENT DEDENT a = 5 NEW_LINE b = 3 NEW_LINE n = 5 NEW_LINE print ( nthElement ( a , b , n ) ) NEW_LINE +" +E950,"import java . util . * ; class GFG { static final int MAX = 10000 ; static Vector < Integer > arr = new Vector < Integer > ( ) ; static void SieveOfEratosthenes ( ) { boolean [ ] prime = new boolean [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p < MAX ; p ++ ) if ( prime [ p ] ) arr . add ( p ) ; } static boolean isEuclid ( long n ) { long product = 1 ; int i = 0 ; while ( product < n ) { product = product * arr . get ( i ) ; if ( product + 1 == n ) return true ; i ++ ; } return false ; } public static void main ( String [ ] args ) { SieveOfEratosthenes ( ) ; long n = 31 ; if ( isEuclid ( n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; n = 42 ; if ( isEuclid ( n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","MAX = 10000 NEW_LINE arr = [ ] NEW_LINE def SieveOfEratosthenes ( ) : NEW_LINE INDENT prime = [ True ] * MAX NEW_LINE p = 2 NEW_LINE while p * p < MAX : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * 2 , MAX , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT p += 1 NEW_LINE DEDENT for p in range ( 2 , MAX ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT arr . append ( p ) NEW_LINE DEDENT DEDENT DEDENT def isEuclid ( n ) : NEW_LINE INDENT product = 1 NEW_LINE i = 0 NEW_LINE while ( product < n ) : NEW_LINE INDENT product = product * arr [ i ] NEW_LINE if ( product + 1 == n ) : NEW_LINE INDENT return True NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT SieveOfEratosthenes ( ) NEW_LINE n = 31 NEW_LINE if ( isEuclid ( n ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT n = 42 NEW_LINE if ( isEuclid ( n ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E951,"import java . io . * ; import java . util . * ; class GFG { static int minElements ( int arr [ ] , int n ) { int halfSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) halfSum = halfSum + arr [ i ] ; halfSum = halfSum / 2 ; Arrays . sort ( arr ) ; int res = 0 , curr_sum = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { curr_sum += arr [ i ] ; res ++ ; if ( curr_sum > halfSum ) return res ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 1 , 7 , 1 } ; int n = arr . length ; System . out . println ( minElements ( arr , n ) ) ; } } +","def minElements ( arr , n ) : NEW_LINE INDENT halfSum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT halfSum = halfSum + arr [ i ] NEW_LINE DEDENT halfSum = int ( halfSum / 2 ) NEW_LINE arr . sort ( reverse = True ) NEW_LINE res = 0 NEW_LINE curr_sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT curr_sum += arr [ i ] NEW_LINE res += 1 NEW_LINE if curr_sum > halfSum : NEW_LINE INDENT return res NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT arr = [ 3 , 1 , 7 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE print ( minElements ( arr , n ) ) NEW_LINE +" +E952,"class Test { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int a , int b ) { return ( a * b ) / gcd ( a , b ) ; } public static void main ( String [ ] args ) { int a = 15 , b = 20 ; System . out . println ( "" LCM ▁ of ▁ "" + a + "" ▁ and ▁ "" + b + "" ▁ is ▁ "" + lcm ( a , b ) ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if a == 0 : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b % a , a ) NEW_LINE DEDENT def lcm ( a , b ) : NEW_LINE INDENT return ( a * b ) / gcd ( a , b ) NEW_LINE DEDENT a = 15 NEW_LINE b = 20 NEW_LINE print ( ' LCM ▁ of ' , a , ' and ' , b , ' is ' , lcm ( a , b ) ) NEW_LINE +" +E953,"class GFG { static int MAX = 1000005 ; static boolean prime [ ] = new boolean [ MAX ] ; static void SieveOfEratosthenes ( boolean [ ] prime ) { prime [ 1 ] = false ; prime [ 0 ] = false ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } } static void prime_xor ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i < MAX ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { if ( ( i + 1 ) % k == 0 ) { ans ^= arr [ i ] ; } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 5 , 7 , 11 , 8 } ; int n = arr . length ; int K = 2 ; prime_xor ( arr , n , K ) ; } } +","MAX = 1000005 NEW_LINE def SieveOfEratosthenes ( prime ) : NEW_LINE INDENT prime [ 1 ] = False ; NEW_LINE prime [ 0 ] = False ; NEW_LINE for p in range ( 2 , int ( MAX ** ( 1 / 2 ) ) ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * 2 , MAX , p ) : NEW_LINE INDENT prime [ i ] = False ; NEW_LINE DEDENT DEDENT DEDENT DEDENT def prime_xor ( arr , n , k ) : NEW_LINE INDENT prime = [ True ] * MAX ; NEW_LINE SieveOfEratosthenes ( prime ) ; NEW_LINE ans = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( prime [ arr [ i ] ] ) : NEW_LINE INDENT if ( ( i + 1 ) % k == 0 ) : NEW_LINE INDENT ans ^= arr [ i ] ; NEW_LINE DEDENT DEDENT DEDENT print ( ans ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 3 , 5 , 7 , 11 , 8 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE K = 2 ; NEW_LINE prime_xor ( arr , n , K ) ; NEW_LINE DEDENT +" +E954,"import java . util . * ; class GFG { static void computeTotient ( int n ) { long phi [ ] = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) phi [ i ] = i ; for ( int p = 2 ; p <= n ; p ++ ) { if ( phi [ p ] == p ) { phi [ p ] = p - 1 ; for ( int i = 2 * p ; i <= n ; i += p ) { phi [ i ] = ( phi [ i ] / p ) * ( p - 1 ) ; } } } for ( int i = 1 ; i <= n ; i ++ ) System . out . println ( "" Totient ▁ of ▁ "" + i + "" ▁ is ▁ "" + phi [ i ] ) ; } public static void main ( String [ ] args ) { int n = 12 ; computeTotient ( n ) ; } } +","def computeTotient ( n ) : NEW_LINE INDENT phi = [ ] NEW_LINE for i in range ( n + 2 ) : NEW_LINE INDENT phi . append ( 0 ) NEW_LINE DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT phi [ i ] = i NEW_LINE DEDENT for p in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( phi [ p ] == p ) : NEW_LINE INDENT phi [ p ] = p - 1 NEW_LINE for i in range ( 2 * p , n + 1 , p ) : NEW_LINE INDENT phi [ i ] = ( phi [ i ] // p ) * ( p - 1 ) NEW_LINE DEDENT DEDENT DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT print ( "" Totient ▁ of ▁ "" , i , "" ▁ is ▁ "" , phi [ i ] ) NEW_LINE DEDENT DEDENT n = 12 NEW_LINE computeTotient ( n ) NEW_LINE +" +E955,"class GFG { static int countDigit ( int n ) { int temp = n , count = 0 ; while ( temp != 0 ) { int d = temp % 10 ; temp /= 10 ; if ( d == 2 || d == 3 || d == 5 || d == 7 ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int n = 1234567890 ; System . out . println ( countDigit ( n ) ) ; } } +","def countDigit ( n ) : NEW_LINE INDENT temp = n NEW_LINE count = 0 NEW_LINE while ( temp != 0 ) : NEW_LINE INDENT d = temp % 10 NEW_LINE temp //= 10 NEW_LINE if ( d == 2 or d == 3 or d == 5 or d == 7 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 1234567890 NEW_LINE print ( countDigit ( n ) ) NEW_LINE DEDENT +" +E956,"class GFG { static char getChar ( String str ) { int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { sum += ( str . charAt ( i ) - ' a ' + 1 ) ; } if ( sum % 26 == 0 ) return ' z ' ; else { sum = sum % 26 ; return ( char ) ( ' a ' + sum - 1 ) ; } } public static void main ( String [ ] args ) { String str = "" gfg "" ; System . out . println ( getChar ( str ) ) ; } } +","def getChar ( strr ) : NEW_LINE INDENT summ = 0 NEW_LINE for i in range ( len ( strr ) ) : NEW_LINE INDENT summ += ( ord ( strr [ i ] ) - ord ( ' a ' ) + 1 ) NEW_LINE DEDENT if ( summ % 26 == 0 ) : NEW_LINE INDENT return ord ( ' z ' ) NEW_LINE DEDENT else : NEW_LINE INDENT summ = summ % 26 NEW_LINE return chr ( ord ( ' a ' ) + summ - 1 ) NEW_LINE DEDENT DEDENT strr = "" gfg "" NEW_LINE print ( getChar ( strr ) ) NEW_LINE +" +E957,"class GFG { static int countWays ( int n , int arr [ ] , int len ) { int count [ ] = new int [ n + 1 ] ; count [ 0 ] = 1 ; if ( n == 0 ) return 1 ; for ( int i = 1 ; i <= n ; i ++ ) { int no_ways = 0 ; for ( int j = 0 ; j < len ; j ++ ) { if ( i - arr [ j ] >= 0 ) { no_ways += count [ i - arr [ j ] ] ; } count [ i ] = no_ways ; } } return count [ n ] ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 5 } ; int len = arr . length ; int n = 5 ; System . out . print ( countWays ( n , arr , len ) ) ; } } +","def countWays ( n , arr ) : NEW_LINE INDENT count = [ 0 ] * ( n + 1 ) NEW_LINE count [ 0 ] = 1 NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT no_ways = 0 NEW_LINE for j in arr : NEW_LINE INDENT if ( i - j >= 0 ) : NEW_LINE INDENT no_ways += count [ i - j ] NEW_LINE DEDENT count [ i ] = no_ways NEW_LINE DEDENT DEDENT return count [ n ] NEW_LINE DEDENT arr = [ 1 , 3 , 5 ] NEW_LINE n = 5 NEW_LINE print ( countWays ( n , arr ) ) NEW_LINE +" +E958,"import java . util . * ; public class PrimeNumber { static void primeOccurences ( int [ ] arr , int k ) { Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { int val = arr [ i ] ; int freq ; if ( map . containsKey ( val ) ) { freq = map . get ( val ) ; freq ++ ; } else freq = 1 ; map . put ( val , freq ) ; } for ( Map . Entry < Integer , Integer > entry : map . entrySet ( ) ) { int value = entry . getValue ( ) ; if ( isPrime ( value ) && value >= k ) System . out . println ( entry . getKey ( ) ) ; } } private static boolean isPrime ( int n ) { if ( ( n > 2 && n % 2 == 0 ) || n == 1 ) return false ; for ( int i = 3 ; i <= ( int ) Math . sqrt ( n ) ; i += 2 ) { if ( n % i == 0 ) return false ; } return true ; } public static void main ( String [ ] args ) { int [ ] arr = { 11 , 11 , 11 , 23 , 11 , 37 , 37 , 51 , 51 , 51 , 51 , 51 } ; int k = 2 ; primeOccurences ( arr , k ) ; } } +","def primeOccurences ( arr , k ) : NEW_LINE INDENT map = { } NEW_LINE for val in arr : NEW_LINE INDENT freq = 0 NEW_LINE if val in map : NEW_LINE INDENT freq = map [ val ] NEW_LINE freq += 1 NEW_LINE DEDENT else : NEW_LINE INDENT freq = 1 NEW_LINE DEDENT map [ val ] = freq NEW_LINE DEDENT for entry in map : NEW_LINE INDENT value = map [ entry ] NEW_LINE if isPrime ( value ) and value >= k : NEW_LINE INDENT print ( entry ) NEW_LINE DEDENT DEDENT DEDENT def isPrime ( n ) : NEW_LINE INDENT if ( n > 2 and not n % 2 ) or n == 1 : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( 3 , int ( n ** 0.5 + 1 ) , 2 ) : NEW_LINE INDENT if not n % i : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT arr = [ 11 , 11 , 11 , 23 , 11 , 37 , 37 , 51 , 51 , 51 , 51 , 51 ] NEW_LINE k = 2 NEW_LINE primeOccurences ( arr , k ) NEW_LINE +" +E959,"import java . io . * ; class GFG { static int Nth_Term ( int n ) { return ( int ) ( 3 * Math . pow ( n , 2 ) - n + 2 ) / ( 2 ) ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( Nth_Term ( N ) ) ; } } +","def Nth_Term ( n ) : NEW_LINE INDENT return ( 3 * pow ( n , 2 ) - n + 2 ) // ( 2 ) NEW_LINE DEDENT N = 5 NEW_LINE print ( Nth_Term ( N ) ) NEW_LINE +" +E960,"import java . util . * ; class GFG { static long sum ( long n ) { long root = ( long ) Math . sqrt ( n ) ; long ans = 0 ; for ( int i = 1 ; i <= root ; i ++ ) ans += n / i ; ans = 2 * ans - ( root * root ) ; return ans ; } public static void main ( String [ ] args ) { long n = 35 ; System . out . println ( sum ( n ) ) ; } } +","import math NEW_LINE def sum ( n ) : NEW_LINE INDENT root = ( int ) ( math . sqrt ( n ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , root + 1 ) : NEW_LINE INDENT ans = ans + n // i NEW_LINE DEDENT ans = 2 * ans - ( root * root ) NEW_LINE return ans NEW_LINE DEDENT n = 35 NEW_LINE print ( sum ( n ) ) NEW_LINE +" +E961,"import java . util . * ; import java . lang . Math ; public class autobio { public static boolean isAutoBio ( int num ) { String autoStr ; int index , number , i , j , cnt ; autoStr = Integer . toString ( num ) ; for ( i = 0 ; i < autoStr . length ( ) ; i ++ ) { index = Integer . parseInt ( autoStr . charAt ( i ) + "" "" ) ; cnt = 0 ; for ( j = 0 ; j < autoStr . length ( ) ; j ++ ) { number = Integer . parseInt ( autoStr . charAt ( j ) + "" "" ) ; if ( number == i ) cnt ++ ; } if ( cnt != index ) return false ; } return true ; } public static void findAutoBios ( double n ) { double high , low ; int i , flag = 0 ; low = Math . pow ( 10.0 , n - 1 ) ; high = Math . pow ( 10.0 , n ) - 1.0 ; for ( i = ( int ) low ; i <= ( int ) high ; i ++ ) if ( isAutoBio ( i ) ) { flag = 1 ; System . out . print ( i + "" , ▁ "" ) ; } if ( flag == 0 ) System . out . println ( "" There ▁ is ▁ no ▁ Autobiographical ▁ Number "" + "" with ▁ "" + ( int ) n + "" ▁ digits "" ) ; } public static void main ( String [ ] args ) { double N = 0 ; findAutoBios ( N ) ; N = 4 ; findAutoBios ( N ) ; } } +","from math import pow NEW_LINE def isAutoBio ( num ) : NEW_LINE INDENT autoStr = str ( num ) NEW_LINE for i in range ( 0 , len ( autoStr ) ) : NEW_LINE INDENT index = int ( autoStr [ i ] ) NEW_LINE cnt = 0 NEW_LINE for j in range ( 0 , len ( autoStr ) ) : NEW_LINE INDENT number = int ( autoStr [ j ] ) NEW_LINE if number == i : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT if cnt != index : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def findAutoBios ( n ) : NEW_LINE INDENT low = int ( pow ( 10 , n - 1 ) ) NEW_LINE high = int ( pow ( 10 , n ) - 1 ) NEW_LINE flag = 0 NEW_LINE for i in range ( low , high + 1 ) : NEW_LINE INDENT if isAutoBio ( i ) : NEW_LINE INDENT flag = 1 NEW_LINE print ( i , end = ' , ▁ ' ) NEW_LINE DEDENT DEDENT if flag == 0 : NEW_LINE INDENT print ( "" There ▁ is ▁ no ▁ Autobiographical ▁ Number ▁ with ▁ "" + str ( n ) + "" ▁ digits "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 0 NEW_LINE findAutoBios ( N ) NEW_LINE N = 4 NEW_LINE findAutoBios ( N ) NEW_LINE DEDENT +" +E962,"class GFG { static boolean isLucky ( int n ) { boolean arr [ ] = new boolean [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) arr [ i ] = false ; while ( n > 0 ) { int digit = n % 10 ; if ( arr [ digit ] ) return false ; arr [ digit ] = true ; n = n / 10 ; } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 1291 , 897 , 4566 , 1232 , 80 , 700 } ; int n = arr . length ; for ( int i = 0 ; i < n ; i ++ ) if ( isLucky ( arr [ i ] ) ) System . out . print ( arr [ i ] + "" ▁ is ▁ Lucky ▁ \n "" ) ; else System . out . print ( arr [ i ] + "" ▁ is ▁ not ▁ Lucky ▁ \n "" ) ; } } +","import math NEW_LINE def isLucky ( n ) : NEW_LINE INDENT ar = [ 0 ] * 10 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT digit = math . floor ( n % 10 ) NEW_LINE if ( ar [ digit ] ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT ar [ digit ] = 1 NEW_LINE n = n / 10 NEW_LINE DEDENT return 1 NEW_LINE DEDENT arr = [ 1291 , 897 , 4566 , 1232 , 80 , 700 ] NEW_LINE n = len ( arr ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT k = arr [ i ] NEW_LINE if ( isLucky ( k ) ) : NEW_LINE INDENT print ( k , "" ▁ is ▁ Lucky ▁ "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( k , "" ▁ is ▁ not ▁ Lucky ▁ "" ) NEW_LINE DEDENT DEDENT +" +E963,"class GFG { static void printSeriesSum ( int N ) { double sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) { sum += ( double ) i / ( i + 1 ) ; } else { sum -= ( double ) i / ( i + 1 ) ; } } System . out . print ( sum + "" \n "" ) ; } public static void main ( String [ ] args ) { int N = 10 ; printSeriesSum ( N ) ; } } +","def printSeriesSum ( N ) : NEW_LINE INDENT sum = 0 ; NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( i & 1 ) : NEW_LINE INDENT sum += i / ( i + 1 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT sum -= i / ( i + 1 ) ; NEW_LINE DEDENT DEDENT print ( sum ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 10 ; NEW_LINE printSeriesSum ( N ) ; NEW_LINE DEDENT +" +E964,"class GFG { static int __gcd ( int a , int b ) { if ( b == 0 ) { return a ; } else { return __gcd ( b , a % b ) ; } } static int power ( int x , int y , int m ) { if ( y == 0 ) return 1 ; int p = power ( x , y / 2 , m ) % m ; p = ( p * p ) % m ; return ( y % 2 == 0 ) ? p : ( x * p ) % m ; } static void modInverse ( int a , int m ) { if ( __gcd ( a , m ) != 1 ) System . out . print ( "" Inverse ▁ doesn ' t ▁ exist "" ) ; else { System . out . print ( "" Modular ▁ multiplicative ▁ inverse ▁ is ▁ "" + power ( a , m - 2 , m ) ) ; } } public static void main ( String [ ] args ) { int a = 3 , m = 11 ; modInverse ( a , m ) ; } } +","def __gcd ( a , b ) : NEW_LINE INDENT if ( b == 0 ) : NEW_LINE INDENT return a NEW_LINE DEDENT else : NEW_LINE INDENT return __gcd ( b , a % b ) NEW_LINE DEDENT DEDENT def power ( x , y , m ) : NEW_LINE INDENT if ( y == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT p = power ( x , y // 2 , m ) % m NEW_LINE p = ( p * p ) % m NEW_LINE return p if ( y % 2 == 0 ) else ( x * p ) % m NEW_LINE DEDENT def modInverse ( a , m ) : NEW_LINE INDENT if ( __gcd ( a , m ) != 1 ) : NEW_LINE INDENT print ( "" Inverse ▁ doesn ' t ▁ exist "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Modular ▁ multiplicative ▁ inverse ▁ is ▁ "" , power ( a , m - 2 , m ) ) NEW_LINE DEDENT DEDENT a = 3 NEW_LINE m = 11 NEW_LINE modInverse ( a , m ) NEW_LINE +" +E965,"import java . io . * ; class GFG { 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 ) ; } static int countPrimeFactors ( int x ) { int res = 0 ; if ( x % 2 == 0 ) { res ++ ; while ( x % 2 == 0 ) x = x / 2 ; } for ( int i = 3 ; i <= Math . sqrt ( x ) ; i = i + 2 ) { if ( x % i == 0 ) { res ++ ; while ( x % i == 0 ) x = x / i ; } } if ( x > 2 ) res ++ ; return res ; } static int countCommonPrimeFactors ( int a , int b ) { int gcd = __gcd ( a , b ) ; return countPrimeFactors ( gcd ) ; } public static void main ( String [ ] args ) { int a = 6 , b = 12 ; System . out . println ( countCommonPrimeFactors ( a , b ) ) ; } } +","from math import sqrt , gcd NEW_LINE def countPrimeFactors ( x ) : NEW_LINE INDENT res = 0 NEW_LINE if ( x % 2 == 0 ) : NEW_LINE INDENT res += 1 NEW_LINE while ( x % 2 == 0 ) : NEW_LINE INDENT x = x / 2 NEW_LINE DEDENT DEDENT k = int ( sqrt ( x ) ) + 1 NEW_LINE for i in range ( 3 , k , 2 ) : NEW_LINE INDENT if ( x % i == 0 ) : NEW_LINE INDENT res += 1 NEW_LINE while ( x % i == 0 ) : NEW_LINE INDENT x = x / i NEW_LINE DEDENT DEDENT DEDENT if ( x > 2 ) : NEW_LINE INDENT res += 1 NEW_LINE DEDENT return res NEW_LINE DEDENT def countCommonPrimeFactors ( a , b ) : NEW_LINE INDENT gcd__ = gcd ( a , b ) NEW_LINE return countPrimeFactors ( gcd__ ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 6 NEW_LINE b = 12 NEW_LINE print ( countCommonPrimeFactors ( a , b ) ) NEW_LINE DEDENT +" +E966,"class Factorial { int factorial ( int n ) { return ( n == 1 || n == 0 ) ? 1 : n * factorial ( n - 1 ) ; } public static void main ( String args [ ] ) { Factorial obj = new Factorial ( ) ; int num = 5 ; System . out . println ( "" Factorial ▁ of ▁ "" + num + "" ▁ is ▁ "" + obj . factorial ( num ) ) ; } } +","def factorial ( n ) : NEW_LINE INDENT return 1 if ( n == 1 or n == 0 ) else n * factorial ( n - 1 ) NEW_LINE DEDENT num = 5 NEW_LINE print ( "" Factorial ▁ of "" , num , "" is "" , factorial ( num ) ) NEW_LINE +" +E967,"import java . util . * ; class Digits { public static int getFirstDigit ( int x ) { while ( x >= 10 ) x /= 10 ; return x ; } public static int getCountWithSameStartAndEndFrom1 ( int x ) { if ( x < 10 ) return x ; int tens = x / 10 ; int res = tens + 9 ; int firstDigit = getFirstDigit ( x ) ; int lastDigit = x % 10 ; if ( lastDigit < firstDigit ) res -- ; return res ; } public static int getCountWithSameStartAndEnd ( int start , int end ) { return getCountWithSameStartAndEndFrom1 ( end ) - getCountWithSameStartAndEndFrom1 ( start - 1 ) ; } public static void main ( String [ ] args ) { int start = 5 , end = 40 ; System . out . print ( getCountWithSameStartAndEnd ( start , end ) ) ; } } +","def getFirstDigit ( x ) : NEW_LINE INDENT while ( x >= 10 ) : NEW_LINE INDENT x /= 10 NEW_LINE DEDENT return x NEW_LINE DEDENT def getCountWithSameStartAndEndFrom1 ( x ) : NEW_LINE INDENT if ( x < 10 ) : NEW_LINE INDENT return x NEW_LINE DEDENT tens = x / 10 NEW_LINE res = tens + 9 NEW_LINE firstDigit = getFirstDigit ( x ) NEW_LINE lastDigit = x % 10 NEW_LINE if ( lastDigit < firstDigit ) : NEW_LINE INDENT res = res - 1 NEW_LINE DEDENT return res NEW_LINE DEDENT def getCountWithSameStartAndEnd ( start , end ) : NEW_LINE INDENT return ( getCountWithSameStartAndEndFrom1 ( end ) - getCountWithSameStartAndEndFrom1 ( start - 1 ) ) NEW_LINE DEDENT start = 5 NEW_LINE end = 40 NEW_LINE print ( getCountWithSameStartAndEnd ( start , end ) ) NEW_LINE +" +E968,"import java . util . * ; class GFG { static String find_number ( int N , int K ) { String r ; if ( N % 100 == 0 ) { N += 1 ; r = String . valueOf ( N ) ; } else { r = String . valueOf ( N ) ; } for ( int i = 1 ; i <= K ; i ++ ) r += ""00"" ; return r ; } public static void main ( String [ ] args ) { int N = 1000 , K = 2 ; String ans = find_number ( N , K ) ; System . out . println ( ans ) ; } } +","def find_number ( N , K ) : NEW_LINE INDENT r = "" "" NEW_LINE if ( N % 100 == 0 ) : NEW_LINE INDENT N += 1 ; NEW_LINE r = str ( N ) NEW_LINE DEDENT else : NEW_LINE INDENT r = str ( N ) NEW_LINE DEDENT for i in range ( 1 , K + 1 ) : NEW_LINE INDENT r += ""00"" NEW_LINE DEDENT return r NEW_LINE DEDENT N = 1000 NEW_LINE K = 2 ; NEW_LINE ans = find_number ( N , K ) NEW_LINE print ( ans ) NEW_LINE +" +E969,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int digitSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += n % 10 ; n = n / 10 ; } return sum ; } static int totalPairs ( int arr1 [ ] , int arr2 [ ] , int n , int m ) { Set < pair > s = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( digitSum ( arr1 [ i ] ) == digitSum ( arr2 [ j ] ) ) { if ( arr1 [ i ] < arr2 [ j ] ) s . add ( new pair ( arr1 [ i ] , arr2 [ j ] ) ) ; else s . add ( new pair ( arr2 [ j ] , arr1 [ i ] ) ) ; } } } return s . size ( ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 100 , 3 , 7 , 50 } ; int arr2 [ ] = { 5 , 1 , 10 , 4 } ; int n = arr1 . length ; int m = arr2 . length ; System . out . println ( totalPairs ( arr1 , arr2 , n , m ) ) ; } } +","def digitSum ( n ) : NEW_LINE INDENT Sum = 0 NEW_LINE while n > 0 : NEW_LINE INDENT Sum += n % 10 NEW_LINE n = n // 10 NEW_LINE DEDENT return Sum NEW_LINE DEDENT def totalPairs ( arr1 , arr2 , n , m ) : NEW_LINE INDENT s = set ( ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 0 , m ) : NEW_LINE INDENT if digitSum ( arr1 [ i ] ) == digitSum ( arr2 [ j ] ) : NEW_LINE INDENT if arr1 [ i ] < arr2 [ j ] : NEW_LINE INDENT s . add ( ( arr1 [ i ] , arr2 [ j ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT s . add ( ( arr2 [ j ] , arr1 [ i ] ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return len ( s ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr1 = [ 100 , 3 , 7 , 50 ] NEW_LINE arr2 = [ 5 , 1 , 10 , 4 ] NEW_LINE n = len ( arr1 ) NEW_LINE m = len ( arr2 ) NEW_LINE print ( totalPairs ( arr1 , arr2 , n , m ) ) NEW_LINE DEDENT +" +E970,"class GFG { static int N = 5 ; static int func ( int idx , int cur , int a [ ] , int dp [ ] [ ] , int n , int x ) { if ( idx == n ) { return 0 ; } if ( dp [ idx ] [ cur ] != - 1 ) { return dp [ idx ] [ cur ] ; } int ans = 0 ; if ( cur == 0 ) { ans = Math . max ( ans , a [ idx ] + func ( idx + 1 , 0 , a , dp , n , x ) ) ; ans = Math . max ( ans , x * a [ idx ] + func ( idx + 1 , 1 , a , dp , n , x ) ) ; } else if ( cur == 1 ) { ans = Math . max ( ans , x * a [ idx ] + func ( idx + 1 , 1 , a , dp , n , x ) ) ; ans = Math . max ( ans , a [ idx ] + func ( idx + 1 , 2 , a , dp , n , x ) ) ; } else { ans = Math . max ( ans , a [ idx ] + func ( idx + 1 , 2 , a , dp , n , x ) ) ; } return dp [ idx ] [ cur ] = ans ; } static int getMaximumSum ( int a [ ] , int n , int x ) { int dp [ ] [ ] = new int [ n ] [ 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } int maxi = 0 ; for ( int i = 0 ; i < n ; i ++ ) { maxi = Math . max ( maxi , func ( i , 0 , a , dp , n , x ) ) ; } return maxi ; } public static void main ( String [ ] args ) { int a [ ] = { - 3 , 8 , - 2 , 1 , - 6 } ; int n = a . length ; int x = - 1 ; System . out . println ( getMaximumSum ( a , n , x ) ) ; } } +","N = 5 NEW_LINE def func ( idx , cur , a , dp , n , x ) : NEW_LINE INDENT if ( idx == n ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( dp [ idx ] [ cur ] != - 1 ) : NEW_LINE INDENT return dp [ idx ] [ cur ] NEW_LINE DEDENT ans = 0 NEW_LINE if ( cur == 0 ) : NEW_LINE INDENT ans = max ( ans , a [ idx ] + func ( idx + 1 , 0 , a , dp , n , x ) ) NEW_LINE ans = max ( ans , x * a [ idx ] + func ( idx + 1 , 1 , a , dp , n , x ) ) NEW_LINE DEDENT elif ( cur == 1 ) : NEW_LINE INDENT ans = max ( ans , x * a [ idx ] + func ( idx + 1 , 1 , a , dp , n , x ) ) NEW_LINE ans = max ( ans , a [ idx ] + func ( idx + 1 , 2 , a , dp , n , x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = max ( ans , a [ idx ] + func ( idx + 1 , 2 , a , dp , n , x ) ) NEW_LINE DEDENT dp [ idx ] [ cur ] = ans NEW_LINE return dp [ idx ] [ cur ] NEW_LINE DEDENT def getMaximumSum ( a , n , x ) : NEW_LINE INDENT dp = [ [ - 1 for i in range ( 3 ) ] for j in range ( n ) ] NEW_LINE maxi = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT maxi = max ( maxi , func ( i , 0 , a , dp , n , x ) ) NEW_LINE DEDENT return maxi NEW_LINE DEDENT a = [ - 3 , 8 , - 2 , 1 , - 6 ] NEW_LINE n = len ( a ) NEW_LINE x = - 1 NEW_LINE print ( getMaximumSum ( a , n , x ) ) NEW_LINE +" +E971,"import java . lang . Math ; class GFG { static int exponent ( int A , int B ) { if ( A == 0 ) return 0 ; if ( B == 0 ) return 1 ; int y ; if ( B % 2 == 0 ) { y = exponent ( A , B / 2 ) ; y = ( y * y ) ; } else { y = A ; y = ( y * exponent ( A , B - 1 ) ) ; } return y ; } static int sum ( int k , int n ) { int sum = exponent ( k , n + 1 ) - exponent ( k - 1 , n + 1 ) ; return sum ; } public static void main ( String [ ] args ) { int n = 3 ; int K = 3 ; System . out . println ( sum ( K , n ) ) ; } } +","def exponent ( A , B ) : NEW_LINE INDENT if ( A == 0 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT if ( B == 0 ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT if ( B % 2 == 0 ) : NEW_LINE INDENT y = exponent ( A , B / 2 ) ; NEW_LINE y = ( y * y ) ; NEW_LINE DEDENT else : NEW_LINE INDENT y = A ; NEW_LINE y = ( y * exponent ( A , B - 1 ) ) ; NEW_LINE DEDENT return y ; NEW_LINE DEDENT def sum ( k , n ) : NEW_LINE INDENT sum = exponent ( k , n + 1 ) - exponent ( k - 1 , n + 1 ) ; NEW_LINE return sum ; NEW_LINE DEDENT n = 3 ; NEW_LINE K = 3 ; NEW_LINE print ( sum ( K , n ) ) ; NEW_LINE +" +E972,"import java . util . * ; class GFG { static int MAX = 1000000 ; static ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; static void sieve ( ) { int n = MAX ; int nNew = ( n ) / 2 ; boolean [ ] marked = new boolean [ nNew + 100 ] ; int tmp = ( int ) Math . sqrt ( n ) ; for ( int i = 1 ; i <= ( tmp - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= nNew ; j = j + 2 * i + 1 ) marked [ j ] = true ; primes . add ( 2 ) ; for ( int i = 1 ; i <= nNew ; i ++ ) if ( marked [ i ] == false ) primes . add ( 2 * i + 1 ) ; } static void primeLcm ( int [ ] arr , int n ) { int [ ] factors = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { int copy = arr [ i ] ; int sqr = ( int ) Math . sqrt ( copy ) ; for ( int j = 0 ; primes . get ( j ) <= sqr ; j ++ ) { if ( copy % primes . get ( j ) == 0 ) { while ( copy % primes . get ( j ) == 0 ) copy = copy / primes . get ( j ) ; factors [ primes . get ( j ) ] = 1 ; } } if ( copy > 1 ) factors [ copy ] = 1 ; } if ( factors [ 2 ] == 1 ) System . out . print ( ""2 ▁ "" ) ; for ( int i = 3 ; i <= MAX ; i = i + 2 ) if ( factors [ i ] == 1 ) System . out . print ( i + "" ▁ "" ) ; } public static void main ( String [ ] args ) { sieve ( ) ; int [ ] arr = { 20 , 10 , 15 , 60 } ; int n = arr . length ; primeLcm ( arr , n ) ; } } +","import math ; NEW_LINE MAX = 10000 ; NEW_LINE primes = [ ] ; NEW_LINE def sieve ( ) : NEW_LINE INDENT n = MAX ; NEW_LINE nNew = int ( n / 2 ) ; NEW_LINE marked = [ False ] * ( nNew + 100 ) ; NEW_LINE tmp = int ( math . sqrt ( n ) ) ; NEW_LINE for i in range ( 1 , int ( ( tmp - 1 ) / 2 ) + 1 ) : NEW_LINE INDENT for j in range ( ( i * ( i + 1 ) ) << 1 , nNew + 1 , 2 * i + 1 ) : NEW_LINE INDENT marked [ j ] = True ; NEW_LINE DEDENT DEDENT primes . append ( 2 ) ; NEW_LINE for i in range ( 1 , nNew + 1 ) : NEW_LINE INDENT if ( marked [ i ] == False ) : NEW_LINE INDENT primes . append ( 2 * i + 1 ) ; NEW_LINE DEDENT DEDENT DEDENT def primeLcm ( arr , n ) : NEW_LINE INDENT factors = [ 0 ] * ( MAX ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT copy = arr [ i ] ; NEW_LINE sqr = int ( math . sqrt ( copy ) ) ; NEW_LINE j = 0 ; NEW_LINE while ( primes [ j ] <= sqr ) : NEW_LINE INDENT if ( copy % primes [ j ] == 0 ) : NEW_LINE INDENT while ( copy % primes [ j ] == 0 ) : NEW_LINE INDENT copy = int ( copy / primes [ j ] ) ; NEW_LINE DEDENT factors [ primes [ j ] ] = 1 ; NEW_LINE DEDENT j += 1 ; NEW_LINE DEDENT if ( copy > 1 ) : NEW_LINE INDENT factors [ copy ] = 1 ; NEW_LINE DEDENT DEDENT if ( factors [ 2 ] == 1 ) : NEW_LINE INDENT print ( ""2 ▁ "" , end = "" "" ) ; NEW_LINE DEDENT for i in range ( 3 , MAX + 1 , 2 ) : NEW_LINE INDENT if ( factors [ i ] == 1 ) : NEW_LINE INDENT print ( i , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT DEDENT sieve ( ) ; NEW_LINE arr = [ 20 , 10 , 15 , 60 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE primeLcm ( arr , n ) ; NEW_LINE +" +E973,"import java . util . * ; class GFG { static int Alcuin ( int n ) { double _n = n , ans ; ans = Math . round ( ( _n * _n ) / 12 ) - Math . floor ( _n / 4 ) * Math . floor ( ( _n + 2 ) / 4 ) ; return ( int ) ans ; } static void solve ( int n ) { int i = 0 ; for ( i = 1 ; i <= n ; i ++ ) { System . out . print ( Alcuin ( i ) + "" , ▁ "" ) ; } } public static void main ( String [ ] args ) { int n = 15 ; solve ( n ) ; } } +","from math import ceil , floor NEW_LINE def Alcuin ( n ) : NEW_LINE INDENT _n = n NEW_LINE ans = 0 NEW_LINE ans = ( round ( ( _n * _n ) / 12 ) - floor ( _n / 4 ) * floor ( ( _n + 2 ) / 4 ) ) NEW_LINE return ans NEW_LINE DEDENT def solve ( n ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT print ( Alcuin ( i ) , end = "" , ▁ "" ) NEW_LINE DEDENT DEDENT n = 15 NEW_LINE solve ( n ) NEW_LINE +" +E974,"class GFG { static int getMSB ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return ( ( n + 1 ) >> 2 ) ; } static void multiply ( int F [ ] [ ] , int M [ ] [ ] ) { int x = F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ; int y = F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ; int z = F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ; int w = F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } static void power ( int F [ ] [ ] , int n ) { if ( n == 0 || n == 1 ) return ; int [ ] [ ] M = { { 1 , 1 } , { 1 , 0 } } ; for ( int m = getMSB ( n ) ; m > 0 ; m = m >> 1 ) { multiply ( F , F ) ; if ( ( n & m ) > 0 ) { multiply ( F , M ) ; } } } static int fib ( int n ) { int [ ] [ ] F = { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n - 1 ) ; return F [ 0 ] [ 0 ] ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( fib ( n ) ) ; } } +","def getMSB ( n ) : NEW_LINE INDENT n |= n >> 1 NEW_LINE n |= n >> 2 NEW_LINE n |= n >> 4 NEW_LINE n |= n >> 8 NEW_LINE n |= n >> 16 NEW_LINE return ( ( n + 1 ) >> 2 ) NEW_LINE DEDENT def multiply ( F , M ) : NEW_LINE INDENT x = F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] NEW_LINE y = F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] NEW_LINE z = F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] NEW_LINE w = F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] NEW_LINE F [ 0 ] [ 0 ] = x NEW_LINE F [ 0 ] [ 1 ] = y NEW_LINE F [ 1 ] [ 0 ] = z NEW_LINE F [ 1 ] [ 1 ] = w NEW_LINE DEDENT def power ( F , n ) : NEW_LINE INDENT if ( n == 0 or n == 1 ) : NEW_LINE INDENT return NEW_LINE DEDENT M = [ [ 1 , 1 ] , [ 1 , 0 ] ] NEW_LINE m = getMSB ( n ) NEW_LINE while m : NEW_LINE INDENT multiply ( F , F ) NEW_LINE if ( n & m ) : NEW_LINE INDENT multiply ( F , M ) NEW_LINE DEDENT m = m >> 1 NEW_LINE DEDENT DEDENT def fib ( n ) : NEW_LINE INDENT F = [ [ 1 , 1 ] , [ 1 , 0 ] ] NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT power ( F , n - 1 ) NEW_LINE return F [ 0 ] [ 0 ] NEW_LINE DEDENT n = 6 NEW_LINE print ( fib ( n ) ) NEW_LINE +" +E975,"public class GFG { static void printMinIndexChar ( String str , String patt ) { int minIndex = Integer . MAX_VALUE ; int m = str . length ( ) ; int n = patt . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( patt . charAt ( i ) == str . charAt ( j ) && j < minIndex ) { minIndex = j ; break ; } } } if ( minIndex != Integer . MAX_VALUE ) System . out . println ( "" Minimum ▁ Index ▁ Character ▁ = ▁ "" + str . charAt ( minIndex ) ) ; else System . out . println ( "" No ▁ character ▁ present "" ) ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; String patt = "" set "" ; printMinIndexChar ( str , patt ) ; } } +","def printMinIndexChar ( Str , patt ) : NEW_LINE INDENT minIndex = 10 ** 9 NEW_LINE m = len ( Str ) NEW_LINE n = len ( patt ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if ( patt [ i ] == Str [ j ] and j < minIndex ) : NEW_LINE INDENT minIndex = j NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if ( minIndex != 10 ** 9 ) : NEW_LINE INDENT print ( "" Minimum ▁ Index ▁ Character ▁ = ▁ "" , Str [ minIndex ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No ▁ character ▁ present "" ) NEW_LINE DEDENT DEDENT Str = "" geeksforgeeks "" NEW_LINE patt = "" set "" NEW_LINE printMinIndexChar ( Str , patt ) NEW_LINE +" +E976,"class GFG { static int squares ( int l , int b , int a ) { return ( int ) ( Math . ceil ( l / ( double ) a ) * Math . ceil ( b / ( double ) a ) ) ; } public static void main ( String [ ] args ) { int l = 11 , b = 23 , a = 14 ; System . out . println ( squares ( l , b , a ) ) ; } } +","import math NEW_LINE def squares ( l , b , a ) : NEW_LINE INDENT return math . ceil ( l / a ) * math . ceil ( b / a ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT l = 11 NEW_LINE b = 23 NEW_LINE a = 14 NEW_LINE print ( squares ( l , b , a ) ) NEW_LINE DEDENT +" +E977,"void append ( int new_data ) { Node new_node = new Node ( new_data ) ; Node last = head ; new_node . next = null ; if ( head == null ) { new_node . prev = null ; head = new_node ; return ; } while ( last . next != null ) last = last . next ; last . next = new_node ; new_node . prev = last ; } +","def append ( self , new_data ) : NEW_LINE INDENT new_node = Node ( data = new_data ) NEW_LINE last = self . head NEW_LINE new_node . next = None NEW_LINE if self . head is None : NEW_LINE INDENT new_node . prev = None NEW_LINE self . head = new_node NEW_LINE return NEW_LINE DEDENT while ( last . next is not None ) : NEW_LINE INDENT last = last . next NEW_LINE DEDENT last . next = new_node NEW_LINE new_node . prev = last NEW_LINE DEDENT +" +E978,"import java . io . * ; class GFG { static void maxProductSum ( String str , int m ) { int n = str . length ( ) ; int maxProd = Integer . MIN_VALUE , maxSum = Integer . MIN_VALUE ; for ( int i = 0 ; i < n - m ; i ++ ) { int product = 1 , sum = 0 ; for ( int j = i ; j < m + i ; j ++ ) { product = product * ( str . charAt ( j ) - '0' ) ; sum = sum + ( str . charAt ( j ) - '0' ) ; } maxProd = Math . max ( maxProd , product ) ; maxSum = Math . max ( maxSum , sum ) ; } System . out . println ( "" Maximum ▁ Product ▁ = ▁ "" + maxProd ) ; System . out . print ( "" \n Maximum ▁ Sum ▁ = ▁ "" + maxSum ) ; } public static void main ( String [ ] args ) { String str = ""3675356291"" ; int m = 5 ; maxProductSum ( str , m ) ; } } +","import sys NEW_LINE def maxProductSum ( string , m ) : NEW_LINE INDENT n = len ( string ) NEW_LINE maxProd , maxSum = ( - ( sys . maxsize ) - 1 , - ( sys . maxsize ) - 1 ) NEW_LINE for i in range ( n - m ) : NEW_LINE INDENT product , sum = 1 , 0 NEW_LINE for j in range ( i , m + i ) : NEW_LINE INDENT product = product * ( ord ( string [ j ] ) - ord ( '0' ) ) NEW_LINE sum = sum + ( ord ( string [ j ] ) - ord ( '0' ) ) NEW_LINE DEDENT maxProd = max ( maxProd , product ) NEW_LINE maxSum = max ( maxSum , sum ) NEW_LINE DEDENT print ( "" Maximum ▁ Product ▁ = "" , maxProd ) NEW_LINE print ( "" Maximum ▁ sum ▁ = "" , maxSum ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = ""3675356291"" NEW_LINE m = 5 NEW_LINE maxProductSum ( string , m ) NEW_LINE DEDENT +" +E979,"class GFG { static void findPhoneNumber ( int n ) { int temp = n ; int sum = 0 ; while ( temp != 0 ) { sum += temp % 10 ; temp = temp / 10 ; } if ( sum < 10 ) System . out . print ( n + ""0"" + sum ) ; else System . out . print ( n + "" "" + sum ) ; } public static void main ( String [ ] args ) { int n = 98765432 ; findPhoneNumber ( n ) ; } } +","def findPhoneNumber ( n ) : NEW_LINE INDENT temp = n NEW_LINE sum = 0 NEW_LINE while ( temp != 0 ) : NEW_LINE INDENT sum += temp % 10 NEW_LINE temp = temp // 10 NEW_LINE DEDENT if ( sum < 10 ) : NEW_LINE INDENT print ( n , ""0"" , sum ) NEW_LINE DEDENT else : NEW_LINE INDENT n = str ( n ) NEW_LINE sum = str ( sum ) NEW_LINE n += sum NEW_LINE print ( n ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 98765432 NEW_LINE findPhoneNumber ( n ) NEW_LINE DEDENT +" +E980,"class GFG { static int countOfSubarrays ( int [ ] arr , int n ) { int count = 0 ; int [ ] v = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) v [ arr [ i ] ] = i ; int maximum = Integer . MIN_VALUE ; int minimum = Integer . MAX_VALUE ; for ( int i = 1 ; i <= n ; i ++ ) { maximum = Math . max ( maximum , v [ i ] ) ; minimum = Math . min ( minimum , v [ i ] ) ; if ( maximum - minimum < i ) count = count + 1 ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 1 , 3 , 2 , 5 , 6 } ; int n = arr . length ; System . out . print ( countOfSubarrays ( arr , n ) + "" \n "" ) ; } } +","import sys NEW_LINE INT_MAX = sys . maxsize ; NEW_LINE INT_MIN = - ( sys . maxsize - 1 ) ; NEW_LINE def countOfSubarrays ( arr , n ) : NEW_LINE INDENT count = 0 ; NEW_LINE v = [ 0 ] * ( n + 1 ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT v [ arr [ i ] ] = i ; NEW_LINE DEDENT maximum = INT_MIN ; NEW_LINE minimum = INT_MAX ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT maximum = max ( maximum , v [ i ] ) ; NEW_LINE minimum = min ( minimum , v [ i ] ) ; NEW_LINE if ( maximum - minimum < i ) : NEW_LINE INDENT count = count + 1 ; NEW_LINE DEDENT DEDENT return count ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 4 , 1 , 3 , 2 , 5 , 6 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( countOfSubarrays ( arr , n ) ) ; NEW_LINE DEDENT +" +E981,"class GFG { static int maxSum ( int p0 , int p1 , int a [ ] , int pos , int n ) { if ( pos == n ) { if ( p0 == p1 ) return p0 ; else return 0 ; } int ans = maxSum ( p0 , p1 , a , pos + 1 , n ) ; ans = Math . max ( ans , maxSum ( p0 + a [ pos ] , p1 , a , pos + 1 , n ) ) ; ans = Math . max ( ans , maxSum ( p0 , p1 + a [ pos ] , a , pos + 1 , n ) ) ; return ans ; } public static void main ( String [ ] args ) { int n = 4 ; int a [ ] = { 1 , 2 , 3 , 6 } ; System . out . println ( maxSum ( 0 , 0 , a , 0 , n ) ) ; } } +","def maxSum ( p0 , p1 , a , pos , n ) : NEW_LINE INDENT if ( pos == n ) : NEW_LINE INDENT if ( p0 == p1 ) : NEW_LINE INDENT return p0 ; NEW_LINE DEDENT else : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT DEDENT ans = maxSum ( p0 , p1 , a , pos + 1 , n ) ; NEW_LINE ans = max ( ans , maxSum ( p0 + a [ pos ] , p1 , a , pos + 1 , n ) ) ; NEW_LINE ans = max ( ans , maxSum ( p0 , p1 + a [ pos ] , a , pos + 1 , n ) ) ; NEW_LINE return ans ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 4 ; NEW_LINE a = [ 1 , 2 , 3 , 6 ] ; NEW_LINE print ( maxSum ( 0 , 0 , a , 0 , n ) ) ; NEW_LINE DEDENT +" +E982,"class GFG { static int MAXN = 10000000 ; static int minimumSteps ( int n , int m , int a , int b ) { if ( n > m ) return MAXN ; if ( n == m ) return 0 ; return Math . min ( 1 + minimumSteps ( n * a , m , a , b ) , 1 + minimumSteps ( n * b , m , a , b ) ) ; } public static void main ( String [ ] args ) { int n = 120 , m = 51840 ; int a = 2 , b = 3 ; System . out . println ( minimumSteps ( n , m , a , b ) ) ; } } +","MAXN = 10000000 NEW_LINE def minimumSteps ( n , m , a , b ) : NEW_LINE INDENT if ( n > m ) : NEW_LINE INDENT return MAXN NEW_LINE DEDENT if ( n == m ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT return min ( 1 + minimumSteps ( n * a , m , a , b ) , 1 + minimumSteps ( n * b , m , a , b ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 120 NEW_LINE m = 51840 NEW_LINE a = 2 NEW_LINE b = 3 NEW_LINE print ( minimumSteps ( n , m , a , b ) ) NEW_LINE DEDENT +" +E983,"class GFG { static String printLargestString ( String s , int l , int r ) { int freq [ ] = new int [ 26 ] ; l -- ; r -- ; for ( int i = Math . min ( l , r ) ; i <= Math . max ( l , r ) ; i ++ ) { freq [ s . charAt ( i ) - ' a ' ] ++ ; } String ans = "" "" ; for ( int i = 25 ; i >= 0 ; i -- ) { while ( freq [ i ] > 0 ) { ans += ( char ) ( ' a ' + i ) ; freq [ i ] -- ; } } return ans ; } public static void main ( String [ ] args ) { String s = "" striver "" ; int l = 3 , r = 5 ; System . out . println ( printLargestString ( s , l , r ) ) ; } } +","def printLargestString ( s , l , r ) : NEW_LINE INDENT freq = [ 0 ] * 26 NEW_LINE l -= 1 NEW_LINE r -= 1 NEW_LINE for i in range ( min ( l , r ) , max ( l , r ) + 1 ) : NEW_LINE INDENT freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT ans = "" "" NEW_LINE for i in range ( 25 , - 1 , - 1 ) : NEW_LINE INDENT while ( freq [ i ] ) : NEW_LINE INDENT ans += chr ( ord ( ' a ' ) + i ) NEW_LINE freq [ i ] -= 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" striver "" NEW_LINE l = 3 NEW_LINE r = 5 NEW_LINE print ( printLargestString ( s , l , r ) ) NEW_LINE DEDENT +" +E984,"import java . util . HashMap ; class SymmetricPairs { static void findSymPairs ( int arr [ ] [ ] ) { HashMap < Integer , Integer > hM = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { int first = arr [ i ] [ 0 ] ; int sec = arr [ i ] [ 1 ] ; Integer val = hM . get ( sec ) ; if ( val != null && val == first ) System . out . println ( "" ( "" + sec + "" , ▁ "" + first + "" ) "" ) ; else hM . put ( first , sec ) ; } } public static void main ( String arg [ ] ) { int arr [ ] [ ] = new int [ 5 ] [ 2 ] ; arr [ 0 ] [ 0 ] = 11 ; arr [ 0 ] [ 1 ] = 20 ; arr [ 1 ] [ 0 ] = 30 ; arr [ 1 ] [ 1 ] = 40 ; arr [ 2 ] [ 0 ] = 5 ; arr [ 2 ] [ 1 ] = 10 ; arr [ 3 ] [ 0 ] = 40 ; arr [ 3 ] [ 1 ] = 30 ; arr [ 4 ] [ 0 ] = 10 ; arr [ 4 ] [ 1 ] = 5 ; findSymPairs ( arr ) ; } } +","def findSymPairs ( arr , row ) : NEW_LINE INDENT hM = dict ( ) NEW_LINE for i in range ( row ) : NEW_LINE INDENT first = arr [ i ] [ 0 ] NEW_LINE sec = arr [ i ] [ 1 ] NEW_LINE if ( sec in hM . keys ( ) and hM [ sec ] == first ) : NEW_LINE INDENT print ( "" ( "" , sec , "" , "" , first , "" ) "" ) NEW_LINE DEDENT else : NEW_LINE INDENT hM [ first ] = sec NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ [ 0 for i in range ( 2 ) ] for i in range ( 5 ) ] NEW_LINE arr [ 0 ] [ 0 ] , arr [ 0 ] [ 1 ] = 11 , 20 NEW_LINE arr [ 1 ] [ 0 ] , arr [ 1 ] [ 1 ] = 30 , 40 NEW_LINE arr [ 2 ] [ 0 ] , arr [ 2 ] [ 1 ] = 5 , 10 NEW_LINE arr [ 3 ] [ 0 ] , arr [ 3 ] [ 1 ] = 40 , 30 NEW_LINE arr [ 4 ] [ 0 ] , arr [ 4 ] [ 1 ] = 10 , 5 NEW_LINE findSymPairs ( arr , 5 ) NEW_LINE DEDENT +" +E985,"import java . util . * ; class GFG { static long fact ( int n ) { long res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static long nCr ( int n , int r ) { return fact ( n ) / ( 1 * fact ( r ) * fact ( n - r ) ) ; } static long number_of_subsequences ( int arr [ ] , int k , int n ) { long s = 0 ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } for ( Map . Entry < Integer , Integer > j : mp . entrySet ( ) ) { s = s + 1 * nCr ( j . getValue ( ) , k ) ; } return s ; } static public void main ( String [ ] arg ) { int arr [ ] = { 1 , 1 , 1 , 1 , 2 , 2 , 2 } ; int k = 2 ; int n = arr . length ; System . out . println ( number_of_subsequences ( arr , k , n ) ) ; } } +","def fact ( n ) : NEW_LINE INDENT res = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT res = res * i NEW_LINE DEDENT return res NEW_LINE DEDENT def nCr ( n , r ) : NEW_LINE INDENT return fact ( n ) // ( fact ( r ) * fact ( n - r ) ) NEW_LINE DEDENT def number_of_subsequences ( arr , k , n ) : NEW_LINE INDENT s = 0 NEW_LINE m = dict ( ) NEW_LINE for i in arr : NEW_LINE INDENT m [ i ] = m . get ( i , 0 ) + 1 NEW_LINE DEDENT for j in m : NEW_LINE INDENT s = s + nCr ( m [ j ] , k ) NEW_LINE DEDENT return s NEW_LINE DEDENT arr = [ 1 , 1 , 1 , 1 , 2 , 2 , 2 ] NEW_LINE k = 2 NEW_LINE n = len ( arr ) NEW_LINE print ( number_of_subsequences ( arr , k , n ) ) NEW_LINE +" +E986,"class GFG { static int SIZE = 26 ; static void SieveOfEratosthenes ( boolean [ ] prime , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i < p_size ; i += p ) prime [ i ] = false ; } } } static void printChar ( String str , int n ) { boolean [ ] prime = new boolean [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , str . length ( ) + 1 ) ; int [ ] freq = new int [ SIZE ] ; for ( int i = 0 ; i < SIZE ; i ++ ) freq [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) freq [ str . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ freq [ str . charAt ( i ) - ' a ' ] ] ) { System . out . print ( str . charAt ( i ) ) ; } } } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int n = str . length ( ) ; printChar ( str , n ) ; } } +","SIZE = 26 NEW_LINE from math import sqrt NEW_LINE def SieveOfEratosthenes ( prime , p_size ) : NEW_LINE INDENT prime [ 0 ] = False NEW_LINE prime [ 1 ] = False NEW_LINE for p in range ( 2 , int ( sqrt ( p_size ) ) , 1 ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT for i in range ( p * 2 , p_size , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def printChar ( str , n ) : NEW_LINE INDENT prime = [ True for i in range ( n + 1 ) ] NEW_LINE SieveOfEratosthenes ( prime , len ( str ) + 1 ) NEW_LINE freq = [ 0 for i in range ( SIZE ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT freq [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( prime [ freq [ ord ( str [ i ] ) - ord ( ' a ' ) ] ] ) : NEW_LINE INDENT print ( str [ i ] , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = "" geeksforgeeks "" NEW_LINE n = len ( str ) NEW_LINE printChar ( str , n ) NEW_LINE DEDENT +" +E987,"class GFG { static int claculate sum ( int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ( 1 << i ) ; } return sum ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( "" Sum ▁ of ▁ the ▁ series ▁ : ▁ "" + calculateSum ( n ) ) ; } } ; +","def calculateSum ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sum = sum + ( 1 << i ) NEW_LINE DEDENT return sum NEW_LINE DEDENT n = 10 NEW_LINE print ( "" Sum ▁ of ▁ series ▁ "" , calculateSum ( n ) ) NEW_LINE +" +E988,"import java . io . * ; import java . util . * ; class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 || n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int SumOfPrimeDivisors ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 ) { if ( isPrime ( i ) ) sum += i ; } } return sum ; } public static void main ( String args [ ] ) { int n = 60 ; System . out . print ( "" Sum ▁ of ▁ prime ▁ divisors ▁ of ▁ 60 ▁ is ▁ "" + SumOfPrimeDivisors ( n ) + "" \n "" ) ; } } +","N = 1000005 NEW_LINE def isPrime ( n ) : NEW_LINE INDENT if n <= 1 : NEW_LINE INDENT return False NEW_LINE DEDENT if n <= 3 : NEW_LINE INDENT return True NEW_LINE DEDENT if n % 2 == 0 or n % 3 == 0 : NEW_LINE INDENT return False NEW_LINE DEDENT i = 5 NEW_LINE while i * i <= n : NEW_LINE INDENT if ( n % i == 0 or n % ( i + 2 ) == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT i = i + 6 NEW_LINE DEDENT return True NEW_LINE DEDENT def SumOfPrimeDivisors ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT if isPrime ( i ) : NEW_LINE INDENT sum += i NEW_LINE DEDENT DEDENT DEDENT return sum NEW_LINE DEDENT n = 60 NEW_LINE print ( "" Sum ▁ of ▁ prime ▁ divisors ▁ of ▁ 60 ▁ is ▁ "" + str ( SumOfPrimeDivisors ( n ) ) ) NEW_LINE +" +E989,"import java . util . * ; class GFG { static int elementCount ( int arr1 [ ] , int n1 , int arr2 [ ] , int n2 ) { int count = 0 ; HashSet < Integer > hash = new HashSet < > ( ) ; for ( int i = 0 ; i < n2 ; i ++ ) { hash . add ( arr2 [ i ] ) ; } for ( int i = 0 ; i < n1 ; i ++ ) { for ( int j = 1 ; j * j <= arr1 [ i ] ; j ++ ) { if ( arr1 [ i ] % j == 0 ) { if ( ( hash . contains ( j ) && j != ( int ) hash . toArray ( ) [ hash . size ( ) - 1 ] ) || ( hash . contains ( arr1 [ i ] / j ) && ( arr1 [ i ] / j ) != ( int ) hash . toArray ( ) [ hash . size ( ) - 1 ] ) ) { count ++ ; break ; } } } } return count ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 10 , 2 , 13 , 4 , 15 } ; int arr2 [ ] = { 2 , 4 , 5 , 6 } ; int n1 = arr1 . length ; int n2 = arr2 . length ; System . out . println ( elementCount ( arr1 , n1 , arr2 , n2 ) ) ; } } +","from math import sqrt NEW_LINE def elementCount ( arr1 , arr2 ) : NEW_LINE INDENT count = 0 NEW_LINE hash = frozenset ( arr2 ) NEW_LINE for x in arr1 : NEW_LINE INDENT for j in range ( 1 , int ( sqrt ( x ) ) + 1 ) : NEW_LINE INDENT if x % j == 0 : NEW_LINE INDENT if ( j in hash or x / j in hash ) : NEW_LINE INDENT count += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT return count NEW_LINE DEDENT arr1 = [ 10 , 2 , 13 , 4 , 15 ] NEW_LINE arr2 = [ 2 , 4 , 5 , 6 ] NEW_LINE print ( elementCount ( arr1 , arr2 ) ) NEW_LINE +" +E990,"import java . util . * ; class GFG { static int countSubarray ( int arr [ ] , int n , int k ) { int s = 0 ; int i = 0 ; while ( i < n ) { if ( arr [ i ] > k ) { i ++ ; continue ; } int count = 0 ; while ( i < n && arr [ i ] <= k ) { i ++ ; count ++ ; } s += ( ( count * ( count + 1 ) ) / 2 ) ; } return ( n * ( n + 1 ) / 2 - s ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 } ; int k = 2 ; int n = arr . length ; System . out . print ( countSubarray ( arr , n , k ) ) ; } } +","def countSubarray ( arr , n , k ) : NEW_LINE INDENT s = 0 NEW_LINE i = 0 NEW_LINE while ( i < n ) : NEW_LINE INDENT if ( arr [ i ] > k ) : NEW_LINE INDENT i = i + 1 NEW_LINE continue NEW_LINE DEDENT count = 0 NEW_LINE while ( i < n and arr [ i ] <= k ) : NEW_LINE INDENT i = i + 1 NEW_LINE count = count + 1 NEW_LINE DEDENT s = s + ( ( count * ( count + 1 ) ) // 2 ) NEW_LINE DEDENT return ( n * ( n + 1 ) // 2 - s ) NEW_LINE DEDENT arr = [ 1 , 2 , 3 ] NEW_LINE k = 2 NEW_LINE n = len ( arr ) NEW_LINE print ( countSubarray ( arr , n , k ) ) NEW_LINE +" +E991,"import java . io . * ; import java . util . * ; public class GFG { static int countNum ( int [ ] arr , int n ) { int count = 0 ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] != arr [ i + 1 ] && arr [ i ] != arr [ i + 1 ] - 1 ) count += arr [ i + 1 ] - arr [ i ] - 1 ; return count ; } static public void main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 8 , 6 } ; int n = arr . length ; System . out . println ( countNum ( arr , n ) ) ; } } +","def countNum ( arr , n ) : NEW_LINE INDENT count = 0 NEW_LINE arr . sort ( ) NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT if ( arr [ i ] != arr [ i + 1 ] and arr [ i ] != arr [ i + 1 ] - 1 ) : NEW_LINE INDENT count += arr [ i + 1 ] - arr [ i ] - 1 ; NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 3 , 5 , 8 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countNum ( arr , n ) ) NEW_LINE +" +E992,"class GFG { static void max_element ( int a [ ] , int n ) { int [ ] pre = new int [ n ] ; pre [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = Math . max ( pre [ i - 1 ] , a [ i ] ) ; int [ ] suf = new int [ n ] ; suf [ n - 1 ] = a [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) suf [ i ] = Math . max ( suf [ i + 1 ] , a [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) System . out . print ( suf [ i + 1 ] + "" ▁ "" ) ; else if ( i == n - 1 ) System . out . print ( pre [ i - 1 ] + "" ▁ "" ) ; else System . out . print ( Math . max ( pre [ i - 1 ] , suf [ i + 1 ] ) + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int a [ ] = { 2 , 5 , 6 , 1 , 3 } ; int n = a . length ; max_element ( a , n ) ; } } +","def max_element ( a , n ) : NEW_LINE INDENT pre = [ 0 ] * n ; NEW_LINE pre [ 0 ] = a [ 0 ] ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT pre [ i ] = max ( pre [ i - 1 ] , a [ i ] ) ; NEW_LINE DEDENT suf = [ 0 ] * n ; NEW_LINE suf [ n - 1 ] = a [ n - 1 ] ; NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT suf [ i ] = max ( suf [ i + 1 ] , a [ i ] ) ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( i == 0 ) : NEW_LINE INDENT print ( suf [ i + 1 ] , end = "" ▁ "" ) ; NEW_LINE DEDENT elif ( i == n - 1 ) : NEW_LINE INDENT print ( pre [ i - 1 ] , end = "" ▁ "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( max ( pre [ i - 1 ] , suf [ i + 1 ] ) , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 2 , 5 , 6 , 1 , 3 ] ; NEW_LINE n = len ( a ) ; NEW_LINE max_element ( a , n ) ; NEW_LINE DEDENT +" +E993,"class Test { static boolean isRotated ( String str1 , String str2 ) { if ( str1 . length ( ) != str2 . length ( ) ) return false ; String clock_rot = "" "" ; String anticlock_rot = "" "" ; int len = str2 . length ( ) ; anticlock_rot = anticlock_rot + str2 . substring ( len - 2 , len ) + str2 . substring ( 0 , len - 2 ) ; clock_rot = clock_rot + str2 . substring ( 2 ) + str2 . substring ( 0 , 2 ) ; return ( str1 . equals ( clock_rot ) || str1 . equals ( anticlock_rot ) ) ; } public static void main ( String [ ] args ) { String str1 = "" geeks "" ; String str2 = "" eksge "" ; System . out . println ( isRotated ( str1 , str2 ) ? "" Yes "" : "" No "" ) ; } } +","def isRotated ( str1 , str2 ) : NEW_LINE INDENT if ( len ( str1 ) != len ( str2 ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT clock_rot = "" "" NEW_LINE anticlock_rot = "" "" NEW_LINE l = len ( str2 ) NEW_LINE anticlock_rot = ( anticlock_rot + str2 [ l - 2 : ] + str2 [ 0 : l - 2 ] ) NEW_LINE clock_rot = clock_rot + str2 [ 2 : ] + str2 [ 0 : 2 ] NEW_LINE return ( str1 == clock_rot or str1 == anticlock_rot ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = "" geeks "" NEW_LINE str2 = "" eksge "" NEW_LINE DEDENT if isRotated ( str1 , str2 ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E994,"class GFG { static int findMax ( int num ) { byte size_of_int = 4 ; int num_copy = num ; int j = size_of_int * 8 - 1 ; int i = 0 ; while ( i < j ) { int m = ( num_copy >> i ) & 1 ; int n = ( num_copy >> j ) & 1 ; if ( m > n ) { int x = ( 1 << i | 1 << j ) ; num = num ^ x ; } i ++ ; j -- ; } return num ; } static public void main ( String [ ] args ) { int num = 4 ; System . out . println ( findMax ( num ) ) ; } } +","def findMax ( num ) : NEW_LINE INDENT num_copy = num NEW_LINE j = 4 * 8 - 1 ; NEW_LINE i = 0 NEW_LINE while ( i < j ) : NEW_LINE INDENT m = ( num_copy >> i ) & 1 NEW_LINE n = ( num_copy >> j ) & 1 NEW_LINE if ( m > n ) : NEW_LINE INDENT x = ( 1 << i | 1 << j ) NEW_LINE num = num ^ x NEW_LINE DEDENT i += 1 NEW_LINE j -= 1 NEW_LINE DEDENT return num NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT num = 4 NEW_LINE print ( findMax ( num ) ) NEW_LINE DEDENT +" +E995,"import java . util . * ; class GFG { static boolean check ( String s , int l ) { Vector < Integer > pos = new Vector < Integer > ( ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( s . charAt ( i ) == '1' ) pos . add ( i ) ; } int t = pos . size ( ) ; for ( int i = 1 ; i < t ; i ++ ) { if ( ( pos . get ( i ) - pos . get ( i - 1 ) ) != ( pos . get ( 1 ) - pos . get ( 0 ) ) ) return false ; } return true ; } public static void main ( String args [ ] ) { String s = ""100010001000"" ; int l = s . length ( ) ; if ( check ( s , l ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def check ( s , l ) : NEW_LINE INDENT pos = [ ] NEW_LINE for i in range ( l ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT pos . append ( i ) NEW_LINE DEDENT DEDENT t = len ( pos ) NEW_LINE for i in range ( 1 , t ) : NEW_LINE INDENT if ( ( pos [ i ] - pos [ i - 1 ] ) != ( pos [ 1 ] - pos [ 0 ] ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT s = ""100010001000"" NEW_LINE l = len ( s ) NEW_LINE if ( check ( s , l ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E996,"import java . io . * ; class GFG { static int maximum_one ( String s , int n ) { int cnt_one = 0 ; int max_cnt = 0 , temp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) { cnt_one ++ ; temp ++ ; } else { max_cnt = Math . max ( max_cnt , temp ) ; temp = 0 ; } } max_cnt = Math . max ( max_cnt , temp ) ; int [ ] left = new int [ n ] ; int right [ ] = new int [ n ] ; if ( s . charAt ( 0 ) == '1' ) left [ 0 ] = 1 ; else left [ 0 ] = 0 ; if ( s . charAt ( n - 1 ) == '1' ) right [ n - 1 ] = 1 ; else right [ n - 1 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) left [ i ] = left [ i - 1 ] + 1 ; else left [ i ] = 0 ; } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '1' ) right [ i ] = right [ i + 1 ] + 1 ; else right [ i ] = 0 ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( s . charAt ( i ) == '0' ) { int sum = left [ i - 1 ] + right [ i + 1 ] ; if ( sum < cnt_one ) max_cnt = Math . max ( max_cnt , sum + 1 ) ; else max_cnt = Math . max ( max_cnt , sum ) ; } } return max_cnt ; } public static void main ( String [ ] args ) { String s = ""111011101"" ; System . out . println ( maximum_one ( s , s . length ( ) ) ) ; } } +","def maximum_one ( s , n ) : NEW_LINE INDENT cnt_one = 0 NEW_LINE cnt , max_cnt = 0 , 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT cnt_one += 1 NEW_LINE cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT max_cnt = max ( max_cnt , cnt ) NEW_LINE cnt = 0 NEW_LINE DEDENT DEDENT max_cnt = max ( max_cnt , cnt ) NEW_LINE left = [ 0 ] * n NEW_LINE right = [ 0 ] * n NEW_LINE if ( s [ 0 ] == '1' ) : NEW_LINE INDENT left [ 0 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT left [ 0 ] = 0 NEW_LINE DEDENT if ( s [ n - 1 ] == '1' ) : NEW_LINE INDENT right [ n - 1 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT right [ n - 1 ] = 0 NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT left [ i ] = left [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT left [ i ] = 0 NEW_LINE DEDENT DEDENT for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT right [ i ] = right [ i + 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT right [ i ] = 0 NEW_LINE DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( s [ i ] == '0' ) : NEW_LINE INDENT sum = left [ i - 1 ] + right [ i + 1 ] NEW_LINE if ( sum < cnt_one ) : NEW_LINE INDENT max_cnt = max ( max_cnt , sum + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT max_cnt = max ( max_cnt , sum ) NEW_LINE DEDENT DEDENT DEDENT return max_cnt NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = ""111011101"" NEW_LINE print ( maximum_one ( s , len ( s ) ) ) NEW_LINE DEDENT +" +E997,"class GFG { static void nDigitPerfectCubes ( int n ) { int smallest = ( int ) Math . pow ( Math . ceil ( Math . cbrt ( Math . pow ( 10 , ( n - 1 ) ) ) ) , 3 ) ; System . out . print ( smallest + "" ▁ "" ) ; int largest = ( int ) Math . pow ( Math . ceil ( Math . cbrt ( Math . pow ( 10 , ( n ) ) ) ) - 1 , 3 ) ; System . out . print ( largest ) ; } public static void main ( String args [ ] ) { int n = 3 ; nDigitPerfectCubes ( n ) ; } } +","from math import ceil NEW_LINE def nDigitPerfectCubes ( n ) : NEW_LINE INDENT print ( pow ( ceil ( ( pow ( 10 , ( n - 1 ) ) ) ** ( 1 / 3 ) ) , 3 ) , end = "" ▁ "" ) NEW_LINE print ( pow ( ceil ( ( pow ( 10 , ( n ) ) ) ** ( 1 / 3 ) ) - 1 , 3 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 3 NEW_LINE nDigitPerfectCubes ( n ) NEW_LINE DEDENT +" +E998,"class GFG { static boolean isMultipleof5 ( int n ) { if ( ( n & 1 ) == 1 ) n <<= 1 ; float x = n ; x = ( ( int ) ( x * 0.1 ) ) * 10 ; if ( ( int ) x == n ) return true ; return false ; } public static void main ( String [ ] args ) { int i = 19 ; if ( isMultipleof5 ( i ) == true ) System . out . println ( i + "" is ▁ multiple ▁ of ▁ 5"" ) ; else System . out . println ( i + "" ▁ is ▁ not ▁ a ▁ "" + "" multiple ▁ of ▁ 5"" ) ; } } +","def isMultipleof5 ( n ) : NEW_LINE INDENT if ( ( n & 1 ) == 1 ) : NEW_LINE INDENT n <<= 1 ; NEW_LINE DEDENT x = n NEW_LINE x = ( ( int ) ( x * 0.1 ) ) * 10 NEW_LINE if ( x == n ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 0 NEW_LINE DEDENT i = 19 NEW_LINE if ( isMultipleof5 ( i ) == 1 ) : NEW_LINE INDENT print ( i , "" is ▁ multiple ▁ of ▁ 5"" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( i , "" is ▁ not ▁ a ▁ multiple ▁ of ▁ 5"" ) NEW_LINE DEDENT +" +E999,"class GFG { static int minsteps ( int n , int m ) { if ( m > n ) { return - 1 ; } else { return ( ( n + 1 ) / 2 + m - 1 ) / m * m ; } } public static void main ( String [ ] args ) { int n = 17 , m = 4 ; int ans = minsteps ( n , m ) ; System . out . println ( ans ) ; } } +","def minsteps ( n , m ) : NEW_LINE INDENT if ( m > n ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT else : NEW_LINE INDENT return ( ( n + 1 ) // 2 + m - 1 ) // m * m ; NEW_LINE DEDENT DEDENT n = 17 NEW_LINE m = 4 NEW_LINE ans = minsteps ( n , m ) NEW_LINE print ( ans ) NEW_LINE +" +E1000,"class GFG { static void gridStr ( String str ) { int l = str . length ( ) ; int k = 0 , row , column ; row = ( int ) Math . floor ( Math . sqrt ( l ) ) ; column = ( int ) Math . ceil ( Math . sqrt ( l ) ) ; if ( row * column < l ) { row = column ; } char s [ ] [ ] = new char [ row ] [ column ] ; for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < column ; j ++ ) { if ( k < str . length ( ) ) s [ i ] [ j ] = str . charAt ( k ) ; k ++ ; } } for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < column ; j ++ ) { if ( s [ i ] [ j ] == 0 ) { break ; } System . out . print ( s [ i ] [ j ] ) ; } System . out . println ( "" "" ) ; } } public static void main ( String [ ] args ) { String str = "" GEEKSFORGEEKS "" ; gridStr ( str ) ; } } +","from math import sqrt , floor , ceil NEW_LINE def gridStr ( string ) : NEW_LINE INDENT l = len ( string ) NEW_LINE k = 0 NEW_LINE row = floor ( sqrt ( l ) ) NEW_LINE column = ceil ( sqrt ( l ) ) NEW_LINE if ( row * column < l ) : NEW_LINE INDENT row = column NEW_LINE DEDENT s = [ [ 0 for j in range ( column ) ] for i in range ( row ) ] NEW_LINE for i in range ( row ) : NEW_LINE INDENT for j in range ( column ) : NEW_LINE INDENT if k >= l : NEW_LINE INDENT s [ i ] [ j ] = "" ▁ "" NEW_LINE k += 1 NEW_LINE DEDENT else : NEW_LINE INDENT s [ i ] [ j ] = string [ k ] NEW_LINE k += 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( row ) : NEW_LINE INDENT for j in range ( column ) : NEW_LINE INDENT if s [ i ] [ j ] == "" ▁ "" : NEW_LINE INDENT break NEW_LINE DEDENT print ( s [ i ] [ j ] , end = "" "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" GEEKSFORGEEKS "" NEW_LINE gridStr ( string ) NEW_LINE DEDENT +" +E1001,"import java . util . * ; class GFG { static int maxProfit ( int price [ ] , int start , int end ) { if ( end <= start ) return 0 ; int profit = 0 ; for ( int i = start ; i < end ; i ++ ) { for ( int j = i + 1 ; j <= end ; j ++ ) { if ( price [ j ] > price [ i ] ) { int curr_profit = price [ j ] - price [ i ] + maxProfit ( price , start , i - 1 ) + maxProfit ( price , j + 1 , end ) ; profit = Math . max ( profit , curr_profit ) ; } } } return profit ; } public static void main ( String [ ] args ) { int price [ ] = { 100 , 180 , 260 , 310 , 40 , 535 , 695 } ; int n = price . length ; System . out . print ( maxProfit ( price , 0 , n - 1 ) ) ; } } +","def maxProfit ( price , start , end ) : NEW_LINE INDENT if ( end <= start ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT profit = 0 ; NEW_LINE for i in range ( start , end , 1 ) : NEW_LINE INDENT for j in range ( i + 1 , end + 1 ) : NEW_LINE INDENT if ( price [ j ] > price [ i ] ) : NEW_LINE INDENT curr_profit = price [ j ] - price [ i ] + \ NEW_LINE INDENT maxProfit ( price , start , i - 1 ) + \ NEW_LINE maxProfit ( price , j + 1 , end ) ; NEW_LINE DEDENT profit = max ( profit , curr_profit ) ; NEW_LINE DEDENT DEDENT DEDENT return profit ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT price = [ 100 , 180 , 260 , 310 , 40 , 535 , 695 ] ; NEW_LINE n = len ( price ) ; NEW_LINE print ( maxProfit ( price , 0 , n - 1 ) ) ; NEW_LINE DEDENT +" +E1002,"import java . util . * ; class GFG { static int maximum_middle_value ( int n , int k , int arr [ ] ) { int ans = - 1 ; int low = ( n + 1 - k ) / 2 ; int high = ( n + 1 - k ) / 2 + k ; for ( int i = low ; i <= high ; i ++ ) { ans = Math . max ( ans , arr [ i - 1 ] ) ; } return ans ; } public static void main ( String args [ ] ) { int n = 5 , k = 2 ; int arr [ ] = { 9 , 5 , 3 , 7 , 10 } ; System . out . println ( maximum_middle_value ( n , k , arr ) ) ; n = 9 ; k = 3 ; int arr1 [ ] = { 2 , 4 , 3 , 9 , 5 , 8 , 7 , 6 , 10 } ; System . out . println ( maximum_middle_value ( n , k , arr1 ) ) ; } } +","def maximum_middle_value ( n , k , arr ) : NEW_LINE INDENT ans = - 1 NEW_LINE low = ( n + 1 - k ) // 2 NEW_LINE high = ( n + 1 - k ) // 2 + k NEW_LINE for i in range ( low , high + 1 ) : NEW_LINE INDENT ans = max ( ans , arr [ i - 1 ] ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n , k = 5 , 2 NEW_LINE arr = [ 9 , 5 , 3 , 7 , 10 ] NEW_LINE print ( maximum_middle_value ( n , k , arr ) ) NEW_LINE n , k = 9 , 3 NEW_LINE arr1 = [ 2 , 4 , 3 , 9 , 5 , 8 , 7 , 6 , 10 ] NEW_LINE print ( maximum_middle_value ( n , k , arr1 ) ) NEW_LINE DEDENT +" +E1003,"class sum_dig { static int countRec ( int n , int sum ) { if ( n == 0 ) return sum == 0 ? 1 : 0 ; if ( sum == 0 ) return 1 ; int ans = 0 ; for ( int i = 0 ; i <= 9 ; i ++ ) if ( sum - i >= 0 ) ans += countRec ( n - 1 , sum - i ) ; return ans ; } static int finalCount ( int n , int sum ) { int ans = 0 ; for ( int i = 1 ; i <= 9 ; i ++ ) if ( sum - i >= 0 ) ans += countRec ( n - 1 , sum - i ) ; return ans ; } public static void main ( String args [ ] ) { int n = 2 , sum = 5 ; System . out . println ( finalCount ( n , sum ) ) ; } } +","def countRec ( n , sum ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return ( sum == 0 ) NEW_LINE DEDENT if ( sum == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 0 , 10 ) : NEW_LINE INDENT if ( sum - i >= 0 ) : NEW_LINE INDENT ans = ans + countRec ( n - 1 , sum - i ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT def finalCount ( n , sum ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 1 , 10 ) : NEW_LINE INDENT if ( sum - i >= 0 ) : NEW_LINE INDENT ans = ans + countRec ( n - 1 , sum - i ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n = 2 NEW_LINE sum = 5 NEW_LINE print ( finalCount ( n , sum ) ) NEW_LINE +" +E1004,"class GFG { static long calculateSum ( int n , int k ) { int res = 1 ; int MOD = 1000000007 ; while ( k > 0 ) { if ( ( k & 1 ) == 1 ) res = ( res * n ) % MOD ; k = k / 2 ; n = ( n * n ) % MOD ; } return res ; } public static void main ( String [ ] args ) { int n = 4 , k = 3 ; System . out . print ( calculateSum ( n , k ) ) ; } } ; +","def calculateSum ( n , k ) : NEW_LINE INDENT res = 1 NEW_LINE MOD = 1000000007 NEW_LINE while k > 0 : NEW_LINE INDENT if ( k & 1 ) == 1 : NEW_LINE INDENT res = ( res * n ) % MOD NEW_LINE DEDENT k = k // 2 NEW_LINE n = ( n * n ) % MOD NEW_LINE DEDENT return res NEW_LINE DEDENT n = 4 NEW_LINE k = 3 NEW_LINE print ( calculateSum ( n , k ) ) NEW_LINE +" +E1005,"class GFG { static int countPairs ( int s , int K ) { if ( K > s || ( s - K ) % 2 == 1 ) { return 0 ; } if ( ( s - K ) / 2 == 1 & K == 1 ) { return 0 ; } int setBits = __builtin_popcount ( K ) ; int pairsCount = ( int ) Math . pow ( 2 , setBits ) ; if ( s == K ) { pairsCount -= 2 ; } return pairsCount ; } static int __builtin_popcount ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } public static void main ( String [ ] args ) { int s = 9 , K = 5 ; System . out . println ( countPairs ( s , K ) ) ; } } +","def countPairs ( s , K ) : NEW_LINE INDENT if ( K > s or ( s - K ) % 2 == 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT setBits = ( str ( bin ( K ) ) [ 2 : ] ) . count ( ""1"" ) NEW_LINE pairsCount = pow ( 2 , setBits ) NEW_LINE if ( s == K ) : NEW_LINE INDENT pairsCount -= 2 NEW_LINE DEDENT return pairsCount NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s , K = 9 , 5 NEW_LINE print ( countPairs ( s , K ) ) NEW_LINE DEDENT +" +E1006,"class Test { static void splitString ( String str ) { StringBuffer alpha = new StringBuffer ( ) , num = new StringBuffer ( ) , special = new StringBuffer ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( Character . isDigit ( str . charAt ( i ) ) ) num . append ( str . charAt ( i ) ) ; else if ( Character . isAlphabetic ( str . charAt ( i ) ) ) alpha . append ( str . charAt ( i ) ) ; else special . append ( str . charAt ( i ) ) ; } System . out . println ( alpha ) ; System . out . println ( num ) ; System . out . println ( special ) ; } public static void main ( String args [ ] ) { String str = "" geeks01 $ $ for02geeks03 ! @ ! ! "" ; splitString ( str ) ; } } +","def splitString ( str ) : NEW_LINE INDENT alpha = "" "" NEW_LINE num = "" "" NEW_LINE special = "" "" NEW_LINE for i in range ( len ( str ) ) : NEW_LINE INDENT if ( str [ i ] . isdigit ( ) ) : NEW_LINE INDENT num = num + str [ i ] NEW_LINE DEDENT elif ( ( str [ i ] >= ' A ' and str [ i ] <= ' Z ' ) or ( str [ i ] >= ' a ' and str [ i ] <= ' z ' ) ) : NEW_LINE INDENT alpha += str [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT special += str [ i ] NEW_LINE DEDENT DEDENT print ( alpha ) NEW_LINE print ( num ) NEW_LINE print ( special ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" geeks01 $ $ for02geeks03 ! @ ! ! "" NEW_LINE splitString ( str ) NEW_LINE DEDENT +" +E1007,"import java . util . * ; public class GfG { private static int atMostK ( int arr [ ] , int n , int k ) { int count = 0 ; int left = 0 ; int right = 0 ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; while ( right < n ) { map . put ( arr [ right ] , map . getOrDefault ( arr [ right ] , 0 ) + 1 ) ; while ( map . size ( ) > k ) { map . put ( arr [ left ] , map . get ( arr [ left ] ) - 1 ) ; if ( map . get ( arr [ left ] ) == 0 ) map . remove ( arr [ left ] ) ; left ++ ; } count += right - left + 1 ; right ++ ; } return count ; } private static int exactlyK ( int arr [ ] , int n , int k ) { return ( atMostK ( arr , n , k ) - atMostK ( arr , n , k - 1 ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 2 , 1 , 6 } ; int n = arr . length ; int k = 2 ; System . out . print ( exactlyK ( arr , n , k ) ) ; } } +","def atMostK ( arr , n , k ) : NEW_LINE INDENT count = 0 NEW_LINE left = 0 NEW_LINE right = 0 NEW_LINE map = { } NEW_LINE while ( right < n ) : NEW_LINE INDENT if arr [ right ] not in map : NEW_LINE INDENT map [ arr [ right ] ] = 0 NEW_LINE DEDENT map [ arr [ right ] ] += 1 NEW_LINE while ( len ( map ) > k ) : NEW_LINE INDENT if arr [ left ] not in map : NEW_LINE INDENT map [ arr [ left ] ] = 0 NEW_LINE DEDENT map [ arr [ left ] ] -= 1 NEW_LINE if map [ arr [ left ] ] == 0 : NEW_LINE INDENT del map [ arr [ left ] ] NEW_LINE DEDENT left += 1 NEW_LINE DEDENT count += right - left + 1 NEW_LINE right += 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def exactlyK ( arr , n , k ) : NEW_LINE INDENT return ( atMostK ( arr , n , k ) - atMostK ( arr , n , k - 1 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 1 , 2 , 1 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE k = 2 NEW_LINE print ( exactlyK ( arr , n , k ) ) NEW_LINE DEDENT +" +E1008,"import java . util . Scanner ; class Pattern { void display ( int n ) { int sp = n / 2 , st = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= sp ; j ++ ) { System . out . print ( "" ▁ "" ) ; } int count = 1 ; for ( int k = 1 ; k <= st ; k ++ ) { if ( k % 2 == 0 ) System . out . print ( "" * "" ) ; else System . out . print ( count ++ ) ; } System . out . println ( ) ; if ( i <= n / 2 ) { sp = sp - 1 ; st = st + 2 ; } else { sp = sp + 1 ; st = st - 2 ; } } } public static void main ( String [ ] args ) { int n = 5 ; Pattern p = new Pattern ( ) ; p . display ( n ) ; } } +","def display ( n ) : NEW_LINE INDENT sp = n // 2 NEW_LINE st = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , sp + 1 ) : NEW_LINE INDENT print ( end = "" ▁ "" ) NEW_LINE DEDENT count = 1 NEW_LINE for k in range ( 1 , st + 1 ) : NEW_LINE INDENT if ( k % 2 == 0 ) : NEW_LINE INDENT print ( "" * "" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( count , end = "" "" ) NEW_LINE count += 1 NEW_LINE DEDENT DEDENT print ( ) NEW_LINE if ( i <= n // 2 ) : NEW_LINE INDENT sp = sp - 1 NEW_LINE st = st + 2 NEW_LINE DEDENT else : NEW_LINE INDENT sp = sp + 1 NEW_LINE st = st - 2 NEW_LINE DEDENT DEDENT DEDENT n = 5 NEW_LINE display ( n ) NEW_LINE +" +E1009,"class GFG { static final int R = 3 ; static final int C = 5 ; static int maxArea ( int mat [ ] [ ] ) { int hist [ ] [ ] = new int [ R + 1 ] [ C + 1 ] ; for ( int i = 0 ; i < C ; i ++ ) { hist [ 0 ] [ i ] = mat [ 0 ] [ i ] ; for ( int j = 1 ; j < R ; j ++ ) { hist [ j ] [ i ] = ( mat [ j ] [ i ] == 0 ) ? 0 : hist [ j - 1 ] [ i ] + 1 ; } } for ( int i = 0 ; i < R ; i ++ ) { int count [ ] = new int [ R + 1 ] ; for ( int j = 0 ; j < C ; j ++ ) { count [ hist [ i ] [ j ] ] ++ ; } int col_no = 0 ; for ( int j = R ; j >= 0 ; j -- ) { if ( count [ j ] > 0 ) { for ( int k = 0 ; k < count [ j ] ; k ++ ) { hist [ i ] [ col_no ] = j ; col_no ++ ; } } } } int curr_area , max_area = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { curr_area = ( j + 1 ) * hist [ i ] [ j ] ; if ( curr_area > max_area ) { max_area = curr_area ; } } } return max_area ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 0 , 1 , 1 } , { 1 , 1 , 0 , 1 , 0 } } ; System . out . println ( "" Area ▁ of ▁ the ▁ largest ▁ rectangle ▁ is ▁ "" + maxArea ( mat ) ) ; } } +","R = 3 NEW_LINE C = 5 NEW_LINE def maxArea ( mat ) : NEW_LINE INDENT hist = [ [ 0 for i in range ( C + 1 ) ] for i in range ( R + 1 ) ] NEW_LINE for i in range ( 0 , C , 1 ) : NEW_LINE INDENT hist [ 0 ] [ i ] = mat [ 0 ] [ i ] NEW_LINE for j in range ( 1 , R , 1 ) : NEW_LINE INDENT if ( ( mat [ j ] [ i ] == 0 ) ) : NEW_LINE INDENT hist [ j ] [ i ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT hist [ j ] [ i ] = hist [ j - 1 ] [ i ] + 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( 0 , R , 1 ) : NEW_LINE INDENT count = [ 0 for i in range ( R + 1 ) ] NEW_LINE for j in range ( 0 , C , 1 ) : NEW_LINE INDENT count [ hist [ i ] [ j ] ] += 1 NEW_LINE DEDENT col_no = 0 NEW_LINE j = R NEW_LINE while ( j >= 0 ) : NEW_LINE INDENT if ( count [ j ] > 0 ) : NEW_LINE INDENT for k in range ( 0 , count [ j ] , 1 ) : NEW_LINE INDENT hist [ i ] [ col_no ] = j NEW_LINE col_no += 1 NEW_LINE DEDENT DEDENT j -= 1 NEW_LINE DEDENT DEDENT max_area = 0 NEW_LINE for i in range ( 0 , R , 1 ) : NEW_LINE INDENT for j in range ( 0 , C , 1 ) : NEW_LINE INDENT curr_area = ( j + 1 ) * hist [ i ] [ j ] NEW_LINE if ( curr_area > max_area ) : NEW_LINE INDENT max_area = curr_area NEW_LINE DEDENT DEDENT DEDENT return max_area NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT mat = [ [ 0 , 1 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 1 , 1 ] , [ 1 , 1 , 0 , 1 , 0 ] ] NEW_LINE print ( "" Area ▁ of ▁ the ▁ largest ▁ rectangle ▁ is "" , maxArea ( mat ) ) NEW_LINE DEDENT +" +E1010,"import java . io . * ; class GFG { static int lcs ( int dp [ ] [ ] , String a , String b , int m , int n ) { for ( int i = 0 ; i < 100 ; i ++ ) for ( int j = 0 ; j < 100 ; j ++ ) dp [ i ] [ j ] = - 1 ; if ( m < 0 || n < 0 ) { return 0 ; } if ( dp [ m ] [ n ] != - 1 ) return dp [ m ] [ n ] ; int ans = 0 ; if ( a . charAt ( m ) == b . charAt ( n ) ) { ans = ( a . charAt ( m ) - 48 ) + lcs ( dp , a , b , m - 1 , n - 1 ) ; } else ans = Math . max ( lcs ( dp , a , b , m - 1 , n ) , lcs ( dp , a , b , m , n - 1 ) ) ; dp [ m ] [ n ] = ans ; return ans ; } static int costOfString ( String str ) { int cost = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) cost += ( str . charAt ( i ) - 48 ) ; return cost ; } public static void main ( String [ ] args ) { String a , b ; a = ""9142"" ; b = ""1429"" ; int dp [ ] [ ] = new int [ 101 ] [ 101 ] ; System . out . print ( ( costOfString ( a ) + costOfString ( b ) - 2 * lcs ( dp , a , b , a . length ( ) - 1 , b . length ( ) - 1 ) ) ) ; } } +","def lcs ( dp , a , b , m , n ) : NEW_LINE INDENT for i in range ( 100 ) : NEW_LINE INDENT for j in range ( 100 ) : NEW_LINE INDENT dp [ i ] [ j ] = - 1 NEW_LINE DEDENT DEDENT if ( m < 0 or n < 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( dp [ m ] [ n ] != - 1 ) : NEW_LINE INDENT return dp [ m ] [ n ] NEW_LINE DEDENT ans = 0 NEW_LINE if ( a [ m ] == b [ n ] ) : NEW_LINE INDENT ans = ( ord ( a [ m ] ) - 48 ) + lcs ( dp , a , b , m - 1 , n - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = max ( lcs ( dp , a , b , m - 1 , n ) , lcs ( dp , a , b , m , n - 1 ) ) NEW_LINE DEDENT dp [ m ] [ n ] = ans NEW_LINE return ans NEW_LINE DEDENT def costOfString ( s ) : NEW_LINE INDENT cost = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT cost += ( ord ( s [ i ] ) - 48 ) NEW_LINE DEDENT return cost NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = ""9142"" NEW_LINE b = ""1429"" NEW_LINE dp = [ [ 0 for x in range ( 101 ) ] for y in range ( 101 ) ] NEW_LINE print ( costOfString ( a ) + costOfString ( b ) - 2 * lcs ( dp , a , b , len ( a ) - 1 , len ( b ) - 1 ) ) NEW_LINE DEDENT +" +E1011,"import java . util . * ; class GFG { public static int maxUniqueNum ( int arr [ ] , int N , int M ) { int maxUnique = 0 ; for ( int i = 0 ; i < N - M ; i ++ ) { int currentUnique = 0 ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int k = i ; k < i + M ; k ++ ) { if ( ! map . containsKey ( arr [ k ] ) ) { map . put ( arr [ i ] , 1 ) ; currentUnique ++ ; continue ; } } if ( currentUnique > maxUnique ) maxUnique = currentUnique ; } return maxUnique ; } public static void main ( String [ ] args ) { int [ ] arr = { 5 , 3 , 5 , 2 , 3 , 2 } ; int N = 6 ; int M = 3 ; System . out . println ( maxUniqueNum ( arr , N , M ) ) ; } } +","def maxUniqueNum ( a , N , M ) : NEW_LINE INDENT maxUnique = 0 NEW_LINE for i in range ( N - M ) : NEW_LINE INDENT s = set ( ) NEW_LINE for j in range ( M ) : NEW_LINE INDENT s . add ( a [ i + j ] ) NEW_LINE DEDENT if ( len ( s ) > maxUnique ) : NEW_LINE INDENT maxUnique = len ( s ) NEW_LINE DEDENT DEDENT return maxUnique NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 5 , 3 , 5 , 2 , 3 , 2 ] NEW_LINE M = 3 NEW_LINE N = len ( arr ) NEW_LINE print ( maxUniqueNum ( arr , N , M ) ) NEW_LINE DEDENT +" +E1012,"class GFG { static String complement ( String s ) { String comps = "" "" ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '0' ) comps += '1' ; else comps += '0' ; } return comps ; } static String nthTerm ( int n ) { String s = ""0"" ; for ( int i = 1 ; i < n ; i ++ ) s += complement ( s ) ; return s ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . print ( nthTerm ( n ) ) ; } } +","def complement ( s ) : NEW_LINE INDENT comps = "" "" ; NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if ( s [ i ] == '0' ) : NEW_LINE INDENT comps += '1' ; NEW_LINE DEDENT else : NEW_LINE INDENT comps += '0' ; NEW_LINE DEDENT DEDENT return comps ; NEW_LINE DEDENT def nthTerm ( n ) : NEW_LINE INDENT s = ""0"" ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT s += complement ( s ) ; NEW_LINE DEDENT return s ; NEW_LINE DEDENT n = 4 ; NEW_LINE print ( nthTerm ( n ) ) ; NEW_LINE +" +E1013,"import java . io . * ; class GFG { static int evenFibSum ( int limit ) { if ( limit < 2 ) return 0 ; long ef1 = 0 , ef2 = 2 ; long sum = ef1 + ef2 ; while ( ef2 <= limit ) { long ef3 = 4 * ef2 + ef1 ; if ( ef3 > limit ) break ; ef1 = ef2 ; ef2 = ef3 ; sum += ef2 ; } return ( int ) sum ; } public static void main ( String [ ] args ) { int limit = 400 ; System . out . println ( evenFibSum ( limit ) ) ; } } +","def evenFibSum ( limit ) : NEW_LINE INDENT if ( limit < 2 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT ef1 = 0 NEW_LINE ef2 = 2 NEW_LINE sm = ef1 + ef2 NEW_LINE while ( ef2 <= limit ) : NEW_LINE INDENT ef3 = 4 * ef2 + ef1 NEW_LINE if ( ef3 > limit ) : NEW_LINE INDENT break NEW_LINE DEDENT ef1 = ef2 NEW_LINE ef2 = ef3 NEW_LINE sm = sm + ef2 NEW_LINE DEDENT return sm NEW_LINE DEDENT limit = 400 NEW_LINE print ( evenFibSum ( limit ) ) NEW_LINE +" +E1014,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int factorial ( int N ) { int fact = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fact = fact * i ; return fact ; } static int nthTerm ( int N ) { return ( factorial ( N ) * ( N + 2 ) / 2 ) ; } public static void main ( String args [ ] ) { int N = 6 ; System . out . println ( nthTerm ( N ) ) ; } } +","def factorial ( N ) : NEW_LINE INDENT fact = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT fact = fact * i NEW_LINE DEDENT return fact NEW_LINE DEDENT def nthTerm ( N ) : NEW_LINE INDENT return ( factorial ( N ) * ( N + 2 ) // 2 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 6 NEW_LINE print ( nthTerm ( N ) ) NEW_LINE DEDENT +" +E1015,"import java . io . * ; import java . lang . * ; class GFG { public static double answer ( double X , double K ) { double i = 10 ; double MAX = Math . pow ( i , K ) - 1 ; return ( MAX - ( MAX % X ) ) ; } public static void main ( String [ ] args ) { double X = 30 ; double K = 3 ; System . out . println ( ( int ) answer ( X , K ) ) ; } } +","def answer ( X , K ) : NEW_LINE INDENT MAX = pow ( 10 , K ) - 1 NEW_LINE return ( MAX - ( MAX % X ) ) NEW_LINE DEDENT X = 30 ; NEW_LINE K = 3 ; NEW_LINE print ( answer ( X , K ) ) ; NEW_LINE +" +E1016,"class GFG { static int maxLength ( int [ ] a , int n ) { int maximum = 1 ; int left [ ] = new int [ n ] ; int right [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { left [ i ] = 1 ; right [ i ] = 1 ; } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( a [ i ] > a [ i + 1 ] ) { right [ i ] = right [ i + 1 ] + 1 ; } maximum = Math . max ( maximum , right [ i ] ) ; } for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] < a [ i - 1 ] ) { left [ i ] = left [ i - 1 ] + 1 ; } } if ( n > 2 ) { for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( a [ i - 1 ] > a [ i + 1 ] ) { maximum = Math . max ( maximum , left [ i - 1 ] + right [ i + 1 ] ) ; } } } return maximum ; } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 7 , 3 , 5 , 2 , 9 } ; int n = arr . length ; System . out . println ( maxLength ( arr , n ) ) ; } } +","def maxLength ( a , n ) : NEW_LINE INDENT maximum = 1 ; NEW_LINE left = [ 0 ] * n ; NEW_LINE right = [ 0 ] * n ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT left [ i ] = 1 ; NEW_LINE right [ i ] = 1 ; NEW_LINE DEDENT for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT if ( a [ i ] > a [ i + 1 ] ) : NEW_LINE INDENT right [ i ] = right [ i + 1 ] + 1 ; NEW_LINE DEDENT maximum = max ( maximum , right [ i ] ) ; NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( a [ i ] < a [ i - 1 ] ) : NEW_LINE INDENT left [ i ] = left [ i - 1 ] + 1 ; NEW_LINE DEDENT DEDENT if ( n > 2 ) : NEW_LINE INDENT for i in range ( 1 , n - 1 ) : NEW_LINE INDENT if ( a [ i - 1 ] > a [ i + 1 ] ) : NEW_LINE INDENT maximum = max ( maximum , left [ i - 1 ] + right [ i + 1 ] ) ; NEW_LINE DEDENT DEDENT DEDENT return maximum ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 8 , 7 , 3 , 5 , 2 , 9 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( maxLength ( arr , n ) ) ; NEW_LINE DEDENT +" +E1017,"public class GFG { public static void main ( String args [ ] ) { int n = 3 ; int a [ ] = { 1 , 2 , 3 } ; int i = 0 ; long sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } long x = sum / n ; if ( x * n == sum ) System . out . println ( x ) ; else System . out . println ( "" - 1"" ) ; } } +","if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 3 NEW_LINE a = [ 1 , 2 , 3 ] NEW_LINE i = 0 NEW_LINE sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT sum += a [ i ] NEW_LINE DEDENT x = sum // n NEW_LINE if ( x * n == sum ) : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" - 1"" ) NEW_LINE DEDENT DEDENT +" +E1018,"import java . util . * ; public class GFG { public static ArrayList < Integer > getPerfectSquares ( int n ) { ArrayList < Integer > perfectSquares = new ArrayList < > ( ) ; int current = 1 , i = 1 ; while ( current <= n ) { perfectSquares . add ( current ) ; current = ( int ) Math . pow ( ++ i , 2 ) ; } return perfectSquares ; } public static int countTriplets ( int n ) { ArrayList < Integer > perfectSquares = getPerfectSquares ( ( int ) Math . pow ( n , 2 ) ) ; int count = 0 ; for ( int a = 1 ; a <= n ; a ++ ) { int aSquare = ( int ) Math . pow ( a , 2 ) ; for ( int i = 0 ; i < perfectSquares . size ( ) ; i ++ ) { int cSquare = perfectSquares . get ( i ) ; int bSquare = cSquare - aSquare ; int b = ( int ) Math . sqrt ( bSquare ) ; int c = ( int ) Math . sqrt ( cSquare ) ; if ( c < a || ! perfectSquares . contains ( bSquare ) ) continue ; if ( ( b >= a ) && ( b <= c ) && ( aSquare + bSquare == cSquare ) ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( countTriplets ( n ) ) ; } } +","import math NEW_LINE def getPerfectSquares ( n ) : NEW_LINE INDENT perfectSquares = [ ] NEW_LINE current = 1 NEW_LINE i = 1 NEW_LINE while ( current <= n ) : NEW_LINE INDENT perfectSquares . append ( current ) NEW_LINE i += 1 NEW_LINE current = i ** 2 NEW_LINE DEDENT return perfectSquares NEW_LINE DEDENT def countTriplets ( n ) : NEW_LINE INDENT perfectSquares = getPerfectSquares ( n ** 2 ) NEW_LINE count = 0 NEW_LINE for a in range ( 1 , n + 1 ) : NEW_LINE INDENT aSquare = a ** 2 NEW_LINE for i in range ( len ( perfectSquares ) ) : NEW_LINE INDENT cSquare = perfectSquares [ i ] NEW_LINE bSquare = abs ( cSquare - aSquare ) NEW_LINE b = math . sqrt ( bSquare ) NEW_LINE b = int ( b ) NEW_LINE c = math . sqrt ( cSquare ) NEW_LINE c = int ( c ) NEW_LINE if ( c < a or ( bSquare not in perfectSquares ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( ( b >= a ) and ( b <= c ) and ( aSquare + bSquare == cSquare ) ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 10 NEW_LINE print ( countTriplets ( n ) ) NEW_LINE DEDENT +" +E1019,"import java . io . * ; class GFG { static int centered_pentagonal_Num ( int n ) { return ( 5 * n * n - 5 * n + 2 ) / 2 ; } public static void main ( String [ ] args ) { int n = 7 ; System . out . print ( n + "" th ▁ Centered ▁ "" + "" pentagonal ▁ number : ▁ "" ) ; System . out . println ( centered_pentagonal_Num ( n ) ) ; } } +","def centered_pentagonal_Num ( n ) : NEW_LINE INDENT return ( 5 * n * n - 5 * n + 2 ) // 2 NEW_LINE DEDENT n = 7 NEW_LINE print ( "" % sth ▁ Centered ▁ pentagonal ▁ number ▁ : ▁ "" % n , centered_pentagonal_Num ( n ) ) NEW_LINE +" +E1020,"import java . io . * ; class GFG { static void PossibleValues ( int b , int x , int n ) { int leastdivisible = ( b / x + 1 ) * x ; int flag = 1 ; while ( leastdivisible <= n ) { if ( leastdivisible - b >= 1 ) { System . out . print ( leastdivisible - b + "" ▁ "" ) ; leastdivisible += x ; flag = 0 ; } else break ; } if ( flag > 0 ) System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { int b = 10 , x = 6 , n = 40 ; PossibleValues ( b , x , n ) ; } } +","def PossibleValues ( b , x , n ) : NEW_LINE INDENT leastdivisible = int ( b / x + 1 ) * x NEW_LINE flag = 1 NEW_LINE while ( leastdivisible <= n ) : NEW_LINE INDENT if ( leastdivisible - b >= 1 ) : NEW_LINE INDENT print ( leastdivisible - b , end = "" ▁ "" ) NEW_LINE leastdivisible += x NEW_LINE flag = 0 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( flag != 0 ) : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT b = 10 NEW_LINE x = 6 NEW_LINE n = 40 NEW_LINE PossibleValues ( b , x , n ) NEW_LINE DEDENT +" +E1021,"static int findLongestRepeatingSubSeq ( String str ) { int n = str . length ( ) ; int dp [ ] [ ] = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= n ; j ++ ) dp [ i ] [ j ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( str . charAt ( i - 1 ) == str . charAt ( j - 1 ) && i != j ) dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] ; else dp [ i ] [ j ] = Math . max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) ; } } return dp [ n ] [ n ] ; } +","def findLongestRepeatingSubSeq ( str ) : NEW_LINE INDENT n = len ( str ) NEW_LINE dp = [ [ 0 for k in range ( n + 1 ) ] for l in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( str [ i - 1 ] == str [ j - 1 ] and i != j ) : NEW_LINE INDENT dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT return dp [ n ] [ n ] NEW_LINE DEDENT +" +E1022,"import java . io . * ; class GFG { static int countIntegralSolutions ( int n ) { return ( ( n + 1 ) * ( n + 2 ) ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( countIntegralSolutions ( n ) ) ; } } +","def countIntegralSolutions ( n ) : NEW_LINE INDENT return int ( ( ( n + 1 ) * ( n + 2 ) ) / 2 ) NEW_LINE DEDENT n = 3 NEW_LINE print ( countIntegralSolutions ( n ) ) NEW_LINE +" +E1023,"import java . util . * ; class GFG { static String check ( int [ ] arr , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) count ++ ; } if ( ( count & 1 ) != 0 ) return "" Odd "" ; else return "" Even "" ; } public static void main ( String args [ ] ) { int [ ] arr = { 3 , 9 , 12 , 13 , 15 } ; int n = arr . length ; System . out . println ( check ( arr , n ) ) ; } } +","def check ( arr , n ) : NEW_LINE INDENT count = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] & 1 ) : NEW_LINE INDENT count = count + 1 ; NEW_LINE DEDENT DEDENT if ( count & 1 ) : NEW_LINE INDENT return "" Odd "" ; NEW_LINE DEDENT else : NEW_LINE INDENT return "" Even "" ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 3 , 9 , 12 , 13 , 15 ] NEW_LINE n = len ( arr ) NEW_LINE print ( check ( arr , n ) ) NEW_LINE DEDENT +" +E1024,"import java . util . * ; class GFG { static void dfs ( Vector < Integer > graph [ ] , int node , int dist [ ] , boolean vis [ ] , int c ) { if ( vis [ node ] ) { return ; } vis [ node ] = true ; dist [ node ] = c ; for ( int i = 0 ; i < graph [ node ] . size ( ) ; i ++ ) { if ( ! vis [ graph [ node ] . get ( i ) ] ) { dfs ( graph , graph [ node ] . get ( i ) , dist , vis , c + 1 ) ; } } } static int countOfNodes ( Vector < Integer > graph [ ] , int n ) { boolean [ ] vis = new boolean [ n + 1 ] ; int [ ] dist = new int [ n + 1 ] ; dfs ( graph , 1 , dist , vis , 0 ) ; int even = 0 , odd = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( dist [ i ] % 2 == 0 ) { even ++ ; } else { odd ++ ; } } int ans = ( ( even * ( even - 1 ) ) + ( odd * ( odd - 1 ) ) ) / 2 ; return ans ; } public static void main ( String [ ] args ) { int n = 5 ; Vector < Integer > [ ] graph = new Vector [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { graph [ i ] = new Vector < Integer > ( ) ; } graph [ 0 ] = new Vector < Integer > ( ) ; graph [ 1 ] = new Vector ( Arrays . asList ( 2 ) ) ; graph [ 2 ] = new Vector < Integer > ( 1 , 3 ) ; graph [ 3 ] = new Vector < Integer > ( 2 ) ; int ans = countOfNodes ( graph , n ) ; System . out . println ( ans ) ; } } +","def dfs ( graph , node , dist , vis , c ) : NEW_LINE INDENT if ( vis [ node ] ) : NEW_LINE INDENT return ; NEW_LINE DEDENT vis [ node ] = True ; NEW_LINE dist [ node ] = c ; NEW_LINE for i in range ( len ( graph [ node ] ) ) : NEW_LINE INDENT if ( not vis [ graph [ node ] [ i ] ] ) : NEW_LINE INDENT dfs ( graph , graph [ node ] [ i ] , dist , vis , c + 1 ) ; NEW_LINE DEDENT DEDENT DEDENT def countOfNodes ( graph , n ) : NEW_LINE INDENT vis = [ False ] * ( n + 1 ) ; NEW_LINE dist = [ 0 ] * ( n + 1 ) ; NEW_LINE dfs ( graph , 1 , dist , vis , 0 ) ; NEW_LINE even = 0 ; odd = 0 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( dist [ i ] % 2 == 0 ) : NEW_LINE INDENT even += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT odd += 1 ; NEW_LINE DEDENT DEDENT ans = ( ( even * ( even - 1 ) ) + ( odd * ( odd - 1 ) ) ) // 2 ; NEW_LINE return ans ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 5 ; NEW_LINE graph = [ [ ] , [ 2 ] , [ 1 , 3 ] , [ 2 ] ] ; NEW_LINE ans = countOfNodes ( graph , n ) ; NEW_LINE print ( ans ) ; NEW_LINE DEDENT +" +E1025,"public class GFG { static boolean flipsPossible ( int [ ] a , int n ) { int count_odd = 0 , count_even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] & 1 ) == 1 ) count_odd ++ ; else count_even ++ ; } if ( count_odd % 2 == 1 && count_even % 2 == 1 ) return false ; else return true ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 0 , 1 , 1 , 0 , 1 } ; int n = a . length ; if ( flipsPossible ( a , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def flipsPossible ( a , n ) : NEW_LINE INDENT count_odd = 0 ; count_even = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] & 1 ) : NEW_LINE INDENT count_odd += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT count_even += 1 ; NEW_LINE DEDENT DEDENT if ( count_odd % 2 and count_even % 2 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT else : NEW_LINE INDENT return True ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , 0 , 1 , 1 , 0 , 1 ] ; NEW_LINE n = len ( a ) ; NEW_LINE if ( flipsPossible ( a , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E1026,"import java . io . * ; class GFG { static void findSeries ( int num , int first , int sec ) { System . out . print ( first + "" ▁ "" + sec + "" ▁ "" ) ; int counter = 0 , sum ; while ( counter < num - 2 ) { sum = first + sec ; System . out . print ( sum + "" ▁ "" ) ; first = sec ; sec = sum ; counter ++ ; } } public static void main ( String [ ] args ) { int n = 5 , first = 2 , sec = 4 ; findSeries ( n , first , sec ) ; } } +","def findSeries ( num , first , sec ) : NEW_LINE INDENT print ( "" { } ▁ { } ▁ "" . format ( first , sec ) , end = "" "" ) NEW_LINE counter = 0 NEW_LINE while ( counter < num - 2 ) : NEW_LINE INDENT sum = first + sec NEW_LINE print ( "" { } ▁ "" . format ( sum ) , end = "" "" ) NEW_LINE first = sec NEW_LINE sec = sum NEW_LINE counter = counter + 1 NEW_LINE DEDENT DEDENT n = 5 NEW_LINE first = 2 NEW_LINE sec = 4 NEW_LINE findSeries ( n , first , sec ) NEW_LINE +" +E1027,"import java . io . * ; class GFG { static int countOdd ( int n ) { int coun = 0 , m , j , i ; for ( i = n - 2 ; i >= 1 ; i -- ) { if ( i >= 1 ) { m = ( n - i ) / 2 ; j = ( i * ( i + 1 ) ) / 2 ; coun += j * m ; } else { m = ( ( n - 1 ) - i ) / 2 ; j = ( i * ( i + 1 ) ) / 2 ; coun += j * m ; } } return coun ; } static int countEven ( int n ) { int coun = 0 , m , j , i ; for ( i = n - 2 ; i >= 1 ; i -- ) { if ( i >= 1 ) { m = ( ( n - 1 ) - i ) / 2 ; j = ( i * ( i + 1 ) ) / 2 ; coun += j * m ; } else { m = ( n - i ) / 2 ; j = ( i * ( i + 1 ) ) / 2 ; coun += j * m ; } } return coun ; } public static void main ( String [ ] args ) { int n = 5 ; if ( n >= 1 ) System . out . println ( countOdd ( n ) ) ; else System . out . println ( countEven ( n ) ) ; } } +","def countOdd ( n ) : NEW_LINE INDENT coun = 0 NEW_LINE i = n - 2 NEW_LINE while ( i >= 1 ) : NEW_LINE INDENT if ( i & 1 ) : NEW_LINE INDENT m = int ( ( n - i ) / 2 ) NEW_LINE j = int ( ( i * ( i + 1 ) ) / 2 ) NEW_LINE coun += j * m NEW_LINE DEDENT else : NEW_LINE INDENT m = int ( ( ( n - 1 ) - i ) / 2 ) NEW_LINE j = int ( ( i * ( i + 1 ) ) / 2 ) NEW_LINE coun += j * m NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT return coun NEW_LINE DEDENT def countEven ( n ) : NEW_LINE INDENT coun = 0 NEW_LINE i = n - 2 NEW_LINE while ( i >= 1 ) : NEW_LINE INDENT if ( i & 1 ) : NEW_LINE INDENT m = int ( ( ( n - 1 ) - i ) / 2 ) NEW_LINE j = int ( ( i * ( i + 1 ) ) / 2 ) NEW_LINE coun += j * m NEW_LINE DEDENT else : NEW_LINE INDENT m = int ( ( n - i ) / 2 ) NEW_LINE j = ( i * ( i + 1 ) ) // 2 NEW_LINE coun += j * m NEW_LINE DEDENT DEDENT return coun NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE if ( n & 1 ) : NEW_LINE INDENT print ( countOdd ( n ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( countEven ( n ) ) NEW_LINE DEDENT DEDENT +" +E1028,"class GFG { static long mod = ( long ) ( 1e9 + 7 ) ; static long factorial ( long n , long p ) { long res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = ( res * i ) % p ; return res ; } static long power ( long x , long y , long p ) { long res = 1 ; x = x % p ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } static long modInverse ( long n , long p ) { return power ( n , p - 2 , p ) ; } static long nCrModP ( long n , long r , long p ) { if ( r == 0 ) return 1 ; long fac [ ] = new long [ ( int ) n + 1 ] ; fac [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fac [ i ] = fac [ i - 1 ] * i % p ; return ( fac [ ( int ) n ] * modInverse ( fac [ ( int ) r ] , p ) % p * modInverse ( fac [ ( int ) n - ( int ) r ] , p ) % p ) % p ; } static long countArrangements ( long n , long k , long p ) { return ( factorial ( n , p ) * nCrModP ( k , n , p ) ) % p ; } public static void main ( String [ ] args ) { long N = 5 , K = 8 ; System . out . println ( countArrangements ( N , K , mod ) ) ; } } +","mod = 10 ** 9 + 7 NEW_LINE def factorial ( n , p ) : NEW_LINE INDENT res = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT res = ( res * i ) % p NEW_LINE DEDENT return res NEW_LINE DEDENT def power ( x , y , p ) : NEW_LINE INDENT res = 1 NEW_LINE x = x % p NEW_LINE while ( y > 0 ) : NEW_LINE INDENT if ( y & 1 ) : NEW_LINE INDENT res = ( res * x ) % p NEW_LINE DEDENT y = y >> 1 NEW_LINE x = ( x * x ) % p NEW_LINE DEDENT return res NEW_LINE DEDENT def modInverse ( n , p ) : NEW_LINE INDENT return power ( n , p - 2 , p ) NEW_LINE DEDENT def nCrModP ( n , r , p ) : NEW_LINE INDENT if ( r == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT fac = [ 0 for i in range ( n + 1 ) ] NEW_LINE fac [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT fac [ i ] = fac [ i - 1 ] * i % p NEW_LINE DEDENT return ( fac [ n ] * modInverse ( fac [ r ] , p ) % p * modInverse ( fac [ n - r ] , p ) % p ) % p NEW_LINE DEDENT def countArrangements ( n , k , p ) : NEW_LINE INDENT return ( factorial ( n , p ) * nCrModP ( k , n , p ) ) % p NEW_LINE DEDENT N = 5 NEW_LINE K = 8 NEW_LINE print ( countArrangements ( N , K , mod ) ) NEW_LINE +" +E1029,"class GFG { static void subString ( char str [ ] , int n ) { for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; for ( int k = i ; k <= j ; k ++ ) { System . out . print ( str [ k ] ) ; } System . out . println ( ) ; } } } public static void main ( String [ ] args ) { char str [ ] = { ' a ' , ' b ' , ' c ' } ; subString ( str , str . length ) ; } } +","def subString ( Str , n ) : NEW_LINE INDENT for Len in range ( 1 , n + 1 ) : NEW_LINE INDENT for i in range ( n - Len + 1 ) : NEW_LINE INDENT j = i + Len - 1 NEW_LINE for k in range ( i , j + 1 ) : NEW_LINE INDENT print ( Str [ k ] , end = "" "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT DEDENT Str = "" abc "" NEW_LINE subString ( Str , len ( Str ) ) NEW_LINE +" +E1030,"import java . io . * ; import java . math . * ; class GFG { static int sumofseries ( int n ) { int res = 0 ; for ( int i = 1 ; i <= n ; i ++ ) res += ( i ) * ( i + 1 ) * ( i + 2 ) ; return res ; } public static void main ( String [ ] args ) { System . out . println ( sumofseries ( 3 ) ) ; } } +","def sumofseries ( n ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT res += ( i ) * ( i + 1 ) * ( i + 2 ) NEW_LINE DEDENT return res NEW_LINE DEDENT print ( sumofseries ( 3 ) ) NEW_LINE +" +E1031,"import java . util . Arrays ; class GFG { static void countWaysToJump ( int arr [ ] , int n ) { int count_jump [ ] = new int [ n ] ; Arrays . fill ( count_jump , 0 ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= n - i - 1 ) count_jump [ i ] ++ ; for ( int j = i + 1 ; j < n - 1 && j <= arr [ i ] + i ; j ++ ) if ( count_jump [ j ] != - 1 ) count_jump [ i ] += count_jump [ j ] ; if ( count_jump [ i ] == 0 ) count_jump [ i ] = - 1 ; } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( count_jump [ i ] + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 8 , 9 , 1 , 0 , 7 , 6 , 8 , 9 } ; int n = arr . length ; countWaysToJump ( arr , n ) ; } } +","def countWaysToJump ( arr , n ) : NEW_LINE INDENT count_jump = [ 0 for i in range ( n ) ] NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT if ( arr [ i ] >= n - i - 1 ) : NEW_LINE INDENT count_jump [ i ] += 1 NEW_LINE DEDENT j = i + 1 NEW_LINE while ( j < n - 1 and j <= arr [ i ] + i ) : NEW_LINE INDENT if ( count_jump [ j ] != - 1 ) : NEW_LINE INDENT count_jump [ i ] += count_jump [ j ] NEW_LINE DEDENT j += 1 NEW_LINE DEDENT if ( count_jump [ i ] == 0 ) : NEW_LINE INDENT count_jump [ i ] = - 1 NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT print ( count_jump [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 1 , 3 , 5 , 8 , 9 , 1 , 0 , 7 , 6 , 8 , 9 ] NEW_LINE n = len ( arr ) NEW_LINE countWaysToJump ( arr , n ) NEW_LINE +" +E1032,"import java . util . * ; class gfg { public static double calculateSum ( double n ) { return 2 * ( Math . pow ( n , 6 ) + 15 * Math . pow ( n , 4 ) + 15 * Math . pow ( n , 2 ) + 1 ) ; } public static void main ( String [ ] args ) { double n = 1.4142 ; System . out . println ( ( int ) Math . ceil ( calculateSum ( n ) ) ) ; } } +","import math NEW_LINE def calculateSum ( n ) : NEW_LINE INDENT a = int ( n ) NEW_LINE return ( 2 * ( pow ( n , 6 ) + 15 * pow ( n , 4 ) + 15 * pow ( n , 2 ) + 1 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 1.4142 NEW_LINE print ( math . ceil ( calculateSum ( n ) ) ) NEW_LINE DEDENT +" +E1033,"import java . util . * ; import java . lang . * ; import java . io . * ; class Gfg { static boolean isMajority ( int a [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( mp . containsKey ( a [ i ] ) ) mp . put ( a [ i ] , mp . get ( a [ i ] ) + 1 ) ; else mp . put ( a [ i ] , 1 ) ; for ( Map . Entry < Integer , Integer > x : mp . entrySet ( ) ) if ( x . getValue ( ) >= n / 2 ) return true ; return false ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 3 , 9 , 2 , 2 } ; int n = a . length ; if ( isMajority ( a , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isMajority ( a ) : NEW_LINE INDENT mp = { } NEW_LINE for i in a : NEW_LINE INDENT if i in mp : mp [ i ] += 1 NEW_LINE else : mp [ i ] = 1 NEW_LINE DEDENT for x in mp : NEW_LINE INDENT if mp [ x ] >= len ( a ) // 2 : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT a = [ 2 , 3 , 9 , 2 , 2 ] NEW_LINE print ( "" Yes "" if isMajority ( a ) else "" No "" ) NEW_LINE +" +E1034,"import java . util . HashSet ; import java . util . Set ; public class MaxPossibleSuminWindow { static int returnMaxSum ( int A [ ] , int B [ ] , int n ) { Set < Integer > mp = new HashSet < Integer > ( ) ; int result = 0 ; int curr_sum = 0 , curr_begin = 0 ; for ( int i = 0 ; i < n ; ++ i ) { while ( mp . contains ( A [ i ] ) ) { mp . remove ( A [ curr_begin ] ) ; curr_sum -= B [ curr_begin ] ; curr_begin ++ ; } mp . add ( A [ i ] ) ; curr_sum += B [ i ] ; result = Integer . max ( result , curr_sum ) ; } return result ; } public static void main ( String [ ] args ) { int A [ ] = { 0 , 1 , 2 , 3 , 0 , 1 , 4 } ; int B [ ] = { 9 , 8 , 1 , 2 , 3 , 4 , 5 } ; int n = A . length ; System . out . println ( returnMaxSum ( A , B , n ) ) ; } } +","def returnMaxSum ( A , B , n ) : NEW_LINE INDENT mp = set ( ) NEW_LINE result = 0 NEW_LINE curr_sum = curr_begin = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT while A [ i ] in mp : NEW_LINE INDENT mp . remove ( A [ curr_begin ] ) NEW_LINE curr_sum -= B [ curr_begin ] NEW_LINE curr_begin += 1 NEW_LINE DEDENT mp . add ( A [ i ] ) NEW_LINE curr_sum += B [ i ] NEW_LINE result = max ( result , curr_sum ) NEW_LINE DEDENT return result NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 0 , 1 , 2 , 3 , 0 , 1 , 4 ] NEW_LINE B = [ 9 , 8 , 1 , 2 , 3 , 4 , 5 ] NEW_LINE n = len ( A ) NEW_LINE print ( returnMaxSum ( A , B , n ) ) NEW_LINE DEDENT +" +E1035,"import java . util . ArrayList ; public class PrintPath { public static boolean hasPath ( Node root , ArrayList < Integer > arr , int x ) { if ( root == null ) return false ; arr . add ( root . data ) ; if ( root . data == x ) return true ; if ( hasPath ( root . left , arr , x ) || hasPath ( root . right , arr , x ) ) return true ; arr . remove ( arr . size ( ) - 1 ) ; return false ; } public static void printPath ( Node root , int x ) { ArrayList < Integer > arr = new ArrayList < > ( ) ; if ( hasPath ( root , arr , x ) ) { for ( int i = 0 ; i < arr . size ( ) - 1 ; i ++ ) System . out . print ( arr . get ( i ) + "" - > "" ) ; System . out . print ( arr . get ( arr . size ( ) - 1 ) ) ; } else System . out . print ( "" No ▁ Path "" ) ; } public static void main ( String args [ ] ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; int x = 5 ; printPath ( root , x ) ; } } class Node { int data ; Node left , right ; Node ( int data ) { this . data = data ; left = right = null ; } } ; +","class getNode : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . left = self . right = None NEW_LINE DEDENT DEDENT def hasPath ( root , arr , x ) : NEW_LINE INDENT if ( not root ) : NEW_LINE INDENT return False NEW_LINE DEDENT arr . append ( root . data ) NEW_LINE if ( root . data == x ) : NEW_LINE INDENT return True NEW_LINE DEDENT if ( hasPath ( root . left , arr , x ) or hasPath ( root . right , arr , x ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT arr . pop ( - 1 ) NEW_LINE return False NEW_LINE DEDENT def printPath ( root , x ) : NEW_LINE INDENT arr = [ ] NEW_LINE if ( hasPath ( root , arr , x ) ) : NEW_LINE INDENT for i in range ( len ( arr ) - 1 ) : NEW_LINE INDENT print ( arr [ i ] , end = "" - > "" ) NEW_LINE DEDENT print ( arr [ len ( arr ) - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No ▁ Path "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT root = getNode ( 1 ) NEW_LINE root . left = getNode ( 2 ) NEW_LINE root . right = getNode ( 3 ) NEW_LINE root . left . left = getNode ( 4 ) NEW_LINE root . left . right = getNode ( 5 ) NEW_LINE root . right . left = getNode ( 6 ) NEW_LINE root . right . right = getNode ( 7 ) NEW_LINE x = 5 NEW_LINE printPath ( root , x ) NEW_LINE DEDENT +" +E1036,"import java . util . * ; class GFG { static void SieveOfEratosthenes ( boolean prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static int xorOfElements ( int arr [ ] , int n ) { boolean prime [ ] = new boolean [ n + 1 ] ; Arrays . fill ( prime , true ) ; SieveOfEratosthenes ( prime , n + 1 ) ; int i , j ; HashMap < Integer , Integer > m = new HashMap < > ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( m . containsKey ( arr [ i ] ) ) m . put ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; else m . put ( arr [ i ] , 1 ) ; } int xor = 0 ; for ( Map . Entry < Integer , Integer > entry : m . entrySet ( ) ) { int key = entry . getKey ( ) ; int value = entry . getValue ( ) ; if ( prime [ value ] ) { xor ^= ( key ) ; } } return xor ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 4 , 6 , 5 , 4 , 6 } ; int n = arr . length ; System . out . println ( xorOfElements ( arr , n ) ) ; } } +","from math import sqrt NEW_LINE def SieveOfEratosthenes ( prime , p_size ) : NEW_LINE INDENT prime [ 0 ] = False ; NEW_LINE prime [ 1 ] = False ; NEW_LINE for p in range ( 2 , int ( sqrt ( p_size ) ) + 1 ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT for i in range ( p * 2 , p_size + 1 , p ) : NEW_LINE INDENT prime [ i ] = False ; NEW_LINE DEDENT DEDENT DEDENT return prime NEW_LINE DEDENT def xorPrimeFreq ( arr , n ) : NEW_LINE INDENT prime = [ True ] * ( n + 1 ) ; NEW_LINE prime = SieveOfEratosthenes ( prime , n + 1 ) ; NEW_LINE m = dict . fromkeys ( arr , 0 ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT m [ arr [ i ] ] += 1 ; NEW_LINE DEDENT xorVal = 0 ; NEW_LINE for key , value in m . items ( ) : NEW_LINE INDENT if ( prime [ value ] ) : NEW_LINE INDENT xorVal ^= key ; NEW_LINE DEDENT DEDENT return xorVal ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 5 , 4 , 6 , 5 , 4 , 6 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( xorPrimeFreq ( arr , n ) ) ; NEW_LINE DEDENT +" +E1037,"class GFG { static void minimumFlip ( String s , int x , int y ) { s = s + s ; boolean isOpposite = false ; if ( x > y ) { swap ( x , y ) ; isOpposite = true ; } int valClockwise = 0 ; char cur = s . charAt ( x ) ; for ( int i = x ; i <= y ; i ++ ) { if ( s . charAt ( i ) != cur ) { cur = s . charAt ( i ) ; valClockwise ++ ; } } int valAnticlockwise = 0 ; cur = s . charAt ( y ) ; x += s . length ( ) ; for ( int i = y ; i < x ; i ++ ) { if ( s . charAt ( i ) != cur ) { cur = s . charAt ( i ) ; valAnticlockwise ++ ; } } if ( valClockwise <= valAnticlockwise ) { if ( ! isOpposite ) { System . out . println ( "" Clockwise ▁ "" + valClockwise ) ; } else { System . out . println ( "" Anti - clockwise ▁ "" + valAnticlockwise ) ; } } else if ( ! isOpposite ) { System . out . println ( "" Anti - clockwise ▁ "" + valAnticlockwise ) ; } else { System . out . println ( "" Clockwise ▁ "" + valClockwise ) ; } } static void swap ( int a , int b ) { int c = a ; a = b ; b = c ; } public static void main ( String [ ] args ) { int x = 0 , y = 8 ; String s = ""000110"" ; minimumFlip ( s , x , y ) ; } } +","def minimumFlip ( s , x , y ) : NEW_LINE INDENT s = s + s NEW_LINE isOpposite = False NEW_LINE if ( x > y ) : NEW_LINE INDENT temp = y NEW_LINE y = x ; NEW_LINE x = temp NEW_LINE isOpposite = True NEW_LINE DEDENT valClockwise = 0 NEW_LINE cur = s [ x ] NEW_LINE for i in range ( x , y + 1 , 1 ) : NEW_LINE INDENT if ( s [ i ] != cur ) : NEW_LINE INDENT cur = s [ i ] NEW_LINE valClockwise += 1 NEW_LINE DEDENT DEDENT valAnticlockwise = 0 NEW_LINE cur = s [ y ] NEW_LINE x += len ( s ) - 1 NEW_LINE for i in range ( y , x + 1 , 1 ) : NEW_LINE INDENT if ( s [ i ] != cur ) : NEW_LINE INDENT cur = s [ i ] NEW_LINE valAnticlockwise += 1 NEW_LINE DEDENT DEDENT if ( valClockwise <= valAnticlockwise ) : NEW_LINE INDENT if ( isOpposite == False ) : NEW_LINE INDENT print ( "" Clockwise "" , valClockwise ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Anti - clockwise "" , valAnticlockwise ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( isOpposite == False ) : NEW_LINE INDENT print ( "" Anti - clockwise "" , valAnticlockwise ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Clockwise "" , valClockwise ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT x = 0 NEW_LINE y = 8 NEW_LINE s = ""000110"" NEW_LINE minimumFlip ( s , x , y ) NEW_LINE DEDENT +" +E1038,"class GFG { final static int MAX = 26 ; static int maxSubStr ( char [ ] str1 , int len1 , char [ ] str2 , int len2 ) { if ( len1 > len2 ) return 0 ; int freq1 [ ] = new int [ MAX ] ; for ( int i = 0 ; i < len1 ; i ++ ) freq1 [ i ] = 0 ; for ( int i = 0 ; i < len1 ; i ++ ) freq1 [ str1 [ i ] - ' a ' ] ++ ; int freq2 [ ] = new int [ MAX ] ; for ( int i = 0 ; i < len2 ; i ++ ) freq2 [ i ] = 0 ; for ( int i = 0 ; i < len2 ; i ++ ) freq2 [ str2 [ i ] - ' a ' ] ++ ; int minPoss = Integer . MAX_VALUE ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq1 [ i ] == 0 ) continue ; if ( freq1 [ i ] > freq2 [ i ] ) return 0 ; minPoss = Math . min ( minPoss , freq2 [ i ] / freq1 [ i ] ) ; } return minPoss ; } public static void main ( String [ ] args ) { String str1 = "" geeks "" , str2 = "" gskefrgoekees "" ; int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; System . out . println ( maxSubStr ( str1 . toCharArray ( ) , len1 , str2 . toCharArray ( ) , len2 ) ) ; } } +","import sys NEW_LINE MAX = 26 ; NEW_LINE def maxSubStr ( str1 , len1 , str2 , len2 ) : NEW_LINE INDENT if ( len1 > len2 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT freq1 = [ 0 ] * MAX ; NEW_LINE for i in range ( len1 ) : NEW_LINE INDENT freq1 [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1 ; NEW_LINE DEDENT freq2 = [ 0 ] * MAX ; NEW_LINE for i in range ( len2 ) : NEW_LINE INDENT freq2 [ ord ( str2 [ i ] ) - ord ( ' a ' ) ] += 1 ; NEW_LINE DEDENT minPoss = sys . maxsize ; NEW_LINE for i in range ( MAX ) : NEW_LINE INDENT if ( freq1 [ i ] == 0 ) : NEW_LINE INDENT continue ; NEW_LINE DEDENT if ( freq1 [ i ] > freq2 [ i ] ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT minPoss = min ( minPoss , freq2 [ i ] / freq1 [ i ] ) ; NEW_LINE DEDENT return int ( minPoss ) ; NEW_LINE DEDENT str1 = "" geeks "" ; str2 = "" gskefrgoekees "" ; NEW_LINE len1 = len ( str1 ) ; NEW_LINE len2 = len ( str2 ) ; NEW_LINE print ( maxSubStr ( str1 , len1 , str2 , len2 ) ) ; NEW_LINE +" +E1039,"class GFG { private static boolean isValidString ( String str , int n ) { int index = str . indexOf ( "" b "" ) ; if ( index == 0 ) return false ; while ( index != - 1 ) { if ( str . charAt ( index - 1 ) != ' a ' ) return false ; if ( index + 1 < n && str . charAt ( index + 1 ) != ' b ' ) return false ; if ( index + 2 < n && str . charAt ( index + 2 ) == ' b ' ) return false ; if ( index == n - 1 ) return false ; index = str . indexOf ( "" b "" , index + 2 ) ; } return true ; } public static void main ( String [ ] args ) { String str = "" abbaaabbabba "" ; int n = str . length ( ) ; System . out . println ( isValidString ( str , n ) ) ; } } +","def isValidString ( str , n ) : NEW_LINE INDENT idx = str . find ( "" b "" ) NEW_LINE if ( idx == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT while ( idx != - 1 ) : NEW_LINE INDENT if ( str [ idx - 1 ] != ' a ' ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( idx + 1 < n and str [ idx + 1 ] != ' b ' ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( idx + 2 < n and str [ idx + 2 ] == ' b ' ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( idx == n - 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT idx = str . find ( "" b "" , idx + 2 ) NEW_LINE DEDENT return True NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" abbaaabbabba "" NEW_LINE n = len ( str ) NEW_LINE print ( isValidString ( str , n ) ) NEW_LINE DEDENT +" +E1040,"class GFG { static int gcd ( int a , int b ) { if ( ( a % b ) == 0 ) return b ; return gcd ( b , a % b ) ; } static int firstFactorialDivisibleNumber ( int x ) { int i = 1 ; int new_x = x ; for ( i = 1 ; i < x ; i ++ ) { new_x /= gcd ( i , new_x ) ; if ( new_x == 1 ) break ; } return i ; } public static void main ( String [ ] args ) { int x = 16 ; System . out . print ( firstFactorialDivisibleNumber ( x ) ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if ( ( a % b ) == 0 ) : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b , a % b ) NEW_LINE DEDENT def firstFactorialDivisibleNumber ( x ) : NEW_LINE INDENT i = 1 NEW_LINE new_x = x NEW_LINE for i in range ( 1 , x ) : NEW_LINE INDENT new_x /= gcd ( i , new_x ) NEW_LINE if ( new_x == 1 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return i NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT x = 16 NEW_LINE print ( firstFactorialDivisibleNumber ( x ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E1041,"import java . io . * ; class GFG { static int xorLessK ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tempXor = 0 ; for ( int j = i ; j < n ; j ++ ) { tempXor ^= arr [ j ] ; if ( tempXor < k ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int k = 3 ; int arr [ ] = new int [ ] { 8 , 9 , 10 , 11 , 12 } ; int n = arr . length ; System . out . println ( xorLessK ( arr , n , k ) ) ; } } +","def xorLessK ( arr , n , k ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT tempXor = 0 NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT tempXor ^= arr [ j ] NEW_LINE if ( tempXor < k ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT k = 3 NEW_LINE arr = [ 8 , 9 , 10 , 11 , 12 ] NEW_LINE n = len ( arr ) NEW_LINE print ( xorLessK ( arr , n , k ) ) NEW_LINE DEDENT +" +E1042,"class GFG { static void findNumbers ( int arr [ ] , int n ) { int num [ ] = new int [ n ] ; int b_minus_a = arr [ n - 1 ] - arr [ 1 ] ; num [ 1 ] = ( arr [ 0 ] + b_minus_a ) / 2 ; num [ 0 ] = arr [ 0 ] - num [ 1 ] ; for ( int i = 1 ; i <= ( n - 2 ) ; i ++ ) num [ i + 1 ] = arr [ i ] - num [ 0 ] ; System . out . print ( "" Numbers ▁ are : ▁ "" ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( num [ i ] + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 13 , 10 , 14 , 9 , 17 , 21 , 16 , 18 , 13 , 17 } ; int n = 5 ; findNumbers ( arr , n ) ; } } +","def findNumbers ( arr , n ) : NEW_LINE INDENT num = [ 0 for i in range ( n ) ] NEW_LINE b_minus_a = arr [ n - 1 ] - arr [ 1 ] NEW_LINE num [ 1 ] = ( arr [ 0 ] + b_minus_a ) // 2 NEW_LINE num [ 0 ] = arr [ 0 ] - num [ 1 ] NEW_LINE for i in range ( 1 , ( n - 2 ) + 1 ) : NEW_LINE INDENT num [ i + 1 ] = arr [ i ] - num [ 0 ] NEW_LINE DEDENT print ( "" Numbers ▁ are : ▁ "" , end = "" "" ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( num [ i ] , end = "" , ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 13 , 10 , 14 , 9 , 17 , 21 , 16 , 18 , 13 , 17 ] NEW_LINE n = 5 NEW_LINE findNumbers ( arr , n ) NEW_LINE +" +E1043,"import java . util . * ; class GFG { static Vector < Long > pr = new Vector < > ( ) ; static boolean prime [ ] = new boolean [ 10000000 + 1 ] ; static void sieve ( long n ) { for ( int i = 2 ; i <= n ; i += 1 ) { prime [ i ] = true ; } for ( int p = 2 ; ( int ) p * ( int ) p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = ( int ) p * ( int ) p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) pr . add ( ( long ) p ) ; } static long SemiPrimeSum ( long N ) { long ans = 0 ; for ( int i = 0 ; i < pr . size ( ) ; i += 1 ) { for ( int j = i ; j < pr . size ( ) ; j += 1 ) { if ( ( long ) pr . get ( i ) * ( long ) pr . get ( j ) > N ) break ; ans += ( long ) pr . get ( i ) * ( long ) pr . get ( j ) ; } } return ans ; } public static void main ( String [ ] args ) { long N = 6 ; sieve ( N ) ; System . out . println ( SemiPrimeSum ( N ) ) ; } } +","pr = [ ] NEW_LINE prime = [ 1 for i in range ( 10000000 + 1 ) ] NEW_LINE def sieve ( n ) : NEW_LINE INDENT for p in range ( 2 , n ) : NEW_LINE INDENT if p * p > n : NEW_LINE INDENT break NEW_LINE DEDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( 2 * p , n + 1 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT for p in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT pr . append ( p ) NEW_LINE DEDENT DEDENT DEDENT def SemiPrimeSum ( N ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( len ( pr ) ) : NEW_LINE INDENT for j in range ( i , len ( pr ) ) : NEW_LINE INDENT if ( pr [ i ] * pr [ j ] > N ) : NEW_LINE INDENT break NEW_LINE DEDENT ans += pr [ i ] * pr [ j ] NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N = 6 NEW_LINE sieve ( N ) NEW_LINE print ( SemiPrimeSum ( N ) ) NEW_LINE +" +E1044,"class GFG { static String largestPalinSub ( String s ) { String res = "" "" ; char mx = s . charAt ( 0 ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) mx = ( char ) Math . max ( ( int ) mx , ( int ) s . charAt ( i ) ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( s . charAt ( i ) == mx ) res += s . charAt ( i ) ; return res ; } public static void main ( String [ ] args ) { String s = "" geeksforgeeks "" ; System . out . println ( largestPalinSub ( s ) ) ; } } +","def largestPalinSub ( s ) : NEW_LINE INDENT res = "" "" NEW_LINE mx = s [ 0 ] NEW_LINE for i in range ( 1 , len ( s ) ) : NEW_LINE INDENT mx = max ( mx , s [ i ] ) NEW_LINE DEDENT for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT if s [ i ] == mx : NEW_LINE INDENT res += s [ i ] NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" geeksforgeeks "" NEW_LINE print ( largestPalinSub ( s ) ) NEW_LINE DEDENT +" +E1045,"import java . util . ArrayList ; import java . util . Deque ; import java . util . LinkedList ; public class PrintAllPalindrome { public static void main ( String [ ] args ) { String input = "" nitin "" ; System . out . println ( "" All ▁ possible ▁ palindrome "" + "" partions ▁ for ▁ "" + input + "" ▁ are ▁ : "" ) ; allPalPartitions ( input ) ; } private static void allPalPartitions ( String input ) { int n = input . length ( ) ; ArrayList < ArrayList < String > > allPart = new ArrayList < > ( ) ; Deque < String > currPart = new LinkedList < String > ( ) ; allPalPartitonsUtil ( allPart , currPart , 0 , n , input ) ; for ( int i = 0 ; i < allPart . size ( ) ; i ++ ) { for ( int j = 0 ; j < allPart . get ( i ) . size ( ) ; j ++ ) { System . out . print ( allPart . get ( i ) . get ( j ) + "" ▁ "" ) ; } System . out . println ( ) ; } } private static void allPalPartitonsUtil ( ArrayList < ArrayList < String > > allPart , Deque < String > currPart , int start , int n , String input ) { if ( start >= n ) { allPart . add ( new ArrayList < > ( currPart ) ) ; return ; } for ( int i = start ; i < n ; i ++ ) { if ( isPalindrome ( input , start , i ) ) { currPart . addLast ( input . substring ( start , i + 1 ) ) ; allPalPartitonsUtil ( allPart , currPart , i + 1 , n , input ) ; currPart . removeLast ( ) ; } } } private static boolean isPalindrome ( String input , int start , int i ) { while ( start < i ) { if ( input . charAt ( start ++ ) != input . charAt ( i -- ) ) return false ; } return true ; } } +","def isPalindrome ( string : str , low : int , high : int ) : NEW_LINE INDENT while low < high : NEW_LINE INDENT if string [ low ] != string [ high ] : NEW_LINE INDENT return False NEW_LINE DEDENT low += 1 NEW_LINE high -= 1 NEW_LINE DEDENT return True NEW_LINE DEDENT def allPalPartUtil ( allPart : list , currPart : list , start : int , n : int , string : str ) : NEW_LINE INDENT if start >= n : NEW_LINE INDENT x = currPart . copy ( ) NEW_LINE allPart . append ( x ) NEW_LINE return NEW_LINE DEDENT for i in range ( start , n ) : NEW_LINE INDENT if isPalindrome ( string , start , i ) : NEW_LINE INDENT currPart . append ( string [ start : i + 1 ] ) NEW_LINE allPalPartUtil ( allPart , currPart , i + 1 , n , string ) NEW_LINE currPart . pop ( ) NEW_LINE DEDENT DEDENT DEDENT def allPalPartitions ( string : str ) : NEW_LINE INDENT n = len ( string ) NEW_LINE allPart = [ ] NEW_LINE currPart = [ ] NEW_LINE allPalPartUtil ( allPart , currPart , 0 , n , string ) NEW_LINE for i in range ( len ( allPart ) ) : NEW_LINE INDENT for j in range ( len ( allPart [ i ] ) ) : NEW_LINE INDENT print ( allPart [ i ] [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" nitin "" NEW_LINE allPalPartitions ( string ) NEW_LINE DEDENT +" +E1046,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { public static int findLength ( String str , int n ) { int current_sum = 0 ; int max_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { current_sum += ( str . charAt ( i ) == '0' ? 1 : - 1 ) ; if ( current_sum < 0 ) current_sum = 0 ; max_sum = Math . max ( current_sum , max_sum ) ; } return max_sum == 0 ? - 1 : max_sum ; } public static void main ( String [ ] args ) { String str = ""11000010001"" ; int n = str . length ( ) ; System . out . println ( findLength ( str , n ) ) ; } } +","def findLength ( string , n ) : NEW_LINE INDENT current_sum = 0 NEW_LINE max_sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT current_sum += ( 1 if string [ i ] == '0' else - 1 ) NEW_LINE if current_sum < 0 : NEW_LINE INDENT current_sum = 0 NEW_LINE DEDENT max_sum = max ( current_sum , max_sum ) NEW_LINE DEDENT return max_sum if max_sum else 0 NEW_LINE DEDENT s = ""11000010001"" NEW_LINE n = 11 NEW_LINE print ( findLength ( s , n ) ) NEW_LINE +" +E1047,"import java . io . * ; class GFG { static int Series ( int Arr [ ] , int N , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( Arr [ i ] == 1 ) count ++ ; if ( K >= ( N - count ) ) return 1 ; else return 0 ; } public static void main ( String [ ] args ) { int Arr [ ] = { 5 , 1 , 2 } ; int N = Arr . length ; int K = 2 ; int result = Series ( Arr , N , K ) ; if ( result == 1 ) System . out . println ( "" Possible "" ) ; else System . out . println ( "" Not ▁ Possible "" ) ; } } +","def Series ( Arr , N , K ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if Arr [ i ] == 1 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if K >= ( N - count ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 0 NEW_LINE DEDENT Arr = [ 5 , 1 , 2 ] NEW_LINE N = len ( Arr ) NEW_LINE K = 2 NEW_LINE result = Series ( Arr , N , K ) NEW_LINE if result == 1 : NEW_LINE INDENT print ( "" Possible "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Not ▁ Possible "" ) NEW_LINE DEDENT +" +E1048,"class GFG { static int countDigit ( int n ) { boolean prime [ ] = new boolean [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) prime [ i ] = false ; prime [ 2 ] = prime [ 3 ] = true ; prime [ 5 ] = prime [ 7 ] = true ; int temp = n , count = 0 ; while ( temp != 0 ) { int d = temp % 10 ; temp /= 10 ; if ( d > 0 && n % d == 0 && prime [ d ] == true ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int n = 1032 ; System . out . println ( countDigit ( n ) ) ; } } +","def countDigit ( n ) : NEW_LINE INDENT prime = [ False ] * 10 NEW_LINE prime [ 2 ] = True NEW_LINE prime [ 3 ] = True ; NEW_LINE prime [ 5 ] = True NEW_LINE prime [ 7 ] = True ; NEW_LINE temp = n NEW_LINE count = 0 ; NEW_LINE while ( temp != 0 ) : NEW_LINE INDENT d = temp % 10 ; NEW_LINE temp //= 10 ; NEW_LINE if ( d > 0 and n % d == 0 and prime [ d ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT n = 1032 NEW_LINE print ( countDigit ( n ) ) NEW_LINE +" +E1049,"import java . util . * ; class GFG { double polyapothem ( double n , double a ) { if ( a < 0 && n < 0 ) return - 1 ; return ( a / ( 2 * java . lang . Math . tan ( ( 180 / n ) * 3.14159 / 180 ) ) ) ; } public static void main ( String args [ ] ) { double a = 9 , n = 6 ; GFG g = new GFG ( ) ; System . out . println ( g . polyapothem ( n , a ) ) ; } } +","from math import tan NEW_LINE def polyapothem ( n , a ) : NEW_LINE INDENT if ( a < 0 and n < 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return a / ( 2 * tan ( ( 180 / n ) * 3.14159 / 180 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 9 NEW_LINE n = 6 NEW_LINE print ( ' { 0 : . 6 } ' . format ( polyapothem ( n , a ) ) ) NEW_LINE DEDENT +" +E1050,"import java . io . * ; class GFG { static long evenPowerSum ( int n ) { return ( 8 * n * ( n + 1 ) * ( 2 * n + 1 ) * ( 3 * n * n + 3 * n - 1 ) ) / 15 ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( evenPowerSum ( n ) ) ; } } +","def evenPowerSum ( n ) : NEW_LINE INDENT return ( 8 * n * ( n + 1 ) * ( 2 * n + 1 ) * ( 3 * n * n + 3 * n - 1 ) ) / 15 ; NEW_LINE DEDENT n = 4 ; NEW_LINE print ( int ( evenPowerSum ( n ) ) ) ; NEW_LINE +" +E1051,"class GFG { static void printModulus ( int X , int Y ) { int n = Math . max ( X , Y ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( X % i == Y % i ) System . out . print ( i + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int X , Y ; X = 10 ; Y = 20 ; printModulus ( X , Y ) ; } } +","def printModulus ( X , Y ) : NEW_LINE INDENT n = max ( X , Y ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( X % i == Y % i ) : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT X = 10 NEW_LINE Y = 20 NEW_LINE printModulus ( X , Y ) NEW_LINE +" +E1052,"import java . io . * ; class GFG { static int __gcd ( int a , int b ) { if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return __gcd ( a - b , b ) ; return __gcd ( a , b - a ) ; } static int minValidNumber ( int p , int q ) { if ( q % p == 0 ) return __gcd ( p , q ) ; else return - 1 ; } public static void main ( String [ ] args ) { int p = 2 , q = 6 ; System . out . print ( minValidNumber ( p , q ) ) ; } } +","from math import gcd NEW_LINE def minValidNumber ( p , q ) : NEW_LINE INDENT if ( q % p == 0 ) : NEW_LINE INDENT return gcd ( p , q ) NEW_LINE DEDENT else : NEW_LINE INDENT return - 1 NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT p , q = 2 , 6 ; NEW_LINE print ( minValidNumber ( p , q ) ) NEW_LINE DEDENT +" +E1053,"class GFG { static int maxSum ( int arr [ ] , int n , int k ) { if ( n < k ) { System . out . println ( "" Invalid "" ) ; return - 1 ; } int max_sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) max_sum += arr [ i ] ; int window_sum = max_sum ; for ( int i = k ; i < n ; i ++ ) { window_sum += arr [ i ] - arr [ i - k ] ; max_sum = Math . max ( max_sum , window_sum ) ; } return max_sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 2 , 10 , 2 , 3 , 1 , 0 , 20 } ; int k = 4 ; int n = arr . length ; System . out . println ( maxSum ( arr , n , k ) ) ; } } +","import sys NEW_LINE INT_MIN = - sys . maxsize - 1 NEW_LINE def maxSum ( arr , n , k ) : NEW_LINE INDENT if not n > k : NEW_LINE INDENT print ( "" Invalid "" ) NEW_LINE return - 1 NEW_LINE DEDENT max_sum = INT_MIN NEW_LINE window_sum = sum ( arr [ : k ] ) NEW_LINE for i in range ( n - k ) : NEW_LINE INDENT window_sum = window_sum - arr [ i ] + arr [ i + k ] NEW_LINE max_sum = max ( window_sum , max_sum ) NEW_LINE DEDENT return max_sum NEW_LINE DEDENT arr = [ 1 , 4 , 2 , 10 , 2 , 3 , 1 , 0 , 20 ] NEW_LINE k = 4 NEW_LINE n = len ( arr ) NEW_LINE print ( maxSum ( arr , n , k ) ) NEW_LINE +" +E1054,"class GFG { static void sort ( String a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( a [ i ] + a [ j ] ) . compareTo ( a [ j ] + a [ i ] ) > 0 ) { String s = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = s ; } } } } static String lexsmallest ( String a [ ] , int n ) { sort ( a , n ) ; String answer = "" "" ; for ( int i = 0 ; i < n ; i ++ ) answer += a [ i ] ; return answer ; } public static void main ( String args [ ] ) { String a [ ] = { "" c "" , "" cb "" , "" cba "" } ; int n = 3 ; System . out . println ( "" lexiographically ▁ smallest ▁ string ▁ = ▁ "" + lexsmallest ( a , n ) ) ; } } +","def lexSmallest ( a , n ) : NEW_LINE INDENT a . sort ( reverse = True ) NEW_LINE answer = "" "" NEW_LINE for i in range ( n ) : NEW_LINE INDENT answer += a [ i ] NEW_LINE DEDENT return answer NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ "" c "" , "" cb "" , "" cba "" ] NEW_LINE n = len ( a ) NEW_LINE print ( lexSmallest ( a , n ) ) NEW_LINE DEDENT +" +E1055,"import java . util . * ; public class FindAnagrams { private static void printAnagrams ( String arr [ ] ) { HashMap < String , List < String > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { String word = arr [ i ] ; char [ ] letters = word . toCharArray ( ) ; Arrays . sort ( letters ) ; String newWord = new String ( letters ) ; if ( map . containsKey ( newWord ) ) { map . get ( newWord ) . add ( word ) ; } else { List < String > words = new ArrayList < > ( ) ; words . add ( word ) ; map . put ( newWord , words ) ; } } for ( String s : map . keySet ( ) ) { List < String > values = map . get ( s ) ; if ( values . size ( ) > 1 ) { System . out . print ( values ) ; } } } public static void main ( String [ ] args ) { String arr [ ] = { "" cat "" , "" dog "" , "" tac "" , "" god "" , "" act "" } ; printAnagrams ( arr ) ; } } +","from collections import defaultdict NEW_LINE def printAnagramsTogether ( words ) : NEW_LINE INDENT groupedWords = defaultdict ( list ) NEW_LINE for word in words : NEW_LINE INDENT groupedWords [ "" "" . join ( sorted ( word ) ) ] . append ( word ) NEW_LINE DEDENT for group in groupedWords . values ( ) : NEW_LINE INDENT print ( "" ▁ "" . join ( group ) ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ "" cat "" , "" dog "" , "" tac "" , "" god "" , "" act "" ] NEW_LINE printAnagramsTogether ( arr ) NEW_LINE DEDENT +" +E1056,"import java . util . Arrays ; class GFG { static String commonPrefixUtil ( String str1 , String str2 ) { String result = "" "" ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; for ( int i = 0 , j = 0 ; i <= n1 - 1 && j <= n2 - 1 ; i ++ , j ++ ) { if ( str1 . charAt ( i ) != str2 . charAt ( j ) ) { break ; } result += str1 . charAt ( i ) ; } return ( result ) ; } static void commonPrefix ( String arr [ ] , int n ) { Arrays . sort ( arr ) ; System . out . println ( commonPrefixUtil ( arr [ 0 ] , arr [ n - 1 ] ) ) ; } public static void main ( String [ ] args ) { String arr [ ] = { "" geeksforgeeks "" , "" geeks "" , "" geek "" , "" geezer "" } ; int n = arr . length ; commonPrefix ( arr , n ) ; } } +","def commonPrefixUtil ( str1 , str2 ) : NEW_LINE INDENT n1 = len ( str1 ) NEW_LINE n2 = len ( str2 ) NEW_LINE result = "" "" NEW_LINE j = 0 NEW_LINE i = 0 NEW_LINE while ( i <= n1 - 1 and j <= n2 - 1 ) : NEW_LINE INDENT if ( str1 [ i ] != str2 [ j ] ) : NEW_LINE INDENT break NEW_LINE DEDENT result += ( str1 [ i ] ) NEW_LINE i += 1 NEW_LINE j += 1 NEW_LINE DEDENT return ( result ) NEW_LINE DEDENT def commonPrefix ( arr , n ) : NEW_LINE INDENT arr . sort ( reverse = False ) NEW_LINE print ( commonPrefixUtil ( arr [ 0 ] , arr [ n - 1 ] ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ "" geeksforgeeks "" , "" geeks "" , "" geek "" , "" geezer "" ] NEW_LINE n = len ( arr ) NEW_LINE commonPrefix ( arr , n ) NEW_LINE DEDENT +" +E1057,"import java . util . * ; class GFG { static int changeTheArray ( int arr [ ] , int n ) { int minEle = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; int maxEle = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; int minOperations = Integer . MAX_VALUE ; for ( int num = minEle ; num <= maxEle ; num ++ ) { int operations = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != num ) { operations += ( Math . abs ( num - arr [ i ] ) - 1 ) ; } } minOperations = Math . min ( minOperations , operations ) ; } return minOperations ; } public static void main ( String args [ ] ) { int arr [ ] = { 10 , 1 , 4 } ; int n = arr . length ; System . out . println ( changeTheArray ( arr , n ) ) ; } } +","import math NEW_LINE import sys NEW_LINE def changeTheArray ( arr , n ) : NEW_LINE INDENT minEle = min ( arr ) NEW_LINE maxEle = max ( arr ) NEW_LINE minOperations = sys . maxsize NEW_LINE for num in range ( minEle , maxEle + 1 ) : NEW_LINE INDENT operations = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] != num : NEW_LINE INDENT operations += ( abs ( num - arr [ i ] ) - 1 ) NEW_LINE DEDENT DEDENT minOperations = min ( minOperations , operations ) NEW_LINE DEDENT return minOperations NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 10 , 1 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( changeTheArray ( arr , n ) ) NEW_LINE DEDENT +" +E1058,"import java . util . * ; import java . io . * ; class GFG { static void findElements ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( arr [ j ] > arr [ i ] ) count ++ ; if ( count >= 2 ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 2 , - 6 , 3 , 5 , 1 } ; int n = arr . length ; findElements ( arr , n ) ; } } +","def findElements ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT count = 0 NEW_LINE for j in range ( 0 , n ) : NEW_LINE INDENT if arr [ j ] > arr [ i ] : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT DEDENT if count >= 2 : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 2 , - 6 , 3 , 5 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE findElements ( arr , n ) NEW_LINE +" +E1059,"class GFG { static int cntSubArrays ( int [ ] arr , int n , int k ) { int res = 0 ; int i = 0 ; while ( i < n ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; res += Math . max ( j - i - k + 1 , 0 ) ; i = j ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 2 , 5 } ; int n = arr . length ; int k = 2 ; System . out . println ( cntSubArrays ( arr , n , k ) ) ; } } +","def cntSubArrays ( arr , n , k ) : NEW_LINE INDENT res = 0 ; NEW_LINE i = 0 ; NEW_LINE while ( i < n ) : NEW_LINE INDENT j = i + 1 ; NEW_LINE while ( j < n and arr [ j ] >= arr [ j - 1 ] ) : NEW_LINE INDENT j += 1 ; NEW_LINE DEDENT res += max ( j - i - k + 1 , 0 ) ; NEW_LINE i = j ; NEW_LINE DEDENT return res ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 2 , 5 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE k = 2 ; NEW_LINE print ( cntSubArrays ( arr , n , k ) ) ; NEW_LINE DEDENT +" +E1060,"import java . util . * ; class GFG { static boolean match_words ( String dictionary [ ] , String sentence [ ] , int n , int m ) { Map < String , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( dictionary [ i ] ) ) { mp . put ( dictionary [ i ] , mp . get ( dictionary [ i ] ) + 1 ) ; } else { mp . put ( dictionary [ i ] , 1 ) ; } } for ( int i = 0 ; i < m ; i ++ ) { if ( mp . containsKey ( sentence [ i ] ) ) mp . put ( sentence [ i ] , mp . get ( sentence [ i ] ) - 1 ) ; else return false ; } return true ; } public static void main ( String [ ] args ) { String dictionary [ ] = { "" find "" , "" a "" , "" geeks "" , "" all "" , "" for "" , "" on "" , "" geeks "" , "" answers "" , "" inter "" } ; int n = dictionary . length ; String sentence [ ] = { "" find "" , "" all "" , "" answers "" , "" on "" , "" geeks "" , "" for "" , "" geeks "" } ; int m = sentence . length ; if ( match_words ( dictionary , sentence , n , m ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","def match_words ( dictionary , sentence , n , m ) : NEW_LINE INDENT mp = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT mp [ dictionary [ i ] ] = mp . get ( dictionary [ i ] , 0 ) + 1 NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT if ( mp [ sentence [ i ] ] ) : NEW_LINE INDENT mp [ sentence [ i ] ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT dictionary = [ "" find "" , "" a "" , "" geeks "" , "" all "" , "" for "" , "" on "" , "" geeks "" , "" answers "" , "" inter "" ] NEW_LINE n = len ( dictionary ) NEW_LINE sentence = [ "" find "" , "" all "" , "" answers "" , "" on "" , "" geeks "" , "" for "" , "" geeks "" ] NEW_LINE m = len ( sentence ) NEW_LINE if ( match_words ( dictionary , sentence , n , m ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT +" +E1061,"import java . io . * ; class GFG { static int sumofproduct ( int n ) { int ans = 0 ; for ( int x = 1 ; x <= n ; x ++ ) { int y = n / x ; ans += ( y * x ) ; } return ans ; } static public void main ( String [ ] args ) { int n = 10 ; System . out . println ( sumofproduct ( n ) ) ; } } +","def sumofproduct ( n ) : NEW_LINE INDENT ans = 0 NEW_LINE for x in range ( 1 , n + 1 ) : NEW_LINE INDENT y = int ( n / x ) NEW_LINE ans += ( y * x ) NEW_LINE DEDENT return ans NEW_LINE DEDENT n = 10 NEW_LINE print ( sumofproduct ( n ) ) NEW_LINE +" +E1062,"import java . io . * ; class GFG { static boolean isUnique ( int [ ] a , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; sum += n - 1 ; return ( sum == k ) ; } static public void main ( String [ ] args ) { int [ ] a = { 3 , 3 , 3 } ; int n = a . length ; int k = 12 ; if ( isUnique ( a , n , k ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isUnique ( a , n , k ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT sum += a [ i ] NEW_LINE DEDENT sum += n - 1 NEW_LINE return ( sum == k ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 3 , 3 , 3 ] NEW_LINE n = len ( a ) NEW_LINE k = 12 NEW_LINE if ( isUnique ( a , n , k ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1063,"class GFG { public static void main ( String [ ] args ) { int first , second ; for ( first = 1 ; first <= 5 ; ++ first ) for ( second = 1 ; second <= 5 ; ++ second ) System . out . printf ( "" % d ▁ \n "" , 5 * first + second - 5 ) ; } } +","if name == ' _ _ main _ _ ' : NEW_LINE INDENT for first in range ( 1 , 6 ) : NEW_LINE INDENT for second in range ( 1 , 6 ) : NEW_LINE INDENT print ( 5 * first + second - 5 ) NEW_LINE DEDENT DEDENT DEDENT +" +E1064,"public class ACX { static int calculate_ ( String s ) { if ( s . length ( ) == 1 ) return 0 ; int count_ = 0 ; char [ ] s1 = s . toCharArray ( ) ; for ( int i = s . length ( ) - 1 ; i > 0 😉 { if ( s1 [ i ] == '0' ) { count_ ++ ; i -- ; } else { count_ ++ ; while ( s1 [ i ] == '1' && i > 0 ) { count_ ++ ; i -- ; } if ( i == 0 ) count_ ++ ; s1 [ i ] = '1' ; } } return count_ ; } public static void main ( String [ ] args ) { String s ; s = ""10000100000"" ; System . out . println ( calculate_ ( s ) ) ; } } +","def calculate_ ( s ) : NEW_LINE INDENT if len ( s ) == 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT count_ = 0 NEW_LINE i = len ( s ) - 1 NEW_LINE while i > 0 : NEW_LINE INDENT if s [ i ] == '0' : NEW_LINE INDENT count_ += 1 NEW_LINE i -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT count_ += 1 NEW_LINE while s [ i ] == '1' and i > 0 : NEW_LINE INDENT count_ += 1 NEW_LINE i -= 1 NEW_LINE DEDENT if i == 0 : NEW_LINE INDENT count_ += 1 NEW_LINE DEDENT s = s [ : i ] + ""1"" + s [ i + 1 : ] NEW_LINE DEDENT DEDENT return count_ NEW_LINE DEDENT s = ""10000100000"" NEW_LINE print ( calculate_ ( s ) ) NEW_LINE +" +E1065,"import java . util . * ; class GFG { static String getWinner ( String str , int len ) { int total = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) == ' S ' ) { total ++ ; } } if ( ( total % 2 ) == 1 ) return "" First "" ; return "" Second "" ; } public static void main ( String [ ] args ) { String str = "" GSSS "" ; int len = str . length ( ) ; System . out . println ( getWinner ( str , len ) ) ; } } +","def getWinner ( string , length ) : NEW_LINE INDENT total = 0 ; NEW_LINE for i in range ( length ) : NEW_LINE INDENT if ( string [ i ] == ' S ' ) : NEW_LINE INDENT total += 1 ; NEW_LINE DEDENT DEDENT if ( ( total % 2 ) == 1 ) : NEW_LINE INDENT return "" First "" ; NEW_LINE DEDENT return "" Second "" ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" GSSS "" ; NEW_LINE length = len ( string ) ; NEW_LINE print ( getWinner ( string , length ) ) ; NEW_LINE DEDENT +" +E1066,"class GFG { static void countPermutations ( int N , int B ) { int x = ( int ) Math . pow ( B , N ) ; int y = ( int ) Math . pow ( B , N - 1 ) ; System . out . println ( x - y ) ; } public static void main ( String [ ] args ) { int N = 6 ; int B = 4 ; countPermutations ( N , B ) ; } } +","def countPermutations ( N , B ) : NEW_LINE INDENT x = B ** N NEW_LINE y = B ** ( N - 1 ) NEW_LINE print ( x - y ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N , B = 6 , 4 NEW_LINE countPermutations ( N , B ) NEW_LINE DEDENT +" +E1067,"import java . util . * ; import java . io . * ; class GFG { static String check ( int k , int d0 , int d1 ) { int s = ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 + ( 8 * ( d0 + d1 ) ) % 10 + ( 6 * ( d0 + d1 ) ) % 10 ; int a = ( k - 3 ) % 4 ; int x = 0 ; switch ( a ) { case 0 : x = 0 ; break ; case 1 : x = ( 2 * ( d0 + d1 ) ) % 10 ; break ; case 2 : x = ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 ; break ; case 3 : x = ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 + ( 8 * ( d0 + d1 ) ) % 10 ; break ; } int sum = d0 + d1 + ( ( ( k - 3 ) / 4 ) * s + x ) ; if ( sum % 3 == 0 ) return "" YES "" ; return "" NO "" ; } public static void main ( String [ ] args ) { int k , d0 , d1 ; k = 13 ; d0 = 8 ; d1 = 1 ; System . out . println ( check ( k , d0 , d1 ) ) ; k = 5 ; d0 = 3 ; d1 = 4 ; System . out . println ( check ( k , d0 , d1 ) ) ; } } +","def check ( k , d0 , d1 ) : NEW_LINE INDENT s = ( ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 + ( 8 * ( d0 + d1 ) ) % 10 + ( 6 * ( d0 + d1 ) ) % 10 ) NEW_LINE a = ( k - 3 ) % 4 NEW_LINE if ( a == 0 ) : NEW_LINE INDENT x = 0 NEW_LINE DEDENT elif ( a == 1 ) : NEW_LINE INDENT x = ( 2 * ( d0 + d1 ) ) % 10 NEW_LINE DEDENT elif ( a == 2 ) : NEW_LINE INDENT x = ( ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 ) NEW_LINE DEDENT elif ( a == 3 ) : NEW_LINE INDENT x = ( ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 + ( 8 * ( d0 + d1 ) ) % 10 ) NEW_LINE DEDENT sum = d0 + d1 + ( ( k - 3 ) // 4 ) * s + x NEW_LINE if ( sum % 3 == 0 ) : NEW_LINE INDENT return "" YES "" NEW_LINE DEDENT else : NEW_LINE INDENT return "" NO "" NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT k = 13 NEW_LINE d0 = 8 NEW_LINE d1 = 1 NEW_LINE print ( check ( k , d0 , d1 ) ) NEW_LINE k = 5 NEW_LINE d0 = 3 NEW_LINE d1 = 4 NEW_LINE print ( check ( k , d0 , d1 ) ) NEW_LINE DEDENT +" +E1068,"import java . io . * ; class GFG { public static void main ( String args [ ] ) { int n = 5 , i , j , num = 1 , gap ; gap = n - 1 ; for ( j = 1 ; j <= n ; j ++ ) { num = j ; for ( i = 1 ; i <= gap ; i ++ ) System . out . print ( "" ▁ "" ) ; gap -- ; for ( i = 1 ; i <= j ; i ++ ) { System . out . print ( num ) ; num ++ ; } num -- ; num -- ; for ( i = 1 ; i < j ; i ++ ) { System . out . print ( num ) ; num -- ; } System . out . println ( ) ; } } } +","n = 5 NEW_LINE num = 1 NEW_LINE gap = n - 1 NEW_LINE for j in range ( 1 , n + 1 ) : NEW_LINE INDENT num = j NEW_LINE for i in range ( 1 , gap + 1 ) : NEW_LINE INDENT print ( "" ▁ "" , end = "" "" ) NEW_LINE DEDENT gap = gap - 1 NEW_LINE for i in range ( 1 , j + 1 ) : NEW_LINE INDENT print ( num , end = "" "" ) NEW_LINE num = num + 1 NEW_LINE DEDENT num = num - 2 NEW_LINE for i in range ( 1 , j ) : NEW_LINE INDENT print ( num , end = "" "" ) NEW_LINE num = num - 1 NEW_LINE DEDENT print ( ) NEW_LINE DEDENT +" +E1069,"class GFG { static int isKthBitSet ( long x , long k ) { int rslt = ( ( x & ( 1 << ( k - 1 ) ) ) != 0 ) ? 1 : 0 ; return rslt ; } static int isPalindrome ( long x ) { long l = 1 ; long r = ( Integer . SIZE / 8 ) * 8 ; while ( l < r ) { if ( isKthBitSet ( x , l ) != isKthBitSet ( x , r ) ) { return 0 ; } l ++ ; r -- ; } return 1 ; } public static void main ( String [ ] args ) { long x = 1 << 15 + 1 << 16 ; System . out . println ( isPalindrome ( x ) ) ; x = ( 1 << 31 ) + 1 ; System . out . println ( isPalindrome ( x ) ) ; } } +","import sys NEW_LINE def isKthBitSet ( x , k ) : NEW_LINE INDENT if ( ( x & ( 1 << ( k - 1 ) ) ) != 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT def isPalindrome ( x ) : NEW_LINE INDENT l = 1 NEW_LINE r = 2 * 8 NEW_LINE while ( l < r ) : NEW_LINE INDENT if ( isKthBitSet ( x , l ) != isKthBitSet ( x , r ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT l += 1 NEW_LINE r -= 1 NEW_LINE DEDENT return True NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT x = 1 << 15 + 1 << 16 NEW_LINE print ( int ( isPalindrome ( x ) ) ) NEW_LINE x = 1 << 31 + 1 NEW_LINE print ( int ( isPalindrome ( x ) ) ) NEW_LINE DEDENT +" +E1070,"import java . util . HashMap ; import java . util . HashSet ; class GFG { public static void getSum ( int [ ] a , int n ) { int [ ] P = new int [ n ] ; P [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) P [ i ] = a [ i ] + P [ i - 1 ] ; int S = P [ n - 1 ] ; HashMap < Integer , Integer > hash = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) hash . put ( P [ i ] , 1 ) ; HashSet < Integer > res = new HashSet < > ( ) ; for ( int i = 1 ; i * i <= S ; i ++ ) { if ( S % i == 0 ) { boolean pres = true ; int div1 = i , div2 = S / i ; for ( int j = div1 ; j <= S ; j += div1 ) { if ( hash . get ( j ) == null || hash . get ( j ) != 1 ) { pres = false ; break ; } } if ( pres && div1 != S ) res . add ( div1 ) ; pres = true ; for ( int j = S / i ; j <= S ; j += S / i ) { if ( hash . get ( j ) == null || hash . get ( j ) != 1 ) { pres = false ; break ; } } if ( pres && div2 != S ) res . add ( div2 ) ; } } if ( res . size ( ) == 0 ) { System . out . println ( "" - 1"" ) ; return ; } for ( int i : res ) System . out . print ( i + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 2 , 1 , 1 , 1 , 2 , 1 , 3 } ; int n = a . length ; getSum ( a , n ) ; } } +","from math import sqrt NEW_LINE def getSum ( a , n ) : NEW_LINE INDENT P = [ 0 ] * n NEW_LINE P [ 0 ] = a [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT P [ i ] = a [ i ] + P [ i - 1 ] NEW_LINE DEDENT S = P [ n - 1 ] NEW_LINE hash = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT hash [ P [ i ] ] = 1 NEW_LINE DEDENT res = set ( ) NEW_LINE for i in range ( 1 , int ( sqrt ( S ) ) + 1 ) : NEW_LINE INDENT if ( S % i == 0 ) : NEW_LINE INDENT pres = True ; NEW_LINE div1 = i NEW_LINE div2 = S // i NEW_LINE for j in range ( div1 , S + 1 , div1 ) : NEW_LINE INDENT if j not in hash . keys ( ) : NEW_LINE INDENT pres = False NEW_LINE break NEW_LINE DEDENT DEDENT if ( pres and div1 != S ) : NEW_LINE INDENT res . add ( div1 ) NEW_LINE DEDENT pres = True NEW_LINE for j in range ( S // i , S + 1 , S // i ) : NEW_LINE INDENT if j not in hash . keys ( ) : NEW_LINE INDENT pres = False ; NEW_LINE break NEW_LINE DEDENT DEDENT if ( pres and div2 != S ) : NEW_LINE INDENT res . add ( div2 ) NEW_LINE DEDENT DEDENT DEDENT if ( len ( res ) == 0 ) : NEW_LINE INDENT print ( "" - 1"" ) NEW_LINE return NEW_LINE DEDENT for i in res : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , 2 , 1 , 1 , 1 , 2 , 1 , 3 ] NEW_LINE n = len ( a ) NEW_LINE getSum ( a , n ) NEW_LINE DEDENT +" +E1071,"import java . util . * ; class GFG { static int MAX_CHAR = 26 ; static String removeChars ( char arr [ ] , int k ) { int [ ] hash = new int [ MAX_CHAR ] ; int n = arr . length ; for ( int i = 0 ; i < n ; ++ i ) hash [ arr [ i ] - ' a ' ] ++ ; String ans = "" "" ; for ( int i = 0 ; i < n ; ++ i ) { if ( hash [ arr [ i ] - ' a ' ] != k ) { ans += arr [ i ] ; } } return ans ; } public static void main ( String [ ] args ) { char str [ ] = "" geeksforgeeks "" . toCharArray ( ) ; int k = 2 ; System . out . print ( removeChars ( str , k ) ) ; } } +","MAX_CHAR = 26 NEW_LINE def removeChars ( arr , k ) : NEW_LINE INDENT hash = [ 0 ] * MAX_CHAR NEW_LINE n = len ( arr ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT hash [ ord ( arr [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT ans = "" "" NEW_LINE index = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( hash [ ord ( arr [ i ] ) - ord ( ' a ' ) ] != k ) : NEW_LINE INDENT ans += arr [ i ] NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" geeksforgeeks "" NEW_LINE k = 2 NEW_LINE print ( removeChars ( str , k ) ) NEW_LINE DEDENT +" +E1072,"import java . util . * ; class GFG { public static int firstEven ( int arr [ ] , int n ) { HashMap < Integer , Boolean > map = new HashMap < Integer , Boolean > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . get ( arr [ i ] ) == null ) map . put ( arr [ i ] , false ) ; else { boolean val = map . get ( arr [ i ] ) ; if ( val == true ) map . put ( arr [ i ] , false ) ; else map . put ( arr [ i ] , true ) ; } } int j = 0 ; for ( j = 0 ; j < n ; j ++ ) { if ( map . get ( arr [ j ] ) == true ) break ; } return arr [ j ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 6 , 8 , 1 , 6 } ; int n = arr . length ; System . out . println ( firstEven ( arr , n ) ) ; } } +","def firstEven ( arr , n ) : NEW_LINE INDENT map1 = { } NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if arr [ i ] not in map1 : NEW_LINE INDENT map1 [ arr [ i ] ] = False NEW_LINE DEDENT else : NEW_LINE INDENT map1 [ arr [ i ] ] = not map1 [ arr [ i ] ] NEW_LINE DEDENT DEDENT for j in range ( 0 , n ) : NEW_LINE INDENT if map1 [ arr [ j ] ] == True : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return arr [ j ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 4 , 6 , 8 , 1 , 6 ] NEW_LINE print ( firstEven ( arr , 6 ) ) NEW_LINE DEDENT +" +E1073,"import java . io . * ; import java . util . Arrays ; class GFG { static String s = "" "" ; static String ReverseString ( String s ) { char [ ] arr = s . toCharArray ( ) ; for ( int i = 0 ; i < arr . length / 2 ; i ++ ) { char temp = arr [ i ] ; arr [ i ] = arr [ arr . length - i - 1 ] ; arr [ arr . length - i - 1 ] = temp ; } return new String ( arr ) ; } static void binary_conversion ( int m ) { while ( m != 0 ) { int tmp = m % 2 ; s += Integer . toString ( tmp ) ; m = ( int ) ( m / 2 ) ; } s = ReverseString ( s ) ; } static int find_character ( int n , int m , int i ) { binary_conversion ( m ) ; String s1 = "" "" ; for ( int x = 0 ; x < n ; x ++ ) { for ( int y = 0 ; y < s . length ( ) ; y ++ ) { if ( s . charAt ( y ) == '1' ) s1 += ""10"" ; else s1 += ""01"" ; } s = s1 ; s1 = "" "" ; } return s . charAt ( i ) - '0' ; } public static void main ( String args [ ] ) { int m = 5 , n = 2 , i = 8 ; System . out . print ( find_character ( n , m , i ) ) ; } } +","def binary_conversion ( s , m ) : NEW_LINE INDENT while ( m ) : NEW_LINE INDENT temp = m % 2 NEW_LINE s += str ( temp ) NEW_LINE m = m // 2 NEW_LINE DEDENT return s [ : : - 1 ] NEW_LINE DEDENT def find_character ( n , m , i ) : NEW_LINE INDENT s = "" "" NEW_LINE s = binary_conversion ( s , m ) NEW_LINE s1 = "" "" NEW_LINE for x in range ( n ) : NEW_LINE INDENT for j in range ( len ( s ) ) : NEW_LINE INDENT if s [ j ] == ""1"" : NEW_LINE INDENT s1 += ""10"" NEW_LINE DEDENT else : NEW_LINE INDENT s1 += ""01"" NEW_LINE DEDENT DEDENT s = s1 NEW_LINE s1 = "" "" NEW_LINE DEDENT e = ord ( s [ i ] ) NEW_LINE r = ord ( '0' ) NEW_LINE return e - r NEW_LINE DEDENT m , n , i = 5 , 2 , 8 NEW_LINE print ( find_character ( n , m , i ) ) NEW_LINE +" +E1074,"class GFG { static int cntSquares ( int n ) { return n * ( n + 1 ) * ( 2 * n + 1 ) / 6 ; } public static void main ( String args [ ] ) { System . out . println ( cntSquares ( 4 ) ) ; } } +","def cntSquares ( n ) : NEW_LINE INDENT return int ( n * ( n + 1 ) * ( 2 * n + 1 ) / 6 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( cntSquares ( 4 ) ) ; NEW_LINE DEDENT +" +E1075,"class GFG { static int multiplyWith3Point5 ( int x ) { return ( x << 1 ) + x + ( x >> 1 ) ; } public static void main ( String [ ] args ) { int x = 2 ; System . out . println ( multiplyWith3Point5 ( x ) ) ; } } +","def multiplyWith3Point5 ( x ) : NEW_LINE INDENT return ( x << 1 ) + x + ( x >> 1 ) NEW_LINE DEDENT x = 4 NEW_LINE print ( multiplyWith3Point5 ( x ) ) NEW_LINE +" +E1076,"class GFG { static int countSubSeq ( String str , int len ) { int ans = 0 ; int mul = 1 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) == '0' ) ans += mul ; mul *= 2 ; } return ans ; } public static void main ( String [ ] args ) { String str = ""10010"" ; int len = str . length ( ) ; System . out . print ( countSubSeq ( str , len ) ) ; } } +","def countSubSeq ( strr , lenn ) : NEW_LINE INDENT ans = 0 NEW_LINE mul = 1 NEW_LINE for i in range ( lenn ) : NEW_LINE INDENT if ( strr [ i ] == '0' ) : NEW_LINE INDENT ans += mul NEW_LINE DEDENT mul *= 2 NEW_LINE DEDENT return ans NEW_LINE DEDENT strr = ""10010"" NEW_LINE lenn = len ( strr ) NEW_LINE print ( countSubSeq ( strr , lenn ) ) NEW_LINE +" +E1077,"class GFG { static int a , b , c ; static void swapThree ( ) { a = a + b + c ; b = a - ( b + c ) ; c = a - ( b + c ) ; a = a - ( b + c ) ; } public static void main ( String [ ] args ) { a = 10 ; b = 20 ; c = 30 ; System . out . println ( "" Before ▁ swapping ▁ a ▁ = ▁ "" + a + "" , ▁ b ▁ = ▁ "" + b + "" , ▁ c ▁ = ▁ "" + c ) ; swapThree ( ) ; System . out . println ( "" After ▁ swapping ▁ a ▁ = ▁ "" + a + "" , ▁ b ▁ = ▁ "" + b + "" , ▁ c ▁ = ▁ "" + c ) ; } } +","def swapThree ( a , b , c ) : NEW_LINE INDENT a = a + b + c NEW_LINE b = a - ( b + c ) NEW_LINE c = a - ( b + c ) NEW_LINE a = a - ( b + c ) NEW_LINE print ( "" After ▁ swapping ▁ a ▁ = "" , a , "" , ▁ b ▁ = "" , b , "" , ▁ c ▁ = "" , c ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 10 NEW_LINE b = 20 NEW_LINE c = 30 NEW_LINE print ( "" Before ▁ swapping ▁ a ▁ = "" , a , "" , ▁ b ▁ = "" , b , "" , ▁ c ▁ = "" , c ) NEW_LINE swapThree ( a , b , c ) NEW_LINE DEDENT +" +E1078,"import java . util . * ; class GFG { static int countSubarrays ( int a [ ] , int n ) { int count = 0 ; int [ ] pre = new int [ n + 1 ] ; Arrays . fill ( pre , 0 ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) { pre [ i ] = pre [ i - 1 ] + a [ i - 1 ] ; } for ( int i = 1 ; i < n + 1 ; i ++ ) { for ( int j = i ; j < n + 1 ; j ++ ) { int sum1 = pre [ j ] - pre [ i - 1 ] , count1 = j - i + 1 ; int sum2 = pre [ n ] - sum1 , count2 = ( ( n - count1 ) == 0 ) ? 1 : ( n - count1 ) ; int includ = sum1 / count1 ; int exclud = sum2 / count2 ; if ( includ > exclud ) count ++ ; } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 6 , 3 , 5 } ; int n = arr . length ; System . out . println ( countSubarrays ( arr , n ) ) ; } } +","def countSubarrays ( a , n ) : NEW_LINE INDENT count = 0 NEW_LINE pre = [ 0 for i in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT pre [ i ] = pre [ i - 1 ] + a [ i - 1 ] NEW_LINE DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( i , n + 1 ) : NEW_LINE INDENT sum1 = pre [ j ] - pre [ i - 1 ] NEW_LINE count1 = j - i + 1 NEW_LINE sum2 = pre [ n ] - sum1 NEW_LINE if n - count1 == 0 : NEW_LINE INDENT count2 = 1 NEW_LINE DEDENT else : NEW_LINE INDENT count2 = n - count1 NEW_LINE DEDENT includ = sum1 // count1 NEW_LINE exclud = sum2 // count2 NEW_LINE if ( includ > exclud ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 6 , 3 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countSubarrays ( arr , n ) ) NEW_LINE +" +E1079,"class GFG { static void reverse ( int [ ] arr , int n , int k , int m ) { for ( int i = 0 ; i < n ; i += k + m ) { int left = i ; int right = Math . min ( i + k - 1 , n - 1 ) ; while ( left < right ) swap ( arr , left ++ , right -- ) ; } } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 } ; int k = 3 ; int m = 2 ; int n = arr . length ; reverse ( arr , n , k , m ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def reverse ( arr , n , k , m ) : NEW_LINE INDENT for i in range ( 0 , n , k + m ) : NEW_LINE INDENT left = i ; NEW_LINE right = min ( i + k - 1 , n - 1 ) ; NEW_LINE while ( left < right ) : NEW_LINE INDENT arr = swap ( arr , left , right ) ; NEW_LINE left += 1 ; NEW_LINE right -= 1 ; NEW_LINE DEDENT DEDENT return arr ; NEW_LINE DEDENT def swap ( arr , i , j ) : NEW_LINE INDENT temp = arr [ i ] ; NEW_LINE arr [ i ] = arr [ j ] ; NEW_LINE arr [ j ] = temp ; NEW_LINE return arr ; NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 ] ; NEW_LINE k = 3 ; NEW_LINE m = 2 ; NEW_LINE n = len ( arr ) ; NEW_LINE arr = reverse ( arr , n , k , m ) ; NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT +" +E1080,"class GFG { static int count ( int n ) { return ( int ) Math . pow ( 2 , n - 1 ) ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( count ( n ) ) ; } } +","def count ( n ) : NEW_LINE INDENT return pow ( 2 , n - 1 ) NEW_LINE DEDENT n = 4 NEW_LINE print ( count ( n ) ) NEW_LINE +" +E1081,"class GFG { static boolean isSubsetSum ( int set [ ] , int n , int sum ) { boolean subset [ ] [ ] = new boolean [ sum + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) subset [ 0 ] [ i ] = true ; for ( int i = 1 ; i <= sum ; i ++ ) subset [ i ] [ 0 ] = false ; for ( int i = 1 ; i <= sum ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { subset [ i ] [ j ] = subset [ i ] [ j - 1 ] ; if ( i >= set [ j - 1 ] ) subset [ i ] [ j ] = subset [ i ] [ j ] || subset [ i - set [ j - 1 ] ] [ j - 1 ] ; } } return subset [ sum ] [ n ] ; } public static void main ( String args [ ] ) { int set [ ] = { 3 , 34 , 4 , 12 , 5 , 2 } ; int sum = 9 ; int n = set . length ; if ( isSubsetSum ( set , n , sum ) == true ) System . out . println ( "" Found ▁ a ▁ subset "" + "" ▁ with ▁ given ▁ sum "" ) ; else System . out . println ( "" No ▁ subset ▁ with "" + "" ▁ given ▁ sum "" ) ; } } +","def isSubsetSum ( set , n , sum ) : NEW_LINE INDENT subset = ( [ [ False for i in range ( sum + 1 ) ] for i in range ( n + 1 ) ] ) NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT subset [ i ] [ 0 ] = True NEW_LINE DEDENT for i in range ( 1 , sum + 1 ) : NEW_LINE INDENT subset [ 0 ] [ i ] = False NEW_LINE DEDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , sum + 1 ) : NEW_LINE INDENT if j < set [ i - 1 ] : NEW_LINE INDENT subset [ i ] [ j ] = subset [ i - 1 ] [ j ] NEW_LINE DEDENT if j >= set [ i - 1 ] : NEW_LINE INDENT subset [ i ] [ j ] = ( subset [ i - 1 ] [ j ] or subset [ i - 1 ] [ j - set [ i - 1 ] ] ) NEW_LINE DEDENT DEDENT DEDENT return subset [ n ] [ sum ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT set = [ 3 , 34 , 4 , 12 , 5 , 2 ] NEW_LINE sum = 9 NEW_LINE n = len ( set ) NEW_LINE if ( isSubsetSum ( set , n , sum ) == True ) : NEW_LINE INDENT print ( "" Found ▁ a ▁ subset ▁ with ▁ given ▁ sum "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No ▁ subset ▁ with ▁ given ▁ sum "" ) NEW_LINE DEDENT DEDENT +" +E1082,"import java . io . * ; class GFG { static int colourVisible ( int height [ ] , int colour [ ] , int K ) { int arr [ ] = new int [ K + 1 ] ; int visible = 0 ; int max = height [ K - 1 ] ; arr [ colour [ K - 1 ] ] = 1 ; for ( int i = K - 2 ; i >= 0 ; i -- ) { if ( height [ i ] > max ) { max = height [ i ] ; arr [ colour [ i ] ] = 1 ; } } for ( int i = 1 ; i <= K ; i ++ ) { if ( arr [ i ] == 1 ) visible ++ ; } return visible ; } public static void main ( String [ ] args ) { int height [ ] = { 3 , 5 , 1 , 2 , 3 } ; int colour [ ] = { 1 , 2 , 3 , 4 , 3 } ; int K = colour . length ; System . out . println ( colourVisible ( height , colour , K ) ) ; } } +","def colourVisible ( height , colour , K ) : NEW_LINE INDENT arr = [ 0 for i in range ( K + 1 ) ] NEW_LINE visible = 0 NEW_LINE max = height [ K - 1 ] NEW_LINE arr [ colour [ K - 1 ] ] = 1 NEW_LINE i = K - 2 NEW_LINE while ( i >= 0 ) : NEW_LINE INDENT if ( height [ i ] > max ) : NEW_LINE INDENT max = height [ i ] NEW_LINE arr [ colour [ i ] ] = 1 NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT for i in range ( 1 , K + 1 , 1 ) : NEW_LINE INDENT if ( arr [ i ] == 1 ) : NEW_LINE INDENT visible += 1 NEW_LINE DEDENT DEDENT return visible NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT height = [ 3 , 5 , 1 , 2 , 3 ] NEW_LINE colour = [ 1 , 2 , 3 , 4 , 3 ] NEW_LINE K = len ( colour ) NEW_LINE print ( colourVisible ( height , colour , K ) ) NEW_LINE DEDENT +" +E1083,"import java . util . * ; class GFG { public static void sortRows ( int mat [ ] [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) Arrays . sort ( mat [ i ] ) ; } public static void findAndPrintCommonElements ( int mat [ ] [ ] , int n ) { sortRows ( mat , n ) ; int curr_index [ ] = new int [ n ] ; int f = 0 ; for ( ; curr_index [ 0 ] < n ; curr_index [ 0 ] ++ ) { int value = mat [ 0 ] [ curr_index [ 0 ] ] ; boolean present = true ; for ( int i = 1 ; i < n ; i ++ ) { while ( curr_index [ i ] < n && mat [ i ] [ curr_index [ i ] ] <= value ) curr_index [ i ] ++ ; if ( mat [ i ] [ curr_index [ i ] - 1 ] != value ) present = false ; if ( curr_index [ i ] == n ) { f = 1 ; break ; } } if ( present ) System . out . print ( value + "" ▁ "" ) ; if ( f == 1 ) break ; } } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 12 , 1 , 14 , 3 , 16 } , { 14 , 2 , 1 , 3 , 35 } , { 14 , 1 , 14 , 3 , 11 } , { 14 , 25 , 3 , 2 , 1 } , { 1 , 18 , 3 , 21 , 14 } } ; int n = 5 ; findAndPrintCommonElements ( mat , n ) ; } } +","MAX = 100 NEW_LINE def sortRows ( mat , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT mat [ i ] . sort ( ) ; NEW_LINE DEDENT DEDENT def findAndPrintCommonElements ( mat , n ) : NEW_LINE INDENT sortRows ( mat , n ) NEW_LINE curr_index = [ 0 ] * n NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT curr_index [ i ] = 0 NEW_LINE DEDENT f = 0 NEW_LINE while ( curr_index [ 0 ] < n ) : NEW_LINE INDENT value = mat [ 0 ] [ curr_index [ 0 ] ] NEW_LINE present = True NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT while ( curr_index [ i ] < n and mat [ i ] [ curr_index [ i ] ] <= value ) : NEW_LINE INDENT curr_index [ i ] = curr_index [ i ] + 1 NEW_LINE DEDENT if ( mat [ i ] [ curr_index [ i ] - 1 ] != value ) : NEW_LINE INDENT present = False NEW_LINE DEDENT if ( curr_index [ i ] == n ) : NEW_LINE INDENT f = 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ( present ) : NEW_LINE INDENT print ( value , end = "" ▁ "" ) NEW_LINE DEDENT if ( f == 1 ) : NEW_LINE INDENT break NEW_LINE DEDENT curr_index [ 0 ] = curr_index [ 0 ] + 1 NEW_LINE DEDENT DEDENT mat = [ [ 12 , 1 , 14 , 3 , 16 ] , [ 14 , 2 , 1 , 3 , 35 ] , [ 14 , 1 , 14 , 3 , 11 ] , [ 14 , 25 , 3 , 2 , 1 ] , [ 1 , 18 , 3 , 21 , 14 ] ] NEW_LINE n = 5 NEW_LINE findAndPrintCommonElements ( mat , n ) NEW_LINE +" +E1084,"class GFG { static void MaximumProduct ( int a [ ] , int n ) { int cntneg = 0 ; int cntzero = 0 ; int used [ ] = new int [ n ] ; int pos = - 1 ; for ( int i = 0 ; i < n ; ++ i ) { if ( a [ i ] == 0 ) { used [ i ] = 1 ; cntzero ++ ; } if ( a [ i ] < 0 ) { cntneg ++ ; if ( pos == - 1 || Math . abs ( a [ pos ] ) > Math . abs ( a [ i ] ) ) { pos = i ; } } } if ( cntneg % 2 == 1 ) { used [ pos ] = 1 ; } if ( cntzero == n || ( cntzero == n - 1 && cntneg == 1 ) ) { for ( int i = 0 ; i < n - 1 ; ++ i ) { System . out . println ( 1 + "" ▁ "" + ( i + 1 ) + "" ▁ "" + ( i + 2 ) ) ; } return ; } int lst = - 1 ; for ( int i = 0 ; i < n ; ++ i ) { if ( used [ i ] == 1 ) { if ( lst != - 1 ) { System . out . println ( 1 + "" ▁ "" + ( lst + 1 ) + "" ▁ "" + ( i + 1 ) ) ; } lst = i ; } } if ( lst != - 1 ) { System . out . println ( 2 + "" ▁ "" + ( lst + 1 ) ) ; } lst = - 1 ; for ( int i = 0 ; i < n ; ++ i ) { if ( used [ i ] != 1 ) { if ( lst != - 1 ) { System . out . println ( 1 + "" ▁ "" + ( lst + 1 ) + "" ▁ "" + ( i + 1 ) ) ; } lst = i ; } } } public static void main ( String [ ] args ) { int a [ ] = { 5 , - 2 , 0 , 1 , - 3 } ; int n = a . length ; MaximumProduct ( a , n ) ; } } +","def MaximumProduct ( a , n ) : NEW_LINE INDENT cntneg = 0 NEW_LINE cntzero = 0 NEW_LINE used = [ 0 ] * n NEW_LINE pos = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] == 0 ) : NEW_LINE INDENT used [ i ] = 1 NEW_LINE cntzero += 1 NEW_LINE DEDENT if ( a [ i ] < 0 ) : NEW_LINE INDENT cntneg += 1 NEW_LINE if ( pos == - 1 or abs ( a [ pos ] ) > abs ( a [ i ] ) ) : NEW_LINE INDENT pos = i NEW_LINE DEDENT DEDENT DEDENT if ( cntneg % 2 == 1 ) : NEW_LINE INDENT used [ pos ] = 1 NEW_LINE DEDENT if ( cntzero == n or ( cntzero == n - 1 and cntneg == 1 ) ) : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT print ( 1 , "" ▁ "" , i + 1 , "" ▁ "" , i + 2 ) NEW_LINE DEDENT return NEW_LINE DEDENT lst = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( used [ i ] ) : NEW_LINE INDENT if ( lst != - 1 ) : NEW_LINE INDENT print ( 1 , "" ▁ "" , lst + 1 , "" ▁ "" , i + 1 ) NEW_LINE DEDENT lst = i NEW_LINE DEDENT DEDENT if ( lst != - 1 ) : NEW_LINE INDENT print ( 2 , "" ▁ "" , lst + 1 ) NEW_LINE DEDENT lst = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( not used [ i ] ) : NEW_LINE INDENT if ( lst != - 1 ) : NEW_LINE INDENT print ( 1 , "" ▁ "" , lst + 1 , "" ▁ "" , i + 1 ) NEW_LINE DEDENT lst = i NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 5 , - 2 , 0 , 1 , - 3 ] NEW_LINE n = len ( a ) NEW_LINE MaximumProduct ( a , n ) NEW_LINE DEDENT +" +E1085,"import java . io . * ; class GFG { static int getSum ( int n ) { int sum = 0 ; while ( n != 0 ) { sum = sum + n % 10 ; n = n / 10 ; } return sum ; } public static void main ( String [ ] args ) { int n = 687 ; System . out . println ( getSum ( n ) ) ; } } +","def getSum ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE while ( n != 0 ) : NEW_LINE INDENT sum = sum + int ( n % 10 ) NEW_LINE n = int ( n / 10 ) NEW_LINE DEDENT return sum NEW_LINE DEDENT n = 687 NEW_LINE print ( getSum ( n ) ) NEW_LINE +" +E1086,"import java . util . * ; class Count { public static int countSetBits ( int n ) { int count = 0 ; while ( n != 0 ) { count ++ ; n &= ( n - 1 ) ; } return count ; } public static int FlippedCount ( int a , int b ) { return countSetBits ( a ^ b ) ; } public static void main ( String [ ] args ) { int a = 10 ; int b = 20 ; System . out . print ( FlippedCount ( a , b ) ) ; } } +","def countSetBits ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while n : NEW_LINE INDENT count += 1 NEW_LINE n &= ( n - 1 ) NEW_LINE DEDENT return count NEW_LINE DEDENT def FlippedCount ( a , b ) : NEW_LINE INDENT return countSetBits ( a ^ b ) NEW_LINE DEDENT a = 10 NEW_LINE b = 20 NEW_LINE print ( FlippedCount ( a , b ) ) NEW_LINE +" +E1087,"import java . util . * ; class GFG { static int findSum ( int arr [ ] , int N ) { Map < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } int maxFreq = 0 ; for ( Map . Entry < Integer , Integer > entry : mp . entrySet ( ) ) { if ( entry . getValue ( ) > maxFreq ) { maxFreq = entry . getValue ( ) ; } } int sum = 0 ; for ( Map . Entry < Integer , Integer > entry : mp . entrySet ( ) ) { if ( entry . getValue ( ) == maxFreq ) { sum += entry . getKey ( ) * entry . getValue ( ) ; } } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 } ; int N = arr . length ; System . out . println ( findSum ( arr , N ) ) ; } } +","def findSum ( arr , N ) : NEW_LINE INDENT mp = dict ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT mp [ arr [ i ] ] = mp . get ( arr [ i ] , 0 ) + 1 NEW_LINE DEDENT maxFreq = 0 NEW_LINE for itr in mp : NEW_LINE INDENT if ( mp [ itr ] > maxFreq ) : NEW_LINE INDENT maxFreq = mp [ itr ] NEW_LINE DEDENT DEDENT Sum = 0 NEW_LINE for itr in mp : NEW_LINE INDENT if ( mp [ itr ] == maxFreq ) : NEW_LINE INDENT Sum += itr * mp [ itr ] NEW_LINE DEDENT DEDENT return Sum NEW_LINE DEDENT arr = [ 1 , 1 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 ] NEW_LINE N = len ( arr ) NEW_LINE print ( findSum ( arr , N ) ) NEW_LINE +" +E1088,"import java . util . * ; class Count { public static int MDAS_Factorial ( int N ) { if ( N <= 2 ) return N ; if ( N <= 4 ) return ( N + 3 ) ; if ( ( N - 4 ) % 4 == 0 ) return ( N + 1 ) ; else if ( ( N - 4 ) % 4 <= 2 ) return ( N + 2 ) ; else return ( N - 1 ) ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . println ( MDAS_Factorial ( N ) ) ; N = 10 ; System . out . println ( MDAS_Factorial ( N ) ) ; } } +","def MDAS_Factorial ( N ) : NEW_LINE INDENT if N <= 2 : NEW_LINE INDENT return N NEW_LINE DEDENT if N <= 4 : NEW_LINE INDENT return N + 3 NEW_LINE DEDENT if ( N - 4 ) % 4 == 0 : NEW_LINE INDENT return N + 1 NEW_LINE DEDENT elif ( N - 4 ) % 4 <= 2 : NEW_LINE INDENT return N + 2 NEW_LINE DEDENT else : NEW_LINE INDENT return N - 1 NEW_LINE DEDENT DEDENT N = 4 NEW_LINE print ( MDAS_Factorial ( N ) ) NEW_LINE N = 10 NEW_LINE print ( MDAS_Factorial ( N ) ) NEW_LINE +" +E1089,"import java . util . * ; import java . lang . * ; public class GfG { static int maxAND ( int arr [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) res = res > ( arr [ i ] & arr [ j ] ) ? res : ( arr [ i ] & arr [ j ] ) ; return res ; } public static void main ( String argc [ ] ) { int arr [ ] = { 4 , 8 , 6 , 2 } ; int n = arr . length ; System . out . println ( "" Maximum ▁ AND ▁ Value ▁ = ▁ "" + maxAND ( arr , n ) ) ; } } +","def maxAND ( arr , n ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT res = max ( res , arr [ i ] & arr [ j ] ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT arr = [ 4 , 8 , 6 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Maximum ▁ AND ▁ Value ▁ = ▁ "" , maxAND ( arr , n ) ) NEW_LINE +" +E1090,"public class GFG { static boolean check ( int arr [ ] , int x , int n ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { double y = Math . sqrt ( arr [ i ] ) ; if ( Math . floor ( y ) == Math . ceil ( y ) ) { sum += arr [ i ] ; } } if ( sum % x == 0 ) return true ; else return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 9 , 10 } ; int n = arr . length ; int x = 13 ; if ( check ( arr , x , n ) ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","import math NEW_LINE def check ( a , y ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( len ( a ) ) : NEW_LINE INDENT x = math . sqrt ( a [ i ] ) NEW_LINE if ( math . floor ( x ) == math . ceil ( x ) ) : NEW_LINE INDENT sum = sum + a [ i ] NEW_LINE DEDENT DEDENT if ( sum % y == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT a = [ 2 , 3 , 4 , 9 , 10 ] NEW_LINE x = 13 NEW_LINE if check ( a , x ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1091,"import java . util . * ; class GFG { static int MAX_SIZE = ( int ) 1e6 ; static boolean [ ] prime = new boolean [ MAX_SIZE + 1 ] ; static void sieve ( ) { Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p <= MAX_SIZE ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= MAX_SIZE ; i += p ) prime [ i ] = false ; } } } static int kthPrimeGreaterThanN ( int n , int k ) { int res = - 1 ; for ( int i = n + 1 ; i < MAX_SIZE ; i ++ ) { if ( prime [ i ] == true ) k -- ; if ( k == 0 ) { res = i ; break ; } } return res ; } public static void main ( String [ ] args ) { sieve ( ) ; int n = 2 , k = 15 ; System . out . println ( kthPrimeGreaterThanN ( n , k ) ) ; } } +","MAX_SIZE = int ( 1e6 ) NEW_LINE prime = [ True ] * ( MAX_SIZE + 1 ) NEW_LINE def seive ( ) : NEW_LINE INDENT p = 2 NEW_LINE while ( p * p <= MAX_SIZE ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( p * p , MAX_SIZE , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT p += 1 NEW_LINE DEDENT DEDENT def kthPrimeGreaterThanN ( n , k ) : NEW_LINE INDENT res = - 1 NEW_LINE for i in range ( n + 1 , MAX_SIZE ) : NEW_LINE INDENT if ( prime [ i ] == True ) : NEW_LINE INDENT k -= 1 NEW_LINE DEDENT if ( k == 0 ) : NEW_LINE INDENT res = i NEW_LINE break NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 2 NEW_LINE k = 15 NEW_LINE seive ( ) NEW_LINE print ( kthPrimeGreaterThanN ( n , k ) ) NEW_LINE DEDENT +" +E1092,"import java . util . Arrays ; class GFG { static int minimumSets ( int arr [ ] , int n , int key ) { int i , j ; Arrays . sort ( arr ) ; for ( i = 0 , j = n - 1 ; i <= j ; ++ i ) if ( arr [ i ] + arr [ j ] <= key ) j -- ; return i ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 3 , 4 } ; int n = arr . length ; int key = 5 ; System . out . println ( minimumSets ( arr , n , key ) ) ; } } +","def minimumSets ( arr , n , key ) : NEW_LINE INDENT arr . sort ( reverse = False ) NEW_LINE j = n - 1 NEW_LINE for i in range ( 0 , j + 1 , 1 ) : NEW_LINE INDENT if ( arr [ i ] + arr [ j ] <= key ) : NEW_LINE INDENT j -= 1 NEW_LINE DEDENT DEDENT return i + 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 3 , 5 , 3 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE key = 5 NEW_LINE print ( minimumSets ( arr , n , key ) ) NEW_LINE DEDENT +" +E1093,"class GFG { static boolean isPalindrome ( char [ ] str ) { int len = str . length ; if ( len == 1 ) return true ; char ptr1 = str [ 0 ] ; char ptr2 = str [ len - 1 ] ; while ( ptr2 > ptr1 ) { if ( ptr1 != ptr2 ) return false ; ptr1 ++ ; ptr2 -- ; } return true ; } static int noOfAppends ( String s ) { if ( isPalindrome ( s . toCharArray ( ) ) ) return 0 ; s = s . substring ( 1 ) ; return 1 + noOfAppends ( s ) ; } public static void main ( String arr [ ] ) { String s = "" abede "" ; System . out . printf ( "" % d \n "" , noOfAppends ( s ) ) ; } } +","def isPalindrome ( Str ) : NEW_LINE INDENT Len = len ( Str ) NEW_LINE if ( Len == 1 ) : NEW_LINE INDENT return True NEW_LINE DEDENT ptr1 = 0 NEW_LINE ptr2 = Len - 1 NEW_LINE while ( ptr2 > ptr1 ) : NEW_LINE INDENT if ( Str [ ptr1 ] != Str [ ptr2 ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT ptr1 += 1 NEW_LINE ptr2 -= 1 NEW_LINE DEDENT return True NEW_LINE DEDENT def noOfAppends ( s ) : NEW_LINE INDENT if ( isPalindrome ( s ) ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT del s [ 0 ] NEW_LINE return 1 + noOfAppends ( s ) NEW_LINE DEDENT se = "" abede "" NEW_LINE s = [ i for i in se ] NEW_LINE print ( noOfAppends ( s ) ) NEW_LINE +" +E1094,"import java . util . * ; class GFG { static void add_factors ( int n , HashMap < Integer , Integer > mp ) { for ( int i = 1 ; i <= ( Math . sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { if ( mp . containsKey ( i ) ) mp . put ( i , mp . get ( i ) + 1 ) ; else mp . put ( i , 1 ) ; } else { if ( mp . containsKey ( i ) ) mp . put ( i , mp . get ( i ) + 1 ) ; else mp . put ( i , 1 ) ; if ( mp . containsKey ( n / i ) ) mp . put ( n / i , mp . get ( n / i ) + 1 ) ; else mp . put ( n / i , 1 ) ; } } } } static void count_divisors ( int a [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( mp . get ( a [ i ] ) == null ? 0 + "" ▁ "" : mp . get ( a [ i ] ) + "" ▁ "" ) ; add_factors ( a [ i ] , mp ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 1 , 28 , 4 , 2 , 6 , 7 } ; int n = arr . length ; count_divisors ( arr , n ) ; } } +","from collections import defaultdict NEW_LINE import math NEW_LINE def add_factors ( n , mp ) : NEW_LINE INDENT for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 , ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT if ( n // i == i ) : NEW_LINE INDENT mp [ i ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ i ] += 1 NEW_LINE mp [ n // i ] += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT def count_divisors ( a , n ) : NEW_LINE INDENT mp = defaultdict ( int ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( mp [ a [ i ] ] , end = "" ▁ "" ) NEW_LINE add_factors ( a [ i ] , mp ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 8 , 1 , 28 , 4 , 2 , 6 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE count_divisors ( arr , n ) NEW_LINE DEDENT +" +E1095,"import java . util . * ; class GFG { static boolean isPossible ( int [ ] arr , int n , int C , int mid ) { int magnet = 1 , currPosition = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] - currPosition >= mid ) { magnet ++ ; currPosition = arr [ i ] ; if ( magnet == C ) return true ; } } return false ; } static int binarySearch ( int n , int C , int [ ] arr ) { int lo , hi , mid , ans ; Arrays . sort ( arr ) ; lo = 0 ; hi = arr [ n - 1 ] ; ans = 0 ; while ( lo <= hi ) { mid = ( lo + hi ) / 2 ; if ( ! isPossible ( arr , n , C , mid ) ) hi = mid - 1 ; else { ans = Math . max ( ans , mid ) ; lo = mid + 1 ; } } return ans ; } public static void main ( String args [ ] ) { int C = 4 ; int [ ] arr = { 1 , 2 , 5 , 8 , 10 , 18 } ; int n = arr . length ; System . out . println ( binarySearch ( n , C , arr ) ) ; } } +","def isPossible ( arr , n , C , mid ) : NEW_LINE INDENT magnet = 1 NEW_LINE currPosition = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i ] - currPosition >= mid ) : NEW_LINE INDENT magnet += 1 NEW_LINE currPosition = arr [ i ] NEW_LINE if ( magnet == C ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT return False NEW_LINE DEDENT def binarySearch ( n , C , arr ) : NEW_LINE INDENT arr . sort ( reverse = False ) NEW_LINE lo = 0 NEW_LINE hi = arr [ n - 1 ] NEW_LINE ans = 0 NEW_LINE while ( lo <= hi ) : NEW_LINE INDENT mid = int ( ( lo + hi ) / 2 ) NEW_LINE if ( isPossible ( arr , n , C , mid ) == False ) : NEW_LINE INDENT hi = mid - 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = max ( ans , mid ) NEW_LINE lo = mid + 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT C = 4 NEW_LINE arr = [ 1 , 2 , 5 , 8 , 10 , 18 ] NEW_LINE n = len ( arr ) NEW_LINE print ( binarySearch ( n , C , arr ) ) NEW_LINE DEDENT +" +E1096,"public class GFG { static int makePalindrome ( int n , boolean odd ) { int res = n ; if ( odd ) { n = n / 10 ; } while ( n > 0 ) { res = 10 * res + n % 10 ; n /= 10 ; } return res ; } static boolean isPalindrome ( int n , int base ) { int reversed = 0 ; int temp = n ; while ( temp > 0 ) { reversed = reversed * base + temp % base ; temp /= base ; } return reversed == n ; } static void sumPalindrome ( int n , int k ) { int sum = 0 , i = 1 ; int p = makePalindrome ( i , true ) ; while ( p < n ) { if ( isPalindrome ( p , k ) ) { sum += p ; } i ++ ; p = makePalindrome ( i , true ) ; } i = 1 ; p = makePalindrome ( i , false ) ; while ( p < n ) { if ( isPalindrome ( p , k ) ) { sum += p ; } i ++ ; p = makePalindrome ( i , false ) ; } System . out . println ( "" Total ▁ sum ▁ is ▁ "" + sum ) ; } public static void main ( String [ ] args ) { int n = 1000000 , k = 2 ; sumPalindrome ( n , k ) ; } } +","def makePalindrome ( n , odd ) : NEW_LINE INDENT res = n ; NEW_LINE if ( odd ) : NEW_LINE INDENT n = int ( n / 10 ) ; NEW_LINE DEDENT while ( n > 0 ) : NEW_LINE INDENT res = 10 * res + n % 10 ; NEW_LINE n = int ( n / 10 ) ; NEW_LINE DEDENT return res ; NEW_LINE DEDENT def isPalindrome ( n , base ) : NEW_LINE INDENT reversed = 0 ; NEW_LINE temp = n ; NEW_LINE while ( temp > 0 ) : NEW_LINE INDENT reversed = reversed * base + temp % base ; NEW_LINE temp = int ( temp / base ) ; NEW_LINE DEDENT return reversed == n ; NEW_LINE DEDENT def sumPalindrome ( n , k ) : NEW_LINE INDENT sum = 0 ; NEW_LINE i = 1 ; NEW_LINE p = makePalindrome ( i , True ) ; NEW_LINE while ( p < n ) : NEW_LINE INDENT if ( isPalindrome ( p , k ) ) : NEW_LINE INDENT sum += p ; NEW_LINE DEDENT i += 1 ; NEW_LINE p = makePalindrome ( i , True ) ; NEW_LINE DEDENT i = 1 ; NEW_LINE p = makePalindrome ( i , False ) ; NEW_LINE while ( p < n ) : NEW_LINE INDENT if ( isPalindrome ( p , k ) ) : NEW_LINE INDENT sum += p ; NEW_LINE DEDENT i += 1 ; NEW_LINE p = makePalindrome ( i , False ) ; NEW_LINE DEDENT print ( "" Total ▁ sum ▁ is "" , sum ) ; NEW_LINE DEDENT n = 1000000 ; NEW_LINE k = 2 ; NEW_LINE sumPalindrome ( n , k ) ; NEW_LINE +" +E1097,"class GFG { static class Node { int data ; Node left , right ; } ; static int res ; static Node newNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = newNode . right = null ; return ( newNode ) ; } static int countUntil ( Node root ) { if ( root == null ) return 0 ; int l = countUntil ( root . left ) ; int r = countUntil ( root . right ) ; int maxCount ; if ( root . data == 1 ) maxCount = l + r + 1 ; else maxCount = l + r ; res = Math . max ( res , maxCount ) ; if ( root . data == 1 ) return Math . max ( l , r ) + 1 ; else return Math . max ( l , r ) ; } static int findMaxCount ( Node root ) { res = Integer . MIN_VALUE ; countUntil ( root ) ; return res ; } public static void main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 0 ) ; root . right = newNode ( 1 ) ; root . left . left = newNode ( 1 ) ; root . left . right = newNode ( 1 ) ; root . left . right . left = newNode ( 1 ) ; root . left . right . right = newNode ( 0 ) ; System . out . print ( findMaxCount ( root ) ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . data = 0 NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def newNode ( data ) : NEW_LINE INDENT newNode = Node ( ) NEW_LINE newNode . data = data NEW_LINE newNode . left = newNode . right = None NEW_LINE return ( newNode ) NEW_LINE DEDENT res = 0 NEW_LINE def countUntil ( root ) : NEW_LINE INDENT global res NEW_LINE if ( root == None ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT l = countUntil ( root . left ) NEW_LINE r = countUntil ( root . right ) NEW_LINE maxCount = 0 NEW_LINE if ( root . data == 1 ) : NEW_LINE INDENT maxCount = l + r + 1 NEW_LINE DEDENT else : NEW_LINE INDENT maxCount = l + r NEW_LINE DEDENT res = max ( res , maxCount ) NEW_LINE if ( root . data == 1 ) : NEW_LINE INDENT return max ( l , r ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return max ( l , r ) NEW_LINE DEDENT DEDENT def findMaxCount ( root ) : NEW_LINE INDENT global res NEW_LINE res = - 999999 NEW_LINE countUntil ( root ) NEW_LINE return res NEW_LINE DEDENT root = newNode ( 1 ) NEW_LINE root . left = newNode ( 0 ) NEW_LINE root . right = newNode ( 1 ) NEW_LINE root . left . left = newNode ( 1 ) NEW_LINE root . left . right = newNode ( 1 ) NEW_LINE root . left . right . left = newNode ( 1 ) NEW_LINE root . left . right . right = newNode ( 0 ) NEW_LINE print ( findMaxCount ( root ) ) NEW_LINE +" +E1098,"import java . io . * ; class GFG { static int countDigits ( int n ) { int count = 0 ; while ( n > 0 ) { count += 1 ; n /= 10 ; } return count ; } static int getDistinct ( int d , int count ) { int num = 0 ; count = ( int ) Math . pow ( 10 , count - 1 ) ; while ( count > 0 ) { num += ( count * d ) ; count /= 10 ; } return num ; } static int findCount ( int L , int R ) { int count = 0 ; int countDigitsL = countDigits ( L ) ; int countDigitsR = countDigits ( R ) ; int firstDigitL = ( L / ( int ) Math . pow ( 10 , countDigitsL - 1 ) ) ; int firstDigitR = ( R / ( int ) Math . pow ( 10 , countDigitsR - 1 ) ) ; if ( countDigitsL < countDigitsR ) { count += ( 9 * ( countDigitsR - countDigitsL - 1 ) ) ; if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) count += ( 9 - firstDigitL + 1 ) ; else count += ( 9 - firstDigitL ) ; if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) count += firstDigitR ; else count += ( firstDigitR - 1 ) ; } else { if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) count += ( 9 - firstDigitL + 1 ) ; else count += ( 9 - firstDigitL ) ; if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) count -= ( 9 - firstDigitR ) ; else count -= ( 9 - firstDigitR + 1 ) ; } return count ; } public static void main ( String [ ] args ) { int L = 10 , R = 50 ; System . out . println ( findCount ( L , R ) ) ; } } +","def countDigits ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT count += 1 NEW_LINE n //= 10 NEW_LINE DEDENT return count NEW_LINE DEDENT def getDistinct ( d , count ) : NEW_LINE INDENT num = 0 NEW_LINE count = pow ( 10 , count - 1 ) NEW_LINE while ( count > 0 ) : NEW_LINE INDENT num += ( count * d ) NEW_LINE count //= 10 NEW_LINE DEDENT return num NEW_LINE DEDENT def findCount ( L , R ) : NEW_LINE INDENT count = 0 NEW_LINE countDigitsL = countDigits ( L ) NEW_LINE countDigitsR = countDigits ( R ) NEW_LINE firstDigitL = ( L // pow ( 10 , countDigitsL - 1 ) ) NEW_LINE firstDigitR = ( R // pow ( 10 , countDigitsR - 1 ) ) NEW_LINE if ( countDigitsL < countDigitsR ) : NEW_LINE INDENT count += ( 9 * ( countDigitsR - countDigitsL - 1 ) ) NEW_LINE if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) : NEW_LINE INDENT count += ( 9 - firstDigitL + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT count += ( 9 - firstDigitL ) NEW_LINE DEDENT if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) : NEW_LINE INDENT count += firstDigitR NEW_LINE DEDENT else : NEW_LINE INDENT count += ( firstDigitR - 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) : NEW_LINE INDENT count += ( 9 - firstDigitL + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT count += ( 9 - firstDigitL ) NEW_LINE DEDENT if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) : NEW_LINE INDENT count -= ( 9 - firstDigitR ) NEW_LINE DEDENT else : NEW_LINE INDENT count -= ( 9 - firstDigitR + 1 ) NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT L = 10 NEW_LINE R = 50 NEW_LINE print ( findCount ( L , R ) ) NEW_LINE +" +E1099,"import java . util . * ; class GFG { static boolean isPalindrome ( int n ) { int divisor = 1 ; while ( n / divisor >= 10 ) divisor *= 10 ; while ( n != 0 ) { int leading = n / divisor ; int trailing = n % 10 ; if ( leading != trailing ) return false ; n = ( n % divisor ) / 10 ; divisor = divisor / 100 ; } return true ; } static int largestPalindrome ( int [ ] A , int n ) { Arrays . sort ( A ) ; for ( int i = n - 1 ; i >= 0 ; -- i ) { if ( isPalindrome ( A [ i ] ) ) return A [ i ] ; } return - 1 ; } public static void main ( String [ ] args ) { int [ ] A = { 1 , 232 , 54545 , 999991 } ; int n = A . length ; System . out . println ( largestPalindrome ( A , n ) ) ; } } +","def isPalindrome ( n ) : NEW_LINE INDENT divisor = 1 NEW_LINE while ( n / divisor >= 10 ) : NEW_LINE INDENT divisor *= 10 NEW_LINE DEDENT while ( n != 0 ) : NEW_LINE INDENT leading = n // divisor NEW_LINE trailing = n % 10 NEW_LINE if ( leading != trailing ) : NEW_LINE INDENT return False NEW_LINE DEDENT n = ( n % divisor ) // 10 NEW_LINE divisor = divisor // 100 NEW_LINE DEDENT return True NEW_LINE DEDENT def largestPalindrome ( A , n ) : NEW_LINE INDENT A . sort ( ) NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( isPalindrome ( A [ i ] ) ) : NEW_LINE INDENT return A [ i ] NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 1 , 232 , 54545 , 999991 ] NEW_LINE n = len ( A ) NEW_LINE print ( largestPalindrome ( A , n ) ) NEW_LINE DEDENT +" +E1100,"import java . util . * ; public class GFG { public static ArrayList < Integer > getPerfectSquares ( int n ) { ArrayList < Integer > perfectSquares = new ArrayList < > ( ) ; int current = 1 , i = 1 ; while ( current <= n ) { perfectSquares . add ( current ) ; current = ( int ) Math . pow ( ++ i , 2 ) ; } return perfectSquares ; } public static int maxPairSum ( int arr [ ] ) { int n = arr . length ; int max , secondMax ; if ( arr [ 0 ] > arr [ 1 ] ) { max = arr [ 0 ] ; secondMax = arr [ 1 ] ; } else { max = arr [ 1 ] ; secondMax = arr [ 0 ] ; } for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { secondMax = max ; max = arr [ i ] ; } else if ( arr [ i ] > secondMax ) { secondMax = arr [ i ] ; } } return ( max + secondMax ) ; } public static int countPairsWith ( int n , ArrayList < Integer > perfectSquares , HashSet < Integer > nums ) { int count = 0 ; for ( int i = 0 ; i < perfectSquares . size ( ) ; i ++ ) { int temp = perfectSquares . get ( i ) - n ; if ( temp > n && nums . contains ( temp ) ) count ++ ; } return count ; } public static int countPairs ( int arr [ ] ) { int i , n = arr . length ; int max = maxPairSum ( arr ) ; ArrayList < Integer > perfectSquares = getPerfectSquares ( max ) ; HashSet < Integer > nums = new HashSet < > ( ) ; for ( i = 0 ; i < n ; i ++ ) nums . add ( arr [ i ] ) ; int count = 0 ; for ( i = 0 ; i < n ; i ++ ) { count += countPairsWith ( arr [ i ] , perfectSquares , nums ) ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 6 , 9 , 10 , 20 } ; System . out . println ( countPairs ( arr ) ) ; } } +","def getPerfectSquares ( n ) : NEW_LINE INDENT perfectSquares = [ ] ; NEW_LINE current = 1 ; NEW_LINE i = 1 ; NEW_LINE while ( current <= n ) : NEW_LINE INDENT perfectSquares . append ( current ) ; NEW_LINE i += 1 ; NEW_LINE current = int ( pow ( i , 2 ) ) ; NEW_LINE DEDENT return perfectSquares ; NEW_LINE DEDENT def maxPairSum ( arr ) : NEW_LINE INDENT n = len ( arr ) ; NEW_LINE max = 0 ; NEW_LINE secondMax = 0 ; NEW_LINE if ( arr [ 0 ] > arr [ 1 ] ) : NEW_LINE INDENT max = arr [ 0 ] ; NEW_LINE secondMax = arr [ 1 ] ; NEW_LINE DEDENT else : NEW_LINE INDENT max = arr [ 1 ] ; NEW_LINE secondMax = arr [ 0 ] ; NEW_LINE DEDENT for i in range ( 2 , n ) : NEW_LINE INDENT if ( arr [ i ] > max ) : NEW_LINE INDENT secondMax = max ; NEW_LINE max = arr [ i ] ; NEW_LINE DEDENT elif ( arr [ i ] > secondMax ) : NEW_LINE INDENT secondMax = arr [ i ] ; NEW_LINE DEDENT DEDENT return ( max + secondMax ) ; NEW_LINE DEDENT def countPairsWith ( n , perfectSquares , nums ) : NEW_LINE INDENT count = 0 ; NEW_LINE for i in range ( len ( perfectSquares ) ) : NEW_LINE INDENT temp = perfectSquares [ i ] - n ; NEW_LINE if ( temp > n and ( temp in nums ) ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT return count ; NEW_LINE DEDENT def countPairs ( arr ) : NEW_LINE INDENT n = len ( arr ) ; NEW_LINE max = maxPairSum ( arr ) ; NEW_LINE perfectSquares = getPerfectSquares ( max ) ; NEW_LINE nums = [ ] ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT nums . append ( arr [ i ] ) ; NEW_LINE DEDENT count = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT count += countPairsWith ( arr [ i ] , perfectSquares , nums ) ; NEW_LINE DEDENT return count ; NEW_LINE DEDENT arr = [ 2 , 3 , 6 , 9 , 10 , 20 ] ; NEW_LINE print ( countPairs ( arr ) ) ; NEW_LINE +" +E1101,"import java . io . * ; class GFG { public static void main ( String [ ] args ) { int i , j , k , sp , space = 4 ; char prt = ' $ ' ; for ( i = 1 ; i <= 5 ; i ++ ) { for ( sp = space ; sp >= 1 ; sp -- ) { System . out . print ( "" ▁ "" ) ; } for ( j = 1 ; j <= i ; j ++ ) { System . out . print ( prt ) ; } for ( k = 1 ; k <= ( i - 1 ) ; k ++ ) { if ( i == 1 ) { continue ; } System . out . print ( prt ) ; } System . out . println ( ) ; space -- ; } space = 1 ; for ( i = 4 ; i >= 1 ; i -- ) { for ( sp = space ; sp >= 1 ; sp -- ) { System . out . print ( "" ▁ "" ) ; } for ( j = 1 ; j <= i ; j ++ ) { System . out . print ( prt ) ; } for ( k = 1 ; k <= ( i - 1 ) ; k ++ ) { System . out . print ( prt ) ; } space ++ ; System . out . println ( ) ; } space = 3 ; for ( i = 2 ; i <= 5 ; i ++ ) { if ( ( i % 2 ) != 0 ) { for ( sp = space ; sp >= 1 ; sp -- ) { System . out . print ( "" ▁ "" ) ; } for ( j = 1 ; j <= i ; j ++ ) { System . out . print ( prt ) ; } } if ( ( i % 2 ) != 0 ) { System . out . println ( ) ; space -- ; } } } } +","if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT space = 4 NEW_LINE prt = ' $ ' NEW_LINE for i in range ( 1 , 6 ) : NEW_LINE INDENT for sp in range ( space , 0 , - 1 ) : NEW_LINE INDENT print ( end = "" ▁ "" ) NEW_LINE DEDENT for j in range ( 1 , i + 1 ) : NEW_LINE INDENT print ( prt , end = "" "" ) NEW_LINE DEDENT for k in range ( 1 , i ) : NEW_LINE INDENT if ( i == 1 ) : NEW_LINE INDENT continue NEW_LINE DEDENT print ( prt , end = "" "" ) NEW_LINE DEDENT print ( ) NEW_LINE space -= 1 NEW_LINE DEDENT space = 1 NEW_LINE for i in range ( 4 , 0 , - 1 ) : NEW_LINE INDENT for sp in range ( space , 0 , - 1 ) : NEW_LINE INDENT print ( end = "" ▁ "" ) NEW_LINE DEDENT for j in range ( 1 , i + 1 ) : NEW_LINE INDENT print ( prt , end = "" "" ) NEW_LINE DEDENT for k in range ( 1 , i ) : NEW_LINE INDENT print ( prt , end = "" "" ) NEW_LINE DEDENT space += 1 NEW_LINE print ( ) NEW_LINE DEDENT space = 3 NEW_LINE for i in range ( 2 , 6 ) : NEW_LINE INDENT if ( ( i % 2 ) != 0 ) : NEW_LINE INDENT for sp in range ( space , 0 , - 1 ) : NEW_LINE INDENT print ( "" ▁ "" , end = "" "" ) NEW_LINE DEDENT for j in range ( 1 , i + 1 ) : NEW_LINE INDENT print ( prt , end = "" "" ) NEW_LINE DEDENT DEDENT if ( ( i % 2 ) != 0 ) : NEW_LINE INDENT print ( ) NEW_LINE space -= 1 NEW_LINE DEDENT DEDENT DEDENT +" +E1102,"import java . util . Arrays ; class GFG { static int maxLen ( int [ ] arr , int n ) { int min_val = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; int freq = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == min_val ) freq ++ ; } return freq ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 1 } ; int n = arr . length ; System . out . println ( maxLen ( arr , n ) ) ; } } +","def maxLen ( arr , n ) : NEW_LINE INDENT min_val = min ( arr ) ; NEW_LINE freq = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] == min_val ) : NEW_LINE INDENT freq += 1 ; NEW_LINE DEDENT DEDENT return freq ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 3 , 1 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( maxLen ( arr , n ) ) ; NEW_LINE DEDENT +" +E1103,"import java . util . * ; class GfG { static int printKDistinct ( int arr [ ] , int n , int k ) { Map < Integer , Integer > h = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( h . containsKey ( arr [ i ] ) ) h . put ( arr [ i ] , h . get ( arr [ i ] ) + 1 ) ; else h . put ( arr [ i ] , 1 ) ; } if ( h . size ( ) < k ) return - 1 ; int dist_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( h . get ( arr [ i ] ) == 1 ) dist_count ++ ; if ( dist_count == k ) return arr [ i ] ; } return - 1 ; } public static void main ( String [ ] args ) { int ar [ ] = { 1 , 2 , 1 , 3 , 4 , 2 } ; int n = ar . length ; System . out . println ( printKDistinct ( ar , n , 2 ) ) ; } } +","def printKDistinct ( arr , size , KthIndex ) : NEW_LINE INDENT dict = { } NEW_LINE vect = [ ] NEW_LINE for i in range ( size ) : NEW_LINE INDENT if ( arr [ i ] in dict ) : NEW_LINE INDENT dict [ arr [ i ] ] = dict [ arr [ i ] ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT dict [ arr [ i ] ] = 1 NEW_LINE DEDENT DEDENT for i in range ( size ) : NEW_LINE INDENT if ( dict [ arr [ i ] ] > 1 ) : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT KthIndex = KthIndex - 1 NEW_LINE DEDENT if ( KthIndex == 0 ) : NEW_LINE INDENT return arr [ i ] NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT arr = [ 1 , 2 , 1 , 3 , 4 , 2 ] NEW_LINE size = len ( arr ) NEW_LINE print ( printKDistinct ( arr , size , 2 ) ) NEW_LINE +" +E1104,"class GFG { static boolean checkSubarraySum ( int [ ] arr , int n , int k , int sum ) { int curr_sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) curr_sum += arr [ i ] ; if ( curr_sum == sum ) return true ; for ( int j = k ; j < n ; j ++ ) { curr_sum = curr_sum + arr [ j ] - arr [ j - k ] ; if ( curr_sum == sum ) return true ; } return false ; } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 1 , 4 , 2 , 10 , 2 , 3 , 1 , 0 , 20 } ; int k = 4 ; int sum = 18 ; int n = arr . length ; if ( checkSubarraySum ( arr , n , k , sum ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","def checkSubarraySum ( arr , n , k , sumV ) : NEW_LINE INDENT curr_sum = 0 NEW_LINE for i in range ( 0 , k ) : NEW_LINE INDENT curr_sum += arr [ i ] NEW_LINE DEDENT if ( curr_sum == sumV ) : NEW_LINE INDENT return true NEW_LINE DEDENT for j in range ( k , n ) : NEW_LINE INDENT curr_sum = ( curr_sum + arr [ j ] - arr [ j - k ] ) NEW_LINE if ( curr_sum == sumV ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT arr = [ 1 , 4 , 2 , 10 , 2 , 3 , 1 , 0 , 20 ] NEW_LINE k = 4 NEW_LINE sumV = 18 NEW_LINE n = len ( arr ) NEW_LINE if ( checkSubarraySum ( arr , n , k , sumV ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT +" +E1105,"import java . io . * ; class GFG { static void printCombination ( int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( i % 3 != 0 ) { for ( int j = 1 ; j < n ; j ++ ) { if ( j % 3 != 0 ) { for ( int k = 1 ; k < n ; k ++ ) { if ( k % 3 != 0 && ( i + j + k ) == n ) { System . out . println ( i + "" ▁ "" + j + "" ▁ "" + k ) ; return ; } } } } } } } public static void main ( String [ ] args ) { int n = 233 ; printCombination ( n ) ; } } +","def printCombination ( n ) : NEW_LINE INDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( i % 3 != 0 ) : NEW_LINE INDENT for j in range ( 1 , n ) : NEW_LINE INDENT if ( j % 3 != 0 ) : NEW_LINE INDENT for k in range ( 1 , n ) : NEW_LINE INDENT if ( k % 3 != 0 and ( i + j + k ) == n ) : NEW_LINE INDENT print ( i , j , k ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT n = 233 ; NEW_LINE printCombination ( n ) ; NEW_LINE +" +E1106,"class GFG { static int countNumbersWith4 ( int n ) { if ( n < 4 ) return 0 ; int d = ( int ) Math . log10 ( n ) ; int [ ] a = new int [ d + 2 ] ; a [ 0 ] = 0 ; a [ 1 ] = 1 ; for ( int i = 2 ; i <= d ; i ++ ) a [ i ] = a [ i - 1 ] * 9 + ( int ) Math . ceil ( Math . pow ( 10 , i - 1 ) ) ; int p = ( int ) Math . ceil ( Math . pow ( 10 , d ) ) ; int msd = n / p ; if ( msd == 4 ) return ( msd ) * a [ d ] + ( n % p ) + 1 ; if ( msd > 4 ) return ( msd - 1 ) * a [ d ] + p + countNumbersWith4 ( n % p ) ; return ( msd ) * a [ d ] + countNumbersWith4 ( n % p ) ; } public static void main ( String [ ] args ) { int n = 328 ; System . out . println ( "" Count ▁ of ▁ numbers ▁ from ▁ 1 ▁ to ▁ "" + n + "" ▁ that ▁ have ▁ 4 ▁ as ▁ a ▁ digit ▁ is ▁ "" + countNumbersWith4 ( n ) ) ; } } +","import math as mt NEW_LINE def countNumbersWith4 ( n ) : NEW_LINE INDENT if ( n < 4 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT d = int ( mt . log10 ( n ) ) NEW_LINE a = [ 1 for i in range ( d + 1 ) ] NEW_LINE a [ 0 ] = 0 NEW_LINE if len ( a ) > 1 : NEW_LINE INDENT a [ 1 ] = 1 NEW_LINE DEDENT for i in range ( 2 , d + 1 ) : NEW_LINE INDENT a [ i ] = a [ i - 1 ] * 9 + mt . ceil ( pow ( 10 , i - 1 ) ) NEW_LINE DEDENT p = mt . ceil ( pow ( 10 , d ) ) NEW_LINE msd = n // p NEW_LINE if ( msd == 4 ) : NEW_LINE INDENT return ( msd ) * a [ d ] + ( n % p ) + 1 NEW_LINE DEDENT if ( msd > 4 ) : NEW_LINE INDENT return ( ( msd - 1 ) * a [ d ] + p + countNumbersWith4 ( n % p ) ) NEW_LINE DEDENT return ( msd ) * a [ d ] + countNumbersWith4 ( n % p ) NEW_LINE DEDENT n = 328 NEW_LINE print ( "" Count ▁ of ▁ numbers ▁ from ▁ 1 ▁ to "" , n , "" that ▁ have ▁ 4 ▁ as ▁ a ▁ digit ▁ is "" , countNumbersWith4 ( n ) ) NEW_LINE +" +E1107,"import java . util . * ; class GFG { static Vector < Integer > arr = new Vector < Integer > ( ) ; static void generateDivisors ( int n ) { for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) arr . add ( i ) ; else { arr . add ( i ) ; arr . add ( n / i ) ; } } } } static double harmonicMean ( int n ) { generateDivisors ( n ) ; double sum = 0.0 ; int len = arr . size ( ) ; for ( int i = 0 ; i < len ; i ++ ) sum = sum + n / arr . get ( i ) ; sum = sum / n ; return arr . size ( ) / sum ; } static boolean isOreNumber ( int n ) { double mean = harmonicMean ( n ) ; if ( mean - Math . floor ( mean ) == 0 ) return true ; else return false ; } public static void main ( String [ ] args ) { int n = 28 ; if ( isOreNumber ( n ) ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } } +","arr = [ ] NEW_LINE def generateDivisors ( n ) : NEW_LINE INDENT for i in range ( 1 , int ( n ** ( 0.5 ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT if n // i == i : NEW_LINE INDENT arr . append ( i ) NEW_LINE DEDENT else : NEW_LINE INDENT arr . append ( i ) NEW_LINE arr . append ( n // i ) NEW_LINE DEDENT DEDENT DEDENT DEDENT def harmonicMean ( n ) : NEW_LINE INDENT generateDivisors ( n ) NEW_LINE Sum = 0 NEW_LINE length = len ( arr ) NEW_LINE for i in range ( 0 , length ) : NEW_LINE INDENT Sum = Sum + ( n / arr [ i ] ) NEW_LINE DEDENT Sum = Sum / n NEW_LINE return length / Sum NEW_LINE DEDENT def isOreNumber ( n ) : NEW_LINE INDENT mean = harmonicMean ( n ) NEW_LINE if mean - int ( mean ) == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 28 NEW_LINE if isOreNumber ( n ) == True : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E1108,"class GFG { static int powOfPositive ( int n ) { int pos = ( int ) Math . floor ( ( Math . log ( n ) / Math . log ( 2 ) ) ) ; return ( int ) Math . pow ( 2 , pos ) ; } static int powOfNegative ( int n ) { int pos = ( int ) Math . ceil ( ( Math . log ( n ) / Math . log ( 2 ) ) ) ; return ( int ) ( - 1 * Math . pow ( 2 , pos ) ) ; } static void highestPowerOf2 ( int n ) { if ( n > 0 ) { System . out . println ( powOfPositive ( n ) ) ; } else { n = - n ; System . out . println ( powOfNegative ( n ) ) ; } } public static void main ( String [ ] args ) { int n = - 24 ; highestPowerOf2 ( n ) ; } } +","from math import floor , ceil , log2 NEW_LINE def powOfPositive ( n ) : NEW_LINE INDENT pos = floor ( log2 ( n ) ) ; NEW_LINE return 2 ** pos ; NEW_LINE DEDENT def powOfNegative ( n ) : NEW_LINE INDENT pos = ceil ( log2 ( n ) ) ; NEW_LINE return ( - 1 * pow ( 2 , pos ) ) ; NEW_LINE DEDENT def highestPowerOf2 ( n ) : NEW_LINE INDENT if ( n > 0 ) : NEW_LINE INDENT print ( powOfPositive ( n ) ) ; NEW_LINE DEDENT else : NEW_LINE INDENT n = - n ; NEW_LINE print ( powOfNegative ( n ) ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = - 24 ; NEW_LINE highestPowerOf2 ( n ) ; NEW_LINE DEDENT +" +E1109,"import java . util . * ; class GfG { static boolean prime [ ] = new boolean [ 1000000 + 5 ] ; static void findPrime ( ) { Arrays . fill ( prime , true ) ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= 1000000 ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= 1000000 ; i += p ) prime [ i ] = false ; } } } static int lenOfLongSubarr ( int arr [ ] , int n ) { Map < Integer , Integer > um = new HashMap < Integer , Integer > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += prime [ arr [ i ] ] == false ? - 1 : 1 ; if ( sum == 1 ) maxLen = i + 1 ; else if ( ! um . containsKey ( sum ) ) um . put ( sum , i ) ; if ( um . containsKey ( sum - 1 ) ) { if ( maxLen < ( i - um . get ( sum - 1 ) ) ) maxLen = i - um . get ( sum - 1 ) ; } } return maxLen ; } public static void main ( String [ ] args ) { findPrime ( ) ; int arr [ ] = { 1 , 9 , 3 , 4 , 5 , 6 , 7 , 8 } ; int n = arr . length ; System . out . println ( lenOfLongSubarr ( arr , n ) ) ; } } +","prime = [ True ] * ( 1000000 + 5 ) NEW_LINE def findPrime ( ) : NEW_LINE INDENT prime [ 0 ] , prime [ 1 ] = False , False NEW_LINE for p in range ( 2 , 1001 ) : NEW_LINE INDENT if prime [ p ] == True : NEW_LINE INDENT for i in range ( p * 2 , 1000001 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def lenOfLongSubarr ( arr , n ) : NEW_LINE INDENT um = { } NEW_LINE Sum , maxLen = 0 , 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT Sum = Sum - 1 if prime [ arr [ i ] ] == False else Sum + 1 NEW_LINE if Sum == 1 : NEW_LINE INDENT maxLen = i + 1 NEW_LINE DEDENT elif Sum not in um : NEW_LINE INDENT um [ Sum ] = i NEW_LINE DEDENT if ( Sum - 1 ) in um : NEW_LINE INDENT if maxLen < ( i - um [ Sum - 1 ] ) : NEW_LINE INDENT maxLen = i - um [ Sum - 1 ] NEW_LINE DEDENT DEDENT DEDENT return maxLen NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT findPrime ( ) NEW_LINE arr = [ 1 , 9 , 3 , 4 , 5 , 6 , 7 , 8 ] NEW_LINE n = len ( arr ) NEW_LINE print ( lenOfLongSubarr ( arr , n ) ) NEW_LINE DEDENT +" +E1110,"import java . io . * ; class TurnOff { static int turnOffK ( int n , int k ) { if ( k <= 0 ) return n ; return ( n & ~ ( 1 << ( k - 1 ) ) ) ; } public static void main ( String [ ] args ) { int n = 15 ; int k = 4 ; System . out . println ( turnOffK ( n , k ) ) ; } } +","def turnOffK ( n , k ) : NEW_LINE INDENT if ( k <= 0 ) : NEW_LINE INDENT return n NEW_LINE DEDENT return ( n & ~ ( 1 << ( k - 1 ) ) ) NEW_LINE DEDENT n = 15 NEW_LINE k = 4 NEW_LINE print ( turnOffK ( n , k ) ) NEW_LINE +" +E1111,"class GFG { static int longestSubarray ( int a [ ] , int n ) { int hash [ ] [ ] = new int [ n ] [ 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { int num = a [ i ] ; while ( num != 0 ) { hash [ i ] [ num % 10 ] = 1 ; num /= 10 ; } } int longest = Integer . MIN_VALUE ; int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int j ; for ( j = 0 ; j < 10 ; j ++ ) { if ( hash [ i ] [ j ] == 1 & hash [ i + 1 ] [ j ] == 1 ) { count ++ ; break ; } } if ( j == 10 ) { longest = Math . max ( longest , count + 1 ) ; count = 0 ; } } longest = Math . max ( longest , count + 1 ) ; return longest ; } public static void main ( String [ ] args ) { int a [ ] = { 11 , 22 , 33 , 44 , 54 , 56 , 63 } ; int n = a . length ; System . out . println ( longestSubarray ( a , n ) ) ; } } +","import sys NEW_LINE def longestSubarray ( a , n ) : NEW_LINE INDENT hash = [ [ 0 for i in range ( 10 ) ] for j in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT num = a [ i ] NEW_LINE while ( num ) : NEW_LINE INDENT hash [ i ] [ num % 10 ] = 1 NEW_LINE num = int ( num / 10 ) NEW_LINE DEDENT DEDENT longest = - sys . maxsize - 1 NEW_LINE count = 0 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT for j in range ( 10 ) : NEW_LINE INDENT if ( hash [ i ] [ j ] and hash [ i + 1 ] [ j ] ) : NEW_LINE INDENT count += 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ( j == 10 ) : NEW_LINE INDENT longest = max ( longest , count + 1 ) NEW_LINE count = 0 NEW_LINE DEDENT DEDENT longest = max ( longest , count + 1 ) NEW_LINE return longest NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 11 , 22 , 33 , 44 , 54 , 56 , 63 ] NEW_LINE n = len ( a ) NEW_LINE print ( longestSubarray ( a , n ) ) NEW_LINE DEDENT +" +E1112,"import java . io . * ; class GFG { static void find_Solution ( double x , int n ) { double sum = x , e = 2 , o = 1 , p = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { p += 2 ; sum += ( double ) ( o / e ) * ( double ) ( Math . pow ( x , p ) / p ) ; o = o * ( o + 2 ) ; e = e * ( e + 2 ) ; } System . out . println ( sum ) ; } public static void main ( String [ ] args ) { double x = - 0.5 ; if ( Math . abs ( x ) >= 1 ) { System . out . println ( "" Invalid ▁ Input "" ) ; } int n = 8 ; find_Solution ( x , n ) ; } } +","def find_Solution ( x , n ) : NEW_LINE INDENT Sum = x NEW_LINE e = 2 NEW_LINE o = 1 NEW_LINE p = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT p += 2 NEW_LINE Sum += ( o / e ) * ( pow ( x , p ) / p ) NEW_LINE o = o * ( o + 2 ) NEW_LINE e = e * ( e + 2 ) NEW_LINE DEDENT print ( round ( Sum , 10 ) ) NEW_LINE DEDENT x = - 0.5 NEW_LINE if ( abs ( x ) >= 1 ) : NEW_LINE INDENT print ( "" Invalid ▁ Input \n "" ) NEW_LINE DEDENT n = 8 NEW_LINE find_Solution ( x , n ) NEW_LINE +" +E1113,"class GFG { static void replaceOriginal ( String s , int n ) { char r [ ] = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { r [ i ] = s . charAt ( n - 1 - i ) ; if ( s . charAt ( i ) != ' a ' && s . charAt ( i ) != ' e ' && s . charAt ( i ) != ' i ' && s . charAt ( i ) != ' o ' && s . charAt ( i ) != ' u ' ) { System . out . print ( r [ i ] ) ; } } System . out . println ( "" "" ) ; } public static void main ( String [ ] args ) { String s = "" geeksforgeeks "" ; int n = s . length ( ) ; replaceOriginal ( s , n ) ; } } +","def replaceOriginal ( s , n ) : NEW_LINE INDENT r = [ ' ▁ ' ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT r [ i ] = s [ n - 1 - i ] NEW_LINE if ( s [ i ] != ' a ' and s [ i ] != ' e ' and s [ i ] != ' i ' and s [ i ] != ' o ' and s [ i ] != ' u ' ) : NEW_LINE INDENT print ( r [ i ] , end = "" "" ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" geeksforgeeks "" NEW_LINE n = len ( s ) NEW_LINE replaceOriginal ( s , n ) NEW_LINE DEDENT +" +E1114,"import java . util . * ; class GFG { static void SieveOfEratosthenes ( boolean prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static int xorOfPrime ( char [ ] s ) { boolean [ ] prime = new boolean [ 100005 ] ; for ( int i = 0 ; i < 100005 ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , 10005 ) ; int i , j ; Map < Character , Integer > m = new HashMap < > ( ) ; for ( i = 0 ; i < s . length ; i ++ ) { if ( m . containsKey ( s [ i ] ) ) { m . put ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; } else { m . put ( s [ i ] , 1 ) ; } } int result = 0 ; int flag = 0 ; for ( Map . Entry < Character , Integer > entry : m . entrySet ( ) ) { if ( prime [ entry . getValue ( ) ] ) { result ^= entry . getValue ( ) ; flag = 1 ; } } if ( flag != 1 ) return - 1 ; return result ; } public static void main ( String [ ] args ) { char [ ] s = "" gggggeeekkkks "" . toCharArray ( ) ; System . out . println ( xorOfPrime ( s ) ) ; } } +","from collections import defaultdict NEW_LINE def SieveOfEratosthenes ( prime , p_size ) : NEW_LINE INDENT prime [ 0 ] = False NEW_LINE prime [ 1 ] = False NEW_LINE p = 2 NEW_LINE while p * p <= p_size : NEW_LINE INDENT if prime [ p ] : NEW_LINE INDENT for i in range ( p * 2 , p_size + 1 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT p += 1 NEW_LINE DEDENT DEDENT def xorOfPrime ( s ) : NEW_LINE INDENT prime = [ True ] * 100005 NEW_LINE SieveOfEratosthenes ( prime , 10005 ) NEW_LINE m = defaultdict ( lambda : 0 ) NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT m [ s [ i ] ] += 1 NEW_LINE DEDENT result = flag = 0 NEW_LINE for it in m : NEW_LINE INDENT if prime [ m [ it ] ] : NEW_LINE INDENT result ^= m [ it ] NEW_LINE flag = 1 NEW_LINE DEDENT DEDENT if not flag : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return result NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" gggggeeekkkks "" NEW_LINE print ( xorOfPrime ( s ) ) NEW_LINE DEDENT +" +E1115,"import java . io . * ; class GFG { static void findNumbers ( int n , int d ) { for ( int i = 0 ; i < n - 2 ; i ++ ) System . out . print ( ""1"" + "" ▁ "" ) ; System . out . print ( ""2"" + "" ▁ "" ) ; System . out . println ( n + d ) ; } public static void main ( String args [ ] ) { int N = 3 , D = 5 ; findNumbers ( N , D ) ; } } +","def pattern ( n , d ) : NEW_LINE INDENT for i in range ( 0 , n - 2 ) : NEW_LINE INDENT print ( ""1"" , end = "" ▁ "" ) NEW_LINE DEDENT print ( ""2"" , end = "" ▁ "" ) NEW_LINE print ( n + d ) NEW_LINE DEDENT N = 3 NEW_LINE D = 5 NEW_LINE pattern ( N , D ) NEW_LINE +" +E1116,"import java . io . * ; class GFG { static final double PI = 3.142 ; public static void main ( String [ ] args ) { double x , ret , val ; x = 60.0 ; val = ( int ) PI / 180.0 ; ret = Math . cos ( x * val ) ; System . out . print ( "" The ▁ cosine ▁ of ▁ "" + x + "" ▁ is ▁ "" ) ; System . out . print ( ret ) ; System . out . println ( "" ▁ degrees "" ) ; x = 90.0 ; val = ( int ) PI / 180.0 ; ret = Math . cos ( x * val ) ; System . out . print ( "" The ▁ cosine ▁ of ▁ "" + x + "" ▁ is ▁ "" ) ; System . out . print ( ret ) ; System . out . println ( "" ▁ degrees "" ) ; } } +","import math NEW_LINE if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT PI = 3.14159265 NEW_LINE x = 60.0 NEW_LINE val = PI / 180.0 NEW_LINE ret = math . cos ( x * val ) NEW_LINE print ( "" The ▁ cosine ▁ of ▁ is ▁ "" , x , end = "" ▁ "" ) NEW_LINE print ( "" ▁ degrees "" , ret ) NEW_LINE x = 90.0 NEW_LINE val = PI / 180.0 NEW_LINE ret = math . cos ( x * val ) NEW_LINE print ( "" The ▁ cosine ▁ of ▁ is ▁ "" , x , end = "" ▁ "" ) NEW_LINE print ( "" degrees "" , ret ) NEW_LINE DEDENT +" +E1117,"class GFG { final static int N = 100 ; final static int INF = 1000000 ; static int dp [ ] [ ] = new int [ N ] [ N ] ; static int vis [ ] [ ] = new int [ N ] [ N ] ; static int findSum ( int [ ] arr , int n , int k , int l , int r ) { if ( ( l ) + ( n - 1 - r ) == k ) return arr [ r ] - arr [ l ] ; if ( vis [ l ] [ r ] == 1 ) return dp [ l ] [ r ] ; vis [ l ] [ r ] = 1 ; dp [ l ] [ r ] = Math . min ( findSum ( arr , n , k , l , r - 1 ) , findSum ( arr , n , k , l + 1 , r ) ) ; return dp [ l ] [ r ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 100 , 120 , 140 } ; int k = 2 ; int n = arr . length ; System . out . println ( findSum ( arr , n , k , 0 , n - 1 ) ) ; } } +","import numpy as np NEW_LINE N = 100 NEW_LINE INF = 1000000 NEW_LINE dp = np . zeros ( ( N , N ) ) ; NEW_LINE vis = np . zeros ( ( N , N ) ) ; NEW_LINE def findSum ( arr , n , k , l , r ) : NEW_LINE INDENT if ( ( l ) + ( n - 1 - r ) == k ) : NEW_LINE INDENT return arr [ r ] - arr [ l ] ; NEW_LINE DEDENT if ( vis [ l ] [ r ] ) : NEW_LINE INDENT return dp [ l ] [ r ] ; NEW_LINE DEDENT vis [ l ] [ r ] = 1 ; NEW_LINE dp [ l ] [ r ] = min ( findSum ( arr , n , k , l , r - 1 ) , findSum ( arr , n , k , l + 1 , r ) ) ; NEW_LINE return dp [ l ] [ r ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 100 , 120 , 140 ] ; NEW_LINE k = 2 ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( findSum ( arr , n , k , 0 , n - 1 ) ) ; NEW_LINE DEDENT +" +E1118,"class GFG { static int totalPairs ( String s1 , String s2 ) { int count = 0 ; int [ ] arr1 = new int [ 7 ] ; int [ ] arr2 = new int [ 7 ] ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { int set_bits = Integer . bitCount ( s1 . charAt ( i ) ) ; arr1 [ set_bits ] ++ ; } for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { int set_bits = Integer . bitCount ( s2 . charAt ( i ) ) ; arr2 [ set_bits ] ++ ; } for ( int i = 1 ; i <= 6 ; i ++ ) { count += ( arr1 [ i ] * arr2 [ i ] ) ; } return count ; } public static void main ( String [ ] args ) { String s1 = "" geeks "" ; String s2 = "" forgeeks "" ; System . out . println ( totalPairs ( s1 , s2 ) ) ; } } +","def countSetBits ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while ( n ) : NEW_LINE INDENT count += n & 1 NEW_LINE n >>= 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def totalPairs ( s1 , s2 ) : NEW_LINE INDENT count = 0 ; NEW_LINE arr1 = [ 0 ] * 7 ; arr2 = [ 0 ] * 7 ; NEW_LINE for i in range ( len ( s1 ) ) : NEW_LINE INDENT set_bits = countSetBits ( ord ( s1 [ i ] ) ) NEW_LINE arr1 [ set_bits ] += 1 ; NEW_LINE DEDENT for i in range ( len ( s2 ) ) : NEW_LINE INDENT set_bits = countSetBits ( ord ( s2 [ i ] ) ) ; NEW_LINE arr2 [ set_bits ] += 1 ; NEW_LINE DEDENT for i in range ( 1 , 7 ) : NEW_LINE INDENT count += ( arr1 [ i ] * arr2 [ i ] ) ; NEW_LINE DEDENT return count ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s1 = "" geeks "" ; NEW_LINE s2 = "" forgeeks "" ; NEW_LINE print ( totalPairs ( s1 , s2 ) ) ; NEW_LINE DEDENT +" +E1119,"class GFG { static long minOperations ( long n ) { long count = 0 ; long d = 0 ; if ( n == 1 ) return 0 ; while ( n > 9 ) { d = Math . max ( n % 10 , d ) ; n /= 10 ; count += 10 ; } d = Math . max ( d , n - 1 ) ; count += Math . abs ( d ) ; return count - 1 ; } public static void main ( String [ ] args ) { long n = 240 ; System . out . println ( minOperations ( n ) ) ; } } +","def minOperations ( n ) : NEW_LINE INDENT count = 0 NEW_LINE d = 0 NEW_LINE if ( n == 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT while ( n > 9 ) : NEW_LINE INDENT d = max ( n % 10 , d ) NEW_LINE n //= 10 NEW_LINE count += 10 NEW_LINE DEDENT d = max ( d , n - 1 ) NEW_LINE count += abs ( d ) NEW_LINE return count - 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 240 NEW_LINE print ( minOperations ( n ) ) NEW_LINE DEDENT +" +E1120,"class GFG { static void myCopy ( char s1 [ ] , char s2 [ ] ) { int i = 0 ; for ( i = 0 ; i < s1 . length ; i ++ ) s2 [ i ] = s1 [ i ] ; } public static void main ( String [ ] args ) { char s1 [ ] = "" GEEKSFORGEEKS "" . toCharArray ( ) ; char s2 [ ] = new char [ s1 . length ] ; myCopy ( s1 , s2 ) ; System . out . println ( String . valueOf ( s2 ) ) ; } } +","def myCopy ( s1 , s2 ) : NEW_LINE INDENT for i in range ( len ( s1 ) ) : NEW_LINE INDENT s2 [ i ] = s1 [ i ] ; NEW_LINE DEDENT DEDENT s1 = "" GEEKSFORGEEKS "" ; NEW_LINE s2 = [ ' ' ] * ( len ( s1 ) ) ; NEW_LINE myCopy ( s1 , s2 ) ; NEW_LINE print ( ( "" "" . join ( s2 ) ) ) ; NEW_LINE +" +E1121,"import java . util . * ; class GFG { static void bitonicGenerator ( int arr [ ] , int n ) { Vector < Integer > evenArr = new Vector < Integer > ( ) ; Vector < Integer > oddArr = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 != 1 ) { evenArr . add ( arr [ i ] ) ; } else { oddArr . add ( arr [ i ] ) ; } } Collections . sort ( evenArr ) ; Collections . sort ( oddArr , Collections . reverseOrder ( ) ) ; int i = 0 ; for ( int j = 0 ; j < evenArr . size ( ) ; j ++ ) { arr [ i ++ ] = evenArr . get ( j ) ; } for ( int j = 0 ; j < oddArr . size ( ) ; j ++ ) { arr [ i ++ ] = oddArr . get ( j ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = arr . length ; bitonicGenerator ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def bitonicGenerator ( arr , n ) : NEW_LINE INDENT evenArr = [ ] NEW_LINE oddArr = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( ( i % 2 ) == 0 ) : NEW_LINE INDENT evenArr . append ( arr [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT oddArr . append ( arr [ i ] ) NEW_LINE DEDENT DEDENT evenArr = sorted ( evenArr ) NEW_LINE oddArr = sorted ( oddArr ) NEW_LINE oddArr = oddArr [ : : - 1 ] NEW_LINE i = 0 NEW_LINE for j in range ( len ( evenArr ) ) : NEW_LINE INDENT arr [ i ] = evenArr [ j ] NEW_LINE i += 1 NEW_LINE DEDENT for j in range ( len ( oddArr ) ) : NEW_LINE INDENT arr [ i ] = oddArr [ j ] NEW_LINE i += 1 NEW_LINE DEDENT DEDENT arr = [ 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 ] NEW_LINE n = len ( arr ) NEW_LINE bitonicGenerator ( arr , n ) NEW_LINE for i in arr : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT +" +E1122,"import java . io . * ; class GFG { static void ReverseCharBridge ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = ' A ' ; j < ' A ' + ( 2 * n ) - 1 ; j ++ ) { if ( j >= ( ' A ' + n - 1 ) + i ) System . out . print ( ( char ) ( ( ' A ' + n - 1 ) - ( j % ( ' A ' + n - 1 ) ) ) ) ; else if ( j <= ( ' A ' + n - 1 ) - i ) System . out . print ( ( char ) j ) ; else System . out . print ( "" ▁ "" ) ; } System . out . println ( ) ; } } public static void main ( String args [ ] ) { int n = 6 ; ReverseCharBridge ( n ) ; } } +","def ReverseCharBridge ( n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( ord ( ' A ' ) , ord ( ' A ' ) + ( 2 * n ) - 1 ) : NEW_LINE INDENT if j >= ( ord ( ' A ' ) + n - 1 ) + i : NEW_LINE INDENT print ( chr ( ( ord ( ' A ' ) + n - 1 ) - ( j % ( ord ( ' A ' ) + n - 1 ) ) ) , end = ' ' ) NEW_LINE DEDENT elif j <= ( ord ( ' A ' ) + n - 1 ) - i : NEW_LINE INDENT print ( chr ( j ) , end = ' ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( end = "" ▁ "" ) NEW_LINE DEDENT DEDENT print ( "" \n "" , end = ' ' ) NEW_LINE DEDENT DEDENT n = 6 NEW_LINE ReverseCharBridge ( n ) NEW_LINE +" +E1123,"class GFG { final static int n = 4 ; final static int m = 4 ; static float calcProbability ( int M [ ] [ ] , int k ) { float dp [ ] [ ] = new float [ m ] [ n ] ; float sum [ ] = new float [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { dp [ 0 ] [ j ] = M [ 0 ] [ j ] ; sum [ 0 ] = sum [ 0 ] + dp [ 0 ] [ j ] ; } for ( int i = 1 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dp [ i ] [ j ] += dp [ i - 1 ] [ j ] / sum [ i - 1 ] + M [ i ] [ j ] ; sum [ i ] += dp [ i ] [ j ] ; } } return dp [ n - 1 ] [ k - 1 ] / sum [ n - 1 ] ; } public static void main ( String [ ] args ) { int M [ ] [ ] = { { 1 , 1 , 0 , 3 } , { 2 , 3 , 2 , 3 } , { 9 , 3 , 0 , 2 } , { 2 , 3 , 2 , 2 } } ; int k = 3 ; System . out . println ( calcProbability ( M , k ) ) ; } } +","n = 4 NEW_LINE m = 4 NEW_LINE def calcProbability ( M , k ) : NEW_LINE INDENT dp = [ [ 0 for i in range ( n ) ] for i in range ( m ) ] NEW_LINE Sum = [ 0 for i in range ( n ) ] NEW_LINE for j in range ( n ) : NEW_LINE INDENT dp [ 0 ] [ j ] = M [ 0 ] [ j ] NEW_LINE Sum [ 0 ] += dp [ 0 ] [ j ] NEW_LINE DEDENT for i in range ( 1 , m ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT dp [ i ] [ j ] += ( dp [ i - 1 ] [ j ] / Sum [ i - 1 ] + M [ i ] [ j ] ) NEW_LINE Sum [ i ] += dp [ i ] [ j ] NEW_LINE DEDENT DEDENT return dp [ n - 1 ] [ k - 1 ] / Sum [ n - 1 ] NEW_LINE DEDENT M = [ [ 1 , 1 , 0 , 3 ] , [ 2 , 3 , 2 , 3 ] , [ 9 , 3 , 0 , 2 ] , [ 2 , 3 , 2 , 2 ] ] NEW_LINE k = 3 NEW_LINE print ( calcProbability ( M , k ) ) NEW_LINE +" +E1124,"import java . util . Arrays ; class GFG { static int largestSubset ( int [ ] a , int n ) { Arrays . sort ( a ) ; int [ ] dp = new int [ n ] ; dp [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int mxm = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( a [ j ] % a [ i ] == 0 ) { mxm = Math . max ( mxm , dp [ j ] ) ; } } dp [ i ] = 1 + mxm ; } return Arrays . stream ( dp ) . max ( ) . getAsInt ( ) ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 3 , 6 , 13 , 17 , 18 } ; int n = a . length ; System . out . println ( largestSubset ( a , n ) ) ; } } +","def largestSubset ( a , n ) : NEW_LINE INDENT a . sort ( ) NEW_LINE dp = [ 0 for i in range ( n ) ] NEW_LINE dp [ n - 1 ] = 1 ; NEW_LINE for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT mxm = 0 ; NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT if a [ j ] % a [ i ] == 0 : NEW_LINE INDENT mxm = max ( mxm , dp [ j ] ) NEW_LINE DEDENT DEDENT dp [ i ] = 1 + mxm NEW_LINE DEDENT return max ( dp ) NEW_LINE DEDENT a = [ 1 , 3 , 6 , 13 , 17 , 18 ] NEW_LINE n = len ( a ) NEW_LINE print ( largestSubset ( a , n ) ) NEW_LINE +" +E1125,"class GFG { static String findLargest ( int N ) { String largest = strings ( N , '7' ) ; return largest ; } static String findSmallest ( int N ) { String smallest = ""1"" + strings ( ( N - 1 ) , '0' ) ; return smallest ; } private static String strings ( int N , char c ) { String temp = "" "" ; for ( int i = 0 ; i < N ; i ++ ) { temp += c ; } return temp ; } static void printLargestSmallest ( int N ) { System . out . print ( "" Largest : ▁ "" + findLargest ( N ) + "" \n "" ) ; System . out . print ( "" Smallest : ▁ "" + findSmallest ( N ) + "" \n "" ) ; } public static void main ( String [ ] args ) { int N = 4 ; printLargestSmallest ( N ) ; } } +","def findLargest ( N ) : NEW_LINE INDENT largest = strings ( N , '7' ) ; NEW_LINE return largest ; NEW_LINE DEDENT def findSmallest ( N ) : NEW_LINE INDENT smallest = ""1"" + strings ( ( N - 1 ) , '0' ) ; NEW_LINE return smallest ; NEW_LINE DEDENT def strings ( N , c ) : NEW_LINE INDENT temp = "" "" ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT temp += c ; NEW_LINE DEDENT return temp ; NEW_LINE DEDENT def printLargestSmallest ( N ) : NEW_LINE INDENT print ( "" Largest : ▁ "" , findLargest ( N ) ) ; NEW_LINE print ( "" Smallest : ▁ "" , findSmallest ( N ) ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 4 ; NEW_LINE printLargestSmallest ( N ) ; NEW_LINE DEDENT +" +E1126,"class GFG { static void findMaxNum ( int arr [ ] , int n ) { int [ ] hash = new int [ 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { hash [ arr [ i ] ] ++ ; } for ( int i = 9 ; i >= 0 ; i -- ) { for ( int j = 0 ; j < hash [ i ] ; j ++ ) System . out . print ( i ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 0 } ; int n = arr . length ; findMaxNum ( arr , n ) ; } } +","def findMaxNum ( arr , n ) : NEW_LINE INDENT hash = [ 0 ] * 10 NEW_LINE for i in range ( n ) : NEW_LINE INDENT hash [ arr [ i ] ] += 1 NEW_LINE DEDENT for i in range ( 9 , - 1 , - 1 ) : NEW_LINE INDENT for j in range ( hash [ i ] ) : NEW_LINE INDENT print ( i , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 , 0 ] NEW_LINE n = len ( arr ) NEW_LINE findMaxNum ( arr , n ) NEW_LINE DEDENT +" +E1127,"import java . util . Scanner ; class Deserium { static int countDigits ( int n ) { int c = 0 ; do { c ++ ; n = n / 10 ; } while ( n != 0 ) ; return c ; } static boolean isDeserium ( int x ) { int temp = x ; int p = countDigits ( x ) ; int sum = 0 ; while ( x != 0 ) { int digit = x % 10 ; sum += Math . pow ( digit , p ) ; p -- ; x = x / 10 ; } return ( sum == temp ) ; } public static void main ( String [ ] args ) { int x = 135 ; if ( isDeserium ( x ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def countDigits ( n ) : NEW_LINE INDENT c = 0 NEW_LINE while ( n != 0 ) : NEW_LINE INDENT c += 1 NEW_LINE n = int ( n / 10 ) NEW_LINE DEDENT return c NEW_LINE DEDENT def isDeserium ( x ) : NEW_LINE INDENT temp = x NEW_LINE p = countDigits ( x ) NEW_LINE sum = 0 NEW_LINE while ( x != 0 ) : NEW_LINE INDENT digit = int ( x % 10 ) NEW_LINE sum += pow ( digit , p ) NEW_LINE p -= 1 NEW_LINE x = int ( x / 10 ) NEW_LINE DEDENT return ( sum == temp ) NEW_LINE DEDENT x = 135 NEW_LINE if ( isDeserium ( x ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1128,"import java . util . * ; class GFG { static double polyarea ( double n , double r ) { if ( r < 0 && n < 0 ) return - 1 ; double A = ( ( r * r * n ) * Math . sin ( ( 360 / n ) * 3.14159 / 180 ) ) / 2 ; return A ; } public static void main ( String [ ] args ) { float r = 9 , n = 6 ; System . out . println ( polyarea ( n , r ) ) ; } } +","from math import sin NEW_LINE def polyarea ( n , r ) : NEW_LINE INDENT if ( r < 0 and n < 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT A = ( ( ( r * r * n ) * sin ( ( 360 / n ) * 3.14159 / 180 ) ) / 2 ) ; NEW_LINE return round ( A , 3 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT r , n = 9 , 6 NEW_LINE print ( polyarea ( n , r ) ) NEW_LINE DEDENT +" +E1129,"import java . io . * ; class GFG { static int smallestSumSubarr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = - arr [ i ] ; int sum_here = arr [ 0 ] , max_sum = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { sum_here = Math . max ( sum_here + arr [ i ] , arr [ i ] ) ; max_sum = Math . max ( max_sum , sum_here ) ; } return ( - 1 ) * max_sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , - 4 , 2 , - 3 , - 1 , 7 , - 5 } ; int n = arr . length ; System . out . print ( "" Smallest ▁ sum : ▁ "" + smallestSumSubarr ( arr , n ) ) ; } } +","def smallestSumSubarr ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT arr [ i ] = - arr [ i ] NEW_LINE DEDENT sum_here = arr [ 0 ] NEW_LINE max_sum = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT sum_here = max ( sum_here + arr [ i ] , arr [ i ] ) NEW_LINE max_sum = max ( max_sum , sum_here ) NEW_LINE DEDENT return ( - 1 ) * max_sum NEW_LINE DEDENT arr = [ 3 , - 4 , 2 , - 3 , - 1 , 7 , - 5 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Smallest ▁ sum : "" , smallestSumSubarr ( arr , n ) ) NEW_LINE +" +E1130,"import java . io . * ; class GFG { static int countSub ( int arr [ ] , int n , int x ) { int st = 0 ; int end = 0 ; int sum = 0 ; int cnt = 0 ; while ( end < n ) { sum += arr [ end ] ; while ( st <= end && sum > x ) { sum -= arr [ st ] ; st ++ ; } cnt += ( end - st + 1 ) ; end ++ ; } return cnt ; } static int findSubSumLtoR ( int arr [ ] , int n , int L , int R ) { int Rcnt = countSub ( arr , n , R ) ; int Lcnt = countSub ( arr , n , L - 1 ) ; return Rcnt - Lcnt ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 6 } ; int n = arr . length ; int L = 3 ; int R = 8 ; System . out . println ( findSubSumLtoR ( arr , n , L , R ) ) ; } } +","def countSub ( arr , n , x ) : NEW_LINE INDENT st = 0 NEW_LINE end = 0 NEW_LINE sum = 0 NEW_LINE cnt = 0 NEW_LINE while end < n : NEW_LINE INDENT sum += arr [ end ] NEW_LINE while ( st <= end and sum > x ) : NEW_LINE INDENT sum -= arr [ st ] NEW_LINE st += 1 NEW_LINE DEDENT cnt += ( end - st + 1 ) NEW_LINE end += 1 NEW_LINE DEDENT return cnt NEW_LINE DEDENT def findSubSumLtoR ( arr , n , L , R ) : NEW_LINE INDENT Rcnt = countSub ( arr , n , R ) NEW_LINE Lcnt = countSub ( arr , n , L - 1 ) NEW_LINE return Rcnt - Lcnt NEW_LINE DEDENT arr = [ 1 , 4 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE L = 3 NEW_LINE R = 8 NEW_LINE print ( findSubSumLtoR ( arr , n , L , R ) ) NEW_LINE +" +E1131,"import java . util . * ; class MinimumCostPath { private static int min ( int x , int y , int z ) { if ( x < y ) return ( x < z ) ? x : z ; else return ( y < z ) ? y : z ; } private static int minCost ( int cost [ ] [ ] , int m , int n ) { int i , j ; int tc [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ; tc [ 0 ] [ 0 ] = cost [ 0 ] [ 0 ] ; for ( i = 1 ; i <= m ; i ++ ) tc [ i ] [ 0 ] = tc [ i - 1 ] [ 0 ] + cost [ i ] [ 0 ] ; for ( j = 1 ; j <= n ; j ++ ) tc [ 0 ] [ j ] = tc [ 0 ] [ j - 1 ] + cost [ 0 ] [ j ] ; for ( i = 1 ; i <= m ; i ++ ) for ( j = 1 ; j <= n ; j ++ ) tc [ i ] [ j ] = min ( tc [ i - 1 ] [ j - 1 ] , tc [ i - 1 ] [ j ] , tc [ i ] [ j - 1 ] ) + cost [ i ] [ j ] ; return tc [ m ] [ n ] ; } public static void main ( String args [ ] ) { int cost [ ] [ ] = { { 1 , 2 , 3 } , { 4 , 8 , 2 } , { 1 , 5 , 3 } } ; System . out . println ( minCost ( cost , 2 , 2 ) ) ; } } +","R = 3 NEW_LINE C = 3 NEW_LINE def minCost ( cost , m , n ) : NEW_LINE INDENT tc = [ [ 0 for x in range ( C ) ] for x in range ( R ) ] NEW_LINE tc [ 0 ] [ 0 ] = cost [ 0 ] [ 0 ] NEW_LINE for i in range ( 1 , m + 1 ) : NEW_LINE INDENT tc [ i ] [ 0 ] = tc [ i - 1 ] [ 0 ] + cost [ i ] [ 0 ] NEW_LINE DEDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT tc [ 0 ] [ j ] = tc [ 0 ] [ j - 1 ] + cost [ 0 ] [ j ] NEW_LINE DEDENT for i in range ( 1 , m + 1 ) : NEW_LINE INDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT tc [ i ] [ j ] = min ( tc [ i - 1 ] [ j - 1 ] , tc [ i - 1 ] [ j ] , tc [ i ] [ j - 1 ] ) + cost [ i ] [ j ] NEW_LINE DEDENT DEDENT return tc [ m ] [ n ] NEW_LINE DEDENT cost = [ [ 1 , 2 , 3 ] , [ 4 , 8 , 2 ] , [ 1 , 5 , 3 ] ] NEW_LINE print ( minCost ( cost , 2 , 2 ) ) NEW_LINE +" +E1132,"class GFG { static int msbPos ( long n ) { int msb_p = - 1 ; while ( n > 0 ) { n = n >> 1 ; msb_p ++ ; } return msb_p ; } static long andOperator ( long x , long y ) { long res = 0 ; while ( x > 0 && y > 0 ) { int msb_p1 = msbPos ( x ) ; int msb_p2 = msbPos ( y ) ; if ( msb_p1 != msb_p2 ) break ; long msb_val = ( 1 << msb_p1 ) ; res = res + msb_val ; x = x - msb_val ; y = y - msb_val ; } return res ; } public static void main ( String [ ] args ) { long x = 10 , y = 15 ; System . out . print ( andOperator ( x , y ) ) ; } } +","def msbPos ( n ) : NEW_LINE INDENT msb_p = - 1 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT n = n >> 1 NEW_LINE msb_p += 1 NEW_LINE DEDENT return msb_p NEW_LINE DEDENT def andOperator ( x , y ) : NEW_LINE INDENT res = 0 NEW_LINE while ( x > 0 and y > 0 ) : NEW_LINE INDENT msb_p1 = msbPos ( x ) NEW_LINE msb_p2 = msbPos ( y ) NEW_LINE if ( msb_p1 != msb_p2 ) : NEW_LINE INDENT break NEW_LINE DEDENT msb_val = ( 1 << msb_p1 ) NEW_LINE res = res + msb_val NEW_LINE x = x - msb_val NEW_LINE y = y - msb_val NEW_LINE DEDENT return res NEW_LINE DEDENT x , y = 10 , 15 NEW_LINE print ( andOperator ( x , y ) ) NEW_LINE +" +E1133,"import java . util . * ; class GFG { static long [ ] count_color = new long [ 2 ] ; static void dfs ( Vector < Integer > adj [ ] , int node , int parent , boolean color ) { count_color [ color == false ? 0 : 1 ] ++ ; for ( int i = 0 ; i < adj [ node ] . size ( ) ; i ++ ) { if ( adj [ node ] . get ( i ) != parent ) dfs ( adj , adj [ node ] . get ( i ) , node , ! color ) ; } } static int findMaxEdges ( Vector < Integer > adj [ ] , int n ) { dfs ( adj , 1 , 0 , false ) ; return ( int ) ( count_color [ 0 ] * count_color [ 1 ] - ( n - 1 ) ) ; } public static void main ( String [ ] args ) { int n = 5 ; Vector < Integer > [ ] adj = new Vector [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) adj [ i ] = new Vector < Integer > ( ) ; adj [ 1 ] . add ( 2 ) ; adj [ 1 ] . add ( 3 ) ; adj [ 2 ] . add ( 4 ) ; adj [ 3 ] . add ( 5 ) ; System . out . println ( findMaxEdges ( adj , n ) ) ; } } +","def dfs ( adj , node , parent , color ) : NEW_LINE INDENT count_color [ color ] += 1 NEW_LINE for i in range ( len ( adj [ node ] ) ) : NEW_LINE INDENT if ( adj [ node ] [ i ] != parent ) : NEW_LINE INDENT dfs ( adj , adj [ node ] [ i ] , node , not color ) NEW_LINE DEDENT DEDENT DEDENT def findMaxEdges ( adj , n ) : NEW_LINE INDENT dfs ( adj , 1 , 0 , 0 ) NEW_LINE return ( count_color [ 0 ] * count_color [ 1 ] - ( n - 1 ) ) NEW_LINE DEDENT count_color = [ 0 , 0 ] NEW_LINE n = 5 NEW_LINE adj = [ [ ] for i in range ( n + 1 ) ] NEW_LINE adj [ 1 ] . append ( 2 ) NEW_LINE adj [ 1 ] . append ( 3 ) NEW_LINE adj [ 2 ] . append ( 4 ) NEW_LINE adj [ 3 ] . append ( 5 ) NEW_LINE print ( findMaxEdges ( adj , n ) ) NEW_LINE +" +E1134,"import java . util . * ; class solution { static void steps ( String str , int n ) { boolean flag = false ; int x = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( x == 0 ) flag = true ; if ( x == n - 1 ) flag = false ; for ( int j = 0 ; j < x ; j ++ ) System . out . print ( "" * "" ) ; System . out . print ( str . charAt ( i ) + "" \n "" ) ; if ( flag == true ) x ++ ; else x -- ; } } public static void main ( String args [ ] ) { int n = 4 ; String str = "" GeeksForGeeks "" ; System . out . println ( "" String : ▁ "" + str ) ; System . out . println ( "" Max ▁ Length ▁ of ▁ Steps : ▁ "" + n ) ; steps ( str , n ) ; } } +","import math as mt NEW_LINE def steps ( string , n ) : NEW_LINE INDENT flag = False NEW_LINE x = 0 NEW_LINE for i in range ( len ( string ) ) : NEW_LINE INDENT if ( x == 0 ) : NEW_LINE INDENT flag = True NEW_LINE DEDENT if ( x == n - 1 ) : NEW_LINE INDENT flag = False NEW_LINE DEDENT for j in range ( x ) : NEW_LINE INDENT print ( "" * "" , end = "" "" ) NEW_LINE DEDENT print ( string [ i ] ) NEW_LINE if ( flag == True ) : NEW_LINE INDENT x += 1 NEW_LINE DEDENT else : NEW_LINE INDENT x -= 1 NEW_LINE DEDENT DEDENT DEDENT n = 4 NEW_LINE string = "" GeeksForGeeks "" NEW_LINE print ( "" String : ▁ "" , string ) NEW_LINE print ( "" Max ▁ Length ▁ of ▁ Steps : ▁ "" , n ) NEW_LINE steps ( string , n ) NEW_LINE +" +E1135,"import java . util . * ; class GFG { static int max_xor ( int arr [ ] , int n ) { int maxx = 0 , mask = 0 ; HashSet < Integer > se = new HashSet < Integer > ( ) ; for ( int i = 30 ; i >= 0 ; i -- ) { mask |= ( 1 << i ) ; for ( int j = 0 ; j < n ; ++ j ) { se . add ( arr [ j ] & mask ) ; } int newMaxx = maxx | ( 1 << i ) ; for ( int prefix : se ) { if ( se . contains ( newMaxx ^ prefix ) ) { maxx = newMaxx ; break ; } } se . clear ( ) ; } return maxx ; } public static void main ( String [ ] args ) { int arr [ ] = { 25 , 10 , 2 , 8 , 5 , 3 } ; int n = arr . length ; System . out . println ( max_xor ( arr , n ) ) ; } } +","def max_xor ( arr , n ) : NEW_LINE INDENT maxx = 0 NEW_LINE mask = 0 ; NEW_LINE se = set ( ) NEW_LINE for i in range ( 30 , - 1 , - 1 ) : NEW_LINE INDENT mask |= ( 1 << i ) NEW_LINE newMaxx = maxx | ( 1 << i ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT se . add ( arr [ i ] & mask ) NEW_LINE DEDENT for prefix in se : NEW_LINE INDENT if ( newMaxx ^ prefix ) in se : NEW_LINE INDENT maxx = newMaxx NEW_LINE break NEW_LINE DEDENT DEDENT se . clear ( ) NEW_LINE DEDENT return maxx NEW_LINE DEDENT arr = [ 25 , 10 , 2 , 8 , 5 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE print ( max_xor ( arr , n ) ) NEW_LINE +" +E1136,"import java . util . * ; import java . lang . * ; import java . io . * ; class exp_sq { static long N = 1000000007L ; public static void main ( String [ ] args ) { long base = 5 ; long exp = 100000 ; long modulo = exponentiation ( base , exp ) ; System . out . println ( modulo ) ; } static long exponentiation ( long base , long exp ) { long t = 1L ; while ( exp > 0 ) { if ( exp % 2 != 0 ) t = ( t * base ) % N ; base = ( base * base ) % N ; exp /= 2 ; } return t % N ; } } +","N = 1000000007 ; NEW_LINE def exponentiation ( bas , exp ) : NEW_LINE INDENT t = 1 ; NEW_LINE while ( exp > 0 ) : NEW_LINE INDENT if ( exp % 2 != 0 ) : NEW_LINE INDENT t = ( t * bas ) % N ; NEW_LINE DEDENT bas = ( bas * bas ) % N ; NEW_LINE exp = int ( exp / 2 ) ; NEW_LINE DEDENT return t % N ; NEW_LINE DEDENT bas = 5 ; NEW_LINE exp = 100000 ; NEW_LINE modulo = exponentiation ( bas , exp ) ; NEW_LINE print ( modulo ) ; NEW_LINE +" +E1137,"public class GFG { static long countMaxIntersect ( long n ) { return ( n ) * ( n - 1 ) / 2 ; } public static void main ( String args [ ] ) { long n = 8 ; System . out . println ( countMaxIntersect ( n ) ) ; } } +","def countMaxIntersect ( n ) : NEW_LINE INDENT return int ( n * ( n - 1 ) / 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 8 NEW_LINE print ( countMaxIntersect ( n ) ) NEW_LINE DEDENT +" +E1138,"class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } static void findArray ( int n , int k , int s ) { int vis [ ] = new int [ n ] ; int cnt = 0 ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n && cnt < k ; i += 2 ) { arr [ i ] = s ; vis [ i ] = 1 ; cnt ++ ; } int val = s ; if ( s % 2 == 0 ) val ++ ; else val = val + 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis [ i ] == 0 ) { arr [ i ] = val ; } } printArr ( arr , n ) ; } public static void main ( String [ ] args ) { int n = 8 , k = 3 , s = 12 ; findArray ( n , k , s ) ; } } +","def printArr ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT def findArray ( n , k , s ) : NEW_LINE INDENT vis = [ 0 ] * n ; NEW_LINE cnt = 0 ; NEW_LINE arr = [ 0 ] * n ; NEW_LINE i = 0 ; NEW_LINE while ( i < n and cnt < k ) : NEW_LINE INDENT arr [ i ] = s ; NEW_LINE vis [ i ] = 1 ; NEW_LINE cnt += 1 ; NEW_LINE i += 2 ; NEW_LINE DEDENT val = s ; NEW_LINE if ( s % 2 == 0 ) : NEW_LINE INDENT val += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT val = val + 2 ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( vis [ i ] == 0 ) : NEW_LINE INDENT arr [ i ] = val ; NEW_LINE DEDENT DEDENT printArr ( arr , n ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 8 ; k = 3 ; s = 12 ; NEW_LINE findArray ( n , k , s ) ; NEW_LINE DEDENT +" +E1139,"import java . io . * ; class GFG { static int modInverse ( int a , int m ) { a = a % m ; for ( int x = 1 ; x < m ; x ++ ) if ( ( a * x ) % m == 1 ) return x ; return 1 ; } public static void main ( String args [ ] ) { int a = 3 , m = 11 ; System . out . println ( modInverse ( a , m ) ) ; } } +","def modInverse ( a , m ) : NEW_LINE INDENT a = a % m ; NEW_LINE for x in range ( 1 , m ) : NEW_LINE INDENT if ( ( a * x ) % m == 1 ) : NEW_LINE INDENT return x NEW_LINE DEDENT DEDENT return 1 NEW_LINE DEDENT a = 3 NEW_LINE m = 11 NEW_LINE print ( modInverse ( a , m ) ) NEW_LINE +" +E1140,"import java . util . * ; class GFG { static int countDistinctCode ( String str ) { Set < String > codes = new HashSet < > ( ) ; for ( int i = 0 ; i < str . length ( ) - 1 ; i ++ ) codes . add ( str . substring ( i , i + 2 ) ) ; return codes . size ( ) ; } public static void main ( String [ ] args ) { String str = "" UPUP "" ; System . out . println ( countDistinctCode ( str ) ) ; } } +","def countDistinctCode ( string ) : NEW_LINE INDENT codes = set ( ) NEW_LINE for i in range ( 0 , len ( string ) - 1 ) : NEW_LINE INDENT codes . add ( string [ i : i + 2 ] ) NEW_LINE DEDENT return len ( codes ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" UPUP "" NEW_LINE print ( countDistinctCode ( string ) ) NEW_LINE DEDENT +" +E1141,"class GFG { static int OR ( int a [ ] , int n ) { int ans = a [ 0 ] ; int i ; for ( i = 1 ; i < n ; i ++ ) { ans |= a [ i ] ; } return ans ; } public static void main ( String args [ ] ) { int a [ ] = { 1 , 4 , 6 } ; int n = a . length ; System . out . println ( OR ( a , n ) ) ; } } +","def OR ( a , n ) : NEW_LINE INDENT ans = a [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT ans |= a [ i ] NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 1 , 4 , 6 ] NEW_LINE n = len ( a ) NEW_LINE print ( OR ( a , n ) ) NEW_LINE DEDENT +" +E1142,"import java . util . Arrays ; import java . util . Collections ; class GFG { public static int kthSmallest ( Integer [ ] arr , int k ) { Arrays . sort ( arr ) ; return arr [ k - 1 ] ; } public static void main ( String [ ] args ) { Integer arr [ ] = new Integer [ ] { 12 , 3 , 5 , 7 , 19 } ; int k = 2 ; System . out . print ( "" K ' th ▁ smallest ▁ element ▁ is ▁ "" + kthSmallest ( arr , k ) ) ; } } +","def kthSmallest ( arr , n , k ) : NEW_LINE INDENT arr . sort ( ) NEW_LINE return arr [ k - 1 ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 12 , 3 , 5 , 7 , 19 ] NEW_LINE n = len ( arr ) NEW_LINE k = 2 NEW_LINE print ( "" K ' th ▁ smallest ▁ element ▁ is "" , kthSmallest ( arr , n , k ) ) NEW_LINE DEDENT +" +E1143,"class GFG { static int findOddPair ( int A [ ] , int N ) { int i , j ; int oddPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] ^ A [ j ] ) % 2 != 0 ) oddPair ++ ; } } return oddPair ; } public static void main ( String args [ ] ) { int A [ ] = { 5 , 4 , 7 , 2 , 1 } ; int N = A . length ; System . out . println ( findOddPair ( A , N ) ) ; } } +","def findOddPair ( A , N ) : NEW_LINE INDENT oddPair = 0 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT if ( ( A [ i ] ^ A [ j ] ) % 2 != 0 ) : NEW_LINE INDENT oddPair += 1 NEW_LINE DEDENT DEDENT DEDENT return oddPair NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = [ 5 , 4 , 7 , 2 , 1 ] NEW_LINE N = len ( A ) NEW_LINE print ( findOddPair ( A , N ) ) NEW_LINE DEDENT +" +E1144,"import java . util . * ; class GFG { static void ReplaceElements ( int arr [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , 1 ) ; } else { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } } for ( int i = 0 ; i < n ; ++ i ) { arr [ i ] = n - mp . get ( arr [ i ] ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 5 , 2 , 2 , 5 , 4 } ; int n = arr . length ; ReplaceElements ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def ReplaceElements ( arr , n ) : NEW_LINE INDENT mp = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT mp [ arr [ i ] ] = mp . get ( arr [ i ] , 0 ) + 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT arr [ i ] = n - mp [ arr [ i ] ] NEW_LINE DEDENT DEDENT arr = [ 1 , 2 , 5 , 2 , 2 , 5 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE ReplaceElements ( arr , n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT +" +E1145,"import java . io . * ; class Combination { static void combinationUtil ( int arr [ ] , int n , int r , int index , int data [ ] , int i ) { if ( index == r ) { for ( int j = 0 ; j < r ; j ++ ) System . out . print ( data [ j ] + "" ▁ "" ) ; System . out . println ( "" "" ) ; return ; } if ( i >= n ) return ; data [ index ] = arr [ i ] ; combinationUtil ( arr , n , r , index + 1 , data , i + 1 ) ; combinationUtil ( arr , n , r , index , data , i + 1 ) ; } static void printCombination ( int arr [ ] , int n , int r ) { int data [ ] = new int [ r ] ; combinationUtil ( arr , n , r , 0 , data , 0 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int r = 3 ; int n = arr . length ; printCombination ( arr , n , r ) ; } } +","def printCombination ( arr , n , r ) : NEW_LINE INDENT data = [ 0 ] * r NEW_LINE combinationUtil ( arr , n , r , 0 , data , 0 ) NEW_LINE DEDENT def combinationUtil ( arr , n , r , index , data , i ) : NEW_LINE INDENT if ( index == r ) : NEW_LINE INDENT for j in range ( r ) : NEW_LINE INDENT print ( data [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE return NEW_LINE DEDENT if ( i >= n ) : NEW_LINE INDENT return NEW_LINE DEDENT data [ index ] = arr [ i ] NEW_LINE combinationUtil ( arr , n , r , index + 1 , data , i + 1 ) NEW_LINE combinationUtil ( arr , n , r , index , data , i + 1 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE r = 3 NEW_LINE n = len ( arr ) NEW_LINE printCombination ( arr , n , r ) NEW_LINE DEDENT +" +E1146,"class GFG { static void sieve ( int maxm , int [ ] prime ) { prime [ 0 ] = prime [ 1 ] = 1 ; for ( int i = 2 ; i * i <= maxm ; i ++ ) if ( prime [ i ] == 0 ) for ( int j = 2 * i ; j <= maxm ; j += i ) prime [ j ] = 1 ; } static long countPair ( int [ ] a , int n ) { int maxm = a [ 0 ] ; int i ; for ( i = 1 ; i < n ; i ++ ) if ( a [ i ] > maxm ) maxm = a [ i ] ; int [ ] prime = new int [ maxm + 1 ] ; for ( i = 0 ; i < maxm + 1 ; i ++ ) prime [ i ] = 0 ; sieve ( maxm , prime ) ; int countPrimes = 0 ; for ( i = 0 ; i < n ; i ++ ) if ( prime [ a [ i ] ] == 0 ) countPrimes ++ ; int nonPrimes = n - countPrimes ; long pairswith1Prime = nonPrimes * countPrimes ; long pairsWith2Primes = ( countPrimes * ( countPrimes - 1 ) ) / 2 ; return pairswith1Prime + pairsWith2Primes ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 4 , 7 } ; int n = arr . length ; System . out . println ( countPair ( arr , n ) ) ; } } +","def sieve ( maxm , prime ) : NEW_LINE INDENT prime [ 0 ] = prime [ 1 ] = 1 ; NEW_LINE i = 2 ; NEW_LINE while ( i * i <= maxm ) : NEW_LINE INDENT if ( prime [ i ] == 0 ) : NEW_LINE INDENT for j in range ( 2 * i , maxm + 1 , i ) : NEW_LINE INDENT prime [ j ] = 1 ; NEW_LINE DEDENT DEDENT i += 1 ; NEW_LINE DEDENT DEDENT def countPair ( a , n ) : NEW_LINE INDENT maxm = max ( a ) ; NEW_LINE prime = [ 0 ] * ( maxm + 1 ) ; NEW_LINE sieve ( maxm , prime ) ; NEW_LINE countPrimes = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( prime [ a [ i ] ] == 0 ) : NEW_LINE INDENT countPrimes += 1 ; NEW_LINE DEDENT DEDENT nonPrimes = n - countPrimes ; NEW_LINE pairswith1Prime = nonPrimes * countPrimes ; NEW_LINE pairsWith2Primes = ( countPrimes * ( countPrimes - 1 ) ) // 2 ; NEW_LINE return pairswith1Prime + pairsWith2Primes ; NEW_LINE DEDENT arr = [ 2 , 3 , 5 , 4 , 7 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( countPair ( arr , n ) ) ; NEW_LINE +" +E1147,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int nextPerfectCube ( int N ) { int nextN = ( int ) Math . floor ( Math . cbrt ( N ) ) + 1 ; return nextN * nextN * nextN ; } public static void main ( String args [ ] ) { int n = 35 ; System . out . print ( nextPerfectCube ( n ) ) ; } } +","from math import * NEW_LINE def nextPerfectCube ( N ) : NEW_LINE INDENT nextN = floor ( N ** ( 1 / 3 ) ) + 1 NEW_LINE return nextN ** 3 NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 35 NEW_LINE print ( nextPerfectCube ( n ) ) NEW_LINE DEDENT +" +E1148,"class GFG { static void reverse ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i += k ) { int left = i ; int right = Math . min ( i + k - 1 , n - 1 ) ; int temp ; while ( left < right ) { temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; left += 1 ; right -= 1 ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; int k = 3 ; int n = arr . length ; reverse ( arr , n , k ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } } +","def reverse ( arr , n , k ) : NEW_LINE INDENT i = 0 NEW_LINE while ( i < n ) : NEW_LINE INDENT left = i NEW_LINE right = min ( i + k - 1 , n - 1 ) NEW_LINE while ( left < right ) : NEW_LINE INDENT arr [ left ] , arr [ right ] = arr [ right ] , arr [ left ] NEW_LINE left += 1 ; NEW_LINE right - + 1 NEW_LINE DEDENT i += k NEW_LINE DEDENT DEDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] NEW_LINE k = 3 NEW_LINE n = len ( arr ) NEW_LINE reverse ( arr , n , k ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT +" +E1149,"class GFG { public static void printChar ( String str , int n ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ str . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ str . charAt ( i ) - ' a ' ] % 2 == 1 ) { System . out . print ( str . charAt ( i ) ) ; } } } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int n = str . length ( ) ; printChar ( str , n ) ; } } +","import sys NEW_LINE import math NEW_LINE def printChar ( str_ , n ) : NEW_LINE INDENT freq = [ 0 ] * 26 NEW_LINE for i in range ( n ) : NEW_LINE INDENT freq [ ord ( str_ [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( freq [ ord ( str_ [ i ] ) - ord ( ' a ' ) ] ) % 2 == 1 : NEW_LINE INDENT print ( "" { } "" . format ( str_ [ i ] ) , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str_ = "" geeksforgeeks "" NEW_LINE n = len ( str_ ) NEW_LINE printChar ( str_ , n ) NEW_LINE DEDENT +" +E1150,"class GFG { static boolean isSafe ( int x , int y ) { return ( x < 4 && y < 3 ) ; } static int minJump ( int height [ ] [ ] , int x , int y ) { if ( x == 4 - 1 && y == 3 - 1 ) return 0 ; int diag = Integer . MAX_VALUE ; if ( isSafe ( x + 1 , y + 1 ) ) diag = minJump ( height , x + 1 , y + 1 ) + Math . abs ( height [ x ] [ y ] - height [ x + 1 ] [ y + 1 ] ) ; int down = Integer . MAX_VALUE ; if ( isSafe ( x + 1 , y ) ) down = minJump ( height , x + 1 , y ) + Math . abs ( height [ x ] [ y ] - height [ x + 1 ] [ y ] ) ; int right = Integer . MAX_VALUE ; if ( isSafe ( x , y + 1 ) ) right = minJump ( height , x , y + 1 ) + Math . abs ( height [ x ] [ y ] - height [ x ] [ y + 1 ] ) ; return Math . min ( down , Math . min ( right , diag ) ) ; } public static void main ( String [ ] args ) { int height [ ] [ ] = { { 5 , 4 , 2 } , { 9 , 2 , 1 } , { 2 , 5 , 9 } , { 1 , 3 , 11 } } ; System . out . println ( minJump ( height , 0 , 0 ) ) ; } } +","R = 4 NEW_LINE C = 3 NEW_LINE def isSafe ( x , y ) : NEW_LINE INDENT return ( x < R and y < C ) NEW_LINE DEDENT def minJump ( height , x , y ) : NEW_LINE INDENT if ( x == R - 1 and y == C - 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT diag = 10 ** 9 NEW_LINE if ( isSafe ( x + 1 , y + 1 ) ) : NEW_LINE INDENT diag = ( minJump ( height , x + 1 , y + 1 ) + abs ( height [ x ] [ y ] - height [ x + 1 ] [ y + 1 ] ) ) NEW_LINE DEDENT down = 10 ** 9 NEW_LINE if ( isSafe ( x + 1 , y ) ) : NEW_LINE INDENT down = ( minJump ( height , x + 1 , y ) + abs ( height [ x ] [ y ] - height [ x + 1 ] [ y ] ) ) NEW_LINE DEDENT right = 10 ** 9 NEW_LINE if ( isSafe ( x , y + 1 ) ) : NEW_LINE INDENT right = ( minJump ( height , x , y + 1 ) + abs ( height [ x ] [ y ] - height [ x ] [ y + 1 ] ) ) NEW_LINE DEDENT return min ( [ down , right , diag ] ) NEW_LINE DEDENT height = [ [ 5 , 4 , 2 ] , [ 9 , 2 , 1 ] , [ 2 , 5 , 9 ] , [ 1 , 3 , 11 ] ] NEW_LINE print ( minJump ( height , 0 , 0 ) ) NEW_LINE +" +E1151,"import java . util . * ; class Main { static int segregate ( int arr [ ] , int size ) { int j = 0 , i ; for ( i = 0 ; i < size ; i ++ ) { if ( arr [ i ] <= 0 ) { int temp ; temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; j ++ ; } } return j ; } static int findMissingPositive ( int arr [ ] , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) { int x = Math . abs ( arr [ i ] ) ; if ( x - 1 < size && arr [ x - 1 ] > 0 ) arr [ x - 1 ] = - arr [ x - 1 ] ; } for ( i = 0 ; i < size ; i ++ ) if ( arr [ i ] > 0 ) return i + 1 ; return size + 1 ; } static int findMissing ( int arr [ ] , int size ) { int shift = segregate ( arr , size ) ; int arr2 [ ] = new int [ size - shift ] ; int j = 0 ; for ( int i = shift ; i < size ; i ++ ) { arr2 [ j ] = arr [ i ] ; j ++ ; } return findMissingPositive ( arr2 , j ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 10 , 2 , - 10 , - 20 } ; int arr_size = arr . length ; int missing = findMissing ( arr , arr_size ) ; System . out . println ( "" The ▁ smallest ▁ positive ▁ missing ▁ number ▁ is ▁ "" + missing ) ; } } +","def segregate ( arr , size ) : NEW_LINE INDENT j = 0 NEW_LINE for i in range ( size ) : NEW_LINE INDENT if ( arr [ i ] <= 0 ) : NEW_LINE INDENT arr [ i ] , arr [ j ] = arr [ j ] , arr [ i ] NEW_LINE j += 1 NEW_LINE DEDENT DEDENT return j NEW_LINE DEDENT def findMissingPositive ( arr , size ) : NEW_LINE INDENT for i in range ( size ) : NEW_LINE INDENT if ( abs ( arr [ i ] ) - 1 < size and arr [ abs ( arr [ i ] ) - 1 ] > 0 ) : NEW_LINE INDENT arr [ abs ( arr [ i ] ) - 1 ] = - arr [ abs ( arr [ i ] ) - 1 ] NEW_LINE DEDENT DEDENT for i in range ( size ) : NEW_LINE INDENT if ( arr [ i ] > 0 ) : NEW_LINE INDENT return i + 1 NEW_LINE DEDENT DEDENT return size + 1 NEW_LINE DEDENT def findMissing ( arr , size ) : NEW_LINE INDENT shift = segregate ( arr , size ) NEW_LINE return findMissingPositive ( arr [ shift : ] , size - shift ) NEW_LINE DEDENT arr = [ 0 , 10 , 2 , - 10 , - 20 ] NEW_LINE arr_size = len ( arr ) NEW_LINE missing = findMissing ( arr , arr_size ) NEW_LINE print ( "" The ▁ smallest ▁ positive ▁ missing ▁ number ▁ is ▁ "" , missing ) NEW_LINE +" +E1152,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static int minStepsNeeded ( int k , int d1 , int d2 , int x ) { int gcd = __gcd ( d1 , d2 ) ; if ( ( k - x ) % gcd != 0 ) return - 1 ; Queue < pair > q = new LinkedList < > ( ) ; HashSet < Integer > visited = new HashSet < > ( ) ; q . add ( new pair ( k , 0 ) ) ; visited . add ( k ) ; while ( ! q . isEmpty ( ) ) { int s = q . peek ( ) . first ; int stp = q . peek ( ) . second ; if ( s == x ) return stp ; q . remove ( ) ; if ( ! visited . contains ( s + d1 ) ) { q . add ( new pair ( s + d1 , stp + 1 ) ) ; visited . add ( s + d1 ) ; } if ( visited . contains ( s + d2 ) ) { q . add ( new pair ( s + d2 , stp + 1 ) ) ; visited . add ( s + d2 ) ; } if ( ! visited . contains ( s - d1 ) ) { q . add ( new pair ( s - d1 , stp + 1 ) ) ; visited . add ( s - d1 ) ; } if ( ! visited . contains ( s - d2 ) ) { q . add ( new pair ( s - d2 , stp + 1 ) ) ; visited . add ( s - d2 ) ; } } return Integer . MIN_VALUE ; } public static void main ( String [ ] args ) { int k = 10 , d1 = 4 , d2 = 6 , x = 8 ; System . out . println ( minStepsNeeded ( k , d1 , d2 , x ) ) ; } } +","from math import gcd as __gcd NEW_LINE from collections import deque as queue NEW_LINE def minStepsNeeded ( k , d1 , d2 , x ) : NEW_LINE INDENT gcd = __gcd ( d1 , d2 ) NEW_LINE if ( ( k - x ) % gcd != 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT q = queue ( ) NEW_LINE visited = dict ( ) NEW_LINE q . appendleft ( [ k , 0 ] ) NEW_LINE visited [ k ] = 1 NEW_LINE while ( len ( q ) > 0 ) : NEW_LINE INDENT sr = q . pop ( ) NEW_LINE s , stp = sr [ 0 ] , sr [ 1 ] NEW_LINE if ( s == x ) : NEW_LINE INDENT return stp NEW_LINE DEDENT if ( s + d1 not in visited ) : NEW_LINE INDENT q . appendleft ( [ ( s + d1 ) , stp + 1 ] ) NEW_LINE visited [ ( s + d1 ) ] = 1 NEW_LINE DEDENT if ( s + d2 not in visited ) : NEW_LINE INDENT q . appendleft ( [ ( s + d2 ) , stp + 1 ] ) NEW_LINE visited [ ( s + d2 ) ] = 1 NEW_LINE DEDENT if ( s - d1 not in visited ) : NEW_LINE INDENT q . appendleft ( [ ( s - d1 ) , stp + 1 ] ) NEW_LINE visited [ ( s - d1 ) ] = 1 NEW_LINE DEDENT if ( s - d2 not in visited ) : NEW_LINE INDENT q . appendleft ( [ ( s - d2 ) , stp + 1 ] ) NEW_LINE visited [ ( s - d2 ) ] = 1 NEW_LINE DEDENT DEDENT DEDENT k = 10 NEW_LINE d1 = 4 NEW_LINE d2 = 6 NEW_LINE x = 8 NEW_LINE print ( minStepsNeeded ( k , d1 , d2 , x ) ) NEW_LINE +" +E1153,"import java . util . * ; import java . lang . * ; class Main { static void minAbsSumPair ( int arr [ ] , int arr_size ) { int inv_count = 0 ; int l , r , min_sum , sum , min_l , min_r ; if ( arr_size < 2 ) { System . out . println ( "" Invalid ▁ Input "" ) ; return ; } min_l = 0 ; min_r = 1 ; min_sum = arr [ 0 ] + arr [ 1 ] ; for ( l = 0 ; l < arr_size - 1 ; l ++ ) { for ( r = l + 1 ; r < arr_size ; r ++ ) { sum = arr [ l ] + arr [ r ] ; if ( Math . abs ( min_sum ) > Math . abs ( sum ) ) { min_sum = sum ; min_l = l ; min_r = r ; } } } System . out . println ( "" ▁ The ▁ two ▁ elements ▁ whose ▁ "" + "" sum ▁ is ▁ minimum ▁ are ▁ "" + arr [ min_l ] + "" ▁ and ▁ "" + arr [ min_r ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 60 , - 10 , 70 , - 80 , 85 } ; minAbsSumPair ( arr , 6 ) ; } } +","def minAbsSumPair ( arr , arr_size ) : NEW_LINE INDENT inv_count = 0 NEW_LINE if arr_size < 2 : NEW_LINE INDENT print ( "" Invalid ▁ Input "" ) NEW_LINE return NEW_LINE DEDENT min_l = 0 NEW_LINE min_r = 1 NEW_LINE min_sum = arr [ 0 ] + arr [ 1 ] NEW_LINE for l in range ( 0 , arr_size - 1 ) : NEW_LINE INDENT for r in range ( l + 1 , arr_size ) : NEW_LINE INDENT sum = arr [ l ] + arr [ r ] NEW_LINE if abs ( min_sum ) > abs ( sum ) : NEW_LINE INDENT min_sum = sum NEW_LINE min_l = l NEW_LINE min_r = r NEW_LINE DEDENT DEDENT DEDENT print ( "" The ▁ two ▁ elements ▁ whose ▁ sum ▁ is ▁ minimum ▁ are "" , arr [ min_l ] , "" and ▁ "" , arr [ min_r ] ) NEW_LINE DEDENT arr = [ 1 , 60 , - 10 , 70 , - 80 , 85 ] NEW_LINE minAbsSumPair ( arr , 6 ) ; NEW_LINE +" +E1154,"import java . util . * ; class GFG { static int findSubsequence ( int arr [ ] , int n ) { int len = 1 ; int tmp ; int i , j , d ; int dp [ ] = new int [ 10 ] ; int cnt [ ] = new int [ 10 ] ; int locMax ; tmp = arr [ 0 ] ; while ( tmp > 0 ) { dp [ tmp % 10 ] = 1 ; tmp /= 10 ; } for ( i = 1 ; i < n ; i ++ ) { tmp = arr [ i ] ; locMax = 1 ; Arrays . fill ( cnt , 0 ) ; while ( tmp > 0 ) { cnt [ tmp % 10 ] = 1 ; tmp /= 10 ; } for ( d = 0 ; d <= 9 ; d ++ ) { if ( cnt [ d ] == 1 ) { dp [ d ] ++ ; locMax = Math . max ( locMax , dp [ d ] ) ; } } for ( d = 0 ; d <= 9 ; d ++ ) { if ( cnt [ d ] == 1 ) { dp [ d ] = locMax ; } } len = Math . max ( len , locMax ) ; } return len ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 12 , 44 , 29 , 33 , 96 , 89 } ; int n = arr . length ; System . out . print ( findSubsequence ( arr , n ) ) ; } } +","def findSubsequence ( arr , n ) : NEW_LINE INDENT length = 1 ; NEW_LINE dp = [ 0 ] * 10 ; NEW_LINE tmp = arr [ 0 ] ; NEW_LINE while ( tmp > 0 ) : NEW_LINE INDENT dp [ tmp % 10 ] = 1 ; NEW_LINE tmp //= 10 ; NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT tmp = arr [ i ] ; NEW_LINE locMax = 1 ; NEW_LINE cnt = [ 0 ] * 10 NEW_LINE while ( tmp > 0 ) : NEW_LINE INDENT cnt [ tmp % 10 ] = 1 ; NEW_LINE tmp //= 10 ; NEW_LINE DEDENT for d in range ( 10 ) : NEW_LINE INDENT if ( cnt [ d ] ) : NEW_LINE INDENT dp [ d ] += 1 ; NEW_LINE locMax = max ( locMax , dp [ d ] ) ; NEW_LINE DEDENT DEDENT for d in range ( 10 ) : NEW_LINE INDENT if ( cnt [ d ] ) : NEW_LINE INDENT dp [ d ] = locMax ; NEW_LINE DEDENT DEDENT length = max ( length , locMax ) ; NEW_LINE DEDENT return length ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 12 , 44 , 29 , 33 , 96 , 89 ] ; NEW_LINE n = len ( arr ) NEW_LINE print ( findSubsequence ( arr , n ) ) ; NEW_LINE DEDENT +" +E1155,"class GFG { static int dp [ ] [ ] [ ] = new int [ 5001 ] [ 5001 ] [ 5 ] ; static int countWaysUtil ( int n , int parts , int nextPart ) { if ( parts == 0 && n == 0 ) return 1 ; if ( n <= 0 || parts <= 0 ) return 0 ; if ( dp [ n ] [ nextPart ] [ parts ] != - 1 ) return dp [ n ] [ nextPart ] [ parts ] ; int ans = 0 ; for ( int i = nextPart ; i <= n ; i ++ ) ans += countWaysUtil ( n - i , parts - 1 , i ) ; return ( dp [ n ] [ nextPart ] [ parts ] = ans ) ; } static int countWays ( int n ) { for ( int i = 0 ; i < 5001 ; i ++ ) { for ( int j = 0 ; j < 5001 ; j ++ ) { for ( int l = 0 ; l < 5 ; l ++ ) dp [ i ] [ j ] [ l ] = - 1 ; } } return countWaysUtil ( n , 4 , 1 ) ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( countWays ( n ) ) ; } } +","dp = [ [ [ - 1 for i in range ( 5 ) ] for i in range ( 501 ) ] for i in range ( 501 ) ] NEW_LINE def countWaysUtil ( n , parts , nextPart ) : NEW_LINE INDENT if ( parts == 0 and n == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( n <= 0 or parts <= 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( dp [ n ] [ nextPart ] [ parts ] != - 1 ) : NEW_LINE INDENT return dp [ n ] [ nextPart ] [ parts ] NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( nextPart , n + 1 ) : NEW_LINE INDENT ans += countWaysUtil ( n - i , parts - 1 , i ) NEW_LINE DEDENT dp [ n ] [ nextPart ] [ parts ] = ans NEW_LINE return ( ans ) NEW_LINE DEDENT def countWays ( n ) : NEW_LINE INDENT return countWaysUtil ( n , 4 , 1 ) NEW_LINE DEDENT n = 8 NEW_LINE print ( countWays ( n ) ) NEW_LINE +" +E1156,"class GFG { static double nthRoot ( int A , int N ) { double xPre = Math . random ( ) * 10 % 10 ; double eps = 1e-3 ; double delX = Integer . MAX_VALUE ; double xK = 0 ; while ( delX > eps ) { xK = ( ( N - 1.0 ) * xPre + ( double ) A / Math . pow ( xPre , N - 1 ) ) / ( double ) N ; delX = Math . abs ( xK - xPre ) ; xPre = xK ; } return xK ; } static int countPowers ( int a , int b , int k ) { return ( int ) ( Math . floor ( nthRoot ( b , k ) ) - Math . ceil ( nthRoot ( a , k ) ) + 1 ) ; } public static void main ( String [ ] args ) { int a = 7 , b = 28 , k = 2 ; System . out . print ( "" Count ▁ of ▁ Powers ▁ is ▁ "" + countPowers ( a , b , k ) ) ; } } +","import sys NEW_LINE from math import pow , ceil , floor NEW_LINE import random NEW_LINE def nthRoot ( A , N ) : NEW_LINE INDENT xPre = ( random . randint ( 0 , 9 ) ) % 10 NEW_LINE eps = 1e-3 NEW_LINE delX = sys . maxsize NEW_LINE while ( delX > eps ) : NEW_LINE INDENT xK = ( ( N - 1.0 ) * xPre + A / pow ( xPre , N - 1 ) ) / N NEW_LINE delX = abs ( xK - xPre ) NEW_LINE xPre = xK NEW_LINE DEDENT return xK NEW_LINE DEDENT def countPowers ( a , b , k ) : NEW_LINE INDENT return ( floor ( nthRoot ( b , k ) ) - ceil ( nthRoot ( a , k ) ) + 1 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 7 NEW_LINE b = 28 NEW_LINE k = 2 NEW_LINE print ( "" Count ▁ of ▁ Powers ▁ is "" , countPowers ( a , b , k ) ) NEW_LINE DEDENT +" +E1157,"public class GFG { static void minSwaps ( String str1 , String str2 ) { int count = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( str1 . charAt ( i ) != str2 . charAt ( i ) ) count ++ ; } if ( count % 2 == 0 ) System . out . println ( count / 2 ) ; else System . out . println ( "" Not ▁ Possible "" ) ; } public static void main ( String args [ ] ) { String binaryString1 = ""1110000"" ; String binaryString2 = ""0001101"" ; minSwaps ( binaryString1 , binaryString2 ) ; } } +","def minSwaps ( str1 , str2 ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( len ( str1 ) ) : NEW_LINE INDENT if str1 [ i ] != str2 [ i ] : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if count % 2 == 0 : NEW_LINE INDENT print ( count // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Not ▁ Possible "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT binaryString1 = ""1110000"" NEW_LINE binaryString2 = ""0001101"" NEW_LINE minSwaps ( binaryString1 , binaryString2 ) NEW_LINE DEDENT +" +E1158,"import java . util . HashMap ; import java . util . Map ; class GFG { public static int countOrderedPairs ( int [ ] A , int n ) { int orderedPairs = 0 ; HashMap < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . get ( A [ i ] ) == null ) m . put ( A [ i ] , 1 ) ; else { int a = m . get ( A [ i ] ) ; m . put ( A [ i ] , ++ a ) ; } } for ( int entry : m . keySet ( ) ) { int X = entry ; int Y = m . get ( entry ) ; for ( int j = 1 ; j <= Y ; j ++ ) { if ( m . get ( j ) >= X ) orderedPairs ++ ; } } return orderedPairs ; } public static void main ( String [ ] args ) { int [ ] A = { 1 , 1 , 2 , 2 , 3 } ; int n = A . length ; System . out . print ( countOrderedPairs ( A , n ) ) ; } } +","from collections import defaultdict NEW_LINE def countOrderedPairs ( A , n ) : NEW_LINE INDENT orderedPairs = 0 NEW_LINE m = defaultdict ( lambda : 0 ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT m [ A [ i ] ] += 1 NEW_LINE DEDENT for X , Y in m . items ( ) : NEW_LINE INDENT for j in range ( 1 , Y + 1 ) : NEW_LINE INDENT if m [ j ] >= X : NEW_LINE INDENT orderedPairs += 1 NEW_LINE DEDENT DEDENT DEDENT return orderedPairs NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 1 , 1 , 2 , 2 , 3 ] NEW_LINE n = len ( A ) NEW_LINE print ( countOrderedPairs ( A , n ) ) NEW_LINE DEDENT +" +E1159,"import java . util . Arrays ; class AP { static void makeAP ( int arr [ ] , int n ) { int initial_term , common_difference ; if ( n == 3 ) { common_difference = arr [ 2 ] - arr [ 1 ] ; initial_term = arr [ 1 ] - common_difference ; } else if ( ( arr [ 1 ] - arr [ 0 ] ) == arr [ 2 ] - arr [ 1 ] ) { initial_term = arr [ 0 ] ; common_difference = arr [ 1 ] - arr [ 0 ] ; } else if ( ( arr [ 2 ] - arr [ 1 ] ) == ( arr [ 3 ] - arr [ 2 ] ) ) { common_difference = arr [ 2 ] - arr [ 1 ] ; initial_term = arr [ 1 ] - common_difference ; } else { common_difference = ( arr [ 3 ] - arr [ 0 ] ) / 3 ; initial_term = arr [ 0 ] ; } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( initial_term + ( i * common_difference ) + "" ▁ "" ) ; System . out . println ( ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 7 } ; int n = arr . length ; makeAP ( arr , n ) ; } } +","def makeAP ( arr , n ) : NEW_LINE INDENT initial_term , common_difference = 0 , 0 NEW_LINE if ( n == 3 ) : NEW_LINE INDENT common_difference = arr [ 2 ] - arr [ 1 ] NEW_LINE initial_term = arr [ 1 ] - common_difference NEW_LINE DEDENT elif ( ( arr [ 1 ] - arr [ 0 ] ) == arr [ 2 ] - arr [ 1 ] ) : NEW_LINE INDENT initial_term = arr [ 0 ] NEW_LINE common_difference = arr [ 1 ] - arr [ 0 ] NEW_LINE DEDENT elif ( ( arr [ 2 ] - arr [ 1 ] ) == ( arr [ 3 ] - arr [ 2 ] ) ) : NEW_LINE INDENT common_difference = arr [ 2 ] - arr [ 1 ] NEW_LINE initial_term = arr [ 1 ] - common_difference NEW_LINE DEDENT else : NEW_LINE INDENT common_difference = ( arr [ 3 ] - arr [ 0 ] ) / 3 NEW_LINE initial_term = arr [ 0 ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( int ( initial_term + ( i * common_difference ) ) , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT arr = [ 1 , 3 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE makeAP ( arr , n ) NEW_LINE +" +E1160,"class Test { static int arr [ ] = new int [ ] { 1 , 2 , 2 , 4 } ; static int countIncreasing ( int n ) { int cnt = 0 ; int len = 1 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { if ( arr [ i + 1 ] > arr [ i ] ) len ++ ; else { cnt += ( ( ( len - 1 ) * len ) / 2 ) ; len = 1 ; } } if ( len > 1 ) cnt += ( ( ( len - 1 ) * len ) / 2 ) ; return cnt ; } public static void main ( String [ ] args ) { System . out . println ( "" Count ▁ of ▁ strictly ▁ increasing ▁ subarrays ▁ is ▁ "" + countIncreasing ( arr . length ) ) ; } } +","def countIncreasing ( arr , n ) : NEW_LINE INDENT cnt = 0 NEW_LINE len = 1 NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT if arr [ i + 1 ] > arr [ i ] : NEW_LINE INDENT len += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += ( ( ( len - 1 ) * len ) / 2 ) NEW_LINE len = 1 NEW_LINE DEDENT DEDENT if len > 1 : NEW_LINE INDENT cnt += ( ( ( len - 1 ) * len ) / 2 ) NEW_LINE DEDENT return cnt NEW_LINE DEDENT arr = [ 1 , 2 , 2 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Count ▁ of ▁ strictly ▁ increasing ▁ subarrays ▁ is "" , int ( countIncreasing ( arr , n ) ) ) NEW_LINE +" +E1161,"import java . io . * ; class GFG { static float harmonicMean ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( float ) 1 / arr [ i ] ; return ( float ) n / sum ; } public static void main ( String args [ ] ) { float arr [ ] = { 13.5f , 14.5f , 14.8f , 15.2f , 16.1f } ; int n = arr . length ; System . out . println ( harmonicMean ( arr , n ) ) ; } } +","def harmonicMean ( arr , n ) : NEW_LINE INDENT sm = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sm = sm + ( 1 ) / arr [ i ] ; NEW_LINE DEDENT return n / sm NEW_LINE DEDENT arr = [ 13.5 , 14.5 , 14.8 , 15.2 , 16.1 ] ; NEW_LINE n = len ( arr ) NEW_LINE print ( harmonicMean ( arr , n ) ) NEW_LINE +" +E1162,"class GFG { static boolean asPowerSum ( int w , int m ) { while ( m > 0 ) { if ( ( m - 1 ) % w == 0 ) m = ( m - 1 ) / w ; else if ( ( m + 1 ) % w == 0 ) m = ( m + 1 ) / w ; else if ( m % w == 0 ) m = m / w ; else break ; } return ( m == 0 ) ; } public static void main ( String [ ] args ) { int w = 3 , m = 7 ; if ( asPowerSum ( w , m ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def asPowerSum ( w , m ) : NEW_LINE INDENT while ( m > 0 ) : NEW_LINE INDENT if ( ( m - 1 ) % w == 0 ) : NEW_LINE INDENT m = ( m - 1 ) / w ; NEW_LINE DEDENT elif ( ( m + 1 ) % w == 0 ) : NEW_LINE INDENT m = ( m + 1 ) / w ; NEW_LINE DEDENT elif ( m % w == 0 ) : NEW_LINE INDENT m = m / w ; NEW_LINE DEDENT else : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT return ( m == 0 ) ; NEW_LINE DEDENT w = 3 ; NEW_LINE m = 7 ; NEW_LINE if ( asPowerSum ( w , m ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT +" +E1163,"class GFG { static void result ( long n , long k , long t ) { if ( t <= k ) System . out . println ( t ) ; else if ( t <= n ) System . out . println ( k ) ; else { long temp = t - n ; temp = k - temp ; System . out . println ( temp ) ; } } public static void main ( String args [ ] ) { long n , k , t ; n = 10 ; k = 5 ; t = 12 ; result ( n , k , t ) ; } } +","def result ( n , k , t ) : NEW_LINE INDENT if ( t <= k ) : NEW_LINE INDENT print ( t ) NEW_LINE DEDENT elif ( t <= n ) : NEW_LINE INDENT print ( k ) NEW_LINE DEDENT else : NEW_LINE INDENT temp = t - n NEW_LINE temp = k - temp NEW_LINE print ( temp ) NEW_LINE DEDENT DEDENT n = 10 NEW_LINE k = 5 NEW_LINE t = 12 NEW_LINE result ( n , k , t ) NEW_LINE +" +E1164,"import java . util . Arrays ; class GfG { private static int table [ ] [ ] ; private static int height ; private GfG ( int n ) { height = ( int ) Math . ceil ( Math . log10 ( n ) / Math . log10 ( 2 ) ) ; table = new int [ n + 1 ] [ height + 1 ] ; } private static void preprocessing ( ) { for ( int i = 0 ; i < table . length ; i ++ ) { Arrays . fill ( table [ i ] , - 1 ) ; } } private static void calculateSparse ( int u , int v ) { table [ v ] [ 0 ] = u ; for ( int i = 1 ; i <= height ; i ++ ) { table [ v ] [ i ] = table [ table [ v ] [ i - 1 ] ] [ i - 1 ] ; if ( table [ v ] [ i ] == - 1 ) break ; } } private static int kthancestor ( int V , int k ) { for ( int i = 0 ; i <= height ; i ++ ) { if ( ( k & ( 1 << i ) ) != 0 ) { V = table [ V ] [ i ] ; if ( V == - 1 ) break ; } } return V ; } public static void main ( String args [ ] ) { int n = 6 ; GfG obj = new GfG ( n ) ; preprocessing ( ) ; calculateSparse ( 1 , 2 ) ; calculateSparse ( 1 , 3 ) ; calculateSparse ( 2 , 4 ) ; calculateSparse ( 2 , 5 ) ; calculateSparse ( 3 , 6 ) ; int K = 2 , V = 5 ; System . out . print ( kthancestor ( V , K ) ) ; } } +","import math NEW_LINE class GfG : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . height = int ( math . ceil ( math . log10 ( n ) / math . log10 ( 2 ) ) ) NEW_LINE self . table = [ 0 ] * ( n + 1 ) NEW_LINE DEDENT def preprocessing ( self ) : NEW_LINE INDENT i = 0 NEW_LINE while ( i < len ( self . table ) ) : NEW_LINE INDENT self . table [ i ] = [ - 1 ] * ( self . height + 1 ) NEW_LINE i = i + 1 NEW_LINE DEDENT DEDENT def calculateSparse ( self , u , v ) : NEW_LINE INDENT self . table [ v ] [ 0 ] = u NEW_LINE i = 1 NEW_LINE while ( i <= self . height ) : NEW_LINE INDENT self . table [ v ] [ i ] = self . table [ self . table [ v ] [ i - 1 ] ] [ i - 1 ] NEW_LINE if ( self . table [ v ] [ i ] == - 1 ) : NEW_LINE INDENT break NEW_LINE DEDENT i = i + 1 NEW_LINE DEDENT DEDENT def kthancestor ( self , V , k ) : NEW_LINE INDENT i = 0 NEW_LINE while ( i <= self . height ) : NEW_LINE INDENT if ( ( k & ( 1 << i ) ) != 0 ) : NEW_LINE INDENT V = self . table [ V ] [ i ] NEW_LINE if ( V == - 1 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT i = i + 1 NEW_LINE DEDENT return V NEW_LINE DEDENT DEDENT n = 6 NEW_LINE obj = GfG ( n ) NEW_LINE obj . preprocessing ( ) NEW_LINE obj . calculateSparse ( 1 , 2 ) NEW_LINE obj . calculateSparse ( 1 , 3 ) NEW_LINE obj . calculateSparse ( 2 , 4 ) NEW_LINE obj . calculateSparse ( 2 , 5 ) NEW_LINE obj . calculateSparse ( 3 , 6 ) NEW_LINE K = 2 NEW_LINE V = 5 NEW_LINE print ( obj . kthancestor ( V , K ) ) NEW_LINE +" +E1165,"class GFG { static void factors ( int n , int i ) { if ( i <= n ) { if ( n % i == 0 ) { System . out . print ( i + "" ▁ "" ) ; } factors ( n , i + 1 ) ; } } public static void main ( String args [ ] ) { int N = 16 ; factors ( N , 1 ) ; } } +","def factors ( n , i ) : NEW_LINE INDENT if ( i <= n ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT print ( i , end = "" ▁ "" ) ; NEW_LINE DEDENT factors ( n , i + 1 ) ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 16 ; NEW_LINE factors ( N , 1 ) ; NEW_LINE DEDENT +" +E1166,"import java . util . HashMap ; import java . util . Map ; class GfG { static int sumKRepeating ( int arr [ ] , int n , int k ) { int sum = 0 ; HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! mp . containsKey ( arr [ i ] ) ) mp . put ( arr [ i ] , 0 ) ; mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } for ( Integer x : mp . keySet ( ) ) if ( mp . get ( x ) == k ) sum += x ; return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 9 , 10 , 11 , 8 , 8 , 9 , 8 } ; int n = arr . length ; int k = 3 ; System . out . println ( sumKRepeating ( arr , n , k ) ) ; } } +","import math as mt NEW_LINE def sumKRepeating ( arr , n , k ) : NEW_LINE INDENT Sum = 0 NEW_LINE mp = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] in mp . keys ( ) : NEW_LINE INDENT mp [ arr [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ arr [ i ] ] = 1 NEW_LINE DEDENT DEDENT for x in mp : NEW_LINE INDENT if ( mp [ x ] == k ) : NEW_LINE INDENT Sum += x NEW_LINE DEDENT DEDENT return Sum NEW_LINE DEDENT arr = [ 9 , 9 , 10 , 11 , 8 , 8 , 9 , 8 ] NEW_LINE n = len ( arr ) NEW_LINE k = 3 NEW_LINE print ( sumKRepeating ( arr , n , k ) ) NEW_LINE +" +E1167,"class GFG { static int power ( int num , int n ) { if ( n == 0 ) return 1 ; else if ( n % 2 == 0 ) return power ( num , n / 2 ) * power ( num , n / 2 ) ; else return num * power ( num , n / 2 ) * power ( num , n / 2 ) ; } static int checkRecursive ( int x , int n , int curr_num , int curr_sum ) { int results = 0 ; int p = power ( curr_num , n ) ; while ( p + curr_sum < x ) { results += checkRecursive ( x , n , curr_num + 1 , p + curr_sum ) ; curr_num ++ ; p = power ( curr_num , n ) ; } if ( p + curr_sum == x ) results ++ ; return results ; } public static void main ( String [ ] args ) { int x = 10 , n = 2 ; System . out . println ( checkRecursive ( x , n , 1 , 0 ) ) ; } } +","def power ( num , n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif ( n % 2 == 0 ) : NEW_LINE INDENT return power ( num , n // 2 ) * power ( num , n // 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT return num * power ( num , n // 2 ) * power ( num , n // 2 ) NEW_LINE DEDENT DEDENT def checkRecursive ( x , n , curr_num = 1 , curr_sum = 0 ) : NEW_LINE INDENT results = 0 NEW_LINE p = power ( curr_num , n ) NEW_LINE while ( p + curr_sum < x ) : NEW_LINE INDENT results += checkRecursive ( x , n , curr_num + 1 , p + curr_sum ) NEW_LINE curr_num = curr_num + 1 NEW_LINE p = power ( curr_num , n ) NEW_LINE DEDENT if ( p + curr_sum == x ) : NEW_LINE INDENT results = results + 1 NEW_LINE DEDENT return results NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT x = 10 NEW_LINE n = 2 NEW_LINE print ( checkRecursive ( x , n ) ) NEW_LINE DEDENT +" +E1168,"import java . io . * ; class GFG { static int nCr ( int n , int r ) { int fac [ ] = new int [ 100 ] ; for ( int i = 0 ; i < n ; i ++ ) fac [ i ] = 1 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { fac [ i ] = fac [ i - 1 ] * i ; } int ans = fac [ n ] / ( fac [ n - r ] * fac [ r ] ) ; return ans ; } public static void main ( String [ ] args ) { int n = 3 ; int k = 3 ; int ans = nCr ( n + k - 1 , k ) + nCr ( k - 1 , n - 1 ) ; System . out . println ( ans ) ; } } +","def nCr ( n , r ) : NEW_LINE INDENT fac = list ( ) NEW_LINE fac . append ( 1 ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT fac . append ( fac [ i - 1 ] * i ) NEW_LINE DEDENT ans = fac [ n ] / ( fac [ n - r ] * fac [ r ] ) NEW_LINE return ans NEW_LINE DEDENT n = 3 NEW_LINE k = 3 NEW_LINE ans = nCr ( n + k - 1 , k ) + nCr ( k - 1 , n - 1 ) NEW_LINE print ( ans ) NEW_LINE +" +E1169,"import java . io . * ; class GFG { static int pairORSum ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) ans += arr [ i ] ^ arr [ j ] ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 9 , 7 , 6 } ; int n = arr . length ; System . out . println ( pairORSum ( arr , arr . length ) ) ; } } +","def pairORSum ( arr , n ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT ans = ans + ( arr [ i ] ^ arr [ j ] ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT arr = [ 5 , 9 , 7 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE print ( pairORSum ( arr , n ) ) NEW_LINE +" +E1170,"class GFG { static void alphabetPattern ( int N ) { int index , side_index ; int Top = 1 , Bottom = 1 , Diagonal = N - 1 ; for ( index = 0 ; index < N ; index ++ ) System . out . print ( Top ++ + "" ▁ "" ) ; System . out . println ( ) ; for ( index = 1 ; index < N - 1 ; index ++ ) { for ( side_index = 0 ; side_index < 2 * ( N - index - 1 ) ; side_index ++ ) System . out . print ( "" ▁ "" ) ; System . out . print ( Diagonal -- ) ; System . out . println ( ) ; } for ( index = 0 ; index < N ; index ++ ) System . out . print ( Bottom ++ + "" ▁ "" ) ; } public static void main ( String args [ ] ) { int N = 5 ; alphabetPattern ( N ) ; } } +","def alphabetPattern ( N ) : NEW_LINE INDENT Top , Bottom , Diagonal = 1 , 1 , N - 1 NEW_LINE for index in range ( N ) : NEW_LINE INDENT print ( Top , end = ' ▁ ' ) NEW_LINE Top += 1 NEW_LINE DEDENT print ( ) NEW_LINE for index in range ( 1 , N - 1 ) : NEW_LINE INDENT for side_index in range ( 2 * ( N - index - 1 ) ) : NEW_LINE INDENT print ( ' ▁ ' , end = ' ' ) NEW_LINE DEDENT print ( Diagonal , end = ' ' ) NEW_LINE Diagonal -= 1 NEW_LINE print ( ) NEW_LINE DEDENT for index in range ( N ) : NEW_LINE INDENT print ( Bottom , end = ' ▁ ' ) NEW_LINE Bottom += 1 NEW_LINE DEDENT DEDENT N = 5 NEW_LINE alphabetPattern ( N ) NEW_LINE +" +E1171,"import java . io . * ; import java . util . * ; class GFG { static Boolean areElementsContiguous ( int arr [ ] , int n ) { HashSet < Integer > us = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) us . add ( arr [ i ] ) ; int count = 1 ; int curr_ele = arr [ 0 ] - 1 ; while ( us . contains ( curr_ele ) == true ) { count ++ ; curr_ele -- ; } curr_ele = arr [ 0 ] + 1 ; while ( us . contains ( curr_ele ) == true ) { count ++ ; curr_ele ++ ; } return ( count == ( us . size ( ) ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 2 , 3 , 6 , 4 , 4 , 6 , 6 } ; int n = arr . length ; if ( areElementsContiguous ( arr , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def areElementsContiguous ( arr ) : NEW_LINE INDENT us = set ( ) NEW_LINE for i in arr : us . add ( i ) NEW_LINE count = 1 NEW_LINE curr_ele = arr [ 0 ] - 1 NEW_LINE while curr_ele in us : NEW_LINE INDENT count += 1 NEW_LINE curr_ele -= 1 NEW_LINE DEDENT curr_ele = arr [ 0 ] + 1 NEW_LINE while curr_ele in us : NEW_LINE INDENT count += 1 NEW_LINE curr_ele += 1 NEW_LINE DEDENT return ( count == len ( us ) ) NEW_LINE DEDENT arr = [ 5 , 2 , 3 , 6 , 4 , 4 , 6 , 6 ] NEW_LINE if areElementsContiguous ( arr ) : print ( "" Yes "" ) NEW_LINE else : print ( "" No "" ) NEW_LINE +" +E1172,"class Main { static int pivotedBinarySearch ( int arr [ ] , int n , int key ) { int pivot = findPivot ( arr , 0 , n - 1 ) ; if ( pivot == - 1 ) return binarySearch ( arr , 0 , n - 1 , key ) ; if ( arr [ pivot ] == key ) return pivot ; if ( arr [ 0 ] <= key ) return binarySearch ( arr , 0 , pivot - 1 , key ) ; return binarySearch ( arr , pivot + 1 , n - 1 , key ) ; } static int findPivot ( int arr [ ] , int low , int high ) { if ( high < low ) return - 1 ; if ( high == low ) return low ; int mid = ( low + high ) / 2 ; if ( mid < high && arr [ mid ] > arr [ mid + 1 ] ) return mid ; if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) return ( mid - 1 ) ; if ( arr [ low ] >= arr [ mid ] ) return findPivot ( arr , low , mid - 1 ) ; return findPivot ( arr , mid + 1 , high ) ; } static int binarySearch ( int arr [ ] , int low , int high , int key ) { if ( high < low ) return - 1 ; int mid = ( low + high ) / 2 ; if ( key == arr [ mid ] ) return mid ; if ( key > arr [ mid ] ) return binarySearch ( arr , ( mid + 1 ) , high , key ) ; return binarySearch ( arr , low , ( mid - 1 ) , key ) ; } public static void main ( String args [ ] ) { int arr1 [ ] = { 5 , 6 , 7 , 8 , 9 , 10 , 1 , 2 , 3 } ; int n = arr1 . length ; int key = 3 ; System . out . println ( "" Index ▁ of ▁ the ▁ element ▁ is ▁ : ▁ "" + pivotedBinarySearch ( arr1 , n , key ) ) ; } } +","def pivotedBinarySearch ( arr , n , key ) : NEW_LINE INDENT pivot = findPivot ( arr , 0 , n - 1 ) ; NEW_LINE if pivot == - 1 : NEW_LINE INDENT return binarySearch ( arr , 0 , n - 1 , key ) ; NEW_LINE DEDENT if arr [ pivot ] == key : NEW_LINE INDENT return pivot NEW_LINE DEDENT if arr [ 0 ] <= key : NEW_LINE INDENT return binarySearch ( arr , 0 , pivot - 1 , key ) ; NEW_LINE DEDENT return binarySearch ( arr , pivot + 1 , n - 1 , key ) ; NEW_LINE DEDENT def findPivot ( arr , low , high ) : NEW_LINE INDENT if high < low : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if high == low : NEW_LINE INDENT return low NEW_LINE DEDENT mid = int ( ( low + high ) / 2 ) NEW_LINE if mid < high and arr [ mid ] > arr [ mid + 1 ] : NEW_LINE INDENT return mid NEW_LINE DEDENT if mid > low and arr [ mid ] < arr [ mid - 1 ] : NEW_LINE INDENT return ( mid - 1 ) NEW_LINE DEDENT if arr [ low ] >= arr [ mid ] : NEW_LINE INDENT return findPivot ( arr , low , mid - 1 ) NEW_LINE DEDENT return findPivot ( arr , mid + 1 , high ) NEW_LINE DEDENT def binarySearch ( arr , low , high , key ) : NEW_LINE INDENT if high < low : NEW_LINE INDENT return - 1 NEW_LINE DEDENT mid = int ( ( low + high ) / 2 ) NEW_LINE if key == arr [ mid ] : NEW_LINE INDENT return mid NEW_LINE DEDENT if key > arr [ mid ] : NEW_LINE INDENT return binarySearch ( arr , ( mid + 1 ) , high , key ) ; NEW_LINE DEDENT return binarySearch ( arr , low , ( mid - 1 ) , key ) ; NEW_LINE DEDENT arr1 = [ 5 , 6 , 7 , 8 , 9 , 10 , 1 , 2 , 3 ] NEW_LINE n = len ( arr1 ) NEW_LINE key = 3 NEW_LINE print ( "" Index ▁ of ▁ the ▁ element ▁ is ▁ : ▁ "" , pivotedBinarySearch ( arr1 , n , key ) ) NEW_LINE +" +E1173,"import java . util . * ; class geeks { public static void findDandZeroes ( int [ ] a , int [ ] b , int n ) { HashMap < Double , Integer > mpp = new HashMap < > ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( b [ i ] != 0 && a [ i ] != 0 ) { double val = ( double ) ( - 1.0 * b [ i ] ) / ( double ) ( a [ i ] ) ; if ( mpp . get ( val ) != null ) { int x = mpp . get ( val ) ; mpp . put ( val , ++ x ) ; } else mpp . put ( val , 1 ) ; } else if ( b [ i ] == 0 && a [ i ] == 0 ) count += 1 ; } int maxi = 0 ; for ( HashMap . Entry < Double , Integer > entry : mpp . entrySet ( ) ) { maxi = Math . max ( entry . getValue ( ) , maxi ) ; } for ( HashMap . Entry < Double , Integer > entry : mpp . entrySet ( ) ) { if ( entry . getValue ( ) == maxi ) { System . out . println ( "" Value ▁ of ▁ d ▁ is : ▁ "" + entry . getKey ( ) ) ; break ; } } System . out . println ( "" The ▁ number ▁ of ▁ zeros ▁ in ▁ array ▁ C ▁ is : ▁ "" + ( maxi + count ) ) ; } public static void main ( String [ ] args ) { int [ ] a = { 13 , 37 , 39 } ; int [ ] b = { 1 , 2 , 3 } ; int n = a . length ; findDandZeroes ( a , b , n ) ; } } +","def findDandZeros ( a , b , n ) : NEW_LINE INDENT mpp = { } ; NEW_LINE count = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( b [ i ] != 0 and a [ i ] != 0 ) : NEW_LINE INDENT val = ( - 1.0 * b [ i ] ) / a [ i ] ; NEW_LINE if val not in mpp : NEW_LINE INDENT mpp [ val ] = 0 ; NEW_LINE DEDENT mpp [ val ] += 1 ; NEW_LINE DEDENT elif ( b [ i ] == 0 and a [ i ] == 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT maxi = 0 ; NEW_LINE for item in mpp : NEW_LINE INDENT maxi = max ( mpp [ item ] , maxi ) ; NEW_LINE DEDENT for keys , values in mpp . items ( ) : NEW_LINE INDENT if ( values == maxi ) : NEW_LINE INDENT print ( "" Value ▁ of ▁ d ▁ is : "" , keys ) ; NEW_LINE break ; NEW_LINE DEDENT DEDENT print ( "" The ▁ number ▁ of ▁ zeros ▁ in ▁ array ▁ C ▁ is : "" , maxi + count ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 13 , 37 , 39 ] ; NEW_LINE b = [ 1 , 2 , 3 ] ; NEW_LINE n = len ( a ) ; NEW_LINE findDandZeros ( a , b , n ) ; NEW_LINE DEDENT +" +E1174,"class GFG { static int count_odd_pair ( int n , int a [ ] ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 0 ) even ++ ; else odd ++ ; } int ans = odd * even * 2 ; return ans ; } static int count_even_pair ( int odd_sum_pairs , int n ) { int total_pairs = ( n * ( n - 1 ) ) ; int ans = total_pairs - odd_sum_pairs ; return ans ; } public static void main ( String [ ] args ) { int n = 6 ; int [ ] a = { 2 , 4 , 5 , 9 , 1 , 8 } ; int odd_sum_pairs = count_odd_pair ( n , a ) ; int even_sum_pairs = count_even_pair ( odd_sum_pairs , n ) ; System . out . println ( "" Even ▁ Sum ▁ Pairs ▁ = ▁ "" + even_sum_pairs ) ; System . out . println ( "" Odd ▁ Sum ▁ Pairs = ▁ "" + odd_sum_pairs ) ; } } +","def count_odd_pair ( n , a ) : NEW_LINE INDENT odd = 0 NEW_LINE even = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( a [ i ] % 2 == 0 ) : NEW_LINE INDENT even = even + 1 NEW_LINE DEDENT else : NEW_LINE INDENT odd = odd + 1 NEW_LINE DEDENT DEDENT ans = odd * even * 2 NEW_LINE return ans NEW_LINE DEDENT def count_even_pair ( odd_sum_pairs , n ) : NEW_LINE INDENT total_pairs = ( n * ( n - 1 ) ) NEW_LINE ans = total_pairs - odd_sum_pairs NEW_LINE return ans NEW_LINE DEDENT n = 6 NEW_LINE a = [ 2 , 4 , 5 , 9 , 1 , 8 ] NEW_LINE odd_sum_pairs = count_odd_pair ( n , a ) NEW_LINE even_sum_pairs = count_even_pair ( odd_sum_pairs , n ) NEW_LINE print ( "" Even ▁ Sum ▁ Pairs ▁ = "" , even_sum_pairs ) NEW_LINE print ( "" Odd ▁ Sum ▁ Pairs = "" , odd_sum_pairs ) NEW_LINE +" +E1175,"import java . util . * ; class GFG { static void printQueries ( int n , int a [ ] , int q , int qry [ ] ) { HashSet < Integer > occ = new HashSet < > ( ) ; int [ ] suffixCount = new int [ n + 1 ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { occ . add ( a [ i ] ) ; suffixCount [ i + 1 ] = occ . size ( ) ; } for ( int i = 0 ; i < q ; i ++ ) System . out . println ( suffixCount [ qry [ i ] ] ) ; } public static void main ( String args [ ] ) { int n = 5 , q = 3 ; int a [ ] = { 2 , 4 , 6 , 10 , 2 } ; int qry [ ] = { 1 , 3 , 2 } ; printQueries ( n , a , q , qry ) ; } } +","def printQueries ( n , a , q , qry ) : NEW_LINE INDENT occ = dict ( ) NEW_LINE suffixCount = [ 0 for i in range ( n + 1 ) ] NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT occ [ a [ i ] ] = 1 NEW_LINE suffixCount [ i + 1 ] = len ( occ ) NEW_LINE DEDENT for i in range ( q ) : NEW_LINE INDENT print ( suffixCount [ qry [ i ] ] ) NEW_LINE DEDENT DEDENT n = 5 NEW_LINE q = 3 NEW_LINE a = [ 2 , 4 , 6 , 10 , 2 ] NEW_LINE qry = [ 1 , 3 , 2 ] NEW_LINE printQueries ( n , a , q , qry ) NEW_LINE +" +E1176,"import java . io . * ; class GFG { static int countRotations ( String n ) { int len = n . length ( ) ; if ( len == 1 ) { int oneDigit = n . charAt ( 0 ) - '0' ; if ( oneDigit % 4 == 0 ) return 1 ; return 0 ; } int twoDigit , count = 0 ; for ( int i = 0 ; i < ( len - 1 ) ; i ++ ) { twoDigit = ( n . charAt ( i ) - '0' ) * 10 + ( n . charAt ( i + 1 ) - '0' ) ; if ( twoDigit % 4 == 0 ) count ++ ; } twoDigit = ( n . charAt ( len - 1 ) - '0' ) * 10 + ( n . charAt ( 0 ) - '0' ) ; if ( twoDigit % 4 == 0 ) count ++ ; return count ; } public static void main ( String args [ ] ) { String n = ""4834"" ; System . out . println ( "" Rotations : ▁ "" + countRotations ( n ) ) ; } } +","def countRotations ( n ) : NEW_LINE INDENT l = len ( n ) NEW_LINE if ( l == 1 ) : NEW_LINE INDENT oneDigit = ( int ) ( n [ 0 ] ) NEW_LINE if ( oneDigit % 4 == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 0 NEW_LINE DEDENT count = 0 NEW_LINE for i in range ( 0 , l - 1 ) : NEW_LINE INDENT twoDigit = ( int ) ( n [ i ] ) * 10 + ( int ) ( n [ i + 1 ] ) NEW_LINE if ( twoDigit % 4 == 0 ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT DEDENT twoDigit = ( int ) ( n [ l - 1 ] ) * 10 + ( int ) ( n [ 0 ] ) NEW_LINE if ( twoDigit % 4 == 0 ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT return count NEW_LINE DEDENT n = ""4834"" NEW_LINE print ( "" Rotations : ▁ "" , countRotations ( n ) ) NEW_LINE +" +E1177,"import java . io . * ; import java . util . * ; class GFG { public static int smallestX ( int n ) { int [ ] temp = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) temp [ i ] = 0 ; if ( n == 0 ) return - 1 ; int count = 0 , x = 0 ; for ( x = 1 ; count < 10 ; x ++ ) { int y = x * n ; while ( y > 0 ) { if ( temp [ y % 10 ] == 0 ) { count ++ ; temp [ y % 10 ] = 1 ; } y /= 10 ; } } return x - 1 ; } public static void main ( String args [ ] ) { int n = 5 ; System . out . print ( smallestX ( n ) ) ; } } +","def smallestX ( n ) : NEW_LINE INDENT temp = [ 0 ] * 10 NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT count = 0 NEW_LINE x = 1 NEW_LINE while ( count < 10 ) : NEW_LINE INDENT y = x * n NEW_LINE while ( y > 0 ) : NEW_LINE INDENT if ( temp [ y % 10 ] == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE temp [ y % 10 ] = 1 NEW_LINE DEDENT y = int ( y / 10 ) NEW_LINE DEDENT x += 1 NEW_LINE DEDENT return x - 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE print ( smallestX ( n ) ) NEW_LINE DEDENT +" +E1178,"import java . io . * ; import java . util . HashMap ; import java . util . Map ; class GFG { static void distinctAdjacentElement ( int a [ ] , int n ) { HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( m . containsKey ( a [ i ] ) ) { int x = m . get ( a [ i ] ) + 1 ; m . put ( a [ i ] , x ) ; } else { m . put ( a [ i ] , 1 ) ; } } int mx = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( mx < m . get ( a [ i ] ) ) mx = m . get ( a [ i ] ) ; if ( mx > ( n + 1 ) / 2 ) System . out . println ( "" NO "" ) ; else System . out . println ( "" YES "" ) ; } public static void main ( String [ ] args ) { int a [ ] = { 7 , 7 , 7 , 7 } ; int n = 4 ; distinctAdjacentElement ( a , n ) ; } } +","def distantAdjacentElement ( a , n ) : NEW_LINE INDENT m = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] in m : NEW_LINE INDENT m [ a [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT m [ a [ i ] ] = 1 NEW_LINE DEDENT DEDENT mx = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if mx < m [ a [ i ] ] : NEW_LINE INDENT mx = m [ a [ i ] ] NEW_LINE DEDENT DEDENT if mx > ( n + 1 ) // 2 : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 7 , 7 , 7 , 7 ] NEW_LINE n = len ( a ) NEW_LINE distantAdjacentElement ( a , n ) NEW_LINE DEDENT +" +E1179,"import java . io . * ; class GFG { static int fnMod ( int n ) { int rem = n % 4 ; if ( rem == 0 || rem == 3 ) return 0 ; else if ( rem == 1 || rem == 2 ) return 1 ; return 0 ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . print ( fnMod ( n ) ) ; } } +","def fnMod ( n ) : NEW_LINE INDENT rem = n % 4 NEW_LINE if ( rem == 0 or rem == 3 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif ( rem == 1 or rem == 2 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 6 NEW_LINE print ( fnMod ( n ) ) NEW_LINE DEDENT +" +E1180,"class GFG { static boolean isRectangle ( int a , int b , int c , int d ) { if ( ( a ^ b ^ c ^ d ) != 0 ) return false ; else return true ; } public static void main ( String [ ] args ) { int a , b , c , d ; a = 3 ; b = 2 ; c = 3 ; d = 2 ; if ( isRectangle ( a , b , c , d ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isRectangle ( a , b , c , d ) : NEW_LINE INDENT if a ^ b ^ c ^ d : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT a , b , c , d = 3 , 2 , 3 , 2 NEW_LINE print ( "" Yes "" if isRectangle ( a , b , c , d ) else "" No "" ) NEW_LINE +" +E1181,"class GFG { static int merge ( int arr [ ] , int temp [ ] , int left , int mid , int right ) { int inv_count = 0 ; int i = left ; int j = mid ; int k = left ; while ( ( i <= mid - 1 ) && ( j <= right ) ) { if ( arr [ i ] <= arr [ j ] ) { temp [ k ++ ] = arr [ i ++ ] ; } else { temp [ k ++ ] = arr [ j ++ ] ; inv_count = inv_count + ( mid - i ) ; } } while ( i <= mid - 1 ) { temp [ k ++ ] = arr [ i ++ ] ; } while ( j <= right ) { temp [ k ++ ] = arr [ j ++ ] ; } for ( i = left ; i <= right ; i ++ ) { arr [ i ] = temp [ i ] ; } return inv_count ; } static int _mergeSort ( int arr [ ] , int temp [ ] , int left , int right ) { int mid , inv_count = 0 ; if ( right > left ) { mid = ( right + left ) / 2 ; inv_count = _mergeSort ( arr , temp , left , mid ) ; inv_count += _mergeSort ( arr , temp , mid + 1 , right ) ; inv_count += merge ( arr , temp , left , mid + 1 , right ) ; } return inv_count ; } static int mergeSort ( int arr [ ] , int array_size ) { int [ ] temp = new int [ array_size ] ; return _mergeSort ( arr , temp , 0 , array_size - 1 ) ; } static int minSwapToReachArr ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] - 1 ) - i > 2 ) { return - 1 ; } } int numOfInversion = mergeSort ( arr , N ) ; return numOfInversion ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 5 , 3 , 4 } ; int N = arr . length ; int res = minSwapToReachArr ( arr , N ) ; System . out . println ( res == - 1 ? "" Not ▁ Possible \n "" : res ) ; } } +","def merge ( arr , temp , left , mid , right ) : NEW_LINE INDENT inv_count = 0 NEW_LINE i = left NEW_LINE j = mid NEW_LINE k = left NEW_LINE while ( i <= mid - 1 ) and ( j <= right ) : NEW_LINE INDENT if arr [ i ] <= arr [ j ] : NEW_LINE INDENT temp [ k ] = arr [ i ] NEW_LINE k , i = k + 1 , i + 1 NEW_LINE DEDENT else : NEW_LINE INDENT temp [ k ] = arr [ j ] NEW_LINE k , j = k + 1 , j + 1 NEW_LINE inv_count = inv_count + ( mid - i ) NEW_LINE DEDENT DEDENT while i <= mid - 1 : NEW_LINE INDENT temp [ k ] = arr [ i ] NEW_LINE k , i = k + 1 , i + 1 NEW_LINE DEDENT while j <= right : NEW_LINE INDENT temp [ k ] = arr [ j ] NEW_LINE k , j = k + 1 , j + 1 NEW_LINE DEDENT for i in range ( left , right + 1 ) : NEW_LINE INDENT arr [ i ] = temp [ i ] NEW_LINE DEDENT return inv_count NEW_LINE DEDENT def _mergeSort ( arr , temp , left , right ) : NEW_LINE INDENT inv_count = 0 NEW_LINE if right > left : NEW_LINE INDENT mid = ( right + left ) // 2 NEW_LINE inv_count = _mergeSort ( arr , temp , left , mid ) NEW_LINE inv_count += _mergeSort ( arr , temp , mid + 1 , right ) NEW_LINE inv_count += merge ( arr , temp , left , mid + 1 , right ) NEW_LINE DEDENT return inv_count NEW_LINE DEDENT def mergeSort ( arr , array_size ) : NEW_LINE INDENT temp = [ None ] * array_size NEW_LINE return _mergeSort ( arr , temp , 0 , array_size - 1 ) NEW_LINE DEDENT def minSwapToReachArr ( arr , N ) : NEW_LINE INDENT for i in range ( 0 , N ) : NEW_LINE INDENT if ( arr [ i ] - 1 ) - i > 2 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT DEDENT numOfInversion = mergeSort ( arr , N ) NEW_LINE return numOfInversion NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 5 , 3 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE res = minSwapToReachArr ( arr , N ) NEW_LINE if res == - 1 : NEW_LINE INDENT print ( "" Not ▁ Possible "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( res ) NEW_LINE DEDENT DEDENT +" +E1182,"class GFG { static boolean Prime ( int n ) { if ( n < 2 ) return false ; for ( int i = 2 ; i <= ( int ) Math . sqrt ( n ) ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static boolean primeCountDivisors ( int n ) { if ( n < 2 ) return false ; for ( int i = 2 ; i <= ( int ) Math . sqrt ( n ) ; i ++ ) if ( n % i == 0 ) { long a = n , c = 0 ; while ( a % i == 0 ) { a /= i ; c ++ ; } if ( a == 1 && Prime ( ( int ) c + 1 ) == true ) return true ; else return false ; } return true ; } public static void main ( String [ ] args ) { int n = 13 ; if ( primeCountDivisors ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","from math import sqrt NEW_LINE def Prime ( n ) : NEW_LINE INDENT if ( n < 2 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT for i in range ( 2 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT return True ; NEW_LINE DEDENT def primeCountDivisors ( n ) : NEW_LINE INDENT if ( n < 2 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT for i in range ( 2 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT a = n ; c = 0 ; NEW_LINE while ( a % i == 0 ) : NEW_LINE INDENT a //= i ; NEW_LINE c += 1 ; NEW_LINE DEDENT if ( a == 1 and Prime ( c + 1 ) ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT else : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT DEDENT return True ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 13 ; NEW_LINE if ( primeCountDivisors ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E1183,"import java . util . * ; class GFG { static int countSubSeq ( int a [ ] , int n , int k ) { Arrays . sort ( a ) ; List < Integer > arr = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; ) { int count = 1 , x = a [ i ] ; i ++ ; while ( i < n && a [ i ] == x ) { count ++ ; i ++ ; } arr . add ( count ) ; } int m = arr . size ( ) ; n = Math . min ( m , k ) ; int count = 1 ; int [ ] [ ] dp = new int [ n + 1 ] [ m + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) dp [ 0 ] [ i ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = m ; j >= 0 ; j -- ) { if ( j > m - i ) dp [ i ] [ j ] = 0 ; else { dp [ i ] [ j ] = dp [ i ] [ j + 1 ] + arr . get ( j ) * dp [ i - 1 ] [ j + 1 ] ; } } count = count + dp [ i ] [ 0 ] ; } return count ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 2 , 3 , 3 , 5 } ; int n = a . length ; int k = 3 ; System . out . println ( countSubSeq ( a , n , k ) ) ; } } +","def countSubSeq ( a , n , k ) : NEW_LINE INDENT a . sort ( reverse = False ) NEW_LINE arr = [ ] NEW_LINE i = 0 NEW_LINE while ( i < n ) : NEW_LINE INDENT count = 1 NEW_LINE x = a [ i ] NEW_LINE i += 1 NEW_LINE while ( i < n and a [ i ] == x ) : NEW_LINE INDENT count += 1 NEW_LINE i += 1 NEW_LINE DEDENT arr . append ( count ) NEW_LINE DEDENT m = len ( arr ) NEW_LINE n = min ( m , k ) NEW_LINE count = 1 NEW_LINE dp = [ [ 0 for i in range ( m + 1 ) ] for j in range ( n + 1 ) ] NEW_LINE for i in range ( m + 1 ) : NEW_LINE INDENT dp [ 0 ] [ i ] = 1 NEW_LINE DEDENT for i in range ( 1 , n + 1 , 1 ) : NEW_LINE INDENT j = m NEW_LINE while ( j >= 0 ) : NEW_LINE INDENT if ( j > m - i ) : NEW_LINE INDENT dp [ i ] [ j ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = dp [ i ] [ j + 1 ] + \ NEW_LINE INDENT arr [ j ] * dp [ i - 1 ] [ j + 1 ] NEW_LINE DEDENT DEDENT j -= 1 NEW_LINE DEDENT count = count + dp [ i ] [ 0 ] NEW_LINE DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 2 , 2 , 3 , 3 , 5 ] NEW_LINE n = len ( a ) NEW_LINE k = 3 NEW_LINE print ( countSubSeq ( a , n , k ) ) NEW_LINE DEDENT +" +E1184,"class GFG { static boolean isVowel ( char ch ) { switch ( ch ) { case ' a ' : case ' e ' : case ' i ' : case ' o ' : case ' u ' : return true ; } return false ; } static boolean isSatisfied ( char [ ] str , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( ! isVowel ( str [ i ] ) && ! isVowel ( str [ i - 1 ] ) ) { return false ; } } for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( isVowel ( str [ i ] ) && ! isVowel ( str [ i - 1 ] ) && ! isVowel ( str [ i + 1 ] ) ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String str = "" acaba "" ; int n = str . length ( ) ; if ( isSatisfied ( str . toCharArray ( ) , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isVowel ( ch ) : NEW_LINE INDENT if ch in [ ' i ' , ' a ' , ' e ' , ' o ' , ' u ' ] : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT def isSatisfied ( st , n ) : NEW_LINE INDENT for i in range ( 1 , n ) : NEW_LINE INDENT if ( isVowel ( st [ i ] ) == False and isVowel ( st [ i - 1 ] ) == False ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT for i in range ( 1 , n - 1 ) : NEW_LINE INDENT if ( isVowel ( st [ i ] ) and isVowel ( st [ i - 1 ] ) == False and isVowel ( st [ i + 1 ] ) == False ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT st = "" acaba "" NEW_LINE n = len ( st ) NEW_LINE if ( isSatisfied ( st , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1185,"class GFG { static void equal_xor_sum ( int arr [ ] , int n ) { int Sum = 0 ; int Xor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { Sum = Sum + arr [ i ] ; Xor = Xor ^ arr [ i ] ; } if ( Sum == Xor ) System . out . println ( "" YES "" ) ; else System . out . println ( "" NO "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 3 , 7 , 10 } ; int n = arr . length ; equal_xor_sum ( arr , n ) ; } } +","def equal_xor_sum ( arr , n ) : NEW_LINE INDENT Sum = 0 ; NEW_LINE Xor = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT Sum = Sum + arr [ i ] ; NEW_LINE Xor = Xor ^ arr [ i ] ; NEW_LINE DEDENT if ( Sum == Xor ) : NEW_LINE INDENT print ( "" YES "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 6 , 3 , 7 , 10 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE equal_xor_sum ( arr , n ) ; NEW_LINE DEDENT +" +E1186,"import java . io . * ; class GFG { static int getMinLength ( double arr [ ] , int n ) { int count = 0 ; int result = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { count ++ ; } else { if ( count != 0 ) result = Math . min ( result , count ) ; count = 0 ; } } return result ; } public static void main ( String [ ] args ) { double arr [ ] = { 1 , 1 , 0 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 } ; int n = arr . length ; System . out . println ( getMinLength ( arr , n ) ) ; } } +","import sys NEW_LINE def getMinLength ( arr , n ) : NEW_LINE INDENT count = 0 ; NEW_LINE result = sys . maxsize ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] == 1 ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT if ( count != 0 ) : NEW_LINE INDENT result = min ( result , count ) ; NEW_LINE DEDENT count = 0 ; NEW_LINE DEDENT DEDENT return result ; NEW_LINE DEDENT arr = [ 1 , 1 , 0 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( getMinLength ( arr , n ) ) ; NEW_LINE +" +E1187,"class GFG { static boolean isPowerOfTwo ( int n ) { return ( n > 0 && ( ( n & ( n - 1 ) ) == 0 ) ) ? true : false ; } static int findPosition ( int n ) { if ( ! isPowerOfTwo ( n ) ) return - 1 ; int i = 1 , pos = 1 ; while ( ( i & n ) == 0 ) { i = i << 1 ; ++ pos ; } return pos ; } public static void main ( String [ ] args ) { int n = 16 ; int pos = findPosition ( n ) ; if ( pos == - 1 ) System . out . println ( "" n ▁ = ▁ "" + n + "" , ▁ Invalid ▁ number "" ) ; else System . out . println ( "" n ▁ = ▁ "" + n + "" , ▁ Position ▁ "" + pos ) ; n = 12 ; pos = findPosition ( n ) ; if ( pos == - 1 ) System . out . println ( "" n ▁ = ▁ "" + n + "" , ▁ Invalid ▁ number "" ) ; else System . out . println ( "" n ▁ = ▁ "" + n + "" , ▁ Position ▁ "" + pos ) ; n = 128 ; pos = findPosition ( n ) ; if ( pos == - 1 ) System . out . println ( "" n ▁ = ▁ "" + n + "" , ▁ Invalid ▁ number "" ) ; else System . out . println ( "" n ▁ = ▁ "" + n + "" , ▁ Position ▁ "" + pos ) ; } } +","def isPowerOfTwo ( n ) : NEW_LINE INDENT return ( True if ( n > 0 and ( ( n & ( n - 1 ) ) > 0 ) ) else False ) ; NEW_LINE DEDENT def findPosition ( n ) : NEW_LINE INDENT if ( isPowerOfTwo ( n ) == True ) : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT i = 1 ; NEW_LINE pos = 1 ; NEW_LINE while ( ( i & n ) == 0 ) : NEW_LINE INDENT i = i << 1 ; NEW_LINE pos += 1 ; NEW_LINE DEDENT return pos ; NEW_LINE DEDENT n = 16 ; NEW_LINE pos = findPosition ( n ) ; NEW_LINE if ( pos == - 1 ) : NEW_LINE INDENT print ( "" n ▁ = "" , n , "" , ▁ Invalid ▁ number "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" n ▁ = "" , n , "" , ▁ Position ▁ "" , pos ) ; NEW_LINE DEDENT n = 12 ; NEW_LINE pos = findPosition ( n ) ; NEW_LINE if ( pos == - 1 ) : NEW_LINE INDENT print ( "" n ▁ = "" , n , "" , ▁ Invalid ▁ number "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" n ▁ = "" , n , "" , ▁ Position ▁ "" , pos ) ; NEW_LINE DEDENT n = 128 ; NEW_LINE pos = findPosition ( n ) ; NEW_LINE if ( pos == - 1 ) : NEW_LINE INDENT print ( "" n ▁ = "" , n , "" , ▁ Invalid ▁ number "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" n ▁ = "" , n , "" , ▁ Position ▁ "" , pos ) ; NEW_LINE DEDENT +" +E1188,"import java . io . * ; public class GFG { static int totalNumber ( int n ) { return 8 * ( int ) Math . pow ( 9 , n - 1 ) ; } static public void main ( String [ ] args ) { int n = 3 ; System . out . println ( totalNumber ( n ) ) ; } } +","def totalNumber ( n ) : NEW_LINE INDENT return 8 * pow ( 9 , n - 1 ) ; NEW_LINE DEDENT n = 3 NEW_LINE print ( totalNumber ( n ) ) NEW_LINE +" +E1189,"class GFG { static int rev_num = 0 ; static int base_pos = 1 ; static int reversDigits ( int num ) { if ( num > 0 ) { reversDigits ( num / 10 ) ; rev_num += ( num % 10 ) * base_pos ; base_pos *= 10 ; } return rev_num ; } public static void main ( String [ ] args ) { int num = 4562 ; System . out . println ( reversDigits ( num ) ) ; } } +","rev_num = 0 NEW_LINE base_pos = 1 NEW_LINE def reversDigits ( num ) : NEW_LINE INDENT global rev_num NEW_LINE global base_pos NEW_LINE if ( num > 0 ) : NEW_LINE INDENT reversDigits ( ( int ) ( num / 10 ) ) NEW_LINE rev_num += ( num % 10 ) * base_pos NEW_LINE base_pos *= 10 NEW_LINE DEDENT return rev_num NEW_LINE DEDENT num = 4562 NEW_LINE print ( "" Reverse ▁ of ▁ no . ▁ is ▁ "" , reversDigits ( num ) ) NEW_LINE +" +E1190,"import java . util . * ; class GfG { static boolean check ( char s [ ] ) { int l = s . length ; Arrays . sort ( s ) ; for ( int i = 1 ; i < l ; i ++ ) { if ( s [ i ] - s [ i - 1 ] != 1 ) return false ; } return true ; } public static void main ( String [ ] args ) { String str = "" dcef "" ; if ( check ( str . toCharArray ( ) ) == true ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; String str1 = "" xyza "" ; if ( check ( str1 . toCharArray ( ) ) == true ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def check ( s ) : NEW_LINE INDENT l = len ( s ) NEW_LINE s = ' ' . join ( sorted ( s ) ) NEW_LINE for i in range ( 1 , l ) : NEW_LINE INDENT if ord ( s [ i ] ) - ord ( s [ i - 1 ] ) != 1 : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" dcef "" NEW_LINE if check ( string ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT string = "" xyza "" NEW_LINE if check ( string ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1191,"class GFG { static void maxRegions ( int n ) { int num ; num = n * ( n + 1 ) / 2 + 1 ; System . out . println ( num ) ; ; } public static void main ( String [ ] args ) { int n = 10 ; maxRegions ( n ) ; } } +","def maxRegions ( n ) : NEW_LINE INDENT num = n * ( n + 1 ) // 2 + 1 NEW_LINE print ( num ) NEW_LINE DEDENT n = 10 NEW_LINE maxRegions ( n ) NEW_LINE +" +E1192,"import java . io . * ; import static java . lang . Math . pow ; public class A { static void bestApproximate ( int x [ ] , int y [ ] ) { int n = x . length ; double m , c , sum_x = 0 , sum_y = 0 , sum_xy = 0 , sum_x2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum_x += x [ i ] ; sum_y += y [ i ] ; sum_xy += x [ i ] * y [ i ] ; sum_x2 += pow ( x [ i ] , 2 ) ; } m = ( n * sum_xy - sum_x * sum_y ) / ( n * sum_x2 - pow ( sum_x , 2 ) ) ; c = ( sum_y - m * sum_x ) / n ; System . out . println ( "" m ▁ = ▁ "" + m ) ; System . out . println ( "" c ▁ = ▁ "" + c ) ; } public static void main ( String args [ ] ) { int x [ ] = { 1 , 2 , 3 , 4 , 5 } ; int y [ ] = { 14 , 27 , 40 , 55 , 68 } ; bestApproximate ( x , y ) ; } } +","def bestApproximate ( x , y , n ) : NEW_LINE INDENT sum_x = 0 NEW_LINE sum_y = 0 NEW_LINE sum_xy = 0 NEW_LINE sum_x2 = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sum_x += x [ i ] NEW_LINE sum_y += y [ i ] NEW_LINE sum_xy += x [ i ] * y [ i ] NEW_LINE sum_x2 += pow ( x [ i ] , 2 ) NEW_LINE DEDENT m = ( float ) ( ( n * sum_xy - sum_x * sum_y ) / ( n * sum_x2 - pow ( sum_x , 2 ) ) ) ; NEW_LINE c = ( float ) ( sum_y - m * sum_x ) / n ; NEW_LINE print ( "" m ▁ = ▁ "" , m ) ; NEW_LINE print ( "" c ▁ = ▁ "" , c ) ; NEW_LINE DEDENT x = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE y = [ 14 , 27 , 40 , 55 , 68 ] NEW_LINE n = len ( x ) NEW_LINE bestApproximate ( x , y , n ) NEW_LINE +" +E1193,"import java . util . TreeSet ; class GFG { static void printPrevGreater ( int [ ] arr , int n ) { TreeSet < Integer > ts = new TreeSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Integer c = ts . ceiling ( arr [ i ] ) ; if ( c == null ) System . out . print ( - 1 + "" ▁ "" ) ; else System . out . print ( c + "" ▁ "" ) ; ts . add ( arr [ i ] ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 10 , 5 , 11 , 10 , 20 , 12 } ; int n = arr . length ; printPrevGreater ( arr , n ) ; } } +","def printPrevGreater ( arr , n ) : NEW_LINE INDENT s = set ( ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT it = [ x for x in s if x >= arr [ i ] ] NEW_LINE if len ( it ) == 0 : NEW_LINE INDENT print ( "" - 1"" , end = "" ▁ "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( min ( it ) , end = "" ▁ "" ) NEW_LINE DEDENT s . add ( arr [ i ] ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 10 , 5 , 11 , 10 , 20 , 12 ] NEW_LINE n = len ( arr ) NEW_LINE printPrevGreater ( arr , n ) NEW_LINE DEDENT +" +E1194,"import java . util . * ; class GFG { static int MAX = 1000005 ; static Vector < Boolean > prime = new Vector < > ( MAX ) ; static void vecIni ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { prime . add ( i , true ) ; } } static void seive ( int N ) { prime . add ( 0 , false ) ; prime . add ( 1 , false ) ; for ( int i = 2 ; i <= N ; i ++ ) { if ( prime . get ( i ) ) { for ( int j = 2 ; i * j <= N ; j ++ ) { prime . add ( i * j , false ) ; } } } } static int countLogNeeded ( int N ) { int count = 0 ; seive ( N ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( prime . get ( i ) ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { vecIni ( ) ; int N = 6 ; System . out . println ( countLogNeeded ( N ) ) ; } } +","MAX = 1000005 NEW_LINE prime = [ True for i in range ( MAX ) ] NEW_LINE def seive ( N ) : NEW_LINE INDENT prime [ 0 ] , prime [ 1 ] = False , False NEW_LINE for i in range ( 2 , N + 1 ) : NEW_LINE INDENT if ( prime [ i ] ) : NEW_LINE INDENT for j in range ( 2 , N + 1 ) : NEW_LINE INDENT if ( i * j > N ) : NEW_LINE INDENT break NEW_LINE DEDENT prime [ i * j ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def countLogNeeded ( N ) : NEW_LINE INDENT count = 0 NEW_LINE seive ( N ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT if ( prime [ i ] ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 6 NEW_LINE print ( countLogNeeded ( N ) ) NEW_LINE DEDENT +" +E1195,"import java . util . * ; class GFG { static void findMinimumOperation ( int n , int d , int arrays [ ] [ ] ) { int cnt = 0 ; int first = Integer . MIN_VALUE , end = Integer . MAX_VALUE ; while ( n > 0 ) { int arr [ ] = { arrays [ cnt ] [ 0 ] , arrays [ cnt ] [ 1 ] } ; Arrays . sort ( arr ) ; first = Math . max ( first , arr [ 0 ] ) ; end = Math . min ( end , arr [ 1 ] ) ; cnt ++ ; n -- ; } if ( first > end ) System . out . print ( "" - 1"" ) ; else { if ( d >= first && d <= end ) { System . out . print ( ""0"" ) ; } else System . out . print ( Math . min ( Math . abs ( first - d ) , Math . abs ( d - end ) ) ) ; } } public static void main ( String [ ] args ) { int n = 3 , d = 3 ; int arrays [ ] [ ] = { { 0 , 7 } , { 2 , 14 } , { 4 , 6 } } ; findMinimumOperation ( n , d , arrays ) ; } } +","def findMinimumOperation ( n , d , arrays ) : NEW_LINE INDENT cnt = 0 NEW_LINE first = - 10 ** 9 NEW_LINE end = 10 ** 9 NEW_LINE while ( n ) : NEW_LINE INDENT arr = [ arrays [ cnt ] [ 0 ] , arrays [ cnt ] [ 1 ] ] NEW_LINE arr = sorted ( arr ) NEW_LINE first = max ( first , arr [ 0 ] ) NEW_LINE end = min ( end , arr [ 1 ] ) NEW_LINE cnt += 1 NEW_LINE n -= 1 NEW_LINE DEDENT if ( first > end ) : NEW_LINE INDENT print ( "" - 1"" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT if ( d >= first and d <= end ) : NEW_LINE INDENT print ( ""0"" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( min ( abs ( first - d ) , abs ( d - end ) ) , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE d = 3 NEW_LINE arrays = [ [ 0 , 7 ] , [ 2 , 14 ] , [ 4 , 6 ] ] NEW_LINE findMinimumOperation ( n , d , arrays ) NEW_LINE DEDENT +" +E1196,"class GFG { static int MAX = 90 ; public static void main ( String [ ] args ) { long [ ] arr = new long [ MAX ] ; long [ ] index1 = new long [ MAX ] ; long [ ] index2 = new long [ MAX ] ; long [ ] index3 = new long [ MAX ] ; long [ ] index4 = new long [ MAX ] ; arr [ 0 ] = 0 ; arr [ 1 ] = 1 ; for ( int i = 2 ; i < MAX ; i ++ ) arr [ i ] = arr [ i - 1 ] + arr [ i - 2 ] ; int c1 = 0 , c2 = 0 , c3 = 0 , c4 = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( arr [ i ] % 2 == 0 ) index1 [ c1 ++ ] = i ; if ( arr [ i ] % 3 == 0 ) index2 [ c2 ++ ] = i ; if ( arr [ i ] % 5 == 0 ) index3 [ c3 ++ ] = i ; if ( arr [ i ] % 8 == 0 ) index4 [ c4 ++ ] = i ; } System . out . print ( "" Index ▁ of ▁ Fibonacci ▁ numbers ▁ divisible ▁ by "" + "" ▁ 2 ▁ are ▁ : \n "" ) ; for ( int i = 0 ; i < c1 ; i ++ ) System . out . print ( index1 [ i ] + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; System . out . print ( "" Index ▁ of ▁ Fibonacci ▁ number ▁ divisible ▁ by "" + "" ▁ 3 ▁ are ▁ : \n "" ) ; for ( int i = 0 ; i < c2 ; i ++ ) System . out . print ( index2 [ i ] + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; System . out . print ( "" Index ▁ of ▁ Fibonacci ▁ number ▁ divisible ▁ by "" + "" ▁ 5 ▁ are ▁ : \n "" ) ; for ( int i = 0 ; i < c3 ; i ++ ) System . out . print ( index3 [ i ] + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; System . out . print ( "" Index ▁ of ▁ Fibonacci ▁ number ▁ divisible ▁ by "" + "" ▁ 8 ▁ are ▁ : \n "" ) ; for ( int i = 0 ; i < c4 ; i ++ ) System . out . print ( index4 [ i ] + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; } } +","MAX = 90 ; NEW_LINE arr = [ 0 ] * ( MAX ) ; NEW_LINE index1 = [ 0 ] * ( MAX ) ; NEW_LINE index2 = [ 0 ] * ( MAX ) ; NEW_LINE index3 = [ 0 ] * ( MAX ) ; NEW_LINE index4 = [ 0 ] * ( MAX ) ; NEW_LINE arr [ 0 ] = 0 ; NEW_LINE arr [ 1 ] = 1 ; NEW_LINE for i in range ( 2 , MAX ) : NEW_LINE INDENT arr [ i ] = arr [ i - 1 ] + arr [ i - 2 ] ; NEW_LINE DEDENT c1 , c2 , c3 , c4 = 0 , 0 , 0 , 0 ; NEW_LINE for i in range ( MAX ) : NEW_LINE INDENT if ( arr [ i ] % 2 == 0 ) : NEW_LINE INDENT index1 [ c1 ] = i ; NEW_LINE c1 += 1 ; NEW_LINE DEDENT if ( arr [ i ] % 3 == 0 ) : NEW_LINE INDENT index2 [ c2 ] = i ; NEW_LINE c2 += 1 ; NEW_LINE DEDENT if ( arr [ i ] % 5 == 0 ) : NEW_LINE INDENT index3 [ c3 ] = i ; NEW_LINE c3 += 1 ; NEW_LINE DEDENT if ( arr [ i ] % 8 == 0 ) : NEW_LINE INDENT index4 [ c4 ] = i ; NEW_LINE c4 += 1 ; NEW_LINE DEDENT DEDENT print ( "" Index ▁ of ▁ Fibonacci ▁ numbers "" , "" divisible ▁ by ▁ 2 ▁ are ▁ : "" ) ; NEW_LINE for i in range ( c1 ) : NEW_LINE INDENT print ( index1 [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE print ( "" Index ▁ of ▁ Fibonacci ▁ number "" , "" divisible ▁ by ▁ 3 ▁ are ▁ : "" ) ; NEW_LINE for i in range ( c2 ) : NEW_LINE INDENT print ( index2 [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE print ( "" Index ▁ of ▁ Fibonacci ▁ number "" , "" divisible ▁ by ▁ 5 ▁ are ▁ : "" ) ; NEW_LINE for i in range ( c3 ) : NEW_LINE INDENT print ( index3 [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE print ( "" Index ▁ of ▁ Fibonacci ▁ number "" , "" divisible ▁ by ▁ 8 ▁ are ▁ : "" ) ; NEW_LINE for i in range ( c4 ) : NEW_LINE INDENT print ( index4 [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE +" +E1197,"class GFG { static boolean check ( String s ) { int [ ] freq = new int [ 26 ] ; int n = s . length ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { freq [ ( s . charAt ( i ) ) - 97 ] += 1 ; } for ( int i = 0 ; i < freq . length ; i ++ ) { if ( freq [ i ] % 2 == 1 ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String s = "" abaccaba "" ; if ( check ( s ) ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","def check ( s ) : NEW_LINE INDENT freq = [ 0 ] * 26 NEW_LINE n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT freq [ ord ( s [ i ] ) - 97 ] += 1 NEW_LINE DEDENT for i in range ( 26 ) : NEW_LINE INDENT if ( freq [ i ] % 2 == 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT s = "" abaccaba "" NEW_LINE if ( check ( s ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1198,"public class GFG { static class Pair { int min ; int max ; } static Pair getMinMax ( int arr [ ] , int low , int high ) { Pair minmax = new Pair ( ) ; Pair mml = new Pair ( ) ; Pair mmr = new Pair ( ) ; int mid ; if ( low == high ) { minmax . max = arr [ low ] ; minmax . min = arr [ low ] ; return minmax ; } if ( high == low + 1 ) { if ( arr [ low ] > arr [ high ] ) { minmax . max = arr [ low ] ; minmax . min = arr [ high ] ; } else { minmax . max = arr [ high ] ; minmax . min = arr [ low ] ; } return minmax ; } mid = ( low + high ) / 2 ; mml = getMinMax ( arr , low , mid ) ; mmr = getMinMax ( arr , mid + 1 , high ) ; if ( mml . min < mmr . min ) { minmax . min = mml . min ; } else { minmax . min = mmr . min ; } if ( mml . max > mmr . max ) { minmax . max = mml . max ; } else { minmax . max = mmr . max ; } return minmax ; } public static void main ( String args [ ] ) { int arr [ ] = { 1000 , 11 , 445 , 1 , 330 , 3000 } ; int arr_size = 6 ; Pair minmax = getMinMax ( arr , 0 , arr_size - 1 ) ; System . out . printf ( "" \n Minimum ▁ element ▁ is ▁ % d "" , minmax . min ) ; System . out . printf ( "" \n Maximum ▁ element ▁ is ▁ % d "" , minmax . max ) ; } } +","def getMinMax ( low , high , arr ) : NEW_LINE INDENT arr_max = arr [ low ] NEW_LINE arr_min = arr [ low ] NEW_LINE if low == high : NEW_LINE INDENT arr_max = arr [ low ] NEW_LINE arr_min = arr [ low ] NEW_LINE return ( arr_max , arr_min ) NEW_LINE DEDENT elif high == low + 1 : NEW_LINE INDENT if arr [ low ] > arr [ high ] : NEW_LINE INDENT arr_max = arr [ low ] NEW_LINE arr_min = arr [ high ] NEW_LINE DEDENT else : NEW_LINE INDENT arr_max = arr [ high ] NEW_LINE arr_min = arr [ low ] NEW_LINE DEDENT return ( arr_max , arr_min ) NEW_LINE DEDENT else : NEW_LINE INDENT mid = int ( ( low + high ) / 2 ) NEW_LINE arr_max1 , arr_min1 = getMinMax ( low , mid , arr ) NEW_LINE arr_max2 , arr_min2 = getMinMax ( mid + 1 , high , arr ) NEW_LINE DEDENT return ( max ( arr_max1 , arr_max2 ) , min ( arr_min1 , arr_min2 ) ) NEW_LINE DEDENT arr = [ 1000 , 11 , 445 , 1 , 330 , 3000 ] NEW_LINE high = len ( arr ) - 1 NEW_LINE low = 0 NEW_LINE arr_max , arr_min = getMinMax ( low , high , arr ) NEW_LINE print ( ' Minimum ▁ element ▁ is ▁ ' , arr_min ) NEW_LINE print ( ' nMaximum ▁ element ▁ is ▁ ' , arr_max ) NEW_LINE +" +E1199,"import java . util . LinkedList ; import java . util . Queue ; class GFG { public static int countUnvisited ( int n , int m ) { int X = ( m * n ) - m - n ; Queue < Integer > queue = new LinkedList < > ( ) ; queue . add ( X ) ; int count = 0 ; while ( ! queue . isEmpty ( ) ) { int curr = queue . poll ( ) ; count ++ ; if ( curr - m > 0 ) queue . add ( curr - m ) ; if ( curr - n > 0 ) queue . add ( curr - n ) ; } return count ; } public static void main ( String args [ ] ) { int n = 2 , m = 5 ; System . out . print ( countUnvisited ( n , m ) ) ; } } +","def countUnvisited ( n , m ) : NEW_LINE INDENT i = 0 NEW_LINE X = ( m * n ) - m - n NEW_LINE queue = [ ] NEW_LINE queue . append ( X ) NEW_LINE count = 0 NEW_LINE while ( len ( queue ) > 0 ) : NEW_LINE INDENT curr = queue [ 0 ] NEW_LINE queue . remove ( queue [ 0 ] ) NEW_LINE count += 1 NEW_LINE if ( curr - m > 0 ) : NEW_LINE INDENT queue . append ( curr - m ) NEW_LINE DEDENT if ( curr - n > 0 ) : NEW_LINE INDENT queue . append ( curr - n ) NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 2 NEW_LINE m = 5 NEW_LINE print ( countUnvisited ( n , m ) ) NEW_LINE DEDENT +" +E1200,"class Alpha { private int ch ; void uppercaseAlphabets ( ) { for ( int c = 65 ; c <= 90 ; ++ c ) System . out . print ( "" ▁ "" + c ) ; System . out . print ( "" \n "" ) ; } void lowercaseAlphabets ( ) { for ( int c = 97 ; c <= 122 ; ++ c ) System . out . print ( "" ▁ "" + c ) ; System . out . print ( "" \n "" ) ; } public static void main ( String [ ] args ) { int ch ; System . out . println ( "" Uppercase ▁ Alphabets "" ) ; Alpha ob = new Alpha ( ) ; ob . uppercaseAlphabets ( ) ; System . out . println ( "" Lowercase ▁ Alphabets ▁ "" ) ; ob . lowercaseAlphabets ( ) ; } } +","def lowercaseAlphabets ( ) : NEW_LINE INDENT for c in range ( 97 , 123 ) : NEW_LINE INDENT print ( chr ( c ) , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE DEDENT def uppercaseAlphabets ( ) : NEW_LINE INDENT for c in range ( 65 , 91 ) : NEW_LINE INDENT print ( chr ( c ) , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE DEDENT print ( "" Uppercase ▁ Alphabets "" ) ; NEW_LINE uppercaseAlphabets ( ) ; NEW_LINE print ( "" Lowercase ▁ Alphabets ▁ "" ) ; NEW_LINE lowercaseAlphabets ( ) ; NEW_LINE +" +E1201,"class GFG { static int countNums ( int a , int b , int c , int d ) { int x = b / c - ( a - 1 ) / c ; int y = b / d - ( a - 1 ) / d ; int k = ( c * d ) / __gcd ( c , d ) ; int z = b / k - ( a - 1 ) / k ; return b - a + 1 - x - y + z ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 50 , c = 4 , d = 6 ; System . out . println ( countNums ( a , b , c , d ) ) ; } } +","from math import gcd NEW_LINE def countNums ( a , b , c , d ) : NEW_LINE INDENT x = b // c - ( a - 1 ) // c ; NEW_LINE y = b // d - ( a - 1 ) // d ; NEW_LINE k = ( c * d ) // gcd ( c , d ) ; NEW_LINE z = b // k - ( a - 1 ) // k ; NEW_LINE return ( b - a + 1 - x - y + z ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 10 ; b = 50 ; c = 4 ; d = 6 ; NEW_LINE print ( countNums ( a , b , c , d ) ) ; NEW_LINE DEDENT +" +E1202,"import java . io . * ; class GFG { static int countSubarray ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = i ; j < n ; j ++ ) { if ( sum + arr [ j ] < k ) { sum = arr [ j ] + sum ; count ++ ; } else { break ; } } } return count ; } public static void main ( String [ ] args ) { int array [ ] = { 1 , 11 , 2 , 3 , 15 } ; int k = 10 ; int size = array . length ; int count = countSubarray ( array , size , k ) ; System . out . println ( count ) ; } } +","def countSubarray ( arr , n , k ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sum = 0 ; NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT if ( sum + arr [ j ] < k ) : NEW_LINE INDENT sum = arr [ j ] + sum NEW_LINE count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT return count ; NEW_LINE DEDENT array = [ 1 , 11 , 2 , 3 , 15 ] NEW_LINE k = 10 NEW_LINE size = len ( array ) NEW_LINE count = countSubarray ( array , size , k ) ; NEW_LINE print ( count ) NEW_LINE +" +E1203,"import java . io . * ; class GFG { static void printPattern ( int n ) { if ( n == 0 || n < 0 ) { System . out . print ( n + "" ▁ "" ) ; return ; } System . out . print ( n + "" ▁ "" ) ; printPattern ( n - 5 ) ; System . out . print ( n + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int n = 16 ; printPattern ( n ) ; } } +","def printPattern ( n ) : NEW_LINE INDENT if ( n == 0 or n < 0 ) : NEW_LINE INDENT print ( n , end = "" , ▁ "" ) NEW_LINE return NEW_LINE DEDENT print ( n , end = "" , ▁ "" ) NEW_LINE printPattern ( n - 5 ) NEW_LINE print ( n , end = "" , ▁ "" ) NEW_LINE DEDENT n = 16 NEW_LINE printPattern ( n ) NEW_LINE +" +E1204,"import java . io . * ; class GFG { int MAX = 100 ; static int countCommon ( int mat [ ] [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( mat [ i ] [ i ] == mat [ i ] [ n - i - 1 ] ) res ++ ; return res ; } public static void main ( String args [ ] ) throws IOException { int mat [ ] [ ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; System . out . println ( countCommon ( mat , 3 ) ) ; } } +","Max = 100 NEW_LINE def countCommon ( mat , n ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if mat [ i ] [ i ] == mat [ i ] [ n - i - 1 ] : NEW_LINE INDENT res = res + 1 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT mat = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] NEW_LINE print ( countCommon ( mat , 3 ) ) NEW_LINE +" +E1205,"import java . util . * ; class GFG { static int getMinimumOps ( Vector < Integer > ar ) { int n = ar . size ( ) ; int small = Collections . min ( ar ) ; int large = Collections . max ( ar ) ; int [ ] [ ] dp = new int [ n ] [ large + 1 ] ; for ( int j = small ; j <= large ; j ++ ) { dp [ 0 ] [ j ] = Math . abs ( ar . get ( 0 ) - j ) ; } for ( int i = 1 ; i < n ; i ++ ) { int minimum = Integer . MAX_VALUE ; for ( int j = small ; j <= large ; j ++ ) { minimum = Math . min ( minimum , dp [ i - 1 ] [ j ] ) ; dp [ i ] [ j ] = minimum + Math . abs ( ar . get ( i ) - j ) ; } } int ans = Integer . MAX_VALUE ; for ( int j = small ; j <= large ; j ++ ) { ans = Math . min ( ans , dp [ n - 1 ] [ j ] ) ; } return ans ; } public static void main ( String [ ] args ) { Integer [ ] arr = { 1 , 2 , 1 , 4 , 3 } ; Vector < Integer > ar = new Vector < > ( Arrays . asList ( arr ) ) ; System . out . println ( getMinimumOps ( ar ) ) ; } } +","def getMinimumOps ( ar ) : NEW_LINE INDENT n = len ( ar ) NEW_LINE small = min ( ar ) NEW_LINE large = max ( ar ) NEW_LINE dp = [ [ 0 for i in range ( large + 1 ) ] for i in range ( n ) ] NEW_LINE for j in range ( small , large + 1 ) : NEW_LINE INDENT dp [ 0 ] [ j ] = abs ( ar [ 0 ] - j ) NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT minimum = 10 ** 9 NEW_LINE for j in range ( small , large + 1 ) : NEW_LINE INDENT minimum = min ( minimum , dp [ i - 1 ] [ j ] ) NEW_LINE dp [ i ] [ j ] = minimum + abs ( ar [ i ] - j ) NEW_LINE DEDENT DEDENT ans = 10 ** 9 NEW_LINE for j in range ( small , large + 1 ) : NEW_LINE INDENT ans = min ( ans , dp [ n - 1 ] [ j ] ) NEW_LINE DEDENT return ans NEW_LINE DEDENT ar = [ 1 , 2 , 1 , 4 , 3 ] NEW_LINE print ( getMinimumOps ( ar ) ) NEW_LINE +" +E1206,"class GFG { static boolean find ( String s1 , String s2 ) { int len = s1 . length ( ) , len_1 = s2 . length ( ) ; if ( len != len_1 ) { return false ; } int d [ ] = new int [ len ] ; d [ 0 ] = s2 . charAt ( 0 ) - s1 . charAt ( 0 ) ; for ( int i = 1 ; i < len ; i ++ ) { if ( s1 . charAt ( i ) > s2 . charAt ( i ) ) { return false ; } else { d [ i ] = s2 . charAt ( i ) - s1 . charAt ( i ) ; } } for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( d [ i ] < d [ i + 1 ] ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String s1 = "" abcd "" , s2 = "" bcdd "" ; if ( find ( s1 , s2 ) ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","def find ( s1 , s2 ) : NEW_LINE INDENT len__ = len ( s1 ) NEW_LINE len_1 = len ( s2 ) NEW_LINE if ( len__ != len_1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT d = [ 0 for i in range ( len__ ) ] NEW_LINE d [ 0 ] = ord ( s2 [ 0 ] ) - ord ( s1 [ 0 ] ) NEW_LINE for i in range ( 1 , len__ , 1 ) : NEW_LINE INDENT if ( s1 [ i ] > s2 [ i ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT else : NEW_LINE INDENT d [ i ] = ord ( s2 [ i ] ) - ord ( s1 [ i ] ) NEW_LINE DEDENT DEDENT for i in range ( len__ - 1 ) : NEW_LINE INDENT if ( d [ i ] < d [ i + 1 ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s1 = "" abcd "" NEW_LINE s2 = "" bcdd "" NEW_LINE if ( find ( s1 , s2 ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1207,"import java . util . HashMap ; import java . util . Map ; class GFG { static int solveQuery ( int start , int end , int arr [ ] ) { Map < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = start ; i <= end ; i ++ ) mp . put ( arr [ i ] , mp . get ( arr [ i ] ) == null ? 1 : mp . get ( arr [ i ] ) + 1 ) ; int count = 0 ; for ( Map . Entry < Integer , Integer > entry : mp . entrySet ( ) ) if ( entry . getKey ( ) == entry . getValue ( ) ) count ++ ; return count ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 2 , 3 , 3 , 3 } ; int n = A . length ; int [ ] [ ] queries = { { 0 , 1 } , { 1 , 1 } , { 0 , 2 } , { 1 , 3 } , { 3 , 5 } , { 0 , 5 } } ; int q = queries . length ; for ( int i = 0 ; i < q ; i ++ ) { int start = queries [ i ] [ 0 ] ; int end = queries [ i ] [ 1 ] ; System . out . println ( "" Answer ▁ for ▁ Query ▁ "" + ( i + 1 ) + "" ▁ = ▁ "" + solveQuery ( start , end , A ) ) ; } } } +","import math as mt NEW_LINE def solveQuery ( start , end , arr ) : NEW_LINE INDENT frequency = dict ( ) NEW_LINE for i in range ( start , end + 1 ) : NEW_LINE INDENT if arr [ i ] in frequency . keys ( ) : NEW_LINE INDENT frequency [ arr [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT frequency [ arr [ i ] ] = 1 NEW_LINE DEDENT DEDENT count = 0 NEW_LINE for x in frequency : NEW_LINE INDENT if x == frequency [ x ] : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT A = [ 1 , 2 , 2 , 3 , 3 , 3 ] NEW_LINE n = len ( A ) NEW_LINE queries = [ [ 0 , 1 ] , [ 1 , 1 ] , [ 0 , 2 ] , [ 1 , 3 ] , [ 3 , 5 ] , [ 0 , 5 ] ] NEW_LINE q = len ( queries ) NEW_LINE for i in range ( q ) : NEW_LINE INDENT start = queries [ i ] [ 0 ] NEW_LINE end = queries [ i ] [ 1 ] NEW_LINE print ( "" Answer ▁ for ▁ Query ▁ "" , ( i + 1 ) , "" ▁ = ▁ "" , solveQuery ( start , end , A ) ) NEW_LINE DEDENT +" +E1208,"class GFG { static int solve ( int N , int K ) { int [ ] combo ; combo = new int [ 50 ] ; combo [ 0 ] = 1 ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 0 ; j <= N ; j ++ ) { if ( j >= i ) { combo [ j ] += combo [ j - i ] ; } } } return combo [ N ] ; } public static void main ( String args [ ] ) { int N = 29 ; int K = 5 ; System . out . println ( solve ( N , K ) ) ; solve ( N , K ) ; } } +","def solve ( N , K ) : NEW_LINE INDENT combo = [ 0 ] * ( N + 1 ) NEW_LINE combo [ 0 ] = 1 NEW_LINE for i in range ( 1 , K + 1 ) : NEW_LINE INDENT for j in range ( 0 , N + 1 ) : NEW_LINE INDENT if j >= i : NEW_LINE INDENT combo [ j ] += combo [ j - i ] NEW_LINE DEDENT DEDENT DEDENT return combo [ N ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N , K = 29 , 5 NEW_LINE print ( solve ( N , K ) ) NEW_LINE DEDENT +" +E1209,"import java . util . Vector ; class GFG { static int deno [ ] = { 1 , 2 , 5 , 10 , 20 , 50 , 100 , 500 , 1000 } ; static int n = deno . length ; static void findMin ( int V ) { Vector < Integer > ans = new Vector < > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { while ( V >= deno [ i ] ) { V -= deno [ i ] ; ans . add ( deno [ i ] ) ; } } for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { System . out . print ( "" ▁ "" + ans . elementAt ( i ) ) ; } } public static void main ( String [ ] args ) { int n = 93 ; System . out . print ( "" Following ▁ is ▁ minimal ▁ number ▁ of ▁ change ▁ for ▁ "" + n + "" : ▁ "" ) ; findMin ( n ) ; } } +","def findMin ( V ) : NEW_LINE INDENT deno = [ 1 , 2 , 5 , 10 , 20 , 50 , 100 , 500 , 1000 ] NEW_LINE n = len ( deno ) NEW_LINE ans = [ ] NEW_LINE i = n - 1 NEW_LINE while ( i >= 0 ) : NEW_LINE INDENT while ( V >= deno [ i ] ) : NEW_LINE INDENT V -= deno [ i ] NEW_LINE ans . append ( deno [ i ] ) NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT for i in range ( len ( ans ) ) : NEW_LINE INDENT print ( ans [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 93 NEW_LINE print ( "" Following ▁ is ▁ minimal ▁ number "" , "" of ▁ change ▁ for "" , n , "" : ▁ "" , end = "" "" ) NEW_LINE findMin ( n ) NEW_LINE DEDENT +" +E1210,"import java . util . * ; class GFG { static void checkPalindrome ( int num ) { String str = Integer . toString ( num ) ; int l = 0 , r = str . length ( ) - 1 ; while ( l < r ) { if ( str . charAt ( l ) != str . charAt ( r ) ) { System . out . print ( "" No "" ) ; return ; } l ++ ; r -- ; } System . out . print ( "" Yes "" ) ; return ; } public static void main ( String args [ ] ) { int n = 19 , k = 3 ; checkPalindrome ( n + k ) ; } } +","def checkPalindrome ( num ) : NEW_LINE INDENT string = str ( num ) NEW_LINE l = 0 NEW_LINE r = len ( string ) - 1 ; NEW_LINE while ( l < r ) : NEW_LINE INDENT if ( string [ l ] != string [ r ] ) : NEW_LINE INDENT print ( "" No "" ) NEW_LINE return ; NEW_LINE DEDENT l = l + 1 ; NEW_LINE r = r - 1 ; NEW_LINE DEDENT print ( "" Yes "" ) NEW_LINE return ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 19 NEW_LINE k = 3 NEW_LINE checkPalindrome ( n + k ) ; NEW_LINE DEDENT +" +E1211,"class GFG { static void updateArray ( int arr [ ] , int n ) { for ( int i = 0 ; i <= n - 2 ; i ++ ) arr [ i ] = arr [ i + 1 ] ; arr [ n - 1 ] = - 1 ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 1 , 3 , 2 , 4 } ; int N = arr . length ; updateArray ( arr , N ) ; } } +","def updateArray ( arr , n ) : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT arr [ i ] = arr [ i + 1 ] NEW_LINE DEDENT arr [ n - 1 ] = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 5 , 1 , 3 , 2 , 4 ] NEW_LINE N = len ( arr ) NEW_LINE updateArray ( arr , N ) NEW_LINE DEDENT +" +E1212,"class GFG { static int maxProduct ( int [ ] arr , int n ) { if ( n < 3 ) return - 1 ; int max_product = Integer . MIN_VALUE ; for ( int i = 0 ; i < n - 2 ; i ++ ) for ( int j = i + 1 ; j < n - 1 ; j ++ ) for ( int k = j + 1 ; k < n ; k ++ ) max_product = Math . max ( max_product , arr [ i ] * arr [ j ] * arr [ k ] ) ; return max_product ; } public static void main ( String [ ] args ) { int [ ] arr = { 10 , 3 , 5 , 6 , 20 } ; int n = arr . length ; ; int max = maxProduct ( arr , n ) ; if ( max == - 1 ) System . out . println ( "" No ▁ Triplet ▁ Exists "" ) ; else System . out . println ( "" Maximum ▁ product ▁ is ▁ "" + max ) ; } } +","import sys NEW_LINE def maxProduct ( arr , n ) : NEW_LINE INDENT if n < 3 : NEW_LINE INDENT return - 1 NEW_LINE DEDENT max_product = - ( sys . maxsize - 1 ) NEW_LINE for i in range ( 0 , n - 2 ) : NEW_LINE INDENT for j in range ( i + 1 , n - 1 ) : NEW_LINE INDENT for k in range ( j + 1 , n ) : NEW_LINE INDENT max_product = max ( max_product , arr [ i ] * arr [ j ] * arr [ k ] ) NEW_LINE DEDENT DEDENT DEDENT return max_product NEW_LINE DEDENT arr = [ 10 , 3 , 5 , 6 , 20 ] NEW_LINE n = len ( arr ) NEW_LINE max = maxProduct ( arr , n ) NEW_LINE if max == - 1 : NEW_LINE INDENT print ( "" No ▁ Tripplet ▁ Exits "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Maximum ▁ product ▁ is "" , max ) NEW_LINE DEDENT +" +E1213,"import java . util . * ; class GFG { static int count ( String S , int X ) { int count = 0 ; int N = S . length ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( S . charAt ( i ) != '0' ) { for ( int len = 1 ; ( i + len ) <= N ; ++ len ) { int num = Integer . parseInt ( S . substring ( i , i + len ) ) ; if ( num > X ) count ++ ; } } } return count ; } public static void main ( String [ ] args ) { String S = ""2222"" ; int X = 97 ; System . out . println ( count ( S , X ) ) ; } } +","def countSubStr ( S , X ) : NEW_LINE INDENT cnt = 0 NEW_LINE N = len ( S ) NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT if ( S [ i ] != '0' ) : NEW_LINE INDENT j = 1 NEW_LINE while ( ( j + i ) <= N ) : NEW_LINE INDENT num = int ( S [ i : i + j ] ) NEW_LINE if ( num > X ) : NEW_LINE INDENT cnt = cnt + 1 NEW_LINE DEDENT j = j + 1 NEW_LINE DEDENT DEDENT DEDENT return cnt ; NEW_LINE DEDENT S = ""2222"" ; NEW_LINE X = 97 ; NEW_LINE print ( countSubStr ( S , X ) ) NEW_LINE +" +E1214,"class GFG { static void printPattern ( int radius ) { double dist ; for ( int i = 0 ; i <= 2 * radius ; i ++ ) { for ( int j = 0 ; j <= 2 * radius ; j ++ ) { dist = Math . sqrt ( ( i - radius ) * ( i - radius ) + ( j - radius ) * ( j - radius ) ) ; if ( dist > radius - 0.5 && dist < radius + 0.5 ) System . out . print ( "" * "" ) ; else System . out . print ( "" ▁ "" ) ; } System . out . print ( "" \n "" ) ; } } public static void main ( String [ ] args ) { int radius = 6 ; printPattern ( radius ) ; } } +","import math NEW_LINE def printPattern ( radius ) : NEW_LINE INDENT for i in range ( ( 2 * radius ) + 1 ) : NEW_LINE INDENT for j in range ( ( 2 * radius ) + 1 ) : NEW_LINE INDENT dist = math . sqrt ( ( i - radius ) * ( i - radius ) + ( j - radius ) * ( j - radius ) ) NEW_LINE if ( dist > radius - 0.5 and dist < radius + 0.5 ) : NEW_LINE INDENT print ( "" * "" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" ▁ "" , end = "" "" ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE DEDENT DEDENT radius = 6 NEW_LINE printPattern ( radius ) NEW_LINE +" +E1215,"import java . util . * ; class GFG { static int findSum ( int arr [ ] , int N ) { Map < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) mp . put ( arr [ i ] , mp . get ( arr [ i ] ) == null ? 1 : mp . get ( arr [ i ] ) + 1 ) ; int sum = 0 ; for ( Map . Entry < Integer , Integer > entry : mp . entrySet ( ) ) { if ( entry . getValue ( ) % 2 != 0 ) sum += ( entry . getKey ( ) ) * ( entry . getValue ( ) ) ; } return sum ; } public static void main ( String args [ ] ) { int arr [ ] = { 10 , 20 , 20 , 10 , 40 , 40 , 10 } ; int N = arr . length ; System . out . println ( findSum ( arr , N ) ) ; } } +","import collections NEW_LINE def findsum ( arr , N ) : NEW_LINE INDENT mp = collections . defaultdict ( int ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT mp [ arr [ i ] ] += 1 NEW_LINE DEDENT sum = 0 NEW_LINE for i in mp : NEW_LINE INDENT if ( mp [ i ] % 2 != 0 ) : NEW_LINE INDENT sum += ( i * mp [ i ] ) NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT arr = [ 10 , 20 , 20 , 10 , 40 , 40 , 10 ] NEW_LINE N = len ( arr ) NEW_LINE print ( findsum ( arr , N ) ) NEW_LINE +" +E1216,"import java . util . * ; class GFG { static void findFrequencyUtil ( int arr [ ] , int low , int high , int [ ] freq ) { if ( arr [ low ] == arr [ high ] ) { freq [ arr [ low ] ] += high - low + 1 ; } else { int mid = ( low + high ) / 2 ; findFrequencyUtil ( arr , low , mid , freq ) ; findFrequencyUtil ( arr , mid + 1 , high , freq ) ; } } static void findFrequency ( int arr [ ] , int n ) { int [ ] freq = new int [ arr [ n - 1 ] + 1 ] ; findFrequencyUtil ( arr , 0 , n - 1 , freq ) ; for ( int i = 0 ; i <= arr [ n - 1 ] ; i ++ ) if ( freq [ i ] != 0 ) System . out . println ( "" Element ▁ "" + i + "" ▁ occurs ▁ "" + freq [ i ] + "" ▁ times "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 2 , 3 , 3 , 5 , 5 , 8 , 8 , 8 , 9 , 9 , 10 } ; int n = arr . length ; findFrequency ( arr , n ) ; } } +","def findFrequencyUtil ( arr , low , high , freq ) : NEW_LINE INDENT if ( arr [ low ] == arr [ high ] ) : NEW_LINE INDENT freq [ arr [ low ] ] += high - low + 1 NEW_LINE DEDENT else : NEW_LINE INDENT mid = int ( ( low + high ) / 2 ) NEW_LINE findFrequencyUtil ( arr , low , mid , freq ) NEW_LINE findFrequencyUtil ( arr , mid + 1 , high , freq ) NEW_LINE DEDENT DEDENT def findFrequency ( arr , n ) : NEW_LINE INDENT freq = [ 0 for i in range ( n - 1 + 1 ) ] NEW_LINE findFrequencyUtil ( arr , 0 , n - 1 , freq ) NEW_LINE for i in range ( 0 , arr [ n - 1 ] + 1 , 1 ) : NEW_LINE INDENT if ( freq [ i ] != 0 ) : NEW_LINE INDENT print ( "" Element "" , i , "" occurs "" , freq [ i ] , "" times "" ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 1 , 1 , 2 , 3 , 3 , 5 , 5 , 8 , 8 , 8 , 9 , 9 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE findFrequency ( arr , n ) NEW_LINE DEDENT +" +E1217,"import java . io . * ; import java . lang . * ; class GFG { public static double sumOfSeries ( double num ) { double res = 0 , fact = 1 ; for ( int i = 1 ; i <= num ; i ++ ) { fact = fact * i ; res = res + ( i / fact ) ; } return ( res ) ; } public static void main ( String [ ] args ) { double n = 5 ; System . out . println ( "" Sum : ▁ "" + sumOfSeries ( n ) ) ; } } +","def sumOfSeries ( num ) : NEW_LINE INDENT res = 0 NEW_LINE fact = 1 NEW_LINE for i in range ( 1 , num + 1 ) : NEW_LINE INDENT fact *= i NEW_LINE res = res + ( i / fact ) NEW_LINE DEDENT return res NEW_LINE DEDENT n = 5 NEW_LINE print ( "" Sum : ▁ "" , sumOfSeries ( n ) ) NEW_LINE +" +E1218,"class GFG { static void calcSum ( int arr [ ] , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) sum += arr [ i ] ; System . out . print ( sum + "" ▁ "" ) ; for ( int i = k ; i < n ; i ++ ) { sum = ( sum - arr [ i - k ] ) + arr [ i ] ; System . out . print ( sum + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . length ; int k = 3 ; calcSum ( arr , n , k ) ; } } +","def calcSum ( arr , n , k ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( k ) : NEW_LINE INDENT sum += arr [ i ] NEW_LINE DEDENT print ( sum , end = "" ▁ "" ) NEW_LINE for i in range ( k , n ) : NEW_LINE INDENT sum = ( sum - arr [ i - k ] ) + arr [ i ] NEW_LINE print ( sum , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE k = 3 NEW_LINE calcSum ( arr , n , k ) NEW_LINE DEDENT +" +E1219,"import java . lang . * ; import java . util . * ; class GFG { static int minChanges ( int [ ] A , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n - 2 ; ++ i ) { if ( ( i - 1 >= 0 ) && A [ i - 1 ] == 1 && A [ i + 1 ] == 1 && A [ i ] == 0 ) { A [ i + 1 ] = 0 ; cnt ++ ; } } return cnt ; } public static void main ( String args [ ] ) { int [ ] A = { 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 } ; int n = A . length ; System . out . print ( minChanges ( A , n ) ) ; } } +","def minChanges ( A , n ) : NEW_LINE INDENT cnt = 0 NEW_LINE for i in range ( n - 2 ) : NEW_LINE INDENT if ( ( i - 1 >= 0 ) and A [ i - 1 ] == 1 and A [ i + 1 ] == 1 and A [ i ] == 0 ) : NEW_LINE INDENT A [ i + 1 ] = 0 NEW_LINE cnt = cnt + 1 NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT A = [ 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 ] NEW_LINE n = len ( A ) NEW_LINE print ( minChanges ( A , n ) ) NEW_LINE +" +E1220,"class GfG { static int calcNodes ( int N , int I ) { int result = 0 ; result = I * ( N - 1 ) + 1 ; return result ; } public static void main ( String [ ] args ) { int N = 5 , I = 2 ; System . out . println ( "" Leaf ▁ nodes ▁ = ▁ "" + calcNodes ( N , I ) ) ; } } +","def calcNodes ( N , I ) : NEW_LINE INDENT result = 0 NEW_LINE result = I * ( N - 1 ) + 1 NEW_LINE return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 5 NEW_LINE I = 2 NEW_LINE print ( "" Leaf ▁ nodes ▁ = ▁ "" , calcNodes ( N , I ) ) NEW_LINE DEDENT +" +E1221,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static pair countSum ( int arr [ ] , int n ) { int NumberOfOdds = 0 , NumberOfEvens = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 1 ) NumberOfOdds ++ ; NumberOfEvens = n - NumberOfOdds ; int NumberOfOddSubsequences = ( 1 << NumberOfEvens ) * ( 1 << ( NumberOfOdds - 1 ) ) ; int NumberOfEvenSubsequences = ( 1 << n ) - 1 - NumberOfOddSubsequences ; return new pair ( NumberOfEvenSubsequences , NumberOfOddSubsequences ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 3 } ; int n = arr . length ; pair ans = countSum ( arr , n ) ; System . out . print ( "" EvenSum ▁ = ▁ "" + ans . first ) ; System . out . print ( "" ▁ OddSum ▁ = ▁ "" + ans . second ) ; } } +","def countSum ( arr , n ) : NEW_LINE INDENT NumberOfOdds = 0 ; NumberOfEvens = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] & 1 ) : NEW_LINE INDENT NumberOfOdds += 1 ; NEW_LINE DEDENT DEDENT NumberOfEvens = n - NumberOfOdds ; NEW_LINE NumberOfOddSubsequences = ( 1 << NumberOfEvens ) * \ NEW_LINE INDENT ( 1 << ( NumberOfOdds - 1 ) ) ; NEW_LINE DEDENT NumberOfEvenSubsequences = ( 1 << n ) - 1 - \ NEW_LINE INDENT NumberOfOddSubsequences ; NEW_LINE DEDENT return ( NumberOfEvenSubsequences , NumberOfOddSubsequences ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 2 , 3 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE ans = countSum ( arr , n ) ; NEW_LINE print ( "" EvenSum ▁ = "" , ans [ 0 ] , end = "" ▁ "" ) ; NEW_LINE print ( "" OddSum ▁ = "" , ans [ 1 ] ) ; NEW_LINE DEDENT +" +E1222,"class GFG { static int findMinNumber ( int n ) { int count = 0 , ans = 1 ; while ( n % 2 == 0 ) { count ++ ; n /= 2 ; } if ( count % 3 != 0 ) ans *= Math . pow ( 2 , ( count % 3 ) ) ; for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { count = 0 ; while ( n % i == 0 ) { count ++ ; n /= i ; } if ( count % 3 != 0 ) ans *= Math . pow ( i , ( count % 3 ) ) ; } if ( n > 2 ) ans *= n ; return ans ; } public static void main ( String [ ] args ) { int n = 128 ; System . out . print ( findMinNumber ( n ) + "" \n "" ) ; } } +","def findMinNumber ( n ) : NEW_LINE INDENT count = 0 ; NEW_LINE ans = 1 ; NEW_LINE while ( n % 2 == 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE n /= 2 ; NEW_LINE DEDENT if ( count % 3 != 0 ) : NEW_LINE INDENT ans *= pow ( 2 , ( count % 3 ) ) ; NEW_LINE DEDENT for i in range ( 3 , int ( pow ( n , 1 / 2 ) ) , 2 ) : NEW_LINE INDENT count = 0 ; NEW_LINE while ( n % i == 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE n /= i ; NEW_LINE DEDENT if ( count % 3 != 0 ) : NEW_LINE INDENT ans *= pow ( i , ( count % 3 ) ) ; NEW_LINE DEDENT DEDENT if ( n > 2 ) : NEW_LINE INDENT ans *= n ; NEW_LINE DEDENT return ans ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 128 ; NEW_LINE print ( findMinNumber ( n ) ) ; NEW_LINE DEDENT +" +E1223,"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static boolean is_vow ( char c ) { return ( c == ' a ' ) || ( c == ' e ' ) || ( c == ' i ' ) || ( c == ' o ' ) || ( c == ' u ' ) ; } static void removeVowels ( String str ) { System . out . print ( str . charAt ( 0 ) ) ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) if ( ( ! is_vow ( str . charAt ( i - 1 ) ) ) || ( ! is_vow ( str . charAt ( i ) ) ) ) System . out . print ( str . charAt ( i ) ) ; } public static void main ( String [ ] args ) { String str = "" geeks ▁ for ▁ geeks "" ; removeVowels ( str ) ; } } +","def is_vow ( c ) : NEW_LINE INDENT return ( ( c == ' a ' ) or ( c == ' e ' ) or ( c == ' i ' ) or ( c == ' o ' ) or ( c == ' u ' ) ) ; NEW_LINE DEDENT def removeVowels ( str ) : NEW_LINE INDENT print ( str [ 0 ] , end = "" "" ) ; NEW_LINE for i in range ( 1 , len ( str ) ) : NEW_LINE INDENT if ( ( is_vow ( str [ i - 1 ] ) != True ) or ( is_vow ( str [ i ] ) != True ) ) : NEW_LINE INDENT print ( str [ i ] , end = "" "" ) ; NEW_LINE DEDENT DEDENT DEDENT str = "" ▁ geeks ▁ for ▁ geeks "" ; NEW_LINE removeVowels ( str ) ; NEW_LINE +" +E1224,"import java . io . * ; class Gfg { static float areacircumscribed ( float a ) { float PI = 3.14159265f ; return ( a * a * ( PI / 2 ) ) ; } public static void main ( String arg [ ] ) { float a = 6 ; System . out . print ( "" Area ▁ of ▁ an ▁ circumscribed "" + "" circle ▁ is ▁ : "" ) ; System . out . println ( areacircumscribed ( a ) ) ; } } +","PI = 3.14159265 NEW_LINE def areacircumscribed ( a ) : NEW_LINE INDENT return ( a * a * ( PI / 2 ) ) NEW_LINE DEDENT a = 6 NEW_LINE print ( "" ▁ Area ▁ of ▁ an ▁ circumscribed ▁ circle ▁ is ▁ : "" , round ( areacircumscribed ( a ) , 2 ) ) NEW_LINE +" +E1225,"import java . io . * ; import java . lang . * ; class GFG { public static int breakEvenPoint ( int exp1 , int S , int M ) { double earn = S - M ; double exp = exp1 ; double res = Math . ceil ( exp / earn ) ; int res1 = ( int ) res ; return res1 ; } public static void main ( String [ ] args ) { int exp = 3550 , S = 90 , M = 65 ; System . out . println ( breakEvenPoint ( exp , S , M ) ) ; } } +","import math NEW_LINE def breakEvenPoint ( exp , S , M ) : NEW_LINE INDENT earn = S - M NEW_LINE res = math . ceil ( exp / earn ) NEW_LINE return res NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT exp = 3550 NEW_LINE S = 90 NEW_LINE M = 65 NEW_LINE print ( int ( breakEvenPoint ( exp , S , M ) ) ) NEW_LINE DEDENT +" +E1226,"import java . io . * ; class GFG { static int MAX = 256 ; static int countPairs ( String s ) { int cnt [ ] = new int [ MAX ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) cnt [ s . charAt ( i ) ] ++ ; int ans = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) ans += cnt [ i ] * cnt [ i ] ; return ans ; } public static void main ( String [ ] args ) { String s = "" geeksforgeeks "" ; System . out . println ( countPairs ( s ) ) ; } } +","MAX = 256 NEW_LINE def countPairs ( s ) : NEW_LINE INDENT cnt = [ 0 for i in range ( 0 , MAX ) ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT cnt [ ord ( s [ i ] ) - 97 ] += 1 NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( 0 , MAX ) : NEW_LINE INDENT ans += cnt [ i ] * cnt [ i ] NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" geeksforgeeks "" NEW_LINE print ( countPairs ( s ) ) NEW_LINE DEDENT +" +E1227,"import java . util . * ; class GFG { static double sumOfSeries ( int n ) { return 0.0246 * ( Math . pow ( 10 , n ) - 1 - ( 9 * n ) ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( sumOfSeries ( n ) ) ; } } +","import math NEW_LINE def sumOfSeries ( n ) : NEW_LINE INDENT return 0.0246 * ( math . pow ( 10 , n ) - 1 - ( 9 * n ) ) NEW_LINE DEDENT n = 3 NEW_LINE print ( sumOfSeries ( n ) ) NEW_LINE +" +E1228,"import java . util . * ; class GFG { public static int maxLenSub ( int arr [ ] , int n ) { int mls [ ] = new int [ n ] , max = 0 ; for ( int i = 0 ; i < n ; i ++ ) mls [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( Math . abs ( arr [ i ] - arr [ j ] ) <= 1 && mls [ i ] < mls [ j ] + 1 ) mls [ i ] = mls [ j ] + 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( max < mls [ i ] ) max = mls [ i ] ; return max ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 5 , 6 , 3 , 7 , 6 , 5 , 8 } ; int n = arr . length ; System . out . println ( "" Maximum ▁ length ▁ subsequence ▁ = ▁ "" + maxLenSub ( arr , n ) ) ; } } +","def maxLenSub ( arr , n ) : NEW_LINE INDENT mls = [ ] NEW_LINE max = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT mls . append ( 1 ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT if ( abs ( arr [ i ] - arr [ j ] ) <= 1 and mls [ i ] < mls [ j ] + 1 ) : NEW_LINE INDENT mls [ i ] = mls [ j ] + 1 NEW_LINE DEDENT DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT if ( max < mls [ i ] ) : NEW_LINE INDENT max = mls [ i ] NEW_LINE DEDENT DEDENT return max NEW_LINE DEDENT arr = [ 2 , 5 , 6 , 3 , 7 , 6 , 5 , 8 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Maximum ▁ length ▁ subsequence ▁ = ▁ "" , maxLenSub ( arr , n ) ) NEW_LINE +" +E1229,"import java . util . * ; class GFG { static int mod = 1000000007 ; static int [ ] [ ] dp = new int [ 1000 ] [ 1000 ] ; static int calculate ( int pos , int prev , String s , Vector < Integer > index ) { if ( pos == s . length ( ) ) return 1 ; if ( dp [ pos ] [ prev ] != - 1 ) return dp [ pos ] [ prev ] ; int answer = 0 ; for ( int i = 0 ; i < index . size ( ) ; i ++ ) { if ( index . get ( i ) . compareTo ( prev ) >= 0 ) { answer = ( answer % mod + calculate ( pos + 1 , index . get ( i ) , s , index ) % mod ) % mod ; } } return dp [ pos ] [ prev ] = answer ; } static int countWays ( Vector < String > a , String s ) { int n = a . size ( ) ; Vector < Integer > [ ] index = new Vector [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) index [ i ] = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < a . get ( i ) . length ( ) ; j ++ ) { index [ a . get ( i ) . charAt ( j ) - ' a ' ] . add ( j + 1 ) ; } } for ( int i = 0 ; i < 1000 ; i ++ ) { for ( int j = 0 ; j < 1000 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } return calculate ( 0 , 0 , s , index [ 0 ] ) ; } public static void main ( String [ ] args ) { Vector < String > A = new Vector < String > ( ) ; A . add ( "" adc "" ) ; A . add ( "" aec "" ) ; A . add ( "" erg "" ) ; String S = "" ac "" ; System . out . print ( countWays ( A , S ) ) ; } } +","mod = 1000000007 NEW_LINE dp = [ [ - 1 for i in range ( 1000 ) ] for j in range ( 1000 ) ] ; NEW_LINE def calculate ( pos , prev , s , index ) : NEW_LINE INDENT if ( pos == len ( s ) ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( dp [ pos ] [ prev ] != - 1 ) : NEW_LINE INDENT return dp [ pos ] [ prev ] NEW_LINE DEDENT c = ord ( s [ pos ] ) - ord ( ' a ' ) ; NEW_LINE answer = 0 NEW_LINE for i in range ( len ( index ) ) : NEW_LINE INDENT if ( index [ i ] > prev ) : NEW_LINE INDENT answer = ( answer % mod + calculate ( pos + 1 , index [ i ] , s , index ) % mod ) % mod NEW_LINE DEDENT DEDENT dp [ pos ] [ prev ] = 4 NEW_LINE return dp [ pos ] [ prev ] NEW_LINE DEDENT def countWays ( a , s ) : NEW_LINE INDENT n = len ( a ) NEW_LINE index = [ [ ] for i in range ( 26 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( len ( a [ i ] ) ) : NEW_LINE INDENT index [ ord ( a [ i ] [ j ] ) - ord ( ' a ' ) ] . append ( j + 1 ) ; NEW_LINE DEDENT DEDENT return calculate ( 0 , 0 , s , index [ 0 ] ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = [ ] NEW_LINE A . append ( "" adc "" ) NEW_LINE A . append ( "" aec "" ) NEW_LINE A . append ( "" erg "" ) NEW_LINE S = "" ac "" NEW_LINE print ( countWays ( A , S ) ) NEW_LINE DEDENT +" +E1230,"class IsDivisible { static boolean divisibleBy36 ( String num ) { int l = num . length ( ) ; if ( l == 0 ) return false ; if ( l == 1 && num . charAt ( 0 ) != '0' ) return false ; int two_digit_num = ( num . charAt ( l - 2 ) - '0' ) * 10 + ( num . charAt ( l - 1 ) - '0' ) ; if ( two_digit_num % 4 != 0 ) return false ; int sum = 0 ; for ( int i = 0 ; i < l ; i ++ ) sum += ( num . charAt ( i ) - '0' ) ; if ( sum % 9 != 0 ) return false ; return true ; } public static void main ( String [ ] args ) { String num = ""92567812197966231384"" ; if ( divisibleBy36 ( num ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def divisibleBy36 ( num ) : NEW_LINE INDENT l = len ( num ) NEW_LINE if ( l == 0 ) : NEW_LINE INDENT return ( "" No "" ) NEW_LINE DEDENT if ( l == 1 and num [ 0 ] != '0' ) : NEW_LINE INDENT return ( "" No "" ) NEW_LINE DEDENT two_digit_num = ( ( ( int ) ( num [ l - 2 ] ) ) * 10 + ( int ) ( num [ l - 1 ] ) ) NEW_LINE if ( two_digit_num % 4 != 0 ) : NEW_LINE INDENT return "" No "" NEW_LINE DEDENT sm = 0 NEW_LINE for i in range ( 0 , l ) : NEW_LINE INDENT sm = sm + ( int ) ( num [ i ] ) NEW_LINE DEDENT if ( sm % 9 != 0 ) : NEW_LINE INDENT return ( "" No "" ) NEW_LINE DEDENT return ( "" Yes "" ) NEW_LINE DEDENT num = ""92567812197966231384"" NEW_LINE print ( divisibleBy36 ( num ) ) NEW_LINE +" +E1231,"class GFG { static int sum [ ] = new int [ 1000005 ] ; static int toInt ( char x ) { return x - '0' ; } static void prepareSum ( String s ) { sum [ 0 ] = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sum [ i + 1 ] = sum [ i ] + toInt ( s . charAt ( i ) ) ; } } static void query ( int l , int r ) { if ( ( sum [ r + 1 ] - sum [ l ] ) % 3 == 0 ) { System . out . println ( "" Divisible ▁ by ▁ 3"" ) ; } else { System . out . println ( "" Not ▁ divisible ▁ by ▁ 3"" ) ; } } public static void main ( String [ ] args ) { String n = ""12468236544"" ; prepareSum ( n ) ; query ( 0 , 1 ) ; query ( 1 , 2 ) ; query ( 3 , 6 ) ; query ( 0 , 10 ) ; } } +","sum = [ 0 for i in range ( 1000005 ) ] NEW_LINE def toInt ( x ) : NEW_LINE INDENT return int ( x ) NEW_LINE DEDENT def prepareSum ( s ) : NEW_LINE INDENT sum [ 0 ] = 0 NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT sum [ i + 1 ] = sum [ i ] + toInt ( s [ i ] ) NEW_LINE DEDENT DEDENT def query ( l , r ) : NEW_LINE INDENT if ( ( sum [ r + 1 ] - sum [ l ] ) % 3 == 0 ) : NEW_LINE INDENT print ( "" Divisible ▁ by ▁ 3"" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Not ▁ divisible ▁ by ▁ 3"" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = ""12468236544"" NEW_LINE prepareSum ( n ) NEW_LINE query ( 0 , 1 ) NEW_LINE query ( 1 , 2 ) NEW_LINE query ( 3 , 6 ) NEW_LINE query ( 0 , 10 ) NEW_LINE DEDENT +" +E1232,"import java . io . * ; import java . util . * ; class GFG { static int distancesum ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int res = 0 , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { res += ( arr [ i ] * i - sum ) ; sum += arr [ i ] ; } return res ; } static int totaldistancesum ( int x [ ] , int y [ ] , int n ) { return distancesum ( x , n ) + distancesum ( y , n ) ; } public static void main ( String [ ] args ) { int x [ ] = { - 1 , 1 , 3 , 2 } ; int y [ ] = { 5 , 6 , 5 , 3 } ; int n = x . length ; System . out . println ( totaldistancesum ( x , y , n ) ) ; } } +","def distancesum ( arr , n ) : NEW_LINE INDENT arr . sort ( ) NEW_LINE res = 0 NEW_LINE sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT res += ( arr [ i ] * i - sum ) NEW_LINE sum += arr [ i ] NEW_LINE DEDENT return res NEW_LINE DEDENT def totaldistancesum ( x , y , n ) : NEW_LINE INDENT return distancesum ( x , n ) + distancesum ( y , n ) NEW_LINE DEDENT x = [ - 1 , 1 , 3 , 2 ] NEW_LINE y = [ 5 , 6 , 5 , 3 ] NEW_LINE n = len ( x ) NEW_LINE print ( totaldistancesum ( x , y , n ) ) NEW_LINE +" +E1233,"import java . io . * ; class GFG { static int squareSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( 2 * i ) * ( 2 * i ) ; return sum ; } public static void main ( String args [ ] ) throws IOException { System . out . println ( squareSum ( 8 ) ) ; } } +","def squareSum ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 0 , n + 1 ) : NEW_LINE INDENT sum += ( 2 * i ) * ( 2 * i ) NEW_LINE DEDENT return sum NEW_LINE DEDENT ans = squareSum ( 8 ) NEW_LINE print ( ans ) NEW_LINE +" +E1234,"class GFG { static int findAndSum ( int [ ] arr , int n ) { int sum = 0 ; int mul = 1 ; for ( int i = 0 ; i < 30 ; i ++ ) { boolean count_on = false ; int l = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) if ( count_on ) l ++ ; else { count_on = true ; l ++ ; } else if ( count_on ) { sum += ( ( mul * l * ( l + 1 ) ) / 2 ) ; count_on = false ; l = 0 ; } } if ( count_on ) { sum += ( ( mul * l * ( l + 1 ) ) / 2 ) ; count_on = false ; l = 0 ; } mul *= 2 ; } return sum ; } public static void main ( String [ ] args ) { int [ ] arr = { 7 , 1 , 1 , 5 } ; int n = arr . length ; System . out . println ( findAndSum ( arr , n ) ) ; } } +","import math as mt NEW_LINE def findAndSum ( arr , n ) : NEW_LINE INDENT Sum = 0 NEW_LINE mul = 1 NEW_LINE for i in range ( 30 ) : NEW_LINE INDENT count_on = 0 NEW_LINE l = 0 NEW_LINE for j in range ( n ) : NEW_LINE INDENT if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) : NEW_LINE INDENT if ( count_on ) : NEW_LINE INDENT l += 1 NEW_LINE DEDENT else : NEW_LINE INDENT count_on = 1 NEW_LINE l += 1 NEW_LINE DEDENT DEDENT elif ( count_on ) : NEW_LINE INDENT Sum += ( ( mul * l * ( l + 1 ) ) // 2 ) NEW_LINE count_on = 0 NEW_LINE l = 0 NEW_LINE DEDENT DEDENT if ( count_on ) : NEW_LINE INDENT Sum += ( ( mul * l * ( l + 1 ) ) // 2 ) NEW_LINE count_on = 0 NEW_LINE l = 0 NEW_LINE DEDENT mul *= 2 NEW_LINE DEDENT return Sum NEW_LINE DEDENT arr = [ 7 , 1 , 1 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE print ( findAndSum ( arr , n ) ) NEW_LINE +" +E1235,"import java . util . Arrays ; public class GFG { static boolean isAlphabaticOrder ( String s ) { int n = s . length ( ) ; char c [ ] = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ i ] = s . charAt ( i ) ; } Arrays . sort ( c ) ; for ( int i = 0 ; i < n ; i ++ ) if ( c [ i ] != s . charAt ( i ) ) return false ; return true ; } public static void main ( String args [ ] ) { String s = "" aabbbcc "" ; if ( isAlphabaticOrder ( s ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isAlphabaticOrder ( s ) : NEW_LINE INDENT n = len ( s ) NEW_LINE c = [ s [ i ] for i in range ( len ( s ) ) ] NEW_LINE c . sort ( reverse = False ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( c [ i ] != s [ i ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "" aabbbcc "" NEW_LINE if ( isAlphabaticOrder ( s ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1236,"public class DLL { Node head ; class Node { int data ; Node prev ; Node next ; Node ( int d ) { data = d ; } } public void push ( int new_data ) { Node new_Node = new Node ( new_data ) ; new_Node . next = head ; new_Node . prev = null ; if ( head != null ) head . prev = new_Node ; head = new_Node ; } public void InsertAfter ( Node prev_Node , int new_data ) { if ( prev_Node == null ) { System . out . println ( "" The ▁ given ▁ previous ▁ node ▁ cannot ▁ be ▁ NULL ▁ "" ) ; return ; } Node new_node = new Node ( new_data ) ; new_node . next = prev_Node . next ; prev_Node . next = new_node ; new_node . prev = prev_Node ; if ( new_node . next != null ) new_node . next . prev = new_node ; } void append ( int new_data ) { Node new_node = new Node ( new_data ) ; Node last = head ; new_node . next = null ; if ( head == null ) { new_node . prev = null ; head = new_node ; return ; } while ( last . next != null ) last = last . next ; last . next = new_node ; new_node . prev = last ; } public void printlist ( Node node ) { Node last = null ; System . out . println ( "" Traversal ▁ in ▁ forward ▁ Direction "" ) ; while ( node != null ) { System . out . print ( node . data + "" ▁ "" ) ; last = node ; node = node . next ; } System . out . println ( ) ; System . out . println ( "" Traversal ▁ in ▁ reverse ▁ direction "" ) ; while ( last != null ) { System . out . print ( last . data + "" ▁ "" ) ; last = last . prev ; } } public static void main ( String [ ] args ) { DLL dll = new DLL ( ) ; dll . append ( 6 ) ; dll . push ( 7 ) ; dll . push ( 1 ) ; dll . append ( 4 ) ; dll . InsertAfter ( dll . head . next , 8 ) ; System . out . println ( "" Created ▁ DLL ▁ is : ▁ "" ) ; dll . printlist ( dll . head ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . next = None NEW_LINE self . prev = None NEW_LINE DEDENT DEDENT class DoublyLinkedList : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . head = None NEW_LINE DEDENT def push ( self , new_data ) : NEW_LINE INDENT new_node = Node ( new_data ) NEW_LINE new_node . next = self . head NEW_LINE if self . head is not None : NEW_LINE INDENT self . head . prev = new_node NEW_LINE DEDENT self . head = new_node NEW_LINE DEDENT def insertAfter ( self , prev_node , new_data ) : NEW_LINE INDENT if prev_node is None : NEW_LINE INDENT print "" the ▁ given ▁ previous ▁ node ▁ cannot ▁ be ▁ NULL "" NEW_LINE return NEW_LINE DEDENT new_node = Node ( new_data ) NEW_LINE new_node . next = prev_node . next NEW_LINE prev_node . next = new_node NEW_LINE new_node . prev = prev_node NEW_LINE if new_node . next is not None : NEW_LINE INDENT new_node . next . prev = new_node NEW_LINE DEDENT DEDENT def append ( self , new_data ) : NEW_LINE INDENT new_node = Node ( new_data ) NEW_LINE new_node . next = None NEW_LINE if self . head is None : NEW_LINE INDENT new_node . prev = None NEW_LINE self . head = new_node NEW_LINE return NEW_LINE DEDENT last = self . head NEW_LINE while ( last . next is not None ) : NEW_LINE INDENT last = last . next NEW_LINE DEDENT last . next = new_node NEW_LINE new_node . prev = last NEW_LINE return NEW_LINE DEDENT def printList ( self , node ) : NEW_LINE INDENT print "" \n Traversal ▁ in ▁ forward ▁ direction "" NEW_LINE while ( node is not None ) : NEW_LINE INDENT print "" ▁ % ▁ d "" % ( node . data ) , NEW_LINE last = node NEW_LINE node = node . next NEW_LINE DEDENT print "" \n Traversal ▁ in ▁ reverse ▁ direction "" NEW_LINE while ( last is not None ) : NEW_LINE INDENT print "" ▁ % ▁ d "" % ( last . data ) , NEW_LINE last = last . prev NEW_LINE DEDENT DEDENT DEDENT llist = DoublyLinkedList ( ) NEW_LINE llist . append ( 6 ) NEW_LINE llist . push ( 7 ) NEW_LINE llist . push ( 1 ) NEW_LINE llist . append ( 4 ) NEW_LINE llist . insertAfter ( llist . head . next , 8 ) NEW_LINE print "" Created ▁ DLL ▁ is : ▁ "" , NEW_LINE llist . printList ( llist . head ) NEW_LINE +" +E1237,"public class GFG { final static int size = 10001 ; static int prime [ ] = new int [ size ] ; static int freq [ ] = new int [ size ] ; static void sieve ( int a , int b ) { prime [ 1 ] = 1 ; for ( int i = 2 ; i * i < size ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = i * 2 ; j < size ; j += i ) prime [ j ] = 1 ; } } for ( int p = 1 ; p < size ; p ++ ) { for ( int q = 1 ; q < size ; q ++ ) { if ( prime [ p ] == 0 && prime [ q ] == 0 && a * p + b * q < size ) { freq [ a * p + b * q ] ++ ; } } } } public static void main ( String [ ] args ) { int queries = 2 , a = 1 , b = 2 ; sieve ( a , b ) ; int arr [ ] = { 15 , 25 } ; for ( int i = 0 ; i < queries ; i ++ ) { System . out . print ( freq [ arr [ i ] ] + "" ▁ "" ) ; } } } +","from math import sqrt NEW_LINE size = 1000 NEW_LINE prime = [ 0 for i in range ( size ) ] NEW_LINE freq = [ 0 for i in range ( size ) ] NEW_LINE def sieve ( a , b ) : NEW_LINE INDENT prime [ 1 ] = 1 NEW_LINE for i in range ( 2 , int ( sqrt ( size ) ) + 1 , 1 ) : NEW_LINE INDENT if ( prime [ i ] == 0 ) : NEW_LINE INDENT for j in range ( i * 2 , size , i ) : NEW_LINE INDENT prime [ j ] = 1 NEW_LINE DEDENT DEDENT DEDENT for p in range ( 1 , size , 1 ) : NEW_LINE INDENT for q in range ( 1 , size , 1 ) : NEW_LINE INDENT if ( prime [ p ] == 0 and prime [ q ] == 0 and a * p + b * q < size ) : NEW_LINE INDENT freq [ a * p + b * q ] += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT queries = 2 NEW_LINE a = 1 NEW_LINE b = 2 NEW_LINE sieve ( a , b ) NEW_LINE arr = [ 15 , 25 ] NEW_LINE for i in range ( queries ) : NEW_LINE INDENT print ( freq [ arr [ i ] ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT +" +E1238,"import java . util . * ; import java . lang . * ; class GFG { static String replaceConsonants ( String str ) { String res = "" "" ; int i = 0 , count = 0 ; while ( i < str . length ( ) ) { if ( str . charAt ( i ) != ' a ' && str . charAt ( i ) != ' e ' && str . charAt ( i ) != ' i ' && str . charAt ( i ) != ' o ' && str . charAt ( i ) != ' u ' ) { i ++ ; count ++ ; } else { if ( count > 0 ) res += count ; res += str . charAt ( i ) ; i ++ ; count = 0 ; } } if ( count > 0 ) res += count ; return res ; } public static void main ( String [ ] args ) { String str = "" abcdeiop "" ; System . out . println ( replaceConsonants ( str ) ) ; } } +","def replaceConsonants ( string ) : NEW_LINE INDENT res = "" "" ; NEW_LINE i = 0 ; count = 0 ; NEW_LINE while ( i < len ( string ) ) : NEW_LINE INDENT if ( string [ i ] != ' a ' and string [ i ] != ' e ' and string [ i ] != ' i ' and string [ i ] != ' o ' and string [ i ] != ' u ' ) : NEW_LINE INDENT i += 1 ; NEW_LINE count += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT if ( count > 0 ) : NEW_LINE INDENT res += str ( count ) ; NEW_LINE DEDENT res += string [ i ] ; NEW_LINE i += 1 NEW_LINE count = 0 ; NEW_LINE DEDENT DEDENT if ( count > 0 ) : NEW_LINE INDENT res += str ( count ) ; NEW_LINE DEDENT return res ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" abcdeiop "" ; NEW_LINE print ( replaceConsonants ( string ) ) ; NEW_LINE DEDENT +" +E1239,"public static int count ( int S [ ] , int m , int n ) { int table [ ] = new int [ n + 1 ] ; table [ 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = S [ i ] ; j <= n ; j ++ ) table [ j ] += table [ j - S [ i ] ] ; return table [ n ] ; } +","def count ( S , m , n ) : NEW_LINE INDENT table = [ 0 for k in range ( n + 1 ) ] NEW_LINE table [ 0 ] = 1 NEW_LINE for i in range ( 0 , m ) : NEW_LINE INDENT for j in range ( S [ i ] , n + 1 ) : NEW_LINE INDENT table [ j ] += table [ j - S [ i ] ] NEW_LINE DEDENT DEDENT return table [ n ] NEW_LINE DEDENT arr = [ 1 , 2 , 3 ] NEW_LINE m = len ( arr ) NEW_LINE n = 4 NEW_LINE x = count ( arr , m , n ) NEW_LINE print ( x ) NEW_LINE +" +E1240,"class GFG { static void minReplacement ( String str ) { if ( str . length ( ) > 26 ) { System . out . println ( "" IMPOSSIBLE "" ) ; } else { int hash [ ] = new int [ 26 ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { hash [ str . charAt ( i ) - ' a ' ] ++ ; } int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( hash [ str . charAt ( i ) - ' a ' ] > 1 ) { for ( int j = 0 ; j < 26 ; j ++ ) { if ( hash [ j ] == 0 ) { hash [ str . charAt ( i ) - ' a ' ] -- ; str = str . substring ( 0 , i ) + ( char ) ( j + ' a ' ) + str . substring ( i + 1 ) ; hash [ j ] ++ ; break ; } } } } System . out . println ( str ) ; } } public static void main ( String [ ] args ) { String str = "" xxxxyyyy "" ; minReplacement ( str ) ; } } +","def minReplacement ( string ) : NEW_LINE INDENT if len ( string ) > 26 : NEW_LINE INDENT print ( "" IMPOSSIBLE "" ) NEW_LINE DEDENT else : NEW_LINE INDENT Hash = [ 0 ] * 26 NEW_LINE for i in range ( 0 , len ( string ) ) : NEW_LINE INDENT Hash [ ord ( string [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT count = 0 NEW_LINE for i in range ( 0 , len ( string ) ) : NEW_LINE INDENT if Hash [ ord ( string [ i ] ) - ord ( ' a ' ) ] > 1 : NEW_LINE INDENT for j in range ( 0 , 26 ) : NEW_LINE INDENT if Hash [ j ] == 0 : NEW_LINE INDENT Hash [ ord ( string [ i ] ) - ord ( ' a ' ) ] -= 1 NEW_LINE string [ i ] = chr ( j + ord ( ' a ' ) ) NEW_LINE Hash [ j ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ' ' . join ( string ) ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" xxxxyyyy "" NEW_LINE minReplacement ( list ( string ) ) NEW_LINE DEDENT +" +E1241,"class GFG { final static int N = 3 ; static int findStepsForDDM ( int arr [ ] [ ] ) { int result = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < N ; j ++ ) sum += Math . abs ( arr [ i ] [ j ] ) ; sum -= Math . abs ( arr [ i ] [ i ] ) ; if ( Math . abs ( arr [ i ] [ i ] ) < Math . abs ( sum ) ) result += Math . abs ( Math . abs ( arr [ i ] [ i ] ) - Math . abs ( sum ) ) ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 3 , - 2 , 1 } , { 1 , - 3 , 2 } , { - 1 , 2 , 4 } } ; System . out . println ( findStepsForDDM ( arr ) ) ; } } +","N = 3 NEW_LINE def findStepsForDDM ( arr ) : NEW_LINE INDENT result = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT sum = 0 NEW_LINE for j in range ( N ) : NEW_LINE INDENT sum += abs ( arr [ i ] [ j ] ) NEW_LINE DEDENT sum -= abs ( arr [ i ] [ i ] ) NEW_LINE if ( abs ( arr [ i ] [ i ] ) < abs ( sum ) ) : NEW_LINE INDENT result += abs ( abs ( arr [ i ] [ i ] ) - abs ( sum ) ) NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT arr = [ [ 3 , - 2 , 1 ] , [ 1 , - 3 , 2 ] , [ - 1 , 2 , 4 ] ] NEW_LINE print ( findStepsForDDM ( arr ) ) NEW_LINE +" +E1242,"class GFG { static boolean isArmstrong ( int x , int n ) { int sum1 = 0 ; int temp = x ; while ( temp > 0 ) { int digit = temp % 10 ; sum1 += Math . pow ( digit , n ) ; temp /= 10 ; } return sum1 == x ; } static void CalculateXORandOR ( int n ) { int CalculateXOR = 0 ; int CalculateOR = 0 ; int start = ( int ) Math . pow ( 10 , n - 1 ) ; int end = ( int ) ( Math . pow ( 10 , n ) ) - 1 ; for ( int i = start ; i < end + 1 ; i ++ ) { if ( isArmstrong ( i , n ) ) { CalculateXOR = CalculateXOR ^ i ; CalculateOR = CalculateOR | i ; } } System . out . println ( "" XOR ▁ = ▁ "" + CalculateXOR ) ; System . out . println ( "" OR ▁ = ▁ "" + CalculateOR ) ; } public static void main ( String [ ] args ) { int n = 4 ; CalculateXORandOR ( n ) ; } } +","def isArmstrong ( x , n ) : NEW_LINE INDENT sum1 = 0 NEW_LINE temp = x NEW_LINE while temp > 0 : NEW_LINE INDENT digit = temp % 10 NEW_LINE sum1 += digit ** n NEW_LINE temp //= 10 NEW_LINE DEDENT return sum1 == x NEW_LINE DEDENT def CalculateXORandOR ( n ) : NEW_LINE INDENT CalculateXOR = 0 NEW_LINE CalculateOR = 0 NEW_LINE start = 10 ** ( n - 1 ) NEW_LINE end = ( 10 ** n ) - 1 NEW_LINE for i in range ( start , end + 1 ) : NEW_LINE INDENT if ( isArmstrong ( i , n ) ) : NEW_LINE INDENT CalculateXOR = CalculateXOR ^ i NEW_LINE CalculateOR = CalculateOR | i NEW_LINE DEDENT DEDENT print ( "" XOR ▁ = ▁ "" , CalculateXOR ) NEW_LINE print ( "" OR ▁ = ▁ "" , CalculateOR ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 4 ; NEW_LINE CalculateXORandOR ( n ) ; NEW_LINE DEDENT +" +E1243,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void decToOctal ( int n ) { int octalNum [ ] = new int [ 100 ] ; int i = 0 ; while ( n != 0 ) { octalNum [ i ] = n % 8 ; n = n / 8 ; i ++ ; } for ( int j = i - 1 ; j >= 0 ; j -- ) System . out . print ( octalNum [ j ] ) ; System . out . println ( "" \n "" ) ; } static void nDigitPerfectSquares ( int n ) { int decimal = ( int ) Math . pow ( Math . ceil ( Math . sqrt ( Math . pow ( 8 , n ) ) ) - 1 , 2 ) ; decToOctal ( decimal ) ; } public static void main ( String [ ] args ) { int n = 2 ; nDigitPerfectSquares ( n ) ; } } +","from math import sqrt , ceil NEW_LINE def decToOctal ( n ) : NEW_LINE INDENT octalNum = [ 0 ] * 100 ; NEW_LINE i = 0 ; NEW_LINE while ( n != 0 ) : NEW_LINE INDENT octalNum [ i ] = n % 8 ; NEW_LINE n = n // 8 ; NEW_LINE i += 1 ; NEW_LINE DEDENT for j in range ( i - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( octalNum [ j ] , end = "" "" ) ; NEW_LINE DEDENT print ( ) ; NEW_LINE DEDENT def nDigitPerfectSquares ( n ) : NEW_LINE INDENT decimal = pow ( ceil ( sqrt ( pow ( 8 , n ) ) ) - 1 , 2 ) ; NEW_LINE decToOctal ( decimal ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 2 ; NEW_LINE nDigitPerfectSquares ( n ) ; NEW_LINE DEDENT +" +E1244,"class OddPosition { public static long getFinalElement ( long n ) { long finalNum ; for ( finalNum = 2 ; finalNum * 2 <= n ; finalNum *= 2 ) ; return finalNum ; } public static void main ( String [ ] args ) { int N = 12 ; System . out . println ( getFinalElement ( N ) ) ; } } +","def getFinalElement ( n ) : NEW_LINE INDENT finalNum = 2 NEW_LINE while finalNum * 2 <= n : NEW_LINE INDENT finalNum *= 2 NEW_LINE DEDENT return finalNum NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 12 NEW_LINE print ( getFinalElement ( N ) ) NEW_LINE DEDENT +" +E1245,"import java . io . * ; class GFG { static int maxSum ( int arr [ ] , int n ) { if ( n < 2 ) return - 1 ; int ans = arr [ 0 ] + arr [ 1 ] ; for ( int i = 1 ; i + 1 < n ; i ++ ) ans = Math . min ( ans , ( arr [ i ] + arr [ i + 1 ] ) ) ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 12 , 2 , 2 } ; int n = arr . length ; System . out . println ( maxSum ( arr , n ) ) ; } } +","def maxSum ( arr , n ) : NEW_LINE INDENT if ( n < 2 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT ans = arr [ 0 ] + arr [ 1 ] NEW_LINE for i in range ( 1 , n - 1 , 1 ) : NEW_LINE INDENT ans = min ( ans , ( arr [ i ] + arr [ i + 1 ] ) ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 12 , 2 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( maxSum ( arr , n ) ) NEW_LINE DEDENT +" +E1246,"class GFG { static int findCount ( String str ) { int result = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i == ( str . charAt ( i ) - ' a ' ) || i == ( str . charAt ( i ) - ' A ' ) ) { result ++ ; } } return result ; } public static void main ( String [ ] args ) { String str = "" AbgdeF "" ; System . out . print ( findCount ( str ) ) ; } } +","def findCount ( str ) : NEW_LINE INDENT result = 0 NEW_LINE for i in range ( len ( str ) ) : NEW_LINE INDENT if ( ( i == ord ( str [ i ] ) - ord ( ' a ' ) ) or ( i == ord ( str [ i ] ) - ord ( ' A ' ) ) ) : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT str = ' AbgdeF ' NEW_LINE print ( findCount ( str ) ) NEW_LINE +" +E1247,"import java . io . * ; class GFG { static int power ( int x , int y ) { if ( y == 0 ) return 1 ; else if ( y % 2 == 0 ) return power ( x , y / 2 ) * power ( x , y / 2 ) ; else return x * power ( x , y / 2 ) * power ( x , y / 2 ) ; } static void sieveOfEratosthenes ( int n , boolean isPrime [ ] ) { isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i <= n ; i ++ ) isPrime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) isPrime [ i ] = false ; } } } static boolean leftTruPrime ( int n ) { int temp = n , cnt = 0 , temp1 ; while ( temp != 0 ) { cnt ++ ; temp1 = temp % 10 ; if ( temp1 == 0 ) return false ; temp = temp / 10 ; } boolean isPrime [ ] = new boolean [ n + 1 ] ; sieveOfEratosthenes ( n , isPrime ) ; for ( int i = cnt ; i > 0 ; i -- ) { int mod = power ( 10 , i ) ; if ( ! isPrime [ n % mod ] ) return false ; } return true ; } public static void main ( String args [ ] ) { int n = 113 ; if ( leftTruPrime ( n ) ) System . out . println ( n + "" ▁ is ▁ left ▁ truncatable ▁ prime "" ) ; else System . out . println ( n + "" ▁ is ▁ not ▁ left ▁ truncatable ▁ prime "" ) ; } } +","def power ( x , y ) : NEW_LINE INDENT if ( y == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif ( y % 2 == 0 ) : NEW_LINE INDENT return ( power ( x , y // 2 ) * power ( x , y // 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT return ( x * power ( x , y // 2 ) * power ( x , y // 2 ) ) NEW_LINE DEDENT DEDENT def sieveOfEratosthenes ( n , isPrime ) : NEW_LINE INDENT isPrime [ 0 ] = isPrime [ 1 ] = False NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT isPrime [ i ] = True NEW_LINE DEDENT p = 2 NEW_LINE while ( p * p <= n ) : NEW_LINE INDENT if ( isPrime [ p ] == True ) : NEW_LINE INDENT i = p * 2 NEW_LINE while ( i <= n ) : NEW_LINE INDENT isPrime [ i ] = False NEW_LINE i = i + p NEW_LINE DEDENT DEDENT p = p + 1 NEW_LINE DEDENT DEDENT def leftTruPrime ( n ) : NEW_LINE INDENT temp = n NEW_LINE cnt = 0 NEW_LINE while ( temp != 0 ) : NEW_LINE INDENT cnt = cnt + 1 NEW_LINE temp1 = temp % 10 ; NEW_LINE if ( temp1 == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT temp = temp // 10 NEW_LINE DEDENT isPrime = [ None ] * ( n + 1 ) NEW_LINE sieveOfEratosthenes ( n , isPrime ) NEW_LINE for i in range ( cnt , 0 , - 1 ) : NEW_LINE INDENT mod = power ( 10 , i ) NEW_LINE if ( isPrime [ n % mod ] != True ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT n = 113 NEW_LINE if ( leftTruPrime ( n ) ) : NEW_LINE INDENT print ( n , "" is ▁ left ▁ truncatable ▁ prime "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n , "" is ▁ not ▁ left ▁ truncatable ▁ prime "" ) NEW_LINE DEDENT +" +E1248,"class GFG { static char findExtraCharcter ( char [ ] strA , char [ ] strB ) { int [ ] m1 = new int [ 256 ] ; for ( int i = 0 ; i < strB . length ; i ++ ) m1 [ strB [ i ] ] ++ ; for ( int i = 0 ; i < strA . length ; i ++ ) m1 [ strA [ i ] ] -- ; for ( int i = 0 ; i < m1 . length ; i ++ ) { if ( m1 [ i ] == 1 ) return ( char ) i ; } return Character . MIN_VALUE ; } public static void main ( String [ ] args ) { String strA = "" abcd "" ; String strB = "" cbdad "" ; System . out . println ( findExtraCharcter ( strA . toCharArray ( ) , strB . toCharArray ( ) ) ) ; } } +","def findExtraCharacter ( strA , strB ) : NEW_LINE INDENT m1 = { } NEW_LINE for i in strB : NEW_LINE INDENT if i in m1 : NEW_LINE INDENT m1 [ i ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT m1 [ i ] = 1 NEW_LINE DEDENT DEDENT for i in strA : NEW_LINE INDENT m1 [ i ] -= 1 NEW_LINE DEDENT for h1 in m1 : NEW_LINE INDENT if m1 [ h1 ] == 1 : NEW_LINE INDENT return h1 NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT strA = ' abcd ' NEW_LINE strB = ' cbdad ' NEW_LINE print ( findExtraCharacter ( strA , strB ) ) NEW_LINE DEDENT +" +E1249,"import java . io . * ; public class GFG { static float AvgofSquareN ( int n ) { float sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum / n ; } static public void main ( String [ ] args ) { int n = 2 ; System . out . println ( AvgofSquareN ( n ) ) ; } } +","def AvgofSquareN ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT sum += ( i * i ) NEW_LINE DEDENT return sum / n NEW_LINE DEDENT n = 2 NEW_LINE print ( AvgofSquareN ( n ) ) NEW_LINE +" +E1250,"class GFG { static int lcm_fun ( int a , int b ) { if ( b == 0 ) return a ; return lcm_fun ( b , a % b ) ; } static int digitLCM ( int n ) { int lcm = 1 ; while ( n > 0 ) { lcm = ( n % 10 * lcm ) / lcm_fun ( n % 10 , lcm ) ; if ( lcm == 0 ) return 0 ; n = n / 10 ; } return lcm ; } public static void main ( String [ ] args ) { int n = 397 ; System . out . println ( digitLCM ( n ) ) ; } } +","def lcm_fun ( a , b ) : NEW_LINE INDENT if ( b == 0 ) : NEW_LINE INDENT return a ; NEW_LINE DEDENT return lcm_fun ( b , a % b ) ; NEW_LINE DEDENT def digitLCM ( n ) : NEW_LINE INDENT lcm = 1 ; NEW_LINE while ( n > 0 ) : NEW_LINE INDENT lcm = int ( ( n % 10 * lcm ) / lcm_fun ( n % 10 , lcm ) ) ; NEW_LINE if ( lcm == 0 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT n = int ( n / 10 ) ; NEW_LINE DEDENT return lcm ; NEW_LINE DEDENT n = 397 ; NEW_LINE print ( digitLCM ( n ) ) ; NEW_LINE +" +E1251,"import java . util . * ; public class GFG { static int fact ( int n ) { if ( n <= 1 ) return 1 ; return n * fact ( n - 1 ) ; } static int nPr ( int n , int r ) { return fact ( n ) / fact ( n - r ) ; } public static void main ( String args [ ] ) { int n = 5 ; int r = 2 ; System . out . println ( n + "" P "" + r + "" ▁ = ▁ "" + nPr ( n , r ) ) ; } } +","import math NEW_LINE def fact ( n ) : NEW_LINE INDENT if ( n <= 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return n * fact ( n - 1 ) NEW_LINE DEDENT def nPr ( n , r ) : NEW_LINE INDENT return math . floor ( fact ( n ) / fact ( n - r ) ) NEW_LINE DEDENT n = 5 NEW_LINE r = 2 NEW_LINE print ( n , "" P "" , r , "" = "" , nPr ( n , r ) ) NEW_LINE +" +E1252,"class GFG { static boolean isPossible ( int a [ ] , int n ) { int cur = a [ 0 ] ; cur -- ; for ( int i = 1 ; i < n ; i ++ ) { int nxt = a [ i ] ; if ( nxt > cur ) nxt -- ; else if ( nxt < cur ) return false ; cur = nxt ; } return true ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 1 , 2 , 3 } ; int n = a . length ; if ( isPossible ( a , n ) ) System . out . printf ( "" Yes "" ) ; else System . out . printf ( "" No "" ) ; } } +","def isPossible ( a , n ) : NEW_LINE INDENT cur = a [ 0 ] ; NEW_LINE cur -= 1 ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT nxt = a [ i ] ; NEW_LINE if ( nxt > cur ) : NEW_LINE INDENT nxt -= 1 ; NEW_LINE DEDENT elif ( nxt < cur ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT cur = nxt ; NEW_LINE DEDENT return True ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , 2 , 1 , 2 , 3 ] ; NEW_LINE n = len ( a ) ; NEW_LINE if ( isPossible ( a , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E1253,"public class GFG { static int fact ( int n ) { int num = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { num = num * i ; } return num ; } static int Special_Factorial_Number ( int k ) { for ( int i = 1 ; i <= k ; i ++ ) { if ( fact ( i ) % k == 0 ) { return i ; } } return 0 ; } public static void main ( String [ ] args ) { int k = 16 ; System . out . println ( Special_Factorial_Number ( k ) ) ; } } +","def fact ( n ) : NEW_LINE INDENT num = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT num = num * i NEW_LINE DEDENT return num NEW_LINE DEDENT def Special_Factorial_Number ( k ) : NEW_LINE INDENT for i in range ( 1 , k + 1 ) : NEW_LINE INDENT if ( fact ( i ) % k == 0 ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT return 0 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT k = 16 NEW_LINE print ( Special_Factorial_Number ( k ) ) NEW_LINE DEDENT +" +E1254,"import java . util . * ; class GFG { static int mod = 1000000007 ; static int noOfBinaryStrings ( int N , int k ) { int dp [ ] = new int [ 100002 ] ; for ( int i = 1 ; i <= k - 1 ; i ++ ) { dp [ i ] = 1 ; } dp [ k ] = 2 ; for ( int i = k + 1 ; i <= N ; i ++ ) { dp [ i ] = ( dp [ i - 1 ] + dp [ i - k ] ) % mod ; } return dp [ N ] ; } public static void main ( String [ ] args ) { int N = 4 ; int K = 2 ; System . out . println ( noOfBinaryStrings ( N , K ) ) ; } } +","mod = 1000000007 ; NEW_LINE def noOfBinaryStrings ( N , k ) : NEW_LINE INDENT dp = [ 0 ] * 100002 ; NEW_LINE for i in range ( 1 , K ) : NEW_LINE INDENT dp [ i ] = 1 ; NEW_LINE DEDENT dp [ k ] = 2 ; NEW_LINE for i in range ( k + 1 , N + 1 ) : NEW_LINE INDENT dp [ i ] = ( dp [ i - 1 ] + dp [ i - k ] ) % mod ; NEW_LINE DEDENT return dp [ N ] ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 4 ; NEW_LINE K = 2 ; NEW_LINE print ( noOfBinaryStrings ( N , K ) ) ; NEW_LINE DEDENT +" +E1255,"class GFG { static void reverse ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i += 2 * k ) { int left = i ; int right = Math . min ( i + k - 1 , n - 1 ) ; while ( left < right ) { swap ( arr , left ++ , right -- ) ; } } } static int [ ] swap ( int [ ] array , int i , int j ) { int temp = array [ i ] ; array [ i ] = array [ j ] ; array [ j ] = temp ; return array ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 } ; int k = 3 ; int n = arr . length ; reverse ( arr , n , k ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def reverse ( arr , n , k ) : NEW_LINE INDENT for i in range ( 0 , n , 2 * k ) : NEW_LINE INDENT left = i NEW_LINE right = min ( i + k - 1 , n - 1 ) NEW_LINE while ( left < right ) : NEW_LINE INDENT temp = arr [ left ] NEW_LINE arr [ left ] = arr [ right ] NEW_LINE arr [ right ] = temp NEW_LINE left += 1 NEW_LINE right -= 1 NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 ] NEW_LINE k = 3 NEW_LINE n = len ( arr ) NEW_LINE reverse ( arr , n , k ) NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT +" +E1256,"class GFG { static final int MAX = 100 ; static int [ ] [ ] mat = new int [ MAX ] [ MAX ] ; static void fillRemaining ( int i , int j , int n ) { int x = 2 ; for ( int k = i + 1 ; k < n ; k ++ ) mat [ k ] [ j ] = x ++ ; for ( int k = 0 ; k < i ; k ++ ) mat [ k ] [ j ] = x ++ ; } static void constructMatrix ( int n ) { int right = n - 1 , left = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { mat [ i ] [ right ] = 1 ; fillRemaining ( i , right , n ) ; right -- ; } else { mat [ i ] [ left ] = 1 ; fillRemaining ( i , left , n ) ; left ++ ; } } } public static void main ( String args [ ] ) { int n = 5 ; constructMatrix ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) System . out . print ( mat [ i ] [ j ] + "" ▁ "" ) ; System . out . println ( ) ; } } } +","MAX = 100 ; NEW_LINE mat = [ [ 0 for x in range ( MAX ) ] for y in range ( MAX ) ] ; NEW_LINE def fillRemaining ( i , j , n ) : NEW_LINE INDENT x = 2 ; NEW_LINE for k in range ( i + 1 , n ) : NEW_LINE INDENT mat [ k ] [ j ] = x ; NEW_LINE x += 1 ; NEW_LINE DEDENT for k in range ( i ) : NEW_LINE INDENT mat [ k ] [ j ] = x ; NEW_LINE x += 1 ; NEW_LINE DEDENT DEDENT def constructMatrix ( n ) : NEW_LINE INDENT right = n - 1 ; NEW_LINE left = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( i % 2 == 0 ) : NEW_LINE INDENT mat [ i ] [ right ] = 1 ; NEW_LINE fillRemaining ( i , right , n ) ; NEW_LINE right -= 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT mat [ i ] [ left ] = 1 ; NEW_LINE fillRemaining ( i , left , n ) ; NEW_LINE left += 1 ; NEW_LINE DEDENT DEDENT DEDENT n = 5 ; NEW_LINE constructMatrix ( n ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE DEDENT +" +E1257,"class Test { static int arr [ ] = { 10 , 20 , 30 , 50 , 10 , 70 , 30 } ; static void printMaxOfMin ( int n ) { for ( int k = 1 ; k <= n ; k ++ ) { int maxOfMin = Integer . MIN_VALUE ; for ( int i = 0 ; i <= n - k ; i ++ ) { int min = arr [ i ] ; for ( int j = 1 ; j < k ; j ++ ) { if ( arr [ i + j ] < min ) min = arr [ i + j ] ; } if ( min > maxOfMin ) maxOfMin = min ; } System . out . print ( maxOfMin + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { printMaxOfMin ( arr . length ) ; } } +","INT_MIN = - 1000000 NEW_LINE def printMaxOfMin ( arr , n ) : NEW_LINE INDENT for k in range ( 1 , n + 1 ) : NEW_LINE INDENT maxOfMin = INT_MIN ; NEW_LINE for i in range ( n - k + 1 ) : NEW_LINE INDENT min = arr [ i ] NEW_LINE for j in range ( k ) : NEW_LINE INDENT if ( arr [ i + j ] < min ) : NEW_LINE INDENT min = arr [ i + j ] NEW_LINE DEDENT DEDENT if ( min > maxOfMin ) : NEW_LINE INDENT maxOfMin = min NEW_LINE DEDENT DEDENT print ( maxOfMin , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 10 , 20 , 30 , 50 , 10 , 70 , 30 ] NEW_LINE n = len ( arr ) NEW_LINE printMaxOfMin ( arr , n ) NEW_LINE +" +E1258,"import java . util . * ; class solution { static int countSubArrays ( int arr [ ] , int n , int K ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int bitwise_or = 0 ; for ( int k = i ; k <= j ; k ++ ) { bitwise_or = bitwise_or | arr [ k ] ; } if ( bitwise_or >= K ) count ++ ; } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 4 , 5 } ; int n = arr . length ; int k = 6 ; System . out . println ( countSubArrays ( arr , n , k ) ) ; } } +","def countSubArrays ( arr , n , K ) : NEW_LINE INDENT count = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i , n ) : NEW_LINE INDENT bitwise_or = 0 NEW_LINE for k in range ( i , j + 1 ) : NEW_LINE INDENT bitwise_or = bitwise_or | arr [ k ] NEW_LINE DEDENT if ( bitwise_or >= K ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 3 , 4 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE k = 6 NEW_LINE print ( countSubArrays ( arr , n , k ) ) NEW_LINE DEDENT +" +E1259,"import java . util . * ; class GFG { static String CHARS = "" qwertyuiopasdfghjklzxcvbnm "" ; static int MAX = 26 ; static String getString ( char [ ] str , int n ) { Map < Character , Character > uMap = new HashMap < > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { uMap . put ( CHARS . charAt ( i ) , CHARS . charAt ( ( i + 1 ) % MAX ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = uMap . get ( str [ i ] ) ; } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String str = "" geeks "" ; int n = str . length ( ) ; System . out . println ( getString ( str . toCharArray ( ) , n ) ) ; } } +","CHARS = "" qwertyuiopasdfghjklzxcvbnm "" ; NEW_LINE MAX = 26 ; NEW_LINE def getString ( string , n ) : NEW_LINE INDENT string = list ( string ) ; NEW_LINE uMap = { } ; NEW_LINE for i in range ( MAX ) : NEW_LINE INDENT uMap [ CHARS [ i ] ] = CHARS [ ( i + 1 ) % MAX ] ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT string [ i ] = uMap [ string [ i ] ] ; NEW_LINE DEDENT return "" "" . join ( string ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" geeks "" ; NEW_LINE n = len ( string ) ; NEW_LINE print ( getString ( string , n ) ) ; NEW_LINE DEDENT +" +E1260,"import java . util . * ; public class SortExample { static void printOrder ( Integer [ ] arr , int k ) { int n = arr . length ; Arrays . sort ( arr , 0 , k ) ; Arrays . sort ( arr , k , n , Collections . reverseOrder ( ) ) ; } public static void main ( String [ ] args ) { Integer [ ] arr = { 5 , 4 , 6 , 2 , 1 , 3 , 8 , 9 , - 1 } ; int k = 4 ; printOrder ( arr , k ) ; System . out . printf ( "" % s "" , Arrays . toString ( arr ) ) ; } } +","def printOrder ( arr , n , k ) : NEW_LINE INDENT a = arr [ 0 : k ] ; NEW_LINE a . sort ( ) ; NEW_LINE b = arr [ k : n ] ; NEW_LINE b . sort ( ) ; NEW_LINE b . reverse ( ) ; NEW_LINE return a + b ; NEW_LINE DEDENT arr = [ 5 , 4 , 6 , 2 , 1 , 3 , 8 , 9 , - 1 ] ; NEW_LINE k = 4 ; NEW_LINE n = len ( arr ) ; NEW_LINE arr = printOrder ( arr , n , k ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT +" +E1261,"import java . lang . Math ; public class GfG { static int countSteps ( int n ) { int steps = 0 ; while ( n > 0 ) { int largest = ( int ) Math . sqrt ( n ) ; n -= ( largest * largest ) ; steps ++ ; } return steps ; } public static void main ( String [ ] args ) { int n = 85 ; System . out . println ( countSteps ( n ) ) ; } } +","from math import sqrt NEW_LINE def countSteps ( n ) : NEW_LINE INDENT steps = 0 ; NEW_LINE while ( n ) : NEW_LINE INDENT largest = int ( sqrt ( n ) ) ; NEW_LINE n -= ( largest * largest ) ; NEW_LINE steps += 1 ; NEW_LINE DEDENT return steps ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 85 ; NEW_LINE print ( countSteps ( n ) ) ; NEW_LINE DEDENT +" +E1262,"import java . io . * ; class GFG { static float Area ( float a ) { if ( a < 0 ) return - 1 ; float h = ( float ) 1.268 * a ; float A = ( float ) ( 0.70477 * Math . pow ( h , 2 ) ) ; return A ; } public static void main ( String [ ] args ) { float a = 5 ; System . out . println ( Area ( a ) ) ; } } +","import math NEW_LINE def Area ( a ) : NEW_LINE INDENT if ( a < 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT h = 1.268 * a NEW_LINE A = 0.70477 * math . pow ( h , 2 ) NEW_LINE return A NEW_LINE DEDENT a = 5 NEW_LINE print ( Area ( a ) , end = "" \n "" ) NEW_LINE +" +E1263,"import java . util . Arrays ; class GFG { static final int SIZE = 26 ; static boolean isVowel ( char ch ) { if ( ch == ' a ' || ch == ' e ' || ch == ' i ' || ch == ' o ' || ch == ' u ' ) { return true ; } return false ; } static String createAltStr ( String str1 , String str2 , int start , int l ) { String finalStr = "" "" ; for ( int i = 0 , j = start ; j < l ; i ++ , j ++ ) { finalStr = ( finalStr + str1 . charAt ( i ) ) + str2 . charAt ( j ) ; } return finalStr ; } static String findAltStr ( String str ) { int char_freq [ ] = new int [ SIZE ] ; Arrays . fill ( char_freq , 0 ) ; int nv = 0 , nc = 0 ; String vstr = "" "" , cstr = "" "" ; int l = str . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { char ch = str . charAt ( i ) ; if ( isVowel ( ch ) ) { nv ++ ; } else { nc ++ ; } char_freq [ ch - 97 ] ++ ; } if ( Math . abs ( nv - nc ) >= 2 ) { return "" no ▁ such ▁ String "" ; } for ( int i = 0 ; i < SIZE ; i ++ ) { char ch = ( char ) ( i + 97 ) ; for ( int j = 1 ; j <= char_freq [ i ] ; j ++ ) { if ( isVowel ( ch ) ) { vstr += ch ; } else { cstr += ch ; } } } if ( nv > nc ) { return ( vstr . charAt ( 0 ) + createAltStr ( cstr , vstr , 1 , nv ) ) ; } if ( nc > nv ) { return ( cstr . charAt ( 0 ) + createAltStr ( vstr , cstr , 1 , nc ) ) ; } if ( cstr . charAt ( 0 ) < vstr . charAt ( 0 ) ) { return createAltStr ( cstr , vstr , 0 , nv ) ; } return createAltStr ( vstr , cstr , 0 , nc ) ; } public static void main ( String [ ] args ) { String str = "" aeroplane "" ; System . out . println ( findAltStr ( str ) ) ; } } +","SIZE = 26 NEW_LINE def isVowel ( ch ) : NEW_LINE INDENT if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def createAltStr ( str1 , str2 , start , l ) : NEW_LINE INDENT finalStr = "" "" NEW_LINE i = 0 NEW_LINE j = start NEW_LINE while j < l : NEW_LINE INDENT finalStr += str1 [ i ] + str2 [ j ] NEW_LINE i += 1 NEW_LINE j += 1 NEW_LINE DEDENT return finalStr NEW_LINE DEDENT def findAltStr ( string ) : NEW_LINE INDENT char_freq = [ 0 ] * SIZE NEW_LINE nv = 0 NEW_LINE nc = 0 NEW_LINE vstr = "" "" NEW_LINE cstr = "" "" NEW_LINE l = len ( string ) NEW_LINE for i in range ( l ) : NEW_LINE INDENT ch = string [ i ] NEW_LINE if isVowel ( ch ) : NEW_LINE INDENT nv += 1 NEW_LINE DEDENT else : NEW_LINE INDENT nc += 1 NEW_LINE DEDENT char_freq [ ord ( ch ) - 97 ] += 1 NEW_LINE DEDENT if abs ( nv - nc ) >= 2 : NEW_LINE INDENT return "" no ▁ such ▁ string "" NEW_LINE DEDENT for i in range ( SIZE ) : NEW_LINE INDENT ch = chr ( i + 97 ) NEW_LINE for j in range ( 1 , char_freq [ i ] + 1 ) : NEW_LINE INDENT if isVowel ( ch ) : NEW_LINE INDENT vstr += ch NEW_LINE DEDENT else : NEW_LINE INDENT cstr += ch NEW_LINE DEDENT DEDENT DEDENT if nv > nc : NEW_LINE INDENT return vstr [ 0 ] + createAltStr ( cstr , vstr , 1 , nv ) NEW_LINE DEDENT if nc > nv : NEW_LINE INDENT return cstr [ 0 ] + createAltStr ( vstr , cstr , 1 , nc ) NEW_LINE DEDENT if cstr [ 0 ] < vstr [ 0 ] : NEW_LINE INDENT return createAltStr ( cstr , vstr , 0 , nv ) NEW_LINE DEDENT return createAltStr ( vstr , cstr , 0 , nc ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" aeroplane "" NEW_LINE print ( findAltStr ( string ) ) NEW_LINE DEDENT +" +E1264,"class GFG { static final int N = 5 ; static final int M = 5 ; static int minOperation ( boolean arr [ ] [ ] ) { int ans = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { for ( int j = M - 1 ; j >= 0 ; j -- ) { if ( arr [ i ] [ j ] == false ) { ans ++ ; for ( int k = 0 ; k <= i ; k ++ ) { for ( int h = 0 ; h <= j ; h ++ ) { if ( arr [ k ] [ h ] == true ) { arr [ k ] [ h ] = false ; } else { arr [ k ] [ h ] = true ; } } } } } } return ans ; } public static void main ( String [ ] args ) { boolean mat [ ] [ ] = { { false , false , true , true , true } , { false , false , false , true , true } , { false , false , false , true , true } , { true , true , true , true , true } , { true , true , true , true , true } } ; System . out . println ( minOperation ( mat ) ) ; } } +","def minOperation ( arr ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( N - 1 , - 1 , - 1 ) : NEW_LINE INDENT for j in range ( M - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( arr [ i ] [ j ] == 0 ) : NEW_LINE INDENT ans += 1 NEW_LINE for k in range ( i + 1 ) : NEW_LINE INDENT for h in range ( j + 1 ) : NEW_LINE INDENT if ( arr [ k ] [ h ] == 1 ) : NEW_LINE INDENT arr [ k ] [ h ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT arr [ k ] [ h ] = 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT mat = [ [ 0 , 0 , 1 , 1 , 1 ] , [ 0 , 0 , 0 , 1 , 1 ] , [ 0 , 0 , 0 , 1 , 1 ] , [ 1 , 1 , 1 , 1 , 1 ] , [ 1 , 1 , 1 , 1 , 1 ] ] NEW_LINE M = 5 NEW_LINE N = 5 NEW_LINE print ( minOperation ( mat ) ) NEW_LINE +" +E1265,"import java . io . * ; class GFG { static void decToOctal ( int n ) { int [ ] octalNum = new int [ 100 ] ; int i = 0 ; while ( n != 0 ) { octalNum [ i ] = n % 8 ; n = n / 8 ; i ++ ; } for ( int j = i - 1 ; j >= 0 ; j -- ) System . out . print ( octalNum [ j ] ) ; } public static void main ( String [ ] args ) { int n = 33 ; decToOctal ( n ) ; } } +","def decToOctal ( n ) : NEW_LINE INDENT octalNum = [ 0 ] * 100 ; NEW_LINE i = 0 ; NEW_LINE while ( n != 0 ) : NEW_LINE INDENT octalNum [ i ] = n % 8 ; NEW_LINE n = int ( n / 8 ) ; NEW_LINE i += 1 ; NEW_LINE DEDENT for j in range ( i - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( octalNum [ j ] , end = "" "" ) ; NEW_LINE DEDENT DEDENT n = 33 ; NEW_LINE decToOctal ( n ) ; NEW_LINE +" +E1266,"class GFG { static boolean isPrime ( long n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 || n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static boolean isFactorialPrime ( long n ) { if ( ! isPrime ( n ) ) return false ; long fact = 1 ; int i = 1 ; while ( fact <= n + 1 ) { fact = fact * i ; if ( n + 1 == fact || n - 1 == fact ) return true ; i ++ ; } return false ; } public static void main ( String args [ ] ) { int n = 23 ; if ( isFactorialPrime ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","from math import sqrt NEW_LINE def isPrime ( n ) : NEW_LINE INDENT if ( n <= 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( n <= 3 ) : NEW_LINE INDENT return True NEW_LINE DEDENT if ( n % 2 == 0 or n % 3 == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( 5 , int ( sqrt ( n ) ) + 1 , 6 ) : NEW_LINE INDENT if ( n % i == 0 or n % ( i + 2 ) == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def isFactorialPrime ( n ) : NEW_LINE INDENT if ( not isPrime ( n ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT fact = 1 NEW_LINE i = 1 NEW_LINE while ( fact <= n + 1 ) : NEW_LINE INDENT fact = fact * i NEW_LINE if ( n + 1 == fact or n - 1 == fact ) : NEW_LINE INDENT return True NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 23 NEW_LINE if ( isFactorialPrime ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1267,"class ConvertNum { static int convert ( int m , int n ) { if ( m == n ) return 0 ; if ( m > n ) return m - n ; if ( m <= 0 && n > 0 ) return - 1 ; if ( n % 2 == 1 ) return 1 + convert ( m , n + 1 ) ; else return 1 + convert ( m , n / 2 ) ; } public static void main ( String [ ] args ) { int m = 3 , n = 11 ; System . out . println ( "" Minimum ▁ number ▁ of ▁ "" + "" operations ▁ : ▁ "" + convert ( m , n ) ) ; } } +","def conver ( m , n ) : NEW_LINE INDENT if ( m == n ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( m > n ) : NEW_LINE INDENT return m - n NEW_LINE DEDENT if ( m <= 0 and n > 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if ( n % 2 == 1 ) : NEW_LINE INDENT return 1 + conver ( m , n + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT return 1 + conver ( m , n / 2 ) NEW_LINE DEDENT DEDENT m = 3 NEW_LINE n = 11 NEW_LINE print ( "" Minimum ▁ number ▁ of ▁ operations ▁ : "" , conver ( m , n ) ) NEW_LINE +" +E1268,"import java . util . Arrays ; import java . util . Collections ; class GFG { static final int MAX = 1000000 ; static boolean [ ] prime = new boolean [ MAX ] ; public static void sieve ( ) { Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } } static void printPrimeQuad ( int n ) { for ( int i = 0 ; i < n - 7 ; i ++ ) { if ( prime [ i ] && prime [ i + 2 ] && prime [ i + 6 ] && prime [ i + 8 ] ) { System . out . println ( i + "" ▁ "" + ( i + 2 ) + "" ▁ "" + ( i + 6 ) + "" ▁ "" + ( i + 8 ) ) ; } } } public static void main ( String [ ] args ) { int n = 20 ; sieve ( ) ; printPrimeQuad ( n ) ; } } +","from math import sqrt NEW_LINE MAX = 100000 NEW_LINE prime = [ True ] * MAX NEW_LINE def sieve ( ) : NEW_LINE INDENT for p in range ( 2 , int ( sqrt ( MAX ) ) + 1 ) : NEW_LINE INDENT if prime [ p ] == True : NEW_LINE INDENT for i in range ( p * 2 , MAX , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def printPrimeQuad ( n ) : NEW_LINE INDENT for i in range ( n - 7 ) : NEW_LINE INDENT if ( prime [ i ] and prime [ i + 2 ] and prime [ i + 6 ] and prime [ i + 8 ] ) : NEW_LINE INDENT print ( i , i + 2 , i + 6 , i + 8 ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT sieve ( ) NEW_LINE n = 20 NEW_LINE printPrimeQuad ( 20 ) NEW_LINE DEDENT +" +E1269,"class GFG { static void sum ( int mat [ ] [ ] , int r , int c ) { int i , j ; int upper_sum = 0 ; int lower_sum = 0 ; for ( i = 0 ; i < r ; i ++ ) for ( j = 0 ; j < c ; j ++ ) { if ( i <= j ) { upper_sum += mat [ i ] [ j ] ; } } System . out . println ( "" Upper ▁ sum ▁ is ▁ "" + upper_sum ) ; for ( i = 0 ; i < r ; i ++ ) for ( j = 0 ; j < c ; j ++ ) { if ( j <= i ) { lower_sum += mat [ i ] [ j ] ; } } System . out . print ( "" Lower ▁ sum ▁ is ▁ "" + lower_sum ) ; } public static void main ( String [ ] args ) { int r = 3 ; int c = 3 ; int mat [ ] [ ] = { { 6 , 5 , 4 } , { 1 , 2 , 5 } , { 7 , 9 , 7 } } ; sum ( mat , r , c ) ; } } +","def Sum ( mat , r , c ) : NEW_LINE INDENT i , j = 0 , 0 ; NEW_LINE upper_sum = 0 ; NEW_LINE lower_sum = 0 ; NEW_LINE for i in range ( r ) : NEW_LINE INDENT for j in range ( c ) : NEW_LINE INDENT if ( i <= j ) : NEW_LINE INDENT upper_sum += mat [ i ] [ j ] ; NEW_LINE DEDENT DEDENT DEDENT print ( "" Upper ▁ sum ▁ is ▁ "" , upper_sum ) ; NEW_LINE for i in range ( r ) : NEW_LINE INDENT for j in range ( c ) : NEW_LINE INDENT if ( j <= i ) : NEW_LINE INDENT lower_sum += mat [ i ] [ j ] ; NEW_LINE DEDENT DEDENT DEDENT print ( "" Lower ▁ sum ▁ is ▁ "" , lower_sum ) ; NEW_LINE DEDENT r = 3 ; NEW_LINE c = 3 ; NEW_LINE mat = [ [ 6 , 5 , 4 ] , [ 1 , 2 , 5 ] , [ 7 , 9 , 7 ] ] ; NEW_LINE Sum ( mat , r , c ) ; NEW_LINE +" +E1270,"class GFG { static void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } static void removeMin ( int arr [ ] , int n ) { int i , minVal = arr [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) minVal = Math . min ( minVal , arr [ i ] ) ; for ( i = 0 ; i < n ; i ++ ) arr [ i ] = arr [ i ] - minVal ; } static void removeFromMax ( int arr [ ] , int n ) { int i , maxVal = arr [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) maxVal = Math . max ( maxVal , arr [ i ] ) ; for ( i = 0 ; i < n ; i ++ ) arr [ i ] = maxVal - arr [ i ] ; } static void modifyArray ( int arr [ ] , int n , int k ) { if ( k % 2 == 0 ) removeMin ( arr , n ) ; else removeFromMax ( arr , n ) ; printArray ( arr , n ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 4 , 8 , 12 , 16 } ; int n = arr . length ; int k = 2 ; modifyArray ( arr , n , k ) ; } } +","def printArray ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT def removeMin ( arr , n ) : NEW_LINE INDENT minVal = arr [ 0 ] ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT minVal = min ( minVal , arr [ i ] ) ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT arr [ i ] = arr [ i ] - minVal ; NEW_LINE DEDENT DEDENT def removeFromMax ( arr , n ) : NEW_LINE INDENT maxVal = arr [ 0 ] ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT maxVal = max ( maxVal , arr [ i ] ) ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT arr [ i ] = maxVal - arr [ i ] ; NEW_LINE DEDENT DEDENT def modifyArray ( arr , n , k ) : NEW_LINE INDENT if ( k % 2 == 0 ) : NEW_LINE INDENT removeMin ( arr , n ) ; NEW_LINE DEDENT else : NEW_LINE INDENT removeFromMax ( arr , n ) ; NEW_LINE DEDENT printArray ( arr , n ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 4 , 8 , 12 , 16 ] ; NEW_LINE n = len ( arr ) NEW_LINE k = 2 ; NEW_LINE modifyArray ( arr , n , k ) ; NEW_LINE DEDENT +" +E1271,"class GFG { static int LongestSubarray ( int a [ ] , int n , int k ) { int [ ] pre = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > k ) pre [ i ] = 1 ; else pre [ i ] = - 1 ; } for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = pre [ i - 1 ] + pre [ i ] ; int len = 0 ; int lo = 1 , hi = n ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; boolean ok = false ; for ( int i = mid - 1 ; i < n ; i ++ ) { int x = pre [ i ] ; if ( i - mid >= 0 ) x -= pre [ i - mid ] ; if ( x > 0 ) { ok = true ; break ; } } if ( ok == true ) { len = mid ; lo = mid + 1 ; } else hi = mid - 1 ; } return len ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 3 , 4 , 5 , 3 , 7 } ; int k = 3 ; int n = a . length ; System . out . println ( LongestSubarray ( a , n , k ) ) ; } } +","def LongestSubarray ( a , n , k ) : NEW_LINE INDENT pre = [ 0 for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] > k ) : NEW_LINE INDENT pre [ i ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT pre [ i ] = - 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT pre [ i ] = pre [ i - 1 ] + pre [ i ] NEW_LINE DEDENT Len = 0 NEW_LINE lo = 1 NEW_LINE hi = n NEW_LINE while ( lo <= hi ) : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE ok = False NEW_LINE for i in range ( mid - 1 , n ) : NEW_LINE INDENT x = pre [ i ] NEW_LINE if ( i - mid >= 0 ) : NEW_LINE INDENT x -= pre [ i - mid ] NEW_LINE DEDENT if ( x > 0 ) : NEW_LINE INDENT ok = True NEW_LINE break NEW_LINE DEDENT DEDENT if ( ok == True ) : NEW_LINE INDENT Len = mid NEW_LINE lo = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT hi = mid - 1 NEW_LINE DEDENT DEDENT return Len NEW_LINE DEDENT a = [ 2 , 3 , 4 , 5 , 3 , 7 ] NEW_LINE k = 3 NEW_LINE n = len ( a ) NEW_LINE print ( LongestSubarray ( a , n , k ) ) NEW_LINE +" +E1272,"import java . io . * ; class GFG { static int findSum ( int n ) { int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= n ; j ++ ) ans += ( i / j ) ; return ans ; } public static void main ( String [ ] args ) { int N = 2 ; System . out . println ( findSum ( N ) ) ; } } +","def findSum ( N ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT for j in range ( 1 , N + 1 ) : NEW_LINE INDENT ans += i // j NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N = 2 NEW_LINE print ( findSum ( N ) ) NEW_LINE +" +E1273,"import java . util . * ; class GFG { static boolean permutation ( int [ ] arr , int n ) { Set < Integer > hash = new HashSet < Integer > ( ) ; int maxEle = 0 ; for ( int i = 0 ; i < n ; i ++ ) { hash . add ( arr [ i ] ) ; maxEle = Math . max ( maxEle , arr [ i ] ) ; } if ( maxEle != n ) return false ; if ( hash . size ( ) == n ) return true ; return false ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 5 , 3 , 2 } ; int n = arr . length ; if ( permutation ( arr , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def permutation ( arr , n ) : NEW_LINE INDENT s = set ( ) NEW_LINE maxEle = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT s . add ( arr [ i ] ) ; NEW_LINE maxEle = max ( maxEle , arr [ i ] ) ; NEW_LINE DEDENT if ( maxEle != n ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( len ( s ) == n ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT return False ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 5 , 3 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE if ( permutation ( arr , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1274,"import java . util . * ; class GFG { static int N = 5 ; static void printHosoya ( int n ) { int dp [ ] [ ] = new int [ N ] [ N ] ; dp [ 0 ] [ 0 ] = dp [ 1 ] [ 0 ] = 1 ; dp [ 1 ] [ 1 ] = 1 ; for ( int i = 2 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i > j ) dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + dp [ i - 2 ] [ j ] ; else dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] + dp [ i - 2 ] [ j - 2 ] ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) System . out . print ( dp [ i ] [ j ] + "" ▁ "" ) ; System . out . println ( "" "" ) ; } } public static void main ( String [ ] args ) { int n = 5 ; printHosoya ( n ) ; } } +","N = 5 NEW_LINE def printHosoya ( n ) : NEW_LINE INDENT dp = [ [ 0 for i in range ( N ) ] for i in range ( N ) ] NEW_LINE dp [ 0 ] [ 0 ] = dp [ 1 ] [ 0 ] = dp [ 1 ] [ 1 ] = 1 NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ( i > j ) : NEW_LINE INDENT dp [ i ] [ j ] = ( dp [ i - 1 ] [ j ] + dp [ i - 2 ] [ j ] ) NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = ( dp [ i - 1 ] [ j - 1 ] + dp [ i - 2 ] [ j - 2 ] ) NEW_LINE DEDENT DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 ) : NEW_LINE INDENT print ( dp [ i ] [ j ] , end = ' ▁ ' ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT n = 5 NEW_LINE printHosoya ( n ) NEW_LINE +" +E1275,"import java . util . Arrays ; import java . io . * ; class GFG { static int pairs_count ( int arr [ ] , int n , int sum ) { int ans = 0 ; Arrays . sort ( arr ) ; int i = 0 , j = n - 1 ; while ( i < j ) { if ( arr [ i ] + arr [ j ] < sum ) i ++ ; else if ( arr [ i ] + arr [ j ] > sum ) j -- ; else { int x = arr [ i ] , xx = i ; while ( ( i < j ) && ( arr [ i ] == x ) ) i ++ ; int y = arr [ j ] , yy = j ; while ( ( j >= i ) && ( arr [ j ] == y ) ) j -- ; if ( x == y ) { int temp = i - xx + yy - j - 1 ; ans += ( temp * ( temp + 1 ) ) / 2 ; } else ans += ( i - xx ) * ( yy - j ) ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 7 , 5 , - 1 } ; int n = arr . length ; int sum = 6 ; System . out . println ( pairs_count ( arr , n , sum ) ) ; } } +","def pairs_count ( arr , n , sum ) : NEW_LINE INDENT ans = 0 NEW_LINE arr = sorted ( arr ) NEW_LINE i , j = 0 , n - 1 NEW_LINE while ( i < j ) : NEW_LINE INDENT if ( arr [ i ] + arr [ j ] < sum ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT elif ( arr [ i ] + arr [ j ] > sum ) : NEW_LINE INDENT j -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT x = arr [ i ] NEW_LINE xx = i NEW_LINE while ( i < j and arr [ i ] == x ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT y = arr [ j ] NEW_LINE yy = j NEW_LINE while ( j >= i and arr [ j ] == y ) : NEW_LINE INDENT j -= 1 NEW_LINE DEDENT if ( x == y ) : NEW_LINE INDENT temp = i - xx + yy - j - 1 NEW_LINE ans += ( temp * ( temp + 1 ) ) // 2 NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( i - xx ) * ( yy - j ) NEW_LINE DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT arr = [ 1 , 5 , 7 , 5 , - 1 ] NEW_LINE n = len ( arr ) NEW_LINE sum = 6 NEW_LINE print ( pairs_count ( arr , n , sum ) ) NEW_LINE +" +E1276,"import java . util . * ; class GFG { static final int MAX = 100005 ; static HashSet < Integer > fibonacci = new HashSet < Integer > ( ) ; static void createHash ( ) { int prev = 0 , curr = 1 ; fibonacci . add ( prev ) ; fibonacci . add ( curr ) ; while ( curr <= MAX ) { int temp = curr + prev ; fibonacci . add ( temp ) ; prev = curr ; curr = temp ; } } static boolean checkArray ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( fibonacci . contains ( arr [ i ] ) ) sum += arr [ i ] ; if ( fibonacci . contains ( sum ) ) return true ; return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 , 8 , 2 } ; int n = arr . length ; createHash ( ) ; if ( checkArray ( arr , n ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","MAX = 100005 NEW_LINE fibonacci = set ( ) NEW_LINE def createHash ( ) : NEW_LINE INDENT global fibonacci NEW_LINE prev , curr = 0 , 1 NEW_LINE fibonacci . add ( prev ) NEW_LINE fibonacci . add ( curr ) NEW_LINE while ( curr <= MAX ) : NEW_LINE INDENT temp = curr + prev NEW_LINE if temp <= MAX : NEW_LINE INDENT fibonacci . add ( temp ) NEW_LINE DEDENT prev = curr NEW_LINE curr = temp NEW_LINE DEDENT DEDENT def checkArray ( arr , n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] in fibonacci ) : NEW_LINE INDENT sum += arr [ i ] NEW_LINE DEDENT DEDENT if ( sum in fibonacci ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 8 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE createHash ( ) NEW_LINE if ( checkArray ( arr , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1277,"class GFG { static void makearrayequal ( int arr [ ] , int n ) { int x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x += ( arr [ i ] & 1 ) ; } System . out . println ( Math . min ( x , n - x ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 3 , 2 , 1 } ; int n = arr . length ; makearrayequal ( arr , n ) ; } } +","def makearrayequal ( arr , n ) : NEW_LINE INDENT x = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT x += arr [ i ] & 1 ; NEW_LINE DEDENT print ( min ( x , n - x ) ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 4 , 3 , 2 , 1 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE makearrayequal ( arr , n ) ; NEW_LINE DEDENT +" +E1278,"import java . util . * ; import java . lang . * ; import java . io . * ; class LinearSearch { static int countRotations ( int arr [ ] , int n ) { int min = arr [ 0 ] , min_index = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( min > arr [ i ] ) { min = arr [ i ] ; min_index = i ; } } return min_index ; } public static void main ( String [ ] args ) { int arr [ ] = { 15 , 18 , 2 , 3 , 6 , 12 } ; int n = arr . length ; System . out . println ( countRotations ( arr , n ) ) ; } } +","def countRotations ( arr , n ) : NEW_LINE INDENT min = arr [ 0 ] NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( min > arr [ i ] ) : NEW_LINE INDENT min = arr [ i ] NEW_LINE min_index = i NEW_LINE DEDENT DEDENT return min_index ; NEW_LINE DEDENT arr = [ 15 , 18 , 2 , 3 , 6 , 12 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countRotations ( arr , n ) ) NEW_LINE +" +E1279,"class GFG { static boolean check ( int s ) { int [ ] freq = new int [ 10 ] ; int r , i ; for ( i = 0 ; i < 10 ; i ++ ) { freq [ i ] = 0 ; } while ( s != 0 ) { r = s % 10 ; s = ( int ) ( s / 10 ) ; freq [ r ] += 1 ; } int xor__ = 0 ; for ( i = 0 ; i < 10 ; i ++ ) { xor__ = xor__ ^ freq [ i ] ; if ( xor__ == 0 ) return true ; else return false ; } return true ; } public static void main ( String [ ] args ) { int s = 122233 ; if ( check ( s ) ) System . out . println ( "" Yes \n "" ) ; else System . out . println ( "" No \n "" ) ; } } +","def check ( s ) : NEW_LINE INDENT freq = [ 0 ] * 10 NEW_LINE while ( s != 0 ) : NEW_LINE INDENT r = s % 10 NEW_LINE s = s // 10 NEW_LINE freq [ r ] += 1 NEW_LINE DEDENT xor = 0 NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT xor = xor ^ freq [ i ] NEW_LINE DEDENT if ( xor == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT s = 122233 NEW_LINE if ( check ( s ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1280,"class GFG { static int count ( int n ) { int cnt = 0 ; int p = 1 ; while ( p <= n ) { cnt ++ ; p *= 2 ; } return cnt ; } public static void main ( String args [ ] ) { int n = 7 ; System . out . print ( count ( n ) ) ; } } +","def count ( n ) : NEW_LINE INDENT cnt = 0 NEW_LINE p = 1 NEW_LINE while ( p <= n ) : NEW_LINE INDENT cnt = cnt + 1 NEW_LINE p *= 2 NEW_LINE DEDENT return cnt NEW_LINE DEDENT n = 7 NEW_LINE print ( count ( n ) ) ; NEW_LINE +" +E1281,"import java . util . * ; class GFG { static void powerSet ( String str , int index , String curr ) { int n = str . length ( ) ; if ( index == n ) { return ; } System . out . println ( curr ) ; for ( int i = index + 1 ; i < n ; i ++ ) { curr += str . charAt ( i ) ; powerSet ( str , i , curr ) ; curr = curr . substring ( 0 , curr . length ( ) - 1 ) ; } } public static void main ( String [ ] args ) { String str = "" abc "" ; int index = - 1 ; String curr = "" "" ; powerSet ( str , index , curr ) ; } } +","def powerSet ( str1 , index , curr ) : NEW_LINE INDENT n = len ( str1 ) NEW_LINE if ( index == n ) : NEW_LINE INDENT return NEW_LINE DEDENT print ( curr ) NEW_LINE for i in range ( index + 1 , n ) : NEW_LINE INDENT curr += str1 [ i ] NEW_LINE powerSet ( str1 , i , curr ) NEW_LINE curr = curr . replace ( curr [ len ( curr ) - 1 ] , "" "" ) NEW_LINE DEDENT return NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = "" abc "" ; NEW_LINE powerSet ( str , - 1 , "" "" ) NEW_LINE DEDENT +" +E1282,"import java . util . HashSet ; import java . util . Iterator ; import java . util . Set ; class GFG { static int findMinimumX ( int a [ ] , int n ) { Set < Integer > st = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) st . add ( a [ i ] ) ; if ( st . size ( ) == 1 ) return 0 ; if ( st . size ( ) == 2 ) { Iterator < Integer > it = st . iterator ( ) ; int el1 = it . next ( ) ; int el2 = it . next ( ) ; if ( ( el2 - el1 ) % 2 == 0 ) return ( el2 - el1 ) / 2 ; else return ( el2 - el1 ) ; } if ( st . size ( ) == 3 ) { Iterator < Integer > it = st . iterator ( ) ; int el1 = it . next ( ) ; int el2 = it . next ( ) ; int el3 = it . next ( ) ; if ( ( el2 - el1 ) == ( el3 - el2 ) ) return el2 - el1 ; else return - 1 ; } return - 1 ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 4 , 4 , 7 , 4 , 1 } ; int n = a . length ; System . out . println ( findMinimumX ( a , n ) ) ; } } +","def findMinimumX ( a , n ) : NEW_LINE INDENT st = set ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT st . add ( a [ i ] ) NEW_LINE DEDENT if ( len ( st ) == 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( len ( st ) == 2 ) : NEW_LINE INDENT st = list ( st ) NEW_LINE el1 = st [ 0 ] NEW_LINE el2 = st [ 1 ] NEW_LINE if ( ( el2 - el1 ) % 2 == 0 ) : NEW_LINE INDENT return int ( ( el2 - el1 ) / 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT return ( el2 - el1 ) NEW_LINE DEDENT DEDENT if ( len ( st ) == 3 ) : NEW_LINE INDENT st = list ( st ) NEW_LINE el1 = st [ 0 ] NEW_LINE el2 = st [ 1 ] NEW_LINE el3 = st [ 2 ] NEW_LINE if ( ( el2 - el1 ) == ( el3 - el2 ) ) : NEW_LINE INDENT return el2 - el1 NEW_LINE DEDENT else : NEW_LINE INDENT return - 1 NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 1 , 4 , 4 , 7 , 4 , 1 ] NEW_LINE n = len ( a ) NEW_LINE print ( findMinimumX ( a , n ) ) NEW_LINE DEDENT +" +E1283,"import java . util . * ; class solution { static void printFirstNegativeInteger ( int arr [ ] , int n , int k ) { boolean flag ; for ( int i = 0 ; i < ( n - k + 1 ) ; i ++ ) { flag = false ; for ( int j = 0 ; j < k ; j ++ ) { if ( arr [ i + j ] < 0 ) { System . out . print ( ( arr [ i + j ] ) + "" ▁ "" ) ; flag = true ; break ; } } if ( ! flag ) System . out . print ( ""0"" + "" ▁ "" ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 12 , - 1 , - 7 , 8 , - 15 , 30 , 16 , 28 } ; int n = arr . length ; int k = 3 ; printFirstNegativeInteger ( arr , n , k ) ; } } +","def printFirstNegativeInteger ( arr , n , k ) : NEW_LINE INDENT for i in range ( 0 , ( n - k + 1 ) ) : NEW_LINE INDENT flag = False NEW_LINE for j in range ( 0 , k ) : NEW_LINE INDENT if ( arr [ i + j ] < 0 ) : NEW_LINE INDENT print ( arr [ i + j ] , end = "" ▁ "" ) NEW_LINE flag = True NEW_LINE break NEW_LINE DEDENT DEDENT if ( not ( flag ) ) : NEW_LINE INDENT print ( ""0"" , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 12 , - 1 , - 7 , 8 , - 15 , 30 , 16 , 28 ] NEW_LINE n = len ( arr ) NEW_LINE k = 3 NEW_LINE printFirstNegativeInteger ( arr , n , k ) NEW_LINE +" +E1284,"class GfG { static void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; System . out . println ( ) ; return ; } static void printSequencesRecur ( int arr [ ] , int n , int k , int index ) { int i ; if ( k == 0 ) { printArray ( arr , index ) ; } if ( k > 0 ) { for ( i = 1 ; i <= n ; ++ i ) { arr [ index ] = i ; printSequencesRecur ( arr , n , k - 1 , index + 1 ) ; } } } static void printSequences ( int n , int k ) { int arr [ ] = new int [ k ] ; printSequencesRecur ( arr , n , k , 0 ) ; return ; } public static void main ( String [ ] args ) { int n = 3 ; int k = 2 ; printSequences ( n , k ) ; } } +","def printArray ( arr , size ) : NEW_LINE INDENT for i in range ( size ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE return ; NEW_LINE DEDENT def printSequencesRecur ( arr , n , k , index ) : NEW_LINE INDENT if ( k == 0 ) : NEW_LINE INDENT printArray ( arr , index ) ; NEW_LINE DEDENT if ( k > 0 ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT arr [ index ] = i ; NEW_LINE printSequencesRecur ( arr , n , k - 1 , index + 1 ) ; NEW_LINE DEDENT DEDENT DEDENT def printSequences ( n , k ) : NEW_LINE INDENT arr = [ 0 ] * n ; NEW_LINE printSequencesRecur ( arr , n , k , 0 ) ; NEW_LINE return ; NEW_LINE DEDENT n = 3 ; NEW_LINE k = 2 ; NEW_LINE printSequences ( n , k ) ; NEW_LINE +" +E1285,"public class GFG { static final int no_of_chars = 256 ; static String findSubString ( String str , String pat ) { int len1 = str . length ( ) ; int len2 = pat . length ( ) ; if ( len1 < len2 ) { System . out . println ( "" No ▁ such ▁ window ▁ exists "" ) ; return "" "" ; } int hash_pat [ ] = new int [ no_of_chars ] ; int hash_str [ ] = new int [ no_of_chars ] ; for ( int i = 0 ; i < len2 ; i ++ ) hash_pat [ pat . charAt ( i ) ] ++ ; int start = 0 , start_index = - 1 , min_len = Integer . MAX_VALUE ; int count = 0 ; for ( int j = 0 ; j < len1 ; j ++ ) { hash_str [ str . charAt ( j ) ] ++ ; if ( hash_pat [ str . charAt ( j ) ] != 0 && hash_str [ str . charAt ( j ) ] <= hash_pat [ str . charAt ( j ) ] ) count ++ ; if ( count == len2 ) { while ( hash_str [ str . charAt ( start ) ] > hash_pat [ str . charAt ( start ) ] || hash_pat [ str . charAt ( start ) ] == 0 ) { if ( hash_str [ str . charAt ( start ) ] > hash_pat [ str . charAt ( start ) ] ) hash_str [ str . charAt ( start ) ] -- ; start ++ ; } int len_window = j - start + 1 ; if ( min_len > len_window ) { min_len = len_window ; start_index = start ; } } } if ( start_index == - 1 ) { System . out . println ( "" No ▁ such ▁ window ▁ exists "" ) ; return "" "" ; } return str . substring ( start_index , start_index + min_len ) ; } public static void main ( String [ ] args ) { String str = "" this ▁ is ▁ a ▁ test ▁ string "" ; String pat = "" tist "" ; System . out . print ( "" Smallest ▁ window ▁ is ▁ : \n ▁ "" + findSubString ( str , pat ) ) ; } } +","no_of_chars = 256 NEW_LINE def findSubString ( string , pat ) : NEW_LINE INDENT len1 = len ( string ) NEW_LINE len2 = len ( pat ) NEW_LINE if len1 < len2 : NEW_LINE INDENT print ( "" No ▁ such ▁ window ▁ exists "" ) NEW_LINE return "" "" NEW_LINE DEDENT hash_pat = [ 0 ] * no_of_chars NEW_LINE hash_str = [ 0 ] * no_of_chars NEW_LINE for i in range ( 0 , len2 ) : NEW_LINE INDENT hash_pat [ ord ( pat [ i ] ) ] += 1 NEW_LINE DEDENT start , start_index , min_len = 0 , - 1 , float ( ' inf ' ) NEW_LINE count = 0 NEW_LINE for j in range ( 0 , len1 ) : NEW_LINE INDENT hash_str [ ord ( string [ j ] ) ] += 1 NEW_LINE if ( hash_pat [ ord ( string [ j ] ) ] != 0 and hash_str [ ord ( string [ j ] ) ] <= hash_pat [ ord ( string [ j ] ) ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if count == len2 : NEW_LINE INDENT while ( hash_str [ ord ( string [ start ] ) ] > hash_pat [ ord ( string [ start ] ) ] or hash_pat [ ord ( string [ start ] ) ] == 0 ) : NEW_LINE INDENT if ( hash_str [ ord ( string [ start ] ) ] > hash_pat [ ord ( string [ start ] ) ] ) : NEW_LINE INDENT hash_str [ ord ( string [ start ] ) ] -= 1 NEW_LINE DEDENT start += 1 NEW_LINE DEDENT len_window = j - start + 1 NEW_LINE if min_len > len_window : NEW_LINE INDENT min_len = len_window NEW_LINE start_index = start NEW_LINE DEDENT DEDENT DEDENT if start_index == - 1 : NEW_LINE INDENT print ( "" No ▁ such ▁ window ▁ exists "" ) NEW_LINE return "" "" NEW_LINE DEDENT return string [ start_index : start_index + min_len ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" this ▁ is ▁ a ▁ test ▁ string "" NEW_LINE pat = "" tist "" NEW_LINE print ( "" Smallest ▁ window ▁ is ▁ : ▁ "" ) NEW_LINE print ( findSubString ( string , pat ) ) NEW_LINE DEDENT +" +E1286,"class ProductArray { void productArray ( int arr [ ] , int n ) { if ( n == 1 ) { System . out . print ( ""0"" ) ; return ; } int i , temp = 1 ; int prod [ ] = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) prod [ j ] = 1 ; for ( i = 0 ; i < n ; i ++ ) { prod [ i ] = temp ; temp *= arr [ i ] ; } temp = 1 ; for ( i = n - 1 ; i >= 0 ; i -- ) { prod [ i ] *= temp ; temp *= arr [ i ] ; } for ( i = 0 ; i < n ; i ++ ) System . out . print ( prod [ i ] + "" ▁ "" ) ; return ; } public static void main ( String [ ] args ) { ProductArray pa = new ProductArray ( ) ; int arr [ ] = { 10 , 3 , 5 , 6 , 2 } ; int n = arr . length ; System . out . println ( "" The ▁ product ▁ array ▁ is ▁ : ▁ "" ) ; pa . productArray ( arr , n ) ; } } +","def productArray ( arr , n ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT print ( 0 ) NEW_LINE return NEW_LINE DEDENT i , temp = 1 , 1 NEW_LINE prod = [ 1 for i in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT prod [ i ] = temp NEW_LINE temp *= arr [ i ] NEW_LINE DEDENT temp = 1 NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT prod [ i ] *= temp NEW_LINE temp *= arr [ i ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( prod [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT return NEW_LINE DEDENT arr = [ 10 , 3 , 5 , 6 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" The ▁ product ▁ array ▁ is : ▁ n "" ) NEW_LINE productArray ( arr , n ) NEW_LINE +" +E1287,"import java . util . Arrays ; class GFG { static int NoofTriplets ( int N , int K ) { int [ ] cnt = new int [ K ] ; Arrays . fill ( cnt , 0 , cnt . length , 0 ) ; for ( int i = 1 ; i <= N ; i += 1 ) { cnt [ i % K ] += 1 ; } if ( ( K & 1 ) != 0 ) { return cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] ; } else { return ( cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] + cnt [ K / 2 ] * cnt [ K / 2 ] * cnt [ K / 2 ] ) ; } } public static void main ( String [ ] args ) { int N = 3 , K = 2 ; System . out . println ( NoofTriplets ( N , K ) ) ; } } +","def NoofTriplets ( N , K ) : NEW_LINE INDENT cnt = [ 0 ] * K ; NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT cnt [ i % K ] += 1 ; NEW_LINE DEDENT if ( K & 1 ) : NEW_LINE INDENT rslt = cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] ; NEW_LINE return rslt NEW_LINE DEDENT else : NEW_LINE INDENT rslt = ( cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] + cnt [ K // 2 ] * cnt [ K // 2 ] * cnt [ K // 2 ] ) ; NEW_LINE return rslt NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 3 ; K = 2 ; NEW_LINE print ( NoofTriplets ( N , K ) ) ; NEW_LINE DEDENT +" +E1288,"class GFG { static void command ( boolean arr [ ] , int a , int b ) { arr [ a ] ^= true ; arr [ b + 1 ] ^= true ; } static void process ( boolean arr [ ] , int n ) { for ( int k = 1 ; k <= n ; k ++ ) { arr [ k ] ^= arr [ k - 1 ] ; } } static void result ( boolean arr [ ] , int n ) { for ( int k = 1 ; k <= n ; k ++ ) { if ( arr [ k ] == true ) System . out . print ( ""1"" + "" ▁ "" ) ; else System . out . print ( ""0"" + "" ▁ "" ) ; } } public static void main ( String args [ ] ) { int n = 5 , m = 3 ; boolean arr [ ] = new boolean [ n + 2 ] ; command ( arr , 1 , 5 ) ; command ( arr , 2 , 5 ) ; command ( arr , 3 , 5 ) ; process ( arr , n ) ; result ( arr , n ) ; } } +","def command ( brr , a , b ) : NEW_LINE INDENT arr [ a ] ^= 1 NEW_LINE arr [ b + 1 ] ^= 1 NEW_LINE DEDENT def process ( arr , n ) : NEW_LINE INDENT for k in range ( 1 , n + 1 , 1 ) : NEW_LINE INDENT arr [ k ] ^= arr [ k - 1 ] NEW_LINE DEDENT DEDENT def result ( arr , n ) : NEW_LINE INDENT for k in range ( 1 , n + 1 , 1 ) : NEW_LINE INDENT print ( arr [ k ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE m = 3 NEW_LINE arr = [ 0 for i in range ( n + 2 ) ] NEW_LINE command ( arr , 1 , 5 ) NEW_LINE command ( arr , 2 , 5 ) NEW_LINE command ( arr , 3 , 5 ) NEW_LINE process ( arr , n ) NEW_LINE result ( arr , n ) NEW_LINE DEDENT +" +E1289,"class GFG { static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int countSetBitsInGivenRange ( int n , int l , int r ) { int num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; return countSetBits ( n & num ) ; } public static void main ( String [ ] args ) { int n = 42 ; int l = 2 , r = 5 ; System . out . print ( countSetBitsInGivenRange ( n , l , r ) ) ; } } +","def countSetBits ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while ( n ) : NEW_LINE INDENT n &= ( n - 1 ) NEW_LINE count = count + 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def countSetBitsInGivenRange ( n , l , r ) : NEW_LINE INDENT num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) NEW_LINE return countSetBits ( n & num ) NEW_LINE DEDENT n = 42 NEW_LINE l = 2 NEW_LINE r = 5 NEW_LINE ans = countSetBitsInGivenRange ( n , l , r ) NEW_LINE print ( ans ) NEW_LINE +" +E1290,"import java . io . * ; class GFG { static long dig ( long a ) { long count = 0 ; while ( a > 0 ) { a /= 10 ; count ++ ; } return count ; } static void required_number ( long num , long n , long d ) { long i , j , power = 1 , a , flag = 0 ; for ( i = num ; i >= 1 ; i -- ) { power = ( long ) Math . pow ( 10 , i ) ; a = n % power ; if ( d > a ) { flag = 1 ; break ; } } if ( flag > 0 ) { long t = 0 ; for ( j = 0 ; j < i ; j ++ ) { t += 9 * Math . pow ( 10 , j ) ; } if ( n % power == t ) System . out . print ( n ) ; else { System . out . print ( n - ( n % power ) - 1 ) ; } } else System . out . print ( n ) ; } public static void main ( String [ ] args ) { long n = 1029 , d = 102 ; long num = dig ( n ) ; required_number ( num , n , d ) ; } } +","def dig ( a ) : NEW_LINE INDENT count = 0 ; NEW_LINE while ( a > 0 ) : NEW_LINE INDENT a /= 10 NEW_LINE count += 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def required_number ( num , n , d ) : NEW_LINE INDENT flag = 0 NEW_LINE power = 0 NEW_LINE a = 0 NEW_LINE for i in range ( num , 0 , - 1 ) : NEW_LINE INDENT power = pow ( 10 , i ) NEW_LINE a = n % power NEW_LINE if ( d > a ) : NEW_LINE INDENT flag = 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ( flag ) : NEW_LINE INDENT t = 0 NEW_LINE for j in range ( 0 , i ) : NEW_LINE INDENT t += 9 * pow ( 10 , j ) NEW_LINE DEDENT if ( n % power == t ) : NEW_LINE INDENT print ( n , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ( n - ( n % power ) - 1 ) , end = "" "" ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( n , end = "" "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 1029 NEW_LINE d = 102 NEW_LINE num = dig ( n ) NEW_LINE required_number ( num , n , d ) NEW_LINE DEDENT +" +E1291,"class GFG { static int CountZeroBit ( int n ) { int count = 0 ; while ( n > 0 ) { if ( ( n & 1 ) != 0 ) count ++ ; n >>= 1 ; } return count ; } static int CountORandSumEqual ( int N ) { int count = CountZeroBit ( N ) ; return ( 1 << count ) ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . print ( CountORandSumEqual ( N ) ) ; } } +","def CountZeroBit ( n ) : NEW_LINE INDENT count = 0 NEW_LINE while ( n ) : NEW_LINE INDENT if ( not ( n & 1 ) ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT n >>= 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def CountORandSumEqual ( N ) : NEW_LINE INDENT count = CountZeroBit ( N ) NEW_LINE return ( 1 << count ) NEW_LINE DEDENT N = 10 NEW_LINE print ( CountORandSumEqual ( N ) ) NEW_LINE +" +E1292,"import java . io . * ; class GFG { static boolean checkConcurrent ( int a1 , int b1 , int c1 , int a2 , int b2 , int c2 , int a3 , int b3 , int c3 ) { return ( a3 * ( b1 * c2 - b2 * c1 ) + b3 * ( c1 * a2 - c2 * a1 ) + c3 * ( a1 * b2 - a2 * b1 ) == 0 ) ; } public static void main ( String [ ] args ) { int a1 = 2 , b1 = - 3 , c1 = 5 ; int a2 = 3 , b2 = 4 , c2 = - 7 ; int a3 = 9 , b3 = - 5 , c3 = 8 ; if ( checkConcurrent ( a1 , b1 , c1 , a2 , b2 , c2 , a3 , b3 , c3 ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def checkConcurrent ( a1 , b1 , c1 , a2 , b2 , c2 , a3 , b3 , c3 ) : NEW_LINE INDENT return ( a3 * ( b1 * c2 - b2 * c1 ) + b3 * ( c1 * a2 - c2 * a1 ) + c3 * ( a1 * b2 - a2 * b1 ) == 0 ) NEW_LINE DEDENT a1 = 2 NEW_LINE b1 = - 3 NEW_LINE c1 = 5 NEW_LINE a2 = 3 NEW_LINE b2 = 4 NEW_LINE c2 = - 7 NEW_LINE a3 = 9 NEW_LINE b3 = - 5 NEW_LINE c3 = 8 NEW_LINE if ( checkConcurrent ( a1 , b1 , c1 , a2 , b2 , c2 , a3 , b3 , c3 ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1293,"import java . util . * ; class GFG { static String winner ( String moves ) { HashMap < Character , Integer > data = new HashMap < Character , Integer > ( ) ; data . put ( ' R ' , 0 ) ; data . put ( ' P ' , 1 ) ; data . put ( ' S ' , 2 ) ; if ( moves . charAt ( 0 ) == moves . charAt ( 1 ) ) { return "" Draw "" ; } if ( ( ( data . get ( moves . charAt ( 0 ) ) | 1 << ( 2 ) ) - ( data . get ( moves . charAt ( 1 ) ) | 0 << ( 2 ) ) ) % 3 != 0 ) { return "" A "" ; } return "" B "" ; } static void performQueries ( String arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( winner ( arr [ i ] ) + "" \n "" ) ; } public static void main ( String [ ] args ) { String arr [ ] = { "" RS "" , "" SR "" , "" SP "" , "" PP "" } ; int n = arr . length ; performQueries ( arr , n ) ; } } +","def winner ( moves ) : NEW_LINE INDENT data = dict ( ) NEW_LINE data [ ' R ' ] = 0 NEW_LINE data [ ' P ' ] = 1 NEW_LINE data [ ' S ' ] = 2 NEW_LINE if ( moves [ 0 ] == moves [ 1 ] ) : NEW_LINE INDENT return "" Draw "" NEW_LINE DEDENT if ( ( ( data [ moves [ 0 ] ] | 1 << ( 2 ) ) - ( data [ moves [ 1 ] ] | 0 << ( 2 ) ) ) % 3 ) : NEW_LINE INDENT return "" A "" NEW_LINE DEDENT return "" B "" NEW_LINE DEDENT def performQueries ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( winner ( arr [ i ] ) ) NEW_LINE DEDENT DEDENT arr = [ "" RS "" , "" SR "" , "" SP "" , "" PP "" ] NEW_LINE n = len ( arr ) NEW_LINE performQueries ( arr , n ) NEW_LINE +" +E1294,"import java . util . HashSet ; class GFG1 { static int MAX = 100000 ; static long catalan [ ] = new long [ MAX ] ; static void catalanDP ( long n ) { catalan [ 0 ] = catalan [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { catalan [ i ] = 0 ; for ( int j = 0 ; j < i ; j ++ ) { catalan [ i ] += catalan [ j ] * catalan [ i - j - 1 ] ; } } } static int CatalanSequence ( int arr [ ] , int n ) { catalanDP ( n ) ; HashSet < Integer > s = new HashSet < Integer > ( ) ; int a = 1 , b = 1 ; int c ; s . add ( a ) ; if ( n >= 2 ) { s . add ( b ) ; } for ( int i = 2 ; i < n ; i ++ ) { s . add ( ( int ) catalan [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( s . contains ( arr [ i ] ) ) { s . remove ( arr [ i ] ) ; } } return s . size ( ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 5 , 41 } ; int n = arr . length ; System . out . print ( CatalanSequence ( arr , n ) ) ; } } +","MAX = 100000 ; NEW_LINE catalan = [ 0 ] * MAX ; NEW_LINE def catalanDP ( n ) : NEW_LINE INDENT catalan [ 0 ] = catalan [ 1 ] = 1 ; NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT catalan [ i ] = 0 ; NEW_LINE for j in range ( i ) : NEW_LINE INDENT catalan [ i ] += ( catalan [ j ] * catalan [ i - j - 1 ] ) ; NEW_LINE DEDENT DEDENT DEDENT def CatalanSequence ( arr , n ) : NEW_LINE INDENT catalanDP ( n ) ; NEW_LINE s = set ( ) ; NEW_LINE a = 1 ; b = 1 ; NEW_LINE s . add ( a ) ; NEW_LINE if ( n >= 2 ) : NEW_LINE INDENT s . add ( b ) ; NEW_LINE DEDENT for i in range ( 2 , n ) : NEW_LINE INDENT s . add ( catalan [ i ] ) ; NEW_LINE DEDENT temp = set ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] in s : NEW_LINE INDENT temp . add ( arr [ i ] ) NEW_LINE DEDENT DEDENT s = s - temp ; NEW_LINE return len ( s ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 1 , 2 , 5 , 41 ] ; NEW_LINE n = len ( arr ) NEW_LINE print ( CatalanSequence ( arr , n ) ) ; NEW_LINE DEDENT +" +E1295,"import java . util . * ; class GFG { static void removeAnagrams ( String arr [ ] , int N ) { Vector < String > ans = new Vector < String > ( ) ; HashSet < String > found = new HashSet < String > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { String word = arr [ i ] ; word = sort ( word ) ; if ( ! found . contains ( word ) ) { ans . add ( arr [ i ] ) ; found . add ( word ) ; } } Collections . sort ( ans ) ; for ( int i = 0 ; i < ans . size ( ) ; ++ i ) { System . out . print ( ans . get ( i ) + "" ▁ "" ) ; } } static String sort ( String inputString ) { char tempArray [ ] = inputString . toCharArray ( ) ; Arrays . sort ( tempArray ) ; return new String ( tempArray ) ; } public static void main ( String [ ] args ) { String arr [ ] = { "" geeks "" , "" keegs "" , "" code "" , "" doce "" } ; int N = 4 ; removeAnagrams ( arr , N ) ; } } +","def removeAnagrams ( arr , N ) : NEW_LINE INDENT ans = [ ] NEW_LINE found = dict ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT word = arr [ i ] NEW_LINE word = "" ▁ "" . join ( sorted ( word ) ) NEW_LINE if ( word not in found ) : NEW_LINE INDENT ans . append ( arr [ i ] ) NEW_LINE found [ word ] = 1 NEW_LINE DEDENT DEDENT ans = sorted ( ans ) NEW_LINE for i in range ( len ( ans ) ) : NEW_LINE INDENT print ( ans [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ "" geeks "" , "" keegs "" , "" code "" , "" doce "" ] NEW_LINE N = 4 NEW_LINE removeAnagrams ( arr , N ) NEW_LINE DEDENT +" +E1296,"import java . io . * ; class GFG { static int findMaximumNum ( int arr [ ] , int n ) { for ( int i = n ; i >= 1 ; i -- ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( i <= arr [ j ] ) count ++ ; if ( count >= i ) return i ; } return 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 8 , 10 } ; int n = arr . length ; System . out . println ( findMaximumNum ( arr , n ) ) ; } } +","def findMaximumNum ( arr , n ) : NEW_LINE INDENT i = n NEW_LINE while ( i >= 1 ) : NEW_LINE INDENT count = 0 NEW_LINE for j in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( i <= arr [ j ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if ( count >= i ) : NEW_LINE INDENT return i NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT return 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 8 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE print ( findMaximumNum ( arr , n ) ) NEW_LINE DEDENT +" +E1297,"class solution { static void printSubArrays ( int [ ] arr , int start , int end ) { if ( end == arr . length ) return ; else if ( start > end ) printSubArrays ( arr , 0 , end + 1 ) ; else { System . out . print ( "" [ "" ) ; for ( int i = start ; i < end ; i ++ ) { System . out . print ( arr [ i ] + "" , ▁ "" ) ; } System . out . println ( arr [ end ] + "" ] "" ) ; printSubArrays ( arr , start + 1 , end ) ; } return ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 2 , 3 } ; printSubArrays ( arr , 0 , 0 ) ; } } +","def printSubArrays ( arr , start , end ) : NEW_LINE INDENT if end == len ( arr ) : NEW_LINE INDENT return NEW_LINE DEDENT elif start > end : NEW_LINE INDENT return printSubArrays ( arr , 0 , end + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( arr [ start : end + 1 ] ) NEW_LINE return printSubArrays ( arr , start + 1 , end ) NEW_LINE DEDENT DEDENT arr = [ 1 , 2 , 3 ] NEW_LINE printSubArrays ( arr , 0 , 0 ) NEW_LINE +" +E1298,"import java . util . * ; class GFG { static int setBit ( int xorValue ) { int count = 0 ; while ( xorValue >= 1 ) { if ( xorValue % 2 == 1 ) count ++ ; xorValue /= 2 ; } return count ; } static int minFlip ( int n , int k ) { int size = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ; int max = ( int ) Math . pow ( 2 , k ) - 1 ; max = max << ( size - k ) ; int xorValue = ( n ^ max ) ; return ( setBit ( xorValue ) ) ; } public static void main ( String [ ] args ) { int n = 27 , k = 3 ; System . out . println ( "" Min ▁ Flips ▁ = ▁ "" + minFlip ( n , k ) ) ; } } +","import math NEW_LINE def setBit ( xorValue ) : NEW_LINE INDENT count = 0 NEW_LINE while ( xorValue ) : NEW_LINE INDENT if ( xorValue % 2 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT xorValue = int ( xorValue / 2 ) NEW_LINE DEDENT return count NEW_LINE DEDENT def minFlip ( n , k ) : NEW_LINE INDENT size = int ( math . log ( n ) / math . log ( 2 ) + 1 ) NEW_LINE max = pow ( 2 , k ) - 1 NEW_LINE max = max << ( size - k ) NEW_LINE xorValue = ( n ^ max ) NEW_LINE return ( setBit ( xorValue ) ) NEW_LINE DEDENT n = 27 NEW_LINE k = 3 NEW_LINE print ( "" Min ▁ Flips ▁ = ▁ "" , minFlip ( n , k ) ) NEW_LINE +" +E1299,"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static boolean isVowel ( char x ) { if ( x == ' a ' || x == ' e ' || x == ' i ' || x == ' o ' || x == ' u ' ) return true ; else return false ; } static String updateSandwichedVowels ( String a ) { int n = a . length ( ) ; String updatedString = "" "" ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 || i == n - 1 ) { updatedString += a . charAt ( i ) ; continue ; } if ( isVowel ( a . charAt ( i ) ) == true && isVowel ( a . charAt ( i - 1 ) ) == false && isVowel ( a . charAt ( i + 1 ) ) == false ) { continue ; } updatedString += a . charAt ( i ) ; } return updatedString ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; String updatedString = updateSandwichedVowels ( str ) ; System . out . print ( updatedString ) ; } } +","def isVowel ( x ) : NEW_LINE INDENT if ( x == ' a ' or x == ' e ' or x == ' i ' or x == ' o ' or x == ' u ' ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT def updateSandwichedVowels ( a ) : NEW_LINE INDENT n = len ( a ) NEW_LINE updatedString = "" "" NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( i == 0 or i == n - 1 ) : NEW_LINE INDENT updatedString += a [ i ] NEW_LINE continue NEW_LINE DEDENT if ( isVowel ( a [ i ] ) == True and isVowel ( a [ i - 1 ] ) == False and isVowel ( a [ i + 1 ] ) == False ) : NEW_LINE INDENT continue NEW_LINE DEDENT updatedString += a [ i ] NEW_LINE DEDENT return updatedString NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = "" geeksforgeeks "" NEW_LINE updatedString = updateSandwichedVowels ( str ) NEW_LINE print ( updatedString ) NEW_LINE DEDENT +" +E1300,"import java . io . * ; class GFG { static int totalWays ( int N , int M , int X ) { int dp [ ] [ ] = new int [ N + 1 ] [ 2 ] ; if ( X == 1 ) { dp [ 0 ] [ 0 ] = 1 ; } else { dp [ 0 ] [ 1 ] = 0 ; } if ( X == 1 ) { dp [ 1 ] [ 0 ] = 0 ; dp [ 1 ] [ 1 ] = M - 1 ; } else { dp [ 1 ] [ 0 ] = 1 ; dp [ 1 ] [ 1 ] = ( M - 2 ) ; } for ( int i = 2 ; i < N ; i ++ ) { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] * ( M - 1 ) + dp [ i - 1 ] [ 1 ] * ( M - 2 ) ; } return dp [ N - 1 ] [ 0 ] ; } public static void main ( String [ ] args ) { int N = 4 , M = 3 , X = 2 ; System . out . println ( totalWays ( N , M , X ) ) ; } } +","def totalWays ( N , M , X ) : NEW_LINE INDENT dp = [ [ 0 for i in range ( 2 ) ] for j in range ( N + 1 ) ] NEW_LINE if ( X == 1 ) : NEW_LINE INDENT dp [ 0 ] [ 0 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ 0 ] [ 1 ] = 0 NEW_LINE DEDENT if ( X == 1 ) : NEW_LINE INDENT dp [ 1 ] [ 0 ] = 0 NEW_LINE dp [ 1 ] [ 1 ] = M - 1 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ 1 ] [ 0 ] = 1 NEW_LINE dp [ 1 ] [ 1 ] = ( M - 2 ) NEW_LINE DEDENT for i in range ( 2 , N ) : NEW_LINE INDENT dp [ i ] [ 0 ] = dp [ i - 1 ] [ 1 ] NEW_LINE dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] * ( M - 1 ) + dp [ i - 1 ] [ 1 ] * ( M - 2 ) NEW_LINE DEDENT return dp [ N - 1 ] [ 0 ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 4 NEW_LINE M = 3 NEW_LINE X = 2 NEW_LINE print ( totalWays ( N , M , X ) ) NEW_LINE DEDENT +" +E1301,"import java . util . Arrays ; class GFG { static int findMinimal ( int [ ] a , int n ) { Arrays . sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) sum += ( a [ i ] + a [ n - i - 1 ] ) * ( a [ i ] + a [ n - i - 1 ] ) ; return sum ; } public static void main ( String str [ ] ) { int [ ] a = { 8 , 5 , 2 , 3 } ; int n = a . length ; System . out . println ( findMinimal ( a , n ) ) ; } } +","def findMinimal ( a , n ) : NEW_LINE INDENT a . sort ( ) NEW_LINE sum = 0 NEW_LINE for i in range ( n // 2 ) : NEW_LINE INDENT sum += ( ( a [ i ] + a [ n - i - 1 ] ) * ( a [ i ] + a [ n - i - 1 ] ) ) NEW_LINE DEDENT return sum NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 8 , 5 , 2 , 3 ] NEW_LINE n = len ( a ) NEW_LINE print ( findMinimal ( a , n ) ) NEW_LINE DEDENT +" +E1302,"class GFG { static int minOperations ( String str , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( i + 1 ) ) count ++ ; } return ( count + 1 ) / 2 ; } public static void main ( String [ ] args ) { String str = ""000111"" ; int n = str . length ( ) ; System . out . println ( minOperations ( str , n ) ) ; } } +","def minOperations ( str , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( str [ i ] != str [ i + 1 ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return ( count + 1 ) // 2 NEW_LINE DEDENT str = ""000111"" NEW_LINE n = len ( str ) NEW_LINE print ( minOperations ( str , n ) ) NEW_LINE +" +E1303,"class GFG { static int toDecimal ( String binary , int i ) { int n = binary . length ( ) ; if ( i == n - 1 ) return binary . charAt ( i ) - '0' ; return ( ( binary . charAt ( i ) - '0' ) << ( n - i - 1 ) ) + toDecimal ( binary , i + 1 ) ; } public static void main ( String [ ] args ) { String binary = ""1010"" ; int i = 0 ; System . out . println ( toDecimal ( binary , i ) ) ; } } +","def toDecimal ( binary , i = 0 ) : NEW_LINE INDENT n = len ( binary ) NEW_LINE if ( i == n - 1 ) : NEW_LINE INDENT return int ( binary [ i ] ) - 0 NEW_LINE DEDENT return ( ( ( int ( binary [ i ] ) - 0 ) << ( n - i - 1 ) ) + toDecimal ( binary , i + 1 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT binary = ""1010"" NEW_LINE print ( toDecimal ( binary ) ) NEW_LINE DEDENT +" +E1304,"class GFG { public static int countPairs ( int n ) { int num = ( ( n / 2 ) + 1 ) ; int max = n % num ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { int val = ( ( n % i ) % j ) % n ; if ( val == max ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( countPairs ( n ) ) ; } } +","def countPairs ( n ) : NEW_LINE INDENT num = ( ( n // 2 ) + 1 ) NEW_LINE Max = n % num NEW_LINE count = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT val = ( ( n % i ) % j ) % n NEW_LINE if ( val == Max ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT n = 5 NEW_LINE print ( countPairs ( n ) ) NEW_LINE +" +E1305,"import java . util . * ; class GFG { static void createHash ( HashSet < Integer > hash , int maxElement ) { int prev = 0 , curr = 1 ; hash . add ( prev ) ; hash . add ( curr ) ; while ( curr <= maxElement ) { int temp = curr + prev ; hash . add ( temp ) ; prev = curr ; curr = temp ; } } static void fibonacci ( int arr [ ] , int n ) { int max_val = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; HashSet < Integer > hash = new HashSet < Integer > ( ) ; createHash ( hash , max_val ) ; int minimum = Integer . MAX_VALUE ; int maximum = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash . contains ( arr [ i ] ) ) { minimum = Math . min ( minimum , arr [ i ] ) ; maximum = Math . max ( maximum , arr [ i ] ) ; } } System . out . print ( minimum + "" , ▁ "" + maximum + "" \n "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; int n = arr . length ; fibonacci ( arr , n ) ; } } +","import sys NEW_LINE def createHash ( hash , maxElement ) : NEW_LINE INDENT prev = 0 NEW_LINE curr = 1 NEW_LINE hash . add ( prev ) NEW_LINE hash . add ( curr ) NEW_LINE while ( curr <= maxElement ) : NEW_LINE INDENT temp = curr + prev NEW_LINE hash . add ( temp ) NEW_LINE prev = curr NEW_LINE curr = temp NEW_LINE DEDENT DEDENT def fibonacci ( arr , n ) : NEW_LINE INDENT max_val = max ( arr ) NEW_LINE hash = set ( ) NEW_LINE createHash ( hash , max_val ) NEW_LINE minimum = sys . maxsize NEW_LINE maximum = - sys . maxsize - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] in hash ) : NEW_LINE INDENT minimum = min ( minimum , arr [ i ] ) NEW_LINE maximum = max ( maximum , arr [ i ] ) NEW_LINE DEDENT DEDENT print ( minimum , end = "" , ▁ "" ) NEW_LINE print ( maximum ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE fibonacci ( arr , n ) NEW_LINE DEDENT +" +E1306,"class GFG { static void printInSortedOrder ( String arr [ ] , int n ) { int index [ ] = new int [ n ] ; int i , j , min ; for ( i = 0 ; i < n ; i ++ ) { index [ i ] = i ; } for ( i = 0 ; i < n - 1 ; i ++ ) { min = i ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ index [ min ] ] . compareTo ( arr [ index [ j ] ] ) > 0 ) { min = j ; } } if ( min != i ) { int temp = index [ min ] ; index [ min ] = index [ i ] ; index [ i ] = temp ; } } for ( i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ index [ i ] ] + "" ▁ "" ) ; } } static public void main ( String [ ] args ) { String arr [ ] = { "" geeks "" , "" quiz "" , "" geeks "" , "" for "" } ; int n = 4 ; printInSortedOrder ( arr , n ) ; } } +","def printInSortedOrder ( arr , n ) : NEW_LINE INDENT index = [ 0 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT index [ i ] = i NEW_LINE DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT min = i NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( arr [ index [ min ] ] > arr [ index [ j ] ] ) : NEW_LINE INDENT min = j NEW_LINE DEDENT DEDENT if ( min != i ) : NEW_LINE INDENT index [ min ] , index [ i ] = index [ i ] , index [ min ] NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ index [ i ] ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ "" geeks "" , "" quiz "" , "" geeks "" , "" for "" ] NEW_LINE n = 4 NEW_LINE printInSortedOrder ( arr , n ) NEW_LINE DEDENT +" +E1307,"class GfG { static long binomialCoeff ( int n , int k ) { long res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static long countPaths ( int x1 , int y1 , int x2 , int y2 ) { int m = Math . abs ( x1 - x2 ) ; int n = Math . abs ( y1 - y2 ) ; return ( binomialCoeff ( m + n , n ) ) ; } public static void main ( String [ ] args ) { int x1 = 2 , y1 = 3 , x2 = 4 , y2 = 5 ; System . out . println ( countPaths ( x1 , y1 , x2 , y2 ) ) ; } } +","def binomialCoeff ( n , k ) : NEW_LINE INDENT res = 1 NEW_LINE if ( k > n - k ) : NEW_LINE INDENT k = n - k NEW_LINE DEDENT for i in range ( k ) : NEW_LINE INDENT res *= ( n - i ) NEW_LINE res //= ( i + 1 ) NEW_LINE DEDENT return res NEW_LINE DEDENT def countPaths ( x1 , y1 , x2 , y2 ) : NEW_LINE INDENT m = abs ( x1 - x2 ) NEW_LINE n = abs ( y1 - y2 ) NEW_LINE return ( binomialCoeff ( m + n , n ) ) NEW_LINE DEDENT x1 , y1 , x2 , y2 = 2 , 3 , 4 , 5 NEW_LINE print ( countPaths ( x1 , y1 , x2 , y2 ) ) NEW_LINE +" +E1308,"import java . io . * ; class GFG { static int findN ( int k ) { int ans ; if ( k == 0 ) ans = 3 ; if ( k == 1 ) ans = 1 ; else if ( k % 4 == 0 ) ans = k ; else if ( k % 4 == 3 ) ans = k - 1 ; else ans = - 1 ; return ans ; } public static void main ( String [ ] args ) { int k = 7 ; int res = findN ( k ) ; if ( res == - 1 ) System . out . println ( "" Not ▁ possible "" ) ; else System . out . println ( res ) ; } } +","def findN ( k ) : NEW_LINE INDENT if ( k == 0 ) : NEW_LINE INDENT ans = 3 NEW_LINE DEDENT if ( k == 1 ) : NEW_LINE INDENT ans = 1 NEW_LINE DEDENT elif ( k % 4 == 0 ) : NEW_LINE INDENT ans = k NEW_LINE DEDENT elif ( k % 4 == 3 ) : NEW_LINE INDENT ans = k - 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = - 1 NEW_LINE DEDENT return ans NEW_LINE DEDENT k = 7 NEW_LINE res = findN ( k ) NEW_LINE if ( res == - 1 ) : NEW_LINE INDENT print ( "" Not ▁ possible "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( res ) NEW_LINE DEDENT +" +E1309,"class GFG { static void print_asterisk ( int asterisk ) { if ( asterisk == 0 ) return ; System . out . print ( "" * ▁ "" ) ; print_asterisk ( asterisk - 1 ) ; } static void print_space ( int space ) { if ( space == 0 ) return ; System . out . print ( "" ▁ "" ) ; System . out . print ( "" ▁ "" ) ; print_space ( space - 1 ) ; } static void pattern ( int n , int num ) { if ( n == 0 ) return ; print_asterisk ( num - n + 1 ) ; print_space ( 2 * n - 1 ) ; print_asterisk ( num - n + 1 ) ; System . out . println ( ) ; pattern ( n - 1 , num ) ; } public static void main ( String [ ] args ) { int n = 5 ; pattern ( n , n ) ; } } +","def print_asterisk ( asterisk ) : NEW_LINE INDENT if ( asterisk == 0 ) : NEW_LINE INDENT return ; NEW_LINE DEDENT print ( "" * "" , end = "" ▁ "" ) ; NEW_LINE print_asterisk ( asterisk - 1 ) ; NEW_LINE DEDENT def print_space ( space ) : NEW_LINE INDENT if ( space == 0 ) : NEW_LINE INDENT return ; NEW_LINE DEDENT print ( "" ▁ "" , end = "" "" ) ; NEW_LINE print ( "" ▁ "" , end = "" "" ) ; NEW_LINE print_space ( space - 1 ) ; NEW_LINE DEDENT def pattern ( n , num ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return ; NEW_LINE DEDENT print_asterisk ( num - n + 1 ) ; NEW_LINE print_space ( 2 * n - 1 ) ; NEW_LINE print_asterisk ( num - n + 1 ) ; NEW_LINE print ( ) ; NEW_LINE pattern ( n - 1 , num ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 ; NEW_LINE pattern ( n , n ) ; NEW_LINE DEDENT +" +E1310,"import java . lang . * ; import java . util . * ; class GFG { static int isMultipleOf3 ( int n ) { int odd_count = 0 ; int even_count = 0 ; if ( n < 0 ) n = - n ; if ( n == 0 ) return 1 ; if ( n == 1 ) return 0 ; while ( n != 0 ) { if ( ( n & 1 ) != 0 ) odd_count ++ ; if ( ( n & 2 ) != 0 ) even_count ++ ; n = n >> 2 ; } return isMultipleOf3 ( Math . abs ( odd_count - even_count ) ) ; } public static void main ( String [ ] args ) { int num = 24 ; if ( isMultipleOf3 ( num ) != 0 ) System . out . println ( num + "" ▁ is ▁ multiple ▁ of ▁ 3"" ) ; else System . out . println ( num + "" ▁ is ▁ not ▁ a ▁ multiple ▁ of ▁ 3"" ) ; } } +","def isMultipleOf3 ( n ) : NEW_LINE INDENT odd_count = 0 NEW_LINE even_count = 0 NEW_LINE if ( n < 0 ) : NEW_LINE INDENT n = - n NEW_LINE DEDENT if ( n == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( n == 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT while ( n ) : NEW_LINE INDENT if ( n & 1 ) : NEW_LINE INDENT odd_count += 1 NEW_LINE DEDENT if ( n & 2 ) : NEW_LINE INDENT even_count += 1 NEW_LINE DEDENT n = n >> 2 NEW_LINE DEDENT return isMultipleOf3 ( abs ( odd_count - even_count ) ) NEW_LINE DEDENT num = 24 NEW_LINE if ( isMultipleOf3 ( num ) ) : NEW_LINE INDENT print ( num , ' is ▁ multiple ▁ of ▁ 3' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( num , ' is ▁ not ▁ a ▁ multiple ▁ of ▁ 3' ) NEW_LINE DEDENT +" +E1311,"class GFG { static float findNumber ( int N , int S ) { float i = ( ( ( float ) ( N ) * ( float ) ( N + 1 ) ) / 4 ) - ( ( float ) ( S + 1 ) / 2 ) ; return i ; } static void check ( int N , int S ) { float i = findNumber ( N , S ) ; int integerI = ( int ) i ; if ( i - integerI == 0 ) System . out . println ( "" Yes : ▁ "" + integerI + "" , ▁ "" + ( integerI + 1 ) ) ; else System . out . println ( "" No "" ) ; } public static void main ( String [ ] args ) { int N = 4 , S = 3 ; check ( N , S ) ; N = 5 ; S = 3 ; check ( N , S ) ; } } +","def findNumber ( N , S ) : NEW_LINE INDENT i = ( ( ( N ) * ( N + 1 ) ) / 4 ) - ( ( S + 1 ) / 2 ) ; NEW_LINE return i ; NEW_LINE DEDENT def check ( N , S ) : NEW_LINE INDENT i = findNumber ( N , S ) ; NEW_LINE integerI = int ( i ) ; NEW_LINE if ( i - integerI == 0 ) : NEW_LINE INDENT print ( "" Yes : "" , integerI , "" , "" , integerI + 1 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 4 ; NEW_LINE S = 3 ; NEW_LINE check ( N , S ) ; NEW_LINE N = 5 ; NEW_LINE S = 3 ; NEW_LINE check ( N , S ) ; NEW_LINE DEDENT +" +E1312,"class GFG { static void thirdLargest ( int arr [ ] , int arr_size ) { if ( arr_size < 3 ) { System . out . printf ( "" ▁ Invalid ▁ Input ▁ "" ) ; return ; } int first = arr [ 0 ] , second = Integer . MIN_VALUE , third = Integer . MIN_VALUE ; for ( int i = 1 ; i < arr_size ; i ++ ) { if ( arr [ i ] > first ) { third = second ; second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second ) { third = second ; second = arr [ i ] ; } else if ( arr [ i ] > third ) { third = arr [ i ] ; } } System . out . printf ( "" The ▁ third ▁ Largest ▁ element ▁ is ▁ % d \n "" , third ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 13 , 1 , 10 , 34 , 16 } ; int n = arr . length ; thirdLargest ( arr , n ) ; } } +","import sys NEW_LINE def thirdLargest ( arr , arr_size ) : NEW_LINE INDENT if ( arr_size < 3 ) : NEW_LINE INDENT print ( "" ▁ Invalid ▁ Input ▁ "" ) NEW_LINE return NEW_LINE DEDENT first = arr [ 0 ] NEW_LINE second = - sys . maxsize NEW_LINE third = - sys . maxsize NEW_LINE for i in range ( 1 , arr_size ) : NEW_LINE INDENT if ( arr [ i ] > first ) : NEW_LINE INDENT third = second NEW_LINE second = first NEW_LINE first = arr [ i ] NEW_LINE DEDENT elif ( arr [ i ] > second ) : NEW_LINE INDENT third = second NEW_LINE second = arr [ i ] NEW_LINE DEDENT elif ( arr [ i ] > third ) : NEW_LINE INDENT third = arr [ i ] NEW_LINE DEDENT DEDENT print ( "" The ▁ third ▁ Largest "" , "" element ▁ is "" , third ) NEW_LINE DEDENT arr = [ 12 , 13 , 1 , 10 , 34 , 16 ] NEW_LINE n = len ( arr ) NEW_LINE thirdLargest ( arr , n ) NEW_LINE +" +E1313,"class GFG { static int gcd ( int a , int b ) { if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } static int squarearea ( int l , int b ) { if ( l < 0 || b < 0 ) return - 1 ; int n = ( l * b ) / gcd ( l , b ) ; return n * n ; } public static void main ( String [ ] args ) { int l = 6 , b = 4 ; System . out . println ( squarearea ( l , b ) ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 or b == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( a == b ) : NEW_LINE INDENT return a NEW_LINE DEDENT if ( a > b ) : NEW_LINE INDENT return gcd ( a - b , b ) NEW_LINE DEDENT return gcd ( a , b - a ) NEW_LINE DEDENT def squarearea ( l , b ) : NEW_LINE INDENT if ( l < 0 or b < 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT n = ( l * b ) / gcd ( l , b ) NEW_LINE return n * n NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT l = 6 NEW_LINE b = 4 NEW_LINE print ( int ( squarearea ( l , b ) ) ) NEW_LINE DEDENT +" +E1314,"class GFG { static int countUnsetBits ( int n ) { int x = n ; n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return Integer . bitCount ( x ^ n ) ; } public static void main ( String [ ] args ) { int n = 17 ; System . out . println ( countUnsetBits ( n ) ) ; } } +","import math NEW_LINE def countUnsetBits ( n ) : NEW_LINE INDENT x = n NEW_LINE n |= n >> 1 NEW_LINE n |= n >> 2 NEW_LINE n |= n >> 4 NEW_LINE n |= n >> 8 NEW_LINE n |= n >> 16 NEW_LINE t = math . log ( x ^ n , 2 ) NEW_LINE return math . floor ( t ) NEW_LINE DEDENT n = 17 NEW_LINE print ( countUnsetBits ( n ) ) NEW_LINE +" +E1315,"import java . io . * ; class GFG { static int N = 1000001 ; static int visited [ ] = new int [ N ] ; static int goesTo [ ] = new int [ N ] ; static int dfs ( int i ) { if ( visited [ i ] == 1 ) return 0 ; visited [ i ] = 1 ; int x = dfs ( goesTo [ i ] ) ; return ( x + 1 ) ; } static int noOfTranspositions ( int P [ ] , int n ) { for ( int i = 1 ; i <= n ; i ++ ) visited [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) goesTo [ P [ i ] ] = i + 1 ; int transpositions = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( visited [ i ] == 0 ) { int ans = dfs ( i ) ; transpositions += ans - 1 ; } } return transpositions ; } public static void main ( String [ ] args ) { int permutation [ ] = { 5 , 1 , 4 , 3 , 2 } ; int n = permutation . length ; System . out . println ( noOfTranspositions ( permutation , n ) ) ; } } +","N = 1000001 NEW_LINE visited = [ 0 ] * N ; NEW_LINE goesTo = [ 0 ] * N ; NEW_LINE def dfs ( i ) : NEW_LINE INDENT if ( visited [ i ] == 1 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT visited [ i ] = 1 ; NEW_LINE x = dfs ( goesTo [ i ] ) ; NEW_LINE return ( x + 1 ) ; NEW_LINE DEDENT def noOfTranspositions ( P , n ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT visited [ i ] = 0 ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT goesTo [ P [ i ] ] = i + 1 ; NEW_LINE DEDENT transpositions = 0 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( visited [ i ] == 0 ) : NEW_LINE INDENT ans = dfs ( i ) ; NEW_LINE transpositions += ans - 1 ; NEW_LINE DEDENT DEDENT return transpositions ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT permutation = [ 5 , 1 , 4 , 3 , 2 ] ; NEW_LINE n = len ( permutation ) ; NEW_LINE print ( noOfTranspositions ( permutation , n ) ) ; NEW_LINE DEDENT +" +E1316,"class GFG { static String getCount ( int N ) { if ( N % 2 == 1 ) return ""0"" ; String result = ""9"" ; for ( int i = 1 ; i <= N / 2 - 1 ; i ++ ) result += ""0"" ; return result ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . println ( getCount ( N ) ) ; } } +","def getCount ( N ) : NEW_LINE INDENT if ( N % 2 == 1 ) : NEW_LINE INDENT return ""0"" NEW_LINE DEDENT result = ""9"" NEW_LINE for i in range ( 1 , N // 2 ) : NEW_LINE INDENT result = result + ""0"" NEW_LINE DEDENT return result NEW_LINE DEDENT N = 4 NEW_LINE print ( getCount ( N ) ) NEW_LINE +" +E1317,"import java . io . * ; class GFG { static boolean isDivisible ( long n ) { while ( n / 100 > 0 ) { long d = n % 10 ; n /= 10 ; n += d * 2 ; } return ( n % 19 == 0 ) ; } public static void main ( String [ ] args ) { long n = 101156 ; if ( isDivisible ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isDivisible ( n ) : NEW_LINE INDENT while ( n // 100 ) : NEW_LINE INDENT d = n % 10 NEW_LINE n //= 10 NEW_LINE n += d * 2 NEW_LINE DEDENT return ( n % 19 == 0 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 101156 NEW_LINE if ( isDivisible ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1318,"class GFG { static void printArr ( int [ ] arr , int k ) { for ( int i = 0 ; i < k ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; } static void printSeqUtil ( int n , int k , int len , int [ ] arr ) { if ( len == k ) { printArr ( arr , k ) ; return ; } int i = ( len == 0 ) ? 1 : arr [ len - 1 ] + 1 ; len ++ ; while ( i <= n ) { arr [ len - 1 ] = i ; printSeqUtil ( n , k , len , arr ) ; i ++ ; } len -- ; } static void printSeq ( int n , int k ) { int [ ] arr = new int [ k ] ; int len = 0 ; printSeqUtil ( n , k , len , arr ) ; } static public void main ( String [ ] args ) { int k = 3 , n = 7 ; printSeq ( n , k ) ; } } +","def printArr ( arr , k ) : NEW_LINE INDENT for i in range ( k ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( ) ; NEW_LINE DEDENT def printSeqUtil ( n , k , len1 , arr ) : NEW_LINE INDENT if ( len1 == k ) : NEW_LINE INDENT printArr ( arr , k ) ; NEW_LINE return ; NEW_LINE DEDENT i = 1 if ( len1 == 0 ) else ( arr [ len1 - 1 ] + 1 ) ; NEW_LINE len1 += 1 ; NEW_LINE while ( i <= n ) : NEW_LINE INDENT arr [ len1 - 1 ] = i ; NEW_LINE printSeqUtil ( n , k , len1 , arr ) ; NEW_LINE i += 1 ; NEW_LINE DEDENT len1 -= 1 ; NEW_LINE DEDENT def printSeq ( n , k ) : NEW_LINE INDENT arr = [ 0 ] * k ; NEW_LINE len1 = 0 ; NEW_LINE printSeqUtil ( n , k , len1 , arr ) ; NEW_LINE DEDENT k = 3 ; NEW_LINE n = 7 ; NEW_LINE printSeq ( n , k ) ; NEW_LINE +" +E1319,"class GFG { static int MAXN = 1000001 ; static int [ ] spf = new int [ MAXN ] ; static int [ ] hash1 = new int [ MAXN ] ; static void sieve ( ) { spf [ 1 ] = 1 ; for ( int i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } static void getFactorization ( int x ) { int temp ; while ( x != 1 ) { temp = spf [ x ] ; if ( x % temp == 0 ) { hash1 [ spf [ x ] ] ++ ; x = x / spf [ x ] ; } while ( x % temp == 0 ) x = x / temp ; } } static boolean check ( int x ) { int temp ; while ( x != 1 ) { temp = spf [ x ] ; if ( x % temp == 0 && hash1 [ temp ] > 1 ) return false ; while ( x % temp == 0 ) x = x / temp ; } return true ; } static boolean hasValidNum ( int [ ] arr , int n ) { sieve ( ) ; for ( int i = 0 ; i < n ; i ++ ) getFactorization ( arr [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) if ( check ( arr [ i ] ) ) return true ; return false ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 8 , 4 , 10 , 6 , 7 } ; int n = arr . length ; if ( hasValidNum ( arr , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","MAXN = 1000001 NEW_LINE spf = [ i for i in range ( MAXN ) ] NEW_LINE hash1 = [ 0 for i in range ( MAXN ) ] NEW_LINE def sieve ( ) : NEW_LINE INDENT for i in range ( 4 , MAXN , 2 ) : NEW_LINE INDENT spf [ i ] = 2 NEW_LINE DEDENT for i in range ( 3 , MAXN ) : NEW_LINE INDENT if i * i < MAXN : NEW_LINE INDENT break NEW_LINE DEDENT if ( spf [ i ] == i ) : NEW_LINE INDENT for j in range ( i * i , MAXN , i ) : NEW_LINE INDENT if ( spf [ j ] == j ) : NEW_LINE INDENT spf [ j ] = i NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT def getFactorization ( x ) : NEW_LINE INDENT while ( x != 1 ) : NEW_LINE INDENT temp = spf [ x ] NEW_LINE if ( x % temp == 0 ) : NEW_LINE INDENT hash1 [ spf [ x ] ] += 1 NEW_LINE x = x // spf [ x ] NEW_LINE DEDENT while ( x % temp == 0 ) : NEW_LINE INDENT x = x // temp NEW_LINE DEDENT DEDENT DEDENT def check ( x ) : NEW_LINE INDENT while ( x != 1 ) : NEW_LINE INDENT temp = spf [ x ] NEW_LINE if ( x % temp == 0 and hash1 [ temp ] > 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT while ( x % temp == 0 ) : NEW_LINE INDENT x = x // temp NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def hasValidNum ( arr , n ) : NEW_LINE INDENT sieve ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT getFactorization ( arr [ i ] ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( check ( arr [ i ] ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT arr = [ 2 , 8 , 4 , 10 , 6 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE if ( hasValidNum ( arr , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1320,"import java . io . * ; class GFG { 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 ) ; } static void printRatio ( int a , int b , int c , int d ) { if ( b * c > a * d ) { int temp = c ; c = d ; d = c ; temp = a ; a = b ; b = temp ; } int lcm = ( a * c ) / __gcd ( a , c ) ; int x = lcm / a ; b *= x ; int y = lcm / c ; d *= y ; int k = __gcd ( b , d ) ; b /= k ; d /= k ; System . out . print ( b + "" : "" + d ) ; } public static void main ( String [ ] args ) { int a = 4 , b = 3 , c = 2 , d = 2 ; printRatio ( a , b , c , d ) ; } } +","import math NEW_LINE def printRatio ( a , b , c , d ) : NEW_LINE INDENT if ( b * c > a * d ) : NEW_LINE INDENT swap ( c , d ) NEW_LINE swap ( a , b ) NEW_LINE DEDENT lcm = ( a * c ) / math . gcd ( a , c ) NEW_LINE x = lcm / a NEW_LINE b = int ( b * x ) NEW_LINE y = lcm / c NEW_LINE d = int ( d * y ) NEW_LINE k = math . gcd ( b , d ) NEW_LINE b = int ( b / k ) NEW_LINE d = int ( d / k ) NEW_LINE print ( b , "" : "" , d ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 4 NEW_LINE b = 3 NEW_LINE c = 2 NEW_LINE d = 2 NEW_LINE printRatio ( a , b , c , d ) NEW_LINE DEDENT +" +E1321,"class GFG { static int SieveOfAtkin ( int limit ) { if ( limit > 2 ) System . out . print ( 2 + "" ▁ "" ) ; if ( limit > 3 ) System . out . print ( 3 + "" ▁ "" ) ; boolean sieve [ ] = new boolean [ limit ] ; for ( int i = 0 ; i < limit ; i ++ ) sieve [ i ] = false ; for ( int x = 1 ; x * x < limit ; x ++ ) { for ( int y = 1 ; y * y < limit ; y ++ ) { int n = ( 4 * x * x ) + ( y * y ) ; if ( n <= limit && ( n % 12 == 1 || n % 12 == 5 ) ) sieve [ n ] ^= true ; n = ( 3 * x * x ) + ( y * y ) ; if ( n <= limit && n % 12 == 7 ) sieve [ n ] ^= true ; n = ( 3 * x * x ) - ( y * y ) ; if ( x > y && n <= limit && n % 12 == 11 ) sieve [ n ] ^= true ; } } for ( int r = 5 ; r * r < limit ; r ++ ) { if ( sieve [ r ] ) { for ( int i = r * r ; i < limit ; i += r * r ) sieve [ i ] = false ; } } for ( int a = 5 ; a < limit ; a ++ ) if ( sieve [ a ] ) System . out . print ( a + "" ▁ "" ) ; return 0 ; } public static void main ( String [ ] args ) { int limit = 20 ; SieveOfAtkin ( limit ) ; } } +","def SieveOfAtkin ( limit ) : NEW_LINE INDENT if ( limit > 2 ) : NEW_LINE INDENT print ( 2 , end = "" ▁ "" ) NEW_LINE DEDENT if ( limit > 3 ) : NEW_LINE INDENT print ( 3 , end = "" ▁ "" ) NEW_LINE DEDENT sieve = [ False ] * limit NEW_LINE for i in range ( 0 , limit ) : NEW_LINE INDENT sieve [ i ] = False NEW_LINE DEDENT x = 1 NEW_LINE while ( x * x < limit ) : NEW_LINE INDENT y = 1 NEW_LINE while ( y * y < limit ) : NEW_LINE INDENT n = ( 4 * x * x ) + ( y * y ) NEW_LINE if ( n <= limit and ( n % 12 == 1 or n % 12 == 5 ) ) : NEW_LINE INDENT sieve [ n ] ^= True NEW_LINE DEDENT n = ( 3 * x * x ) + ( y * y ) NEW_LINE if ( n <= limit and n % 12 == 7 ) : NEW_LINE INDENT sieve [ n ] ^= True NEW_LINE DEDENT n = ( 3 * x * x ) - ( y * y ) NEW_LINE if ( x > y and n <= limit and n % 12 == 11 ) : NEW_LINE INDENT sieve [ n ] ^= True NEW_LINE DEDENT y += 1 NEW_LINE DEDENT x += 1 NEW_LINE DEDENT r = 5 NEW_LINE while ( r * r < limit ) : NEW_LINE INDENT if ( sieve [ r ] ) : NEW_LINE INDENT for i in range ( r * r , limit , r * r ) : NEW_LINE INDENT sieve [ i ] = False NEW_LINE DEDENT DEDENT DEDENT for a in range ( 5 , limit ) : NEW_LINE INDENT if ( sieve [ a ] ) : NEW_LINE INDENT print ( a , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT limit = 20 NEW_LINE SieveOfAtkin ( limit ) NEW_LINE +" +E1322,"import java . lang . Math ; import java . io . * ; class GFG { static double calculateSide ( double n , double r ) { double theta , theta_in_radians ; theta = 360 / n ; theta_in_radians = theta * 3.14 / 180 ; return 2 * r * Math . sin ( theta_in_radians / 2 ) ; } public static void main ( String [ ] args ) { double n = 3 ; double r = 5 ; System . out . println ( calculateSide ( n , r ) ) ; } } +","from math import sin NEW_LINE def calculateSide ( n , r ) : NEW_LINE INDENT theta = 360 / n NEW_LINE theta_in_radians = theta * 3.14 / 180 NEW_LINE return 2 * r * sin ( theta_in_radians / 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE r = 5 NEW_LINE print ( ' { 0 : . 5 } ' . format ( calculateSide ( n , r ) ) ) NEW_LINE DEDENT +" +E1323,"import java . io . * ; public class GFG { static int findSum ( int n ) { int [ ] [ ] arr = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) arr [ i ] [ j ] = Math . abs ( i - j ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) sum += arr [ i ] [ j ] ; return sum ; } static public void main ( String [ ] args ) { int n = 3 ; System . out . println ( findSum ( n ) ) ; } } +","def findSum ( n ) : NEW_LINE INDENT arr = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT arr [ i ] [ j ] = abs ( i - j ) NEW_LINE DEDENT DEDENT sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT sum += arr [ i ] [ j ] NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 3 NEW_LINE print ( findSum ( n ) ) NEW_LINE DEDENT +" +E1324,"import java . util . Vector ; class GFG { static class Pair { private int first ; private int second ; Pair ( int first , int second ) { this . first = first ; this . second = second ; } public int getFirst ( ) { return first ; } public int getSecond ( ) { return second ; } } static int solve ( int [ ] Array , int N , int K ) { int [ ] count_Arr = new int [ N + 2 ] ; int factor = 1 ; int size = N ; while ( size > 0 ) { int start = 1 ; int end = size ; count_Arr [ 1 ] += factor * N ; count_Arr [ end + 1 ] -= factor * N ; factor ++ ; size /= 2 ; } for ( int i = 2 ; i <= N ; i ++ ) count_Arr [ i ] += count_Arr [ i - 1 ] ; Vector < Pair > element = new Vector < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Pair x = new Pair ( Array [ i ] , count_Arr [ i + 1 ] ) ; element . add ( x ) ; } int start = 1 ; for ( int i = 0 ; i < N ; i ++ ) { int end = start + element . elementAt ( 0 ) . getSecond ( ) - 1 ; if ( K >= start && K <= end ) return element . elementAt ( i ) . getFirst ( ) ; start += element . elementAt ( i ) . getSecond ( ) ; } return - 1 ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 5 , 1 } ; int N = arr . length ; int K = 13 ; System . out . println ( solve ( arr , N , K ) ) ; } } +","def solve ( Array , N , K ) : NEW_LINE INDENT count_Arr = [ 0 ] * ( N + 2 ) ; NEW_LINE factor = 1 ; NEW_LINE size = N ; NEW_LINE while ( size ) : NEW_LINE INDENT start = 1 ; NEW_LINE end = size ; NEW_LINE count_Arr [ 1 ] += factor * N ; NEW_LINE count_Arr [ end + 1 ] -= factor * N ; NEW_LINE factor += 1 ; NEW_LINE size //= 2 ; NEW_LINE DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT count_Arr [ i ] += count_Arr [ i - 1 ] ; NEW_LINE DEDENT element = [ ] ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT element . append ( ( Array [ i ] , count_Arr [ i + 1 ] ) ) ; NEW_LINE DEDENT element . sort ( ) ; NEW_LINE start = 1 ; NEW_LINE for i in range ( N ) : NEW_LINE INDENT end = start + element [ i ] [ 1 ] - 1 ; NEW_LINE if ( K >= start and K <= end ) : NEW_LINE INDENT return element [ i ] [ 0 ] ; NEW_LINE DEDENT start += element [ i ] [ 1 ] ; NEW_LINE DEDENT return - 1 ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 4 , 5 , 1 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE K = 13 ; NEW_LINE print ( solve ( arr , N , K ) ) ; NEW_LINE DEDENT +" +E1325,"import java . util . Scanner ; class PatternA { void display ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= n / 2 ; j ++ ) { if ( ( j == 0 || j == n / 2 ) && i != 0 || i == 0 && j != 0 && j != n / 2 || i == n / 2 ) System . out . print ( "" * "" ) ; else System . out . print ( "" ▁ "" ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PatternA a = new PatternA ( ) ; a . display ( 7 ) ; } } +","def display ( n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( ( n // 2 ) + 1 ) : NEW_LINE INDENT if ( ( j == 0 or j == n // 2 ) and i != 0 or i == 0 and j != 0 and j != n // 2 or i == n // 2 ) : NEW_LINE INDENT print ( "" * "" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" ▁ "" , end = "" "" ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE DEDENT DEDENT display ( 7 ) NEW_LINE +" +E1326,"class GFG { static int maxSum ( int arr1 [ ] , int arr2 [ ] , int n ) { int initialParity = 0 , finalParity = 0 ; int sum = 0 , minPositive = Integer . MAX_VALUE , maxNegative = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { initialParity += arr2 [ i ] ; if ( arr1 [ i ] >= 0 ) { finalParity += 1 ; sum += arr1 [ i ] ; minPositive = Math . min ( minPositive , arr1 [ i ] ) ; } else { maxNegative = Math . max ( maxNegative , arr1 [ i ] ) ; } } if ( initialParity % 2 == finalParity % 2 ) { return sum ; } else { if ( minPositive + maxNegative >= 0 ) { return sum + maxNegative ; } else { return sum - minPositive ; } } } public static void main ( String [ ] args ) { int arr1 [ ] = { 2 , - 4 , 5 , 3 } ; int arr2 [ ] = { 0 , 1 , 0 , 1 } ; int n = arr1 . length ; System . out . println ( maxSum ( arr1 , arr2 , n ) ) ; } } +","import sys NEW_LINE def maxSum ( arr1 , arr2 , n ) : NEW_LINE INDENT initialParity , finalParity = 0 , 0 NEW_LINE sum = 0 NEW_LINE minPositive = sys . maxsize NEW_LINE maxNegative = - sys . maxsize - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT initialParity += arr2 [ i ] ; NEW_LINE if ( arr1 [ i ] >= 0 ) : NEW_LINE INDENT finalParity += 1 NEW_LINE sum += arr1 [ i ] NEW_LINE minPositive = min ( minPositive , arr1 [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT maxNegative = max ( maxNegative , arr1 [ i ] ) NEW_LINE DEDENT DEDENT if ( initialParity % 2 == finalParity % 2 ) : NEW_LINE INDENT return sum NEW_LINE DEDENT else : NEW_LINE INDENT if ( minPositive + maxNegative >= 0 ) : NEW_LINE INDENT return sum + maxNegative NEW_LINE DEDENT else : NEW_LINE INDENT return sum - minPositive NEW_LINE DEDENT DEDENT DEDENT arr1 = [ 2 , - 4 , 5 , 3 ] NEW_LINE arr2 = [ 0 , 1 , 0 , 1 ] NEW_LINE n = len ( arr1 ) NEW_LINE print ( maxSum ( arr1 , arr2 , n ) ) NEW_LINE +" +E1327,"import java . util . * ; class GFG { public static void printTaxicab2 ( int N ) { int i = 1 , count = 0 ; while ( count < N ) { int int_count = 0 ; for ( int j = 1 ; j <= Math . pow ( i , 1.0 / 3 ) ; j ++ ) for ( int k = j + 1 ; k <= Math . pow ( i , 1.0 / 3 ) ; k ++ ) if ( j * j * j + k * k * k == i ) int_count ++ ; if ( int_count == 2 ) { count ++ ; System . out . println ( count + "" ▁ "" + i ) ; } i ++ ; } } public static void main ( String [ ] args ) { int N = 5 ; printTaxicab2 ( N ) ; } } +","def printTaxicab2 ( N ) : NEW_LINE INDENT i , count = 1 , 0 NEW_LINE while ( count < N ) : NEW_LINE INDENT int_count = 0 NEW_LINE for j in range ( 1 , int ( pow ( i , 1.0 / 3 ) ) + 1 ) : NEW_LINE INDENT for k in range ( j + 1 , int ( pow ( i , 1.0 / 3 ) ) + 1 ) : NEW_LINE INDENT if ( j * j * j + k * k * k == i ) : NEW_LINE INDENT int_count += 1 NEW_LINE DEDENT DEDENT DEDENT if ( int_count == 2 ) : NEW_LINE INDENT count += 1 NEW_LINE print ( count , "" ▁ "" , i ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT DEDENT N = 5 NEW_LINE printTaxicab2 ( N ) NEW_LINE +" +E1328,"class Test { static void findIndex ( int a [ ] , int n , int key ) { int start = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == key ) { start = i ; break ; } } if ( start == - 1 ) { System . out . println ( "" Key ▁ not ▁ present ▁ in ▁ array "" ) ; return ; } int end = start ; for ( int i = n - 1 ; i >= start ; i -- ) { if ( a [ i ] == key ) { end = i ; break ; } } if ( start == end ) System . out . println ( "" Only ▁ one ▁ key ▁ is ▁ present ▁ at ▁ index ▁ : ▁ "" + start ) ; else { System . out . println ( "" Start ▁ index : ▁ "" + start ) ; System . out . println ( "" Last ▁ index : ▁ "" + end ) ; } } public static void main ( String args [ ] ) { int a [ ] = { 1 , 2 , 7 , 8 , 8 , 9 , 8 , 0 , 0 , 0 , 8 } ; int key = 8 ; findIndex ( a , a . length , key ) ; } } +","def findIndex ( a , n , key ) : NEW_LINE INDENT start = - 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] == key : NEW_LINE INDENT start = i NEW_LINE break NEW_LINE DEDENT DEDENT if start == - 1 : NEW_LINE INDENT print ( "" Key ▁ not ▁ present ▁ in ▁ array "" ) NEW_LINE return 0 NEW_LINE DEDENT end = start NEW_LINE for i in range ( n - 1 , start - 1 , - 1 ) : NEW_LINE INDENT if a [ i ] == key : NEW_LINE INDENT end = i NEW_LINE break NEW_LINE DEDENT DEDENT if start == end : NEW_LINE INDENT print ( "" Only ▁ one ▁ key ▁ is ▁ present ▁ at ▁ index ▁ : ▁ "" , start ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Start ▁ index : ▁ "" , start ) NEW_LINE print ( "" Last ▁ index : ▁ "" , end ) NEW_LINE DEDENT DEDENT a = [ 1 , 2 , 7 , 8 , 8 , 9 , 8 , 0 , 0 , 0 , 8 ] NEW_LINE n = len ( a ) NEW_LINE key = 8 NEW_LINE findIndex ( a , n , key ) NEW_LINE +" +E1329,"import java . util . * ; class GFG { static int ans = 0 ; static Vector < Vector < Integer > > gr = new Vector < Vector < Integer > > ( ) ; static void Add_Edge ( int u , int v ) { gr . get ( u ) . add ( v ) ; gr . get ( v ) . add ( u ) ; } static void dfs ( int child , int par , int color [ ] ) { if ( color [ child ] != color [ par ] ) ans ++ ; for ( int i = 0 ; i < gr . get ( child ) . size ( ) ; i ++ ) { if ( gr . get ( child ) . get ( i ) == par ) continue ; dfs ( gr . get ( child ) . get ( i ) , child , color ) ; } } public static void main ( String args [ ] ) { for ( int i = 0 ; i <= 10 ; i ++ ) gr . add ( new Vector < Integer > ( ) ) ; int color [ ] = { 0 , 1 , 2 , 3 , 2 , 2 , 3 } ; Add_Edge ( 1 , 2 ) ; Add_Edge ( 1 , 3 ) ; Add_Edge ( 2 , 4 ) ; Add_Edge ( 2 , 5 ) ; Add_Edge ( 3 , 6 ) ; dfs ( 1 , 0 , color ) ; System . out . println ( ans ) ; } } +","ans = 0 NEW_LINE gr = [ [ ] for i in range ( 100005 ) ] NEW_LINE def Add_Edge ( u , v ) : NEW_LINE INDENT gr [ u ] . append ( v ) NEW_LINE gr [ v ] . append ( u ) NEW_LINE DEDENT def dfs ( child , par , color ) : NEW_LINE INDENT global ans NEW_LINE if ( color [ child ] != color [ par ] ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT for it in gr [ child ] : NEW_LINE INDENT if ( it == par ) : NEW_LINE INDENT continue NEW_LINE DEDENT dfs ( it , child , color ) NEW_LINE DEDENT DEDENT color = [ 0 , 1 , 2 , 3 , 2 , 2 , 3 ] NEW_LINE Add_Edge ( 1 , 2 ) NEW_LINE Add_Edge ( 1 , 3 ) NEW_LINE Add_Edge ( 2 , 4 ) NEW_LINE Add_Edge ( 2 , 5 ) NEW_LINE Add_Edge ( 3 , 6 ) NEW_LINE dfs ( 1 , 0 , color ) NEW_LINE print ( ans ) NEW_LINE +" +E1330,"class GFG { static int longestFibonacciSubarray ( int n , int a [ ] ) { if ( n <= 2 ) return n ; int len = 2 ; int mx = Integer . MIN_VALUE ; for ( int i = 2 ; i < n ; i ++ ) { if ( a [ i ] == a [ i - 1 ] + a [ i - 2 ] ) len ++ ; else len = 2 ; mx = Math . max ( mx , len ) ; } return mx ; } public static void main ( String [ ] args ) { int n = 5 ; int a [ ] = { 2 , 4 , 6 , 10 , 2 } ; System . out . println ( longestFibonacciSubarray ( n , a ) ) ; } } +","def longestFibonacciSubarray ( n , a ) : NEW_LINE INDENT if ( n <= 2 ) : NEW_LINE INDENT return n NEW_LINE DEDENT Len = 2 NEW_LINE mx = - 10 ** 9 NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT if ( a [ i ] == a [ i - 1 ] + a [ i - 2 ] ) : NEW_LINE INDENT Len += 1 NEW_LINE DEDENT else : NEW_LINE INDENT Len = 2 NEW_LINE DEDENT mx = max ( mx , Len ) NEW_LINE DEDENT return mx NEW_LINE DEDENT n = 5 NEW_LINE a = [ 2 , 4 , 6 , 10 , 2 ] NEW_LINE print ( longestFibonacciSubarray ( n , a ) ) NEW_LINE +" +E1331,"import java . util . * ; class GFG { public static void ancestorMatrix ( Node root , int matrix [ ] [ ] , int size ) { if ( root == null ) return ; ancestorMatrix ( root . left , matrix , size ) ; ancestorMatrix ( root . right , matrix , size ) ; if ( root . left != null ) { matrix [ root . data ] [ root . left . data ] = 1 ; for ( int i = 0 ; i < size ; i ++ ) { if ( matrix [ root . left . data ] [ i ] == 1 ) matrix [ root . data ] [ i ] = 1 ; } } if ( root . right != null ) { matrix [ root . data ] [ root . right . data ] = 1 ; for ( int i = 0 ; i < size ; i ++ ) { if ( matrix [ root . right . data ] [ i ] == 1 ) matrix [ root . data ] [ i ] = 1 ; } } } public static void main ( String [ ] args ) { Node tree_root = new Node ( 5 ) ; tree_root . left = new Node ( 1 ) ; tree_root . right = new Node ( 2 ) ; tree_root . left . left = new Node ( 0 ) ; tree_root . left . right = new Node ( 4 ) ; tree_root . right . left = new Node ( 3 ) ; int size = 6 ; int matrix [ ] [ ] = new int [ size ] [ size ] ; ancestorMatrix ( tree_root , matrix , size ) ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size ; j ++ ) { System . out . print ( matrix [ i ] [ j ] + "" ▁ "" ) ; } System . out . println ( ) ; } } static class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; this . left = this . right = null ; } } } +","class newnode : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . left = self . right = None NEW_LINE DEDENT DEDENT def ancestorMatrixRec ( root , anc ) : NEW_LINE INDENT global mat , MAX NEW_LINE if root == None : NEW_LINE INDENT return 0 NEW_LINE DEDENT data = root . data NEW_LINE for i in range ( len ( anc ) ) : NEW_LINE INDENT mat [ anc [ i ] ] [ data ] = 1 NEW_LINE DEDENT anc . append ( data ) NEW_LINE l = ancestorMatrixRec ( root . left , anc ) NEW_LINE r = ancestorMatrixRec ( root . right , anc ) NEW_LINE anc . pop ( - 1 ) NEW_LINE return l + r + 1 NEW_LINE DEDENT def ancestorMatrix ( root ) : NEW_LINE INDENT anc = [ ] NEW_LINE n = ancestorMatrixRec ( root , anc ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT MAX = 100 NEW_LINE mat = [ [ 0 ] * MAX for i in range ( MAX ) ] NEW_LINE root = newnode ( 5 ) NEW_LINE root . left = newnode ( 1 ) NEW_LINE root . right = newnode ( 2 ) NEW_LINE root . left . left = newnode ( 0 ) NEW_LINE root . left . right = newnode ( 4 ) NEW_LINE root . right . left = newnode ( 3 ) NEW_LINE ancestorMatrix ( root ) NEW_LINE +" +E1332,"import java . io . * ; class GFG { static int OddDivCount ( int a , int b ) { int res = 0 ; for ( int i = a ; i <= b ; ++ i ) { int divCount = 0 ; for ( int j = 1 ; j <= i ; ++ j ) { if ( i % j == 0 ) { ++ divCount ; } } if ( ( divCount % 2 ) != 0 ) { ++ res ; } } return res ; } public static void main ( String [ ] args ) { int a = 1 , b = 10 ; System . out . println ( OddDivCount ( a , b ) ) ; } } +","def OddDivCount ( a , b ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( a , b + 1 ) : NEW_LINE INDENT divCount = 0 NEW_LINE for j in range ( 1 , i + 1 ) : NEW_LINE INDENT if ( i % j == 0 ) : NEW_LINE INDENT divCount += 1 NEW_LINE DEDENT DEDENT if ( divCount % 2 ) : NEW_LINE INDENT res += 1 NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 1 NEW_LINE b = 10 NEW_LINE print ( OddDivCount ( a , b ) ) NEW_LINE DEDENT +" +E1333,"import java . io . * ; class GFG { static void findNDigitNumsUtil ( int n , int sum , char out [ ] , int index ) { if ( index > n || sum < 0 ) return ; if ( index == n ) { if ( sum == 0 ) { out [ index ] = ''; System . out . print ( out ) ; System . out . print ( "" ▁ "" ) ; } return ; } for ( int i = 0 ; i <= 9 ; i ++ ) { out [ index ] = ( char ) ( i + '0' ) ; findNDigitNumsUtil ( n , sum - i , out , index + 1 ) ; } } static void findNDigitNums ( int n , int sum ) { char [ ] out = new char [ n + 1 ] ; for ( int i = 1 ; i <= 9 ; i ++ ) { out [ 0 ] = ( char ) ( i + '0' ) ; findNDigitNumsUtil ( n , sum - i , out , 1 ) ; } } public static void main ( String [ ] args ) { int n = 2 , sum = 3 ; findNDigitNums ( n , sum ) ; } } +","def findNDigitNumsUtil ( n , sum , out , index ) : NEW_LINE INDENT if ( index > n or sum < 0 ) : NEW_LINE INDENT return NEW_LINE DEDENT f = "" "" NEW_LINE if ( index == n ) : NEW_LINE INDENT if ( sum == 0 ) : NEW_LINE INDENT out [ index ] = "" "" NEW_LINE for i in out : NEW_LINE INDENT f = f + i NEW_LINE DEDENT print ( f , end = "" ▁ "" ) NEW_LINE DEDENT return NEW_LINE DEDENT for i in range ( 10 ) : NEW_LINE INDENT out [ index ] = chr ( i + ord ( '0' ) ) NEW_LINE findNDigitNumsUtil ( n , sum - i , out , index + 1 ) NEW_LINE DEDENT DEDENT def findNDigitNums ( n , sum ) : NEW_LINE INDENT out = [ False ] * ( n + 1 ) NEW_LINE for i in range ( 1 , 10 ) : NEW_LINE INDENT out [ 0 ] = chr ( i + ord ( '0' ) ) NEW_LINE findNDigitNumsUtil ( n , sum - i , out , 1 ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 2 NEW_LINE sum = 3 NEW_LINE findNDigitNums ( n , sum ) NEW_LINE DEDENT +" +E1334,"import java . util . * ; class GFG { static int minimumIncrease ( int a , int b , int c ) { int arr [ ] = { a , b , c } ; Arrays . sort ( arr ) ; if ( arr [ 0 ] + arr [ 1 ] >= arr [ 2 ] ) return 0 ; else return arr [ 2 ] - ( arr [ 0 ] + arr [ 1 ] ) ; } public static void main ( String [ ] args ) { int a = 3 , b = 5 , c = 10 ; System . out . println ( minimumIncrease ( a , b , c ) ) ; } } +","def minimumIncrease ( a , b , c ) : NEW_LINE INDENT arr = [ a , b , c ] NEW_LINE arr . sort ( ) NEW_LINE if arr [ 0 ] + arr [ 1 ] >= arr [ 2 ] : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return arr [ 2 ] - ( arr [ 0 ] + arr [ 1 ] ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a , b , c = 3 , 5 , 10 NEW_LINE print ( minimumIncrease ( a , b , c ) ) NEW_LINE DEDENT +" +E1335,"import java . io . * ; class GFG { static int breakSum ( int n ) { if ( n == 0 || n == 1 ) return n ; return Math . max ( ( breakSum ( n / 2 ) + breakSum ( n / 3 ) + breakSum ( n / 4 ) ) , n ) ; } public static void main ( String [ ] args ) { int n = 12 ; System . out . println ( breakSum ( n ) ) ; } } +","def breakSum ( n ) : NEW_LINE INDENT if ( n == 0 or n == 1 ) : NEW_LINE INDENT return n NEW_LINE DEDENT return max ( ( breakSum ( n // 2 ) + breakSum ( n // 3 ) + breakSum ( n // 4 ) ) , n ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 12 NEW_LINE print ( breakSum ( n ) ) NEW_LINE DEDENT +" +E1336,"import java . util . * ; class GFG { public static int maxLengthSquare ( int row , int column , int [ ] [ ] arr , int k ) { int sum [ ] [ ] = new int [ row + 1 ] [ column + 1 ] ; int cur_max = 1 ; int max = 0 ; for ( int i = 1 ; i <= row ; i ++ ) { for ( int j = 1 ; j <= column ; j ++ ) { sum [ i ] [ j ] = sum [ i - 1 ] [ j ] + sum [ i ] [ j - 1 ] + arr [ i - 1 ] [ j - 1 ] - sum [ i - 1 ] [ j - 1 ] ; if ( i >= cur_max && j >= cur_max && sum [ i ] [ j ] - sum [ i - cur_max ] [ j ] - sum [ i ] [ j - cur_max ] + sum [ i - cur_max ] [ j - cur_max ] <= k ) { max = cur_max ++ ; } } } return max ; } public static void main ( String args [ ] ) { int row = 4 , column = 4 ; int matrix [ ] [ ] = { { 1 , 1 , 1 , 1 } , { 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 } } ; int k = 6 ; int ans = maxLengthSquare ( row , column , matrix , k ) ; System . out . println ( ans ) ; } } +","import numpy as np NEW_LINE def maxLengthSquare ( row , column , arr , k ) : NEW_LINE INDENT sum = np . zeros ( ( row + 1 , column + 1 ) ) ; NEW_LINE cur_max = 1 ; NEW_LINE max = 0 ; NEW_LINE for i in range ( 1 , row + 1 ) : NEW_LINE INDENT for j in range ( 1 , column + 1 ) : NEW_LINE INDENT sum [ i ] [ j ] = sum [ i - 1 ] [ j ] + sum [ i ] [ j - 1 ] + \ NEW_LINE INDENT arr [ i - 1 ] [ j - 1 ] - \ NEW_LINE sum [ i - 1 ] [ j - 1 ] ; NEW_LINE DEDENT if ( i >= cur_max and j >= cur_max and sum [ i ] [ j ] - sum [ i - cur_max ] [ j ] - sum [ i ] [ j - cur_max ] + sum [ i - cur_max ] [ j - cur_max ] <= k ) : NEW_LINE INDENT max = cur_max ; NEW_LINE cur_max += 1 ; NEW_LINE DEDENT DEDENT DEDENT return max ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT row = 4 ; NEW_LINE column = 4 ; NEW_LINE matrix = [ [ 1 , 1 , 1 , 1 ] , [ 1 , 0 , 0 , 0 ] , [ 1 , 0 , 0 , 0 ] , [ 1 , 0 , 0 , 0 ] ] ; NEW_LINE k = 6 ; NEW_LINE ans = maxLengthSquare ( row , column , matrix , k ) ; NEW_LINE print ( ans ) ; NEW_LINE DEDENT +" +E1337,"class GFG { static int minimumChanges ( int arr [ ] , int n ) { int i ; int changes = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { int j ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] == 0 ) break ; } i = j - 1 ; changes ++ ; } } return changes ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 1 , 0 , 0 , 0 , 1 , 0 , 1 , 1 } ; int n = arr . length ; System . out . println ( "" Minimum ▁ operations : ▁ "" + minimumChanges ( arr , n ) ) ; } } +","def minimumChanges ( arr , n ) : NEW_LINE INDENT changes = 0 NEW_LINE i = 0 NEW_LINE while i < n : NEW_LINE INDENT if arr [ i ] == 1 : NEW_LINE INDENT j = i + 1 NEW_LINE while j < n : NEW_LINE INDENT if arr [ j ] == 0 : NEW_LINE INDENT break NEW_LINE DEDENT j += 1 NEW_LINE DEDENT i = j - 1 NEW_LINE changes += 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return changes NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 1 , 0 , 0 , 0 , 1 , 0 , 1 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Minimum ▁ operations : "" , minimumChanges ( arr , n ) ) NEW_LINE DEDENT +" +E1338,"import java . util . * ; class GFG { static int MAX = 100005 ; static Vector < Integer > addPrimes ( ) { int n = MAX ; boolean [ ] prime = new boolean [ n + 1 ] ; Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } Vector < Integer > ans = new Vector < Integer > ( ) ; for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) ans . add ( p ) ; return ans ; } static boolean is_prime ( int n ) { return ( n == 3 || n == 5 || n == 7 ) ; } static int find_Sum ( int n ) { int sum = 0 ; Vector < Integer > v = addPrimes ( ) ; for ( int i = 0 ; i < v . size ( ) && n > 0 ; i ++ ) { int flag = 1 ; int a = v . get ( i ) ; while ( a != 0 ) { int d = a % 10 ; a = a / 10 ; if ( is_prime ( d ) ) { flag = 0 ; break ; } } if ( flag == 1 ) { n -- ; sum = sum + v . get ( i ) ; } } return sum ; } public static void main ( String [ ] args ) { int n = 7 ; System . out . println ( find_Sum ( n ) ) ; } } +","MAX = 100005 NEW_LINE def addPrimes ( ) : NEW_LINE INDENT n = MAX NEW_LINE prime = [ True for i in range ( n + 1 ) ] NEW_LINE for p in range ( 2 , n + 1 ) : NEW_LINE INDENT if p * p > n : NEW_LINE INDENT break NEW_LINE DEDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( 2 * p , n + 1 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT ans = [ ] NEW_LINE for p in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT ans . append ( p ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT def is_prime ( n ) : NEW_LINE INDENT if n in [ 3 , 5 , 7 ] : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def find_Sum ( n ) : NEW_LINE INDENT Sum = 0 NEW_LINE v = addPrimes ( ) NEW_LINE for i in range ( len ( v ) ) : NEW_LINE INDENT flag = 1 NEW_LINE a = v [ i ] NEW_LINE while ( a != 0 ) : NEW_LINE INDENT d = a % 10 ; NEW_LINE a = a // 10 ; NEW_LINE if ( is_prime ( d ) ) : NEW_LINE INDENT flag = 0 NEW_LINE break NEW_LINE DEDENT DEDENT if ( flag == 1 ) : NEW_LINE INDENT n -= 1 NEW_LINE Sum = Sum + v [ i ] NEW_LINE DEDENT if n == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return Sum NEW_LINE DEDENT n = 7 NEW_LINE print ( find_Sum ( n ) ) NEW_LINE +" +E1339,"import java . io . * ; class GFG { static void NicomachuTheorum_sum ( int n ) { int sum = 0 ; for ( int k = 1 ; k <= n ; k ++ ) sum += k * k * k ; int triNo = n * ( n + 1 ) / 2 ; if ( sum == triNo * triNo ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } public static void main ( String [ ] args ) { int n = 5 ; NicomachuTheorum_sum ( n ) ; } } +","def NicomachuTheorum_sum ( n ) : NEW_LINE INDENT sum = 0 ; NEW_LINE for k in range ( 1 , n + 1 ) : NEW_LINE INDENT sum += k * k * k ; NEW_LINE DEDENT triNo = n * ( n + 1 ) / 2 ; NEW_LINE if ( sum == triNo * triNo ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT n = 5 ; NEW_LINE NicomachuTheorum_sum ( n ) ; NEW_LINE +" +E1340,"class GFG { static int MAX = 1000 ; static int sequence [ ] = new int [ MAX ] ; static void vanEckSequence ( ) { for ( int i = 0 ; i < MAX - 1 ; i ++ ) { sequence [ i ] = 0 ; } for ( int i = 0 ; i < MAX - 1 ; i ++ ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( sequence [ j ] == sequence [ i ] ) { sequence [ i + 1 ] = i - j ; break ; } } } } static int getNthTerm ( int n ) { return sequence [ n ] ; } public static void main ( String [ ] args ) { vanEckSequence ( ) ; int n = 6 ; System . out . println ( getNthTerm ( n ) ) ; n = 100 ; System . out . println ( getNthTerm ( n ) ) ; } } +","MAX = 1000 NEW_LINE sequence = [ 0 ] * ( MAX + 1 ) ; NEW_LINE def vanEckSequence ( ) : NEW_LINE INDENT for i in range ( MAX ) : NEW_LINE INDENT sequence [ i ] = 0 ; NEW_LINE DEDENT for i in range ( MAX ) : NEW_LINE INDENT for j in range ( i - 1 , - 1 , - 1 ) : NEW_LINE INDENT if ( sequence [ j ] == sequence [ i ] ) : NEW_LINE INDENT sequence [ i + 1 ] = i - j ; NEW_LINE break ; NEW_LINE DEDENT DEDENT DEDENT DEDENT def getNthTerm ( n ) : NEW_LINE INDENT return sequence [ n ] ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT vanEckSequence ( ) ; NEW_LINE n = 6 ; NEW_LINE print ( getNthTerm ( n ) ) ; NEW_LINE n = 100 ; NEW_LINE print ( getNthTerm ( n ) ) ; NEW_LINE DEDENT +" +E1341,"import java . io . * ; class GFG { static int maximumFixedPoints ( int a [ ] , int n ) { int i , count = 0 , swapped = 0 ; int pos [ ] = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) pos [ a [ i ] ] = i ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == i ) count ++ ; else if ( swapped == 0 && pos [ i ] == a [ i ] ) { count += 2 ; swapped = 1 ; } } if ( swapped == 0 && count < n - 1 ) count ++ ; return count ; } public static void main ( String [ ] args ) { int [ ] a = { 0 , 1 , 3 , 4 , 2 } ; int n = a . length ; System . out . println ( maximumFixedPoints ( a , n ) ) ; } } +","def maximumFixedPoints ( a , n ) : NEW_LINE INDENT pos = [ None ] * n NEW_LINE count , swapped = 0 , 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT pos [ a [ i ] ] = i NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT if a [ i ] == i : NEW_LINE INDENT count += 1 NEW_LINE DEDENT elif swapped == 0 and pos [ i ] == a [ i ] : NEW_LINE INDENT count += 2 NEW_LINE swapped = 1 NEW_LINE DEDENT DEDENT if swapped == 0 and count < n - 1 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT return count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 0 , 1 , 3 , 4 , 2 ] NEW_LINE n = len ( a ) NEW_LINE print ( maximumFixedPoints ( a , n ) ) NEW_LINE DEDENT +" +E1342,"import java . util . * ; import java . lang . * ; public class GfG { public static void countCurrency ( int amount ) { int [ ] notes = new int [ ] { 2000 , 500 , 200 , 100 , 50 , 20 , 10 , 5 , 1 } ; int [ ] noteCounter = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( amount >= notes [ i ] ) { noteCounter [ i ] = amount / notes [ i ] ; amount = amount - noteCounter [ i ] * notes [ i ] ; } } System . out . println ( "" Currency ▁ Count ▁ - > "" ) ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( noteCounter [ i ] != 0 ) { System . out . println ( notes [ i ] + "" ▁ : ▁ "" + noteCounter [ i ] ) ; } } } public static void main ( String argc [ ] ) { int amount = 868 ; countCurrency ( amount ) ; } } +","def countCurrency ( amount ) : NEW_LINE INDENT notes = [ 2000 , 500 , 200 , 100 , 50 , 20 , 10 , 5 , 1 ] NEW_LINE noteCounter = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] NEW_LINE print ( "" Currency ▁ Count ▁ - > ▁ "" ) NEW_LINE for i , j in zip ( notes , noteCounter ) : NEW_LINE INDENT if amount >= i : NEW_LINE INDENT j = amount // i NEW_LINE amount = amount - j * i NEW_LINE print ( i , "" ▁ : ▁ "" , j ) NEW_LINE DEDENT DEDENT DEDENT amount = 868 NEW_LINE countCurrency ( amount ) NEW_LINE +" +E1343,"class GFG { static int MAX_CHAR = 256 ; public static boolean isPalindrome ( String str , int l , int h ) { while ( h > l ) if ( str . charAt ( l ++ ) != str . charAt ( h -- ) ) return false ; return true ; } public static boolean check ( String str ) { int n = str . length ( ) ; int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str . charAt ( i ) ] ++ ; if ( freq [ str . charAt ( i ) ] > 2 ) return true ; } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str . charAt ( i ) ] > 1 ) str . replace ( str . charAt ( k ++ ) , str . charAt ( i ) ) ; str . replace ( str . charAt ( k ) , ' \0' ) ; if ( isPalindrome ( str , 0 , k - 1 ) ) { if ( ( k & 1 ) == 1 ) { if ( k / 2 >= 1 ) return ( str . charAt ( k / 2 ) == str . charAt ( k / 2 - 1 ) ) ; } return false ; } return true ; } public static void main ( String [ ] args ) { String str = "" ABCABD "" ; if ( check ( str ) ) System . out . println ( "" Repeated ▁ Subsequence ▁ Exists "" ) ; else System . out . println ( "" Repeated ▁ Subsequence "" + "" ▁ Doesn ' t ▁ Exists "" ) ; } } +","MAX_CHAR = 256 NEW_LINE def isPalindrome ( Str , l , h ) : NEW_LINE INDENT while ( h > l ) : NEW_LINE INDENT if ( Str [ l ] != Str [ h ] ) : NEW_LINE INDENT l += 1 NEW_LINE h -= 1 NEW_LINE return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def check ( Str ) : NEW_LINE INDENT n = len ( Str ) NEW_LINE freq = [ 0 for i in range ( MAX_CHAR ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT freq [ ord ( Str [ i ] ) ] += 1 NEW_LINE if ( freq [ ord ( Str [ i ] ) ] > 2 ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT k = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( freq [ ord ( Str [ i ] ) ] > 1 ) : NEW_LINE INDENT Str [ k ] = Str [ i ] NEW_LINE k += 1 NEW_LINE DEDENT DEDENT Str [ k ] = ' \0' NEW_LINE if ( isPalindrome ( Str , 0 , k - 1 ) ) : NEW_LINE INDENT if ( k & 1 ) : NEW_LINE INDENT return Str [ k // 2 ] == Str [ k // 2 - 1 ] NEW_LINE DEDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT S = "" ABCABD "" NEW_LINE Str = [ i for i in S ] NEW_LINE if ( check ( Str ) ) : NEW_LINE INDENT print ( "" Repeated ▁ Subsequence ▁ Exists "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Repeated ▁ Subsequence ▁ Doesn ' t ▁ Exists "" ) NEW_LINE DEDENT +" +E1344,"class GFG { static int N = 100005 ; static int mod = 1000000007 ; static int cnt [ ] = new int [ N ] ; static void Divisors ( ) { for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j * i < N ; j ++ ) { cnt [ i * j ] ++ ; } } } static int Sumofdivisors ( int A , int B , int C ) { int sum = 0 ; Divisors ( ) ; for ( int i = 1 ; i <= A ; i ++ ) { for ( int j = 1 ; j <= B ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { int x = i * j * k ; sum += cnt [ x ] ; if ( sum >= mod ) { sum -= mod ; } } } } return sum ; } public static void main ( String [ ] args ) { int A = 5 , B = 6 , C = 7 ; System . out . println ( Sumofdivisors ( A , B , C ) ) ; } } +","N = 100005 NEW_LINE mod = 1000000007 NEW_LINE cnt = [ 0 ] * N ; NEW_LINE def Divisors ( ) : NEW_LINE INDENT for i in range ( 1 , N ) : NEW_LINE INDENT for j in range ( 1 , N // i ) : NEW_LINE INDENT cnt [ i * j ] += 1 ; NEW_LINE DEDENT DEDENT DEDENT def Sumofdivisors ( A , B , C ) : NEW_LINE INDENT sum = 0 ; NEW_LINE Divisors ( ) ; NEW_LINE for i in range ( 1 , A + 1 ) : NEW_LINE INDENT for j in range ( 1 , B + 1 ) : NEW_LINE INDENT for k in range ( 1 , C + 1 ) : NEW_LINE INDENT x = i * j * k ; NEW_LINE sum += cnt [ x ] ; NEW_LINE if ( sum >= mod ) : NEW_LINE INDENT sum -= mod ; NEW_LINE DEDENT DEDENT DEDENT DEDENT return sum ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = 5 ; B = 6 ; C = 7 ; NEW_LINE print ( Sumofdivisors ( A , B , C ) ) ; NEW_LINE DEDENT +" +E1345,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int factorial ( int N ) { int fact = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fact = fact * i ; return fact ; } static int nthTerm ( int N ) { return ( factorial ( N + 1 ) / 2 ) ; } public static void main ( String args [ ] ) { int N = 6 ; System . out . println ( nthTerm ( N ) ) ; } } +","def factorial ( N ) : NEW_LINE INDENT fact = 1 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT fact = fact * i NEW_LINE DEDENT return fact NEW_LINE DEDENT def nthTerm ( N ) : NEW_LINE INDENT return ( factorial ( N + 1 ) // 2 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 6 NEW_LINE print ( nthTerm ( N ) ) NEW_LINE DEDENT +" +E1346,"import java . util . * ; class GFG { static void prefix ( char [ ] str ) { int k = 1 , j ; int n = str . length ; Vector < Integer > g = new Vector < > ( ) ; int flag = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) { g . add ( i ) ; flag = 1 ; } } if ( flag == 0 ) { System . out . println ( String . valueOf ( str ) ) ; } else { int len = g . size ( ) ; while ( k < g . get ( 0 ) ) { int cnt = 0 ; for ( j = 0 ; j < len ; j ++ ) { if ( ( g . get ( j ) + k ) < n && str [ g . get ( j ) + k ] == str [ k ] ) { cnt ++ ; } } if ( cnt == len ) { k ++ ; } else { break ; } } for ( int i = 0 ; i < k ; i ++ ) { System . out . print ( str [ i ] ) ; } System . out . println ( ) ; } } public static void main ( String args [ ] ) { String str = "" abcab "" ; prefix ( str . toCharArray ( ) ) ; } } +","def prefix ( string ) : NEW_LINE INDENT k = 1 ; NEW_LINE n = len ( string ) ; NEW_LINE g = [ ] ; NEW_LINE flag = 0 ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( string [ i ] == string [ 0 ] ) : NEW_LINE INDENT g . append ( i ) ; NEW_LINE flag = 1 ; NEW_LINE DEDENT DEDENT if ( flag == 0 ) : NEW_LINE INDENT print ( string ) ; NEW_LINE DEDENT else : NEW_LINE INDENT length = len ( g ) ; NEW_LINE while ( k < g [ 0 ] ) : NEW_LINE INDENT cnt = 0 ; NEW_LINE for j in range ( length ) : NEW_LINE INDENT if ( string [ g [ j ] + k ] == string [ k ] ) : NEW_LINE INDENT cnt += 1 ; NEW_LINE DEDENT DEDENT if ( cnt == len ) : NEW_LINE INDENT k += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT for i in range ( k + 1 ) : NEW_LINE INDENT print ( string [ i ] , end = "" "" ) ; NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" abcab "" ; NEW_LINE prefix ( string ) ; NEW_LINE DEDENT +" +E1347,"import java . lang . * ; class GFG { static int findTerm ( int n ) { if ( n == 1 ) return n ; else { int term = 7 ; for ( int i = 2 ; i <= n ; i ++ ) term = term * 2 + ( i - 1 ) ; return term ; } } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( findTerm ( n ) ) ; } } +","def findTerm ( n ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT term = 7 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT term = term * 2 + ( i - 1 ) ; NEW_LINE DEDENT DEDENT return term ; NEW_LINE DEDENT print ( findTerm ( 5 ) ) NEW_LINE +" +E1348,"public class GFG { static int INT_SIZE = 32 ; static int Right_most_setbit ( int num ) { int pos = 1 ; for ( int i = 0 ; i < INT_SIZE ; i ++ ) { if ( ( num & ( 1 << i ) ) == 0 ) pos ++ ; else break ; } return pos ; } public static void main ( String [ ] args ) { int num = 18 ; int pos = Right_most_setbit ( num ) ; System . out . println ( pos ) ; } } +","INT_SIZE = 32 NEW_LINE def Right_most_setbit ( num ) : NEW_LINE INDENT pos = 1 NEW_LINE for i in range ( INT_SIZE ) : NEW_LINE INDENT if not ( num & ( 1 << i ) ) : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return pos NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT num = 18 NEW_LINE pos = Right_most_setbit ( num ) NEW_LINE print ( pos ) NEW_LINE DEDENT +" +E1349,"public class GFG { static long subarrayXor ( int arr [ ] , int n , int m ) { long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int xorSum = 0 ; for ( int j = i ; j < n ; j ++ ) { xorSum = xorSum ^ arr [ j ] ; if ( xorSum == m ) ans ++ ; } } return ans ; } public static void main ( String args [ ] ) { int [ ] arr = { 4 , 2 , 2 , 6 , 4 } ; int n = arr . length ; int m = 6 ; System . out . println ( "" Number ▁ of ▁ subarrays "" + "" ▁ having ▁ given ▁ XOR ▁ is ▁ "" + subarrayXor ( arr , n , m ) ) ; } } +","def subarrayXor ( arr , n , m ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT xorSum = 0 NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT xorSum = xorSum ^ arr [ j ] NEW_LINE if ( xorSum == m ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT arr = [ 4 , 2 , 2 , 6 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE m = 6 NEW_LINE print ( "" Number ▁ of ▁ subarrays ▁ having ▁ given ▁ XOR ▁ is ▁ "" , subarrayXor ( arr , n , m ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E1350,"import java . util . * ; class GFG { static int TrialDivision ( int N ) { int i = 2 ; int k = ( int ) Math . ceil ( Math . sqrt ( N ) ) ; while ( i <= k ) { if ( N % i == 0 ) return 0 ; i += 1 ; } return 1 ; } public static void main ( String [ ] args ) { int N = 49 ; int p = TrialDivision ( N ) ; if ( p != 0 ) System . out . print ( "" Prime "" ) ; else System . out . print ( "" Composite "" ) ; } } +","def TrialDivision ( N ) : NEW_LINE INDENT i = 2 NEW_LINE k = int ( N ** 0.5 ) NEW_LINE while ( i <= k ) : NEW_LINE INDENT if ( N % i == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return 1 NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 49 NEW_LINE p = TrialDivision ( N ) NEW_LINE if ( p ) : NEW_LINE INDENT print ( "" Prime "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Composite "" ) NEW_LINE DEDENT DEDENT +" +E1351,"class GFG { static int count ( int arr [ ] , int N , int K ) { int count = 0 , ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == K ) { count = count + 1 ; } else { ans += ( count * ( count + 1 ) ) / 2 ; count = 0 ; } } ans = ans + ( count * ( count + 1 ) ) / 2 ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 0 , 0 , 1 , 1 , 0 , 0 } ; int N = arr . length ; int K = 0 ; System . out . print ( count ( arr , N , K ) ) ; } } +","def count ( arr , N , K ) : NEW_LINE INDENT count = 0 NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ( arr [ i ] == K ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( count * ( count + 1 ) ) // 2 NEW_LINE count = 0 NEW_LINE DEDENT DEDENT ans = ans + ( count * ( count + 1 ) ) // 2 NEW_LINE return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 0 , 0 , 1 , 1 , 0 , 0 ] NEW_LINE N = len ( arr ) NEW_LINE K = 0 NEW_LINE print ( count ( arr , N , K ) ) NEW_LINE DEDENT +" +E1352,"import java . io . * ; class GFG { static long centered_heptagonal_num ( long n ) { return ( 7 * n * n - 7 * n + 2 ) / 2 ; } public static void main ( String [ ] args ) { long n = 5 ; System . out . println ( n + "" th ▁ Centered ▁ "" + "" heptagonal ▁ number ▁ : ▁ "" + centered_heptagonal_num ( n ) ) ; } } +","def centered_heptagonal_num ( n ) : NEW_LINE INDENT return ( 7 * n * n - 7 * n + 2 ) // 2 NEW_LINE DEDENT n = 5 NEW_LINE print ( "" % sth ▁ Centered ▁ heptagonal ▁ number ▁ : ▁ "" % n , centered_heptagonal_num ( n ) ) NEW_LINE +" +E1353,"class GFG { static double pie = 3.1415926535897 ; static double findsolution ( double d , double h , double m , double n ) { double k = ( 4 * m ) / ( pie * d * d ) ; if ( n > k ) return - 1 ; double ans = ( h / ( k - n ) ) ; return ans ; } public static void main ( String [ ] args ) { double d = 1 , h = 1 , m = 1 , n = 1 ; System . out . printf ( "" % .5f "" , findsolution ( d , h , m , n ) ) ; } } +","pie = 3.1415926535897 NEW_LINE def findsolution ( d , h , m , n ) : NEW_LINE INDENT k = ( 4 * m ) / ( pie * d * d ) NEW_LINE if ( n > k ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT ans = ( h / ( k - n ) ) NEW_LINE return round ( ans , 5 ) NEW_LINE DEDENT d = 1 NEW_LINE h = 1 NEW_LINE m = 1 NEW_LINE n = 1 NEW_LINE print ( findsolution ( d , h , m , n ) ) NEW_LINE +" +E1354,"class GFG { static int countNum ( int N , int arr [ ] ) { int sum = 0 , count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( ( sum - arr [ i ] ) % arr [ i ] == 0 ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 10 , 4 , 6 , 7 } ; int n = arr . length ; System . out . println ( countNum ( n , arr ) ) ; } } +","def countNum ( N , arr ) : NEW_LINE INDENT Sum , count = 0 , 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT Sum += arr [ i ] NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT if ( ( Sum - arr [ i ] ) % arr [ i ] == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 3 , 10 , 4 , 6 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countNum ( n , arr ) ) NEW_LINE +" +E1355,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int CountTrailingZeros ( int n ) { String bit = Integer . toBinaryString ( n ) ; StringBuilder bit1 = new StringBuilder ( ) ; bit1 . append ( bit ) ; bit1 = bit1 . reverse ( ) ; int zero = 0 ; for ( int i = 0 ; i < 64 ; i ++ ) { if ( bit1 . charAt ( i ) == '0' ) zero ++ ; else break ; } return zero ; } public static void main ( String [ ] args ) { int n = 4 ; int ans = CountTrailingZeros ( n ) ; System . out . println ( ans ) ; } } +","def CountTrailingZeros ( n ) : NEW_LINE INDENT bit = bin ( n ) [ 2 : ] NEW_LINE bit = bit [ : : - 1 ] NEW_LINE zero = 0 ; NEW_LINE for i in range ( len ( bit ) ) : NEW_LINE INDENT if ( bit [ i ] == '0' ) : NEW_LINE INDENT zero += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return zero NEW_LINE DEDENT n = 4 NEW_LINE ans = CountTrailingZeros ( n ) NEW_LINE print ( ans ) NEW_LINE +" +E1356,"class GfG { static void printConsecutive ( int last , int first ) { System . out . print ( first ++ ) ; for ( int x = first ; x <= last ; x ++ ) System . out . print ( "" ▁ + ▁ "" + x ) ; } static void findConsecutive ( int N ) { for ( int last = 1 ; last < N ; last ++ ) { for ( int first = 0 ; first < last ; first ++ ) { if ( 2 * N == ( last - first ) * ( last + first + 1 ) ) { System . out . printf ( N + "" ▁ = ��� "" ) ; printConsecutive ( last , first + 1 ) ; return ; } } } System . out . print ( "" - 1"" ) ; } public static void main ( String [ ] args ) { int n = 12 ; findConsecutive ( n ) ; } } +","def printConsecutive ( last , first ) : NEW_LINE INDENT print ( first , end = "" "" ) NEW_LINE first += 1 NEW_LINE for x in range ( first , last + 1 ) : NEW_LINE INDENT print ( "" ▁ + "" , x , end = "" "" ) NEW_LINE DEDENT DEDENT def findConsecutive ( N ) : NEW_LINE INDENT for last in range ( 1 , N ) : NEW_LINE INDENT for first in range ( 0 , last ) : NEW_LINE INDENT if 2 * N == ( last - first ) * ( last + first + 1 ) : NEW_LINE INDENT print ( N , "" = ▁ "" , end = "" "" ) NEW_LINE printConsecutive ( last , first + 1 ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT print ( "" - 1"" ) NEW_LINE DEDENT n = 12 NEW_LINE findConsecutive ( n ) NEW_LINE +" +E1357,"public class LongestCommonSubSequence { static int LCSubStr ( char X [ ] , char Y [ ] , int m , int n ) { int LCStuff [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ; int result = 0 ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 || j == 0 ) LCStuff [ i ] [ j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) { LCStuff [ i ] [ j ] = LCStuff [ i - 1 ] [ j - 1 ] + 1 ; result = Integer . max ( result , LCStuff [ i ] [ j ] ) ; } else LCStuff [ i ] [ j ] = 0 ; } } return result ; } public static void main ( String [ ] args ) { String X = "" OldSite : GeeksforGeeks . org "" ; String Y = "" NewSite : GeeksQuiz . com "" ; int m = X . length ( ) ; int n = Y . length ( ) ; System . out . println ( "" Length ▁ of ▁ Longest ▁ Common ▁ Substring ▁ is ▁ "" + LCSubStr ( X . toCharArray ( ) , Y . toCharArray ( ) , m , n ) ) ; } } +","def LCSubStr ( X , Y , m , n ) : NEW_LINE INDENT LCSuff = [ [ 0 for k in range ( n + 1 ) ] for l in range ( m + 1 ) ] NEW_LINE result = 0 NEW_LINE for i in range ( m + 1 ) : NEW_LINE INDENT for j in range ( n + 1 ) : NEW_LINE INDENT if ( i == 0 or j == 0 ) : NEW_LINE INDENT LCSuff [ i ] [ j ] = 0 NEW_LINE DEDENT elif ( X [ i - 1 ] == Y [ j - 1 ] ) : NEW_LINE INDENT LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1 NEW_LINE result = max ( result , LCSuff [ i ] [ j ] ) NEW_LINE DEDENT else : NEW_LINE INDENT LCSuff [ i ] [ j ] = 0 NEW_LINE DEDENT DEDENT DEDENT return result NEW_LINE DEDENT X = ' OldSite : GeeksforGeeks . org ' NEW_LINE Y = ' NewSite : GeeksQuiz . com ' NEW_LINE m = len ( X ) NEW_LINE n = len ( Y ) NEW_LINE print ( ' Length ▁ of ▁ Longest ▁ Common ▁ Substring ▁ is ' , LCSubStr ( X , Y , m , n ) ) NEW_LINE +" +E1358,"class GFG { static int getPassingCars ( int [ ] A , int n ) { int result = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( A [ i ] == 0 ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( A [ j ] == 1 ) result ++ ; } } return result ; } public static void main ( String [ ] args ) { int [ ] A = { 0 , 1 , 0 , 1 , 1 } ; int n = A . length ; System . out . println ( getPassingCars ( A , n ) ) ; } } +","def getPassingCars ( A , n ) : NEW_LINE INDENT result = 0 NEW_LINE for i in range ( 0 , n - 1 , 1 ) : NEW_LINE INDENT if ( A [ i ] == 0 ) : NEW_LINE INDENT for j in range ( i + 1 , n , 1 ) : NEW_LINE INDENT if ( A [ j ] ) : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = [ 0 , 1 , 0 , 1 , 1 ] NEW_LINE n = len ( A ) NEW_LINE print ( getPassingCars ( A , n ) ) NEW_LINE DEDENT +" +E1359,"public class DLL { Node head ; class Node { int data ; Node prev ; Node next ; Node ( int d ) { data = d ; } } } +","class Node : NEW_LINE INDENT def __init__ ( self , next = None , prev = None , data = None ) : NEW_LINE INDENT self . next = next NEW_LINE self . prev = prev NEW_LINE self . data = data NEW_LINE DEDENT DEDENT +" +E1360,"public class GFG { static int search ( int arr [ ] , int n , int x ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == x ) { return i ; } } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 10 , 30 , 15 } ; int x = 30 ; int n = arr . length ; System . out . printf ( "" % d ▁ is ▁ present ▁ at ▁ index ▁ % d "" , x , search ( arr , n , x ) ) ; } } +","def search ( arr , n , x ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if arr [ i ] == x : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT arr = [ 1 , 10 , 30 , 15 ] NEW_LINE x = 30 NEW_LINE n = len ( arr ) NEW_LINE print ( x , "" is ▁ present ▁ at ▁ index "" , search ( arr , n , x ) ) NEW_LINE +" +E1361,"import java . lang . * ; class GFG { static int findKHCF ( int x , int y , int k ) { int small = Math . min ( x , y ) ; int count = 1 ; for ( int i = 2 ; i <= small ; i ++ ) { if ( x % i == 0 && y % i == 0 ) count ++ ; if ( count == k ) return i ; } return - 1 ; } public static void main ( String [ ] args ) { int x = 4 , y = 24 , k = 3 ; System . out . print ( findKHCF ( x , y , k ) ) ; } } +","def findKHCF ( x , y , k ) : NEW_LINE INDENT small = min ( x , y ) NEW_LINE count = 1 NEW_LINE for i in range ( 2 , small + 1 ) : NEW_LINE INDENT if ( x % i == 0 and y % i == 0 ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT if ( count == k ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT return - 1 NEW_LINE DEDENT x = 4 NEW_LINE y = 24 NEW_LINE k = 3 NEW_LINE print ( findKHCF ( x , y , k ) ) NEW_LINE +" +E1362,"import java . io . * ; class GFG { static int distancesum ( int x [ ] , int y [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) sum += ( Math . abs ( x [ i ] - x [ j ] ) + Math . abs ( y [ i ] - y [ j ] ) ) ; return sum ; } public static void main ( String [ ] args ) { int x [ ] = { - 1 , 1 , 3 , 2 } ; int y [ ] = { 5 , 6 , 5 , 3 } ; int n = x . length ; System . out . println ( distancesum ( x , y , n ) ) ; } } +","def distancesum ( x , y , n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT sum += ( abs ( x [ i ] - x [ j ] ) + abs ( y [ i ] - y [ j ] ) ) NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT x = [ - 1 , 1 , 3 , 2 ] NEW_LINE y = [ 5 , 6 , 5 , 3 ] NEW_LINE n = len ( x ) NEW_LINE print ( distancesum ( x , y , n ) ) NEW_LINE +" +E1363,"class GFG { static int days [ ] = { 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; static int dayOfYear ( String date ) { int year = Integer . parseInt ( date . substring ( 0 , 4 ) ) ; int month = Integer . parseInt ( date . substring ( 5 , 7 ) ) ; int day = Integer . parseInt ( date . substring ( 8 ) ) ; if ( month > 2 && year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 ) ) { ++ day ; } while ( -- month > 0 ) { day = day + days [ month - 1 ] ; } return day ; } public static void main ( String [ ] args ) { String date = ""2019-01-09"" ; System . out . println ( dayOfYear ( date ) ) ; } } +","days = [ 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] ; NEW_LINE def dayOfYear ( date ) : NEW_LINE INDENT year = ( int ) ( date [ 0 : 4 ] ) ; NEW_LINE month = ( int ) ( date [ 5 : 7 ] ) ; NEW_LINE day = ( int ) ( date [ 8 : ] ) ; NEW_LINE if ( month > 2 and year % 4 == 0 and ( year % 100 != 0 or year % 400 == 0 ) ) : NEW_LINE INDENT day += 1 ; NEW_LINE DEDENT month -= 1 ; NEW_LINE while ( month > 0 ) : NEW_LINE INDENT day = day + days [ month - 1 ] ; NEW_LINE month -= 1 ; NEW_LINE DEDENT return day ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT date = ""2019-01-09"" ; NEW_LINE print ( dayOfYear ( date ) ) ; NEW_LINE DEDENT +" +E1364,"import java . io . * ; class GFG { static boolean isUnary ( int n ) { if ( n == 1 || n == 7 ) return true ; else if ( n / 10 == 0 ) return false ; int x , sum = 0 ; while ( n != 0 ) { x = n % 10 ; sum = sum + x * x ; n = n / 10 ; } return isUnary ( sum ) ; } static int countUnary ( int a , int b ) { int count = 0 ; for ( int i = a ; i <= b ; i ++ ) { if ( isUnary ( i ) == true ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int a = 1000 , b = 1099 ; System . out . println ( countUnary ( a , b ) ) ; } } +","def isUnary ( n ) : NEW_LINE INDENT if ( n == 1 or n == 7 ) : NEW_LINE INDENT return True NEW_LINE DEDENT elif ( int ( n / 10 ) == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT sum = 0 NEW_LINE while ( n != 0 ) : NEW_LINE INDENT x = n % 10 NEW_LINE sum = sum + x * x NEW_LINE n = int ( n / 10 ) NEW_LINE DEDENT return isUnary ( sum ) NEW_LINE DEDENT def countUnary ( a , b ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( a , b + 1 , 1 ) : NEW_LINE INDENT if ( isUnary ( i ) == 1 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 1000 NEW_LINE b = 1099 NEW_LINE print ( countUnary ( a , b ) ) NEW_LINE DEDENT +" +E1365,"class GFG { static int find_count ( int [ ] arr ) { int ans = 0 ; for ( int i : arr ) { int x = Integer . bitCount ( i ) ; if ( i % x == 0 ) ans += 1 ; } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; System . out . print ( find_count ( arr ) ) ; } } +","def bitsoncount ( x ) : NEW_LINE INDENT return bin ( x ) . count ( '1' ) NEW_LINE DEDENT def find_count ( arr ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in arr : NEW_LINE INDENT x = bitsoncount ( i ) NEW_LINE if ( i % x == 0 ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 ] NEW_LINE print ( find_count ( arr ) ) NEW_LINE +" +E1366,"class GFG { static final int MOD = 1000000007 ; static int product ( int ar [ ] , int n ) { int result = 1 ; for ( int i = 0 ; i < n ; i ++ ) result = ( result * ar [ i ] ) % MOD ; return result ; } public static void main ( String [ ] args ) { int ar [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = ar . length ; System . out . printf ( "" % d "" , product ( ar , n ) ) ; } } +","MOD = 1000000007 NEW_LINE def product ( ar , n ) : NEW_LINE INDENT result = 1 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT result = ( result * ar [ i ] ) % MOD NEW_LINE DEDENT return result NEW_LINE DEDENT ar = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE n = len ( ar ) NEW_LINE print ( product ( ar , n ) ) NEW_LINE +" +E1367,"import java . util . * ; class GFG { static int MOD = 1000000007 ; static void SieveOfEratosthenes ( boolean prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static int productPrimeFreq ( int arr [ ] , int n ) { boolean [ ] prime = new boolean [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , n + 1 ) ; int i , j ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } long product = 1 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { if ( prime [ it . getValue ( ) ] ) { product *= ( it . getKey ( ) % MOD ) ; product %= MOD ; } } return ( int ) ( product ) ; } static public void main ( String [ ] arg ) { int arr [ ] = { 5 , 4 , 6 , 5 , 4 , 6 } ; int n = arr . length ; System . out . println ( productPrimeFreq ( arr , n ) ) ; } } +","MOD = 1000000007 NEW_LINE def SieveOfEratosthenes ( prime , p_size ) : NEW_LINE INDENT prime [ 0 ] = False NEW_LINE prime [ 1 ] = False NEW_LINE for p in range ( 2 , p_size ) : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT for i in range ( 2 * p , p_size , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def productPrimeFreq ( arr , n ) : NEW_LINE INDENT prime = [ True for i in range ( n + 1 ) ] NEW_LINE SieveOfEratosthenes ( prime , n + 1 ) NEW_LINE i , j = 0 , 0 NEW_LINE m = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT m [ arr [ i ] ] = m . get ( arr [ i ] , 0 ) + 1 NEW_LINE DEDENT product = 1 NEW_LINE for it in m : NEW_LINE INDENT if ( prime [ m [ it ] ] ) : NEW_LINE INDENT product *= it % MOD NEW_LINE product %= MOD NEW_LINE DEDENT DEDENT return product NEW_LINE DEDENT arr = [ 5 , 4 , 6 , 5 , 4 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE print ( productPrimeFreq ( arr , n ) ) NEW_LINE +" +E1368,"class GFG { static int maxval ( int [ ] a , int n ) { if ( n < 2 ) { System . out . print ( "" Invalid ▁ Input "" ) ; return - 9999 ; } int max1 = 0 , max2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] + i ; if ( x > max1 ) { max2 = max1 ; max1 = x ; } else if ( x > max2 & x != max1 ) { max2 = x ; } } return ( max1 * max2 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 3 , 1 , 10 } ; int len = arr . length ; System . out . println ( maxval ( arr , len ) ) ; } } +","def maxval ( a , n ) : NEW_LINE INDENT if ( n < 2 ) : NEW_LINE INDENT print ( "" Invalid ▁ Input "" ) NEW_LINE return - 9999 NEW_LINE DEDENT ( max1 , max2 ) = ( 0 , 0 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT x = a [ i ] + i NEW_LINE if ( x > max1 ) : NEW_LINE INDENT max2 = max1 NEW_LINE max1 = x NEW_LINE DEDENT elif ( x > max2 and x != max1 ) : NEW_LINE INDENT max2 = x NEW_LINE DEDENT DEDENT return ( max1 * max2 ) NEW_LINE DEDENT print ( maxval ( [ 4 , 5 , 3 , 1 , 10 ] , 5 ) ) NEW_LINE +" +E1369,"class GFG { static class Node { int data ; Node left ; Node right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static int result ; static int minPathSumUtil ( Node root ) { if ( root == null ) return 0 ; if ( root . left == null && root . right == null ) return root . data ; int ls = minPathSumUtil ( root . left ) ; int rs = minPathSumUtil ( root . right ) ; if ( root . left != null && root . right != null ) { result = Math . min ( result , ls + rs + root . data ) ; return Math . min ( ls + root . data , rs + root . data ) ; } if ( root . left == null ) return rs + root . data ; else return ls + root . data ; } static int minPathSum ( Node root ) { result = Integer . MAX_VALUE ; minPathSumUtil ( root ) ; return result ; } public static void main ( String args [ ] ) { Node root = newNode ( 4 ) ; root . left = newNode ( 5 ) ; root . right = newNode ( - 6 ) ; root . left . left = newNode ( 2 ) ; root . left . right = newNode ( - 3 ) ; root . right . left = newNode ( 1 ) ; root . right . right = newNode ( 8 ) ; System . out . print ( minPathSum ( root ) ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def newNode ( data ) : NEW_LINE INDENT node = Node ( 0 ) NEW_LINE node . data = data NEW_LINE node . left = node . right = None NEW_LINE return ( node ) NEW_LINE DEDENT result = - 1 NEW_LINE def minPathSumUtil ( root ) : NEW_LINE INDENT global result NEW_LINE if ( root == None ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( root . left == None and root . right == None ) : NEW_LINE INDENT return root . data NEW_LINE DEDENT ls = minPathSumUtil ( root . left ) NEW_LINE rs = minPathSumUtil ( root . right ) NEW_LINE if ( root . left != None and root . right != None ) : NEW_LINE INDENT result = min ( result , ls + rs + root . data ) NEW_LINE return min ( ls + root . data , rs + root . data ) NEW_LINE DEDENT if ( root . left == None ) : NEW_LINE INDENT return rs + root . data NEW_LINE DEDENT else : NEW_LINE INDENT return ls + root . data NEW_LINE DEDENT DEDENT def minPathSum ( root ) : NEW_LINE INDENT global result NEW_LINE result = 9999999 NEW_LINE minPathSumUtil ( root ) NEW_LINE return result NEW_LINE DEDENT root = newNode ( 4 ) NEW_LINE root . left = newNode ( 5 ) NEW_LINE root . right = newNode ( - 6 ) NEW_LINE root . left . left = newNode ( 2 ) NEW_LINE root . left . right = newNode ( - 3 ) NEW_LINE root . right . left = newNode ( 1 ) NEW_LINE root . right . right = newNode ( 8 ) NEW_LINE print ( minPathSum ( root ) ) NEW_LINE +" +E1370,"import java . io . * ; class GFG { static long andOperator ( long a , long b ) { while ( a < b ) { b -= ( b & - b ) ; } return b ; } public static void main ( String [ ] args ) { long a , b ; a = 10 ; b = 15 ; System . out . println ( andOperator ( a , b ) ) ; } } +","def andOperator ( a , b ) : NEW_LINE INDENT while ( a < b ) : NEW_LINE INDENT b -= ( b & - b ) NEW_LINE DEDENT return b NEW_LINE DEDENT a , b = 10 , 15 NEW_LINE print ( andOperator ( a , b ) ) NEW_LINE +" +E1371,"import java . io . * ; class GFG { 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 ) ; } static int countPrimitiveRoots ( int p ) { int result = 1 ; for ( int i = 2 ; i < p ; i ++ ) if ( __gcd ( i , p ) == 1 ) result ++ ; return result ; } public static void main ( String [ ] args ) { int p = 5 ; System . out . println ( countPrimitiveRoots ( p - 1 ) ) ; } } +","from math import gcd NEW_LINE def countPrimitiveRoots ( p ) : NEW_LINE INDENT result = 1 NEW_LINE for i in range ( 2 , p , 1 ) : NEW_LINE INDENT if ( gcd ( i , p ) == 1 ) : NEW_LINE INDENT result += 1 NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT p = 5 NEW_LINE print ( countPrimitiveRoots ( p - 1 ) ) NEW_LINE DEDENT +" +E1372,"import java . util . * ; class GFG { static void printPattern ( int n ) { int i , j ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j < 2 * n ; j ++ ) { if ( j == ( n - i + 1 ) || j == ( n + i - 1 ) ) { System . out . print ( "" * ▁ "" ) ; } else if ( ( i >= 4 && i <= n - 4 ) && ( j == n - i + 4 || j == n + i - 4 ) ) { System . out . print ( "" * ▁ "" ) ; } else if ( i == n || ( i == n - 4 && j >= n - ( n - 2 * 4 ) && j <= n + n - 2 * 4 ) ) { System . out . print ( "" * ▁ "" ) ; } else { System . out . print ( "" ▁ "" + "" ▁ "" ) ; } } System . out . print ( "" \n "" ) ; } } public static void main ( String [ ] args ) { int N = 9 ; printPattern ( N ) ; } } +","def printPattern ( n ) : NEW_LINE INDENT for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , 2 * n ) : NEW_LINE INDENT if ( j == ( n - i + 1 ) or j == ( n + i - 1 ) ) : NEW_LINE INDENT print ( "" * ▁ "" , end = "" "" ) NEW_LINE DEDENT elif ( ( i >= 4 and i <= n - 4 ) and ( j == n - i + 4 or j == n + i - 4 ) ) : NEW_LINE INDENT print ( "" * ▁ "" , end = "" "" ) NEW_LINE DEDENT elif ( i == n or ( i == n - 4 and j >= n - ( n - 2 * 4 ) and j <= n + n - 2 * 4 ) ) : NEW_LINE INDENT print ( "" * ▁ "" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" ▁ "" + "" ▁ "" , end = "" "" ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE DEDENT DEDENT N = 9 NEW_LINE printPattern ( N ) NEW_LINE +" +E1373,"import java . util . * ; class GFG { static void printOrder ( int [ ] arr , int n , int k ) { int len1 = k , len2 = n - k ; int [ ] arr1 = new int [ k ] ; int [ ] arr2 = new int [ n - k ] ; for ( int i = 0 ; i < k ; i ++ ) arr1 [ i ] = arr [ i ] ; for ( int i = k ; i < n ; i ++ ) arr2 [ i - k ] = arr [ i ] ; Arrays . sort ( arr1 , 0 , k ) ; Arrays . sort ( arr2 , k , n - k ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < k ) arr [ i ] = arr1 [ i ] ; else { arr [ i ] = arr2 [ len2 - 1 ] ; len2 -- ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 4 , 6 , 2 , 1 , 3 , 8 , 9 , - 1 } ; int k = 4 ; int n = arr . length ; printOrder ( arr , n , k ) ; } } +","def printOrder ( arr , n , k ) : NEW_LINE INDENT len1 = k NEW_LINE len2 = n - k NEW_LINE arr1 = [ 0 ] * k NEW_LINE arr2 = [ 0 ] * ( n - k ) NEW_LINE for i in range ( k ) : NEW_LINE INDENT arr1 [ i ] = arr [ i ] NEW_LINE DEDENT for i in range ( k , n ) : NEW_LINE INDENT arr2 [ i - k ] = arr [ i ] NEW_LINE DEDENT arr1 . sort ( ) NEW_LINE arr2 . sort ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( i < k ) : NEW_LINE INDENT arr [ i ] = arr1 [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT arr [ i ] = arr2 [ len2 - 1 ] NEW_LINE len2 -= 1 NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 5 , 4 , 6 , 2 , 1 , 3 , 8 , 9 , - 1 ] NEW_LINE k = 4 NEW_LINE n = len ( arr ) NEW_LINE printOrder ( arr , n , k ) NEW_LINE DEDENT +" +E1374,"import java . util . * ; class GFG { static boolean isPlusPossible ( int arr [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } boolean foundModOne = false ; for ( Map . Entry < Integer , Integer > x : mp . entrySet ( ) ) { int element = x . getKey ( ) ; int frequency = x . getValue ( ) ; if ( frequency % 4 == 0 ) continue ; if ( frequency % 4 == 1 ) { if ( foundModOne ) return false ; foundModOne = true ; } else return false ; } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 2 } ; int n = arr . length ; if ( isPlusPossible ( arr , n ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def isPlusPossible ( arr , n ) : NEW_LINE INDENT mp = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT mp [ arr [ i ] ] = mp . get ( arr [ i ] , 0 ) + 1 NEW_LINE DEDENT foundModOne = False NEW_LINE for x in mp : NEW_LINE INDENT element = x NEW_LINE frequency = mp [ x ] NEW_LINE if ( frequency % 4 == 0 ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( frequency % 4 == 1 ) : NEW_LINE INDENT if ( foundModOne == True ) : NEW_LINE INDENT return False NEW_LINE DEDENT foundModOne = True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT arr = [ 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE if ( isPlusPossible ( arr , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1375,"class GFG { static float sumOfAP ( float a , float d , float n ) { float sum = ( n / 2 ) * ( 2 * a + ( n - 1 ) * d ) ; return sum ; } public static void main ( String [ ] args ) { float n = 20 ; float a = 2.5f , d = 1.5f ; System . out . print ( sumOfAP ( a , d , n ) ) ; } } +","def sumOfAP ( a , d , n ) : NEW_LINE INDENT sum = ( n / 2 ) * ( 2 * a + ( n - 1 ) * d ) NEW_LINE return sum NEW_LINE DEDENT n = 20 NEW_LINE a = 2.5 NEW_LINE d = 1.5 NEW_LINE print ( sumOfAP ( a , d , n ) ) NEW_LINE +" +E1376,"import java . io . * ; import java . math . * ; class GFG { static boolean isPerfectSquare ( int num ) { int n = ( int ) ( Math . sqrt ( num ) ) ; return ( n * n == num ) ; } static void checkFib ( int array [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPerfectSquare ( 5 * array [ i ] * array [ i ] + 4 ) || isPerfectSquare ( 5 * array [ i ] * array [ i ] - 4 ) ) { System . out . print ( array [ i ] + "" ▁ "" ) ; count ++ ; } } if ( count == 0 ) System . out . println ( "" None ▁ Present "" ) ; } public static void main ( String [ ] args ) { int array [ ] = { 4 , 2 , 8 , 5 , 20 , 1 , 40 , 13 , 23 } ; int n = array . length ; checkFib ( array , n ) ; } } +","import math NEW_LINE def isPerfectSquare ( num ) : NEW_LINE INDENT n = int ( math . sqrt ( num ) ) NEW_LINE return ( n * n == num ) NEW_LINE DEDENT def checkFib ( array , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( isPerfectSquare ( 5 * array [ i ] * array [ i ] + 4 ) or isPerfectSquare ( 5 * array [ i ] * array [ i ] - 4 ) ) : NEW_LINE INDENT print ( array [ i ] , "" ▁ "" , end = "" "" ) ; NEW_LINE count = count + 1 NEW_LINE DEDENT DEDENT if ( count == 0 ) : NEW_LINE INDENT print ( "" None ▁ present "" ) ; NEW_LINE DEDENT DEDENT array = [ 4 , 2 , 8 , 5 , 20 , 1 , 40 , 13 , 23 ] NEW_LINE n = len ( array ) NEW_LINE checkFib ( array , n ) NEW_LINE +" +E1377,"import java . util . * ; class Solution { static float largestCube ( float r ) { if ( r < 0 ) return - 1 ; float a = ( 2 * r ) / ( float ) Math . sqrt ( 3 ) ; return a ; } public static void main ( String args [ ] ) { float r = 5 ; System . out . println ( largestCube ( r ) ) ; } } +","from math import sqrt NEW_LINE def largestCube ( r ) : NEW_LINE INDENT if ( r < 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT a = ( 2 * r ) / sqrt ( 3 ) NEW_LINE return a NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT r = 5 NEW_LINE print ( "" { 0 : . 6 } "" . format ( largestCube ( r ) ) ) NEW_LINE DEDENT +" +E1378,"class GFG { static int countTransformation ( String a , String b ) { int n = a . length ( ) , m = b . length ( ) ; if ( m == 0 ) { return 1 ; } int dp [ ] [ ] = new int [ m ] [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( i == 0 ) { if ( j == 0 ) { dp [ i ] [ j ] = ( a . charAt ( j ) == b . charAt ( i ) ) ? 1 : 0 ; } else if ( a . charAt ( j ) == b . charAt ( i ) ) { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + 1 ; } else { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] ; } } else if ( a . charAt ( j ) == b . charAt ( i ) ) { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j - 1 ] ; } else { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] ; } } } return dp [ m - 1 ] [ n - 1 ] ; } public static void main ( String [ ] args ) { String a = "" abcccdf "" , b = "" abccdf "" ; System . out . println ( countTransformation ( a , b ) ) ; } } +","def countTransformation ( a , b ) : NEW_LINE INDENT n = len ( a ) NEW_LINE m = len ( b ) NEW_LINE if m == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT dp = [ [ 0 ] * ( n ) for _ in range ( m ) ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT for j in range ( i , n ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT if j == 0 : NEW_LINE INDENT if a [ j ] == b [ i ] : NEW_LINE INDENT dp [ i ] [ j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = 0 NEW_LINE DEDENT DEDENT elif a [ j ] == b [ i ] : NEW_LINE INDENT dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = dp [ i ] [ j - 1 ] NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if a [ j ] == b [ i ] : NEW_LINE INDENT dp [ i ] [ j ] = ( dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = dp [ i ] [ j - 1 ] NEW_LINE DEDENT DEDENT DEDENT DEDENT return dp [ m - 1 ] [ n - 1 ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = "" abcccdf "" NEW_LINE b = "" abccdf "" NEW_LINE print ( countTransformation ( a , b ) ) NEW_LINE DEDENT +" +E1379,"import java . util . HashMap ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void findFourElements ( int arr [ ] , int n , int X ) { HashMap < Integer , pair > mp = new HashMap < Integer , pair > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) mp . put ( arr [ i ] + arr [ j ] , new pair ( i , j ) ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int sum = arr [ i ] + arr [ j ] ; if ( mp . containsKey ( X - sum ) ) { pair p = mp . get ( X - sum ) ; if ( p . first != i && p . first != j && p . second != i && p . second != j ) { System . out . print ( arr [ i ] + "" , ▁ "" + arr [ j ] + "" , ▁ "" + arr [ p . first ] + "" , ▁ "" + arr [ p . second ] ) ; return ; } } } } } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 20 , 30 , 40 , 1 , 2 } ; int n = arr . length ; int X = 91 ; findFourElements ( arr , n , X ) ; } } +","def findFourElements ( arr , n , X ) : NEW_LINE INDENT mp = { } NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT mp [ arr [ i ] + arr [ j ] ] = [ i , j ] NEW_LINE DEDENT DEDENT for i in range ( n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT summ = arr [ i ] + arr [ j ] NEW_LINE if ( X - summ ) in mp : NEW_LINE INDENT p = mp [ X - summ ] NEW_LINE if ( p [ 0 ] != i and p [ 0 ] != j and p [ 1 ] != i and p [ 1 ] != j ) : NEW_LINE INDENT print ( arr [ i ] , "" , ▁ "" , arr [ j ] , "" , ▁ "" , arr [ p [ 0 ] ] , "" , ▁ "" , arr [ p [ 1 ] ] , sep = "" "" ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT arr = [ 10 , 20 , 30 , 40 , 1 , 2 ] NEW_LINE n = len ( arr ) NEW_LINE X = 91 NEW_LINE findFourElements ( arr , n , X ) NEW_LINE +" +E1380,"import java . io . * ; class GFG { static int countWays ( int n ) { int counter = 0 ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = i ; j < n ; j ++ ) for ( int k = j ; k < n ; k ++ ) for ( int l = k ; l < n ; l ++ ) if ( i + j + k + l == n ) counter ++ ; return counter ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( countWays ( n ) ) ; } } +","def countWays ( n ) : NEW_LINE INDENT counter = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT for j in range ( i , n ) : NEW_LINE INDENT for k in range ( j , n ) : NEW_LINE INDENT for l in range ( k , n ) : NEW_LINE INDENT if ( i + j + k + l == n ) : NEW_LINE INDENT counter += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT return counter NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 8 NEW_LINE print ( countWays ( n ) ) NEW_LINE DEDENT +" +E1381,"class MaxConsecutiveOnes { private static int maxConsecutiveOnes ( int x ) { int count = 0 ; while ( x != 0 ) { x = ( x & ( x << 1 ) ) ; count ++ ; } return count ; } public static void main ( String strings [ ] ) { System . out . println ( maxConsecutiveOnes ( 14 ) ) ; System . out . println ( maxConsecutiveOnes ( 222 ) ) ; } } +","def maxConsecutiveOnes ( x ) : NEW_LINE INDENT count = 0 NEW_LINE while ( x != 0 ) : NEW_LINE INDENT x = ( x & ( x << 1 ) ) NEW_LINE count = count + 1 NEW_LINE DEDENT return count NEW_LINE DEDENT print ( maxConsecutiveOnes ( 14 ) ) NEW_LINE print ( maxConsecutiveOnes ( 222 ) ) NEW_LINE +" +E1382,"import java . io . * ; import java . util . * ; public class GFG { public static boolean isFascinating ( int num ) { int [ ] freq = new int [ 10 ] ; String val = "" "" + num + num * 2 + num * 3 ; for ( int i = 0 ; i < val . length ( ) ; i ++ ) { int digit = val . charAt ( i ) - '0' ; if ( freq [ digit ] > 0 ) return false ; else freq [ digit ] ++ ; } for ( int i = 1 ; i < freq . length ; i ++ ) { if ( freq [ i ] == 0 ) return false ; } return true ; } public static void main ( String args [ ] ) { int num = 192 ; if ( num < 100 ) System . out . println ( "" No "" ) ; else { boolean ans = isFascinating ( num ) ; if ( ans ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } } +","def isFascinating ( num ) : NEW_LINE INDENT freq = [ 0 ] * 10 NEW_LINE val = ( str ( num ) + str ( num * 2 ) + str ( num * 3 ) ) NEW_LINE for i in range ( len ( val ) ) : NEW_LINE INDENT digit = int ( val [ i ] ) NEW_LINE if freq [ digit ] > 0 : NEW_LINE INDENT return False NEW_LINE DEDENT else : NEW_LINE INDENT freq [ digit ] += 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , 10 ) : NEW_LINE INDENT if freq [ i ] == 0 : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT num = 192 NEW_LINE if num < 100 : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = isFascinating ( num ) NEW_LINE if ans : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT DEDENT +" +E1383,"import java . io . * ; class GFG { static void printDistinct ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < i ; j ++ ) if ( arr [ i ] == arr [ j ] ) break ; if ( i == j ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 10 , 5 , 4 , 9 , 120 , 4 , 6 , 10 } ; int n = arr . length ; printDistinct ( arr , n ) ; } } +","def printDistinct ( arr , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT d = 0 NEW_LINE for j in range ( 0 , i ) : NEW_LINE INDENT if ( arr [ i ] == arr [ j ] ) : NEW_LINE INDENT d = 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ( d == 0 ) : NEW_LINE INDENT print ( arr [ i ] ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 6 , 10 , 5 , 4 , 9 , 120 , 4 , 6 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE printDistinct ( arr , n ) NEW_LINE +" +E1384,"import java . io . * ; class Solution { static int closestMultiple ( int n , int x ) { if ( x > n ) return x ; n = n + x / 2 ; n = n - ( n % x ) ; return n ; } public static void main ( String [ ] args ) { int n = 56287 , x = 27 ; System . out . println ( closestMultiple ( n , x ) ) ; } } +","def closestMultiple ( n , x ) : NEW_LINE INDENT if x > n : NEW_LINE INDENT return x ; NEW_LINE DEDENT z = ( int ) ( x / 2 ) ; NEW_LINE n = n + z ; NEW_LINE n = n - ( n % x ) ; NEW_LINE return n ; NEW_LINE DEDENT n = 56287 ; NEW_LINE x = 27 ; NEW_LINE print ( closestMultiple ( n , x ) ) ; NEW_LINE +" +E1385,"public class GFG { static final int MAX = 1000 ; static int maxSubsequenceSubstring ( char x [ ] , char y [ ] , int n , int m ) { int dp [ ] [ ] = new int [ MAX ] [ MAX ] ; for ( int i = 0 ; i <= m ; i ++ ) for ( int j = 0 ; j <= n ; j ++ ) dp [ i ] [ j ] = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( x [ j - 1 ] == y [ i - 1 ] ) dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] ; else dp [ i ] [ j ] = dp [ i ] [ j - 1 ] ; } } int ans = 0 ; for ( int i = 1 ; i <= m ; i ++ ) ans = Math . max ( ans , dp [ i ] [ n ] ) ; return ans ; } public static void main ( String [ ] args ) { char x [ ] = "" ABCD "" . toCharArray ( ) ; char y [ ] = "" BACDBDCD "" . toCharArray ( ) ; int n = x . length , m = y . length ; System . out . println ( maxSubsequenceSubstring ( x , y , n , m ) ) ; } } +","MAX = 1000 NEW_LINE def maxSubsequenceSubstring ( x , y , n , m ) : NEW_LINE INDENT dp = [ [ 0 for i in range ( MAX ) ] for i in range ( MAX ) ] NEW_LINE for i in range ( 1 , m + 1 ) : NEW_LINE INDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( x [ j - 1 ] == y [ i - 1 ] ) : NEW_LINE INDENT dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = dp [ i ] [ j - 1 ] NEW_LINE DEDENT DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 1 , m + 1 ) : NEW_LINE INDENT ans = max ( ans , dp [ i ] [ n ] ) NEW_LINE DEDENT return ans NEW_LINE DEDENT x = "" ABCD "" NEW_LINE y = "" BACDBDCD "" NEW_LINE n = len ( x ) NEW_LINE m = len ( y ) NEW_LINE print ( maxSubsequenceSubstring ( x , y , n , m ) ) NEW_LINE +" +E1386,"import java . io . * ; import java . util . * ; class GFG { static int findMaxGCD ( int [ ] arr , int n , int k ) { Arrays . sort ( arr ) ; int high = arr [ n - 1 ] ; int [ ] divisors = new int [ high + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= Math . sqrt ( arr [ i ] ) ; j ++ ) { if ( arr [ i ] % j == 0 ) { divisors [ j ] ++ ; if ( j != arr [ i ] / j ) divisors [ arr [ i ] / j ] ++ ; } } } for ( int i = high ; i >= 1 ; i -- ) if ( divisors [ i ] >= k ) return i ; return 0 ; } static public void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 8 , 8 , 12 } ; int k = 3 ; int n = arr . length ; System . out . println ( findMaxGCD ( arr , n , k ) ) ; } } +","import math NEW_LINE def findMaxGCD ( arr , n , k ) : NEW_LINE INDENT high = max ( arr ) NEW_LINE divisors = [ 0 ] * ( high + 1 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( 1 , int ( math . sqrt ( arr [ i ] ) ) + 1 ) : NEW_LINE INDENT if ( arr [ i ] % j == 0 ) : NEW_LINE INDENT divisors [ j ] += 1 NEW_LINE if ( j != arr [ i ] // j ) : NEW_LINE INDENT divisors [ arr [ i ] // j ] += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in range ( high , 0 , - 1 ) : NEW_LINE INDENT if ( divisors [ i ] >= k ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 8 , 8 , 12 ] NEW_LINE k = 3 NEW_LINE n = len ( arr ) NEW_LINE print ( findMaxGCD ( arr , n , k ) ) NEW_LINE DEDENT +" +E1387,"class GFG { static int Max_Sum ( int n ) { return ( n * ( n - 1 ) ) / 2 ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( Max_Sum ( n ) ) ; } } +","def Max_Sum ( n ) : NEW_LINE INDENT return ( n * ( n - 1 ) ) // 2 ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 8 ; NEW_LINE print ( Max_Sum ( n ) ) ; NEW_LINE DEDENT +" +E1388,"class GFG { static int [ ] [ ] [ ] [ ] lookup = new int [ 50 ] [ 1000 ] [ 1000 ] [ 2 ] ; static int countRec ( int digits , int esum , int osum , int isOdd , int n ) { if ( digits == n ) return ( esum - osum == 1 ) ? 1 : 0 ; if ( lookup [ digits ] [ esum ] [ osum ] [ isOdd ] != - 1 ) return lookup [ digits ] [ esum ] [ osum ] [ isOdd ] ; int ans = 0 ; if ( isOdd == 1 ) for ( int i = 0 ; i <= 9 ; i ++ ) ans += countRec ( digits + 1 , esum , osum + i , 0 , n ) ; else for ( int i = 0 ; i <= 9 ; i ++ ) ans += countRec ( digits + 1 , esum + i , osum , 1 , n ) ; return lookup [ digits ] [ esum ] [ osum ] [ isOdd ] = ans ; } static int finalCount ( int n ) { int digits = 0 ; for ( int i = 0 ; i < 50 ; i ++ ) for ( int j = 0 ; j < 1000 ; j ++ ) for ( int k = 0 ; k < 1000 ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) lookup [ i ] [ j ] [ k ] [ l ] = - 1 ; int ans = 0 ; int esum = 0 , osum = 0 ; for ( int i = 1 ; i <= 9 ; i ++ ) ans += countRec ( digits + 1 , esum + i , osum , 1 , n ) ; return ans ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "" Coutn ▁ of ▁ "" + n + "" ▁ digit ▁ numbers ▁ is ▁ "" + finalCount ( n ) ) ; } } +","def countRec ( digits , esum , osum , isOdd , n ) : NEW_LINE INDENT if digits == n : NEW_LINE INDENT return ( esum - osum == 1 ) NEW_LINE DEDENT if lookup [ digits ] [ esum ] [ osum ] [ isOdd ] != - 1 : NEW_LINE INDENT return lookup [ digits ] [ esum ] [ osum ] [ isOdd ] NEW_LINE DEDENT ans = 0 NEW_LINE if isOdd : NEW_LINE INDENT for i in range ( 10 ) : NEW_LINE INDENT ans += countRec ( digits + 1 , esum , osum + i , False , n ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 10 ) : NEW_LINE INDENT ans += countRec ( digits + 1 , esum + i , osum , True , n ) NEW_LINE DEDENT DEDENT lookup [ digits ] [ esum ] [ osum ] [ isOdd ] = ans NEW_LINE return ans NEW_LINE DEDENT def finalCount ( n ) : NEW_LINE INDENT global lookup NEW_LINE digits = 0 NEW_LINE lookup = [ [ [ [ - 1 , - 1 ] for i in range ( 500 ) ] for j in range ( 500 ) ] for k in range ( 50 ) ] NEW_LINE ans = 0 NEW_LINE esum = 0 NEW_LINE osum = 0 NEW_LINE for i in range ( 1 , 10 ) : NEW_LINE INDENT ans += countRec ( digits + 1 , esum + i , osum , True , n ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT lookup = [ ] NEW_LINE n = 3 NEW_LINE print ( "" Count ▁ of ▁ % d ▁ digit ▁ numbers ▁ is ▁ % d "" % ( n , finalCount ( n ) ) ) NEW_LINE DEDENT +" +E1389,"public class LCS_3Strings { static int lcsOf3 ( String X , String Y , String Z , int m , int n , int o ) { int [ ] [ ] [ ] L = new int [ m + 1 ] [ n + 1 ] [ o + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { for ( int k = 0 ; k <= o ; k ++ ) { if ( i == 0 || j == 0 || k == 0 ) L [ i ] [ j ] [ k ] = 0 ; else if ( X . charAt ( i - 1 ) == Y . charAt ( j - 1 ) && X . charAt ( i - 1 ) == Z . charAt ( k - 1 ) ) L [ i ] [ j ] [ k ] = L [ i - 1 ] [ j - 1 ] [ k - 1 ] + 1 ; else L [ i ] [ j ] [ k ] = Math . max ( Math . max ( L [ i - 1 ] [ j ] [ k ] , L [ i ] [ j - 1 ] [ k ] ) , L [ i ] [ j ] [ k - 1 ] ) ; } } } return L [ m ] [ n ] [ o ] ; } public static void main ( String args [ ] ) { String X = "" AGGT12"" ; String Y = ""12TXAYB "" ; String Z = ""12XBA "" ; int m = X . length ( ) ; int n = Y . length ( ) ; int o = Z . length ( ) ; System . out . println ( "" Length ▁ of ▁ LCS ▁ is ▁ "" + lcsOf3 ( X , Y , Z , m , n , o ) ) ; } } +","def lcsOf3 ( X , Y , Z , m , n , o ) : NEW_LINE INDENT L = [ [ [ 0 for i in range ( o + 1 ) ] for j in range ( n + 1 ) ] for k in range ( m + 1 ) ] NEW_LINE for i in range ( m + 1 ) : NEW_LINE INDENT for j in range ( n + 1 ) : NEW_LINE INDENT for k in range ( o + 1 ) : NEW_LINE INDENT if ( i == 0 or j == 0 or k == 0 ) : NEW_LINE INDENT L [ i ] [ j ] [ k ] = 0 NEW_LINE DEDENT elif ( X [ i - 1 ] == Y [ j - 1 ] and X [ i - 1 ] == Z [ k - 1 ] ) : NEW_LINE INDENT L [ i ] [ j ] [ k ] = L [ i - 1 ] [ j - 1 ] [ k - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT L [ i ] [ j ] [ k ] = max ( max ( L [ i - 1 ] [ j ] [ k ] , L [ i ] [ j - 1 ] [ k ] ) , L [ i ] [ j ] [ k - 1 ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return L [ m ] [ n ] [ o ] NEW_LINE DEDENT X = ' AGGT12' NEW_LINE Y = '12TXAYB ' NEW_LINE Z = '12XBA ' NEW_LINE m = len ( X ) NEW_LINE n = len ( Y ) NEW_LINE o = len ( Z ) NEW_LINE print ( ' Length ▁ of ▁ LCS ▁ is ' , lcsOf3 ( X , Y , Z , m , n , o ) ) NEW_LINE +" +E1390,"import java . io . * ; class GFG { static void printGreater ( int x , int y ) { double X = y * Math . log ( x ) ; double Y = x * Math . log ( y ) ; if ( Math . abs ( X - Y ) < 1e-9 ) { System . out . println ( "" Equal "" ) ; } else if ( X > Y ) { System . out . println ( x + "" ^ "" + y ) ; } else { System . out . println ( y + "" ^ "" + x ) ; } } public static void main ( String [ ] args ) { int x = 5 , y = 8 ; printGreater ( x , y ) ; } } +","import math NEW_LINE def printGreater ( x , y ) : NEW_LINE INDENT X = y * math . log ( x ) ; NEW_LINE Y = x * math . log ( y ) ; NEW_LINE if ( abs ( X - Y ) < 1e-9 ) : NEW_LINE INDENT print ( "" Equal "" ) ; NEW_LINE DEDENT elif ( X > Y ) : NEW_LINE INDENT print ( x , "" ^ "" , y ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( y , "" ^ "" , x ) ; NEW_LINE DEDENT DEDENT x = 5 ; NEW_LINE y = 8 ; NEW_LINE printGreater ( x , y ) ; NEW_LINE +" +E1391,"import java . util . Arrays ; class GFG { static int getElement ( int a [ ] , int n , int S ) { Arrays . sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( sum + ( a [ i ] * ( n - i ) ) == S ) return a [ i ] ; sum += a [ i ] ; } return - 1 ; } public static void main ( String [ ] args ) { int S = 5 ; int a [ ] = { 1 , 3 , 2 , 5 , 8 } ; int n = a . length ; System . out . println ( getElement ( a , n , S ) ) ; } } +","def getElement ( a , n , S ) : NEW_LINE INDENT a . sort ( ) ; NEW_LINE sum = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( sum + ( a [ i ] * ( n - i ) ) == S ) : NEW_LINE INDENT return a [ i ] ; NEW_LINE DEDENT sum += a [ i ] ; NEW_LINE DEDENT return - 1 ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT S = 5 ; NEW_LINE a = [ 1 , 3 , 2 , 5 , 8 ] ; NEW_LINE n = len ( a ) ; NEW_LINE print ( getElement ( a , n , S ) ) ; NEW_LINE DEDENT +" +E1392,"class GFG { static boolean canMakeEqual ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { while ( a [ i ] % 5 == 0 ) { a [ i ] /= 5 ; } while ( a [ i ] % 3 == 0 ) { a [ i ] /= 3 ; } } int last = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] != last ) { return false ; } } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 18 , 30 , 54 , 90 , 162 } ; int n = arr . length ; if ( canMakeEqual ( arr , n ) ) { System . out . print ( "" YES "" + "" \n "" ) ; } else { System . out . print ( "" NO "" + "" \n "" ) ; } } } +","def canMakeEqual ( a , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT while ( a [ i ] % 5 == 0 ) : NEW_LINE INDENT a [ i ] //= 5 ; NEW_LINE DEDENT while ( a [ i ] % 3 == 0 ) : NEW_LINE INDENT a [ i ] //= 3 ; NEW_LINE DEDENT DEDENT last = a [ 0 ] ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( a [ i ] != last ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT return True ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 18 , 30 , 54 , 90 , 162 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE if ( canMakeEqual ( arr , n ) ) : NEW_LINE INDENT print ( "" YES "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) ; NEW_LINE DEDENT DEDENT +" +E1393,"import java . * ; public class GFG { public static void main ( String a [ ] ) { int x = 10 ; int y = 5 ; x = x ^ y ; y = x ^ y ; x = x ^ y ; System . out . println ( "" After ▁ swap : ▁ x ▁ = ▁ "" + x + "" , ▁ y ▁ = ▁ "" + y ) ; } } +","x = 10 NEW_LINE y = 5 NEW_LINE x = x ^ y ; NEW_LINE y = x ^ y ; NEW_LINE x = x ^ y ; NEW_LINE print ( "" After ▁ Swapping : ▁ x ▁ = ▁ "" , x , "" ▁ y ▁ = "" , y ) NEW_LINE +" +E1394,"import java . util . * ; class geeks { public static int minimumOperations ( int [ ] a , int n ) { HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . get ( a [ i ] ) != null ) { int x = mp . get ( a [ i ] ) ; mp . put ( a [ i ] , ++ x ) ; } else mp . put ( a [ i ] , 1 ) ; } int count = 0 ; for ( HashMap . Entry < Integer , Integer > entry : mp . entrySet ( ) ) { if ( entry . getValue ( ) > 1 ) { count += ( entry . getValue ( ) - 1 ) ; } } return count ; } public static void main ( String [ ] args ) { int [ ] a = { 2 , 1 , 2 , 3 , 3 , 4 , 3 } ; int n = a . length ; System . out . println ( minimumOperations ( a , n ) ) ; } } +","def minimumOperations ( a , n ) : NEW_LINE INDENT mp = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if a [ i ] in mp . keys ( ) : NEW_LINE INDENT mp [ a [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT mp [ a [ i ] ] = 1 NEW_LINE DEDENT DEDENT count = 0 NEW_LINE for it in mp : NEW_LINE INDENT if ( mp [ it ] > 1 ) : NEW_LINE INDENT count += mp [ it ] - 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT a = [ 2 , 1 , 2 , 3 , 3 , 4 , 3 ] NEW_LINE n = len ( a ) NEW_LINE print ( minimumOperations ( a , n ) ) NEW_LINE +" +E1395,"import java . util . * ; class GFG { static int xorRange ( int pre [ ] , int l , int r ) { int cntOnes = pre [ r ] ; if ( l - 1 >= 0 ) cntOnes -= pre [ l - 1 ] ; if ( cntOnes % 2 == 0 ) return 0 ; else return 1 ; } static void performQueries ( int queries [ ] [ ] , int q , int a [ ] , int n ) { int [ ] pre = new int [ n ] ; pre [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = pre [ i - 1 ] + a [ i ] ; for ( int i = 0 ; i < q ; i ++ ) System . out . println ( xorRange ( pre , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 0 , 1 , 1 , 0 , 1 , 1 } ; int n = a . length ; int queries [ ] [ ] = { { 0 , 3 } , { 0 , 2 } } ; int q = queries . length ; performQueries ( queries , q , a , n ) ; } } +","def xorRange ( pre , l , r ) : NEW_LINE INDENT cntOnes = pre [ r ] NEW_LINE if ( l - 1 >= 0 ) : NEW_LINE INDENT cntOnes -= pre [ l - 1 ] NEW_LINE DEDENT if ( cntOnes % 2 == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT def performQueries ( queries , q , a , n ) : NEW_LINE INDENT pre = [ 0 for i in range ( n ) ] NEW_LINE pre [ 0 ] = a [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT pre [ i ] = pre [ i - 1 ] + a [ i ] NEW_LINE DEDENT for i in range ( q ) : NEW_LINE INDENT print ( xorRange ( pre , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) NEW_LINE DEDENT DEDENT a = [ 1 , 0 , 1 , 1 , 0 , 1 , 1 ] NEW_LINE n = len ( a ) NEW_LINE queries = [ [ 0 , 3 ] , [ 0 , 2 ] ] NEW_LINE q = len ( queries ) NEW_LINE performQueries ( queries , q , a , n ) NEW_LINE +" +E1396,"class gfg { static int countNums ( int n , int x , int y ) { boolean [ ] arr = new boolean [ n + 1 ] ; if ( x <= n ) arr [ x ] = true ; if ( y <= n ) arr [ y ] = true ; int result = 0 ; for ( int i = Math . min ( x , y ) ; i <= n ; i ++ ) { if ( arr [ i ] ) { if ( i + x <= n ) arr [ i + x ] = true ; if ( i + y <= n ) arr [ i + y ] = true ; result ++ ; } } return result ; } public static void main ( String [ ] args ) { int n = 15 , x = 5 , y = 7 ; System . out . println ( countNums ( n , x , y ) ) ; } } +","def countNums ( n , x , y ) : NEW_LINE INDENT arr = [ False for i in range ( n + 2 ) ] NEW_LINE if ( x <= n ) : NEW_LINE INDENT arr [ x ] = True NEW_LINE DEDENT if ( y <= n ) : NEW_LINE INDENT arr [ y ] = True NEW_LINE DEDENT result = 0 NEW_LINE for i in range ( min ( x , y ) , n + 1 ) : NEW_LINE INDENT if ( arr [ i ] ) : NEW_LINE INDENT if ( i + x <= n ) : NEW_LINE INDENT arr [ i + x ] = True NEW_LINE DEDENT if ( i + y <= n ) : NEW_LINE INDENT arr [ i + y ] = True NEW_LINE DEDENT result = result + 1 NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT n = 15 NEW_LINE x = 5 NEW_LINE y = 7 NEW_LINE print ( countNums ( n , x , y ) ) NEW_LINE +" +E1397,"class GFG { static int get_max_splits ( String num_String ) { int count = 0 , current_num ; int running_sum = 0 ; for ( int i = 0 ; i < num_String . length ( ) ; i ++ ) { current_num = num_String . charAt ( i ) - '0' ; running_sum += current_num ; if ( current_num % 3 == 0 || ( running_sum != 0 && running_sum % 3 == 0 ) ) { count += 1 ; running_sum = 0 ; } } return count ; } public static void main ( String [ ] args ) { System . out . print ( get_max_splits ( ""12345"" ) + "" \n "" ) ; } } +","def get_max_splits ( num_string ) : NEW_LINE INDENT count = 0 NEW_LINE running_sum = 0 NEW_LINE for i in range ( len ( num_string ) ) : NEW_LINE INDENT current_num = int ( num_string [ i ] ) NEW_LINE running_sum += current_num NEW_LINE if current_num % 3 == 0 or ( running_sum != 0 and running_sum % 3 == 0 ) : NEW_LINE INDENT count += 1 NEW_LINE running_sum = 0 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT print get_max_splits ( ""12345"" ) NEW_LINE +" +E1398,"import java . io . * ; class Series { static int term ( int n ) { return n * ( n + 1 ) / 2 ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( term ( n ) ) ; } } +","def term ( n ) : NEW_LINE INDENT return n * ( n + 1 ) / 2 NEW_LINE DEDENT n = 4 NEW_LINE print term ( n ) NEW_LINE +" +E1399,"import java . io . * ; class GFG { static void anglequichord ( int z ) { System . out . println ( "" The ▁ angle ▁ is ▁ "" + z + "" ▁ degrees "" ) ; } public static void main ( String [ ] args ) { int z = 48 ; anglequichord ( z ) ; } } +","def anglequichord ( z ) : NEW_LINE INDENT print ( "" The ▁ angle ▁ is ▁ "" , z , "" ▁ degrees "" ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT z = 48 NEW_LINE anglequichord ( z ) NEW_LINE DEDENT +" +E1400,"import java . io . * ; class GFG { static int findLength ( String str ) { int n = str . length ( ) ; int maxlen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j += 2 ) { int length = j - i + 1 ; int leftsum = 0 , rightsum = 0 ; for ( int k = 0 ; k < length / 2 ; k ++ ) { leftsum += ( str . charAt ( i + k ) - '0' ) ; rightsum += ( str . charAt ( i + k + length / 2 ) - '0' ) ; } if ( leftsum == rightsum && maxlen < length ) maxlen = length ; } } return maxlen ; } public static void main ( String [ ] args ) { String str = ""1538023"" ; System . out . println ( "" Length ▁ of ▁ the ▁ substring ▁ is ▁ "" + findLength ( str ) ) ; } } +","def findLength ( str ) : NEW_LINE INDENT n = len ( str ) NEW_LINE maxlen = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( i + 1 , n , 2 ) : NEW_LINE INDENT length = j - i + 1 NEW_LINE leftsum = 0 NEW_LINE rightsum = 0 NEW_LINE for k in range ( 0 , int ( length / 2 ) ) : NEW_LINE INDENT leftsum += ( int ( str [ i + k ] ) - int ( '0' ) ) NEW_LINE rightsum += ( int ( str [ i + k + int ( length / 2 ) ] ) - int ( '0' ) ) NEW_LINE DEDENT if ( leftsum == rightsum and maxlen < length ) : NEW_LINE INDENT maxlen = length NEW_LINE DEDENT DEDENT DEDENT return maxlen NEW_LINE DEDENT str = ""1538023"" NEW_LINE print ( "" Length ▁ of ▁ the ▁ substring ▁ is "" , findLength ( str ) ) NEW_LINE +" +E1401,"class GFG { static int MOD = 2019 ; static int min_modulo ( int l , int r ) { if ( r - l >= MOD ) return 0 ; else { int ans = MOD - 1 ; for ( int i = l ; i <= r ; i ++ ) { for ( int j = i + 1 ; j <= r ; j ++ ) { ans = Math . min ( ans , ( i * j ) % MOD ) ; } } return ans ; } } public static void main ( String [ ] args ) { int l = 2020 , r = 2040 ; System . out . println ( min_modulo ( l , r ) ) ; } } +","MOD = 2019 ; NEW_LINE def min_modulo ( l , r ) : NEW_LINE INDENT if ( r - l >= MOD ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT else : NEW_LINE INDENT ans = MOD - 1 ; NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT for j in range ( i + 1 , r + 1 ) : NEW_LINE INDENT ans = min ( ans , ( i * j ) % MOD ) ; NEW_LINE DEDENT DEDENT return ans ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT l = 2020 ; r = 2040 ; NEW_LINE print ( min_modulo ( l , r ) ) ; NEW_LINE DEDENT +" +E1402,"class GFG { static int countPairsWithProdK ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] * arr [ j ] == k ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 3 , 4 , 2 } ; int N = arr . length ; int K = 3 ; System . out . println ( countPairsWithProdK ( arr , N , K ) ) ; } } +","def countPairsWithProdK ( arr , n , k ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( arr [ i ] * arr [ j ] == k ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 1 , 5 , 3 , 4 , 2 ] NEW_LINE N = len ( arr ) NEW_LINE K = 3 NEW_LINE print ( countPairsWithProdK ( arr , N , K ) ) NEW_LINE +" +E1403,"class GFG { public static int Xor_Sum ( int [ ] arr , int n ) { int sum = 0 , index = - 1 ; int left_xor = 0 , right_xor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { left_xor = left_xor ^ arr [ i ] ; right_xor = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) { right_xor = right_xor ^ arr [ j ] ; } if ( left_xor + right_xor > sum ) { sum = left_xor + right_xor ; index = i ; } } return index + 1 ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 4 , 6 , 3 , 8 , 13 , 34 , 2 , 21 , 10 } ; int n = arr . length ; System . out . println ( Xor_Sum ( arr , n ) ) ; } } +","def Xor_Sum ( arr , n ) : NEW_LINE INDENT sum = 0 NEW_LINE index , left_xor = 0 , 0 NEW_LINE right_xor = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT left_xor = left_xor ^ arr [ i ] NEW_LINE right_xor = 0 NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT right_xor = right_xor ^ arr [ j ] NEW_LINE DEDENT if ( left_xor + right_xor > sum ) : NEW_LINE INDENT sum = left_xor + right_xor NEW_LINE index = i NEW_LINE DEDENT DEDENT return index + 1 NEW_LINE DEDENT arr = [ 1 , 4 , 6 , 3 , 8 , 13 , 34 , 2 , 21 , 10 ] NEW_LINE n = len ( arr ) NEW_LINE print ( Xor_Sum ( arr , n ) ) NEW_LINE +" +E1404,"import java . util . * ; import java . lang . * ; public class GfG { public static void print ( char a [ ] , int n , int ind ) { for ( int i = ind ; i < n + ind ; i ++ ) System . out . print ( a [ ( i % n ) ] + "" ▁ "" ) ; } public static void main ( String argc [ ] ) { char [ ] a = new char [ ] { ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' } ; int n = 6 ; print ( a , n , 3 ) ; } } +","def prints ( a , n , ind ) : NEW_LINE INDENT i = ind NEW_LINE while i < n + ind : NEW_LINE INDENT print ( a [ ( i % n ) ] , end = "" ▁ "" ) NEW_LINE i = i + 1 NEW_LINE DEDENT DEDENT a = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ] NEW_LINE n = len ( a ) ; NEW_LINE prints ( a , n , 3 ) ; NEW_LINE +" +E1405,"class GFG { static int printPattern ( int i , int j , int n ) { if ( j >= n ) { return 0 ; } if ( i >= n ) { return 1 ; } if ( j == i || j == n - 1 - i ) { if ( i == n - 1 - j ) { System . out . print ( "" / "" ) ; } else { System . out . print ( "" \ \"" ) ; } } else { System . out . print ( "" * "" ) ; } if ( printPattern ( i , j + 1 , n ) == 1 ) { return 1 ; } System . out . println ( ) ; return printPattern ( i + 1 , 0 , n ) ; } public static void main ( String [ ] args ) { int N = 9 ; printPattern ( 0 , 0 , N ) ; } } +","def printPattern ( i , j , n ) : NEW_LINE INDENT if ( j >= n ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( i >= n ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( j == i or j == n - 1 - i ) : NEW_LINE INDENT if ( i == n - 1 - j ) : NEW_LINE INDENT print ( "" / "" , end = "" "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" \\ "" , end = "" "" ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( "" * "" , end = "" "" ) NEW_LINE DEDENT if ( printPattern ( i , j + 1 , n ) == 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT print ( ) NEW_LINE return printPattern ( i + 1 , 0 , n ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT N = 9 NEW_LINE printPattern ( 0 , 0 , N ) NEW_LINE DEDENT +" +E1406,"import java . util . Arrays ; class GFG { static int findMaxValue ( int [ ] arr , int n ) { if ( n < 4 ) { System . out . println ( "" The ▁ array ▁ should ▁ have "" + "" ▁ atleast ▁ 4 ▁ elements "" ) ; } int table1 [ ] = new int [ n + 1 ] ; int table2 [ ] = new int [ n ] ; int table3 [ ] = new int [ n - 1 ] ; int table4 [ ] = new int [ n - 2 ] ; Arrays . fill ( table1 , Integer . MIN_VALUE ) ; Arrays . fill ( table2 , Integer . MIN_VALUE ) ; Arrays . fill ( table3 , Integer . MIN_VALUE ) ; Arrays . fill ( table4 , Integer . MIN_VALUE ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { table1 [ i ] = Math . max ( table1 [ i + 1 ] , arr [ i ] ) ; } for ( int i = n - 2 ; i >= 0 ; i -- ) { table2 [ i ] = Math . max ( table2 [ i + 1 ] , table1 [ i + 1 ] - arr [ i ] ) ; } for ( int i = n - 3 ; i >= 0 ; i -- ) table3 [ i ] = Math . max ( table3 [ i + 1 ] , table2 [ i + 1 ] + arr [ i ] ) ; for ( int i = n - 4 ; i >= 0 ; i -- ) table4 [ i ] = Math . max ( table4 [ i + 1 ] , table3 [ i + 1 ] - arr [ i ] ) ; return table4 [ 0 ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 8 , 9 , 2 , 20 } ; int n = arr . length ; System . out . println ( findMaxValue ( arr , n ) ) ; } } +","def findMaxValue ( arr , n ) : NEW_LINE INDENT if n < 4 : NEW_LINE INDENT print ( "" The ▁ array ▁ should ▁ have ▁ atlest ▁ 4 ▁ elements "" ) NEW_LINE return MIN NEW_LINE DEDENT table1 , table2 = [ MIN ] * ( n + 1 ) , [ MIN ] * n NEW_LINE table3 , table4 = [ MIN ] * ( n - 1 ) , [ MIN ] * ( n - 2 ) NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT table1 [ i ] = max ( table1 [ i + 1 ] , arr [ i ] ) NEW_LINE DEDENT for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE INDENT table2 [ i ] = max ( table2 [ i + 1 ] , table1 [ i + 1 ] - arr [ i ] ) NEW_LINE DEDENT for i in range ( n - 3 , - 1 , - 1 ) : NEW_LINE INDENT table3 [ i ] = max ( table3 [ i + 1 ] , table2 [ i + 1 ] + arr [ i ] ) NEW_LINE DEDENT for i in range ( n - 4 , - 1 , - 1 ) : NEW_LINE INDENT table4 [ i ] = max ( table4 [ i + 1 ] , table3 [ i + 1 ] - arr [ i ] ) NEW_LINE DEDENT return table4 [ 0 ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 4 , 8 , 9 , 2 , 20 ] NEW_LINE n = len ( arr ) NEW_LINE MIN = - 100000000 NEW_LINE print ( findMaxValue ( arr , n ) ) NEW_LINE DEDENT +" +E1407,"import java . util . * ; class GFG { static void printElements ( int a [ ] , int n ) { Arrays . sort ( a ) ; a = reverse ( a ) ; int cnt = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] != a [ i + 1 ] ) { System . out . print ( a [ i ] + "" ▁ occurs ▁ "" + cnt + "" ▁ times \n "" ) ; cnt = 1 ; } else cnt += 1 ; } System . out . print ( a [ n - 1 ] + "" ▁ occurs ▁ "" + cnt + "" ▁ times \n "" ) ; } static int [ ] reverse ( int a [ ] ) { int i , n = a . length , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 1 , 1 , 2 , 3 , 4 , 9 , 9 , 10 } ; int n = a . length ; printElements ( a , n ) ; } } +","def printElements ( a , n ) : NEW_LINE INDENT a . sort ( reverse = True ) NEW_LINE cnt = 1 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( a [ i ] != a [ i + 1 ] ) : NEW_LINE INDENT print ( a [ i ] , "" ▁ occurs ▁ "" , cnt , "" times "" ) NEW_LINE cnt = 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( a [ n - 1 ] , "" occurs "" , cnt , "" times "" ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 1 , 1 , 1 , 2 , 3 , 4 , 9 , 9 , 10 ] NEW_LINE n = len ( a ) NEW_LINE printElements ( a , n ) NEW_LINE DEDENT +" +E1408,"class GFG { static int findMin ( int arr [ ] , int n ) { int m = 0 ; for ( int i = 0 ; i < n ; i ++ ) m = Math . max ( m , arr [ i ] ) ; int freq [ ] = new int [ m + 2 ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ arr [ i ] ] ++ ; for ( int i = 1 ; i <= m + 1 ; i ++ ) { int j = i ; int cnt = 0 ; while ( j <= m ) { cnt += freq [ j ] ; j += i ; } if ( cnt == 0 ) return i ; } return m + 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 12 , 6 } ; int n = arr . length ; System . out . println ( findMin ( arr , n ) ) ; } } +","def findMin ( arr , n ) : NEW_LINE INDENT m = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT m = max ( m , arr [ i ] ) NEW_LINE DEDENT freq = [ 0 ] * ( m + 2 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT freq [ arr [ i ] ] += 1 NEW_LINE DEDENT for i in range ( 1 , m + 2 ) : NEW_LINE INDENT j = i NEW_LINE cnt = 0 NEW_LINE while ( j <= m ) : NEW_LINE INDENT cnt += freq [ j ] NEW_LINE j += i NEW_LINE DEDENT if ( not cnt ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT return m + 1 NEW_LINE DEDENT arr = [ 2 , 12 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE print ( findMin ( arr , n ) ) NEW_LINE +" +E1409,"class GFG { static void swapOperations ( char [ ] a , char [ ] b , char [ ] c ) { int l = a . length ; int i = 0 ; int total_swaps = 0 ; char temp ; for ( i = 0 ; i < l ; i ++ ) { if ( a [ i ] == b [ i ] ) continue ; if ( a [ i ] == c [ i ] ) { temp = b [ i ] ; b [ i ] = c [ i ] ; c [ i ] = temp ; total_swaps ++ ; continue ; } if ( b [ i ] == c [ i ] ) { temp = a [ i ] ; a [ i ] = c [ i ] ; c [ i ] = temp ; total_swaps ++ ; continue ; } break ; } if ( i == l ) System . out . println ( total_swaps ) ; else System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { String a = "" xyz "" ; String b = "" yzx "" ; String c = "" yzx "" ; swapOperations ( a . toCharArray ( ) , b . toCharArray ( ) , c . toCharArray ( ) ) ; } } +","def swapOperations ( a , b , c ) : NEW_LINE INDENT l = len ( a ) ; NEW_LINE i = 0 ; NEW_LINE total_swaps = 0 ; NEW_LINE for i in range ( l ) : NEW_LINE INDENT if ( a [ i ] == b [ i ] ) : NEW_LINE INDENT continue ; NEW_LINE DEDENT if ( a [ i ] == c [ i ] ) : NEW_LINE INDENT b [ i ] , c [ i ] = c [ i ] , b [ i ] ; NEW_LINE total_swaps += 1 ; NEW_LINE continue ; NEW_LINE DEDENT if ( b [ i ] == c [ i ] ) : NEW_LINE INDENT a [ i ] , c [ i ] = c [ i ] , a [ i ] ; NEW_LINE total_swaps += 1 ; NEW_LINE continue ; NEW_LINE DEDENT break ; NEW_LINE DEDENT i += 1 ; NEW_LINE if ( i == l ) : NEW_LINE INDENT print ( total_swaps ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = "" xyz "" ; NEW_LINE b = "" yzx "" ; NEW_LINE c = "" yzx "" ; NEW_LINE swapOperations ( list ( a ) , list ( b ) , list ( c ) ) ; NEW_LINE DEDENT +" +E1410,"class GFG { static int findMinimumZ ( int n , int a , int b ) { if ( a > b ) { swap ( a , b ) ; } int distClock = b - a ; int distAntiClock = ( a - 1 ) + ( n - b + 1 ) ; int minDist = Math . min ( distClock , distAntiClock ) ; if ( minDist == 1 ) { return 3 ; } return minDist ; } private static void swap ( int x , int y ) { int temp = x ; x = y ; y = temp ; } public static void main ( String [ ] args ) { int n = 4 , a = 1 , b = 2 ; System . out . println ( findMinimumZ ( n , a , b ) ) ; } } +","def findMinimumZ ( n , a , b ) : NEW_LINE INDENT if ( a > b ) : NEW_LINE INDENT temp = a NEW_LINE a = b NEW_LINE b = temp NEW_LINE DEDENT distClock = b - a NEW_LINE distAntiClock = ( a - 1 ) + ( n - b + 1 ) NEW_LINE minDist = min ( distClock , distAntiClock ) NEW_LINE if ( minDist == 1 ) : NEW_LINE INDENT return 3 NEW_LINE DEDENT return minDist NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 4 NEW_LINE a = 1 NEW_LINE b = 2 NEW_LINE print ( findMinimumZ ( n , a , b ) ) NEW_LINE DEDENT +" +E1411,"class GFG { static int solve ( int ang , int n ) { if ( ( ang * n ) > ( 180 * ( n - 2 ) ) ) { return 0 ; } else if ( ( ang * n ) % 180 != 0 ) { return 0 ; } int ans = 1 ; int freq = ( ang * n ) / 180 ; ans = ans * ( n - 1 - freq ) ; ans = ans * n ; return ans ; } public static void main ( String [ ] args ) { int ang = 90 , n = 4 ; System . out . println ( solve ( ang , n ) ) ; } } +","def solve ( ang , n ) : NEW_LINE INDENT if ( ( ang * n ) > ( 180 * ( n - 2 ) ) ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif ( ( ang * n ) % 180 != 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT ans = 1 NEW_LINE freq = ( ang * n ) // 180 NEW_LINE ans = ans * ( n - 1 - freq ) NEW_LINE ans = ans * n NEW_LINE return ans NEW_LINE DEDENT ang = 90 NEW_LINE n = 4 NEW_LINE print ( solve ( ang , n ) ) NEW_LINE +" +E1412,"class GFG { static boolean bitsAreInAltPatrnInGivenTRange ( int n , int l , int r ) { int num , prev , curr ; num = n >> ( l - 1 ) ; prev = num & 1 ; num = num >> 1 ; for ( int i = 1 ; i <= ( r - l ) ; i ++ ) { curr = num & 1 ; if ( curr == prev ) return false ; prev = curr ; num = num >> 1 ; } return true ; } public static void main ( String [ ] args ) { int n = 18 ; int l = 1 , r = 3 ; if ( bitsAreInAltPatrnInGivenTRange ( n , l , r ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def bitsAreInAltPatrnInGivenTRange ( n , l , r ) : NEW_LINE INDENT num = n >> ( l - 1 ) ; NEW_LINE prev = num & 1 ; NEW_LINE num = num >> 1 ; NEW_LINE for i in range ( 1 , ( r - l ) ) : NEW_LINE INDENT curr = num & 1 ; NEW_LINE if ( curr == prev ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT prev = curr ; NEW_LINE num = num >> 1 ; NEW_LINE DEDENT return True ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 18 ; NEW_LINE l = 1 ; NEW_LINE r = 3 ; NEW_LINE if ( bitsAreInAltPatrnInGivenTRange ( n , l , r ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E1413,"public class GFG { static int countFibs ( int low , int high ) { int f1 = 0 , f2 = 1 , f3 = 1 ; int result = 0 ; while ( f1 <= high ) { if ( f1 >= low ) result ++ ; f1 = f2 ; f2 = f3 ; f3 = f1 + f2 ; } return result ; } public static void main ( String args [ ] ) { int low = 10 , high = 100 ; System . out . println ( "" Count ▁ of ▁ Fibonacci ▁ Numbers ▁ is ▁ "" + countFibs ( low , high ) ) ; } } +","def countFibs ( low , high ) : NEW_LINE INDENT f1 , f2 , f3 = 0 , 1 , 1 NEW_LINE result = 0 NEW_LINE while ( f1 <= high ) : NEW_LINE INDENT if ( f1 >= low ) : NEW_LINE INDENT result += 1 NEW_LINE DEDENT f1 = f2 NEW_LINE f2 = f3 NEW_LINE f3 = f1 + f2 NEW_LINE DEDENT return result NEW_LINE DEDENT low , high = 10 , 100 NEW_LINE print ( "" Count ▁ of ▁ Fibonacci ▁ Numbers ▁ is "" , countFibs ( low , high ) ) NEW_LINE +" +E1414,"import java . io . * ; class GFG { static void Sum_upto_nth_Term ( int n ) { int r = n * ( n + 1 ) * ( 2 * n + 7 ) / 3 ; System . out . println ( r ) ; } public static void main ( String [ ] args ) { int N = 5 ; Sum_upto_nth_Term ( N ) ; } } +","def Sum_upto_nth_Term ( n ) : NEW_LINE INDENT return n * ( n + 1 ) * ( 2 * n + 7 ) // 3 NEW_LINE DEDENT N = 5 NEW_LINE print ( Sum_upto_nth_Term ( N ) ) NEW_LINE +" +E1415,"class GFG { static class Node { int data ; Node next ; } static Node first , last ; static int length = 0 ; static void printList ( Node node ) { while ( node != null ) { System . out . printf ( "" % d ▁ "" , node . data ) ; node = node . next ; } } static void moveToFront ( Node head , Node p , int m ) { if ( head == null ) return ; p = head ; head = head . next ; m ++ ; if ( length == m ) { p . next = null ; last . next = first ; first = head ; } else moveToFront ( head , p , m ) ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; if ( length == 0 ) last = head_ref ; else first = head_ref ; length ++ ; return head_ref ; } public static void main ( String [ ] args ) { Node start = null ; start = push ( start , 5 ) ; start = push ( start , 4 ) ; start = push ( start , 3 ) ; start = push ( start , 2 ) ; start = push ( start , 1 ) ; start = push ( start , 0 ) ; System . out . printf ( "" \n ▁ Initial ▁ Linked ▁ list \n "" ) ; printList ( start ) ; int m = 4 ; Node temp = new Node ( ) ; moveToFront ( start , temp , m ) ; System . out . printf ( "" \n ▁ Final ▁ Linked ▁ list \n "" ) ; start = first ; printList ( start ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . data = 0 NEW_LINE self . next = None NEW_LINE DEDENT DEDENT first = None NEW_LINE last = None NEW_LINE length = 0 NEW_LINE def printList ( node ) : NEW_LINE INDENT while ( node != None ) : NEW_LINE INDENT print ( node . data , end = "" ▁ "" ) NEW_LINE node = node . next NEW_LINE DEDENT DEDENT def moveToFront ( head , p , m ) : NEW_LINE INDENT global first NEW_LINE global last NEW_LINE global length NEW_LINE if ( head == None ) : NEW_LINE INDENT return head NEW_LINE DEDENT p = head NEW_LINE head = head . next NEW_LINE m = m + 1 NEW_LINE if ( length == m ) : NEW_LINE INDENT p . next = None NEW_LINE last . next = first NEW_LINE first = head NEW_LINE DEDENT else : NEW_LINE INDENT moveToFront ( head , p , m ) NEW_LINE DEDENT DEDENT def push ( head_ref , new_data ) : NEW_LINE INDENT global first NEW_LINE global last NEW_LINE global length NEW_LINE new_node = Node ( ) NEW_LINE new_node . data = new_data NEW_LINE new_node . next = ( head_ref ) NEW_LINE ( head_ref ) = new_node NEW_LINE if ( length == 0 ) : NEW_LINE INDENT last = head_ref NEW_LINE DEDENT else : NEW_LINE INDENT first = head_ref NEW_LINE DEDENT length = length + 1 NEW_LINE return head_ref NEW_LINE DEDENT start = None NEW_LINE start = push ( start , 5 ) NEW_LINE start = push ( start , 4 ) NEW_LINE start = push ( start , 3 ) NEW_LINE start = push ( start , 2 ) NEW_LINE start = push ( start , 1 ) NEW_LINE start = push ( start , 0 ) NEW_LINE print ( "" \n ▁ Initial ▁ Linked ▁ list "" ) NEW_LINE printList ( start ) NEW_LINE m = 4 NEW_LINE temp = None NEW_LINE moveToFront ( start , temp , m ) NEW_LINE print ( "" \n ▁ Final ▁ Linked ▁ list "" ) NEW_LINE start = first NEW_LINE printList ( start ) NEW_LINE +" +E1416,"import java . io . * ; import java . util . * ; public class GFG { static void printRepeating ( Integer [ ] arr , int size ) { SortedSet < Integer > s = new TreeSet < > ( ) ; Collections . addAll ( s , arr ) ; System . out . print ( s ) ; } public static void main ( String args [ ] ) { Integer [ ] arr = { 1 , 3 , 2 , 2 , 1 } ; int n = arr . length ; printRepeating ( arr , n ) ; } } +","def printRepeating ( arr , size ) : NEW_LINE INDENT s = set ( ) NEW_LINE for i in range ( size ) : NEW_LINE INDENT if arr [ i ] not in s : NEW_LINE INDENT s . add ( arr [ i ] ) NEW_LINE DEDENT DEDENT for i in s : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 3 , 2 , 2 , 1 ] NEW_LINE size = len ( arr ) NEW_LINE printRepeating ( arr , size ) NEW_LINE DEDENT +" +E1417,"public class GFG { static int maxsum_SIS ( int arr [ ] , int n ) { int max_sum = 0 ; int current_sum = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i - 1 ] < arr [ i ] ) { current_sum = current_sum + arr [ i ] ; } else { max_sum = Math . max ( max_sum , current_sum ) ; current_sum = arr [ i ] ; } } return Math . max ( max_sum , current_sum ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 4 } ; int n = arr . length ; System . out . println ( "" Maximum ▁ sum ▁ : ▁ "" + maxsum_SIS ( arr , n ) ) ; } } +","def maxsum_SIS ( arr , n ) : NEW_LINE INDENT max_sum = 0 NEW_LINE current_sum = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( arr [ i - 1 ] < arr [ i ] ) : NEW_LINE INDENT current_sum = current_sum + arr [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT max_sum = max ( max_sum , current_sum ) NEW_LINE current_sum = arr [ i ] NEW_LINE DEDENT DEDENT return max ( max_sum , current_sum ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT arr = [ 1 , 2 , 2 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Maximum ▁ sum ▁ : ▁ "" , maxsum_SIS ( arr , n ) ) , NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E1418,"import java . util . * ; class geeks { public static int sumoflength ( int [ ] arr , int n ) { Set < Integer > s = new HashSet < > ( ) ; int j = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( j < n && ! s . contains ( arr [ j ] ) ) { s . add ( arr [ i ] ) ; j ++ ; } ans += ( ( j - i ) * ( j - i + 1 ) ) / 2 ; s . remove ( arr [ i ] ) ; } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . length ; System . out . println ( sumoflength ( arr , n ) ) ; } } +","def sumoflength ( arr , n ) : NEW_LINE INDENT s = [ ] NEW_LINE j = 0 NEW_LINE ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT while ( j < n and ( arr [ j ] not in s ) ) : NEW_LINE INDENT s . append ( arr [ j ] ) NEW_LINE j += 1 NEW_LINE DEDENT ans += ( ( j - i ) * ( j - i + 1 ) ) // 2 NEW_LINE s . remove ( arr [ i ] ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( sumoflength ( arr , n ) ) NEW_LINE DEDENT +" +E1419,"import java . util . * ; class GFG { static void printVector ( Vector < Integer > v , int i ) { for ( int j = i ; j < v . size ( ) ; j ++ ) System . out . print ( v . get ( j ) + "" ▁ "" ) ; System . out . println ( ) ; } static class Node { int data ; Node left , right ; Node ( int x ) { data = x ; left = right = null ; } } ; static Vector < Integer > path = new Vector < Integer > ( ) ; static void printKPathUtil ( Node root , int k ) { if ( root == null ) return ; path . add ( root . data ) ; printKPathUtil ( root . left , k ) ; printKPathUtil ( root . right , k ) ; int f = 0 ; for ( int j = path . size ( ) - 1 ; j >= 0 ; j -- ) { f += path . get ( j ) ; if ( f == k ) printVector ( path , j ) ; } path . remove ( path . size ( ) - 1 ) ; } static void printKPath ( Node root , int k ) { path = new Vector < Integer > ( ) ; printKPathUtil ( root , k ) ; } public static void main ( String args [ ] ) { Node root = new Node ( 1 ) ; root . left = new Node ( 3 ) ; root . left . left = new Node ( 2 ) ; root . left . right = new Node ( 1 ) ; root . left . right . left = new Node ( 1 ) ; root . right = new Node ( - 1 ) ; root . right . left = new Node ( 4 ) ; root . right . left . left = new Node ( 1 ) ; root . right . left . right = new Node ( 2 ) ; root . right . right = new Node ( 5 ) ; root . right . right . right = new Node ( 2 ) ; int k = 5 ; printKPath ( root , k ) ; } } +","def printVector ( v , i ) : NEW_LINE INDENT for j in range ( i , len ( v ) ) : NEW_LINE INDENT print ( v [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT class newNode : NEW_LINE INDENT def __init__ ( self , key ) : NEW_LINE INDENT self . data = key NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def printKPathUtil ( root , path , k ) : NEW_LINE INDENT if ( not root ) : NEW_LINE INDENT return NEW_LINE DEDENT path . append ( root . data ) NEW_LINE printKPathUtil ( root . left , path , k ) NEW_LINE printKPathUtil ( root . right , path , k ) NEW_LINE f = 0 NEW_LINE for j in range ( len ( path ) - 1 , - 1 , - 1 ) : NEW_LINE INDENT f += path [ j ] NEW_LINE if ( f == k ) : NEW_LINE INDENT printVector ( path , j ) NEW_LINE DEDENT DEDENT path . pop ( - 1 ) NEW_LINE DEDENT def printKPath ( root , k ) : NEW_LINE INDENT path = [ ] NEW_LINE printKPathUtil ( root , path , k ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT root = newNode ( 1 ) NEW_LINE root . left = newNode ( 3 ) NEW_LINE root . left . left = newNode ( 2 ) NEW_LINE root . left . right = newNode ( 1 ) NEW_LINE root . left . right . left = newNode ( 1 ) NEW_LINE root . right = newNode ( - 1 ) NEW_LINE root . right . left = newNode ( 4 ) NEW_LINE root . right . left . left = newNode ( 1 ) NEW_LINE root . right . left . right = newNode ( 2 ) NEW_LINE root . right . right = newNode ( 5 ) NEW_LINE root . right . right . right = newNode ( 2 ) NEW_LINE k = 5 NEW_LINE printKPath ( root , k ) NEW_LINE DEDENT +" +E1420,"import java . util . Arrays ; class GFG { static void reverseArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n / 2 ; i ++ ) { swap ( arr , i , ( n + ~ i + 1 ) + ~ 1 + 1 ) ; } } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 3 , 7 , 2 , 1 , 6 } ; int n = arr . length ; reverseArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def reverseArray ( arr , n ) : NEW_LINE INDENT for i in range ( n // 2 ) : NEW_LINE INDENT arr [ i ] , arr [ ( n + ~ i + 1 ) + ~ 1 + 1 ] = arr [ ( n + ~ i + 1 ) + ~ 1 + 1 ] , arr [ i ] NEW_LINE DEDENT DEDENT arr = [ 5 , 3 , 7 , 2 , 1 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE reverseArray ( arr , n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT +" +E1421,"class GFG { static class Node { int data ; Node next , prev ; } ; static Node getNode ( int data ) { Node new_node = new Node ( ) ; new_node . data = data ; new_node . next = new_node . prev = null ; return new_node ; } static Node push ( Node head_ref , Node new_node ) { new_node . prev = null ; new_node . next = ( head_ref ) ; if ( ( head_ref ) != null ) ( head_ref ) . prev = new_node ; ( head_ref ) = new_node ; return head_ref ; } static Node reverseList ( Node head_ref ) { if ( ( head_ref ) == null || ( ( head_ref ) . next ) == null ) return null ; Node new_head = null ; Node curr = head_ref , next ; while ( curr != null ) { next = curr . next ; new_head = push ( new_head , curr ) ; curr = next ; } head_ref = new_head ; return head_ref ; } static void printList ( Node head ) { while ( head != null ) { System . out . print ( head . data + "" ▁ "" ) ; head = head . next ; } } public static void main ( String args [ ] ) { Node head = null ; head = push ( head , getNode ( 2 ) ) ; head = push ( head , getNode ( 4 ) ) ; head = push ( head , getNode ( 8 ) ) ; head = push ( head , getNode ( 10 ) ) ; System . out . print ( "" Original ▁ list : ▁ "" ) ; printList ( head ) ; head = reverseList ( head ) ; System . out . print ( "" \n Reversed ▁ list : ▁ "" ) ; printList ( head ) ; } } +","import math NEW_LINE class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . next = None NEW_LINE DEDENT DEDENT def getNode ( data ) : NEW_LINE INDENT new_node = Node ( data ) NEW_LINE new_node . data = data NEW_LINE new_node . next = None NEW_LINE new_node . prev = None NEW_LINE return new_node NEW_LINE DEDENT def push ( head_ref , new_node ) : NEW_LINE INDENT new_node . prev = None NEW_LINE new_node . next = head_ref NEW_LINE if ( head_ref != None ) : NEW_LINE INDENT head_ref . prev = new_node NEW_LINE DEDENT head_ref = new_node NEW_LINE return head_ref NEW_LINE DEDENT def reverseList ( head_ref ) : NEW_LINE INDENT if ( head_ref == None or ( head_ref ) . next == None ) : NEW_LINE INDENT return None NEW_LINE DEDENT new_head = None NEW_LINE curr = head_ref NEW_LINE while ( curr != None ) : NEW_LINE INDENT next = curr . next NEW_LINE new_head = push ( new_head , curr ) NEW_LINE curr = next NEW_LINE DEDENT head_ref = new_head NEW_LINE return head_ref NEW_LINE DEDENT def prList ( head ) : NEW_LINE INDENT while ( head != None ) : NEW_LINE INDENT print ( head . data , end = "" ▁ "" ) NEW_LINE head = head . next NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT head = None NEW_LINE head = push ( head , getNode ( 2 ) ) ; NEW_LINE head = push ( head , getNode ( 4 ) ) ; NEW_LINE head = push ( head , getNode ( 8 ) ) ; NEW_LINE head = push ( head , getNode ( 10 ) ) ; NEW_LINE print ( "" Original ▁ list : ▁ "" , end = "" "" ) NEW_LINE prList ( head ) NEW_LINE head = reverseList ( head ) NEW_LINE print ( "" \n Reversed ▁ list : ▁ "" , end = "" "" ) NEW_LINE prList ( head ) NEW_LINE DEDENT +" +E1422,"import java . util . * ; import java . lang . * ; import java . io . * ; public class GFG { static double decdiagonal ( double a ) { if ( a < 0 ) return - 1 ; double d = 1.902 * a ; return d ; } public static void main ( String [ ] args ) { int a = 9 ; System . out . println ( decdiagonal ( a ) ) ; } } +","def decdiagonal ( a ) : NEW_LINE INDENT if ( a < 0 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT d = 1.902 * a NEW_LINE return d NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 9 NEW_LINE print ( decdiagonal ( a ) ) NEW_LINE DEDENT +" +E1423,"class GFG { static int findSum ( int N , int k ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += ( int ) Math . pow ( i , k ) ; } return sum ; } public static void main ( String [ ] args ) { int N = 8 , k = 4 ; System . out . println ( findSum ( N , k ) ) ; } } +","from math import pow NEW_LINE def findSum ( N , k ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 1 , N + 1 , 1 ) : NEW_LINE INDENT sum += pow ( i , k ) NEW_LINE DEDENT return sum NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 8 NEW_LINE k = 4 NEW_LINE print ( int ( findSum ( N , k ) ) ) NEW_LINE DEDENT +" +E1424,"import java . util . Arrays ; import java . util . Stack ; class GFG { static void reverse ( String k ) { Stack < String > s = new Stack < > ( ) ; String [ ] token = k . split ( "" ▁ "" ) ; for ( int i = 0 ; i < token . length ; i ++ ) { s . push ( token [ i ] ) ; } while ( ! s . empty ( ) ) { System . out . print ( s . peek ( ) + "" ▁ "" ) ; s . pop ( ) ; } } public static void main ( String [ ] args ) { String k = "" geeks ▁ for ▁ geeks "" ; reverse ( k ) ; } } +","def reverse ( k ) : NEW_LINE INDENT s = [ ] NEW_LINE token = k . split ( ) NEW_LINE for word in token : NEW_LINE INDENT s . append ( word ) ; NEW_LINE DEDENT while ( len ( s ) ) : NEW_LINE INDENT print ( s . pop ( ) , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT k = "" geeks ▁ for ▁ geeks "" ; NEW_LINE reverse ( k ) ; NEW_LINE DEDENT +" +E1425,"import java . util . * ; class GFG { static boolean subArray ( int [ ] arr , int n , int m ) { int i ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( i = 0 ; i < n ; i ++ ) { mp . put ( arr [ i ] , i + 1 ) ; } int sumcur = 0 ; int p = Integer . MAX_VALUE ; Vector < Integer > ans = new Vector < Integer > ( ) ; for ( i = 1 ; i <= m ; i ++ ) { sumcur += mp . get ( i ) ; p = Math . min ( p , mp . get ( i ) ) ; int val = p * i - i + ( i * ( i + 1 ) ) / 2 ; if ( i == m ) { if ( val == sumcur ) { return true ; } else return false ; } } return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 1 , 3 , 2 , 6 } ; int n = arr . length ; int m = 3 ; if ( subArray ( arr , n , m ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def subArray ( arr , n , m ) : NEW_LINE INDENT i = 0 NEW_LINE mp = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT mp [ arr [ i ] ] = i + 1 NEW_LINE DEDENT sumcur = 0 NEW_LINE p = 10 ** 9 NEW_LINE ans = [ ] NEW_LINE for i in range ( 1 , m + 1 ) : NEW_LINE INDENT sumcur += mp [ i ] NEW_LINE p = min ( p , mp [ i ] ) NEW_LINE val = p * i - i + ( i * ( i + 1 ) ) / 2 NEW_LINE if ( i == m ) : NEW_LINE INDENT if ( val == sumcur ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT DEDENT arr = [ 4 , 5 , 1 , 3 , 2 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE m = 3 NEW_LINE if ( subArray ( arr , n , m ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1426,"import java . util . * ; public class GFG { static class Graph { int V ; LinkedList < Integer > [ ] adj ; Graph ( int V ) { this . V = V ; adj = new LinkedList [ V ] ; for ( int i = 0 ; i < adj . length ; i ++ ) adj [ i ] = new LinkedList < Integer > ( ) ; } void addEdge ( int v , int w ) { adj [ v ] . add ( w ) ; } void DFS ( int s ) { Vector < Boolean > visited = new Vector < Boolean > ( V ) ; for ( int i = 0 ; i < V ; i ++ ) visited . add ( false ) ; Stack < Integer > stack = new Stack < > ( ) ; stack . push ( s ) ; while ( stack . empty ( ) == false ) { s = stack . peek ( ) ; stack . pop ( ) ; if ( visited . get ( s ) == false ) { System . out . print ( s + "" ▁ "" ) ; visited . set ( s , true ) ; } Iterator < Integer > itr = adj [ s ] . iterator ( ) ; while ( itr . hasNext ( ) ) { int v = itr . next ( ) ; if ( ! visited . get ( v ) ) stack . push ( v ) ; } } } } public static void main ( String [ ] args ) { Graph g = new Graph ( 5 ) ; g . addEdge ( 1 , 0 ) ; g . addEdge ( 0 , 2 ) ; g . addEdge ( 2 , 1 ) ; g . addEdge ( 0 , 3 ) ; g . addEdge ( 1 , 4 ) ; System . out . println ( "" Following ▁ is ▁ the ▁ Depth ▁ First ▁ Traversal "" ) ; g . DFS ( 0 ) ; } } +","class Graph : NEW_LINE INDENT def __init__ ( self , V ) : NEW_LINE INDENT self . V = V NEW_LINE self . adj = [ [ ] for i in range ( V ) ] NEW_LINE DEDENT def addEdge ( self , v , w ) : NEW_LINE INDENT self . adj [ v ] . append ( w ) NEW_LINE DEDENT def DFS ( self , s ) : NEW_LINE INDENT visited = [ False for i in range ( self . V ) ] NEW_LINE stack = [ ] NEW_LINE stack . append ( s ) NEW_LINE while ( len ( stack ) ) : NEW_LINE INDENT s = stack [ - 1 ] NEW_LINE stack . pop ( ) NEW_LINE if ( not visited [ s ] ) : NEW_LINE INDENT print ( s , end = ' ▁ ' ) NEW_LINE visited [ s ] = True NEW_LINE DEDENT for node in self . adj [ s ] : NEW_LINE INDENT if ( not visited [ node ] ) : NEW_LINE INDENT stack . append ( node ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT g = Graph ( 5 ) ; NEW_LINE g . addEdge ( 1 , 0 ) ; NEW_LINE g . addEdge ( 0 , 2 ) ; NEW_LINE g . addEdge ( 2 , 1 ) ; NEW_LINE g . addEdge ( 0 , 3 ) ; NEW_LINE g . addEdge ( 1 , 4 ) ; NEW_LINE print ( "" Following ▁ is ▁ Depth ▁ First ▁ Traversal "" ) NEW_LINE g . DFS ( 0 ) NEW_LINE +" +E1427,"import java . util . * ; class solution { static class Node { int data ; Node left , right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static void diagonalPrint ( Node root ) { if ( root == null ) return ; Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root ) ; q . add ( null ) ; while ( q . size ( ) > 0 ) { Node temp = q . peek ( ) ; q . remove ( ) ; if ( temp == null ) { if ( q . size ( ) == 0 ) return ; System . out . println ( ) ; q . add ( null ) ; } else { while ( temp != null ) { System . out . print ( temp . data + "" ▁ "" ) ; if ( temp . left != null ) q . add ( temp . left ) ; temp = temp . right ; } } } } public static void main ( String args [ ] ) { Node root = newNode ( 8 ) ; root . left = newNode ( 3 ) ; root . right = newNode ( 10 ) ; root . left . left = newNode ( 1 ) ; root . left . right = newNode ( 6 ) ; root . right . right = newNode ( 14 ) ; root . right . right . left = newNode ( 13 ) ; root . left . right . left = newNode ( 4 ) ; root . left . right . right = newNode ( 7 ) ; diagonalPrint ( root ) ; } } +","class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . val = data NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def diagonalprint ( root ) : NEW_LINE INDENT if root is None : NEW_LINE INDENT return NEW_LINE DEDENT q = [ ] NEW_LINE q . append ( root ) NEW_LINE q . append ( None ) NEW_LINE while len ( q ) > 0 : NEW_LINE INDENT temp = q . pop ( 0 ) NEW_LINE if not temp : NEW_LINE INDENT if len ( q ) == 0 : NEW_LINE INDENT return NEW_LINE DEDENT print ( ' ▁ ' ) NEW_LINE q . append ( None ) NEW_LINE DEDENT else : NEW_LINE INDENT while temp : NEW_LINE INDENT print ( temp . val , end = ' ▁ ' ) NEW_LINE if temp . left : NEW_LINE INDENT q . append ( temp . left ) NEW_LINE DEDENT temp = temp . right NEW_LINE DEDENT DEDENT DEDENT DEDENT root = Node ( 8 ) NEW_LINE root . left = Node ( 3 ) NEW_LINE root . right = Node ( 10 ) NEW_LINE root . left . left = Node ( 1 ) NEW_LINE root . left . right = Node ( 6 ) NEW_LINE root . right . right = Node ( 14 ) NEW_LINE root . right . right . left = Node ( 13 ) NEW_LINE root . left . right . left = Node ( 4 ) NEW_LINE root . left . right . right = Node ( 7 ) NEW_LINE diagonalprint ( root ) NEW_LINE +" +E1428,"class GFG { static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static char getWinner ( int [ ] arr , int n ) { int gcd = arr [ 0 ] ; int maxEle = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { gcd = __gcd ( gcd , arr [ i ] ) ; maxEle = Math . max ( maxEle , arr [ i ] ) ; } int totalMoves = ( maxEle / gcd ) - n ; if ( totalMoves % 2 == 1 ) return ' A ' ; return ' B ' ; } public static void main ( String args [ ] ) { int [ ] arr = { 5 , 6 , 7 } ; int n = arr . length ; System . out . print ( getWinner ( arr , n ) ) ; } } +","from math import gcd NEW_LINE def getWinner ( arr , n ) : NEW_LINE INDENT __gcd = arr [ 0 ] ; NEW_LINE maxEle = arr [ 0 ] ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT __gcd = gcd ( __gcd , arr [ i ] ) ; NEW_LINE maxEle = max ( maxEle , arr [ i ] ) ; NEW_LINE DEDENT totalMoves = ( maxEle / __gcd ) - n ; NEW_LINE if ( totalMoves % 2 == 1 ) : NEW_LINE INDENT return ' A ' ; NEW_LINE DEDENT return ' B ' ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 5 , 6 , 7 ] ; NEW_LINE n = len ( arr ) NEW_LINE print ( getWinner ( arr , n ) ) NEW_LINE DEDENT +" +E1429,"import java . io . * ; class GFG { static void CountingEvenOdd ( int arr [ ] , int arr_size ) { int even_count = 0 ; int odd_count = 0 ; for ( int i = 0 ; i < arr_size ; i ++ ) { if ( ( arr [ i ] & 1 ) == 1 ) odd_count ++ ; else even_count ++ ; } System . out . println ( "" Number ▁ of ▁ even "" + "" ▁ elements ▁ = ▁ "" + even_count + "" ▁ Number ▁ of ▁ odd ▁ elements ▁ = ▁ "" + odd_count ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 } ; int n = arr . length ; CountingEvenOdd ( arr , n ) ; } } +","def CountingEvenOdd ( arr , arr_size ) : NEW_LINE INDENT even_count = 0 NEW_LINE odd_count = 0 NEW_LINE for i in range ( arr_size ) : NEW_LINE INDENT if ( arr [ i ] & 1 == 1 ) : NEW_LINE INDENT odd_count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT even_count += 1 NEW_LINE DEDENT DEDENT print ( "" Number ▁ of ▁ even ▁ elements ▁ = ▁ "" , even_count ) NEW_LINE print ( "" Number ▁ of ▁ odd ▁ elements ▁ = ▁ "" , odd_count ) NEW_LINE DEDENT arr = [ 2 , 3 , 4 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE CountingEvenOdd ( arr , n ) NEW_LINE +" +E1430,"class GFG { static int findSum ( String str ) { String temp = "" "" ; int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; if ( Character . isDigit ( ch ) ) temp += ch ; else { sum += Integer . parseInt ( temp ) ; temp = ""0"" ; } } return sum + Integer . parseInt ( temp ) ; } public static void main ( String [ ] args ) { String str = ""12abc20yz68"" ; System . out . println ( findSum ( str ) ) ; } } +","def findSum ( str1 ) : NEW_LINE INDENT temp = "" "" NEW_LINE Sum = 0 NEW_LINE for ch in str1 : NEW_LINE INDENT if ( ch . isdigit ( ) ) : NEW_LINE INDENT temp += ch NEW_LINE DEDENT else : NEW_LINE INDENT Sum += int ( temp ) NEW_LINE temp = ""0"" NEW_LINE DEDENT DEDENT return Sum + int ( temp ) NEW_LINE DEDENT str1 = ""12abc20yz68"" NEW_LINE print ( findSum ( str1 ) ) NEW_LINE +" +E1431,"class fibonacci { static int fib ( int n ) { int f [ ] = new int [ n + 2 ] ; int i ; f [ 0 ] = 0 ; f [ 1 ] = 1 ; for ( i = 2 ; i <= n ; i ++ ) { f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; } return f [ n ] ; } public static void main ( String args [ ] ) { int n = 9 ; System . out . println ( fib ( n ) ) ; } } +","def fibonacci ( n ) : NEW_LINE INDENT FibArray = [ 0 , 1 ] NEW_LINE while len ( FibArray ) < n + 1 : NEW_LINE INDENT FibArray . append ( 0 ) NEW_LINE DEDENT if n <= 1 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT if FibArray [ n - 1 ] == 0 : NEW_LINE INDENT FibArray [ n - 1 ] = fibonacci ( n - 1 ) NEW_LINE DEDENT if FibArray [ n - 2 ] == 0 : NEW_LINE INDENT FibArray [ n - 2 ] = fibonacci ( n - 2 ) NEW_LINE DEDENT DEDENT FibArray [ n ] = FibArray [ n - 2 ] + FibArray [ n - 1 ] NEW_LINE return FibArray [ n ] NEW_LINE DEDENT print ( fibonacci ( 9 ) ) NEW_LINE +" +E1432,"import java . io . * ; class GFG { static long oddNumSum ( int n ) { int j = 0 ; long sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { j = ( 2 * i - 1 ) ; sum = sum + ( j * j * j * j ) ; } return sum ; } public static void main ( String args [ ] ) { int n = 6 ; System . out . println ( oddNumSum ( n ) ) ; } } +","def oddNumSum ( n ) : NEW_LINE INDENT j = 0 NEW_LINE sm = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT j = ( 2 * i - 1 ) NEW_LINE sm = sm + ( j * j * j * j ) NEW_LINE DEDENT return sm NEW_LINE DEDENT n = 6 ; NEW_LINE print ( oddNumSum ( n ) ) NEW_LINE +" +E1433,"class GFG { static void findAandB ( double N ) { double val = N * N - 4.0 * N ; if ( val < 0 ) { System . out . println ( "" NO "" ) ; return ; } double a = ( N + Math . sqrt ( val ) ) / 2.0 ; double b = ( N - Math . sqrt ( val ) ) / 2.0 ; System . out . println ( "" a ▁ = ▁ "" + a ) ; System . out . println ( "" b ▁ = ▁ "" + b ) ; } public static void main ( String [ ] args ) { double N = 69.0 ; findAandB ( N ) ; } } +","from math import sqrt NEW_LINE def findAandB ( N ) : NEW_LINE INDENT val = N * N - 4.0 * N NEW_LINE if ( val < 0 ) : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE return NEW_LINE DEDENT a = ( N + sqrt ( val ) ) / 2.0 NEW_LINE b = ( N - sqrt ( val ) ) / 2.0 NEW_LINE print ( "" a ▁ = "" , ' { 0 : . 6 } ' . format ( a ) ) NEW_LINE print ( "" b ▁ = "" , ' { 0 : . 6 } ' . format ( b ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 69.0 NEW_LINE findAandB ( N ) NEW_LINE DEDENT +" +E1434,"class GFG { public static void reverse ( char str [ ] ) { int r = str . length - 1 , l = 0 ; while ( l < r ) { if ( ! Character . isAlphabetic ( str [ l ] ) ) l ++ ; else if ( ! Character . isAlphabetic ( str [ r ] ) ) r -- ; else { char tmp = str [ l ] ; str [ l ] = str [ r ] ; str [ r ] = tmp ; l ++ ; r -- ; } } } public static void main ( String [ ] args ) { String str = "" a ! ! ! b . c . d , e ' f , ghi "" ; char [ ] charArray = str . toCharArray ( ) ; System . out . println ( "" Input ▁ string : ▁ "" + str ) ; reverse ( charArray ) ; String revStr = new String ( charArray ) ; System . out . println ( "" Output ▁ string : ▁ "" + revStr ) ; } } +","def reverseSting ( text ) : NEW_LINE INDENT index = - 1 NEW_LINE for i in range ( len ( text ) - 1 , int ( len ( text ) / 2 ) , - 1 ) : NEW_LINE INDENT if text [ i ] . isalpha ( ) : NEW_LINE INDENT temp = text [ i ] NEW_LINE while True : NEW_LINE INDENT index += 1 NEW_LINE if text [ index ] . isalpha ( ) : NEW_LINE INDENT text [ i ] = text [ index ] NEW_LINE text [ index ] = temp NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT return text NEW_LINE DEDENT string = "" a ! ! ! b . c . d , e ' f , ghi "" NEW_LINE print ( "" Input ▁ string : ▁ "" , string ) NEW_LINE string = reverseSting ( list ( string ) ) NEW_LINE print ( "" Output ▁ string : ▁ "" , "" "" . join ( string ) ) NEW_LINE +" +E1435,"class GFG { static int geometricMean ( int n ) { return ( int ) Math . sqrt ( n ) ; } public static void main ( String [ ] args ) { int n = 16 ; System . out . println ( geometricMean ( n ) ) ; } } +","from math import sqrt NEW_LINE def geometricMean ( n ) : NEW_LINE INDENT return int ( sqrt ( n ) ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 16 ; NEW_LINE print ( geometricMean ( n ) ) ; NEW_LINE DEDENT +" +E1436,"class GFG { static float kPresentProbability ( int a [ ] , int n , int k ) { float count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] == k ) count ++ ; return count / n ; } public static void main ( String [ ] args ) { int A [ ] = { 4 , 7 , 2 , 0 , 8 , 7 , 5 } ; int K = 2 ; int N = A . length ; double n = kPresentProbability ( A , N , K ) ; double p = ( double ) Math . round ( n * 100 ) / 100 ; System . out . println ( p ) ; } } +","def kPresentProbability ( a , n , k ) : NEW_LINE INDENT count = a . count ( k ) NEW_LINE return round ( count / n , 2 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 4 , 7 , 2 , 0 , 8 , 7 , 5 ] NEW_LINE K = 2 NEW_LINE N = len ( A ) NEW_LINE print ( kPresentProbability ( A , N , K ) ) NEW_LINE DEDENT +" +E1437,"import java . io . * ; class GFG { static void checkEvenOdd ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { System . out . print ( "" Even "" ) ; return ; } } System . out . println ( "" Odd "" ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 12 , 20 , 36 , 38 } ; int n = arr . length ; checkEvenOdd ( arr , n ) ; } } +","def checkEvenOdd ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] % 2 == 0 ) : NEW_LINE INDENT print ( "" Even "" , end = "" "" ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT print ( "" Odd "" , end = "" "" ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 2 , 12 , 20 , 36 , 38 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE checkEvenOdd ( arr , n ) ; NEW_LINE DEDENT +" +E1438,"import java . io . * ; class GFG { static int toggleLastMBits ( int n , int m ) { if ( m == 0 ) return n ; int num = ( 1 << m ) - 1 ; return ( n ^ num ) ; } static int largeNumWithNSetAndMUnsetBits ( int n , int m ) { int num = ( 1 << ( n + m ) ) - 1 ; return toggleLastMBits ( num , m ) ; } public static void main ( String [ ] args ) { int n = 2 , m = 2 ; System . out . println ( largeNumWithNSetAndMUnsetBits ( n , m ) ) ; } } +","def toggleLastMBits ( n , m ) : NEW_LINE INDENT if ( m == 0 ) : NEW_LINE INDENT return n NEW_LINE DEDENT num = ( 1 << m ) - 1 NEW_LINE return ( n ^ num ) NEW_LINE DEDENT def largeNumWithNSetAndMUnsetBits ( n , m ) : NEW_LINE INDENT num = ( 1 << ( n + m ) ) - 1 NEW_LINE return toggleLastMBits ( num , m ) NEW_LINE DEDENT n = 2 NEW_LINE m = 2 NEW_LINE print ( largeNumWithNSetAndMUnsetBits ( n , m ) ) NEW_LINE +" +E1439,"import java . io . * ; class GFG { static void series ( int A , int X , int n ) { int term = ( int ) Math . pow ( A , n ) ; System . out . print ( term + "" ▁ "" ) ; for ( int i = 1 ; i <= n ; i ++ ) { term = term * X * ( n - i + 1 ) / ( i * A ) ; System . out . print ( term + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int A = 3 , X = 4 , n = 5 ; series ( A , X , n ) ; } } +","def series ( A , X , n ) : NEW_LINE INDENT term = pow ( A , n ) NEW_LINE print ( term , end = "" ▁ "" ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT term = int ( term * X * ( n - i + 1 ) / ( i * A ) ) NEW_LINE print ( term , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT A = 3 ; X = 4 ; n = 5 NEW_LINE series ( A , X , n ) NEW_LINE +" +E1440,"class MergeSort { void merge ( int arr [ ] , int l , int m , int r ) { int n1 = m - l + 1 ; int n2 = r - m ; int L [ ] = new int [ n1 ] ; int R [ ] = new int [ n2 ] ; for ( int i = 0 ; i < n1 ; ++ i ) L [ i ] = arr [ l + i ] ; for ( int j = 0 ; j < n2 ; ++ j ) R [ j ] = arr [ m + 1 + j ] ; int i = 0 , j = 0 ; int k = l ; while ( i < n1 && j < n2 ) { if ( L [ i ] <= R [ j ] ) { arr [ k ] = L [ i ] ; i ++ ; } else { arr [ k ] = R [ j ] ; j ++ ; } k ++ ; } while ( i < n1 ) { arr [ k ] = L [ i ] ; i ++ ; k ++ ; } while ( j < n2 ) { arr [ k ] = R [ j ] ; j ++ ; k ++ ; } } void sort ( int arr [ ] , int l , int r ) { if ( l < r ) { int m = ( l + r ) / 2 ; sort ( arr , l , m ) ; sort ( arr , m + 1 , r ) ; merge ( arr , l , m , r ) ; } } static void printArray ( int arr [ ] ) { int n = arr . length ; for ( int i = 0 ; i < n ; ++ i ) System . out . print ( arr [ i ] + "" ▁ "" ) ; System . out . println ( ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 12 , 11 , 13 , 5 , 6 , 7 } ; System . out . println ( "" Given ▁ Array "" ) ; printArray ( arr ) ; MergeSort ob = new MergeSort ( ) ; ob . sort ( arr , 0 , arr . length - 1 ) ; System . out . println ( "" \n Sorted ▁ array "" ) ; printArray ( arr ) ; } } +","def mergeSort ( a ) : NEW_LINE INDENT if len ( a ) > 1 : NEW_LINE INDENT mid = len ( a ) // 2 NEW_LINE L = a [ : mid ] NEW_LINE R = a [ mid : ] NEW_LINE mergeSort ( L ) NEW_LINE mergeSort ( R ) NEW_LINE a . clear ( ) NEW_LINE while len ( L ) > 0 and len ( R ) < 0 : NEW_LINE INDENT if L [ 0 ] <= R [ 0 ] : NEW_LINE INDENT a . append ( L [ 0 ] ) NEW_LINE L . pop ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT a . append ( R [ 0 ] ) NEW_LINE R . pop ( 0 ) NEW_LINE DEDENT DEDENT for i in L : NEW_LINE INDENT a . append ( i ) NEW_LINE DEDENT for i in R : NEW_LINE INDENT a . append ( i ) NEW_LINE DEDENT DEDENT DEDENT a = [ 12 , 11 , 13 , 5 , 6 , 7 ] NEW_LINE print ( "" Given ▁ array ▁ is "" ) NEW_LINE print ( * a ) NEW_LINE mergeSort ( a ) NEW_LINE print ( "" Sorted ▁ array ▁ is ▁ : ▁ "" ) NEW_LINE print ( * a ) NEW_LINE +" +E1441,"import java . util . Arrays ; class GFG { static int answer ( int [ ] arr , int [ ] [ ] ranges , int reversals , int index ) { for ( int i = reversals - 1 ; i >= 0 ; i -- ) { int left = ranges [ i ] [ 0 ] , right = ranges [ i ] [ 1 ] ; if ( left <= index && right >= index ) index = right + left - index ; } return arr [ index ] ; } public static void main ( String [ ] args ) { int [ ] arr = { 10 , 20 , 30 , 40 , 50 } ; int reversals = 2 ; int [ ] [ ] ranges = { { 1 , 4 } , { 0 , 2 } } ; int index = 1 ; System . out . println ( answer ( arr , ranges , reversals , index ) ) ; } } +","def answer ( arr , ranges , reversals , index ) : NEW_LINE INDENT i = reversals - 1 NEW_LINE while ( i >= 0 ) : NEW_LINE INDENT left = ranges [ i ] [ 0 ] NEW_LINE right = ranges [ i ] [ 1 ] NEW_LINE if ( left <= index and right >= index ) : NEW_LINE INDENT index = right + left - index NEW_LINE DEDENT i -= 1 NEW_LINE DEDENT return arr [ index ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 10 , 20 , 30 , 40 , 50 ] NEW_LINE reversals = 2 NEW_LINE ranges = [ [ 1 , 4 ] , [ 0 , 2 ] ] NEW_LINE index = 1 NEW_LINE print ( answer ( arr , ranges , reversals , index ) ) NEW_LINE DEDENT +" +E1442,"class IsDivisible { static boolean isDivisibleBy25 ( String str ) { int n = str . length ( ) ; if ( n == 1 ) return false ; return ( ( str . charAt ( n - 1 ) - '0' == 0 && str . charAt ( n - 2 ) - '0' == 0 ) || ( ( str . charAt ( n - 2 ) - '0' ) * 10 + ( str . charAt ( n - 1 ) - '0' ) ) % 25 == 0 ) ; } public static void main ( String [ ] args ) { String str = ""76955"" ; if ( isDivisibleBy25 ( str ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isDivisibleBy25 ( st ) : NEW_LINE INDENT n = len ( st ) NEW_LINE if ( n == 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT return ( ( int ) ( st [ n - 1 ] ) == 0 and ( ( int ) ( st [ n - 2 ] ) == 0 ) or ( ( int ) ( st [ n - 2 ] ) * 10 + ( int ) ( st [ n - 1 ] ) % 25 == 0 ) ) NEW_LINE DEDENT st = ""76955"" NEW_LINE if ( isDivisibleBy25 ( st ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1443,"class gfg { static int square ( int n ) { return n * n ; } static int sum ( int n ) { if ( n == 0 ) return 0 ; if ( n % 2 == 1 ) { return square ( ( n + 1 ) / 2 ) + sum ( n / 2 ) ; } else { return square ( n / 2 ) + sum ( n / 2 ) ; } } static int oddDivSum ( int a , int b ) { return sum ( b ) - sum ( a - 1 ) ; } public static void main ( String [ ] args ) { int a = 3 , b = 9 ; System . out . println ( oddDivSum ( a , b ) ) ; } } +","def square ( n ) : NEW_LINE INDENT return n * n ; NEW_LINE DEDENT def sum ( n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT if ( n % 2 == 1 ) : NEW_LINE INDENT return ( square ( int ( ( n + 1 ) / 2 ) ) + sum ( int ( n / 2 ) ) ) ; NEW_LINE DEDENT else : NEW_LINE INDENT return ( square ( int ( n / 2 ) ) + sum ( int ( n / 2 ) ) ) ; NEW_LINE DEDENT DEDENT def oddDivSum ( a , b ) : NEW_LINE INDENT return sum ( b ) - sum ( a - 1 ) ; NEW_LINE DEDENT a , b = 3 , 9 ; NEW_LINE print ( oddDivSum ( a , b ) ) ; NEW_LINE +" +E1444,"import java . util . * ; class GFG { static String removeOddFrequencyCharacters ( String s ) { HashMap < Character , Integer > m = new HashMap < Character , Integer > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char p = s . charAt ( i ) ; Integer count = m . get ( p ) ; if ( count == null ) { count = 0 ; m . put ( p , 1 ) ; } else m . put ( p , count + 1 ) ; } String new_string = "" "" ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ( m . get ( s . charAt ( i ) ) & 1 ) == 1 ) continue ; new_string += s . charAt ( i ) ; } return new_string ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; str = removeOddFrequencyCharacters ( str ) ; System . out . print ( str ) ; } } +","def removeOddFrequencyCharacters ( s ) : NEW_LINE INDENT m = dict ( ) NEW_LINE for i in s : NEW_LINE INDENT m [ i ] = m . get ( i , 0 ) + 1 NEW_LINE DEDENT new_s = "" "" NEW_LINE for i in s : NEW_LINE INDENT if ( m [ i ] & 1 ) : NEW_LINE INDENT continue NEW_LINE DEDENT new_s += i NEW_LINE DEDENT return new_s NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = "" geeksforgeeks "" NEW_LINE str = removeOddFrequencyCharacters ( str ) NEW_LINE print ( str ) NEW_LINE DEDENT +" +E1445,"class NDN { static int countNonDecreasing ( int n ) { int dp [ ] [ ] = new int [ 10 ] [ n + 1 ] ; for ( int i = 0 ; i < 10 ; i ++ ) dp [ i ] [ 1 ] = 1 ; for ( int digit = 0 ; digit <= 9 ; digit ++ ) { for ( int len = 2 ; len <= n ; len ++ ) { for ( int x = 0 ; x <= digit ; x ++ ) dp [ digit ] [ len ] += dp [ x ] [ len - 1 ] ; } } int count = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) count += dp [ i ] [ n ] ; return count ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . println ( countNonDecreasing ( n ) ) ; } } +","def countNonDecreasing ( n ) : NEW_LINE INDENT dp = [ [ 0 for i in range ( n + 1 ) ] for i in range ( 10 ) ] NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT dp [ i ] [ 1 ] = 1 NEW_LINE DEDENT for digit in range ( 10 ) : NEW_LINE INDENT for len in range ( 2 , n + 1 ) : NEW_LINE INDENT for x in range ( digit + 1 ) : NEW_LINE INDENT dp [ digit ] [ len ] += dp [ x ] [ len - 1 ] NEW_LINE DEDENT DEDENT DEDENT count = 0 NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT count += dp [ i ] [ n ] NEW_LINE DEDENT return count NEW_LINE DEDENT n = 3 NEW_LINE print ( countNonDecreasing ( n ) ) NEW_LINE +" +E1446,"import java . util . HashMap ; import java . util . Map ; import java . lang . Math ; class GfG { static int maxCount ( int n , int a [ ] ) { HashMap < Integer , Integer > freq = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( freq . containsKey ( a [ i ] ) ) freq . put ( a [ i ] , freq . get ( a [ i ] ) + 1 ) ; else freq . put ( a [ i ] , 1 ) ; } int ans = 0 ; for ( Integer key : freq . keySet ( ) ) { if ( freq . containsKey ( key + 1 ) ) ans = Math . max ( ans , freq . get ( key ) + freq . get ( key + 1 ) ) ; } return ans ; } public static void main ( String [ ] args ) { int n = 5 ; int arr [ ] = { 2 , 2 , 3 , 4 , 5 } ; System . out . println ( maxCount ( n , arr ) ) ; } } +","def maxCount ( a ) : NEW_LINE INDENT freq = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] in freq ) : NEW_LINE INDENT freq [ a [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT freq [ a [ i ] ] = 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for key , value in freq . items ( ) : NEW_LINE INDENT if ( key + 1 in freq ) : NEW_LINE INDENT ans = max ( ans , freq [ key ] + freq [ key + 1 ] ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n = 5 NEW_LINE arr = [ 2 , 2 , 3 , 4 , 5 ] NEW_LINE print ( maxCount ( arr ) ) NEW_LINE +" +E1447,"class GFG { static void dist ( double x1 , double y1 , double x2 , double y2 , double r ) { System . out . println ( "" The ▁ shortest ▁ distance ▁ "" + "" between ▁ a ▁ point ▁ and ▁ a ▁ circle ▁ is ▁ "" + ( Math . sqrt ( ( Math . pow ( ( x2 - x1 ) , 2 ) ) + ( Math . pow ( ( y2 - y1 ) , 2 ) ) ) - r ) ) ; } public static void main ( String [ ] args ) { double x1 = 4 , y1 = 6 , x2 = 35 , y2 = 42 , r = 5 ; dist ( x1 , y1 , x2 , y2 , r ) ; } } +","def dist ( x1 , y1 , x2 , y2 , r ) : NEW_LINE INDENT print ( "" The ▁ shortest ▁ distance ▁ between ▁ a ▁ point ▁ and ▁ a ▁ circle ▁ is ▁ "" , ( ( ( ( x2 - x1 ) ** 2 ) + ( ( y2 - y1 ) ** 2 ) ) ** ( 1 / 2 ) ) - r ) ; NEW_LINE DEDENT x1 = 4 ; NEW_LINE y1 = 6 ; NEW_LINE x2 = 35 ; NEW_LINE y2 = 42 ; NEW_LINE r = 5 ; NEW_LINE dist ( x1 , y1 , x2 , y2 , r ) ; NEW_LINE +" +E1448,"import java . util . * ; class GFG { static int vis [ ] ; static int dfs ( int x , Vector < Vector < Integer > > adj ) { int sz = 1 ; vis [ x ] = 1 ; for ( int i = 0 ; i < adj . get ( x ) . size ( ) ; i ++ ) if ( vis [ adj . get ( x ) . get ( i ) ] == 0 ) sz += dfs ( adj . get ( x ) . get ( i ) , adj ) ; return sz ; } static int maxValue ( int n , Vector < Vector < Integer > > adj ) { int val = 0 ; vis = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) vis [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( vis [ i ] == 0 ) val += dfs ( i , adj ) - 1 ; return val ; } public static void main ( String args [ ] ) { int n = 3 ; Vector < Vector < Integer > > adj = new Vector < Vector < Integer > > ( ) ; Vector < Integer > v = new Vector < Integer > ( ) ; v . add ( 0 ) ; v . add ( 1 ) ; Vector < Integer > v1 = new Vector < Integer > ( ) ; v1 . add ( 1 ) ; v1 . add ( 2 ) ; adj . add ( v ) ; adj . add ( v1 ) ; adj . add ( new Vector < Integer > ( ) ) ; System . out . println ( maxValue ( n , adj ) ) ; } } +","def dfs ( x , adj , vis ) : NEW_LINE INDENT sz = 1 NEW_LINE vis [ x ] = 1 NEW_LINE for ch in adj : NEW_LINE INDENT if ( not vis [ ch ] ) : NEW_LINE INDENT sz += dfs ( ch , adj , vis ) NEW_LINE DEDENT DEDENT return sz NEW_LINE DEDENT def maxValue ( n , adj ) : NEW_LINE INDENT val = 0 NEW_LINE vis = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( not vis [ i ] ) : NEW_LINE INDENT val += dfs ( i , adj , vis ) - 1 NEW_LINE DEDENT DEDENT return val NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE adj = [ 1 , 2 , 2 , 3 ] NEW_LINE print ( maxValue ( n , adj ) ) NEW_LINE DEDENT +" +E1449,"import java . util . * ; class GFG { static double area_of_regular_polygon ( double n , double len ) { double P = ( len * n ) ; double A = len / ( 2 * Math . tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; double area = ( P * A ) / 2 ; return area ; } static double area_of_triangle_inscribed ( double n , double len ) { double area = area_of_regular_polygon ( n , len ) ; double triangle = area / n ; double ins_tri = ( triangle * 3 ) ; return ins_tri ; } static public void main ( String [ ] arg ) { double n = 6 , len = 10 ; System . out . printf ( "" % .3f "" , area_of_triangle_inscribed ( n , len ) ) ; } } +","import math NEW_LINE def area_of_regular_polygon ( n , len ) : NEW_LINE INDENT P = ( len * n ) ; NEW_LINE A = len / ( 2 * math . tan ( ( 180 / n ) * 3.14159 / 180 ) ) NEW_LINE area = ( P * A ) / 2 NEW_LINE return area NEW_LINE DEDENT def area_of_triangle_inscribed ( n , len ) : NEW_LINE INDENT area = area_of_regular_polygon ( n , len ) NEW_LINE triangle = area / n NEW_LINE ins_tri = ( triangle * 3 ) ; NEW_LINE return ins_tri NEW_LINE DEDENT n = 6 NEW_LINE len = 10 NEW_LINE print ( round ( area_of_triangle_inscribed ( n , len ) , 3 ) ) NEW_LINE +" +E1450,"import java . io . * ; class GFG { static int centeredHexagonalNumber ( int n ) { return 3 * n * ( n - 1 ) + 1 ; } public static void main ( String args [ ] ) { int n = 10 ; System . out . print ( n + "" th ▁ centered ▁ "" + "" hexagonal ▁ number : ▁ "" ) ; System . out . println ( centeredHexagonalNumber ( n ) ) ; } } +","def centeredHexagonalNumber ( n ) : NEW_LINE INDENT return 3 * n * ( n - 1 ) + 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 NEW_LINE print ( n , "" th ▁ centered ▁ hexagonal ▁ number : ▁ "" , centeredHexagonalNumber ( n ) ) NEW_LINE DEDENT +" +E1451,"using System ; class GFG { static bool isOrthogonal ( int [ , ] a , int m , int n ) { if ( m != n ) return false ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { int sum = 0 ; for ( int k = 0 ; k < n ; k ++ ) { sum = sum + ( a [ i , k ] * a [ j , k ] ) ; } if ( i == j && sum != 1 ) return false ; if ( i != j && sum != 0 ) return false ; } } return true ; } public static void Main ( ) { int [ , ] a = { { 1 , 0 , 0 } , { 0 , 1 , 0 } , { 0 , 0 , 1 } } ; if ( isOrthogonal ( a , 3 , 3 ) ) Console . WriteLine ( "" Yes "" ) ; else Console . WriteLine ( "" No "" ) ; } } +","def isOrthogonal ( a , m , n ) : NEW_LINE INDENT if ( m != n ) : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( 0 , n ) : NEW_LINE INDENT sum = 0 NEW_LINE for k in range ( 0 , n ) : NEW_LINE INDENT sum = sum + ( a [ i ] [ k ] * a [ j ] [ k ] ) NEW_LINE DEDENT DEDENT if ( i == j and sum != 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( i != j and sum != 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT a = [ [ 1 , 0 , 0 ] , [ 0 , 1 , 0 ] , [ 0 , 0 , 1 ] ] NEW_LINE if ( isOrthogonal ( a , 3 , 3 ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1452,"class GFG { static float getAvg ( float prev_avg , float x , int n ) { return ( prev_avg * n + x ) / ( n + 1 ) ; } static void streamAvg ( float arr [ ] , int n ) { float avg = 0 ; for ( int i = 0 ; i < n ; i ++ ) { avg = getAvg ( avg , arr [ i ] , i ) ; System . out . printf ( "" Average ▁ of ▁ % d ▁ numbers ▁ is ▁ % f ▁ \n "" , i + 1 , avg ) ; } return ; } public static void main ( String [ ] args ) { float arr [ ] = { 10 , 20 , 30 , 40 , 50 , 60 } ; int n = arr . length ; streamAvg ( arr , n ) ; } } +","def getAvg ( prev_avg , x , n ) : NEW_LINE INDENT return ( ( prev_avg * n + x ) / ( n + 1 ) ) ; NEW_LINE DEDENT def streamAvg ( arr , n ) : NEW_LINE INDENT avg = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT avg = getAvg ( avg , arr [ i ] , i ) ; NEW_LINE print ( "" Average ▁ of ▁ "" , i + 1 , "" ▁ numbers ▁ is ▁ "" , avg ) ; NEW_LINE DEDENT DEDENT arr = [ 10 , 20 , 30 , 40 , 50 , 60 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE streamAvg ( arr , n ) ; NEW_LINE +" +E1453,"import java . util . Arrays ; public class MinCostOp_Mintowerheight { static long costOfOperation ( int n , int h [ ] , int cost [ ] , int eq_h ) { long c = 0 ; for ( int i = 0 ; i < n ; i ++ ) c += Math . abs ( h [ i ] - eq_h ) * cost [ i ] ; return c ; } static long Bsearch ( int n , int h [ ] , int cost [ ] ) { int max_h = Arrays . stream ( h ) . max ( ) . getAsInt ( ) ; long ans = Long . MAX_VALUE ; long high = 1 + max_h ; long low = 0 ; while ( high > low ) { int mid = ( int ) ( ( low + high ) >> 1 ) ; long bm = ( mid > 0 ) ? costOfOperation ( n , h , cost , mid - 1 ) : Long . MAX_VALUE ; long m = costOfOperation ( n , h , cost , mid ) ; long am = costOfOperation ( n , h , cost , mid + 1 ) ; if ( ans == m ) break ; ans = Long . min ( ans , m ) ; if ( bm <= m ) high = mid ; else if ( am <= m ) low = mid + 1 ; else return m ; } return ans ; } public static void main ( String args [ ] ) { int h [ ] = { 1 , 2 , 3 } ; int cost [ ] = { 10 , 100 , 1000 } ; int n = h . length ; System . out . println ( Bsearch ( n , h , cost ) ) ; } } +","import sys NEW_LINE def costOfOperation ( n , h , cost , eq_h ) : NEW_LINE INDENT c = 0 NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT c += abs ( h [ i ] - eq_h ) * cost [ i ] NEW_LINE DEDENT return c NEW_LINE DEDENT def Bsearch ( n , h , cost ) : NEW_LINE INDENT max_h = h [ 0 ] NEW_LINE for i in range ( len ( h ) ) : NEW_LINE INDENT if ( h [ i ] > max_h ) : NEW_LINE INDENT max_h = h [ i ] NEW_LINE DEDENT DEDENT ans = sys . maxsize NEW_LINE high = 1 + max_h NEW_LINE low = 0 NEW_LINE while ( high > low ) : NEW_LINE INDENT mid = ( low + high ) >> 1 NEW_LINE if ( mid > 0 ) : NEW_LINE INDENT bm = costOfOperation ( n , h , cost , mid - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT bm = sys . maxsize NEW_LINE DEDENT m = costOfOperation ( n , h , cost , mid ) NEW_LINE am = costOfOperation ( n , h , cost , mid + 1 ) NEW_LINE if ( ans == m ) : NEW_LINE INDENT break NEW_LINE DEDENT ans = min ( ans , m ) NEW_LINE if ( bm <= m ) : NEW_LINE INDENT high = mid NEW_LINE DEDENT elif ( am <= m ) : NEW_LINE INDENT low = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT return m ; NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT h = [ 1 , 2 , 3 ] NEW_LINE cost = [ 10 , 100 , 1000 ] NEW_LINE n = len ( h ) NEW_LINE print ( Bsearch ( n , h , cost ) ) NEW_LINE DEDENT +" +E1454,"class GFG { static boolean check ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] == 1 ) return true ; return false ; } public static void main ( String [ ] args ) { int a [ ] = { 0 , 1 , 0 , 1 } ; int n = a . length ; if ( check ( a , n ) == true ) System . out . println ( "" YES \n "" ) ; else System . out . println ( "" NO \n "" ) ; } } +","def check ( a , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 0 , 1 , 0 , 1 ] NEW_LINE n = len ( a ) NEW_LINE if ( check ( a , n ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E1455,"import java . io . * ; class GFG { static int findIndex ( int n ) { if ( n <= 1 ) return n ; int a = 0 , b = 1 , c = 1 ; int res = 1 ; while ( c < n ) { c = a + b ; res ++ ; a = b ; b = c ; } return res ; } public static void main ( String [ ] args ) { int result = findIndex ( 21 ) ; System . out . println ( result ) ; } } +","def findIndex ( n ) : NEW_LINE INDENT if ( n <= 1 ) : NEW_LINE INDENT return n NEW_LINE DEDENT a = 0 NEW_LINE b = 1 NEW_LINE c = 1 NEW_LINE res = 1 NEW_LINE while ( c < n ) : NEW_LINE INDENT c = a + b NEW_LINE res = res + 1 NEW_LINE a = b NEW_LINE b = c NEW_LINE DEDENT return res NEW_LINE DEDENT result = findIndex ( 21 ) NEW_LINE print ( result ) NEW_LINE +" +E1456,"public class GFG { static int sumNth ( int A [ ] , int B [ ] , int m , int n ) { int res = 0 ; if ( n == 1 ) { for ( int i = 0 ; i < m ; i ++ ) res = res + A [ i ] ; } else if ( n == 2 ) { for ( int i = 0 ; i < m ; i ++ ) res = res + B [ i ] * m ; } else { int f [ ] = new int [ n ] ; f [ 0 ] = 0 ; f [ 1 ] = 1 ; for ( int i = 2 ; i < n ; i ++ ) f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; for ( int i = 0 ; i < m ; i ++ ) { res = res + ( m * ( B [ i ] * f [ n - 1 ] ) ) + ( m * ( A [ i ] * f [ n - 2 ] ) ) ; } } return res ; } public static void main ( String args [ ] ) { int A [ ] = { 1 , 2 , 3 } ; int B [ ] = { 4 , 5 , 6 } ; int n = 3 ; int m = A . length ; System . out . println ( sumNth ( A , B , m , n ) ) ; } } +","def sumNth ( A , B , m , n ) : NEW_LINE INDENT res = 0 ; NEW_LINE if ( n == 1 ) : NEW_LINE INDENT for i in range ( m ) : NEW_LINE INDENT res = res + A [ i ] ; NEW_LINE DEDENT DEDENT elif ( n == 2 ) : NEW_LINE INDENT for i in range ( m ) : NEW_LINE INDENT res = res + B [ i ] * m ; NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT f = [ 0 ] * n ; NEW_LINE f [ 0 ] = 0 ; NEW_LINE f [ 1 ] = 1 ; NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; NEW_LINE DEDENT for i in range ( m ) : NEW_LINE INDENT res = ( res + ( m * ( B [ i ] * f [ n - 1 ] ) ) + ( m * ( A [ i ] * f [ n - 2 ] ) ) ) ; NEW_LINE DEDENT DEDENT return res ; NEW_LINE DEDENT A = [ 1 , 2 , 3 ] ; NEW_LINE B = [ 4 , 5 , 6 ] ; NEW_LINE n = 3 ; NEW_LINE m = len ( A ) ; NEW_LINE print ( sumNth ( A , B , m , n ) ) ; NEW_LINE +" +E1457,"class GFG { static boolean isVowel ( char c ) { return ( c == ' a ' || c == ' A ' || c == ' e ' || c == ' E ' || c == ' i ' || c == ' I ' || c == ' o ' || c == ' O ' || c == ' u ' || c == ' U ' ) ; } static String reverseVowel ( String str1 ) { int j = 0 ; char [ ] str = str1 . toCharArray ( ) ; String vowel = "" "" ; for ( int i = 0 ; i < str . length ; i ++ ) { if ( isVowel ( str [ i ] ) ) { j ++ ; vowel += str [ i ] ; } } for ( int i = 0 ; i < str . length ; i ++ ) { if ( isVowel ( str [ i ] ) ) { str [ i ] = vowel . charAt ( -- j ) ; } } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String str = "" hello ▁ world "" ; System . out . println ( reverseVowel ( str ) ) ; } } +","def isVowel ( c ) : NEW_LINE INDENT if ( c == ' a ' or c == ' A ' or c == ' e ' or c == ' E ' or c == ' i ' or c == ' I ' or c == ' o ' or c == ' O ' or c == ' u ' or c == ' U ' ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def reverserVowel ( string ) : NEW_LINE INDENT j = 0 NEW_LINE vowel = [ 0 ] * len ( string ) NEW_LINE string = list ( string ) NEW_LINE for i in range ( len ( string ) ) : NEW_LINE INDENT if isVowel ( string [ i ] ) : NEW_LINE INDENT vowel [ j ] = string [ i ] NEW_LINE j += 1 NEW_LINE DEDENT DEDENT for i in range ( len ( string ) ) : NEW_LINE INDENT if isVowel ( string [ i ] ) : NEW_LINE INDENT j -= 1 NEW_LINE string [ i ] = vowel [ j ] NEW_LINE DEDENT DEDENT return ' ' . join ( string ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" hello ▁ world "" NEW_LINE print ( reverserVowel ( string ) ) NEW_LINE DEDENT +" +E1458,"import java . io . * ; import java . util . * ; class GFG { static int minimumCost ( int cost [ ] , int n ) { int dp1 = 0 , dp2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int dp0 = cost [ i ] + Math . min ( dp1 , dp2 ) ; dp2 = dp1 ; dp1 = dp0 ; } return Math . min ( dp1 , dp2 ) ; } public static void main ( String args [ ] ) { int a [ ] = { 2 , 5 , 3 , 1 , 7 , 3 , 4 } ; int n = a . length ; System . out . print ( minimumCost ( a , n ) ) ; } } +","def minimumCost ( cost , n ) : NEW_LINE INDENT dp1 = 0 NEW_LINE dp2 = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT dp0 = cost [ i ] + min ( dp1 , dp2 ) NEW_LINE dp2 = dp1 NEW_LINE dp1 = dp0 NEW_LINE DEDENT return min ( dp1 , dp2 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 2 , 5 , 3 , 1 , 7 , 3 , 4 ] NEW_LINE n = len ( a ) NEW_LINE print ( minimumCost ( a , n ) ) NEW_LINE DEDENT +" +E1459,"class GFG { static int N = 2 ; static boolean isVowel ( char ch ) { return ( ch == ' a ' || ch == ' e ' || ch == ' i ' || ch == ' o ' || ch == ' u ' ) ; } static int countVowels ( String str , int l , int r ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( isVowel ( str . charAt ( i ) ) ) cnt ++ ; } return cnt ; } static void performQueries ( String str , int queries [ ] [ ] , int q ) { for ( int i = 0 ; i < q ; i ++ ) { System . out . println ( countVowels ( str , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) ; } } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int queries [ ] [ ] = { { 1 , 3 } , { 2 , 4 } , { 1 , 9 } } ; int q = queries . length ; performQueries ( str , queries , q ) ; } } +","N = 2 ; NEW_LINE def isVowel ( ch ) : NEW_LINE INDENT return ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) ; NEW_LINE DEDENT def countVowels ( string , l , r ) : NEW_LINE INDENT cnt = 0 ; NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT if ( isVowel ( string [ i ] ) ) : NEW_LINE INDENT cnt += 1 ; NEW_LINE DEDENT DEDENT return cnt ; NEW_LINE DEDENT def performQueries ( string , queries , q ) : NEW_LINE INDENT for i in range ( q ) : NEW_LINE INDENT print ( countVowels ( string , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" geeksforgeeks "" ; NEW_LINE queries = [ [ 1 , 3 ] , [ 2 , 4 ] , [ 1 , 9 ] ] ; NEW_LINE q = len ( queries ) NEW_LINE performQueries ( string , queries , q ) ; NEW_LINE DEDENT +" +E1460,"import java . util . * ; class Circular { public static int removeAlternate ( int n ) { if ( n == 1 ) return 1 ; if ( n % 2 == 0 ) return 2 * removeAlternate ( n / 2 ) - 1 ; else return 2 * removeAlternate ( ( ( n - 1 ) / 2 ) ) + 1 ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( removeAlternate ( n ) ) ; n = 10 ; System . out . print ( "" \n "" + removeAlternate ( n ) ) ; } } +","def removeAlternate ( n ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( n % 2 == 0 ) : NEW_LINE INDENT return 2 * removeAlternate ( n / 2 ) - 1 NEW_LINE DEDENT else : NEW_LINE INDENT return 2 * removeAlternate ( ( ( n - 1 ) / 2 ) ) + 1 NEW_LINE DEDENT DEDENT n = 5 NEW_LINE print ( removeAlternate ( n ) ) NEW_LINE n = 10 NEW_LINE print ( removeAlternate ( n ) ) NEW_LINE +" +E1461,"class GFG { static void lowerWythoff ( int n ) { double phi = ( 1 + Math . sqrt ( 5 ) ) / 2.0 ; for ( int i = 1 ; i <= n ; i ++ ) { double ans = Math . floor ( i * phi ) ; System . out . print ( ( int ) ans ) ; if ( i != n ) System . out . print ( "" ▁ , ▁ "" ) ; } } public static void main ( String [ ] args ) { int n = 5 ; lowerWythoff ( n ) ; } } +","from math import sqrt , floor NEW_LINE def lowerWythoff ( n ) : NEW_LINE INDENT phi = ( 1 + sqrt ( 5 ) ) / 2 ; NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ans = floor ( i * phi ) ; NEW_LINE print ( ans , end = "" "" ) ; NEW_LINE if ( i != n ) : NEW_LINE INDENT print ( "" , ▁ "" , end = "" "" ) ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 5 ; NEW_LINE lowerWythoff ( n ) ; NEW_LINE DEDENT +" +E1462,"class Test { static int countPairs ( String str ) { int result = 0 ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( Math . abs ( str . charAt ( i ) - str . charAt ( j ) ) == Math . abs ( i - j ) ) result ++ ; return result ; } public static void main ( String args [ ] ) { String str = "" geeksforgeeks "" ; System . out . println ( countPairs ( str ) ) ; } } +","def countPairs ( str1 ) : NEW_LINE INDENT result = 0 ; NEW_LINE n = len ( str1 ) NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( abs ( ord ( str1 [ i ] ) - ord ( str1 [ j ] ) ) == abs ( i - j ) ) : NEW_LINE INDENT result += 1 ; NEW_LINE DEDENT DEDENT DEDENT return result ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = "" geeksforgeeks "" ; NEW_LINE print ( countPairs ( str1 ) ) ; NEW_LINE DEDENT +" +E1463,"class GFG { static boolean checkPowerof8 ( int n ) { double i = Math . log ( n ) / Math . log ( 8 ) ; return ( i - Math . floor ( i ) < 0.000001 ) ; } public static void main ( String args [ ] ) { int n = 65 ; if ( checkPowerof8 ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","from math import log , trunc NEW_LINE def checkPowerof8 ( n ) : NEW_LINE INDENT i = log ( n , 8 ) NEW_LINE return ( i - trunc ( i ) < 0.000001 ) ; NEW_LINE DEDENT n = 65 NEW_LINE if checkPowerof8 ( n ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1464,"import java . io . * ; class GFG { static void digitsNum ( int N ) { if ( N == 0 ) System . out . println ( ""0"" ) ; if ( N % 9 != 0 ) System . out . print ( ( N % 9 ) ) ; for ( int i = 1 ; i <= ( N / 9 ) ; ++ i ) System . out . print ( ""9"" ) ; for ( int i = 1 ; i <= N ; ++ i ) System . out . print ( ""0"" ) ; System . out . print ( "" "" ) ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . print ( "" The ▁ number ▁ is ▁ : ▁ "" ) ; digitsNum ( N ) ; } } +","import math NEW_LINE def digitsNum ( N ) : NEW_LINE INDENT if ( N == 0 ) : NEW_LINE INDENT print ( ""0"" , end = "" "" ) NEW_LINE DEDENT if ( N % 9 != 0 ) : NEW_LINE INDENT print ( N % 9 , end = "" "" ) NEW_LINE DEDENT for i in range ( 1 , int ( N / 9 ) + 1 ) : NEW_LINE INDENT print ( ""9"" , end = "" "" ) NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT print ( ""0"" , end = "" "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT N = 5 NEW_LINE print ( "" The ▁ number ▁ is ▁ : ▁ "" , end = "" "" ) NEW_LINE digitsNum ( N ) NEW_LINE +" +E1465,"import java . util . * ; class GFG { static void printFirstNegativeInteger ( int arr [ ] , int n , int k ) { LinkedList < Integer > Di = new LinkedList < > ( ) ; int i ; for ( i = 0 ; i < k ; i ++ ) if ( arr [ i ] < 0 ) Di . add ( i ) ; for ( ; i < n ; i ++ ) { if ( ! Di . isEmpty ( ) ) System . out . print ( arr [ Di . peek ( ) ] + "" ▁ "" ) ; else System . out . print ( ""0"" + "" ▁ "" ) ; while ( ( ! Di . isEmpty ( ) ) && Di . peek ( ) < ( i - k + 1 ) ) Di . remove ( ) ; if ( arr [ i ] < 0 ) Di . add ( i ) ; } if ( ! Di . isEmpty ( ) ) System . out . print ( arr [ Di . peek ( ) ] + "" ▁ "" ) ; else System . out . print ( ""0"" + "" ▁ "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , - 1 , - 7 , 8 , - 15 , 30 , 16 , 28 } ; int n = arr . length ; int k = 3 ; printFirstNegativeInteger ( arr , n , k ) ; } } +","from collections import deque NEW_LINE def printFirstNegativeInteger ( arr , n , k ) : NEW_LINE INDENT Di = deque ( ) NEW_LINE for i in range ( k ) : NEW_LINE INDENT if ( arr [ i ] < 0 ) : NEW_LINE INDENT Di . append ( i ) ; NEW_LINE DEDENT DEDENT for i in range ( k , n ) : NEW_LINE INDENT if ( not Di ) : NEW_LINE INDENT print ( 0 , end = ' ▁ ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( arr [ Di [ 0 ] ] , end = ' ▁ ' ) ; NEW_LINE DEDENT while Di and Di [ 0 ] <= ( i - k ) : NEW_LINE INDENT Di . popleft ( ) NEW_LINE DEDENT if ( arr [ i ] < 0 ) : NEW_LINE INDENT Di . append ( i ) ; NEW_LINE DEDENT DEDENT if not Di : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( arr [ Di [ 0 ] ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 12 , - 1 , - 7 , 8 , - 15 , 30 , 16 , 28 ] NEW_LINE n = len ( arr ) NEW_LINE k = 3 NEW_LINE printFirstNegativeInteger ( arr , n , k ) ; NEW_LINE DEDENT +" +E1466,"import java . io . * ; class GFG { public static void findFirstAndLast ( int arr [ ] , int x ) { int n = arr . length ; int first = - 1 , last = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( x != arr [ i ] ) continue ; if ( first == - 1 ) first = i ; last = i ; } if ( first != - 1 ) { System . out . println ( "" First ▁ Occurrence ▁ = ▁ "" + first ) ; System . out . println ( "" Last ▁ Occurrence ▁ = ▁ "" + last ) ; } else System . out . println ( "" Not ▁ Found "" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 2 , 2 , 3 , 4 , 7 , 8 , 8 } ; int x = 8 ; findFirstAndLast ( arr , x ) ; } } +","def findFirstAndLast ( arr , n , x ) : NEW_LINE INDENT first = - 1 NEW_LINE last = - 1 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( x != arr [ i ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( first == - 1 ) : NEW_LINE INDENT first = i NEW_LINE DEDENT last = i NEW_LINE DEDENT if ( first != - 1 ) : NEW_LINE INDENT print ( "" First ▁ Occurrence ▁ = ▁ "" , first , "" ▁ \n Last ▁ Occurrence ▁ = ▁ "" , last ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" Not ▁ Found "" ) NEW_LINE DEDENT DEDENT arr = [ 1 , 2 , 2 , 2 , 2 , 3 , 4 , 7 , 8 , 8 ] NEW_LINE n = len ( arr ) NEW_LINE x = 8 NEW_LINE findFirstAndLast ( arr , n , x ) NEW_LINE +" +E1467,"public class GFG { static final int NO_OF_CHARS = 256 ; static boolean areAnagram ( String str1 , String str2 ) { int [ ] count = new int [ NO_OF_CHARS ] ; int i ; for ( i = 0 ; i < str1 . length ( ) && i < str2 . length ( ) ; i ++ ) { count [ str1 . charAt ( i ) ] ++ ; count [ str2 . charAt ( i ) ] -- ; } if ( str1 . length ( ) != str2 . length ( ) ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] != 0 ) return false ; return true ; } static void findAllAnagrams ( String arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( areAnagram ( arr [ i ] , arr [ j ] ) ) System . out . println ( arr [ i ] + "" ▁ is ▁ anagram ▁ of ▁ "" + arr [ j ] ) ; } public static void main ( String args [ ] ) { String arr [ ] = { "" geeksquiz "" , "" geeksforgeeks "" , "" abcd "" , "" forgeeksgeeks "" , "" zuiqkeegs "" } ; int n = arr . length ; findAllAnagrams ( arr , n ) ; } } +","NO_OF_CHARS = 256 NEW_LINE def areAnagram ( str1 : str , str2 : str ) -> bool : NEW_LINE INDENT count = [ 0 ] * NO_OF_CHARS NEW_LINE i = 0 NEW_LINE while i < len ( str1 ) and i < len ( str2 ) : NEW_LINE INDENT count [ ord ( str1 [ i ] ) ] += 1 NEW_LINE count [ ord ( str2 [ i ] ) ] -= 1 NEW_LINE i += 1 NEW_LINE DEDENT if len ( str1 ) != len ( str2 ) : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( NO_OF_CHARS ) : NEW_LINE INDENT if count [ i ] : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT DEDENT def findAllAnagrams ( arr : list , n : int ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if areAnagram ( arr [ i ] , arr [ j ] ) : NEW_LINE INDENT print ( arr [ i ] , "" is ▁ anagram ▁ of "" , arr [ j ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ "" geeksquiz "" , "" geeksforgeeks "" , "" abcd "" , "" forgeeksgeeks "" , "" zuiqkeegs "" ] NEW_LINE n = len ( arr ) NEW_LINE findAllAnagrams ( arr , n ) NEW_LINE DEDENT +" +E1468,"class GFG { static int MAX = 100 ; public static void main ( String [ ] args ) { long [ ] arr = new long [ MAX ] ; arr [ 0 ] = 0 ; arr [ 1 ] = 1 ; for ( int i = 2 ; i < MAX ; i ++ ) arr [ i ] = arr [ i - 1 ] + arr [ i - 2 ] ; System . out . print ( "" Fibonacci ▁ numbers ▁ divisible ▁ by ▁ "" + "" their ▁ indexes ▁ are ▁ : \n "" ) ; for ( int i = 1 ; i < MAX ; i ++ ) if ( arr [ i ] % i == 0 ) System . out . print ( i + "" ▁ "" ) ; } } +","if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT MAX = 100 NEW_LINE arr = [ 0 for i in range ( MAX ) ] NEW_LINE arr [ 0 ] = 0 NEW_LINE arr [ 1 ] = 1 NEW_LINE for i in range ( 2 , MAX ) : NEW_LINE INDENT arr [ i ] = arr [ i - 1 ] + arr [ i - 2 ] NEW_LINE DEDENT print ( "" Fibonacci ▁ numbers ▁ divisible ▁ by ▁ their ▁ indexes ▁ are ▁ : "" ) NEW_LINE for i in range ( 1 , MAX ) : NEW_LINE INDENT if ( arr [ i ] % i == 0 ) : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT +" +E1469,"import java . io . * ; class GFG { static boolean isPossible ( int Sx , int Sy , int Dx , int Dy , int x , int y ) { if ( Math . abs ( Sx - Dx ) % x == 0 && Math . abs ( Sy - Dy ) % y == 0 && ( Math . abs ( Sx - Dx ) / x ) % 2 == ( Math . abs ( Sy - Dy ) / y ) % 2 ) return true ; return false ; } public static void main ( String [ ] args ) { int Sx = 0 , Sy = 0 , Dx = 0 , Dy = 0 ; int x = 3 , y = 4 ; if ( isPossible ( Sx , Sy , Dx , Dy , x , y ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isPossible ( Sx , Sy , Dx , Dy , x , y ) : NEW_LINE INDENT if ( abs ( Sx - Dx ) % x == 0 and abs ( Sy - Dy ) % y == 0 and ( abs ( Sx - Dx ) / x ) % 2 == ( abs ( Sy - Dy ) / y ) % 2 ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT return False ; NEW_LINE DEDENT Sx = 0 ; NEW_LINE Sy = 0 ; NEW_LINE Dx = 0 ; NEW_LINE Dy = 0 ; NEW_LINE x = 3 ; NEW_LINE y = 4 ; NEW_LINE if ( isPossible ( Sx , Sy , Dx , Dy , x , y ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT +" +E1470,"import java . io . * ; class GFG { static boolean isPerfectSquareString ( String str ) { int sum = 0 ; int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) sum += ( int ) str . charAt ( i ) ; long squareRoot = ( long ) Math . sqrt ( sum ) ; return ( ( squareRoot - Math . floor ( squareRoot ) ) == 0 ) ; } public static void main ( String [ ] args ) { String str = "" d "" ; if ( isPerfectSquareString ( str ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","import math ; NEW_LINE def isPerfectSquareString ( str ) : NEW_LINE INDENT sum = 0 ; NEW_LINE l = len ( str ) ; NEW_LINE for i in range ( l ) : NEW_LINE INDENT sum = sum + ord ( str [ i ] ) ; NEW_LINE DEDENT squareRoot = math . sqrt ( sum ) ; NEW_LINE return ( ( squareRoot - math . floor ( squareRoot ) ) == 0 ) ; NEW_LINE DEDENT str = "" d "" ; NEW_LINE if ( isPerfectSquareString ( str ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT +" +E1471,"import java . util . * ; class GfG { static boolean arePermutation ( String str1 , String str2 ) { int n1 = str1 . length ( ) ; int n2 = str2 . length ( ) ; if ( n1 != n2 ) return false ; char ch1 [ ] = str1 . toCharArray ( ) ; char ch2 [ ] = str2 . toCharArray ( ) ; Arrays . sort ( ch1 ) ; Arrays . sort ( ch2 ) ; for ( int i = 0 ; i < n1 ; i ++ ) if ( ch1 [ i ] != ch2 [ i ] ) return false ; return true ; } public static void main ( String [ ] args ) { String str1 = "" test "" ; String str2 = "" ttew "" ; if ( arePermutation ( str1 , str2 ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def arePermutation ( str1 , str2 ) : NEW_LINE INDENT n1 = len ( str1 ) NEW_LINE n2 = len ( str2 ) NEW_LINE if ( n1 != n2 ) : NEW_LINE INDENT return False NEW_LINE DEDENT a = sorted ( str1 ) NEW_LINE str1 = "" ▁ "" . join ( a ) NEW_LINE b = sorted ( str2 ) NEW_LINE str2 = "" ▁ "" . join ( b ) NEW_LINE for i in range ( 0 , n1 , 1 ) : NEW_LINE INDENT if ( str1 [ i ] != str2 [ i ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str1 = "" test "" NEW_LINE str2 = "" ttew "" NEW_LINE if ( arePermutation ( str1 , str2 ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1472,"class GFG { static int catalanDP ( int n ) { int catalan [ ] = new int [ n + 2 ] ; catalan [ 0 ] = 1 ; catalan [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { catalan [ i ] = 0 ; for ( int j = 0 ; j < i ; j ++ ) { catalan [ i ] += catalan [ j ] * catalan [ i - j - 1 ] ; } } return catalan [ n ] ; } public static void main ( String [ ] args ) { for ( int i = 0 ; i < 10 ; i ++ ) { System . out . print ( catalanDP ( i ) + "" ▁ "" ) ; } } } +","def catalan ( n ) : NEW_LINE INDENT if ( n == 0 or n == 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT catalan = [ 0 for i in range ( n + 1 ) ] NEW_LINE catalan [ 0 ] = 1 NEW_LINE catalan [ 1 ] = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT catalan [ i ] = 0 NEW_LINE for j in range ( i ) : NEW_LINE INDENT catalan [ i ] = catalan [ i ] + catalan [ j ] * catalan [ i - j - 1 ] NEW_LINE DEDENT DEDENT return catalan [ n ] NEW_LINE DEDENT for i in range ( 10 ) : NEW_LINE INDENT print ( catalan ( i ) , end = "" ▁ "" ) NEW_LINE DEDENT +" +E1473,"import java . util . * ; class GFG { static void findGeometricTriplets ( int arr [ ] , int n ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { int i = j - 1 , k = j + 1 ; while ( i >= 0 && k <= n - 1 ) { while ( i >= 0 && arr [ j ] % arr [ i ] == 0 && arr [ k ] % arr [ j ] == 0 && arr [ j ] / arr [ i ] == arr [ k ] / arr [ j ] ) { System . out . println ( arr [ i ] + "" ▁ "" + arr [ j ] + "" ▁ "" + arr [ k ] ) ; k ++ ; i -- ; } if ( i >= 0 && arr [ j ] % arr [ i ] == 0 && arr [ k ] % arr [ j ] == 0 ) { if ( i >= 0 && arr [ j ] / arr [ i ] < arr [ k ] / arr [ j ] ) i -- ; else k ++ ; } else if ( i >= 0 && arr [ j ] % arr [ i ] == 0 ) k ++ ; else i -- ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 , 16 } ; int n = arr . length ; findGeometricTriplets ( arr , n ) ; } } +","def findGeometricTriplets ( arr , n ) : NEW_LINE INDENT for j in range ( 1 , n - 1 ) : NEW_LINE INDENT i = j - 1 NEW_LINE k = j + 1 NEW_LINE while ( i >= 0 and k <= n - 1 ) : NEW_LINE INDENT while ( arr [ j ] % arr [ i ] == 0 and arr [ k ] % arr [ j ] == 0 and arr [ j ] // arr [ i ] == arr [ k ] // arr [ j ] ) : NEW_LINE INDENT print ( arr [ i ] , "" ▁ "" , arr [ j ] , "" ▁ "" , arr [ k ] ) NEW_LINE k += 1 NEW_LINE i -= 1 NEW_LINE DEDENT if ( arr [ j ] % arr [ i ] == 0 and arr [ k ] % arr [ j ] == 0 ) : NEW_LINE INDENT if ( arr [ j ] // arr [ i ] < arr [ k ] // arr [ j ] ) : NEW_LINE INDENT i -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT k += 1 NEW_LINE DEDENT DEDENT elif ( arr [ j ] % arr [ i ] == 0 ) : NEW_LINE INDENT k += 1 NEW_LINE DEDENT else : NEW_LINE INDENT i -= 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 2 , 4 , 16 ] NEW_LINE n = len ( arr ) NEW_LINE findGeometricTriplets ( arr , n ) NEW_LINE DEDENT +" +E1474,"class fibonacci { static int fib ( int n ) { int F [ ] [ ] = new int [ ] [ ] { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n - 1 ) ; return F [ 0 ] [ 0 ] ; } static void multiply ( int F [ ] [ ] , int M [ ] [ ] ) { int x = F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ; int y = F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ; int z = F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ; int w = F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } static void power ( int F [ ] [ ] , int n ) { int i ; int M [ ] [ ] = new int [ ] [ ] { { 1 , 1 } , { 1 , 0 } } ; for ( i = 2 ; i <= n ; i ++ ) multiply ( F , M ) ; } public static void main ( String args [ ] ) { int n = 9 ; System . out . println ( fib ( n ) ) ; } } +","def fib ( n ) : NEW_LINE INDENT F = [ [ 1 , 1 ] , [ 1 , 0 ] ] NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT power ( F , n - 1 ) NEW_LINE return F [ 0 ] [ 0 ] NEW_LINE DEDENT def multiply ( F , M ) : NEW_LINE INDENT x = ( F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ) NEW_LINE y = ( F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ) NEW_LINE z = ( F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ) NEW_LINE w = ( F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ) NEW_LINE F [ 0 ] [ 0 ] = x NEW_LINE F [ 0 ] [ 1 ] = y NEW_LINE F [ 1 ] [ 0 ] = z NEW_LINE F [ 1 ] [ 1 ] = w NEW_LINE DEDENT def power ( F , n ) : NEW_LINE INDENT M = [ [ 1 , 1 ] , [ 1 , 0 ] ] NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT multiply ( F , M ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 9 NEW_LINE print ( fib ( n ) ) NEW_LINE DEDENT +" +E1475,"public class GFG { static char largest_alphabet ( String a , int n ) { char max = ' A ' ; for ( int i = 0 ; i < n ; i ++ ) if ( a . charAt ( i ) > max ) max = a . charAt ( i ) ; return max ; } static char smallest_alphabet ( String a , int n ) { char min = ' z ' ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( a . charAt ( i ) < min ) min = a . charAt ( i ) ; return min ; } public static void main ( String args [ ] ) { String a = "" GeEksforGeeks "" ; int size = a . length ( ) ; System . out . print ( "" Largest ▁ and ▁ smallest ▁ alphabet ▁ is ▁ : ▁ "" ) ; System . out . print ( largest_alphabet ( a , size ) + "" ▁ and ▁ "" ) ; System . out . println ( smallest_alphabet ( a , size ) ) ; } } +","def largest_alphabet ( a , n ) : NEW_LINE INDENT max = ' A ' NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] > max ) : NEW_LINE INDENT max = a [ i ] NEW_LINE DEDENT DEDENT return max NEW_LINE DEDENT def smallest_alphabet ( a , n ) : NEW_LINE INDENT min = ' z ' ; NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( a [ i ] < min ) : NEW_LINE INDENT min = a [ i ] NEW_LINE DEDENT DEDENT return min NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = "" GeEksforGeeks "" NEW_LINE size = len ( a ) NEW_LINE print ( "" Largest ▁ and ▁ smallest ▁ alphabet ▁ is ▁ : ▁ "" , end = "" "" ) NEW_LINE print ( largest_alphabet ( a , size ) , end = "" ▁ and ▁ "" ) NEW_LINE print ( smallest_alphabet ( a , size ) ) NEW_LINE DEDENT +" +E1476,"class GFG { public boolean Check_is_possible ( int l , int r , int k ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( i % k == 0 ) { count ++ ; } } return ( count > 1 ) ; } public static void main ( String [ ] args ) { GFG g = new GFG ( ) ; int l = 4 , r = 12 ; int k = 5 ; if ( g . Check_is_possible ( l , r , k ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } } +","def Check_is_possible ( l , r , k ) : NEW_LINE INDENT count = 0 ; NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT if ( i % k == 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT return ( count > 1 ) ; NEW_LINE DEDENT l = 4 ; NEW_LINE r = 12 ; NEW_LINE k = 5 ; NEW_LINE if ( Check_is_possible ( l , r , k ) ) : NEW_LINE INDENT print ( "" YES "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) ; NEW_LINE DEDENT +" +E1477,"import java . io . * ; class PushZero { static void pushZerosToEnd ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != 0 ) arr [ count ++ ] = arr [ i ] ; while ( count < n ) arr [ count ++ ] = 0 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 9 , 8 , 4 , 0 , 0 , 2 , 7 , 0 , 6 , 0 , 9 } ; int n = arr . length ; pushZerosToEnd ( arr , n ) ; System . out . println ( "" Array ▁ after ▁ pushing ▁ zeros ▁ to ▁ the ▁ back : ▁ "" ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } } +","def pushZerosToEnd ( arr , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] != 0 : NEW_LINE INDENT arr [ count ] = arr [ i ] NEW_LINE count += 1 NEW_LINE DEDENT DEDENT while count < n : NEW_LINE INDENT arr [ count ] = 0 NEW_LINE count += 1 NEW_LINE DEDENT DEDENT arr = [ 1 , 9 , 8 , 4 , 0 , 0 , 2 , 7 , 0 , 6 , 0 , 9 ] NEW_LINE n = len ( arr ) NEW_LINE pushZerosToEnd ( arr , n ) NEW_LINE print ( "" Array ▁ after ▁ pushing ▁ all ▁ zeros ▁ to ▁ end ▁ of ▁ array : "" ) NEW_LINE print ( arr ) NEW_LINE +" +E1478,"class GFG { static boolean check ( String s , int k ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i % k ) ) { return false ; } } return true ; } static int countCommonDivisors ( String a , String b ) { int ct = 0 ; int n = a . length ( ) , m = b . length ( ) ; for ( int i = 1 ; i <= Math . min ( n , m ) ; i ++ ) { if ( n % i == 0 && m % i == 0 ) { if ( a . substring ( 0 , i ) . equals ( b . substring ( 0 , i ) ) ) { if ( check ( a , i ) && check ( b , i ) ) { ct ++ ; } } } } return ct ; } public static void main ( String [ ] args ) { String a = "" xaxa "" , b = "" xaxaxaxa "" ; System . out . println ( countCommonDivisors ( a , b ) ) ; } } +","def check ( s , k ) : NEW_LINE INDENT for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT if ( s [ i ] != s [ i % k ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def countCommonDivisors ( a , b ) : NEW_LINE INDENT ct = 0 NEW_LINE n = len ( a ) NEW_LINE m = len ( b ) NEW_LINE for i in range ( 1 , min ( n , m ) + 1 ) : NEW_LINE INDENT if ( n % i == 0 and m % i == 0 ) : NEW_LINE INDENT if ( a [ 0 : i ] == b [ 0 : i ] ) : NEW_LINE INDENT if ( check ( a , i ) and check ( b , i ) ) : NEW_LINE INDENT ct = ct + 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT return ct NEW_LINE DEDENT a = "" xaxa "" NEW_LINE b = "" xaxaxaxa "" NEW_LINE print ( countCommonDivisors ( a , b ) ) NEW_LINE +" +E1479,"class GFG { static int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } public static void main ( String [ ] args ) { int num = 4562 ; System . out . println ( "" Reverse ▁ of ▁ no . ▁ is ▁ "" + reversDigits ( num ) ) ; } } +","n = 4562 ; NEW_LINE rev = 0 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT a = n % 10 NEW_LINE rev = rev * 10 + a NEW_LINE n = n // 10 NEW_LINE DEDENT print ( rev ) NEW_LINE +" +E1480,"import java . io . * ; class GFG { static int center_nonadecagon_num ( int n ) { return ( 19 * n * n - 19 * n + 2 ) / 2 ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . print ( n + "" th ▁ centered ▁ "" + "" nonadecagonal ▁ number ▁ : ▁ "" ) ; System . out . println ( center_nonadecagon_num ( n ) ) ; n = 7 ; System . out . print ( n + "" th ▁ centered ▁ "" + "" nonadecagonal ▁ number ▁ : ▁ "" ) ; System . out . println ( center_nonadecagon_num ( n ) ) ; } } +","def center_nonadecagon_num ( n ) : NEW_LINE INDENT return ( 19 * n * n - 19 * n + 2 ) // 2 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 2 NEW_LINE print ( n , "" nd ▁ centered ▁ nonadecagonal ▁ "" + "" number ▁ : ▁ "" , center_nonadecagon_num ( n ) ) NEW_LINE n = 7 NEW_LINE print ( n , "" nd ▁ centered ▁ nonadecagonal ▁ "" + "" number ▁ : ▁ "" , center_nonadecagon_num ( n ) ) NEW_LINE DEDENT +" +E1481,"import java . util . Arrays ; public class CountKSubStr { int countkDist ( String str , int k ) { int res = 0 ; int n = str . length ( ) ; int cnt [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { int dist_count = 0 ; Arrays . fill ( cnt , 0 ) ; for ( int j = i ; j < n ; j ++ ) { if ( cnt [ str . charAt ( j ) - ' a ' ] == 0 ) dist_count ++ ; cnt [ str . charAt ( j ) - ' a ' ] ++ ; if ( dist_count == k ) res ++ ; } } return res ; } public static void main ( String [ ] args ) { CountKSubStr ob = new CountKSubStr ( ) ; String ch = "" abcbaa "" ; int k = 3 ; System . out . println ( "" Total ▁ substrings ▁ with ▁ exactly ▁ "" + k + "" ▁ distinct ▁ characters ▁ : ▁ "" + ob . countkDist ( ch , k ) ) ; } } +","def countkDist ( str1 , k ) : NEW_LINE INDENT n = len ( str1 ) NEW_LINE res = 0 NEW_LINE cnt = [ 0 ] * 27 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT dist_count = 0 NEW_LINE cnt = [ 0 ] * 27 NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT if ( cnt [ ord ( str1 [ j ] ) - 97 ] == 0 ) : NEW_LINE INDENT dist_count += 1 NEW_LINE DEDENT cnt [ ord ( str1 [ j ] ) - 97 ] += 1 NEW_LINE if ( dist_count == k ) : NEW_LINE INDENT res += 1 NEW_LINE DEDENT if ( dist_count > k ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str1 = "" abcbaa "" NEW_LINE k = 3 NEW_LINE print ( "" Total ▁ substrings ▁ with ▁ exactly "" , k , "" distinct ▁ characters ▁ : ▁ "" , end = "" "" ) NEW_LINE print ( countkDist ( str1 , k ) ) NEW_LINE DEDENT +" +E1482,"class GFG { static float percent ( int n , int x ) { float p = n * x ; p /= 100 ; return p ; } static float getLoss ( int price [ ] , int quantity [ ] , int X [ ] , int n ) { float loss = 0 ; for ( int i = 0 ; i < n ; i ++ ) { float originalPrice = price [ i ] ; float sellingPrice = originalPrice + percent ( ( int ) originalPrice , X [ i ] ) ; float afterDiscount = sellingPrice - percent ( ( int ) sellingPrice , X [ i ] ) ; loss += ( ( originalPrice - afterDiscount ) * quantity [ i ] ) ; } return loss ; } public static void main ( String args [ ] ) { int price [ ] = { 20 , 48 , 200 , 100 } ; int quantity [ ] = { 20 , 48 , 1 , 1 } ; int X [ ] = { 0 , 48 , 200 , 5 } ; int n = X . length ; System . out . print ( getLoss ( price , quantity , X , n ) ) ; } } +","def percent ( n , x ) : NEW_LINE INDENT p = ( int ) ( n ) * x ; NEW_LINE p /= 100 ; NEW_LINE return p ; NEW_LINE DEDENT def getLoss ( price , quantity , X , n ) : NEW_LINE INDENT loss = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT originalPrice = price [ i ] ; NEW_LINE sellingPrice = originalPrice + percent ( originalPrice , X [ i ] ) ; NEW_LINE afterDiscount = sellingPrice - percent ( sellingPrice , X [ i ] ) ; NEW_LINE loss += ( ( originalPrice - afterDiscount ) * quantity [ i ] ) ; NEW_LINE DEDENT return round ( loss , 2 ) ; NEW_LINE DEDENT price = [ 20 , 48 , 200 , 100 ] ; NEW_LINE quantity = [ 20 , 48 , 1 , 1 ] ; NEW_LINE X = [ 0 , 48 , 200 , 5 ] ; NEW_LINE n = len ( X ) ; NEW_LINE print ( getLoss ( price , quantity , X , n ) ) ; NEW_LINE +" +E1483,"class GFG { static int minCost ( char [ ] s ) { boolean alphabets [ ] = new boolean [ 26 ] ; for ( int i = 0 ; i < s . length ; i ++ ) { alphabets [ ( int ) s [ i ] - 97 ] = true ; } int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( alphabets [ i ] ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { String s = "" geeksforgeeks "" ; System . out . println ( "" Total ▁ cost ▁ to ▁ construct ▁ "" + s + "" ▁ is ▁ "" + minCost ( s . toCharArray ( ) ) ) ; } } +","def minCost ( s ) : NEW_LINE INDENT alphabets = [ False for i in range ( 26 ) ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT alphabets [ ord ( s [ i ] ) - 97 ] = True NEW_LINE DEDENT count = 0 NEW_LINE for i in range ( 26 ) : NEW_LINE INDENT if ( alphabets [ i ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "" geeksforgeeks "" NEW_LINE print ( "" Total ▁ cost ▁ to ▁ construct "" , s , "" is "" , minCost ( s ) ) NEW_LINE DEDENT +" +E1484,"import java . util . * ; import java . lang . Math ; import java . io . * ; class GFG { static int nextPowerOfFour ( int n ) { int x = ( int ) Math . floor ( Math . sqrt ( Math . sqrt ( n ) ) ) ; if ( Math . pow ( x , 4 ) == n ) return n ; else { x = x + 1 ; return ( int ) Math . pow ( x , 4 ) ; } } public static void main ( String [ ] args ) throws java . lang . Exception { int n = 122 ; System . out . println ( nextPowerOfFour ( n ) ) ; } } +","import math NEW_LINE def nextPowerOfFour ( n ) : NEW_LINE INDENT x = math . floor ( ( n ** ( 1 / 2 ) ) ** ( 1 / 2 ) ) ; NEW_LINE if ( ( x ** 4 ) == n ) : NEW_LINE INDENT return n ; NEW_LINE DEDENT else : NEW_LINE INDENT x = x + 1 ; NEW_LINE return ( x ** 4 ) ; NEW_LINE DEDENT DEDENT n = 122 ; NEW_LINE print ( nextPowerOfFour ( n ) ) ; NEW_LINE +" +E1485,"class GFG { static int findCost ( String s1 , String s2 , int a , int b , int c , int d , int n ) { int cost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 . charAt ( i ) == s2 . charAt ( i ) ) continue ; else { if ( ( s1 . charAt ( i ) == '1' && s2 . charAt ( i ) == '2' ) || ( s2 . charAt ( i ) == '1' && s1 . charAt ( i ) == '2' ) ) cost += Math . min ( d , Math . min ( a , b + c ) ) ; else if ( ( s1 . charAt ( i ) == '2' && s2 . charAt ( i ) == '3' ) || ( s2 . charAt ( i ) == '2' && s1 . charAt ( i ) == '3' ) ) cost += Math . min ( d , Math . min ( b , a + c ) ) ; else if ( ( s1 . charAt ( i ) == '1' && s2 . charAt ( i ) == '3' ) || ( s2 . charAt ( i ) == '1' && s1 . charAt ( i ) == '3' ) ) cost += Math . min ( d , Math . min ( c , a + b ) ) ; } } return cost ; } public static void main ( String [ ] args ) { String s1 = ""121"" ; String s2 = ""223"" ; int a = 2 , b = 3 , c = 4 , d = 10 ; int n = s1 . length ( ) ; System . out . println ( findCost ( s1 , s2 , a , b , c , d , n ) ) ; } } +","def findCost ( s1 , s2 , a , b , c , d , n ) : NEW_LINE INDENT cost = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( s1 [ i ] == s2 [ i ] ) : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if ( ( s1 [ i ] == '1' and s2 [ i ] == '2' ) or ( s2 [ i ] == '1' and s1 [ i ] == '2' ) ) : NEW_LINE INDENT cost += min ( d , min ( a , b + c ) ) NEW_LINE DEDENT elif ( ( s1 [ i ] == '2' and s2 [ i ] == '3' ) or ( s2 [ i ] == '2' and s1 [ i ] == '3' ) ) : NEW_LINE INDENT cost += min ( d , min ( b , a + c ) ) NEW_LINE DEDENT elif ( ( s1 [ i ] == '1' and s2 [ i ] == '3' ) or ( s2 [ i ] == '1' and s1 [ i ] == '3' ) ) : NEW_LINE INDENT cost += min ( d , min ( c , a + b ) ) NEW_LINE DEDENT DEDENT DEDENT return cost NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s1 = ""121"" NEW_LINE s2 = ""223"" NEW_LINE a = 2 NEW_LINE b = 3 NEW_LINE c = 4 NEW_LINE d = 10 NEW_LINE n = len ( s1 ) NEW_LINE print ( findCost ( s1 , s2 , a , b , c , d , n ) ) NEW_LINE DEDENT +" +E1486,"class GFG { static void TwentyoneMatchstick ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i += 1 ) { System . out . print ( 5 - arr [ i ] + "" ▁ "" ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 2 , 2 } ; int N = arr . length ; TwentyoneMatchstick ( arr , N ) ; } } +","def TwentyoneMatchstick ( arr , N ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT print ( 5 - arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT arr = [ 3 , 4 , 2 , 2 ] NEW_LINE N = len ( arr ) NEW_LINE TwentyoneMatchstick ( arr , N ) NEW_LINE +" +E1487,"class GFG { static double Perimeter ( double s , int n ) { double perimeter = 1 ; perimeter = n * s ; return perimeter ; } public static void main ( String [ ] args ) { int n = 5 ; double s = 2.5 , peri ; peri = Perimeter ( s , n ) ; System . out . println ( "" Perimeter ▁ of ▁ Regular ▁ Polygon "" + "" ▁ with ▁ "" + n + "" ▁ sides ▁ of ▁ length ▁ "" + s + "" ▁ = ▁ "" + peri ) ; } } +","def Perimeter ( s , n ) : NEW_LINE INDENT perimeter = 1 NEW_LINE perimeter = n * s NEW_LINE return perimeter NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 5 NEW_LINE s = 2.5 NEW_LINE peri = Perimeter ( s , n ) NEW_LINE print ( "" Perimeter ▁ of ▁ Regular ▁ Polygon ▁ with "" , n , "" sides ▁ of ▁ length "" , s , "" = "" , peri ) NEW_LINE DEDENT +" +E1488,"import java . io . * ; class GFG { static boolean checkPalindrome ( String str ) { int n = str . length ( ) ; int count = 0 ; for ( int i = 0 ; i < n / 2 ; ++ i ) if ( str . charAt ( i ) != str . charAt ( n - i - 1 ) ) ++ count ; return ( count <= 1 ) ; } public static void main ( String [ ] args ) { String str = "" abccaa "" ; if ( checkPalindrome ( str ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def checkPalindrome ( str ) : NEW_LINE INDENT n = len ( str ) NEW_LINE count = 0 NEW_LINE for i in range ( 0 , int ( n / 2 ) ) : NEW_LINE INDENT if ( str [ i ] != str [ n - i - 1 ] ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT DEDENT if ( count <= 1 ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT str = "" abccaa "" NEW_LINE if ( checkPalindrome ( str ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1489,"import java . util . * ; import java . lang . * ; class GfG { public static int getSum ( int n ) { int sum = 0 ; while ( n != 0 ) { sum = sum + n % 10 ; n = n / 10 ; } return sum ; } public static int largestDigitSumdivisior ( int n ) { int res = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( n % i == 0 ) res = Math . max ( res , getSum ( i ) ) ; return res ; } public static void main ( String argc [ ] ) { int n = 14 ; System . out . println ( largestDigitSumdivisior ( n ) ) ; } } +","def getSum ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE while n != 0 : NEW_LINE INDENT sum = sum + n % 10 NEW_LINE n = int ( n / 10 ) NEW_LINE DEDENT return sum NEW_LINE DEDENT def largestDigitSumdivisior ( n ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT res = max ( res , getSum ( i ) ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT n = 14 NEW_LINE print ( largestDigitSumdivisior ( n ) ) NEW_LINE +" +E1490,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int n , int m ) { return ( n * m ) / gcd ( n , m ) ; } public static void main ( String [ ] args ) { int n = 2 , m = 3 , k = 5 ; System . out . print ( k / lcm ( n , m ) ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 ) : NEW_LINE INDENT return b ; NEW_LINE DEDENT return gcd ( b % a , a ) ; NEW_LINE DEDENT def lcm ( n , m ) : NEW_LINE INDENT return ( n * m ) // gcd ( n , m ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 2 ; m = 3 ; k = 5 ; NEW_LINE print ( k // lcm ( n , m ) ) ; NEW_LINE DEDENT +" +E1491,"import java . util . * ; class GFG { static boolean checkPrime ( String number ) { int num = Integer . valueOf ( number ) ; for ( int i = 2 ; i * i <= num ; i ++ ) if ( ( num % i ) == 0 ) return false ; return true ; } static int splitIntoPrimes ( String number ) { if ( number . length ( ) == 0 ) return 0 ; if ( number . length ( ) <= 6 && checkPrime ( number ) ) return 1 ; else { int numLen = number . length ( ) ; int ans = 1000000 ; for ( int i = 1 ; i <= 6 && i <= numLen ; i ++ ) { if ( checkPrime ( number . substring ( 0 , i ) ) ) { int val = splitIntoPrimes ( number . substring ( i ) ) ; if ( val != - 1 ) { ans = Math . min ( ans , 1 + val ) ; } } } if ( ans == 1000000 ) return - 1 ; return ans ; } } public static void main ( String [ ] args ) { System . out . print ( splitIntoPrimes ( ""13499315"" ) + "" \n "" ) ; System . out . print ( splitIntoPrimes ( ""43"" ) + "" \n "" ) ; } } +","def checkPrime ( number ) : NEW_LINE INDENT num = int ( number ) NEW_LINE for i in range ( 2 , int ( num ** 0.5 ) ) : NEW_LINE INDENT if ( ( num % i ) == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def splitIntoPrimes ( number ) : NEW_LINE INDENT if ( number == ' ' ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( len ( number ) <= 6 and checkPrime ( number ) ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT numLen = len ( number ) NEW_LINE ans = 1000000 NEW_LINE for i in range ( 1 , ( min ( 6 , numLen ) + 1 ) ) : NEW_LINE INDENT if ( checkPrime ( number [ : i ] ) ) : NEW_LINE INDENT val = splitIntoPrimes ( number [ i : ] ) NEW_LINE if ( val != - 1 ) : NEW_LINE INDENT ans = min ( ans , 1 + val ) NEW_LINE DEDENT DEDENT DEDENT if ( ans == 1000000 ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT return ans NEW_LINE DEDENT DEDENT print ( splitIntoPrimes ( ""13499315"" ) ) NEW_LINE print ( splitIntoPrimes ( ""43"" ) ) NEW_LINE +" +E1492,"import java . util . * ; class GfG { static Character findKthChar ( String s , int k ) { int len = s . length ( ) ; int i = 0 ; int total_len = 0 ; while ( i < len ) { if ( Character . isLetter ( s . charAt ( i ) ) ) { total_len ++ ; if ( total_len == k ) return s . charAt ( i ) ; i ++ ; } else { int n = 0 ; while ( i < len && ! Character . isLetter ( s . charAt ( i ) ) ) { n = n * 10 + ( s . charAt ( i ) - '0' ) ; i ++ ; } int next_total_len = total_len * n ; if ( k <= next_total_len ) { int pos = k % total_len ; if ( pos == 0 ) { pos = total_len ; } return findKthChar ( s , pos ) ; } else { total_len = next_total_len ; } } } return ' ▁ ' ; } public static void main ( String [ ] args ) { String s = "" ab2c3"" ; int k = 5 ; System . out . println ( findKthChar ( s , k ) ) ; } } +","def findKthChar ( s , k ) : NEW_LINE INDENT len1 = len ( s ) NEW_LINE i = 0 NEW_LINE total_len = 0 NEW_LINE while ( i < len1 ) : NEW_LINE INDENT if ( s [ i ] . isalpha ( ) ) : NEW_LINE INDENT total_len += 1 NEW_LINE if ( total_len == k ) : NEW_LINE INDENT return s [ i ] NEW_LINE DEDENT i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT n = 0 NEW_LINE while ( i < len1 and s [ i ] . isalpha ( ) == False ) : NEW_LINE INDENT n = n * 10 + ( ord ( s [ i ] ) - ord ( '0' ) ) NEW_LINE i += 1 NEW_LINE DEDENT next_total_len = total_len * n NEW_LINE if ( k <= next_total_len ) : NEW_LINE INDENT pos = k % total_len NEW_LINE if ( pos == 0 ) : NEW_LINE INDENT pos = total_len NEW_LINE DEDENT return findKthChar ( s , pos ) NEW_LINE DEDENT else : NEW_LINE INDENT total_len = next_total_len NEW_LINE DEDENT DEDENT DEDENT return - 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "" ab2c3"" NEW_LINE k = 5 NEW_LINE print ( findKthChar ( s , k ) ) NEW_LINE DEDENT +" +E1493,"import java . util . * ; import java . lang . * ; class GFG { static double Nth_Term ( int n ) { return ( 2 * Math . pow ( n , 3 ) - 3 * Math . pow ( n , 2 ) + n + 6 ) / 6 ; } static public void main ( String args [ ] ) { int N = 8 ; System . out . println ( Nth_Term ( N ) ) ; } } +","def Nth_Term ( n ) : NEW_LINE INDENT return ( 2 * pow ( n , 3 ) - 3 * pow ( n , 2 ) + n + 6 ) // 6 NEW_LINE DEDENT N = 8 NEW_LINE print ( Nth_Term ( N ) ) NEW_LINE +" +E1494,"import java . io . * ; class GFG { static int solve ( int [ ] A , int [ ] B , int [ ] C ) { int i , j , k ; i = A . length - 1 ; j = B . length - 1 ; k = C . length - 1 ; int min_diff , current_diff , max_term ; min_diff = Math . abs ( Math . max ( A [ i ] , Math . max ( B [ j ] , C [ k ] ) ) - Math . min ( A [ i ] , Math . min ( B [ j ] , C [ k ] ) ) ) ; while ( i != - 1 && j != - 1 && k != - 1 ) { current_diff = Math . abs ( Math . max ( A [ i ] , Math . max ( B [ j ] , C [ k ] ) ) - Math . min ( A [ i ] , Math . min ( B [ j ] , C [ k ] ) ) ) ; if ( current_diff < min_diff ) min_diff = current_diff ; max_term = Math . max ( A [ i ] , Math . max ( B [ j ] , C [ k ] ) ) ; if ( A [ i ] == max_term ) i -= 1 ; else if ( B [ j ] == max_term ) j -= 1 ; else k -= 1 ; } return min_diff ; } public static void main ( String [ ] args ) { int [ ] D = { 5 , 8 , 10 , 15 } ; int [ ] E = { 6 , 9 , 15 , 78 , 89 } ; int [ ] F = { 2 , 3 , 6 , 6 , 8 , 8 , 10 } ; System . out . println ( solve ( D , E , F ) ) ; } } +","def solve ( A , B , C ) : NEW_LINE INDENT i = len ( A ) - 1 NEW_LINE j = len ( B ) - 1 NEW_LINE k = len ( C ) - 1 NEW_LINE min_diff = abs ( max ( A [ i ] , B [ j ] , C [ k ] ) - min ( A [ i ] , B [ j ] , C [ k ] ) ) NEW_LINE while i != - 1 and j != - 1 and k != - 1 : NEW_LINE INDENT current_diff = abs ( max ( A [ i ] , B [ j ] , C [ k ] ) - min ( A [ i ] , B [ j ] , C [ k ] ) ) NEW_LINE if current_diff < min_diff : NEW_LINE INDENT min_diff = current_diff NEW_LINE DEDENT max_term = max ( A [ i ] , B [ j ] , C [ k ] ) NEW_LINE if A [ i ] == max_term : NEW_LINE INDENT i -= 1 NEW_LINE DEDENT elif B [ j ] == max_term : NEW_LINE INDENT j -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT k -= 1 NEW_LINE DEDENT DEDENT return min_diff NEW_LINE DEDENT A = [ 5 , 8 , 10 , 15 ] NEW_LINE B = [ 6 , 9 , 15 , 78 , 89 ] NEW_LINE C = [ 2 , 3 , 6 , 6 , 8 , 8 , 10 ] NEW_LINE print ( solve ( A , B , C ) ) NEW_LINE +" +E1495,"import java . util . * ; class GFG { static class Node { int data ; Node left , right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static boolean CheckPerfectTree ( Node root ) { Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root ) ; int flag = 0 ; while ( q . size ( ) > 0 ) { Node temp = q . peek ( ) ; q . remove ( ) ; if ( temp . left != null && temp . right != null ) { if ( flag == 1 ) return false ; else { q . add ( temp . left ) ; q . add ( temp . right ) ; } } else if ( temp . left == null && temp . right == null ) { flag = 1 ; } else if ( temp . left == null || temp . right == null ) return false ; } return true ; } public static void main ( String args [ ] ) { Node root = newNode ( 7 ) ; root . left = newNode ( 5 ) ; root . right = newNode ( 6 ) ; root . left . left = newNode ( 8 ) ; root . left . right = newNode ( 1 ) ; root . right . left = newNode ( 3 ) ; root . right . right = newNode ( 9 ) ; root . right . right . right = newNode ( 13 ) ; root . right . right . left = newNode ( 10 ) ; if ( CheckPerfectTree ( root ) ) System . out . printf ( "" Yes "" ) ; else System . out . printf ( "" No "" ) ; } } +","import sys NEW_LINE import math NEW_LINE class Node : NEW_LINE INDENT def __init__ ( self , data ) : NEW_LINE INDENT self . data = data NEW_LINE self . left = None NEW_LINE self . right = None NEW_LINE DEDENT DEDENT def newNode ( data ) : NEW_LINE INDENT return Node ( data ) NEW_LINE DEDENT def CheckPerfectTree ( root ) : NEW_LINE INDENT q = [ ] NEW_LINE q . append ( root ) NEW_LINE flag = 0 NEW_LINE while ( q ) : NEW_LINE INDENT temp = q [ 0 ] NEW_LINE q . pop ( 0 ) NEW_LINE if ( temp . left and temp . right ) : NEW_LINE INDENT if ( flag == 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT else : NEW_LINE INDENT q . append ( temp . left ) NEW_LINE q . append ( temp . right ) NEW_LINE DEDENT DEDENT elif ( not temp . left and not temp . right ) : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT elif ( not temp . left or not temp . right ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT root = newNode ( 7 ) NEW_LINE root . left = newNode ( 5 ) NEW_LINE root . left . left = newNode ( 8 ) NEW_LINE root . left . right = newNode ( 1 ) NEW_LINE root . right = newNode ( 6 ) NEW_LINE root . right . left = newNode ( 3 ) NEW_LINE root . right . right = newNode ( 9 ) NEW_LINE root . right . right . left = newNode ( 10 ) NEW_LINE root . right . right . right = newNode ( 13 ) NEW_LINE if CheckPerfectTree ( root ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1496,"import java . util . * ; import java . lang . * ; class GFG { static TreeSet < Integer > set = new TreeSet < Integer > ( ) ; public static void generateNumber ( int count , int a [ ] , int n , int num , int k ) { if ( count == k ) { set . add ( num ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) generateNumber ( count + 1 , a , n , num + a [ i ] , k ) ; } public static void printDistinctIntegers ( int k , int a [ ] , int n ) { generateNumber ( 0 , a , n , 0 , k ) ; System . out . print ( "" The "" + "" ▁ "" + set . size ( ) + "" ▁ "" + "" distinct ▁ integers ▁ are : ▁ "" ) ; System . out . println ( ) ; Iterator < Integer > i = set . iterator ( ) ; while ( set . isEmpty ( ) == false ) { while ( i . hasNext ( ) ) { System . out . print ( i . next ( ) + "" ▁ "" ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 8 , 17 , 5 } ; int n = arr . length ; int k = 2 ; printDistinctIntegers ( k , arr , n ) ; } } +","s = set ( ) NEW_LINE def generateNumber ( count , a , n , num , k ) : NEW_LINE INDENT if k == count : NEW_LINE INDENT s . add ( num ) NEW_LINE return NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT generateNumber ( count + 1 , a , n , num + a [ i ] , k ) NEW_LINE DEDENT DEDENT def printDistinctIntegers ( k , a , n ) : NEW_LINE INDENT generateNumber ( 0 , a , n , 0 , k ) NEW_LINE print ( "" The "" , len ( s ) , "" distinct ▁ integers ▁ are : "" ) NEW_LINE for i in sorted ( s ) : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 3 , 8 , 17 , 5 ] NEW_LINE n , k = len ( a ) , 2 NEW_LINE printDistinctIntegers ( k , a , n ) NEW_LINE DEDENT +" +E1497,"import java . util . * ; class GFG { static int findMin ( int a [ ] , int n ) { double sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Math . log ( a [ i ] ) ; int x = ( int ) Math . exp ( sum / n ) ; return x + 1 ; } public static void main ( String [ ] args ) { int a [ ] = { 3 , 2 , 1 , 4 } ; int n = a . length ; System . out . println ( findMin ( a , n ) ) ; } } +","import math as m NEW_LINE def findMin ( a , n ) : NEW_LINE INDENT _sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT _sum += m . log ( a [ i ] ) NEW_LINE DEDENT x = m . exp ( _sum / n ) NEW_LINE return int ( x + 1 ) NEW_LINE DEDENT a = [ 3 , 2 , 1 , 4 ] NEW_LINE n = len ( a ) NEW_LINE print ( findMin ( a , n ) ) NEW_LINE +" +E1498,"public class GFG { private static void printPaths ( char [ ] [ ] input , int R , int C ) { for ( int i = 0 ; i < C ; i ++ ) { dfs ( input , "" "" , 0 , i , R , C ) ; System . out . println ( ) ; } } private static void dfs ( char [ ] [ ] input , String res , int i , int j , int R , int C ) { if ( i == R ) { System . out . print ( res + "" ▁ "" ) ; return ; } res = res + input [ i ] [ j ] ; for ( int k = 0 ; k < C ; k ++ ) { dfs ( input , res , i + 1 , k , R , C ) ; if ( i + 1 == R ) { break ; } } } public static void main ( String [ ] args ) { char [ ] [ ] input = { { ' a ' , ' b ' } , { ' d ' , ' e ' } } ; int R = input . length ; int C = input [ 0 ] . length ; printPaths ( input , R , C ) ; } } +","def printPaths ( inputchar , R , C ) : NEW_LINE INDENT for i in range ( C ) : NEW_LINE INDENT dfs ( inputchar , "" "" , 0 , i , R , C ) ; NEW_LINE print ( ) NEW_LINE DEDENT DEDENT def dfs ( inputchar , res , i , j , R , C ) : NEW_LINE INDENT if ( i == R ) : NEW_LINE INDENT print ( res , end = "" ▁ "" ) ; NEW_LINE return ; NEW_LINE DEDENT res = res + inputchar [ i ] [ j ] ; NEW_LINE for k in range ( C ) : NEW_LINE INDENT dfs ( inputchar , res , i + 1 , k , R , C ) ; NEW_LINE if ( i + 1 == R ) : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT inputchar = [ [ ' a ' , ' b ' ] , [ ' d ' , ' e ' ] ] ; NEW_LINE R = len ( inputchar ) ; NEW_LINE C = len ( inputchar [ 0 ] ) ; NEW_LINE printPaths ( inputchar , R , C ) ; NEW_LINE DEDENT +" +E1499,"import java . util . * ; class GFG { static final int mod = ( int ) ( 1e9 + 7 ) ; static int power ( int a , int m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( int ) ( ( 1L * a * a ) % mod ) ; else if ( m1 % 2 == 1 ) return ( int ) ( ( 1L * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ) ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } static int factorial ( int x ) { int ans = 1 ; for ( int i = 1 ; i <= x ; i ++ ) ans = ( int ) ( ( 1L * ans * i ) % mod ) ; return ans ; } static int inverse ( int x ) { return power ( x , mod - 2 ) ; } static int binomial ( int n , int r ) { if ( r > n ) return 0 ; int ans = factorial ( n ) ; ans = ( int ) ( ( 1L * ans * inverse ( factorial ( r ) ) ) % mod ) ; ans = ( int ) ( ( 1L * ans * inverse ( factorial ( n - r ) ) ) % mod ) ; return ans ; } static int number_of_sets ( int n , int a , int b ) { int ans = power ( 2 , n ) ; ans = ans - binomial ( n , a ) ; if ( ans < 0 ) ans += mod ; ans = ans - binomial ( n , b ) ; ans -- ; if ( ans < 0 ) ans += mod ; return ans ; } public static void main ( String [ ] args ) { int N = 4 , A = 1 , B = 3 ; System . out . print ( number_of_sets ( N , A , B ) ) ; } } +","mod = 10 ** 9 + 7 NEW_LINE def power ( a , m1 ) : NEW_LINE INDENT if ( m1 == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif ( m1 == 1 ) : NEW_LINE INDENT return a NEW_LINE DEDENT elif ( m1 == 2 ) : NEW_LINE INDENT return ( a * a ) % mod NEW_LINE DEDENT elif ( m1 & 1 ) : NEW_LINE INDENT return ( a * power ( power ( a , m1 // 2 ) , 2 ) ) % mod NEW_LINE DEDENT else : NEW_LINE INDENT return power ( power ( a , m1 // 2 ) , 2 ) % mod NEW_LINE DEDENT DEDENT def factorial ( x ) : NEW_LINE INDENT ans = 1 NEW_LINE for i in range ( 1 , x + 1 ) : NEW_LINE INDENT ans = ( ans * i ) % mod NEW_LINE DEDENT return ans NEW_LINE DEDENT def inverse ( x ) : NEW_LINE INDENT return power ( x , mod - 2 ) NEW_LINE DEDENT def binomial ( n , r ) : NEW_LINE INDENT if ( r > n ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT ans = factorial ( n ) NEW_LINE ans = ( ans * inverse ( factorial ( r ) ) ) % mod NEW_LINE ans = ( ans * inverse ( factorial ( n - r ) ) ) % mod NEW_LINE return ans NEW_LINE DEDENT def number_of_sets ( n , a , b ) : NEW_LINE INDENT ans = power ( 2 , n ) NEW_LINE ans = ans - binomial ( n , a ) NEW_LINE if ( ans < 0 ) : NEW_LINE INDENT ans += mod NEW_LINE DEDENT ans = ans - binomial ( n , b ) NEW_LINE ans -= 1 NEW_LINE if ( ans < 0 ) : NEW_LINE INDENT ans += mod NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 4 NEW_LINE A = 1 NEW_LINE B = 3 NEW_LINE print ( number_of_sets ( N , A , B ) ) NEW_LINE DEDENT +" +E1500,"import java . io . * ; class GFG { public static void main ( String [ ] args ) { double n = 5 , a = 2 ; System . out . println ( sumOfSeries ( a , n ) ) ; } static double sumOfSeries ( double a , double n ) { double res = 0 , prev = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { prev *= ( a / i ) ; res = res + prev ; } return ( res ) ; } } +","from __future__ import division NEW_LINE def sumOfSeries ( a , num ) : NEW_LINE INDENT res = 0 NEW_LINE prev = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT prev *= ( a / i ) NEW_LINE res = res + prev NEW_LINE DEDENT return res NEW_LINE DEDENT n = 5 NEW_LINE a = 2 NEW_LINE print ( round ( sumOfSeries ( a , n ) , 4 ) ) NEW_LINE +" +E1501,"import java . util . HashSet ; class GFG { static int countNum ( int arr [ ] , int n ) { HashSet < Integer > s = new HashSet < > ( ) ; int count = 0 , maxm = Integer . MIN_VALUE , minm = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { s . add ( arr [ i ] ) ; if ( arr [ i ] < minm ) minm = arr [ i ] ; if ( arr [ i ] > maxm ) maxm = arr [ i ] ; } for ( int i = minm ; i <= maxm ; i ++ ) if ( ! s . contains ( i ) ) count ++ ; return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 , 8 , 6 } ; int n = arr . length ; System . out . println ( countNum ( arr , n ) ) ; } } +","def countNum ( arr , n ) : NEW_LINE INDENT s = dict ( ) NEW_LINE count , maxm , minm = 0 , - 10 ** 9 , 10 ** 9 NEW_LINE for i in range ( n ) : NEW_LINE INDENT s [ arr [ i ] ] = 1 NEW_LINE if ( arr [ i ] < minm ) : NEW_LINE INDENT minm = arr [ i ] NEW_LINE DEDENT if ( arr [ i ] > maxm ) : NEW_LINE INDENT maxm = arr [ i ] NEW_LINE DEDENT DEDENT for i in range ( minm , maxm + 1 ) : NEW_LINE INDENT if i not in s . keys ( ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 3 , 5 , 8 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countNum ( arr , n ) ) NEW_LINE +" +E1502,"import java . io . * ; public class GFG { static int MAX_CHAR = 256 ; static boolean isPresent ( String s , String q ) { int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) freq [ s . charAt ( i ) ] ++ ; for ( int i = 0 ; i < q . length ( ) ; i ++ ) { freq [ q . charAt ( i ) ] -- ; if ( freq [ q . charAt ( i ) ] < 0 ) return false ; } return true ; } static public void main ( String [ ] args ) { String s = "" abctd "" ; String q = "" cat "" ; if ( isPresent ( s , q ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","MAX_CHAR = 256 NEW_LINE def isPresent ( s , q ) : NEW_LINE INDENT freq = [ 0 ] * MAX_CHAR NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT freq [ ord ( s [ i ] ) ] += 1 NEW_LINE DEDENT for i in range ( 0 , len ( q ) ) : NEW_LINE INDENT freq [ ord ( q [ i ] ) ] -= 1 NEW_LINE if ( freq [ ord ( q [ i ] ) ] < 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT s = "" abctd "" NEW_LINE q = "" cat "" NEW_LINE if ( isPresent ( s , q ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1503,"class GFG { static double area_of_circle ( int m , int n ) { int square_of_radius = ( m * n ) / 4 ; double area = ( 3.141 * square_of_radius ) ; return area ; } public static void main ( String [ ] args ) { int n = 10 ; int m = 30 ; System . out . println ( area_of_circle ( m , n ) ) ; } } +","def area_of_circle ( m , n ) : NEW_LINE INDENT square_of_radius = ( m * n ) / 4 NEW_LINE area = ( 3.141 * square_of_radius ) NEW_LINE return area NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 NEW_LINE m = 30 NEW_LINE print ( area_of_circle ( m , n ) ) NEW_LINE DEDENT +" +E1504,"import java . io . * ; class GFG { static void printTwoSetBitNums ( int n ) { int x = 1 ; while ( n > 0 ) { int y = 0 ; while ( y < x ) { System . out . print ( ( ( 1 << x ) + ( 1 << y ) ) + "" ▁ "" ) ; n -- ; if ( n == 0 ) return ; y ++ ; } x ++ ; } } public static void main ( String [ ] args ) { int n = 4 ; printTwoSetBitNums ( n ) ; } } +","def printTwoSetBitNums ( n ) : NEW_LINE INDENT x = 1 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT y = 0 NEW_LINE while ( y < x ) : NEW_LINE INDENT print ( ( 1 << x ) + ( 1 << y ) , end = "" ▁ "" ) NEW_LINE n -= 1 NEW_LINE if ( n == 0 ) : NEW_LINE INDENT return NEW_LINE DEDENT y += 1 NEW_LINE DEDENT x += 1 NEW_LINE DEDENT DEDENT printTwoSetBitNums ( 4 ) NEW_LINE +" +E1505,"class GFG { static int binomialCoeff ( int n , int k ) { int [ ] [ ] C = new int [ n + 1 ] [ k + 1 ] ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . min ( i , k ) ; j ++ ) { if ( j == 0 || j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } static int findMax ( int n ) { return binomialCoeff ( n , n / 2 ) ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( findMax ( n ) ) ; } } +","def binomialCoeff ( n , k ) : NEW_LINE INDENT C = [ [ 0 for i in range ( k + 1 ) ] for i in range ( n + 1 ) ] NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT for j in range ( min ( i , k ) + 1 ) : NEW_LINE INDENT if ( j == 0 or j == i ) : NEW_LINE INDENT C [ i ] [ j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] NEW_LINE DEDENT DEDENT DEDENT return C [ n ] [ k ] NEW_LINE DEDENT def findMax ( n ) : NEW_LINE INDENT return binomialCoeff ( n , n // 2 ) NEW_LINE DEDENT n = 5 NEW_LINE print ( findMax ( n ) ) NEW_LINE +" +E1506,"import java . io . * ; class GFG { public static int calculateSum ( String arr [ ] , int n ) { if ( n == 0 ) return 0 ; String s = arr [ 0 ] ; int value = Integer . parseInt ( s ) ; int sum = value ; for ( int i = 2 ; i < n ; i = i + 2 ) { s = arr [ i ] ; value = Integer . parseInt ( s ) ; char operation = arr [ i - 1 ] . charAt ( 0 ) ; if ( operation == ' + ' ) sum += value ; else sum -= value ; } return sum ; } public static void main ( String [ ] args ) { String arr [ ] = { ""3"" , "" + "" , ""4"" , "" - "" , ""7"" , "" + "" , ""13"" } ; int n = arr . length ; System . out . println ( calculateSum ( arr , n ) ) ; } } +","def calculateSum ( arr , n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT s = arr [ 0 ] NEW_LINE value = int ( s ) NEW_LINE sum = value NEW_LINE for i in range ( 2 , n , 2 ) : NEW_LINE INDENT s = arr [ i ] NEW_LINE value = int ( s ) NEW_LINE operation = arr [ i - 1 ] [ 0 ] NEW_LINE if ( operation == ' + ' ) : NEW_LINE INDENT sum += value NEW_LINE DEDENT else : NEW_LINE INDENT sum -= value NEW_LINE DEDENT DEDENT return sum NEW_LINE DEDENT arr = [ ""3"" , "" + "" , ""4"" , "" - "" , ""7"" , "" + "" , ""13"" ] NEW_LINE n = len ( arr ) NEW_LINE print ( calculateSum ( arr , n ) ) NEW_LINE +" +E1507,"import java . io . * ; class GFG { static boolean checkplusperfect ( int x ) { int temp = x ; int n = 0 ; while ( x != 0 ) { x /= 10 ; n ++ ; } x = temp ; int sum = 0 ; while ( x != 0 ) { sum += Math . pow ( x % 10 , n ) ; x /= 10 ; } return ( sum == temp ) ; } public static void main ( String [ ] args ) { int x = 9474 ; if ( checkplusperfect ( x ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","import math NEW_LINE def checkplusperfect ( x ) : NEW_LINE INDENT temp = x NEW_LINE n = 0 NEW_LINE while ( x != 0 ) : NEW_LINE INDENT x = x // 10 NEW_LINE n = n + 1 NEW_LINE DEDENT x = temp NEW_LINE sm = 0 NEW_LINE while ( x != 0 ) : NEW_LINE INDENT sm = sm + ( int ) ( math . pow ( x % 10 , n ) ) NEW_LINE x = x // 10 NEW_LINE DEDENT return ( sm == temp ) NEW_LINE DEDENT x = 9474 NEW_LINE if ( checkplusperfect ( x ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1508,"import java . util . * ; class GFG { static boolean isPossible ( int arr [ ] , int p , int n , int m ) { int sum = 0 ; for ( int i = 0 ; i < p ; i ++ ) sum += arr [ i ] ; if ( sum == ( n * m ) ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 3 , m = 4 ; int arr [ ] = { 6 , 3 , 2 , 1 } ; int p = arr . length ; if ( isPossible ( arr , p , n , m ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def isPossible ( arr , p , n , m ) : NEW_LINE INDENT sum = 0 ; NEW_LINE for i in range ( p ) : NEW_LINE INDENT sum += arr [ i ] ; NEW_LINE DEDENT if ( sum == ( n * m ) ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT return False ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 ; NEW_LINE m = 4 ; NEW_LINE arr = [ 6 , 3 , 2 , 1 ] ; NEW_LINE p = len ( arr ) ; NEW_LINE if ( isPossible ( arr , p , n , m ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E1509,"class GFG { static int reverse ( int n ) { int d = 0 , s = 0 ; while ( n > 0 ) { d = n % 10 ; s = s * 10 + d ; n = n / 10 ; } return s ; } static boolean isPalin ( int n ) { return n == reverse ( n ) ; } static int sumOfArray ( int [ ] arr , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] > 10 ) && isPalin ( arr [ i ] ) ) { s += arr [ i ] ; } } return s ; } public static void main ( String [ ] args ) { int n = 6 ; int [ ] arr = { 12 , 313 , 11 , 44 , 9 , 1 } ; System . out . println ( sumOfArray ( arr , n ) ) ; } } +","def reverse ( n ) : NEW_LINE INDENT d = 0 ; s = 0 ; NEW_LINE while ( n > 0 ) : NEW_LINE INDENT d = n % 10 ; NEW_LINE s = s * 10 + d ; NEW_LINE n = n // 10 ; NEW_LINE DEDENT return s ; NEW_LINE DEDENT def isPalin ( n ) : NEW_LINE INDENT return n == reverse ( n ) ; NEW_LINE DEDENT def sumOfArray ( arr , n ) : NEW_LINE INDENT s = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( ( arr [ i ] > 10 ) and isPalin ( arr [ i ] ) ) : NEW_LINE INDENT s += arr [ i ] ; NEW_LINE DEDENT DEDENT return s ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 6 ; NEW_LINE arr = [ 12 , 313 , 11 , 44 , 9 , 1 ] ; NEW_LINE print ( sumOfArray ( arr , n ) ) ; NEW_LINE DEDENT +" +E1510,"class GFG { static int minCost ( int arr [ ] , int n ) { int count_even = 0 ; int count_odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) count_even ++ ; else count_odd ++ ; } return Math . min ( count_even , count_odd ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 3 , 1 , 5 } ; int n = arr . length ; System . out . println ( minCost ( arr , n ) ) ; } } +","def minCost ( arr , n ) : NEW_LINE INDENT count_even = 0 NEW_LINE count_odd = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] % 2 == 0 ) : NEW_LINE INDENT count_even += 1 NEW_LINE DEDENT else : NEW_LINE INDENT count_odd += 1 NEW_LINE DEDENT DEDENT return min ( count_even , count_odd ) NEW_LINE DEDENT arr = [ 2 , 4 , 3 , 1 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE print ( minCost ( arr , n ) ) NEW_LINE +" +E1511,"import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } static boolean coprime ( int a , int b ) { return ( gcd ( a , b ) == 1 ) ; } static int numOfPairs ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( coprime ( arr [ i ] , arr [ j ] ) ) count ++ ; return count ; } public static void main ( String args [ ] ) throws IOException { int arr [ ] = { 1 , 2 , 5 , 4 , 8 , 3 , 9 } ; int n = arr . length ; System . out . println ( numOfPairs ( arr , n ) ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 or b == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( a == b ) : NEW_LINE INDENT return a NEW_LINE DEDENT if ( a > b ) : NEW_LINE INDENT return gcd ( a - b , b ) NEW_LINE DEDENT return gcd ( a , b - a ) NEW_LINE DEDENT def coprime ( a , b ) : NEW_LINE INDENT return ( gcd ( a , b ) == 1 ) NEW_LINE DEDENT def numOfPairs ( arr , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( coprime ( arr [ i ] , arr [ j ] ) ) : NEW_LINE INDENT count = count + 1 NEW_LINE DEDENT DEDENT DEDENT return count NEW_LINE DEDENT arr = [ 1 , 2 , 5 , 4 , 8 , 3 , 9 ] NEW_LINE n = len ( arr ) NEW_LINE print ( numOfPairs ( arr , n ) ) NEW_LINE +" +E1512,"import java . util . * ; class GFG { static int countSubarrays ( int a [ ] , int n , int m ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int odd = 0 ; for ( int j = i ; j < n ; j ++ ) { if ( a [ j ] % 2 == 0 ) odd ++ ; if ( odd == m ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 2 , 5 , 6 , 9 , 2 , 11 } ; int n = a . length ; int m = 2 ; System . out . println ( countSubarrays ( a , n , m ) ) ; } } +","def countSubarrays ( a , n , m ) : NEW_LINE INDENT count = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT odd = 0 ; NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT if ( a [ j ] % 2 ) : NEW_LINE INDENT odd += 1 ; NEW_LINE DEDENT if ( odd == m ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT DEDENT return count ; NEW_LINE DEDENT a = [ 2 , 2 , 5 , 6 , 9 , 2 , 11 ] ; NEW_LINE n = len ( a ) ; NEW_LINE m = 2 ; NEW_LINE print ( countSubarrays ( a , n , m ) ) ; NEW_LINE +" +E1513,"import java . io . * ; public class GFG { static void divide ( int n , int m ) { System . out . println ( "" Remainder ▁ = ▁ "" + ( ( n ) & ( m - 1 ) ) ) ; System . out . println ( "" Quotient ▁ = ▁ "" + ( n >> ( int ) ( Math . log ( m ) / Math . log ( 2 ) ) ) ) ; } static public void main ( String [ ] args ) { int n = 43 , m = 8 ; divide ( n , m ) ; } } +","import math NEW_LINE def divide ( n , m ) : NEW_LINE INDENT print ( "" Remainder ▁ = ▁ "" , ( ( n ) & ( m - 1 ) ) ) NEW_LINE print ( "" Quotient ▁ = ▁ "" , ( n >> ( int ) ( math . log2 ( m ) ) ) ) NEW_LINE DEDENT n = 43 NEW_LINE m = 8 NEW_LINE divide ( n , m ) NEW_LINE +" +E1514,"import java . util . HashMap ; class GFG { static int maxlen = 100 ; public static void generateSubStrings ( String s , HashMap < String , Integer > mpp ) { int l = s . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { String temp = "" "" ; for ( int j = i ; j < l ; j ++ ) { temp += s . charAt ( j ) ; if ( mpp . containsKey ( temp ) ) { int x = mpp . get ( temp ) ; mpp . put ( temp , ++ x ) ; } else mpp . put ( temp , 1 ) ; } } } public static void binomialCoeff ( int [ ] [ ] C ) { int i , j ; for ( i = 1 ; i < 100 ; i ++ ) { for ( j = 0 ; j < 100 ; j ++ ) { if ( j == 0 || j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } } public static int answerQuery ( HashMap < String , Integer > mpp , int [ ] [ ] C , int k ) { int ans = 0 ; for ( HashMap . Entry < String , Integer > entry : mpp . entrySet ( ) ) { if ( entry . getValue ( ) >= k ) ans += C [ entry . getValue ( ) ] [ k ] ; } return ans ; } public static void main ( String [ ] args ) { String s = "" aabaab "" ; HashMap < String , Integer > mpp = new HashMap < > ( ) ; generateSubStrings ( s , mpp ) ; int [ ] [ ] C = new int [ maxlen ] [ maxlen ] ; binomialCoeff ( C ) ; int [ ] queries = { 2 , 3 , 4 } ; int q = queries . length ; for ( int i = 0 ; i < q ; i ++ ) System . out . println ( answerQuery ( mpp , C , queries [ i ] ) ) ; } } +","from collections import defaultdict NEW_LINE maxlen = 100 NEW_LINE def generateSubStrings ( s , mpp ) : NEW_LINE INDENT l = len ( s ) NEW_LINE for i in range ( 0 , l ) : NEW_LINE INDENT temp = "" "" NEW_LINE for j in range ( i , l ) : NEW_LINE INDENT temp += s [ j ] NEW_LINE mpp [ temp ] += 1 NEW_LINE DEDENT DEDENT DEDENT def binomialCoeff ( C ) : NEW_LINE INDENT for i in range ( 0 , 100 ) : NEW_LINE INDENT for j in range ( 0 , 100 ) : NEW_LINE INDENT if j == 0 or j == i : NEW_LINE INDENT C [ i ] [ j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] NEW_LINE DEDENT DEDENT DEDENT DEDENT def answerQuery ( mpp , C , k ) : NEW_LINE INDENT ans = 0 NEW_LINE for it in mpp : NEW_LINE INDENT if mpp [ it ] >= k : NEW_LINE INDENT ans += C [ mpp [ it ] ] [ k ] NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" aabaab "" NEW_LINE mpp = defaultdict ( lambda : 0 ) NEW_LINE generateSubStrings ( s , mpp ) NEW_LINE C = [ [ 0 for i in range ( maxlen ) ] for j in range ( maxlen ) ] NEW_LINE binomialCoeff ( C ) NEW_LINE queries = [ 2 , 3 , 4 ] NEW_LINE q = len ( queries ) NEW_LINE for i in range ( 0 , q ) : NEW_LINE INDENT print ( answerQuery ( mpp , C , queries [ i ] ) ) NEW_LINE DEDENT DEDENT +" +E1515,"import java . util . Arrays ; class GFG { static int findProduct ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int prod = 1 * arr [ 0 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] != arr [ i + 1 ] ) { prod = prod * arr [ i + 1 ] ; } } return prod ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 1 , 1 , 4 , 5 , 6 } ; int n = arr . length ; System . out . println ( findProduct ( arr , n ) ) ; } } +","def findProduct ( arr , n ) : NEW_LINE INDENT sorted ( arr ) NEW_LINE prod = 1 NEW_LINE for i in range ( 0 , n , 1 ) : NEW_LINE INDENT if ( arr [ i - 1 ] != arr [ i ] ) : NEW_LINE INDENT prod = prod * arr [ i ] NEW_LINE DEDENT DEDENT return prod ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 1 , 1 , 4 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE print ( findProduct ( arr , n ) ) NEW_LINE DEDENT +" +E1516,"import java . util . Arrays ; class GFG { static int SieveOfSundaram ( int n ) { int nNew = ( n - 2 ) / 2 ; boolean marked [ ] = new boolean [ nNew + 1 ] ; Arrays . fill ( marked , false ) ; for ( int i = 1 ; i <= nNew ; i ++ ) for ( int j = i ; ( i + j + 2 * i * j ) <= nNew ; j ++ ) marked [ i + j + 2 * i * j ] = true ; if ( n > 2 ) System . out . print ( 2 + "" ▁ "" ) ; for ( int i = 1 ; i <= nNew ; i ++ ) if ( marked [ i ] == false ) System . out . print ( 2 * i + 1 + "" ▁ "" ) ; return - 1 ; } public static void main ( String [ ] args ) { int n = 20 ; SieveOfSundaram ( n ) ; } } +","def SieveOfSundaram ( n ) : NEW_LINE INDENT nNew = int ( ( n - 2 ) / 2 ) ; NEW_LINE marked = [ 0 ] * ( nNew + 1 ) ; NEW_LINE for i in range ( 1 , nNew + 1 ) : NEW_LINE INDENT j = i ; NEW_LINE while ( ( i + j + 2 * i * j ) <= nNew ) : NEW_LINE INDENT marked [ i + j + 2 * i * j ] = 1 ; NEW_LINE j += 1 ; NEW_LINE DEDENT DEDENT if ( n > 2 ) : NEW_LINE INDENT print ( 2 , end = "" ▁ "" ) ; NEW_LINE DEDENT for i in range ( 1 , nNew + 1 ) : NEW_LINE INDENT if ( marked [ i ] == 0 ) : NEW_LINE INDENT print ( ( 2 * i + 1 ) , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT DEDENT n = 20 ; NEW_LINE SieveOfSundaram ( n ) ; NEW_LINE +" +E1517,"class GFG { long ll ; static void solve ( long n ) { if ( n == 1 ) { System . out . println ( - 1 ) ; } else { int num = 2 ; for ( long i = 0 ; i < n - 1 ; i ++ ) { num = ( num * 10 ) + 3 ; } System . out . println ( num ) ; } } public static void main ( String [ ] args ) { long n = 4 ; solve ( n ) ; } } +","def solve ( n ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT print ( - 1 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT num = 2 ; NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT num = ( num * 10 ) + 3 ; NEW_LINE DEDENT print ( num ) ; NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 4 ; NEW_LINE solve ( n ) ; NEW_LINE DEDENT +" +E1518,"class GFG { static int minimumOperations ( int arr [ ] , int n ) { int brr [ ] = { 0 , 0 , 0 , 0 } ; for ( int i = 0 ; i < n ; i ++ ) brr [ arr [ i ] % 4 ] ++ ; if ( ( brr [ 1 ] + 2 * brr [ 2 ] + 3 * brr [ 3 ] ) % 4 == 0 ) { int min_opr = Math . min ( brr [ 3 ] , brr [ 1 ] ) ; brr [ 3 ] -= min_opr ; brr [ 1 ] -= min_opr ; min_opr += brr [ 2 ] / 2 ; brr [ 2 ] %= 2 ; if ( brr [ 2 ] == 1 ) { min_opr += 2 ; brr [ 2 ] = 0 ; if ( brr [ 3 ] == 1 ) brr [ 3 ] -= 2 ; if ( brr [ 1 ] == 1 ) brr [ 1 ] -= 2 ; } if ( brr [ 1 ] == 1 ) min_opr += ( brr [ 1 ] / 4 ) * 3 ; if ( brr [ 3 ] == 1 ) min_opr += ( brr [ 3 ] / 4 ) * 3 ; return min_opr ; } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 1 , 2 , 3 , 8 } ; int n = arr . length ; System . out . println ( minimumOperations ( arr , n ) ) ; } } +","def minimumOperations ( arr , n ) : NEW_LINE INDENT brr = [ 0 , 0 , 0 , 0 ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT brr [ arr [ i ] % 4 ] += 1 ; NEW_LINE DEDENT if ( ( brr [ 1 ] + 2 * brr [ 2 ] + 3 * brr [ 3 ] ) % 4 == 0 ) : NEW_LINE INDENT min_opr = min ( brr [ 3 ] , brr [ 1 ] ) NEW_LINE brr [ 3 ] -= min_opr NEW_LINE brr [ 1 ] -= min_opr NEW_LINE min_opr += brr [ 2 ] // 2 NEW_LINE brr [ 2 ] %= 2 NEW_LINE if ( brr [ 2 ] ) : NEW_LINE INDENT min_opr += 2 NEW_LINE brr [ 2 ] = 0 NEW_LINE if ( brr [ 3 ] ) : NEW_LINE INDENT brr [ 3 ] -= 2 NEW_LINE DEDENT if ( brr [ 1 ] ) : NEW_LINE INDENT brr [ 1 ] -= 2 NEW_LINE DEDENT DEDENT if ( brr [ 1 ] ) : NEW_LINE INDENT min_opr += ( brr [ 1 ] // 4 ) * 3 NEW_LINE DEDENT if ( brr [ 3 ] ) : NEW_LINE INDENT min_opr += ( brr [ 3 ] // 4 ) * 3 NEW_LINE DEDENT return min_opr NEW_LINE DEDENT return - 1 NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 1 , 2 , 3 , 8 ] NEW_LINE n = len ( arr ) NEW_LINE print ( minimumOperations ( arr , n ) ) NEW_LINE +" +E1519,"import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static int minFn ( int arr [ ] ) { int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < arr . length ; i ++ ) if ( min > arr [ i ] ) min = arr [ i ] ; return min ; } static void minimizeGraph ( int arr [ ] [ ] ) { int min ; for ( int i = 0 ; i < arr . length ; i ++ ) for ( int j = 0 ; j < arr . length ; j ++ ) if ( arr [ i ] [ j ] == 0 ) arr [ i ] [ j ] = Integer . MAX_VALUE ; for ( int i = 0 ; i < arr . length ; i ++ ) { min = minFn ( arr [ i ] ) ; for ( int j = 0 ; j < arr . length ; j ++ ) { if ( ( arr [ i ] [ j ] != min ) || ( arr [ i ] [ j ] == Integer . MAX_VALUE ) ) arr [ i ] [ j ] = 0 ; else min = 0 ; } } for ( int i = 0 ; i < arr . length ; i ++ ) { for ( int j = 0 ; j < arr . length ; j ++ ) System . out . print ( arr [ i ] [ j ] + "" ▁ "" ) ; System . out . print ( "" \n "" ) ; } } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 2 , 4 , 0 } , { 0 , 0 , 0 , 5 } , { 0 , 2 , 0 , 3 } , { 0 , 0 , 0 , 0 } } ; minimizeGraph ( arr ) ; } } +","def minFn ( arr ) : NEW_LINE INDENT minimum = float ( ' inf ' ) NEW_LINE for i in range ( 0 , 4 ) : NEW_LINE INDENT if minimum > arr [ i ] : NEW_LINE INDENT minimum = arr [ i ] NEW_LINE DEDENT DEDENT return minimum NEW_LINE DEDENT def minimizeGraph ( arr ) : NEW_LINE INDENT for i in range ( 0 , 4 ) : NEW_LINE INDENT for j in range ( 0 , 4 ) : NEW_LINE INDENT if arr [ i ] [ j ] == 0 : NEW_LINE INDENT arr [ i ] [ j ] = float ( ' inf ' ) NEW_LINE DEDENT DEDENT DEDENT for i in range ( 0 , 4 ) : NEW_LINE INDENT minimum = minFn ( arr [ i ] ) NEW_LINE for j in range ( 0 , 4 ) : NEW_LINE INDENT if ( ( not ( arr [ i ] [ j ] == minimum ) ) or ( arr [ i ] [ j ] == float ( ' inf ' ) ) ) : NEW_LINE INDENT arr [ i ] [ j ] = 0 NEW_LINE DEDENT else : NEW_LINE INDENT minimum = 0 NEW_LINE DEDENT DEDENT DEDENT for i in range ( 0 , 4 ) : NEW_LINE INDENT for j in range ( 0 , 4 ) : NEW_LINE INDENT print ( arr [ i ] [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ [ 1 , 2 , 4 , 0 ] , [ 0 , 0 , 0 , 5 ] , [ 0 , 2 , 0 , 3 ] , [ 0 , 0 , 0 , 0 ] ] NEW_LINE minimizeGraph ( arr ) NEW_LINE DEDENT +" +E1520,"import java . util . * ; public class GFG { static int getNumToAdd ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int d = arr [ 1 ] - arr [ 0 ] ; int numToAdd = - 1 ; boolean numAdded = false ; for ( int i = 2 ; i < n ; i ++ ) { int diff = arr [ i ] - arr [ i - 1 ] ; if ( diff != d ) { if ( numAdded ) return - 1 ; if ( diff == 2 * d ) { numToAdd = arr [ i ] - d ; numAdded = true ; } else return - 1 ; } } if ( numToAdd == - 1 ) return ( arr [ n - 1 ] + d ) ; return numToAdd ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 7 , 11 , 13 , 15 } ; int n = arr . length ; System . out . println ( getNumToAdd ( arr , n ) ) ; } } +","def getNumToAdd ( arr , n ) : NEW_LINE INDENT arr . sort ( reverse = False ) NEW_LINE d = arr [ 1 ] - arr [ 0 ] NEW_LINE numToAdd = - 1 NEW_LINE numAdded = False NEW_LINE for i in range ( 2 , n , 1 ) : NEW_LINE INDENT diff = arr [ i ] - arr [ i - 1 ] NEW_LINE if ( diff != d ) : NEW_LINE INDENT if ( numAdded ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT if ( diff == 2 * d ) : NEW_LINE INDENT numToAdd = arr [ i ] - d NEW_LINE numAdded = True NEW_LINE DEDENT else : NEW_LINE INDENT return - 1 NEW_LINE DEDENT DEDENT DEDENT if ( numToAdd == - 1 ) : NEW_LINE INDENT return ( arr [ n - 1 ] + d ) NEW_LINE DEDENT return numToAdd NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 3 , 5 , 7 , 11 , 13 , 15 ] NEW_LINE n = len ( arr ) NEW_LINE print ( getNumToAdd ( arr , n ) ) NEW_LINE DEDENT +" +E1521,"import java . io . * ; class GFG { static double PI = 3.1415926535 ; static double findAnglesA ( double a , double b , double c ) { double A = Math . acos ( ( b * b + c * c - a * a ) / ( 2 * b * c ) ) ; return A * 180 / PI ; } static double findAnglesB ( double a , double b , double c ) { double B = Math . acos ( ( a * a + c * c - b * b ) / ( 2 * a * c ) ) ; return B * 180 / PI ; } static void printAngles ( int a , int b , int c ) { double x = ( double ) a ; double y = ( double ) b ; double z = ( double ) c ; double A = findAnglesA ( x , y , z ) ; double B = findAnglesB ( x , y , z ) ; System . out . println ( "" Angles ▁ are ▁ A ▁ = ▁ "" + A + "" , ▁ B ▁ = ▁ "" + B + "" , ▁ C ▁ = ▁ "" + 90 ) ; } static void printOtherSides ( int n ) { int b = 0 , c = 0 ; if ( ( n & 1 ) > 0 ) { if ( n == 1 ) System . out . println ( - 1 ) ; else { b = ( n * n - 1 ) / 2 ; c = ( n * n + 1 ) / 2 ; System . out . println ( "" Side ▁ b ▁ = ▁ "" + b + "" , ▁ Side ▁ c ▁ = ▁ "" + c ) ; } } else { if ( n == 2 ) System . out . println ( - 1 ) ; else { b = n * n / 4 - 1 ; c = n * n / 4 + 1 ; System . out . println ( "" Side ▁ b ▁ = ▁ "" + b + "" , ▁ Side ▁ c ▁ = ▁ "" + c ) ; } } printAngles ( n , b , c ) ; } public static void main ( String [ ] args ) { int a = 12 ; printOtherSides ( a ) ; } } +","import math NEW_LINE PI = 3.1415926535 NEW_LINE def findAnglesA ( a , b , c ) : NEW_LINE INDENT A = math . acos ( ( b * b + c * c - a * a ) / ( 2 * b * c ) ) NEW_LINE return A * 180 / PI NEW_LINE DEDENT def findAnglesB ( a , b , c ) : NEW_LINE INDENT B = math . acos ( ( a * a + c * c - b * b ) / ( 2 * a * c ) ) NEW_LINE return B * 180 / PI NEW_LINE DEDENT def printAngles ( a , b , c ) : NEW_LINE INDENT x = a NEW_LINE y = b NEW_LINE z = c NEW_LINE A = findAnglesA ( x , y , z ) NEW_LINE B = findAnglesB ( x , y , z ) NEW_LINE print ( "" Angles ▁ are ▁ A ▁ = ▁ "" , A , "" , ▁ B ▁ = ▁ "" , B , "" , ▁ C ▁ = ▁ "" , ""90 ▁ "" ) NEW_LINE DEDENT def printOtherSides ( n ) : NEW_LINE INDENT if ( n & 1 ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT print ( "" - 1"" ) NEW_LINE DEDENT else : NEW_LINE INDENT b = ( n * n - 1 ) // 2 NEW_LINE c = ( n * n + 1 ) // 2 NEW_LINE print ( "" Side ▁ b ▁ = ▁ "" , b , "" ▁ Side ▁ c ▁ = ▁ "" , c ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( n == 2 ) : NEW_LINE INDENT print ( "" - 1"" ) NEW_LINE DEDENT else : NEW_LINE INDENT b = n * n // 4 - 1 ; NEW_LINE c = n * n // 4 + 1 ; NEW_LINE print ( "" Side ▁ b ▁ = ▁ "" , b , "" , ▁ Side ▁ c ▁ = ▁ "" , c ) NEW_LINE DEDENT DEDENT printAngles ( n , b , c ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 12 NEW_LINE printOtherSides ( a ) NEW_LINE DEDENT +" +E1522,"import java . lang . * ; class GFG { static int MaximumHeight ( int a [ ] , int n ) { return ( int ) Math . floor ( ( - 1 + Math . sqrt ( 1 + ( 8 * n ) ) ) / 2 ) ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { 40 , 100 , 20 , 30 } ; int n = arr . length ; System . out . println ( MaximumHeight ( arr , n ) ) ; } } +","import math NEW_LINE def MaximumHeight ( a , n ) : NEW_LINE INDENT return ( - 1 + int ( math . sqrt ( 1 + ( 8 * n ) ) ) ) // 2 NEW_LINE DEDENT arr = [ 40 , 100 , 20 , 30 ] NEW_LINE n = len ( arr ) NEW_LINE print ( MaximumHeight ( arr , n ) ) NEW_LINE +" +E1523,"import java . util . HashMap ; class GFG { static int firstElement ( int arr [ ] , int n , int k ) { HashMap < Integer , Integer > count_map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = 0 ; if ( count_map . get ( arr [ i ] ) != null ) { a = count_map . get ( arr [ i ] ) ; } count_map . put ( arr [ i ] , a + 1 ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( count_map . get ( arr [ i ] ) == k ) { return arr [ i ] ; } } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 7 , 4 , 3 , 4 , 8 , 7 } ; int n = arr . length ; int k = 2 ; System . out . println ( firstElement ( arr , n , k ) ) ; } } +","def firstElement ( arr , n , k ) : NEW_LINE INDENT count_map = { } ; NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( arr [ i ] in count_map . keys ( ) ) : NEW_LINE INDENT count_map [ arr [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT count_map [ arr [ i ] ] = 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT for i in range ( 0 , n ) : NEW_LINE INDENT if ( count_map [ arr [ i ] ] == k ) : NEW_LINE INDENT return arr [ i ] NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return - 1 NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 7 , 4 , 3 , 4 , 8 , 7 ] ; NEW_LINE n = len ( arr ) NEW_LINE k = 2 NEW_LINE print ( firstElement ( arr , n , k ) ) NEW_LINE DEDENT +" +E1524,"class Subarray { static int calculate ( int a [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int r = i + 1 ; for ( int j = r ; j < n ; j ++ ) { if ( a [ i ] == a [ j ] ) r += 1 ; else break ; } int d = r - i ; ans += ( d * ( d + 1 ) / 2 ) ; i = r - 1 ; } return ans ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 4 , 5 , 3 , 3 , 3 } ; System . out . println ( calculate ( a , a . length ) ) ; } } +","def calculate ( a , n ) : NEW_LINE INDENT ans = 0 ; NEW_LINE i = 0 ; NEW_LINE while ( i < n ) : NEW_LINE INDENT r = i + 1 ; NEW_LINE for j in range ( r , n ) : NEW_LINE INDENT if ( a [ i ] == a [ j ] ) : NEW_LINE INDENT r = r + 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT d = r - i ; NEW_LINE ans = ans + ( d * ( d + 1 ) / 2 ) ; NEW_LINE i = r - 1 ; NEW_LINE i = i + 1 ; NEW_LINE DEDENT return int ( ans ) ; NEW_LINE DEDENT a = [ 2 , 4 , 5 , 3 , 3 , 3 ] ; NEW_LINE n = len ( a ) ; NEW_LINE print ( calculate ( a , n ) ) ; NEW_LINE +" +E1525,"import java . util . * ; class GFG { static int nth_group ( int n ) { return n * ( 2 * ( int ) Math . pow ( n , 2 ) + 1 ) ; } public static void main ( String arr [ ] ) { int N = 5 ; System . out . println ( nth_group ( N ) ) ; } } +","def nth_group ( n ) : NEW_LINE INDENT return n * ( 2 * pow ( n , 2 ) + 1 ) NEW_LINE DEDENT N = 5 NEW_LINE print ( nth_group ( N ) ) NEW_LINE +" +E1526,"import java . util . Arrays ; import java . util . Comparator ; public class GFG { static class Word { String str ; int index ; Word ( String str , int index ) { this . str = str ; this . index = index ; } } static class DupArray { Word [ ] array ; int size ; public DupArray ( String str [ ] , int size ) { this . size = size ; array = new Word [ size ] ; int i ; for ( i = 0 ; i < size ; ++ i ) { array [ i ] = new Word ( str [ i ] , i ) ; } } } static class compStr implements Comparator < Word > { public int compare ( Word a , Word b ) { return a . str . compareTo ( b . str ) ; } } static void printAnagramsTogether ( String wordArr [ ] , int size ) { DupArray dupArray = new DupArray ( wordArr , size ) ; int i ; for ( i = 0 ; i < size ; ++ i ) { char [ ] char_arr = dupArray . array [ i ] . str . toCharArray ( ) ; Arrays . sort ( char_arr ) ; dupArray . array [ i ] . str = new String ( char_arr ) ; } Arrays . sort ( dupArray . array , new compStr ( ) ) ; for ( i = 0 ; i < size ; ++ i ) System . out . print ( wordArr [ dupArray . array [ i ] . index ] + "" ▁ "" ) ; } public static void main ( String args [ ] ) { String wordArr [ ] = { "" cat "" , "" dog "" , "" tac "" , "" god "" , "" act "" } ; int size = wordArr . length ; printAnagramsTogether ( wordArr , size ) ; } } +","class Word ( object ) : NEW_LINE INDENT def __init__ ( self , string , index ) : NEW_LINE INDENT self . string = string NEW_LINE self . index = index NEW_LINE DEDENT DEDENT def createDupArray ( string , size ) : NEW_LINE INDENT dupArray = [ ] NEW_LINE for i in xrange ( size ) : NEW_LINE INDENT dupArray . append ( Word ( string [ i ] , i ) ) NEW_LINE DEDENT return dupArray NEW_LINE DEDENT def printAnagramsTogether ( wordArr , size ) : NEW_LINE INDENT dupArray = createDupArray ( wordArr , size ) NEW_LINE for i in xrange ( size ) : NEW_LINE INDENT dupArray [ i ] . string = ' ' . join ( sorted ( dupArray [ i ] . string ) ) NEW_LINE DEDENT dupArray = sorted ( dupArray , key = lambda k : k . string ) NEW_LINE for word in dupArray : NEW_LINE INDENT print wordArr [ word . index ] , NEW_LINE DEDENT DEDENT wordArr = [ "" cat "" , "" dog "" , "" tac "" , "" god "" , "" act "" ] NEW_LINE size = len ( wordArr ) NEW_LINE printAnagramsTogether ( wordArr , size ) NEW_LINE +" +E1527,"import java . util . * ; import java . lang . * ; class Main { static void minAbsSumPair ( int arr [ ] , int n ) { int sum , min_sum = 999999 ; int l = 0 , r = n - 1 ; int min_l = l , min_r = n - 1 ; if ( n < 2 ) { System . out . println ( "" Invalid ▁ Input "" ) ; return ; } sort ( arr , l , r ) ; while ( l < r ) { sum = arr [ l ] + arr [ r ] ; if ( Math . abs ( sum ) < Math . abs ( min_sum ) ) { min_sum = sum ; min_l = l ; min_r = r ; } if ( sum < 0 ) l ++ ; else r -- ; } System . out . println ( "" ▁ The ▁ two ▁ elements ▁ whose ▁ "" + "" sum ▁ is ▁ minimum ▁ are ▁ "" + arr [ min_l ] + "" ▁ and ▁ "" + arr [ min_r ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 60 , - 10 , 70 , - 80 , 85 } ; int n = arr . length ; minAbsSumPair ( arr , n ) ; } static int partition ( int arr [ ] , int low , int high ) { int pivot = arr [ high ] ; int i = ( low - 1 ) ; for ( int j = low ; j < high ; j ++ ) { if ( arr [ j ] <= pivot ) { i ++ ; int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } int temp = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = temp ; return i + 1 ; } static void sort ( int arr [ ] , int low , int high ) { if ( low < high ) { int pi = partition ( arr , low , high ) ; sort ( arr , low , pi - 1 ) ; sort ( arr , pi + 1 , high ) ; } } } +","def partition ( arr , si , ei ) : NEW_LINE INDENT x = arr [ ei ] NEW_LINE i = ( si - 1 ) NEW_LINE for j in range ( si , ei ) : NEW_LINE INDENT if ( arr [ j ] <= x ) : NEW_LINE INDENT i += 1 NEW_LINE arr [ i ] , arr [ j ] = arr [ j ] , arr [ i ] NEW_LINE DEDENT DEDENT arr [ i + 1 ] , arr [ ei ] = arr [ ei ] , arr [ i + 1 ] NEW_LINE return ( i + 1 ) NEW_LINE DEDENT def quickSort ( arr , si , ei ) : NEW_LINE INDENT pi = 0 NEW_LINE if ( si < ei ) : NEW_LINE INDENT pi = partition ( arr , si , ei ) NEW_LINE quickSort ( arr , si , pi - 1 ) NEW_LINE quickSort ( arr , pi + 1 , ei ) NEW_LINE DEDENT DEDENT def minAbsSumPair ( arr , n ) : NEW_LINE INDENT sum , min_sum = 0 , 10 ** 9 NEW_LINE l = 0 NEW_LINE r = n - 1 NEW_LINE min_l = l NEW_LINE min_r = n - 1 NEW_LINE if ( n < 2 ) : NEW_LINE INDENT print ( "" Invalid ▁ Input "" , end = "" "" ) NEW_LINE return NEW_LINE DEDENT quickSort ( arr , l , r ) NEW_LINE while ( l < r ) : NEW_LINE INDENT sum = arr [ l ] + arr [ r ] NEW_LINE if ( abs ( sum ) < abs ( min_sum ) ) : NEW_LINE INDENT min_sum = sum NEW_LINE min_l = l NEW_LINE min_r = r NEW_LINE DEDENT if ( sum < 0 ) : NEW_LINE INDENT l += 1 NEW_LINE DEDENT else : NEW_LINE INDENT r -= 1 NEW_LINE DEDENT DEDENT print ( "" The ▁ two ▁ elements ▁ whose ▁ sum ▁ is ▁ minimum ▁ are "" , arr [ min_l ] , "" and "" , arr [ min_r ] ) NEW_LINE DEDENT arr = [ 1 , 60 , - 10 , 70 , - 80 , 85 ] NEW_LINE n = len ( arr ) NEW_LINE minAbsSumPair ( arr , n ) NEW_LINE +" +E1528,"import java . util . * ; class GFG { static void countFreq ( int arr [ ] , int n ) { Map < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) == null ? 1 : mp . get ( arr [ i ] ) + 1 ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( mp . get ( arr [ i ] ) != - 1 ) { System . out . println ( arr [ i ] + "" ▁ "" + mp . get ( arr [ i ] ) ) ; mp . put ( arr [ i ] , - 1 ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 20 , 20 , 10 , 10 , 20 , 5 , 20 } ; int n = arr . length ; countFreq ( arr , n ) ; } } +","def countFreq ( arr , n ) : NEW_LINE INDENT mp = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT if arr [ i ] not in mp : NEW_LINE INDENT mp [ arr [ i ] ] = 0 NEW_LINE DEDENT mp [ arr [ i ] ] += 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( mp [ arr [ i ] ] != - 1 ) : NEW_LINE INDENT print ( arr [ i ] , mp [ arr [ i ] ] ) NEW_LINE DEDENT mp [ arr [ i ] ] = - 1 NEW_LINE DEDENT DEDENT arr = [ 10 , 20 , 20 , 10 , 10 , 20 , 5 , 20 ] NEW_LINE n = len ( arr ) NEW_LINE countFreq ( arr , n ) NEW_LINE +" +E1529,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static boolean isPerfectSquare ( double x ) { double sr = Math . sqrt ( x ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } static boolean isFibonacci ( int n ) { return isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ; } static int totalPairs ( int a [ ] , int b [ ] , int n , int m ) { List < pair > s = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( isFibonacci ( a [ i ] + b [ j ] ) == true ) { if ( a [ i ] < b [ j ] ) { if ( checkDuplicate ( s , new pair ( a [ i ] , b [ j ] ) ) ) s . add ( new pair ( a [ i ] , b [ j ] ) ) ; } else { if ( checkDuplicate ( s , new pair ( b [ j ] , a [ i ] ) ) ) s . add ( new pair ( b [ j ] , a [ i ] ) ) ; } } } } return s . size ( ) ; } static boolean checkDuplicate ( List < pair > pairList , pair newPair ) { for ( pair p : pairList ) { if ( p . first == newPair . first && p . second == newPair . second ) return false ; } return true ; } public static void main ( String [ ] args ) { int a [ ] = { 99 , 1 , 33 , 2 } ; int b [ ] = { 1 , 11 , 2 } ; int n = a . length ; int m = b . length ; System . out . println ( totalPairs ( a , b , n , m ) ) ; } } +","from math import sqrt , floor NEW_LINE def isPerfectSquare ( x ) : NEW_LINE INDENT sr = sqrt ( x ) NEW_LINE return ( ( sr - floor ( sr ) ) == 0 ) NEW_LINE DEDENT def isFibonacci ( n ) : NEW_LINE INDENT return ( isPerfectSquare ( 5 * n * n + 4 ) or isPerfectSquare ( 5 * n * n - 4 ) ) NEW_LINE DEDENT def totalPairs ( a , b , n , m ) : NEW_LINE INDENT s = set ( ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if ( isFibonacci ( a [ i ] + b [ j ] ) == True ) : NEW_LINE INDENT if ( a [ i ] < b [ j ] ) : NEW_LINE INDENT s . add ( ( a [ i ] , b [ j ] ) ) ; NEW_LINE DEDENT else : NEW_LINE INDENT s . add ( ( b [ j ] , a [ i ] ) ) ; NEW_LINE DEDENT DEDENT DEDENT DEDENT return len ( s ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ 99 , 1 , 33 , 2 ] ; NEW_LINE b = [ 1 , 11 , 2 ] ; NEW_LINE n = len ( a ) ; NEW_LINE m = len ( b ) ; NEW_LINE print ( totalPairs ( a , b , n , m ) ) ; NEW_LINE DEDENT +" +E1530,"import java . io . * ; class GFG { static int countSolutions ( int n ) { int res = 0 ; for ( int x = 0 ; x * x < n ; x ++ ) for ( int y = 0 ; x * x + y * y < n ; y ++ ) res ++ ; return res ; } public static void main ( String args [ ] ) { System . out . println ( "" Total ▁ Number ▁ of ▁ distinct ▁ Non - Negative ▁ pairs ▁ is ▁ "" + countSolutions ( 6 ) ) ; } } +","def countSolutions ( n ) : NEW_LINE INDENT res = 0 NEW_LINE x = 0 NEW_LINE while ( x * x < n ) : NEW_LINE INDENT y = 0 NEW_LINE while ( x * x + y * y < n ) : NEW_LINE INDENT res = res + 1 NEW_LINE y = y + 1 NEW_LINE DEDENT x = x + 1 NEW_LINE DEDENT return res NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( "" Total ▁ Number ▁ of ▁ distinct ▁ Non - Negative ▁ pairs ▁ is ▁ "" , countSolutions ( 6 ) ) NEW_LINE DEDENT +" +E1531,"class GFG { static int findLength ( String str , int n ) { int ans = 0 ; for ( int i = 0 ; i <= n - 2 ; i ++ ) { int l = i , r = i + 1 ; int lsum = 0 , rsum = 0 ; while ( r < n && l >= 0 ) { lsum += str . charAt ( l ) - '0' ; rsum += str . charAt ( r ) - '0' ; if ( lsum == rsum ) { ans = Math . max ( ans , r - l + 1 ) ; } l -- ; r ++ ; } } return ans ; } static public void main ( String [ ] args ) { String str = ""123123"" ; System . out . println ( "" Length ▁ of ▁ the ▁ substring ▁ is ▁ "" + findLength ( str , str . length ( ) ) ) ; } } +","def findLength ( st , n ) : NEW_LINE INDENT total = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT total [ i ] = ( total [ i - 1 ] + int ( st [ i - 1 ] ) - int ( '0' ) ) NEW_LINE DEDENT ans = 0 NEW_LINE l = 2 NEW_LINE while ( l <= n ) : NEW_LINE INDENT for i in range ( n - l + 1 ) : NEW_LINE INDENT j = i + l - 1 NEW_LINE if ( total [ i + int ( l / 2 ) ] - total [ i ] == total [ i + l ] - total [ i + int ( l / 2 ) ] ) : NEW_LINE INDENT ans = max ( ans , l ) NEW_LINE DEDENT DEDENT l = l + 2 NEW_LINE DEDENT return ans NEW_LINE DEDENT st = ""123123"" NEW_LINE print ( "" Length ▁ of ▁ the ▁ substring ▁ is "" , findLength ( st , len ( st ) ) ) NEW_LINE +" +E1532,"class LargestSubArray2 { int min ( int x , int y ) { return ( x < y ) ? x : y ; } int max ( int x , int y ) { return ( x > y ) ? x : y ; } int findLength ( int arr [ ] , int n ) { int max_len = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int mn = arr [ i ] , mx = arr [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { mn = min ( mn , arr [ j ] ) ; mx = max ( mx , arr [ j ] ) ; if ( ( mx - mn ) == j - i ) max_len = max ( max_len , mx - mn + 1 ) ; } } return max_len ; } public static void main ( String [ ] args ) { LargestSubArray2 large = new LargestSubArray2 ( ) ; int arr [ ] = { 1 , 56 , 58 , 57 , 90 , 92 , 94 , 93 , 91 , 45 } ; int n = arr . length ; System . out . println ( "" Length ▁ of ▁ the ▁ longest ▁ contiguous ▁ subarray ▁ is ▁ "" + large . findLength ( arr , n ) ) ; } } +","def min ( x , y ) : NEW_LINE INDENT return x if ( x < y ) else y NEW_LINE DEDENT def max ( x , y ) : NEW_LINE INDENT return x if ( x > y ) else y NEW_LINE DEDENT def findLength ( arr , n ) : NEW_LINE INDENT max_len = 1 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT mn = arr [ i ] NEW_LINE mx = arr [ i ] NEW_LINE for j in range ( i + 1 , n ) : NEW_LINE INDENT mn = min ( mn , arr [ j ] ) NEW_LINE mx = max ( mx , arr [ j ] ) NEW_LINE if ( ( mx - mn ) == j - i ) : NEW_LINE INDENT max_len = max ( max_len , mx - mn + 1 ) NEW_LINE DEDENT DEDENT DEDENT return max_len NEW_LINE DEDENT arr = [ 1 , 56 , 58 , 57 , 90 , 92 , 94 , 93 , 91 , 45 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Length ▁ of ▁ the ▁ longest ▁ contiguous ▁ subarray ▁ is ▁ "" , findLength ( arr , n ) ) NEW_LINE +" +E1533,"import java . io . * ; class GFG { static void findCombinationsUtil ( int arr [ ] , int index , int num , int reducedNum ) { if ( reducedNum < 0 ) return ; if ( reducedNum == 0 ) { for ( int i = 0 ; i < index ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; System . out . println ( ) ; return ; } int prev = ( index == 0 ) ? 1 : arr [ index - 1 ] ; for ( int k = prev ; k <= num ; k ++ ) { arr [ index ] = k ; findCombinationsUtil ( arr , index + 1 , num , reducedNum - k ) ; } } static void findCombinations ( int n ) { int arr [ ] = new int [ n ] ; findCombinationsUtil ( arr , 0 , n , n ) ; } public static void main ( String [ ] args ) { int n = 5 ; findCombinations ( n ) ; } } +","def findCombinationsUtil ( arr , index , num , reducedNum ) : NEW_LINE INDENT if ( reducedNum < 0 ) : NEW_LINE INDENT return ; NEW_LINE DEDENT if ( reducedNum == 0 ) : NEW_LINE INDENT for i in range ( index ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT print ( "" "" ) ; NEW_LINE return ; NEW_LINE DEDENT prev = 1 if ( index == 0 ) else arr [ index - 1 ] ; NEW_LINE for k in range ( prev , num + 1 ) : NEW_LINE INDENT arr [ index ] = k ; NEW_LINE findCombinationsUtil ( arr , index + 1 , num , reducedNum - k ) ; NEW_LINE DEDENT DEDENT def findCombinations ( n ) : NEW_LINE INDENT arr = [ 0 ] * n ; NEW_LINE findCombinationsUtil ( arr , 0 , n , n ) ; NEW_LINE DEDENT n = 5 ; NEW_LINE findCombinations ( n ) ; NEW_LINE +" +E1534,"class GFG { static int fib ( int n ) { double phi = ( 1 + Math . sqrt ( 5 ) ) / 2 ; return ( int ) Math . round ( Math . pow ( phi , n ) / Math . sqrt ( 5 ) ) ; } static int calculateSum ( int l , int r ) { int sum = fib ( r + 2 ) - fib ( l + 1 ) ; return sum ; } public static void main ( String [ ] args ) { int l = 4 , r = 8 ; System . out . println ( calculateSum ( l , r ) ) ; } } +","import math NEW_LINE def fib ( n ) : NEW_LINE INDENT phi = ( 1 + math . sqrt ( 5 ) ) / 2 ; NEW_LINE return int ( round ( pow ( phi , n ) / math . sqrt ( 5 ) ) ) ; NEW_LINE DEDENT def calculateSum ( l , r ) : NEW_LINE INDENT sum = fib ( r + 2 ) - fib ( l + 1 ) ; NEW_LINE return sum ; NEW_LINE DEDENT l = 4 ; NEW_LINE r = 8 ; NEW_LINE print ( calculateSum ( l , r ) ) ; NEW_LINE +" +E1535,"import java . io . * ; class GFG { static void MinimumValue ( int x , int y ) { if ( x > y ) { int temp = x ; x = y ; y = temp ; } int a = 1 ; int b = x - 1 ; int c = y - b ; System . out . print ( a + "" ▁ "" + b + "" ▁ "" + c ) ; } public static void main ( String [ ] args ) { int x = 123 , y = 13 ; MinimumValue ( x , y ) ; } } +","def MinimumValue ( x , y ) : NEW_LINE INDENT if ( x > y ) : NEW_LINE INDENT x , y = y , x NEW_LINE DEDENT a = 1 NEW_LINE b = x - 1 NEW_LINE c = y - b NEW_LINE print ( a , b , c ) NEW_LINE DEDENT x = 123 NEW_LINE y = 13 NEW_LINE MinimumValue ( x , y ) NEW_LINE +" +E1536,"class GFG { static int maximumChars ( String str ) { int n = str . length ( ) ; int res = - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( str . charAt ( i ) == str . charAt ( j ) ) res = Math . max ( res , Math . abs ( j - i - 1 ) ) ; return res ; } public static void main ( String [ ] args ) { String str = "" abba "" ; System . out . println ( maximumChars ( str ) ) ; } } +","def maximumChars ( str ) : NEW_LINE INDENT n = len ( str ) NEW_LINE res = - 1 NEW_LINE for i in range ( 0 , n - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if ( str [ i ] == str [ j ] ) : NEW_LINE INDENT res = max ( res , abs ( j - i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = "" abba "" NEW_LINE print ( maximumChars ( str ) ) NEW_LINE DEDENT +" +E1537,"import java . io . * ; class GFG { static int printTribRec ( int n ) { if ( n == 0 || n == 1 || n == 2 ) return 0 ; if ( n == 3 ) return 1 ; else return printTribRec ( n - 1 ) + printTribRec ( n - 2 ) + printTribRec ( n - 3 ) ; } static void printTrib ( int n ) { for ( int i = 1 ; i < n ; i ++ ) System . out . print ( printTribRec ( i ) + "" ▁ "" ) ; } public static void main ( String args [ ] ) { int n = 10 ; printTrib ( n ) ; } } +","def printTribRec ( n ) : NEW_LINE INDENT if ( n == 0 or n == 1 or n == 2 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif ( n == 3 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return ( printTribRec ( n - 1 ) + printTribRec ( n - 2 ) + printTribRec ( n - 3 ) ) NEW_LINE DEDENT DEDENT def printTrib ( n ) : NEW_LINE INDENT for i in range ( 1 , n ) : NEW_LINE INDENT print ( printTribRec ( i ) , "" ▁ "" , end = "" "" ) NEW_LINE DEDENT DEDENT n = 10 NEW_LINE printTrib ( n ) NEW_LINE +" +E1538,"import java . io . * ; class GFG { static int steps ( int N , int M ) { if ( N == 1 ) return 0 ; else if ( N == 2 ) return M ; return 2 * M + ( N - 3 ) ; } public static void main ( String [ ] args ) { int N = 4 , M = 4 ; System . out . print ( steps ( N , M ) ) ; } } +","def steps ( N , M ) : NEW_LINE INDENT if ( N == 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif ( N == 2 ) : NEW_LINE INDENT return M NEW_LINE DEDENT return 2 * M + ( N - 3 ) NEW_LINE DEDENT N = 4 NEW_LINE M = 4 NEW_LINE print ( steps ( N , M ) ) NEW_LINE +" +E1539,"import java . util . * ; class solution { static int waysToKAdjacentSetBits ( int n , int k , int currentIndex , int adjacentSetBits , int lastBit ) { if ( currentIndex == n ) { if ( adjacentSetBits == k ) return 1 ; return 0 ; } int noOfWays = 0 ; if ( lastBit == 1 ) { noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits + 1 , 1 ) ; noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits , 0 ) ; } else if ( lastBit == 0 ) { noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits , 1 ) ; noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits , 0 ) ; } return noOfWays ; } public static void main ( String args [ ] ) { int n = 5 , k = 2 ; int totalWays = waysToKAdjacentSetBits ( n , k , 1 , 0 , 1 ) + waysToKAdjacentSetBits ( n , k , 1 , 0 , 0 ) ; System . out . println ( "" Number ▁ of ▁ ways ▁ = ▁ "" + totalWays ) ; } } +","def waysToKAdjacentSetBits ( n , k , currentIndex , adjacentSetBits , lastBit ) : NEW_LINE INDENT if ( currentIndex == n ) : NEW_LINE INDENT if ( adjacentSetBits == k ) : NEW_LINE INDENT return 1 ; NEW_LINE DEDENT return 0 NEW_LINE DEDENT noOfWays = 0 NEW_LINE if ( lastBit == 1 ) : NEW_LINE INDENT noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits + 1 , 1 ) ; NEW_LINE noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits , 0 ) ; NEW_LINE DEDENT elif ( lastBit != 1 ) : NEW_LINE INDENT noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits , 1 ) ; NEW_LINE noOfWays += waysToKAdjacentSetBits ( n , k , currentIndex + 1 , adjacentSetBits , 0 ) ; NEW_LINE DEDENT return noOfWays ; NEW_LINE DEDENT n = 5 ; k = 2 ; NEW_LINE totalWays = ( waysToKAdjacentSetBits ( n , k , 1 , 0 , 1 ) + waysToKAdjacentSetBits ( n , k , 1 , 0 , 0 ) ) ; NEW_LINE print ( "" Number ▁ of ▁ ways ▁ = "" , totalWays ) ; NEW_LINE +" +E1540,"import java . util . * ; class GFG { static boolean canPlace ( int a [ ] , int n , int p , int sep ) { int prisoners_placed = 1 ; int last_prisoner_placed = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { int current_cell = a [ i ] ; if ( current_cell - last_prisoner_placed >= sep ) { prisoners_placed ++ ; last_prisoner_placed = current_cell ; if ( prisoners_placed == p ) { return true ; } } } return false ; } static int maxDistance ( int cell [ ] , int n , int p ) { Arrays . sort ( cell ) ; int start = 0 ; int end = cell [ n - 1 ] - cell [ 0 ] ; int ans = 0 ; while ( start <= end ) { int mid = start + ( ( end - start ) / 2 ) ; if ( canPlace ( cell , n , p , mid ) ) { ans = mid ; start = mid + 1 ; } else { end = mid - 1 ; } } return ans ; } public static void main ( String [ ] args ) { int cell [ ] = { 1 , 2 , 8 , 4 , 9 } ; int n = cell . length ; int p = 3 ; System . out . println ( maxDistance ( cell , n , p ) ) ; } } +","def canPlace ( a , n , p , sep ) : NEW_LINE INDENT prisoners_placed = 1 NEW_LINE last_prisoner_placed = a [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT current_cell = a [ i ] NEW_LINE if ( current_cell - last_prisoner_placed >= sep ) : NEW_LINE INDENT prisoners_placed += 1 NEW_LINE last_prisoner_placed = current_cell NEW_LINE if ( prisoners_placed == p ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT return False NEW_LINE DEDENT def maxDistance ( cell , n , p ) : NEW_LINE INDENT cell = sorted ( cell ) NEW_LINE start = 0 NEW_LINE end = cell [ n - 1 ] - cell [ 0 ] NEW_LINE ans = 0 NEW_LINE while ( start <= end ) : NEW_LINE INDENT mid = start + ( ( end - start ) // 2 ) NEW_LINE if ( canPlace ( cell , n , p , mid ) ) : NEW_LINE INDENT ans = mid NEW_LINE start = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT end = mid - 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT cell = [ 1 , 2 , 8 , 4 , 9 ] NEW_LINE n = len ( cell ) NEW_LINE p = 3 NEW_LINE print ( maxDistance ( cell , n , p ) ) NEW_LINE +" +E1541,"class GFG { static boolean containsElement ( int [ ] arr , int n ) { int xorArr = 0 ; for ( int i = 0 ; i < n ; ++ i ) xorArr ^= arr [ i ] ; for ( int i = 0 ; i < n ; ++ i ) { int x = xorArr ^ arr [ i ] ; if ( arr [ i ] == x ) return true ; } return false ; } public static void main ( String [ ] args ) { int [ ] arr = { 8 , 2 , 4 , 15 , 1 } ; int n = arr . length ; if ( containsElement ( arr , n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def containsElement ( arr , n ) : NEW_LINE INDENT xorArr = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT xorArr ^= arr [ i ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT x = xorArr ^ arr [ i ] NEW_LINE if ( arr [ i ] == x ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT arr = [ 8 , 2 , 4 , 15 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE if ( containsElement ( arr , n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1542,"import java . util . * ; class GFG { static void solve ( String s ) { HashMap < Character , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( m . containsKey ( s . charAt ( i ) ) ) m . put ( s . charAt ( i ) , m . get ( s . charAt ( i ) ) + 1 ) ; else m . put ( s . charAt ( i ) , 1 ) ; } String new_string = "" "" ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( m . get ( s . charAt ( i ) ) % 2 == 0 ) continue ; new_string = new_string + s . charAt ( i ) ; } System . out . println ( new_string ) ; } public static void main ( String [ ] args ) { String s = "" aabbbddeeecc "" ; solve ( s ) ; } } +","def solve ( s ) : NEW_LINE INDENT m = dict ( ) NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] in m : NEW_LINE INDENT m [ s [ i ] ] = m [ s [ i ] ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT m [ s [ i ] ] = 1 NEW_LINE DEDENT DEDENT new_string = "" "" NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if m [ s [ i ] ] % 2 == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT new_string = new_string + s [ i ] NEW_LINE DEDENT print ( new_string ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "" aabbbddeeecc "" NEW_LINE solve ( s ) NEW_LINE DEDENT +" +E1543,"import java . io . * ; public class GFG { static int getTotalXorOfSubarrayXors ( int arr [ ] , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int freq = ( i + 1 ) * ( N - i ) ; if ( freq % 2 == 1 ) res = res ^ arr [ i ] ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 , 2 , 4 , 6 } ; int N = arr . length ; System . out . println ( getTotalXorOfSubarrayXors ( arr , N ) ) ; } } +","def getTotalXorOfSubarrayXors ( arr , N ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT freq = ( i + 1 ) * ( N - i ) NEW_LINE if ( freq % 2 == 1 ) : NEW_LINE INDENT res = res ^ arr [ i ] NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT arr = [ 3 , 5 , 2 , 4 , 6 ] NEW_LINE N = len ( arr ) NEW_LINE print ( getTotalXorOfSubarrayXors ( arr , N ) ) NEW_LINE +" +E1544,"class GFG { static int sum ( int N ) { int S1 , S2 , S3 ; S1 = ( ( N / 3 ) ) * ( 2 * 3 + ( N / 3 - 1 ) * 3 ) / 2 ; S2 = ( ( N / 4 ) ) * ( 2 * 4 + ( N / 4 - 1 ) * 4 ) / 2 ; S3 = ( ( N / 12 ) ) * ( 2 * 12 + ( N / 12 - 1 ) * 12 ) / 2 ; return S1 + S2 - S3 ; } public static void main ( String [ ] args ) { int N = 20 ; System . out . print ( sum ( 12 ) ) ; } } +","def sum ( N ) : NEW_LINE INDENT global S1 , S2 , S3 NEW_LINE S1 = ( ( ( N // 3 ) ) * ( 2 * 3 + ( N // 3 - 1 ) * 3 ) // 2 ) NEW_LINE S2 = ( ( ( N // 4 ) ) * ( 2 * 4 + ( N // 4 - 1 ) * 4 ) // 2 ) NEW_LINE S3 = ( ( ( N // 12 ) ) * ( 2 * 12 + ( N // 12 - 1 ) * 12 ) // 2 ) NEW_LINE return int ( S1 + S2 - S3 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 12 NEW_LINE print ( sum ( N ) ) NEW_LINE DEDENT +" +E1545,"public static int count ( int S [ ] , int m , int n ) { int table [ ] = new int [ n + 1 ] ; table [ 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = S [ i ] ; j <= n ; j ++ ) table [ j ] += table [ j - S [ i ] ] ; return table [ n ] ; } +","def count ( S , m , n ) : NEW_LINE INDENT table = [ 0 for k in range ( n + 1 ) ] NEW_LINE table [ 0 ] = 1 NEW_LINE for i in range ( 0 , m ) : NEW_LINE INDENT for j in range ( S [ i ] , n + 1 ) : NEW_LINE INDENT table [ j ] += table [ j - S [ i ] ] NEW_LINE DEDENT DEDENT return table [ n ] NEW_LINE DEDENT arr = [ 1 , 2 , 3 ] NEW_LINE m = len ( arr ) NEW_LINE n = 4 NEW_LINE x = count ( arr , m , n ) NEW_LINE print ( x ) NEW_LINE +" +E1546,"import java . io . * ; class GFG { static int countSolutions ( int a ) { int count = Integer . bitCount ( a ) ; count = ( int ) Math . pow ( 2 , count ) ; return count ; } public static void main ( String [ ] args ) { int a = 3 ; System . out . println ( countSolutions ( a ) ) ; } } +","def countSolutions ( a ) : NEW_LINE INDENT count = bin ( a ) . count ( '1' ) NEW_LINE return 2 ** count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 3 NEW_LINE print ( countSolutions ( a ) ) NEW_LINE DEDENT +" +E1547,"class GFG { static int countNumbers ( int n ) { if ( n % 2 == 1 ) return 0 ; return ( 9 * ( int ) Math . pow ( 10 , n / 2 - 1 ) ) ; } public static void main ( String args [ ] ) { int n = 2 ; System . out . print ( countNumbers ( n ) ) ; } } +","def countNumbers ( n ) : NEW_LINE INDENT if n % 2 == 1 : NEW_LINE INDENT return 0 NEW_LINE DEDENT return ( 9 * pow ( 10 , n // 2 - 1 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 2 NEW_LINE print ( countNumbers ( n ) ) NEW_LINE DEDENT +" +E1548,"import java . util . * ; class GFG { static int getMinDiff ( int arr [ ] , int n , int k ) { if ( n == 1 ) return 0 ; Arrays . sort ( arr ) ; int ans = arr [ n - 1 ] - arr [ 0 ] ; int small = arr [ 0 ] + k ; int big = arr [ n - 1 ] - k ; int temp = 0 ; if ( small > big ) { temp = small ; small = big ; big = temp ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { int subtract = arr [ i ] - k ; int add = arr [ i ] + k ; if ( subtract >= small || add <= big ) continue ; if ( big - subtract <= add - small ) small = subtract ; else big = add ; } return Math . min ( ans , big - small ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 6 } ; int n = arr . length ; int k = 10 ; System . out . println ( "" Maximum ▁ difference ▁ is ▁ "" + getMinDiff ( arr , n , k ) ) ; } } +","def getMinDiff ( arr , n , k ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT arr . sort ( ) NEW_LINE ans = arr [ n - 1 ] - arr [ 0 ] NEW_LINE small = arr [ 0 ] + k NEW_LINE big = arr [ n - 1 ] - k NEW_LINE if ( small > big ) : NEW_LINE INDENT small , big = big , small NEW_LINE DEDENT for i in range ( 1 , n - 1 ) : NEW_LINE INDENT subtract = arr [ i ] - k NEW_LINE add = arr [ i ] + k NEW_LINE if ( subtract >= small or add <= big ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( big - subtract <= add - small ) : NEW_LINE INDENT small = subtract NEW_LINE DEDENT else : NEW_LINE INDENT big = add NEW_LINE DEDENT DEDENT return min ( ans , big - small ) NEW_LINE DEDENT arr = [ 4 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE k = 10 NEW_LINE print ( "" Maximum ▁ difference ▁ is "" , getMinDiff ( arr , n , k ) ) NEW_LINE +" +E1549,"import java . io . * ; class GFG { static int minimumChanges ( int n , int a [ ] ) { int i ; int [ ] sf = new int [ n + 1 ] ; sf [ n ] = 0 ; for ( i = n - 1 ; i >= 0 ; i -- ) { sf [ i ] = sf [ i + 1 ] ; if ( a [ i ] <= 0 ) sf [ i ] ++ ; } int pos = 0 ; int mn = n ; for ( i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] >= 0 ) pos ++ ; mn = Math . min ( mn , pos + sf [ i + 1 ] ) ; } return mn ; } public static void main ( String [ ] args ) { int [ ] a = { - 1 , - 2 , - 3 , 3 , - 5 , 3 , 4 } ; int n = a . length ; System . out . println ( minimumChanges ( n , a ) ) ; } } +","def minimumChanges ( n , a ) : NEW_LINE INDENT sf = [ 0 ] * ( n + 1 ) NEW_LINE sf [ n ] = 0 NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT sf [ i ] = sf [ i + 1 ] NEW_LINE if ( a [ i ] <= 0 ) : NEW_LINE INDENT sf [ i ] += 1 NEW_LINE DEDENT DEDENT pos = 0 NEW_LINE mn = n NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( a [ i ] >= 0 ) : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT mn = min ( mn , pos + sf [ i + 1 ] ) NEW_LINE DEDENT return mn NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ - 1 , - 2 , - 3 , 3 , - 5 , 3 , 4 ] NEW_LINE n = len ( a ) NEW_LINE print ( minimumChanges ( n , a ) ) NEW_LINE DEDENT +" +E1550,"import java . util . * ; class Main { static void printFirstRepeating ( int arr [ ] ) { int min = - 1 ; HashSet < Integer > set = new HashSet < > ( ) ; for ( int i = arr . length - 1 ; i >= 0 ; i -- ) { if ( set . contains ( arr [ i ] ) ) min = i ; else set . add ( arr [ i ] ) ; } if ( min != - 1 ) System . out . println ( "" The ▁ first ▁ repeating ▁ element ▁ is ▁ "" + arr [ min ] ) ; else System . out . println ( "" There ▁ are ▁ no ▁ repeating ▁ elements "" ) ; } public static void main ( String [ ] args ) throws java . lang . Exception { int arr [ ] = { 10 , 5 , 3 , 4 , 3 , 5 , 6 } ; printFirstRepeating ( arr ) ; } } +","def printFirstRepeating ( arr , n ) : NEW_LINE INDENT Min = - 1 NEW_LINE myset = dict ( ) NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if arr [ i ] in myset . keys ( ) : NEW_LINE INDENT Min = i NEW_LINE DEDENT else : NEW_LINE INDENT myset [ arr [ i ] ] = 1 NEW_LINE DEDENT DEDENT if ( Min != - 1 ) : NEW_LINE INDENT print ( "" The ▁ first ▁ repeating ▁ element ▁ is "" , arr [ Min ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" There ▁ are ▁ no ▁ repeating ▁ elements "" ) NEW_LINE DEDENT DEDENT arr = [ 10 , 5 , 3 , 4 , 3 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE printFirstRepeating ( arr , n ) NEW_LINE +" +E1551,"import java . io . * ; class GFG { static void solveEven ( int n , int arr [ ] , int b [ ] ) { int left = n - 1 ; for ( int i = 0 ; i < ( n / 2 ) ; ++ i ) { b [ i ] = arr [ left ] ; left = left - 2 ; if ( left < 0 ) break ; } int right = 0 ; for ( int i = n / 2 ; i <= n - 1 ; ++ i ) { b [ i ] = arr [ right ] ; right = right + 2 ; if ( right > n - 2 ) break ; } } static void solveOdd ( int n , int arr [ ] , int b [ ] ) { int left = n - 1 ; for ( int i = 0 ; i < ( n / 2 ) + 1 ; ++ i ) { b [ i ] = arr [ left ] ; left = left - 2 ; if ( left < 0 ) break ; } int right = 1 ; for ( int i = ( n / 2 ) + 1 ; i <= n - 1 ; ++ i ) { b [ i ] = arr [ right ] ; right = right + 2 ; if ( right > n - 2 ) break ; } } static void solve ( int n , int arr [ ] ) { int b [ ] = new int [ n ] ; if ( n % 2 == 0 ) solveEven ( n , arr , b ) ; else solveOdd ( n , arr , b ) ; for ( int i = 0 ; i <= n - 1 ; ++ i ) { System . out . print ( b [ i ] + "" ▁ "" ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . length ; solve ( n , arr ) ; } } +","def solveEven ( n , arr , b ) : NEW_LINE INDENT left = n - 1 NEW_LINE for i in range ( ( n // 2 ) ) : NEW_LINE INDENT b [ i ] = arr [ left ] NEW_LINE left = left - 2 NEW_LINE if ( left < 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT right = 0 NEW_LINE for i in range ( n // 2 , n , 1 ) : NEW_LINE INDENT b [ i ] = arr [ right ] NEW_LINE right = right + 2 NEW_LINE if ( right > n - 2 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT def solveOdd ( n , arr , b ) : NEW_LINE INDENT left = n - 1 NEW_LINE for i in range ( n // 2 + 1 ) : NEW_LINE INDENT b [ i ] = arr [ left ] NEW_LINE left = left - 2 NEW_LINE if ( left < 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT right = 1 NEW_LINE for i in range ( n // 2 + 1 , n , 1 ) : NEW_LINE INDENT b [ i ] = arr [ right ] NEW_LINE right = right + 2 NEW_LINE if ( right > n - 2 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT def solve ( n , arr ) : NEW_LINE INDENT b = [ 0 for i in range ( n ) ] NEW_LINE if ( n % 2 == 0 ) : NEW_LINE INDENT solveEven ( n , arr , b ) NEW_LINE DEDENT else : NEW_LINE INDENT solveOdd ( n , arr , b ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( b [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE solve ( n , arr ) NEW_LINE DEDENT +" +E1552,"class GFG { static void findpair ( int l , int r ) { int c = 0 ; for ( int i = l ; i <= r ; i ++ ) { for ( int j = i + 1 ; j <= r ; j ++ ) { if ( j % i == 0 && j != i ) { System . out . println ( i + "" , ▁ "" + j ) ; c = 1 ; break ; } } if ( c == 1 ) break ; } } public static void main ( String args [ ] ) { int l = 1 , r = 10 ; findpair ( l , r ) ; } } +","def findpair ( l , r ) : NEW_LINE INDENT c = 0 NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT for j in range ( i + 1 , r + 1 ) : NEW_LINE INDENT if ( j % i == 0 and j != i ) : NEW_LINE INDENT print ( i , "" , ▁ "" , j ) NEW_LINE c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT if ( c == 1 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT l = 1 NEW_LINE r = 10 NEW_LINE findpair ( l , r ) NEW_LINE DEDENT +" +E1553,"class GFG { static int nthEven ( int n ) { return ( 2 * n ) ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( nthEven ( n ) ) ; } } +","def nthEven ( n ) : NEW_LINE INDENT return ( 2 * n ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 NEW_LINE print ( nthEven ( n ) ) NEW_LINE DEDENT +" +E1554,"class GFG { static boolean checkUtil ( int num , int dig , int base ) { if ( dig == 1 && num < base ) return true ; if ( dig > 1 && num >= base ) return checkUtil ( num / base , -- dig , base ) ; return false ; } static boolean check ( int num , int dig ) { for ( int base = 2 ; base <= 32 ; base ++ ) if ( checkUtil ( num , dig , base ) ) return true ; return false ; } public static void main ( String [ ] args ) { int num = 8 ; int dig = 3 ; if ( check ( num , dig ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def checkUtil ( num , dig , base ) : NEW_LINE INDENT if ( dig == 1 and num < base ) : NEW_LINE INDENT return True NEW_LINE DEDENT if ( dig > 1 and num >= base ) : NEW_LINE INDENT return checkUtil ( num / base , - - dig , base ) NEW_LINE DEDENT return False NEW_LINE DEDENT def check ( num , dig ) : NEW_LINE INDENT for base in range ( 2 , 33 ) : NEW_LINE INDENT if ( checkUtil ( num , dig , base ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT num = 8 NEW_LINE dig = 3 NEW_LINE if ( check ( num , dig ) == True ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1555,"class SmallestSubArraySum { static int smallestSubWithSum ( int arr [ ] , int n , int x ) { int min_len = n + 1 ; for ( int start = 0 ; start < n ; start ++ ) { int curr_sum = arr [ start ] ; if ( curr_sum > x ) return 1 ; for ( int end = start + 1 ; end < n ; end ++ ) { curr_sum += arr [ end ] ; if ( curr_sum > x && ( end - start + 1 ) < min_len ) min_len = ( end - start + 1 ) ; } } return min_len ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 1 , 4 , 45 , 6 , 10 , 19 } ; int x = 51 ; int n1 = arr1 . length ; int res1 = smallestSubWithSum ( arr1 , n1 , x ) ; if ( res1 == n1 + 1 ) System . out . println ( "" Not ▁ Possible "" ) ; else System . out . println ( res1 ) ; int arr2 [ ] = { 1 , 10 , 5 , 2 , 7 } ; int n2 = arr2 . length ; x = 9 ; int res2 = smallestSubWithSum ( arr2 , n2 , x ) ; if ( res2 == n2 + 1 ) System . out . println ( "" Not ▁ Possible "" ) ; else System . out . println ( res2 ) ; int arr3 [ ] = { 1 , 11 , 100 , 1 , 0 , 200 , 3 , 2 , 1 , 250 } ; int n3 = arr3 . length ; x = 280 ; int res3 = smallestSubWithSum ( arr3 , n3 , x ) ; if ( res3 == n3 + 1 ) System . out . println ( "" Not ▁ Possible "" ) ; else System . out . println ( res3 ) ; } } +","def smallestSubWithSum ( arr , n , x ) : NEW_LINE INDENT min_len = n + 1 NEW_LINE for start in range ( 0 , n ) : NEW_LINE INDENT curr_sum = arr [ start ] NEW_LINE if ( curr_sum > x ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT for end in range ( start + 1 , n ) : NEW_LINE INDENT curr_sum += arr [ end ] NEW_LINE if curr_sum > x and ( end - start + 1 ) < min_len : NEW_LINE INDENT min_len = ( end - start + 1 ) NEW_LINE DEDENT DEDENT DEDENT return min_len ; NEW_LINE DEDENT arr1 = [ 1 , 4 , 45 , 6 , 10 , 19 ] NEW_LINE x = 51 NEW_LINE n1 = len ( arr1 ) NEW_LINE res1 = smallestSubWithSum ( arr1 , n1 , x ) ; NEW_LINE if res1 == n1 + 1 : NEW_LINE INDENT print ( "" Not ▁ possible "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( res1 ) NEW_LINE DEDENT arr2 = [ 1 , 10 , 5 , 2 , 7 ] NEW_LINE n2 = len ( arr2 ) NEW_LINE x = 9 NEW_LINE res2 = smallestSubWithSum ( arr2 , n2 , x ) ; NEW_LINE if res2 == n2 + 1 : NEW_LINE INDENT print ( "" Not ▁ possible "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( res2 ) NEW_LINE DEDENT arr3 = [ 1 , 11 , 100 , 1 , 0 , 200 , 3 , 2 , 1 , 250 ] NEW_LINE n3 = len ( arr3 ) NEW_LINE x = 280 NEW_LINE res3 = smallestSubWithSum ( arr3 , n3 , x ) NEW_LINE if res3 == n3 + 1 : NEW_LINE INDENT print ( "" Not ▁ possible "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( res3 ) NEW_LINE DEDENT +" +E1556,"public class GFG { public static int getSum ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { double sqrtCurrent = Math . sqrt ( arr [ i ] ) ; for ( int j = 0 ; j < n ; j ++ ) { double x = arr [ j ] ; if ( x == sqrtCurrent ) { sum += ( sqrtCurrent * sqrtCurrent ) ; break ; } } } return sum ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 4 , 5 , 6 , 7 , 8 , 9 , 3 } ; int n = arr . length ; System . out . println ( getSum ( arr , n ) ) ; } } +","import math NEW_LINE def getSum ( arr , n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT sqrtCurrent = math . sqrt ( arr [ i ] ) NEW_LINE for j in range ( 0 , n ) : NEW_LINE INDENT x = arr [ j ] NEW_LINE if ( x == sqrtCurrent ) : NEW_LINE INDENT sum += ( sqrtCurrent * sqrtCurrent ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT return int ( sum ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 2 , 4 , 5 , 6 , 7 , 8 , 9 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE print ( getSum ( arr , n ) ) NEW_LINE DEDENT +" +E1557,"import java . io . * ; class GFG { static int findCountOfPairs ( int a , int b , int n ) { int ans = 0 ; ans += n * ( a / n ) * ( b / n ) ; ans += ( a / n ) * ( b % n ) ; ans += ( a % n ) * ( b / n ) ; ans += ( ( a % n ) + ( b % n ) ) / n ; return ans ; } public static void main ( String [ ] args ) { int a = 5 , b = 13 , n = 3 ; System . out . println ( findCountOfPairs ( a , b , n ) ) ; } } +","def findCountOfPairs ( a , b , n ) : NEW_LINE INDENT ans = 0 NEW_LINE ans += n * int ( a / n ) * int ( b / n ) NEW_LINE ans += int ( a / n ) * ( b % n ) NEW_LINE ans += ( a % n ) * int ( b / n ) NEW_LINE ans += int ( ( ( a % n ) + ( b % n ) ) / n ) ; NEW_LINE return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = 5 NEW_LINE b = 13 NEW_LINE n = 3 NEW_LINE print ( findCountOfPairs ( a , b , n ) ) NEW_LINE DEDENT +" +E1558,"import java . util . Arrays ; class GFG { static int bsearch ( int prefixsum [ ] , int n , int k ) { int ans = - 1 ; int left = 1 , right = n ; while ( left <= right ) { int mid = ( left + right ) / 2 ; int i ; for ( i = mid ; i <= n ; i ++ ) { if ( prefixsum [ i ] - prefixsum [ i - mid ] > k ) break ; } if ( i == n + 1 ) { left = mid + 1 ; ans = mid ; } else right = mid - 1 ; } return ans ; } static int maxSize ( int arr [ ] , int n , int k ) { int prefixsum [ ] = new int [ n + 1 ] ; Arrays . fill ( prefixsum , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) prefixsum [ i + 1 ] = prefixsum [ i ] + arr [ i ] ; return bsearch ( prefixsum , n , k ) ; } public static void main ( String arg [ ] ) { int arr [ ] = { 1 , 2 , 10 , 4 } ; int n = arr . length ; int k = 14 ; System . out . println ( maxSize ( arr , n , k ) ) ; } } +","def bsearch ( prefixsum , n , k ) : NEW_LINE INDENT ans , left , right = - 1 , 1 , n NEW_LINE while ( left <= right ) : NEW_LINE INDENT mid = ( left + right ) // 2 NEW_LINE for i in range ( mid , n + 1 ) : NEW_LINE INDENT if ( prefixsum [ i ] - prefixsum [ i - mid ] > k ) : NEW_LINE INDENT i = i - 1 NEW_LINE break NEW_LINE DEDENT DEDENT i = i + 1 NEW_LINE if ( i == n + 1 ) : NEW_LINE INDENT left = mid + 1 NEW_LINE ans = mid NEW_LINE DEDENT else : NEW_LINE INDENT right = mid - 1 NEW_LINE DEDENT DEDENT return ans ; NEW_LINE DEDENT def maxSize ( arr , n , k ) : NEW_LINE INDENT prefixsum = [ 0 for x in range ( n + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT prefixsum [ i + 1 ] = prefixsum [ i ] + arr [ i ] NEW_LINE DEDENT return bsearch ( prefixsum , n , k ) ; NEW_LINE DEDENT arr = [ 1 , 2 , 10 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE k = 14 NEW_LINE print ( maxSize ( arr , n , k ) ) NEW_LINE +" +E1559,"public class Prime { static boolean isprime ( int x ) { for ( int i = 2 ; i * i <= x ; i ++ ) if ( x % i == 0 ) return false ; return true ; } static boolean isSumOfKprimes ( int N , int K ) { if ( N < 2 * K ) return false ; if ( K == 1 ) return isprime ( N ) ; if ( K == 2 ) { if ( N % 2 == 0 ) return true ; return isprime ( N - 2 ) ; } return true ; } public static void main ( String [ ] args ) { int n = 10 , k = 2 ; if ( isSumOfKprimes ( n , k ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def isprime ( x ) : NEW_LINE INDENT i = 2 NEW_LINE while ( i * i <= x ) : NEW_LINE INDENT if ( x % i == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT return 1 NEW_LINE DEDENT def isSumOfKprimes ( N , K ) : NEW_LINE INDENT if ( N < 2 * K ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT if ( K == 1 ) : NEW_LINE INDENT return isprime ( N ) NEW_LINE DEDENT if ( K == 2 ) : NEW_LINE INDENT if ( N % 2 == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return isprime ( N - 2 ) ; NEW_LINE DEDENT return 1 NEW_LINE DEDENT n = 10 NEW_LINE k = 2 NEW_LINE if ( isSumOfKprimes ( n , k ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT +" +E1560,"import java . util . * ; class GFG { static int CountCharacters ( String str , int k ) { int cnt = 0 ; int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ( ( int ) str . charAt ( i ) ) < k ) cnt ++ ; } return cnt ; } public static void main ( String args [ ] ) { String str = "" GeeksForGeeks "" ; int k = 90 ; int count = CountCharacters ( str , k ) ; System . out . println ( "" Characters ▁ with ▁ ASCII ▁ values ▁ less ▁ than ▁ K ▁ are ▁ "" + count ) ; System . out . println ( "" Characters ▁ with ▁ ASCII ▁ values ▁ greater ▁ than ▁ or ▁ equal ▁ to ▁ K ▁ are ▁ "" + ( str . length ( ) - count ) ) ; } } +","def CountCharacters ( str , k ) : NEW_LINE INDENT cnt = 0 NEW_LINE l = len ( str ) NEW_LINE for i in range ( l ) : NEW_LINE INDENT if ( ord ( str [ i ] ) < k ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" GeeksForGeeks "" NEW_LINE k = 90 NEW_LINE count = CountCharacters ( str , k ) NEW_LINE print ( "" Characters ▁ with ▁ ASCII ▁ values "" , "" less ▁ than ▁ K ▁ are "" , count ) NEW_LINE print ( "" Characters ▁ with ▁ ASCII ▁ values "" , "" greater ▁ than ▁ or ▁ equal ▁ to ▁ K ▁ are "" , len ( str ) - count ) NEW_LINE DEDENT +" +E1561,"import java . io . * ; class GFG { static void printUncommon ( int arr1 [ ] , int arr2 [ ] , int n1 , int n2 ) { int i = 0 , j = 0 , k = 0 ; while ( i < n1 && j < n2 ) { if ( arr1 [ i ] < arr2 [ j ] ) { System . out . print ( arr1 [ i ] + "" ▁ "" ) ; i ++ ; k ++ ; } else if ( arr2 [ j ] < arr1 [ i ] ) { System . out . print ( arr2 [ j ] + "" ▁ "" ) ; k ++ ; j ++ ; } else { i ++ ; j ++ ; } } while ( i < n1 ) { System . out . print ( arr1 [ i ] + "" ▁ "" ) ; i ++ ; k ++ ; } while ( j < n2 ) { System . out . print ( arr2 [ j ] + "" ▁ "" ) ; j ++ ; k ++ ; } } public static void main ( String [ ] args ) { int arr1 [ ] = { 10 , 20 , 30 } ; int arr2 [ ] = { 20 , 25 , 30 , 40 , 50 } ; int n1 = arr1 . length ; int n2 = arr2 . length ; printUncommon ( arr1 , arr2 , n1 , n2 ) ; } } +","def printUncommon ( arr1 , arr2 , n1 , n2 ) : NEW_LINE INDENT i = 0 NEW_LINE j = 0 NEW_LINE k = 0 NEW_LINE while ( i < n1 and j < n2 ) : NEW_LINE INDENT if ( arr1 [ i ] < arr2 [ j ] ) : NEW_LINE INDENT print ( arr1 [ i ] , end = "" ▁ "" ) NEW_LINE i = i + 1 NEW_LINE k = k + 1 NEW_LINE DEDENT elif ( arr2 [ j ] < arr1 [ i ] ) : NEW_LINE INDENT print ( arr2 [ j ] , end = "" ▁ "" ) NEW_LINE k = k + 1 NEW_LINE j = j + 1 NEW_LINE DEDENT else : NEW_LINE INDENT i = i + 1 NEW_LINE j = j + 1 NEW_LINE DEDENT DEDENT while ( i < n1 ) : NEW_LINE INDENT print ( arr1 [ i ] , end = "" ▁ "" ) NEW_LINE i = i + 1 NEW_LINE k = k + 1 NEW_LINE DEDENT while ( j < n2 ) : NEW_LINE INDENT print ( arr2 [ j ] , end = "" ▁ "" ) NEW_LINE j = j + 1 NEW_LINE k = k + 1 NEW_LINE DEDENT DEDENT arr1 = [ 10 , 20 , 30 ] NEW_LINE arr2 = [ 20 , 25 , 30 , 40 , 50 ] NEW_LINE n1 = len ( arr1 ) NEW_LINE n2 = len ( arr2 ) NEW_LINE printUncommon ( arr1 , arr2 , n1 , n2 ) NEW_LINE +" +E1562,"public class Test { private static char findExtraCharacter ( String s1 , String s2 ) { String smallStr ; String largeStr ; if ( s1 . length ( ) > s2 . length ( ) ) { smallStr = s2 ; largeStr = s1 ; } else { smallStr = s1 ; largeStr = s2 ; } int smallStrCodeTotal = 0 ; int largeStrCodeTotal = 0 ; int i = 0 ; for ( ; i < smallStr . length ( ) ; i ++ ) { smallStrCodeTotal += smallStr . charAt ( i ) ; largeStrCodeTotal += largeStr . charAt ( i ) ; } largeStrCodeTotal += largeStr . charAt ( i ) ; int intChar = largeStrCodeTotal - smallStrCodeTotal ; return ( char ) intChar ; } public static void main ( String [ ] args ) { String s1 = "" abcd "" ; String s2 = "" cbdae "" ; char extraChar = findExtraCharacter ( s1 , s2 ) ; System . out . println ( "" Extra ▁ character : ▁ "" + extraChar ) ; } } +","def findExtraCharacter ( s1 , s2 ) : NEW_LINE INDENT smallStr = "" "" NEW_LINE largeStr = "" "" NEW_LINE if ( len ( s1 ) > len ( s2 ) ) : NEW_LINE INDENT smallStr = s2 NEW_LINE largeStr = s1 NEW_LINE DEDENT else : NEW_LINE INDENT smallStr = s1 NEW_LINE largeStr = s2 NEW_LINE DEDENT smallStrCodeTotal = 0 NEW_LINE largeStrCodeTotal = 0 NEW_LINE i = 0 NEW_LINE while ( i < len ( smallStr ) ) : NEW_LINE INDENT smallStrCodeTotal += ord ( smallStr [ i ] ) NEW_LINE largeStrCodeTotal += ord ( largeStr [ i ] ) NEW_LINE i += 1 NEW_LINE DEDENT largeStrCodeTotal += ord ( largeStr [ i ] ) NEW_LINE intChar = largeStrCodeTotal - smallStrCodeTotal NEW_LINE return chr ( intChar ) NEW_LINE DEDENT s1 = "" abcd "" NEW_LINE s2 = "" cbdae "" NEW_LINE extraChar = findExtraCharacter ( s1 , s2 ) NEW_LINE print ( "" Extra ▁ Character : "" , extraChar ) NEW_LINE +" +E1563,"class GFG { static void sortMat ( int [ ] [ ] data , int row , int col ) { int size = row * col ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size - 1 ; j ++ ) { if ( data [ j / col ] [ j % col ] > data [ ( j + 1 ) / col ] [ ( j + 1 ) % col ] ) { int temp = data [ j / col ] [ j % col ] ; data [ j / col ] [ j % col ] = data [ ( j + 1 ) / col ] [ ( j + 1 ) % col ] ; data [ ( j + 1 ) / col ] [ ( j + 1 ) % col ] = temp ; } } } } static void printMat ( int [ ] [ ] mat , int row , int col ) { for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { System . out . print ( mat [ i ] [ j ] + "" ▁ "" ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 5 , 4 , 7 } , { 1 , 3 , 8 } , { 2 , 9 , 6 } } ; int row = mat . length ; int col = mat [ 0 ] . length ; sortMat ( mat , row , col ) ; printMat ( mat , row , col ) ; } } +","def sortMat ( data , row , col ) : NEW_LINE INDENT size = row * col NEW_LINE for i in range ( 0 , size ) : NEW_LINE INDENT for j in range ( 0 , size - 1 ) : NEW_LINE INDENT if ( data [ j // col ] [ j % col ] > \ data [ ( j + 1 ) // col ] [ ( j + 1 ) % col ] ) : NEW_LINE INDENT temp = data [ j // col ] [ j % col ] NEW_LINE data [ j // col ] [ j % col ] = \ NEW_LINE INDENT data [ ( j + 1 ) // col ] [ ( j + 1 ) % col ] NEW_LINE DEDENT data [ ( j + 1 ) // col ] [ ( j + 1 ) % col ] = \ NEW_LINE INDENT temp NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT def printMat ( mat , row , col ) : NEW_LINE INDENT for i in range ( row ) : NEW_LINE INDENT for j in range ( col ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT mat = [ [ 5 , 4 , 7 ] , [ 1 , 3 , 8 ] , [ 2 , 9 , 6 ] ] NEW_LINE row = len ( mat ) NEW_LINE col = len ( mat [ 0 ] ) NEW_LINE sortMat ( mat , row , col ) NEW_LINE printMat ( mat , row , col ) NEW_LINE DEDENT +" +E1564,"public class HelloWorld { static int distinctDigitSum ( int n ) { boolean used [ ] = new boolean [ 10 ] ; int sum = 0 ; while ( n > 0 ) { int digit = n % 10 ; if ( ! used [ digit ] ) { used [ digit ] = true ; sum += digit ; } n = n / 10 ; } return sum ; } static String checkSum ( int m , int n ) { int sumM = distinctDigitSum ( m ) ; int sumN = distinctDigitSum ( n ) ; if ( sumM == sumN ) return "" YES "" ; return "" NO "" ; } public static void main ( String [ ] args ) { int m = 2452 , n = 9222 ; System . out . println ( checkSum ( m , n ) ) ; } } +","def distinctDigitSum ( n ) : NEW_LINE INDENT used = [ False ] * 10 NEW_LINE sum = 0 NEW_LINE while ( n > 0 ) : NEW_LINE INDENT digit = n % 10 NEW_LINE if ( not used [ digit ] ) : NEW_LINE INDENT used [ digit ] = True NEW_LINE sum += digit NEW_LINE DEDENT n = n // 10 NEW_LINE DEDENT return sum NEW_LINE DEDENT def checkSum ( m , n ) : NEW_LINE INDENT sumM = distinctDigitSum ( m ) NEW_LINE sumN = distinctDigitSum ( n ) NEW_LINE if ( sumM == sumN ) : NEW_LINE INDENT return "" YES "" NEW_LINE DEDENT return "" NO "" NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT m = 2452 NEW_LINE n = 9222 NEW_LINE print ( checkSum ( m , n ) ) NEW_LINE DEDENT +" +E1565,"class GFG { static void initializeDiffArray ( int A [ ] , int D [ ] ) { int n = A . length ; D [ 0 ] = A [ 0 ] ; D [ n ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) D [ i ] = A [ i ] - A [ i - 1 ] ; } static void update ( int D [ ] , int l , int r , int x ) { D [ l ] += x ; D [ r + 1 ] -= x ; } static int printArray ( int A [ ] , int D [ ] ) { for ( int i = 0 ; i < A . length ; i ++ ) { if ( i == 0 ) A [ i ] = D [ i ] ; else A [ i ] = D [ i ] + A [ i - 1 ] ; System . out . print ( A [ i ] + "" ▁ "" ) ; } System . out . println ( ) ; return 0 ; } public static void main ( String [ ] args ) { int A [ ] = { 10 , 5 , 20 , 40 } ; int n = A . length ; int D [ ] = new int [ n + 1 ] ; initializeDiffArray ( A , D ) ; update ( D , 0 , 1 , 10 ) ; printArray ( A , D ) ; update ( D , 1 , 3 , 20 ) ; update ( D , 2 , 2 , 30 ) ; printArray ( A , D ) ; } } +","def initializeDiffArray ( A ) : NEW_LINE INDENT n = len ( A ) NEW_LINE D = [ 0 for i in range ( 0 , n + 1 ) ] NEW_LINE D [ 0 ] = A [ 0 ] ; D [ n ] = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT D [ i ] = A [ i ] - A [ i - 1 ] NEW_LINE DEDENT return D NEW_LINE DEDENT def update ( D , l , r , x ) : NEW_LINE INDENT D [ l ] += x NEW_LINE D [ r + 1 ] -= x NEW_LINE DEDENT def printArray ( A , D ) : NEW_LINE INDENT for i in range ( 0 , len ( A ) ) : NEW_LINE INDENT if ( i == 0 ) : NEW_LINE INDENT A [ i ] = D [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT A [ i ] = D [ i ] + A [ i - 1 ] NEW_LINE DEDENT print ( A [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( "" "" ) NEW_LINE DEDENT A = [ 10 , 5 , 20 , 40 ] NEW_LINE D = initializeDiffArray ( A ) NEW_LINE update ( D , 0 , 1 , 10 ) NEW_LINE printArray ( A , D ) NEW_LINE update ( D , 1 , 3 , 20 ) NEW_LINE update ( D , 2 , 2 , 30 ) NEW_LINE printArray ( A , D ) NEW_LINE +" +E1566,"class GFG { static int MAX = 100 ; static void printPrincipalDiagonal ( int mat [ ] [ ] , int n ) { System . out . print ( "" Principal ▁ Diagonal : ▁ "" ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) { System . out . print ( mat [ i ] [ j ] + "" , ▁ "" ) ; } } } System . out . println ( "" "" ) ; } static void printSecondaryDiagonal ( int mat [ ] [ ] , int n ) { System . out . print ( "" Secondary ▁ Diagonal : ▁ "" ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( i + j ) == ( n - 1 ) ) { System . out . print ( mat [ i ] [ j ] + "" , ▁ "" ) ; } } } System . out . println ( "" "" ) ; } public static void main ( String args [ ] ) { int n = 4 ; int a [ ] [ ] = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } } ; printPrincipalDiagonal ( a , n ) ; printSecondaryDiagonal ( a , n ) ; } } +","MAX = 100 NEW_LINE def printPrincipalDiagonal ( mat , n ) : NEW_LINE INDENT print ( "" Principal ▁ Diagonal : ▁ "" , end = "" "" ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ( i == j ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = "" , ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT print ( ) NEW_LINE DEDENT def printSecondaryDiagonal ( mat , n ) : NEW_LINE INDENT print ( "" Secondary ▁ Diagonal : ▁ "" , end = "" "" ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ( ( i + j ) == ( n - 1 ) ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = "" , ▁ "" ) NEW_LINE DEDENT DEDENT DEDENT print ( ) NEW_LINE DEDENT n = 4 NEW_LINE a = [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] ] NEW_LINE printPrincipalDiagonal ( a , n ) NEW_LINE printSecondaryDiagonal ( a , n ) NEW_LINE +" +E1567,"class GFG { static int FindMinNumber ( int arr [ ] , int n , int k ) { int i = 0 ; int j = 0 ; int min_num = Integer . MAX_VALUE ; boolean found = false ; int sum = 0 ; while ( i < n ) { sum = sum + arr [ i ] ; if ( sum == k ) { min_num = Math . min ( min_num , ( ( n - ( i + 1 ) ) + j ) ) ; found = true ; } else if ( sum > k ) { while ( sum > k ) { sum = sum - arr [ j ] ; j ++ ; } if ( sum == k ) { min_num = Math . min ( min_num , ( ( n - ( i + 1 ) ) + j ) ) ; found = true ; } } i ++ ; } if ( found ) return min_num ; return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 2 , 5 , 6 } ; int n = arr . length ; int k = 5 ; System . out . println ( FindMinNumber ( arr , n , k ) ) ; } } +","def FindMinNumber ( arr , n , k ) : NEW_LINE INDENT i = 0 NEW_LINE j = 0 NEW_LINE min_num = 10 ** 9 NEW_LINE found = False NEW_LINE Sum = 0 NEW_LINE while ( i < n ) : NEW_LINE INDENT Sum = Sum + arr [ i ] NEW_LINE if ( Sum == k ) : NEW_LINE INDENT min_num = min ( min_num , ( ( n - ( i + 1 ) ) + j ) ) NEW_LINE found = True NEW_LINE DEDENT elif ( Sum > k ) : NEW_LINE INDENT while ( Sum > k ) : NEW_LINE INDENT Sum = Sum - arr [ j ] NEW_LINE j += 1 NEW_LINE DEDENT if ( Sum == k ) : NEW_LINE INDENT min_num = min ( min_num , ( ( n - ( i + 1 ) ) + j ) ) NEW_LINE found = True NEW_LINE DEDENT DEDENT i += 1 NEW_LINE DEDENT if ( found ) : NEW_LINE INDENT return min_num NEW_LINE DEDENT return - 1 NEW_LINE DEDENT arr = [ 1 , 3 , 2 , 5 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE k = 5 NEW_LINE print ( FindMinNumber ( arr , n , k ) ) NEW_LINE +" +E1568,"import java . util . PriorityQueue ; class GFG { public static int minProduct ( int [ ] arr , int n , int k ) { PriorityQueue < Integer > pq = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) pq . add ( arr [ i ] ) ; int count = 0 , ans = 1 ; while ( pq . isEmpty ( ) == false && count < k ) { ans = ans * pq . element ( ) ; pq . remove ( ) ; count ++ ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 198 , 76 , 544 , 123 , 154 , 675 } ; int k = 2 ; int n = arr . length ; System . out . print ( "" Minimum ▁ product ▁ is ▁ "" + minProduct ( arr , n , k ) ) ; } } +","import math NEW_LINE import heapq NEW_LINE def minProduct ( arr , n , k ) : NEW_LINE INDENT heapq . heapify ( arr ) NEW_LINE count = 0 NEW_LINE ans = 1 NEW_LINE while ( arr ) and count < k : NEW_LINE INDENT x = heapq . heappop ( arr ) NEW_LINE ans = ans * x NEW_LINE count = count + 1 NEW_LINE DEDENT return ans ; NEW_LINE DEDENT arr = [ 198 , 76 , 544 , 123 , 154 , 675 ] NEW_LINE k = 2 NEW_LINE n = len ( arr ) NEW_LINE print ( "" Minimum ▁ product ▁ is "" , minProduct ( arr , n , k ) ) NEW_LINE +" +E1569,"class GFG { static int [ ] BitsSetTable256 = new int [ 256 ] ; public static void initialize ( ) { BitsSetTable256 [ 0 ] = 0 ; for ( int i = 0 ; i < 256 ; i ++ ) { BitsSetTable256 [ i ] = ( i & 1 ) + BitsSetTable256 [ i / 2 ] ; } } public static int countSetBits ( int n ) { return ( BitsSetTable256 [ n & 0xff ] + BitsSetTable256 [ ( n >> 8 ) & 0xff ] + BitsSetTable256 [ ( n >> 16 ) & 0xff ] + BitsSetTable256 [ n >> 24 ] ) ; } public static void main ( String [ ] args ) { initialize ( ) ; int n = 9 ; System . out . print ( countSetBits ( n ) ) ; } } +","BitsSetTable256 = [ 0 ] * 256 NEW_LINE def initialize ( ) : NEW_LINE INDENT BitsSetTable256 [ 0 ] = 0 NEW_LINE for i in range ( 256 ) : NEW_LINE INDENT BitsSetTable256 [ i ] = ( i & 1 ) + BitsSetTable256 [ i // 2 ] NEW_LINE DEDENT DEDENT def countSetBits ( n ) : NEW_LINE INDENT return ( BitsSetTable256 [ n & 0xff ] + BitsSetTable256 [ ( n >> 8 ) & 0xff ] + BitsSetTable256 [ ( n >> 16 ) & 0xff ] + BitsSetTable256 [ n >> 24 ] ) NEW_LINE DEDENT initialize ( ) NEW_LINE n = 9 NEW_LINE print ( countSetBits ( n ) ) NEW_LINE +" +E1570,"import java . io . * ; import java . util . Arrays ; class GFG { static int numberOfBST ( int n ) { int dp [ ] = new int [ n + 1 ] ; Arrays . fill ( dp , 0 ) ; dp [ 0 ] = 1 ; dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { dp [ i ] = dp [ i ] + ( dp [ i - j ] * dp [ j - 1 ] ) ; } } return dp [ n ] ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "" Number ▁ of ▁ structurally ▁ "" + "" Unique ▁ BST ▁ with ▁ "" + n + "" ▁ keys ▁ are ▁ : ▁ "" + numberOfBST ( n ) ) ; } } +","def numberOfBST ( n ) : NEW_LINE INDENT dp = [ 0 ] * ( n + 1 ) NEW_LINE dp [ 0 ] , dp [ 1 ] = 1 , 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , i + 1 ) : NEW_LINE INDENT dp [ i ] = dp [ i ] + ( dp [ i - j ] * dp [ j - 1 ] ) NEW_LINE DEDENT DEDENT return dp [ n ] NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 3 NEW_LINE print ( "" Number ▁ of ▁ structurally ▁ Unique ▁ BST ▁ with "" , n , "" keys ▁ are ▁ : "" , numberOfBST ( n ) ) NEW_LINE DEDENT +" +E1571,"class GFG { static int countdig ( int m ) { if ( m == 0 ) return 0 ; else return 1 + countdig ( m / 10 ) ; } static int countSteps ( int x ) { int c = 0 ; int last = x ; while ( last > 0 ) { int digits = countdig ( last ) ; digits -= 1 ; int divisor = ( int ) Math . pow ( 10 , digits ) ; int first = last / divisor ; int lastnumber = first * divisor ; int skipped = ( last - lastnumber ) / first ; skipped += 1 ; c += skipped ; last = last - ( first * skipped ) ; } return c ; } public static void main ( String [ ] args ) { int n = 14 ; System . out . println ( countSteps ( n ) ) ; } } +","def countdig ( m ) : NEW_LINE INDENT if ( m == 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 + countdig ( m // 10 ) NEW_LINE DEDENT DEDENT def countSteps ( x ) : NEW_LINE INDENT c = 0 NEW_LINE last = x NEW_LINE while ( last ) : NEW_LINE INDENT digits = countdig ( last ) NEW_LINE digits -= 1 NEW_LINE divisor = pow ( 10 , digits ) NEW_LINE first = last // divisor NEW_LINE lastnumber = first * divisor NEW_LINE skipped = ( last - lastnumber ) // first NEW_LINE skipped += 1 NEW_LINE c += skipped NEW_LINE last = last - ( first * skipped ) NEW_LINE DEDENT return c NEW_LINE DEDENT n = 14 NEW_LINE print ( countSteps ( n ) ) NEW_LINE +" +E1572,"import java . io . * ; class GFG { static int Add ( int x , int y ) { while ( y != 0 ) { int carry = x & y ; x = x ^ y ; y = carry << 1 ; } return x ; } public static void main ( String arg [ ] ) { System . out . println ( Add ( 15 , 32 ) ) ; } } +","def Add ( x , y ) : NEW_LINE INDENT while ( y != 0 ) : NEW_LINE INDENT carry = x & y NEW_LINE x = x ^ y NEW_LINE y = carry << 1 NEW_LINE DEDENT return x NEW_LINE DEDENT print ( Add ( 15 , 32 ) ) NEW_LINE +" +E1573,"import java . util . * ; import java . lang . * ; public class GfG { static Boolean isOverflow ( long a , long b ) { if ( a == 0 || b == 0 ) return false ; long result = a * b ; if ( a == result / b ) return false ; else return true ; } public static void main ( String argc [ ] ) { long a = Long . parseLong ( ""10000000000"" ) ; long b = Long . parseLong ( "" - 10000000000"" ) ; if ( isOverflow ( a , b ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def isOverflow ( a , b ) : NEW_LINE INDENT if ( a == 0 or b == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT result = a * b NEW_LINE if ( result >= 9223372036854775807 or result <= - 9223372036854775808 ) : NEW_LINE INDENT result = 0 NEW_LINE DEDENT if ( a == ( result // b ) ) : NEW_LINE INDENT print ( result // b ) NEW_LINE return False NEW_LINE DEDENT else : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = 10000000000 NEW_LINE b = - 10000000000 NEW_LINE if ( isOverflow ( a , b ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1574,"import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void pairWithEqualSum ( int A [ ] , int n ) { Map < Integer , Vector < pair > > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { pair p = new pair ( A [ i ] , A [ j ] ) ; Vector < pair > pp = new Vector < pair > ( ) ; if ( mp . containsKey ( A [ i ] + A [ j ] ) ) pp . addAll ( mp . get ( A [ i ] + A [ j ] ) ) ; pp . add ( p ) ; mp . put ( A [ i ] + A [ j ] , pp ) ; } } for ( Map . Entry < Integer , Vector < pair > > itr : mp . entrySet ( ) ) { if ( itr . getValue ( ) . size ( ) > 1 ) { System . out . print ( "" Pairs ▁ : ▁ "" ) ; for ( int i = 0 ; i < itr . getValue ( ) . size ( ) ; i ++ ) { System . out . print ( "" ( ▁ "" + itr . getValue ( ) . get ( i ) . first + "" , ▁ "" + itr . getValue ( ) . get ( i ) . second + "" ) ▁ "" ) ; } System . out . print ( "" ▁ have ▁ sum ▁ : ▁ "" + itr . getKey ( ) + "" \n "" ) ; } } } public static void main ( String [ ] args ) { int A [ ] = { 6 , 4 , 12 , 10 , 22 , 54 , 32 , 42 , 21 , 11 , 8 , 2 } ; int n = A . length ; pairWithEqualSum ( A , n ) ; } } +","def pairWithEqualSum ( A , n ) : NEW_LINE INDENT mp = { } NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT if A [ i ] + A [ j ] in mp : NEW_LINE INDENT mp [ A [ i ] + A [ j ] ] . append ( ( A [ i ] , A [ j ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT mp [ A [ i ] + A [ j ] ] = [ ( A [ i ] , A [ j ] ) ] NEW_LINE DEDENT DEDENT DEDENT for itr in mp : NEW_LINE INDENT if len ( mp [ itr ] ) > 1 : NEW_LINE INDENT print ( "" Pairs ▁ : ▁ "" , end = "" "" ) NEW_LINE for i in range ( 0 , len ( mp [ itr ] ) ) : NEW_LINE INDENT print ( "" ( "" , mp [ itr ] [ i ] [ 0 ] , "" , "" , mp [ itr ] [ i ] [ 1 ] , "" ) "" , end = "" ▁ "" ) NEW_LINE DEDENT print ( "" have ▁ sum ▁ : "" , itr ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 6 , 4 , 12 , 10 , 22 , 54 , 32 , 42 , 21 , 11 , 8 , 2 ] NEW_LINE n = len ( A ) NEW_LINE pairWithEqualSum ( A , n ) NEW_LINE DEDENT +" +E1575,"import java . util . * ; class GFG { static ArrayList < Integer > findingValues ( int m , int n , int mth , int nth ) { int d = ( Math . abs ( mth - nth ) ) / Math . abs ( ( m - 1 ) - ( n - 1 ) ) ; int a = mth - ( ( m - 1 ) * d ) ; ArrayList < Integer > res = new ArrayList < Integer > ( ) ; res . add ( a ) ; res . add ( d ) ; return res ; } static int findSum ( int m , int n , int mth , int nth , int p ) { ArrayList < Integer > ad = findingValues ( m , n , mth , nth ) ; int a = ad . get ( 0 ) ; int d = ad . get ( 1 ) ; int sum = ( p * ( 2 * a + ( p - 1 ) * d ) ) / 2 ; return sum ; } public static void main ( String [ ] args ) { int m = 6 , n = 10 , mTerm = 12 , nTerm = 20 , p = 5 ; System . out . println ( findSum ( m , n , mTerm , nTerm , p ) ) ; } } +","import math as mt NEW_LINE def findingValues ( m , n , mth , nth ) : NEW_LINE INDENT d = ( ( abs ( mth - nth ) ) / abs ( ( m - 1 ) - ( n - 1 ) ) ) NEW_LINE a = mth - ( ( m - 1 ) * d ) NEW_LINE return a , d NEW_LINE DEDENT def findSum ( m , n , mth , nth , p ) : NEW_LINE INDENT a , d = findingValues ( m , n , mth , nth ) NEW_LINE Sum = ( p * ( 2 * a + ( p - 1 ) * d ) ) / 2 NEW_LINE return Sum NEW_LINE DEDENT m = 6 NEW_LINE n = 10 NEW_LINE mTerm = 12 NEW_LINE nTerm = 20 NEW_LINE p = 5 NEW_LINE print ( findSum ( m , n , mTerm , nTerm , p ) ) NEW_LINE +" +E1576,"import java . util . * ; class GFG { static int sameOccurrence ( int arr [ ] , int n , int x , int y ) { int [ ] countX = new int [ n ] ; int [ ] countY = new int [ n ] ; Map < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == x ) { if ( i != 0 ) countX [ i ] = countX [ i - 1 ] + 1 ; else countX [ i ] = 1 ; } else { if ( i != 0 ) countX [ i ] = countX [ i - 1 ] ; else countX [ i ] = 0 ; } if ( arr [ i ] == y ) { if ( i != 0 ) countY [ i ] = countY [ i - 1 ] + 1 ; else countY [ i ] = 1 ; } else { if ( i != 0 ) countY [ i ] = countY [ i - 1 ] ; else countY [ i ] = 0 ; } if ( m . containsKey ( countX [ i ] - countY [ i ] ) ) { m . put ( countX [ i ] - countY [ i ] , m . get ( countX [ i ] - countY [ i ] ) + 1 ) ; } else { m . put ( countX [ i ] - countY [ i ] , 1 ) ; } } int result = m . get ( 0 ) ; for ( Map . Entry < Integer , Integer > it : m . entrySet ( ) ) result = result + ( ( it . getValue ( ) ) * ( ( it . getValue ( ) ) - 1 ) ) / 2 ; return ( result ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 3 , 4 , 1 } ; int n = arr . length ; int x = 2 , y = 3 ; System . out . println ( sameOccurrence ( arr , n , x , y ) ) ; } } +","def sameOccurrence ( arr , n , x , y ) : NEW_LINE INDENT countX = [ 0 for i in range ( n ) ] NEW_LINE countY = [ 0 for i in range ( n ) ] NEW_LINE m = dict ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] == x ) : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT countX [ i ] = countX [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT countX [ i ] = 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT countX [ i ] = countX [ i - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT countX [ i ] = 0 NEW_LINE DEDENT DEDENT if ( arr [ i ] == y ) : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT countY [ i ] = countY [ i - 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT countY [ i ] = 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( i != 0 ) : NEW_LINE INDENT countY [ i ] = countY [ i - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT countY [ i ] = 0 NEW_LINE DEDENT DEDENT m [ countX [ i ] - countY [ i ] ] = m . get ( countX [ i ] - countY [ i ] , 0 ) + 1 NEW_LINE DEDENT result = m [ 0 ] NEW_LINE for j in m : NEW_LINE INDENT result += ( m [ j ] * ( m [ j ] - 1 ) ) // 2 NEW_LINE DEDENT return result NEW_LINE DEDENT arr = [ 1 , 2 , 2 , 3 , 4 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE x , y = 2 , 3 NEW_LINE print ( sameOccurrence ( arr , n , x , y ) ) NEW_LINE +" +E1577,"class GfG { static void findNonPalinString ( char s [ ] ) { int freq [ ] = new int [ 26 ] ; int flag = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] != s [ 0 ] ) flag = 1 ; freq [ s [ i ] - ' a ' ] ++ ; } if ( flag == 0 ) System . out . println ( "" - 1"" ) ; else { for ( int i = 0 ; i < 26 ; i ++ ) for ( int j = 0 ; j < freq [ i ] ; j ++ ) System . out . print ( ( char ) ( ' a ' + i ) ) ; } } public static void main ( String [ ] args ) { String s = "" abba "" ; findNonPalinString ( s . toCharArray ( ) ) ; } } +","def findNonPalinString ( s ) : NEW_LINE INDENT freq = [ 0 ] * ( 26 ) NEW_LINE flag = 0 NEW_LINE for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT if s [ i ] != s [ 0 ] : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT if not flag : NEW_LINE INDENT print ( "" - 1"" ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( 0 , 26 ) : NEW_LINE INDENT for j in range ( 0 , freq [ i ] ) : NEW_LINE INDENT print ( chr ( ord ( ' a ' ) + i ) , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" abba "" NEW_LINE findNonPalinString ( s ) NEW_LINE DEDENT +" +E1578,"class GFG { static boolean isFrequencyEqual ( String str , int len ) { if ( len % 2 == 1 ) { return false ; } int i , freq [ ] = new int [ 26 ] ; for ( i = 0 ; i < len ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } for ( i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == len / 2 ) { return true ; } } return false ; } public static void main ( String [ ] args ) { String str = "" geeksforgeeks "" ; int len = str . length ( ) ; if ( isFrequencyEqual ( str , len ) ) { System . out . println ( "" Yes "" ) ; } else { System . out . println ( "" No "" ) ; } } } +","def isFrequencyEqual ( string , length ) : NEW_LINE INDENT if length % 2 == 1 : NEW_LINE INDENT return False NEW_LINE DEDENT freq = [ 0 ] * 26 NEW_LINE for i in range ( 0 , length ) : NEW_LINE INDENT freq [ ord ( string [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT for i in range ( 0 , 26 ) : NEW_LINE INDENT if freq [ i ] == length // 2 : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT string = "" geeksforgeeks "" NEW_LINE length = len ( string ) NEW_LINE if isFrequencyEqual ( string , length ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1579,"class GFG { static int summ ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } static void printDigitalRoot ( int n ) { int maxi = 1 ; int dig = 1 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { int d1 = summ ( n / i ) ; int d2 = summ ( i ) ; if ( d1 > maxi ) { dig = n / i ; maxi = d1 ; } if ( d2 > maxi ) { dig = i ; maxi = d2 ; } if ( d1 == maxi ) { if ( dig < ( n / i ) ) { dig = n / i ; maxi = d1 ; } } if ( d2 == maxi ) { if ( dig < i ) { dig = i ; maxi = d2 ; } } } } System . out . println ( dig + "" ▁ "" + maxi ) ; } public static void main ( String [ ] args ) { int n = 10 ; printDigitalRoot ( n ) ; } } +","def summ ( n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return 0 ; NEW_LINE DEDENT if ( n % 9 == 0 ) : NEW_LINE INDENT return 9 ; NEW_LINE DEDENT else : NEW_LINE INDENT return ( n % 9 ) ; NEW_LINE DEDENT DEDENT def printDigitalRoot ( n ) : NEW_LINE INDENT maxi = 1 ; NEW_LINE dig = 1 ; NEW_LINE for i in range ( 1 , int ( pow ( n , 1 / 2 ) + 1 ) ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT d1 = summ ( n / i ) ; NEW_LINE d2 = summ ( i ) ; NEW_LINE if ( d1 > maxi ) : NEW_LINE INDENT dig = n / i ; NEW_LINE maxi = d1 ; NEW_LINE DEDENT if ( d2 > maxi ) : NEW_LINE INDENT dig = i ; NEW_LINE maxi = d2 ; NEW_LINE DEDENT if ( d1 == maxi ) : NEW_LINE INDENT if ( dig < ( n / i ) ) : NEW_LINE INDENT dig = n / i ; NEW_LINE maxi = d1 ; NEW_LINE DEDENT DEDENT if ( d2 == maxi ) : NEW_LINE INDENT if ( dig < i ) : NEW_LINE INDENT dig = i ; NEW_LINE maxi = d2 ; NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( int ( dig ) , "" ▁ "" , int ( maxi ) ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 10 ; NEW_LINE printDigitalRoot ( n ) ; NEW_LINE DEDENT +" +E1580,"class GFG { static int countSubarrays ( int [ ] arr , int n ) { int difference = 0 ; int ans = 0 ; int [ ] hash_positive = new int [ n + 1 ] ; int [ ] hash_negative = new int [ n + 1 ] ; hash_positive [ 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & 1 ) == 1 ) { difference ++ ; } else { difference -- ; } if ( difference < 0 ) { ans += hash_negative [ - difference ] ; hash_negative [ - difference ] ++ ; } else { ans += hash_positive [ difference ] ; hash_positive [ difference ] ++ ; } } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 3 , 4 , 6 , 8 , 1 , 10 , 5 , 7 } ; int n = arr . length ; System . out . println ( "" Total ▁ Number ▁ of ▁ Even - Odd "" + "" ▁ subarrays ▁ are ▁ "" + countSubarrays ( arr , n ) ) ; } } +","def countSubarrays ( arr , n ) : NEW_LINE INDENT difference = 0 NEW_LINE ans = 0 NEW_LINE hash_positive = [ 0 ] * ( n + 1 ) NEW_LINE hash_negative = [ 0 ] * ( n + 1 ) NEW_LINE hash_positive [ 0 ] = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( arr [ i ] & 1 == 1 ) : NEW_LINE INDENT difference = difference + 1 NEW_LINE DEDENT else : NEW_LINE INDENT difference = difference - 1 NEW_LINE DEDENT if ( difference < 0 ) : NEW_LINE INDENT ans += hash_negative [ - difference ] NEW_LINE hash_negative [ - difference ] = hash_negative [ - difference ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += hash_positive [ difference ] NEW_LINE hash_positive [ difference ] = hash_positive [ difference ] + 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT arr = [ 3 , 4 , 6 , 8 , 1 , 10 , 5 , 7 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" Total ▁ Number ▁ of ▁ Even - Odd ▁ subarrays ▁ are ▁ "" + str ( countSubarrays ( arr , n ) ) ) NEW_LINE +" +E1581,"import java . util . * ; class GFG { static int MAX = 1000000 ; static boolean [ ] prime = new boolean [ MAX + 1 ] ; static void sieve ( ) { Arrays . fill ( prime , true ) ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= MAX ; i += p ) prime [ i ] = false ; } } } static int distinctSum ( int arr1 [ ] , int arr2 [ ] , int m , int n ) { sieve ( ) ; Set < Integer > sumSet = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( prime [ arr1 [ i ] ] && prime [ arr2 [ j ] ] ) sumSet . add ( arr1 [ i ] + arr2 [ j ] ) ; return sumSet . size ( ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 2 , 3 } ; int arr2 [ ] = { 2 , 2 , 4 , 7 } ; int m = arr1 . length ; int n = arr2 . length ; System . out . println ( distinctSum ( arr1 , arr2 , m , n ) ) ; } } +","MAX = 1000000 NEW_LINE prime = [ True for i in range ( MAX + 1 ) ] NEW_LINE def sieve ( ) : NEW_LINE INDENT prime [ 0 ] , prime [ 1 ] = False , False NEW_LINE for p in range ( 2 , MAX + 1 ) : NEW_LINE INDENT if p * p > MAX : NEW_LINE INDENT break NEW_LINE DEDENT if ( prime [ p ] == True ) : NEW_LINE INDENT for i in range ( 2 * p , MAX + 1 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT DEDENT DEDENT def distinctSum ( arr1 , arr2 , m , n ) : NEW_LINE INDENT sieve ( ) NEW_LINE sumSet = dict ( ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT if ( prime [ arr1 [ i ] ] and prime [ arr2 [ j ] ] ) : NEW_LINE INDENT sumSet [ arr1 [ i ] + arr2 [ j ] ] = 1 NEW_LINE DEDENT DEDENT DEDENT return len ( sumSet ) NEW_LINE DEDENT arr1 = [ 2 , 3 ] NEW_LINE arr2 = [ 2 , 2 , 4 , 7 ] NEW_LINE m = len ( arr1 ) NEW_LINE n = len ( arr2 ) NEW_LINE print ( distinctSum ( arr1 , arr2 , m , n ) ) NEW_LINE +" +E1582,"import java . io . * ; public class GFG { static void shufleArray ( int [ ] a , int n ) { int temp ; n = n / 2 ; for ( int start = n + 1 , j = n + 1 , done = 0 , i ; done < 2 * n - 2 ; done ++ ) { if ( start == j ) { start -- ; j -- ; } i = j > n ? j - n : j ; j = j > n ? 2 * i : 2 * i - 1 ; temp = a [ start ] ; a [ start ] = a [ j ] ; a [ j ] = temp ; } } static public void main ( String [ ] args ) { int [ ] a = { - 1 , 1 , 3 , 5 , 7 , 2 , 4 , 6 , 8 } ; int n = a . length ; shufleArray ( a , n ) ; for ( int i = 1 ; i < n ; i ++ ) System . out . print ( a [ i ] + "" ▁ "" ) ; } } +","def shufleArray ( a , n ) : NEW_LINE INDENT n = n // 2 NEW_LINE start = n + 1 NEW_LINE j = n + 1 NEW_LINE for done in range ( 2 * n - 2 ) : NEW_LINE INDENT if ( start == j ) : NEW_LINE INDENT start -= 1 NEW_LINE j -= 1 NEW_LINE DEDENT i = j - n if j > n else j NEW_LINE j = 2 * i if j > n else 2 * i - 1 NEW_LINE a [ start ] , a [ j ] = a [ j ] , a [ start ] NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT a = [ - 1 , 1 , 3 , 5 , 7 , 2 , 4 , 6 , 8 ] NEW_LINE n = len ( a ) NEW_LINE shufleArray ( a , n ) NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT print ( a [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT +" +E1583,"import java . util . * ; class GFG { static int MAX = 100005 ; static int Min_Replace ( int [ ] arr , int n , int k ) { Arrays . sort ( arr ) ; Integer [ ] freq = new Integer [ MAX ] ; Arrays . fill ( freq , 0 ) ; int p = 0 ; freq [ p ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) ++ freq [ p ] ; else ++ freq [ ++ p ] ; } Arrays . sort ( freq , Collections . reverseOrder ( ) ) ; int ans = 0 ; for ( int i = k ; i <= p ; i ++ ) ans += freq [ i ] ; return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 7 , 8 , 2 , 3 , 2 , 3 } ; int n = arr . length ; int k = 2 ; System . out . println ( Min_Replace ( arr , n , k ) ) ; } } +","MAX = 100005 NEW_LINE def Min_Replace ( arr , n , k ) : NEW_LINE INDENT arr . sort ( reverse = False ) NEW_LINE freq = [ 0 for i in range ( MAX ) ] NEW_LINE p = 0 NEW_LINE freq [ p ] = 1 NEW_LINE for i in range ( 1 , n , 1 ) : NEW_LINE INDENT if ( arr [ i ] == arr [ i - 1 ] ) : NEW_LINE INDENT freq [ p ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT p += 1 NEW_LINE freq [ p ] += 1 NEW_LINE DEDENT DEDENT freq . sort ( reverse = True ) NEW_LINE ans = 0 NEW_LINE for i in range ( k , p + 1 , 1 ) : NEW_LINE INDENT ans += freq [ i ] NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 1 , 2 , 7 , 8 , 2 , 3 , 2 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE k = 2 NEW_LINE print ( Min_Replace ( arr , n , k ) ) NEW_LINE DEDENT +" +E1584,"import java . io . * ; class GFG { static int MAX = 500 ; static int size = 1 ; static void factorial ( int [ ] prevFact , int prev , int n ) { for ( int x = prev + 1 ; x <= n ; x ++ ) size = multiply ( x , prevFact , size ) ; for ( int i = size - 1 ; i >= 0 ; i -- ) System . out . print ( prevFact [ i ] ) ; System . out . print ( "" ▁ "" ) ; } static void printfibFactorials ( int limit ) { if ( limit < 1 ) return ; int a = 1 , b = 1 , c = 2 ; System . out . print ( a + "" ▁ "" + b + "" ▁ "" ) ; int [ ] prevFact = new int [ MAX ] ; prevFact [ 0 ] = 1 ; while ( c < limit ) { factorial ( prevFact , b , c ) ; a = b ; b = c ; c = a + b ; } } static int multiply ( int x , int [ ] prevFact , int size ) { int carry = 0 ; for ( int i = 0 ; i < size ; i ++ ) { int prod = prevFact [ i ] * x + carry ; prevFact [ i ] = prod % 10 ; carry = prod / 10 ; } while ( carry != 0 ) { prevFact [ size ] = carry % 10 ; carry = carry / 10 ; size ++ ; } return size ; } public static void main ( String args [ ] ) { int limit = 20 ; printfibFactorials ( limit ) ; } } +","MAX = 500 NEW_LINE size = 1 NEW_LINE def factorial ( prevFact , prev , n ) : NEW_LINE INDENT global size NEW_LINE for x in range ( ( prev + 1 ) , n + 1 ) : NEW_LINE INDENT size = multiply ( x , prevFact , size ) NEW_LINE DEDENT for i in range ( ( size - 1 ) , - 1 , - 1 ) : NEW_LINE INDENT print ( prevFact [ i ] , end = "" "" ) NEW_LINE DEDENT print ( end = "" ▁ "" ) NEW_LINE DEDENT def printfibFactorials ( limit ) : NEW_LINE INDENT if ( limit < 1 ) : NEW_LINE INDENT return NEW_LINE DEDENT a = 1 NEW_LINE b = 1 NEW_LINE c = 2 NEW_LINE print ( a , b , end = "" ▁ "" ) NEW_LINE prevFact = [ 0 ] * MAX NEW_LINE prevFact [ 0 ] = 1 NEW_LINE while ( c < limit ) : NEW_LINE INDENT factorial ( prevFact , b , c ) NEW_LINE a = b NEW_LINE b = c NEW_LINE c = a + b NEW_LINE DEDENT DEDENT def multiply ( x , prevFact , size ) : NEW_LINE INDENT carry = 0 NEW_LINE for i in range ( 0 , size ) : NEW_LINE INDENT prod = prevFact [ i ] * x + carry NEW_LINE prevFact [ i ] = prod % 10 NEW_LINE carry = prod // 10 NEW_LINE DEDENT while ( carry != 0 ) : NEW_LINE INDENT prevFact [ size ] = carry % 10 NEW_LINE carry = carry // 10 NEW_LINE size = size + 1 NEW_LINE DEDENT return size NEW_LINE DEDENT limit = 20 NEW_LINE printfibFactorials ( limit ) NEW_LINE +" +E1585,"import java . util . * ; import java . lang . * ; class GFG { static int MAX = 3000 ; public static int smartNumber ( int n ) { Integer [ ] primes = new Integer [ MAX ] ; Arrays . fill ( primes , new Integer ( 0 ) ) ; Vector < Integer > result = new Vector < > ( ) ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( primes [ i ] == 0 ) { primes [ i ] = 1 ; for ( int j = i * 2 ; j < MAX ; j = j + i ) { primes [ j ] -= 1 ; if ( ( primes [ j ] + 3 ) == 0 ) result . add ( j ) ; } } } Collections . sort ( result ) ; return result . get ( n - 1 ) ; } public static void main ( String [ ] args ) { int n = 50 ; System . out . println ( smartNumber ( n ) ) ; } } +","MAX = 3000 ; NEW_LINE def smartNumber ( n ) : NEW_LINE INDENT primes = [ 0 ] * MAX ; NEW_LINE result = [ ] ; NEW_LINE for i in range ( 2 , MAX ) : NEW_LINE INDENT if ( primes [ i ] == 0 ) : NEW_LINE INDENT primes [ i ] = 1 ; NEW_LINE j = i * 2 ; NEW_LINE while ( j < MAX ) : NEW_LINE INDENT primes [ j ] -= 1 ; NEW_LINE if ( ( primes [ j ] + 3 ) == 0 ) : NEW_LINE INDENT result . append ( j ) ; NEW_LINE DEDENT j = j + i ; NEW_LINE DEDENT DEDENT DEDENT result . sort ( ) ; NEW_LINE return result [ n - 1 ] ; NEW_LINE DEDENT n = 50 ; NEW_LINE print ( smartNumber ( n ) ) ; NEW_LINE +" +E1586,"class GFG { static int countPairs ( int n ) { int count = 0 ; for ( int x = 1 ; x < n ; x ++ ) { for ( int y = x + 1 ; y <= n ; y ++ ) { if ( ( y + x ) % ( y ^ x ) == 0 ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( countPairs ( n ) ) ; } } +","def countPairs ( n ) : NEW_LINE INDENT count = 0 ; NEW_LINE for x in range ( 1 , n ) : NEW_LINE INDENT for y in range ( x + 1 , n + 1 ) : NEW_LINE INDENT if ( ( y + x ) % ( y ^ x ) == 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT DEDENT return count ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 6 ; NEW_LINE print ( countPairs ( n ) ) ; NEW_LINE DEDENT +" +E1587,"public class GFG { public int [ ] AllIndexesRecursive ( int input [ ] , int x , int start ) { if ( start == input . length ) { int [ ] ans = new int [ 0 ] ; return ans ; } int [ ] smallIndex = AllIndexesRecursive ( input , x , start + 1 ) ; if ( input [ start ] == x ) { int [ ] myAns = new int [ smallIndex . length + 1 ] ; myAns [ 0 ] = start ; for ( int i = 0 ; i < smallIndex . length ; i ++ ) { myAns [ i + 1 ] = smallIndex [ i ] ; } return myAns ; } else { return smallIndex ; } } public int [ ] AllIndexes ( int input [ ] , int x ) { return AllIndexesRecursive ( input , x , 0 ) ; } public static void main ( String args [ ] ) { GFG g = new GFG ( ) ; int arr [ ] = { 1 , 2 , 3 , 2 , 2 , 5 } , x = 2 ; int output [ ] = g . AllIndexes ( arr , x ) ; for ( int i = 0 ; i < output . length ; i ++ ) { System . out . print ( output [ i ] + "" ▁ "" ) ; } } } +","def AllIndexesRecursive ( input , x , start ) : NEW_LINE INDENT if ( start == len ( input ) ) : NEW_LINE INDENT ans = [ ] NEW_LINE return ans NEW_LINE DEDENT smallIndex = AllIndexesRecursive ( input , x , start + 1 ) NEW_LINE if ( input [ start ] == x ) : NEW_LINE INDENT myAns = [ 0 for i in range ( len ( smallIndex ) + 1 ) ] NEW_LINE myAns [ 0 ] = start NEW_LINE for i in range ( len ( smallIndex ) ) : NEW_LINE INDENT myAns [ i + 1 ] = smallIndex [ i ] NEW_LINE DEDENT return myAns NEW_LINE DEDENT else : NEW_LINE INDENT return smallIndex NEW_LINE DEDENT DEDENT def AllIndexes ( input , x ) : NEW_LINE INDENT return AllIndexesRecursive ( input , x , 0 ) NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 2 , 2 , 5 ] NEW_LINE x = 2 NEW_LINE output = AllIndexes ( arr , x ) NEW_LINE for i in output : NEW_LINE INDENT print ( i , end = "" ▁ "" ) NEW_LINE DEDENT +" +E1588,"import java . lang . Math ; class GFG { static int fib ( int n ) { double phi = ( 1 + Math . sqrt ( 5 ) ) / 2 ; return ( int ) Math . round ( Math . pow ( phi , n ) / Math . sqrt ( 5 ) ) ; } static int calculateSum ( int l , int r ) { int sum = 0 ; for ( int i = l ; i <= r ; i ++ ) sum += fib ( i ) ; return sum ; } public static void main ( String [ ] args ) { int l = 4 , r = 8 ; System . out . println ( calculateSum ( l , r ) ) ; } } +","def fib ( n ) : NEW_LINE INDENT phi = ( ( 1 + ( 5 ** ( 1 / 2 ) ) ) / 2 ) ; NEW_LINE return round ( ( phi ** n ) / ( 5 ** ( 1 / 2 ) ) ) ; NEW_LINE DEDENT def calculateSum ( l , r ) : NEW_LINE INDENT sum = 0 ; NEW_LINE for i in range ( l , r + 1 ) : NEW_LINE INDENT sum += fib ( i ) ; NEW_LINE DEDENT return sum ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT l , r = 4 , 8 ; NEW_LINE print ( calculateSum ( l , r ) ) ; NEW_LINE DEDENT +" +E1589,"import java . util . * ; class solution { static int findSum ( int N ) { return ( N * ( N + 1 ) * ( 2 * N - 5 ) + 4 * N ) / 2 ; } public static void main ( String arr [ ] ) { int N = 3 ; System . out . println ( findSum ( N ) ) ; } } +","def findSum ( N ) : NEW_LINE INDENT return ( ( N * ( N + 1 ) * ( 2 * N - 5 ) + 4 * N ) / 2 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 3 NEW_LINE print ( findSum ( N ) ) NEW_LINE DEDENT +" +E1590,"class Sum { void sumOfPrevK ( int N , int K ) { int arr [ ] = new int [ N ] ; arr [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { int j = i - 1 , count = 0 , sum = 0 ; while ( j >= 0 && count < K ) { sum += arr [ j ] ; j -- ; count ++ ; } arr [ i ] = sum ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } public static void main ( String args [ ] ) { Sum s = new Sum ( ) ; int N = 10 , K = 4 ; s . sumOfPrevK ( N , K ) ; } } +","def sumOfPrevK ( N , K ) : NEW_LINE INDENT arr = [ 0 for i in range ( N ) ] NEW_LINE arr [ 0 ] = 1 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT j = i - 1 NEW_LINE count = 0 NEW_LINE sum = 0 NEW_LINE while ( j >= 0 and count < K ) : NEW_LINE INDENT sum = sum + arr [ j ] NEW_LINE j = j - 1 NEW_LINE count = count + 1 NEW_LINE DEDENT arr [ i ] = sum NEW_LINE DEDENT for i in range ( 0 , N ) : NEW_LINE INDENT print ( arr [ i ] ) NEW_LINE DEDENT DEDENT N = 10 NEW_LINE K = 4 NEW_LINE sumOfPrevK ( N , K ) NEW_LINE +" +E1591,"class GFG { static boolean productDivisible ( int n , int k ) { int product = 1 , position = 1 ; while ( n > 0 ) { if ( position % 2 == 0 ) { product *= n % 10 ; } n = n / 10 ; position ++ ; } if ( product % k == 0 ) { return true ; } return false ; } public static void main ( String [ ] args ) { int n = 321922 ; int k = 3 ; if ( productDivisible ( n , k ) ) { System . out . println ( "" YES "" ) ; } else { System . out . println ( "" NO "" ) ; } } } +","def productDivisible ( n , k ) : NEW_LINE INDENT product = 1 NEW_LINE position = 1 NEW_LINE while n > 0 : NEW_LINE INDENT if position % 2 == 0 : NEW_LINE INDENT product *= n % 10 NEW_LINE DEDENT n = n / 10 NEW_LINE position += 1 NEW_LINE DEDENT if product % k == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT n = 321922 NEW_LINE k = 3 NEW_LINE if productDivisible ( n , k ) == True : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT +" +E1592,"class Test { static int countPairs ( int N ) { int count = 0 ; for ( int i = 1 ; i <= Math . cbrt ( N ) ; i ++ ) { int cb = i * i * i ; int diff = N - cb ; int cbrtDiff = ( int ) Math . cbrt ( diff ) ; if ( cbrtDiff * cbrtDiff * cbrtDiff == diff ) count ++ ; } return count ; } public static void main ( String args [ ] ) { for ( int i = 1 ; i <= 10 ; i ++ ) System . out . println ( "" For ▁ n ▁ = ▁ "" + i + "" , ▁ "" + + countPairs ( i ) + "" ▁ pair ▁ exists "" ) ; } } +","import math NEW_LINE def countPairs ( N ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( 1 , int ( math . pow ( N , 1 / 3 ) + 1 ) ) : NEW_LINE INDENT cb = i * i * i NEW_LINE diff = N - cb NEW_LINE cbrtDiff = int ( math . pow ( diff , 1 / 3 ) ) NEW_LINE if ( cbrtDiff * cbrtDiff * cbrtDiff == diff ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT for i in range ( 1 , 11 ) : NEW_LINE INDENT print ( ' For ▁ n ▁ = ▁ ' , i , ' , ▁ ' , countPairs ( i ) , ' ▁ pair ▁ exists ' ) NEW_LINE DEDENT +" +E1593,"import java . util . * ; class GFG { static int MAX = 100 ; static Vector < Integer > Prefix = new Vector < > ( ) ; static int repeated_digit ( int n ) { HashSet < Integer > a = new HashSet < > ( ) ; int d ; while ( n != 0 ) { d = n % 10 ; if ( a . contains ( d ) ) return 0 ; a . add ( d ) ; n /= 10 ; } return 1 ; } static void pre_calculations ( ) { Prefix . add ( 0 ) ; Prefix . add ( repeated_digit ( 1 ) ) ; for ( int i = 2 ; i < MAX + 1 ; i ++ ) Prefix . add ( repeated_digit ( i ) + Prefix . elementAt ( i - 1 ) ) ; } static int calculate ( int L , int R ) { return Prefix . elementAt ( R ) - Prefix . elementAt ( L - 1 ) ; } public static void main ( String [ ] args ) { int L = 1 , R = 100 ; pre_calculations ( ) ; System . out . println ( calculate ( L , R ) ) ; } } +","Prefix = [ 0 ] NEW_LINE def repeated_digit ( n ) : NEW_LINE INDENT a = [ ] NEW_LINE while n != 0 : NEW_LINE INDENT d = n % 10 NEW_LINE if d in a : NEW_LINE INDENT return 0 NEW_LINE DEDENT a . append ( d ) NEW_LINE n = n // 10 NEW_LINE DEDENT return 1 NEW_LINE DEDENT def pre_calculation ( MAX ) : NEW_LINE INDENT global Prefix NEW_LINE Prefix . append ( repeated_digit ( 1 ) ) NEW_LINE for i in range ( 2 , MAX + 1 ) : NEW_LINE INDENT Prefix . append ( repeated_digit ( i ) + Prefix [ i - 1 ] ) NEW_LINE DEDENT DEDENT def calculate ( L , R ) : NEW_LINE INDENT return Prefix [ R ] - Prefix [ L - 1 ] NEW_LINE DEDENT MAX = 1000 NEW_LINE pre_calculation ( MAX ) NEW_LINE L = 1 NEW_LINE R = 100 NEW_LINE print ( calculate ( L , R ) ) NEW_LINE +" +E1594,"class GFG { static boolean Survives ( int n ) { for ( int i = 2 ; ; i ++ ) { if ( i > n ) return true ; if ( n % i == 0 ) return false ; n -= n / i ; } } public static void main ( String [ ] args ) { int n = 17 ; if ( Survives ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def Survives ( n ) : NEW_LINE INDENT i = 2 NEW_LINE while ( True ) : NEW_LINE INDENT if ( i > n ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT if ( n % i == 0 ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT n -= n // i ; NEW_LINE i += 1 NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 17 ; NEW_LINE if ( Survives ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT DEDENT +" +E1595,"import java . io . * ; class GFG { static void maxPerimeter ( int arr [ ] , int n ) { int maxi = 0 ; for ( int i = 0 ; i < n - 2 ; i ++ ) { for ( int j = i + 1 ; j < n - 1 ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { int a = arr [ i ] ; int b = arr [ j ] ; int c = arr [ k ] ; if ( a < b + c && b < c + a && c < a + b ) { maxi = Math . max ( maxi , a + b + c ) ; } } } } if ( maxi > 0 ) System . out . println ( "" Maximum ▁ Perimeter ▁ is : ▁ "" + maxi ) ; else System . out . println ( "" Triangle ▁ formation ▁ "" + "" is ▁ not ▁ possible . "" ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 6 , 1 , 6 , 5 , 8 , 4 } ; maxPerimeter ( arr1 , 6 ) ; int arr2 [ ] = { 2 , 20 , 7 , 55 , 1 , 33 , 12 , 4 } ; maxPerimeter ( arr2 , 8 ) ; int arr3 [ ] = { 33 , 6 , 20 , 1 , 8 , 12 , 5 , 55 , 4 , 9 } ; maxPerimeter ( arr3 , 10 ) ; } } +","def maxPerimeter ( arr ) : NEW_LINE INDENT maxi = 0 NEW_LINE n = len ( arr ) NEW_LINE for i in range ( n - 2 ) : NEW_LINE INDENT for j in range ( i + 1 , n - 1 ) : NEW_LINE INDENT for k in range ( j + 1 , n ) : NEW_LINE INDENT a = arr [ i ] NEW_LINE b = arr [ j ] NEW_LINE c = arr [ k ] NEW_LINE if ( a < b + c and b < a + c and c < a + b ) : NEW_LINE INDENT maxi = max ( maxi , a + b + c ) NEW_LINE DEDENT DEDENT DEDENT DEDENT if ( maxi == 0 ) : NEW_LINE INDENT return "" Triangle ▁ formation ▁ is ▁ not ▁ possible "" NEW_LINE DEDENT else : NEW_LINE INDENT return "" Maximum ▁ Perimeter ▁ is : ▁ "" + str ( maxi ) NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT arr1 = [ 6 , 1 , 6 , 5 , 8 , 4 ] NEW_LINE a = maxPerimeter ( arr1 ) NEW_LINE print ( a ) NEW_LINE arr2 = [ 2 , 20 , 7 , 55 , 1 , 33 , 12 , 4 ] NEW_LINE a = maxPerimeter ( arr2 ) NEW_LINE print ( a ) NEW_LINE arr3 = [ 33 , 6 , 20 , 1 , 8 , 12 , 5 , 55 , 4 , 9 ] NEW_LINE a = maxPerimeter ( arr3 ) NEW_LINE print ( a ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT +" +E1596,"import java . util . * ; class GFG { static boolean isPerfectSquare ( int x ) { int s = ( int ) Math . sqrt ( x ) ; return ( s * s == x ) ; } static boolean isFibonacci ( int N ) { return isPerfectSquare ( 5 * N * N + 4 ) || isPerfectSquare ( 5 * N * N - 4 ) ; } static int nextNonFibonacci ( int N ) { if ( N <= 3 ) return 4 ; if ( isFibonacci ( N + 1 ) ) return N + 2 ; else return N + 1 ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . print ( nextNonFibonacci ( N ) + "" \n "" ) ; N = 5 ; System . out . print ( nextNonFibonacci ( N ) + "" \n "" ) ; N = 7 ; System . out . print ( nextNonFibonacci ( N ) + "" \n "" ) ; } } +","from math import sqrt NEW_LINE def isPerfectSquare ( x ) : NEW_LINE INDENT s = sqrt ( x ) NEW_LINE return ( s * s == x ) NEW_LINE DEDENT def isFibonacci ( N ) : NEW_LINE INDENT return isPerfectSquare ( 5 * N * N + 4 ) or \ NEW_LINE INDENT isPerfectSquare ( 5 * N * N - 4 ) NEW_LINE DEDENT DEDENT def nextNonFibonacci ( N ) : NEW_LINE INDENT if ( N <= 3 ) : NEW_LINE INDENT return 4 NEW_LINE DEDENT if ( isFibonacci ( N + 1 ) ) : NEW_LINE INDENT return N + 2 NEW_LINE DEDENT else : NEW_LINE INDENT return N NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 3 NEW_LINE print ( nextNonFibonacci ( N ) ) NEW_LINE N = 4 NEW_LINE print ( nextNonFibonacci ( N ) ) NEW_LINE N = 7 NEW_LINE print ( nextNonFibonacci ( N ) ) NEW_LINE DEDENT +" +E1597,"public class GFG { static boolean bit_check ( int n ) { if ( ( n & ( n - 1 ) ) == 0 ) return true ; return false ; } public static void main ( String args [ ] ) { int n = 14 ; if ( bit_check ( n ) ) System . out . println ( '1' ) ; else System . out . println ( '0' ) ; } } +","def bit_check ( n ) : NEW_LINE INDENT if ( ( n & ( n - 1 ) ) == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 14 NEW_LINE if ( bit_check ( n ) ) : NEW_LINE INDENT print ( '1' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( '0' ) NEW_LINE DEDENT DEDENT +" +E1598,"import java . io . * ; class GFG { static int center_hexadecagonal_num ( int n ) { return 8 * n * n - 8 * n + 1 ; } public static void main ( String args [ ] ) { int n = 2 ; System . out . print ( n + "" th ▁ centered ▁ "" + "" hexadecagonal ▁ number : ▁ "" ) ; System . out . println ( center_hexadecagonal_num ( n ) ) ; n = 12 ; System . out . print ( n + "" th ▁ centered ▁ "" + "" hexadecagonal ▁ number : ▁ "" ) ; System . out . println ( center_hexadecagonal_num ( n ) ) ; } } +","def center_hexadecagonal_num ( n ) : NEW_LINE INDENT return 8 * n * n - 8 * n + 1 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 2 NEW_LINE print ( n , "" nd ▁ centered ▁ hexadecagonal ▁ "" + "" number ▁ : ▁ "" , center_hexadecagonal_num ( n ) ) NEW_LINE n = 12 NEW_LINE print ( n , "" th ▁ centered ▁ hexadecagonal ▁ "" + "" number ▁ : ▁ "" , center_hexadecagonal_num ( n ) ) NEW_LINE DEDENT +" +E1599,"import java . io . * ; class GFG { static void fib ( int n ) { int a = 0 , b = 1 ; if ( n >= 0 ) System . out . print ( a + "" ▁ "" ) ; if ( n >= 1 ) System . out . print ( b + "" ▁ "" ) ; for ( int i = 2 ; i <= n ; i ++ ) { System . out . print ( a + b + "" ▁ "" ) ; b = a + b ; a = b - a ; } } public static void main ( String [ ] args ) { fib ( 9 ) ; } } +","def fib ( n ) : NEW_LINE INDENT a = 0 NEW_LINE b = 1 NEW_LINE if ( n >= 0 ) : NEW_LINE INDENT print ( a , end = ' ▁ ' ) NEW_LINE DEDENT if ( n >= 1 ) : NEW_LINE INDENT print ( b , end = ' ▁ ' ) NEW_LINE DEDENT for i in range ( 2 , n + 1 ) : NEW_LINE INDENT print ( a + b , end = ' ▁ ' ) NEW_LINE b = a + b NEW_LINE a = b - a NEW_LINE DEDENT DEDENT fib ( 9 ) NEW_LINE +" +E1600,"import java . util . * ; class GFG { static boolean prime ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } static void thirdNumber ( int a , int b ) { int sum = 0 , temp = 0 ; sum = a + b ; temp = 1 ; if ( sum == 0 ) { temp = 2 ; } while ( ! prime ( sum + temp ) ) { temp += 2 ; } System . out . print ( temp ) ; } static public void main ( String [ ] arr ) { int a = 3 , b = 5 ; thirdNumber ( a , b ) ; } } +","def prime ( n ) : NEW_LINE INDENT for i in range ( 2 , n + 1 ) : NEW_LINE INDENT if i * i > n + 1 : NEW_LINE INDENT break NEW_LINE DEDENT if ( n % i == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def thirdNumber ( a , b ) : NEW_LINE INDENT summ = 0 NEW_LINE temp = 0 NEW_LINE summ = a + b NEW_LINE temp = 1 NEW_LINE if ( summ & 1 ) : NEW_LINE INDENT temp = 2 NEW_LINE DEDENT while ( prime ( summ + temp ) == False ) : NEW_LINE INDENT temp += 2 NEW_LINE DEDENT print ( temp ) NEW_LINE DEDENT a = 3 NEW_LINE b = 5 NEW_LINE thirdNumber ( a , b ) NEW_LINE +" +E1601,"import java . io . * ; class GFG { static boolean isBetween ( int a , int b , int c ) { return ( Math . min ( a , b ) <= c && c <= Math . max ( a , b ) ) ; } static boolean canJoin ( int x [ ] , int y [ ] , int i , int j , int k ) { return ( x [ k ] == x [ i ] || x [ k ] == x [ j ] ) && isBetween ( y [ i ] , y [ j ] , y [ k ] ) || ( y [ k ] == y [ i ] || y [ k ] == y [ j ] ) && isBetween ( x [ i ] , x [ j ] , x [ k ] ) ; } static int countLineSegments ( int x [ ] , int y [ ] ) { if ( ( x [ 0 ] == x [ 1 ] && x [ 1 ] == x [ 2 ] ) || ( y [ 0 ] == y [ 1 ] && y [ 1 ] == y [ 2 ] ) ) return 1 ; else if ( canJoin ( x , y , 0 , 1 , 2 ) || canJoin ( x , y , 0 , 2 , 1 ) || canJoin ( x , y , 1 , 2 , 0 ) ) return 2 ; else return 3 ; } public static void main ( String [ ] args ) { int x [ ] = new int [ 3 ] , y [ ] = new int [ 3 ] ; x [ 0 ] = - 1 ; y [ 0 ] = - 1 ; x [ 1 ] = - 1 ; y [ 1 ] = 3 ; x [ 2 ] = 4 ; y [ 2 ] = 3 ; System . out . println ( countLineSegments ( x , y ) ) ; } } +","import math NEW_LINE def isBetween ( a , b , c ) : NEW_LINE INDENT return min ( a , b ) <= c and c <= max ( a , b ) NEW_LINE DEDENT def canJoin ( x , y , i , j , k ) : NEW_LINE INDENT return ( x [ k ] == x [ i ] or x [ k ] == x [ j ] ) and isBetween ( y [ i ] , y [ j ] , y [ k ] ) or ( y [ k ] == y [ i ] or y [ k ] == y [ j ] ) and isBetween ( x [ i ] , x [ j ] , x [ k ] ) NEW_LINE DEDENT def countLineSegments ( x , y ) : NEW_LINE INDENT if ( ( x [ 0 ] == x [ 1 ] and x [ 1 ] == x [ 2 ] ) or ( y [ 0 ] == y [ 1 ] and y [ 1 ] == y [ 2 ] ) ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT elif ( canJoin ( x , y , 0 , 1 , 2 ) or canJoin ( x , y , 0 , 2 , 1 ) or canJoin ( x , y , 1 , 2 , 0 ) ) : NEW_LINE INDENT return 2 NEW_LINE DEDENT else : NEW_LINE INDENT return 3 NEW_LINE DEDENT DEDENT x = [ - 1 , - 1 , 4 ] NEW_LINE y = [ - 1 , 3 , 3 ] NEW_LINE print ( countLineSegments ( x , y ) ) NEW_LINE +" +E1602,"class GFG { static void ReplaceElements ( int arr [ ] , int n ) { int min_ele = arr [ 0 ] ; arr [ 0 ] = - 1 ; for ( int i = 1 ; i < n ; ++ i ) { if ( min_ele < arr [ i ] ) { arr [ i ] = min_ele ; } else if ( min_ele >= arr [ i ] ) { int temp = arr [ i ] ; arr [ i ] = min_ele ; min_ele = temp ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 2 , 1 , 7 , 6 } ; int n = arr . length ; ReplaceElements ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } } +","def ReplaceElements ( arr , n ) : NEW_LINE INDENT min_ele = arr [ 0 ] NEW_LINE arr [ 0 ] = - 1 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( min_ele < arr [ i ] ) : NEW_LINE INDENT arr [ i ] = min_ele NEW_LINE DEDENT elif ( min_ele >= arr [ i ] ) : NEW_LINE INDENT temp = arr [ i ] NEW_LINE arr [ i ] = min_ele NEW_LINE min_ele = temp NEW_LINE DEDENT DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 4 , 5 , 2 , 1 , 7 , 6 ] NEW_LINE n = len ( arr ) NEW_LINE ReplaceElements ( arr , n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT +" +E1603,"class GFG { static void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + "" ▁ "" ) ; } } static int getMin ( int arr [ ] , int i , int j ) { int minVal = arr [ i ++ ] ; while ( i <= j ) { minVal = Math . min ( minVal , arr [ i ] ) ; i ++ ; } return minVal ; } static int getMax ( int arr [ ] , int i , int j ) { int maxVal = arr [ i ++ ] ; while ( i <= j ) { maxVal = Math . max ( maxVal , arr [ i ] ) ; i ++ ; } return maxVal ; } static void generateArr ( int arr [ ] , int n ) { if ( n == 0 ) return ; if ( n == 1 ) { System . out . println ( arr [ 0 ] ) ; return ; } int tmpArr [ ] = new int [ n ] ; tmpArr [ 0 ] = getMax ( arr , 1 , n - 1 ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { tmpArr [ i ] = Math . abs ( getMax ( arr , i + 1 , n - 1 ) - getMin ( arr , 0 , i - 1 ) ) ; } tmpArr [ n - 1 ] = getMin ( arr , 0 , n - 2 ) ; printArray ( tmpArr , n ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 2 , 4 , 3 } ; int n = arr . length ; generateArr ( arr , n ) ; } } +","def printArray ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT DEDENT def getMin ( arr , i , j ) : NEW_LINE INDENT minVal = arr [ i ] NEW_LINE i += 1 NEW_LINE while ( i <= j ) : NEW_LINE INDENT minVal = min ( minVal , arr [ i ] ) NEW_LINE i += 1 NEW_LINE DEDENT return minVal NEW_LINE DEDENT def getMax ( arr , i , j ) : NEW_LINE INDENT maxVal = arr [ i ] NEW_LINE i += 1 NEW_LINE while ( i <= j ) : NEW_LINE INDENT maxVal = max ( maxVal , arr [ i ] ) NEW_LINE i += 1 NEW_LINE DEDENT return maxVal NEW_LINE DEDENT def generateArr ( arr , n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return NEW_LINE DEDENT if ( n == 1 ) : NEW_LINE INDENT print ( arr [ 0 ] , end = "" "" ) NEW_LINE return NEW_LINE DEDENT tmpArr = [ 0 for i in range ( n ) ] NEW_LINE tmpArr [ 0 ] = getMax ( arr , 1 , n - 1 ) NEW_LINE for i in range ( 1 , n - 1 ) : NEW_LINE INDENT tmpArr [ i ] = abs ( getMax ( arr , i + 1 , n - 1 ) - getMin ( arr , 0 , i - 1 ) ) NEW_LINE DEDENT tmpArr [ n - 1 ] = getMin ( arr , 0 , n - 2 ) NEW_LINE printArray ( tmpArr , n ) NEW_LINE DEDENT arr = [ 1 , 5 , 2 , 4 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE generateArr ( arr , n ) NEW_LINE +" +E1604,"class GFG { static int totEdge ( int n ) { int result = 0 ; result = ( n * ( n - 1 ) ) / 2 ; return result ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( totEdge ( n ) ) ; } } +","def totEdge ( n ) : NEW_LINE INDENT result = ( n * ( n - 1 ) ) // 2 NEW_LINE return result NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 6 NEW_LINE print ( totEdge ( n ) ) NEW_LINE DEDENT +" +E1605,"class GFG { static int countNumbers ( int L , int R , int K ) { if ( K == 9 ) { K = 0 ; } int totalnumbers = R - L + 1 ; int factor9 = totalnumbers / 9 ; int rem = totalnumbers % 9 ; int ans = factor9 ; for ( int i = R ; i > R - rem ; i -- ) { int rem1 = i % 9 ; if ( rem1 == K ) { ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { int L = 10 ; int R = 22 ; int K = 3 ; System . out . println ( countNumbers ( L , R , K ) ) ; } } +","def countNumbers ( L , R , K ) : NEW_LINE INDENT if ( K == 9 ) : NEW_LINE INDENT K = 0 NEW_LINE DEDENT totalnumbers = R - L + 1 NEW_LINE factor9 = totalnumbers // 9 NEW_LINE rem = totalnumbers % 9 NEW_LINE ans = factor9 NEW_LINE for i in range ( R , R - rem , - 1 ) : NEW_LINE INDENT rem1 = i % 9 NEW_LINE if ( rem1 == K ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT L = 10 NEW_LINE R = 22 NEW_LINE K = 3 NEW_LINE print ( countNumbers ( L , R , K ) ) NEW_LINE +" +E1606,"import java . io . * ; class GFG { static void SieveOfEratosthenes ( int n , boolean prime [ ] , boolean primesquare [ ] , int a [ ] ) { for ( int i = 2 ; i <= n ; i ++ ) prime [ i ] = true ; for ( int i = 0 ; i < ( ( n * n ) + 1 ) ; i ++ ) primesquare [ i ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } int j = 0 ; for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { a [ j ] = p ; primesquare [ p * p ] = true ; j ++ ; } } } static int countDivisors ( int n ) { if ( n == 1 ) return 1 ; boolean prime [ ] = new boolean [ n + 1 ] ; boolean primesquare [ ] = new boolean [ ( n * n ) + 1 ] ; int a [ ] = new int [ n ] ; SieveOfEratosthenes ( n , prime , primesquare , a ) ; int ans = 1 ; for ( int i = 0 ; ; i ++ ) { if ( a [ i ] * a [ i ] * a [ i ] > n ) break ; int cnt = 1 ; while ( n % a [ i ] == 0 ) { n = n / a [ i ] ; cnt = cnt + 1 ; } ans = ans * cnt ; } if ( prime [ n ] ) ans = ans * 2 ; else if ( primesquare [ n ] ) ans = ans * 3 ; else if ( n != 1 ) ans = ans * 4 ; return ans ; } public static void main ( String args [ ] ) { System . out . println ( "" Total ▁ distinct ▁ divisors "" + "" ▁ of ▁ 100 ▁ are ▁ : ▁ "" + countDivisors ( 100 ) ) ; } } +","def SieveOfEratosthenes ( n , prime , primesquare , a ) : NEW_LINE INDENT for i in range ( 2 , n + 1 ) : NEW_LINE INDENT prime [ i ] = True NEW_LINE DEDENT for i in range ( ( n * n + 1 ) + 1 ) : NEW_LINE INDENT primesquare [ i ] = False NEW_LINE DEDENT prime [ 1 ] = False NEW_LINE p = 2 NEW_LINE while ( p * p <= n ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT i = p * 2 NEW_LINE while ( i <= n ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE i += p NEW_LINE DEDENT DEDENT p += 1 NEW_LINE DEDENT j = 0 NEW_LINE for p in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( prime [ p ] == True ) : NEW_LINE INDENT a [ j ] = p NEW_LINE primesquare [ p * p ] = True NEW_LINE j += 1 NEW_LINE DEDENT DEDENT DEDENT def countDivisors ( n ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT prime = [ False ] * ( n + 2 ) NEW_LINE primesquare = [ False ] * ( n * n + 2 ) NEW_LINE a = [ 0 ] * n NEW_LINE SieveOfEratosthenes ( n , prime , primesquare , a ) NEW_LINE ans = 1 NEW_LINE i = 0 NEW_LINE while ( 1 ) : NEW_LINE INDENT if ( a [ i ] * a [ i ] * a [ i ] > n ) : NEW_LINE INDENT break NEW_LINE DEDENT cnt = 1 NEW_LINE while ( n % a [ i ] == 0 ) : NEW_LINE INDENT n = n / a [ i ] NEW_LINE cnt = cnt + 1 NEW_LINE DEDENT ans = ans * cnt NEW_LINE i += 1 NEW_LINE DEDENT n = int ( n ) NEW_LINE if ( prime [ n ] == True ) : NEW_LINE INDENT ans = ans * 2 NEW_LINE DEDENT elif ( primesquare [ n ] == True ) : NEW_LINE INDENT ans = ans * 3 NEW_LINE DEDENT elif ( n != 1 ) : NEW_LINE INDENT ans = ans * 4 NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( "" Total ▁ distinct ▁ divisors ▁ of ▁ 100 ▁ are ▁ : "" , countDivisors ( 100 ) ) NEW_LINE DEDENT +" +E1607,"class Test { static int arr [ ] = new int [ ] { 1 , 2 , 3 , 4 } ; static void subArray ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { for ( int k = i ; k <= j ; k ++ ) System . out . print ( arr [ k ] + "" ▁ "" ) ; } } } public static void main ( String [ ] args ) { System . out . println ( "" All ▁ Non - empty ▁ Subarrays "" ) ; subArray ( arr . length ) ; } } +","def subArray ( arr , n ) : NEW_LINE INDENT for i in range ( 0 , n ) : NEW_LINE INDENT for j in range ( i , n ) : NEW_LINE INDENT for k in range ( i , j + 1 ) : NEW_LINE INDENT print ( arr [ k ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( "" \n "" , end = "" "" ) NEW_LINE DEDENT DEDENT DEDENT arr = [ 1 , 2 , 3 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( "" All ▁ Non - empty ▁ Subarrays "" ) NEW_LINE subArray ( arr , n ) ; NEW_LINE +" +E1608,"import java . io . * ; class GFG { static int findCullen ( int n ) { return ( 1 << n ) * n + 1 ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . println ( findCullen ( n ) ) ; } } +","def findCullen ( n ) : NEW_LINE INDENT return ( 1 << n ) * n + 1 NEW_LINE DEDENT n = 2 NEW_LINE print ( findCullen ( n ) ) NEW_LINE +" +E1609,"public class GFG { static double printProbability ( int L , int n ) { int p = ( 1 << ( n - 1 ) ) ; return 1.0 - ( ( double ) n ) / ( ( double ) p ) ; } public static void main ( String args [ ] ) { int n = 3 , L = 5 ; System . out . println ( printProbability ( L , n ) ) ; } } +","def printProbability ( L , n ) : NEW_LINE INDENT p = ( 1 << ( n - 1 ) ) NEW_LINE return 1.0 - ( float ( n ) / float ( p ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE L = 5 NEW_LINE print ( printProbability ( L , n ) ) NEW_LINE DEDENT +" +E1610,"class GFG { static String firstLetterWord ( String str ) { String result = "" "" ; boolean v = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ▁ ' ) { v = true ; } else if ( str . charAt ( i ) != ' ▁ ' && v == true ) { result += ( str . charAt ( i ) ) ; v = false ; } } return result ; } public static void main ( String [ ] args ) { String str = "" geeks ▁ for ▁ geeks "" ; System . out . println ( firstLetterWord ( str ) ) ; } } +","def firstLetterWord ( str ) : NEW_LINE INDENT result = "" "" NEW_LINE v = True NEW_LINE for i in range ( len ( str ) ) : NEW_LINE INDENT if ( str [ i ] == ' ▁ ' ) : NEW_LINE INDENT v = True NEW_LINE DEDENT elif ( str [ i ] != ' ▁ ' and v == True ) : NEW_LINE INDENT result += ( str [ i ] ) NEW_LINE v = False NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" geeks ▁ for ▁ geeks "" NEW_LINE print ( firstLetterWord ( str ) ) NEW_LINE DEDENT +" +E1611,"import java . util . * ; class GFG { static void findPrevious ( char [ ] number , int n ) { int i , j ; for ( i = n - 1 ; i > 0 ; i -- ) { if ( number [ i ] < number [ i - 1 ] ) { break ; } } if ( i == 0 ) { System . out . print ( "" Previous ▁ number ▁ is ▁ not ▁ possible "" ) ; return ; } int x = number [ i - 1 ] , greatest = i ; for ( j = i ; j < n ; j ++ ) { if ( number [ j ] < x && number [ j ] > number [ greatest ] ) { greatest = j ; } } swap ( number , greatest , i - 1 ) ; Arrays . sort ( number , i , n ) ; reverse ( number , i , n - 1 ) ; System . out . print ( "" Greatest ▁ smaller ▁ number ▁ with "" + "" same ▁ set ▁ of ▁ digits ▁ is ▁ "" + String . valueOf ( number ) ) ; return ; } static String swap ( char [ ] ch , int i , int j ) { char temp = ch [ i ] ; ch [ i ] = ch [ j ] ; ch [ j ] = temp ; return String . valueOf ( ch ) ; } static void reverse ( char str [ ] , int start , int end ) { char temp ; while ( start <= end ) { temp = str [ start ] ; str [ start ] = str [ end ] ; str [ end ] = temp ; start ++ ; end -- ; } } public static void main ( String [ ] args ) { String digits = ""262345"" ; int n = digits . length ( ) ; findPrevious ( digits . toCharArray ( ) , n ) ; } } +","def findPrevious ( number , n ) : NEW_LINE INDENT number = list ( number ) NEW_LINE i , j = - 1 , - 1 NEW_LINE for i in range ( n - 1 , 0 , - 1 ) : NEW_LINE INDENT if number [ i ] < number [ i - 1 ] : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if i == 0 : NEW_LINE INDENT print ( "" Previous ▁ number ▁ is ▁ not ▁ possible "" ) NEW_LINE return NEW_LINE DEDENT x , greatest = number [ i - 1 ] , i NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT if ( number [ j ] < x and number [ j ] > number [ greatest ] ) : NEW_LINE INDENT greatest = j NEW_LINE DEDENT DEDENT ( number [ greatest ] , number [ i - 1 ] ) = ( number [ i - 1 ] , number [ greatest ] ) NEW_LINE l = number [ i : ] NEW_LINE del number [ i : ] NEW_LINE l . sort ( reverse = True ) NEW_LINE number += l NEW_LINE number = ' ' . join ( number ) NEW_LINE print ( "" Greatest ▁ smaller ▁ number ▁ with "" , "" same ▁ set ▁ of ▁ digits ▁ is "" , number ) NEW_LINE return NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT digits = ""262345"" NEW_LINE n = len ( digits ) NEW_LINE findPrevious ( digits , n ) NEW_LINE DEDENT +" +E1612,"import java . io . * ; class GFG { static int countDecreasing ( int A [ ] , int n ) { int cnt = 0 ; int len = 1 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { if ( A [ i + 1 ] < A [ i ] ) len ++ ; else { cnt += ( ( ( len - 1 ) * len ) / 2 ) ; len = 1 ; } } if ( len > 1 ) cnt += ( ( ( len - 1 ) * len ) / 2 ) ; return cnt ; } public static void main ( String [ ] args ) { int A [ ] = { 100 , 3 , 1 , 13 } ; int n = A . length ; System . out . println ( countDecreasing ( A , n ) ) ; } } +","def countDecreasing ( A , n ) : NEW_LINE INDENT cnt = 0 NEW_LINE len = 1 NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT if ( A [ i + 1 ] < A [ i ] ) : NEW_LINE INDENT len += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += ( ( ( len - 1 ) * len ) // 2 ) ; NEW_LINE len = 1 NEW_LINE DEDENT DEDENT if ( len > 1 ) : NEW_LINE INDENT cnt += ( ( ( len - 1 ) * len ) // 2 ) NEW_LINE DEDENT return cnt NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT A = [ 100 , 3 , 1 , 13 ] NEW_LINE n = len ( A ) NEW_LINE print ( countDecreasing ( A , n ) ) NEW_LINE DEDENT +" +E1613,"import java . util . * ; class GFG { static int count ( int n ) { if ( n == 0 ) return 1 ; if ( n == 1 ) return 1 ; else return ( n * count ( n - 1 ) ) + ( ( n - 1 ) * count ( n - 2 ) ) ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 , 9 } ; int n = 4 ; System . out . println ( count ( n - 1 ) ) ; } } +","def count ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT if n == 1 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return ( n * count ( n - 1 ) ) + ( ( n - 1 ) * count ( n - 2 ) ) NEW_LINE DEDENT DEDENT A = [ 1 , 2 , 3 , 9 ] NEW_LINE print ( count ( len ( A ) - 1 ) ) NEW_LINE +" +E1614,"import java . util . * ; import java . lang . * ; class GFG { public static void SplitAndAdd ( int [ ] A , int length , int rotation ) { int [ ] tmp = new int [ length * 2 ] ; System . arraycopy ( A , 0 , tmp , 0 , length ) ; System . arraycopy ( A , 0 , tmp , length , length ) ; for ( int i = rotation ; i < rotation + length ; i ++ ) A [ i - rotation ] = tmp [ i ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 10 , 5 , 6 , 52 , 36 } ; int n = arr . length ; int position = 2 ; SplitAndAdd ( arr , n , position ) ; for ( int i = 0 ; i < n ; ++ i ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } } +","def SplitAndAdd ( A , length , rotation ) : NEW_LINE INDENT tmp = [ 0 for i in range ( length * 2 ) ] NEW_LINE for i in range ( length ) : NEW_LINE INDENT tmp [ i ] = A [ i ] NEW_LINE tmp [ i + length ] = A [ i ] NEW_LINE DEDENT for i in range ( rotation , rotation + length , 1 ) : NEW_LINE INDENT A [ i - rotation ] = tmp [ i ] ; NEW_LINE DEDENT DEDENT arr = [ 12 , 10 , 5 , 6 , 52 , 36 ] NEW_LINE n = len ( arr ) NEW_LINE position = 2 NEW_LINE SplitAndAdd ( arr , n , position ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) NEW_LINE DEDENT print ( ) NEW_LINE +" +E1615,"class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void commDiv ( int a , int b ) { int n = gcd ( a , b ) ; a = a / n ; b = b / n ; System . out . println ( "" A ▁ = ▁ "" + a + "" , ▁ B ▁ = ▁ "" + b ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 15 ; commDiv ( a , b ) ; } } +","def gcd ( a , b ) : NEW_LINE INDENT if ( a == 0 ) : NEW_LINE INDENT return b NEW_LINE DEDENT return gcd ( b % a , a ) NEW_LINE DEDENT def commDiv ( a , b ) : NEW_LINE INDENT n = gcd ( a , b ) NEW_LINE a = a // n NEW_LINE b = b // n NEW_LINE print ( "" A ▁ = "" , a , "" , ▁ B ▁ = "" , b ) NEW_LINE DEDENT a , b = 10 , 15 NEW_LINE commDiv ( a , b ) NEW_LINE +" +E1616,"class GFG { static boolean adjacentSet ( int n ) { int x = ( n & ( n >> 1 ) ) ; if ( x == 1 ) return true ; else return false ; } public static void main ( String args [ ] ) { int n = 3 ; if ( adjacentSet ( n ) ) System . out . println ( "" Yes "" ) ; else System . out . println ( "" No "" ) ; } } +","def adjacentSet ( n ) : NEW_LINE INDENT return ( n & ( n >> 1 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE if ( adjacentSet ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1617,"import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int MinimumMoves ( int a [ ] , int n , int x ) { int ans = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] <= a [ i - 1 ] ) { int p = ( a [ i - 1 ] - a [ i ] ) / x + 1 ; ans += p ; a [ i ] += p * x ; } } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 3 , 2 } ; int x = 2 ; int n = arr . length ; System . out . println ( MinimumMoves ( arr , n , x ) ) ; } } +","def MinimumMoves ( a , n , x ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if a [ i ] <= a [ i - 1 ] : NEW_LINE INDENT p = ( a [ i - 1 ] - a [ i ] ) // x + 1 NEW_LINE ans += p NEW_LINE a [ i ] += p * x NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 1 , 3 , 3 , 2 ] NEW_LINE x = 2 NEW_LINE n = len ( arr ) NEW_LINE print ( MinimumMoves ( arr , n , x ) ) NEW_LINE DEDENT +" +E1618,"import java . io . * ; class GFG { static int avg_of_even_num ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += 2 * i ; return ( sum / n ) ; } public static void main ( String [ ] args ) { int n = 9 ; System . out . print ( avg_of_even_num ( n ) ) ; } } +","def avg_of_even_num ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT sum = sum + 2 * i NEW_LINE DEDENT return sum / n NEW_LINE DEDENT n = 9 NEW_LINE print ( avg_of_even_num ( n ) ) NEW_LINE +" +E1619,"class GFG { static int findX ( int A , int B ) { int j = 0 , x = 0 ; while ( A != 0 || B != 0 ) { if ( ( A % 2 == 1 ) && ( B % 2 == 1 ) ) { x += ( 1 << j ) ; } A >>= 1 ; B >>= 1 ; j += 1 ; } return x ; } public static void main ( String [ ] args ) { int A = 2 , B = 3 ; int X = findX ( A , B ) ; System . out . println ( "" X ▁ = ▁ "" + X + "" , ▁ Sum ▁ = ▁ "" + ( ( A ^ X ) + ( B ^ X ) ) ) ; } } +","def findX ( A , B ) : NEW_LINE INDENT j = 0 NEW_LINE x = 0 NEW_LINE while ( A or B ) : NEW_LINE INDENT if ( ( A & 1 ) and ( B & 1 ) ) : NEW_LINE INDENT x += ( 1 << j ) NEW_LINE DEDENT A >>= 1 NEW_LINE B >>= 1 NEW_LINE j += 1 NEW_LINE DEDENT return x NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = 2 NEW_LINE B = 3 NEW_LINE X = findX ( A , B ) NEW_LINE print ( "" X ▁ = "" , X , "" , ▁ Sum ▁ = "" , ( A ^ X ) + ( B ^ X ) ) NEW_LINE DEDENT +" +E1620,"class GFG { static final int MAX = 1000001 ; static int factor [ ] = new int [ MAX ] ; static void cal_factor ( ) { factor [ 1 ] = 1 ; for ( int i = 2 ; i < MAX ; i ++ ) factor [ i ] = i ; for ( int i = 4 ; i < MAX ; i += 2 ) factor [ i ] = 2 ; for ( int i = 3 ; i * i < MAX ; i ++ ) { if ( factor [ i ] == i ) { for ( int j = i * i ; j < MAX ; j += i ) { if ( factor [ j ] == j ) factor [ j ] = i ; } } } } static int no_of_representations ( int a [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = a [ i ] ; int flag = 0 ; while ( factor [ temp ] != 1 ) { flag = - 1 ; count ++ ; temp = temp / factor [ temp ] ; } count += flag ; } return count ; } public static void main ( String [ ] args ) { cal_factor ( ) ; int a [ ] = { 4 , 4 , 4 } ; int n = a . length ; System . out . print ( no_of_representations ( a , n ) ) ; } } +","MAX = 1000001 NEW_LINE factor = [ 0 ] * MAX NEW_LINE def cal_factor ( ) : NEW_LINE INDENT factor [ 1 ] = 1 NEW_LINE for i in range ( 2 , MAX ) : NEW_LINE INDENT factor [ i ] = i NEW_LINE DEDENT for i in range ( 4 , MAX , 2 ) : NEW_LINE INDENT factor [ i ] = 2 NEW_LINE DEDENT i = 3 NEW_LINE while i * i < MAX : NEW_LINE INDENT if ( factor [ i ] == i ) : NEW_LINE INDENT for j in range ( i * i , MAX , i ) : NEW_LINE INDENT if ( factor [ j ] == j ) : NEW_LINE INDENT factor [ j ] = i NEW_LINE DEDENT DEDENT DEDENT i += 1 NEW_LINE DEDENT DEDENT def no_of_representations ( a , n ) : NEW_LINE INDENT count = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT temp = a [ i ] NEW_LINE flag = 0 NEW_LINE while ( factor [ temp ] != 1 ) : NEW_LINE INDENT flag = - 1 NEW_LINE count += 1 NEW_LINE temp = temp // factor [ temp ] NEW_LINE DEDENT count += flag NEW_LINE DEDENT return count NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT cal_factor ( ) NEW_LINE a = [ 4 , 4 , 4 ] NEW_LINE n = len ( a ) NEW_LINE print ( no_of_representations ( a , n ) ) NEW_LINE DEDENT +" +E1621,"public class AAB { static int maxSumPair ( int arr1 [ ] , int n1 , int arr2 [ ] , int n2 ) { int max1 = Integer . MIN_VALUE ; int max2 = Integer . MIN_VALUE ; for ( int i = 0 ; i < n1 ; i ++ ) { if ( arr1 [ i ] > max1 ) max1 = arr1 [ i ] ; } for ( int i = 0 ; i < n2 ; i ++ ) { if ( arr2 [ i ] > max2 ) max2 = arr2 [ i ] ; } return max1 + max2 ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 10 , 2 , 3 } ; int arr2 [ ] = { 3 , 4 , 7 } ; int n1 = arr1 . length ; int n2 = arr2 . length ; System . out . println ( maxSumPair ( arr1 , n1 , arr2 , n2 ) ) ; } } +","import sys NEW_LINE def maxSumPair ( arr1 , n1 , arr2 , n2 ) : NEW_LINE INDENT max1 = - sys . maxsize - 1 NEW_LINE max2 = - sys . maxsize - 1 NEW_LINE for i in range ( 0 , n1 ) : NEW_LINE INDENT if ( arr1 [ i ] > max1 ) : NEW_LINE INDENT max1 = arr1 [ i ] NEW_LINE DEDENT DEDENT for i in range ( 0 , n2 ) : NEW_LINE INDENT if ( arr2 [ i ] > max2 ) : NEW_LINE INDENT max2 = arr2 [ i ] NEW_LINE DEDENT DEDENT return max1 + max2 NEW_LINE DEDENT arr1 = [ 10 , 2 , 3 ] NEW_LINE arr2 = [ 3 , 4 , 7 ] NEW_LINE n1 = len ( arr1 ) NEW_LINE n2 = len ( arr2 ) NEW_LINE print ( maxSumPair ( arr1 , n1 , arr2 , n2 ) ) NEW_LINE +" +E1622,"import java . io . * ; class GFG { static int remainder ( String str ) { int len = str . length ( ) ; int num , rem = 0 ; for ( int i = 0 ; i < len ; i ++ ) { num = rem * 10 + ( str . charAt ( i ) - '0' ) ; rem = num % 11 ; } return rem ; } public static void main ( String args [ ] ) { String str = ""3435346456547566345436457867978"" ; System . out . println ( remainder ( str ) ) ; } } +","def remainder ( st ) : NEW_LINE INDENT ln = len ( st ) NEW_LINE rem = 0 NEW_LINE for i in range ( 0 , ln ) : NEW_LINE INDENT num = rem * 10 + ( int ) ( st [ i ] ) NEW_LINE rem = num % 11 NEW_LINE DEDENT return rem NEW_LINE DEDENT st = ""3435346456547566345436457867978"" NEW_LINE print ( remainder ( st ) ) NEW_LINE +" +E1623,"class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + "" ▁ "" ) ; } static void randomList ( int m , int n ) { int arr [ ] = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ ( int ) ( Math . random ( ) * m ) ] ++ ; } printArr ( arr , m ) ; } public static void main ( String args [ ] ) { int m = 4 , n = 8 ; randomList ( m , n ) ; } } +","from random import randint NEW_LINE def printArr ( arr , n ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT print ( arr [ i ] , end = "" ▁ "" ) ; NEW_LINE DEDENT DEDENT def randomList ( m , n ) : NEW_LINE INDENT arr = [ 0 ] * m ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT arr [ randint ( 0 , n ) % m ] += 1 ; NEW_LINE DEDENT printArr ( arr , m ) ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT m = 4 ; n = 8 ; NEW_LINE randomList ( m , n ) ; NEW_LINE DEDENT +" +E1624,"import java . util . * ; class GFG { static final int N = 100005 ; static void SieveOfEratosthenes ( boolean prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static int longestPrimeSubsequence ( int arr [ ] , int n ) { boolean [ ] prime = new boolean [ N + 1 ] ; Arrays . fill ( prime , true ) ; SieveOfEratosthenes ( prime , N ) ; int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { answer ++ ; } } return answer ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 11 , 2 , 9 , 21 } ; int n = arr . length ; System . out . print ( longestPrimeSubsequence ( arr , n ) + "" \n "" ) ; } } +","N = 100005 NEW_LINE def SieveOfEratosthenes ( prime , p_size ) : NEW_LINE INDENT prime [ 0 ] = False NEW_LINE prime [ 1 ] = False NEW_LINE p = 2 NEW_LINE while p * p <= p_size : NEW_LINE INDENT if ( prime [ p ] ) : NEW_LINE INDENT for i in range ( p * 2 , p_size + 1 , p ) : NEW_LINE INDENT prime [ i ] = False NEW_LINE DEDENT DEDENT p += 1 NEW_LINE DEDENT DEDENT def longestPrimeSubsequence ( arr , n ) : NEW_LINE INDENT prime = [ True ] * ( N + 1 ) NEW_LINE SieveOfEratosthenes ( prime , N ) NEW_LINE answer = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( prime [ arr [ i ] ] ) : NEW_LINE INDENT answer += 1 NEW_LINE DEDENT DEDENT return answer NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT arr = [ 3 , 4 , 11 , 2 , 9 , 21 ] NEW_LINE n = len ( arr ) NEW_LINE print ( longestPrimeSubsequence ( arr , n ) ) NEW_LINE DEDENT +" +E1625,"class CatalnNumber { int catalan ( int n ) { int res = 0 ; if ( n <= 1 ) { return 1 ; } for ( int i = 0 ; i < n ; i ++ ) { res += catalan ( i ) * catalan ( n - i - 1 ) ; } return res ; } public static void main ( String [ ] args ) { CatalnNumber cn = new CatalnNumber ( ) ; for ( int i = 0 ; i < 10 ; i ++ ) { System . out . print ( cn . catalan ( i ) + "" ▁ "" ) ; } } } +","def catalan ( n ) : NEW_LINE INDENT if n <= 1 : NEW_LINE INDENT return 1 NEW_LINE DEDENT res = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT res += catalan ( i ) * catalan ( n - i - 1 ) NEW_LINE DEDENT return res NEW_LINE DEDENT for i in range ( 10 ) : NEW_LINE INDENT print catalan ( i ) , NEW_LINE DEDENT +" +E1626,"class GFG { static int smallestIndex ( int [ ] a , int n ) { int right1 = 0 , right0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) right1 = i ; else right0 = i ; } return Math . min ( right1 , right0 ) ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 1 , 1 , 0 , 0 , 1 , 0 , 1 , 1 } ; int n = a . length ; System . out . println ( smallestIndex ( a , n ) ) ; } } +","def smallestIndex ( a , n ) : NEW_LINE INDENT right1 = 0 NEW_LINE right0 = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( a [ i ] == 1 ) : NEW_LINE INDENT right1 = i NEW_LINE DEDENT else : NEW_LINE INDENT right0 = i NEW_LINE DEDENT DEDENT return min ( right1 , right0 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT a = [ 1 , 1 , 1 , 0 , 0 , 1 , 0 , 1 , 1 ] NEW_LINE n = len ( a ) NEW_LINE print ( smallestIndex ( a , n ) ) NEW_LINE DEDENT +" +E1627,"import java . io . * ; import java . math . * ; class GFG { static double polygonArea ( double X [ ] , double Y [ ] , int n ) { double area = 0.0 ; int j = n - 1 ; for ( int i = 0 ; i < n ; i ++ ) { area += ( X [ j ] + X [ i ] ) * ( Y [ j ] - Y [ i ] ) ; j = i ; } return Math . abs ( area / 2.0 ) ; } public static void main ( String [ ] args ) { double X [ ] = { 0 , 2 , 4 } ; double Y [ ] = { 1 , 3 , 7 } ; int n = X . length ; System . out . println ( polygonArea ( X , Y , n ) ) ; } } +","def polygonArea ( X , Y , n ) : NEW_LINE INDENT area = 0.0 NEW_LINE j = n - 1 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT area = area + ( X [ j ] + X [ i ] ) * ( Y [ j ] - Y [ i ] ) NEW_LINE j = i NEW_LINE DEDENT return abs ( area // 2.0 ) NEW_LINE DEDENT X = [ 0 , 2 , 4 ] NEW_LINE Y = [ 1 , 3 , 7 ] NEW_LINE n = len ( X ) NEW_LINE print ( polygonArea ( X , Y , n ) ) NEW_LINE +" +E1628,"import java . io . * ; class GFG { static double PI = 3.14 ; static double areaOfInscribedCircle ( float a ) { return ( PI / 4 ) * a * a ; } public static void main ( String [ ] args ) { float a = 8 ; System . out . println ( "" Area ▁ of ▁ an ▁ inscribed "" + "" ▁ circle : ▁ "" + areaOfInscribedCircle ( a ) ) ; } } +","PI = 3.14 NEW_LINE def areaOfInscribedCircle ( a ) : NEW_LINE INDENT return ( PI / 4 ) * a * a NEW_LINE DEDENT a = 8 NEW_LINE print ( "" Area ▁ of ▁ an ▁ inscribed ▁ circle : "" , round ( areaOfInscribedCircle ( a ) , 2 ) ) NEW_LINE +" +E1629,"import java . io . * ; class GFG { static int divisorSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { for ( int j = 1 ; j * j <= i ; ++ j ) { if ( i % j == 0 ) { if ( i / j == j ) sum += j ; else sum += j + i / j ; } } } return sum ; } public static void main ( String args [ ] ) { int n = 4 ; System . out . println ( divisorSum ( n ) ) ; n = 5 ; System . out . println ( divisorSum ( n ) ) ; } } +","def divisorSum ( n ) : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT j = 1 NEW_LINE while j * j <= i : NEW_LINE INDENT if i % j == 0 : NEW_LINE INDENT if i / j == j : NEW_LINE INDENT sum += j NEW_LINE DEDENT else : NEW_LINE INDENT sum += j + i / j NEW_LINE DEDENT DEDENT j = j + 1 NEW_LINE DEDENT DEDENT return int ( sum ) NEW_LINE DEDENT n = 4 NEW_LINE print ( divisorSum ( n ) ) NEW_LINE n = 5 NEW_LINE print ( divisorSum ( n ) ) NEW_LINE +" +E1630,"import java . util . * ; class GFG { static int MAX = 32 ; static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int pairs ( int arr [ ] , int n , int k ) { int count = 0 ; int [ ] f = new int [ MAX + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) f [ countSetBits ( arr [ i ] ) ] ++ ; for ( int i = 0 ; i <= MAX ; i ++ ) { for ( int j = i ; j <= MAX ; j ++ ) { if ( i + j == k ) { if ( i == j ) count += ( ( f [ i ] * ( f [ i ] - 1 ) ) / 2 ) ; else count += ( f [ i ] * f [ j ] ) ; } } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . length ; int k = 4 ; System . out . println ( pairs ( arr , n , k ) ) ; } } +","MAX = 32 NEW_LINE def countSetBits ( n ) : NEW_LINE INDENT count = 0 ; NEW_LINE while ( n ) : NEW_LINE INDENT n &= ( n - 1 ) ; NEW_LINE count += 1 ; NEW_LINE DEDENT return count ; NEW_LINE DEDENT def pairs ( arr , n , k ) : NEW_LINE INDENT count = 0 ; NEW_LINE f = [ 0 for i in range ( MAX + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT f [ countSetBits ( arr [ i ] ) ] += 1 ; NEW_LINE DEDENT for i in range ( MAX + 1 ) : NEW_LINE INDENT for j in range ( 1 , MAX + 1 ) : NEW_LINE INDENT if ( i + j == k ) : NEW_LINE INDENT if ( i == j ) : NEW_LINE INDENT count += ( ( f [ i ] * ( f [ i ] - 1 ) ) / 2 ) ; NEW_LINE DEDENT else : NEW_LINE INDENT count += ( f [ i ] * f [ j ] ) ; NEW_LINE DEDENT DEDENT DEDENT DEDENT return count ; NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 4 , 5 ] NEW_LINE n = len ( arr ) NEW_LINE k = 4 NEW_LINE print ( pairs ( arr , n , k ) ) NEW_LINE +" +E1631,"import java . io . * ; import java . util . * ; public class CheckPallindromNumberRecursion { public static int oneDigit ( int num ) { if ( ( num >= 0 ) && ( num < 10 ) ) return 1 ; else return 0 ; } public static int isPalUtil ( int num , int dupNum ) throws Exception { if ( num == 0 ) { return dupNum ; } else { dupNum = isPalUtil ( num / 10 , dupNum ) ; } if ( num % 10 == dupNum % 10 ) { return dupNum / 10 ; } else { throw new Exception ( ) ; } } public static int isPal ( int num ) throws Exception { if ( num < 0 ) num = ( - num ) ; int dupNum = ( num ) ; return isPalUtil ( num , dupNum ) ; } public static void main ( String args [ ] ) { int n = 1242 ; try { isPal ( n ) ; System . out . println ( "" Yes "" ) ; } catch ( Exception e ) { System . out . println ( "" No "" ) ; } n = 1231 ; try { isPal ( n ) ; System . out . println ( "" Yes "" ) ; } catch ( Exception e ) { System . out . println ( "" No "" ) ; } n = 12 ; try { isPal ( n ) ; System . out . println ( "" Yes "" ) ; } catch ( Exception e ) { System . out . println ( "" No "" ) ; } n = 88 ; try { isPal ( n ) ; System . out . println ( "" Yes "" ) ; } catch ( Exception e ) { System . out . println ( "" No "" ) ; } n = 8999 ; try { isPal ( n ) ; System . out . println ( "" Yes "" ) ; } catch ( Exception e ) { System . out . println ( "" No "" ) ; } } } +","def oneDigit ( num ) : NEW_LINE INDENT return ( ( num >= 0 ) and ( num < 10 ) ) ; NEW_LINE DEDENT def isPalUtil ( num , dupNum ) : NEW_LINE INDENT if ( oneDigit ( num ) ) : NEW_LINE INDENT return ( num == ( dupNum ) % 10 ) ; NEW_LINE DEDENT if ( isPalUtil ( int ( num / 10 ) , dupNum ) == False ) : NEW_LINE INDENT return - 1 ; NEW_LINE DEDENT dupNum = int ( dupNum / 10 ) ; NEW_LINE return ( num % 10 == ( dupNum ) % 10 ) ; NEW_LINE DEDENT def isPal ( num ) : NEW_LINE INDENT if ( num < 0 ) : NEW_LINE INDENT num = ( - num ) ; NEW_LINE DEDENT dupNum = ( num ) ; NEW_LINE return isPalUtil ( num , dupNum ) ; NEW_LINE DEDENT n = 12321 ; NEW_LINE if ( isPal ( n ) == 0 ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT n = 12 ; NEW_LINE if ( isPal ( n ) == 0 ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT n = 88 ; NEW_LINE if ( isPal ( n ) == 1 ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT n = 8999 ; NEW_LINE if ( isPal ( n ) == 0 ) : NEW_LINE INDENT print ( "" Yes "" ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) ; NEW_LINE DEDENT +" +E1632,"import java . util . * ; import java . lang . * ; class GFG { static int isSumDivides ( int N ) { int temp = N ; int sum = 0 ; while ( temp > 0 ) { sum += temp % 10 ; temp /= 10 ; } if ( N % sum == 0 ) return 1 ; else return 0 ; } public static void main ( String args [ ] ) { int N = 12 ; if ( isSumDivides ( N ) == 1 ) System . out . print ( "" YES "" ) ; else System . out . print ( "" NO "" ) ; } } +","def isSumDivides ( N ) : NEW_LINE INDENT temp = N NEW_LINE sum = 0 NEW_LINE while ( temp ) : NEW_LINE INDENT sum += temp % 10 NEW_LINE temp = int ( temp / 10 ) NEW_LINE DEDENT if ( N % sum == 0 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return 0 NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 12 NEW_LINE if ( isSumDivides ( N ) ) : NEW_LINE INDENT print ( "" YES "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" NO "" ) NEW_LINE DEDENT DEDENT +" +E1633,"class GFG { static int nextZero ( int i , int occurrences [ ] ) { while ( i < occurrences . length ) { if ( occurrences [ i ] == 0 ) return i ; i ++ ; } return - 1 ; } static String getModifiedString ( String str ) { int n = str . length ( ) ; if ( n > 26 ) return "" - 1"" ; char ch [ ] = str . toCharArray ( ) ; int i , occurrences [ ] = new int [ 26 ] ; for ( i = 0 ; i < n ; i ++ ) occurrences [ ch [ i ] - ' a ' ] ++ ; int index = nextZero ( 0 , occurrences ) ; for ( i = 0 ; i < n ; i ++ ) { if ( occurrences [ ch [ i ] - ' a ' ] > 1 ) { occurrences [ ch [ i ] - ' a ' ] -- ; ch [ i ] = ( char ) ( ' a ' + index ) ; occurrences [ index ] = 1 ; index = nextZero ( index + 1 , occurrences ) ; } } return String . valueOf ( ch ) ; } public static void main ( String arr [ ] ) { String str = "" geeksforgeeks "" ; System . out . print ( getModifiedString ( str ) ) ; } } +","def nextZero ( i , occurrences ) : NEW_LINE INDENT while i < 26 : NEW_LINE INDENT if occurrences [ i ] == 0 : NEW_LINE INDENT return i NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return - 1 NEW_LINE DEDENT def getModifiedString ( str ) : NEW_LINE INDENT n = len ( str ) NEW_LINE if n > 26 : NEW_LINE INDENT return "" - 1"" NEW_LINE DEDENT ch = str NEW_LINE ch = list ( ch ) NEW_LINE occurrences = [ 0 ] * 26 NEW_LINE for i in range ( n ) : NEW_LINE INDENT occurrences [ ord ( ch [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT index = nextZero ( 0 , occurrences ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if occurrences [ ord ( ch [ i ] ) - ord ( ' a ' ) ] > 1 : NEW_LINE INDENT occurrences [ ord ( ch [ i ] ) - ord ( ' a ' ) ] -= 1 NEW_LINE ch [ i ] = chr ( ord ( ' a ' ) + index ) NEW_LINE occurrences [ index ] = 1 NEW_LINE index = nextZero ( index + 1 , occurrences ) NEW_LINE DEDENT DEDENT ch = ' ' . join ( ch ) NEW_LINE print ( ch ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT str = "" geeksforgeeks "" NEW_LINE getModifiedString ( str ) NEW_LINE DEDENT +" +E1634,"import java . util . * ; class GFG { static int calculateCycleOperations ( int len ) { int cycle_operations = 0 ; while ( len > 0 ) { len /= 3 ; ++ cycle_operations ; } return -- cycle_operations ; } static int minimumOperations ( int p [ ] , int n ) { int [ ] visited = new int [ n + 1 ] ; Arrays . fill ( visited , 0 ) ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int ele = p [ i ] ; if ( visited [ ele ] == 0 ) { visited [ ele ] = 1 ; int len = 1 ; ele = p [ ele ] ; while ( visited [ ele ] == 0 ) { visited [ ele ] = 1 ; ++ len ; ele = p [ ele ] ; } int operations = calculateCycleOperations ( len ) ; int num = ( int ) Math . pow ( 3 , operations ) ; if ( num != len ) { return - 1 ; } ans = Math . max ( ans , operations ) ; } } return ans ; } public static void main ( String args [ ] ) { int P [ ] = { - 1 , 4 , 6 , 5 , 3 , 2 , 7 , 8 , 9 , 1 } ; int n = P . length - 1 ; System . out . println ( minimumOperations ( P , n ) ) ; } } +","def calculateCycleOperations ( length ) : NEW_LINE INDENT cycle_operations = 0 NEW_LINE while length > 0 : NEW_LINE INDENT length //= 3 NEW_LINE cycle_operations += 1 NEW_LINE DEDENT return cycle_operations - 1 NEW_LINE DEDENT def minimumOperations ( p , n ) : NEW_LINE INDENT visited = [ 0 ] * ( n + 1 ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT ele = p [ i ] NEW_LINE if not visited [ ele ] : NEW_LINE INDENT visited [ ele ] = 1 NEW_LINE length = 1 NEW_LINE ele = p [ ele ] NEW_LINE while not visited [ ele ] : NEW_LINE INDENT visited [ ele ] = 1 NEW_LINE length += 1 NEW_LINE ele = p [ ele ] NEW_LINE DEDENT operations = calculateCycleOperations ( length ) NEW_LINE num = pow ( 3 , operations ) NEW_LINE if num != length : NEW_LINE INDENT return - 1 NEW_LINE DEDENT ans = max ( ans , operations ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT P = [ - 1 , 4 , 6 , 5 , 3 , 2 , 7 , 8 , 9 , 1 ] NEW_LINE n = len ( P ) - 1 NEW_LINE print ( minimumOperations ( P , n ) ) NEW_LINE DEDENT +" +E1635,"class Test { public static void main ( String args [ ] ) { double r = 3 ; double R = 7 ; float pi = ( float ) 3.14159 ; double Volume = 0 ; Volume = 2 * pi * pi * R * r * r ; System . out . printf ( "" Volume : ▁ % f "" , Volume ) ; double Surface = 4 * pi * pi * R * r ; System . out . printf ( "" \n Surface : ▁ % f "" , Surface ) ; } } +","r = 3 NEW_LINE R = 7 NEW_LINE pi = 3.14159 NEW_LINE Volume = ( float ) ( 2 * pi * pi * R * r * r ) ; NEW_LINE print ( "" Volume : ▁ "" , Volume ) ; NEW_LINE Surface = ( float ) ( 4 * pi * pi * R * r ) ; NEW_LINE print ( "" Surface : ▁ "" , Surface ) ; NEW_LINE +" +E1636,"class GFG { static int numberOfPaths ( int m , int n ) { int [ ] dp = new int [ n ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { dp [ j ] += dp [ j - 1 ] ; } } return dp [ n - 1 ] ; } public static void main ( String args [ ] ) { System . out . println ( numberOfPaths ( 3 , 3 ) ) ; } } +","def numberOfPaths ( p , q ) : NEW_LINE INDENT dp = [ 1 for i in range ( q ) ] NEW_LINE for i in range ( p - 1 ) : NEW_LINE INDENT for j in range ( 1 , q ) : NEW_LINE INDENT dp [ j ] += dp [ j - 1 ] NEW_LINE DEDENT DEDENT return dp [ q - 1 ] NEW_LINE DEDENT print ( numberOfPaths ( 3 , 3 ) ) NEW_LINE +" +E1637,"class GFG { static int alternate ( int a , int b , int x ) { return x = a ^ b ^ x ; } public static void main ( String [ ] args ) { int a = - 10 ; int b = 15 ; int x = a ; System . out . print ( "" x ▁ is ▁ : ▁ "" + x ) ; x = alternate ( a , b , x ) ; System . out . print ( "" \n After ▁ exchange ▁ "" ) ; System . out . print ( "" \n x ▁ is ▁ : ▁ "" + x ) ; } } +","def alternate ( a , b , x ) : NEW_LINE INDENT x = a ^ b ^ x NEW_LINE print ( "" After ▁ exchange "" ) NEW_LINE print ( "" x ▁ is "" , x ) NEW_LINE DEDENT a = - 10 NEW_LINE b = 15 NEW_LINE x = a NEW_LINE print ( "" x ▁ is "" , x ) NEW_LINE alternate ( a , b , x ) NEW_LINE +" +E1638,"import java . io . * ; import java . util . * ; class GFG { static double surface_area_octahedron ( double side ) { return ( 2 * ( Math . sqrt ( 3 ) ) * ( side * side ) ) ; } public static void main ( String [ ] args ) { double side = 7 ; System . out . println ( "" Surface ▁ area ▁ of ▁ octahedron ▁ = "" + surface_area_octahedron ( side ) ) ; } } +","import math NEW_LINE def surface_area_octahedron ( side ) : NEW_LINE INDENT return ( 2 * ( math . sqrt ( 3 ) ) * ( side * side ) ) NEW_LINE DEDENT side = 7 NEW_LINE print ( "" Surface ▁ area ▁ of ▁ octahedron ▁ = "" , surface_area_octahedron ( side ) ) NEW_LINE +" +E1639,"import java . io . * ; class GFG { static int CenteredDodecahedral_num ( int n ) { return ( 2 * n + 1 ) * ( 5 * n * n + 5 * n + 1 ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( n + "" th ▁ Centered ▁ "" + "" Dodecahedral ▁ number ▁ : ▁ "" ) ; System . out . println ( CenteredDodecahedral_num ( n ) ) ; n = 10 ; System . out . print ( n + "" th ▁ Centered ▁ "" + "" Dodecahedral ▁ number ▁ : ▁ "" ) ; System . out . println ( CenteredDodecahedral_num ( n ) ) ; } } +","def CenteredDodecahedral_num ( n ) : NEW_LINE INDENT return ( 2 * n + 1 ) * ( 5 * n * n + 5 * n + 1 ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 NEW_LINE print ( n , "" rd ▁ centered ▁ dodecahedral ▁ number : ▁ "" , CenteredDodecahedral_num ( n ) ) NEW_LINE n = 10 NEW_LINE print ( n , "" th ▁ centered ▁ dodecahedral ▁ number ▁ : ▁ "" , CenteredDodecahedral_num ( n ) ) NEW_LINE DEDENT +" +E1640,"import java . lang . Math ; class GfG { static int longestSubstring ( String s ) { int cnt = 1 , maxi = 1 ; int n = s . length ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i - 1 ) ) cnt ++ ; else { maxi = Math . max ( cnt , maxi ) ; cnt = 1 ; } } maxi = Math . max ( cnt , maxi ) ; return maxi ; } public static void main ( String [ ] args ) { String s = "" ccccdeededff "" ; System . out . println ( longestSubstring ( s ) ) ; } } +","def longestSubstring ( s ) : NEW_LINE INDENT cnt = 1 ; NEW_LINE maxi = 1 ; NEW_LINE n = len ( s ) ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( s [ i ] != s [ i - 1 ] ) : NEW_LINE INDENT cnt += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT maxi = max ( cnt , maxi ) ; NEW_LINE cnt = 1 ; NEW_LINE DEDENT DEDENT maxi = max ( cnt , maxi ) ; NEW_LINE return maxi ; NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT s = "" ccccdeededff "" ; NEW_LINE print ( longestSubstring ( s ) ) ; NEW_LINE DEDENT +" +E1641,"class Test { static int firstDigit ( int x ) { while ( x >= 10 ) x = x / 10 ; return x ; } public static void main ( String args [ ] ) { System . out . println ( firstDigit ( 12345 ) ) ; System . out . println ( firstDigit ( 5432 ) ) ; } } +","def firstDigit ( x ) : NEW_LINE INDENT while ( x >= 10 ) : NEW_LINE INDENT x = x // 10 NEW_LINE DEDENT return x NEW_LINE DEDENT print ( firstDigit ( 12345 ) ) NEW_LINE print ( firstDigit ( 5432 ) ) NEW_LINE +" +E1642,"class GFG { static int C [ ] [ ] = new int [ 1000 ] [ 1000 ] ; static void binomialCoeff ( int n ) { int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= i ; j ++ ) { if ( j == 0 || j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } } static int numberOfWays ( int x , int y , int z ) { binomialCoeff ( Math . max ( x , Math . max ( y , z ) ) ) ; int sum = 0 ; for ( int i = 1 ; i <= z ; i ++ ) { sum = ( sum + C [ z ] [ i ] ) ; } int sum1 = 0 ; for ( int i = 1 ; i <= y ; i ++ ) { for ( int j = i + 1 ; j <= x ; j ++ ) { sum1 = ( sum1 + ( C [ y ] [ i ] * C [ x ] [ j ] ) ) ; } } sum1 = ( sum * sum1 ) ; return sum1 ; } public static void main ( String args [ ] ) { int x = 3 ; int y = 2 ; int z = 1 ; System . out . println ( numberOfWays ( x , y , z ) ) ; } } +","C = [ [ 0 for i in range ( 1000 ) ] for i in range ( 1000 ) ] NEW_LINE def binomialCoeff ( n ) : NEW_LINE INDENT i , j = 0 , 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT for j in range ( i + 1 ) : NEW_LINE INDENT if ( j == 0 or j == i ) : NEW_LINE INDENT C [ i ] [ j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + \ NEW_LINE INDENT C [ i - 1 ] [ j ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT def numberOfWays ( x , y , z ) : NEW_LINE INDENT binomialCoeff ( max ( x , max ( y , z ) ) ) NEW_LINE sum = 0 NEW_LINE for i in range ( 1 , z + 1 ) : NEW_LINE INDENT sum = ( sum + C [ z ] [ i ] ) NEW_LINE DEDENT sum1 = 0 NEW_LINE for i in range ( 1 , y + 1 ) : NEW_LINE INDENT for j in range ( i + 1 , x + 1 ) : NEW_LINE INDENT sum1 = ( sum1 + ( C [ y ] [ i ] * C [ x ] [ j ] ) ) NEW_LINE DEDENT DEDENT sum1 = ( sum * sum1 ) NEW_LINE return sum1 NEW_LINE DEDENT x = 3 NEW_LINE y = 2 NEW_LINE z = 1 NEW_LINE print ( numberOfWays ( x , y , z ) ) NEW_LINE +" +E1643,"import java . util . * ; class GFG { static boolean isDivisible ( int n ) { int d ; while ( ( n / 100 ) > 0 ) { d = n % 10 ; n /= 10 ; n = Math . abs ( n - ( d * 14 ) ) ; } return ( n % 47 == 0 ) ; } public static void main ( String [ ] args ) { int N = 59173 ; if ( isDivisible ( N ) ) System . out . print ( "" Yes "" ) ; else System . out . print ( "" No "" ) ; } } +","def isDivisible ( n ) : NEW_LINE INDENT while n // 100 : NEW_LINE INDENT d = n % 10 NEW_LINE n //= 10 NEW_LINE n = abs ( n - ( d * 14 ) ) NEW_LINE DEDENT return ( n % 47 == 0 ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT n = 59173 NEW_LINE if ( isDivisible ( n ) ) : NEW_LINE INDENT print ( "" Yes "" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( "" No "" ) NEW_LINE DEDENT DEDENT +" +E1644,"public final class p028 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p028 ( ) . run ( ) ) ; } private static final int SIZE = 1001 ; public String run ( ) { long sum = 1 ; for ( int n = 3 ; n <= SIZE ; n += 2 ) sum += 4 * n * n - 6 * ( n - 1 ) ; return Long . toString ( sum ) ; } } +","def compute ( ) : NEW_LINE INDENT SIZE = 1001 NEW_LINE ans = 1 NEW_LINE ans += sum ( 4 * i * i - 6 * ( i - 1 ) for i in range ( 3 , SIZE + 1 , 2 ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1645,"import java . math . BigInteger ; public final class p387 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p387 ( ) . run ( ) ) ; } private static final long LIMIT = 100000000000000L ; private BigInteger sum = BigInteger . ZERO ; public String run ( ) { for ( int i = 1 ; i <= 9 ; i ++ ) findHarshadPrimes ( i , i , false ) ; return sum . toString ( ) ; } private void findHarshadPrimes ( long n , int digitSum , boolean isStrong ) { long m = n * 10 ; int s = digitSum ; for ( int i = 0 ; i < 10 && m < LIMIT ; i ++ , m ++ , s ++ ) { if ( isStrong && isPrime ( m ) ) sum = sum . add ( BigInteger . valueOf ( m ) ) ; if ( m % s == 0 ) findHarshadPrimes ( m , s , isPrime ( m / s ) ) ; } } private static boolean isPrime ( long x ) { if ( x < 0 ) throw new IllegalArgumentException ( "" Negative ▁ number "" ) ; if ( x == 0 || x == 1 ) return false ; for ( long i = 2 , end = Library . sqrt ( x ) ; i <= end ; i ++ ) { if ( x % i == 0 ) return false ; } return true ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 10 ** 14 NEW_LINE ans = [ 0 ] NEW_LINE def find_harshad_primes ( n , digitsum , isstrong ) : NEW_LINE INDENT m = n * 10 NEW_LINE s = digitsum NEW_LINE for i in range ( 10 ) : NEW_LINE INDENT if m >= LIMIT : NEW_LINE INDENT break NEW_LINE DEDENT if isstrong and eulerlib . is_prime ( m ) : NEW_LINE INDENT ans [ 0 ] += m NEW_LINE DEDENT if m % s == 0 : NEW_LINE INDENT find_harshad_primes ( m , s , eulerlib . is_prime ( m // s ) ) NEW_LINE DEDENT m += 1 NEW_LINE s += 1 NEW_LINE DEDENT DEDENT for i in range ( 1 , 10 ) : NEW_LINE INDENT find_harshad_primes ( i , i , False ) NEW_LINE DEDENT return str ( ans [ 0 ] ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1646,"public final class p117 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p117 ( ) . run ( ) ) ; } private static final int LENGTH = 50 ; public String run ( ) { long [ ] ways = new long [ LENGTH + 1 ] ; ways [ 0 ] = 1 ; for ( int n = 1 ; n <= LENGTH ; n ++ ) { for ( int k = 1 ; k <= 4 && k <= n ; k ++ ) ways [ n ] += ways [ n - k ] ; } return Long . toString ( ways [ LENGTH ] ) ; } } +","def compute ( ) : NEW_LINE INDENT LENGTH = 50 NEW_LINE ways = [ 1 ] + [ 0 ] * LENGTH NEW_LINE for n in range ( 1 , len ( ways ) ) : NEW_LINE INDENT ways [ n ] += sum ( ways [ max ( n - 4 , 0 ) : n ] ) NEW_LINE DEDENT return str ( ways [ - 1 ] ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1647,"public final class p188 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p188 ( ) . run ( ) ) ; } public String run ( ) { return Integer . toString ( tetrationMod ( 1777 , 1855 , Library . pow ( 10 , 8 ) ) ) ; } private static int tetrationMod ( int x , int y , int m ) { if ( y == 1 ) return x % m ; else return Library . powMod ( x , tetrationMod ( x , y - 1 , Library . totient ( m ) ) , m ) ; } } +","import eulerlib , sys NEW_LINE def compute ( ) : NEW_LINE INDENT x , y , m = 1777 , 1855 , 10 ** 8 NEW_LINE sys . setrecursionlimit ( y + 30 ) NEW_LINE ans = tetration_mod ( x , y , m ) NEW_LINE return str ( ans ) NEW_LINE DEDENT def tetration_mod ( x , y , m ) : NEW_LINE INDENT if y == 1 : NEW_LINE INDENT return x % m NEW_LINE DEDENT else : NEW_LINE INDENT return pow ( x , tetration_mod ( x , y - 1 , totient ( m ) ) , m ) NEW_LINE DEDENT DEDENT def totient ( n ) : NEW_LINE INDENT assert n > 0 NEW_LINE p = 1 NEW_LINE i = 2 NEW_LINE end = eulerlib . sqrt ( n ) NEW_LINE while i <= end : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT p *= i - 1 NEW_LINE n //= i NEW_LINE while n % i == 0 : NEW_LINE INDENT p *= i NEW_LINE n //= i NEW_LINE DEDENT end = eulerlib . sqrt ( n ) NEW_LINE DEDENT i += 1 NEW_LINE DEDENT if n != 1 : NEW_LINE INDENT p *= n - 1 NEW_LINE DEDENT return p NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1648,"public final class p160 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p160 ( ) . run ( ) ) ; } public String run ( ) { return Long . toString ( factorialSuffix ( 1000000000000L ) ) ; } private static long factorialSuffix ( long n ) { long twos = countFactors ( n , 2 ) - countFactors ( n , 5 ) ; if ( twos >= 2505 ) twos = ( twos - 5 ) % 2500 + 5 ; return factorialish ( n ) * Library . powMod ( 2 , ( int ) twos , 100000 ) % 100000 ; } private static long factorialish ( long n ) { return evenFactorialish ( n ) * oddFactorialish ( n ) % 100000 ; } private static long evenFactorialish ( long n ) { if ( n == 0 ) return 1 ; else return factorialish ( n / 2 ) ; } private static long oddFactorialish ( long n ) { if ( n == 0 ) return 1 ; else return oddFactorialish ( n / 5 ) * factorialCoprime ( n ) % 100000 ; } private static long factorialCoprime ( long n ) { n %= 100000 ; long product = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 != 0 && i % 5 != 0 ) product = i * product % 100000 ; } return product ; } private static long countFactors ( long end , long n ) { if ( end == 0 ) return 0 ; else return end / n + countFactors ( end / n , n ) ; } } +","def compute ( ) : NEW_LINE INDENT ans = factorial_suffix ( 10 ** 12 ) NEW_LINE return str ( ans ) NEW_LINE DEDENT def factorial_suffix ( n ) : NEW_LINE INDENT twos = count_factors ( n , 2 ) - count_factors ( n , 5 ) NEW_LINE if twos >= 2505 : NEW_LINE INDENT twos = ( twos - 5 ) % 2500 + 5 NEW_LINE DEDENT return factorialish ( n ) * pow ( 2 , twos , 100000 ) % 100000 NEW_LINE DEDENT def factorialish ( n ) : NEW_LINE INDENT return even_factorialish ( n ) * odd_factorialish ( n ) % 100000 NEW_LINE DEDENT def even_factorialish ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return factorialish ( n // 2 ) NEW_LINE DEDENT DEDENT def odd_factorialish ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT return odd_factorialish ( n // 5 ) * factorial_coprime ( n ) % 100000 NEW_LINE DEDENT DEDENT def factorial_coprime ( n ) : NEW_LINE INDENT n %= 100000 NEW_LINE product = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT if i % 2 != 0 and i % 5 != 0 : NEW_LINE INDENT product = i * product % 100000 NEW_LINE DEDENT DEDENT return product NEW_LINE DEDENT def count_factors ( end , n ) : NEW_LINE INDENT if end == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return end // n + count_factors ( end // n , n ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1649,"public final class p166 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p166 ( ) . run ( ) ) ; } public String run ( ) { int count = 0 ; int [ ] num = new int [ 8 ] ; do { int a = num [ 0 ] , b = num [ 1 ] , c = num [ 2 ] , d = num [ 3 ] ; int e = num [ 4 ] , g = num [ 5 ] , i = num [ 6 ] , k = num [ 7 ] ; int m = b + c + d - e - i ; if ( m < 0 || m > 9 ) continue ; int o = a + b + d - g - k ; if ( o < 0 || o > 9 ) continue ; int j = a + b + c - g - m ; if ( j < 0 || j > 9 ) continue ; int l = a + b + c + d - i - j - k ; if ( l < 0 || l > 9 ) continue ; int f = b + c + d * 2 - e - i - k ; if ( f < 0 || f > 9 ) continue ; int h = a + b + c + d - e - f - g ; if ( h < 0 || h > 9 ) continue ; int n = a + c + d - f - j ; if ( n < 0 || n > 9 ) continue ; int p = a + b + c - h - l ; if ( p < 0 || p > 9 ) continue ; count ++ ; } while ( increment ( num ) ) ; return Integer . toString ( count ) ; } private static boolean increment ( int [ ] num ) { int i = 0 ; while ( num [ i ] == 9 ) { num [ i ] = 0 ; i ++ ; if ( i == num . length ) return false ; } num [ i ] ++ ; return true ; } } +","def compute ( ) : NEW_LINE INDENT ans = 0 NEW_LINE digits = tuple ( range ( 10 ) ) NEW_LINE for b in digits : NEW_LINE INDENT for c in digits : NEW_LINE INDENT for d in digits : NEW_LINE INDENT for e in digits : NEW_LINE INDENT for i in digits : NEW_LINE INDENT m = b + c + d - e - i NEW_LINE if m < 0 or m > 9 : continue NEW_LINE for k in digits : NEW_LINE INDENT f = b + c + d * 2 - e - i - k NEW_LINE if f < 0 or f > 9 : continue NEW_LINE for a in digits : NEW_LINE INDENT for g in digits : NEW_LINE INDENT o = a + b + d - g - k NEW_LINE if o < 0 or o > 9 : continue NEW_LINE j = a + b + c - g - m NEW_LINE if j < 0 or j > 9 : continue NEW_LINE l = a + b + c + d - i - j - k NEW_LINE if l < 0 or l > 9 : continue NEW_LINE h = a + b + c + d - e - f - g NEW_LINE if h < 0 or h > 9 : continue NEW_LINE n = a + c + d - f - j NEW_LINE if n < 0 or n > 9 : continue NEW_LINE p = a + b + c - h - l NEW_LINE if p < 0 or p > 9 : continue NEW_LINE ans += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1650,"import java . math . BigInteger ; public final class p097 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p097 ( ) . run ( ) ) ; } public String run ( ) { BigInteger modulus = BigInteger . TEN . pow ( 10 ) ; BigInteger n = BigInteger . valueOf ( 2 ) . modPow ( BigInteger . valueOf ( 7830457 ) , modulus ) ; n = n . multiply ( BigInteger . valueOf ( 28433 ) ) . mod ( modulus ) ; n = n . add ( BigInteger . ONE ) . mod ( modulus ) ; return String . format ( "" % 010d "" , n ) ; } } +","def compute ( ) : NEW_LINE INDENT MOD = 10 ** 10 NEW_LINE ans = ( 28433 * pow ( 2 , 7830457 , MOD ) + 1 ) % MOD NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1651,"import java . math . BigInteger ; public final class p329 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p329 ( ) . run ( ) ) ; } private static final int START_NUM = 1 ; private static final int END_NUM = 500 ; private static final String CROAK_SEQ = "" PPPPNNPPPNPPNPN "" ; static { assert 0 <= START_NUM && START_NUM < END_NUM && END_NUM < Integer . MAX_VALUE ; assert 1 <= CROAK_SEQ . length ( ) && CROAK_SEQ . length ( ) <= 31 ; } private static final int NUM_JUMPS = CROAK_SEQ . length ( ) - 1 ; private static final int NUM_TRIALS = 1 << NUM_JUMPS ; public String run ( ) { long globalNumerator = 0 ; boolean [ ] isPrime = Library . listPrimality ( END_NUM ) ; for ( int i = START_NUM ; i <= END_NUM ; i ++ ) { for ( int j = 0 ; j < NUM_TRIALS ; j ++ ) { int pos = i ; int trialNumerator = 1 ; if ( isPrime [ pos ] == ( CROAK_SEQ . charAt ( 0 ) == ' P ' ) ) trialNumerator *= 2 ; for ( int k = 0 ; k < NUM_JUMPS ; k ++ ) { if ( pos <= START_NUM ) pos ++ ; else if ( pos >= END_NUM ) pos -- ; else if ( ( ( j >>> k ) & 1 ) == 0 ) pos ++ ; else pos -- ; if ( isPrime [ pos ] == ( CROAK_SEQ . charAt ( k + 1 ) == ' P ' ) ) trialNumerator *= 2 ; } globalNumerator += trialNumerator ; } } BigInteger globalDenominator = BigInteger . valueOf ( END_NUM + 1L - START_NUM ) . shiftLeft ( NUM_JUMPS ) . multiply ( BigInteger . valueOf ( 3 ) . pow ( CROAK_SEQ . length ( ) ) ) ; return new Fraction ( BigInteger . valueOf ( globalNumerator ) , globalDenominator ) . toString ( ) ; } } +","import eulerlib , fractions NEW_LINE def compute ( ) : NEW_LINE INDENT START_NUM = 1 NEW_LINE END_NUM = 500 NEW_LINE CROAK_SEQ = "" PPPPNNPPPNPPNPN "" NEW_LINE assert 0 <= START_NUM < END_NUM NEW_LINE assert 1 <= len ( CROAK_SEQ ) NEW_LINE NUM_JUMPS = len ( CROAK_SEQ ) - 1 NEW_LINE NUM_TRIALS = 2 ** NUM_JUMPS NEW_LINE globalnumerator = 0 NEW_LINE isprime = eulerlib . list_primality ( END_NUM ) NEW_LINE for i in range ( START_NUM , END_NUM + 1 ) : NEW_LINE INDENT for j in range ( NUM_TRIALS ) : NEW_LINE INDENT pos = i NEW_LINE trialnumerator = 1 NEW_LINE if isprime [ pos ] == ( CROAK_SEQ [ 0 ] == ' P ' ) : NEW_LINE INDENT trialnumerator *= 2 NEW_LINE DEDENT for k in range ( NUM_JUMPS ) : NEW_LINE INDENT if pos <= START_NUM : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT elif pos >= END_NUM : NEW_LINE INDENT pos -= 1 NEW_LINE DEDENT elif ( j >> k ) & 1 == 0 : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT else : NEW_LINE INDENT pos -= 1 NEW_LINE DEDENT if isprime [ pos ] == ( CROAK_SEQ [ k + 1 ] == ' P ' ) : NEW_LINE INDENT trialnumerator *= 2 NEW_LINE DEDENT DEDENT globalnumerator += trialnumerator NEW_LINE DEDENT DEDENT globaldenominator = ( END_NUM + 1 - START_NUM ) * 2 ** NUM_JUMPS * 3 ** len ( CROAK_SEQ ) NEW_LINE ans = fractions . Fraction ( globalnumerator , globaldenominator ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1652,"public final class p518 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p518 ( ) . run ( ) ) ; } private static final int LIMIT = Library . pow ( 10 , 8 ) ; public String run ( ) { long sum = 0 ; boolean [ ] isPrime = Library . listPrimality ( LIMIT - 1 ) ; for ( int x = 1 ; x < isPrime . length ; x ++ ) { for ( int y = 1 ; ; y ++ ) { long a = ( long ) x * y * y - 1 ; if ( a >= isPrime . length ) break ; if ( ! isPrime [ ( int ) a ] ) continue ; for ( int z = y + 1 ; ; z ++ ) { if ( Library . gcd ( y , z ) != 1 ) continue ; long b = ( long ) x * y * z - 1 ; long c = ( long ) x * z * z - 1 ; if ( c >= isPrime . length ) break ; if ( isPrime [ ( int ) b ] && isPrime [ ( int ) c ] ) { long addend = a + b + c ; if ( sum + addend < sum ) throw new ArithmeticException ( "" Overflow "" ) ; sum += addend ; } } } } return Long . toString ( sum ) ; } } +","import eulerlib , fractions , itertools NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 10 ** 8 NEW_LINE ans = 0 NEW_LINE isprime = eulerlib . list_primality ( LIMIT - 1 ) NEW_LINE for x in range ( 1 , LIMIT // 4 + 1 ) : NEW_LINE INDENT for y in itertools . count ( 1 ) : NEW_LINE INDENT a = x * y * y - 1 NEW_LINE if a >= LIMIT : NEW_LINE INDENT break NEW_LINE DEDENT if not isprime [ a ] : NEW_LINE INDENT continue NEW_LINE DEDENT for z in itertools . count ( y + 1 ) : NEW_LINE INDENT if fractions . gcd ( y , z ) != 1 : NEW_LINE INDENT continue NEW_LINE DEDENT c = x * z * z - 1 NEW_LINE if c >= LIMIT : NEW_LINE INDENT break NEW_LINE DEDENT if isprime [ c ] : NEW_LINE INDENT b = x * y * z - 1 NEW_LINE if isprime [ b ] : NEW_LINE INDENT ans += a + b + c NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1653,"import java . math . BigInteger ; public final class p101 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p101 ( ) . run ( ) ) ; } private static final int DEGREE = 10 ; public String run ( ) { Fraction sum = Fraction . ZERO ; for ( int k = 1 ; k <= DEGREE ; k ++ ) { for ( int n = k + 1 ; ; n ++ ) { if ( n == DEGREE + 2 ) throw new AssertionError ( ) ; Fraction reference = new Fraction ( generatingFunction ( n ) ) ; Fraction term = optimumPolynomial ( k , n ) ; if ( ! term . equals ( reference ) ) { sum = sum . add ( term ) ; break ; } } } if ( sum . denominator . equals ( BigInteger . ONE ) ) return sum . numerator . toString ( ) ; else return sum . toString ( ) ; } private static Fraction optimumPolynomial ( int k , int n ) { Fraction sum = Fraction . ZERO ; for ( int i = 1 ; i <= k ; i ++ ) { Fraction product = new Fraction ( generatingFunction ( i ) ) ; for ( int j = 1 ; j <= k ; j ++ ) { if ( j != i ) product = product . multiply ( new Fraction ( BigInteger . valueOf ( n - j ) , BigInteger . valueOf ( i - j ) ) ) ; } sum = sum . add ( product ) ; } return sum ; } private static BigInteger generatingFunction ( int n ) { BigInteger sum = BigInteger . ZERO ; BigInteger biN = BigInteger . valueOf ( - n ) ; for ( int i = 0 ; i <= DEGREE ; i ++ ) sum = sum . add ( biN . pow ( i ) ) ; return sum ; } } +","import itertools NEW_LINE from fractions import Fraction NEW_LINE DEGREE = 10 NEW_LINE def compute ( ) : NEW_LINE INDENT ans = Fraction ( 0 , 1 ) NEW_LINE for k in range ( 1 , DEGREE + 1 ) : NEW_LINE INDENT for n in itertools . count ( k + 1 ) : NEW_LINE INDENT if n == DEGREE + 2 : NEW_LINE INDENT raise AssertionError ( ) NEW_LINE DEDENT reference = Fraction ( generating_function ( n ) , 1 ) NEW_LINE term = optimum_polynomial ( k , n ) NEW_LINE if term != reference : NEW_LINE INDENT ans += term NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT return str ( ans . numerator ) + ( "" "" if ans . denominator == 1 else "" / "" + str ( ans . denominator ) ) NEW_LINE DEDENT def optimum_polynomial ( k , n ) : NEW_LINE INDENT sum = Fraction ( 0 , 1 ) NEW_LINE for i in range ( k + 1 ) : NEW_LINE INDENT product = Fraction ( generating_function ( i ) , 1 ) NEW_LINE for j in range ( 1 , k + 1 ) : NEW_LINE INDENT if j != i : NEW_LINE INDENT product *= Fraction ( n - j , i - j ) NEW_LINE DEDENT DEDENT sum += product NEW_LINE DEDENT return sum NEW_LINE DEDENT def generating_function ( n ) : NEW_LINE INDENT return sum ( ( - n ) ** i for i in range ( DEGREE + 1 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1654,"public final class p250 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p250 ( ) . run ( ) ) ; } private static final long MODULUS = 10000000000000000L ; public String run ( ) { long [ ] numSubsets = new long [ 250 ] ; numSubsets [ 0 ] = 1 ; for ( int i = 1 ; i <= 250250 ; i ++ ) { int temp = Library . powMod ( i , i , 250 ) ; long [ ] newArray = new long [ numSubsets . length ] ; for ( int j = 0 ; j < 250 ; j ++ ) newArray [ ( j + temp ) % 250 ] = ( numSubsets [ j ] + numSubsets [ ( j + temp ) % 250 ] ) % MODULUS ; numSubsets = newArray ; } return Long . toString ( ( numSubsets [ 0 ] - 1 + MODULUS ) % MODULUS ) ; } } +","def compute ( ) : NEW_LINE INDENT MOD = 10 ** 16 NEW_LINE subsets = [ 0 ] * 250 NEW_LINE subsets [ 0 ] = 1 NEW_LINE for i in range ( 1 , 250250 + 1 ) : NEW_LINE INDENT offset = pow ( i , i , 250 ) NEW_LINE subsets = [ ( val + subsets [ ( j - offset ) % 250 ] ) % MOD for ( j , val ) in enumerate ( subsets ) ] NEW_LINE DEDENT ans = ( subsets [ 0 ] - 1 ) % MOD NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1655,"public final class p072 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p072 ( ) . run ( ) ) ; } private static final int LIMIT = Library . pow ( 10 , 6 ) ; public String run ( ) { long sum = 0 ; int [ ] totients = Library . listTotients ( LIMIT ) ; for ( int i = 2 ; i < totients . length ; i ++ ) sum += totients [ i ] ; return Long . toString ( sum ) ; } } +","import eulerlib , itertools NEW_LINE def compute ( ) : NEW_LINE INDENT totients = eulerlib . list_totients ( 10 ** 6 ) NEW_LINE ans = sum ( itertools . islice ( totients , 2 , None ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1656,"public final class p031 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p031 ( ) . run ( ) ) ; } private static final int TOTAL = 200 ; private static int [ ] COINS = { 1 , 2 , 5 , 10 , 20 , 50 , 100 , 200 } ; public String run ( ) { int [ ] [ ] ways = new int [ COINS . length + 1 ] [ TOTAL + 1 ] ; ways [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i < COINS . length ; i ++ ) { int coin = COINS [ i ] ; for ( int j = 0 ; j <= TOTAL ; j ++ ) ways [ i + 1 ] [ j ] = ways [ i ] [ j ] + ( j >= coin ? ways [ i + 1 ] [ j - coin ] : 0 ) ; } return Integer . toString ( ways [ COINS . length ] [ TOTAL ] ) ; } } +","def compute ( ) : NEW_LINE INDENT TOTAL = 200 NEW_LINE ways = [ 1 ] + [ 0 ] * TOTAL NEW_LINE for coin in [ 1 , 2 , 5 , 10 , 20 , 50 , 100 , 200 ] : NEW_LINE INDENT for i in range ( len ( ways ) - coin ) : NEW_LINE INDENT ways [ i + coin ] += ways [ i ] NEW_LINE DEDENT DEDENT return str ( ways [ - 1 ] ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1657,"public final class p197 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p197 ( ) . run ( ) ) ; } private static long ITERATIONS = 1000000000000L ; public String run ( ) { double x = - 1 ; double y = - 1 ; long i = 0 ; for ( ; i < ITERATIONS ; i ++ ) { if ( i > 0 && x == y ) break ; x = f ( x ) ; y = f ( f ( y ) ) ; } long remain = ( ITERATIONS - i ) % i ; for ( ; remain > 0 ; remain -- ) x = f ( x ) ; double answer = x + f ( x ) ; answer = Math . floor ( answer * 1e9 ) / 1e9 ; return String . format ( "" % .9f "" , answer ) ; } private static double f ( double x ) { return Math . floor ( Math . pow ( 2 , 30.403243784 - x * x ) ) / 1e9 ; } } +","import math NEW_LINE def compute ( ) : NEW_LINE INDENT def f ( x ) : NEW_LINE INDENT return math . floor ( 2.0 ** ( 30.403243784 - x * x ) ) / 1.0e9 NEW_LINE DEDENT ITERATIONS = 10 ** 12 NEW_LINE x = - 1.0 NEW_LINE y = - 1.0 NEW_LINE i = 0 NEW_LINE while i < ITERATIONS : NEW_LINE INDENT if i > 0 and x == y : NEW_LINE INDENT break NEW_LINE DEDENT x = f ( x ) NEW_LINE y = f ( f ( y ) ) NEW_LINE i += 1 NEW_LINE DEDENT remain = ( ITERATIONS - i ) % i NEW_LINE for i in range ( remain ) : NEW_LINE INDENT x = f ( x ) NEW_LINE DEDENT ans = x + f ( x ) NEW_LINE ans = math . floor ( ans * 1.0e9 ) / 1.0e9 NEW_LINE return f "" { ans : .9f } "" NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1658,"import java . math . BigInteger ; public final class p056 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p056 ( ) . run ( ) ) ; } public String run ( ) { int max = 0 ; for ( int a = 1 ; a < 100 ; a ++ ) { for ( int b = 1 ; b < 100 ; b ++ ) { BigInteger pow = BigInteger . valueOf ( a ) . pow ( b ) ; max = Math . max ( digitSum ( pow ) , max ) ; } } return Integer . toString ( max ) ; } private static int digitSum ( BigInteger n ) { int sum = 0 ; String s = n . toString ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) sum += s . charAt ( i ) - '0' ; return sum ; } } +","def compute ( ) : NEW_LINE INDENT ans = max ( sum ( int ( c ) for c in str ( a ** b ) ) for a in range ( 100 ) for b in range ( 100 ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1659,"public final class p008 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p008 ( ) . run ( ) ) ; } public String run ( ) { long maxProd = - 1 ; for ( int i = 0 ; i + ADJACENT <= NUMBER . length ( ) ; i ++ ) { long prod = 1 ; for ( int j = 0 ; j < ADJACENT ; j ++ ) prod *= NUMBER . charAt ( i + j ) - '0' ; maxProd = Math . max ( prod , maxProd ) ; } return Long . toString ( maxProd ) ; } private static final int ADJACENT = 13 ; private static final String NUMBER = ""7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"" ; } +","def compute ( ) : NEW_LINE INDENT ans = max ( digit_product ( NUMBER [ i : i + ADJACENT ] ) for i in range ( len ( NUMBER ) - ADJACENT + 1 ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT def digit_product ( s ) : NEW_LINE INDENT result = 1 NEW_LINE for c in s : NEW_LINE INDENT result *= int ( c ) NEW_LINE DEDENT return result NEW_LINE DEDENT NUMBER = ""7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"" NEW_LINE ADJACENT = 13 NEW_LINE if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1660,"import java . math . BigInteger ; public final class p164 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p164 ( ) . run ( ) ) ; } private static final int BASE = 10 ; private static final int DIGITS = 20 ; private static final int CONSECUTIVE = 3 ; private static final int MAX_SUM = 9 ; public String run ( ) { BigInteger [ ] [ ] ways = new BigInteger [ DIGITS + CONSECUTIVE + 1 ] [ Library . pow ( BASE , CONSECUTIVE ) ] ; ways [ 0 ] [ 0 ] = BigInteger . ONE ; for ( int prefix = 1 ; prefix < ways [ 0 ] . length ; prefix ++ ) ways [ 0 ] [ prefix ] = BigInteger . ZERO ; for ( int digits = 1 ; digits < ways . length ; digits ++ ) { for ( int prefix = 0 ; prefix < ways [ digits ] . length ; prefix ++ ) { BigInteger sum = BigInteger . ZERO ; if ( digitSum ( prefix ) <= MAX_SUM ) { for ( int nextDigit = 0 ; nextDigit < BASE ; nextDigit ++ ) sum = sum . add ( ways [ digits - 1 ] [ prefix % Library . pow ( BASE , CONSECUTIVE - 1 ) * BASE + nextDigit ] ) ; } ways [ digits ] [ prefix ] = sum ; } } return ways [ DIGITS + CONSECUTIVE ] [ 0 ] . subtract ( ways [ DIGITS + CONSECUTIVE - 1 ] [ 0 ] ) . toString ( ) ; } private static int digitSum ( int n ) { int sum = 0 ; for ( ; n != 0 ; n /= 10 ) sum += n % 10 ; return sum ; } } +","def compute ( ) : NEW_LINE INDENT BASE = 10 NEW_LINE DIGITS = 20 NEW_LINE CONSECUTIVE = 3 NEW_LINE MAX_SUM = 9 NEW_LINE innerlen = BASE ** CONSECUTIVE NEW_LINE ways = [ [ 1 ] + [ 0 ] * ( innerlen - 1 ) ] NEW_LINE for digits in range ( 1 , DIGITS + CONSECUTIVE + 1 ) : NEW_LINE INDENT newrow = [ ] NEW_LINE for prefix in range ( innerlen ) : NEW_LINE INDENT sum = 0 NEW_LINE if digit_sum ( prefix ) <= MAX_SUM : NEW_LINE INDENT for nextdigit in range ( BASE ) : NEW_LINE INDENT sum += ways [ digits - 1 ] [ prefix % ( BASE ** ( CONSECUTIVE - 1 ) ) * BASE + nextdigit ] NEW_LINE DEDENT DEDENT newrow . append ( sum ) NEW_LINE DEDENT ways . append ( newrow ) NEW_LINE DEDENT ans = ways [ - 1 ] [ 0 ] - ways [ - 2 ] [ 0 ] NEW_LINE return str ( ans ) NEW_LINE DEDENT def digit_sum ( n ) : NEW_LINE INDENT return sum ( int ( c ) for c in str ( n ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1661,"import java . math . BigInteger ; public final class p401 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p401 ( ) . run ( ) ) ; } private static final long LIMIT = 1000000000000000L ; private static final long MODULUS = Library . pow ( 10 , 9 ) ; public String run ( ) { int splitCount = ( int ) Library . sqrt ( LIMIT ) ; splitCount = Math . max ( splitCount / 3 , 1 ) ; int splitAt = ( int ) ( LIMIT / ( splitCount + 1 ) ) ; long sum = 0 ; for ( int i = 1 ; i <= splitAt ; i ++ ) { long count = LIMIT / i % MODULUS ; long term = ( long ) i * i % MODULUS ; term = term * count % MODULUS ; sum = ( sum + term ) % MODULUS ; } for ( int i = splitCount ; i >= 1 ; i -- ) { long start = LIMIT / ( i + 1 ) ; long end = LIMIT / i ; long sumSquares = sumSquaresMod ( end ) - sumSquaresMod ( start ) ; sumSquares = ( sumSquares + MODULUS ) % MODULUS ; sum = ( sum + i * sumSquares % MODULUS ) % MODULUS ; } return Long . toString ( sum ) ; } private static final BigInteger MODULUS_BI = BigInteger . valueOf ( MODULUS ) ; private static final BigInteger SIX_BI = BigInteger . valueOf ( 6 ) ; private static long sumSquaresMod ( long n ) { BigInteger x = BigInteger . valueOf ( n ) ; BigInteger y = x . multiply ( x . add ( BigInteger . ONE ) ) ; y = y . multiply ( x . shiftLeft ( 1 ) . add ( BigInteger . ONE ) ) ; y = y . divide ( SIX_BI ) ; y = y . mod ( MODULUS_BI ) ; return y . longValue ( ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 10 ** 15 NEW_LINE MODULUS = 10 ** 9 NEW_LINE splitcount = eulerlib . sqrt ( LIMIT ) NEW_LINE splitat = LIMIT // ( splitcount + 1 ) NEW_LINE def sum_squares ( s , e ) : NEW_LINE INDENT return ( e * ( e + 1 ) * ( e * 2 + 1 ) - s * ( s + 1 ) * ( s * 2 + 1 ) ) // 6 NEW_LINE DEDENT ans = sum ( ( i * i * ( LIMIT // i ) ) for i in range ( 1 , splitat + 1 ) ) NEW_LINE ans += sum ( ( sum_squares ( LIMIT // ( i + 1 ) , LIMIT // i ) * i ) for i in range ( 1 , splitcount + 1 ) ) NEW_LINE return str ( ans % MODULUS ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1662,"public final class p027 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p027 ( ) . run ( ) ) ; } public String run ( ) { int bestNum = 0 ; int bestA = 0 ; int bestB = 0 ; for ( int a = - 1000 ; a <= 1000 ; a ++ ) { for ( int b = - 1000 ; b <= 1000 ; b ++ ) { int num = numberOfConsecutivePrimesGenerated ( a , b ) ; if ( num > bestNum ) { bestNum = num ; bestA = a ; bestB = b ; } } } return Integer . toString ( bestA * bestB ) ; } private static int numberOfConsecutivePrimesGenerated ( int a , int b ) { for ( int i = 0 ; ; i ++ ) { int n = i * i + i * a + b ; if ( n < 0 || ! Library . isPrime ( n ) ) return i ; } } } +","import eulerlib , itertools NEW_LINE def compute ( ) : NEW_LINE INDENT ans = max ( ( ( a , b ) for a in range ( - 999 , 1000 ) for b in range ( 2 , 1000 ) ) , key = count_consecutive_primes ) NEW_LINE return str ( ans [ 0 ] * ans [ 1 ] ) NEW_LINE DEDENT def count_consecutive_primes ( ab ) : NEW_LINE INDENT a , b = ab NEW_LINE for i in itertools . count ( ) : NEW_LINE INDENT n = i * i + i * a + b NEW_LINE if not is_prime ( n ) : NEW_LINE INDENT return i NEW_LINE DEDENT DEDENT DEDENT isprimecache = eulerlib . list_primality ( 1000 ) NEW_LINE def is_prime ( n ) : NEW_LINE INDENT if n < 0 : NEW_LINE INDENT return False NEW_LINE DEDENT elif n < len ( isprimecache ) : NEW_LINE INDENT return isprimecache [ n ] NEW_LINE DEDENT else : NEW_LINE INDENT return eulerlib . is_prime ( n ) NEW_LINE DEDENT DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1663,"public final class p249 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p249 ( ) . run ( ) ) ; } private static final int LIMIT = 5000 ; private static final long MODULUS = 10000000000000000L ; public String run ( ) { boolean [ ] isPrime = Library . listPrimality ( LIMIT * LIMIT / 2 ) ; long [ ] numSubsets = new long [ LIMIT * LIMIT / 2 ] ; numSubsets [ 0 ] = 1 ; int maxSum = 0 ; for ( int i = 0 ; i < LIMIT ; i ++ ) { if ( ! isPrime [ i ] ) continue ; maxSum += i ; for ( int j = maxSum ; j >= i ; j -- ) { long temp = numSubsets [ j ] + numSubsets [ j - i ] ; if ( temp < MODULUS ) numSubsets [ j ] = temp ; else numSubsets [ j ] = temp - MODULUS ; } } long sum = 0 ; for ( int i = 0 ; i < numSubsets . length ; i ++ ) { if ( isPrime [ i ] ) sum = ( sum + numSubsets [ i ] ) % MODULUS ; } return Long . toString ( sum ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 5000 NEW_LINE MODULUS = 10 ** 16 NEW_LINE count = [ 0 ] * ( LIMIT ** 2 // 2 ) NEW_LINE count [ 0 ] = 1 NEW_LINE s = 0 NEW_LINE for p in eulerlib . list_primes ( LIMIT ) : NEW_LINE INDENT for i in reversed ( range ( s + 1 ) ) : NEW_LINE INDENT count [ i + p ] = ( count [ i + p ] + count [ i ] ) % MODULUS NEW_LINE DEDENT s += p NEW_LINE DEDENT isprime = eulerlib . list_primality ( s + 1 ) NEW_LINE ans = sum ( count [ i ] for i in range ( s + 1 ) if isprime [ i ] ) % MODULUS NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1664,"public final class p265 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p265 ( ) . run ( ) ) ; } private static final int N = 5 ; private static final int TWO_POW_N = 1 << N ; public String run ( ) { long sum = 0 ; int start = ( 1 << ( TWO_POW_N - N - 1 ) ) + 1 ; int end = 1 << ( TWO_POW_N - N ) ; for ( int i = start ; i < end ; i += 2 ) { if ( checkArrangement ( i ) ) sum += i ; } return Long . toString ( sum ) ; } private static final int MASK = TWO_POW_N - 1 ; private static final int FULL_SET = ( int ) ( 1L << TWO_POW_N ) - 1 ; private static boolean checkArrangement ( int digits ) { int seen = 0 ; long temp = ( digits & 0xFFFFFFFFL ) | ( ( digits & 0xFFFFFFFFL ) << TWO_POW_N ) ; for ( int i = 0 ; i < TWO_POW_N ; i ++ ) seen |= 1 << ( ( int ) ( temp >>> i ) & MASK ) ; return seen == FULL_SET ; } } +","def compute ( ) : NEW_LINE INDENT N = 5 NEW_LINE TWO_POW_N = 2 ** N NEW_LINE MASK = TWO_POW_N - 1 NEW_LINE def check_arrangement ( digits ) : NEW_LINE INDENT seen = set ( ) NEW_LINE digits |= digits << TWO_POW_N NEW_LINE for i in range ( TWO_POW_N ) : NEW_LINE INDENT seen . add ( ( digits >> i ) & MASK ) NEW_LINE DEDENT return len ( seen ) == TWO_POW_N NEW_LINE DEDENT start = 2 ** ( TWO_POW_N - N - 1 ) + 1 NEW_LINE end = 2 ** ( TWO_POW_N - N ) NEW_LINE ans = sum ( i for i in range ( start , end , 2 ) if check_arrangement ( i ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1665,"import java . util . Arrays ; public final class p179 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p179 ( ) . run ( ) ) ; } private static final int LIMIT = Library . pow ( 10 , 7 ) ; public String run ( ) { int [ ] numDivisors = new int [ LIMIT + 1 ] ; Arrays . fill ( numDivisors , 2 ) ; for ( int i = 2 ; i < numDivisors . length ; i ++ ) { for ( int j = i * 2 ; j < numDivisors . length ; j += i ) numDivisors [ j ] ++ ; } int count = 0 ; for ( int i = 2 ; i < numDivisors . length - 1 ; i ++ ) { if ( numDivisors [ i ] == numDivisors [ i + 1 ] ) count ++ ; } return Integer . toString ( count ) ; } } +","def compute ( ) : NEW_LINE INDENT divisors = [ 2 ] * ( 10 ** 7 + 1 ) NEW_LINE for i in range ( 2 , ( len ( divisors ) + 1 ) // 2 ) : NEW_LINE INDENT for j in range ( i * 2 , len ( divisors ) , i ) : NEW_LINE INDENT divisors [ j ] += 1 NEW_LINE DEDENT DEDENT ans = sum ( ( 1 if divisors [ i ] == divisors [ i + 1 ] else 0 ) for i in range ( 2 , len ( divisors ) - 1 ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1666,"public final class p018 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p018 ( ) . run ( ) ) ; } public String run ( ) { for ( int i = triangle . length - 2 ; i >= 0 ; i -- ) { for ( int j = 0 ; j < triangle [ i ] . length ; j ++ ) triangle [ i ] [ j ] += Math . max ( triangle [ i + 1 ] [ j ] , triangle [ i + 1 ] [ j + 1 ] ) ; } return Integer . toString ( triangle [ 0 ] [ 0 ] ) ; } private int [ ] [ ] triangle = { { 75 } , { 95 , 64 } , { 17 , 47 , 82 } , { 18 , 35 , 87 , 10 } , { 20 , 4 , 82 , 47 , 65 } , { 19 , 1 , 23 , 75 , 3 , 34 } , { 88 , 2 , 77 , 73 , 7 , 63 , 67 } , { 99 , 65 , 4 , 28 , 6 , 16 , 70 , 92 } , { 41 , 41 , 26 , 56 , 83 , 40 , 80 , 70 , 33 } , { 41 , 48 , 72 , 33 , 47 , 32 , 37 , 16 , 94 , 29 } , { 53 , 71 , 44 , 65 , 25 , 43 , 91 , 52 , 97 , 51 , 14 } , { 70 , 11 , 33 , 28 , 77 , 73 , 17 , 78 , 39 , 68 , 17 , 57 } , { 91 , 71 , 52 , 38 , 17 , 14 , 91 , 43 , 58 , 50 , 27 , 29 , 48 } , { 63 , 66 , 4 , 68 , 89 , 53 , 67 , 30 , 73 , 16 , 69 , 87 , 40 , 31 } , { 4 , 62 , 98 , 27 , 23 , 9 , 70 , 98 , 73 , 93 , 38 , 53 , 60 , 4 , 23 } , } ; } +","def compute ( ) : NEW_LINE INDENT for i in reversed ( range ( len ( triangle ) - 1 ) ) : NEW_LINE INDENT for j in range ( len ( triangle [ i ] ) ) : NEW_LINE INDENT triangle [ i ] [ j ] += max ( triangle [ i + 1 ] [ j ] , triangle [ i + 1 ] [ j + 1 ] ) NEW_LINE DEDENT DEDENT return str ( triangle [ 0 ] [ 0 ] ) NEW_LINE DEDENT triangle = [ [ 75 ] , [ 95 , 64 ] , [ 17 , 47 , 82 ] , [ 18 , 35 , 87 , 10 ] , [ 20 , 4 , 82 , 47 , 65 ] , [ 19 , 1 , 23 , 75 , 3 , 34 ] , [ 88 , 2 , 77 , 73 , 7 , 63 , 67 ] , [ 99 , 65 , 4 , 28 , 6 , 16 , 70 , 92 ] , [ 41 , 41 , 26 , 56 , 83 , 40 , 80 , 70 , 33 ] , [ 41 , 48 , 72 , 33 , 47 , 32 , 37 , 16 , 94 , 29 ] , [ 53 , 71 , 44 , 65 , 25 , 43 , 91 , 52 , 97 , 51 , 14 ] , [ 70 , 11 , 33 , 28 , 77 , 73 , 17 , 78 , 39 , 68 , 17 , 57 ] , [ 91 , 71 , 52 , 38 , 17 , 14 , 91 , 43 , 58 , 50 , 27 , 29 , 48 ] , [ 63 , 66 , 4 , 68 , 89 , 53 , 67 , 30 , 73 , 16 , 69 , 87 , 40 , 31 ] , [ 4 , 62 , 98 , 27 , 23 , 9 , 70 , 98 , 73 , 93 , 38 , 53 , 60 , 4 , 23 ] , ] NEW_LINE if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1667,"public final class p015 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p015 ( ) . run ( ) ) ; } public String run ( ) { return Library . binomial ( 40 , 20 ) . toString ( ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT return str ( eulerlib . binomial ( 40 , 20 ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1668,"import java . util . HashSet ; import java . util . Set ; public final class p087 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p087 ( ) . run ( ) ) ; } private static final int LIMIT = 50000000 ; public String run ( ) { int [ ] primes = Library . listPrimes ( Library . sqrt ( LIMIT ) ) ; Set < Integer > sums = new HashSet < > ( ) ; sums . add ( 0 ) ; for ( int i = 2 ; i <= 4 ; i ++ ) { Set < Integer > newsums = new HashSet < > ( ) ; for ( int p : primes ) { long q = 1 ; for ( int j = 0 ; j < i ; j ++ ) q *= p ; if ( q > LIMIT ) break ; int r = ( int ) q ; for ( int x : sums ) { if ( x + r <= LIMIT ) newsums . add ( x + r ) ; } } sums = newsums ; } return Integer . toString ( sums . size ( ) ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 50000000 NEW_LINE primes = eulerlib . list_primes ( eulerlib . sqrt ( LIMIT ) ) NEW_LINE sums = { 0 } NEW_LINE for i in range ( 2 , 5 ) : NEW_LINE INDENT newsums = set ( ) NEW_LINE for p in primes : NEW_LINE INDENT q = p ** i NEW_LINE if q > LIMIT : NEW_LINE INDENT break NEW_LINE DEDENT for x in sums : NEW_LINE INDENT if x + q <= LIMIT : NEW_LINE INDENT newsums . add ( x + q ) NEW_LINE DEDENT DEDENT DEDENT sums = newsums NEW_LINE DEDENT return str ( len ( sums ) ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1669,"import java . math . BigInteger ; public final class p048 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p048 ( ) . run ( ) ) ; } public String run ( ) { BigInteger modulus = BigInteger . TEN . pow ( 10 ) ; BigInteger sum = BigInteger . ZERO ; for ( int i = 1 ; i <= 1000 ; i ++ ) sum = sum . add ( BigInteger . valueOf ( i ) . modPow ( BigInteger . valueOf ( i ) , modulus ) ) ; return sum . mod ( modulus ) . toString ( ) ; } } +","def compute ( ) : NEW_LINE INDENT MOD = 10 ** 10 NEW_LINE ans = sum ( pow ( i , i , MOD ) for i in range ( 1 , 1001 ) ) % MOD NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1670,"public final class p069 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p069 ( ) . run ( ) ) ; } private static final int LIMIT = Library . pow ( 10 , 6 ) ; public String run ( ) { int maxNumer = 0 ; int maxDenom = 1 ; int [ ] totients = Library . listTotients ( LIMIT ) ; for ( int n = 1 ; n < totients . length ; n ++ ) { if ( ( long ) n * maxDenom > ( long ) maxNumer * totients [ n ] ) { maxNumer = n ; maxDenom = totients [ n ] ; } } return Integer . toString ( maxNumer ) ; } } +","import eulerlib , fractions NEW_LINE def compute ( ) : NEW_LINE INDENT totients = eulerlib . list_totients ( 10 ** 6 ) NEW_LINE ans = max ( range ( 2 , len ( totients ) ) , key = ( lambda i : fractions . Fraction ( i , totients [ i ] ) ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1671,"public final class p381 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p381 ( ) . run ( ) ) ; } public String run ( ) { boolean [ ] isPrime = Library . listPrimality ( Library . pow ( 10 , 8 ) ) ; long sum = 0 ; for ( int i = 5 ; i < isPrime . length ; i ++ ) { if ( isPrime [ i ] ) sum += s ( i ) ; } return Long . toString ( sum ) ; } private static int s ( int p ) { return ( int ) ( ( long ) ( p - 3 ) * Library . reciprocalMod ( 8 % p , p ) % p ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT def s ( p ) : NEW_LINE INDENT return ( p - 3 ) * eulerlib . reciprocal_mod ( 8 % p , p ) % p NEW_LINE DEDENT ans = sum ( s ( p ) for p in eulerlib . prime_generator ( 10 ** 8 ) if p >= 5 ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1672,"public final class p129 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p129 ( ) . run ( ) ) ; } private static final int LIMIT = Library . pow ( 10 , 6 ) ; public String run ( ) { for ( int n = LIMIT ; ; n ++ ) { if ( findLeastDivisibleRepunit ( n ) > LIMIT ) return Integer . toString ( n ) ; } } private static int findLeastDivisibleRepunit ( int n ) { if ( n % 2 == 0 || n % 5 == 0 ) return 0 ; if ( n > Integer . MAX_VALUE / 10 ) throw new IllegalArgumentException ( "" Arithmetic ▁ overflow "" ) ; int sum = 1 ; int pow = 1 ; int k = 1 ; while ( sum % n != 0 ) { k ++ ; pow = pow * 10 % n ; sum = ( sum + pow ) % n ; } return k ; } } +","import itertools NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 10 ** 6 NEW_LINE for n in itertools . count ( LIMIT ) : NEW_LINE INDENT if least_divisible_repunit ( n ) > LIMIT : NEW_LINE INDENT return str ( n ) NEW_LINE DEDENT DEDENT DEDENT def least_divisible_repunit ( n ) : NEW_LINE INDENT if n % 2 == 0 or n % 5 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT k = 1 NEW_LINE s = 1 NEW_LINE p = 1 NEW_LINE while s % n != 0 : NEW_LINE INDENT k += 1 NEW_LINE p = p * 10 % n NEW_LINE s = ( s + p ) % n NEW_LINE DEDENT return k NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1673,"import java . util . Arrays ; public final class p032 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p032 ( ) . run ( ) ) ; } public String run ( ) { int sum = 0 ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( hasPandigitalProduct ( i ) ) sum += i ; } return Integer . toString ( sum ) ; } private static boolean hasPandigitalProduct ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 && isPandigital ( "" "" + n + i + n / i ) ) return true ; } return false ; } private static boolean isPandigital ( String s ) { if ( s . length ( ) != 9 ) return false ; char [ ] temp = s . toCharArray ( ) ; Arrays . sort ( temp ) ; return new String ( temp ) . equals ( ""123456789"" ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT ans = sum ( i for i in range ( 1 , 10000 ) if has_pandigital_product ( i ) ) NEW_LINE return str ( ans ) NEW_LINE DEDENT def has_pandigital_product ( n ) : NEW_LINE INDENT for i in range ( 1 , eulerlib . sqrt ( n ) + 1 ) : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT temp = str ( n ) + str ( i ) + str ( n // i ) NEW_LINE if "" "" . join ( sorted ( temp ) ) == ""123456789"" : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1674,"import java . util . HashSet ; import java . util . Set ; public final class p347 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p347 ( ) . run ( ) ) ; } private static final int LIMIT = 10000000 ; public String run ( ) { Set < Integer > possible = new HashSet < > ( ) ; int [ ] primes = Library . listPrimes ( LIMIT / 2 ) ; for ( int i = 0 , end = Library . sqrt ( LIMIT ) ; i < primes . length ; i ++ ) { int p = primes [ i ] ; if ( p > end ) break ; for ( int j = i + 1 ; j < primes . length ; j ++ ) { int q = primes [ j ] ; int lcm = p * q ; if ( lcm > LIMIT ) break ; int multLimit = LIMIT / lcm ; int multiplier = 1 ; while ( multiplier * p <= multLimit ) multiplier *= p ; int maxMult = multiplier ; while ( multiplier % p == 0 ) { multiplier /= p ; while ( multiplier * q <= multLimit ) multiplier *= q ; maxMult = Math . max ( multiplier , maxMult ) ; } possible . add ( maxMult * lcm ) ; } } long sum = 0 ; for ( int x : possible ) sum += x ; return Long . toString ( sum ) ; } } +","import eulerlib NEW_LINE def compute ( ) : NEW_LINE INDENT LIMIT = 10000000 NEW_LINE possible = set ( ) NEW_LINE primes = eulerlib . list_primes ( LIMIT // 2 ) NEW_LINE end = eulerlib . sqrt ( LIMIT ) NEW_LINE for i in range ( len ( primes ) ) : NEW_LINE INDENT p = primes [ i ] NEW_LINE if p > end : NEW_LINE INDENT break NEW_LINE DEDENT for j in range ( i + 1 , len ( primes ) ) : NEW_LINE INDENT q = primes [ j ] NEW_LINE lcm = p * q NEW_LINE if lcm > LIMIT : NEW_LINE INDENT break NEW_LINE DEDENT multlimit = LIMIT // lcm NEW_LINE multiplier = 1 NEW_LINE while multiplier * p <= multlimit : NEW_LINE INDENT multiplier *= p NEW_LINE DEDENT maxmult = multiplier NEW_LINE while multiplier % p == 0 : NEW_LINE INDENT multiplier //= p NEW_LINE while multiplier * q <= multlimit : NEW_LINE INDENT multiplier *= q NEW_LINE DEDENT maxmult = max ( multiplier , maxmult ) NEW_LINE DEDENT possible . add ( maxmult * lcm ) NEW_LINE DEDENT DEDENT ans = sum ( possible ) NEW_LINE return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1675,"public final class p134 implements EulerSolution { public static void main ( String [ ] args ) { System . out . println ( new p134 ( ) . run ( ) ) ; } public String run ( ) { long sum = 0 ; int [ ] primes = Library . listPrimes ( 2000000 ) ; for ( int i = 2 ; primes [ i ] <= 1000000 ; i ++ ) { int p = primes [ i ] ; int q = primes [ i + 1 ] ; int k = 1 ; while ( k < p ) k *= 10 ; long m = ( long ) ( q - p ) * Library . reciprocalMod ( k % q , q ) % q ; sum += m * k + p ; } return Long . toString ( sum ) ; } } +","import eulerlib , itertools NEW_LINE def compute ( ) : NEW_LINE INDENT ans = 0 NEW_LINE primes = eulerlib . list_primes ( 2000000 ) NEW_LINE for i in itertools . count ( 2 ) : NEW_LINE INDENT p = primes [ i ] NEW_LINE q = primes [ i + 1 ] NEW_LINE if p > 1000000 : NEW_LINE INDENT break NEW_LINE DEDENT k = 1 NEW_LINE while k < p : NEW_LINE INDENT k *= 10 NEW_LINE DEDENT m = ( q - p ) * eulerlib . reciprocal_mod ( k % q , q ) % q NEW_LINE ans += m * k + p NEW_LINE DEDENT return str ( ans ) NEW_LINE DEDENT if __name__ == "" _ _ main _ _ "" : NEW_LINE INDENT print ( compute ( ) ) NEW_LINE DEDENT +" +E1676,"class Solution { public int [ ] [ ] floodFill ( int [ ] [ ] image , int sr , int sc , int newColor ) { Queue < Node > queue = new LinkedList < Node > ( ) ; int color = image [ sr ] [ sc ] ; if ( color == newColor ) return image ; queue . add ( new Node ( sr , sc ) ) ; while ( ! queue . isEmpty ( ) ) { Node curr = queue . remove ( ) ; int r = curr . r , c = curr . c ; if ( image [ r ] [ c ] == color ) { image [ r ] [ c ] = newColor ; if ( r - 1 >= 0 ) queue . add ( new Node ( r - 1 , c ) ) ; if ( r + 1 < image . length ) queue . add ( new Node ( r + 1 , c ) ) ; if ( c - 1 >= 0 ) queue . add ( new Node ( r , c - 1 ) ) ; if ( c + 1 < image [ 0 ] . length ) queue . add ( new Node ( r , c + 1 ) ) ; } } return image ; } class Node { int r ; int c ; public Node ( int r , int c ) { this . r = r ; this . c = c ; } } } +","class Solution ( object ) : NEW_LINE INDENT def floodFill ( self , image , sr , sc , newColor ) : NEW_LINE INDENT r_ls , c_ls = len ( image ) , len ( image [ 0 ] ) NEW_LINE color = image [ sr ] [ sc ] NEW_LINE if color == newColor : NEW_LINE INDENT return image NEW_LINE DEDENT queue = [ ( sr , sc ) ] NEW_LINE while len ( queue ) > 0 : NEW_LINE INDENT r , c = queue . pop ( 0 ) NEW_LINE if image [ r ] [ c ] == color : NEW_LINE INDENT image [ r ] [ c ] = newColor NEW_LINE if r - 1 >= 0 : queue . append ( ( r - 1 , c ) ) NEW_LINE if r + 1 < r_ls : queue . append ( ( r + 1 , c ) ) NEW_LINE if c - 1 >= 0 : queue . append ( ( r , c - 1 ) ) NEW_LINE if c + 1 < c_ls : queue . append ( ( r , c + 1 ) ) NEW_LINE DEDENT DEDENT return image NEW_LINE DEDENT DEDENT +" +E1677,"public class Solution { public int thirdMax ( int [ ] nums ) { PriorityQueue < Integer > pq = new PriorityQueue < > ( 3 ) ; Set < Integer > set = new HashSet < > ( ) ; for ( int i : nums ) { if ( set . contains ( i ) ) continue ; pq . offer ( i ) ; set . add ( i ) ; if ( pq . size ( ) > 3 ) set . remove ( pq . poll ( ) ) ; } while ( pq . size ( ) < 3 && pq . size ( ) > 1 ) { pq . poll ( ) ; } return pq . peek ( ) ; } } +","class Solution ( object ) : NEW_LINE INDENT def thirdMax ( self , nums ) : NEW_LINE INDENT import Queue NEW_LINE pq = Queue . PriorityQueue ( 4 ) NEW_LINE check = set ( ) NEW_LINE for n in nums : NEW_LINE INDENT if n in check : NEW_LINE INDENT continue NEW_LINE DEDENT pq . put ( n ) NEW_LINE check . add ( n ) NEW_LINE if len ( check ) > 3 : NEW_LINE INDENT check . remove ( pq . get ( ) ) NEW_LINE DEDENT DEDENT total = len ( check ) NEW_LINE while total < 3 and total > 1 : NEW_LINE INDENT total -= 1 NEW_LINE DEDENT return pq . get ( ) NEW_LINE DEDENT DEDENT +" +E1678,"class Solution { public String licenseKeyFormatting ( String s , int k ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) if ( s . charAt ( i ) != ' - ' ) sb . append ( sb . length ( ) % ( k + 1 ) == k ? ' - ' : "" "" ) . append ( s . charAt ( i ) ) ; return sb . reverse ( ) . toString ( ) . toUpperCase ( ) ; } } +","class Solution ( object ) : NEW_LINE INDENT def licenseKeyFormatting ( self , S , K ) : NEW_LINE INDENT S = S . upper ( ) . replace ( ' - ' , ' ' ) NEW_LINE ls = len ( S ) NEW_LINE if ls % K == 0 : NEW_LINE INDENT pos = K NEW_LINE DEDENT else : NEW_LINE INDENT pos = ls % K NEW_LINE DEDENT res = S [ : pos ] NEW_LINE while pos < ls : NEW_LINE INDENT res += ' - ' + S [ pos : pos + K ] NEW_LINE pos += K NEW_LINE DEDENT return res NEW_LINE DEDENT DEDENT +" +E1679,"class RecentCounter { Queue < Integer > q ; public RecentCounter ( ) { q = new LinkedList ( ) ; } public int ping ( int t ) { q . add ( t ) ; while ( q . peek ( ) < t - 3000 ) q . poll ( ) ; return q . size ( ) ; } } +","class RecentCounter ( object ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . queue = [ ] NEW_LINE DEDENT def ping ( self , t ) : NEW_LINE INDENT self . queue . append ( t ) NEW_LINE while self . queue and self . queue [ 0 ] < t - 3000 : NEW_LINE INDENT self . queue . pop ( 0 ) NEW_LINE DEDENT return len ( self . queue ) NEW_LINE DEDENT DEDENT +" +E1680,"class Solution { public int uniqueMorseRepresentations ( String [ ] words ) { String [ ] MORSE = new String [ ] { "" . - "" , "" - . . . "" , "" - . - . "" , "" - . . "" , "" . "" , "" . . - . "" , "" - - . "" , "" . . . . "" , "" . . "" , "" . - - - "" , "" - . - "" , "" . - . . "" , "" - - "" , "" - . "" , "" - - - "" , "" . - - . "" , "" - - . - "" , "" . - . "" , "" . . . "" , "" - "" , "" . . - "" , "" . . . - "" , "" . - - "" , "" - . . - "" , "" - . - - "" , "" - - . . "" } ; Set < String > seen = new HashSet ( ) ; for ( String word : words ) { StringBuilder code = new StringBuilder ( ) ; for ( char c : word . toCharArray ( ) ) code . append ( MORSE [ c - ' a ' ] ) ; seen . add ( code . toString ( ) ) ; } return seen . size ( ) ; } } +","Morse_tab = [ "" . - "" , "" - . . . "" , "" - . - . "" , "" - . . "" , "" . "" , "" . . - . "" , "" - - . "" , "" . . . . "" , "" . . "" , "" . - - - "" , "" - . - "" , "" . - . . "" , "" - - "" , "" - . "" , "" - - - "" , "" . - - . "" , "" - - . - "" , "" . - . "" , "" . . . "" , "" - "" , "" . . - "" , "" . . . - "" , "" . - - "" , "" - . . - "" , "" - . - - "" , "" - - . . "" ] NEW_LINE class Solution ( object ) : NEW_LINE INDENT def uniqueMorseRepresentations ( self , words ) : NEW_LINE INDENT if len ( words ) == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT ans_set = set ( ) NEW_LINE for word in words : NEW_LINE INDENT morsed = "" "" NEW_LINE for c in word : NEW_LINE INDENT morsed += Morse_tab [ ord ( c ) - ord ( ' a ' ) ] NEW_LINE DEDENT ans_set . add ( morsed ) NEW_LINE DEDENT return len ( ans_set ) NEW_LINE DEDENT DEDENT +" +E1681,"class Solution { public int [ ] runningSum ( int [ ] nums ) { if ( nums . length <= 1 ) return nums ; for ( int i = 1 ; i < nums . length ; i ++ ) nums [ i ] += nums [ i - 1 ] ; return nums ; } } +","class Solution : NEW_LINE INDENT def runningSum ( self , nums : List [ int ] ) -> List [ int ] : NEW_LINE INDENT if nums is None or len ( nums ) == 0 : NEW_LINE INDENT return nums NEW_LINE DEDENT for i in range ( 1 , len ( nums ) ) : NEW_LINE INDENT nums [ i ] += nums [ i - 1 ] NEW_LINE DEDENT return nums NEW_LINE DEDENT DEDENT +" +E1682,"class MyHashMap { final ListNode [ ] nodes = new ListNode [ 10000 ] ; public void put ( int key , int value ) { int i = idx ( key ) ; if ( nodes [ i ] == null ) nodes [ i ] = new ListNode ( - 1 , - 1 ) ; ListNode prev = find ( nodes [ i ] , key ) ; if ( prev . next == null ) prev . next = new ListNode ( key , value ) ; else prev . next . val = value ; } public int get ( int key ) { int i = idx ( key ) ; if ( nodes [ i ] == null ) return - 1 ; ListNode node = find ( nodes [ i ] , key ) ; return node . next == null ? - 1 : node . next . val ; } public void remove ( int key ) { int i = idx ( key ) ; if ( nodes [ i ] == null ) return ; ListNode prev = find ( nodes [ i ] , key ) ; if ( prev . next == null ) return ; prev . next = prev . next . next ; } int idx ( int key ) { return Integer . hashCode ( key ) % nodes . length ; } ListNode find ( ListNode bucket , int key ) { ListNode node = bucket , prev = null ; while ( node != null && node . key != key ) { prev = node ; node = node . next ; } return prev ; } class ListNode { int key , val ; ListNode next ; ListNode ( int key , int val ) { this . key = key ; this . val = val ; } } } +","class MyHashMap ( object ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . size = 10000 NEW_LINE self . nodes = [ None ] * self . size NEW_LINE DEDENT def put ( self , key , value ) : NEW_LINE INDENT index = hash ( key ) % self . size NEW_LINE if self . nodes [ index ] is None : NEW_LINE INDENT self . nodes [ index ] = ListNode ( - 1 , - 1 ) NEW_LINE DEDENT prev = find ( self . nodes [ index ] , key ) NEW_LINE if prev . next is None : NEW_LINE INDENT prev . next = ListNode ( key , value ) NEW_LINE DEDENT else : NEW_LINE INDENT prev . next . val = value NEW_LINE DEDENT DEDENT def get ( self , key ) : NEW_LINE INDENT index = hash ( key ) % self . size NEW_LINE if self . nodes [ index ] is None : NEW_LINE INDENT return - 1 NEW_LINE DEDENT prev = find ( self . nodes [ index ] , key ) NEW_LINE if prev . next is None : NEW_LINE INDENT return - 1 NEW_LINE DEDENT else : NEW_LINE INDENT return prev . next . val NEW_LINE DEDENT DEDENT def remove ( self , key ) : NEW_LINE INDENT index = hash ( key ) % self . size NEW_LINE if self . nodes [ index ] is None : NEW_LINE INDENT return NEW_LINE DEDENT prev = find ( self . nodes [ index ] , key ) NEW_LINE if prev . next is None : NEW_LINE INDENT return NEW_LINE DEDENT prev . next = prev . next . next NEW_LINE DEDENT DEDENT def find ( bucket , key ) : NEW_LINE INDENT node = bucket NEW_LINE prev = None NEW_LINE while node is not None and node . key != key : NEW_LINE INDENT prev = node NEW_LINE node = node . next NEW_LINE DEDENT return prev NEW_LINE DEDENT class ListNode ( ) : NEW_LINE INDENT def __init__ ( self , key , val ) : NEW_LINE INDENT self . key = key NEW_LINE self . val = val NEW_LINE self . next = None NEW_LINE NEW_LINE DEDENT DEDENT +" +E1683,"class MaxStack { TreeMap < Integer , List < Node > > map ; DoubleLinkedList dll ; public MaxStack ( ) { map = new TreeMap ( ) ; dll = new DoubleLinkedList ( ) ; } public void push ( int x ) { Node node = dll . add ( x ) ; if ( ! map . containsKey ( x ) ) map . put ( x , new ArrayList < Node > ( ) ) ; map . get ( x ) . add ( node ) ; } public int pop ( ) { int val = dll . pop ( ) ; List < Node > L = map . get ( val ) ; L . remove ( L . size ( ) - 1 ) ; if ( L . isEmpty ( ) ) map . remove ( val ) ; return val ; } public int top ( ) { return dll . peek ( ) ; } public int peekMax ( ) { return map . lastKey ( ) ; } public int popMax ( ) { int max = peekMax ( ) ; List < Node > L = map . get ( max ) ; Node node = L . remove ( L . size ( ) - 1 ) ; dll . unlink ( node ) ; if ( L . isEmpty ( ) ) map . remove ( max ) ; return max ; } } class DoubleLinkedList { Node head , tail ; public DoubleLinkedList ( ) { head = new Node ( 0 ) ; tail = new Node ( 0 ) ; head . next = tail ; tail . prev = head ; } public Node add ( int val ) { Node x = new Node ( val ) ; x . next = tail ; x . prev = tail . prev ; tail . prev = tail . prev . next = x ; return x ; } public int pop ( ) { return unlink ( tail . prev ) . val ; } public int peek ( ) { return tail . prev . val ; } public Node unlink ( Node node ) { node . prev . next = node . next ; node . next . prev = node . prev ; return node ; } } class Node { int val ; Node prev , next ; public Node ( int v ) { val = v ; } } +","class MaxStack ( object ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . stack = [ ] NEW_LINE self . max_stack = [ ] NEW_LINE DEDENT def push ( self , x ) : NEW_LINE INDENT self . stack . append ( x ) NEW_LINE if len ( self . max_stack ) == 0 : NEW_LINE INDENT self . max_stack . append ( x ) NEW_LINE return NEW_LINE DEDENT if self . max_stack [ - 1 ] > x : NEW_LINE INDENT self . max_stack . append ( self . max_stack [ - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT self . max_stack . append ( x ) NEW_LINE DEDENT DEDENT def pop ( self ) : NEW_LINE INDENT if len ( self . stack ) != 0 : NEW_LINE INDENT self . max_stack . pop ( - 1 ) NEW_LINE return self . stack . pop ( - 1 ) NEW_LINE DEDENT DEDENT def top ( self ) : NEW_LINE INDENT return self . stack [ - 1 ] NEW_LINE DEDENT def peekMax ( self ) : NEW_LINE INDENT if len ( self . max_stack ) != 0 : NEW_LINE INDENT return self . max_stack [ - 1 ] NEW_LINE DEDENT DEDENT def popMax ( self ) : NEW_LINE INDENT val = self . peekMax ( ) NEW_LINE buff = [ ] NEW_LINE while self . top ( ) != val : NEW_LINE INDENT buff . append ( self . pop ( ) ) NEW_LINE DEDENT self . pop ( ) NEW_LINE while len ( buff ) != 0 : NEW_LINE INDENT self . push ( buff . pop ( - 1 ) ) NEW_LINE DEDENT return val NEW_LINE DEDENT DEDENT +" +E1684,"class Solution { public boolean canReorderDoubled ( int [ ] A ) { HashMap < Integer , Integer > valueMap = new HashMap < > ( ) ; A = Arrays . stream ( A ) . boxed ( ) . sorted ( ( a , b ) -> Integer . compare ( Math . abs ( a ) , Math . abs ( b ) ) ) . mapToInt ( i -> i ) . toArray ( ) ; for ( int n : A ) valueMap . put ( n , valueMap . getOrDefault ( n , 0 ) + 1 ) ; for ( int n : A ) { if ( valueMap . get ( n ) <= 0 ) continue ; if ( valueMap . containsKey ( 2 * n ) && valueMap . get ( 2 * n ) > 0 ) { valueMap . put ( n , valueMap . get ( n ) - 1 ) ; valueMap . put ( 2 * n , valueMap . get ( 2 * n ) - 1 ) ; } else { return false ; } } return true ; } } +","class Solution ( object ) : NEW_LINE INDENT def canReorderDoubled ( self , A ) : NEW_LINE INDENT v_map = { } NEW_LINE A . sort ( key = lambda x : abs ( x ) ) NEW_LINE for n in A : NEW_LINE INDENT v_map [ n ] = v_map . get ( n , 0 ) + 1 NEW_LINE DEDENT for n in A : NEW_LINE INDENT if v_map [ n ] <= 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if 2 * n in v_map and v_map [ 2 * n ] > 0 : NEW_LINE INDENT v_map [ n ] -= 1 NEW_LINE v_map [ 2 * n ] -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = Solution ( ) NEW_LINE print s . canReorderDoubled ( [ 3 , 1 , 3 , 6 ] ) NEW_LINE print s . canReorderDoubled ( [ 2 , 1 , 2 , 6 ] ) NEW_LINE print s . canReorderDoubled ( [ 4 , - 2 , 2 , - 4 ] ) NEW_LINE print s . canReorderDoubled ( [ 1 , 2 , 4 , 16 , 8 , 4 ] ) NEW_LINE DEDENT +" +E1685,"class Solution { public int repeatedNTimes ( int [ ] A ) { HashMap < Integer , Integer > hash = new HashMap < > ( ) ; int ans = A [ 0 ] ; for ( int n : A ) { int count = hash . getOrDefault ( n , 0 ) + 1 ; hash . put ( n , count ) ; if ( count >= hash . get ( ans ) ) ans = n ; } return ans ; } } +","import collections NEW_LINE class Solution ( object ) : NEW_LINE INDENT def repeatedNTimes ( self , A ) : NEW_LINE INDENT counter = collections . Counter ( A ) NEW_LINE return counter . most_common ( 1 ) [ 0 ] [ 0 ] NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = Solution ( ) NEW_LINE print s . repeatedNTimes ( [ 1 , 2 , 3 , 3 ] ) NEW_LINE print s . repeatedNTimes ( [ 2 , 1 , 2 , 5 , 3 , 2 ] ) NEW_LINE print s . repeatedNTimes ( [ 5 , 1 , 5 , 2 , 5 , 3 , 5 , 4 ] ) NEW_LINE DEDENT +" +E1686,"import java . util . Map ; class Solution { public int [ ] smallerNumbersThanCurrent ( int [ ] nums ) { int [ ] countList = new int [ 101 ] ; int [ ] res = new int [ nums . length ] ; for ( int i = 0 ; i < nums . length ; i ++ ) countList [ nums [ i ] ] ++ ; for ( int i = 1 ; i < 101 ; i ++ ) countList [ i ] += countList [ i - 1 ] ; for ( int i = 0 ; i < nums . length ; i ++ ) { if ( nums [ i ] == 0 ) res [ i ] = 0 ; else res [ i ] = countList [ nums [ i ] - 1 ] ; } return res ; } } +","class Solution : NEW_LINE INDENT def smallerNumbersThanCurrent ( self , nums : List [ int ] ) -> List [ int ] : NEW_LINE INDENT count_list = [ 0 ] * 101 NEW_LINE for v in nums : NEW_LINE INDENT count_list [ v ] += 1 NEW_LINE DEDENT for i in range ( 1 , 101 ) : NEW_LINE INDENT count_list [ i ] += count_list [ i - 1 ] NEW_LINE DEDENT res = [ ] NEW_LINE for v in nums : NEW_LINE INDENT if v == 0 : NEW_LINE INDENT res . append ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( count_list [ v - 1 ] ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT DEDENT +" +E1687,"class Solution { HashMap < Character , Integer > orderMap = new HashMap < > ( ) ; public boolean isAlienSorted ( String [ ] words , String order ) { for ( int i = 0 ; i < order . length ( ) ; i ++ ) { orderMap . put ( order . charAt ( i ) , i ) ; } for ( int i = 0 ; i < words . length - 1 ; i ++ ) { if ( cmp_alien ( words [ i ] , words [ i + 1 ] ) > 0 ) return false ; } return true ; } private int cmp_alien ( String a , String b ) { int ls = a . length ( ) < b . length ( ) ? a . length ( ) : b . length ( ) ; int pos = 0 ; while ( pos < ls ) { if ( orderMap . get ( a . charAt ( pos ) ) != orderMap . get ( b . charAt ( pos ) ) ) return orderMap . get ( a . charAt ( pos ) ) - orderMap . get ( b . charAt ( pos ) ) ; pos += 1 ; } return a . length ( ) <= b . length ( ) ? - 1 : 1 ; } } +","class Solution ( object ) : NEW_LINE INDENT def isAlienSorted ( self , words , order ) : NEW_LINE INDENT order_map = { } NEW_LINE for i , v in enumerate ( order ) : NEW_LINE INDENT order_map [ v ] = i NEW_LINE DEDENT def cmp_alien ( x , y ) : NEW_LINE INDENT ls = min ( len ( x ) , len ( y ) ) NEW_LINE index = 0 NEW_LINE while index < ls : NEW_LINE INDENT if x [ index ] != y [ index ] : NEW_LINE INDENT return order_map [ x [ index ] ] - order_map [ y [ index ] ] NEW_LINE DEDENT index += 1 NEW_LINE DEDENT return len ( x ) - len ( y ) NEW_LINE DEDENT pos = 0 NEW_LINE while pos + 1 < len ( words ) : NEW_LINE INDENT if cmp_alien ( words [ pos ] , words [ pos + 1 ] ) > 0 : NEW_LINE INDENT return False NEW_LINE DEDENT pos += 1 NEW_LINE DEDENT return True NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = Solution ( ) NEW_LINE print s . isAlienSorted ( [ "" hello "" , "" leetcode "" ] , "" hlabcdefgijkmnopqrstuvwxyz "" ) NEW_LINE print s . isAlienSorted ( [ "" word "" , "" world "" , "" row "" ] , "" worldabcefghijkmnpqstuvxyz "" ) NEW_LINE print s . isAlienSorted ( [ "" apple "" , "" app "" ] , "" abcdefghijklmnopqrstuvwxyz "" ) NEW_LINE DEDENT +" +E1688,"class Solution { public List < Integer > findDisappearedNumbers ( int [ ] nums ) { List < Integer > ret = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < nums . length ; i ++ ) { int val = Math . abs ( nums [ i ] ) - 1 ; if ( nums [ val ] > 0 ) { nums [ val ] = - nums [ val ] ; } } for ( int i = 0 ; i < nums . length ; i ++ ) { if ( nums [ i ] > 0 ) { ret . add ( i + 1 ) ; } } return ret ; } } +","class Solution ( object ) : NEW_LINE INDENT def findDisappearedNumbers ( self , nums ) : NEW_LINE INDENT res = [ ] NEW_LINE if nums : NEW_LINE INDENT n = len ( nums ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT val = abs ( nums [ i ] ) - 1 NEW_LINE if nums [ val ] > 0 : NEW_LINE INDENT nums [ val ] = - nums [ val ] NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT if nums [ i ] > 0 : NEW_LINE INDENT res . append ( i + 1 ) NEW_LINE DEDENT DEDENT DEDENT return res NEW_LINE DEDENT DEDENT +" +E1689,"import com . sun . corba . se . spi . orbutil . fsm . Guard . Result ; class Solution { public String toHex ( int num ) { String hex_map = ""0123456789abcdef "" ; if ( num == 0 ) return ""0"" ; String res = "" "" ; while ( num != 0 && res . length ( ) < 8 ) { res = hex_map . charAt ( num & 15 ) + res ; num = num >> 4 ; } return res ; } } +","class Solution ( object ) : NEW_LINE INDENT def toHex ( self , num ) : NEW_LINE INDENT if num == 0 : NEW_LINE INDENT return '0' NEW_LINE DEDENT mp = '0123456789abcdef ' NEW_LINE ans = ' ' NEW_LINE for _ in range ( 8 ) : NEW_LINE INDENT n = num & 15 NEW_LINE c = mp [ n ] NEW_LINE ans = c + ans NEW_LINE num = num >> 4 NEW_LINE DEDENT return ans . lstrip ( '0' ) NEW_LINE DEDENT DEDENT +" +E1690,"class Solution { public int [ ] kWeakestRows ( int [ ] [ ] mat , int k ) { List < Integer > res = new ArrayList < > ( ) ; int col = 0 ; boolean flag = true ; while ( col < mat [ 0 ] . length && flag ) { for ( int i = 0 ; i < mat . length ; i ++ ) { if ( res . contains ( i ) ) continue ; if ( mat [ i ] [ col ] == 0 ) res . add ( i ) ; if ( res . size ( ) == k ) { flag = false ; break ; } } col += 1 ; } if ( flag ) { for ( int i = 0 ; i < mat . length ; i ++ ) { if ( res . contains ( i ) ) continue ; res . add ( i ) ; if ( res . size ( ) == k ) break ; } } int [ ] ret = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) ret [ i ] = res . get ( i ) ; return ret ; } } +","class Solution ( object ) : NEW_LINE INDENT def kWeakestRows ( self , mat , k ) : NEW_LINE INDENT res = [ ] NEW_LINE num_row = len ( mat ) NEW_LINE num_col = len ( mat [ 0 ] ) NEW_LINE col = 0 NEW_LINE flag = 1 NEW_LINE while col < num_col and flag : NEW_LINE INDENT for i in range ( num_row ) : NEW_LINE INDENT if i in res : NEW_LINE INDENT continue NEW_LINE DEDENT if mat [ i ] [ col ] == 0 : NEW_LINE INDENT res . append ( i ) NEW_LINE DEDENT if len ( res ) == k : NEW_LINE INDENT flag = 0 NEW_LINE break NEW_LINE DEDENT DEDENT col += 1 NEW_LINE DEDENT if len ( res ) == k : NEW_LINE INDENT return res NEW_LINE DEDENT for i in range ( num_row ) : NEW_LINE INDENT if i in res : NEW_LINE INDENT continue NEW_LINE DEDENT res . append ( i ) NEW_LINE if len ( res ) == k : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT DEDENT +" +E1691,"class Solution { public int [ ] [ ] flipAndInvertImage ( int [ ] [ ] A ) { int C = A [ 0 ] . length ; for ( int [ ] row : A ) for ( int i = 0 ; i < ( C + 1 ) / 2 ; ++ i ) { int tmp = row [ i ] ^ 1 ; row [ i ] = row [ C - 1 - i ] ^ 1 ; row [ C - 1 - i ] = tmp ; } return A ; } } +","class Solution ( object ) : NEW_LINE INDENT def flipAndInvertImage ( self , A ) : NEW_LINE INDENT for row in A : NEW_LINE INDENT for i in xrange ( ( len ( row ) + 1 ) / 2 ) : NEW_LINE INDENT row [ i ] , row [ ~ i ] = row [ ~ i ] ^ 1 , row [ i ] ^ 1 NEW_LINE DEDENT DEDENT return A NEW_LINE DEDENT DEDENT +" +E1692,"class Solution { public int [ ] sortedSquares ( int [ ] A ) { int pos = 0 ; int [ ] res = new int [ A . length ] ; int curr = 0 ; while ( pos < A . length && A [ pos ] < 0 ) pos ++ ; int npos = pos - 1 ; while ( pos < A . length && npos >= 0 ) { if ( A [ pos ] * A [ pos ] < A [ npos ] * A [ npos ] ) { res [ curr ++ ] = A [ pos ] * A [ pos ] ; pos ++ ; } else { res [ curr ++ ] = A [ npos ] * A [ npos ] ; npos -- ; } } while ( npos >= 0 ) { res [ curr ++ ] = A [ npos ] * A [ npos ] ; npos -- ; } while ( pos < A . length ) { res [ curr ++ ] = A [ pos ] * A [ pos ] ; pos ++ ; } return res ; } } +","class Solution ( object ) : NEW_LINE INDENT def sortedSquares ( self , A ) : NEW_LINE INDENT pos = 0 NEW_LINE while pos < len ( A ) and A [ pos ] < 0 : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT npos = pos - 1 NEW_LINE res = [ ] NEW_LINE while pos < len ( A ) and npos >= 0 : NEW_LINE INDENT if A [ npos ] ** 2 < A [ pos ] ** 2 : NEW_LINE INDENT res . append ( A [ npos ] ** 2 ) NEW_LINE npos -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT res . append ( A [ pos ] ** 2 ) NEW_LINE pos += 1 NEW_LINE DEDENT DEDENT while npos >= 0 : NEW_LINE INDENT res . append ( A [ npos ] ** 2 ) NEW_LINE npos -= 1 NEW_LINE DEDENT while pos < len ( A ) : NEW_LINE INDENT res . append ( A [ pos ] ** 2 ) NEW_LINE pos += 1 NEW_LINE DEDENT return res NEW_LINE DEDENT DEDENT +" +E1693,"class Solution { public String defangIPaddr ( String address ) { return address . replace ( "" . "" , "" [ . ] "" ) ; } } +","class Solution : NEW_LINE INDENT def defangIPaddr ( self , address : str ) -> str : NEW_LINE INDENT return address . replace ( ' . ' , ' [ . ] ' ) NEW_LINE DEDENT DEDENT +" +E1694,"class Solution { public TreeNode searchBST ( TreeNode root , int val ) { while ( root != null && root . val != val ) { root = val < root . val ? root . left : root . right ; } return root ; } } +","class Solution ( object ) : NEW_LINE INDENT def searchBST ( self , root , val ) : NEW_LINE INDENT while root : NEW_LINE INDENT if root . val == val : NEW_LINE INDENT return root NEW_LINE DEDENT elif root . val > val : NEW_LINE INDENT root = root . left NEW_LINE DEDENT else : NEW_LINE INDENT root = root . right NEW_LINE DEDENT DEDENT return root NEW_LINE DEDENT DEDENT +" +E1695,"class Solution { public List < String > ipToCIDR ( String ip , int n ) { long start = ipToLong ( ip ) ; List < String > ans = new ArrayList ( ) ; while ( n > 0 ) { int mask = Math . max ( 33 - bitLength ( Long . lowestOneBit ( start ) ) , 33 - bitLength ( n ) ) ; ans . add ( longToIP ( start ) + "" / "" + mask ) ; start += 1 << ( 32 - mask ) ; n -= 1 << ( 32 - mask ) ; } return ans ; } private long ipToLong ( String ip ) { long ans = 0 ; for ( String x : ip . split ( "" \\ . "" ) ) { ans = 256 * ans + Integer . valueOf ( x ) ; } return ans ; } private String longToIP ( long x ) { return String . format ( "" % s . % s . % s . % s "" , x >> 24 , ( x >> 16 ) % 256 , ( x >> 8 ) % 256 , x % 256 ) ; } private int bitLength ( long x ) { if ( x == 0 ) return 1 ; int ans = 0 ; while ( x > 0 ) { x >>= 1 ; ans ++ ; } return ans ; } } +","class Solution ( object ) : NEW_LINE INDENT def ipToInt ( self , ip ) : NEW_LINE INDENT ans = 0 NEW_LINE for x in ip . split ( ' . ' ) : NEW_LINE INDENT ans = 256 * ans + int ( x ) NEW_LINE DEDENT return ans NEW_LINE DEDENT def intToIP ( self , x ) : NEW_LINE INDENT return "" . "" . join ( str ( ( x >> i ) % 256 ) for i in ( 24 , 16 , 8 , 0 ) ) NEW_LINE DEDENT def ipToCIDR ( self , ip , n ) : NEW_LINE INDENT start = self . ipToInt ( ip ) NEW_LINE ans = [ ] NEW_LINE while n : NEW_LINE INDENT mask = max ( 33 - ( start & - start ) . bit_length ( ) , 33 - n . bit_length ( ) ) NEW_LINE ans . append ( self . intToIP ( start ) + ' / ' + str ( mask ) ) NEW_LINE start += 1 << ( 32 - mask ) NEW_LINE n -= 1 << ( 32 - mask ) NEW_LINE DEDENT return ans NEW_LINE DEDENT DEDENT +" +E1696,"class Solution { int ans ; public int diameterOfBinaryTree ( TreeNode root ) { ans = 1 ; depth ( root ) ; return ans - 1 ; } public int depth ( TreeNode node ) { if ( node == null ) return 0 ; int L = depth ( node . left ) ; int R = depth ( node . right ) ; ans = Math . max ( ans , L + R + 1 ) ; return Math . max ( L , R ) + 1 ; } } +","class Solution ( object ) : NEW_LINE INDENT def diameterOfBinaryTree ( self , root ) : NEW_LINE INDENT self . ans = 1 NEW_LINE def depth ( node ) : NEW_LINE INDENT if not node : return 0 NEW_LINE L = depth ( node . left ) NEW_LINE R = depth ( node . right ) NEW_LINE self . ans = max ( self . ans , L + R + 1 ) NEW_LINE return max ( L , R ) + 1 NEW_LINE DEDENT depth ( root ) NEW_LINE return self . ans - 1 NEW_LINE DEDENT DEDENT +" +E1697,"class Solution { public int findSecondMinimumValue ( TreeNode root ) { if ( root == null ) return - 1 ; Stack < TreeNode > stack = new Stack < TreeNode > ( ) ; int min_val = root . val ; int ans = Integer . MAX_VALUE ; stack . push ( root ) ; while ( ! stack . empty ( ) ) { TreeNode node = stack . pop ( ) ; if ( node == null ) continue ; if ( node . val < ans && node . val > min_val ) { ans = node . val ; } else if ( node . val == min_val ) { stack . push ( node . left ) ; stack . push ( node . right ) ; } } return ans < Integer . MAX_VALUE ? ans : - 1 ; } } +","class Solution ( object ) : NEW_LINE INDENT def findSecondMinimumValue ( self , root ) : NEW_LINE INDENT if not root : NEW_LINE INDENT return - 1 NEW_LINE DEDENT ans = float ( ' inf ' ) NEW_LINE min_val = root . val NEW_LINE stack = [ root ] NEW_LINE while stack : NEW_LINE INDENT curr = stack . pop ( ) NEW_LINE if not curr : NEW_LINE INDENT continue NEW_LINE DEDENT if min_val < curr . val < ans : NEW_LINE INDENT ans = curr . val NEW_LINE DEDENT elif curr . val == min_val : NEW_LINE INDENT stack . append ( curr . left ) NEW_LINE stack . append ( curr . right ) NEW_LINE DEDENT DEDENT return ans if ans < float ( ' inf ' ) else - 1 NEW_LINE DEDENT DEDENT +" +E1698,"class Solution { public ListNode removeNthFromEnd ( ListNode head , int n ) { ListNode slow , fast , curr ; slow = head ; fast = head ; for ( int i = 0 ; i < n ; i ++ ) fast = fast . next ; if ( fast == null ) { head = head . next ; return head ; } while ( fast . next != null ) { fast = fast . next ; slow = slow . next ; } curr = slow . next ; slow . next = curr . next ; return head ; } } +","class Solution ( object ) : NEW_LINE INDENT def removeNthFromEnd ( self , head , n ) : NEW_LINE INDENT if head is None : NEW_LINE INDENT return None NEW_LINE DEDENT slow = fast = head NEW_LINE for i in range ( n ) : NEW_LINE INDENT fast = fast . next NEW_LINE DEDENT if fast is None : NEW_LINE INDENT head = head . next NEW_LINE return head NEW_LINE DEDENT while fast . next is not None : NEW_LINE INDENT fast = fast . next NEW_LINE slow = slow . next NEW_LINE DEDENT curr = slow . next NEW_LINE slow . next = curr . next NEW_LINE return head NEW_LINE DEDENT DEDENT +"