dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static int sumOfSubstrings ( String num ) { int n = num . Length ; int [ ] sumofdigit = new int [ n ] ; sumofdigit [ 0 ] = num [ 0 ] - '0' ; int res = sumofdigit [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { int numi = num [ i ] - '0' ; sumofdigit [ i ] = ( i + 1 ) * numi + 10 * sumofdigit [ i - 1 ] ; res += sumofdigit [ i ] ; } return res ; } public static void Main ( ) { String num = "1234" ; Console . Write ( sumOfSubstrings ( num ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int toDigit ( char ch ) { return ( ch - '0' ) ; } static int sumOfSubStrings ( string num ) { int n = num . Length ; int prev = toDigit ( num [ 0 ] ) ; int res = prev ; int current = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int numi = toDigit ( num [ i ] ) ; current = ( i + 1 ) * numi + 10 * prev ; res += current ; prev = current ; } return res ; } static void Main ( ) { string num = "1234" ; Console . WriteLine ( sumOfSubStrings ( num ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int equilibrium ( int [ ] a , int n ) { if ( n == 1 ) return ( 0 ) ; int [ ] front = new int [ n ] ; int [ ] back = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i != 0 ) { front [ i ] = front [ i - 1 ] + a [ i ] ; } else { front [ i ] = a [ i ] ; } } for ( int i = n - 1 ; i > 0 ; i -- ) { if ( i <= n - 2 ) { back [ i ] = back [ i + 1 ] + a [ i ] ; } else { back [ i ] = a [ i ] ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( front [ i ] == back [ i ] ) { return i ; } } return - 1 ; } public static void Main ( string [ ] args ) { int [ ] arr = { - 7 , 1 , 5 , 2 , - 4 , 3 , 0 } ; int arr_size = arr . Length ; Console . WriteLine ( " First ▁ Point ▁ of ▁ equilibrium ▁ " + " is ▁ at ▁ index ▁ " + equilibrium ( arr , arr_size ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class UboundedKnapsack { private static int max ( int i , int j ) { return ( i > j ) ? i : j ; } private static int unboundedKnapsack ( int W , int n , int [ ] val , int [ ] wt ) { int [ ] dp = new int [ W + 1 ] ; for ( int i = 0 ; i <= W ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( wt [ j ] <= i ) { dp [ i ] = Math . Max ( dp [ i ] , dp [ i - wt [ j ] ] + val [ j ] ) ; } } } return dp [ W ] ; } public static void Main ( ) { int W = 100 ; int [ ] val = { 10 , 30 , 20 } ; int [ ] wt = { 5 , 10 , 15 } ; int n = val . Length ; Console . WriteLine ( unboundedKnapsack ( W , n , val , wt ) ) ; } }

Index/key variables: W, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: UboundedKnapsack
C# program:
using System ; class GFG { static int ceilSearch ( int [ ] arr , int low , int high , int x ) { int i ; if ( x <= arr [ low ] ) return low ; for ( i = low ; i < high ; i ++ ) { if ( arr [ i ] == x ) return i ; if ( arr [ i ] < x && arr [ i + 1 ] >= x ) return i + 1 ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 8 , 10 , 10 , 12 , 19 } ; int n = arr . Length ; int x = 3 ; int index = ceilSearch ( arr , 0 , n - 1 , x ) ; if ( index == - 1 ) Console . Write ( " Ceiling ▁ of ▁ " + x + " ▁ doesn ' t ▁ exist ▁ in ▁ array " ) ; else Console . Write ( " ceiling ▁ of ▁ " + x + " ▁ is ▁ " + arr [ index ] ) ; } }

Index/key variables: i, index, low
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSumSubarrayRemovingOneEle ( int [ ] arr , int n ) { int [ ] fw = new int [ n ] ; int [ ] bw = new int [ n ] ; int cur_max = arr [ 0 ] , max_so_far = arr [ 0 ] ; fw [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { cur_max = Math . Max ( arr [ i ] , cur_max + arr [ i ] ) ; max_so_far = Math . Max ( max_so_far , cur_max ) ; fw [ i ] = cur_max ; } cur_max = max_so_far = bw [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { cur_max = Math . Max ( arr [ i ] , cur_max + arr [ i ] ) ; max_so_far = Math . Max ( max_so_far , cur_max ) ; bw [ i ] = cur_max ; } int fans = max_so_far ; for ( int i = 1 ; i < n - 1 ; i ++ ) fans = Math . Max ( fans , fw [ i - 1 ] + bw [ i + 1 ] ) ; return fans ; } public static void Main ( ) { int [ ] arr = { - 2 , - 3 , 4 , - 1 , - 2 , 1 , 5 , - 3 } ; int n = arr . Length ; Console . WriteLine ( maxSumSubarrayRemovingOneEle ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int ceilSearch ( int [ ] arr , int low , int high , int x ) { int mid ; if ( x <= arr [ low ] ) return low ; if ( x > arr [ high ] ) return - 1 ; mid = ( low + high ) / 2 ; if ( arr [ mid ] == x ) return mid ; else if ( arr [ mid ] < x ) { if ( mid + 1 <= high && x <= arr [ mid + 1 ] ) return mid + 1 ; else return ceilSearch ( arr , mid + 1 , high , x ) ; } else { if ( mid - 1 >= low && x > arr [ mid - 1 ] ) return mid ; else return ceilSearch ( arr , low , mid - 1 , x ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 8 , 10 , 10 , 12 , 19 } ; int n = arr . Length ; int x = 8 ; int index = ceilSearch ( arr , 0 , n - 1 , x ) ; if ( index == - 1 ) Console . Write ( " Ceiling ▁ of ▁ " + x + " ▁ doesn ' t ▁ exist ▁ in ▁ array " ) ; else Console . Write ( " ceiling ▁ of ▁ " + x + " ▁ is ▁ " + arr [ index ] ) ; } }

Index/key variables: high, index, low, mid
Class/struct names: GFG
C# program:
using System ; class GfG { public class Node { public int data ; public Node left ; public Node right ; } static int getHeight ( Node Node ) { if ( Node == null ) return 0 ; else { int lHeight = getHeight ( Node . left ) ; int rHeight = getHeight ( Node . right ) ; if ( lHeight > rHeight ) return ( lHeight + 1 ) ; else return ( rHeight + 1 ) ; } } static Node newNode ( int data ) { Node Node = new Node ( ) ; Node . data = data ; Node . left = null ; Node . right = null ; return ( Node ) ; } static int getTotalHeight ( Node root ) { if ( root == null ) return 0 ; return getTotalHeight ( root . left ) + getHeight ( root ) + getTotalHeight ( root . right ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; Console . Write ( " Sum ▁ of ▁ heights ▁ of ▁ all ▁ Nodes ▁ = ▁ " + getTotalHeight ( root ) ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; class GFG { public static double maxAverageOfPath ( int [ , ] cost , int N ) { int [ , ] dp = new int [ N + 1 , N + 1 ] ; dp [ 0 , 0 ] = cost [ 0 , 0 ] ; for ( int i = 1 ; i < N ; i ++ ) dp [ i , 0 ] = dp [ i - 1 , 0 ] + cost [ i , 0 ] ; for ( int j = 1 ; j < N ; j ++ ) dp [ 0 , j ] = dp [ 0 , j - 1 ] + cost [ 0 , j ] ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 1 ; j < N ; j ++ ) dp [ i , j ] = Math . Max ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) + cost [ i , j ] ; return ( double ) dp [ N - 1 , N - 1 ] / ( 2 * N - 1 ) ; } public static void Main ( ) { int [ , ] cost = { { 1 , 2 , 3 } , { 6 , 5 , 4 } , { 7 , 3 , 9 } } ; Console . Write ( maxAverageOfPath ( cost , 3 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxCost ( int [ , ] mat , int N ) { int [ , ] dp = new int [ N , N ] ; dp [ 0 , 0 ] = mat [ 0 , 0 ] ; for ( int i = 1 ; i < N ; i ++ ) dp [ i , 0 ] = mat [ i , 0 ] + dp [ i - 1 , 0 ] ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 1 ; j < i + 1 && j < N ; j ++ ) dp [ i , j ] = mat [ i , j ] + Math . Max ( dp [ i - 1 , j - 1 ] , dp [ i - 1 , j ] ) ; int result = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( result < dp [ N - 1 , i ] ) result = dp [ N - 1 , i ] ; return result ; } public static void Main ( ) { int [ , ] mat = { { 4 , 1 , 5 , 6 , 1 } , { 2 , 9 , 2 , 11 , 10 } , { 15 , 1 , 3 , 15 , 2 } , { 16 , 92 , 41 , 4 , 3 } , { 8 , 142 , 6 , 4 , 8 } } ; int N = 5 ; Console . Write ( " Maximum ▁ Path ▁ Sum ▁ : ▁ " + maxCost ( mat , N ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 100 ; static int [ , ] memo = new int [ M , M ] ; static int numberOfPermWithKInversion ( int N , int K ) { if ( N == 0 ) return 0 ; if ( K == 0 ) return 1 ; if ( memo [ N , K ] != 0 ) return memo [ N , K ] ; int sum = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { if ( i <= N - 1 ) sum += numberOfPermWithKInversion ( N - 1 , K - i ) ; } memo [ N , K ] = sum ; return sum ; } static public void Main ( ) { int N = 4 ; int K = 2 ; Console . WriteLine ( numberOfPermWithKInversion ( N , K ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int KnapSack ( int [ ] val , int [ ] wt , int n , int W ) { int [ , ] mat = new int [ 2 , W + 1 ] ; int i = 0 ; while ( i < n ) { int j = 0 ; if ( i % 2 != 0 ) { while ( ++ j <= W ) { if ( wt [ i ] <= j ) { mat [ 1 , j ] = Math . Max ( val [ i ] + mat [ 0 , j - wt [ i ] ] , mat [ 0 , j ] ) ; } else { mat [ 1 , j ] = mat [ 0 , j ] ; } } } else { while ( ++ j <= W ) { if ( wt [ i ] <= j ) { mat [ 0 , j ] = Math . Max ( val [ i ] + mat [ 1 , j - wt [ i ] ] , mat [ 1 , j ] ) ; } else { mat [ 0 , j ] = mat [ 1 , j ] ; } } } i ++ ; } return ( n % 2 != 0 ) ? mat [ 0 , W ] : mat [ 1 , W ] ; } public static void Main ( String [ ] args ) { int [ ] val = { 7 , 8 , 4 } ; int [ ] wt = { 3 , 8 , 6 } ; int W = 10 , n = 3 ; Console . WriteLine ( KnapSack ( val , wt , n , W ) ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProfit ( int [ ] price , int n , int k ) { int [ , ] profit = new int [ k + 1 , n + 1 ] ; for ( int i = 0 ; i <= k ; i ++ ) profit [ i , 0 ] = 0 ; for ( int j = 0 ; j <= n ; j ++ ) profit [ 0 , j ] = 0 ; for ( int i = 1 ; i <= k ; i ++ ) { int prevDiff = int . MinValue ; for ( int j = 1 ; j < n ; j ++ ) { prevDiff = Math . Max ( prevDiff , profit [ i - 1 , j - 1 ] - price [ j - 1 ] ) ; profit [ i , j ] = Math . Max ( profit [ i , j - 1 ] , price [ j ] + prevDiff ) ; } } return profit [ k , n - 1 ] ; } public static void Main ( ) { int k = 3 ; int [ ] price = { 12 , 14 , 17 , 10 , 14 , 13 , 12 , 15 } ; int n = price . Length ; Console . Write ( " Maximum ▁ profit ▁ is : ▁ " + maxProfit ( price , n , k ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Boolean isMajority ( int [ ] a , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( a [ i ] ) ) { var val = mp [ a [ i ] ] ; mp . Remove ( a [ i ] ) ; mp . Add ( a [ i ] , val + 1 ) ; } else { mp . Add ( a [ i ] , 1 ) ; } } foreach ( KeyValuePair < int , int > x in mp ) if ( x . Value >= n / 2 ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 9 , 2 , 2 } ; int n = a . Length ; if ( isMajority ( a , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] lookup = new int [ 1000 , 1000 ] ; static int countSeqUtil ( int n , int dif ) { if ( Math . Abs ( dif ) > n ) return 0 ; if ( n == 1 && dif == 0 ) return 2 ; if ( n == 1 && Math . Abs ( dif ) == 1 ) return 1 ; if ( lookup [ n , n + dif ] != - 1 ) return lookup [ n , n + dif ] ; countSeqUtil ( n - 1 , dif + 1 ) + 2 * countSeqUtil ( n - 1 , dif ) + countSeqUtil ( n - 1 , dif - 1 ) ; return lookup [ n , n + dif ] = res ; } static int countSeq ( int n ) { for ( int k = 0 ; k < lookup . GetLength ( 0 ) ; k ++ ) { for ( int j = 0 ; j < lookup . GetLength ( 1 ) ; j ++ ) { lookup [ k , j ] = - 1 ; } } return countSeqUtil ( n , 0 ) ; } public static void Main ( ) { int n = 2 ; Console . WriteLine ( " Count ▁ of ▁ sequences ▁ is ▁ " + countSeq ( n ) ) ; } }

Accumulator variables: j, k
Iterator variables: j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int parenthesis_count ( string str , int i , int j , int isTrue , int [ , , ] dp ) { if ( i > j ) return 0 ; if ( i == j ) { if ( isTrue == 1 ) { return ( str [ i ] == ' T ' ) ? 1 : 0 ; } else { return ( str [ i ] == ' F ' ) ? 1 : 0 ; } } if ( dp [ i , j , isTrue ] != - 1 ) return dp [ i , j , isTrue ] ; int temp_ans = 0 ; int leftTrue , rightTrue , leftFalse , rightFalse ; for ( int k = i + 1 ; k <= j - 1 ; k = k + 2 ) { if ( dp [ i , k - 1 , 1 ] != - 1 ) leftTrue = dp [ i , k - 1 , 1 ] ; else { leftTrue = parenthesis_count ( str , i , k - 1 , 1 , dp ) ; } if ( dp [ i , k - 1 , 0 ] != - 1 ) leftFalse = dp [ i , k - 1 , 0 ] ; else { leftFalse = parenthesis_count ( str , i , k - 1 , 0 , dp ) ; } if ( dp [ k + 1 , j , 1 ] != - 1 ) rightTrue = dp [ k + 1 , j , 1 ] ; else { rightTrue = parenthesis_count ( str , k + 1 , j , 1 , dp ) ; } if ( dp [ k + 1 , j , 0 ] != - 1 ) rightFalse = dp [ k + 1 , j , 0 ] ; else { rightFalse = parenthesis_count ( str , k + 1 , j , 0 , dp ) ; } if ( str [ k ] == ' & ' ) { if ( isTrue == 1 ) { temp_ans = temp_ans + leftTrue * rightTrue ; } else { temp_ans = temp_ans + leftTrue * rightFalse + leftFalse * rightTrue + leftFalse * rightFalse ; } } else if ( str [ k ] == ' ▁ ' ) { if ( isTrue == 1 ) { temp_ans = temp_ans + leftTrue * rightTrue + leftTrue * rightFalse + leftFalse * rightTrue ; } else { temp_ans = temp_ans + leftFalse * rightFalse ; } } else if ( str [ k ] == ' ^ ' ) { if ( isTrue == 1 ) { temp_ans = temp_ans + leftTrue * rightFalse + leftFalse * rightTrue ; } else { temp_ans = temp_ans + leftTrue * rightTrue + leftFalse * rightFalse ; } } dp [ i , j , isTrue ] = temp_ans ; } return temp_ans ; } static int countWays ( int N , string S ) { int [ , , ] dp = new int [ N + 1 , N + 1 , 2 ] ; for ( int i = 0 ; i < ( N + 1 ) ; i ++ ) { for ( int j = 0 ; j < ( N + 1 ) ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } return parenthesis_count ( S , 0 , N - 1 , 1 , dp ) ; } static void Main ( ) { string symbols = " TTFT " ; string operators = " | & ^ " ; string S = " " ; int j = 0 ; for ( int i = 0 ; i < symbols . Length ; i ++ ) { S = S + symbols [ i ] ; if ( j < operators . Length ) S = S + operators [ j ++ ] ; } int N = S . Length ; Console . WriteLine ( countWays ( N , S ) ) ; } }

Index/key variables: i, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int min ( int a , int b ) { return ( a < b ) ? a : b ; } static int min ( int [ ] arr , int l , int h ) { int mn = arr [ l ] ; for ( int i = l + 1 ; i <= h ; i ++ ) if ( mn > arr [ i ] ) mn = arr [ i ] ; return mn ; } static int max ( int [ ] arr , int l , int h ) { int mx = arr [ l ] ; for ( int i = l + 1 ; i <= h ; i ++ ) if ( mx < arr [ i ] ) mx = arr [ i ] ; return mx ; } static int minRemovals ( int [ ] arr , int l , int h ) { if ( l >= h ) return 0 ; int mn = min ( arr , l , h ) ; int mx = max ( arr , l , h ) ; if ( 2 * mn > mx ) return 0 ; return min ( minRemovals ( arr , l + 1 , h ) , minRemovals ( arr , l , h - 1 ) ) + 1 ; } public static void Main ( ) { int [ ] arr = { 4 , 5 , 100 , 9 , 10 , 11 , 12 , 15 , 200 } ; int n = arr . Length ; Console . Write ( minRemovals ( arr , 0 , n - 1 ) ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node left ; public Node right ; } ; static int sum ; static Node newNode ( int data ) { Node Node = new Node ( ) ; Node . data = data ; Node . left = null ; Node . right = null ; return ( Node ) ; } static int getTotalHeightUtil ( Node root ) { if ( root == null ) { return 0 ; } int lh = getTotalHeightUtil ( root . left ) ; int rh = getTotalHeightUtil ( root . right ) ; int h = Math . Max ( lh , rh ) + 1 ; sum = sum + h ; return h ; } static int getTotalHeight ( Node root ) { sum = 0 ; getTotalHeightUtil ( root ) ; return sum ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; Console . Write ( " Sum ▁ of ▁ heights ▁ of ▁ all ▁ Nodes ▁ = ▁ { 0 } " , getTotalHeight ( root ) ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual void inorder ( ) { if ( root == null ) { return ; } Stack < Node > s = new Stack < Node > ( ) ; Node curr = root ; while ( curr != null s . Count > 0 ) { while ( curr != null ) { s . Push ( curr ) ; curr = curr . left ; } curr = s . Pop ( ) ; Console . Write ( curr . data + " ▁ " ) ; curr = curr . right ; } } public static 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 ) ; tree . inorder ( ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class GFG { static int numberOfPaths ( int m , int n ) { int [ , ] count = new int [ m , n ] ; for ( int i = 0 ; i < m ; i ++ ) count [ i , 0 ] = 1 ; for ( int j = 0 ; j < n ; j ++ ) count [ 0 , j ] = 1 ; for ( int i = 1 ; i < m ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) } return count [ m - 1 , n - 1 ] ; } static public void Main ( ) { Console . WriteLine ( numberOfPaths ( 3 , 3 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] findSubsets ( int [ ] arr ) { Dictionary < int , int > M = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( M . ContainsKey ( arr [ i ] ) ) { M [ arr [ i ] ] ++ ; } else { M [ arr [ i ] ] = 1 ; } } int [ ] subsets = new int [ M . Count ] ; int I = 0 ; foreach ( KeyValuePair < int , int > playerEntry in M ) { subsets [ I ] = playerEntry . Value ; I ++ ; } return subsets ; } static bool subsetSum ( int [ ] subsets , int target ) { bool [ , ] dp = new bool [ subsets . Length + 1 , target + 1 ] ; for ( int i = 0 ; i < dp . GetLength ( 0 ) ; i ++ ) dp [ i , 0 ] = true ; for ( int i = 1 ; i <= subsets . Length ; i ++ ) { for ( int j = 1 ; j <= target ; j ++ ) { dp [ i , j ] = dp [ i - 1 , j ] ; if ( j >= subsets [ i - 1 ] ) { dp [ i , j ] |= dp [ i - 1 , j - subsets [ i - 1 ] ] ; } } } return dp [ subsets . Length , target ] ; } static void divideInto2Subset ( int [ ] arr ) { int [ ] subsets = findSubsets ( arr ) ; if ( ( arr . Length ) % 2 == 1 ) { Console . WriteLine ( " No " ) ; return ; } bool isPossible = subsetSum ( subsets , arr . Length / 2 ) ; if ( isPossible ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } static void Main ( ) { int [ ] arr = { 2 , 1 , 2 , 3 } ; divideInto2Subset ( arr ) ; } }

Index/key variables: I, i
Accumulator variables: I, i, j
Iterator variables: i, j, playerEntry
Class/struct names: GFG
C# program:
using System ; class GFG { static int NUM_STATION = 4 ; static int min ( int a , int b ) { return a < b ? a : b ; } static int carAssembly ( int [ , ] a , int [ , ] t , int [ ] e , int [ ] x ) { int [ ] T1 = new int [ NUM_STATION ] ; int [ ] T2 = new int [ NUM_STATION ] ; int i ; T1 [ 0 ] = e [ 0 ] + a [ 0 , 0 ] ; T2 [ 0 ] = e [ 1 ] + a [ 1 , 0 ] ; for ( i = 1 ; i < NUM_STATION ; ++ i ) { T1 [ i ] = min ( T1 [ i - 1 ] + a [ 0 , i ] , T2 [ i - 1 ] + t [ 1 , i ] + a [ 0 , i ] ) ; T2 [ i ] = min ( T2 [ i - 1 ] + a [ 1 , i ] , T1 [ i - 1 ] + t [ 0 , i ] + a [ 1 , i ] ) ; } return min ( T1 [ NUM_STATION - 1 ] + x [ 0 ] , T2 [ NUM_STATION - 1 ] + x [ 1 ] ) ; } public static void Main ( ) { int [ , ] a = { { 4 , 5 , 3 , 2 } , { 2 , 10 , 1 , 4 } } ; int [ , ] t = { { 0 , 7 , 4 , 5 } , { 0 , 9 , 2 , 8 } } ; int [ ] e = { 10 , 12 } ; int [ ] x = { 18 , 7 } ; Console . Write ( carAssembly ( a , t , e , x ) ) ; } }

Index/key variables: NUM_STATION, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinInsertionsDP ( char [ ] str , int n ) { int [ , ] table = new int [ n , n ] ; int l , h , gap ; for ( gap = 1 ; gap < n ; ++ gap ) for ( l = 0 , h = gap ; h < n ; ++ l , ++ h ) table [ l , h ] = ( str [ l ] == str [ h ] ) ? table [ l + 1 , h - 1 ] : ( Math . Min ( table [ l , h - 1 ] , table [ l + 1 , h ] ) + 1 ) ; return table [ 0 , n - 1 ] ; } public static void Main ( ) { String str = " geeks " ; Console . Write ( findMinInsertionsDP ( str . ToCharArray ( ) , str . Length ) ) ; } }

Index/key variables: h, l
Iterator variables: gap, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxCrossingSum ( int [ ] arr , int l , int m , int h ) { int sum = 0 ; int left_sum = int . MinValue ; for ( int i = m ; i >= l ; i -- ) { sum = sum + arr [ i ] ; if ( sum > left_sum ) left_sum = sum ; } sum = 0 ; int right_sum = int . MinValue ; ; for ( int i = m + 1 ; i <= h ; i ++ ) { sum = sum + arr [ i ] ; if ( sum > right_sum ) right_sum = sum ; } return Math . Max ( left_sum + right_sum , Math . Max ( left_sum , right_sum ) ) ; } static int maxSubArraySum ( int [ ] arr , int l , int h ) { if ( l == h ) return arr [ l ] ; int m = ( l + h ) / 2 ; return Math . Max ( Math . Max ( maxSubArraySum ( arr , l , m ) , maxSubArraySum ( arr , m + 1 , h ) ) , maxCrossingSum ( arr , l , m , h ) ) ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 5 , 7 } ; int n = arr . Length ; int max_sum = maxSubArraySum ( arr , 0 , n - 1 ) ; Console . Write ( " Maximum ▁ contiguous ▁ sum ▁ is ▁ " + max_sum ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float findWater ( int i , int j , float X ) { if ( j > i ) { Console . WriteLine ( " Incorrect ▁ Input " ) ; Environment . Exit ( 0 ) ; } int ll = ( int ) Math . Round ( ( double ) ( i * ( i + 1 ) ) ) ; float [ ] glass = new float [ ll + 2 ] ; int index = 0 ; glass [ index ] = X ; for ( int row = 1 ; row <= i ; ++ row ) { for ( int col = 1 ; col <= row ; ++ col , ++ index ) { X = glass [ index ] ; glass [ index ] = ( X >= 1.0f ) ? 1.0f : X ; X = ( X >= 1.0f ) ? ( X - 1 ) : 0.0f ; glass [ index + row ] += X / 2 ; glass [ index + row + 1 ] += X / 2 ; } } return glass [ ( int ) ( i * ( i - 1 ) / 2 + j - 1 ) ] ; } static void Main ( ) { int i = 2 , j = 2 ; float X = 2.0f ; Console . WriteLine ( " Amount ▁ of ▁ water ▁ in ▁ jth ▁ " + " glass ▁ of ▁ ith ▁ row ▁ is : ▁ " + findWater ( i , j , X ) ) ; } }

Index/key variables: index
Iterator variables: col, row
Class/struct names: GFG
C# program:
using System ; class Pair { int a ; int b ; public Pair ( int a , int b ) { this . a = a ; this . b = b ; } static int maxChainLength ( Pair [ ] arr , int n ) { int i , j , max = 0 ; int [ ] mcl = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) mcl [ i ] = 1 ; for ( i = 1 ; i < n ; i ++ ) for ( j = 0 ; j < i ; j ++ ) if ( arr [ i ] . a > arr [ j ] . b && mcl [ i ] < mcl [ j ] + 1 ) mcl [ i ] = mcl [ j ] + 1 ; for ( i = 0 ; i < n ; i ++ ) if ( max < mcl [ i ] ) max = mcl [ i ] ; return max ; } public static void Main ( ) { Pair [ ] arr = new Pair [ ] { new Pair ( 5 , 24 ) , new Pair ( 15 , 25 ) , new Pair ( 27 , 40 ) , new Pair ( 50 , 60 ) } ; Console . Write ( " Length ▁ of ▁ maximum ▁ size STRNEWLINE TABSYMBOL TABSYMBOL TABSYMBOL TABSYMBOL TABSYMBOL TABSYMBOL TABSYMBOL TABSYMBOL chain ▁ is ▁ " + maxChainLength ( arr , arr . Length ) ) ; } }

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