dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void elementsCoprimeWithArr ( int A [ ] , int N , int L , int R ) { HashSet < Integer > S = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int curr_ele = A [ i ] ; for ( int j = 1 ; j <= Math . sqrt ( curr_ele ) + 1 ; j ++ ) { if ( curr_ele % j == 0 ) { S . add ( j ) ; S . add ( curr_ele / j ) ; } } } HashSet < Integer > store = new HashSet < Integer > ( ) ; for ( int i = L ; i <= R ; i ++ ) store . add ( i ) ; S . remove ( 1 ) ; for ( int it : S ) { int ele = it ; int index = 1 ; while ( index * ele <= R ) { store . remove ( index * ele ) ; index ++ ; } } for ( int i : store ) { System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 } ; int L = 1 , R = 10 ; int N = arr . length ; elementsCoprimeWithArr ( arr , N , L , R ) ; } }

Index/key variables: i
Accumulator variables: i, index, j
Iterator variables: i, it, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxSum ( int [ ] [ ] matrix ) { int r = matrix . length ; int c = matrix [ 0 ] . length ; int sum = 0 ; int mini = Integer . MAX_VALUE ; int count = 0 ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { int k = matrix [ i ] [ j ] ; mini = Math . min ( mini , Math . abs ( k ) ) ; if ( k < 0 ) count ++ ; sum += Math . abs ( k ) ; } } if ( count % 2 == 0 ) { return sum ; } else { return ( sum - 2 * mini ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] matrix = { { 2 , - 2 } , { - 2 , 2 } } ; System . out . print ( maxSum ( matrix ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int lastPositiveElement ( int [ ] arr ) { int N = arr . length ; if ( N == 1 ) return arr [ 0 ] ; int greatest = - 1 , secondGreatest = - 1 ; for ( int x : arr ) { if ( x >= greatest ) { secondGreatest = greatest ; greatest = x ; } else if ( x >= secondGreatest ) { secondGreatest = x ; } } return greatest - secondGreatest ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 4 , 7 } ; System . out . print ( lastPositiveElement ( arr ) ) ; } }

Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void updateArray ( int [ ] arr , int K ) { int sum = 0 ; ArrayList < Integer > res = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] < K ) { sum += arr [ i ] ; } else { if ( sum != 0 ) { res . add ( sum ) ; } sum = 0 ; res . add ( arr [ i ] ) ; } } if ( sum != 0 ) res . add ( sum ) ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) System . out . print ( res . get ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 200 , 6 , 36 , 612 , 121 , 66 , 63 , 39 , 668 , 108 } ; int K = 100 ; updateArray ( arr , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { @ SuppressWarnings ( " unchecked " ) static Vector < Integer > [ ] adj = new Vector [ 100000 ] ; static Vector < Integer > setNum = new Vector < Integer > ( 100000 ) ; static void addEdge ( int a1 , int a2 ) { adj [ a1 ] . add ( a2 ) ; adj [ a2 ] . add ( a1 ) ; } static void toBipartite ( int N ) { for ( int i = 0 ; i < 100000 ; i ++ ) setNum . add ( - 1 ) ; Queue < Integer > q = new LinkedList < > ( ) ; q . add ( 0 ) ; setNum . set ( 0 , 0 ) ; while ( ! q . isEmpty ( ) ) { int v = q . peek ( ) ; q . remove ( ) ; for ( int u : adj [ v ] ) { if ( setNum . get ( u ) == - 1 ) { setNum . set ( u , setNum . get ( v ) ^ 1 ) ; q . add ( u ) ; } } } } static void pathLengthQuery ( int A , int B ) { if ( setNum . get ( A ) == setNum . get ( B ) ) { System . out . println ( " Odd " ) ; } else { System . out . println ( " Even " ) ; } } public static void main ( String [ ] args ) { for ( int i = 0 ; i < 100000 ; i ++ ) adj [ i ] = new Vector < Integer > ( ) ; int N = 7 ; addEdge ( 0 , 1 ) ; addEdge ( 0 , 2 ) ; addEdge ( 1 , 3 ) ; addEdge ( 3 , 4 ) ; addEdge ( 3 , 5 ) ; addEdge ( 2 , 6 ) ; toBipartite ( N ) ; pathLengthQuery ( 4 , 2 ) ; pathLengthQuery ( 0 , 4 ) ; } }

Index/key variables: a1, a2, i, v
Accumulator variables: i
Iterator variables: i, u
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int highestPowerof2 ( int n ) { int p = ( int ) Math . floor ( Math . log ( n ) / Math . log ( 2.0 ) ) ; if ( p % 2 == 0 ) p -= 1 ; int result = ( int ) ( Math . pow ( 2 , p ) ) ; return result ; } static int minStep ( int N , int X ) { if ( N % 2 != 0 && X == 0 ) return - 1 ; int size = 0 ; while ( X < N ) { N -= highestPowerof2 ( N ) ; size += 1 ; } if ( N != 0 ) size += 1 ; return size ; } public static void main ( String [ ] args ) { int N = 11 ; int X = 2 ; System . out . println ( minStep ( N , X ) ) ; } }

Accumulator variables: N, p, size
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static String checkSameDigits ( int N ) { int digit = N % 10 ; while ( N != 0 ) { int current_digit = N % 10 ; N = N / 10 ; if ( current_digit != digit ) { return " No " ; } } return " Yes " ; } public static void main ( String args [ ] ) throws IOException { int N = 222 ; System . out . println ( checkSameDigits ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int positionAfterKJumps ( int X , int Y , int K ) { int addY = Y * ( K / 2 ) ; int reduceX = - 1 * X * ( K / 2 + K % 2 ) ; return addY + reduceX ; } public static void main ( String [ ] args ) { int X = 2 , Y = 5 , K = 3 ; System . out . print ( positionAfterKJumps ( X , Y , K ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findMaxK ( int N ) { int K = N ; for ( int i = N - 1 ; i >= 0 ; i -- ) { K &= i ; if ( K == 0 ) { return i ; } } return 0 ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( findMaxK ( N ) ) ; } }

Accumulator variables: K, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countPairs ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( arr [ j ] % arr [ i ] == 0 ) && ( j + 1 ) % ( i + 1 ) == 0 && ( arr [ j ] / arr [ i ] == ( j + 1 ) / ( i + 1 ) ) ) { count ++ ; } } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , - 2 , 4 , 20 , 25 , - 6 } ; int n = arr . length ; System . out . print ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long factorial ( int n ) { long ans = 1 ; while ( n >= 1 ) { ans *= n ; n -- ; } return ans ; } static void Binary_Num ( int n , int k ) { long num_even , num_odd ; if ( n - k - 1 >= 0 && k - 1 >= 0 ) { num_even = factorial ( n - 2 ) / ( factorial ( k - 1 ) * factorial ( n - k - 1 ) ) ; } else { num_even = 0 ; } if ( k - 2 >= 0 ) { num_odd = factorial ( n - 2 ) / ( factorial ( k - 2 ) * factorial ( n - k ) ) ; } else { num_odd = 0 ; } System . out . println ( num_even + " ▁ " + num_odd ) ; } public static void main ( String [ ] args ) { int N = 9 , K = 6 ; Binary_Num ( N , K ) ; } }

Accumulator variables: ans, n
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void findSumOfAllSubsets ( int [ ] arr , int n , int k ) { int factorial_N = 1 , factorial_d = 1 , factorial_D = 1 ; for ( int i = 1 ; i <= n - 1 ; i ++ ) factorial_N *= i ; for ( int i = 1 ; i <= k - 1 ; i ++ ) factorial_d *= i ; for ( int i = 1 ; i <= n - k ; i ++ ) factorial_D *= i ; int freq = factorial_N / ( factorial_d * factorial_D ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; sum = sum * freq ; System . out . println ( " Sum ▁ of ▁ all ▁ subsets ▁ of ▁ size ▁ = ▁ " + k + " ▁ is ▁ = > ▁ " + sum ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 5 } ; int n = 4 , k = 2 ; findSumOfAllSubsets ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: factorial_D, factorial_N, factorial_d, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maximumTripletXOR ( int A , int B , int C ) { int ans = 0 ; for ( int i = 30 ; i >= 0 ; i -- ) { int cur = 1 << i ; if ( A >= cur ) { ans += cur ; A -= cur ; } else if ( B >= cur ) { ans += cur ; B -= cur ; } else if ( C >= cur ) { ans += cur ; C -= cur ; } } return ans ; } public static void main ( String [ ] args ) { int A = 6 ; int B = 2 ; int C = 10 ; System . out . print ( maximumTripletXOR ( A , B , C ) ) ; } }

Accumulator variables: A, B, C, ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int intCount ( int X , int K ) { int ans = 0 ; for ( int z = 0 ; z < Math . pow ( 10 , K ) ; z += ( Math . pow ( 10 , K ) - 1 ) / 9 ) { if ( z > X ) break ; ans += ( ( X - z ) / Math . pow ( 10 , K ) + 1 ) ; } return ans ; } static int intCountInRange ( int L , int R , int K ) { return ( intCount ( R , K ) - intCount ( L - 1 , K ) ) ; } public static void main ( String [ ] args ) { int L = 49 ; int R = 101 ; int K = 2 ; System . out . print ( intCountInRange ( L , R , K ) ) ; } }

Accumulator variables: ans, z
Iterator variables: z
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countQuadruples ( int A [ ] , int N ) { int ans = 0 ; HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( freq . containsKey ( A [ i ] ) ) ans += freq . get ( A [ i ] ) ; for ( int j = 0 ; j < i ; j ++ ) { for ( int k = 0 ; k < j ; k ++ ) { if ( freq . containsKey ( A [ i ] * A [ j ] * A [ k ] ) ) { freq . put ( A [ i ] * A [ j ] * A [ k ] , freq . get ( A [ i ] * A [ j ] * A [ k ] ) + 1 ) ; } else { freq . put ( A [ i ] * A [ j ] * A [ k ] , 1 ) ; } } } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 2 , 2 , 7 , 40 , 160 } ; int N = arr . length ; System . out . print ( countQuadruples ( 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 . io . * ; class GFG { static int MAXN = 10000000 ; static boolean can ( int Mid , int X , int Y , int A , int B ) { int p1 = X - Mid * B ; int p2 = Y - Mid * B ; if ( p1 < 0 p2 < 0 ) { return false ; } int k = A - B ; if ( k == 0 ) { return true ; } int val = p1 / k + p2 / k ; if ( val >= Mid ) { return true ; } return false ; } static int maxPossibleMoves ( int X , int Y , int A , int B ) { int ans = 0 ; int L = 1 , R = MAXN ; while ( L <= R ) { int Mid = ( L + R ) / 2 ; if ( can ( Mid , X , Y , A , B ) ) { L = Mid + 1 ; ans = Math . max ( ans , Mid ) ; } else { R = Mid - 1 ; } } return ans ; } public static void main ( String [ ] args ) { int X = 10 , Y = 12 , A = 2 , B = 5 ; if ( A < B ) { int temp = A ; A = B ; B = temp ; } System . out . println ( maxPossibleMoves ( X , Y , A , B ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printFactors ( int n ) { for ( int i = 2 ; i <= ( int ) Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { int d1 = i , d2 = n ; while ( d2 % d1 == 0 ) { d2 = d2 / d1 ; } if ( d1 > 1 && d2 > 1 ) { System . out . print ( d1 + " , ▁ " + d2 ) ; return ; } } } System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { int N = 10 ; printFactors ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final int MAXN = 100000 ; static int [ ] bit1 = new int [ MAXN ] ; static int [ ] bit2 = new int [ MAXN ] ; static void update ( int idx , int val , int [ ] bit ) { while ( idx < bit . length ) { bit [ idx ] += val ; idx += idx & ( - idx ) ; } } static int query ( int idx , int [ ] bit ) { int res = 0 ; while ( idx > 0 ) { res += bit [ idx ] ; idx -= idx & ( - idx ) ; } return res ; } static void buildFenwickTree ( int a [ ] , int n ) { for ( int i = 1 ; i <= n ; i ++ ) { update ( i , a [ i - 1 ] , bit1 ) ; update ( i , a [ i - 1 ] * a [ i - 1 ] , bit2 ) ; } } static void pairwiseProductSum ( int a [ ] , int l , int r ) { int sum , e , q ; e = query ( r , bit1 ) - query ( l - 1 , bit1 ) ; e = e * e ; q = query ( r , bit2 ) - query ( l - 1 , bit2 ) ; sum = ( e - q ) / 2 ; System . out . print ( sum + "NEW_LINE"); } static void updateArray ( int [ ] a , int p , int x ) { update ( p , - a [ p - 1 ] , bit1 ) ; update ( p , x , bit1 ) ; update ( p , - a [ p - 1 ] * a [ p - 1 ] , bit2 ) ; update ( p , x * x , bit2 ) ; a [ p - 1 ] = x ; } static void solveQueries ( int [ ] a , int n , int Q , int query [ ] [ ] ) { buildFenwickTree ( a , n ) ; for ( int i = 0 ; i < Q ; i ++ ) { if ( query [ i ] [ 0 ] == 1 ) pairwiseProductSum ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; else updateArray ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; } } public static void main ( String [ ] args ) { int A [ ] = { 5 , 7 , 2 , 3 , 1 } ; int N = A . length ; int Q = 3 ; int query [ ] [ ] = { { 1 , 1 , 3 } , { 2 , 2 , 5 } , { 1 , 2 , 5 } } ; solveQueries ( A , N , Q , query ) ; } }

Index/key variables: MAXN, i, idx
Accumulator variables: i, idx, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countTriplets ( int arr [ ] , int n ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) odd ++ ; else even ++ ; } int c1 = odd * ( even * ( even - 1 ) ) / 2 ; int c2 = ( odd * ( odd - 1 ) * ( odd - 2 ) ) / 6 ; return c1 + c2 ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 6 , 4 , 5 , 10 , 1 , 7 } ; int n = arr . length ; int ans = countTriplets ( arr , n ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int maxUniqueElements ( int [ ] Arr , int N ) { HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . containsKey ( Arr [ i ] ) ) { mp . put ( Arr [ i ] , mp . get ( Arr [ i ] ) + 1 ) ; } else { mp . put ( Arr [ i ] , 1 ) ; } } int cnt = 0 ; for ( Map . Entry < Integer , Integer > entry : mp . entrySet ( ) ) { if ( ( entry . getValue ( ) ) % 2 == 0 ) { cnt ++ ; } } int ans = mp . size ( ) ; if ( cnt % 2 == 1 ) { ans -- ; } return ans ; } public static void main ( String [ ] args ) { int N = 5 ; int A [ ] = { 1 , 2 , 1 , 3 , 7 } ; System . out . println ( maxUniqueElements ( A , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static long countCells ( int n , int m , int s ) { int mx1 = - 1 ; int cont1 = 0 ; for ( int i = 0 ; i < s && i < n ; ++ i ) { int aux = ( n - ( i + 1 ) ) / s + 1 ; if ( aux > mx1 ) { mx1 = cont1 = aux ; } else if ( aux == mx1 ) cont1 += aux ; } int mx2 = - 1 ; int cont2 = 0 ; for ( int i = 0 ; i < s && i < m ; ++ i ) { int aux = ( m - ( i + 1 ) ) / s + 1 ; if ( aux > mx2 ) mx2 = cont2 = aux ; else if ( aux == mx2 ) cont2 += aux ; } return ( long ) ( cont1 * cont2 ) ; } public static void main ( String args [ ] ) { int N = 5 , M = 5 , K = 2 ; System . out . println ( countCells ( N , M , K ) ) ; } }

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

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static int minSumDifference ( int ar [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += ar [ i ] ; int rem = sum % n ; return rem * ( n - rem ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 3 , 6 , 8 , 5 , 2 , 1 , 11 , 7 , 10 , 4 } ; int N = arr . length ; System . out . println ( minSumDifference ( 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 int m = 1000000007 ; static int power ( int x , int y ) { int res = 1 ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % m ; y = y >> 1 ; x = ( x * x ) % m ; } return res ; } static int countNDigitNumber ( int N ) { int ne = N / 2 + N % 2 ; int no = ( int ) Math . floor ( N / 2 ) ; return power ( 4 , ne ) * power ( 5 , no ) ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( countNDigitNumber ( N ) % m ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minSteps ( int N ) { int count = 1 , res = 0 ; for ( int i = 1 ; i <= N ; i += count ) { res = Math . max ( res , count ) ; count ++ ; } return res ; } public static void main ( String [ ] args ) { int N = 6 ; System . out . println ( minSteps ( N ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . Math ; class GFG { static int minSteps ( int N ) { int res = ( ( int ) Math . sqrt ( 1 + 8 * N ) - 1 ) / 2 ; return res ; } public static void main ( String [ ] args ) { int N = 6 ; System . out . println ( minSteps ( N ) + "NEW_LINE"); } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void oppositeFaceOfDice ( int N ) { int ans = 7 - N ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int N = 2 ; oppositeFaceOfDice ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countReachablePoints ( int X , int Y , int L , int R ) { int diff_arr [ ] = new int [ 100000 ] ; int count = 0 ; diff_arr [ X ] = 1 ; diff_arr [ X + 1 ] = - 1 ; for ( int i = X ; i <= Y ; i ++ ) { diff_arr [ i ] += diff_arr [ i - 1 ] ; if ( diff_arr [ i ] >= 1 ) { diff_arr [ i + L ] += 1 ; diff_arr [ i + R + 1 ] -= 1 ; count ++ ; } } return count ; } public static void main ( String [ ] args ) { int X = 3 , Y = 12 , L = 2 , R = 3 ; System . out . print ( countReachablePoints ( X , Y , L , R ) ) ; } }

Index/key variables: X, i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node next ; } ; static Node newNode ( int data ) { Node new_node = new Node ( ) ; new_node . data = data ; new_node . next = null ; return new_node ; } static Node reverse ( Node head ) { Node prev = null ; Node current = head ; Node next ; while ( current != null ) { next = current . next ; current . next = prev ; prev = current ; current = next ; } return prev ; } static Node multiplyHelp ( Node head , int M ) { Node res = head ; Node prev = null ; int carry = 0 , product = 1 ; while ( head != null ) { product = head . data * M ; product += carry ; carry = product / 10 ; head . data = product % 10 ; prev = head ; head = head . next ; } if ( carry > 0 ) prev . next = newNode ( carry ) ; return res ; } static Node multiply ( Node head , int M ) { head = reverse ( head ) ; head = multiplyHelp ( head , M ) ; return reverse ( head ) ; } static void printList ( Node node ) { while ( node != null ) { System . out . print ( node . data ) ; node = node . next ; } } public static void main ( String [ ] args ) { Node head = newNode ( 1 ) ; head . next = newNode ( 2 ) ; head . next . next = newNode ( 7 ) ; head . next . next . next = newNode ( 3 ) ; int M = 3 ; head = multiply ( head , M ) ; printList ( head ) ; } }

Accumulator variables: product
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int [ ] s = new int [ 11 ] ; static void sieveOfEratosthenes ( int N ) { boolean [ ] prime = new boolean [ N + 1 ] ; for ( int i = 2 ; i < N + 1 ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i < N + 1 ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j < N / i + 1 ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } static int generatePrimeFactors ( int N ) { int curr = s [ N ] ; HashMap < Integer , Integer > cnt = new HashMap < > ( ) ; cnt . put ( s [ N ] , 1 ) ; while ( N > 1 ) { N /= s [ N ] ; if ( N != 0 && s [ N ] != 0 ) if ( ! cnt . containsKey ( s [ N ] ) ) cnt . put ( s [ N ] , 1 ) ; else cnt . put ( s [ N ] , cnt . get ( s [ N ] ) + 1 ) ; } if ( cnt . containsKey ( 0 ) ) cnt . remove ( 0 ) ; int totfactor = 1 ; for ( Map . Entry < Integer , Integer > i : cnt . entrySet ( ) ) totfactor *= i . getValue ( ) + 1 ; return totfactor ; } static int countTriplets ( int N ) { int CountTriplet = 0 ; for ( int z = 1 ; z < N + 1 ; z ++ ) { int p = generatePrimeFactors ( N - z ) ; if ( p > 1 ) CountTriplet += p ; } return CountTriplet + 1 ; } public static void main ( String [ ] args ) { int N = 10 ; sieveOfEratosthenes ( N ) ; System . out . print ( countTriplets ( N ) ) ; } }

Index/key variables: N, i
Accumulator variables: CountTriplet, N, i, j, totfactor, z
Iterator variables: i, j, z
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { public static int minimumSubarray ( int [ ] arr , int n , int m ) { int [ ] mapu = new int [ m + 1 ] ; Arrays . fill ( mapu , 0 ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mapu [ arr [ i ] ] ++ ; if ( mapu [ arr [ i ] ] == ( n / m ) + 1 ) c ++ ; } if ( c == 0 ) return 0 ; int ans = n ; int l = 0 , r = 0 ; while ( r < n ) { if ( -- mapu [ arr [ r ] ] == ( n / m ) ) c -- ; if ( c == 0 ) { while ( l <= r && c == 0 ) { ans = Math . min ( ans , r - l + 1 ) ; if ( ++ mapu [ arr [ l ] ] > ( n / m ) ) c ++ ; l ++ ; } } r ++ ; } return ans ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 1 , 2 , 1 , 1 , 2 } ; int M = 2 ; int N = arr . length ; System . out . println ( minimumSubarray ( arr , N , M ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: c, i, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String checkSum ( int arr [ ] , int n , int k ) { HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( m . containsKey ( arr [ i ] ) ) { m . put ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; } else { m . put ( arr [ i ] , 1 ) ; } Vector < Integer > [ ] freq = new Vector [ n + 1 ] ; for ( int i = 0 ; i < freq . length ; i ++ ) freq [ i ] = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int f = m . get ( arr [ i ] ) ; if ( f != - 1 ) { freq [ f ] . add ( arr [ i ] ) ; m . put ( arr [ i ] , - 1 ) ; } } int count = 0 ; int kleastfreqsum = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int x : freq [ i ] ) { kleastfreqsum += x ; count ++ ; if ( count == k ) break ; } if ( count == k ) break ; } count = 0 ; int kmostfreqsum = 0 ; for ( int i = n ; i >= 0 ; i -- ) { for ( int x : freq [ i ] ) { kmostfreqsum += x ; count ++ ; if ( count == k ) break ; } if ( count == k ) break ; } if ( kleastfreqsum == kmostfreqsum ) return " Yes " ; return " No " ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 , 2 , 3 , 3 , 4 } ; int N = arr . length ; int K = 2 ; System . out . print ( checkSum ( arr , N , K ) ) ; } }

Index/key variables: f, i
Accumulator variables: count, i, kleastfreqsum, kmostfreqsum
Iterator variables: i, x
Class/struct names: GFG