dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static void findAandB ( double N ) { double val = N * N - 4.0 * N ; if ( val < 0 ) { System . out . println ( " NO " ) ; return ; } double a = ( N + Math . sqrt ( val ) ) / 2.0 ; double b = ( N - Math . sqrt ( val ) ) / 2.0 ; System . out . println ( " a ▁ = ▁ " + a ) ; System . out . println ( " b ▁ = ▁ " + b ) ; } public static void main ( String [ ] args ) { double N = 69.0 ; findAandB ( N ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int minOperations ( int [ ] A , int n ) { if ( ( n & 1 ) > 0 ) return - 1 ; int zeros = 0 , consZeros = 0 , ones = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( A [ i ] == 0 ) zeros ++ ; else ones ++ ; if ( i + 1 < n ) { if ( A [ i ] == 0 && A [ i + 1 ] == 0 ) consZeros ++ ; } } if ( A [ 0 ] == A [ n - 1 ] && A [ 0 ] == 0 ) consZeros ++ ; if ( zeros == ones ) return consZeros ; else return - 1 ; } public static void main ( String [ ] args ) { int [ ] A = new int [ ] { 1 , 1 , 0 , 0 } ; int n = A . length ; System . out . println ( minOperations ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: consZeros, ones, zeros
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countdig ( int m ) { if ( m == 0 ) return 0 ; else return 1 + countdig ( m / 10 ) ; } static int countSteps ( int x ) { int c = 0 ; int last = x ; while ( last > 0 ) { int digits = countdig ( last ) ; digits -= 1 ; int divisor = ( int ) Math . pow ( 10 , digits ) ; int first = last / divisor ; int lastnumber = first * divisor ; int skipped = ( last - lastnumber ) / first ; skipped += 1 ; c += skipped ; last = last - ( first * skipped ) ; } return c ; } public static void main ( String [ ] args ) { int n = 14 ; System . out . println ( countSteps ( n ) ) ; } }

Accumulator variables: c, digits, skipped
Class/struct names: GFG
Java program:
import java . util . * ; class Solution { static long power ( long x , long y , long p ) { while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } static long gcd ( long a , long b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static long powerGCD ( long a , long b , long n ) { long e = power ( a , n , b ) ; return gcd ( e , b ) ; } public static void main ( String args [ ] ) { long a = 5 , b = 4 , n = 2 ; System . out . print ( powerGCD ( a , b , n ) ) ; } }

Class/struct names: Solution
Java program:
public class GFG { static boolean allOddDigits ( int n ) { while ( n != 0 ) { if ( ( n % 10 ) % 2 == 0 ) return false ; n /= 10 ; } return true ; } static int largestNumber ( int n ) { if ( n % 2 == 0 ) n -- ; for ( int i = n ; ; i -= 2 ) if ( allOddDigits ( i ) ) return i ; } public static void main ( String [ ] args ) { int N = 23 ; System . out . println ( largestNumber ( N ) ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int largestNumber ( int n ) { String s = " " ; int duplicate = n ; while ( n > 0 ) { s = ( char ) ( n % 10 + 48 ) + s ; n /= 10 ; } int index = - 1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ( ( int ) ( s . charAt ( i ) - '0' ) % 2 & 1 ) == 0 ) { index = i ; break ; } } if ( index == - 1 ) return duplicate ; int num = 0 ; for ( int i = 0 ; i < index ; i ++ ) num = num * 10 + ( int ) ( s . charAt ( i ) - '0' ) ; num = num * 10 + ( ( int ) s . charAt ( index ) - ( int ) ( '0' ) - 1 ) ; for ( int i = index + 1 ; i < s . length ( ) ; i ++ ) num = num * 10 + 9 ; return num ; } public static void main ( String [ ] args ) { int N = 24578 ; System . out . println ( largestNumber ( N ) ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static int countNumbers ( int N ) { return ( int ) Math . sqrt ( N ) - 1 ; } public static void main ( String args [ ] ) { int N = 36 ; System . out . println ( countNumbers ( N ) ) ; } }

Class/struct names: solution
Java program:
class GFG { static int countOrderedPairs ( int N ) { int count_pairs = 0 ; for ( int i = 1 ; i <= ( int ) Math . sqrt ( N - 1 ) ; ++ i ) { for ( int j = i ; j * i < N ; ++ j ) ++ count_pairs ; } count_pairs *= 2 ; count_pairs -= ( int ) ( Math . sqrt ( N - 1 ) ) ; return count_pairs ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( countOrderedPairs ( N ) ) ; } }

Accumulator variables: count_pairs
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void pairwiseDifference ( int arr [ ] , int n ) { int diff ; for ( int i = 0 ; i < n - 1 ; i ++ ) { diff = Math . abs ( arr [ i ] - arr [ i + 1 ] ) ; System . out . print ( diff + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 10 , 15 , 5 , 6 } ; int n = arr . length ; pairwiseDifference ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static long sumAP ( long n , long d ) { n /= d ; return ( n ) * ( 1 + n ) * d / 2 ; } static long sumMultiples ( long n ) { n -- ; return sumAP ( n , 2 ) + sumAP ( n , 5 ) - sumAP ( n , 10 ) ; } public static void main ( String [ ] args ) { long n = 20 ; System . out . println ( sumMultiples ( n ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
Java program:
class geeksforgeeks { static int markingScheme ( int N , int answerKey [ ] , int studentAnswer [ ] ) { int positive = 0 , negative = 0 , notattempt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( studentAnswer [ i ] == 0 ) notattempt ++ ; else if ( answerKey [ i ] == studentAnswer [ i ] ) positive ++ ; else if ( answerKey [ i ] != studentAnswer [ i ] ) negative ++ ; } return ( positive * 3 ) + ( negative * - 1 ) ; } public static void main ( String args [ ] ) { int answerKey [ ] = { 1 , 2 , 3 , 4 , 1 } ; int studentAnswer [ ] = { 1 , 2 , 3 , 4 , 0 } ; int N = answerKey . length ; int marking_Scheme = markingScheme ( N , answerKey , studentAnswer ) ; System . out . println ( marking_Scheme ) ; } }

Index/key variables: i
Accumulator variables: i, negative, notattempt, positive
Iterator variables: i
Class/struct names: geeksforgeeks
Java program:
class GFG { static int MAX = 10000 ; static boolean [ ] prime = new boolean [ MAX + 1 ] ; static void SieveOfEratosthenes ( ) { prime [ 1 ] = true ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == false ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = true ; } } } static int solve ( int n ) { int count = 0 , num = 1 ; int prod = 1 ; while ( count < n ) { if ( ! prime [ num ] ) { prod *= num ; count ++ ; } num ++ ; } return prod ; } public static void main ( String [ ] args ) { SieveOfEratosthenes ( ) ; int n = 5 ; System . out . println ( solve ( n ) ) ; } }

Index/key variables: i, num, p
Accumulator variables: count, i, num, p, prod
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int divisor ( int a ) { int div = 1 , count = 0 ; for ( int i = 2 ; i <= Math . sqrt ( a ) ; i ++ ) { while ( a % i == 0 ) { count ++ ; a = a / i ; } div = div * ( count + 1 ) ; count = 0 ; } if ( a > 1 ) { div = div * ( 2 ) ; } return div ; } static int OddDivCount ( int a , int b ) { int res = 0 ; for ( int i = a ; i <= b ; ++ i ) { int divCount = divisor ( i ) ; if ( divCount % 2 == 1 ) { ++ res ; } } return res ; } public static void main ( String [ ] args ) { int a = 1 , b = 10 ; System . out . println ( OddDivCount ( a , b ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean Check_is_possible ( int l , int r , int k ) { int div_count = ( r / k ) - ( l / k ) ; if ( l % k == 0 ) { div_count ++ ; } return ( div_count > 1 ) ; } public static void main ( String [ ] args ) { int l = 30 , r = 70 , k = 10 ; if ( Check_is_possible ( l , r , k ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

Accumulator variables: div_count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int nth_group ( int n ) { return n * ( 2 * ( int ) Math . pow ( n , 2 ) + 1 ) ; } public static void main ( String arr [ ] ) { int N = 5 ; System . out . println ( nth_group ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printPossible ( int a , int b , int c ) { if ( ( a + b + c ) % 2 != 0 a + b < c ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } public static void main ( String [ ] args ) { int a = 2 , b = 4 , c = 2 ; printPossible ( a , b , c ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPerfectPower ( int n ) { if ( n == 1 ) { return true ; } for ( int x = 2 ; x <= Math . sqrt ( n ) ; x ++ ) { int y = 2 ; int p = ( int ) Math . pow ( x , y ) ; while ( p <= n && p > 0 ) { if ( p == n ) { return true ; } y ++ ; p = ( int ) Math . pow ( x , y ) ; } } return false ; } static boolean isStrongNumber ( int n ) { HashMap < Integer , Integer > count = new HashMap < Integer , Integer > ( ) ; while ( n % 2 == 0 ) { n = n / 2 ; if ( count . containsKey ( 2 ) ) { count . put ( 2 , count . get ( 2 ) + 1 ) ; } else { count . put ( 2 , 1 ) ; } } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { n = n / i ; if ( count . containsKey ( i ) ) { count . put ( i , count . get ( i ) + 1 ) ; } else { count . put ( i , 1 ) ; } } } if ( n > 2 ) { if ( count . containsKey ( n ) ) { count . put ( n , count . get ( n ) + 1 ) ; } else { count . put ( n , 1 ) ; } } int flag = 0 ; for ( Map . Entry < Integer , Integer > b : count . entrySet ( ) ) { if ( b . getValue ( ) == 1 ) { flag = 1 ; break ; } } if ( flag == 1 ) { return false ; } else { return true ; } } static boolean isTrojan ( int n ) { if ( ! isPerfectPower ( n ) && isStrongNumber ( n ) ) { return true ; } else { return false ; } } public static void main ( String [ ] args ) { int n = 108 ; if ( isTrojan ( n ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Accumulator variables: i, x, y
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void Sum_upto_nth_Term ( int n ) { int r = n * ( n + 1 ) * ( 2 * n + 7 ) / 3 ; System . out . println ( r ) ; } public static void main ( String [ ] args ) { int N = 5 ; Sum_upto_nth_Term ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int CalculateDifference ( int arr [ ] , int n ) { int max_val = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max_val ) max_val = arr [ i ] ; } boolean [ ] prime = new boolean [ max_val + 1 ] ; for ( int i = 0 ; i <= max_val ; i ++ ) prime [ i ] = true ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } int S1 = 0 , S2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { S1 += arr [ i ] ; } else if ( arr [ i ] != 1 ) { S2 += arr [ i ] ; } } return Math . abs ( S2 - S1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 10 , 15 , 7 } ; int n = arr . length ; System . out . println ( CalculateDifference ( arr , n ) ) ; } }

Index/key variables: i, p
Accumulator variables: S1, S2, i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
public class GFG { static double sum ( int x , int n ) { double total = 1.0 ; double previous = 1.0 ; for ( int i = 1 ; i <= n ; i ++ ) { previous = ( previous * x ) / ( i + 1 ) ; total = total + previous ; } return total ; } public static void main ( String [ ] args ) { int x = 5 , n = 4 ; System . out . print ( " Sum ▁ is : ▁ " + sum ( x , n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int numberOfDivisors ( int num ) { int c = 0 ; for ( int i = 1 ; i <= num ; i ++ ) { if ( num % i == 0 ) { c += 1 ; } } return c ; } static int countNumbers ( int n ) { int c = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( numberOfDivisors ( i ) == 9 ) c += 1 ; } return c ; } public static void main ( String [ ] args ) { int n = 1000 ; System . out . print ( countNumbers ( n ) ) ; } }

Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int numberOfDistinct ( int n ) { int ans = 0 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { ans ++ ; if ( ( n / i ) != i ) ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( numberOfDistinct ( n ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int MAX = 1000 ; static Vector < Integer > arr = new Vector < Integer > ( ) ; static void ulam ( ) { arr . add ( 1 ) ; arr . add ( 2 ) ; for ( int i = 3 ; i < MAX ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < arr . size ( ) - 1 ; j ++ ) { for ( int k = j + 1 ; k < arr . size ( ) ; k ++ ) { if ( arr . get ( j ) + arr . get ( k ) == i ) { count ++ ; } if ( count > 1 ) break ; } if ( count > 1 ) break ; } if ( count == 1 ) { arr . add ( i ) ; } } } public static void main ( String [ ] args ) { ulam ( ) ; int n = 9 ; System . out . println ( arr . get ( n - 1 ) ) ; } }

Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
public class GFG { static int NumberOfRectangles ( int n , int m ) { if ( n % 2 == 0 ) return ( n / 2 ) * m ; else if ( m % 2 == 0 ) return ( m / 2 ) * n ; return ( n * m - 1 ) / 2 ; } public static void main ( String args [ ] ) { int n = 3 , m = 3 ; System . out . println ( NumberOfRectangles ( n , m ) ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static long findNumUtil ( long res , int a , int aCount , int b , int bCount , int n ) { if ( res > 1e11 ) return ( long ) 1e11 ; if ( aCount == bCount && res >= n ) return res ; return Math . min ( findNumUtil ( res * 10 + a , a , aCount + 1 , b , bCount , n ) , findNumUtil ( res * 10 + b , a , aCount , b , bCount + 1 , n ) ) ; } static int findNum ( int n , int a , int b ) { int result = 0 ; int aCount = 0 ; int bCount = 0 ; return ( int ) findNumUtil ( result , a , aCount , b , bCount , n ) ; } public static void main ( String args [ ] ) { int N = 4500 ; int A = 4 ; int B = 7 ; System . out . println ( findNum ( N , A , B ) ) ; } }

Class/struct names: GFG
Java program:
public class Improve { public static void main ( String args [ ] ) { int n = 7 ; int k = 3 ; if ( n % k == 0 ) System . out . println ( n / k + " ▁ " + n / k ) ; else System . out . println ( ( n - ( n % k ) ) / k + " ▁ " + ( ( ( n - ( n % k ) ) / k ) + 1 ) ) ; } }

Class/struct names: Improve
Java program:
import java . io . * ; class GFG { public static void main ( String [ ] args ) { float m = 50 , n = 5 , x = 67 , h = 2927 ; int z = ( int ) ( Math . ceil ( h / 60 * 1.0 ) ) ; if ( z <= n ) System . out . println ( z * m ) ; else System . out . println ( n * m + ( z - n ) * x ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static double sumProductDifference ( int a , int b , int c , int d , int e ) { double rootSum = ( double ) ( - 1 * b ) / a ; double rootProduct = ( double ) e / a ; return Math . abs ( rootSum - rootProduct ) ; } public static void main ( String args [ ] ) { System . out . println ( sumProductDifference ( 8 , 4 , 6 , 4 , 1 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int numberOfSolutions ( int n ) { int c = 0 ; for ( int x = 0 ; x <= n ; ++ x ) if ( n == x + ( n ^ x ) ) ++ c ; return c ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . print ( numberOfSolutions ( n ) ) ; } }

Iterator variables: x
Class/struct names: GFG
Java program:
public class GFG { static int minimumLectures ( int m , int n ) { int ans = 0 ; if ( n < ( int ) Math . ceil ( 0.75 * m ) ) ans = ( int ) Math . ceil ( ( ( 0.75 * m ) - n ) / 0.25 ) ; else ans = 0 ; return ans ; } public static void main ( String [ ] args ) { int M = 9 , N = 1 ; System . out . println ( minimumLectures ( M , N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countNumbers ( int N ) { return ( int ) ( Math . pow ( 10 , N ) - Math . pow ( 8 , N ) ) / 2 ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( countNumbers ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static final int MAX = 10000 ; static int prefix [ ] = new int [ MAX + 1 ] ; static void buildPrefix ( ) { boolean prime [ ] = new boolean [ MAX + 1 ] ; for ( int i = 0 ; i < MAX + 1 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } prefix [ 0 ] = prefix [ 1 ] = 0 ; for ( int p = 2 ; p <= MAX ; p ++ ) { prefix [ p ] = prefix [ p - 1 ] ; if ( prime [ p ] == true ) prefix [ p ] += p ; } } static int sumPrimeRange ( int L , int R ) { buildPrefix ( ) ; return prefix [ R ] - prefix [ L - 1 ] ; } public static void main ( String args [ ] ) { int L = 10 , R = 20 ; System . out . println ( sumPrimeRange ( L , R ) ) ; } }

Index/key variables: R, i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int calculateSum ( int n ) { return 2 * ( n * ( n + 1 ) * ( 2 * n + 1 ) / 6 ) + n * ( n + 1 ) / 2 + 2 * ( n ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( " Sum ▁ = ▁ " + calculateSum ( n ) ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static void checkSolution ( int a , int b , int c ) { if ( ( ( b * b ) - ( 4 * a * c ) ) > 0 ) System . out . println ( "2 ▁ solutions " ) ; else if ( ( ( b * b ) - ( 4 * a * c ) ) == 0 ) System . out . println ( "1 ▁ solution " ) ; else System . out . println ( " No ▁ solutions " ) ; } public static void main ( String [ ] args ) { int a = 2 , b = 5 , c = 2 ; checkSolution ( a , b , c ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . BigInteger ; class GFG { static BigInteger Bits ( int kilobytes ) { BigInteger Bits = new BigInteger ( "0" ) ; BigInteger kilo = BigInteger . valueOf ( kilobytes ) ; Bits = kilo . multiply ( BigInteger . valueOf ( 8192 ) ) ; return Bits ; } static BigInteger Bytes ( int kilobytes ) { BigInteger Bytes = new BigInteger ( "0" ) ; BigInteger kilo = BigInteger . valueOf ( kilobytes ) ; Bytes = kilo . multiply ( BigInteger . valueOf ( 1024 ) ) ; return Bytes ; } public static void main ( String args [ ] ) { int kilobytes = 1 ; System . out . print ( kilobytes + " ▁ Kilobytes ▁ = ▁ " + Bytes ( kilobytes ) + " ▁ Bytes ▁ and ▁ " + Bits ( kilobytes ) + " ▁ Bits . " ) ; } }

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

Class/struct names: GFG
Java program:
public class GFG { static int sum ( int x , int y , int n ) { int sum1 = ( int ) ( ( Math . pow ( x , 2 ) * ( Math . pow ( x , 2 * n ) - 1 ) ) / ( Math . pow ( x , 2 ) - 1 ) ) ; int sum2 = ( int ) ( ( x * y * ( Math . pow ( x , n ) * Math . pow ( y , n ) - 1 ) ) / ( x * y - 1 ) ) ; return sum1 + sum2 ; } public static void main ( String args [ ] ) { int x = 2 , y = 2 , n = 2 ; System . out . println ( sum ( x , y , n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printPair ( int g , int l ) { System . out . print ( g + " ▁ " + l ) ; } public static void main ( String [ ] args ) { int g = 3 , l = 12 ; printPair ( g , l ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int calculateSum ( int n ) { int a1 = 1 , a2 = 2 ; int r = 2 ; int d = 1 ; return ( n ) * ( 2 * a1 + ( n - 1 ) * d ) / 2 + a2 * ( int ) ( Math . pow ( r , n ) - 1 ) / ( r - 1 ) ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( " Sum ▁ = ▁ " + calculateSum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { public static long repeatedSum ( long n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } public static long repeatedProduct ( long n ) { long prod = 1 ; while ( n > 0 prod > 9 ) { if ( n == 0 ) { n = prod ; prod = 1 ; } prod *= n % 10 ; n /= 10 ; } return prod ; } public static long maxSumProduct ( long N ) { if ( N < 10 ) return N ; return Math . max ( repeatedSum ( N ) , repeatedProduct ( N ) ) ; } public static void main ( String [ ] args ) { long n = 631 ; System . out . println ( maxSumProduct ( n ) ) ; } }

Accumulator variables: n, prod
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int max_value ( int array [ ] [ ] , int M , int K , int N ) { int [ ] time = new int [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { time [ array [ i ] [ 0 ] ] = array [ i ] [ 1 ] ; } int [ ] [ ] dp = new int [ M ] [ 2 ] ; dp [ 0 ] [ 0 ] = 0 ; dp [ 0 ] [ 1 ] = time [ 0 ] ; for ( int i = 1 ; i < M ; i ++ ) { dp [ i ] [ 0 ] = Math . max ( dp [ i - 1 ] [ 0 ] , dp [ i - 1 ] [ 1 ] ) ; dp [ i ] [ 1 ] = time [ i ] ; if ( i - K >= 0 ) { dp [ i ] [ 1 ] += Math . max ( dp [ i - K ] [ 0 ] , dp [ i - K ] [ 1 ] ) ; } } return Math . max ( dp [ M - 1 ] [ 0 ] , dp [ M - 1 ] [ 1 ] ) ; } public static void main ( String [ ] args ) { int array [ ] [ ] = { { 0 , 10 } , { 4 , 110 } , { 5 , 30 } } ; int N = 3 ; int K = 4 ; int M = 6 ; System . out . println ( max_value ( array , M , K , N ) ) ; } }

Index/key variables: M, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > digits = new Vector < Integer > ( ) ; static boolean [ ] vis = new boolean [ 170 ] ; static int [ ] [ ] [ ] [ ] dp = new int [ 19 ] [ 19 ] [ 2 ] [ 170 ] ; static void ConvertIntoDigit ( int n ) { while ( n > 0 ) { int dig = n % 10 ; digits . add ( dig ) ; n /= 10 ; } Collections . reverse ( digits ) ; } static int solve ( int idx , int k , int tight , int sum ) { if ( idx == digits . size ( ) && k == 0 && sum % 2 == 1 ) { if ( ! vis [ sum ] ) { vis [ sum ] = true ; return 1 ; } return 0 ; } if ( idx > digits . size ( ) ) { return 0 ; } if ( dp [ idx ] [ k ] [ tight ] [ sum ] > 0 ) { return dp [ idx ] [ k ] [ tight ] [ sum ] ; } int j ; if ( idx < digits . size ( ) && tight == 0 ) { j = digits . get ( idx ) ; } else { j = 9 ; } int cnt = 0 ; for ( int i = ( k > 0 ? 0 : 1 ) ; i <= j ; i ++ ) { int newtight = tight ; if ( i < j ) { newtight = 1 ; } if ( i == 0 ) cnt += solve ( idx + 1 , k - 1 , newtight , sum ) ; else cnt += solve ( idx + 1 , k , newtight , sum + i ) ; } return dp [ idx ] [ k ] [ tight ] [ sum ] = cnt ; } public static void main ( String [ ] args ) { int N , k ; N = 169 ; k = 2 ; ConvertIntoDigit ( N ) ; k = digits . size ( ) - k ; System . out . print ( solve ( 0 , k , 0 , 0 ) ) ; } }

Index/key variables: idx, k, sum, tight
Accumulator variables: cnt, i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSubsets ( int N ) { if ( N <= 2 ) return N ; if ( N == 3 ) return 2 ; int [ ] DP = new int [ N + 1 ] ; DP [ 0 ] = 0 ; DP [ 1 ] = 1 ; DP [ 2 ] = 2 ; DP [ 3 ] = 2 ; for ( int i = 4 ; i <= N ; i ++ ) { DP [ i ] = DP [ i - 2 ] + DP [ i - 3 ] ; } return DP [ N ] ; } public static void main ( String [ ] args ) { int N = 20 ; System . out . print ( countSubsets ( N ) ) ; } }

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