dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static double averageSetBits ( int N , int K , int arr [ ] ) { double p = N ; double q = 0 ; for ( int i = 0 ; i < K ; i ++ ) { double _p = p , _q = q ; p = _p - _p * arr [ i ] / N + _q * arr [ i ] / N ; q = _q - _q * arr [ i ] / N + _p * arr [ i ] / N ; } return p ; } public static void main ( String [ ] args ) { int N = 5 ; int arr [ ] = { 1 , 2 , 3 } ; int K = arr . length ; System . out . println ( String . format ( " % .10f " , averageSetBits ( N , K , arr ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxSubseq ( int arr [ ] , int N , int K ) { int sum = 0 ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( K == 0 ) break ; if ( arr [ i ] < 0 ) { arr [ i ] = - arr [ i ] ; K -- ; } } for ( int i = 0 ; i < N ; i ++ ) if ( arr [ i ] > 0 ) sum += arr [ i ] ; return sum ; } public static void main ( String [ ] args ) { int [ ] arr = { 6 , - 10 , - 1 , 0 , - 4 , 2 } ; int K = 2 ; int N = arr . length ; System . out . println ( maxSubseq ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: K, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static long KthSolution ( long X , long K ) { long ans = 0 ; for ( int i = 0 ; i < 64 ; i ++ ) { if ( ( X & ( 1 << i ) ) == 0 ) { if ( ( K & 1 ) > 0 ) { ans |= ( 1 << i ) ; } K >>= 1 ; if ( K == 0 ) { break ; } } } return ans ; } public static void main ( String [ ] args ) { long X = 5 , K = 5 ; System . out . println ( KthSolution ( X , K ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printTheArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void rearrange ( int arr [ ] , int N ) { if ( ( N & 1 ) != 0 ) N -- ; int odd_idx = 1 , even_idx = 0 ; int i , max_elem = arr [ N - 1 ] + 1 ; for ( i = 0 ; i < N / 2 ; i ++ ) { arr [ i ] += ( arr [ odd_idx ] % max_elem ) * max_elem ; odd_idx += 2 ; } for ( ; i < N ; i ++ ) { arr [ i ] += ( arr [ even_idx ] % max_elem ) * max_elem ; even_idx += 2 ; } for ( i = 0 ; i < N ; i ++ ) { arr [ i ] = arr [ i ] / max_elem ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 16 , 18 , 19 } ; int N = arr . length ; rearrange ( arr , N ) ; printTheArray ( arr , N ) ; } }

Index/key variables: even_idx, i, odd_idx
Accumulator variables: N, even_idx, i, odd_idx
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class Codechef { static void findRange ( int arr [ ] , int N , int K ) { int L = Integer . MIN_VALUE ; int R = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { int l = ( int ) Math . ceil ( 1.0 * arr [ i ] * K / ( i + 1 ) ) ; int r = ( int ) Math . ceil ( ( 1.0 + arr [ i ] ) * K / ( i + 1 ) ) - 1 ; L = Math . max ( L , l ) ; R = Math . min ( R , r ) ; } System . out . println ( L + " ▁ " + R ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 6 , 9 , 11 } ; int K = 10 ; int N = arr . length ; findRange ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Codechef
Java program:
import java . io . * ; class GFG { static void findAnagram ( String s ) { String check = s ; int i = 0 , j = s . length ( ) - 1 ; while ( i < s . length ( ) && j >= 0 ) { if ( s . charAt ( i ) != s . charAt ( j ) && check . charAt ( i ) != s . charAt ( j ) && check . charAt ( j ) != s . charAt ( i ) ) { char temp = s . charAt ( i ) ; s = s . substring ( 0 , i ) + s . charAt ( j ) + s . substring ( i + 1 ) ; s = s . substring ( 0 , j ) + temp + s . substring ( j + 1 ) ; i ++ ; j = s . length ( ) - 1 ; } else { j -- ; } } if ( s . length ( ) % 2 != 0 ) { int mid = s . length ( ) / 2 ; if ( check . charAt ( mid ) == s . charAt ( mid ) ) { for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( check . charAt ( i ) != s . charAt ( mid ) && s . charAt ( i ) != s . charAt ( mid ) ) { char temp = s . charAt ( i ) ; s = s . substring ( 0 , i ) + s . charAt ( mid ) + s . substring ( i + 1 ) ; s = s . substring ( 0 , mid ) + temp + s . substring ( mid + 1 ) ; break ; } } } } boolean ok = true ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( check . charAt ( i ) == s . charAt ( i ) ) { ok = false ; break ; } } if ( ok ) System . out . println ( s ) ; else System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { String S = " geek " ; findAnagram ( S ) ; } }

Accumulator variables: i, j
Iterator variables: i
Boolean variables: ok
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void constructPermutation ( String S , int N ) { int [ ] ans = new int [ N ] ; ans [ 0 ] = 1 ; for ( int i = 1 ; i < N ; ++ i ) { if ( S . charAt ( i - 1 ) == '0' ) { ans [ i ] = i + 1 ; } else { ans [ i ] = ans [ i - 1 ] ; } for ( int j = 0 ; j < i ; ++ j ) { if ( ans [ j ] >= ans [ i ] ) { ans [ j ] ++ ; } } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( ans [ i ] ) ; if ( i != N - 1 ) { System . out . print ( " ▁ " ) ; } } } public static void main ( String [ ] args ) { String S = "100101" ; constructPermutation ( S , S . length ( ) + 1 ) ; } }

Index/key variables: N, i, j
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long KthSolution ( long X , long K ) { long ans = 0 ; for ( int i = 0 ; i < 64 ; i ++ ) { if ( ( X & ( 1 << i ) ) == 0 ) { if ( ( K & 1 ) > 0 ) { ans |= ( 1 << i ) ; } K >>= 1 ; if ( K == 0 ) { break ; } } } return ans ; } public static void main ( String [ ] args ) { long X = 10 ; long K = 5 ; System . out . println ( KthSolution ( X , K ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countArrays ( int n , int k ) { Vector < Integer > [ ] divisors = new Vector [ k + 1 ] ; for ( int i = 0 ; i < divisors . length ; i ++ ) divisors [ i ] = new Vector < Integer > ( ) ; for ( int i = 1 ; i <= k ; i ++ ) { for ( int j = 2 * i ; j <= k ; j += i ) { divisors [ j ] . add ( i ) ; } } int [ ] [ ] dp = new int [ n + 1 ] [ k + 1 ] ; for ( int j = 1 ; j <= k ; j ++ ) { dp [ 1 ] [ j ] = 1 ; } for ( int x = 2 ; x <= n ; x ++ ) { int sum = 0 ; for ( int j = 1 ; j <= k ; j ++ ) { sum += dp [ x - 1 ] [ j ] ; } for ( int y = 1 ; y <= k ; y ++ ) { dp [ x ] [ y ] = sum ; for ( int d : divisors [ y ] ) { dp [ x ] [ y ] = ( dp [ x ] [ y ] - dp [ x - 1 ] [ d ] ) ; } } } int sum = 0 ; for ( int j = 1 ; j <= k ; j ++ ) { sum += dp [ n ] [ j ] ; } return sum ; } public static void main ( String [ ] args ) { int N = 2 , K = 3 ; System . out . print ( countArrays ( N , K ) ) ; } }

Index/key variables: d, i, j, n, x, y
Accumulator variables: i, j, sum, x, y
Iterator variables: d, i, j, x, y
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minimumMoves ( int A [ ] , int B [ ] , int N ) { int ans = 0 ; int sum_A = 0 , sum_B = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum_A += A [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { sum_B += B [ i ] ; } if ( sum_A != sum_B ) { return - 1 ; } int i = 0 ; while ( i < N ) { if ( A [ i ] > B [ i ] ) { int temp = A [ i ] - B [ i ] ; int j = i - 1 ; while ( j >= 0 && temp > 0 ) { if ( B [ j ] > A [ j ] ) { int cnt = Math . min ( temp , ( B [ j ] - A [ j ] ) ) ; A [ j ] += cnt ; temp -= cnt ; ans += ( cnt * Math . abs ( j - i ) ) ; } j -- ; } if ( temp > 0 ) { j = i + 1 ; while ( j < N && temp > 0 ) { if ( B [ j ] > A [ j ] ) { int cnt = Math . min ( temp , ( B [ j ] - A [ j ] ) ) ; A [ j ] += cnt ; temp -= cnt ; ans += ( cnt * Math . abs ( j - i ) ) ; } j ++ ; } } } i ++ ; } return ans ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 5 , 7 } ; int B [ ] = { 13 , 0 , 0 } ; int N = A . length ; System . out . println ( minimumMoves ( A , B , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, sum_A, sum_B, temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int possibleReachingSequence ( int X , int D , int T ) { if ( X < T ) { System . out . println ( " NO " ) ; return 0 ; } if ( T * D < X ) { System . out . println ( " NO " ) ; return 0 ; } if ( ( X - T ) % ( D - 1 ) == 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } return 0 ; } public static void main ( String args [ ] ) { int X = 10 , D = 3 , T = 6 ; possibleReachingSequence ( X , D , T ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int arrayDivisionByTwo ( int arr [ ] , int n ) { int cnt = 0 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { cnt = 0 ; while ( arr [ i ] % 2 == 0 ) { arr [ i ] = arr [ i ] / 2 ; cnt ++ ; } ans = Math . min ( ans , cnt ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 12 , 40 } ; int n = arr . length ; System . out . print ( arrayDivisionByTwo ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printMinInteger ( int P , int Q , int N ) { if ( Q > P ) { int temp ; temp = P ; P = Q ; Q = temp ; } if ( Q == 0 && ( P == 0 N % P != 0 ) ) { System . out . println ( " Not ▁ Possible " ) ; return ; } int count_P = 0 , count_Q = 0 ; while ( N > 0 ) { if ( N % P == 0 ) { count_P += N / P ; N = 0 ; } else { N = N - Q ; count_Q ++ ; } } if ( N == 0 ) { for ( int i = 0 ; i < count_Q ; i ++ ) System . out . print ( Q ) ; for ( int i = 0 ; i < count_P ; i ++ ) System . out . print ( P ) ; } else { System . out . println ( " Not ▁ Possible " ) ; } } public static void main ( String [ ] args ) { int N = 32 ; int P = 7 ; int Q = 4 ; printMinInteger ( P , Q , N ) ; } }

Accumulator variables: count_P, count_Q, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minPushes ( int N , int K , int [ ] arr ) { int [ ] dp = new int [ 100000 ] ; for ( int i = 0 ; i < dp . length ; i ++ ) dp [ i ] = - 1 ; dp [ N ] = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { for ( int xx = 0 ; xx < 100000 ; xx ++ ) { int x = xx ; if ( dp [ x ] == - 1 ) continue ; int next = ( x + arr [ i ] ) % 100000 ; while ( dp [ next ] == - 1 dp [ next ] > dp [ x ] + 1 ) { dp [ next ] = dp [ x ] + 1 ; x = next ; next = ( next + arr [ i ] ) % 100000 ; } } } return dp [ K ] ; } public static void main ( String [ ] args ) { int N = 99880 , K = 89 ; int [ ] arr = { 100 , 3 } ; System . out . print ( minPushes ( N , K , arr ) ) ; } }

Index/key variables: K, N, i, next, x
Accumulator variables: i, xx
Iterator variables: i, xx
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minApples ( int M , int K , int N , int S , int W , int E ) { if ( M <= S * K ) return M ; else if ( M <= S * K + E + W ) return S * K + ( M - S * K ) * K ; else return - 1 ; } public static void main ( String [ ] args ) { int M = 10 ; int K = 15 ; int N = 0 ; int S = 1 ; int W = 0 ; int E = 0 ; int ans = minApples ( M , K , N , S , W , E ) ; System . out . println ( ans ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumOperations ( int A [ ] , int N ) { int cur_prefix_1 = 0 ; int parity = - 1 ; int minOperationsCase1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cur_prefix_1 += A [ i ] ; if ( cur_prefix_1 == 0 parity * cur_prefix_1 < 0 ) { minOperationsCase1 += Math . abs ( parity - cur_prefix_1 ) ; cur_prefix_1 = parity ; } parity *= - 1 ; } int cur_prefix_2 = 0 ; parity = 1 ; int minOperationsCase2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cur_prefix_2 += A [ i ] ; if ( cur_prefix_2 == 0 parity * cur_prefix_2 < 0 ) { minOperationsCase2 += Math . abs ( parity - cur_prefix_2 ) ; cur_prefix_2 = parity ; } parity *= - 1 ; } return Math . min ( minOperationsCase1 , minOperationsCase2 ) ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , - 3 , 1 , 0 } ; int N = A . length ; System . out . print ( minimumOperations ( A , N ) ) ; } }

Index/key variables: i
Accumulator variables: cur_prefix_1, cur_prefix_2, i, minOperationsCase1, minOperationsCase2, parity
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void maximumSumArray ( int arr [ ] , int N ) { int [ ] arrA = new int [ ( N ) ] ; int [ ] ans = new int [ ( N ) ] ; int maxSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) arrA [ i ] = arr [ i ] ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] arrB = new int [ ( N ) ] ; int maximum = arrA [ i ] ; arrB [ i ] = maximum ; for ( int j = i - 1 ; j >= 0 ; j -- ) { arrB [ j ] = Math . min ( maximum , arrA [ j ] ) ; maximum = arrB [ j ] ; } maximum = arrA [ i ] ; for ( int j = i + 1 ; j < N ; j ++ ) { arrB [ j ] = Math . min ( maximum , arrA [ j ] ) ; maximum = arrB [ j ] ; } int sum = 0 ; for ( int j = 0 ; j < N ; j ++ ) sum += arrB [ j ] ; if ( sum > maxSum ) { maxSum = sum ; ans = arrB ; } } for ( int val : ans ) { System . out . print ( val + " ▁ " ) ; } } public static void main ( String [ ] args ) { int A [ ] = { 10 , 6 , 8 } ; int N = A . length ; maximumSumArray ( A , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j, val
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minProductUtil ( int R1 , int B1 , int R2 , int B2 , int M ) { int x = Math . min ( R1 - B1 , M ) ; M -= x ; R1 -= x ; if ( M > 0 ) { int y = Math . min ( R2 - B2 , M ) ; M -= y ; R2 -= y ; } return R1 * R2 ; } static int minProduct ( int R1 , int B1 , int R2 , int B2 , int M ) { int res1 = minProductUtil ( R1 , B1 , R2 , B2 , M ) ; int res2 = minProductUtil ( R2 , B2 , R1 , B1 , M ) ; return Math . min ( res1 , res2 ) ; } public static void main ( String [ ] args ) { int R1 = 21 , B1 = 10 , R2 = 13 , B2 = 11 , M = 3 ; System . out . print ( ( minProduct ( R1 , B1 , R2 , B2 , M ) ) ) ; } }

Accumulator variables: M, R1, R2
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxAmount ( int n , int k , int arr [ ] ) { int A [ ] = new int [ 1000001 ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ arr [ i ] ] ++ ; } int j = 0 ; for ( int i = 0 ; i < 1000001 ; i ++ ) { while ( A [ i ] != 0 ) { arr [ j ++ ] = i ; A [ i ] -- ; } } int ans = 0 ; int mod = ( int ) ( 1e9 + 7 ) ; int i = n - 1 ; j = n - 2 ; while ( k > 0 && j >= 0 ) { if ( arr [ i ] > arr [ j ] ) { ans = ans + Math . min ( k , ( i - j ) ) * arr [ i ] ; k = k - ( i - j ) ; arr [ i ] -- ; } else { while ( j >= 0 && arr [ j ] == arr [ i ] ) j -- ; if ( j < 0 ) break ; ans = ans + Math . min ( k , ( i - j ) ) * arr [ i ] ; k = k - ( i - j ) ; arr [ i ] -- ; } } while ( k > 0 && arr [ i ] != 0 ) { ans = ans + Math . min ( n , k ) * arr [ i ] ; k -= n ; arr [ i ] -- ; } ans = ans % mod ; int x = ans ; return x ; } public static void main ( String [ ] args ) { int n = 5 ; int k = 3 ; int arr [ ] = { 4 , 3 , 6 , 2 , 4 } ; int ans = maxAmount ( n , k , arr ) ; System . out . print ( ans ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxAverage ( int A [ ] , int N , int X , int Y ) { Arrays . sort ( A ) ; int sum = 0 ; double res = 0 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; count ++ ; if ( count == X ) { if ( N - i - 1 < X ) { i ++ ; int cnt = 0 ; while ( i < N ) { cnt ++ ; sum += A [ i ] ; i ++ ; } X = X + cnt ; res += ( double ) sum / ( double ) ( X ) ; break ; } res += ( double ) sum / ( double ) ( X ) ; sum = 0 ; count = 0 ; } } System . out . println ( res ) ; } public static void main ( String [ ] args ) { int A [ ] = { 4 , 10 , 6 , 5 } ; int N = A . length ; int X = 2 , Y = 3 ; maxAverage ( A , N , X , Y ) ; } }

Index/key variables: i
Accumulator variables: cnt, count, i, res, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static char [ ] S = " aaabc " . toCharArray ( ) ; static boolean isAdjChar ( ) { for ( int i = 0 ; i < S . length - 1 ; i ++ ) { if ( S [ i ] == S [ i + 1 ] ) return true ; } return false ; } static void rearrangeStringUtil ( int N ) { int i = 0 , j = 1 , k = 2 ; while ( k < N ) { if ( S [ i ] != S [ j ] ) { i ++ ; j ++ ; if ( j == k ) { k ++ ; } } else { if ( S [ j ] == S [ k ] ) { k ++ ; } else { swap ( k , j ) ; i ++ ; j ++ ; if ( j == k ) { k ++ ; } } } } } static void swap ( int i , int j ) { char temp = S [ i ] ; S [ i ] = S [ j ] ; S [ j ] = temp ; } static String rearrangeString ( int N ) { if ( isAdjChar ( ) == false ) { return String . valueOf ( S ) ; } if ( S . length == 2 ) return " - 1" ; rearrangeStringUtil ( N ) ; reverse ( ) ; rearrangeStringUtil ( N ) ; if ( isAdjChar ( ) == false ) { return String . valueOf ( S ) ; } return " - 1" ; } static void reverse ( ) { int l , r = S . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = S [ l ] ; S [ l ] = S [ r ] ; S [ r ] = temp ; } } public static void main ( String [ ] args ) { int N = S . length ; System . out . print ( rearrangeString ( N ) ) ; } }

Index/key variables: i, j, k, l, r
Accumulator variables: i, j, k, l, r
Iterator variables: i, l
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String largestMerge ( String word1 , String word2 ) { String merge = " " ; while ( word1 . length ( ) != 0 || word2 . length ( ) != 0 ) { if ( word1 . compareTo ( word2 ) == 0 || ( word1 . compareTo ( word2 ) > 0 ) ) { merge = merge + word1 . charAt ( 0 ) ; word1 = word1 . substring ( 1 ) ; } else { merge = merge + word2 . charAt ( 0 ) ; word2 = word2 . substring ( 1 ) ; } } return merge ; } public static void main ( String [ ] args ) { String S1 = " xyzxyz " ; String S2 = " xywzxyx " ; System . out . println ( largestMerge ( S1 , S2 ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int findMaximumPoints ( int N , int X [ ] , int H [ ] ) { int ans = 0 ; int prev = Integer . MIN_VALUE ; for ( int i = 0 ; i < N ; ++ i ) { if ( prev < ( X [ i ] - H [ i ] ) ) { ++ ans ; prev = X [ i ] ; } else if ( i == N - 1 || ( X [ i ] + H [ i ] ) < X [ i + 1 ] ) { ++ ans ; prev = X [ i ] + H [ i ] ; } else { prev = X [ i ] ; } } return ans ; } public static void main ( String args [ ] ) { int X [ ] = { 1 , 2 , 3 } ; int H [ ] = { 2 , 5 , 5 } ; int N = X . length ; System . out . println ( findMaximumPoints ( N , X , H ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class Main { public static void maxTime ( String S ) { char [ ] s = S . toCharArray ( ) ; if ( s [ 0 ] == ' ? ' ) { if ( s [ 1 ] <= '3' s [ 1 ] == ' ? ' ) s [ 0 ] = '2' ; else s [ 0 ] = '1' ; } if ( s [ 1 ] == ' ? ' ) { if ( s [ 0 ] != '2' ) { s [ 1 ] = 9 ; } else s [ 1 ] = 3 ; } if ( s [ 3 ] == ' ? ' ) s [ 3 ] = '5' ; if ( s [ 4 ] == ' ? ' ) s [ 4 ] = '9' ; System . out . println ( new String ( s ) ) ; } public static void main ( String [ ] args ) { String S = " ? 4:5 ? " ; maxTime ( S ) ; } }

Class/struct names: Main
Java program:
import java . io . * ; class GFG { static void maxGcd ( int a , int b ) { System . out . println ( Math . abs ( a - b ) ) ; } public static void main ( String [ ] args ) { int a = 2231 ; int b = 343 ; maxGcd ( a , b ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static void sumOfCombinationOf4OR5 ( int [ ] arr , int N ) { int [ ] ans = new int [ N ] ; Arrays . fill ( ans , - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < 4 ) { continue ; } int sum = Integer . MAX_VALUE ; int cnt = 0 ; for ( int j = 0 ; j <= arr [ i ] ; j += 4 ) { if ( ( arr [ i ] - j ) % 5 == 0 ) { sum = Math . min ( sum , cnt + ( arr [ i ] - j ) / 5 ) ; } cnt ++ ; } if ( sum != Integer . MAX_VALUE ) ans [ i ] = sum ; } for ( int num : ans ) System . out . printf ( num + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 7 , 15 , 17 , 22 } ; int N = arr . length ; sumOfCombinationOf4OR5 ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: cnt, i, j
Iterator variables: i, j, num
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printBinaryString ( int arr [ ] [ ] , int N ) { for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) { System . out . print ( 0 ) ; } else { System . out . print ( 1 ) ; } } } public static void main ( String [ ] args ) { int N = 5 , M = 3 ; int arr [ ] [ ] = { { 1 , 3 } , { 2 , 4 } , { 2 , 5 } } ; printBinaryString ( arr , N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static int MinCost ( int days [ ] , int cost [ ] , int N ) { int size = days [ N - 1 ] + 1 ; int [ ] dp = new int [ size ] ; dp [ size - 1 ] = Math . min ( cost [ 0 ] , Math . min ( cost [ 1 ] , cost [ 2 ] ) ) ; int ptr = N - 2 ; for ( int i = size - 2 ; i > 0 ; i -- ) { if ( ptr >= 0 && days [ ptr ] == i ) { int val1 = dp [ i + 1 ] + cost [ 0 ] ; int val2 = cost [ 1 ] + ( ( i + 7 >= size ) ? 0 : dp [ i + 7 ] ) ; int val3 = cost [ 2 ] + ( ( i + 30 >= size ) ? 0 : dp [ i + 30 ] ) ; dp [ i ] = Math . min ( val1 , Math . min ( val2 , val3 ) ) ; ptr -- ; } else { dp [ i ] = dp [ i + 1 ] ; } } return dp [ 1 ] ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 4 , 6 , 7 , 8 , 10 , 17 } ; int cost [ ] = { 3 , 8 , 20 } ; int N = arr . length ; System . out . println ( MinCost ( arr , cost , N ) ) ; } }

Index/key variables: i, ptr, size
Accumulator variables: i, ptr
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void countPairs ( int N , ArrayList < String > arr ) { int open [ ] = new int [ 100 ] ; int close [ ] = new int [ 100 ] ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { char c [ ] = arr . get ( i ) . toCharArray ( ) ; int d = 0 ; int min = 0 ; for ( int j = 0 ; j < c . length ; j ++ ) { if ( c [ j ] == ' ( ' ) { d ++ ; } else { d -- ; if ( d < min ) min = d ; } } if ( d >= 0 ) { if ( min == 0 ) close [ d ] ++ ; } else if ( d < 0 ) { if ( min == d ) open [ - d ] ++ ; } } ans += close [ 0 ] / 2 ; for ( int i = 1 ; i < 100 ; i ++ ) { ans += Math . min ( open [ i ] , close [ i ] ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int N = 7 ; ArrayList < String > list = new ArrayList < String > ( ) ; list . add ( " ) ( ) ) " ) ; list . add ( " ) " ) ; list . add ( " ( ( " ) ; list . add ( " ( ( " ) ; list . add ( " ( " ) ; list . add ( " ) " ) ; list . add ( " ) " ) ; countPairs ( N , list ) ; } }

Index/key variables: d, i, j
Accumulator variables: ans, d, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int minElements ( int arr [ ] , int N , int K ) { int count = 0 ; long requiredNum = 1 ; int i = 0 ; while ( requiredNum <= K ) { if ( i < N && requiredNum >= arr [ i ] ) { requiredNum += arr [ i ] ; i ++ ; } else { count ++ ; requiredNum += requiredNum ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 } ; int K = 6 ; int N = arr . length ; System . out . println ( minElements ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, requiredNum
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int maximumCount ( int arr [ ] , int N ) { int odd = 0 ; int even = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 1 ) odd ++ ; else even ++ ; } if ( odd > 0 && even > 0 ) return N - 2 ; else return N - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 13 , 15 , 3 , 16 , 9 , 13 , 18 } ; int N = arr . length ; System . out . println ( maximumCount ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG