dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int [ ] f = new int [ 12 ] ; static void fact ( ) { f [ 0 ] = f [ 1 ] = 1 ; for ( int i = 2 ; i <= 10 ; i ++ ) f [ i ] = i * 1 * f [ i - 1 ] ; } static void solve ( int [ ] arr , int n , int k ) { fact ( ) ; int even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; } if ( k > even ) Console . Write ( 0 + " STRNEWLINE " ) ; else { Console . Write ( f [ even ] / ( f [ k ] * f [ even - k ] ) ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; int k = 1 ; solve ( arr , n , k ) ; } }

Index/key variables: even, i, k
Accumulator variables: even, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MOD = 1000000007 ; static int nCrModp ( int n , int r ) { if ( n % 2 == 1 ) { return - 1 ; } int [ ] C = new int [ r + 1 ] ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . Min ( i , r ) ; j > 0 ; j -- ) C [ j ] = ( C [ j ] + C [ j - 1 ] ) % MOD ; } return C [ r ] ; } static void Main ( ) { int N = 6 ; Console . WriteLine ( nCrModp ( N , N / 2 ) ) ; } }

Index/key variables: j, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printMinOperations ( int N ) { int [ ] dp = new int [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) dp [ i ] = N ; dp [ 1 ] = 0 ; for ( int i = 2 ; i < N + 1 ; i ++ ) { if ( i % 2 == 0 && dp [ i ] > dp [ i / 2 ] + 1 ) dp [ i ] = dp [ i / 2 ] + 1 ; if ( i % 3 == 0 && dp [ i ] > dp [ i / 3 ] + 1 ) dp [ i ] = dp [ i / 3 ] + 1 ; if ( dp [ i ] > dp [ i - 1 ] + 1 ) dp [ i ] = dp [ i - 1 ] + 1 ; } Console . WriteLine ( dp [ N ] ) ; List < int > seq = new List < int > ( ) ; while ( N > 1 ) { seq . Add ( N ) ; if ( dp [ N - 1 ] == dp [ N ] - 1 ) N = N - 1 ; else if ( N % 2 == 0 && dp [ N / 2 ] == dp [ N ] - 1 ) N = N / 2 ; else N = N / 3 ; } seq . Add ( 1 ) ; seq . Reverse ( ) ; foreach ( var i in seq ) { Console . Write ( i + " ▁ " ) ; } } public static void Main ( ) { int X = 96234 ; printMinOperations ( X ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxLength ( int [ ] arr , int n ) { int [ ] dp = new int [ n ] ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i ] = 1 ; } for ( int i = n - 1 ; i > 1 ; i -- ) { for ( int j = 1 ; j <= Math . Sqrt ( i ) ; j ++ ) { if ( i % j == 0 ) { int s = i / j ; if ( s == j ) { if ( arr [ i ] > arr [ s ] ) { dp [ s ] = Math . Max ( dp [ i ] + 1 , dp [ s ] ) ; } } else { if ( s != i && arr [ i ] > arr [ s ] ) dp [ s ] = Math . Max ( dp [ i ] + 1 , dp [ s ] ) ; if ( arr [ i ] > arr [ j ] ) { dp [ j ] = Math . Max ( dp [ i ] + 1 , dp [ j ] ) ; } } } } } int max = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( dp [ i ] > max ) max = dp [ i ] ; } Console . WriteLine ( max ) ; } public static void Main ( ) { int [ ] arr = new int [ ] { 0 , 1 , 4 , 2 , 3 , 6 , 4 , 9 } ; int size = arr . Length ; maxLength ( arr , size ) ; } }

Index/key variables: i, j, n, s
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProfit ( int [ ] price , int n ) { int buy1 , profit1 , buy2 , profit2 ; buy1 = buy2 = int . MaxValue ; profit1 = profit2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { buy1 = Math . Min ( buy1 , price [ i ] ) ; profit1 = Math . Max ( profit1 , price [ i ] - buy1 ) ; buy2 = Math . Min ( buy2 , price [ i ] - profit1 ) ; profit2 = Math . Max ( profit2 , price [ i ] - buy2 ) ; } return profit2 ; } public static void Main ( String [ ] args ) { int [ ] price = { 2 , 30 , 15 , 10 , 8 , 25 , 80 } ; int n = price . Length ; Console . Write ( " Maximum ▁ Profit ▁ = ▁ " + maxProfit ( price , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static int findMaximumScore ( int [ ] a , int n ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . ContainsKey ( a [ i ] ) ) { freq [ a [ i ] ] = freq [ a [ i ] ] + 1 ; } else { freq . Add ( a [ i ] , 1 ) ; } } int [ ] dp = new int [ a . Max ( ) + 1 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = freq [ 1 ] ; for ( int i = 2 ; i < dp . Length ; i ++ ) dp [ i ] = Math . Max ( dp [ i - 1 ] , dp [ i - 2 ] + freq [ i ] * i ) ; return dp [ dp . Length - 1 ] ; } public static void Main ( String [ ] args ) { int n ; n = 3 ; int [ ] a = { 1 , 2 , 3 } ; Console . Write ( findMaximumScore ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maximizeSum ( int [ ] arr ) { int n = arr . Length ; int sum = 0 ; for ( int i = 0 ; i < n ; i = i + 2 ) sum += arr [ i ] ; int [ ] leftDP = new int [ n / 2 ] ; int [ ] rightDP = new int [ n / 2 ] ; int c = 0 ; for ( int i = 1 ; i < n ; i = i + 2 ) { int leftDiff = arr [ i ] - arr [ i - 1 ] ; if ( c - 1 < 0 ) leftDP = leftDiff ; else { if ( leftDP > 0 ) leftDP = leftDiff + leftDP ; else leftDP = leftDiff ; } int rightDiff ; if ( i + 1 >= arr . Length ) rightDiff = 0 ; else rightDiff = arr [ i ] - arr [ i + 1 ] ; if ( c - 1 < 0 ) rightDP = rightDiff ; else { if ( rightDP > 0 ) rightDP = rightDiff + rightDP ; else rightDP = rightDiff ; } c ++ ; } int max = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { max = Math . Max ( max , Math . Max ( leftDP [ i ] , rightDP [ i ] ) ) ; } return max + sum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 8 , 4 , 5 , 7 , 6 , 8 , 9 , 7 , 3 } ; int ans = maximizeSum ( arr ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: i
Accumulator variables: c, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int validsubsequences ( int [ ] arr , int n ) { long [ , ] dp = new long [ n + 1 , 2 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { dp [ i , 0 ] = 0 ; dp [ i , 1 ] = 0 ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( arr [ i - 1 ] % 2 != 0 ) { dp [ i , 1 ] += 1 ; dp [ i , 1 ] += dp [ i - 1 , 0 ] ; dp [ i , 1 ] += dp [ i - 1 , 1 ] ; dp [ i , 0 ] += dp [ i - 1 , 0 ] ; } else { dp [ i , 0 ] += 1 ; dp [ i , 0 ] += dp [ i - 1 , 1 ] ; dp [ i , 0 ] += dp [ i - 1 , 0 ] ; dp [ i , 1 ] += dp [ i - 1 , 1 ] ; } } return ( int ) ( dp [ n , 0 ] + dp [ n , 1 ] ) ; } public static void Main ( ) { int [ ] arr = { 5 , 6 , 9 , 7 } ; int n = arr . Length ; Console . Write ( validsubsequences ( arr , n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long getCount ( int n , int k ) { if ( n == 1 ) return 10 ; long [ , ] dp = new long [ n + 1 , 11 ] ; for ( int i = 1 ; i <= 9 ; i ++ ) dp [ 1 , i ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 9 ; j ++ ) { int l = Math . Max ( 0 , j - k ) ; int r = Math . Min ( 9 , j + k ) ; dp [ i , l ] += dp [ i - 1 , j ] ; dp [ i , r + 1 ] -= dp [ i - 1 , j ] ; } for ( int j = 1 ; j <= 9 ; j ++ ) dp [ i , j ] += dp [ i , j - 1 ] ; } long count = 0 ; for ( int i = 0 ; i <= 9 ; i ++ ) count += dp [ n , i ] ; return count ; } public static void Main ( ) { int n = 2 , k = 1 ; Console . WriteLine ( getCount ( n , k ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int X = 6 ; static readonly int Z = 2 ; static bool existPath ( int V , int [ , ] edges , int u , int v ) { bool [ , ] mat = new bool [ V , V ] ; for ( int i = 0 ; i < X ; i ++ ) mat [ edges [ i , 0 ] , edges [ i , 1 ] ] = true ; for ( int k = 0 ; k < V ; k ++ ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { mat [ i , j ] = mat [ i , j ] || mat [ i , k ] && mat [ k , j ] ; } } } if ( u >= V v >= V ) { return false ; } if ( mat [ u , v ] ) return true ; return false ; } public static void Main ( String [ ] args ) { int V = 4 ; int [ , ] edges = { { 0 , 2 } , { 0 , 1 } , { 1 , 2 } , { 2 , 3 } , { 2 , 0 } , { 3 , 3 } } ; int u = 1 , v = 3 ; if ( existPath ( V , edges , u , v ) ) Console . Write ( " Yes STRNEWLINE " ) ; else Console . Write ( " No STRNEWLINE " ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculate_maximum_splits ( int [ ] arr , int N ) { int [ ] pre = { 0 , - 1 , - 1 } ; int [ ] dp = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { dp [ i ] = 0 ; } int C = 0 ; for ( int i = 0 ; i < N ; i ++ ) { C = C + arr [ i ] ; C = C % 3 ; if ( pre [ C ] == - 1 ) { if ( 1 <= i ) dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = Math . Max ( dp [ i - 1 ] , dp [ pre [ C ] ] + 1 ) ; } pre [ C ] = i ; } return dp [ N - 1 ] ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 36 , 1 , 9 , 2 , 0 , 1 , 8 , 1 } ; int N = arr . Length ; Console . Write ( calculate_maximum_splits ( arr , N ) ) ; } }

Index/key variables: C, N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] prime = new int [ 1000001 ] ; static void seiveOfEratosthenes ( ) { for ( int i = 2 ; i < 1000001 ; i ++ ) { prime [ i ] = 1 ; } for ( int i = 2 ; i * i < 1000001 ; i ++ ) { if ( prime [ i ] == 1 ) { for ( int j = i * i ; j < 1000001 ; j += i ) { prime [ j ] = 0 ; } } } } static void CountElements ( int [ ] arr , int n , int L , int R ) { seiveOfEratosthenes ( ) ; int [ ] countPrime = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { countPrime [ i ] = countPrime [ i - 1 ] + prime [ arr [ i - 1 ] ] ; } Console . Write ( countPrime [ R ] - countPrime [ L - 1 ] + " STRNEWLINE " ) ; return ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 5 , 8 } ; int N = arr . Length ; int L = 1 , R = 3 ; CountElements ( arr , N , L , R ) ; } }

Index/key variables: R, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void OddDivisorsCount ( int n , int q , int [ ] a , pair [ ] Query ) { int [ ] DP = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = ( int ) Math . Sqrt ( a [ i ] ) ; if ( x * x == a [ i ] ) DP [ i ] = 1 ; } for ( int i = 1 ; i < n ; i ++ ) { DP [ i ] = DP [ i - 1 ] + DP [ i ] ; } int l , r ; for ( int i = 0 ; i < q ; i ++ ) { l = Query [ i ] . first ; r = Query [ i ] . second ; if ( l == 0 ) { Console . Write ( DP [ r ] + " STRNEWLINE " ) ; } else { Console . Write ( DP [ r ] - DP [ l - 1 ] + " STRNEWLINE " ) ; } } } public static void Main ( String [ ] args ) { int N = 5 ; int Q = 3 ; int [ ] arr = { 2 , 4 , 5 , 6 , 9 } ; pair [ ] Query = { new pair ( 0 , 2 ) , new pair ( 1 , 3 ) , new pair ( 1 , 4 ) } ; OddDivisorsCount ( N , Q , arr , Query ) ; } }

Index/key variables: i, n, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int n , k ; static int [ , , , ] dp = new int [ 1024 , 2048 , 2 , 2 ] ; static int Ways ( int col , int comp , int row1 , int row2 ) { if ( comp > k ) return 0 ; if ( col > n ) { if ( comp == k ) return 1 ; else return 0 ; } if ( dp [ col , comp , row1 , row2 ] != - 1 ) return dp [ col , comp , row1 , row2 ] ; else { int ans = 0 ; if ( col == 1 ) { ans = ( ans + Ways ( col + 1 , comp + 1 , 0 , 0 ) + Ways ( col + 1 , comp + 1 , 1 , 1 ) ) ; ans = ( ans + Ways ( col + 1 , comp + 2 , 0 , 1 ) + Ways ( col + 1 , comp + 2 , 1 , 0 ) ) ; } else { if ( ( row1 > 0 && row2 > 0 ) || ( row1 == 0 && row2 == 0 ) ) { ans = ( ( ( ans + Ways ( col + 1 , comp + 1 , 0 , 0 ) ) + Ways ( col + 1 , comp + 1 , 1 , 0 ) ) + Ways ( col + 1 , comp + 1 , 0 , 1 ) ) ; ans = ( ans + Ways ( col + 1 , comp , 1 , 1 ) ) ; } if ( row1 > 0 && row2 == 0 ) { ans = ( ( ( ans + Ways ( col + 1 , comp , 0 , 0 ) ) + Ways ( col + 1 , comp , 1 , 1 ) ) + Ways ( col + 1 , comp , 1 , 0 ) ) ; ans = ( ans + Ways ( col + 1 , comp + 2 , 0 , 1 ) ) ; } if ( row1 == 0 && row2 > 0 ) { ans = ( ( ( ans + Ways ( col + 1 , comp , 0 , 0 ) ) + Ways ( col + 1 , comp , 1 , 1 ) ) + Ways ( col + 1 , comp , 0 , 1 ) ) ; ans = ( ans + Ways ( col + 1 , comp + 2 , 1 , 0 ) ) ; } } return dp [ col , comp , row1 , row2 ] = ans ; } } public static void Main ( String [ ] args ) { n = 2 ; k = 1 ; for ( int i = 0 ; i < 1024 ; i ++ ) for ( int j = 0 ; j < 2048 ; j ++ ) for ( int K = 0 ; K < 2 ; K ++ ) for ( int l = 0 ; l < 2 ; l ++ ) dp [ i , j , K , l ] = - 1 ; Console . Write ( Ways ( 1 , 0 , 0 , 0 ) ) ; } }

Accumulator variables: K, i, j, l
Iterator variables: K, i, j, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool [ ] primes = new bool [ 1000001 ] ; static int maxn = 1000000 ; static void sieve ( ) { for ( int i = 0 ; i < primes . Length ; i ++ ) { primes [ i ] = true ; } primes [ 0 ] = false ; primes [ 1 ] = false ; for ( int i = 2 ; i * i <= maxn ; i ++ ) { if ( primes [ i ] ) { for ( int j = i * i ; j <= maxn ; j += i ) primes [ j ] = false ; } } } static String toBinary ( int n ) { String r = " " ; while ( n != 0 ) { r = ( n % 2 == 0 ? "0" : "1" ) + r ; n /= 2 ; } return ( r == " " ) ? "0" : r ; } static void PrimeSplit ( String str ) { String temp ; List < String > ans = new List < String > ( ) ; int bt = 1 << ( str . Length - 1 ) ; int n = str . Length ; for ( int i = 0 ; i < bt ; i ++ ) { temp = toBinary ( i ) + "0" ; int j = 0 , x = n - temp . Length , y ; while ( j < x ) { temp = "0" + temp ; j ++ ; } j = 0 ; x = 0 ; y = - 1 ; String sp = " " , tp = " " ; bool flag = false ; while ( j < n ) { sp += str [ j ] ; if ( temp [ j ] == '1' ) { tp += sp + ' , ' ; y = Int32 . Parse ( sp ) ; if ( ! primes [ y ] ) { flag = true ; break ; } sp = " " ; } j ++ ; } tp += sp ; if ( sp != " " ) { y = Int32 . Parse ( sp ) ; if ( ! primes [ y ] ) flag = true ; } if ( ! flag ) ans . Add ( tp ) ; } if ( ans . Count == 0 ) { Console . WriteLine ( - 1 ) ; } foreach ( String i in ans ) { Console . WriteLine ( i ) ; } } public static void Main ( String [ ] args ) { String str = "11373" ; sieve ( ) ; PrimeSplit ( str ) ; } }

Index/key variables: i, j, y
Accumulator variables: i, j, n, sp, tp
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int countStableNum ( String str , int N ) { int [ , ] count1 = new int [ N , 10 ] ; int [ , ] count2 = new int [ N , 10 ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < 10 ; j ++ ) count1 [ i , j ] = count2 [ i , j ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i != 0 ) { for ( int j = 0 ; j < 10 ; j ++ ) { count1 [ i , j ] += count1 [ i - 1 , j ] ; } } count1 [ i , str [ i ] - '0' ] ++ ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( i != N - 1 ) { for ( int j = 0 ; j < 10 ; j ++ ) { count2 [ i , j ] += count2 [ i + 1 , j ] ; } } count2 [ i , str [ i ] - '0' ] ++ ; } int ans = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( str [ i ] == '9' ) continue ; int c1 = count1 [ i - 1 , str [ i ] - '0' ] ; int c2 = count2 [ i + 1 , str [ i ] - '0' + 1 ] ; if ( c2 == 0 ) continue ; ans = ( ans + ( c1 * ( ( c2 * ( c2 - 1 ) / 2 ) ) ) ) ; } return ans ; } public static void Main ( String [ ] args ) { String str = "224353" ; int N = str . Length ; Console . WriteLine ( countStableNum ( str , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubsequenceUtil ( int ind , int sum , int [ ] A , int N , int [ , ] dp ) { if ( ind == N ) return 1 ; if ( dp [ ind , sum ] != - 1 ) return dp [ ind , sum ] ; if ( A [ ind ] <= sum ) { dp [ ind , sum ] = countSubsequenceUtil ( ind + 1 , sum , A , N , dp ) + countSubsequenceUtil ( ind + 1 , sum - A [ ind ] , A , N , dp ) ; } else { dp [ ind , sum ] = countSubsequenceUtil ( ind + 1 , sum , A , N , dp ) ; } return dp [ ind , sum ] ; } static int countSubsequence ( int [ ] A , int N , int X ) { int [ , ] dp = new int [ N , X + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < X + 1 ; j ++ ) { dp [ i , j ] = - 1 ; } } return countSubsequenceUtil ( 0 , X , A , N , dp ) - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 25 , 13 , 40 } ; int X = 50 ; int N = arr . Length ; Console . Write ( countSubsequence ( arr , N , X ) ) ; } }

Index/key variables: ind
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int waysToDecode2 ( char [ ] s ) { int n = s . Length ; int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = 1 ; if ( s [ 0 ] == '0' ) return 0 ; dp [ 1 ] = ( ( s [ 0 ] == ' * ' ) ? 9 : 1 ) ; for ( int i = 2 ; i <= n ; i ++ ) { char first = s [ i - 2 ] ; char second = s [ i - 1 ] ; if ( second == ' * ' ) { dp [ i ] += 9 * dp [ i - 1 ] ; } else if ( second > '0' ) { dp [ i ] += dp [ i - 1 ] ; } if ( first == '1' first == '2' ) { if ( second == ' * ' ) { if ( first == '1' ) { dp [ i ] += 9 * dp [ i - 2 ] ; } else if ( first == '2' ) { dp [ i ] += 6 * dp [ i - 2 ] ; } } else if ( ( ( first - '0' ) * 10 + ( second - '0' ) ) <= 26 ) { dp [ i ] += dp [ i - 2 ] ; } } else if ( first == ' * ' ) { if ( second == ' * ' ) { dp [ i ] += 15 * dp [ i - 2 ] ; } else if ( second <= '6' ) { dp [ i ] += 2 * dp [ i - 2 ] ; } else { dp [ i ] += dp [ i - 2 ] ; } } } return dp [ n ] ; } public static void Main ( String [ ] args ) { String str = "12*3" ; Console . Write ( waysToDecode2 ( str . ToCharArray ( ) ) + " STRNEWLINE " ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void goodint ( int [ ] arr , int n , int h , int l , int r ) { int [ , ] dp = new int [ n + 1 , h ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < h ; j ++ ) dp [ i , j ] = - 1 ; dp [ 0 , 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < h ; j ++ ) { if ( dp [ i , j ] != - 1 ) { int h1 = ( j + arr [ i ] ) % h ; int h2 = ( j + arr [ i ] - 1 ) % h ; dp [ i + 1 , h1 ] = Math . Max ( dp [ i + 1 , h1 ] , dp [ i , j ] + ( ( h1 >= l && h1 <= r ) ? 1 : 0 ) ) ; dp [ i + 1 , h2 ] = Math . Max ( dp [ i + 1 , h2 ] , dp [ i , j ] + ( ( h2 >= l && h2 <= r ) ? 1 : 0 ) ) ; } } } int ans = 0 ; for ( int i = 0 ; i < h ; i ++ ) { if ( dp [ n , i ] != - 1 ) ans = Math . Max ( ans , dp [ n , i ] ) ; } Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 16 , 17 , 14 , 20 , 20 , 11 , 22 } ; int H = 24 ; int L = 21 ; int R = 23 ; int size = A . Length ; goodint ( A , size , H , L , R ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { class Query { public int L , R ; public Query ( int l , int r ) { L = l ; R = r ; } } ; static void fillPrefixArray ( int [ ] arr , int n , int [ ] prefixArray ) { prefixArray [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { prefixArray [ i ] = prefixArray [ i - 1 ] + arr [ i ] ; } else { prefixArray [ i ] = prefixArray [ i - 1 ] - arr [ i ] ; } } } static int findResultUtil ( int [ ] prefixArray , int L , int R ) { int result ; if ( L == 0 ) { result = prefixArray [ R ] ; } else { result = prefixArray [ R ] - prefixArray [ L - 1 ] ; } if ( L % 2 == 1 ) { result = result * ( - 1 ) ; } return result ; } static void findResult ( int [ ] arr , int n , Query [ ] q , int m ) { int [ ] prefixArray = new int [ n ] ; fillPrefixArray ( arr , n , prefixArray ) ; for ( int i = 0 ; i < m ; i ++ ) { Console . Write ( findResultUtil ( prefixArray , q [ i ] . L , q [ i ] . R ) + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 13 , 15 , 2 , 45 , 31 , 22 , 3 , 27 } ; int n = arr . Length ; Query [ ] q = { new Query ( 2 , 5 ) , new Query ( 6 , 8 ) , new Query ( 1 , 7 ) , new Query ( 4 , 8 ) , new Query ( 0 , 5 ) } ; int m = q . Length ; findResult ( arr , n , q , m ) ; } }

Index/key variables: R, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Query
C# program:
using System ; class GFG { static bool isKPartitionPossible ( int [ ] arr , int N , int K ) { if ( K == 1 ) return true ; if ( N < K ) return false ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum % K != 0 ) return false ; int target = sum / K ; int [ ] dp = new int [ ( 1 << 15 ) ] ; for ( int i = 0 ; i < ( 1 << N ) ; i ++ ) dp [ i ] = - 1 ; dp [ 0 ] = 0 ; for ( int mask = 0 ; mask < ( 1 << N ) ; mask ++ ) { if ( dp [ mask ] == - 1 ) continue ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( ( mask & ( 1 << i ) ) == 0 ) && dp [ mask ] + arr [ i ] <= target ) { dp [ mask ( 1 << i ) ] = ( dp [ mask ] + arr [ i ] ) % target ; } } } if ( dp [ ( 1 << N ) - 1 ] == 0 ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 4 , 5 , 3 , 3 } ; int N = arr . Length ; int K = 3 ; if ( isKPartitionPossible ( arr , N , K ) ) { Console . Write ( " Partitions ▁ into ▁ equal ▁ " ) ; Console . Write ( " sum ▁ is ▁ possible . STRNEWLINE " ) ; } else { Console . Write ( " Partitions ▁ into ▁ equal ▁ " ) ; Console . Write ( " sum ▁ is ▁ not ▁ possible . STRNEWLINE " ) ; } } }

Index/key variables: i, mask
Accumulator variables: i, mask, sum
Iterator variables: i, mask
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static long MAX = ( long ) 1e18 ; static long n , m ; static List < List < long > > v = new List < List < long > > ( ) ; static long [ , ] dp = new long [ 151 , 151 ] ; static long min_operation ( long i , long j , long val , long x ) { if ( i == n - 1 && j == m - 1 ) { if ( val > v [ ( int ) i ] [ ( int ) j ] ) { return dp [ ( int ) i , ( int ) j ] = MAX ; } else { return dp [ ( int ) i , ( int ) j ] = v [ ( int ) i ] [ ( int ) j ] - val ; } } if ( i == n j == m ) { return dp [ ( int ) i , ( int ) j ] = MAX ; } if ( dp [ ( int ) i , ( int ) j ] != - 1 ) { return dp [ ( int ) i , ( int ) j ] ; } if ( val > v [ ( int ) i ] [ ( int ) j ] ) { return dp [ ( int ) i , ( int ) j ] = MAX ; } long temp = v [ ( int ) i ] [ ( int ) j ] - val ; temp += Math . Min ( min_operation ( i + 1 , j , val + x , x ) , min_operation ( i , j + 1 , val + x , x ) ) ; return dp [ ( int ) i , ( int ) j ] = temp ; } static long solve ( long x ) { long ans = Int64 . MaxValue ; for ( long i = 0 ; i < n ; i ++ ) { for ( long j = 0 ; j < m ; j ++ ) { long val = v [ ( int ) i ] [ ( int ) j ] - x * ( i + j ) ; for ( long k = 0 ; k < dp . GetLength ( 0 ) ; k ++ ) { for ( long l = 0 ; l < dp . GetLength ( 1 ) ; l ++ ) { dp [ k , l ] = - 1 ; } } val = min_operation ( 0 , 0 , val , x ) ; ans = Math . Min ( ans , val ) ; } } return ans ; } static public void Main ( ) { for ( int i = 0 ; i < 151 ; i ++ ) { v . Add ( new List < long > ( ) ) ; v [ i ] . Add ( 0 ) ; v [ i ] . Add ( 0 ) ; } v [ 0 ] [ 0 ] = 15 ; v [ 0 ] [ 1 ] = 153 ; v [ 1 ] [ 0 ] = 135 ; v [ 1 ] [ 1 ] = 17 ; n = 2 ; m = 2 ; long x = 3 ; Console . WriteLine ( solve ( x ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, k, l, temp
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int printAllSubsetsRec ( int [ ] arr , int n , List < int > v , int sum ) { if ( sum == 0 ) { return v . Count ; } if ( sum < 0 ) return Int32 . MaxValue ; if ( n == 0 ) return Int32 . MaxValue ; int x = printAllSubsetsRec ( arr , n - 1 , v , sum ) ; v . Add ( arr [ n - 1 ] ) ; int y = printAllSubsetsRec ( arr , n , v , sum - arr [ n - 1 ] ) ; v . RemoveAt ( v . Count - 1 ) ; return Math . Min ( x , y ) ; } static int printAllSubsets ( int [ ] arr , int n , int sum ) { List < int > v = new List < int > ( ) ; return printAllSubsetsRec ( arr , n , v , sum ) ; } static void Main ( ) { int [ ] arr = { 2 , 1 , 4 , 3 , 5 , 6 } ; int sum = 6 ; int n = arr . Length ; Console . WriteLine ( printAllSubsets ( arr , n , sum ) ) ; } }

Class/struct names: GFG