dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
public static void canPlace ( String s , int n , int k ) { int cnt = 0 ; int i = 0 ; while ( i < n ) { if ( s . charAt ( i ) == '1' ) { i += 2 ; } else { if ( i == 0 ) { if ( s . charAt ( i + 1 ) == '0' ) { cnt ++ ; i += 2 ; } else i ++ ; } else if ( i == n - 1 ) { if ( s . charAt ( i - 1 ) == '0' ) { cnt ++ ; i += 2 ; } else i ++ ; } else { if ( s . charAt ( i + 1 ) == '0' && s . charAt ( i - 1 ) == '0' ) { cnt ++ ; i += 2 ; } else i ++ ; } } } if ( cnt >= k ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { String S = "10001" ; int K = 1 ; int N = 5 ; canPlace ( S , N , K ) ; } }

Accumulator variables: cnt, i
Java program:
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 findMaxIntervals ( ArrayList < Pair > v , int n ) { int maxi = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int c = n ; for ( int j = 0 ; j < n ; j ++ ) { if ( v . get ( i ) . second < v . get ( j ) . first || v . get ( i ) . first > v . get ( j ) . second ) { c -- ; } } maxi = Math . max ( c , maxi ) ; } System . out . print ( maxi ) ; } public static void main ( String [ ] args ) { ArrayList < Pair > arr = new ArrayList < > ( ) ; arr . add ( new Pair ( 1 , 2 ) ) ; arr . add ( new Pair ( 3 , 4 ) ) ; arr . add ( new Pair ( 2 , 5 ) ) ; int N = arr . size ( ) ; findMaxIntervals ( arr , N ) ; } }

Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG, Pair
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean check ( int a [ ] , int n ) { boolean flag = false ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( a [ i + 1 ] > a [ i ] && a [ i ] < a [ i - 1 ] ) flag = true ; } if ( flag ) return false ; else return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 2 } ; int N = arr . length ; if ( check ( arr , N ) ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
class GFG { static void smallestNumber ( int arr [ ] , int len ) { int maxi = 0 ; for ( int i = 0 ; i < len ; i ++ ) { maxi = Math . max ( maxi , arr [ i ] ) ; } int ans = - 1 ; for ( int i = 2 ; i < maxi + 2 ; i ++ ) { boolean flag = true ; for ( int j = 0 ; j < len ; j ++ ) { if ( arr [ j ] % i == 0 ) { flag = false ; break ; } } if ( flag ) { ans = i ; break ; } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 6 , 9 , 2 } ; int N = arr . length ; smallestNumber ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
Java program:
public class GFG { static void findDuplicate ( String str , int N ) { int first = 0 ; int second = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( first & ( 1 << ( str . charAt ( i ) - ' a ' ) ) ) != 0 ) { second = second | ( 1 << ( str . charAt ( i ) - ' a ' ) ) ; } else { first = first | ( 1 << ( str . charAt ( i ) - ' a ' ) ) ; } } for ( int i = 0 ; i < 26 ; i ++ ) { if ( ( ( first & ( 1 << i ) ) & ( second & ( 1 << i ) ) ) != 0 ) { System . out . print ( ( char ) ( i + ' a ' ) + " ▁ " ) ; } } } static public void main ( String args [ ] ) { String str = " geeksforgeeks " ; int N = str . length ( ) ; findDuplicate ( str , N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void minOperations ( String S ) { int count = 0 ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i - 1 ) ) { count += 1 ; } } System . out . print ( count ) ; } public static void main ( String [ ] args ) { String S = "0101010101" ; minOperations ( S ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void numberOfPairs ( int arr [ ] , int N ) { int [ ] set_bits = new int [ 31 ] ; Arrays . fill ( set_bits , 0 ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int x = arr [ i ] ; int bitpos = - 1 ; while ( x > 0 ) { bitpos ++ ; x /= 2 ; } for ( int j = 0 ; j <= bitpos ; j ++ ) { count += set_bits [ j ] ; } set_bits [ bitpos ] ++ ; } System . out . println ( count ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 4 , 16 , 8 , 64 } ; int N = arr . length ; numberOfPairs ( arr , N ) ; } }

Index/key variables: bitpos, i, j
Accumulator variables: bitpos, count, i, j, x
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GFG { static void calculateQuery ( int arr [ ] , int N , int query [ ] , int M ) { for ( int i = 0 ; i < M ; i ++ ) { int X = query [ i ] ; int sum_start = 0 , sum_end = 0 ; for ( int j = 0 ; j < N ; j ++ ) { sum_start += arr [ j ] ; if ( arr [ j ] == X ) break ; } for ( int j = N - 1 ; j >= 0 ; j -- ) { sum_end += arr [ j ] ; if ( arr [ j ] == X ) break ; } System . out . print ( Math . min ( sum_end , sum_start ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 6 , 7 , 4 , 5 , 30 } ; int queries [ ] = { 6 , 5 } ; int N = arr . length ; int M = queries . length ; calculateQuery ( arr , N , queries , M ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum_end, sum_start
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair < E , P > { E first ; P second ; public pair ( E first , P second ) { this . first = first ; this . second = second ; } } @ SuppressWarnings ( { " unchecked " , " rawtypes " } ) static void calculateQuery ( int arr [ ] , int N , int query [ ] , int M ) { int prefix = 0 , suffix = 0 ; HashMap < Integer , pair > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { prefix += arr [ i ] ; mp . put ( arr [ i ] , new pair ( prefix , 0 ) ) ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { suffix += arr [ i ] ; mp . put ( arr [ i ] , new pair ( mp . get ( arr [ i ] ) . first , suffix ) ) ; } for ( int i = 0 ; i < M ; i ++ ) { int X = query [ i ] ; System . out . print ( Math . min ( ( int ) mp . get ( X ) . first , ( int ) mp . get ( X ) . second ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 6 , 7 , 4 , 5 , 30 } ; int queries [ ] = { 6 , 5 } ; int N = arr . length ; int M = queries . length ; calculateQuery ( arr , N , queries , M ) ; } }

Index/key variables: i
Accumulator variables: i, prefix, suffix
Iterator variables: i
Class/struct names: GFG, pair
Java program:
class GFG { static void findMaximum ( int arr [ ] , int N , int Q , int queries [ ] [ ] ) { int prefix_max [ ] = new int [ N + 1 ] ; int suffix_max [ ] = new int [ N + 1 ] ; prefix_max [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { prefix_max [ i ] = Math . max ( prefix_max [ i - 1 ] , arr [ i ] ) ; } suffix_max [ N - 1 ] = arr [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) { suffix_max [ i ] = Math . max ( suffix_max [ i + 1 ] , arr [ i ] ) ; } for ( int i = 0 ; i < Q ; i ++ ) { int l = queries [ i ] [ 0 ] ; int r = queries [ i ] [ 1 ] ; if ( l == 0 && r == ( N - 1 ) ) System . out . print ( "0NEW_LINE"); else if ( l == 0 ) System . out . print ( suffix_max [ r + 1 ] + "NEW_LINE"); else if ( r == ( N - 1 ) ) System . out . print ( prefix_max [ l - 1 ] + "NEW_LINE"); else System . out . print ( Math . max ( prefix_max [ l - 1 ] , suffix_max [ r + 1 ] ) + "NEW_LINE"); } } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 6 , 8 , 10 , 15 } ; int N = arr . length ; int queries [ ] [ ] = { { 0 , 1 } , { 0 , 2 } , { 1 , 4 } } ; int Q = queries . length ; findMaximum ( arr , N , Q , queries ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void oddOneOut ( int arr [ ] , int N ) { int odd = 0 , even = 0 ; int lastOdd = 0 , lastEven = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { even ++ ; lastEven = i ; } else { odd ++ ; lastOdd = i ; } } if ( odd == 1 ) { System . out . println ( lastOdd ) ; } else { System . out . println ( lastEven ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 4 , 7 , 8 , 10 } ; int N = arr . length ; oddOneOut ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String minEmail ( String email ) { String ans = new String ( " " ) ; int len = email . length ( ) ; ans += email . charAt ( 0 ) ; int i = 1 ; boolean notAt = true ; while ( i < len ) { if ( i < len - 3 && notAt && email . charAt ( i ) == ' a ' && email . charAt ( i + 1 ) == ' t ' ) { ans += ' @ ' ; i += 1 ; notAt = false ; } else if ( i < len - 4 && email . charAt ( i ) == ' d ' && email . charAt ( i + 1 ) == ' o ' && email . charAt ( i + 2 ) == ' t ' ) { ans += ' . ' ; i += 2 ; } else { ans += email . charAt ( i ) ; } i += 1 ; } return ans ; } public static void main ( String [ ] args ) { String email = new String ( " geeksforgeeksatgmaildotcom " ) ; System . out . println ( minEmail ( email ) ) ; } }

Accumulator variables: ans, i
Boolean variables: notAt
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isGreaterEqual ( int N , int X ) { return ( N * ( N + 1 ) / 2 ) >= X ; } static int minimumPossible ( int X ) { for ( int i = 1 ; i <= X ; i ++ ) { if ( isGreaterEqual ( i , X ) ) return i ; } return 0 ; } public static void main ( String [ ] args ) { int X = 14 ; System . out . print ( minimumPossible ( X ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int Max = 1000005 ; static boolean CheckDivByAllDigits ( int number ) { int n = number ; while ( n > 0 ) { if ( n % 10 != 0 ) if ( number % ( n % 10 ) != 0 ) { return false ; } n /= 10 ; } return true ; } static void cntNumInRang ( int arr [ ] [ ] , int N ) { int prefCntDiv [ ] = new int [ Max + 1 ] ; for ( int i = 1 ; i <= Max ; i ++ ) { int ans = 0 ; if ( CheckDivByAllDigits ( i ) ) ans = 1 ; prefCntDiv [ i ] = prefCntDiv [ i - 1 ] + ans ; } for ( int i = 0 ; i < N ; i ++ ) System . out . print ( ( prefCntDiv [ arr [ i ] [ 1 ] ] - prefCntDiv [ arr [ i ] [ 0 ] - 1 ] ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 5 } , { 12 , 14 } } ; int N = arr . length ; cntNumInRang ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class sol { public int arrayNesting ( int [ ] arr ) { int res = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] == i ) { res = Math . max ( res , 1 ) ; } else { int count = 0 ; int curr_index = i ; while ( arr [ curr_index ] != curr_index ) { int next_index = arr [ curr_index ] ; arr [ curr_index ] = curr_index ; curr_index = next_index ; count ++ ; } res = Math . max ( res , count ) ; } } return res ; } } class GFG { public static void main ( String [ ] args ) { sol st = new sol ( ) ; int [ ] arr = { 5 , 4 , 0 , 3 , 1 , 6 , 2 } ; int res = st . arrayNesting ( arr ) ; System . out . println ( res ) ; } }

Index/key variables: curr_index, i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, sol
Java program:
import java . util . * ; class GFG { static int N = 200000 ; static int prime [ ] = new int [ 20000 ] ; static int index = 0 ; static void Sieve ( ) { index = 0 ; int p [ ] = new int [ N + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) { p [ i ] = 1 ; } p [ 0 ] = p [ 1 ] = 0 ; for ( int i = 2 ; i * i <= N ; i ++ ) { if ( p [ i ] == 1 ) { for ( int j = i * i ; j <= N ; j += i ) { p [ j ] = 0 ; } } } for ( int i = 1 ; i < N ; i ++ ) { if ( p [ i ] == 1 ) { prime [ index ++ ] = ( int ) ( Math . pow ( i , 4 ) ) ; } } } static void countNumbers ( int L , int R ) { int Count = 0 ; for ( int i = 0 ; i < index ; i ++ ) { int p = prime [ i ] ; if ( p >= L && p <= R ) { Count ++ ; } } System . out . println ( Count ) ; } public static void main ( String [ ] args ) { int L = 16 , R = 85000 ; Sieve ( ) ; countNumbers ( L , R ) ; } }

Index/key variables: i, j
Accumulator variables: Count, i, index, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void countRemainingElements ( int [ ] L1 , int [ ] L2 , int n ) { int one = 0 ; int zero = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( L1 [ i ] == 1 ) one ++ ; else zero ++ ; } int ans = n ; for ( int i = 0 ; i < n ; i ++ ) { if ( L2 [ i ] == 1 ) { one -- ; if ( one < 0 ) { ans = i ; break ; } } else { zero -- ; if ( zero < 0 ) { ans = i ; break ; } } } System . out . println ( n - ans ) ; } public static void main ( String [ ] args ) { int [ ] L1 = { 1 , 1 , 0 , 0 } ; int [ ] L2 = { 0 , 0 , 0 , 1 } ; int N = L1 . length ; countRemainingElements ( L1 , L2 , N ) ; } }

Index/key variables: i
Accumulator variables: i, one, zero
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int getCount ( int rows , int columns , int [ ] [ ] A ) { int res = 0 ; for ( int i = 0 ; i < rows ; i ++ ) { for ( int j = i + 1 ; j < rows ; j ++ ) { if ( A [ i ] [ 0 ] * A [ j ] [ 1 ] == A [ i ] [ 1 ] * A [ j ] [ 0 ] ) { res ++ ; } } } return res ; } public static void main ( String [ ] args ) { int [ ] [ ] A = { { 4 , 8 } , { 10 , 20 } , { 15 , 30 } , { 3 , 6 } } ; int columns = 2 ; int rows = 4 ; System . out . print ( getCount ( rows , columns , A ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Min_Score_Index ( int N , int [ ] A ) { int [ ] Score = new int [ N ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( A [ i ] + i < N ) Score [ i ] = A [ i ] * Score [ A [ i ] + i ] ; else Score [ i ] = A [ i ] ; } int min_value = Integer . MAX_VALUE ; for ( int i : Score ) min_value = Math . min ( i , min_value ) ; int ind = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( Score [ i ] == min_value ) ind = i ; } System . out . print ( ind ) ; } public static void main ( String [ ] args ) { int N = 5 ; int [ ] A = { 1 , 2 , 3 , 4 , 5 } ; Min_Score_Index ( N , A ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void minLength ( String S , String T , int N , int M ) { String temp = " " ; int subtract = 0 ; for ( int i = 0 ; i < N ; ++ i ) { temp += S . charAt ( i ) ; if ( temp . length ( ) >= M ) { if ( T . equals ( temp . substring ( temp . length ( ) - M , temp . length ( ) ) ) ) { subtract += M ; int cnt = 0 ; while ( cnt != M ) { temp = temp . substring ( 0 , temp . length ( ) - 1 ) ; ++ cnt ; } } } } System . out . println ( ( N - subtract ) ) ; } public static void main ( String [ ] args ) { String S = " aabcbcbd " , T = " abc " ; int N = S . length ( ) ; int M = T . length ( ) ; minLength ( S , T , N , M ) ; } }

Accumulator variables: subtract, temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int maximumCount ( int [ ] arr1 , int [ ] arr2 , int s1 , int s2 ) { int sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < s1 ; i ++ ) { sum1 += arr1 [ i ] ; } for ( int j = 0 ; j < s2 ; j ++ ) { sum2 += arr2 [ j ] ; } int len = 0 ; if ( s1 >= s2 ) { len = s2 ; } else { len = s1 ; } Arrays . sort ( arr1 ) ; Arrays . sort ( arr2 ) ; int j = 0 , k = s2 - 1 , count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( sum1 <= sum2 ) { if ( arr2 [ k ] >= arr1 [ i ] ) { int dif1 = arr1 [ j ] , dif2 = arr2 [ k ] ; sum1 -= dif1 ; sum1 += dif2 ; sum2 -= dif2 ; sum2 += dif1 ; j ++ ; k -- ; count ++ ; } else { break ; } } else { break ; } } return count ; } public static void main ( String [ ] args ) { int [ ] arr1 = new int [ ] { 1 , 3 , 2 , 4 } ; int [ ] arr2 = new int [ ] { 6 , 7 , 8 } ; int N = arr1 . length ; int M = arr2 . length ; System . out . println ( maximumCount ( arr1 , arr2 , N , M ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, sum1, sum2
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isValidDigit ( int digit , int K ) { while ( K != 0 ) { if ( K % 10 == digit ) { return true ; } K = K / 10 ; } return false ; } static int noOfValidNumbers ( int K , int arr [ ] ) { int count = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { int no = arr [ i ] ; boolean flag = true ; while ( no != 0 ) { int digit = no % 10 ; if ( ! isValidDigit ( digit , K ) ) { flag = false ; break ; } no = no / 10 ; } if ( flag == true ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int K = 12 ; int arr [ ] = { 1 , 12 , 1222 , 13 , 2 } ; System . out . println ( noOfValidNumbers ( K , arr ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class pair { int element , index ; pair ( int element , int index ) { this . element = element ; this . index = index ; } } class GFG { static void minimumIndex ( int [ ] arr , int [ ] Q ) { int N = arr . length ; int M = Q . length ; ArrayList < pair > storeArrIdx = new ArrayList < > ( ) ; int [ ] minIdx = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { storeArrIdx . add ( new pair ( arr [ i ] , i ) ) ; } Arrays . sort ( arr ) ; Collections . sort ( storeArrIdx , ( a , b ) -> a . element - b . element ) ; minIdx [ N - 1 ] = storeArrIdx . get ( N - 1 ) . index ; for ( int i = N - 2 ; i >= 0 ; i -- ) { minIdx [ i ] = Math . min ( minIdx [ i + 1 ] , storeArrIdx . get ( i ) . index ) ; } for ( int i = 0 ; i < M ; i ++ ) { int pos = lower_bound ( arr , Q [ i ] ) ; if ( pos == N ) { System . out . print ( " - 1" + " ▁ " ) ; continue ; } System . out . print ( minIdx [ pos ] + " ▁ " ) ; } } static int lower_bound ( int [ ] arr , int element ) { for ( int i = 0 ; i < arr . length ; i ++ ) if ( element <= arr [ i ] ) return i ; return arr . length ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 9 } ; int [ ] Q = { 7 , 10 , 0 } ; minimumIndex ( arr , Q ) ; } }

Index/key variables: N, i, pos
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static boolean isSubarrayExistUtil ( int arr [ ] , int K , int N ) { int totalXOR = 0 ; int SubarrayXOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) totalXOR ^= arr [ i ] ; for ( int i = 0 ; i < K ; i ++ ) SubarrayXOR ^= arr [ i ] ; if ( SubarrayXOR == ( totalXOR ^ SubarrayXOR ) ) return true ; for ( int i = K ; i < N ; i ++ ) { SubarrayXOR ^= arr [ i ] ; SubarrayXOR ^= arr [ i - 1 ] ; if ( SubarrayXOR == ( totalXOR ^ SubarrayXOR ) ) return true ; } return false ; } static void isSubarrayExist ( int arr [ ] , int K , int N ) { if ( isSubarrayExistUtil ( arr , K , N ) ) System . out . print ( "YESNEW_LINE"); else System . out . print ( "NONEW_LINE"); } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 3 , 5 , 7 , 7 , 3 , 4 } ; int N = arr . length ; int K = 5 ; isSubarrayExist ( arr , K , N ) ; } }

Index/key variables: i
Accumulator variables: SubarrayXOR, i, totalXOR
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void countPairs ( int L , int R ) { int count_even ; if ( L % 2 == 0 ) { count_even = ( R / 2 ) - ( L / 2 ) + 1 ; } else { count_even = ( R / 2 ) - ( L / 2 ) ; } int count_odd ; if ( L % 2 == 0 ) { count_odd = ( ( R + 1 ) / 2 ) - ( ( L + 1 ) / 2 ) ; } else { count_odd = ( ( R + 1 ) / 2 ) - ( ( L + 1 ) / 2 ) + 1 ; } count_even *= count_even ; count_odd *= count_odd ; System . out . println ( count_even + count_odd ) ; } public static void main ( String [ ] args ) { int L = 1 , R = 3 ; countPairs ( L , R ) ; } }

Accumulator variables: count_even, count_odd
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int getDefiniteFinds ( int [ ] arr ) { int n = arr . length ; int [ ] smallestRight = new int [ n + 1 ] ; smallestRight [ n ] = Integer . MAX_VALUE ; for ( int i = n - 1 ; i >= 0 ; i -- ) { smallestRight [ i ] = Math . min ( smallestRight [ i + 1 ] , arr [ i ] ) ; } int mn = Integer . MIN_VALUE ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( mn < arr [ i ] && arr [ i ] < smallestRight [ i + 1 ] ) { ans ++ ; } mn = Math . max ( arr [ i ] , mn ) ; } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 5 , 4 , 9 } ; System . out . println ( getDefiniteFinds ( arr ) ) ; } }

Index/key variables: i, n
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Count_numbers ( int L , int R ) { int count = ( R - L ) / 2 ; if ( R % 2 != 0 L % 2 != 0 ) count += 1 ; System . out . print ( count ) ; } public static void main ( String [ ] args ) { int L = 6 , R = 30 ; Count_numbers ( L , R ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean checkReverse ( int leftSum , int rightSum ) { int rev = 0 ; int temp = rightSum ; while ( temp != 0 ) { rev = ( rev * 10 ) + ( temp % 10 ) ; temp /= 10 ; } if ( rev == leftSum ) { return true ; } return false ; } static int findIndex ( int [ ] arr , int N ) { int rightSum = 0 ; int leftSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { rightSum += arr [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { rightSum -= arr [ i ] ; if ( checkReverse ( leftSum , rightSum ) ) { return i ; } leftSum += arr [ i ] ; } return - 1 ; } public static void main ( String [ ] args ) { int [ ] arr = { 5 , 7 , 3 , 6 , 4 , 9 , 2 } ; int N = arr . length ; System . out . print ( findIndex ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, leftSum, rightSum, temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int LCS ( int [ ] firstArr , int [ ] secondArr ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < firstArr . length ; i ++ ) { mp . put ( firstArr [ i ] , i + 1 ) ; } Vector < Integer > tempArr = new Vector < > ( ) ; for ( int i = 0 ; i < secondArr . length ; i ++ ) { if ( mp . containsKey ( secondArr [ i ] ) ) { tempArr . add ( mp . get ( secondArr [ i ] ) ) ; } } Vector < Integer > tail = new Vector < > ( ) ; tail . add ( tempArr . get ( 0 ) ) ; for ( int i = 1 ; i < tempArr . size ( ) ; i ++ ) { if ( tempArr . get ( i ) > tail . lastElement ( ) ) tail . add ( tempArr . get ( i ) ) ; else if ( tempArr . get ( i ) < tail . get ( 0 ) ) tail . add ( 0 , tempArr . get ( i ) ) ; } return ( int ) tail . size ( ) ; } public static void main ( String [ ] args ) { int [ ] firstArr = { 3 , 5 , 1 , 8 } ; int [ ] secondArr = { 3 , 3 , 5 , 3 , 8 } ; System . out . print ( LCS ( firstArr , secondArr ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int totalWays ( int n , String str ) { ArrayList < Integer > IdxOf0s = new ArrayList < Integer > ( ) ; int cntWays = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '0' ) { IdxOf0s . add ( i ) ; } } int M = IdxOf0s . size ( ) ; if ( ( M == 0 ) || ( ( M % 2 ) != 0 ) ) { return 0 ; } for ( int i = 2 ; i < M ; i += 2 ) { cntWays = cntWays * ( IdxOf0s . get ( i ) - IdxOf0s . get ( i - 1 ) ) ; } return cntWays ; } public static void main ( String [ ] args ) { String str = "00100" ; int n = str . length ( ) ; System . out . print ( totalWays ( n , str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG