dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class solution { static final int max = 4 ; static int countWays ( int index , int cnt , int dp [ ] [ ] , int n , int m , int k ) { if ( index == n ) { if ( cnt == k ) return 1 ; else return 0 ; } if ( dp [ index ] [ cnt ] != - 1 ) return dp [ index ] [ cnt ] ; int ans = 0 ; ans += countWays ( index + 1 , cnt , dp , n , m , k ) ; ans += ( m - 1 ) * countWays ( index + 1 , cnt + 1 , dp , n , m , k ) ; return dp [ index ] [ cnt ] = ans ; } public static void main ( String args [ ] ) { int n = 3 , m = 3 , k = 2 ; int dp [ ] [ ] = new int [ n + 1 ] [ max ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) for ( int j = 0 ; j < max ; j ++ ) dp [ i ] [ j ] = - 1 ; System . out . println ( m * countWays ( 1 , 0 , dp , n , m , k ) ) ; } }

Index/key variables: cnt, i, index, j, max
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: solution
Java program:
class GFG { static int MAX = 300 ; static int checkFunc ( int i , int j , String st ) { if ( st . charAt ( i ) == ' ( ' && st . charAt ( j ) == ' ) ' ) return 1 ; if ( st . charAt ( i ) == ' ( ' && st . charAt ( j ) == ' ? ' ) return 1 ; if ( st . charAt ( i ) == ' ? ' && st . charAt ( j ) == ' ) ' ) return 1 ; if ( st . charAt ( i ) == ' [ ' && st . charAt ( j ) == ' ] ' ) return 1 ; if ( st . charAt ( i ) == ' [ ' && st . charAt ( j ) == ' ? ' ) return 1 ; if ( st . charAt ( i ) == ' ? ' && st . charAt ( j ) == ' ] ' ) return 1 ; if ( st . charAt ( i ) == ' { ' && st . charAt ( j ) == ' } ' ) return 1 ; if ( st . charAt ( i ) == ' { ' && st . charAt ( j ) == ' ? ' ) return 1 ; if ( st . charAt ( i ) == ' ? ' && st . charAt ( j ) == ' } ' ) return 1 ; return 0 ; } static int countRec ( int start , int end , int dp [ ] [ ] , String st ) { int sum = 0 ; if ( start > end ) return 1 ; if ( dp [ start ] [ end ] != - 1 ) return dp [ start ] [ end ] ; int i , r = 0 ; for ( i = start + 1 ; i <= end ; i += 2 ) { if ( checkFunc ( start , i , st ) == 1 ) { sum = sum + countRec ( start + 1 , i - 1 , dp , st ) * countRec ( i + 1 , end , dp , st ) ; } else if ( st . charAt ( start ) == ' ? ' && st . charAt ( i ) == ' ? ' ) { sum = sum + countRec ( start + 1 , i - 1 , dp , st ) * countRec ( i + 1 , end , dp , st ) * 3 ; } } return dp [ start ] [ end ] = sum ; } static int countWays ( String st ) { int n = st . length ( ) ; if ( n % 2 == 1 ) return 0 ; int dp [ ] [ ] = new int [ MAX ] [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) dp [ i ] [ j ] = - 1 ; return countRec ( 0 , n - 1 , dp , st ) ; } public static void main ( String [ ] args ) { String st = " ( ? ( [ ? ) ] ? } ? " ; System . out . println ( countWays ( st ) ) ; } }

Index/key variables: MAX, end, i, j, start
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static int dp [ ] [ ] [ ] [ ] = new int [ 64 ] [ 64 ] [ 64 ] [ 2 ] ; static int func ( int third , int seta , int setb , int carry , int number ) { if ( dp [ third ] [ seta ] [ setb ] [ carry ] != - 1 ) return dp [ third ] [ seta ] [ setb ] [ carry ] ; int shift = ( number >> third ) ; if ( shift == 0 && seta == 0 && setb == 0 && carry == 0 ) return 1 ; if ( shift == 0 seta < 0 setb < 0 ) return 0 ; int mask = shift & 1 ; dp [ third ] [ seta ] [ setb ] [ carry ] = 0 ; if ( ( mask == 1 ) && carry == 1 ) { dp [ third ] [ seta ] [ setb ] [ carry ] += func ( third + 1 , seta , setb , 0 , number ) + func ( third + 1 , seta - 1 , setb - 1 , 1 , number ) ; } else if ( mask == 1 && carry == 0 ) { dp [ third ] [ seta ] [ setb ] [ carry ] += func ( third + 1 , seta - 1 , setb , 0 , number ) + func ( third + 1 , seta , setb - 1 , 0 , number ) ; } else if ( mask == 0 && carry == 1 ) { dp [ third ] [ seta ] [ setb ] [ carry ] += func ( third + 1 , seta - 1 , setb , 1 , number ) + func ( third + 1 , seta , setb - 1 , 1 , number ) ; } else if ( mask == 0 && carry == 0 ) { dp [ third ] [ seta ] [ setb ] [ carry ] += func ( third + 1 , seta , setb , 0 , number ) + func ( third + 1 , seta - 1 , setb - 1 , 1 , number ) ; } return dp [ third ] [ seta ] [ setb ] [ carry ] ; } static int possibleSwaps ( int a , int b , int c ) { for ( int q = 0 ; q < 64 ; q ++ ) { for ( int r = 0 ; r < 64 ; r ++ ) { for ( int p = 0 ; p < 64 ; p ++ ) { for ( int d = 0 ; d < 2 ; d ++ ) { dp [ q ] [ r ] [ p ] [ d ] = - 1 ; } } } } int ans = func ( 0 , a , b , 0 , c ) ; return ans ; } public static void main ( String [ ] args ) { int x = 2 , y = 2 , c = 20 ; System . out . println ( possibleSwaps ( x , y , c ) ) ; } }

Index/key variables: carry, d, p, q, r, seta, setb, third
Accumulator variables: d, p, q, r
Iterator variables: d, p, q, r
Class/struct names: GfG
Java program:
import java . io . * ; class GFG { static int calculateEvenSum ( int n ) { if ( n <= 0 ) return 0 ; int fibo [ ] = new int [ 2 * n + 1 ] ; fibo [ 0 ] = 0 ; fibo [ 1 ] = 1 ; int sum = 0 ; for ( int i = 2 ; i <= 2 * n ; i ++ ) { fibo [ i ] = fibo [ i - 1 ] + fibo [ i - 2 ] ; if ( i % 2 == 0 ) sum += fibo [ i ] ; } return sum ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( " Even ▁ indexed ▁ Fibonacci ▁ Sum ▁ upto ▁ " + n + " ▁ terms : ▁ " + + calculateEvenSum ( n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX = 1000 ; static int f [ ] = new int [ MAX ] ; static int fib ( int n ) { if ( n == 0 ) { return 0 ; } if ( n == 1 n == 2 ) { return ( f [ n ] = 1 ) ; } if ( f [ n ] == 1 ) { return f [ n ] ; } int k = ( n % 2 == 1 ) ? ( n + 1 ) / 2 : n / 2 ; f [ n ] = ( n % 2 == 1 ) ? ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) : ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } static int calculateEvenSum ( int n ) { return ( fib ( 2 * n + 1 ) - 1 ) ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( " Even ▁ indexed ▁ Fibonacci ▁ Sum ▁ upto ▁ " + n + " ▁ terms : ▁ " + calculateEvenSum ( n ) ) ; } }

Index/key variables: MAX, n
Class/struct names: GFG
Java program:
class GFG { static final int MAX = 32768 ; static int [ ] arr = new int [ 2 * MAX ] ; static void gouldSequence ( ) { arr [ 0 ] = 1 ; int i = 1 ; int p = 1 ; while ( i <= MAX ) { int j = 0 ; while ( j < i ) { arr [ i + j ] = 2 * arr [ j ] ; j ++ ; } i = ( 1 << p ) ; p ++ ; } } static void printSequence ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { gouldSequence ( ) ; int n = 16 ; printSequence ( n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, p
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int factorial ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } static int countWays ( int m , int n ) { m = m - 1 ; n = n - 1 ; return factorial ( m + n ) / ( factorial ( m ) * factorial ( n ) ) ; } public static void main ( String [ ] args ) { int m = 5 ; int n = 5 ; int result = countWays ( m , n ) ; System . out . println ( result ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int MatrixChainOrder ( int p [ ] , int n ) { int [ ] [ ] dp = new int [ n ] [ n ] ; for ( int i = 1 ; i < n ; i ++ ) dp [ i ] [ i ] = 0 ; for ( int L = 1 ; L < n - 1 ; L ++ ) for ( int i = 1 ; i < n - L ; i ++ ) dp [ i ] [ i + L ] = Math . min ( dp [ i + 1 ] [ i + L ] + p [ i - 1 ] * p [ i ] * p [ i + L ] , dp [ i ] [ i + L - 1 ] + p [ i - 1 ] * p [ i + L - 1 ] * p [ i + L ] ) ; return dp [ 1 ] [ n - 1 ] ; } public static void main ( String args [ ] ) { int arr [ ] = { 10 , 20 , 30 , 40 , 30 } ; int size = arr . length ; System . out . print ( " Minimum ▁ number ▁ of ▁ multiplications ▁ is ▁ " + MatrixChainOrder ( arr , size ) ) ; } }

Index/key variables: i, n
Accumulator variables: L, i
Iterator variables: L, i
Class/struct names: GFG
Java program:
public class GFG { static int CommomSubsequencesCount ( String s , String t ) { int n1 = s . length ( ) ; int n2 = t . length ( ) ; int dp [ ] [ ] = new int [ n1 + 1 ] [ n2 + 1 ] ; char ch1 , ch2 ; for ( int i = 0 ; i <= n1 ; i ++ ) { for ( int j = 0 ; j <= n2 ; j ++ ) { dp [ i ] [ j ] = 0 ; } } for ( int i = 1 ; i <= n1 ; i ++ ) { for ( int j = 1 ; j <= n2 ; j ++ ) { ch1 = s . charAt ( i - 1 ) ; ch2 = t . charAt ( j - 1 ) ; if ( ch1 == ch2 ) dp [ i ] [ j ] = 1 + dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j ] ; else dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j ] - dp [ i - 1 ] [ j - 1 ] ; } } return dp [ n1 ] [ n2 ] ; } public static void main ( String args [ ] ) { String s = " ajblqcpdz " ; String t = " aefcnbtdi " ; System . out . println ( CommomSubsequencesCount ( s , t ) ) ; } }

Index/key variables: i, j, n1, n2
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int createPalindrome ( int input , int isOdd ) { int n = input ; int palin = input ; if ( isOdd % 2 == 1 ) { n /= 10 ; } while ( n > 0 ) { palin = palin * 10 + ( n % 10 ) ; n /= 10 ; } return palin ; } static Vector < Integer > generatePalindromes ( int N ) { Vector < Integer > palindromes = new Vector < > ( ) ; int number ; for ( int j = 0 ; j < 2 ; j ++ ) { int i = 1 ; while ( ( number = createPalindrome ( i ++ , j ) ) <= N ) { palindromes . add ( number ) ; } } return palindromes ; } static String reverse ( String input ) { char [ ] temparray = input . toCharArray ( ) ; int left , right = 0 ; right = temparray . length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . valueOf ( temparray ) ; } static int minimumNoOfPalindromes ( int N ) { String a = String . valueOf ( N ) ; String b = String . valueOf ( N ) ; b = reverse ( b ) ; if ( a . equals ( b ) ) { return 1 ; } Vector < Integer > palindromes = generatePalindromes ( N ) ; Collections . sort ( palindromes ) ; int l = 0 , r = palindromes . size ( ) - 1 ; while ( l < r ) { if ( palindromes . get ( l ) + palindromes . get ( r ) == N ) { return 2 ; } else if ( palindromes . get ( l ) + palindromes . get ( r ) < N ) { ++ l ; } else { -- r ; } } return 3 ; } public static void main ( String [ ] args ) { int N = 65 ; System . out . println ( minimumNoOfPalindromes ( N ) ) ; } }

Index/key variables: left, right
Accumulator variables: i, j, left, n, right
Iterator variables: j, left
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int lcs ( int dp [ ] [ ] , String a , String b , int m , int n ) { for ( int i = 0 ; i < 100 ; i ++ ) for ( int j = 0 ; j < 100 ; j ++ ) dp [ i ] [ j ] = - 1 ; if ( m < 0 n < 0 ) { return 0 ; } if ( dp [ m ] [ n ] != - 1 ) return dp [ m ] [ n ] ; int ans = 0 ; if ( a . charAt ( m ) == b . charAt ( n ) ) { ans = ( a . charAt ( m ) - 48 ) + lcs ( dp , a , b , m - 1 , n - 1 ) ; } else ans = Math . max ( lcs ( dp , a , b , m - 1 , n ) , lcs ( dp , a , b , m , n - 1 ) ) ; dp [ m ] [ n ] = ans ; return ans ; } static int costOfString ( String str ) { int cost = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) cost += ( str . charAt ( i ) - 48 ) ; return cost ; } public static void main ( String [ ] args ) { String a , b ; a = "9142" ; b = "1429" ; int dp [ ] [ ] = new int [ 101 ] [ 101 ] ; System . out . print ( ( costOfString ( a ) + costOfString ( b ) - 2 * lcs ( dp , a , b , a . length ( ) - 1 , b . length ( ) - 1 ) ) ) ; } }

Index/key variables: i, j, m, n
Accumulator variables: cost, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxSubArraySum ( int arr [ ] , int size ) { int max_so_far = arr [ 0 ] ; int curr_max = arr [ 0 ] ; for ( int i = 1 ; i < size ; i ++ ) { curr_max = Math . max ( arr [ i ] , curr_max + arr [ i ] ) ; max_so_far = Math . max ( max_so_far , curr_max ) ; } return max_so_far ; } static int lenOfLongSubarrWithGivenSum ( int arr [ ] , int n , int k ) { HashMap < Integer , Integer > um = new HashMap < Integer , Integer > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum == k ) maxLen = i + 1 ; if ( um . containsKey ( sum ) ) um . put ( sum , i ) ; if ( um . containsKey ( sum - k ) ) { if ( maxLen < ( i - um . get ( sum - k ) ) ) maxLen = i - um . get ( sum - k ) ; } } return maxLen ; } static int lenLongSubarrWithMaxSum ( int arr [ ] , int n ) { int maxSum = maxSubArraySum ( arr , n ) ; return lenOfLongSubarrWithGivenSum ( arr , n , maxSum ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , - 2 , - 1 , 3 , - 4 } ; int n = arr . length ; System . out . println ( " Length ▁ of ▁ longest ▁ subarray ▁ " + " having ▁ maximum ▁ sum ▁ = ▁ " + lenLongSubarrWithMaxSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 100 ; static int start , end ; static boolean sumEqualToK ( int arr [ ] , int n , int k ) { HashMap < Integer , Integer > um = new HashMap < Integer , Integer > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum == k ) { maxLen = i + 1 ; start = 0 ; end = i ; } if ( ! um . containsKey ( sum ) ) um . put ( sum , i ) ; if ( um . containsKey ( sum - k ) ) { if ( maxLen < ( i - um . get ( sum - k ) ) ) { maxLen = i - um . get ( sum - k ) ; start = um . get ( sum - k ) + 1 ; end = i ; } } } return ( maxLen != 0 ) ; } static void sumZeroMatrix ( int mat [ ] [ ] , int row , int col , int k ) { int [ ] temp = new int [ row ] ; int area ; boolean sum = false ; int fup = 0 , fdown = 0 , fleft = 0 , fright = 0 ; int maxArea = Integer . MIN_VALUE ; for ( int left = 0 ; left < col ; left ++ ) { temp = memset ( temp , 0 ) ; for ( int right = left ; right < col ; right ++ ) { for ( int i = 0 ; i < row ; i ++ ) temp [ i ] += mat [ i ] [ right ] ; sum = sumEqualToK ( temp , row , k ) ; area = ( end - start + 1 ) * ( right - left + 1 ) ; if ( sum && maxArea < area ) { fup = start ; fdown = end ; fleft = left ; fright = right ; maxArea = area ; } } } if ( fup == 0 && fdown == 0 && fleft == 0 && fright == 0 && mat [ 0 ] [ 0 ] != k ) { System . out . print ( " No ▁ sub - matrix ▁ with ▁ sum ▁ " + k + " ▁ exists " ) ; return ; } System . out . print ( " ( Top , ▁ Left ) : ▁ " + " ( " + fup + " , ▁ " + fleft + " ) " + "NEW_LINE"); System . out . print ( " ( Bottom , ▁ Right ) : ▁ " + " ( " + fdown + " , ▁ " + fright + " ) " + "NEW_LINE"); for ( int j = fup ; j <= fdown ; j ++ ) { for ( int i = fleft ; i <= fright ; i ++ ) System . out . print ( mat [ j ] [ i ] + " ▁ " ) ; System . out . println ( ) ; } } static int [ ] memset ( int [ ] arr , int val ) { for ( int i = 0 ; i < arr . length ; i ++ ) arr [ i ] = val ; return arr ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 7 , - 6 , 5 } , { - 8 , 6 , 7 , - 2 } , { 10 , - 15 , 3 , 2 } , { - 5 , 2 , 0 , 9 } } ; int row = 4 , col = 4 ; int k = 7 ; sumZeroMatrix ( mat , row , col , k ) ; } }

Index/key variables: i, j, right, row
Accumulator variables: i, j, left, right, sum
Iterator variables: i, j, left, right
Boolean variables: sum
Class/struct names: GFG
Java program:
class GFG { static long countPartitions ( int n , int k ) { long [ ] [ ] dp = new long [ 201 ] [ 201 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } if ( dp [ n ] [ k ] >= 0 ) return dp [ n ] [ k ] ; if ( n < k ) return 0 ; if ( n < 2 * k ) return 1 ; long answer = 1 ; for ( int i = k ; i < n ; i ++ ) answer = answer + countPartitions ( n - i , i ) ; dp [ n ] [ k ] = answer ; return answer ; } public static void main ( String [ ] args ) { int n = 10 , k = 3 ; System . out . println ( " Total ▁ Aggregate ▁ sum ▁ of ▁ " + " all ▁ Valid ▁ Partitions : ▁ " + countPartitions ( n , k ) * n ) ; } }

Index/key variables: i, j, k, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int GCD ( int a , int b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } static void makePairs ( Vector < Integer > pairs , int a , int b ) { for ( int i = a ; i <= b ; i ++ ) { int sumOfDigits = 0 , k = i ; while ( k > 0 ) { sumOfDigits += k % 10 ; k /= 10 ; } if ( sumOfDigits <= 162 ) pairs . add ( sumOfDigits ) ; } } static int countCoPrime ( int a , int b ) { Vector < Integer > pairs = new Vector < Integer > ( ) ; makePairs ( pairs , a , b ) ; int count = 0 ; for ( int i = 0 ; i < pairs . size ( ) ; i ++ ) for ( int j = i + 1 ; j < pairs . size ( ) ; j ++ ) if ( GCD ( pairs . get ( i ) , pairs . get ( j ) ) == 1 ) count ++ ; return count ; } public static void main ( String args [ ] ) { int a = 12 , b = 15 ; System . out . println ( countCoPrime ( a , b ) ) ; } }

Accumulator variables: count, i, j, k, sumOfDigits
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static long recursive ( long idx , long sum , long tight , String st , long [ ] [ ] [ ] dp , long num ) { if ( idx == num ) { return sum == 0 ? 1 : 0 ; } if ( dp [ ( int ) idx ] [ ( int ) tight ] [ ( int ) sum ] != - 1 ) return dp [ ( int ) idx ] [ ( int ) tight ] [ ( int ) sum ] ; long newTight ; long ans = 0 ; long d ; for ( d = 0 ; d < 10 ; ++ d ) { newTight = 0 ; if ( tight == 1 && st . charAt ( ( int ) idx ) - '0' < d ) continue ; if ( tight == 1 && st . charAt ( ( int ) idx ) - '0' == d ) newTight = 1 ; if ( sum >= d ) ans += recursive ( idx + 1 , sum - d , ( int ) newTight , st , dp , num ) ; } return dp [ ( int ) idx ] [ ( int ) tight ] [ ( int ) sum ] = ans ; } static ArrayList < Long > formArray ( long N ) { long [ ] [ ] [ ] dp = new long [ 20 ] [ 2 ] [ 166 ] ; for ( long [ ] [ ] innerRow : dp ) { for ( long [ ] innerInnerRow : innerRow ) { Arrays . fill ( innerInnerRow , - 1 ) ; } } String st = String . valueOf ( N ) ; long num = st . length ( ) ; ArrayList < Long > arr = new ArrayList < Long > ( ) ; for ( int i = 1 ; i <= 162 ; ++ i ) { arr . add ( recursive ( 0 , i , 1 , st , dp , num ) ) ; } return arr ; } static long findPair ( long a , long b ) { ArrayList < Long > arr_smaller = formArray ( a - 1 ) ; ArrayList < Long > arr_greater = formArray ( b ) ; for ( int i = 0 ; i < arr_greater . size ( ) ; ++ i ) { arr_greater . set ( i , arr_greater . get ( i ) - arr_smaller . get ( i ) ) ; } long ans = 0 ; for ( int i = 1 ; i <= 162 ; ++ i ) { for ( int j = i + 1 ; j <= 162 ; ++ j ) { if ( gcd ( i , j ) == 1 ) { ans = ( ans + arr_greater . get ( i - 1 ) * arr_greater . get ( j - 1 ) ) ; } } } return ans ; } public static void main ( String [ ] args ) { long a = 12 , b = 15 ; System . out . println ( findPair ( a , b ) ) ; } }

Accumulator variables: ans
Iterator variables: d, i, innerInnerRow, innerRow, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > factors ( int n ) { Vector < Integer > v = new Vector < > ( ) ; v . add ( 1 ) ; for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v . add ( i ) ; if ( n / i != i ) { v . add ( n / i ) ; } } } return v ; } static boolean check ( int n ) { Vector < Integer > v = new Vector < > ( ) ; v = factors ( n ) ; Collections . sort ( v ) ; int r = v . size ( ) ; boolean [ ] [ ] subset = new boolean [ r + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= r ; i ++ ) subset [ i ] [ 0 ] = true ; for ( int i = 1 ; i <= n ; i ++ ) subset [ 0 ] [ i ] = false ; for ( int i = 1 ; i <= r ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( j < v . elementAt ( i - 1 ) ) subset [ i ] [ j ] = subset [ i - 1 ] [ j ] ; else { subset [ i ] [ j ] = subset [ i - 1 ] [ j ] || subset [ i - 1 ] [ j - v . elementAt ( i - 1 ) ] ; } } } if ( ( subset [ r ] [ n ] ) == false ) return false ; else return true ; } public static void main ( String [ ] args ) { int n = 40 ; if ( check ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i, j, n, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class AQW { static int fib [ ] = new int [ 43 ] ; static void fibonacci ( ) { fib [ 0 ] = 1 ; fib [ 1 ] = 2 ; for ( int i = 2 ; i < 43 ; i ++ ) fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } static int rec ( int x , int y , int last ) { if ( y == 0 ) { if ( x == 0 ) return 1 ; return 0 ; } int sum = 0 ; for ( int i = last ; i >= 0 && fib [ i ] * y >= x ; i -- ) { if ( fib [ i ] > x ) continue ; sum += rec ( x - fib [ i ] , y - 1 , i ) ; } return sum ; } public static void main ( String [ ] args ) { fibonacci ( ) ; int n = 13 , k = 3 ; System . out . println ( " Possible ▁ ways ▁ are : ▁ " + rec ( n , k , 42 ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: AQW
Java program:
import java . io . * ; import java . util . * ; class GFG { static int minimumCost ( int cost [ ] , int n ) { int dp [ ] = new int [ n ] ; if ( n == 1 ) return cost [ 0 ] ; dp [ 0 ] = cost [ 0 ] ; dp [ 1 ] = cost [ 1 ] ; for ( int i = 2 ; i < n ; i ++ ) { dp [ i ] = Math . min ( dp [ i - 1 ] , dp [ i - 2 ] ) + cost [ i ] ; } return Math . min ( dp [ n - 2 ] , dp [ n - 1 ] ) ; } public static void main ( String args [ ] ) { int a [ ] = { 16 , 19 , 10 , 12 , 18 } ; int n = a . length ; System . out . print ( minimumCost ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int minimumCost ( int cost [ ] , int n ) { int dp1 = 0 , dp2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int dp0 = cost [ i ] + Math . min ( dp1 , dp2 ) ; dp2 = dp1 ; dp1 = dp0 ; } return Math . min ( dp1 , dp2 ) ; } public static void main ( String args [ ] ) { int a [ ] = { 2 , 5 , 3 , 1 , 7 , 3 , 4 } ; int n = a . length ; System . out . print ( minimumCost ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int size = 1000 ; static int maxCost ( int a [ ] [ ] , int m , int n , int dp [ ] [ ] ) { if ( n < 0 m < 0 ) return ( int ) - 1e9 ; else if ( m == 0 && n == 0 ) return 0 ; else if ( dp [ m ] [ n ] != - 1 ) return dp [ m ] [ n ] ; else { int num = m + n ; if ( ( num & ( num - 1 ) ) == 0 ) return dp [ m ] [ n ] = a [ m ] [ n ] + maxCost ( a , m - 1 , n - 1 , dp ) ; else return dp [ m ] [ n ] = ( a [ m ] [ n ] + Math . max ( maxCost ( a , m - 1 , n , dp ) , maxCost ( a , m , n - 1 , dp ) ) ) ; } } static int answer ( int a [ ] [ ] , int n ) { int dp [ ] [ ] = new int [ size ] [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } return maxCost ( a , n - 1 , n - 1 , dp ) ; } public static void main ( String [ ] args ) { int a [ ] [ ] = { { 1 , 2 , 3 , 1 } , { 4 , 5 , 6 , 1 } , { 7 , 8 , 9 , 1 } , { 1 , 1 , 1 , 1 } } ; int n = 4 ; System . out . println ( answer ( a , n ) ) ; } }

Index/key variables: i, j, m, n, size
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int editDistanceWith2Ops ( String X , String Y ) { int m = X . length ( ) , n = Y . length ( ) ; int L [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) { L [ i ] [ j ] = 0 ; } else if ( X . charAt ( i - 1 ) == Y . charAt ( j - 1 ) ) { L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1 ; } else { L [ i ] [ j ] = Math . max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] ) ; } } } int lcs = L [ m ] [ n ] ; return ( m - lcs ) + ( n - lcs ) ; } public static void main ( String [ ] args ) { String X = " abc " , Y = " acd " ; System . out . println ( editDistanceWith2Ops ( X , Y ) ) ; } }

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