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

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountOfOddSum ( int [ , ] a , int n ) { int [ , ] dp = new int [ n , 2 ] ; int [ , ] cnt = new int [ n , 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { if ( a [ i , j ] % 2 == 0 ) { cnt [ i , 0 ] ++ ; } else { cnt [ i , 1 ] ++ ; } } } dp [ 0 , 0 ] = cnt [ 0 , 0 ] ; dp [ 0 , 1 ] = cnt [ 0 , 1 ] ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i , 0 ] = ( dp [ i - 1 , 0 ] * cnt [ i , 0 ] + dp [ i - 1 , 1 ] * cnt [ i , 1 ] ) ; dp [ i , 1 ] = ( dp [ i - 1 , 0 ] * cnt [ i , 1 ] + dp [ i - 1 , 1 ] * cnt [ i , 0 ] ) ; } return dp [ n - 1 , 1 ] ; } public static void Main ( ) { int [ , ] a = { { 1 , 2 } , { 3 , 6 } } ; int n = a . GetLength ( 1 ) ; int ans = CountOfOddSum ( a , n ) ; Console . WriteLine ( ans ) ; } }

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

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool isStepNum ( int n ) { int prevDigit = - 1 ; while ( n > 0 ) { int curDigit = n % 10 ; if ( prevDigit != - 1 ) { if ( Math . Abs ( curDigit - prevDigit ) != 1 ) return false ; } n /= 10 ; prevDigit = curDigit ; } return true ; } public static void displaySteppingNumbers ( int n , int m ) { for ( int i = n ; i <= m ; i ++ ) if ( isStepNum ( i ) ) Console . Write ( i + " ▁ " ) ; } public static void Main ( ) { int n = 0 , m = 21 ; displaySteppingNumbers ( n , m ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System . Collections . Generic ; using System ; class GFG { static List < int > v = new List < int > ( ) ; static int [ , , , ] dp = new int [ 18 , 180 , 180 , 2 ] ; static int memo ( int index , int evenSum , int oddSum , int tight ) { if ( index == v . Count ) { if ( evenSum > oddSum ) { return 1 ; } else { return 0 ; } } if ( dp [ index , evenSum , oddSum , tight ] != - 1 ) { return dp [ index , evenSum , oddSum , tight ] ; } int limit = ( tight > 0 ) ? v [ index ] : 9 ; int ans = 0 ; for ( int d = 0 ; d <= limit ; d ++ ) { int currTight = 0 ; if ( d == v [ index ] ) { currTight = tight ; } if ( d % 2 != 0 ) { ans += memo ( index + 1 , evenSum , oddSum + d , currTight ) ; else { ans += memo ( index + 1 , evenSum + d , oddSum , currTight ) ; } } dp [ index , evenSum , oddSum , tight ] = ans ; return ans ; } static int CountNum ( int n ) { v . Clear ( ) ; while ( n > 0 ) { v . Add ( n % 10 ) ; n = n / 10 ; } v . Reverse ( ) ; for ( int i = 0 ; i < 18 ; i ++ ) { for ( int j = 0 ; j < 180 ; j ++ ) { for ( int k = 0 ; k < 180 ; k ++ ) { for ( int l = 0 ; l < 2 ; l ++ ) { dp [ i , j , k , l ] = - 1 ; } } } } return memo ( 0 , 0 , 0 , 1 ) ; } public static void Main ( String [ ] args ) { int L , R ; L = 2 ; R = 10 ; Console . WriteLine ( CountNum ( R ) - CountNum ( L - 1 ) ) ; } }

Index/key variables: index
Accumulator variables: ans, d, i, j, k, l
Iterator variables: d, i, j, k, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCount ( int K ) { int [ ] memo = new int [ 100 ] ; for ( int i = 0 ; i < 100 ; i ++ ) { memo [ i ] = int . MaxValue ; } memo [ 0 ] = 0 ; for ( int i = 1 ; i < 100 ; i ++ ) { memo [ i ] = Math . Min ( memo [ i - 1 ] + 1 , memo [ i ] ) ; } for ( int i = 10 ; i < 100 ; i ++ ) { memo [ i ] = Math . Min ( memo [ i - 10 ] + 1 , memo [ i ] ) ; } for ( int i = 25 ; i < 100 ; i ++ ) { memo [ i ] = Math . Min ( memo [ i - 25 ] + 1 , memo [ i ] ) ; } int min_count = 0 ; while ( K > 0 ) { min_count += memo [ K % 100 ] ; K /= 100 ; } return min_count ; } static public void Main ( ) { int K = 69 ; Console . WriteLine ( minCount ( K ) ) ; } }

Index/key variables: i
Accumulator variables: K, i, min_count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int N = 10000 ; static int count_required_sequence ( int n , int [ ] arr ) { int total_required_subsequence = 0 ; int total_n_required_subsequence = 0 ; int [ , ] dp = new int [ N , 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { int turn_required = 0 ; for ( int j = - 1 ; j <= 1 ; j ++ ) turn_required += dp [ arr [ i ] + j , 0 ] ; int required_end_i = ( total_required_subsequence + turn_required ) ; int n_required_end_i = ( 1 + total_n_required_subsequence - turn_required ) ; total_required_subsequence += required_end_i ; total_n_required_subsequence += n_required_end_i ; dp [ arr [ i ] , 1 ] += required_end_i ; dp [ arr [ i ] , 0 ] += n_required_end_i ; } return total_required_subsequence ; } static public void Main ( ) { int [ ] arr = { 1 , 6 , 2 , 1 , 9 } ; int n = arr . Length ; Console . WriteLine ( count_required_sequence ( n , arr ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, total_n_required_subsequence, total_required_subsequence, turn_required
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; namespace IterativeCombination { class Combination { private int [ ] Indices ; private int R ; private bool [ ] Flags ; private int Start ; private int End ; public Combination ( int [ ] arr , int r ) { this . Indices = arr ; this . R = r ; } public void GetFirst ( ) { Flags = new bool [ this . Indices . Length ] ; for ( int i = 0 ; i < this . R ; ++ i ) { Flags [ i ] = true ; } this . Start = 0 ; this . End = this . R - 1 ; this . Output ( ) ; } public bool HasNext ( ) { return End < ( this . Indices . Length - 1 ) ; } public void Next ( ) { if ( this . Start == this . End ) { this . Flags [ this . End ] = false ; this . Flags [ this . End + 1 ] = true ; this . Start += 1 ; this . End += 1 ; while ( this . End + 1 < this . Indices . Length && this . Flags [ this . End + 1 ] ) { ++ this . End ; } } else { if ( this . Start == 0 ) { Flags [ this . End ] = false ; Flags [ this . End + 1 ] = true ; this . End -= 1 ; } else { Flags [ this . End + 1 ] = true ; for ( int i = this . Start ; i <= this . End ; ++ i ) { Flags [ i ] = false ; } for ( int i = 0 ; i < this . End - this . Start ; ++ i ) { Flags [ i ] = true ; } this . End = this . End - this . Start - 1 ; this . Start = 0 ; } } this . Output ( ) ; } private void Output ( ) { for ( int i = 0 , count = 0 ; i < Indices . Length && count < this . R ; ++ i ) { if ( Flags [ i ] ) { Console . Write ( Indices [ i ] ) ; Console . Write ( " ▁ " ) ; ++ count ; } } Console . WriteLine ( ) ; } } class AppDriver { static void Main ( ) { int [ ] arr = { 0 , 1 , 2 , 3 } ; int r = 3 ; Combination com = new Combination ( arr , r ) ; com . GetFirst ( ) ; while ( com . HasNext ( ) ) { com . Next ( ) ; } } } }

Index/key variables: i
Accumulator variables: End, Start
Iterator variables: i
Class/struct names: AppDriver, Combination
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX_INDEX = 51 ; static int MAX_SUM = 2505 ; static int [ , , ] dp = new int [ MAX_INDEX , MAX_SUM , MAX_INDEX ] ; static int waysutil ( int index , int sum , int count , List < int > arr , int K ) { if ( index < 0 ) { return 0 ; } if ( index == 0 ) { if ( count == 0 ) { return 0 ; } int remainder = sum % count ; if ( remainder != 0 ) { return 0 ; } int average = sum / count ; if ( average == K ) { return 1 ; } } if ( dp [ index , sum , count ] != - 1 ) { return dp [ index , sum , count ] ; } int dontpick = waysutil ( index - 1 , sum , count , arr , K ) ; int pick = waysutil ( index - 1 , sum + arr [ index ] , count + 1 , arr , K ) ; int total = pick + dontpick ; dp [ index , sum , count ] = total ; return total ; } static int ways ( int N , int K , int [ ] arr ) { List < int > Arr = new List < int > ( ) ; Arr . Add ( - 1 ) ; for ( int i = 0 ; i < N ; ++ i ) { Arr . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < MAX_INDEX ; i ++ ) { for ( int j = 0 ; j < MAX_SUM ; j ++ ) { for ( int l = 0 ; l < MAX_INDEX ; l ++ ) { dp [ i , j , l ] = - 1 ; } } } int answer = waysutil ( N , 0 , 0 , Arr , K ) ; return answer ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 6 , 2 , 8 , 7 , 6 , 5 , 9 } ; int N = arr . Length ; int K = 5 ; Console . WriteLine ( ways ( N , K , arr ) ) ; } }

Index/key variables: i, index
Accumulator variables: i, j, l
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int arrSize = 51 ; static int maxSum = 201 ; static int MAX = 100 ; static int inf = 999999 ; static int [ , ] dp = new int [ arrSize , maxSum ] ; static int [ , ] visit = new int [ arrSize , maxSum ] ; static int RetClose ( int a , int b , int s ) { if ( Math . Abs ( a - s ) < Math . Abs ( b - s ) ) return a ; else return b ; } static int MinDiff ( int i , int sum , int [ ] arr , int n ) { if ( i == n ) return 0 ; if ( visit [ i , sum + MAX ] > 0 ) return dp [ i , sum + MAX ] ; visit [ i , sum + MAX ] = 1 ; dp [ i , sum + MAX ] = RetClose ( arr [ i ] + MinDiff ( i + 1 , sum + arr [ i ] , arr , n ) , MinDiff ( i + 1 , sum , arr , n ) , - 1 * sum ) ; return dp [ i , sum + MAX ] ; } static void FindClose ( int [ ] arr , int n ) { int ans = inf ; for ( int i = 1 ; i <= n ; i ++ ) ans = RetClose ( arr [ i - 1 ] + MinDiff ( i , arr [ i - 1 ] , arr , n ) , ans , 0 ) ; Console . WriteLine ( ans ) ; } public static void Main ( ) { int [ ] arr = { 25 , - 9 , - 10 , - 4 , - 7 , - 33 } ; int n = arr . Length ; FindClose ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int totalPaths ( int i , int j , int n , int [ , ] grid , int [ , ] dp ) { if ( i < 0 j < 0 i >= n j >= n ) return 0 ; if ( dp [ i , j ] == - 1 ) { if ( grid [ i , j ] == 1 ) dp [ i , j ] = totalPaths ( i , j + 1 , n , grid , dp ) ; else if ( grid [ i , j ] == 2 ) dp [ i , j ] = totalPaths ( i + 1 , j , n , grid , dp ) ; else dp [ i , j ] = totalPaths ( i , j + 1 , n , grid , dp ) + totalPaths ( i + 1 , j , n , grid , dp ) ; } return dp [ i , j ] ; } static int maxSumPath ( int i , int j , int n , int [ , ] grid , int [ , ] dp ) { if ( i < 0 j < 0 i >= n j >= n ) return 0 ; if ( dp [ i , j ] == - 1 ) { if ( grid [ i , j ] == 1 ) dp [ i , j ] = grid [ i , j ] + maxSumPath ( i , j + 1 , n , grid , dp ) ; else if ( grid [ i , j ] == 2 ) dp [ i , j ] = grid [ i , j ] + maxSumPath ( i + 1 , j , n , grid , dp ) ; else dp [ i , j ] = grid [ i , j ] + Math . Max ( maxSumPath ( i , j + 1 , n , grid , dp ) , maxSumPath ( i + 1 , j , n , grid , dp ) ) ; } return dp [ i , j ] ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 1 , 1 , 3 , 2 , 1 } , { 3 , 2 , 2 , 1 , 2 } , { 1 , 3 , 3 , 1 , 3 } , { 1 , 2 , 3 , 1 , 2 } , { 1 , 1 , 1 , 3 , 1 } } ; int n = grid . GetLength ( 0 ) ; int [ , ] dp = new int [ n , n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) dp [ i , j ] = - 1 ; dp [ n - 1 , n - 1 ] = 1 ; Console . WriteLine ( " Total ▁ paths : ▁ " + totalPaths ( 0 , 0 , n , grid , dp ) ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) dp [ i , j ] = - 1 ; dp [ n - 1 , n - 1 ] = grid [ n - 1 , n - 1 ] ; Console . WriteLine ( " Maximum ▁ sum : ▁ " + maxSumPath ( 0 , 0 , n , grid , dp ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100000 ; static int bitscount = 32 ; static int [ , ] prefix_count = new int [ bitscount , MAX ] ; static void findPrefixCount ( int [ ] arr , int n ) { for ( int i = 0 ; i < bitscount ; i ++ ) { prefix_count [ i , 0 ] = ( ( arr [ 0 ] >> i ) & 1 ) ; for ( int j = 1 ; j < n ; j ++ ) { prefix_count [ i , j ] = ( ( arr [ j ] >> i ) & 1 ) ; prefix_count [ i , j ] += prefix_count [ i , j - 1 ] ; } } } static int rangeOr ( int l , int r ) { int ans = 0 ; for ( int i = 0 ; i < bitscount ; i ++ ) { int x ; if ( l == 0 ) x = prefix_count [ i , r ] ; else x = prefix_count [ i , r ] - prefix_count [ i , l - 1 ] ; if ( x != 0 ) ans = ( ans | ( 1 << i ) ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 5 , 3 , 5 , 2 , 3 } ; int n = arr . Length ; findPrefixCount ( arr , n ) ; int [ , ] queries = { { 1 , 3 } , { 4 , 5 } } ; int q = queries . GetLength ( 0 ) ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( rangeOr ( queries [ i , 0 ] , queries [ i , 1 ] ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int palindromeSubStrs ( String s ) { int [ , ] dp = new int [ s . Length , s . Length ] ; int st , end , i , len ; Dictionary < String , Boolean > m = new Dictionary < String , Boolean > ( ) ; for ( i = 0 ; i < s . Length ; i ++ ) { dp [ i , i ] = 1 ; if ( ! m . ContainsKey ( s . Substring ( i , 1 ) ) ) m . Add ( s . Substring ( i , 1 ) , true ) ; } for ( i = 0 ; i < s . Length - 1 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { dp [ i , i + 1 ] = 1 ; if ( ! m . ContainsKey ( s . Substring ( i , 2 ) ) ) m . Add ( s . Substring ( i , 2 ) , true ) ; } else dp [ i , i + 1 ] = 0 ; } for ( len = 3 ; len <= s . Length ; len ++ ) { for ( st = 0 ; st <= s . Length - len ; st ++ ) { end = st + len - 1 ; if ( s [ st ] == s [ end ] && dp [ st + 1 , end - 1 ] == 1 ) { dp [ st , end ] = 1 ; m . Add ( s . Substring ( st , end + 1 - st ) , true ) ; } else dp [ st , end ] = 0 ; } } return m . Count ; } public static void Main ( String [ ] args ) { String s = " abaaa " ; Console . WriteLine ( palindromeSubStrs ( s ) ) ; } }

Index/key variables: end, i, st
Accumulator variables: i, len, st
Iterator variables: i, len, st
Class/struct names: GFG
C# program:
using System ; class GFG { static int n = 4 , m = 4 ; static int [ , ] arr = { { 1 , 0 , 3 , - 1 } , { 3 , 5 , 1 , - 2 } , { - 2 , 0 , 1 , 1 } , { 2 , 1 , - 1 , 1 } } ; static int [ , , ] cache = new int [ 5 , 5 , 5 ] ; static int sum ( int i1 , int j1 , int i2 , int j2 ) { if ( i1 == i2 && j1 == j2 ) { return arr [ i1 , j1 ] ; } return arr [ i1 , j1 ] + arr [ i2 , j2 ] ; } static int maxSumPath ( int i1 , int j1 , int i2 ) { int j2 = i1 + j1 - i2 ; if ( i1 >= n i2 >= n j1 >= m j2 >= m ) { return 0 ; } if ( cache [ i1 , j1 , i2 ] != - 1 ) { return cache [ i1 , j1 , i2 ] ; } int ans = int . MinValue ; ans = Math . Max ( ans , maxSumPath ( i1 + 1 , j1 , i2 + 1 ) + sum ( i1 , j1 , i2 , j2 ) ) ; ans = Math . Max ( ans , maxSumPath ( i1 , j1 + 1 , i2 ) + sum ( i1 , j1 , i2 , j2 ) ) ; ans = Math . Max ( ans , maxSumPath ( i1 , j1 + 1 , i2 + 1 ) + sum ( i1 , j1 , i2 , j2 ) ) ; ans = Math . Max ( ans , maxSumPath ( i1 + 1 , j1 , i2 ) + sum ( i1 , j1 , i2 , j2 ) ) ; cache [ i1 , j1 , i2 ] = ans ; return ans ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < 5 ; i ++ ) for ( int i1 = 0 ; i1 < 5 ; i1 ++ ) for ( int i2 = 0 ; i2 < 5 ; i2 ++ ) cache [ i , i1 , i2 ] = - 1 ; Console . WriteLine ( maxSumPath ( 0 , 0 , 0 ) ) ; } }

Accumulator variables: i, i1, i2
Iterator variables: i, i1, i2
Class/struct names: GFG
C# program:
using System ; class GFG { static void BellmanFord ( int [ , ] graph , int V , int E , int src ) { int [ ] dis = new int [ V ] ; for ( int i = 0 ; i < V ; i ++ ) dis [ i ] = int . MaxValue ; dis [ src ] = 0 ; for ( int i = 0 ; i < V - 1 ; i ++ ) { for ( int j = 0 ; j < E ; j ++ ) { if ( dis [ graph [ j , 0 ] ] = int . MaxValue && dis [ graph [ j , 0 ] ] + graph [ j , 2 ] < dis [ graph [ j , 1 ] ] ) dis [ graph [ j , 1 ] ] = dis [ graph [ j , 0 ] ] + graph [ j , 2 ] ; } } for ( int i = 0 ; i < E ; i ++ ) { int x = graph [ i , 0 ] ; int y = graph [ i , 1 ] ; int weight = graph [ i , 2 ] ; if ( dis [ x ] != int . MaxValue && dis [ x ] + weight < dis [ y ] ) Console . WriteLine ( " Graph ▁ contains ▁ negative " + " ▁ weight ▁ cycle " ) ; } Console . WriteLine ( " Vertex ▁ Distance ▁ from ▁ Source " ) ; for ( int i = 0 ; i < V ; i ++ ) Console . WriteLine ( i + " TABSYMBOL TABSYMBOL " + dis [ i ] ) ; } public static void Main ( String [ ] args ) { int [ , ] graph = { { 0 , 1 , - 1 } , { 0 , 2 , 4 } , { 1 , 2 , 3 } , { 1 , 3 , 2 } , { 1 , 4 , 2 } , { 3 , 2 , 5 } , { 3 , 1 , 1 } , { 4 , 3 , - 3 } } ; BellmanFord ( graph , V , E , 0 ) ; } }

Index/key variables: V, i, src, x, y
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] m ; static int [ , ] a ; static int [ ] x ; static List < int > [ ] g ; static int ans = 0 ; static void dfs ( int u , int p ) { foreach ( int v in g [ u ] ) { if ( v != p ) { dfs ( v , u ) ; for ( int i = 0 ; i < 22 ; i ++ ) a [ u , i ] += a [ v , i ] ; } } int pp = 0 ; for ( int i = 0 ; i < 22 ; i ++ ) { if ( ! ( ( a [ u , i ] > 0 && x [ i ] - a [ u , i ] > 0 ) || ( a [ u , i ] == 0 && x [ i ] == 0 ) ) ) { pp = 1 ; break ; } } if ( pp == 0 ) ans ++ ; } public static void Main ( String [ ] args ) { int n = 4 ; g = new List < int > [ n + 1 ] ; m = new int [ n + 1 ] ; m [ 1 ] = 1 ; m [ 2 ] = 3 ; m [ 3 ] = 2 ; m [ 4 ] = 3 ; a = new int [ n + 1 , 22 ] ; x = new int [ 22 ] ; for ( int i = 1 ; i <= n ; i ++ ) { g [ i ] = new List < int > ( ) ; int y = m [ i ] ; int k = 0 ; while ( y != 0 ) { int p = y % 2 ; if ( p == 1 ) { x [ k ] ++ ; a [ i , k ] ++ ; } y = y / 2 ; k ++ ; } } g [ 1 ] . Add ( 2 ) ; g [ 2 ] . Add ( 1 ) ; g [ 1 ] . Add ( 3 ) ; g [ 3 ] . Add ( 1 ) ; g [ 1 ] . Add ( 4 ) ; g [ 4 ] . Add ( 1 ) ; dfs ( 1 , 0 ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: i, k, u
Accumulator variables: ans, i, k
Iterator variables: i, v
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int maxn = 16 ; static int [ ] dp = new int [ maxn + 1 ] ; static void precompute ( ) { for ( int i = 0 ; i <= maxn ; i ++ ) dp [ i ] = - 1 ; dp [ 0 ] = 0 ; int [ ] vec = { 4 , 6 , 9 } ; for ( int i = 1 ; i < maxn ; ++ i ) { foreach ( int j in vec ) { if ( i >= j && dp [ i - j ] != - 1 ) { dp [ i ] = Math . Max ( dp [ i ] , dp [ i - j ] + 1 ) ; } } } } static int Maximum_Summands ( int n ) { if ( n < maxn ) return dp [ n ] ; else { int t = ( n - maxn ) / 4 + 1 ; return t + dp [ n - 4 * t ] ; } } static void Main ( ) { int n = 12 ; precompute ( ) ; Console . WriteLine ( Maximum_Summands ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int min ( int a , int b ) { return ( a > b ) ? b : a ; } static int minCostJumpsDP ( int [ ] A , int k ) { int size = A . Length ; int [ ] x = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) x [ i ] = int . MaxValue ; x [ 0 ] = 0 ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = i + 1 ; j < i + k + 1 && j < size ; j ++ ) { x [ j ] = min ( x [ j ] , x [ i ] + Math . Abs ( A [ i ] - A [ j ] ) ) ; } } return x [ size - 1 ] ; } public static void Main ( String [ ] args ) { int [ ] input = { 83 , 26 , 37 , 35 , 33 , 35 , 56 } ; Console . WriteLine ( minCostJumpsDP ( input , 3 ) ) ; } }

Index/key variables: i, j, size
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int dfs ( int node , int parent , int [ ] dp1 , int [ ] dp2 , List < List < int > > adj ) { int firstmax = - 1 ; int secondmax = - 1 ; for ( int i = 0 ; i < adj [ node ] . Count ; ++ i ) { if ( adj [ node ] [ i ] == parent ) continue ; dfs ( adj [ node ] [ i ] , node , dp1 , dp2 , adj ) ; if ( firstmax == - 1 ) { firstmax = dp1 [ adj [ node ] [ i ] ] ; } else if ( dp1 [ adj [ node ] [ i ] ] >= firstmax ) { secondmax = firstmax ; firstmax = dp1 [ adj [ node ] [ i ] ] ; } else if ( dp1 [ adj [ node ] [ i ] ] > secondmax ) { secondmax = dp1 [ adj [ node ] [ i ] ] ; } } dp1 [ node ] = 1 ; dp1 [ node ] += firstmax ; if ( secondmax != - 1 ) dp2 [ node ] = 1 + firstmax + secondmax ; return Math . Max ( dp1 [ node ] , dp2 [ node ] ) ; } static void Main ( ) { int n = 5 ; List < List < int > > adj = new List < List < int > > ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { adj . Add ( new List < int > ( ) ) ; } adj [ 1 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 1 ) ; adj [ 1 ] . Add ( 3 ) ; adj [ 3 ] . Add ( 1 ) ; adj [ 2 ] . Add ( 4 ) ; adj [ 4 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 5 ) ; adj [ 5 ] . Add ( 2 ) ; int [ ] dp1 = new int [ n + 1 ] ; int [ ] dp2 = new int [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { dp1 [ i ] = 0 ; dp2 [ i ] = 0 ; } Console . WriteLine ( " Diameter ▁ of ▁ the ▁ given ▁ tree ▁ is ▁ " + dfs ( 1 , 1 , dp1 , dp2 , adj ) ) ; } }

Index/key variables: i, node
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { static int N = 4 ; static int getSum ( int r1 , int r2 , int c1 , int c2 , int [ , ] dp ) { return dp [ r2 , c2 ] - dp [ r2 , c1 ] - dp [ r1 , c2 ] + dp [ r1 , c1 ] ; } static bool sumFound ( int K , int S , int [ , ] grid ) { int [ , ] dp = new int [ N + 1 , N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { dp [ i + 1 , j + 1 ] = dp [ i + 1 , j ] + dp [ i , j + 1 ] - dp [ i , j ] + grid [ i , j ] ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { int sum = getSum ( i , i + K , j , j + K , dp ) ; if ( sum == S ) { return true ; } } } return false ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; int K = 2 ; int S = 14 ; if ( sumFound ( K , S , grid ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GfG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void bfs ( int n , int m , int num ) { Queue < int > q = new Queue < int > ( ) ; q . Enqueue ( num ) ; while ( q . Count != 0 ) { int stepNum = q . Dequeue ( ) ; if ( stepNum <= m && stepNum >= n ) { Console . Write ( stepNum + " ▁ " ) ; } if ( stepNum == 0 stepNum > m ) continue ; int lastDigit = stepNum % 10 ; int stepNumA = stepNum * 10 + ( lastDigit - 1 ) ; int stepNumB = stepNum * 10 + ( lastDigit + 1 ) ; if ( lastDigit == 0 ) q . Enqueue ( stepNumB ) ; else if ( lastDigit == 9 ) q . Enqueue ( stepNumA ) ; else { q . Enqueue ( stepNumA ) ; q . Enqueue ( stepNumB ) ; } } } static void displaySteppingNumbers ( int n , int m ) { for ( int i = 0 ; i <= 9 ; i ++ ) bfs ( n , m , i ) ; } static public void Main ( ) { int n = 0 , m = 21 ; displaySteppingNumbers ( n , m ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG