dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static class Node { int val ; Node next ; Node ( int _val ) { val = _val ; next = null ; } } ; static void getLastTwoPerson ( int n ) { int total = n ; Node head = new Node ( 1 ) ; Node temp = head ; for ( int i = 2 ; i <= n ; i ++ ) { temp . next = new Node ( i ) ; temp = temp . next ; } temp . next = head ; temp = head ; Node del ; while ( total != 2 ) { del = temp . next . next ; temp . next . next = temp . next . next . next ; temp = temp . next ; del = null ; System . gc ( ) ; total -= 1 ; } System . out . print ( temp . val + " ▁ " + temp . next . val ) ; } public static void main ( String [ ] args ) { int n = 2 ; getLastTwoPerson ( n ) ; } }

Accumulator variables: i, total
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . io . * ; class GFG { static int findMinDenomin ( int n ) { return ( ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ) ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( findMinDenomin ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int findContent ( int arr [ ] , int n ) { int content = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { content = __gcd ( content , arr [ i ] ) ; } return content ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int n = 3 ; int arr [ ] = { 9 , 6 , 12 } ; System . out . print ( findContent ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void inverseEqual ( int arr [ ] , int n ) { int [ ] brr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int present_index = arr [ i ] - 1 ; brr [ present_index ] = i + 1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != brr [ i ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } public static void main ( String [ ] args ) { int n = 4 ; int [ ] arr = { 1 , 4 , 3 , 2 } ; inverseEqual ( arr , n ) ; } }

Index/key variables: i, n, present_index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void linearCongruentialMethod ( int Xo , int m , int a , int c , int [ ] randomNums , int noOfRandomNums ) { randomNums [ 0 ] = Xo ; for ( int i = 1 ; i < noOfRandomNums ; i ++ ) { randomNums [ i ] = ( ( randomNums [ i - 1 ] * a ) + c ) % m ; } } public static void main ( String [ ] args ) { int Xo = 5 ; int m = 7 ; int a = 3 ; int c = 3 ; int noOfRandomNums = 10 ; int [ ] randomNums = new int [ noOfRandomNums ] ; linearCongruentialMethod ( Xo , m , a , c , randomNums , noOfRandomNums ) ; for ( int i = 0 ; i < noOfRandomNums ; i ++ ) { System . out . print ( randomNums [ i ] + " ▁ " ) ; } } }

Index/key variables: i, noOfRandomNums
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void multiplicativeCongruentialMethod ( int Xo , int m , int a , int [ ] randomNums , int noOfRandomNums ) { randomNums [ 0 ] = Xo ; for ( int i = 1 ; i < noOfRandomNums ; i ++ ) { randomNums [ i ] = ( randomNums [ i - 1 ] * a ) % m ; } } public static void main ( String [ ] args ) { int Xo = 3 ; int m = 15 ; int a = 7 ; int noOfRandomNums = 10 ; int [ ] randomNums = new int [ noOfRandomNums ] ; multiplicativeCongruentialMethod ( Xo , m , a , randomNums , noOfRandomNums ) ; for ( int i = 0 ; i < noOfRandomNums ; i ++ ) { System . out . print ( randomNums [ i ] + " ▁ " ) ; } } }

Index/key variables: i, noOfRandomNums
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MOD = 1000000007 ; static int power ( int a , int b , int m ) { a %= m ; int res = 1 ; while ( b > 0 ) { if ( b % 2 == 1 ) res = ( ( res % m ) * ( a % m ) ) % m ; a = ( ( a % m ) * ( a % m ) ) % m ; b >>= 1 ; } return res % m ; } static int productOfDivisors ( int p [ ] , int n ) { HashMap < Integer , Integer > prime = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime . containsKey ( p [ i ] ) ) prime . put ( p [ i ] , prime . get ( p [ i ] ) + 1 ) ; else prime . put ( p [ i ] , 1 ) ; } int product = 1 , d = 1 ; for ( Map . Entry < Integer , Integer > itr : prime . entrySet ( ) ) { int val = power ( itr . getKey ( ) , ( itr . getValue ( ) ) * ( itr . getValue ( ) + 1 ) / 2 , MOD ) ; product = ( power ( product , itr . getValue ( ) + 1 , MOD ) * power ( val , d , MOD ) ) % MOD ; d = ( d * ( itr . getValue ( ) + 1 ) ) % ( MOD - 1 ) ; } return product ; } public static void main ( String [ ] args ) { int arr [ ] = { 11 , 11 } ; int n = arr . length ; System . out . println ( productOfDivisors ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void printFractions ( int n ) { for ( int i = 1 ; i < n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { if ( __gcd ( i , j ) == 1 ) { String a = String . valueOf ( i ) ; String b = String . valueOf ( j ) ; System . out . print ( a + " / " + b + " , ▁ " ) ; } } } } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int n = 3 ; printFractions ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int numberOfObjects ( int N , int M ) { int initial = Math . min ( N , M ) ; int last = ( N + M ) / 3 ; return Math . min ( initial , last ) ; } public static void main ( String [ ] args ) { int N = 8 ; int M = 7 ; System . out . println ( numberOfObjects ( N , M ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int SquareRoot ( int num ) { int count = 0 ; for ( int n = 1 ; n <= num ; n += 2 ) { num = num - n ; count += 1 ; if ( num == 0 ) break ; } return count ; } public static void main ( String [ ] args ) { int N = 81 ; System . out . println ( SquareRoot ( N ) ) ; } }

Accumulator variables: count, n
Iterator variables: n
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int gcd ( int x , int y ) { if ( x == 0 ) return y ; return gcd ( y % x , x ) ; } static int findDistinct ( int arr [ ] , int n ) { int maximum = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; if ( n == 1 ) return 1 ; if ( n == 2 ) { return ( maximum / gcd ( arr [ 0 ] , arr [ 1 ] ) ) ; } int k = gcd ( arr [ 0 ] , arr [ 1 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { k = gcd ( k , arr [ i ] ) ; } return ( maximum / k ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 5 } ; int n = arr . length ; System . out . println ( findDistinct ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void findLocalMaximaMinima ( int n , int [ ] arr ) { Vector < Integer > mx = new Vector < Integer > ( ) ; Vector < Integer > mn = new Vector < Integer > ( ) ; if ( arr [ 0 ] > arr [ 1 ] ) mx . add ( 0 ) ; else if ( arr [ 0 ] < arr [ 1 ] ) mn . add ( 0 ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( ( arr [ i - 1 ] > arr [ i ] ) && ( arr [ i ] < arr [ i + 1 ] ) ) mn . add ( i ) ; else if ( ( arr [ i - 1 ] < arr [ i ] ) && ( arr [ i ] > arr [ i + 1 ] ) ) mx . add ( i ) ; } if ( arr [ n - 1 ] > arr [ n - 2 ] ) mx . add ( n - 1 ) ; else if ( arr [ n - 1 ] < arr [ n - 2 ] ) mn . add ( n - 1 ) ; if ( mx . size ( ) > 0 ) { System . out . print ( " Points ▁ of ▁ Local ▁ " + " maxima ▁ are ▁ : ▁ " ) ; for ( Integer a : mx ) System . out . print ( a + " ▁ " ) ; System . out . println ( ) ; } else System . out . println ( " There ▁ are ▁ no ▁ points ▁ " + " of ▁ Local ▁ Maxima ▁ " ) ; if ( mn . size ( ) > 0 ) { System . out . print ( " Points ▁ of ▁ Local ▁ " + " minima ▁ are ▁ : ▁ " ) ; for ( Integer a : mn ) System . out . print ( a + " ▁ " ) ; System . out . println ( ) ; } else System . out . println ( " There ▁ are ▁ no ▁ points ▁ of ▁ " + " Local ▁ Maxima ▁ " ) ; } public static void main ( String [ ] args ) { int N = 9 ; int arr [ ] = { 10 , 20 , 15 , 14 , 13 , 25 , 5 , 4 , 3 } ; findLocalMaximaMinima ( N , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: a, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int power ( int a , int b ) { if ( b == 0 ) return 1 ; if ( b == 1 ) return a ; int tmp = power ( a , b / 2 ) ; int result = tmp * tmp ; if ( b % 2 == 1 ) result *= a ; return result ; } static boolean check ( int n ) { int temp = n ; while ( temp > 0 ) { int last_digit = temp % 10 ; if ( last_digit == 0 last_digit == 1 ) return false ; if ( n % last_digit == 0 ) return false ; temp = temp / 10 ; } return true ; } static void solve ( int n ) { int L = power ( 10 , n - 1 ) ; int R = power ( 10 , n ) - 1 ; int flag = 0 ; for ( int i = L ; i <= R ; i ++ ) { boolean answer = check ( i ) ; if ( answer == true ) { System . out . println ( i ) ; flag ++ ; break ; } } if ( flag == 0 ) System . out . println ( " - 1" ) ; } public static void main ( String [ ] args ) { int N = 4 ; solve ( N ) ; } }

Accumulator variables: flag, i, result
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void costOfSubsequence ( int N , int [ ] arr , int [ ] costArray ) { int i , temp ; int cost = 0 ; Set < Integer > removedElements = new HashSet < Integer > ( ) ; int ans = 0 ; for ( i = 1 ; i < ( N - 1 ) ; i ++ ) { temp = arr [ i ] ; if ( ( ( arr [ i - 1 ] < temp ) && ( temp < arr [ i + 1 ] ) ) || ( ( arr [ i - 1 ] > temp ) && ( temp > arr [ i + 1 ] ) ) ) { removedElements . add ( temp ) ; } } for ( i = 0 ; i < ( N ) ; i ++ ) { temp = arr [ i ] ; if ( ! ( removedElements . contains ( temp ) ) ) { ans += arr [ i ] ; } else { cost += costArray [ i ] ; } } System . out . print ( ans + " , ▁ " ) ; System . out . print ( cost ) ; } public static void main ( String [ ] args ) { int N ; N = 4 ; int [ ] arr = { 1 , 3 , 4 , 2 } ; int [ ] costArray = { 0 , 1 , 0 , 0 } ; costOfSubsequence ( N , arr , costArray ) ; } }

Index/key variables: i
Accumulator variables: ans, cost, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxN = 100000000 ; static Vector < Integer > prime = new Vector < Integer > ( ) ; static void sieve ( int n ) { boolean [ ] check = new boolean [ 1000007 ] ; for ( int i = 0 ; i < 1000007 ; i ++ ) check [ i ] = false ; int i , j ; check [ 0 ] = false ; check [ 1 ] = true ; check [ 2 ] = false ; for ( i = 4 ; i <= n ; i += 2 ) check [ i ] = true ; for ( i = 3 ; i * i <= n ; i += 2 ) if ( ! check [ i ] ) { for ( j = i * i ; j <= n ; j += 2 * i ) check [ j ] = true ; } prime . add ( 2 ) ; for ( i = 3 ; i <= n ; i += 2 ) if ( ! check [ i ] ) prime . add ( i ) ; return ; } static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } static int count ( int a [ ] , int n , int m ) { int [ ] parity = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) parity [ i ] = 0 ; for ( int i = 1 ; i < ( 1 << n ) ; i ++ ) { int mult = 1 ; for ( int j = 0 ; j < n ; j ++ ) if ( ( i & ( 1 << j ) ) != 0 ) mult *= a [ j ] ; parity [ countSetBits ( i ) & 1 ] += ( m / mult ) ; } return parity [ 1 ] - parity [ 0 ] ; } static int countRelPrime ( int n , int m ) { int [ ] a = new int [ 20 ] ; int i = 0 , j = 0 ; int pz = prime . size ( ) ; while ( n != 1 && i < pz ) { if ( ( int ) prime . get ( i ) * ( int ) prime . get ( i ) > n ) break ; if ( n % prime . get ( i ) == 0 ) { a [ j ] = ( int ) prime . get ( i ) ; j ++ ; } while ( n % prime . get ( i ) == 0 ) n /= prime . get ( i ) ; i ++ ; } if ( n != 1 ) { a [ j ] = n ; j ++ ; } return m - count ( a , j , m ) ; } static void countRelPrimeInRange ( int n , int l , int r ) { sieve ( ( int ) Math . sqrt ( maxN ) ) ; int result = countRelPrime ( n , r ) - countRelPrime ( n , l - 1 ) ; System . out . println ( result ) ; } public static void main ( String [ ] args ) { int N = 7 , L = 3 , R = 9 ; countRelPrimeInRange ( N , L , R ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, mult, n
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void find_Xor ( int arr [ ] , pair query [ ] , int N , int Q ) { for ( int i = 1 ; i < N ; i ++ ) { arr [ i ] = arr [ i ] ^ arr [ i - 1 ] ; } int ans = 0 ; for ( int i = 0 ; i < Q ; i ++ ) { if ( query [ i ] . first == 0 ) ans = arr [ query [ i ] . second ] ; else ans = arr [ query [ i ] . first - 1 ] ^ arr [ query [ i ] . second ] ; System . out . print ( ans + "NEW_LINE"); } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 4 , 5 , 1 , 1 , 5 , 3 } ; int N = 8 ; int Q = 2 ; pair query [ ] = { new pair ( 1 , 4 ) , new pair ( 3 , 7 ) } ; find_Xor ( arr , query , N , Q ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
class GFG { static int [ ] DiStirngMatch ( String Str ) { int N = Str . length ( ) ; int [ ] arr = new int [ N + 1 ] ; int START = 0 , END = N ; for ( int i = 0 ; i < N ; i ++ ) { if ( Str . charAt ( i ) == ' I ' ) arr [ i ] = START ++ ; if ( Str . charAt ( i ) == ' D ' ) arr [ i ] = END -- ; } arr [ N ] = START ; return arr ; } public static void main ( String [ ] args ) { String Str = " IDID " ; int N = Str . length ( ) ; int [ ] ptr = DiStirngMatch ( Str ) ; for ( int i = 0 ; i <= N ; i ++ ) System . out . print ( ptr [ i ] + " ▁ " ) ; } }

Index/key variables: N, i
Accumulator variables: END, START, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean IsPrime ( int i ) { if ( i % 2 == 0 && i != 2 ) return false ; else { for ( int j = 3 ; j <= Math . sqrt ( i ) ; j += 2 ) { if ( i % j == 0 ) return false ; } return true ; } } public static void main ( String [ ] args ) { int c = 0 ; int N = 72 ; for ( int i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( IsPrime ( i ) ) { if ( N % i == 0 ) { c ++ ; if ( IsPrime ( N / i ) && i != ( N / i ) ) c ++ ; } } } System . out . print ( Math . pow ( 2 , c ) - 1 ) ; } }

Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void find_seq ( int arr [ ] , int m , int n ) { int b [ ] = new int [ n ] ; int x = 0 ; b [ 0 ] = x ; for ( int i = 0 ; i < n - 1 ; i ++ ) { b [ i + 1 ] = x + arr [ i ] + b [ i ] ; } int mn = n ; for ( int i = 0 ; i < n ; i ++ ) { mn = Math . min ( mn , b [ i ] ) ; } x = 1 - mn ; for ( int i = 0 ; i < n ; i ++ ) { b [ i ] += x ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( b [ i ] + " ▁ " ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { int N = 3 ; int arr [ ] = new int [ ] { - 2 , 1 } ; int M = arr . length ; find_seq ( arr , M , N ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void isEqualFactors ( int N ) { int ev_count = 0 , od_count = 0 ; for ( int i = 1 ; i <= Math . sqrt ( N ) + 1 ; i ++ ) { if ( N % i == 0 ) { if ( i == N / i ) { if ( i % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; } else { if ( i % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; if ( ( N / i ) % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; } } } if ( ev_count == od_count ) System . out . print ( " YES " + "NEW_LINE"); else System . out . print ( " NO " + "NEW_LINE"); } public static void main ( String [ ] args ) { int N = 10 ; isEqualFactors ( N ) ; } }

Accumulator variables: ev_count, i, od_count
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static void isEqualFactors ( int N ) { if ( ( N % 2 == 0 ) && ( N % 4 != 0 ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } public static void main ( String args [ ] ) { int N = 10 ; isEqualFactors ( N ) ; N = 125 ; isEqualFactors ( N ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int count_crazy_primes ( int L , int R ) { int prime [ ] = new int [ R + 1 ] ; int countPrime [ ] = new int [ R + 1 ] ; int freqPrime [ ] = new int [ R + 1 ] ; prime [ 0 ] = 1 ; prime [ 1 ] = 1 ; for ( int p = 2 ; p * p <= R ; p ++ ) { if ( prime [ p ] == 0 ) { for ( int i = p * p ; i <= R ; i += p ) prime [ i ] = 1 ; } } for ( int i = 1 ; i <= R ; i ++ ) { countPrime [ i ] = countPrime [ i - 1 ] ; if ( prime [ i ] != 0 ) { countPrime [ i ] ++ ; } } for ( int i = 1 ; i <= R ; i ++ ) { freqPrime [ i ] = freqPrime [ i - 1 ] ; if ( prime [ countPrime [ i ] ] != 0 ) { freqPrime [ i ] ++ ; } } return ( freqPrime [ R ] - freqPrime [ L - 1 ] ) ; } public static void main ( String [ ] args ) { int L = 4 , R = 12 ; System . out . println ( count_crazy_primes ( L , R ) ) ; } }

Index/key variables: R, i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findNumbers ( int n , int b ) { double largest = Math . pow ( b , n ) - 1 ; System . out . println ( largest ) ; } public static void main ( String [ ] args ) { int N = 2 , B = 5 ; findNumbers ( N , B ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static void maximizedArray ( int arr [ ] , int N ) { int num , i = 0 ; for ( int l = N ; l > 0 ; l -- ) { num = arr [ i ] ; int one = 0 ; int zero = 0 ; while ( num != 0 ) { if ( num % 2 == 0 ) { zero ++ ; } else { one ++ ; } num = num >> 1 ; } for ( int j = zero ; j < ( one + zero ) ; j ++ ) { num += ( 1 << j ) ; } System . out . print ( num ) ; i ++ ; if ( N > 0 ) System . out . print ( " , ▁ " ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 8 , 15 , 9 , 10 , 14 } ; int N = arr . length ; maximizedArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, j, l, num, one, zero
Iterator variables: j, l
Class/struct names: GFG
Java program:
class GFG { static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static int findGCD ( int arr [ ] , int n ) { int gcd = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { gcd = __gcd ( arr [ i ] , gcd ) ; if ( gcd == 1 ) { return 1 ; } } return gcd ; } static int findLCM ( int arr [ ] , int n ) { int lcm = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { lcm = ( ( ( arr [ i ] * lcm ) ) / ( __gcd ( arr [ i ] , lcm ) ) ) ; } return lcm ; } static void findRatio ( int arr [ ] , int n ) { int gcd = findGCD ( arr , n ) ; int lcm = findLCM ( arr , n ) ; System . out . print ( ( lcm / gcd ) ) ; System . out . print ( " : 1" ) ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { 6 , 12 , 36 } ; int N = 3 ; findRatio ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void compute ( int a [ ] , int N , int K ) { Map < Long , Long > eqVal = new HashMap < Long , Long > ( ) ; long maxX = 0 ; for ( int i = 0 ; i < N ; i ++ ) { long val = a [ i ] % K ; val = ( val == 0 ? 0 : K - val ) ; if ( val == 0 ) continue ; if ( eqVal . containsKey ( val ) ) { long numVal = eqVal . get ( val ) ; maxX = Math . max ( maxX , val + ( K * numVal ) ) ; eqVal . put ( val , eqVal . getOrDefault ( val , 0l ) + 1l ) ; } else { eqVal . put ( val , 1l ) ; maxX = Math . max ( maxX , val ) ; } } System . out . println ( maxX == 0 ? 0 : maxX + 1 ) ; } public static void main ( String [ ] args ) { int K = 3 ; int a [ ] = { 1 , 2 , 2 , 18 } ; int N = a . length ; compute ( a , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void sumOfTheArrayForQuery ( int [ ] A , int N , int [ ] X , int [ ] Y , int Q ) { int sum = 0 ; HashMap < Integer , Integer > count = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; if ( count . containsKey ( A [ i ] ) ) { count . replace ( A [ i ] , count . get ( A [ i ] ) + 1 ) ; } else { count . put ( A [ i ] , 1 ) ; } } for ( int i = 0 ; i < Q ; i ++ ) { int x = X [ i ] , y = Y [ i ] ; if ( count . containsKey ( X [ i ] ) ) { sum -= count . get ( X [ i ] ) * X [ i ] ; sum += count . get ( X [ i ] ) * Y [ i ] ; } if ( count . containsKey ( Y [ i ] ) && count . containsKey ( X [ i ] ) ) { count . replace ( Y [ i ] , count . get ( Y [ i ] ) + count . get ( X [ i ] ) ) ; } if ( count . containsKey ( X [ i ] ) ) { count . replace ( X [ i ] , 0 ) ; } System . out . print ( sum + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 1 , 3 , 2 } ; int X [ ] = { 2 , 3 , 5 } ; int Y [ ] = { 3 , 1 , 2 } ; int N = arr . length ; int Q = X . length ; sumOfTheArrayForQuery ( arr , N , X , Y , Q ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static int maxOR ( int [ ] arr , int n ) { int max_value = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . max ( ans , ( max_value arr [ i ] ) ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { 3 , 6 , 8 , 16 } ; int n = 4 ; System . out . print ( maxOR ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void IncrementFactors ( int count [ ] , int val ) { for ( int i = 1 ; i * i <= val ; i ++ ) { if ( val % i == 0 ) { if ( i == val / i ) { count [ i ] ++ ; } else { count [ i ] ++ ; count [ val / i ] ++ ; } } } } static void generateArr ( int A [ ] , int n ) { int [ ] B = new int [ n ] ; int maxi = Arrays . stream ( A ) . max ( ) . getAsInt ( ) ; int count [ ] = new int [ maxi + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { B [ i ] = count [ A [ i ] ] ; IncrementFactors ( count , A [ i ] ) ; } printArr ( B , n ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 1 , 28 , 4 , 2 , 6 , 7 } ; int n = arr . length ; generateArr ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static ArrayList < Integer > SieveOfEratosthenes ( int n ) { boolean [ ] prime = new boolean [ 2 * n + 1 ] ; Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p <= 2 * n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= 2 * n ; i += p ) prime [ i ] = false ; } } ArrayList < Integer > primes = new ArrayList < > ( ) ; for ( int p = 2 ; p <= 2 * n ; p ++ ) if ( prime [ p ] ) primes . add ( p ) ; return primes ; } static int minChanges ( int [ ] arr ) { int n = arr . length ; int ans = 0 ; int maxi = arr [ 0 ] ; for ( int i = 1 ; i < arr . length ; i ++ ) maxi = Math . max ( maxi , arr [ i ] ) ; ArrayList < Integer > primes = SieveOfEratosthenes ( maxi ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = - 1 ; for ( int j = 0 ; j < primes . size ( ) ; j ++ ) { if ( arr [ i ] == primes . get ( j ) ) { x = j ; break ; } else if ( arr [ i ] < primes . get ( j ) ) { x = j ; break ; } } int minm = Math . abs ( primes . get ( x ) - arr [ i ] ) ; if ( x > 1 ) { minm = Math . min ( minm , Math . abs ( primes . get ( x - 1 ) - arr [ i ] ) ) ; } ans += minm ; } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 25 , 13 , 6 , 20 } ; System . out . println ( minChanges ( arr ) ) ; } }

Index/key variables: i, p
Accumulator variables: ans, i, j, p
Iterator variables: i, j, p
Class/struct names: GFG