dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static void numberofpairs ( int [ ] [ ] v , int k ) { int n = v . length ; if ( n % 2 == 1 ) { System . out . println ( 0 ) ; return ; } int ans = 0 ; int dp [ ] [ ] = new int [ k ] [ 2 ] ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { dp [ i ] [ j ] = 0 ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( i + j ) % 2 == 0 ) dp [ v [ i ] [ j ] - 1 ] [ 0 ] ++ ; else dp [ v [ i ] [ j ] - 1 ] [ 1 ] ++ ; } } for ( int i = 0 ; i < k ; i ++ ) { for ( int j = i + 1 ; j < k ; j ++ ) { ans += dp [ i ] [ 0 ] * dp [ j ] [ 1 ] ; ans += dp [ i ] [ 1 ] * dp [ j ] [ 0 ] ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 1 , 2 } , { 3 , 4 } } ; int K = 4 ; numberofpairs ( mat , K ) ; } }

Index/key variables: i, j, k
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] [ ] [ ] [ ] dp = new int [ 50 ] [ 50 ] [ 50 ] [ 50 ] ; static int FindMaxS ( int X , int Y , int Z , int n , int [ ] A , int [ ] B , int [ ] C ) { if ( X < 0 Y < 0 Z < 0 ) return Integer . MIN_VALUE ; if ( n < 0 ) return 0 ; if ( dp [ n ] [ X ] [ Y ] [ Z ] != - 1 ) { return dp [ n ] [ X ] [ Y ] [ Z ] ; } int ch = A [ n ] + FindMaxS ( X - 1 , Y , Z , n - 1 , A , B , C ) ; int ca = B [ n ] + FindMaxS ( X , Y - 1 , Z , n - 1 , A , B , C ) ; int co = C [ n ] + FindMaxS ( X , Y , Z - 1 , n - 1 , A , B , C ) ; int no = FindMaxS ( X , Y , Z , n - 1 , A , B , C ) ; int maximum = Math . max ( ch , Math . max ( ca , Math . max ( co , no ) ) ) ; return dp [ n ] [ X ] [ Y ] [ Z ] = maximum ; } public static void main ( String [ ] args ) { int X = 1 ; int Y = 1 ; int Z = 1 ; int [ ] A = { 10 , 0 , 5 } ; int [ ] B = { 5 , 10 , 0 } ; int [ ] C = { 0 , 5 , 10 } ; int n = B . length ; for ( int i = 0 ; i < 50 ; i ++ ) for ( int j = 0 ; j < 50 ; j ++ ) for ( int k = 0 ; k < 50 ; k ++ ) for ( int l = 0 ; l < 50 ; l ++ ) dp [ i ] [ j ] [ k ] [ l ] = - 1 ; System . out . print ( FindMaxS ( X , Y , Z , n - 1 , A , B , C ) ) ; } }

Index/key variables: X, Y, Z, i, j, k, l, n
Accumulator variables: i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int MOD = 1000000007 ; static Integer array [ ] = { 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 } ; static Vector < Integer > MEM = new Vector < Integer > ( Arrays . asList ( array ) ) ; static int mod_pow2 ( int n ) { while ( n >= MEM . size ( ) ) MEM . add ( ( MEM . get ( MEM . size ( ) - 1 ) * 2 ) % MOD ) ; return MEM . get ( n ) ; } static int inversions ( char [ ] bstr ) { int total = 0 , zeros = 0 , questions = 0 ; int j = bstr . length - 1 ; for ( int i = 0 ; i < bstr . length / 2 ; i ++ ) { char temp = bstr [ i ] ; bstr [ i ] = bstr [ j ] ; bstr [ j ] = temp ; j -- ; } for ( char x : bstr ) { int q ; if ( x == '1' ) { int z = zeros * mod_pow2 ( questions ) ; if ( questions == 0 ) q = 0 ; else q = questions * mod_pow2 ( questions - 1 ) ; total = ( total + z + q ) % MOD ; } else if ( x == '0' ) { zeros += 1 ; } else { total *= 2 ; int z = zeros * mod_pow2 ( questions ) ; if ( questions == 0 ) q = 0 ; else q = questions * mod_pow2 ( questions - 1 ) ; total = ( total + z + q ) % MOD ; questions += 1 ; } } return total ; } public static void main ( String [ ] args ) { char S [ ] = " ? 0 ? " . toCharArray ( ) ; System . out . println ( inversions ( S ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, questions, total, zeros
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int minRemovalsUtil ( int [ ] arr ) { int result = 0 ; if ( arr . length < 3 ) { return - 1 ; } int [ ] leftIncreasing = new int [ arr . length ] ; int [ ] rightIncreasing = new int [ arr . length ] ; for ( int i = 1 ; i < arr . length ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ j ] < arr [ i ] ) { leftIncreasing [ i ] = Math . max ( leftIncreasing [ i ] , leftIncreasing [ j ] + 1 ) ; } } } for ( int i = arr . length - 2 ; i >= 0 ; i -- ) { for ( int j = arr . length - 1 ; j > i ; j -- ) { if ( arr [ j ] < arr [ i ] ) { rightIncreasing [ i ] = Math . max ( rightIncreasing [ i ] , rightIncreasing [ j ] + 1 ) ; } } } for ( int i = 0 ; i < arr . length ; i ++ ) { if ( leftIncreasing [ i ] != 0 && rightIncreasing [ i ] != 0 ) { result = Math . max ( result , leftIncreasing [ i ] + rightIncreasing [ i ] ) ; } } return arr . length - ( result + 1 ) ; } public static void minRemovals ( int [ ] arr ) { int ans = minRemovalsUtil ( arr ) ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 1 , 5 , 6 , 2 , 3 , 1 } ; minRemovals ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntNum ( String X , int i , int sum , int tight ) { if ( i >= X . length ( ) sum < 0 ) { if ( sum == 0 ) { return 1 ; } return 0 ; } int res = 0 ; int end = tight != 0 ? X . charAt ( i ) - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { res += cntNum ( X , i + 1 , sum - j , ( tight > 0 & ( j == end ) ) == true ? 1 : 0 ) ; } return res ; } static int UtilCntNumRange ( int L , int R , int Y ) { if ( R == 0 && Y == 0 ) { return 1 ; } String str = String . valueOf ( R ) ; int cntR = cntNum ( str , 0 , Y , 1 ) ; str = String . valueOf ( L - 1 ) ; int cntL = cntNum ( str , 0 , Y , 1 ) ; return ( cntR - cntL ) ; } public static void main ( String [ ] args ) { int L = 20 , R = 10000 , Y = 14 ; System . out . print ( UtilCntNumRange ( L , R , Y ) ) ; } }

Accumulator variables: j, res
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class Gfg { static void bfs ( int n , int [ ] a , ArrayList < ArrayList < Integer > > invGr , int [ ] ans , int parity ) { Queue < Integer > q = new LinkedList < > ( ) ; int [ ] vis = new int [ n + 1 ] ; int [ ] dist = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ( ( a [ i ] + parity ) & 1 ) != 0 ) { q . add ( i ) ; vis [ i ] = 1 ; } } while ( ! q . isEmpty ( ) ) { int v = q . peek ( ) ; q . poll ( ) ; for ( Integer u : invGr . get ( v ) ) { if ( vis [ u ] == 0 ) { dist [ u ] = dist [ v ] + 1 ; vis [ u ] = 1 ; if ( ( a [ u ] + parity ) % 2 == 0 ) { if ( ans [ u ] == - 1 ) ans [ u ] = dist [ u ] ; } q . add ( u ) ; } } } } static void minJumps ( int [ ] a , int [ ] jump , int n ) { ArrayList < ArrayList < Integer > > invGr = new ArrayList < > ( ) ; for ( int i = 0 ; i <= n ; i ++ ) invGr . add ( new ArrayList < Integer > ( ) ) ; int [ ] ans = new int [ n + 1 ] ; Arrays . fill ( ans , - 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i + jump [ i ] >= 1 && i + jump [ i ] <= n ) { invGr . get ( i + jump [ i ] ) . add ( i ) ; } if ( i - jump [ i ] >= 1 && i - jump [ i ] <= n ) { invGr . get ( i - jump [ i ] ) . add ( i ) ; } } bfs ( n , a , invGr , ans , 0 ) ; bfs ( n , a , invGr , ans , 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) { System . out . print ( ans [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 0 , 4 , 2 , 5 , 2 , 1 } ; int [ ] jump = { 0 , 1 , 2 , 3 , 1 , 2 } ; int N = arr . length ; minJumps ( arr , jump , N - 1 ) ; } }

Index/key variables: i, u, v
Accumulator variables: i
Iterator variables: i, u
Class/struct names: Gfg
Java program:
import java . util . * ; class GFG { static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static int findMaxGCD ( int arr [ ] , int N ) { int high = 0 ; for ( int i = 0 ; i < N ; i ++ ) { high = Math . max ( high , arr [ i ] ) ; } int [ ] count = new int [ high + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { count [ arr [ i ] ] += 1 ; } int counter = 0 ; for ( int i = high ; i > 0 ; i -- ) { int j = i ; while ( j <= high ) { if ( count [ j ] > 0 ) counter += count [ j ] ; j += i ; if ( counter == 2 ) return i ; } counter = 0 ; } return 0 ; } static int maxlen ( int i , int j , int arr [ ] , int arr1 [ ] , int N , int maxgcd ) { int a = 1 ; if ( i >= N j >= N ) return 0 ; if ( __gcd ( arr [ i ] , arr1 [ j ] ) == maxgcd && arr [ i ] != arr1 [ j ] ) { a = Math . max ( a , 1 + maxlen ( i , j + 1 , arr , arr1 , N , maxgcd ) ) ; return a ; } return Math . max ( maxlen ( i + 1 , j , arr , arr1 , N , maxgcd ) , maxlen ( i , j + 1 , arr , arr1 , N , maxgcd ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 8 , 5 , 6 } ; int arr1 [ ] = { 1 , 2 , 8 , 5 , 6 } ; int n = arr . length ; Arrays . sort ( arr ) ; int maxgcd = findMaxGCD ( arr , n ) ; System . out . print ( maxlen ( 0 , 0 , arr , arr1 , n , maxgcd ) ) ; } }

Index/key variables: i, j
Accumulator variables: counter, i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static ArrayList < ArrayList < ArrayList < Integer > > > dp ; static int countPaths = 0 ; static boolean isPerfectSquare ( int n ) { double sr = Math . sqrt ( n ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } static void countUniquePaths ( int a [ ] [ ] , int m , int n , int ans ) { dp . get ( 0 ) . get ( 0 ) . add ( a [ 0 ] [ 0 ] ) ; for ( int i = 1 ; i < m ; i ++ ) { a [ i ] [ 0 ] *= a [ i - 1 ] [ 0 ] ; dp . get ( i ) . get ( 0 ) . add ( a [ i ] [ 0 ] ) ; } for ( int i = 1 ; i < n ; i ++ ) { a [ 0 ] [ i ] *= a [ 0 ] [ i - 1 ] ; dp . get ( 0 ) . get ( i ) . add ( a [ 0 ] [ i ] ) ; } for ( int i = 1 ; i < m ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { ArrayList < Integer > top = dp . get ( i - 1 ) . get ( j ) ; ArrayList < Integer > left = dp . get ( i ) . get ( j - 1 ) ; ArrayList < Integer > curr = new ArrayList < > ( ) ; for ( int k = 0 ; k < top . size ( ) ; k ++ ) { curr . add ( top . get ( k ) * a [ i ] [ j ] ) ; } for ( int k = 0 ; k < left . size ( ) ; k ++ ) { curr . add ( left . get ( k ) * a [ i ] [ j ] ) ; } dp . get ( i ) . set ( j , curr ) ; } } for ( Integer i : dp . get ( m - 1 ) . get ( n - 1 ) ) { if ( isPerfectSquare ( i ) ) { countPaths ++ ; } } } public static void main ( String [ ] args ) { int M = 3 , N = 4 ; int mat [ ] [ ] = { { 1 , 2 , 3 , 1 } , { 3 , 1 , 2 , 4 } , { 2 , 3 , 1 , 1 } } ; dp = new ArrayList < > ( ) ; for ( int i = 0 ; i < 105 ; i ++ ) { dp . add ( new ArrayList < > ( ) ) ; for ( int j = 0 ; j < 105 ; j ++ ) dp . get ( i ) . add ( new ArrayList < Integer > ( ) ) ; } countUniquePaths ( mat , M , N , 1 ) ; System . out . println ( countPaths ) ; } }

Index/key variables: i, j
Accumulator variables: countPaths, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int MAX = 100000 ; static int [ ] dp = new int [ MAX + 1 ] ; static List < Integer > denomination = new LinkedList < Integer > ( ) ; static int countMinCoins ( int n , int C [ ] , int m ) { if ( n == 0 ) { dp [ 0 ] = 0 ; return 0 ; } if ( dp [ n ] != - 1 ) return dp [ n ] ; int ret = Integer . MAX_VALUE ; for ( int i = 0 ; i < m ; i ++ ) { if ( C [ i ] <= n ) { int x = countMinCoins ( n - C [ i ] , C , m ) ; if ( x != Integer . MAX_VALUE ) ret = Math . min ( ret , 1 + x ) ; } } dp [ n ] = ret ; return ret ; } static void findSolution ( int n , int C [ ] , int m ) { if ( n == 0 ) { for ( int it : denomination ) { System . out . print ( it + " ▁ " ) ; } return ; } for ( int i = 0 ; i < m ; i ++ ) { if ( n - C [ i ] >= 0 && dp [ n - C [ i ] ] + 1 == dp [ n ] ) { denomination . add ( C [ i ] ) ; findSolution ( n - C [ i ] , C , m ) ; break ; } } } static void countMinCoinsUtil ( int X , int C [ ] , int N ) { for ( int i = 0 ; i < dp . length ; i ++ ) dp [ i ] = - 1 ; int isPossible = countMinCoins ( X , C , N ) ; if ( isPossible == Integer . MAX_VALUE ) { System . out . print ( " - 1" ) ; } else { findSolution ( X , C , N ) ; } } public static void main ( String [ ] args ) { int X = 21 ; int arr [ ] = { 2 , 3 , 4 , 5 } ; int N = arr . length ; countMinCoinsUtil ( X , arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int binCoff ( int n , int r ) { int val = 1 ; int i ; if ( r > ( n - r ) ) { r = ( n - r ) ; } for ( i = 0 ; i < r ; i ++ ) { val *= ( n - i ) ; val /= ( i + 1 ) ; } return val ; } static int findWays ( int n ) { n -- ; int a , b , ans ; a = binCoff ( 2 * n , n ) ; b = a / ( n + 1 ) ; ans = b ; return ans ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . print ( findWays ( n ) ) ; } }

Accumulator variables: i, n, val
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int [ ] [ ] dp = new int [ 1010 ] [ 1010 ] ; static int solve ( String s , String t ) { int n = s . length ( ) ; int r = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { dp [ i ] [ j ] = 0 ; if ( i > 0 ) { dp [ i ] [ j ] = Math . max ( dp [ i - 1 ] [ j ] , dp [ i ] [ j ] ) ; } if ( s . charAt ( i ) == t . charAt ( j ) ) { int ans = 1 ; if ( i > 0 && j > 0 ) { ans = 1 + dp [ i - 1 ] [ j - 1 ] ; } dp [ i ] [ j ] = Math . max ( dp [ i ] [ j ] , ans ) ; r = Math . max ( r , dp [ i ] [ j ] ) ; } } } return ( n - r ) ; } public static void main ( String [ ] args ) { String s = " abcde " ; String t = " edacb " ; System . out . print ( solve ( s , t ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int longestSubstring ( String s , int n ) { Map < Integer , Integer > index = new HashMap < > ( ) ; int answer = 0 ; int mask = 0 ; index . put ( mask , - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { int temp = ( int ) s . charAt ( i ) - 97 ; mask ^= ( 1 << temp ) ; if ( index . containsKey ( mask ) ) { answer = Math . max ( answer , i - index . get ( mask ) ) ; } else index . put ( mask , i ) ; for ( int j = 0 ; j < 26 ; j ++ ) { int mask2 = mask ^ ( 1 << j ) ; if ( index . containsKey ( mask2 ) ) { answer = Math . max ( answer , i - index . get ( mask2 ) ) ; } } } return answer ; } public static void main ( String [ ] args ) { String s = " adbabd " ; int n = s . length ( ) ; System . out . print ( longestSubstring ( s , n ) ) ; } }

Accumulator variables: i, j, mask
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { public static void countNums ( int N ) { int dp [ ] [ ] = new int [ N ] [ 16 ] ; for ( int i = 1 ; i <= 9 ; i ++ ) dp [ 0 ] [ i ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { for ( int k = 0 ; k < 16 ; k ++ ) { int xor = j ^ k ; dp [ i ] [ xor ] += dp [ i - 1 ] [ k ] ; } } } int count = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) count += dp [ N - 1 ] [ i ] ; System . out . println ( count ) ; } public static void main ( String [ ] args ) { int N = 1 ; countNums ( N ) ; } }

Index/key variables: N, i, k, xor
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void SubarrayWithMaxSum ( Vector < Integer > nums ) { int currMax = nums . get ( 0 ) , globalMax = nums . get ( 0 ) ; int endIndex = 0 ; int startIndex = 0 , globalMaxStartIndex = 0 ; for ( int i = 1 ; i < nums . size ( ) ; ++ i ) { if ( nums . get ( i ) > nums . get ( i ) + currMax ) { currMax = nums . get ( i ) ; } else if ( nums . get ( i ) < nums . get ( i ) + currMax ) { currMax = nums . get ( i ) + currMax ; } if ( currMax > globalMax ) { globalMax = currMax ; endIndex = i ; globalMaxStartIndex = startIndex ; } } for ( int i = globalMaxStartIndex ; i <= endIndex ; ++ i ) { System . out . print ( nums . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { Vector < Integer > arr = new Vector < Integer > ( ) ; arr . add ( - 2 ) ; arr . add ( - 5 ) ; arr . add ( 6 ) ; arr . add ( - 2 ) ; arr . add ( - 3 ) ; arr . add ( 1 ) ; arr . add ( 5 ) ; arr . add ( - 6 ) ; SubarrayWithMaxSum ( arr ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int count ( int a [ ] , int M , int N ) { int cnt = 0 ; for ( int i = 1 ; i <= M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i % a [ j ] == 0 ) { cnt ++ ; break ; } } } return cnt ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 5 , 7 } ; int m = 100 ; int n = arr . length ; System . out . print ( count ( arr , m , n ) ) ; } }

Index/key variables: j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int [ ] [ ] dp = new int [ 15 ] [ 10 ] ; static int solve ( int n , int last , int k ) { if ( n == 1 ) { if ( last == k ) { return ( k - 1 ) ; } else { return 1 ; } } if ( dp [ n ] [ last ] == 1 ) return dp [ n ] [ last ] ; if ( last == k ) { return dp [ n ] [ last ] = ( k - 1 ) * solve ( n - 1 , k , k ) + ( k - 1 ) * solve ( n - 1 , 1 , k ) ; } else { return dp [ n ] [ last ] = solve ( n - 1 , k , k ) ; } } public static void main ( String [ ] args ) { int n = 2 , k = 3 ; int x = solve ( n , k , k ) + solve ( n , 1 , k ) ; System . out . print ( x ) ; } }

Index/key variables: last, n
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void print ( int [ ] occ , String s ) { for ( int i = 1 ; i <= s . length ( ) - 1 ; i ++ ) { System . out . print ( s . substring ( 0 , i ) + " ▁ occurs ▁ " + occ [ i ] + " ▁ times . " + "NEW_LINE"); } } static int [ ] prefix_function ( String s ) { int [ ] LPS = new int [ s . length ( ) ] ; LPS [ 0 ] = 0 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { int j = LPS [ i - 1 ] ; while ( j > 0 && s . charAt ( i ) != s . charAt ( j ) ) { j = LPS [ j - 1 ] ; } if ( s . charAt ( i ) == s . charAt ( j ) ) { LPS [ i ] = j + 1 ; } else { LPS [ i ] = 0 ; } } return LPS ; } static void count_occurence ( String s ) { int n = s . length ( ) ; int [ ] LPS = prefix_function ( s ) ; int [ ] occ = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { occ [ LPS [ i ] ] ++ ; } for ( int i = n - 1 ; i > 0 ; i -- ) { occ [ LPS [ i - 1 ] ] += occ [ i ] ; } for ( int i = 0 ; i <= n ; i ++ ) occ [ i ] ++ ; print ( occ , s ) ; } public static void main ( String [ ] args ) { String A = " ABACABA " ; count_occurence ( A ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maximumSum ( int A [ ] , int B [ ] , int length , int X , int Y ) { int l = length ; int l1 = Math . min ( length , X ) ; int l2 = Math . min ( length , Y ) ; int dp [ ] [ ] = new int [ l1 + 1 ] [ l2 + 1 ] ; int max_sum = Integer . MIN_VALUE ; for ( int i = 1 ; i <= l1 ; i ++ ) { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] + A [ i - 1 ] ; max_sum = Math . max ( max_sum , dp [ i ] [ 0 ] ) ; } for ( int i = 1 ; i <= l2 ; i ++ ) { dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + B [ i - 1 ] ; max_sum = Math . max ( max_sum , dp [ 0 ] [ i ] ) ; } for ( int i = 1 ; i <= l1 ; i ++ ) { for ( int j = 1 ; j <= l2 ; j ++ ) { if ( i + j <= l ) dp [ i ] [ j ] = Math . max ( dp [ i - 1 ] [ j ] + A [ i + j - 1 ] , dp [ i ] [ j - 1 ] + B [ i + j - 1 ] ) ; max_sum = Math . max ( dp [ i ] [ j ] , max_sum ) ; } } return max_sum ; } public static void main ( String [ ] args ) { int A [ ] = new int [ ] { 1 , 2 , 3 , 4 , 5 } ; int B [ ] = new int [ ] { 5 , 4 , 3 , 2 , 1 } ; int X = 3 , Y = 2 ; int N = A . length ; System . out . println ( maximumSum ( A , B , N , X , Y ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int reduceZero ( int N ) { int [ ] dp = new int [ N + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) dp [ i ] = ( int ) 1e9 ; dp [ 0 ] = 0 ; for ( int i = 0 ; i <= N ; i ++ ) { for ( char c : String . valueOf ( i ) . toCharArray ( ) ) { dp [ i ] = Math . min ( dp [ i ] , dp [ i - ( c - '0' ) ] + 1 ) ; } } return dp [ N ] ; } public static void main ( String [ ] args ) { int N = 25 ; System . out . print ( reduceZero ( N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: c, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printpenta ( int n ) { if ( n < 0 ) return ; int first = 0 ; int second = 0 ; int third = 0 ; int fourth = 0 ; int fifth = 1 ; int curr = 0 ; if ( n == 0 n == 1 n == 2 n == 3 ) System . out . print ( first + "NEW_LINE"); else if ( n == 5 ) System . out . print ( fifth + "NEW_LINE"); else { for ( int i = 5 ; i < n ; i ++ ) { curr = first + second + third + fourth + fifth ; first = second ; second = third ; third = fourth ; fourth = fifth ; fifth = curr ; } System . out . print ( curr + "NEW_LINE"); } } public static void main ( String [ ] args ) { int n = 10 ; printpenta ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int [ ] [ ] [ ] dp = new int [ 100001 ] [ 20 ] [ 2 ] ; static int possibleBinaries ( int pos , int ones , int sum , int k ) { if ( ones == k ) return 0 ; if ( pos == 0 ) return ( sum == 0 ) ? 1 : 0 ; if ( dp [ pos ] [ ones ] [ sum ] != - 1 ) return dp [ pos ] [ ones ] [ sum ] ; int ret = possibleBinaries ( pos - 1 , ones + 1 , ( sum + 1 ) % 2 , k ) + possibleBinaries ( pos - 1 , 0 , sum , k ) ; dp [ pos ] [ ones ] [ sum ] = ret ; return dp [ pos ] [ ones ] [ sum ] ; } public static void main ( String [ ] args ) { int N = 3 ; int K = 2 ; for ( int i = 0 ; i < 100001 ; i ++ ) { for ( int j = 0 ; j < 20 ; j ++ ) { for ( int l = 0 ; l < 2 ; l ++ ) dp [ i ] [ j ] [ l ] = - 1 ; } } System . out . print ( possibleBinaries ( N , 0 , 0 , K ) ) ; } }

Index/key variables: i, j, l, ones, pos, sum
Accumulator variables: i, j, l
Iterator variables: i, j, l
Class/struct names: GFG
Java program:
class GFG { static int [ ] [ ] [ ] dp = new int [ 101 ] [ 101 ] [ 101 ] ; static int N , M , K ; static int MOD = 1000000007 ; public static void Initialize ( ) { for ( int i = 0 ; i <= 100 ; i ++ ) for ( int j = 0 ; j <= 100 ; j ++ ) for ( int z = 0 ; z <= 100 ; z ++ ) dp [ i ] [ j ] [ z ] = - 1 ; } public static int CountWays ( int i , int j , int k ) { if ( i >= N i < 0 j >= M j < 0 k < 0 ) return 0 ; if ( i == 0 && j == 0 && k == 0 ) return 1 ; if ( dp [ i ] [ j ] [ k ] != - 1 ) return dp [ i ] [ j ] [ k ] ; else dp [ i ] [ j ] [ k ] = ( CountWays ( i + 1 , j , k - 1 ) % MOD + CountWays ( i - 1 , j , k - 1 ) % MOD + CountWays ( i , j - 1 , k - 1 ) % MOD + CountWays ( i , j + 1 , k - 1 ) % MOD + CountWays ( i , j , k - 1 ) % MOD ) % MOD ; return dp [ i ] [ j ] [ k ] ; } public static void main ( String [ ] args ) { N = 3 ; M = 3 ; K = 4 ; Initialize ( ) ; System . out . println ( CountWays ( 0 , 0 , K ) ) ; } }

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