dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void ccountSubsets ( int arr [ ] , int n , int gcd [ ] , int m ) { HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; HashMap < Integer , Integer > subsets = new HashMap < Integer , Integer > ( ) ; int arrMax = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arrMax = Math . max ( arrMax , arr [ i ] ) ; if ( freq . containsKey ( arr [ i ] ) ) { freq . put ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) ; } else { freq . put ( arr [ i ] , 1 ) ; } } for ( int i = arrMax ; i >= 1 ; i -- ) { int sub = 0 ; int add = 0 ; if ( freq . containsKey ( i ) ) add = freq . get ( i ) ; for ( int j = 2 ; j * i <= arrMax ; j ++ ) { if ( freq . containsKey ( i * j ) ) add += freq . get ( j * i ) ; sub += subsets . get ( j * i ) ; } subsets . put ( i , ( 1 << add ) - 1 - sub ) ; } for ( int i = 0 ; i < m ; i ++ ) System . out . print ( " Number ▁ of ▁ subsets ▁ with ▁ gcd ▁ " + gcd [ i ] + " ▁ is ▁ " + subsets . get ( gcd [ i ] ) + "NEW_LINE"); } public static void main ( String [ ] args ) { int gcd [ ] = { 2 , 3 } ; int arr [ ] = { 9 , 6 , 2 } ; int n = arr . length ; int m = gcd . length ; ccountSubsets ( arr , n , gcd , m ) ; } }

Index/key variables: i
Accumulator variables: add, i, j, sub
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int sumBitDifferences ( int arr [ ] , int n ) { for ( int i = 0 ; i < 32 ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) if ( ( arr [ j ] & ( 1 << i ) ) != 0 ) count ++ ; ans += ( count * ( n - count ) * 2 ) ; } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 5 } ; int n = arr . length ; System . out . println ( sumBitDifferences ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: ans, count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . printf ( " % d ▁ " , arr [ i ] ) ; System . out . println ( " " ) ; } static void generateUtil ( int x , int arr [ ] , int curr_sum , int curr_idx ) { if ( curr_sum == x ) { printArr ( arr , curr_idx ) ; return ; } int num = 1 ; while ( num <= x - curr_sum && ( curr_idx == 0 num <= arr [ curr_idx - 1 ] ) ) { arr [ curr_idx ] = num ; generateUtil ( x , arr , curr_sum + num , curr_idx + 1 ) ; num ++ ; } } static void generate ( int x ) { int arr [ ] = new int [ x ] ; generateUtil ( x , arr , 0 , 0 ) ; } public static void main ( String [ ] args ) { int x = 5 ; generate ( x ) ; } }

Index/key variables: curr_idx, i, x
Accumulator variables: i, num
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isPerfect ( int n ) { int sum = 1 ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( i * i != n ) sum = sum + i + n / i ; else sum = sum + i ; } } if ( sum == n && n != 1 ) return true ; return false ; } public static void main ( String [ ] args ) { System . out . println ( " Below ▁ are ▁ all ▁ perfect " + " numbers ▁ till ▁ 10000" ) ; for ( int n = 2 ; n < 10000 ; n ++ ) if ( isPerfect ( n ) ) System . out . println ( n + " ▁ is ▁ a ▁ perfect ▁ number " ) ; } }

Accumulator variables: i, n
Iterator variables: i, n
Class/struct names: GFG
Java program:
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 " ) ; } }

Accumulator variables: base
Iterator variables: base
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int mod ( String num , int a ) { int res = 0 ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) res = ( res * 10 + ( int ) num . charAt ( i ) - '0' ) % a ; return res ; } public static void main ( String [ ] args ) { String num = "12316767678678" ; System . out . println ( mod ( num , 10 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int modInverse ( int a , int m ) { for ( int x = 1 ; x < m ; x ++ ) if ( ( ( a % m ) * ( x % m ) ) % m == 1 ) return x ; return 1 ; } public static void main ( String args [ ] ) { int a = 3 , m = 11 ; System . out . println ( modInverse ( a , m ) ) ; } }

Accumulator variables: x
Iterator variables: x
Class/struct names: GFG
Java program:
class GFG { static int modInverse ( int a , int m ) { int m0 = m ; int y = 0 , x = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { int q = a / m ; int t = m ; m = a % m ; a = t ; t = y ; y = x - q * y ; x = t ; } if ( x < 0 ) x += m0 ; return x ; } public static void main ( String args [ ] ) { int a = 3 , m = 11 ; System . out . println ( " Modular ▁ multiplicative ▁ " + " inverse ▁ is ▁ " + modInverse ( a , m ) ) ; } }

Accumulator variables: x
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int phi ( int n ) { int result = 1 ; for ( int i = 2 ; i < n ; i ++ ) if ( gcd ( i , n ) == 1 ) result ++ ; return result ; } public static void main ( String [ ] args ) { int n ; for ( n = 1 ; n <= 10 ; n ++ ) System . out . println ( " phi ( " + n + " ) ▁ = ▁ " + phi ( n ) ) ; } }

Accumulator variables: i, n, result
Iterator variables: i, n
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int phi ( int n ) { float result = n ; for ( int p = 2 ; p * p <= n ; ++ p ) { if ( n % p == 0 ) { while ( n % p == 0 ) n /= p ; result *= ( 1.0 - ( 1.0 / ( float ) p ) ) ; } } if ( n > 1 ) result *= ( 1.0 - ( 1.0 / ( float ) n ) ) ; return ( int ) result ; } public static void main ( String args [ ] ) { int n ; for ( n = 1 ; n <= 10 ; n ++ ) System . out . println ( " phi ( " + n + " ) ▁ = ▁ " + phi ( n ) ) ; } }

Accumulator variables: n, result
Iterator variables: n, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int getRemainder ( int num , int divisor ) { while ( num >= divisor ) num -= divisor ; return num ; } public static void main ( String [ ] args ) { int num = 100 , divisor = 7 ; System . out . println ( getRemainder ( num , divisor ) ) ; } }

Accumulator variables: num
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int factorial ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } static double sum ( int n ) { double sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += 1.0 / factorial ( i ) ; return sum ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( sum ( n ) ) ; } }

Accumulator variables: i, res, sum
Iterator variables: i
Class/struct names: GFG
Java program:
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 catalan ( int n ) { long c = binomialCoeff ( 2 * n , n ) ; return c / ( n + 1 ) ; } static long findWays ( int n ) { if ( ( n & 1 ) != 0 ) return 0 ; return catalan ( n / 2 ) ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( " Total ▁ possible ▁ expressions ▁ of ▁ length ▁ " + n + " ▁ is ▁ " + findWays ( 6 ) ) ; } }

Accumulator variables: res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isOperand ( char c ) { return ( c >= '0' && c <= '9' ) ; } static int value ( char c ) { return ( int ) ( c - '0' ) ; } static int evaluate ( String exp ) { if ( exp . length ( ) == 0 ) return - 1 ; int res = value ( exp . charAt ( 0 ) ) ; for ( int i = 1 ; i < exp . length ( ) ; i += 2 ) { char opr = exp . charAt ( i ) , opd = exp . charAt ( i + 1 ) ; if ( isOperand ( opd ) == false ) return - 1 ; if ( opr == ' + ' ) res += value ( opd ) ; else if ( opr == ' - ' ) res -= value ( opd ) ; else if ( opr == ' * ' ) res *= value ( opd ) ; else if ( opr == ' / ' ) res /= value ( opd ) ; else return - 1 ; } return res ; } public static void main ( String [ ] args ) { String expr1 = "1 + 2*5 + 3" ; int res = evaluate ( expr1 ) ; if ( res == - 1 ) System . out . println ( expr1 + " ▁ is ▁ Invalid " ) ; else System . out . println ( " Value ▁ of ▁ " + expr1 + " ▁ is ▁ " + res ) ; String expr2 = "1 + 2*3" ; res = evaluate ( expr2 ) ; if ( res == - 1 ) System . out . println ( expr2 + " ▁ is ▁ Invalid " ) ; else System . out . println ( " Value ▁ of ▁ " + expr2 + " ▁ is ▁ " + res ) ; String expr3 = "4-2 + 6*3" ; res = evaluate ( expr3 ) ; if ( res == - 1 ) System . out . println ( expr3 + " ▁ is ▁ Invalid " ) ; else System . out . println ( " Value ▁ of ▁ " + expr3 + " ▁ is ▁ " + res ) ; String expr4 = "1 + + 2" ; res = evaluate ( expr4 ) ; if ( res == - 1 ) System . out . println ( expr4 + " ▁ is ▁ Invalid " ) ; else System . out . println ( " Value ▁ of ▁ " + expr4 + " ▁ is ▁ " + res ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
class Test { static void printFibonacciNumbers ( int n ) { int f1 = 0 , f2 = 1 , i ; if ( n < 1 ) return ; System . out . print ( f1 + " ▁ " ) ; 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 ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
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 / gcd ( a , b ) ) * b ; } public static void main ( String [ ] args ) { int a = 15 , b = 20 ; System . out . println ( " LCM ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + lcm ( a , b ) ) ; } }

Class/struct names: Test
Java program:
class GFG { static void convert_to_words ( char [ ] num ) { int len = num . length ; if ( len == 0 ) { System . out . println ( " empty ▁ string " ) ; return ; } if ( len > 4 ) { System . out . println ( " Length ▁ more ▁ than ▁ 4 ▁ is ▁ not ▁ supported " ) ; return ; } String [ ] single_digits = new String [ ] { " zero " , " one " , " two " , " three " , " four " , " five " , " six " , " seven " , " eight " , " nine " } ; String [ ] two_digits = new String [ ] { " " , " ten " , " eleven " , " twelve " , " thirteen " , " fourteen " , " fifteen " , " sixteen " , " seventeen " , " eighteen " , " nineteen " } ; String [ ] tens_multiple = new String [ ] { " " , " " , " twenty " , " thirty " , " forty " , " fifty " , " sixty " , " seventy " , " eighty " , " ninety " } ; String [ ] tens_power = new String [ ] { " hundred " , " thousand " } ; System . out . print ( String . valueOf ( num ) + " : ▁ " ) ; if ( len == 1 ) { System . out . println ( single_digits [ num [ 0 ] - '0' ] ) ; return ; } int x = 0 ; while ( x < num . length ) { if ( len >= 3 ) { if ( num [ x ] - '0' != 0 ) { System . out . print ( single_digits [ num [ x ] - '0' ] + " ▁ " ) ; System . out . print ( tens_power [ len - 3 ] + " ▁ " ) ; } -- len ; } else { if ( num [ x ] - '0' == 1 ) { int sum = num [ x ] - '0' + num [ x + 1 ] - '0' ; System . out . println ( two_digits [ sum ] ) ; return ; } else if ( num [ x ] - '0' == 2 && num [ x + 1 ] - '0' == 0 ) { System . out . println ( " twenty " ) ; return ; } else { int i = ( num [ x ] - '0' ) ; if ( i > 0 ) System . out . print ( tens_multiple [ i ] + " ▁ " ) ; else System . out . print ( " " ) ; ++ x ; if ( num [ x ] - '0' != 0 ) System . out . println ( single_digits [ num [ x ] - '0' ] ) ; } } ++ x ; } } public static void main ( String [ ] args ) { convert_to_words ( "9923" . toCharArray ( ) ) ; convert_to_words ( "523" . toCharArray ( ) ) ; convert_to_words ( "89" . toCharArray ( ) ) ; convert_to_words ( "8" . toCharArray ( ) ) ; } }

Index/key variables: i, sum, x
Class/struct names: GFG
Java program:
class GFG { static int MAX = 11 ; static boolean isMultipleof5 ( int n ) { char str [ ] = new char [ MAX ] ; int len = str . length ; if ( str [ len - 1 ] == '5' str [ len - 1 ] == '0' ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 19 ; if ( isMultipleof5 ( n ) == true ) System . out . println ( n + " ▁ is ▁ multiple ▁ " + " of ▁ 5" ) ; else System . out . println ( n + " ▁ is ▁ not ▁ a ▁ " + " multiple ▁ of ▁ 5" ) ; } }

Index/key variables: MAX
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countSubsequences ( int arr [ ] ) { int odd = 0 ; int even = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) odd ++ ; else even ++ ; } return ( ( 1 << odd ) - 1 ) * ( 1 << even ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 1 } ; System . out . println ( countSubsequences ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Or_of_Ands_for_each_query ( int arr [ ] , int n , int queries [ ] [ ] , int q ) { int bits [ ] = new int [ 32 ] ; Arrays . fill ( bits , 0 ) ; for ( int i = 0 ; i < 32 ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( ( 1 << i ) & arr [ j ] ) != 0 ) { bits [ i ] ++ ; } } } for ( int p = 0 ; p < q ; p ++ ) { for ( int i = 0 ; i < 32 ; i ++ ) { if ( ( ( 1 << i ) & arr [ queries [ p ] [ 0 ] ] ) != 0 ) { bits [ i ] -- ; } if ( ( queries [ p ] [ 1 ] & ( 1 << i ) ) != 0 ) { bits [ i ] ++ ; } } arr [ queries [ p ] [ 0 ] ] = queries [ p ] [ 1 ] ; int ans = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { if ( bits [ i ] != 0 ) { ans |= ( 1 << i ) ; } } System . out . println ( ans ) ; } } public static void main ( String [ ] args ) { int n = 3 , q = 2 ; int arr [ ] = { 3 , 5 , 7 } ; int queries [ ] [ ] = { { 1 , 2 } , { 2 , 1 } } ; Or_of_Ands_for_each_query ( arr , n , queries , q ) ; } }

Index/key variables: i, j, p
Accumulator variables: ans, i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int XorSum ( int A [ ] , int B [ ] , int N , int M ) { int ans = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( ans == - 1 ) ans = ( A [ i ] & B [ j ] ) ; else ans ^= ( A [ i ] & B [ j ] ) ; } } return ans ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 5 } ; int B [ ] = { 2 , 3 } ; int N = A . length ; int M = B . length ; System . out . println ( XorSum ( A , B , N , M ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countbitdiff ( int xo ) { int count = 0 ; while ( xo != 0 ) { if ( xo % 2 == 1 ) { count ++ ; } xo = xo / 2 ; } return count ; } static void shortestPath ( int n , int a , int b ) { int xorVal = a ^ b ; int cnt = countbitdiff ( xorVal ) ; if ( cnt % 2 == 0 ) System . out . print ( cnt / 2 ) ; else System . out . print ( " - 1" ) ; } public static void main ( String [ ] args ) { int n = 15 ; int a = 15 , b = 3 ; shortestPath ( n , a , b ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int M = 3 ; static int N = 3 ; static int findXOR ( int X ) { int ans = 0 ; while ( X != 0 ) { ans ^= ( X % 10 ) ; X /= 10 ; } return ans ; } static void printXORmatrix ( int arr [ ] [ ] ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } static void convertXOR ( int arr [ ] [ ] ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { int X = arr [ i ] [ j ] ; int temp = findXOR ( X ) ; arr [ i ] [ j ] = temp ; } } printXORmatrix ( arr ) ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 27 , 173 , 5 } , { 21 , 6 , 624 } , { 5 , 321 , 49 } } ; convertXOR ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: X, ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSet ( int N ) { int ans = 0 ; while ( N > 0 ) { ans += N & 1 ; N >>= 1 ; } return ans ; } static int countSub ( int [ ] arr , int k ) { int ans = 0 ; int setK = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { if ( countSet ( arr [ i ] ) == k ) setK += 1 ; else setK = 0 ; ans += setK ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 1 , 5 , 6 } ; int K = 2 ; System . out . print ( countSub ( arr , K ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, setK
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void oddXorSubarray ( int a [ ] , int n ) { int odd = 0 ; int c_odd = 0 ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 != 0 ) { odd = ( odd == 0 ) ? 1 : 0 ; } if ( odd != 0 ) { c_odd ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { result += c_odd ; if ( a [ i ] % 2 != 0 ) { c_odd = ( n - i - c_odd ) ; } } System . out . println ( result ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 7 , 9 , 10 } ; int N = arr . length ; oddXorSubarray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: c_odd, i, result
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printORSumforEachElement ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int req_sum = 0 ; for ( int j = 0 ; j < N ; j ++ ) { req_sum += ( arr [ i ] arr [ j ] ) ; } System . out . print ( req_sum + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = arr . length ; printORSumforEachElement ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, req_sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Bitwise_OR_sum_i ( int arr1 [ ] , int arr2 [ ] , int M , int N ) { int frequency [ ] = new int [ 32 ] ; Arrays . fill ( frequency , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int bit_position = 0 ; int num = arr1 [ i ] ; while ( num != 0 ) { if ( ( num & 1 ) != 0 ) { frequency [ bit_position ] += 1 ; } bit_position += 1 ; num >>= 1 ; } } for ( int i = 0 ; i < M ; i ++ ) { int num = arr2 [ i ] ; int value_at_that_bit = 1 ; int bitwise_OR_sum = 0 ; for ( int bit_position = 0 ; bit_position < 32 ; bit_position ++ ) { if ( ( num & 1 ) != 0 ) { bitwise_OR_sum += N * value_at_that_bit ; } else { bitwise_OR_sum += frequency [ bit_position ] * value_at_that_bit ; } num >>= 1 ; value_at_that_bit <<= 1 ; } System . out . print ( bitwise_OR_sum + " ▁ " ) ; } return ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 1 , 2 , 3 } ; int arr2 [ ] = { 1 , 2 , 3 } ; int N = arr1 . length ; int M = arr2 . length ; Bitwise_OR_sum_i ( arr1 , arr2 , M , N ) ; } }

Index/key variables: bit_position, i
Accumulator variables: bit_position, bitwise_OR_sum, i
Iterator variables: bit_position, i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void countPairs ( int [ ] arr , int k , int size ) { int count = 0 , x ; for ( int i = 0 ; i < size - 1 ; i ++ ) { for ( int j = i + 1 ; j < size ; j ++ ) { x = arr [ i ] | arr [ j ] ; if ( x == k ) count ++ ; } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 38 , 44 , 29 , 62 } ; int K = 46 ; int N = arr . length ; countPairs ( arr , K , N ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
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 Vector < pair > [ ] adj = new Vector [ 100005 ] ; static int visited [ ] = new int [ 100005 ] ; static int ans = 0 ; static void dfs ( int node , int xorr , int k ) { visited [ node ] = 1 ; if ( node != 1 && xorr == k ) ans ++ ; for ( pair x : adj [ node ] ) { if ( visited [ x . first ] != 1 ) { int xorr1 = xorr ^ x . second ; dfs ( x . first , xorr1 , k ) ; } } } static void countNodes ( int N , int K , int R , int [ ] [ ] edges ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { int u = edges [ i ] [ 0 ] , v = edges [ i ] [ 1 ] , w = edges [ i ] [ 2 ] ; adj [ u ] . add ( new pair ( v , w ) ) ; adj [ v ] . add ( new pair ( u , w ) ) ; } dfs ( R , 0 , K ) ; System . out . print ( ans + "NEW_LINE"); } public static void main ( String [ ] args ) { int K = 0 , R = 1 ; for ( int i = 0 ; i < adj . length ; i ++ ) adj [ i ] = new Vector < pair > ( ) ; int [ ] [ ] edges = { { 1 , 2 , 3 } , { 1 , 3 , 1 } , { 2 , 4 , 3 } , { 2 , 5 , 4 } , { 3 , 6 , 1 } , { 3 , 7 , 2 } } ; int N = edges . length ; countNodes ( N , K , R , edges ) ; } }

Index/key variables: i, node, u, v
Accumulator variables: ans, i
Iterator variables: i, x
Class/struct names: GFG, pair
Java program:
class GFG { static void findMinXORSubarray ( int arr [ ] , int n , int k ) { if ( n < k ) return ; int res_index = 0 ; int curr_xor = 0 ; for ( int i = 0 ; i < k ; i ++ ) curr_xor ^= arr [ i ] ; int min_xor = curr_xor ; for ( int i = k ; i < n ; i ++ ) { curr_xor ^= ( arr [ i ] ^ arr [ i - k ] ) ; if ( curr_xor < min_xor ) { min_xor = curr_xor ; res_index = ( i - k + 1 ) ; } } System . out . println ( min_xor ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 7 , 90 , 20 , 10 , 50 , 40 } ; int k = 3 ; int n = arr . length ; findMinXORSubarray ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: curr_xor, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findmax ( int arr [ ] , int n , int k ) { int trav , i ; int c = 0 , maximum = 0 ; for ( i = 0 ; i < n - k + 1 ; i ++ ) { trav = i - 1 ; c = 0 ; while ( trav >= 0 && arr [ trav ] == 1 ) { trav -- ; c ++ ; } trav = i + k ; while ( trav < n && arr [ trav ] == 1 ) { trav ++ ; c ++ ; } c += k ; if ( c > maximum ) maximum = c ; } return maximum ; } public static void main ( String args [ ] ) { int k = 3 ; int arr [ ] = { 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 } ; int n = arr . length ; int ans = findmax ( arr , n , k ) ; System . out . println ( ans ) ; } }

Index/key variables: trav
Accumulator variables: c, i, trav
Iterator variables: i
Class/struct names: GFG
Java program:
import java . lang . * ; import java . util . * ; class GFG { static int height ( int N ) { return ( int ) Math . ceil ( Math . log ( N + 1 ) / Math . log ( 2 ) ) - 1 ; } static void findLeafNodes ( int arr [ ] , int n ) { int h = height ( n ) ; ArrayList < Integer > arrlist = new ArrayList < > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( height ( i + 1 ) == h ) { arrlist . add ( arr [ i ] ) ; } else if ( height ( i + 1 ) == h - 1 && n <= ( ( 2 * i ) + 1 ) ) { arrlist . add ( arr [ i ] ) ; } else { break ; } } printLeafNodes ( arrlist ) ; } static void printLeafNodes ( ArrayList < Integer > arrlist ) { for ( int i = arrlist . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( arrlist . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; findLeafNodes ( arr , arr . length ) ; } }

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