dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static void findValuesOfK ( int g ) { int count = 0 ; for ( int i = 1 ; i * i <= g ; i ++ ) { if ( g % i == 0 ) { if ( i != g / i ) { if ( i % 2 == 1 ) { count ++ ; } if ( ( g / i ) % 2 == 1 ) { count ++ ; } } else if ( i % 2 == 1 ) { count ++ ; } } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { int G = 125 ; findValuesOfK ( G ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static double Avgdifference ( double arr [ ] , int N , int K ) { double sum = 0 ; for ( int i = 0 ; i < K ; i ++ ) sum += arr [ i ] ; double min = sum ; double max = sum ; for ( int i = K ; i <= N - K + 1 ; i ++ ) { sum += arr [ i ] - arr [ i - K ] ; if ( min > sum ) min = sum ; if ( max < sum ) max = sum ; } return ( max - min ) / K ; } public static void main ( String [ ] args ) { double arr [ ] = { 3 , 8 , 9 , 15 } ; int N = arr . length ; int K = 2 ; System . out . println ( Avgdifference ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findSet ( int N , int K ) { ArrayList < Integer > a = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i != K ) a . add ( i ) ; } int MaxDistinct = ( N - K ) + ( K / 2 ) ; Collections . reverse ( a ) ; for ( int i = 0 ; i < MaxDistinct ; i ++ ) System . out . print ( a . get ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int N = 5 , K = 3 ; findSet ( N , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static long [ ] ExtendedEuclidAlgo ( long a , long b ) { if ( a == 0 ) { return new long [ ] { b , 0 , 1 } ; } else { long x1 = 1 , y1 = 1 ; long gcdy [ ] = ExtendedEuclidAlgo ( b % a , a ) ; long gcd = gcdy [ 0 ] ; x1 = gcdy [ 1 ] ; y1 = gcdy [ 2 ] ; long y = x1 ; long x = y1 - ( long ) Math . floor ( b / a ) * x1 ; return new long [ ] { gcd , x , y } ; } } public static void linearCongruence ( long A , long B , long N ) { A = A % N ; B = B % N ; long u = 0 , v = 0 ; long person [ ] = ExtendedEuclidAlgo ( A , N ) ; long d = person [ 0 ] ; u = person [ 1 ] ; v = person [ 2 ] ; if ( B % d != 0 ) { System . out . println ( - 1 ) ; return ; } long x0 = ( u * ( B / d ) ) % N ; if ( x0 < 0 ) x0 += N ; for ( long i = 0 ; i <= d - 1 ; i ++ ) { long an = ( x0 + i * ( N / d ) ) % N ; System . out . print ( an + " ▁ " ) ; } } public static void main ( String [ ] args ) { long A = 15 ; long B = 9 ; long N = 18 ; linearCongruence ( A , B , N ) ; } }

Accumulator variables: i, x0
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int factorialWithoutMul ( int N ) { int ans = N ; for ( int i = N - 1 ; i > 0 ; i -- ) { int sum = 0 ; for ( int j = 0 ; j < i ; j ++ ) sum += ans ; ans = sum ; } return ans ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( factorialWithoutMul ( N ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void tripletAndSum ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { ans += arr [ i ] & arr [ j ] & arr [ k ] ; } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 , 4 , 7 } ; int N = arr . length ; tripletAndSum ( arr , N ) ; } }

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int tripletAndSum ( int [ ] arr , int n ) { int ans = 0 ; for ( int bit = 0 ; bit < 32 ; bit ++ ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & ( 1 << bit ) ) != 0 ) cnt ++ ; } ans += ( 1 << bit ) * cnt * ( cnt - 1 ) * ( cnt - 2 ) / 6 ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 , 4 , 7 } ; int N = arr . length ; System . out . print ( tripletAndSum ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, bit, cnt, i
Iterator variables: bit, i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static void smallestPermutation ( int [ ] arr , int N ) { boolean [ ] w = new boolean [ 2 * N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ arr [ i ] ] = true ; } Set < Integer > S = new HashSet < Integer > ( ) ; for ( int i = 1 ; i <= 2 * N ; i ++ ) { if ( ! w [ i ] ) S . add ( i ) ; } boolean found = true ; Vector < Integer > P = new Vector < Integer > ( ) ; int [ ] p = { 4 , 5 , 1 , 2 , 3 , 6 } ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . contains ( arr [ i ] ) ) { found = false ; break ; } P . add ( arr [ i ] ) ; P . add ( arr [ i ] ) ; S . remove ( arr [ i ] ) ; } if ( ! found ) { System . out . print ( " - 1" ) ; } else { for ( int i = 0 ; i < 2 * N ; i ++ ) System . out . print ( p [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 1 , 3 } ; int N = arr . length ; smallestPermutation ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: found
Class/struct names: Main
Java program:
import java . util . HashMap ; public class GFG { static void maximumSubsequenceSum ( int A [ ] , int N ) { int ans = 0 ; HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { mp . put ( A [ i ] - i , mp . getOrDefault ( A [ i ] - i , 0 ) + A [ i ] ) ; ans = Math . max ( ans , mp . get ( A [ i ] - i ) ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int A [ ] = { 10 , 7 , 1 , 9 , 10 , 1 } ; int N = A . length ; maximumSubsequenceSum ( A , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void nearestPerfectSquare ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int sr = ( int ) Math . sqrt ( arr [ i ] ) ; int a = sr * sr ; int b = ( sr + 1 ) * ( sr + 1 ) ; if ( ( arr [ i ] - a ) < ( b - arr [ i ] ) ) System . out . print ( a + " ▁ " ) ; else System . out . print ( b + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 7 , 13 } ; int N = arr . length ; nearestPerfectSquare ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean prime [ ] = new boolean [ 100001 ] ; static void SieveOfEratosthenes ( int n ) { Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } static void NumberofSets ( int N ) { SieveOfEratosthenes ( N ) ; if ( N == 2 ) { System . out . print ( 1 ) ; } else if ( N == 3 ) { System . out . print ( 2 ) ; } else { int ans = 1 ; for ( int i = N / 2 + 1 ; i <= N ; i ++ ) { if ( prime [ i ] ) { ans += 1 ; } } System . out . print ( ans ) ; } } public static void main ( String [ ] args ) { int N = 9 ; NumberofSets ( N ) ; } }

Index/key variables: i, p
Accumulator variables: ans, i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int floorDifference ( int A [ ] , int N , int X ) { int totalSum = 0 ; int perElementSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalSum += A [ i ] ; perElementSum += A [ i ] / X ; } int totalFloorSum = totalSum / X ; return Math . abs ( totalFloorSum - perElementSum ) ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int X = 4 ; int N = A . length ; System . out . print ( floorDifference ( A , N , X ) ) ; } }

Index/key variables: i
Accumulator variables: i, perElementSum, totalSum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int val ( char c ) { if ( c >= '0' && c <= '9' ) return ( int ) c - '0' ; else return ( int ) c - ' A ' + 10 ; } static int toDeci ( String str , int base ) { int len = str . length ( ) ; int power = 1 ; int num = 0 ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( val ( str . charAt ( i ) ) >= base ) { System . out . printf ( " Invalid ▁ Number " ) ; return - 1 ; } num += val ( str . charAt ( i ) ) * power ; power = power * base ; } return num ; } static char reVal ( int num ) { if ( num >= 0 && num <= 9 ) return ( char ) ( num + '0' ) ; else return ( char ) ( num - 10 + ' A ' ) ; } static String fromDeci ( int base , int inputNum ) { String res = " " ; while ( inputNum > 0 ) { res += reVal ( inputNum % base ) ; inputNum /= base ; } res = reverse ( res ) ; return res ; } static void convertBase ( String s , int a , int b ) { int num = toDeci ( s , a ) ; String ans = fromDeci ( b , num ) ; System . out . print ( ans ) ; } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { String s = "10B " ; int a = 16 , b = 10 ; convertBase ( s , a , b ) ; } }

Index/key variables: l, r
Accumulator variables: i, inputNum, l, num, r, res
Iterator variables: i, l
Class/struct names: GFG
Java program:
class GFG { static int fact ( int N ) { if ( N == 1 N == 0 ) return 1 ; return N * fact ( N - 1 ) ; } static void prefixFactorialArray ( int [ ] arr , int N ) { for ( int i = 1 ; i < N ; i ++ ) { arr [ i ] += arr [ i - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = fact ( arr [ i ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . length ; prefixFactorialArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static int [ ] removeEveryKth ( int l [ ] , int k ) { for ( int i = 0 ; i < l . length ; i ++ ) { if ( i % k == 0 ) l [ i ] = 0 ; } ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( 0 ) ; for ( int i = 1 ; i < l . length ; i ++ ) { if ( l [ i ] != 0 ) list . add ( l [ i ] ) ; } return list . stream ( ) . mapToInt ( i -> i ) . toArray ( ) ; } static void printArray ( int l [ ] ) { for ( int i = 1 ; i < l . length ; i ++ ) System . out . print ( l [ i ] + " ▁ " ) ; System . out . println ( ) ; } static void printSequence ( int n , int k ) { int l [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) l [ i ] = i ; int x = 1 ; for ( int i = 0 ; i < k ; i ++ ) { int p = l [ x ] + l [ x + 1 ] ; l = removeEveryKth ( l , p ) ; x += 1 ; } printArray ( l ) ; } public static void main ( String [ ] args ) { int N = 8 ; int K = 2 ; printSequence ( N , K ) ; } }

Index/key variables: i, x
Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int makeEqual ( int arr [ ] , int n ) { int fre0 [ ] = new int [ 33 ] ; int fre1 [ ] = new int [ 33 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = arr [ i ] ; for ( int j = 0 ; j < 33 ; j ++ ) { if ( ( x & 1 ) != 0 ) { fre1 [ j ] += 1 ; } else { fre0 [ j ] += 1 ; } x = x >> 1 ; } } int ans = 0 ; for ( int i = 0 ; i < 33 ; i ++ ) { ans += Math . min ( fre0 [ i ] , fre1 [ i ] ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 } ; int N = arr . length ; System . out . print ( makeEqual ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int sum ( int arr [ ] , int N , int K ) { int sum = 0 ; ArrayList < Integer > v = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { v . add ( arr [ i ] ) ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( v . get ( i ) % K == 0 ) { int x = v . get ( i ) / K ; for ( int j = 0 ; j < K ; j ++ ) { v . add ( x ) ; } } else break ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) sum = sum + v . get ( i ) ; return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 6 , 8 , 2 } ; int K = 2 ; int N = arr . length ; System . out . println ( sum ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void check ( int arr [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , - 1 , 3 , - 2 , - 1 } ; int N = arr . length ; check ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void expectedValue ( int P , int a , int b , int N ) { double expValue = P + ( N * 0.5 * ( a + b ) ) ; System . out . print ( expValue ) ; } public static void main ( String [ ] args ) { int P = 3000 , a = 20 , b = 10 , N = 30 ; expectedValue ( P , a , b , N ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int startingPoint ( int A [ ] , int N ) { int sum = 0 ; int in = 0 ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; if ( sum < min ) { min = sum ; in = i + 1 ; } } if ( sum < 0 ) { return - 1 ; } return in % N ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , - 6 , 7 , - 4 , - 4 , 6 , - 1 } ; int N = arr . length ; System . out . print ( startingPoint ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static class node { int data ; node next ; node ( int d ) { data = d ; } } static node EvalNearestMult ( node N , int K ) { node temp = N ; int t ; while ( N != null ) { if ( N . data < K ) N . data = 0 ; else { if ( N . data == K ) N . data = K ; else { N . data = ( N . data / K ) * K ; } } N = N . next ; } return temp ; } static void printList ( node N ) { while ( N != null ) { System . out . print ( N . data + " ▁ " ) ; N = N . next ; } } public static void main ( String [ ] args ) { node head = new node ( 3 ) ; head . next = new node ( 5 ) ; head . next . next = new node ( 8 ) ; node t = EvalNearestMult ( head , 3 ) ; printList ( t ) ; } }

Class/struct names: GFG, node
Java program:
class GFG { static int nearestPow ( int x , int y ) { if ( y == 1 ) return 1 ; int k = ( int ) ( Math . log10 ( x ) / Math . log10 ( y ) ) ; if ( Math . abs ( Math . pow ( y , k ) - x ) < Math . abs ( Math . pow ( y , ( k + 1 ) ) - x ) ) return ( int ) ( Math . pow ( y , k ) ) ; return ( int ) ( Math . pow ( y , ( k + 1 ) ) ) ; } static void replacebyNearestPower ( int [ ] arr ) { int prev = arr [ arr . length - 1 ] ; int lastNext = arr [ 0 ] ; int next = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { int temp = arr [ i ] ; if ( i == arr . length - 1 ) next = lastNext ; else next = arr [ ( i + 1 ) % arr . length ] ; int prevPow = nearestPow ( arr [ i ] , prev ) ; int nextPow = nearestPow ( arr [ i ] , next ) ; if ( Math . abs ( arr [ i ] - prevPow ) < Math . abs ( arr [ i ] - nextPow ) ) arr [ i ] = prevPow ; else arr [ i ] = nextPow ; prev = temp ; } for ( int i = 0 ; i < arr . length ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 2 , 3 , 4 , 1 , 2 } ; replacebyNearestPower ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static boolean makeSumX ( int arr [ ] , int X , int S , int i ) { if ( i == arr . length ) { return S == X ; } String a = Integer . toString ( arr [ i ] ) ; int l = Integer . parseInt ( a . substring ( 0 , a . length ( ) - 1 ) ) ; int r = Integer . parseInt ( a . substring ( 1 ) ) ; boolean x = makeSumX ( arr , X , S + l , i + 1 ) ; boolean y = makeSumX ( arr , X , S + r , i + 1 ) ; return ( x y ) ; } static void Check ( int arr [ ] , int X ) { if ( makeSumX ( arr , X , 0 , 0 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 545 , 433 , 654 , 23 } ; int X = 134 ; Check ( arr , X ) ; } }

Index/key variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPower ( int m , int y ) { int res1 = ( int ) Math . log ( y ) / ( int ) Math . log ( m ) ; double res2 = ( int ) Math . log ( y ) / ( int ) Math . log ( m ) ; return ( res1 == res2 ) ; } static int numSub ( int arr [ ] , int n , int m ) { int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPower ( m , arr [ i ] ) ) { cnt ++ ; ans += ( cnt * ( cnt - 1 ) ) / 2 ; } else { cnt = 0 ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 3 } ; int m = 3 ; int n = arr . length ; System . out . println ( numSub ( arr , n , m ) ) ; } }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int cntPairs ( int arr [ ] , int N ) { int res = 0 ; int bit [ ] = new int [ 32 ] ; for ( int i = 0 ; i < N ; i ++ ) { int pos = ( int ) ( Math . log ( arr [ i ] ) / Math . log ( 2 ) ) ; bit [ pos ] ++ ; } for ( int i = 0 ; i < 32 ; i ++ ) { res += ( bit [ i ] * ( bit [ i ] - 1 ) ) / 2 ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = arr . length ; System . out . println ( cntPairs ( arr , N ) ) ; } }

Index/key variables: i, pos
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashSet ; class GFG { static void minimumMEX ( int arr [ ] , int N , int K ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 1 ; i <= N + 1 ; i ++ ) s . add ( i ) ; for ( int i = 0 ; i < K ; i ++ ) s . remove ( arr [ i ] ) ; int mex = s . iterator ( ) . next ( ) ; for ( int i = K ; i < N ; i ++ ) { s . remove ( arr [ i ] ) ; s . add ( arr [ i - K ] ) ; int firstElem = s . iterator ( ) . next ( ) ; mex = Math . min ( mex , firstElem ) ; } System . out . print ( mex + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int K = 3 ; int N = arr . length ; minimumMEX ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void smallerNumbers ( int arr [ ] , int N ) { int hash [ ] = new int [ 100000 ] ; for ( int i = 0 ; i < N ; i ++ ) hash [ arr [ i ] ] ++ ; int sum = 0 ; for ( int i = 1 ; i < 100000 ; i ++ ) { hash [ i ] += hash [ i - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { System . out . println ( "0" ) ; continue ; } System . out . print ( hash [ arr [ i ] - 1 ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 1 , 1 , 2 } ; int N = arr . length ; smallerNumbers ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int truncMod ( int a , int n ) { int q = a / n ; return a - n * q ; } public static void main ( String [ ] args ) { int a , b ; a = 9 ; b = 4 ; System . out . println ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + truncMod ( a , b ) ) ; a = - 9 ; b = 4 ; System . out . println ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + truncMod ( a , b ) ) ; a = 9 ; b = - 4 ; System . out . println ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + truncMod ( a , b ) ) ; a = - 9 ; b = - 4 ; System . out . println ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + truncMod ( a , b ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Double average ( int arr [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; return Double . valueOf ( sum / N ) ; } static Double mean ( int arr [ ] , int N ) { Double avg = 0.0 ; for ( int i = 0 ; i < N ; i ++ ) { avg += Double . valueOf ( ( arr [ i ] - avg ) / ( i + 1 ) ) ; } return avg ; } public static void main ( String args [ ] ) { int arr [ ] = { Integer . MAX_VALUE , 1 , 2 } ; int N = arr . length ; System . out . println ( " Average ▁ by ▁ Standard ▁ method : ▁ " + String . format ( " % .10f " , average ( arr , N ) ) ) ; System . out . println ( " Average ▁ by ▁ Efficient ▁ method : ▁ " + String . format ( " % .10f " , mean ( arr , N ) ) ) ; } }

Index/key variables: i
Accumulator variables: avg, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countPairs ( int [ ] arr , int N ) { int count = 0 ; Map < Double , Integer > mp = new HashMap < Double , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Double val = 1.0 * arr [ i ] ; Double idx = 1.0 * ( i + 1 ) ; if ( mp . containsKey ( val / idx ) ) count += mp . get ( val / idx ) ; if ( mp . containsKey ( val / idx ) ) mp . put ( val / idx , mp . getOrDefault ( val / idx , 0 ) + 1 ) ; else mp . put ( val / idx , 1 ) ; } System . out . print ( count ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 3 , 5 , 6 , 5 } ; int N = arr . length ; countPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void add_edge ( ArrayList < ArrayList < Integer > > adj , int u , int v ) { adj . get ( u ) . add ( v ) ; adj . get ( v ) . add ( u ) ; } static void dfs ( ArrayList < Integer > parent , ArrayList < ArrayList < Integer > > adj , int u , int par ) { parent . set ( u , par ) ; for ( int child : adj . get ( u ) ) { if ( child != par ) dfs ( parent , adj , child , u ) ; } } static void countSmallerAncestors ( ArrayList < ArrayList < Integer > > adj , int n ) { ArrayList < Integer > parent = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < ( int ) ( 1e5 ) ; i ++ ) { parent . add ( 0 ) ; } dfs ( parent , adj , 1 , - 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) { int node = i ; int cnt = 0 ; while ( parent . get ( node ) != - 1 ) { if ( parent . get ( node ) < i ) cnt += 1 ; node = parent . get ( node ) ; } System . out . print ( cnt + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 6 ; ArrayList < ArrayList < Integer > > adj = new ArrayList < ArrayList < Integer > > ( ) ; for ( int i = 0 ; i < ( int ) ( 1e5 ) ; i ++ ) { adj . add ( new ArrayList < Integer > ( ) ) ; } add_edge ( adj , 1 , 5 ) ; add_edge ( adj , 1 , 4 ) ; add_edge ( adj , 4 , 6 ) ; add_edge ( adj , 5 , 3 ) ; add_edge ( adj , 5 , 2 ) ; countSmallerAncestors ( adj , N ) ; } }

Accumulator variables: cnt, i
Iterator variables: child, i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void countSubsequences ( int [ ] A ) { int odd = 0 ; int even = 0 ; for ( int el : A ) { if ( el % 2 == 1 ) odd ++ ; else even ++ ; } if ( odd == 0 ) System . out . println ( 0 ) ; else System . out . println ( 1 << ( A . length - 1 ) ) ; } public static void main ( String [ ] args ) { int [ ] A = { 1 , 3 , 4 } ; countSubsequences ( A ) ; } }

Accumulator variables: even, odd
Iterator variables: el
Class/struct names: GFG