dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class pair { public int x , y ; public pair ( int x , int y ) { this . x = x ; this . y = y ; } public String toString ( ) { return " ( " + this . x + " , ▁ " + this . y + " ) " ; } } class GFG { public static void maxZeros ( int [ , ] mat , int n , int m ) { if ( n == 0 m == 0 ) return ; pair [ , ] dp = new pair [ n + 1 , m + 1 ] ; dp [ 0 , 0 ] = new pair ( countTwos ( mat [ 0 , 0 ] ) , countFives ( mat [ 0 , 0 ] ) ) ; for ( int i = 1 ; i < n ; i ++ ) dp [ i , 0 ] = add ( dp [ i - 1 , 0 ] , new pair ( countTwos ( mat [ i , 0 ] ) , countFives ( mat [ i , 0 ] ) ) ) ; for ( int i = 1 ; i < m ; i ++ ) dp [ 0 , i ] = add ( dp [ 0 , i - 1 ] , new pair ( countTwos ( mat [ 0 , i ] ) , countFives ( mat [ 0 , i ] ) ) ) ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; j < m ; j ++ ) { pair top = dp [ i - 1 , j ] ; pair left = dp [ i , j - 1 ] ; pair curr = new pair ( countTwos ( mat [ i , j ] ) , countFives ( mat [ i , j ] ) ) ; top = add ( top , curr ) ; left = add ( left , curr ) ; if ( check ( top , left ) ) dp [ i , j ] = top ; else dp [ i , j ] = left ; } } Console . WriteLine ( Math . Min ( dp [ n - 1 , m - 1 ] . x , dp [ n - 1 , m - 1 ] . y ) ) ; } public static bool check ( pair one , pair two ) { int top = Math . Min ( one . x , one . y ) ; int left = Math . Min ( two . x , two . y ) ; if ( top > left ) return true ; else return false ; } public static int countTwos ( int num ) { int count = 0 ; while ( num != 0 && num % 2 == 0 ) { num /= 2 ; count ++ ; } return count ; } public static int countFives ( int num ) { int count = 0 ; while ( num != 0 && num % 5 == 0 ) { num /= 5 ; count ++ ; } return count ; } public static pair add ( pair one , pair two ) { pair np = new pair ( one . x + two . x , one . y + two . y ) ; return np ; } public static void Main ( String [ ] args ) { int N = 3 , M = 4 ; int [ , ] mat = { { 6 , 25 , 4 , 10 } , { 12 , 25 , 1 , 15 } , { 7 , 15 , 15 , 5 } } ; maxZeros ( mat , N , M ) ; } }

Accumulator variables: count, i, j, num
Iterator variables: i, j
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 100005 ; static List < int > SieveOfEratosthenes ( ) { bool [ ] seive = new bool [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) seive [ i ] = true ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( seive [ p ] == true ) { for ( int i = p * p ; i < MAX ; i += p ) { seive [ i ] = false ; } } } List < int > v = new List < int > ( ) ; for ( int p = 2 ; p < MAX ; p ++ ) { if ( seive [ p ] ) { v . Add ( p ) ; } } return v ; } static void build ( int [ ] dp , int [ ] arr , int N ) { dp [ 0 ] = 0 ; dp [ 1 ] = 0 ; List < int > prime = SieveOfEratosthenes ( ) ; int [ ] pref = new int [ N + 1 ] ; pref [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { pref [ i ] = pref [ i - 1 ] + arr [ i - 1 ] ; } for ( int i = 2 ; i <= N ; i ++ ) { dp [ i ] = dp [ i - 1 ] ; for ( int j = 0 ; j <= prime . Count ; j ++ ) { int r = i - 1 ; int l = r - prime [ j ] + 1 ; if ( l < 0 ) break ; int temp = 0 ; temp = pref [ r + 1 ] - pref [ l ] ; if ( l - 2 >= 0 ) temp += dp [ l - 2 + 1 ] ; dp [ i ] = Math . Max ( dp [ i ] , temp ) ; } } } static void maxSumSubseq ( int [ ] arr , int N ) { int [ ] dp = new int [ N + 1 ] ; build ( dp , arr , N ) ; Console . Write ( dp [ N ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 10 , 7 , 10 , 10 , 10 } ; int N = arr . Length ; maxSumSubseq ( arr , N ) ; } }

Index/key variables: MAX, N, i, j, l, p
Accumulator variables: i, j, p, temp
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxScore ( int [ ] arr ) { int N = arr . Length ; N ++ ; int [ , ] dp = new int [ N + 1 , 2 * ( N - 1 ) + 1 ] ; dp [ 0 , 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int s = 1 ; s <= 2 * ( N - 1 ) ; s ++ ) { for ( int j = 1 ; j <= N - 1 && j <= s ; j ++ ) { dp [ i , s ] = Math . Max ( dp [ i , s ] , arr [ j - 1 ] + dp [ i - 1 , s - j ] ) ; } } } return dp [ N , 2 * ( N - 1 ) ] - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 0 } ; Console . Write ( maxScore ( arr ) ) ; } }

Accumulator variables: N, i, j, s
Iterator variables: i, j, s
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumCost ( int [ ] cost , int n , int x ) { int [ ] dp = new int [ n + 2 ] ; dp [ 0 ] = cost [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( i == 1 ) dp [ i ] = cost [ i ] + dp [ i - 1 ] ; if ( i == 2 ) dp [ i ] = cost [ i ] + Math . Min ( dp [ i - 1 ] , x + dp [ i - 2 ] ) ; if ( i >= 3 ) dp [ i ] = cost [ i ] + Math . Min ( dp [ i - 1 ] , Math . Min ( x + dp [ i - 2 ] , 2 * x + dp [ i - 3 ] ) ) ; } Console . WriteLine ( dp [ n - 1 ] ) ; } public static void Main ( ) { int X = 4 ; int [ ] cost = { 6 , 3 , 9 , 2 , 1 , 3 } ; int N = cost . Length ; minimumCost ( cost , N , X ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxSum ( int [ ] a , int n , int k ) { if ( n <= 0 ) return 0 ; int option = maxSum ( a , n - 1 , k ) ; if ( k >= a [ n - 1 ] ) option = Math . Max ( option , a [ n - 1 ] + maxSum ( a , n - 2 , k - a [ n - 1 ] ) ) ; return option ; } public static void Main ( String [ ] args ) { int [ ] arr = { 50 , 10 , 20 , 30 , 40 } ; int N = arr . Length ; int K = 100 ; Console . WriteLine ( maxSum ( arr , N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkStr ( string str , int P , int Q ) { int N = str . Length ; char prev = str [ 0 ] ; int cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == prev ) { cnt ++ ; } else { if ( prev == '1' && cnt >= Q ) { return false ; } if ( prev == '0' && cnt >= P ) { return false ; } cnt = 1 ; } prev = str [ i ] ; } if ( prev == '1' && cnt >= Q ) { return false ; } if ( prev == '0' && cnt >= P ) { return false ; } return true ; } static int cntBinStr ( string str , int N , int P , int Q ) { int len = str . Length ; if ( len == N ) { if ( checkStr ( str , P , Q ) ) return 1 ; return 0 ; } int X = cntBinStr ( str + '0' , N , P , Q ) ; int Y = cntBinStr ( str + '1' , N , P , Q ) ; return X + Y ; } public static void Main ( ) { int N = 5 , P = 2 , Q = 3 ; Console . WriteLine ( cntBinStr ( " " , N , P , Q ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int binCoff ( int N , int R ) { int res = 1 ; if ( R > ( N - R ) ) { R = ( N - R ) ; } for ( int i = 0 ; i < R ; i ++ ) { res *= ( N - i ) ; res /= ( i + 1 ) ; } return res ; } static int cntPermutation ( int N ) { int cntPerm ; int C_2N_N = binCoff ( 2 * N , N ) ; cntPerm = C_2N_N / ( N + 1 ) ; return cntPerm ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; Console . WriteLine ( cntPermutation ( N / 2 ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void smallestPosition ( int [ , ] m , int k ) { int n = m . GetLength ( 0 ) ; int mm = m . GetLength ( 1 ) ; int [ , ] xor = new int [ n , mm ] ; List < int > minHeap = new List < int > ( ) ; Dictionary < int , int [ ] > map = new Dictionary < int , int [ ] > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < mm ; j ++ ) { int a = i - 1 >= 0 ? xor [ i - 1 , j ] : 0 ; int b = j - 1 >= 0 ? xor [ i , j - 1 ] : 0 ; int c = ( i - 1 >= 0 && j - 1 >= 0 ) ? xor [ i - 1 , j - 1 ] : 0 ; xor [ i , j ] = m [ i , j ] ^ a ^ b ^ c ; minHeap . Add ( xor [ i , j ] ) ; minHeap . Sort ( ) ; if ( minHeap . Count > k ) { minHeap . RemoveAt ( 0 ) ; } if ( ! map . ContainsKey ( xor [ i , j ] ) ) map . Add ( xor [ i , j ] , new int [ ] { i , j } ) ; } } minHeap . Sort ( ) ; int kth_max_e = minHeap [ 0 ] ; Console . WriteLine ( ( map [ kth_max_e ] [ 0 ] + 1 ) + " ▁ " + ( map [ kth_max_e ] [ 1 ] + 1 ) ) ; } public static void Main ( String [ ] args ) { int [ , ] m = { { 1 , 2 , 3 } , { 2 , 2 , 1 } , { 2 , 4 , 2 } } ; int k = 1 ; smallestPosition ( m , k ) ; } }

Index/key variables: kth_max_e
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestPalSubstr ( string str ) { int n = str . Length ; int maxLength = 1 , start = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { for ( int j = i ; j < str . Length ; j ++ ) { int flag = 1 ; for ( int k = 0 ; k < ( j - i + 1 ) / 2 ; k ++ ) if ( str [ i + k ] != str [ j - k ] ) flag = 0 ; if ( flag != 0 && ( j - i + 1 ) > maxLength ) { start = i ; maxLength = j - i + 1 ; } } } return maxLength ; } public static void Main ( ) { string str = " forgeeksskeegfor " ; Console . Write ( longestPalSubstr ( str ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , , ] dp = new int [ 101 , 101 , 101 ] ; static int helper ( int [ ] arr , int left , int right , int count , int m ) { if ( left > right ) return 0 ; if ( dp [ left , right , count ] != - 1 ) { return dp [ left , right , count ] ; } int ans = ( count + 1 ) * m + helper ( arr , left + 1 , right , 0 , m ) ; for ( int i = left + 1 ; i <= right ; ++ i ) { if ( arr [ i ] == arr [ left ] ) { ans = Math . Max ( ans , helper ( arr , left + 1 , i - 1 , 0 , m ) + helper ( arr , i , right , count + 1 , m ) ) ; } } dp [ left , right , count ] = ans ; return ans ; } static int maxPoints ( int [ ] arr , int n , int m ) { int len = n ; 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 helper ( arr , 0 , len - 1 , 0 , m ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 2 , 2 , 2 , 3 , 4 , 3 , 1 } ; int M = 3 ; int N = arr . Length ; Console . Write ( maxPoints ( arr , N , M ) ) ; } }

Index/key variables: i, left
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int inf = 1000000008 ; public static int minSteps ( int m , int n ) { if ( n == m ) return 0 ; if ( m > n ) return inf ; int min_cost = inf ; for ( int i = 2 ; i < m ; i += 2 ) { if ( m % i == 0 ) { min_cost = Math . Min ( min_cost , m / i + minSteps ( m + i , n ) ) ; } } return min_cost ; } public static void Main ( String [ ] args ) { int M = 6 ; int N = 24 ; int minimum_cost = minSteps ( M , N ) ; minimum_cost = minimum_cost == inf ? - 1 : minimum_cost ; Console . WriteLine ( minimum_cost ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCountOfNumbers ( int N ) { int k = N % 10 ; int z = N - ( 9 * ( 9 - k ) ) ; if ( z >= 9 && z % 10 == 9 ) { return 10 - k ; } else return - 1 ; } public static void Main ( String [ ] args ) { int N = 156 ; Console . Write ( minCountOfNumbers ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void manipulation ( int [ , ] matrix , int [ ] q ) { int x1 = q [ 0 ] , y1 = q [ 1 ] , x2 = q [ 2 ] , y2 = q [ 3 ] ; for ( int i = x1 - 1 ; i < x2 ; i ++ ) { for ( int j = y1 - 1 ; j < y2 ; j ++ ) { if ( matrix [ i , j ] == 1 ) matrix [ i , j ] = 0 ; else matrix [ i , j ] = 1 ; } } } public static int [ ] GetRow ( int [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new int [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } static void queries_fxn ( int [ , ] matrix , int [ , ] queries ) { for ( int i = 0 ; i < queries . GetLength ( 0 ) ; i ++ ) manipulation ( matrix , GetRow ( queries , i ) ) ; } public static void Main ( String [ ] args ) { int [ , ] matrix = { { 0 , 1 , 0 } , { 1 , 1 , 0 } } ; int [ , ] queries = { { 1 , 1 , 2 , 3 } , { 1 , 1 , 1 , 1 } , { 1 , 2 , 2 , 3 } } ; queries_fxn ( matrix , queries ) ; Console . Write ( " [ " ) ; for ( int i = 0 ; i < matrix . GetLength ( 0 ) ; i ++ ) { Console . Write ( " [ " ) ; for ( int j = 0 ; j < matrix . GetLength ( 1 ) ; j ++ ) Console . Write ( matrix [ i , j ] + " , ▁ " ) ; if ( i == matrix . Length - 1 ) Console . Write ( " ] " ) ; else Console . Write ( " ] , ▁ " ) ; } Console . Write ( " ] " ) ; } }

Index/key variables: i, rowLength
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int INF = ( int ) 1e7 ; static int min_op ( int cur , int M ) { if ( cur > M ) return INF ; if ( cur == M ) return 0 ; int op = INF ; for ( int i = 2 ; i * i <= cur ; i ++ ) { if ( cur % i == 0 ) { if ( i % 2 == 0 ) { op = Math . Min ( op , 1 + min_op ( cur + i , M ) ) ; } if ( ( cur / i ) != i && ( cur / i ) % 2 == 0 ) { op = Math . Min ( op , 1 + min_op ( cur + ( cur / i ) , M ) ) ; } } } return op ; } static void min_operations ( int N , int M ) { int op = min_op ( N , M ) ; if ( op >= INF ) Console . Write ( " - 1" ) ; else Console . Write ( op + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int N = 6 , M = 24 ; min_operations ( N , M ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { private static int [ ] findPrimeFactors ( int n ) { int [ ] primeFactors = new int [ 9 ] ; int j = 0 ; if ( n % 2 == 0 ) { primeFactors [ j ++ ] = 2 ; while ( n % 2 == 0 ) n >>= 1 ; } for ( int i = 3 ; i * i <= n ; i += 2 ) { if ( n % i == 0 ) { primeFactors [ j ++ ] = i ; while ( n % i == 0 ) n /= i ; } } if ( n > 2 ) primeFactors [ j ++ ] = n ; int [ ] temp = new int [ j ] ; Array . Copy ( primeFactors , temp , j ) ; return temp ; } private static void findShortestSubsequence ( int [ ] dp , int [ ] a , int index , int [ ] primeFactors ) { int n = a . Length ; for ( int j = index ; j < n ; j ++ ) { int bitmask = 0 ; for ( int p = 0 ; p < primeFactors . Length ; p ++ ) { if ( a [ j ] % primeFactors [ p ] == 0 ) { bitmask ^= ( 1 << p ) ; } } for ( int i = 0 ; i < dp . Length ; i ++ ) { if ( dp [ i ] == n + 1 ) continue ; dp [ bitmask & i ] = Math . Min ( dp [ bitmask & i ] , dp [ i ] + 1 ) ; } } } private static void printMinimumLength ( int [ ] a ) { int min = a . Length + 1 ; for ( int i = 0 ; i < a . Length - 1 ; i ++ ) { int [ ] primeFactors = findPrimeFactors ( a [ i ] ) ; int n = primeFactors . Length ; int [ ] dp = new int [ 1 << n ] ; for ( i = 0 ; i < dp . Length ; i ++ ) dp [ i ] = a . Length + 1 ; int setBits = ( 1 << n ) - 1 ; dp [ setBits ] = 1 ; findShortestSubsequence ( dp , a , i + 1 , primeFactors ) ; min = Math . Min ( dp [ 0 ] , min ) ; } if ( min == a . Length + 1 ) Console . WriteLine ( - 1 ) ; else Console . WriteLine ( min ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 6 , 12 , 3 } ; printMinimumLength ( arr ) ; } }

Index/key variables: i, j, p, setBits
Accumulator variables: bitmask, i, j, n, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { public static int xorSum ( int [ ] a , int n , int mask , int [ ] dp ) { if ( dp [ mask ] != - 1 ) { return dp [ mask ] ; } int max_value = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( i != j && ( mask & ( 1 << i ) ) == 0 && ( mask & ( 1 << j ) ) == 0 ) { max_value = Math . Max ( max_value , ( a [ i ] ^ a [ j ] ) + xorSum ( a , n , ( mask | ( 1 << i ) | ( 1 << j ) ) , dp ) ) ; } } } return dp [ mask ] = max_value ; } public static void Main ( String [ ] args ) { int n = 4 ; int [ ] arr = { 1 , 2 , 3 , 4 } ; int [ ] dp = new int [ ( 1 << n ) + 5 ] ; for ( int i = 0 ; i < dp . Length ; i ++ ) dp [ i ] = - 1 ; Console . WriteLine ( xorSum ( arr , n , 0 , dp ) ) ; } }

Index/key variables: i, j, mask
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long [ ] fib = new long [ 101 ] ; static long [ ] dp1 = new long [ 101 ] ; static long [ ] dp2 = new long [ 101 ] ; static long [ ] v = new long [ 101 ] ; static void fibonacci ( ) { fib [ 1 ] = 1 ; fib [ 2 ] = 2 ; for ( int i = 3 ; i <= 87 ; i ++ ) { fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } } static long find ( long num ) { int cnt = 0 ; for ( int i = 87 ; i > 0 ; i -- ) { if ( num >= fib [ i ] ) { v [ cnt ++ ] = i ; num -= fib [ i ] ; } } for ( int i = 0 ; i < cnt / 2 ; i ++ ) { long t = v [ i ] ; v [ i ] = v [ cnt - i - 1 ] ; v [ cnt - i - 1 ] = t ; } dp1 [ 0 ] = 1 ; dp2 [ 0 ] = ( v [ 0 ] - 1 ) / 2 ; for ( int i = 1 ; i < cnt ; i ++ ) { dp1 [ i ] = dp1 [ i - 1 ] + dp2 [ i - 1 ] ; dp2 [ i ] = ( ( v [ i ] - v [ i - 1 ] ) / 2 ) * dp2 [ i - 1 ] + ( ( v [ i ] - v [ i - 1 ] - 1 ) / 2 ) * dp1 [ i - 1 ] ; } return ( dp1 [ cnt - 1 ] + dp2 [ cnt - 1 ] ) ; } static void Main ( ) { fibonacci ( ) ; int num = 13 ; Console . Write ( find ( num ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, num
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void countNums ( int N ) { int l = ( int ) Math . Pow ( 10 , N - 1 ) , r = ( int ) Math . Pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int xor = 0 , temp = i ; while ( temp > 0 ) { xor = xor ^ ( temp % 10 ) ; temp /= 10 ; } if ( xor <= 9 ) count ++ ; } Console . WriteLine ( count ) ; } public static void Main ( ) { int N = 2 ; countNums ( N ) ; } }

Accumulator variables: count, i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void main_fun ( int [ ] arr , int n ) { int [ , ] dp = new int [ 4 , n ] ; if ( arr [ 0 ] == 0 ) dp [ 0 , 0 ] = 1 ; else dp [ 1 , 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) dp [ 0 , i ] = dp [ 0 , i - 1 ] + 1 ; else dp [ 0 , i ] = dp [ 0 , i - 1 ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) dp [ 1 , i ] = Math . Max ( dp [ 1 , i - 1 ] + 1 , dp [ 0 , i - 1 ] + 1 ) ; else dp [ 1 , i ] = dp [ 1 , i - 1 ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) { dp [ 2 , i ] = Math . Max ( dp [ 2 , i - 1 ] + 1 , Math . Max ( dp [ 1 , i - 1 ] + 1 , dp [ 0 , i - 1 ] + 1 ) ) ; } else dp [ 2 , i ] = dp [ 2 , i - 1 ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { dp [ 3 , i ] = Math . Max ( dp [ 3 , i - 1 ] + 1 , Math . Max ( dp [ 2 , i - 1 ] + 1 , Math . Max ( dp [ 1 , i - 1 ] + 1 , dp [ 0 , i - 1 ] + 1 ) ) ) ; } else dp [ 3 , i ] = dp [ 3 , i - 1 ] ; } int ans = Math . Max ( dp [ 2 , n - 1 ] , Math . Max ( dp [ 1 , n - 1 ] , Math . Max ( dp [ 0 , n - 1 ] , dp [ 3 , n - 1 ] ) ) ) ; Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int n = 4 ; int [ ] arr = { 0 , 1 , 0 , 1 } ; main_fun ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void SubarrayWithMaxSum ( List < int > nums ) { int endIndex = 0 , currMax = nums [ 0 ] ; int globalMax = nums [ 0 ] ; for ( int i = 1 ; i < nums . Count ; ++ i ) { currMax = Math . Max ( nums [ i ] , nums [ i ] + currMax ) ; if ( currMax > globalMax ) { globalMax = currMax ; endIndex = i ; } } int startIndex = endIndex ; while ( startIndex >= 0 ) { globalMax -= nums [ startIndex ] ; if ( globalMax == 0 ) break ; startIndex -- ; } for ( int i = startIndex ; i <= endIndex ; ++ i ) { Console . Write ( nums [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { List < int > arr = new List < int > ( ) ; arr . Add ( - 2 ) ; arr . Add ( - 5 ) ; arr . Add ( 6 ) ; arr . Add ( - 2 ) ; arr . Add ( - 3 ) ; arr . Add ( 1 ) ; arr . Add ( 5 ) ; arr . Add ( - 6 ) ; SubarrayWithMaxSum ( arr ) ; } }

Index/key variables: i, startIndex
Accumulator variables: globalMax, startIndex
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > primes ; static int M = 100005 ; static void sieve ( ) { primes = new List < int > ( ) ; bool [ ] mark = new bool [ M ] ; for ( int i = 2 ; i < M ; i ++ ) mark [ i ] = true ; for ( int i = 2 ; i * i < M ; i ++ ) { if ( mark [ i ] ) { for ( int j = i * i ; j < M ; j += i ) mark [ j ] = false ; } } for ( int i = 2 ; i < M ; i ++ ) if ( mark [ i ] ) primes . Add ( i ) ; } static void countPrimonacci ( int l , int r ) { List < int > dp = new List < int > ( ) ; dp . Add ( 1 ) ; dp . Add ( 1 ) ; int i = 2 ; HashSet < int > s = new HashSet < int > ( ) ; while ( true ) { int x = 0 ; for ( int j = 0 ; j < primes . Count ; j ++ ) { int p = primes [ j ] ; if ( p >= i ) break ; x += dp [ i - p ] ; } if ( x >= l && x <= r ) s . Add ( x ) ; if ( x > r ) break ; dp . Add ( x ) ; i ++ ; } Console . WriteLine ( s . Count ) ; } public static void Main ( String [ ] args ) { sieve ( ) ; int L = 1 , R = 10 ; countPrimonacci ( L , R ) ; } }

Index/key variables: M, i, j
Accumulator variables: i, j, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = ( int ) ( 1e5 + 5 ) ; static int MOD = 1000000007 ; static int [ ] dp = new int [ N ] ; static void countStrings ( int K , int [ , ] Q ) { dp [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { dp [ i ] = dp [ i - 1 ] ; if ( i >= K ) dp [ i ] = ( dp [ i ] + dp [ i - K ] ) % MOD ; } for ( int i = 1 ; i < N ; i ++ ) { dp [ i ] = ( dp [ i ] + dp [ i - 1 ] ) % MOD ; } for ( int i = 0 ; i < Q . GetLength ( 0 ) ; i ++ ) { int ans = dp [ Q [ i , 1 ] ] - dp [ Q [ i , 0 ] - 1 ] ; if ( ans < 0 ) ans = ans + MOD ; Console . Write ( ans + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int K = 3 ; int [ , ] Q = { { 1 , 4 } , { 3 , 7 } } ; countStrings ( K , Q ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static long minSum ( int n , int [ ] num , int [ ] price ) { long [ ] dp = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = int . MaxValue ; long ans = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( num [ j ] > num [ i ] ) { dp [ j ] = ( long ) Math . Min ( ( long ) dp [ j ] , ( long ) price [ i ] + ( long ) price [ j ] ) ; ans = Math . Min ( ans , ( long ) dp [ i ] + ( long ) price [ j ] ) ; } } } return ans != int . MaxValue ? ans : - 1 ; } public static void Main ( String [ ] args ) { int [ ] num = { 2 , 4 , 6 , 7 , 8 } ; int [ ] price = { 10 , 20 , 100 , 20 , 40 } ; int n = price . Length ; Console . WriteLine ( minSum ( n , num , price ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long binomialCoeff ( int n , int k ) { long res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static long countStrings ( int N ) { if ( N % 2 == 1 ) return 0 ; else { N /= 2 ; long c = binomialCoeff ( 2 * N , N ) ; return c / ( N + 1 ) ; } } public static void Main ( String [ ] args ) { int N = 6 ; Console . Write ( countStrings ( N ) + " ▁ " ) ; } }

Accumulator variables: N, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int n , int k , int mod , int [ ] dp ) { if ( n < 0 ) return 0 ; if ( n == 0 ) return 1 ; if ( dp [ n ] != - 1 ) return dp [ n ] ; int cnt = 0 ; for ( int i = 2 ; i <= k ; i += 2 ) { cnt = ( cnt % mod + solve ( n - i , k , mod , dp ) % mod ) % mod ; } dp [ n ] = cnt ; return cnt ; } public static void Main ( String [ ] args ) { int mod = ( int ) ( 1e9 + 7 ) ; int n = 4 , k = 2 ; int [ ] dp = new int [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) dp [ i ] = - 1 ; int ans = solve ( n , k , mod , dp ) ; Console . WriteLine ( ans ) ; } }

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