dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static void countCurrency ( int amount ) { int [ ] notes = new int [ ] { 2000 , 500 , 200 , 100 , 50 , 20 , 10 , 5 , 1 } ; int [ ] noteCounter = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( amount >= notes [ i ] ) { noteCounter [ i ] = amount / notes [ i ] ; amount = amount - noteCounter [ i ] * notes [ i ] ; } } System . out . println ( " Currency ▁ Count ▁ - > " ) ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( noteCounter [ i ] != 0 ) { System . out . println ( notes [ i ] + " ▁ : ▁ " + noteCounter [ i ] ) ; } } } public static void main ( String argc [ ] ) { int amount = 868 ; countCurrency ( amount ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
import java . util . Arrays ; public class GFG { static int minSum ( int [ ] A , int n ) { int min_val = Arrays . stream ( A ) . min ( ) . getAsInt ( ) ; return ( min_val * ( n - 1 ) ) ; } static public void main ( String [ ] args ) { int [ ] A = { 3 , 6 , 2 , 8 , 7 , 5 } ; int n = A . length ; System . out . println ( ( minSum ( A , n ) ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . Arrays ; public class GFG { static void NextFit ( int blockSize [ ] , int m , int processSize [ ] , int n ) { int allocation [ ] = new int [ n ] , j = 0 ; Arrays . fill ( allocation , - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; while ( j < m ) { count ++ ; if ( blockSize [ j ] >= processSize [ i ] ) { allocation [ i ] = j ; blockSize [ j ] -= processSize [ i ] ; break ; } j = ( j + 1 ) % m ; } } System . out . print ( " Process No . Process Size Block no . "); for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( i + 1 + " TABSYMBOL TABSYMBOL " + processSize [ i ] + " TABSYMBOL TABSYMBOL " ) ; if ( allocation [ i ] != - 1 ) { System . out . print ( allocation [ i ] + 1 ) ; } else { System . out . print ( " Not ▁ Allocated " ) ; } System . out . println ( " " ) ; } } static public void main ( String [ ] args ) { int blockSize [ ] = { 5 , 10 , 20 } ; int processSize [ ] = { 10 , 20 , 5 } ; int m = blockSize . length ; int n = processSize . length ; NextFit ( blockSize , m , processSize , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int price [ ] = { 2 , 30 , 15 , 10 , 8 , 25 , 80 } ; int profit = 0 ; for ( int i = 1 ; i < price . length ; i ++ ) { int sub = price [ i ] - price [ i - 1 ] ; if ( sub > 0 ) profit += sub ; } System . out . print ( " Maximum ▁ Profit = " + profit ) ; } }

Index/key variables: i
Accumulator variables: i, profit
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node left , right ; } ; static Node newnode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static boolean printPathUtil ( Node node , HashSet < Integer > s , int root_data ) { if ( node == null ) return false ; int rem = root_data - node . data ; if ( s . contains ( rem ) ) return true ; s . add ( node . data ) ; boolean res = printPathUtil ( node . left , s , root_data ) || printPathUtil ( node . right , s , root_data ) ; s . remove ( node . data ) ; return res ; } static boolean isPathSum ( Node root ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; return printPathUtil ( root . left , s , root . data ) || printPathUtil ( root . right , s , root . data ) ; } public static void main ( String [ ] args ) { Node root = newnode ( 8 ) ; root . left = newnode ( 5 ) ; root . right = newnode ( 4 ) ; root . left . left = newnode ( 9 ) ; root . left . right = newnode ( 7 ) ; root . left . right . left = newnode ( 1 ) ; root . left . right . right = newnode ( 12 ) ; root . left . right . right . right = newnode ( 2 ) ; root . right . right = newnode ( 11 ) ; root . right . right . left = newnode ( 3 ) ; System . out . print ( isPathSum ( root ) == true ? " Yes " : " No " ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . ArrayList ; public class LRU { public static void main ( String [ ] args ) { int capacity = 4 ; int arr [ ] = { 7 , 0 , 1 , 2 , 0 , 3 , 0 , 4 , 2 , 3 , 0 , 3 , 2 } ; ArrayList < Integer > s = new ArrayList < > ( capacity ) ; int count = 0 ; int page_faults = 0 ; for ( int i : arr ) { if ( ! s . contains ( i ) ) { if ( s . size ( ) == capacity ) { s . remove ( 0 ) ; s . add ( capacity - 1 , i ) ; } else s . add ( count , i ) ; page_faults ++ ; ++ count ; } else { s . remove ( ( Object ) i ) ; s . add ( s . size ( ) , i ) ; } } System . out . println ( page_faults ) ; } }

Accumulator variables: page_faults
Iterator variables: i
Class/struct names: LRU
Java program:
class Test { static int arr [ ] = new int [ ] { 3 , 7 , 90 , 20 , 10 , 50 , 40 } ; static void findMinAvgSubarray ( int n , int k ) { if ( n < k ) return ; int res_index = 0 ; int curr_sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) curr_sum += arr [ i ] ; int min_sum = curr_sum ; for ( int i = k ; i < n ; i ++ ) { curr_sum += arr [ i ] - arr [ i - k ] ; if ( curr_sum < min_sum ) { min_sum = curr_sum ; res_index = ( i - k + 1 ) ; } } System . out . println ( " Subarray ▁ between ▁ [ " + res_index + " , ▁ " + ( res_index + k - 1 ) + " ] ▁ has ▁ minimum ▁ average " ) ; } public static void main ( String [ ] args ) { int k = 3 ; findMinAvgSubarray ( arr . length , k ) ; } }

Index/key variables: i
Accumulator variables: curr_sum, i
Iterator variables: i
Class/struct names: Test
Java program:
import java . io . * ; class GFG { static int [ ] seg = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; static int computeSegment ( int x ) { if ( x == 0 ) return seg [ 0 ] ; int count = 0 ; while ( x > 0 ) { count += seg [ x % 10 ] ; x /= 10 ; } return count ; } static int elementMinSegment ( int [ ] arr , int n ) { int minseg = computeSegment ( arr [ 0 ] ) ; int minindex = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int temp = computeSegment ( arr [ i ] ) ; if ( temp < minseg ) { minseg = temp ; minindex = i ; } } return arr [ minindex ] ; } static public void main ( String [ ] args ) { int [ ] arr = { 489 , 206 , 745 , 123 , 756 } ; int n = arr . length ; System . out . println ( elementMinSegment ( arr , n ) ) ; } }

Index/key variables: i, minindex
Accumulator variables: count, i, x
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findLargest ( int m , int s ) { if ( s == 0 ) { System . out . print ( m == 1 ? " Largest ▁ number ▁ is ▁ 0" : " Not ▁ possible " ) ; return ; } if ( s > 9 * m ) { System . out . println ( " Not ▁ possible " ) ; return ; } int [ ] res = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { if ( s >= 9 ) { res [ i ] = 9 ; s -= 9 ; } else { res [ i ] = s ; s = 0 ; } } System . out . print ( " Largest ▁ number ▁ is ▁ " ) ; for ( int i = 0 ; i < m ; i ++ ) System . out . print ( res [ i ] ) ; } public static void main ( String [ ] args ) { int s = 9 , m = 2 ; findLargest ( m , s ) ; } }

Index/key variables: i, m
Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static String str ; static int min ( int a , int b ) { return ( a < b ) ? a : b ; } static int findOverlappingPair ( String str1 , String str2 ) { int max = Integer . MIN_VALUE ; int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; for ( int i = 1 ; i <= min ( len1 , len2 ) ; i ++ ) { if ( str1 . substring ( len1 - i ) . compareTo ( str2 . substring ( 0 , i ) ) == 0 ) { if ( max < i ) { max = i ; str = str1 + str2 . substring ( i ) ; } } } for ( int i = 1 ; i <= min ( len1 , len2 ) ; i ++ ) { if ( str1 . substring ( 0 , i ) . compareTo ( str2 . substring ( len2 - i ) ) == 0 ) { if ( max < i ) { max = i ; str = str2 + str1 . substring ( i ) ; } } } return max ; } static String findShortestSuperstring ( String arr [ ] , int len ) { while ( len != 1 ) { int max = Integer . MIN_VALUE ; int l = 0 , r = 0 ; String resStr = " " ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = i + 1 ; j < len ; j ++ ) { int res = findOverlappingPair ( arr [ i ] , arr [ j ] ) ; if ( max < res ) { max = res ; resStr = str ; l = i ; r = j ; } } } len -- ; if ( max == Integer . MIN_VALUE ) arr [ 0 ] += arr [ len ] ; else { arr [ l ] = resStr ; arr [ r ] = arr [ len ] ; } } return arr [ 0 ] ; } public static void main ( String [ ] args ) { String [ ] arr = { " catgc " , " ctaagt " , " gcta " , " ttca " , " atgcatc " } ; int len = arr . length ; System . out . println ( " The ▁ Shortest ▁ Superstring ▁ is ▁ " + findShortestSuperstring ( arr , len ) ) ; } }

Index/key variables: i, j, l, len, r
Accumulator variables: i, j, len
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { static int minJumps ( int arr [ ] , int l , int h ) { if ( h == l ) return 0 ; if ( arr [ l ] == 0 ) return Integer . MAX_VALUE ; int min = Integer . MAX_VALUE ; for ( int i = l + 1 ; i <= h && i <= l + arr [ l ] ; i ++ ) { int jumps = minJumps ( arr , i , h ) ; if ( jumps != Integer . MAX_VALUE && jumps + 1 < min ) min = jumps + 1 ; } return min ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 6 , 3 , 2 , 3 , 6 , 8 , 9 , 5 } ; int n = arr . length ; System . out . print ( " Minimum ▁ number ▁ of ▁ jumps ▁ to ▁ reach ▁ end ▁ is ▁ " + minJumps ( arr , 0 , n - 1 ) ) ; } }

Index/key variables: l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { final static int dp [ ] [ ] = new int [ 1001 ] [ 3001 ] ; static int recBananaCnt ( int A , int B , int C ) { if ( B <= A ) { return 0 ; } if ( B <= C ) { return B - A ; } if ( A == 0 ) { return B ; } if ( dp [ A ] [ B ] != - 1 ) { return dp [ A ] [ B ] ; } int maxCount = Integer . MIN_VALUE ; int tripCount = B % C == 0 ? ( ( 2 * B ) / C ) - 1 : ( ( 2 * B ) / C ) + 1 ; for ( int i = 1 ; i <= A ; i ++ ) { int curCount = recBananaCnt ( A - i , B - tripCount * i , C ) ; if ( curCount > maxCount ) { maxCount = curCount ; dp [ A ] [ B ] = maxCount ; } } return maxCount ; } static int maxBananaCnt ( int A , int B , int C ) { for ( int i = 0 ; i < 1001 ; i ++ ) for ( int j = 0 ; j < 3001 ; j ++ ) dp [ i ] [ j ] = - 1 ; return recBananaCnt ( A , B , C ) ; } public static void main ( String [ ] args ) { int A = 1000 ; int B = 3000 ; int C = 1000 ; System . out . println ( maxBananaCnt ( A , B , C ) ) ; } }

Index/key variables: A, B, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int calculate ( int position , int used , int unused , int P , int M , int dp [ ] [ ] [ ] ) { if ( position == P ) { return unused == 0 ? 1 : 0 ; } if ( dp [ position ] [ used ] [ unused ] != - 1 ) return dp [ position ] [ used ] [ unused ] ; int result = 0 ; if ( unused > 0 ) { result += calculate ( position + 1 , used + 1 , unused - 1 , P , M , dp ) * unused ; } if ( used > M ) { result += calculate ( position + 1 , used , unused , P , M , dp ) * ( used - M ) ; } return dp [ position ] [ used ] [ unused ] = result ; } static int solve ( int N , int P , int M ) { int [ ] [ ] [ ] dp = new int [ 101 ] [ 101 ] [ 101 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { for ( int j = 0 ; j < 101 ; j ++ ) for ( int k = 0 ; k < 101 ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } return calculate ( 0 , 0 , N , P , M , dp ) ; } public static void main ( String [ ] args ) { int N = 2 , M = 0 , P = 3 ; System . out . println ( solve ( N , P , M ) ) ; } }

Index/key variables: i, j, k, position, unused, used
Accumulator variables: i, j, k, result
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static int minJumps ( int arr [ ] , int n ) { int [ ] jumps = new int [ n ] ; int min ; jumps [ n - 1 ] = 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] == 0 ) jumps [ i ] = Integer . MAX_VALUE ; else if ( arr [ i ] >= n - i - 1 ) jumps [ i ] = 1 ; else { min = Integer . MAX_VALUE ; for ( int j = i + 1 ; j < n && j <= arr [ i ] + i ; j ++ ) { if ( min > jumps [ j ] ) min = jumps [ j ] ; } if ( min != Integer . MAX_VALUE ) jumps [ i ] = min + 1 ; else jumps [ i ] = min ; } } return jumps [ 0 ] ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 6 , 1 , 0 , 9 } ; int size = arr . length ; System . out . println ( " Minimum ▁ number ▁ of " + " ▁ jumps ▁ to ▁ reach ▁ end ▁ is ▁ " + minJumps ( arr , size ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { public static int [ ] [ ] dp = new int [ 100 ] [ 1000 ] ; public static boolean [ ] prime = new boolean [ 1005 ] ; public static void SieveOfEratosthenes ( int n ) { prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } public static int countOfNumbers ( int index , int sum , int N ) { if ( index == N + 1 ) { if ( prime [ sum ] == true ) { return 1 ; } return 0 ; } int val = dp [ index ] [ sum ] ; if ( val != - 1 ) { return val ; } val = 0 ; if ( index == 1 ) { for ( int digit = ( N == 1 ? 0 : 1 ) ; digit <= 9 ; ++ digit ) { val += countOfNumbers ( index + 1 , sum + digit , N ) ; } } else { for ( int digit = 0 ; digit <= 9 ; ++ digit ) { val += countOfNumbers ( index + 1 , sum + digit , N ) ; } } return val ; } public static void main ( String args [ ] ) { for ( int [ ] row : dp ) Arrays . fill ( row , - 1 ) ; Arrays . fill ( prime , true ) ; SieveOfEratosthenes ( 1000 ) ; int N = 6 ; System . out . println ( countOfNumbers ( 1 , 0 , N ) ) ; } }

Index/key variables: i, index, p, sum
Accumulator variables: i, p, val
Iterator variables: digit, i, p, row
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static HashMap < String , Integer > memo ; public static int dfs ( int [ ] V , int left , int K ) { int q = 0 ; String key = Arrays . toString ( V ) ; key += Integer . toString ( left ) ; if ( memo . containsKey ( key ) ) return memo . get ( key ) ; else if ( left == 0 ) { for ( int i = 1 ; i < K ; ++ i ) if ( V [ i ] > 0 ) { V [ i ] -- ; q = Math . max ( q , 1 + dfs ( V , K - i , K ) ) ; V [ i ] ++ ; } } else { for ( int i = 1 ; i < K ; ++ i ) { if ( V [ i ] > 0 ) { V [ i ] -- ; int nleft = i <= left ? left - i : K + left - i ; q = Math . max ( q , dfs ( V , nleft , K ) ) ; V [ i ] ++ ; } } } memo . put ( key , q ) ; return q ; } public static int maxGroups ( int K , int [ ] arr ) { int V [ ] = new int [ K ] ; for ( int x : arr ) V [ x % K ] ++ ; memo = new HashMap < String , Integer > ( ) ; int ans = V [ 0 ] + dfs ( V , 0 , K ) ; return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int K = 3 ; System . out . println ( maxGroups ( K , arr ) ) ; } }

Index/key variables: K, i
Accumulator variables: key
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int alternatingSum ( int [ ] arr ) { int sum = 0 ; int sumSoFar = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i % 2 == 1 ) { sumSoFar -= arr [ i ] ; } else { sumSoFar = Math . max ( sumSoFar + arr [ i ] , arr [ i ] ) ; } sum = Math . max ( sum , sumSoFar ) ; } sumSoFar = 0 ; for ( int i = 1 ; i < arr . length ; i ++ ) { if ( i % 2 == 0 ) { sumSoFar -= arr [ i ] ; } else { sumSoFar = Math . max ( sumSoFar + arr [ i ] , arr [ i ] ) ; } sum = Math . max ( sum , sumSoFar ) ; } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { - 4 , - 10 , 3 , 5 } ; int ans = alternatingSum ( arr ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: i, sumSoFar
Iterator variables: i
Class/struct names: GFG
Java program:
class SmallestSubArraySum { static int smallestSubWithSum ( int arr [ ] , int n , int x ) { int min_len = n + 1 ; for ( int start = 0 ; start < n ; start ++ ) { int curr_sum = arr [ start ] ; if ( curr_sum > x ) return 1 ; for ( int end = start + 1 ; end < n ; end ++ ) { curr_sum += arr [ end ] ; if ( curr_sum > x && ( end - start + 1 ) < min_len ) min_len = ( end - start + 1 ) ; } } return min_len ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 1 , 4 , 45 , 6 , 10 , 19 } ; int x = 51 ; int n1 = arr1 . length ; int res1 = smallestSubWithSum ( arr1 , n1 , x ) ; if ( res1 == n1 + 1 ) System . out . println ( " Not ▁ Possible " ) ; else System . out . println ( res1 ) ; int arr2 [ ] = { 1 , 10 , 5 , 2 , 7 } ; int n2 = arr2 . length ; x = 9 ; int res2 = smallestSubWithSum ( arr2 , n2 , x ) ; if ( res2 == n2 + 1 ) System . out . println ( " Not ▁ Possible " ) ; else System . out . println ( res2 ) ; int arr3 [ ] = { 1 , 11 , 100 , 1 , 0 , 200 , 3 , 2 , 1 , 250 } ; int n3 = arr3 . length ; x = 280 ; int res3 = smallestSubWithSum ( arr3 , n3 , x ) ; if ( res3 == n3 + 1 ) System . out . println ( " Not ▁ Possible " ) ; else System . out . println ( res3 ) ; } }

Index/key variables: end, start
Accumulator variables: curr_sum, end, start
Iterator variables: end, start
Class/struct names: SmallestSubArraySum
Java program:
class SmallestSubArraySum { static int smallestSubWithSum ( int arr [ ] , int n , int x ) { int curr_sum = 0 , min_len = n + 1 ; int start = 0 , end = 0 ; while ( end < n ) { while ( curr_sum <= x && end < n ) curr_sum += arr [ end ++ ] ; while ( curr_sum > x && start < n ) { if ( end - start < min_len ) min_len = end - start ; curr_sum -= arr [ start ++ ] ; } } return min_len ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 1 , 4 , 45 , 6 , 10 , 19 } ; int x = 51 ; int n1 = arr1 . length ; int res1 = smallestSubWithSum ( arr1 , n1 , x ) ; if ( res1 == n1 + 1 ) System . out . println ( " Not ▁ Possible " ) ; else System . out . println ( res1 ) ; int arr2 [ ] = { 1 , 10 , 5 , 2 , 7 } ; int n2 = arr2 . length ; x = 9 ; int res2 = smallestSubWithSum ( arr2 , n2 , x ) ; if ( res2 == n2 + 1 ) System . out . println ( " Not ▁ Possible " ) ; else System . out . println ( res2 ) ; int arr3 [ ] = { 1 , 11 , 100 , 1 , 0 , 200 , 3 , 2 , 1 , 250 } ; int n3 = arr3 . length ; x = 280 ; int res3 = smallestSubWithSum ( arr3 , n3 , x ) ; if ( res3 == n3 + 1 ) System . out . println ( " Not ▁ Possible " ) ; else System . out . println ( res3 ) ; } }

Accumulator variables: curr_sum, end, start
Class/struct names: SmallestSubArraySum
Java program:
public class GFG { static class Node { int data ; Node left , right ; Node ( int data ) { this . data = data ; left = null ; right = null ; } } static int maxLen ; static int maxSum ; static void sumOfLongRootToLeafPath ( Node root , int sum , int len ) { if ( root == null ) { if ( maxLen < len ) { maxLen = len ; maxSum = sum ; } else if ( maxLen == len && maxSum < sum ) maxSum = sum ; return ; } sumOfLongRootToLeafPath ( root . left , sum + root . data , len + 1 ) ; sumOfLongRootToLeafPath ( root . right , sum + root . data , len + 1 ) ; } static int sumOfLongRootToLeafPathUtil ( Node root ) { if ( root == null ) return 0 ; maxSum = Integer . MIN_VALUE ; maxLen = 0 ; sumOfLongRootToLeafPath ( root , 0 , 0 ) ; return maxSum ; } public static void main ( String args [ ] ) { Node root = new Node ( 4 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 5 ) ; root . left . left = new Node ( 7 ) ; root . left . right = new Node ( 1 ) ; root . right . left = new Node ( 2 ) ; root . right . right = new Node ( 3 ) ; root . left . right . left = new Node ( 6 ) ; System . out . println ( " Sum ▁ = ▁ " + sumOfLongRootToLeafPathUtil ( root ) ) ; } }

Class/struct names: GFG, Node
Java program:
import java . io . * ; class GFG { static int numberOfArrays ( int n , int l ) { int [ ] [ ] dp = new int [ l + 1 ] [ n + 1 ] ; dp [ 0 ] [ 1 ] = 1 ; for ( int i = 0 ; i < l ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { for ( int k = j ; k <= n ; k += j ) { dp [ i + 1 ] [ k ] += dp [ i ] [ j ] ; } } } int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { ans += dp [ l ] [ i ] ; } return ans ; } public static void main ( String [ ] args ) { int N = 2 , L = 4 ; System . out . println ( numberOfArrays ( N , L ) ) ; } }

Index/key variables: i, j, k, l
Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class Test { static int arr [ ] = new int [ ] { 16 , 16 , 16 } ; static int countMinOperations ( int n ) { int result = 0 ; while ( true ) { int zero_count = 0 ; int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) break ; else if ( arr [ i ] == 0 ) zero_count ++ ; } if ( zero_count == n ) return result ; if ( i == n ) { for ( int j = 0 ; j < n ; j ++ ) arr [ j ] = arr [ j ] / 2 ; result ++ ; } for ( int j = i ; j < n ; j ++ ) { if ( arr [ j ] % 2 == 1 ) { arr [ j ] -- ; result ++ ; } } } } public static void main ( String [ ] args ) { System . out . println ( "Minimum number of steps required to NEW_LINE" + " get ▁ the ▁ given ▁ target ▁ array ▁ is ▁ " + countMinOperations ( arr . length ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, result, zero_count
Iterator variables: i, j
Class/struct names: Test
Java program:
import java . util . * ; import java . awt . Point ; public class GFG { static int recursiveChoosing ( int [ ] arr , int start , int M , HashMap < Point , Integer > dp ) { Point key = new Point ( start , M ) ; if ( start >= arr . length ) { return 0 ; } if ( arr . length - start <= 2 * M ) { int Sum = 0 ; for ( int i = start ; i < arr . length ; i ++ ) { Sum = Sum + arr [ i ] ; } return Sum ; } int sum = 0 ; for ( int i = start ; i < arr . length ; i ++ ) { sum = sum + arr [ i ] ; } int total = sum ; if ( dp . containsKey ( key ) ) { return dp . get ( key ) ; } int psa = 0 ; for ( int x = 1 ; x < 2 * M + 1 ; x ++ ) { int psb = recursiveChoosing ( arr , start + x , Math . max ( x , M ) , dp ) ; psa = Math . max ( psa , total - psb ) ; } dp . put ( key , psa ) ; return dp . get ( key ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 7 , 9 , 4 , 4 } ; int N = arr . length ; HashMap < Point , Integer > dp = new HashMap < Point , Integer > ( ) ; System . out . print ( recursiveChoosing ( arr , 0 , 1 , dp ) ) ; } }

Index/key variables: i
Accumulator variables: i, x
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static int maxSum ( int [ ] arr , int i , int n , int prev , boolean is_selected , int [ ] [ ] dp ) { if ( i == n ) { return 0 ; } int cur = Math . abs ( arr [ i ] ) % 2 ; if ( dp [ i ] [ prev ] != - 1 ) { return dp [ i ] [ prev ] ; } if ( i == n - 1 && is_selected == false ) return dp [ i ] [ prev ] = arr [ i ] ; if ( cur != prev ) { dp [ i ] [ prev ] = arr [ i ] + maxSum ( arr , i + 1 , n , cur , true , dp ) ; } dp [ i ] [ prev ] = Math . max ( dp [ i ] [ prev ] , maxSum ( arr , i + 1 , n , prev , is_selected , dp ) ) ; return dp [ i ] [ prev ] ; } static void maxSumUtil ( int arr [ ] , int n ) { int [ ] [ ] dp = new int [ 100 ] [ 3 ] ; for ( int [ ] arr1 : dp ) Arrays . fill ( arr1 , - 1 ) ; System . out . print ( maxSum ( arr , 0 , n , 2 , false , dp ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 6 , 8 , - 5 , 10 } ; int N = arr . length ; maxSumUtil ( arr , N ) ; } }

Index/key variables: i, prev
Iterator variables: arr1
Class/struct names: GFG
Java program:
class GFG { static int findMinOps ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 , j = n - 1 ; i <= j ; ) { if ( arr [ i ] == arr [ j ] ) { i ++ ; j -- ; } else if ( arr [ i ] > arr [ j ] ) { j -- ; arr [ j ] += arr [ j + 1 ] ; ans ++ ; } else { i ++ ; arr [ i ] += arr [ i - 1 ] ; ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { 1 , 4 , 5 , 9 , 1 } ; System . out . println ( " Count ▁ of ▁ minimum ▁ operations ▁ is ▁ " + findMinOps ( arr , arr . length ) ) ; } }

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