dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int Count ( int [ ] S , int m , int n ) { int [ , ] table = new int [ m + 1 , n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { table [ 0 , i ] = int . MaxValue - 1 ; } for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( S [ i - 1 ] > j ) { table [ i , j ] = table [ i - 1 , j ] ; } else { table [ i , j ] = Math . Min ( table [ i - 1 , j ] , table [ i , j - S [ i - 1 ] ] + 1 ) ; } } } return table [ m , n ] ; } public static void Main ( String [ ] args ) { int [ ] arr = { 9 , 6 , 5 , 1 } ; int m = 4 ; Console . WriteLine ( Count ( arr , m , 11 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int INF = 10000000 ; static int maximum ( int A , int B , int C , int D ) { return Math . Max ( Math . Max ( A , B ) , Math . Max ( C , D ) ) ; } static int maxProductUtil ( int X , int Y , int [ ] A , int [ ] B , int [ , ] dp ) { if ( X < 0 Y < 0 ) return - INF ; if ( dp [ X , Y ] != - 1 ) return dp [ X , Y ] ; dp [ X , Y ] = maximum ( A [ X ] * B [ Y ] + maxProductUtil ( X - 1 , Y - 1 , A , B , dp ) , A [ X ] * B [ Y ] , maxProductUtil ( X - 1 , Y , A , B , dp ) , maxProductUtil ( X , Y - 1 , A , B , dp ) ) ; return dp [ X , Y ] ; } static int maxProduct ( int [ ] A , int N , int [ ] B , int M ) { int [ , ] dp = new int [ N , M ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { dp [ i , j ] = - 1 ; } } return maxProductUtil ( N - 1 , M - 1 , A , B , dp ) ; } public static void Main ( String [ ] args ) { int [ ] a = { - 2 , 6 , - 2 , - 5 } ; int [ ] b = { - 3 , 4 , - 2 , 8 } ; int n = a . Length ; int m = b . Length ; Console . Write ( maxProduct ( a , n , b , m ) ) ; } }

Index/key variables: X, Y
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void twoStringsEquality ( String s , String t ) { int n = s . Length ; int [ , ] dp = new int [ n , n + 1 ] ; if ( s [ n - 1 ] == t [ 0 ] ) dp [ n - 1 , 1 ] = 1 ; if ( s [ n - 1 ] == t [ n - 1 ] ) dp [ n - 1 , 0 ] = 1 ; for ( int i = n - 1 ; i > 0 ; i -- ) { for ( int j = 0 ; j <= n - i ; j ++ ) { if ( dp [ i , j ] > 0 ) { if ( s [ i - 1 ] == t [ j ] ) dp [ i - 1 , j + 1 ] = 1 ; if ( s [ i - 1 ] == t [ i + j - 1 ] ) dp [ i - 1 , j ] = 1 ; } } } bool ans = false ; for ( int i = 0 ; i <= n ; i ++ ) { if ( dp [ 0 , i ] == 1 ) { ans = true ; break ; } } if ( ans == true ) Console . Write ( " Yes " + " STRNEWLINE " ) ; else Console . Write ( " No " + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String S = " abab " ; String T = " baab " ; twoStringsEquality ( S , T ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: ans
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int [ ] arr , int n ) { int totalSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { totalSum += arr [ i ] ; } int [ , ] dp = new int [ 2 , n ] ; for ( int i = 0 ; i < n ; i ++ ) { dp [ 0 , i ] = 1 ; dp [ 1 , i ] = arr [ i ] ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ i ] > arr [ j ] ) { if ( dp [ 0 , i ] < dp [ 0 , j ] + 1 ) { dp [ 0 , i ] = dp [ 0 , j ] + 1 ; dp [ 1 , i ] = dp [ 1 , j ] + arr [ i ] ; } else if ( dp [ 0 , i ] == dp [ 0 , j ] + 1 ) { dp [ 1 , i ] = Math . Min ( dp [ 1 , i ] , dp [ 1 , j ] + arr [ i ] ) ; } } } } int maxm = 0 ; int subtractSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( dp [ 0 , i ] > maxm ) { maxm = dp [ 0 , i ] ; subtractSum = dp [ 1 , i ] ; } else if ( dp [ 0 , i ] == maxm ) { subtractSum = Math . Min ( subtractSum , dp [ 1 , i ] ) ; } } return totalSum - subtractSum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 6 , 1 , 2 , 3 , 8 } ; int n = arr . Length ; Console . Write ( findSum ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, totalSum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( int n ) { if ( n == 2 ) return 1 ; else if ( n == 4 ) return 2 ; else if ( n == 6 ) return 4 ; int [ ] table = new int [ n + 1 ] ; int i ; for ( i = 0 ; i < n + 1 ; i ++ ) table [ i ] = 0 ; table [ 0 ] = 0 ; table [ 2 ] = 1 ; table [ 4 ] = 2 ; table [ 6 ] = 4 ; for ( i = 8 ; i <= n ; i = i + 2 ) { table [ i ] = table [ i - 2 ] + table [ i - 4 ] + table [ i - 6 ] ; } return table [ n ] ; } public static void Main ( ) { int n = 8 ; Console . Write ( count ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MOD = 1000000007 ; static bool isPrime ( String number ) { int num = Int32 . Parse ( number ) ; for ( int i = 2 ; i * i <= num ; i ++ ) { if ( ( num % i ) == 0 ) return false ; } return num > 1 ? true : false ; } static int countPrimeStrings ( String number , int i ) { if ( i == 0 ) return 1 ; int cnt = 0 ; for ( int j = 1 ; j <= 6 ; j ++ ) { if ( i - j >= 0 && number [ i - j ] != '0' && isPrime ( number . Substring ( i - j , j ) ) ) { cnt += countPrimeStrings ( number , i - j ) ; cnt %= MOD ; } } return cnt ; } public static void Main ( String [ ] args ) { String s1 = "3175" ; int l = s1 . Length ; Console . Write ( countPrimeStrings ( s1 , l ) ) ; } }

Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MOD = 1000000007 ; static bool [ ] sieve = new bool [ 1000000 ] ; static void buildSieve ( ) { for ( int j = 0 ; j < sieve . Length ; j ++ ) sieve [ j ] = true ; sieve [ 0 ] = false ; sieve [ 1 ] = false ; for ( int p = 2 ; p * p <= 1000000 ; p ++ ) { if ( sieve [ p ] == true ) { for ( int i = p * p ; i < 1000000 ; i += p ) sieve [ i ] = false ; } } } static bool isPrime ( String number ) { int num = Int32 . Parse ( number ) ; return sieve [ num ] ; } static int rec ( String number , int i , int [ ] dp ) { if ( dp [ i ] != - 1 ) return dp [ i ] ; int cnt = 0 ; for ( int j = 1 ; j <= 6 ; j ++ ) { if ( i - j >= 0 && number [ i - j ] != '0' && isPrime ( number . Substring ( i - j , j ) ) ) { cnt += rec ( number , i - j , dp ) ; cnt %= MOD ; } } return dp [ i ] = cnt ; } static int countPrimeStrings ( String number ) { int n = number . Length ; int [ ] dp = new int [ n + 1 ] ; for ( int j = 0 ; j < dp . Length ; j ++ ) dp [ j ] = - 1 ; dp [ 0 ] = 1 ; return rec ( number , n , dp ) ; } public static void Main ( String [ ] args ) { buildSieve ( ) ; String s1 = "3175" ; Console . Write ( countPrimeStrings ( s1 ) + " STRNEWLINE " ) ; } }

Index/key variables: i, j, num, p
Accumulator variables: cnt, i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int squareOfZeroes ( int [ , ] matrix ) { int lastIdx = matrix . GetLength ( 0 ) - 1 ; Dictionary < string , bool > cache = new Dictionary < string , bool > ( ) ; if ( hasSquareOfZeroes ( matrix , 0 , 0 , lastIdx , lastIdx , cache ) ) { return 1 ; } else { return 0 ; } } static bool hasSquareOfZeroes ( int [ , ] matrix , int r1 , int c1 , int r2 , int c2 , Dictionary < string , bool > cache ) { if ( r1 >= r2 c1 >= c2 ) { return false ; } string key = r1 + " - " + c1 + " - " + r2 + " - " + c2 ; if ( cache . ContainsKey ( key ) ) { return cache [ key ] ; } cache [ key ] = ( isSquareOfZeroes ( matrix , r1 , c1 , r2 , c2 ) || hasSquareOfZeroes ( matrix , r1 + 1 , c1 + 1 , r2 - 1 , c2 - 1 , cache ) || hasSquareOfZeroes ( matrix , r1 , c1 + 1 , r2 - 1 , c2 , cache ) || hasSquareOfZeroes ( matrix , r1 + 1 , c1 , r2 , c2 - 1 , cache ) || hasSquareOfZeroes ( matrix , r1 + 1 , c1 + 1 , r2 , c2 , cache ) || hasSquareOfZeroes ( matrix , r1 , c1 , r2 - 1 , c2 - 1 , cache ) ) ; return cache [ key ] ; } static bool isSquareOfZeroes ( int [ , ] matrix , int r1 , int c1 , int r2 , int c2 ) { for ( int row = r1 ; row < r2 + 1 ; row ++ ) { if ( matrix [ row , c1 ] != 0 matrix [ row , c2 ] != 0 ) { return false ; } } for ( int col = c1 ; col < c2 + 1 ; col ++ ) { if ( matrix [ r1 , col ] != 0 matrix [ r2 , col ] != 0 ) { return false ; } } return true ; } static public void Main ( ) { int [ , ] matrix = { { 1 , 1 , 1 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 0 , 1 } , { 0 , 1 , 1 , 1 , 0 , 1 } , { 0 , 0 , 0 , 1 , 0 , 1 } , { 0 , 1 , 1 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 0 , 1 } } ; int ans ; ans = squareOfZeroes ( matrix ) ; if ( ans == 1 ) { Console . WriteLine ( " True " ) ; } else { Console . WriteLine ( " False " ) ; } } }

Index/key variables: key
Accumulator variables: col, row
Iterator variables: col, row
Class/struct names: GFG
C# program:
using System ; class GFG { public static void CountWays ( int a , int b , int c ) { int x = b + c + 1 ; int [ ] arr = new int [ x ] ; for ( int i = a ; i <= b ; i ++ ) { for ( int j = b ; j <= c ; j ++ ) { arr [ i + j ] ++ ; } } for ( int i = 1 ; i < x ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { int a = 1 ; int b = 2 ; int c = 2 ; CountWays ( a , b , c ) ; } }

Index/key variables: i, x
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void CountWays ( int a , int b , int c ) { int x = b + c + 2 ; int [ ] arr = new int [ x ] ; for ( int i = 1 ; i <= b ; i ++ ) { arr [ i + b ] ++ ; arr [ i + c + 1 ] -- ; } for ( int i = 1 ; i < x - 1 ; i ++ ) { arr [ i ] += arr [ i - 1 ] ; Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void Main ( ) { int a = 1 ; int b = 2 ; int c = 2 ; CountWays ( a , b , c ) ; } }

Index/key variables: i, x
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void differentStrings ( string s ) { int n = s . Length ; int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = dp [ 1 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == s [ i - 1 ] && ( s [ i ] == '1' s [ i ] == '2' ) ) dp [ i + 1 ] = dp [ i ] + dp [ i - 1 ] ; else dp [ i + 1 ] = dp [ i ] ; } Console . Write ( dp [ n ] ) ; } public static void Main ( ) { string S = "0111022110" ; differentStrings ( S ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static int sumPathCost ( int [ , ] grid , int m , int n ) { int sum = 0 , count ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { count = nCr ( i + j , i ) * nCr ( m + n - i - j , m - i ) ; sum += count * grid [ i , j ] ; } } return sum ; } public static void Main ( ) { int m = 2 ; int n = 2 ; int [ , ] grid = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; Console . Write ( sumPathCost ( grid , m , n ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int K ; static int N ; static List < int > v = new List < int > ( ) ; static int [ , , , , ] dp = new int [ 20 , 1000 , 10 , 2 , 2 ] ; static void init ( int x ) { for ( int i = 0 ; i < 20 ; i ++ ) for ( int j = 0 ; j < 1000 ; j ++ ) for ( int k = 0 ; k < 10 ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) for ( int m = 0 ; m < 2 ; m ++ ) dp [ i , j , k , l , m ] = - 1 ; v . Clear ( ) ; while ( x > 0 ) { v . Add ( x % 10 ) ; x /= 10 ; } v . Reverse ( ) ; N = v . Count ; } static int fun ( int pos , int sum , int st , int check , int f ) { if ( pos == N ) { return ( sum == 0 && check == 1 ) ? 1 : 0 ; } if ( dp [ pos , sum , st , check , f ] != - 1 ) return dp [ pos , sum , st , check , f ] ; int lmt = 9 ; if ( f == 0 ) lmt = v [ pos ] ; int ans = 0 ; for ( int digit = 0 ; digit <= lmt ; digit ++ ) { int nf = f ; int new_sum = ( sum + digit ) % K ; int new_check = check ; int new_st = st ; if ( f == 0 && digit < lmt ) nf = 1 ; if ( check == 0 && digit != 0 ) { new_st = digit ; new_check = 1 ; } if ( pos == N - 1 && new_st == digit ) continue ; ans += fun ( pos + 1 , new_sum , new_st , new_check , nf ) ; } return dp [ pos , sum , st , check , f ] = ans ; } static void findCount ( int L , int R , int K ) { init ( R ) ; int r_ans = fun ( 0 , 0 , 0 , 0 , 0 ) ; init ( L - 1 ) ; int l_ans = fun ( 0 , 0 , 0 , 0 , 0 ) ; Console . Write ( r_ans - l_ans ) ; } public static void Main ( String [ ] args ) { int L = 10 ; int R = 20 ; K = 2 ; findCount ( L , R , K ) ; } }

Index/key variables: pos
Accumulator variables: ans, digit, i, j, k, l, m, x
Iterator variables: digit, i, j, k, l, m
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSumProd ( string S , int K ) { int len = S . Length ; if ( K > len ) return - 1 ; if ( K == len ) return 0 ; int [ ] dp = new int [ len ] ; int count_zero = 0 , count_one = 0 ; for ( int j = 0 ; j < len ; j ++ ) { if ( S [ j ] == '0' ) { count_zero ++ ; } else { count_one ++ ; } dp [ j ] = count_zero * count_one ; } for ( int i = 1 ; i < K ; i ++ ) { for ( int j = len - 1 ; j >= i ; j -- ) { count_zero = 0 ; count_one = 0 ; dp [ j ] = Int32 . MaxValue ; for ( int k = j ; k >= i ; k -- ) { if ( S [ k ] == '0' ) { count_zero ++ ; } else { count_one ++ ; } dp [ j ] = Math . Min ( dp [ j ] , count_zero * count_one + dp [ k - 1 ] ) ; } } } return dp [ len - 1 ] ; } public static void Main ( string [ ] args ) { string S = "1011000110110100" ; int K = 5 ; Console . Write ( minSumProd ( S , K ) ) ; } }

Index/key variables: j, k, len
Accumulator variables: count_one, count_zero, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int minPrizes ( int [ ] arr , int n ) { int [ ] dpLeft = new int [ n ] ; dpLeft [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) { dpLeft [ i ] = dpLeft [ i - 1 ] + 1 ; } else { dpLeft [ i ] = 1 ; } } int [ ] dpRight = new int [ n ] ; dpRight [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > arr [ i + 1 ] ) { dpRight [ i ] = dpRight [ i + 1 ] + 1 ; } else { dpRight [ i ] = 1 ; } } int totalPrizes = 0 ; for ( int i = 0 ; i < n ; i ++ ) { totalPrizes += Math . Max ( dpLeft [ i ] , dpRight [ i ] ) ; } Console . Write ( totalPrizes + " STRNEWLINE " ) ; return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 3 } ; int n = arr . Length ; minPrizes ( arr , n ) ; } }

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

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minFlip ( string a ) { int n = a . Length ; int [ , ] dp = new int [ n + 1 , 2 ] ; dp [ 0 , 0 ] = ( a [ 0 ] == '1' ? 1 : 0 ) ; dp [ 0 , 1 ] = ( a [ 0 ] == '0' ? 1 : 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i , 0 ] = dp [ i - 1 , 0 ] + ( a [ i ] == '1' ? 1 : 0 ) ; dp [ i , 1 ] = Math . Min ( dp [ i - 1 , 0 ] , dp [ i - 1 , 1 ] ) + ( a [ i ] == '0' ? 1 : 0 ) ; } int answer = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { answer = Math . Min ( answer , dp [ i , 1 ] + dp [ n - 1 , 0 ] - dp [ i , 0 ] ) ; } return Math . Min ( answer , dp [ n - 1 , 0 ] ) ; } public static void Main ( string [ ] args ) { string s = "1100111000101" ; Console . Write ( minFlip ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int LIIDS ( int [ ] arr , int N ) { int [ ] dp = new int [ N + 1 ] ; int ans = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { dp [ i ] = 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i + i ; j <= N ; j += i ) { if ( j < arr . Length && arr [ j ] > arr [ i ] ) { dp [ j ] = Math . Max ( dp [ j ] , dp [ i ] + 1 ) ; } } ans = Math . Max ( ans , dp [ i ] ) ; } return ans ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 7 , 9 , 10 } ; int N = arr . Length ; Console . WriteLine ( LIIDS ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static bool isPerfectSquare ( double x ) { double sr = Math . Sqrt ( x ) ; return ( ( sr - Math . Floor ( sr ) ) == 0 ) ; } static int findSubarraySum ( int [ ] arr , int n , int K ) { Dictionary < int , int > prevSum = new Dictionary < int , int > ( ) ; int res = 0 ; int currsum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { currsum += arr [ i ] ; if ( currsum == K ) { res ++ ; } if ( prevSum . ContainsKey ( currsum - K ) ) res += ( prevSum [ currsum - K ] ) ; if ( prevSum . ContainsKey ( currsum ) ) { prevSum [ currsum ] ++ ; } else { prevSum [ currsum ] = 1 ; } } return res ; } static void countSubarray ( int [ ] arr , int n , int K ) { for ( int i = 0 ; i < n ; i ++ ) { if ( isPerfectSquare ( arr [ i ] ) ) { arr [ i ] = 1 ; } else { arr [ i ] = 0 ; } } Console . Write ( findSubarraySum ( arr , n , K ) ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 4 , 9 , 2 } ; int K = 2 ; int N = arr . Length ; countSubarray ( arr , N , K ) ; } }

Index/key variables: currsum, i
Accumulator variables: currsum, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int mod = 1000000007 ; static int calculate ( int pos , int left , int k , int L , int R ) { if ( pos == k ) { if ( left == 0 ) return 1 ; else return 0 ; } if ( left == 0 ) return 0 ; int answer = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( i > left ) break ; answer = ( ( answer + calculate ( pos + 1 , left - i , k , L , R ) ) % mod ) ; } return answer ; } static int countWaystoDivide ( int n , int k , int L , int R ) { return calculate ( 0 , n , k , L , R ) ; } public static void Main ( String [ ] args ) { int N = 12 ; int K = 3 ; int L = 1 ; int R = 5 ; Console . Write ( countWaystoDivide ( N , K , L , R ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void PossibleSum ( int n , int m , int [ , ] v , int k ) { int [ , ] dp = new int [ n + 1 , k + 1 ] ; dp [ 0 , 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= k ; j ++ ) { if ( dp [ i , j ] == 1 ) { for ( int d = 0 ; d < m ; d ++ ) { if ( ( j + v [ i , d ] ) <= k ) { dp [ i + 1 , j + v [ i , d ] ] = 1 ; } } } } } if ( dp [ n , k ] == 1 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } public static void Main ( String [ ] args ) { int N = 2 , M = 10 , K = 5 ; int [ , ] arr = new int [ , ] { { 4 , 0 , 15 , 3 , 2 , 20 , 10 , 1 , 5 , 4 } , { 4 , 0 , 10 , 3 , 2 , 25 , 4 , 1 , 5 , 4 } } ; PossibleSum ( N , M , arr , K ) ; } }

Accumulator variables: d, i, j
Iterator variables: d, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool [ ] dp = new bool [ 1 << 20 ] ; static bool isprime ( int n ) { if ( n == 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } static bool solve ( int [ ] arr , int curr , int mask , int n ) { if ( isprime ( curr ) ) { if ( mask == ( 1 << n ) - 1 ) { return true ; } curr = 0 ; } if ( mask == ( 1 << n ) - 1 ) { if ( ! isprime ( curr ) ) { return false ; } } if ( dp [ mask ] ) return dp [ mask ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( mask & ( 1 << i ) ) == 0 ) { if ( solve ( arr , curr + arr [ i ] , mask 1 << i , n ) ) { return true ; } } } return dp [ mask ] = false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 6 , 7 , 13 } ; int n = arr . Length ; if ( solve ( arr , 0 , 0 , n ) ) { Console . Write ( " YES " ) ; } else { Console . Write ( " NO " ) ; } } }

Index/key variables: i, mask
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int dim = 5 ; static void createTable ( int [ , ] mtrx , int k , int p , int [ , ] dp ) { dp [ 0 , 0 ] = mtrx [ 0 , 0 ] ; for ( int j = 1 ; j < dim ; j ++ ) { dp [ 0 , j ] = mtrx [ 0 , j ] + dp [ 0 , j - 1 ] ; } for ( int i = 1 ; i < dim ; i ++ ) { dp [ i , 0 ] = mtrx [ i , 0 ] + dp [ i - 1 , 0 ] ; } for ( int i = 1 ; i < dim ; i ++ ) { for ( int j = 1 ; j < dim ; j ++ ) { dp [ i , j ] = mtrx [ i , j ] + dp [ i - 1 , j ] + dp [ i , j - 1 ] - dp [ i - 1 , j - 1 ] ; } } } static int countSubMatrixUtil ( int [ , ] dp , int k , int p ) { int count = 0 ; int subMatSum = 0 ; for ( int i = k - 1 ; i < dim ; i ++ ) { for ( int j = k - 1 ; j < dim ; j ++ ) { if ( i == ( k - 1 ) || j == ( k - 1 ) ) { if ( i == ( k - 1 ) && j == ( k - 1 ) ) { subMatSum = dp [ i , j ] ; } else if ( i == ( k - 1 ) ) { subMatSum = dp [ i , j ] - dp [ i , j - k ] ; } else { subMatSum = dp [ i , j ] - dp [ i - k , j ] ; } } else { subMatSum = dp [ i , j ] - dp [ i - k , j ] - dp [ i , j - k ] + dp [ i - k , j - k ] ; } if ( subMatSum >= p ) { count ++ ; } } } return count ; } static int countSubMatrix ( int [ , ] mtrx , int k , int p ) { int [ , ] dp = new int [ dim , dim ] ; for ( int i = 0 ; i < dim ; i ++ ) { for ( int j = 0 ; j < dim ; j ++ ) { dp [ i , j ] = 0 ; } } createTable ( mtrx , k , p , dp ) ; return countSubMatrixUtil ( dp , k , p ) ; } public static void Main ( String [ ] args ) { int [ , ] mtrx = { { 1 , 7 , 1 , 1 , 1 } , { 2 , 2 , 2 , 2 , 2 } , { 3 , 9 , 6 , 7 , 3 } , { 4 , 3 , 2 , 4 , 5 } , { 5 , 1 , 5 , 3 , 1 } } ; int k = 3 ; int p = 35 ; Console . Write ( countSubMatrix ( mtrx , k , p ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void canMakePaliQueries ( String str , int [ , ] Q ) { int n = str . Length ; int [ , ] dp = new int [ 26 , n ] ; for ( int i = 0 ; i < 26 ; i ++ ) { char currentChar = ( char ) ( i + ' a ' ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( j == 0 ) { dp [ i , j ] = ( str [ j ] == currentChar ) ? 1 : 0 ; } else { dp [ i , j ] = dp [ i , j - 1 ] + ( ( str [ j ] == currentChar ) ? 1 : 0 ) ; } } } for ( int l = 0 ; l < Q . GetLength ( 0 ) ; l ++ ) { int [ ] query = GetRow ( Q , l ) ; int left = query [ 0 ] ; int right = query [ 1 ] ; int k = query [ 2 ] ; int unMatchedCount = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int occurrence = dp [ i , right ] - dp [ i , left ] + ( str [ left ] == ( i + ' a ' ) ? 1 : 0 ) ; if ( occurrence % 2 == 1 ) unMatchedCount ++ ; } int ans = unMatchedCount / 2 ; if ( ans <= k ) { Console . Write ( " YES STRNEWLINE " ) ; } else { Console . Write ( " NO STRNEWLINE " ) ; } } } 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 ; } public static void Main ( String [ ] args ) { String str = " GeeksforGeeks " ; int [ , ] Q = { { 1 , 5 , 3 } , { 5 , 7 , 0 } , { 8 , 11 , 3 } , { 3 , 10 , 5 } , { 0 , 9 , 5 } } ; canMakePaliQueries ( str , Q ) ; } }

Index/key variables: i, j, left, rowLength
Accumulator variables: i, j, l, unMatchedCount
Iterator variables: i, j, l
Class/struct names: GFG