dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
public class FactorialGCD { static int factorial ( int x ) { if ( x <= 1 ) return 1 ; int res = 2 ; for ( int i = 3 ; i <= x ; i ++ ) res = res * i ; return res ; } static int gcdOfFactorial ( int m , int n ) { int min = m < n ? m : n ; return factorial ( min ) ; } public static void main ( String [ ] args ) { int m = 5 , n = 9 ; System . out . println ( gcdOfFactorial ( m , n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: FactorialGCD
Java program:
import java . io . * ; class GFG { static int recDigSum ( int n ) { if ( n == 0 ) return 0 ; else { if ( n % 9 == 0 ) return 9 ; else return n % 9 ; } } static void check ( int n ) { n = recDigSum ( n ) ; if ( n == 2 n == 3 n == 5 n == 7 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { int n = 5602 ; check ( n ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findNumber ( int n ) { int x = ( int ) Math . floor ( ( - 1 + Math . sqrt ( 1 + 8 * n - 8 ) ) / 2 ) ; int base = ( x * ( x + 1 ) ) / 2 + 1 ; return n - base + 1 ; } public static void main ( String [ ] args ) { int n = 55 ; System . out . println ( findNumber ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; public class GFG { static int weightedMean ( int n ) { return ( 2 * n + 1 ) / 3 ; } static public void main ( String [ ] args ) { int n = 10 ; System . out . println ( weightedMean ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void calculate ( int a [ ] , int b [ ] , int n , int m ) { int mul = 1 ; for ( int i = 0 ; i < m ; i ++ ) if ( b [ i ] != 0 ) mul = mul * b [ i ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = ( int ) Math . floor ( a [ i ] / mul ) ; System . out . print ( x + " ▁ " ) ; } } public static void main ( String [ ] args ) { int a [ ] = { 5 , 100 , 8 } ; int b [ ] = { 2 , 3 } ; int n = a . length ; int m = b . length ; calculate ( a , b , n , m ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int findPowerOfP ( int n , int p ) { int count = 0 ; int r = p ; while ( r <= n ) { count += ( n / r ) ; r = r * p ; } return count ; } static Vector < pair > primeFactorsofK ( int k ) { Vector < pair > ans = new Vector < pair > ( ) ; for ( int i = 2 ; k != 1 ; i ++ ) { if ( k % i == 0 ) { int count = 0 ; while ( k % i == 0 ) { k = k / i ; count ++ ; } ans . add ( new pair ( i , count ) ) ; } } return ans ; } static int largestPowerOfK ( int n , int k ) { Vector < pair > vec = new Vector < pair > ( ) ; vec = primeFactorsofK ( k ) ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < vec . size ( ) ; i ++ ) ans = Math . min ( ans , findPowerOfP ( n , vec . get ( i ) . first ) / vec . get ( i ) . second ) ; return ans ; } public static void main ( String [ ] args ) { System . out . print ( largestPowerOfK ( 7 , 2 ) + "NEW_LINE"); System . out . print ( largestPowerOfK ( 10 , 9 ) + "NEW_LINE"); } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
class GFG { static void print ( int n ) { System . out . println ( n + n / 2 ) ; for ( int i = 2 ; i <= n ; i += 2 ) System . out . print ( i + " ▁ " ) ; for ( int i = 1 ; i <= n ; i += 2 ) System . out . print ( i + " ▁ " ) ; for ( int i = 2 ; i <= n ; i += 2 ) System . out . print ( i + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 3 ; print ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int lcm_fun ( int a , int b ) { if ( b == 0 ) return a ; return lcm_fun ( b , a % b ) ; } static int digitLCM ( int n ) { int lcm = 1 ; while ( n > 0 ) { lcm = ( n % 10 * lcm ) / lcm_fun ( n % 10 , lcm ) ; if ( lcm == 0 ) return 0 ; n = n / 10 ; } return lcm ; } public static void main ( String [ ] args ) { int n = 397 ; System . out . println ( digitLCM ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static double e = 2.71828 ; static int roundNo ( float num ) { return ( int ) ( num < 0 ? num - 0.5 : num + 0.5 ) ; } static void printBestCandidate ( int candidate [ ] , int n ) { int sample_size = roundNo ( ( float ) ( n / e ) ) ; System . out . println ( " Sample size is " + sample_size); int best = 0 ; for ( int i = 1 ; i < sample_size ; i ++ ) if ( candidate [ i ] > candidate [ best ] ) best = i ; for ( int i = sample_size ; i < n ; i ++ ) if ( candidate [ i ] >= candidate [ best ] ) { best = i ; break ; } if ( best >= sample_size ) System . out . println ( " Best candidate found is " +  ( best + 1 ) + " ▁ with ▁ talent ▁ " + candidate [ best ] ) ; else System . out . print ( "Couldn't find a best candidateNEW_LINE"); } public static void main ( String [ ] args ) { int n = 8 ; int [ ] candidate = new int [ n ] ; Random rand = new Random ( ) ; for ( int i = 0 ; i < n ; i ++ ) candidate [ i ] = 1 + rand . nextInt ( ( 8 - 1 ) + 1 ) ; System . out . print ( " Candidate ▁ : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( i + 1 + " ▁ " ) ; System . out . println ( ) ; System . out . print ( " Talents ▁ : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( candidate [ i ] + " ▁ " ) ; printBestCandidate ( candidate , n ) ; } }

Index/key variables: best, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static double u_cal ( double u , int n ) { double temp = u ; for ( int i = 1 ; i < n ; i ++ ) temp = temp * ( u + i ) ; return temp ; } static int fact ( int n ) { int f = 1 ; for ( int i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } public static void main ( String [ ] args ) { int n = 5 ; double x [ ] = { 1891 , 1901 , 1911 , 1921 , 1931 } ; double [ ] [ ] y = new double [ n ] [ n ] ; y [ 0 ] [ 0 ] = 46 ; y [ 1 ] [ 0 ] = 66 ; y [ 2 ] [ 0 ] = 81 ; y [ 3 ] [ 0 ] = 93 ; y [ 4 ] [ 0 ] = 101 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = n - 1 ; j >= i ; j -- ) y [ j ] [ i ] = y [ j ] [ i - 1 ] - y [ j - 1 ] [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) System . out . print ( y [ i ] [ j ] + " TABSYMBOL " ) ; System . out . println ( " " ) ; ; } double value = 1925 ; double sum = y [ n - 1 ] [ 0 ] ; double u = ( value - x [ n - 1 ] ) / ( x [ 1 ] - x [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { sum = sum + ( u_cal ( u , i ) * y [ n - 1 ] [ i ] ) / fact ( i ) ; } System . out . println ( " Value at " + value + " ▁ is ▁ " + String . format ( " % .6g % n " , sum ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: f, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int sumDigitSquare ( int n ) { int sq = 0 ; while ( n != 0 ) { int digit = n % 10 ; sq += digit * digit ; n = n / 10 ; } return sq ; } static boolean isHappy ( int n ) { while ( true ) { if ( n == 1 ) return true ; n = sumDigitSquare ( n ) ; if ( n == 4 ) return false ; } } public static void main ( String args [ ] ) { int n = 23 ; if ( isHappy ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: sq
Class/struct names: GFG
Java program:
class GFG { static long findSumSubsets ( int n ) { return ( n * ( n + 1 ) / 2 ) * ( 1 << ( n - 1 ) ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( findSumSubsets ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMin ( int a [ ] , int n ) { double sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Math . log ( a [ i ] ) ; int x = ( int ) Math . exp ( sum / n ) ; return x + 1 ; } public static void main ( String [ ] args ) { int a [ ] = { 3 , 2 , 1 , 4 } ; int n = a . length ; System . out . println ( findMin ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countdigits ( int N ) { int count = 0 ; while ( N > 0 ) { count ++ ; N = N / 10 ; } return count ; } static void cyclic ( int N ) { int num = N ; int n = countdigits ( N ) ; while ( true ) { System . out . println ( num ) ; int rem = num % 10 ; int dev = num / 10 ; num = ( int ) ( ( Math . pow ( 10 , n - 1 ) ) * rem + dev ) ; if ( num == N ) break ; } } public static void main ( String [ ] args ) { int N = 5674 ; cyclic ( N ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . Arrays ; public class GFG { static boolean sackRace ( int p1 , int s1 , int p2 , int s2 ) { return ( ( s1 > s2 && ( p2 - p1 ) % ( s1 - s2 ) == 0 ) || ( s2 > s1 && ( p1 - p2 ) % ( s2 - s1 ) == 0 ) ) ; } public static void main ( String args [ ] ) { int p1 = 4 , s1 = 4 , p2 = 8 , s2 = 2 ; if ( sackRace ( p1 , s1 , p2 , s2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static void solve ( int n ) { double a = n / 2 ; if ( n % 2 != 0 ) { System . out . println ( ( Math . ceil ( a ) - 1 ) + " ▁ " + ( Math . floor ( a ) + 1 ) ) ; } else { if ( ( int ) ( a ) % 2 == 0 ) { System . out . println ( ( Math . ceil ( a ) - 1 ) + " ▁ " + ( Math . floor ( a ) + 1 ) ) ; } else { System . out . println ( ( Math . ceil ( a ) - 2 ) + " ▁ " + ( Math . floor ( a ) + 2 ) ) ; } } } public static void main ( String [ ] args ) { int n = 34 ; solve ( n ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . math . * ; class GFG { static int countDigits ( int a , int b ) { int count = 0 ; int p = Math . abs ( a * b ) ; if ( p == 0 ) return 1 ; while ( p > 0 ) { count ++ ; p = p / 10 ; } return count ; } public static void main ( String args [ ] ) { int a = 33 ; int b = - 24 ; System . out . println ( " Number ▁ of ▁ digits ▁ = ▁ " + countDigits ( a , b ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . io . * ; public class GFG { static void multiple ( int a , int b , int x ) { if ( b < 0 ) { if ( a == 1 && x == 1 ) System . out . println ( "1" ) ; else System . out . println ( "0" ) ; } int mul = ( int ) Math . pow ( a , b ) ; int ans = mul / x ; int ans1 = x * ans ; int ans2 = x * ( ans + 1 ) ; System . out . println ( ( ( mul - ans1 ) <= ( ans2 - mul ) ) ? ans1 : ans2 ) ; } static public void main ( String [ ] args ) { int a = 349 , b = 1 , x = 4 ; multiple ( a , b , x ) ; } }

Class/struct names: GFG
Java program:
public class Main { static int maxSum ( int n ) { if ( n == 1 ) return 1 ; else return ( n * ( n - 1 ) / 2 ) - 1 + n / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( maxSum ( n ) ) ; } }

Class/struct names: Main
Java program:
import java . io . * ; class GFG { static int compute_average ( int a , int b ) { return ( a + b ) / 2 ; } public static void main ( String [ ] args ) { int a = Integer . MAX_VALUE ; int b = Integer . MAX_VALUE ; System . out . println ( " Actual ▁ average ▁ : ▁ " + Integer . MAX_VALUE ) ; System . out . println ( " Computed ▁ average ▁ : ▁ " + compute_average ( a , b ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int minNum ( int arr [ ] , int n ) { Boolean odd = false ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 != 0 ) odd = ! odd ; if ( odd ) return 1 ; return 2 ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = arr . length ; System . out . println ( minNum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: odd
Class/struct names: GFG
Java program:
public class GFG { static int msbPos ( int n ) { int pos = 0 ; while ( n != 0 ) { pos ++ ; n = n >> 1 ; } return pos ; } static int josephify ( int n ) { int position = msbPos ( n ) ; int j = 1 << ( position - 1 ) ; n = n ^ j ; n = n << 1 ; n = n | 1 ; return n ; } public static void main ( String [ ] args ) { int n = 41 ; System . out . println ( josephify ( n ) ) ; } }

Accumulator variables: pos
Class/struct names: GFG
Java program:
public class CountXor { static int countXorPair ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( ( arr [ i ] ^ arr [ j ] ) % 2 == 1 ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 } ; System . out . println ( countXorPair ( arr , arr . length ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: CountXor
Java program:
class GFG { static int powmod ( int x , int y , int p ) { while ( y > 0 ) { if ( ( y & 1 ) > 0 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } static int discreteLogarithm ( int a , int b , int m ) { int n = ( int ) ( Math . sqrt ( m ) + 1 ) ; int [ ] value = new int [ m ] ; for ( int i = n ; i >= 1 ; -- i ) value [ powmod ( a , i * n , m ) ] = i ; for ( int j = 0 ; j < n ; ++ j ) { int cur = ( powmod ( a , j , m ) * b ) % m ; if ( value [ cur ] > 0 ) { int ans = value [ cur ] * n - j ; if ( ans < m ) return ans ; } } return - 1 ; } public static void main ( String [ ] args ) { int a = 2 , b = 3 , m = 5 ; System . out . println ( discreteLogarithm ( a , b , m ) ) ; a = 3 ; b = 7 ; m = 11 ; System . out . println ( discreteLogarithm ( a , b , m ) ) ; } }

Index/key variables: cur, m
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int discreteLogarithm ( int a , int b , int m ) { int n = ( int ) ( Math . sqrt ( m ) + 1 ) ; int an = 1 ; for ( int i = 0 ; i < n ; ++ i ) an = ( an * a ) % m ; int [ ] value = new int [ m ] ; for ( int i = 1 , cur = an ; i <= n ; ++ i ) { if ( value [ cur ] == 0 ) value [ cur ] = i ; cur = ( cur * an ) % m ; } for ( int i = 0 , cur = b ; i <= n ; ++ i ) { if ( value [ cur ] > 0 ) { int ans = value [ cur ] * n - i ; if ( ans < m ) return ans ; } cur = ( cur * a ) % m ; } return - 1 ; } public static void main ( String [ ] args ) { int a = 2 , b = 3 , m = 5 ; System . out . println ( discreteLogarithm ( a , b , m ) ) ; a = 3 ; b = 7 ; m = 11 ; System . out . println ( discreteLogarithm ( a , b , m ) ) ; } }

Index/key variables: cur, m
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String nthprimedigitsnumber ( int number ) { int rem ; String num = " " ; while ( number > 0 ) { rem = number % 4 ; switch ( rem ) { case 1 : num += '2' ; break ; case 2 : num += '3' ; break ; case 3 : num += '5' ; break ; case 0 : num += '7' ; break ; } if ( number % 4 == 0 ) number -- ; number = number / 4 ; } return new StringBuilder ( num ) . reverse ( ) . toString ( ) ; } public static void main ( String [ ] args ) { int number = 21 ; System . out . println ( nthprimedigitsnumber ( 10 ) ) ; System . out . println ( nthprimedigitsnumber ( 21 ) ) ; } }

Accumulator variables: num, number
Class/struct names: GFG
Java program:
class Test { static int countPairs ( int N ) { int count = 0 ; for ( int i = 1 ; i <= Math . cbrt ( N ) ; i ++ ) { int cb = i * i * i ; int diff = N - cb ; int cbrtDiff = ( int ) Math . cbrt ( diff ) ; if ( cbrtDiff * cbrtDiff * cbrtDiff == diff ) count ++ ; } return count ; } public static void main ( String args [ ] ) { for ( int i = 1 ; i <= 10 ; i ++ ) System . out . println ( " For ▁ n ▁ = ▁ " + i + " , ▁ " + + countPairs ( i ) + " ▁ pair ▁ exists " ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: Test
Java program:
import java . util . HashMap ; import java . util . Iterator ; import java . util . Set ; class Test { static HashMap < Long , Integer > primeFactors ( long num ) { HashMap < Long , Integer > ans = new HashMap < Long , Integer > ( ) { @ Override public Integer get ( Object key ) { if ( containsKey ( key ) ) { return super . get ( key ) ; } return 0 ; } } ; for ( long i = 2 ; i * i <= num ; i ++ ) { while ( num % i == 0 ) { num /= i ; ans . put ( i , ans . get ( i ) + 1 ) ; } } if ( num > 1 ) ans . put ( num , ans . get ( num ) + 1 ) ; ; return ans ; } static long legendre ( long factor , long num ) { long count = 0 , fac2 = factor ; while ( num >= factor ) { count += num / factor ; factor *= fac2 ; } return count ; } static boolean possible ( HashMap < Long , Integer > factors , long num ) { Set < Long > s = factors . keySet ( ) ; Iterator < Long > itr = s . iterator ( ) ; while ( itr . hasNext ( ) ) { long temp = itr . next ( ) ; if ( legendre ( temp , num ) < factors . get ( temp ) ) return false ; } return true ; } static long search ( long start , long end , HashMap < Long , Integer > factors ) { long mid = ( start + end ) / 2 ; if ( ! possible ( factors , mid ) ) return search ( mid + 1 , end , factors ) ; if ( start == mid ) return mid ; return search ( start , mid , factors ) ; } static long findFact ( long num ) { HashMap < Long , Integer > factors = primeFactors ( num ) ; return search ( 1 , num , factors ) ; } public static void main ( String args [ ] ) { System . out . println ( findFact ( 6 ) ) ; System . out . println ( findFact ( 997587429953L ) ) ; } }

Accumulator variables: count, factor, i, num
Iterator variables: i
Class/struct names: Test
Java program:
import java . util . Arrays ; import java . util . Vector ; class Test { static void printEqualModNumbers ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int d = arr [ n - 1 ] - arr [ 0 ] ; if ( d == 0 ) { System . out . println ( " Infinite ▁ solution " ) ; return ; } Vector < Integer > v = new Vector < > ( ) ; for ( int i = 1 ; i * i <= d ; i ++ ) { if ( d % i == 0 ) { v . add ( i ) ; if ( i != d / i ) v . add ( d / i ) ; } } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { int temp = arr [ 0 ] % v . get ( i ) ; int j ; for ( j = 1 ; j < n ; j ++ ) if ( arr [ j ] % v . get ( i ) != temp ) break ; if ( j == n ) System . out . print ( v . get ( i ) + " ▁ " ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 38 , 6 , 34 } ; printEqualModNumbers ( arr , arr . length ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Test
Java program:
class Test { static int FirstDigit ( int arr [ ] , int n ) { double S = 0 ; for ( int i = 0 ; i < n ; i ++ ) S = S + Math . log10 ( arr [ i ] * 1.0 ) ; double fract_S = S - Math . floor ( S ) ; int ans = ( int ) Math . pow ( 10 , fract_S ) ; return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 8 , 3 , 7 } ; System . out . println ( FirstDigit ( arr , arr . length ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
class Test { static int countDigit ( int n ) { int temp = n , count = 0 ; while ( temp != 0 ) { int d = temp % 10 ; temp /= 10 ; if ( d > 0 && n % d == 0 ) count ++ ; } return count ; } public static void main ( String args [ ] ) { int n = 1012 ; System . out . println ( countDigit ( n ) ) ; } }

Accumulator variables: count, temp
Class/struct names: Test
Java program:
import java . io . * ; class GFG { static int makeOdd ( int n ) { if ( n % 2 != 0 ) return 1 ; int ans = 1 ; while ( n % 2 == 0 ) { n /= 2 ; ans *= 2 ; } return ans ; } public static void main ( String [ ] args ) { int n = 36 ; int res = makeOdd ( n ) ; System . out . println ( res ) ; } }

Accumulator variables: ans, n
Class/struct names: GFG
Java program:
import java . io . * ; class Solution { static int closestMultiple ( int n , int x ) { if ( x > n ) return x ; n = n + x / 2 ; n = n - ( n % x ) ; return n ; } public static void main ( String [ ] args ) { int n = 56287 , x = 27 ; System . out . println ( closestMultiple ( n , x ) ) ; } }

Class/struct names: Solution
Java program:
class Test { static void printCubes ( int a , int b ) { int acrt = ( int ) Math . cbrt ( a ) ; int bcrt = ( int ) Math . cbrt ( b ) ; for ( int i = acrt ; i <= bcrt ; i ++ ) if ( i * i * i >= a && i * i * i <= b ) System . out . print ( i * i * i + " ▁ " ) ; } public static void main ( String [ ] args ) { int a = 24 , b = 576 ; System . out . println ( " Perfect ▁ cubes ▁ in ▁ given ▁ range : " ) ; printCubes ( a , b ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
class GFG { static int number0f2s ( int n ) { int count = 0 ; while ( n > 0 ) { if ( n % 10 == 2 ) count ++ ; n = n / 10 ; } return count ; } static int numberOf2sinRange ( int n ) { int count = 0 ; for ( int i = 2 ; i <= n ; i ++ ) count += number0f2s ( i ) ; return count ; } public static void main ( String [ ] args ) { System . out . print ( numberOf2sinRange ( 22 ) ) ; System . out . println ( ) ; System . out . print ( numberOf2sinRange ( 100 ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minToggle ( int arr [ ] , int n ) { int zero [ ] = new int [ n + 1 ] ; zero [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { if ( arr [ i - 1 ] == 0 ) zero [ i ] = zero [ i - 1 ] + 1 ; else zero [ i ] = zero [ i - 1 ] ; } int ans = n ; for ( int i = 1 ; i <= n ; ++ i ) ans = Math . min ( ans , i - zero [ i ] + zero [ n ] - zero [ i ] ) ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 0 , 1 , 1 , 0 } ; int n = arr . length ; System . out . println ( minToggle ( arr , n ) ) ; } }

Index/key variables: i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class IsDivisible { static boolean check ( String str ) { int n = str . length ( ) ; if ( ( str . charAt ( n - 1 ) - '0' ) % 2 != 0 ) return false ; int digitSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) digitSum += ( str . charAt ( i ) - '0' ) ; return ( digitSum % 3 == 0 ) ; } public static void main ( String [ ] args ) { String str = "1332" ; if ( check ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: digitSum, i
Iterator variables: i
Class/struct names: IsDivisible
Java program:
import java . io . * ; import java . util . * ; public class Solution { static int res = 0 ; static int checkRecursive ( int num , int x , int k , int n ) { if ( x == 0 ) res ++ ; int r = ( int ) Math . floor ( Math . pow ( num , 1.0 / n ) ) ; for ( int i = k + 1 ; i <= r ; i ++ ) { int a = x - ( int ) Math . pow ( i , n ) ; if ( a >= 0 ) checkRecursive ( num , x - ( int ) Math . pow ( i , n ) , i , n ) ; } return res ; } static int check ( int x , int n ) { return checkRecursive ( x , x , 0 , n ) ; } public static void main ( String [ ] args ) { System . out . println ( check ( 10 , 2 ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: Solution
Java program:
import java . util . * ; class GFG { static int reverseNum ( int n ) { int rem , rev = 0 ; while ( n > 0 ) { rem = n % 10 ; rev = rev * 10 + rem ; n /= 10 ; } return rev ; } static boolean isPalindrom ( int num ) { return num == reverseNum ( num ) ; } static int nthPalindrome ( int n , int k ) { int num = ( int ) Math . pow ( 10 , k - 1 ) ; while ( true ) { if ( isPalindrom ( num ) ) -- n ; if ( n == 0 ) break ; ++ num ; } return num ; } public static void main ( String [ ] args ) { int n = 6 , k = 5 ; System . out . println ( n + " th ▁ palindrome ▁ of ▁ " + k + " ▁ digit ▁ = ▁ " + nthPalindrome ( n , k ) ) ; n = 10 ; k = 6 ; System . out . println ( n + " th ▁ palindrome ▁ of ▁ " + k + " ▁ digit ▁ = ▁ " + nthPalindrome ( n , k ) ) ; } }

Accumulator variables: n
Class/struct names: GFG