dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { public static int [ , ] dp = new int [ 100 , 1000 ] ; public static bool [ ] prime = new bool [ 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 i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 1000 ; j ++ ) { dp [ i , j ] = - 1 ; } } for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( 1000 ) ; int N = 6 ; Console . WriteLine ( countOfNumbers ( 1 , 0 , N ) ) ; } }

Index/key variables: i, p, sum
Accumulator variables: i, j, p, val
Iterator variables: digit, i, j, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static Dictionary < String , int > memo ; public static int dfs ( int [ ] V , int left , int K ) { int q = 0 ; String key = string . Join ( " , " , V ) ; key += left . ToString ( ) ; if ( memo . ContainsKey ( key ) ) return memo [ 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 ] ++ ; } } } if ( memo . ContainsKey ( key ) ) memo [ key ] = q ; else memo . Add ( key , q ) ; return q ; } public static int maxGroups ( int K , int [ ] arr ) { int [ ] V = new int [ K ] ; foreach ( int x in arr ) V [ x % K ] ++ ; memo = new Dictionary < String , int > ( ) ; 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 ; Console . WriteLine ( maxGroups ( K , arr ) ) ; } }

Index/key variables: K, i, key
Accumulator variables: key
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int alternatingSum ( int [ ] arr , int n ) { int sum = 0 ; int sumSoFar = 0 ; for ( int i = 0 ; i < n ; 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 < n ; 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 ( ) { int [ ] arr = { - 4 , - 10 , 3 , 5 } ; int n = arr . Length ; int ans = alternatingSum ( arr , n ) ; Console . Write ( ans ) ; } }

Index/key variables: i
Accumulator variables: i, sumSoFar
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { 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 ; } static public void Main ( ) { 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 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( res1 ) ; int [ ] arr2 = { 1 , 10 , 5 , 2 , 7 } ; int n2 = arr2 . Length ; x = 9 ; int res2 = smallestSubWithSum ( arr2 , n2 , x ) ; if ( res2 == n2 + 1 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( 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 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( res3 ) ; } }

Index/key variables: end, start
Accumulator variables: curr_sum, end, start
Iterator variables: end, start
Class/struct names: GFG
C# program:
using System ; class GFG { 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 ; } static public void Main ( ) { 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 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( res1 ) ; int [ ] arr2 = { 1 , 10 , 5 , 2 , 7 } ; int n2 = arr2 . Length ; x = 9 ; int res2 = smallestSubWithSum ( arr2 , n2 , x ) ; if ( res2 == n2 + 1 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( 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 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( res3 ) ; } }

Accumulator variables: curr_sum, end, start
Class/struct names: GFG
C# program:
using System ; public class GFG { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = null ; right = null ; } } public static int maxLen ; public static int maxSum ; public 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 ) ; } public static int sumOfLongRootToLeafPathUtil ( Node root ) { if ( root == null ) { return 0 ; } maxSum = int . MinValue ; 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 ) ; Console . WriteLine ( " Sum ▁ = ▁ " + sumOfLongRootToLeafPathUtil ( root ) ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int numberOfArrays ( int n , int l ) { int [ , ] dp = new int [ l + 1 , n + 1 ] ; for ( int i = 0 ; i < l + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) dp [ i , j ] = 0 ; } 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 ( ) { int N = 2 , L = 4 ; Console . Write ( numberOfArrays ( N , L ) ) ; } }

Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { 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 ( ) { Console . Write ( " Minimum ▁ number ▁ of ▁ steps ▁ required ▁ to ▁ STRNEWLINE " + " 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: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int recursiveChoosing ( int [ ] arr , int start , int M , Dictionary < Tuple < int , int > , int > dp ) { Tuple < int , int > key = new Tuple < int , int > ( 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 [ 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 [ key ] = psa ; return dp [ key ] ; } static void Main ( ) { int [ ] arr = { 2 , 7 , 9 , 4 , 4 } ; int N = arr . Length ; Dictionary < Tuple < int , int > , int > dp = new Dictionary < Tuple < int , int > , int > ( ) ; Console . Write ( recursiveChoosing ( arr , 0 , 1 , dp ) ) ; } }

Index/key variables: i, key
Accumulator variables: i, x
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ ] arr , int i , int n , int prev , bool 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 i = 0 ; i < 100 ; ++ i ) { for ( int j = 0 ; j < 3 ; ++ j ) { dp [ i , j ] = - 1 ; } } Console . Write ( 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
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; 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 ( ) { int [ ] arr = new int [ ] { 1 , 4 , 5 , 9 , 1 } ; Console . Write ( " 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
C# program:
using System ; class GFG { static int findSmallest ( int [ ] arr , int n ) { int res = 1 ; for ( int i = 0 ; i < n && arr [ i ] <= res ; i ++ ) res = res + arr [ i ] ; return res ; } public static void Main ( ) { int [ ] arr1 = { 1 , 3 , 4 , 5 } ; int n1 = arr1 . Length ; Console . WriteLine ( findSmallest ( arr1 , n1 ) ) ; int [ ] arr2 = { 1 , 2 , 6 , 10 , 11 , 15 } ; int n2 = arr2 . Length ; Console . WriteLine ( findSmallest ( arr2 , n2 ) ) ; int [ ] arr3 = { 1 , 1 , 1 , 1 } ; int n3 = arr3 . Length ; Console . WriteLine ( findSmallest ( arr3 , n3 ) ) ; int [ ] arr4 = { 1 , 1 , 3 , 4 } ; int n4 = arr4 . Length ; Console . WriteLine ( findSmallest ( arr4 , n4 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static HashSet < int > s ; static void countXOR ( int [ ] arr , int [ ] comb , int start , int end , int index , int r ) { if ( index == r ) { int new_xor = 0 ; for ( int j = 0 ; j < r ; j ++ ) { new_xor ^= comb [ j ] ; } s . Add ( new_xor ) ; return ; } for ( int i = start ; i <= end && end - i + 1 >= r - index ; i ++ ) { comb [ index ] = arr [ i ] ; countXOR ( arr , comb , i + 1 , end , index + 1 , r ) ; } } static void maxSizeSet ( int [ ] arr , int N ) { for ( int r = 1 ; r <= N ; r ++ ) { int [ ] comb = new int [ r + 1 ] ; countXOR ( arr , comb , 0 , N - 1 , 0 , r ) ; } Console . WriteLine ( s . Count ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . Length ; s = new HashSet < int > ( ) ; maxSizeSet ( arr , N ) ; } }

Index/key variables: i, index, j
Accumulator variables: i, j, new_xor, r
Iterator variables: i, j, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubArraySum ( int [ ] a , int size ) { int max_so_far = int . MinValue , max_ending_here = 0 , start = 0 , end = 0 , s = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here += a [ i ] ; if ( max_so_far < max_ending_here ) { max_so_far = max_ending_here ; start = s ; end = i ; } if ( max_ending_here < 0 ) { max_ending_here = 0 ; s = i + 1 ; } } return ( end - start + 1 ) ; } public static void Main ( String [ ] args ) { int [ ] a = { - 2 , - 3 , 4 , - 1 , - 2 , 1 , 5 , - 3 } ; int n = a . Length ; Console . Write ( maxSubArraySum ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, max_ending_here
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { private static int LongSubarrSeq ( int [ ] arr1 , int [ ] arr2 ) { int M = arr1 . Length ; int N = arr2 . Length ; int maxL = 0 ; int [ , ] DP = new int [ M + 1 , N + 1 ] ; for ( int i = 1 ; i <= M ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { if ( arr1 [ i - 1 ] == arr2 [ j - 1 ] ) { DP [ i , j ] = 1 + DP [ i - 1 , j - 1 ] ; } else { DP [ i , j ] = DP [ i , j - 1 ] ; } } } for ( int i = 1 ; i <= M ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { maxL = Math . Max ( maxL , DP [ i , j ] ) ; } } return maxL ; } static public void Main ( ) { int [ ] arr1 = { 4 , 2 , 3 , 1 , 5 , 6 } ; int [ ] arr2 = { 3 , 1 , 4 , 6 , 5 , 2 } ; Console . WriteLine ( LongSubarrSeq ( arr1 , arr2 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinDiff ( int [ ] arr , int n ) { int diff = int . MaxValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( Math . Abs ( ( arr [ i ] - arr [ j ] ) ) < diff ) diff = Math . Abs ( ( arr [ i ] - arr [ j ] ) ) ; return diff ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 5 , 3 , 19 , 18 , 25 } ; Console . Write ( " Minimum ▁ difference ▁ is ▁ " + findMinDiff ( arr , arr . Length ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findLongestSubstring ( int posA , int posB , String A , String B , int canSkip , int n , int [ , , ] dp ) { if ( posA >= n posB >= n ) { return 0 ; } if ( dp [ posA , posB , canSkip ] != - 1 ) { return dp [ posA , posB , canSkip ] ; } int op1 = 0 ; int op2 = 0 ; int op3 = 0 ; if ( A [ posA ] == B [ posB ] ) { op1 = 1 + findLongestSubstring ( posA + 1 , posB + 1 , A , B , 0 , n , dp ) ; } if ( canSkip == 1 ) { op2 = findLongestSubstring ( posA + 1 , posB , A , B , canSkip , n , dp ) ; } op3 = findLongestSubstring ( posA , posB + 1 , A , B , canSkip , n , dp ) ; return dp [ posA , posB , canSkip ] = Math . Max ( op1 , Math . Max ( op2 , op3 ) ) ; } static void minOperations ( String A , String B , int N ) { int [ , , ] dp = new int [ N , N , 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } Console . WriteLine ( N - findLongestSubstring ( 0 , 0 , A , B , 1 , N , dp ) ) ; } static public void Main ( ) { String A = " abab " ; String B = " baba " ; int N = A . Length ; minOperations ( A , B , N ) ; } }

Index/key variables: posA, posB
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System ; using System . Collections . Generic ; public class GFG { static int MOD = 1000000007 ; static int [ , , ] dp = new int [ 5005 , 12 , 12 ] ; static int findCountUtil ( int N , int [ ] maxDigit , int position , int previous , int count ) { if ( position == N ) { return 1 ; } int ans = dp [ position , previous , count ] ; if ( ans != - 1 ) { return ans ; } ans = 0 ; for ( int i = 0 ; i <= 9 ; ++ i ) { if ( count == 0 && previous != i ) { ans = ( ans + ( findCountUtil ( N , maxDigit , position + 1 , i , maxDigit [ i ] - 1 ) ) % MOD ) % MOD ; } else if ( count != 0 ) { ans = ( ans + ( findCountUtil ( N , maxDigit , position + 1 , i , ( previous == i && position != 0 ) ? count - 1 : maxDigit [ i ] - 1 ) ) % MOD ) % MOD ; } } return ans ; } static void findCount ( int N , int [ ] maxDigit ) { int position = 0 ; int previous = 0 ; int count = 1 ; int ans = findCountUtil ( N , maxDigit , position , previous , count ) ; Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int N = 2 ; int [ ] maxDigit = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ; for ( int i = 0 ; i < dp . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < dp . GetLength ( 1 ) ; j ++ ) { for ( int k = 0 ; k < dp . GetLength ( 2 ) ; k ++ ) dp [ i , j , k ] = - 1 ; } } findCount ( N , maxDigit ) ; } }

Index/key variables: i
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinDiff ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int diff = int . MaxValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i + 1 ] - arr [ i ] < diff ) diff = arr [ i + 1 ] - arr [ i ] ; return diff ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 5 , 3 , 19 , 18 , 25 } ; Console . WriteLine ( " Minimum ▁ difference ▁ is ▁ " + findMinDiff ( arr , arr . Length ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static public void Main ( ) { int a = 2 , b = 10 ; int size = Math . Abs ( b - a ) + 1 ; int [ ] array = new int [ size ] ; for ( int i = a ; i <= b ; i ++ ) if ( i % 2 == 0 i % 5 == 0 ) array [ i - a ] = 1 ; Console . WriteLine ( " MULTIPLES ▁ of ▁ 2" + " ▁ and ▁ 5 : " ) ; for ( int i = a ; i <= b ; i ++ ) if ( array [ i - a ] == 1 ) Console . Write ( i + " ▁ " ) ; } }

Index/key variables: size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int max ( int l , int r ) { return ( l > r ? l : r ) ; } public class Node { public int data ; public Node left , right ; } public class INT { public int v ; public INT ( int a ) { v = a ; } } public static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return node ; } public static void print ( Node root ) { if ( root != null ) { print ( root . left ) ; Console . Write ( root . data + " ▁ " ) ; print ( root . right ) ; } } public static Node pruneUtil ( Node root , int k , INT sum ) { if ( root == null ) { return null ; } INT lsum = new INT ( sum . v + ( root . data ) ) ; INT rsum = new INT ( lsum . v ) ; root . left = pruneUtil ( root . left , k , lsum ) ; root . right = pruneUtil ( root . right , k , rsum ) ; sum . v = max ( lsum . v , rsum . v ) ; if ( sum . v < k ) { root = null ; } return root ; } public static Node prune ( Node root , int k ) { INT sum = new INT ( 0 ) ; return pruneUtil ( root , k , sum ) ; } public static void Main ( string [ ] args ) { int k = 45 ; Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; root . left . left . left = newNode ( 8 ) ; root . left . left . right = newNode ( 9 ) ; root . left . right . left = newNode ( 12 ) ; root . right . right . left = newNode ( 10 ) ; root . right . right . left . right = newNode ( 11 ) ; root . left . left . right . left = newNode ( 13 ) ; root . left . left . right . right = newNode ( 14 ) ; root . left . left . right . right . left = newNode ( 15 ) ; Console . WriteLine ( " Tree ▁ before ▁ truncation STRNEWLINE " ) ; print ( root ) ; root = prune ( root , k ) ; Console . WriteLine ( " STRNEWLINE STRNEWLINE Tree ▁ after ▁ truncation STRNEWLINE " ) ; print ( root ) ; } }

Class/struct names: GFG, INT, Node
C# program:
using System ; class Node { public int key ; public Node left , right ; public Node ( int item ) { key = item ; left = right = null ; } } class BinaryTree { Node root ; BinaryTree ( ) { root = null ; } void printPostorder ( Node node ) { if ( node == null ) return ; printPostorder ( node . left ) ; printPostorder ( node . right ) ; Console . Write ( node . key + " ▁ " ) ; } void printInorder ( Node node ) { if ( node == null ) return ; printInorder ( node . left ) ; Console . Write ( node . key + " ▁ " ) ; printInorder ( node . right ) ; } void printPreorder ( Node node ) { if ( node == null ) return ; Console . Write ( node . key + " ▁ " ) ; printPreorder ( node . left ) ; printPreorder ( node . right ) ; } void printPostorder ( ) { printPostorder ( root ) ; } void printInorder ( ) { printInorder ( root ) ; } void printPreorder ( ) { printPreorder ( root ) ; } static public void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; Console . WriteLine ( " Preorder ▁ traversal ▁ " + " of ▁ binary ▁ tree ▁ is ▁ " ) ; tree . printPreorder ( ) ; Console . WriteLine ( " STRNEWLINE Inorder ▁ traversal ▁ " + " of ▁ binary ▁ tree ▁ is ▁ " ) ; tree . printInorder ( ) ; Console . WriteLine ( " STRNEWLINE Postorder ▁ traversal ▁ " + " of ▁ binary ▁ tree ▁ is ▁ " ) ; tree . printPostorder ( ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections ; class GFG { static int M = 100 ; static int mxSubSum ( int i , int [ ] arr , int j , int [ , ] dp ) { if ( i == 0 ) { return dp [ i , j ] = Math . Max ( 0 , arr [ i ] ) ; } if ( dp [ i , j ] != - 1 ) { return dp [ i , j ] ; } int X = Math . Max ( 0 , arr [ i ] + mxSubSum ( i - 1 , arr , j , dp ) ) ; if ( j == 0 ) { return dp [ i , j ] = X ; } int Y = mxSubSum ( i - 1 , arr , j - 1 , dp ) ; return dp [ i , j ] = Math . Max ( X , Y ) ; } static int MaximumSubarraySum ( int n , int [ ] arr , int k ) { int [ , ] dp = new int [ M , M ] ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < M ; j ++ ) dp [ i , j ] = - 1 ; mxSubSum ( n - 1 , arr , k , dp ) ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= k ; j ++ ) { res = Math . Max ( res , dp [ i , j ] ) ; } } Array . Sort ( arr ) ; if ( arr [ n - 1 ] < 0 ) { res = arr [ n - 1 ] ; } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 2 , 1 , 3 , - 2 , 4 , - 7 , 20 } ; int K = 1 ; int N = arr . Length ; Console . WriteLine ( MaximumSubarraySum ( N , arr , K ) ) ; } }

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