dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static void FindMatrix ( int n , int m , int x , int y ) { int a , b , i , j ; if ( n * m == 1 ) { if ( x > y ) { System . out . print ( y + "NEW_LINE"); } else { System . out . print ( x + "NEW_LINE"); } return ; } a = Math . min ( x , y ) ; b = Math . min ( 2 * x , y ) - a ; boolean flag = true ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( flag ) System . out . print ( a + " ▁ " ) ; else System . out . print ( b + " ▁ " ) ; flag = ! flag ; } if ( ( ( n % 2 != 0 && m % 2 == 0 ) || ( n % 2 == 0 && m % 2 == 0 ) ) ) flag = ! flag ; System . out . print ( "NEW_LINE"); } } public static void main ( String [ ] args ) { int N , M , X , Y ; N = 3 ; M = 3 ; X = 5 ; Y = 3 ; FindMatrix ( N , M , X , Y ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; public class TSPGreedy { static void findMinRoute ( int [ ] [ ] tsp ) { int sum = 0 ; int counter = 0 ; int j = 0 , i = 0 ; int min = Integer . MAX_VALUE ; List < Integer > visitedRouteList = new ArrayList < > ( ) ; visitedRouteList . add ( 0 ) ; int [ ] route = new int [ tsp . length ] ; while ( i < tsp . length && j < tsp [ i ] . length ) { if ( counter >= tsp [ i ] . length - 1 ) { break ; } if ( j != i && ! ( visitedRouteList . contains ( j ) ) ) { if ( tsp [ i ] [ j ] < min ) { min = tsp [ i ] [ j ] ; route [ counter ] = j + 1 ; } } j ++ ; if ( j == tsp [ i ] . length ) { sum += min ; min = Integer . MAX_VALUE ; visitedRouteList . add ( route [ counter ] - 1 ) ; j = 0 ; i = route [ counter ] - 1 ; counter ++ ; } } i = route [ counter - 1 ] - 1 ; for ( j = 0 ; j < tsp . length ; j ++ ) { if ( ( i != j ) && tsp [ i ] [ j ] < min ) { min = tsp [ i ] [ j ] ; route [ counter ] = j + 1 ; } } sum += min ; System . out . print ( " Minimum ▁ Cost ▁ is ▁ : ▁ " ) ; System . out . println ( sum ) ; } public static void main ( String [ ] args ) { int [ ] [ ] tsp = { { - 1 , 10 , 15 , 20 } , { 10 , - 1 , 35 , 25 } , { 15 , 35 , - 1 , 30 } , { 20 , 25 , 30 , - 1 } } ; findMinRoute ( tsp ) ; } }

Index/key variables: counter, i, j
Accumulator variables: counter, j, sum
Iterator variables: j
Class/struct names: TSPGreedy
Java program:
import java . util . * ; class GFG { static void findCount ( int [ ] Arr1 , int [ ] Arr2 ) { int MAX = Math . max ( Arrays . stream ( Arr1 ) . max ( ) . getAsInt ( ) , Arrays . stream ( Arr2 ) . max ( ) . getAsInt ( ) ) ; int [ ] Count = new int [ 2 * MAX + 1 ] ; int n = Arr1 . length , m = Arr2 . length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int element = Arr1 [ i ] + Arr2 [ j ] ; Count [ element ] ++ ; } } for ( int i = 1 ; i <= 2 * MAX ; i ++ ) { if ( Count [ i ] > 0 ) { System . out . print ( i + " - > " + Count [ i ] + "NEW_LINE"); } } } public static void main ( String [ ] args ) { int [ ] arr1 = { 1 , 2 } ; int [ ] arr2 = { 1 , 2 , 1 } ; findCount ( arr1 , arr2 ) ; } }

Index/key variables: element, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void findAandB ( double N ) { if ( N == 1 ) { System . out . print ( " No " ) ; return ; } double a = N * N / ( N - 1 ) ; double b = a / N ; System . out . print ( " a ▁ = ▁ " + a + "NEW_LINE"); System . out . print ( " b ▁ = ▁ " + b + "NEW_LINE"); } public static void main ( String [ ] args ) { double N = 6 ; findAandB ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxSelections ( int A [ ] , int n , int k ) { Arrays . sort ( A ) ; int sum = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + A [ i ] ; if ( sum > k ) { break ; } count ++ ; } return count ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 7 , 2 , 9 , 4 } ; int k = 15 ; int n = A . length ; System . out . print ( maxSelections ( A , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void computePair ( double K ) { if ( K == 1 ) { System . out . print ( " No " ) ; return ; } else { System . out . print ( K * K / ( K - 1 ) + " ▁ " ) ; System . out . print ( K / ( K - 1 ) + "NEW_LINE"); } } public static void main ( String [ ] args ) { double K = 6 ; computePair ( K ) ; } }

Class/struct names: GFG
Java program:
class GFG { static String ConstructBinaryString ( int N , int M , int K ) { if ( M < ( N - 1 ) || M > K * ( N + 1 ) ) return " - 1" ; String ans = " " ; int l = Math . min ( K , M / ( N - 1 ) ) ; int temp = N ; while ( temp != 0 ) { temp -- ; ans += '0' ; if ( temp == 0 ) break ; for ( int i = 0 ; i < l ; i ++ ) { ans += '1' ; } } M -= ( N - 1 ) * l ; if ( M == 0 ) return ans ; l = Math . min ( M , K ) ; for ( int i = 0 ; i < l ; i ++ ) ans += '1' ; M -= l ; while ( M > 0 ) { ans = '1' + ans ; M -- ; } return ans ; } public static void main ( String [ ] args ) { int N = 5 , M = 9 , K = 2 ; System . out . println ( ConstructBinaryString ( N , M , K ) ) ; } }

Accumulator variables: M, ans, i, temp
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void number ( int num ) { int a [ ] = new int [ 20 ] ; int r , i = 0 , j ; while ( num > 0 ) { r = num % 10 ; if ( 9 - r > r ) a [ i ] = r ; else a [ i ] = 9 - r ; i ++ ; num = num / 10 ; } if ( a [ i - 1 ] == 0 ) { System . out . print ( "9" ) ; i -- ; } for ( j = i - 1 ; j >= 0 ; j -- ) System . out . print ( a [ j ] ) ; } public static void main ( String [ ] args ) { int num = 4545 ; number ( num ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
Java program:
class GFG { static boolean isDivisible ( int N ) { return ( N - 1 ) % 3 != 0 ; } public static void main ( String [ ] args ) { int N = 6 ; if ( isDivisible ( N ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int countDigitSum ( int N , int K ) { int l = ( int ) Math . pow ( 10 , N - 1 ) , r = ( int ) Math . pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int num = i ; int digits [ ] = new int [ N ] ; for ( int j = N - 1 ; j >= 0 ; j -- ) { digits [ j ] = num % 10 ; num /= 10 ; } int sum = 0 , flag = 0 ; for ( int j = 0 ; j < K ; j ++ ) sum += digits [ j ] ; for ( int j = 1 ; j < N - K + 1 ; j ++ ) { int curr_sum = 0 ; for ( int m = j ; m < j + K ; m ++ ) { curr_sum += digits [ m ] ; } if ( sum != curr_sum ) { flag = 1 ; break ; } } if ( flag == 0 ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int N = 2 , K = 1 ; System . out . print ( countDigitSum ( N , K ) ) ; } }

Index/key variables: N, j, m
Accumulator variables: count, curr_sum, i, j, m, num, sum
Iterator variables: i, j, m
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int noOfFactors ( int N ) { if ( N == 1 ) return 1 ; int count = 0 ; int ans = 1 ; while ( N % 2 == 0 ) { count ++ ; N = N / 2 ; } ans *= ( count / 2 + 1 ) ; for ( int i = 3 ; i * i <= N ; i = i + 2 ) { count = 0 ; while ( N % i == 0 ) { count ++ ; N = N / i ; } ans *= ( count / 2 + 1 ) ; } return ans ; } public static void main ( String [ ] args ) { int N = 100 ; System . out . print ( noOfFactors ( N ) ) ; } }

Accumulator variables: ans, count
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean possible ( int N , int a , int b , int n ) { int sum_of_angle = 180 * ( N - 2 ) ; int Total_angle = ( N * ( ( 2 * a ) + ( N - 1 ) * b ) ) / 2 ; if ( sum_of_angle != Total_angle ) return false ; else return true ; } static int nth_angle ( int N , int a , int b , int n ) { int nth = 0 ; nth = a + ( n - 1 ) * b ; return nth ; } public static void main ( String [ ] args ) { int N = 3 , a = 30 , b = 30 , n = 3 ; if ( possible ( N , a , b , n ) ) System . out . print ( nth_angle ( N , a , b , n ) ) ; else System . out . print ( " Not ▁ Possible " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void DFS ( int U , int [ ] vis , ArrayList < ArrayList < Integer > > adj ) { vis [ U ] = 1 ; for ( Integer V : adj . get ( U ) ) { if ( vis [ V ] == 0 ) DFS ( V , vis , adj ) ; } } static void minCost ( int N , int M , int vCost , int eCost , int sorc [ ] , ArrayList < Integer > colored , int destination [ ] ) { ArrayList < ArrayList < Integer > > adj = new ArrayList < > ( ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) adj . add ( new ArrayList < Integer > ( ) ) ; for ( int i = 0 ; i < M ; i ++ ) { adj . get ( sorc [ i ] ) . add ( destination [ i ] ) ; adj . get ( destination [ i ] ) . add ( sorc [ i ] ) ; } int [ ] vis = new int [ N + 1 ] ; for ( int i = 0 ; i < colored . size ( ) ; i ++ ) { DFS ( colored . get ( i ) , vis , adj ) ; } int X = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( vis [ i ] == 0 ) { X ++ ; DFS ( i , vis , adj ) ; } } int mincost = X * Math . min ( vCost , eCost ) ; System . out . println ( mincost ) ; } public static void main ( String [ ] args ) { int N = 3 , M = 1 ; int sorc [ ] = { 1 } ; int destination [ ] = { 2 } ; int vCost = 3 , eCost = 2 ; ArrayList < Integer > colored = new ArrayList < > ( ) ; colored . add ( 1 ) ; minCost ( N , M , vCost , eCost , sorc , colored , destination ) ; } }

Index/key variables: U, V, i
Accumulator variables: X, i
Iterator variables: V, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int min_cost ( int n , int x , int p , int q ) { if ( x == 1 ) { System . out . println ( ( n - 1 ) * p ) ; return 0 ; } int ans = ( n - 1 ) * p ; int pre = 0 ; while ( n > 1 ) { int tmp = n / x ; if ( tmp < 0 ) break ; pre += ( n - tmp * x ) * p ; n /= x ; pre += q ; ans = Math . min ( ans , pre + ( n - 1 ) * p ) ; } return ans ; } public static void main ( String [ ] args ) { int n = 5 , x = 2 , p = 2 , q = 3 ; System . out . println ( min_cost ( n , x , p , q ) ) ; } }

Accumulator variables: n, pre
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int calculateWays ( int arr1 [ ] , int arr2 [ ] , int N ) { int A = arr2 [ 0 ] , B = arr2 [ 1 ] ; int C = arr2 [ 2 ] , D = arr2 [ 3 ] ; int ans = 0 ; for ( int b = 0 ; b <= B && b * 5 <= ( N ) ; b ++ ) for ( int c = 0 ; c <= C && b * 5 + c * 10 <= ( N ) ; c ++ ) for ( int d = 0 ; d <= D && b * 5 + c * 10 + d * 20 <= ( N ) ; d ++ ) if ( ( b * 5 ) + ( c * 10 ) + ( d * 20 ) >= ( N - A ) ) ans ++ ; return ans ; } public static void main ( String [ ] args ) { int N = 123 ; int arr1 [ ] = { 1 , 5 , 10 , 20 } ; int arr2 [ ] = { 6 , 4 , 3 , 5 } ; System . out . print ( calculateWays ( arr1 , arr2 , N ) ) ; } }

Accumulator variables: ans, b, c, d
Iterator variables: b, c, d
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] ways = new int [ 1010 ] ; static int calculateWays ( int arr1 [ ] , int arr2 [ ] , int N ) { int A = arr2 [ 0 ] , B = arr2 [ 1 ] ; int C = arr2 [ 2 ] , D = arr2 [ 3 ] ; int ans = 0 ; for ( int b = 0 ; b <= B && b * 5 <= N ; b ++ ) { for ( int a = 0 ; a <= A && a * 1 + b * 5 <= N ; a ++ ) { ways [ a + b * 5 ] ++ ; } } for ( int c = 0 ; c <= C && c * 10 <= ( N ) ; c ++ ) { for ( int d = 0 ; d <= D && c * 10 + d * 20 <= ( N ) ; d ++ ) { ans += ways [ N - c * 10 - d * 20 ] ; } } return ans ; } public static void main ( String [ ] args ) { int N = 123 ; int arr1 [ ] = { 1 , 5 , 10 , 20 } ; int arr2 [ ] = { 6 , 4 , 3 , 5 } ; System . out . print ( calculateWays ( arr1 , arr2 , N ) ) ; } }

Accumulator variables: a, ans, b, c, d
Iterator variables: a, b, c, d
Class/struct names: GFG
Java program:
class GFG { public static void countMissingNum ( int [ ] a , int N ) { int count = a [ N - 1 ] - a [ 0 ] + 1 - N ; System . out . println ( count ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 10 , 20 , 40 } ; int N = arr . length ; countMissingNum ( arr , N ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int maxXORSubsequence ( int arr [ ] , int n ) { int i , odd = 0 , even = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) odd ++ ; else even ++ ; } int maxlen ; if ( odd == n ) { if ( odd % 2 == 0 ) maxlen = n - 1 ; else maxlen = n ; } else if ( even == n ) { maxlen = 0 ; } else { if ( odd % 2 == 0 ) maxlen = even + odd - 1 ; else maxlen = even + odd ; } return maxlen ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 , 7 } ; int n = arr . length ; System . out . print ( maxXORSubsequence ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int numberOfPairs ( int n ) { if ( n % 2 == 0 ) return n / 2 - 1 ; else return n / 2 ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( numberOfPairs ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int good_pair ( String str [ ] , int N ) { int countStr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { String res = str [ i ] + str [ j ] ; int vowel [ ] = new int [ 5 ] ; for ( int k = 0 ; k < res . length ( ) ; k ++ ) { if ( res . charAt ( k ) == ' a ' ) vowel [ 0 ] = 1 ; else if ( res . charAt ( k ) == ' e ' ) vowel [ 1 ] = 1 ; else if ( res . charAt ( k ) == ' i ' ) vowel [ 2 ] = 1 ; else if ( res . charAt ( k ) == ' o ' ) vowel [ 3 ] = 1 ; else if ( res . charAt ( k ) == ' u ' ) vowel [ 4 ] = 1 ; } int temp = 0 ; for ( int ind = 0 ; ind < 5 ; ind ++ ) { if ( vowel [ ind ] == 1 ) temp ++ ; } if ( temp == 5 ) countStr ++ ; } } return countStr ; } public static void main ( String [ ] args ) { String arr [ ] = { " aaweiolkju " , " oxdfgujkmi " } ; int N = arr . length ; System . out . print ( good_pair ( arr , N ) ) ; } }

Index/key variables: i, ind, j
Accumulator variables: countStr, i, ind, j, k, temp
Iterator variables: i, ind, j, k
Class/struct names: GFG
Java program:
class GFG { static void sieveOfEratosthenes ( int N , int s [ ] ) { boolean [ ] prime = new boolean [ N + 1 ] ; for ( int i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j * i <= N ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } static int generatePrimeFactors ( int N ) { int [ ] s = new int [ N + 1 ] ; int sum = 0 ; sieveOfEratosthenes ( N , s ) ; int curr = s [ N ] ; int cnt = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( curr == s [ N ] ) { cnt ++ ; continue ; } sum = sum + cnt ; curr = s [ N ] ; cnt = 1 ; } return sum ; } static void findSum ( int N ) { int sum = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { sum += generatePrimeFactors ( i ) ; } System . out . print ( sum + "NEW_LINE"); } public static void main ( String [ ] args ) { int N = 4 ; findSum ( N ) ; } }

Index/key variables: N, i
Accumulator variables: N, cnt, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int LCM ( int a , int b ) { int lcm = a > b ? a : b ; while ( true ) { if ( lcm % a == 0 && lcm % b == 0 ) break ; else lcm ++ ; } return lcm ; } static void findMinLCM ( int arr [ ] , int n ) { int minLCM = Integer . MAX_VALUE ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int val = LCM ( arr [ i ] , arr [ i + 1 ] ) ; if ( val < minLCM ) { minLCM = val ; } } System . out . print ( minLCM + "NEW_LINE"); } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 8 , 12 , 16 , 20 , 24 } ; int n = arr . length ; findMinLCM ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i, lcm
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int find_max ( int n , int k ) { int [ ] X = new int [ 32 ] ; int cnt = 0 ; for ( int i = 31 ; i >= 0 && cnt != k ; i -- ) { if ( ( n & ( 1 << i ) ) != 0 ) { X [ i ] = 1 ; cnt ++ ; } } String s = " " ; for ( int i = 31 ; i >= 0 ; i -- ) s += X [ i ] == 0 ? '0' : '1' ; return Integer . parseInt ( s , 2 ) ; } public static void main ( String [ ] args ) { int n = 10 , k = 2 ; System . out . println ( find_max ( n , k ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, s
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void convert ( String s ) { int num = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) num = num * 10 + ( ( int ) s . charAt ( i ) - 48 ) ; System . out . print ( num ) ; } public static void main ( String [ ] args ) { String s = "123" ; convert ( s ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int hell = 1000000007 ; static final int N = 100005 ; static int c_0 , c_1 , c_2 ; static void count_k ( int [ ] arr , Stack < Integer > ones , Stack < Integer > twos , Stack < Integer > zeros ) { for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] % 3 == 0 ) { c_0 ++ ; zeros . add ( arr [ i ] ) ; } else if ( arr [ i ] % 3 == 1 ) { c_1 ++ ; ones . add ( arr [ i ] ) ; } else { c_2 ++ ; twos . add ( arr [ i ] ) ; } } return ; } static void printArrangement ( int [ ] arr , Stack < Integer > ones , Stack < Integer > twos , Stack < Integer > zeros ) { if ( ( c_0 == 0 && c_1 != 0 && c_2 != 0 ) c_0 > c_1 + c_2 + 1 ) { System . out . print ( " - 1" ) ; return ; } if ( c_0 == 0 ) { for ( int i = 0 ; i < arr . length ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } return ; } int i , j ; int [ ] ans = new int [ N ] ; Arrays . fill ( ans , - 1 ) ; for ( i = 1 , j = 0 ; j < c_1 ; i += 2 , j ++ ) { ans [ i ] = ones . peek ( ) ; ones . pop ( ) ; } ans [ i - 1 ] = zeros . peek ( ) ; zeros . pop ( ) ; c_0 -- ; for ( j = 0 ; j < c_2 ; j ++ , i += 2 ) { ans [ i ] = twos . peek ( ) ; twos . pop ( ) ; } for ( int k = 0 ; c_0 > 0 ; k += 2 ) { if ( ans [ k ] == - 1 ) { ans [ k ] = zeros . peek ( ) ; c_0 -- ; } } for ( int i1 = 0 ; i1 < N ; i1 ++ ) { if ( ans [ i1 ] != - 1 ) System . out . print ( ans [ i1 ] + " ▁ " ) ; } return ; } static void solve ( int n , int [ ] arr ) { Stack < Integer > ones = new Stack < Integer > ( ) ; Stack < Integer > zeros = new Stack < Integer > ( ) ; Stack < Integer > twos = new Stack < Integer > ( ) ; c_0 = 0 ; c_1 = 0 ; c_2 = 0 ; count_k ( arr , ones , twos , zeros ) ; printArrangement ( arr , ones , twos , zeros ) ; } public static void main ( String [ ] args ) { int n = 5 ; int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; solve ( n , arr ) ; } }

Index/key variables: N, i, i1, k
Accumulator variables: c_0, c_1, c_2, i, i1, j, k
Iterator variables: i, i1, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void countUniqueDigits ( int N ) { int res = 0 ; int cnt [ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; while ( N > 0 ) { int rem = N % 10 ; cnt [ rem ] ++ ; N = N / 10 ; } for ( int i = 0 ; i < cnt . length ; i ++ ) { if ( cnt [ i ] == 1 ) { res ++ ; } } System . out . println ( res ) ; } public static void main ( String [ ] args ) { int N = 2234262 ; countUniqueDigits ( N ) ; } }

Index/key variables: i, rem
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean checkUniqueFrequency ( int arr [ ] , int n ) { HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . containsKey ( arr [ i ] ) ) { freq . put ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) ; } else { freq . put ( arr [ i ] , 1 ) ; } } HashSet < Integer > uniqueFreq = new HashSet < Integer > ( ) ; for ( Map . Entry < Integer , Integer > i : freq . entrySet ( ) ) { if ( uniqueFreq . contains ( i . getValue ( ) ) ) return false ; else uniqueFreq . add ( i . getValue ( ) ) ; } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 5 , 5 } ; int n = arr . length ; boolean res = checkUniqueFrequency ( arr , n ) ; if ( res ) System . out . print ( " Yes " + "NEW_LINE"); else System . out . print ( " No " + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . Math ; class GFG { static double power ( int N , int P ) { return Math . pow ( N , P ) ; } public static int log2 ( int N ) { int result = ( int ) ( Math . log ( N ) / Math . log ( 2 ) ) ; return result ; } static double specialSum ( int n ) { double sum = n * ( n + 1 ) / 2 ; int a = log2 ( n ) ; sum = sum + power ( 2 , a + 1 ) - 1 ; return sum ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( specialSum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void Permute ( Vector < Integer > arr , int n ) { int odd = 0 , four = 0 ; int non_four = 0 ; Vector < Integer > ODD = new Vector < Integer > ( ) ; Vector < Integer > FOUR = new Vector < Integer > ( n ) ; Vector < Integer > NON_FOUR = new Vector < Integer > ( n ) ; for ( int x : arr ) { if ( x % 2 != 0 ) { odd ++ ; ODD . add ( x ) ; } else if ( x % 4 == 0 ) { four ++ ; FOUR . add ( x ) ; } else { non_four ++ ; NON_FOUR . add ( x ) ; } } if ( non_four == 0 && four >= odd - 1 ) { int x = ODD . size ( ) ; int y = FOUR . size ( ) ; int i ; for ( i = 0 ; i < x ; i ++ ) { System . out . print ( ODD . get ( i ) + " ▁ " ) ; if ( i < y ) System . out . print ( FOUR . get ( i ) + " ▁ " ) ; } while ( i < y ) System . out . print ( FOUR . get ( i ) + " ▁ " ) ; System . out . println ( ) ; } else if ( non_four > 0 && four >= odd ) { int x = ODD . size ( ) ; int y = FOUR . size ( ) ; int i ; for ( i = 0 ; i < x ; i ++ ) { System . out . print ( ODD . get ( i ) + " ▁ " ) ; if ( i < y ) System . out . print ( FOUR . get ( i ) + " ▁ " ) ; } while ( i < y ) System . out . print ( FOUR . get ( i ) + " ▁ " ) ; for ( int j = 0 ; j < ( int ) NON_FOUR . size ( ) ; j ++ ) System . out . print ( NON_FOUR . get ( j ) + " ▁ " ) ; System . out . println ( ) ; } else System . out . println ( " Not ▁ Possible " ) ; } public static void main ( String [ ] args ) { Vector < Integer > arr = new Vector < Integer > ( ) ; arr . add ( 2 ) ; arr . add ( 7 ) ; arr . add ( 1 ) ; arr . add ( 8 ) ; arr . add ( 2 ) ; arr . add ( 8 ) ; Permute ( arr , arr . size ( ) ) ; } }

Accumulator variables: four, i, j, non_four, odd
Iterator variables: i, j, x
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { static void findArray ( int sum , int xorr ) { if ( xorr > sum sum % 2 != xorr % 2 ) { System . out . println ( " No ▁ Array ▁ Possible " ) ; return ; } if ( sum == xorr ) { if ( sum == 0 ) System . out . println ( " Array ▁ is ▁ empty ▁ " + " with ▁ size ▁ 0" ) ; else System . out . println ( " Array ▁ size ▁ is ▁ " + 1 ) ; System . out . println ( " Array ▁ is ▁ " + sum ) ; return ; } int mid = ( sum - xorr ) / 2 ; if ( xorr == 1 && mid == 1 ) { System . out . println ( " Array ▁ size ▁ is ▁ " + 3 ) ; System . out . println ( " Array ▁ is ▁ " + xorr + " ▁ " + mid + " ▁ " + mid ) ; } else { System . out . println ( " Array ▁ size ▁ is ▁ " + 2 ) ; System . out . println ( " Array ▁ is ▁ " + ( xorr + mid ) + " ▁ " + mid ) ; } } public static void main ( String [ ] args ) { int sum = 4 , xorr = 2 ; findArray ( sum , xorr ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String Kperiodicinteger ( char [ ] X , int N , int K ) { String temp = String . valueOf ( X ) ; for ( int i = 0 ; i < K ; i ++ ) { int j = i ; while ( j < N ) { X [ j ] = X [ i ] ; j += K ; } } if ( String . valueOf ( X ) . compareTo ( temp ) >= 0 ) { return String . valueOf ( X ) ; } int POS = 0 ; for ( int i = K - 1 ; i >= 0 ; i -- ) { if ( X [ i ] != '9' ) { X [ i ] ++ ; POS = i ; break ; } } for ( int i = POS + 1 ; i < K ; i ++ ) { X [ i ] = '0' ; } for ( int i = 0 ; i < K ; i ++ ) { int j = i ; while ( j < N ) { X [ j ] = X [ i ] ; j += K ; } } return String . valueOf ( X ) ; } public static void main ( String [ ] args ) { int N = 4 , K = 2 ; String X = "1215" ; System . out . print ( Kperiodicinteger ( X . toCharArray ( ) , N , K ) ) ; } }

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