dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static int Kadane ( int arr [ ] , int n ) { int largestSum = 0 , currMax = 0 ; int currSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { currSum += arr [ i ] ; currMax = Math . max ( currMax , arr [ i ] ) ; largestSum = Math . max ( largestSum , currMax * currSum ) ; if ( currSum < 0 ) { currMax = 0 ; currSum = 0 ; } } return largestSum ; } static int maximumWeight ( int arr [ ] , int n ) { int largestSum = Kadane ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = - arr [ i ] ; } largestSum = Math . max ( largestSum , Kadane ( arr , n ) ) ; return largestSum ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , - 3 , 8 , - 2 , 5 } ; int N = arr . length ; System . out . println ( maximumWeight ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: currSum, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; class GFG { public static void arrayPartition ( int a [ ] , int n ) { int [ ] ans = new int [ n ] ; int cnt = 0 ; int ind = 0 , flag = 0 ; 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 ( int i = 0 ; i < n ; i ++ ) { if ( mp . get ( a [ i ] ) == 1 ) cnt ++ ; if ( mp . get ( a [ i ] ) > 2 && flag == 0 ) { flag = 1 ; ind = i ; } } int p = ( cnt + 1 ) / 2 ; int ans1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans [ i ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . get ( a [ i ] ) == 1 && ans1 < p ) { ans [ i ] = 1 ; ans1 ++ ; } else if ( mp . get ( a [ i ] ) == 1 ) { ans [ i ] = 2 ; } } if ( cnt % 2 == 1 && flag == 0 ) { System . out . println ( - 1 + "NEW_LINE"); return ; } if ( cnt % 2 == 0 ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( ans [ i ] + " ▁ " ) ; } } else { for ( int i = 0 ; i < n ; i ++ ) { if ( ind == i ) System . out . print ( 2 + " ▁ " ) ; else System . out . print ( ans [ i ] + " ▁ " ) ; } } } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 1 , 2 , 3 , 4 , 4 } ; int N = arr . length ; arrayPartition ( arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: ans1, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void evenOdd ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int even_digits = 0 ; int odd_digits = 0 ; int temp = arr [ i ] ; while ( temp > 0 ) { if ( ( temp % 10 ) % 2 != 0 ) odd_digits ++ ; else even_digits ++ ; temp /= 10 ; } if ( even_digits > odd_digits ) { int res = 0 ; while ( arr [ i ] > 0 ) { res += arr [ i ] % 10 ; arr [ i ] /= 10 ; } System . out . print ( res + " ▁ " ) ; } else if ( odd_digits > even_digits ) { int res = 1 ; while ( arr [ i ] > 0 ) { res *= arr [ i ] % 10 ; arr [ i ] /= 10 ; } System . out . print ( res + " ▁ " ) ; } else System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 113 , 141 , 214 , 3186 } ; int N = arr . length ; evenOdd ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: even_digits, i, odd_digits, res, temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . util . HashMap ; class GFG { static void primeFactorization ( int N ) { int [ ] sieve = new int [ N / 2 + 1 ] ; for ( int i = 0 ; i <= N / 2 ; i ++ ) { sieve [ i ] = 0 ; } for ( int i = 2 ; i <= N / 2 ; i ++ ) { if ( sieve [ i ] == 0 ) { for ( int j = i * i ; j <= N / 2 ; j += i ) { sieve [ j ] = 1 ; } } } ArrayList < Integer > prime = new ArrayList < Integer > ( ) ; for ( int i = 3 ; i <= N / 2 ; i ++ ) if ( sieve [ i ] == 0 ) prime . add ( i ) ; int x = prime . size ( ) ; System . out . println ( "2 - > " + x ) ; for ( int i : prime ) System . out . println ( i + " - > 1" ) ; } public static void main ( String args [ ] ) { int N = 18 ; primeFactorization ( N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; class GFG { public static int sumOfFirstM ( int A [ ] , int N , int M ) { int sum = 0 ; for ( int i = 0 ; i < M ; i ++ ) { sum = sum + A [ i % N ] ; } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 } ; int M = 5 ; int N = arr . length ; System . out . println ( sumOfFirstM ( arr , N , M ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void canReach0toM ( int [ ] [ ] a , int n , int m ) { int [ ] rightMost = new int [ m + 1 ] ; int [ ] dp = new int [ m + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { rightMost [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { int a1 = a [ i ] [ 0 ] ; int b1 = a [ i ] [ 1 ] ; rightMost [ a1 ] = Math . max ( rightMost [ a1 ] , b1 ) ; } for ( int i = m ; i >= 0 ; i -- ) { dp [ i ] = i ; for ( int j = Math . min ( m , rightMost [ i ] ) ; j > i ; j -- ) { dp [ i ] = Math . max ( dp [ i ] , dp [ j ] ) ; } } if ( dp [ 0 ] >= m ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] arr = { { 0 , 2 } , { 2 , 2 } , { 2 , 5 } , { 4 , 5 } } ; int M = 5 ; int N = arr . length ; canReach0toM ( arr , N , M ) ; } }

Index/key variables: a1, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void countPairs ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int count = 0 ; for ( int x = 1 ; x <= arr [ i ] ; x ++ ) { for ( int y = x ; y <= arr [ i ] ; y ++ ) { if ( gcd ( x , y ) > 1 ) count ++ ; } } System . out . print ( count + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 10 , 20 } ; int N = 3 ; countPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i, x, y
Iterator variables: i, x, y
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 1005 ; static void preCalculate ( int [ ] phi , int [ ] ans ) { phi [ 0 ] = 0 ; phi [ 1 ] = 1 ; for ( int i = 2 ; i <= MAX ; i ++ ) phi [ i ] = i ; for ( int i = 2 ; i <= MAX ; i ++ ) { if ( phi [ i ] == i ) { for ( int j = i ; j <= MAX ; j += i ) phi [ j ] -= ( phi [ j ] / i ) ; } } for ( int i = 1 ; i <= MAX ; i ++ ) ans [ i ] = ans [ i - 1 ] + ( i - phi [ i ] ) ; } static void countPairs ( int [ ] arr , int N ) { int [ ] phi = new int [ 100000 ] ; Arrays . fill ( phi , 0 ) ; int [ ] ans = new int [ 100000 ] ; Arrays . fill ( ans , 0 ) ; preCalculate ( phi , ans ) ; for ( int i = 0 ; i < N ; ++ i ) { System . out . print ( ans [ arr [ i ] ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 10 , 20 } ; int N = 3 ; countPairs ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static int maximumTurns ( int arr [ ] , int N ) { int Count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { while ( arr [ i ] % 2 == 0 ) { Count ++ ; arr [ i ] = arr [ i ] / 2 ; } } return Count ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 2 , 4 } ; int M = 3 , K = 2 ; int N = arr . length ; System . out . println ( maximumTurns ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: Count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void isPossible ( int W , int B , int D ) { if ( W > B ) { int temp = W ; W = B ; B = temp ; } if ( B > W * ( D + 1 ) ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } public static void main ( String [ ] args ) { int W = 2 ; int B = 5 ; int D = 2 ; isPossible ( W , B , D ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int GCD ( int a , int b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } public static int maxGCDInRange ( int L , int R ) { int ans = 1 ; for ( int Z = R ; Z >= 1 ; Z -- ) { if ( ( R / Z ) - ( L - 1 ) / Z > 1 ) { ans = Z ; break ; } } return ans ; } public static void main ( String [ ] args ) { int L = 102 ; int R = 139 ; System . out . println ( maxGCDInRange ( L , R ) ) ; }

Accumulator variables: Z
Iterator variables: Z
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int noOfWays ( int N , int K ) { String S = String . valueOf ( N ) ; int ans = 1 ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { int count = 1 ; while ( i < S . length ( ) && ( int ) S . charAt ( i ) - 48 + ( int ) S . charAt ( i - 1 ) - 48 == K ) { count ++ ; i ++ ; } if ( count % 2 == 1 ) ans *= ( count + 1 ) / 2 ; } return ans ; } public static void main ( String [ ] args ) { int N = 1454781 ; int K = 9 ; System . out . print ( noOfWays ( N , K ) ) ; } }

Accumulator variables: ans, count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countSetBits ( int n ) { int count = 0 ; while ( n != 0 ) { n = n & ( n - 1 ) ; count ++ ; } return count ; } static int minOperations ( int A , int B ) { int cnt1 = 0 , cnt2 = 0 ; cnt1 += countSetBits ( A ) ; cnt2 += countSetBits ( B ) ; if ( ( cnt1 + cnt2 ) % 2 != 0 ) return - 1 ; int oneZero = 0 , zeroOne = 0 ; int ans = 0 ; for ( int i = 0 ; i < Math . max ( cnt1 , cnt2 ) ; i ++ ) { int bitpos = 1 << i ; if ( ( ( bitpos & A ) == 0 ) && ( ( bitpos & B ) != 0 ) ) zeroOne ++ ; if ( ( ( bitpos & A ) != 0 ) && ( ( bitpos & B ) == 0 ) ) oneZero ++ ; } ans = ( zeroOne / 2 ) + ( oneZero / 2 ) ; if ( zeroOne % 2 != 0 ) ans += 2 ; return ans ; } public static void main ( String args [ ] ) { int A = 27 , B = 5 ; System . out . println ( minOperations ( A , B ) ) ; } }

Accumulator variables: ans, cnt1, cnt2, count, i, oneZero, zeroOne
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { public static Integer maximumSum ( int [ ] A , int N , int K ) { int curr_sum = 0 ; int max_sum = Integer . MIN_VALUE ; for ( int i = 0 ; i < N - K + 1 ; i ++ ) { int [ ] dupl_arr = Arrays . copyOfRange ( A , i , i + K ) ; Arrays . sort ( dupl_arr ) ; Boolean flag = true ; for ( int j = 1 ; j < K ; j ++ ) { if ( dupl_arr [ j ] - dupl_arr [ j - 1 ] != 1 ) { flag = false ; break ; } } if ( flag ) { int temp = 0 ; curr_sum = 0 ; for ( int x = 0 ; x < dupl_arr . length ; x ++ ) { curr_sum += dupl_arr [ x ] ; } max_sum = Math . max ( max_sum , curr_sum ) ; curr_sum = 0 ; } } return max_sum ; } public static void main ( String args [ ] ) { int [ ] arr = { 10 , 12 , 9 , 8 , 10 , 15 , 1 , 3 , 2 } ; int K = 3 ; int N = arr . length ; System . out . println ( maximumSum ( arr , N , K ) ) ; } }

Index/key variables: j, x
Accumulator variables: curr_sum, i, j, x
Iterator variables: i, j, x
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . ArrayList ; class GFG { static int MAX = 10000 ; static ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; public static void sieveSundaram ( ) { ArrayList < Boolean > marked = new ArrayList < Boolean > ( MAX / 2 + 100 ) ; for ( int i = 0 ; i < MAX / 2 + 100 ; i ++ ) { marked . add ( false ) ; } 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 . set ( j , true ) ; primes . add ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked . get ( i ) == false ) primes . add ( 2 * i + 1 ) ; } public static Boolean isSmith ( int n ) { int original_no = n ; int pDigitSum = 0 ; for ( int i = 0 ; primes . get ( i ) <= n / 2 ; i ++ ) { while ( n % primes . get ( i ) == 0 ) { int p = primes . get ( i ) ; n = n / p ; while ( p > 0 ) { pDigitSum += ( p % 10 ) ; p = p / 10 ; } } } if ( n != 1 && n != original_no ) { while ( n > 0 ) { pDigitSum = pDigitSum + n % 10 ; n = n / 10 ; } } int sumDigits = 0 ; while ( original_no > 0 ) { sumDigits = sumDigits + original_no % 10 ; original_no = original_no / 10 ; } return ( pDigitSum == sumDigits ) ; } public static Boolean isSmithBrotherPair ( int X , int Y ) { return isSmith ( X ) && isSmith ( Y ) && Math . abs ( X - Y ) == 1 ; } public static Integer countSmithBrotherPairs ( int A [ ] , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = i + 1 ; j < N ; j ++ ) { if ( isSmithBrotherPair ( A [ i ] , A [ j ] ) ) count ++ ; } return count ; } public static void main ( String args [ ] ) { sieveSundaram ( ) ; int A [ ] = { 728 , 729 , 28 , 2964 , 2965 } ; int N = A . length ; System . out . println ( countSmithBrotherPairs ( A , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, pDigitSum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 10000 ; static ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; static void sieveSundaram ( ) { ArrayList < Boolean > marked = new ArrayList < Boolean > ( MAX / 2 + 100 ) ; for ( int i = 0 ; i < MAX / 2 + 100 ; i ++ ) { marked . add ( false ) ; } 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 . set ( j , true ) ; primes . add ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked . get ( i ) == false ) primes . add ( 2 * i + 1 ) ; } static Boolean isSmith ( int n ) { int original_no = n ; int pDigitSum = 0 ; for ( int i = 0 ; primes . get ( i ) <= n / 2 ; i ++ ) { while ( n % primes . get ( i ) == 0 ) { int p = primes . get ( i ) ; n = n / p ; while ( p > 0 ) { pDigitSum += ( p % 10 ) ; p = p / 10 ; } } } if ( n != 1 && n != original_no ) { while ( n > 0 ) { pDigitSum = pDigitSum + n % 10 ; n = n / 10 ; } } int sumDigits = 0 ; while ( original_no > 0 ) { sumDigits = sumDigits + original_no % 10 ; original_no = original_no / 10 ; } return ( pDigitSum == sumDigits ) ; } static Boolean isSmithBrotherPair ( int X , int Y ) { return isSmith ( X ) && isSmith ( Y ) ; } static Integer countSmithBrotherPairs ( int A [ ] , int N ) { int count = 0 ; Arrays . sort ( A ) ; for ( int i = 0 ; i < N - 2 ; i ++ ) if ( isSmithBrotherPair ( A [ i ] , A [ i + 1 ] ) ) count ++ ; return count ; } public static void main ( String [ ] args ) { sieveSundaram ( ) ; int A [ ] = { 728 , 729 , 28 , 2964 , 2965 } ; int N = A . length ; System . out . print ( countSmithBrotherPairs ( A , N ) ) ; } }

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

Index/key variables: i, j
Accumulator variables: count, i, j, totalSum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static void printUnitaryDivisors ( int n ) { for ( int i = 1 ; i <= ( int ) Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i && gcd ( i , n / i ) == 1 ) { System . out . print ( i + " ▁ " ) ; } else { if ( gcd ( i , n / i ) == 1 ) { System . out . print ( i + " ▁ " + n / i + " ▁ " ) ; } } } } } public static void main ( String [ ] args ) { int N = 12 ; printUnitaryDivisors ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } static int largestK ( int A [ ] , int N ) { int l = 0 , r = N - 1 , flag = 0 ; while ( l < r ) { if ( A [ l ] != A [ r ] ) { flag = 1 ; break ; } l ++ ; r -- ; } if ( flag == 0 ) return - 1 ; int K = Math . abs ( A [ 0 ] - A [ N - 1 ] ) ; for ( int i = 1 ; i < N / 2 ; i ++ ) K = gcd ( K , Math . abs ( A [ i ] - A [ N - i - 1 ] ) ) ; return K ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 , 2 , 1 } ; int N = A . length ; System . out . println ( largestK ( A , N ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static boolean PermuteAndFind ( int [ ] power , int idx , int SumSoFar , int target ) { if ( idx == power . length ) { if ( SumSoFar == target ) return true ; return false ; } boolean select = PermuteAndFind ( power , idx + 1 , SumSoFar , target ) ; boolean notselect = PermuteAndFind ( power , idx + 1 , SumSoFar + power [ idx ] , target ) ; return ( select notselect ) ; } public static void DistinctPowersOf3 ( int N ) { int [ ] power = new int [ 16 ] ; power [ 0 ] = 1 ; for ( int i = 1 ; i < 16 ; i ++ ) power [ i ] = 3 * power [ i - 1 ] ; boolean found = PermuteAndFind ( power , 0 , 0 , N ) ; if ( found == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String args [ ] ) { int N = 91 ; DistinctPowersOf3 ( N ) ; } }

Index/key variables: i, idx
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void DistinctPowersOf3 ( int N ) { while ( N > 0 ) { if ( N % 3 == 2 ) { System . out . println ( " No " ) ; return ; } N /= 3 ; } System . out . println ( " Yes " ) ; } public static void main ( String args [ ] ) { int N = 91 ; DistinctPowersOf3 ( N ) ; } }

Accumulator variables: N
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int gcd ( int A , int B ) { if ( B == 0 ) return A ; else return gcd ( B , A % B ) ; } static int getDistinctValues ( int A , int B , int C ) { int g = gcd ( A , B ) ; int num_values = C / g ; return num_values ; } public static void main ( String [ ] args ) { int A = 2 ; int B = 3 ; int C = 10 ; System . out . println ( getDistinctValues ( A , B , C ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int [ ] game_with_number ( int arr [ ] , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { arr [ i ] = arr [ i ] ^ arr [ i + 1 ] ; } return arr ; } static void print ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 11 , 1 , 2 , 3 } ; int n = arr . length ; int [ ] new_arr = game_with_number ( arr , n ) ; print ( new_arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int currSubArrayScore ( int [ ] a , int [ ] b , int l , int r ) { int straightScore = 0 ; int reverseScore = 0 ; for ( int i = l ; i <= r ; i ++ ) { straightScore += a [ i ] * b [ i ] ; reverseScore += a [ r - ( i - l ) ] * b [ i ] ; } return Math . max ( straightScore , reverseScore ) ; } static void maxScoreSubArray ( int [ ] a , int [ ] b , int n ) { int res = 0 , start = 0 , end = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { int currScore = currSubArrayScore ( a , b , i , j ) ; if ( currScore > res ) { res = currScore ; start = i ; end = j ; } } } System . out . print ( res ) ; } public static void main ( String [ ] args ) { int A [ ] = { 13 , 4 , 5 } ; int B [ ] = { 10 , 22 , 2 } ; int N = A . length ; maxScoreSubArray ( A , B , N ) ; } }

Index/key variables: i
Accumulator variables: i, j, reverseScore, straightScore
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void maxScoreSubArray ( int [ ] a , int [ ] b , int n ) { int res = 0 ; for ( int mid = 0 ; mid < n ; mid ++ ) { int straightScore = a [ mid ] * b [ mid ] , reverseScore = a [ mid ] * a [ mid ] ; int prev = mid - 1 , next = mid + 1 ; res = Math . max ( res , Math . max ( straightScore , reverseScore ) ) ; while ( prev >= 0 && next < n ) { straightScore += ( a [ prev ] * b [ prev ] + a [ next ] * b [ next ] ) ; reverseScore += ( a [ prev ] * b [ next ] + a [ next ] * b [ prev ] ) ; res = Math . max ( res , Math . max ( straightScore , reverseScore ) ) ; prev -- ; next ++ ; } straightScore = 0 ; reverseScore = 0 ; prev = mid - 1 ; next = mid ; while ( prev >= 0 && next < n ) { straightScore += ( a [ prev ] * b [ prev ] + a [ next ] * b [ next ] ) ; reverseScore += ( a [ prev ] * b [ next ] + a [ next ] * b [ prev ] ) ; res = Math . max ( res , Math . max ( straightScore , reverseScore ) ) ; prev -- ; next ++ ; } } System . out . println ( res ) ; } public static void main ( String [ ] args ) { int A [ ] = { 13 , 4 , 5 } ; int B [ ] = { 10 , 22 , 2 } ; int N = A . length ; maxScoreSubArray ( A , B , N ) ; } }

Index/key variables: mid, next, prev
Accumulator variables: mid, next, prev, reverseScore, straightScore
Iterator variables: mid
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumSizeSubarray ( int arr [ ] , int N ) { int i = 0 , j = N - 1 ; while ( i < N && arr [ i ] == 0 ) { i ++ ; } if ( i == N ) return 1 ; while ( j >= 0 && arr [ j ] == 0 ) { j -- ; } return ( j - i + 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 2 , 0 , 0 , 12 , 0 , 0 , 0 } ; int N = arr . length ; System . out . print ( minimumSizeSubarray ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void countXorPartition ( int N ) { double a = Math . pow ( 2 , ( int ) ( N - Math . log ( N + 1 ) / Math . log ( 2 ) ) ) ; System . out . print ( a ) ; } public static void main ( String [ ] args ) { int N = 5 ; countXorPartition ( N ) ; } }

Class/struct names: GFG
Java program:
public class MyClass { static void countValues ( int A , int B , int C ) { if ( B >= A ) { System . out . println ( 0 ) ; return ; } if ( B == 0 ) { System . out . println ( C / A ) ; return ; } int ans = C / A ; if ( ans * A + B <= C ) { ans ++ ; } System . out . println ( ans ) ; } public static void main ( String args [ ] ) { int A = 6 , B = 3 , N = 15 ; countValues ( A , B , N ) ; } }

Accumulator variables: ans
Class/struct names: MyClass
Java program:
class GFG { static int highestPowerof2 ( int n ) { int p = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) ; return ( int ) Math . pow ( 2 , p ) ; } static boolean isPowerOfTwo ( int n ) { if ( n == 0 ) return false ; return ( int ) ( Math . ceil ( ( Math . log ( n ) / Math . log ( 2 ) ) ) ) == ( int ) ( Math . floor ( ( ( Math . log ( n ) / Math . log ( 2 ) ) ) ) ) ; } static int reduceToOne ( int N ) { if ( N == 1 ) { return 0 ; } if ( isPowerOfTwo ( N ) == true ) { return 1 + reduceToOne ( N / 2 ) ; } else { return 1 + reduceToOne ( N - highestPowerof2 ( N ) ) ; } } public static void main ( String [ ] args ) { int N = 7 ; System . out . println ( reduceToOne ( N ) ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static int maximumSum ( int arr [ ] , int N ) { int ans = 0 ; for ( int bit = 0 ; bit < 32 ; bit ++ ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & ( 1 << bit ) ) == 1 ) { sum += arr [ i ] ; } } ans = Math . max ( ans , sum ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 4 , 1 , 7 , 11 } ; int N = arr . length ; System . out . println ( maximumSum ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: bit, i, sum
Iterator variables: bit, i
Class/struct names: GFG