dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int nswp ( int n ) { int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = 2 * dp [ i - 1 ] + dp [ i - 2 ] ; return dp [ n ] ; } public static void Main ( ) { int n = 3 ; Console . WriteLine ( nswp ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int MAX = 256 ; static int numberofways ( String A , String B , int N , int M ) { List < int > [ ] pos = new List < int > [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) pos [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < M ; i ++ ) pos [ B [ i ] ] . Add ( i + 1 ) ; int [ , ] dpl = new int [ N + 2 , M + 2 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= M ; j ++ ) { if ( A [ i - 1 ] == B [ j - 1 ] ) dpl [ i , j ] = dpl [ i - 1 , j - 1 ] + 1 ; else dpl [ i , j ] = Math . Max ( dpl [ i - 1 , j ] , dpl [ i , j - 1 ] ) ; } } int LCS = dpl [ N , M ] ; int [ , ] dpr = new int [ N + 2 , M + 2 ] ; for ( int i = N ; i >= 1 ; i -- ) { for ( int j = M ; j >= 1 ; j -- ) { if ( A [ i - 1 ] == B [ j - 1 ] ) dpr [ i , j ] = dpr [ i + 1 , j + 1 ] + 1 ; else dpr [ i , j ] = Math . Max ( dpr [ i + 1 , j ] , dpr [ i , j + 1 ] ) ; } } int ans = 0 ; for ( int i = 0 ; i <= N ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { foreach ( int x in pos [ j ] ) { if ( dpl [ i , x - 1 ] + dpr [ i + 1 , x + 1 ] == LCS ) { ans ++ ; break ; } } } } return ans ; } public static void Main ( String [ ] args ) { String A = " aa " , B = " baaa " ; int N = A . Length , M = B . Length ; Console . WriteLine ( numberofways ( A , B , N , M ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: ans, i, j
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; public class GfG { static int lcs ( string X , string Y , int m , int n ) { int [ , ] L = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; ++ i ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i , j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ i , j ] = L [ i - 1 , j - 1 ] + 2 * ( X [ i - 1 ] - '0' ) ; else L [ i , j ] = L [ i - 1 , j ] > L [ i , j - 1 ] ? L [ i - 1 , j ] : L [ i , j - 1 ] ; } } return L [ m , n ] ; } static int findMinCost ( string X , string Y ) { int m = X . Length , n = Y . Length ; int cost = 0 ; for ( int i = 0 ; i < m ; ++ i ) cost += X [ i ] - '0' ; for ( int i = 0 ; i < n ; ++ i ) cost += Y [ i ] - '0' ; return cost - lcs ( X , Y , m , n ) ; } public static void Main ( ) { string X = "3759" ; string Y = "9350" ; Console . WriteLine ( " Minimum ▁ Cost ▁ to ▁ make ▁ two ▁ strings " + " ▁ identical ▁ is ▁ = ▁ " + findMinCost ( X , Y ) ) ; } }

Index/key variables: i
Accumulator variables: cost, j
Iterator variables: i, j
Class/struct names: GfG
C# program:
using System ; class GFG { static bool isSubSeqDivisible ( string str ) { int i , j , k , l = str . Length ; int [ ] arr = new int [ l ] ; for ( i = 0 ; i < n ; i ++ ) arr [ i ] = str [ i ] - '0' ; for ( i = 0 ; i < l ; i ++ ) { for ( j = i ; j < l ; j ++ ) { for ( k = j ; k < l ; k ++ ) { if ( arr [ i ] % 8 == 0 ) return true ; else if ( ( arr [ i ] * 10 + arr [ j ] ) % 8 == 0 && i != j ) return true ; else if ( ( arr [ i ] * 100 + arr [ j ] * 10 + arr [ k ] ) % 8 == 0 && i != j && j != k && i != k ) return true ; } } } return false ; } public static void Main ( ) { string str = "3144" ; if ( isSubSeqDivisible ( str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, j, k, l
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSubSeqDivisible ( String str ) { int n = str . Length ; int [ , ] dp = new int [ n + 1 , 10 ] ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) arr [ i ] = ( int ) ( str [ i - 1 ] - '0' ) ; for ( int i = 1 ; i <= n ; i ++ ) { dp [ i , arr [ i ] % 8 ] = 1 ; for ( int j = 0 ; j < 8 ; j ++ ) { if ( dp [ i - 1 , j ] > dp [ i , ( j * 10 + arr [ i ] ) % 8 ] ) dp [ i , ( j * 10 + arr [ i ] ) % 8 ] = dp [ i - 1 , j ] ; if ( dp [ i - 1 , j ] > dp [ i , j ] ) dp [ i , j ] = dp [ i - 1 , j ] ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( dp [ i , 0 ] == 1 ) return true ; } return false ; } public static void Main ( ) { string str = "3144" ; if ( isSubSeqDivisible ( str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void Main ( String [ ] args ) { String str = "129365" ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int no = 8 ; while ( no < 100 ) { no = no + 8 ; if ( mp . ContainsKey ( ( no / 10 ) % 10 ) ) mp [ ( no / 10 ) % 10 ] = no % 10 ; else mp . Add ( ( no / 10 ) % 10 , no % 10 ) ; } bool [ ] visited = new bool [ 10 ] ; int i ; for ( i = str . Length - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == '8' ) { Console . Write ( " Yes " ) ; break ; } if ( visited [ mp [ str [ i ] - '0' ] ] ) { Console . Write ( " Yes " ) ; break ; } visited [ str [ i ] - '0' ] = true ; } if ( i == - 1 ) Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxLength ( String s , int n ) { int [ , ] dp = new int [ n , n ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( s [ i ] == ' ( ' && s [ i + 1 ] == ' ) ' ) dp [ i , i + 1 ] = 2 ; for ( int l = 2 ; l < n ; l ++ ) { for ( int i = 0 , j = l ; j < n ; i ++ , j ++ ) { if ( s [ i ] == ' ( ' && s [ j ] == ' ) ' ) dp [ i , j ] = 2 + dp [ i + 1 , j - 1 ] ; for ( int k = i ; k < j ; k ++ ) dp [ i , j ] = Math . Max ( dp [ i , j ] , dp [ i , k ] + dp [ k + 1 , j ] ) ; } } return dp [ 0 , n - 1 ] ; } public static void Main ( ) { string s = " ( ) ( ( ( ( ( ( ) " ; int n = s . Length ; Console . WriteLine ( maxLength ( s , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k, l
Iterator variables: i, k, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int find_partial_sum ( int [ ] arr , int start , int end ) { int sum = 0 ; for ( int i = start ; i < end ; i ++ ) sum += arr [ i ] ; return sum ; } static int maxSumBitonicSubArr ( int [ ] arr , int n ) { int max_sum = - 1000000 ; int i = 0 ; while ( i < n ) { int j = i ; while ( j + 1 < n && arr [ j ] < arr [ j + 1 ] ) j ++ ; while ( i < j && arr [ i ] <= 0 ) i ++ ; int k = j ; while ( k + 1 < n && arr [ k ] > arr [ k + 1 ] ) k ++ ; int last = k ; while ( k > j && arr [ k ] <= 0 ) k -- ; int sum_inc = find_partial_sum ( arr , i , j + 1 ) ; int sum_dec = find_partial_sum ( arr , j , k + 1 ) ; int sum_all = sum_inc + sum_dec - arr [ j ] ; max_sum = Math . Max ( Math . Max ( max_sum , sum_inc ) , Math . Max ( sum_dec , sum_all ) ) ; i = Math . Max ( last , i + 1 ) ; } return max_sum ; } public static void Main ( ) { int [ ] arr = { 5 , 3 , 9 , 2 , 7 , 6 , 4 } ; int n = arr . Length ; Console . WriteLine ( " Maximum ▁ sum ▁ = ▁ " + maxSumBitonicSubArr ( arr , n ) ) ; int [ ] arr2 = { 1 , 2 , 3 , 4 , 5 } ; int n2 = arr2 . Length ; Console . WriteLine ( " Maximum ▁ sum ▁ = ▁ " + maxSumBitonicSubArr ( arr2 , n2 ) ) ; int [ ] arr3 = { 5 , 4 , 3 , 2 , 1 } ; int n3 = arr3 . Length ; Console . WriteLine ( " Maximum ▁ sum ▁ = ▁ " + maxSumBitonicSubArr ( arr3 , n3 ) ) ; int [ ] arr4 = { 5 , 5 , 5 , 5 } ; int n4 = arr4 . Length ; Console . WriteLine ( " Maximum ▁ sum ▁ = ▁ " + maxSumBitonicSubArr ( arr4 , n4 ) ) ; int [ ] arr5 = { - 1 , 0 , 1 , 2 , 3 , 1 , 0 , - 1 , - 10 } ; int n5 = arr5 . Length ; Console . WriteLine ( " Maximum ▁ sum ▁ = ▁ " + maxSumBitonicSubArr ( arr5 , n5 ) ) ; int [ ] arr6 = { - 1 , 0 , 1 , 2 , 0 , - 1 , - 2 , 0 , 1 , 3 } ; int n6 = arr6 . Length ; Console . WriteLine ( " Maximum ▁ sum ▁ = ▁ " + maxSumBitonicSubArr ( arr6 , n6 ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int smallestSumSubarr ( int [ ] arr , int n ) { int min_ending_here = 2147483647 ; int min_so_far = 2147483647 ; for ( int i = 0 ; i < n ; i ++ ) { if ( min_ending_here > 0 ) min_ending_here = arr [ i ] ; else min_ending_here += arr [ i ] ; min_so_far = Math . Min ( min_so_far , min_ending_here ) ; } return min_so_far ; } public static void Main ( ) { int [ ] arr = { 3 , - 4 , 2 , - 3 , - 1 , 7 , - 5 } ; int n = arr . Length ; Console . Write ( " Smallest ▁ sum : ▁ " + smallestSumSubarr ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, min_ending_here
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int ans ( int n ) { if ( n < 6 ) { return n ; } return n % 6 + 10 * ( ans ( n / 6 ) ) ; } static int getSpecialNumber ( int N ) { return ans ( -- N ) ; } public static void Main ( String [ ] args ) { int N = 17 ; int answer = getSpecialNumber ( N ) ; Console . WriteLine ( answer ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] dp = new int [ 300 , 300 ] ; static int minimumSquare ( int m , int n ) { int vertical_min = int . MaxValue ; int horizontal_min = int . MaxValue ; if ( n == 13 && m == 11 ) return 6 ; if ( m == 13 && n == 11 ) return 6 ; if ( m == n ) return 1 ; if ( dp [ m , n ] != 0 ) return dp [ m , n ] ; for ( int i = 1 ; i <= m / 2 ; i ++ ) { horizontal_min = Math . Min ( minimumSquare ( i , n ) + minimumSquare ( m - i , n ) , horizontal_min ) ; } for ( int j = 1 ; j <= n / 2 ; j ++ ) { vertical_min = Math . Min ( minimumSquare ( m , j ) + minimumSquare ( m , n - j ) , vertical_min ) ; } dp [ m , n ] = Math . Min ( vertical_min , horizontal_min ) ; return dp [ m , n ] ; } public static void Main ( ) { int m = 30 , n = 35 ; Console . WriteLine ( minimumSquare ( m , n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long fact ( int n ) { long res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static long nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } public static void Main ( String [ ] args ) { int n = 2 ; Console . Write ( " Number ▁ of ▁ Non - Decreasing ▁ digits : ▁ " + nCr ( n + 9 , 9 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long countWays ( int n , int k ) { long total = k ; int mod = 1000000007 ; long same = 0 , diff = k ; for ( int i = 2 ; i <= n ; i ++ ) { same = diff ; diff = total * ( k - 1 ) ; diff = diff % mod ; total = ( same + diff ) % mod ; } return total ; } static void Main ( ) { int n = 3 , k = 2 ; Console . Write ( countWays ( n , k ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static long sumOfSubstrings ( string num ) { long sum = 0 ; long mf = 1 ; for ( int i = num . Length - 1 ; i >= 0 ; i -- ) { sum += ( num [ i ] - '0' ) * ( i + 1 ) * mf ; mf = mf * 10 + 1 ; } return sum ; } public static void Main ( ) { string num = "6759" ; Console . WriteLine ( sumOfSubstrings ( num ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Test { static int maxSumWithK ( int [ ] a , int n , int k ) { int [ ] maxSum = new int [ n ] ; maxSum [ 0 ] = a [ 0 ] ; int curr_max = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { curr_max = Math . Max ( a [ i ] , curr_max + a [ i ] ) ; maxSum [ i ] = curr_max ; } int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) sum += a [ i ] ; int result = sum ; for ( int i = k ; i < n ; i ++ ) { sum = sum + a [ i ] - a [ i - k ] ; result = Math . Max ( result , sum ) ; result = Math . Max ( result , sum + maxSum [ i - k ] ) ; } return result ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , - 10 , - 3 } ; int k = 4 ; Console . Write ( maxSumWithK ( arr , arr . Length , k ) ) ; ; } }

Index/key variables: i, n
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: Test
C# program:
using System ; class Gfg { static int [ ] arr = { 1 , 5 , 6 } ; static int countWays ( int N ) { int [ ] count = new int [ N + 1 ] ; count [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) for ( int j = 0 ; j < arr . Length ; j ++ ) if ( i >= arr [ j ] ) count [ i ] += count [ i - arr [ j ] ] ; return count [ N ] ; } public static void Main ( ) { int N = 7 ; Console . Write ( " Total ▁ number ▁ of ▁ ways ▁ = ▁ " + countWays ( N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Gfg
C# program:
using System ; class GFG { static int getTotalNumberOfSequences ( int m , int n ) { if ( m < n ) return 0 ; if ( n == 0 ) return 1 ; return getTotalNumberOfSequences ( m - 1 , n ) + getTotalNumberOfSequences ( m / 2 , n - 1 ) ; } public static void Main ( ) { int m = 10 ; int n = 4 ; Console . Write ( " Total ▁ number ▁ of ▁ possible ▁ sequences ▁ " + getTotalNumberOfSequences ( m , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class Sequences { static int getTotalNumberOfSequences ( int m , int n ) { int [ , ] T = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i < m + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { if ( i == 0 j == 0 ) T [ i , j ] = 0 ; else if ( i < j ) T [ i , j ] = 0 ; else if ( j == 1 ) T [ i , j ] = i ; else T [ i , j ] = T [ i - 1 , j ] + T [ i / 2 , j - 1 ] ; } } return T [ m , n ] ; } public static void Main ( ) { int m = 10 ; int n = 4 ; Console . WriteLine ( " Total ▁ number ▁ of ▁ possible ▁ sequences ▁ " + getTotalNumberOfSequences ( m , n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Sequences
C# program:
using System ; class GFG { static int lcs ( string str1 , string str2 , int m , int n ) { int [ , ] L = new int [ m + 1 , n + 1 ] ; int i , j ; for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i , j ] = 0 ; else if ( str1 [ i - 1 ] == str2 [ j - 1 ] ) L [ i , j ] = L [ i - 1 , j - 1 ] + 1 ; else L [ i , j ] = Math . Max ( L [ i - 1 , j ] , L [ i , j - 1 ] ) ; } } return L [ m , n ] ; } static void printMinDelAndInsert ( string str1 , string str2 ) { int m = str1 . Length ; int n = str2 . Length ; int len = lcs ( str1 , str2 , m , n ) ; Console . Write ( " Minimum ▁ number ▁ of ▁ " + " deletions ▁ = ▁ " ) ; Console . WriteLine ( m - len ) ; Console . Write ( " Minimum ▁ number ▁ of ▁ " + " insertions ▁ = ▁ " ) ; Console . Write ( n - len ) ; } public static void Main ( ) { string str1 = new string ( " heap " ) ; string str2 = new string ( " pea " ) ; printMinDelAndInsert ( str1 , str2 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { static int lis ( int [ ] arr , int n ) { int result = 0 ; int [ ] lis = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) lis [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( result < lis [ i ] ) result = lis [ i ] ; return result ; } static int minimumNumberOfDeletions ( int [ ] arr , int n ) { int len = lis ( arr , n ) ; return ( n - len ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 30 , 40 , 2 , 5 , 1 , 7 , 45 , 50 , 8 } ; int n = arr . Length ; Console . Write ( " Minimum ▁ number ▁ of " + " ▁ deletions ▁ = ▁ " + minimumNumberOfDeletions ( arr , n ) ) ; } }

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 int inf = 1000000000 ; static int minCost ( int [ ] a , int n , int k ) { int [ , ] dp = new int [ n + 1 , k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= k ; j ++ ) dp [ i , j ] = inf ; dp [ 0 , 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= k ; j ++ ) for ( int m = i - 1 ; m >= 0 ; m -- ) dp [ i , j ] = Math . Min ( dp [ i , j ] , dp [ m , j - 1 ] + ( a [ i - 1 ] - a [ m ] ) * ( a [ i - 1 ] - a [ m ] ) ) ; return dp [ n , k ] ; } public static void Main ( ) { int k = 2 ; int [ ] a = { 1 , 5 , 8 , 10 } ; int n = a . Length ; Console . Write ( minCost ( a , n , k ) ) ; } }

Index/key variables: m
Accumulator variables: i, j, m
Iterator variables: i, j, m
Class/struct names: GFG
C# program:
using System ; class GFG { static int lps ( String str ) { int n = str . Length ; int [ , ] L = new int [ n , n ] ; for ( int i = 0 ; i < n ; i ++ ) L [ i , i ] = 1 ; for ( int cl = 2 ; cl <= n ; cl ++ ) { for ( int i = 0 ; i < n - cl + 1 ; i ++ ) { int j = i + cl - 1 ; if ( str [ i ] == str [ j ] && cl == 2 ) L [ i , j ] = 2 ; else if ( str [ i ] == str [ j ] ) L [ i , j ] = L [ i + 1 , j - 1 ] + 2 ; else L [ i , j ] = Math . Max ( L [ i , j - 1 ] , L [ i + 1 , j ] ) ; } } return L [ 0 , n - 1 ] ; } static int minimumNumberOfDeletions ( string str ) { int n = str . Length ; int len = lps ( str ) ; return ( n - len ) ; } public static void Main ( ) { string str = " geeksforgeeks " ; Console . Write ( " Minimum ▁ number ▁ of " + " ▁ deletions ▁ = ▁ " + minimumNumberOfDeletions ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: cl, i
Iterator variables: cl, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int offeringNumber ( int n , int [ ] templeHeight ) { for ( int i = 0 ; i < n ; ++ i ) { int left = 0 , right = 0 ; for ( int j = i - 1 ; j >= 0 ; -- j ) { if ( templeHeight [ j ] < templeHeight [ j + 1 ] ) ++ left ; else break ; } for ( int j = i + 1 ; j < n ; ++ j ) { if ( templeHeight [ j ] < templeHeight [ j - 1 ] ) ++ right ; else break ; } sum += Math . Max ( right , left ) + 1 ; } return sum ; } static public void Main ( ) { int [ ] arr1 = { 1 , 2 , 2 } ; Console . WriteLine ( offeringNumber ( 3 , arr1 ) ) ; int [ ] arr2 = { 1 , 4 , 3 , 6 , 2 , 1 } ; Console . WriteLine ( offeringNumber ( 6 , arr2 ) ) ; } }

Index/key variables: j
Accumulator variables: sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool modularSum ( int [ ] arr , int n , int m ) { if ( n > m ) return true ; bool [ ] DP = new bool [ m ] ; for ( int l = 0 ; l < DP . Length ; l ++ ) DP [ l ] = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( DP [ 0 ] ) return true ; bool [ ] temp = new bool [ m ] ; for ( int l = 0 ; l < temp . Length ; l ++ ) temp [ l ] = false ; for ( int j = 0 ; j < m ; j ++ ) { if ( DP [ j ] == true ) { if ( DP [ ( j + arr [ i ] ) % m ] == false ) temp [ ( j + arr [ i ] ) % m ] = true ; } } for ( int j = 0 ; j < m ; j ++ ) if ( temp [ j ] ) DP [ j ] = true ; DP [ arr [ i ] % m ] = true ; } return DP [ 0 ] ; } public static void Main ( ) { int [ ] arr = { 1 , 7 } ; int n = arr . Length ; int m = 5 ; if ( modularSum ( arr , n , m ) ) Console . Write ( " YES STRNEWLINE " ) ; else Console . Write ( " NO STRNEWLINE " ) ; } }

Index/key variables: i, j, l, m
Accumulator variables: i, j, l
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ , ] tri , int n ) { if ( n > 1 ) tri [ 1 , 1 ] = tri [ 1 , 1 ] + tri [ 0 , 0 ] ; tri [ 1 , 0 ] = tri [ 1 , 0 ] + tri [ 0 , 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { tri [ i , 0 ] = tri [ i , 0 ] + tri [ i - 1 , 0 ] ; tri [ i , i ] = tri [ i , i ] + tri [ i - 1 , i - 1 ] ; for ( int j = 1 ; j < i ; j ++ ) { if ( tri [ i , j ] + tri [ i - 1 , j - 1 ] >= tri [ i , j ] + tri [ i - 1 , j ] ) tri [ i , j ] = tri [ i , j ] + tri [ i - 1 , j - 1 ] ; else tri [ i , j ] = tri [ i , j ] + tri [ i - 1 , j ] ; } } int max = tri [ n - 1 , 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( max < tri [ n - 1 , i ] ) max = tri [ n - 1 , i ] ; } return max ; } public static void Main ( ) { int [ , ] tri = { { 1 , 0 , 0 } , { 2 , 1 , 0 } , { 3 , 3 , 2 } } ; Console . Write ( maxSum ( tri , 3 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumDifferenceSum ( int [ ] arr , int N ) { int [ , ] dp = new int [ N , 2 ] ; for ( int i = 0 ; i < N ; i ++ ) dp [ i , 0 ] = dp [ i , 1 ] = 0 ; for ( int i = 0 ; i < ( N - 1 ) ; i ++ ) { dp [ i + 1 , 0 ] = Math . Max ( dp [ i , 0 ] , dp [ i , 1 ] + Math . Abs ( 1 - arr [ i ] ) ) ; dp [ i + 1 , 1 ] = Math . Max ( dp [ i , 0 ] + Math . Abs ( arr [ i + 1 ] - 1 ) , dp [ i , 1 ] + Math . Abs ( arr [ i + 1 ] - arr [ i ] ) ) ; } return Math . Max ( dp [ N - 1 , 0 ] , dp [ N - 1 , 1 ] ) ; } public static void Main ( ) { int [ ] arr = { 3 , 2 , 1 , 4 , 5 } ; int N = arr . Length ; Console . Write ( maximumDifferenceSum ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countStrUtil ( int [ , , ] dp , int n , int bCount = 1 , int cCount = 2 ) { if ( bCount < 0 cCount < 0 ) return 0 ; if ( n == 0 ) return 1 ; if ( bCount == 0 && cCount == 0 ) return 1 ; if ( dp [ n , bCount , cCount ] != - 1 ) return dp [ n , bCount , cCount ] ; int res = countStrUtil ( dp , n - 1 , bCount , cCount ) ; res += countStrUtil ( dp , n - 1 , bCount - 1 , cCount ) ; res += countStrUtil ( dp , n - 1 , bCount , cCount - 1 ) ; return ( dp [ n , bCount , cCount ] = res ) ; } static int countStr ( int n ) { int [ , , ] dp = new int [ n + 1 , 2 , 3 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) for ( int j = 0 ; j < 2 ; j ++ ) for ( int k = 0 ; k < 3 ; k ++ ) dp [ i , j , k ] = - 1 ; return countStrUtil ( dp , n ) ; } static void Main ( ) { int n = 3 ; Console . Write ( countStr ( n ) ) ; } }

Accumulator variables: i, j, k, res
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 8 ; static int [ ] dx = { 1 , 2 , 2 , 1 , - 1 , - 2 , - 2 , - 1 } ; static int [ ] dy = { 2 , 1 , - 1 , - 2 , - 2 , - 1 , 1 , 2 } ; static bool inside ( int x , int y ) { return ( x >= 0 && x < N && y >= 0 && y < N ) ; } static double findProb ( int start_x , int start_y , int steps ) { double [ , , ] dp1 = new double [ N , N , steps + 1 ] ; for ( int i = 0 ; i < N ; ++ i ) for ( int j = 0 ; j < N ; ++ j ) dp1 [ i , j , 0 ] = 1 ; for ( int s = 1 ; s <= steps ; ++ s ) { for ( int x = 0 ; x < N ; ++ x ) { for ( int y = 0 ; y < N ; ++ y ) { double prob = 0.0 ; for ( int i = 0 ; i < 8 ; ++ i ) { int nx = x + dx [ i ] ; int ny = y + dy [ i ] ; if ( inside ( nx , ny ) ) prob += dp1 [ nx , ny , s - 1 ] / 8.0 ; } dp1 [ x , y , s ] = prob ; } } } return dp1 [ start_x , start_y , steps ] ; } static void Main ( ) { int K = 3 ; Console . WriteLine ( findProb ( 0 , 0 , K ) ) ; } }

Index/key variables: i
Accumulator variables: prob
Iterator variables: i, j, s, x, y
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubarray ( int [ ] arr , int n , int k ) { int s = 0 ; int i = 0 ; while ( i < n ) { if ( arr [ i ] > k ) { i ++ ; continue ; } int count = 0 ; while ( i < n && arr [ i ] <= k ) { i ++ ; count ++ ; } s += ( ( count * ( count + 1 ) ) / 2 ) ; } return ( n * ( n + 1 ) / 2 - s ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 } ; int k = 2 ; int n = arr . Length ; Console . WriteLine ( countSubarray ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, s
Class/struct names: GFG