dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int solve ( int A [ ] , int N , int K ) { int sum = 0 ; int c = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; if ( A [ i ] == 0 ) c ++ ; } if ( ( K > sum ) || ( ( ( sum + K ) % 2 ) != 0 ) ) return 0 ; sum = ( sum + K ) / 2 ; int dp [ ] [ ] = new int [ N + 1 ] [ sum + 1 ] ; for ( int i = 0 ; i <= sum ; i ++ ) dp [ 0 ] [ i ] = 0 ; for ( int i = 0 ; i <= N ; i ++ ) dp [ i ] [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= sum ; j ++ ) { if ( ( A [ i - 1 ] <= j ) && ( A [ i - 1 ] != 0 ) ) dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + dp [ i - 1 ] [ j - A [ i - 1 ] ] ; else dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; } } return dp [ N ] [ sum ] + ( int ) Math . pow ( 2 , c ) ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 1 , 2 , 3 } ; int N = A . length ; int K = 3 ; System . out . print ( solve ( A , N , K ) ) ; } }

Index/key variables: N, i, j, sum
Accumulator variables: c, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static int maximizeAnd ( int i , int mask , int A [ ] , int B [ ] , int N , int [ ] [ ] dp ) { if ( i == N ) return 0 ; if ( dp [ i ] [ mask ] != - 1 ) return dp [ i ] [ mask ] ; for ( int j = 0 ; j < N ; ++ j ) { if ( ( mask & ( 1 << j ) ) == 0 ) { dp [ i ] [ mask ] = Math . max ( dp [ i ] [ mask ] , ( A [ i ] & B [ j ] ) + maximizeAnd ( i + 1 , mask | ( 1 << j ) , A , B , N , dp ) ) ; } } return dp [ i ] [ mask ] ; } static int maximizeAndUtil ( int A [ ] , int B [ ] , int N ) { int dp [ ] [ ] = new int [ N ] [ ( 1 << N ) + 1 ] ; for ( int dd [ ] : dp ) Arrays . fill ( dd , - 1 ) ; return maximizeAnd ( 0 , 0 , A , B , N , dp ) ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 5 , 7 , 11 } ; int B [ ] = { 2 , 6 , 10 , 12 } ; int N = A . length ; System . out . print ( maximizeAndUtil ( A , B , N ) ) ; } }

Index/key variables: N, i, j, mask
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] [ ] [ ] [ ] dp = new int [ 100 ] [ 2 ] [ 10 ] [ 2 ] ; static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static int noncoprimeCount ( int i , int N , char [ ] S , int bound , int prev , int allZeros ) { if ( i == N ) return 1 ; int val = dp [ i ] [ bound ] [ prev ] [ allZeros ] ; if ( val != - 1 ) return val ; int cnt = 0 ; for ( int j = 0 ; j <= ( bound != 0 ? ( S [ i ] - '0' ) : 9 ) ; ++ j ) { if ( ( __gcd ( j , prev ) != 1 ) || ( i == 0 ) allZeros == 1 ) { cnt += noncoprimeCount ( i + 1 , N , S , bound != 0 & ( j == ( S [ i ] - '0' ) ) ? 1 : 0 , j , ( allZeros != 0 & ( j == 0 ) ) ? 1 : 0 ) ; } } return val = cnt ; } static void noncoprimeCountUtil ( int R ) { String S = String . valueOf ( R ) ; int N = S . length ( ) ; for ( int i = 0 ; i < 100 ; i ++ ) for ( int j = 0 ; j < 2 ; j ++ ) for ( int k = 0 ; k < 10 ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) dp [ i ] [ j ] [ k ] [ l ] = - 1 ; int ans = noncoprimeCount ( 0 , N , S . toCharArray ( ) , 1 , 0 , 1 ) ; System . out . print ( ans - 1 + "NEW_LINE"); } public static void main ( String [ ] args ) { int N = 10000 ; noncoprimeCountUtil ( N ) ; } }

Index/key variables: allZeros, bound, i, j, k, l, prev
Accumulator variables: cnt, i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int ans = 0 ; static int maximumStonesUtil ( int [ ] arr , int n , int i , int [ ] dp ) { if ( i >= n ) return 0 ; ans = dp [ i ] ; if ( ans != - 1 ) return ans ; ans = Integer . MIN_VALUE ; ans = Math . max ( ans , arr [ i ] - maximumStonesUtil ( arr , n , i + 1 , dp ) ) ; if ( i + 1 < n ) ans = Math . max ( ans , arr [ i ] + arr [ i + 1 ] - maximumStonesUtil ( arr , n , i + 2 , dp ) ) ; if ( i + 2 < n ) ans = Math . max ( ans , arr [ i ] + arr [ i + 1 ] + arr [ i + 2 ] - maximumStonesUtil ( arr , n , i + 3 , dp ) ) ; return ans ; } static String maximumStones ( int [ ] arr , int n ) { int [ ] dp = new int [ n ] ; Arrays . fill ( dp , - 1 ) ; int res = maximumStonesUtil ( arr , n , 0 , dp ) ; if ( res > 0 ) return " Player1" ; else if ( res < 0 ) return " Player2" ; else return " Tie " ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 7 } ; int n = arr . length ; System . out . print ( maximumStones ( arr , n ) ) ; } }

Index/key variables: i, n
Class/struct names: GFG
Java program:
class GFG { static int numberOfWays ( int N ) { int [ ] [ ] DP = new int [ N + 1 ] [ 5 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < 5 ; j ++ ) { DP [ i ] [ j ] = 0 ; } } DP [ 1 ] [ 1 ] = 1 ; DP [ 1 ] [ 2 ] = 1 ; DP [ 1 ] [ 3 ] = 1 ; DP [ 1 ] [ 4 ] = 1 ; for ( int i = 2 ; i <= N ; i ++ ) { if ( i - 1 > 0 && DP [ i - 1 ] [ 1 ] > 0 ) DP [ i ] [ 1 ] = DP [ i - 1 ] [ 4 ] ; if ( i - 2 > 0 && DP [ i - 2 ] [ 2 ] > 0 ) DP [ i ] [ 2 ] = DP [ i - 2 ] [ 4 ] ; if ( i - 3 > 0 && DP [ i - 3 ] [ 3 ] > 0 ) DP [ i ] [ 3 ] = DP [ i - 3 ] [ 4 ] ; DP [ i ] [ 4 ] = ( DP [ i ] [ 1 ] + DP [ i ] [ 2 ] + DP [ i ] [ 3 ] ) ; } return DP [ N ] [ 4 ] ; } static public void main ( String [ ] args ) { int N = 15 ; System . out . println ( numberOfWays ( N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int countSortedArrays ( int start , int m , int size , int n ) { if ( size == m ) return 1 ; if ( start > n ) return 0 ; int notTaken = 0 , taken = 0 ; taken = countSortedArrays ( start , m , size + 1 , n ) ; notTaken = countSortedArrays ( start + 1 , m , size , n ) ; return taken + notTaken ; } public static void main ( String [ ] args ) { int n = 2 , m = 3 ; System . out . println ( countSortedArrays ( 1 , m , 0 , n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void maximumSum ( int arr [ ] , int n ) { long [ ] preSum = new long [ n ] ; long sum = 0 ; long maxSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = Math . max ( arr [ i ] , sum + arr [ i ] ) ; maxSum = Math . max ( maxSum , sum ) ; preSum [ i ] = maxSum ; } sum = 0 ; maxSum = 0 ; long [ ] postSum = new long [ n + 1 ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sum = Math . max ( arr [ i ] , sum + arr [ i ] ) ; maxSum = Math . max ( maxSum , sum ) ; postSum [ i ] = maxSum ; } long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . max ( ans , preSum [ i ] + postSum [ i + 1 ] ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 7 , 6 , - 1 , - 4 , - 5 , 7 , 1 } ; maximumSum ( arr , arr . length ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int numberOfUniqueOutcomes ( int N , int S ) { if ( S < N ) return 0 ; if ( N == 1 N == S ) return 1 ; return ( numberOfUniqueOutcomes ( N - 1 , S - 1 ) + numberOfUniqueOutcomes ( N - 1 , S - 2 ) ) ; } public static void main ( String [ ] args ) { int N = 3 , S = 4 ; System . out . println ( numberOfUniqueOutcomes ( N , S ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int mn = - 2147483648 ; static int lisOtimised ( String s ) { int [ ] dp = new int [ 30 ] ; Arrays . fill ( dp , 0 ) ; int N = s . length ( ) ; int lis = mn ; for ( int i = 0 ; i < N ; i ++ ) { int val = ( int ) s . charAt ( i ) - 97 ; int curr = 0 ; for ( int j = 0 ; j < val ; j ++ ) { curr = Math . max ( curr , dp [ j ] ) ; } curr ++ ; lis = Math . max ( lis , curr ) ; dp [ val ] = Math . max ( dp [ val ] , curr ) ; } return lis ; } public static void main ( String [ ] args ) { String s = " fdryutiaghfse " ; System . out . print ( lisOtimised ( s ) ) ; } }

Index/key variables: j, val
Accumulator variables: curr, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int MAX = ( int ) ( 1e9 ) ; static int MinimumLength ( int A [ ] , int N , int K ) { Arrays . sort ( A ) ; int suffix [ ] = new int [ N + 1 ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) suffix [ i ] = suffix [ i + 1 ] + A [ i ] ; int dp [ ] [ ] = new int [ N + 1 ] [ K + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) for ( int j = 0 ; j <= K ; j ++ ) dp [ i ] [ j ] = MAX ; dp [ N ] [ 0 ] = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { for ( int j = K ; j >= 0 ; j -- ) { if ( j <= A [ i ] ) { dp [ i ] [ j ] = A [ i ] ; continue ; } if ( dp [ i + 1 ] [ j - A [ i ] ] == MAX ) dp [ i ] [ j ] = MAX ; else dp [ i ] [ j ] = Math . min ( dp [ i + 1 ] [ j ] , dp [ i + 1 ] [ j - A [ i ] ] + A [ i ] ) ; } } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( suffix [ i ] - dp [ i ] [ K ] >= K ) { return N - i ; } } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 7 , 4 , 5 , 6 , 8 } ; int K = 13 ; int N = arr . length ; System . out . println ( MinimumLength ( arr , N , K ) ) ; } }

Index/key variables: K, N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { final static int size = 20 ; static int [ ] dp = new int [ size ] ; static int ans ; static void insertVector ( int mask ) { for ( int i = 0 ; i < 20 ; i ++ ) { if ( ( mask & 1 << i ) == 0 ) continue ; if ( dp [ i ] == 0 ) { dp [ i ] = mask ; ++ ans ; return ; } mask ^= dp [ i ] ; } } static void maxSizeSet ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { insertVector ( arr [ i ] ) ; } System . out . println ( 1 << ans ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; maxSizeSet ( arr , N ) ; } }

Index/key variables: i, size
Accumulator variables: i, mask
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxSum ( int arr [ ] , int N , int K ) { int [ ] dp = new int [ N + 2 ] ; Arrays . fill ( dp , 0 ) ; int maxval = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( ( i + K * arr [ i ] ) >= N ) { dp [ i ] = arr [ i ] ; } else { dp [ i ] = dp [ i + K * arr [ i ] ] + arr [ i ] ; } maxval = Math . max ( maxval , dp [ i ] ) ; } System . out . print ( maxval ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 3 , 1 , 2 } ; int N = arr . length ; int K = 3 ; maxSum ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxSubmatrixSum ( int [ ] [ ] matrix ) { int r = matrix . length ; int c = matrix [ 0 ] . length ; int maxSubmatrix = 0 ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { for ( int k = i ; k < r ; k ++ ) { for ( int l = j ; l < c ; l ++ ) { int sumSubmatrix = 0 ; for ( int m = i ; m <= k ; m ++ ) { for ( int n = j ; n <= l ; n ++ ) { sumSubmatrix += matrix [ m ] [ n ] ; } } maxSubmatrix = Math . max ( maxSubmatrix , sumSubmatrix ) ; } } } } System . out . println ( maxSubmatrix ) ; } public static void main ( String [ ] args ) { int [ ] [ ] matrix = { { 0 , - 2 , - 7 , 0 } , { 9 , 2 , - 6 , 2 } , { - 4 , 1 , - 4 , 1 } , { - 1 , 8 , 0 , - 2 } } ; maxSubmatrixSum ( matrix ) ; } }

Index/key variables: m, n
Accumulator variables: i, j, k, l, m, n, sumSubmatrix
Iterator variables: i, j, k, l, m, n
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void maximumSubsetSum ( int arr1 [ ] , int arr2 [ ] , int length ) { int dp [ ] = new int [ length + 1 ] ; if ( length == 1 ) { System . out . print ( Math . max ( arr1 [ 0 ] , arr2 [ 0 ] ) ) ; return ; } if ( length == 2 ) { System . out . print ( Math . max ( Math . max ( arr1 [ 1 ] , arr2 [ 1 ] ) , Math . max ( arr1 [ 0 ] , arr2 [ 0 ] ) ) ) ; return ; } else { dp [ 0 ] = Math . max ( arr1 [ 0 ] , arr2 [ 0 ] ) ; dp [ 1 ] = Math . max ( Math . max ( arr1 [ 1 ] , arr2 [ 1 ] ) , Math . max ( arr1 [ 0 ] , arr2 [ 0 ] ) ) ; int index = 2 ; while ( index < length ) { dp [ index ] = Math . max ( Math . max ( arr1 [ index ] , arr2 [ index ] ) , Math . max ( Math . max ( arr1 [ index ] + dp [ index - 2 ] , arr2 [ index ] + dp [ index - 2 ] ) , dp [ index - 1 ] ) ) ; ++ index ; } System . out . print ( dp [ length - 1 ] ) ; } } public static void main ( String [ ] args ) { int arr1 [ ] = { - 1 , - 2 , 4 , - 4 , 5 } ; int arr2 [ ] = { - 1 , - 2 , - 3 , 4 , 10 } ; int length = arr1 . length ; maximumSubsetSum ( arr1 , arr2 , length ) ; } }

Index/key variables: index
Class/struct names: GFG
Java program:
import java . util . * ; import java . util . ArrayList ; import java . util . List ; class GFG { static void minAtEachIndex ( int n , int arr [ ] ) { int dp1 [ ] = new int [ n ] ; int dp2 [ ] = new int [ n ] ; int i ; dp1 [ 0 ] = arr [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) dp1 [ i ] = Math . min ( arr [ i ] , dp1 [ i - 1 ] + 1 ) ; dp2 [ n - 1 ] = arr [ n - 1 ] ; for ( i = n - 2 ; i >= 0 ; i -- ) dp2 [ i ] = Math . min ( arr [ i ] , dp2 [ i + 1 ] + 1 ) ; ArrayList < Integer > v = new ArrayList < Integer > ( ) ; for ( i = 0 ; i < n ; i ++ ) v . add ( Math . min ( dp1 [ i ] , dp2 [ i ] ) ) ; for ( int x : v ) System . out . print ( x + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 2 , 5 , 3 } ; int N = arr . length ; minAtEachIndex ( N , arr ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int totalArrays ( int N , int M ) { int [ ] end_with_one = new int [ N + 1 ] ; int [ ] end_not_with_one = new int [ N + 1 ] ; end_with_one [ 0 ] = 1 ; end_not_with_one [ 0 ] = 0 ; end_with_one [ 1 ] = 0 ; end_not_with_one [ 1 ] = M - 1 ; for ( int i = 2 ; i < N ; i ++ ) { end_with_one [ i ] = end_not_with_one [ i - 1 ] ; end_not_with_one [ i ] = end_with_one [ i - 1 ] * ( M - 1 ) + end_not_with_one [ i - 1 ] * ( M - 2 ) ; } return end_with_one [ N - 1 ] ; } public static void main ( String [ ] args ) { int N = 3 , M = 3 ; int temp = totalArrays ( N , M ) ; int ans = M * temp ; System . out . print ( ans + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int prodOfDigit ( int N ) { int res = 1 ; while ( N > 0 ) { res = res * ( N % 10 ) ; N /= 10 ; } return res ; } static int cntNumRange ( int L , int R , int K ) { int cnt = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( prodOfDigit ( i ) == K ) { cnt ++ ; } } return cnt ; } public static void main ( String [ ] args ) { int L = 20 , R = 10000 , K = 14 ; System . out . print ( cntNumRange ( L , R , K ) ) ; } }

Accumulator variables: N, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static double findMedXOR ( int mat [ ] [ ] , int N , int M ) { int dp [ ] [ ] = new int [ N ] [ M ] ; int med [ ] = new int [ N * M ] ; dp [ 0 ] [ 0 ] = mat [ 0 ] [ 0 ] ; med [ 0 ] = dp [ 0 ] [ 0 ] ; int len = 1 ; for ( int i = 1 ; i < N ; i ++ ) { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] ^ mat [ i ] [ 0 ] ; med [ len ++ ] = dp [ i ] [ 0 ] ; } for ( int i = 1 ; i < M ; i ++ ) { dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] ^ mat [ 0 ] [ i ] ; med [ len ++ ] = dp [ 0 ] [ i ] ; } for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j < M ; j ++ ) { dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ^ dp [ i ] [ j - 1 ] ^ dp [ i - 1 ] [ j - 1 ] ^ mat [ i ] [ j ] ; med [ len ++ ] = dp [ i ] [ j ] ; } } Arrays . sort ( med ) ; if ( len % 2 == 0 ) { return ( med [ ( len / 2 ) ] + med [ ( len / 2 ) - 1 ] ) / 2.0 ; } return med [ len / 2 ] ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 2 } , { 2 , 3 } } ; int N = mat . length ; int M = 2 ; System . out . println ( findMedXOR ( mat , N , M ) ) ; } }

Index/key variables: M, N, i, j
Accumulator variables: i, j, len
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void countWaysToTileBoard ( int N ) { int dp [ ] = new int [ N + 1 ] ; dp [ 0 ] = 1 ; dp [ 1 ] = 2 ; for ( int i = 2 ; i <= N ; i ++ ) { dp [ i ] = ( 2 * dp [ i - 1 ] + dp [ i - 2 ] ) ; } System . out . print ( dp [ N ] ) ; } public static void main ( String [ ] args ) { int N = 2 ; countWaysToTileBoard ( N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void FindSub ( String str , String res , int i ) { if ( i == str . length ( ) ) { if ( res . length ( ) > 0 ) { System . out . print ( res + " ▁ " ) ; } return ; } char ch = str . charAt ( i ) ; FindSub ( str , res , i + 1 ) ; FindSub ( str , res + ch , i + 1 ) ; FindSub ( str , res + ( int ) ch , i + 1 ) ; ; } public static void main ( String [ ] args ) { String str = " ab " ; String res = " " ; int N = str . length ( ) ; FindSub ( str , res , 0 ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int MinOp ( int N ) { if ( N <= 1 ) return N ; int bit = ( int ) ( Math . log ( N ) / Math . log ( 2 ) ) + 1 ; return ( ( 1 << bit ) - 1 ) - MinOp ( N - ( 1 << ( bit - 1 ) ) ) ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . println ( MinOp ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int maxProductPath ( int [ ] [ ] grid ) { int n = grid . length ; int m = grid [ 0 ] . length ; int [ ] [ ] maxPath = new int [ n ] [ m ] ; int [ ] [ ] minPath = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int mn = Integer . MAX_VALUE ; int mx = Integer . MIN_VALUE ; if ( i == 0 && j == 0 ) { mx = grid [ i ] [ j ] ; mn = grid [ i ] [ j ] ; } if ( i > 0 ) { int tempmx = Math . max ( ( maxPath [ i - 1 ] [ j ] * grid [ i ] [ j ] ) , ( minPath [ i - 1 ] [ j ] * grid [ i ] [ j ] ) ) ; mx = Math . max ( mx , tempmx ) ; int tempmn = Math . min ( ( maxPath [ i - 1 ] [ j ] * grid [ i ] [ j ] ) , ( minPath [ i - 1 ] [ j ] * grid [ i ] [ j ] ) ) ; mn = Math . min ( mn , tempmn ) ; } if ( j > 0 ) { int tempmx = Math . max ( ( maxPath [ i ] [ j - 1 ] * grid [ i ] [ j ] ) , ( minPath [ i ] [ j - 1 ] * grid [ i ] [ j ] ) ) ; mx = Math . max ( mx , tempmx ) ; int tempmn = Math . min ( ( maxPath [ i ] [ j - 1 ] * grid [ i ] [ j ] ) , ( minPath [ i ] [ j - 1 ] * grid [ i ] [ j ] ) ) ; mn = Math . min ( mn , tempmn ) ; } maxPath [ i ] [ j ] = mx ; minPath [ i ] [ j ] = mn ; } } if ( maxPath [ n - 1 ] [ m - 1 ] < 0 ) { return - 1 ; } else { return ( maxPath [ n - 1 ] [ m - 1 ] ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 1 , - 2 , 1 } , { 1 , - 2 , 1 } , { 3 , - 4 , 1 } } ; System . out . println ( maxProductPath ( mat ) ) ; } }

Index/key variables: i, j, m, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int removeSmallestSubarray ( int arr [ ] , int S , int n , int k ) { int target_remainder = S % k ; HashMap < Integer , Integer > map1 = new HashMap < > ( ) ; map1 . put ( 0 , - 1 ) ; int curr_remainder = 0 ; int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { curr_remainder = ( curr_remainder + arr [ i ] + k ) % k ; map1 . put ( curr_remainder , i ) ; int mod = ( curr_remainder - target_remainder + k ) % k ; if ( map1 . containsKey ( mod ) ) { res = Math . min ( res , i - map1 . get ( mod ) ) ; } } if ( res == Integer . MAX_VALUE res == n ) { res = - 1 ; } return res ; } static int smstSubmatDeleted ( int [ ] [ ] mat , int N , int M , int K ) { int S = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) S += mat [ i ] [ j ] ; } int min_area = N * M ; int left = 0 ; int right = 0 ; int width ; int area ; int [ ] prefixRowSum = new int [ N ] ; for ( left = 0 ; left < M ; left ++ ) { Arrays . fill ( prefixRowSum , 0 ) ; for ( right = left ; right < M ; right ++ ) { for ( int i = 0 ; i < N ; i ++ ) { prefixRowSum [ i ] += mat [ i ] [ right ] ; } width = removeSmallestSubarray ( prefixRowSum , S , N , K ) ; if ( width != - 1 ) { area = ( right - left + 1 ) * ( width ) ; if ( area < min_area ) { min_area = area ; } } } } return min_area ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 6 , 2 , 6 } , { 3 , 2 , 8 } , { 2 , 5 , 3 } } ; int K = 3 ; int N = mat . length ; int M = mat [ 0 ] . length ; System . out . print ( smstSubmatDeleted ( mat , N , M , K ) ) ; } }

Index/key variables: N, i, j, right
Accumulator variables: S, i, j, left, right
Iterator variables: i, j, left, right
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static int countstrings ( int n , int start ) { if ( n == 0 ) { return 1 ; } int cnt = 0 ; for ( int i = start ; i < 5 ; i ++ ) { cnt += countstrings ( n - 1 , i ) ; } return cnt ; } static int countVowelStrings ( int n ) { return countstrings ( n , 0 ) ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . print ( countVowelStrings ( n ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static int findNumberOfStrings ( int n ) { return ( n + 1 ) * ( n + 2 ) * ( n + 3 ) * ( n + 4 ) / 24 ; } public static void main ( String [ ] args ) { int N = 2 ; System . out . print ( findNumberOfStrings ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int mod = ( int ) 1e9 + 7 ; static int findTotalPath ( int X , int n , ArrayList < Integer > dp ) { if ( X == 0 ) { return 1 ; } int ans = 0 ; if ( dp . get ( X ) != - 1 ) { return dp . get ( X ) ; } for ( int i = 1 ; i <= Math . min ( X , n ) ; ++ i ) { ans += findTotalPath ( X - i , n , dp ) % mod ; ans %= mod ; } dp . set ( X , ans ) ; return ans ; } public static void main ( String [ ] args ) { int n = 3 , X = 2 ; ArrayList < Integer > dp = new ArrayList < Integer > ( Collections . nCopies ( X + 1 , - 1 ) ) ; System . out . print ( findTotalPath ( X , n , dp ) ) ; } }

Accumulator variables: ans
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] [ ] bin = new int [ 3000 ] [ 3000 ] ; static void countWays ( int [ ] arr ) { int mod = ( int ) 1e9 + 7 ; bin [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i < 3000 ; i ++ ) { bin [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { bin [ i ] [ j ] = ( bin [ i - 1 ] [ j ] + bin [ i - 1 ] [ j - 1 ] ) % mod ; } } int n = 0 ; for ( int x : arr ) n += x ; int [ ] ways = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { ways [ i ] = 1 ; for ( int j = 0 ; j < arr . length ; j ++ ) { ways [ i ] = ( ways [ i ] * bin [ arr [ j ] + i - 1 ] [ i - 1 ] ) % mod ; } for ( int j = 1 ; j < i ; j ++ ) { ways [ i ] = ( ( ways [ i ] - bin [ i ] [ j ] * ways [ j ] ) % mod + mod ) % mod ; } } int ans = 0 ; for ( int x : ways ) ans = ( ans + x ) % mod ; System . out . print ( ans + "NEW_LINE"); } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 1 } ; countWays ( arr ) ; } }

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