dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static int ncr ( int n , int r ) { int ans = 1 ; for ( int i = 1 ; i <= r ; i += 1 ) { ans *= ( n - r + i ) ; ans /= i ; } return ans ; } static int NoOfDistributions ( int N , int R ) { return ncr ( N - 1 , R - 1 ) ; } public static void main ( String [ ] args ) { int N = 4 ; int R = 3 ; System . out . println ( NoOfDistributions ( N , R ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int ncr ( int n , int r ) { int ans = 1 ; for ( int i = 1 ; i <= r ; i += 1 ) { ans *= ( n - r + i ) ; ans /= i ; } return ans ; } static int NoOfDistributions ( int N , int R ) { return ncr ( N + R - 1 , R - 1 ) ; } public static void main ( String [ ] args ) { int N = 4 , R = 3 ; System . out . println ( NoOfDistributions ( N , R ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean checkPerfectcube ( int n ) { int d = ( int ) Math . cbrt ( n ) ; if ( d * d * d == n ) return true ; return false ; } static int smallestPerfectCube ( int a [ ] , int n ) { int mini = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( checkPerfectcube ( a [ i ] ) ) { mini = Math . min ( a [ i ] , mini ) ; } } return mini ; } public static void main ( String [ ] args ) { int a [ ] = { 16 , 8 , 25 , 2 , 3 , 10 } ; int n = a . length ; System . out . print ( smallestPerfectCube ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void Vertices ( int x , int y ) { int val = Math . abs ( x ) + Math . abs ( y ) ; System . out . print ( val * ( x < 0 ? - 1 : 1 ) + " ▁ 0 ▁ " ) ; System . out . print ( "0 ▁ " + val * ( y < 0 ? - 1 : 1 ) ) ; } public static void main ( String [ ] args ) { int x = 3 , y = 3 ; Vertices ( x , y ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void CheckSubarray ( int arr [ ] , int N ) { int presum [ ] = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i += 1 ) { presum [ i ] = presum [ i - 1 ] + arr [ i - 1 ] ; } for ( int i = 1 ; i <= N ; i += 1 ) { for ( int j = i ; j <= N ; j += 1 ) { if ( ( presum [ j ] - presum [ i - 1 ] ) % N == 0 ) { System . out . print ( ( i - 1 ) + " ▁ " + ( j - 1 ) ) ; return ; } } } System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 7 , 5 , 3 , 7 } ; int N = arr . length ; CheckSubarray ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void CheckSubarray ( int arr [ ] , int N ) { int [ ] presum = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i += 1 ) { presum [ i ] = presum [ i - 1 ] + arr [ i - 1 ] ; } Vector < Integer > [ ] moduloclass = new Vector [ N ] ; for ( int i = 0 ; i < N ; i += 1 ) { moduloclass [ i ] = new Vector < > ( ) ; } for ( int i = 1 ; i <= N ; i += 1 ) { moduloclass [ presum [ i ] % N ] . add ( i - 1 ) ; } if ( moduloclass [ 0 ] . size ( ) > 0 ) { System . out . print ( 0 + " ▁ " + moduloclass [ 0 ] . get ( 0 ) ) ; return ; } for ( int i = 1 ; i < N ; i += 1 ) { if ( moduloclass [ i ] . size ( ) >= 2 ) { System . out . print ( moduloclass [ i ] . get ( 0 ) + 1 + " ▁ " + moduloclass [ i ] . get ( 1 ) ) ; return ; } } } public static void main ( String args [ ] ) { int arr [ ] = { 7 , 3 , 5 , 2 } ; int N = arr . length ; CheckSubarray ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countBits ( int n ) { int count = 0 ; while ( n > 0 ) { count ++ ; n >>= 1 ; } return count ; } static int findNearestNumber ( int n ) { int cnt = countBits ( n ) ; cnt -= 1 ; if ( cnt % 2 == 1 ) { return 1 << ( cnt + 1 ) ; } else { int tempnum = 0 ; for ( int i = 0 ; i <= cnt ; i += 2 ) { tempnum += 1 << i ; } if ( tempnum < n ) { return ( 1 << ( cnt + 2 ) ) ; } else if ( tempnum == n ) { return n ; } for ( int i = 0 ; i <= cnt ; i += 2 ) { tempnum -= ( 1 << i ) ; if ( tempnum < n ) { return tempnum += ( 1 << i ) ; } } } return Integer . MIN_VALUE ; } public static void main ( String [ ] args ) { int n = 19 ; System . out . println ( findNearestNumber ( n ) ) ; } }

Accumulator variables: cnt, count, i, tempnum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countNum ( int n ) { if ( n == 1 ) return 1 ; int count = ( int ) Math . pow ( 2 , n - 2 ) ; return count ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( countNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String constructString ( int n ) { String s = " " ; for ( int i = 0 ; i < n ; i ++ ) { s += "10" ; } return s ; } static int binaryToDecimal ( String n ) { String num = n ; int dec_value = 0 ; int base = 1 ; int len = num . length ( ) ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( num . charAt ( i ) == '1' ) dec_value += base ; base = base * 2 ; } return dec_value ; } static int findNumber ( int n ) { String s = constructString ( n - 1 ) ; int num = binaryToDecimal ( s ) ; return num ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( findNumber ( n ) ) ; } }

Accumulator variables: dec_value, i, s
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static class Node { int data ; Node next ; } ; static Node push ( Node head_ref , int data ) { Node new_node = new Node ( ) ; new_node . data = data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; return head_ref ; } static int bitonic_point ( Node node ) { if ( node == null ) return - 1 ; if ( node . next == null ) return - 1 ; if ( node . data > node . next . data ) return - 1 ; while ( node . next != null ) { if ( node . data > node . next . data ) break ; node = node . next ; } int bitonicPoint = node . data ; while ( node . next != null ) { if ( node . data < node . next . data ) return - 1 ; node = node . next ; } return bitonicPoint ; } public static void main ( String args [ ] ) { Node head = null ; head = push ( head , 100 ) ; head = push ( head , 201 ) ; head = push ( head , 399 ) ; head = push ( head , 490 ) ; head = push ( head , 377 ) ; head = push ( head , 291 ) ; head = push ( head , 100 ) ; System . out . println ( bitonic_point ( head ) ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . Collections ; import java . util . Vector ; class GFG { static int MinRemove ( int [ ] a , int n , int k ) { int [ ] cnt = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) cnt [ 0 ] ++ ; else if ( cnt [ a [ i ] - 1 ] > 0 ) { cnt [ a [ i ] - 1 ] -- ; cnt [ a [ i ] ] ++ ; } } return n - ( k * cnt [ k - 1 ] ) ; } public static void main ( String [ ] args ) { int a [ ] = { 0 , 1 , 2 , 3 , 4 , 0 , 1 , 0 , 1 , 2 , 3 , 4 } ; int k = 5 ; int n = a . length ; System . out . println ( MinRemove ( a , n , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int mosaic ( int n ) { int i , ans = 1 ; for ( i = 2 ; i <= n ; i ++ ) { if ( n % i == 0 && n > 0 ) { int count = 0 ; while ( n % i == 0 ) { n /= i ; count ++ ; } ans *= count * i ; } } return ans ; } static void nMosaicNumbers ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) System . out . print ( mosaic ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 10 ; nMosaicNumbers ( n ) ; } }

Accumulator variables: ans, count, i, n
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countNodes ( int N , int X ) { int height = ( int ) Math . floor ( Math . log ( N ) / Math . log ( 2 ) ) ; if ( X > height ) { System . out . println ( "0 0 "); return ; } if ( N == 1 ) { System . out . println ( "1 1 "); return ; } int max_total_nodes = ( 1 << ( height + 1 ) ) - 1 ; int nodes_last_level = ( 1 << height ) - ( max_total_nodes - N ) ; int from_root ; int from_leaf ; if ( X == height ) from_root = nodes_last_level ; else from_root = 1 << X ; int left_leaf_nodes = ( ( 1 << height ) - nodes_last_level ) / 2 ; if ( X == 0 ) { from_leaf = nodes_last_level + left_leaf_nodes ; } else { int i = X ; while ( nodes_last_level > 1 && i > 0 ) { nodes_last_level = ( int ) Math . ceil ( ( float ) nodes_last_level / ( float ) 2 ) ; i -- ; } from_leaf = nodes_last_level ; i = X ; while ( left_leaf_nodes > 1 && i > 0 ) { left_leaf_nodes = ( int ) Math . ceil ( ( float ) left_leaf_nodes / ( float ) 2 ) ; i -- ; } from_leaf += left_leaf_nodes ; } System . out . println ( from_root + "NEW_LINE" + from_leaf); } public static void main ( String [ ] args ) { int N = 38 , X = 3 ; countNodes ( N , X ) ; } }

Accumulator variables: from_leaf, i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int sum_of_4_squares ( int n ) { int i , odd = 0 , even = 0 ; for ( i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i % 2 == 0 ) even += i ; else odd += i ; if ( ( n / i ) != i ) { if ( ( n / i ) % 2 == 0 ) even += ( n / i ) ; else odd += ( n / i ) ; } } } if ( n % 2 == 1 ) return 8 * ( odd + even ) ; else return 24 * ( odd ) ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( sum_of_4_squares ( n ) ) ; } }

Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int mosaic ( int n ) { int i , ans = 1 ; for ( i = 2 ; i <= n ; i ++ ) { if ( n % i == 0 && n > 0 ) { int count = 0 ; while ( n % i == 0 ) { n /= i ; count ++ ; } ans *= count * i ; } } return ans ; } public static void main ( String [ ] args ) { int n = 36 ; System . out . println ( mosaic ( n ) ) ; } }

Accumulator variables: ans, count, i, n
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int Total_Ways ( int n ) { int fac = 1 ; for ( int i = 2 ; i <= n - 1 ; i ++ ) { fac = fac * i ; } return ( fac * 2 ) ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( Total_Ways ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int MaxNumbers ( int a [ ] , int n ) { int [ ] fre = { 0 , 0 , 0 } ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] %= 3 ; fre [ a [ i ] ] ++ ; } int ans = fre [ 0 ] ; int k = Math . min ( fre [ 1 ] , fre [ 2 ] ) ; ans += k ; fre [ 1 ] -= k ; fre [ 2 ] -= k ; ans += fre [ 1 ] / 3 + fre [ 2 ] / 3 ; return ans ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 4 , 10 , 7 , 11 , 2 , 8 , 5 , 9 } ; int n = a . length ; System . out . println ( MaxNumbers ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int pairs ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int sum = countSetBits ( arr [ i ] ) + countSetBits ( arr [ j ] ) ; if ( sum == k ) count ++ ; } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . length ; int k = 4 ; System . out . println ( pairs ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, n
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 32 ; static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int pairs ( int arr [ ] , int n , int k ) { int count = 0 ; int [ ] f = new int [ MAX + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) f [ countSetBits ( arr [ i ] ) ] ++ ; for ( int i = 0 ; i <= MAX ; i ++ ) { for ( int j = i ; j <= MAX ; j ++ ) { if ( i + j == k ) { if ( i == j ) count += ( ( f [ i ] * ( f [ i ] - 1 ) ) / 2 ) ; else count += ( f [ i ] * f [ j ] ) ; } } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . length ; int k = 4 ; System . out . println ( pairs ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, n
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void LowerHessenbergMatrix ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( j > i + 1 ) System . out . print ( '0' + " ▁ " ) ; else { System . out . printf ( " % .0f " , Math . random ( ) * 10 ) ; System . out . print ( " ▁ " ) ; } } System . out . println ( "NEW_LINE"); } } public static void main ( String [ ] args ) { int n = 4 ; LowerHessenbergMatrix ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void UpperHessenbergMatrix ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( i > j + 1 ) { System . out . print ( 0 + " ▁ " ) ; } else { System . out . print ( ( int ) ( Math . random ( ) * 10 ) + " ▁ " ) ; } } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 4 ; UpperHessenbergMatrix ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class Gfg { public static int composite_factors ( int n ) { int count = 0 ; int i , j ; int [ ] a = new int [ n + 1 ] ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = 0 ; } for ( i = 1 ; i <= n ; ++ i ) { if ( n % i == 0 ) { a [ i ] = i ; } } for ( i = 2 ; i <= n ; i ++ ) { j = 2 ; int p = 1 ; while ( j < a [ i ] ) { if ( a [ i ] % j == 0 ) { p = 0 ; break ; } j ++ ; } if ( p == 0 && a [ i ] != 0 ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int n = 100 ; System . out . println ( composite_factors ( n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, j
Iterator variables: i
Class/struct names: Gfg
Java program:
class GFG { static boolean isMersenne ( int n ) { while ( n != 0 ) { int r = n % 2 ; if ( r == 0 ) return false ; n /= 2 ; } return true ; } static int sumOfMersenne ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 && isMersenne ( arr [ i ] ) ) { sum += arr [ i ] ; } } return sum ; } public static void main ( String [ ] args ) { int [ ] arr = { 17 , 6 , 7 , 63 , 3 } ; int n = arr . length ; System . out . print ( sumOfMersenne ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, n, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int sumOfFactors ( int n ) { int sum = 0 ; for ( int f = 1 ; f <= n / 2 ; f ++ ) { if ( n % f == 0 ) { sum += f ; } } return sum ; } static int getSum ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 && arr [ i ] == sumOfFactors ( arr [ i ] ) ) { sum += arr [ i ] ; } } return sum ; } public static void main ( String [ ] args ) { int [ ] arr = { 17 , 6 , 10 , 6 , 4 } ; int n = arr . length ; System . out . print ( getSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: f, i, sum
Iterator variables: f, i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean sameLength ( int A , int B ) { while ( ( A > 0 ) && ( B > 0 ) ) { A = A / 10 ; B = B / 10 ; } if ( ( A == 0 ) && ( B == 0 ) ) return true ; return false ; } public static void main ( String [ ] args ) { int A = 21 , B = 1 ; if ( sameLength ( A , B ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int N = 2 ; static int M = 2 ; static void Matrix ( char a [ ] [ ] ) { char ch = '1' ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( a [ i ] [ j ] == ' . ' ) a [ i ] [ j ] = ch ; ch = ( ch == '1' ) ? '0' : '1' ; System . out . print ( a [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; if ( i % 2 == 0 ) ch = '0' ; else ch = '1' ; } } public static void main ( String [ ] args ) { char a [ ] [ ] = { { ' . ' , ' _ ' } , { ' _ ' , ' . ' } } ; Matrix ( a ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int cnt_neg ; static boolean exists_zero ; static void preProcess ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) cnt_neg ++ ; if ( arr [ i ] == 0 ) exists_zero = true ; } } static boolean isPossible ( int k ) { if ( ! exists_zero ) { if ( k >= cnt_neg && ( k - cnt_neg ) % 2 == 0 ) return true ; else return false ; } else { if ( k >= cnt_neg ) return true ; else return false ; } } public static void main ( String [ ] args ) { int arr [ ] = { - 1 , 2 , - 3 , 4 , 5 } ; int n = arr . length ; preProcess ( arr , n ) ; int queries [ ] = { 1 , 2 , 3 , 4 } ; int q = arr . length ; for ( int i = 0 ; i < q ; i ++ ) { if ( isPossible ( queries [ i ] ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: cnt_neg, i
Iterator variables: i
Boolean variables: exists_zero
Class/struct names: GFG
Java program:
class GFG { static int FindXorSum ( int arr [ ] , int k , int n ) { if ( n < k ) return 0 ; int [ ] x = new int [ n ] ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 ) x [ i ] = x [ i - 1 ] ^ arr [ i ] ; else x [ i ] = arr [ i ] ; if ( i >= k - 1 ) { int sum = 0 ; sum = x [ i ] ; if ( i - k > - 1 ) sum ^= x [ i - k ] ; result += sum ; } } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = 4 , k = 2 ; System . out . println ( FindXorSum ( arr , k , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, result, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int reverse ( int n ) { int rev = 0 ; while ( n > 0 ) { int d = n % 10 ; rev = rev * 10 + d ; n = n / 10 ; } return rev ; } static boolean isPalin ( int n ) { return ( n == reverse ( n ) ) ; } static int countDigits ( int n ) { int c = 0 ; while ( n > 0 ) { n = n / 10 ; c ++ ; } return c ; } static int countPalinDigits ( int [ ] arr , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 10 || isPalin ( arr [ i ] ) ) { s += countDigits ( arr [ i ] ) ; } } return s ; } public static void main ( String [ ] args ) { int [ ] arr = { 121 , 56 , 434 } ; int n = arr . length ; System . out . println ( countPalinDigits ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: c, i, s
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int reverse ( int n ) { int d = 0 , s = 0 ; while ( n > 0 ) { d = n % 10 ; s = s * 10 + d ; n = n / 10 ; } return s ; } static boolean isPalin ( int n ) { return n == reverse ( n ) ; } static int sumOfArray ( int [ ] arr , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] > 10 ) && isPalin ( arr [ i ] ) ) { s += arr [ i ] ; } } return s ; } public static void main ( String [ ] args ) { int n = 6 ; int [ ] arr = { 12 , 313 , 11 , 44 , 9 , 1 } ; System . out . println ( sumOfArray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int MAX = 1000000 ; static int [ ] prime = new int [ MAX + 1 ] ; static void updatePrimes ( ) { for ( int i = 2 ; i <= MAX ; i ++ ) { prime [ i ] = 1 ; } prime [ 0 ] = prime [ 1 ] = 0 ; for ( int i = 2 ; i * i <= MAX ; i ++ ) { if ( prime [ i ] == 1 ) { for ( int j = i * i ; j <= MAX ; j += i ) { prime [ j ] = 0 ; } } } for ( int i = 1 ; i <= MAX ; i ++ ) { prime [ i ] += prime [ i - 1 ] ; } } static int getDifference ( int l , int r ) { int total = r - l + 1 ; int primes = prime [ r ] - prime [ l - 1 ] ; int composites = total - primes ; return ( Math . abs ( primes - composites ) ) ; } public static void main ( String [ ] args ) { int queries [ ] [ ] = { { 1 , 10 } , { 5 , 30 } } ; int q = queries . length ; updatePrimes ( ) ; for ( int i = 0 ; i < q ; i ++ ) System . out . println ( getDifference ( queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) ; } }

Index/key variables: i, j, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . text . * ; class GFG { static double p = 1 , f = 1 ; static double e ( int x , int n ) { double r ; if ( n == 0 ) return 1 ; r = e ( x , n - 1 ) ; p = p * x ; f = f * n ; return ( r + p / f ) ; } public static void main ( String [ ] args ) { int x = 4 , n = 15 ; DecimalFormat df = new DecimalFormat ( "0 . # # # # # # " ) ; System . out . println ( df . format ( e ( x , n ) ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 1000000 ; static int [ ] Sieve = new int [ MAX + 1 ] ; static void constructSieve ( ) { for ( int i = 2 ; i <= MAX ; i ++ ) { if ( Sieve [ i ] == 0 ) { for ( int j = 2 * i ; j <= MAX ; j += i ) { int temp = j ; while ( temp > 1 && temp % i == 0 ) { Sieve [ j ] ++ ; temp = temp / i ; } } } } } static void checkElements ( int A [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( Sieve [ A [ i ] ] == k ) { System . out . println ( " YES " ) ; } else { System . out . println ( " No " ) ; } } } public static void main ( String [ ] args ) { constructSieve ( ) ; int k = 3 ; int A [ ] = { 12 , 36 , 42 , 72 } ; int n = A . length ; checkElements ( A , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int mod = 1000000007 ; static long modularexpo ( long x , long y , long p ) { long res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } static void multiply ( long F [ ] [ ] , long M [ ] [ ] , long m ) { long x = ( ( F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] ) % m + ( F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ) % m ) % m ; long y = ( ( F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] ) % m + ( F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ) % m ) % m ; long z = ( ( F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] ) % m + ( F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ) % m ) % m ; long w = ( ( F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] ) % m + ( F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ) % m ) % m ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } static void power ( long F [ ] [ ] , long n , long m ) { if ( n == 0 n == 1 ) return ; long M [ ] [ ] = { { 1 , 1 } , { 1 , 0 } } ; power ( F , n / 2 , m ) ; multiply ( F , F , m ) ; if ( n % 2 != 0 ) multiply ( F , M , m ) ; } static long fib ( long n , long m ) { long F [ ] [ ] = { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n - 1 , m ) ; return F [ 0 ] [ 0 ] ; } public static void main ( String [ ] args ) { long n = 4 ; long base = fib ( n , mod ) % mod ; long expo = fib ( n , mod - 1 ) % ( mod - 1 ) ; long result = modularexpo ( base , expo , mod ) % mod ; System . out . println ( result ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int cntWays ( int arr [ ] , int n ) { if ( n == 1 ) { return 0 ; } int tot_sum = 0 , sum = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { tot_sum += arr [ i ] ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += arr [ i ] ; if ( sum == tot_sum / 2 ) { ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , - 1 , 1 , - 1 , 1 , - 1 } ; int n = arr . length ; System . out . println ( cntWays ( arr , n ) ) ; } }

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