dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MAX = 100 ; static int [ , , ] dp = new int [ 1000 , MAX , MAX ] ; static int productDigitSum ( int x , int y ) { int sumx = 0 ; while ( x > 0 ) { sumx += ( x % 10 ) ; x /= 10 ; } int sumy = 0 ; while ( y > 0 ) { sumy += ( y % 10 ) ; y /= 10 ; } return ( sumx * sumy ) ; } static int solve ( int [ ] arr , int i , int len , int prev , int n , int k ) { if ( len == k ) return 0 ; if ( i == n ) return Int32 . MinValue ; if ( dp [ i , len , prev ] != 0 ) return dp [ i , len , prev ] ; int inc = 0 , exc = 0 ; if ( ( len & 1 ) != 0 ) { inc = ( productDigitSum ( arr [ prev ] , arr [ i ] ) + solve ( arr , i + 1 , len + 1 , 0 , n , k ) ) ; } else { inc = solve ( arr , i + 1 , len + 1 , i , n , k ) ; } exc = solve ( arr , i + 1 , len , prev , n , k ) ; return dp [ i , len , prev ] = Math . Max ( inc , exc ) ; } public static void Main ( ) { int [ ] arr = { 10 , 5 , 9 , 101 , 24 , 2 , 20 , 14 } ; int n = arr . Length ; int k = 6 ; Console . Write ( solve ( arr , 0 , 0 , 0 , n , k ) ) ; } }

Index/key variables: i, prev
Accumulator variables: sumx, sumy, x, y
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > [ ] factors = new List < int > [ 100005 ] ; static int [ ] dp = new int [ 100005 ] ; static void precompute ( ) { for ( int i = 0 ; i < factors . Length ; i ++ ) factors [ i ] = new List < int > ( ) ; for ( int i = 1 ; i <= 100000 ; i ++ ) { for ( int j = i ; j <= 100000 ; j += i ) { factors [ j ] . Add ( i ) ; } } } static int solve ( int [ ] arr , int k , int n ) { if ( k == n - 1 ) { return 0 ; } if ( k >= n ) { return int . MaxValue ; } if ( dp [ k ] != 0 ) { return dp [ k ] ; } int ans = int . MaxValue ; foreach ( int j in factors [ arr [ k ] ] ) { int res = solve ( arr , k + j , n ) ; if ( res != int . MaxValue ) { ans = Math . Min ( ans , res + 1 ) ; } } return dp [ k ] = ans ; } public static void Main ( String [ ] args ) { precompute ( ) ; int [ ] arr = { 2 , 8 , 16 , 55 , 99 , 100 } ; int n = arr . Length ; Console . Write ( solve ( arr , 0 , n ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int maxDistance ( int [ , ] grid ) { List < pair > one = new List < pair > ( ) ; int M = grid . GetLength ( 0 ) ; int N = grid . GetLength ( 1 ) ; int ans = - 1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i , j ] == 1 ) one . Add ( new pair ( i , j ) ) ; } } if ( one . Count == 0 M * N == one . Count ) return - 1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i , j ] == 1 ) continue ; int dist = int . MaxValue ; foreach ( pair p in one ) { int d = Math . Abs ( p . first - i ) + Math . Abs ( p . second - j ) ; dist = Math . Min ( dist , d ) ; if ( dist <= ans ) break ; } ans = Math . Max ( ans , dist ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 0 , 0 , 1 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ; Console . Write ( maxDistance ( arr ) + " STRNEWLINE " ) ; } }

Iterator variables: i, j, p
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static int index = 0 ; class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int maxDistance ( int [ , ] grid ) { Queue < pair > q = new Queue < pair > ( ) ; int M = grid . GetLength ( 0 ) ; int N = grid . GetLength ( 1 ) ; int ans = - 1 ; int [ , ] dirs = { { 0 , 1 } , { 1 , 0 } , { 0 , - 1 } , { - 1 , 0 } } ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i , j ] == 1 ) q . Enqueue ( new pair ( i , j ) ) ; } } if ( q . Count == 0 M * N == q . Count ) return - 1 ; while ( q . Count > 0 ) { int cnt = q . Count ; while ( cnt -- > 0 ) { pair p = q . Peek ( ) ; q . Dequeue ( ) ; for ( int i = 0 ; i < dirs . GetLength ( 0 ) ; ) { int [ ] dir = GetRow ( dirs , i ++ ) ; int x = p . first + dir [ 0 ] ; int y = p . second + dir [ 1 ] ; if ( x < 0 x >= M y < 0 y >= N grid [ x , y ] > 0 ) continue ; q . Enqueue ( new pair ( x , y ) ) ; grid [ x , y ] = 1 ; } } ++ ans ; } return ans ; } 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 ) { int [ , ] arr = { { 0 , 0 , 1 } , { 0 , 0 , 0 } , { 0 , 0 , 1 } } ; Console . Write ( maxDistance ( arr ) + " STRNEWLINE " ) ; } }

Index/key variables: i, rowLength
Accumulator variables: cnt, i
Iterator variables: i, j
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int mod = ( int ) ( 1e9 + 7 ) ; static int [ , ] dp ; static int f ( int n , int k ) { if ( n < k ) return 0 ; if ( n == k ) return 1 ; if ( k == 1 ) return 1 ; if ( dp [ n , k ] != - 1 ) return dp [ n , k ] ; return dp [ n , k ] = ( ( k * f ( n - 1 , k ) ) % mod + ( f ( n - 1 , k - 1 ) ) % mod ) % mod ; } static long operation ( int n ) { dp = new int [ n + 1 , n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { dp [ i , j ] = - 1 ; } } long ans = 0 , fac = 1 ; for ( int k = 1 ; k <= n ; k ++ ) { fac *= k ; ans = ( ans + ( fac * f ( n , k ) ) % mod ) % mod ; } return ans ; } public static void Main ( String [ ] args ) { int n = 5 ; Console . Write ( operation ( n ) + " STRNEWLINE " ) ; } }

Accumulator variables: fac, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountSets ( int x , int pos ) { if ( x <= 0 ) { if ( pos == 0 ) return 1 ; else return 0 ; } if ( pos == 0 ) return 1 ; int answer = CountSets ( x - 1 , pos ) + CountSets ( x - 2 , pos - 1 ) ; return answer ; } static int CountOrderedSets ( int n ) { int [ ] factorial = new int [ 10000 ] ; factorial [ 0 ] = 1 ; for ( int i = 1 ; i < 10000 ; i ++ ) factorial [ i ] = factorial [ i - 1 ] * i ; int answer = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int sets = CountSets ( n , i ) * factorial [ i ] ; answer = answer + sets ; } return answer ; } public static void Main ( String [ ] args ) { int N = 3 ; Console . Write ( CountOrderedSets ( N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaximumSum ( int [ ] a , int n ) { int [ , ] dp = new int [ n + 1 , n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) dp [ i , j ] = Int32 . MinValue ; } for ( int i = 0 ; i < n + 1 ; i ++ ) dp [ i , 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { int val = Int32 . MinValue ; if ( ( i - 2 >= 0 && dp [ i - 2 , j - 1 ] != Int32 . MinValue ) i - 2 < 0 ) { val = a [ i - 1 ] + ( i - 2 >= 0 ? dp [ i - 2 , j - 1 ] : 0 ) ; } if ( i - 1 >= j ) { val = Math . Max ( val , dp [ i - 1 , j ] ) ; } dp [ i , j ] = val ; } } return dp [ n , n / 2 ] ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = A . Length ; Console . Write ( MaximumSum ( A , N ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static SortedSet < int > kPowKform = new SortedSet < int > ( ) ; static int func ( int n ) { if ( n <= 0 ) return 0 ; if ( kPowKform . Contains ( n ) ) return 1 ; int answer = 0 ; int x = n ; while ( x > 0 ) { int d = x % 10 ; if ( d != 0 ) { if ( func ( n - d * d ) == 1 ) { answer = 1 ; break ; } } x /= 10 ; } return answer ; } static void canBeConverted ( int n ) { if ( func ( n ) == 1 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( ) { int N = 90 ; for ( int i = 1 ; i <= 8 ; i ++ ) { int val = 1 ; for ( int j = 1 ; j <= i ; j ++ ) val *= i ; kPowKform . Add ( val ) ; } canBeConverted ( N ) ; } }

Accumulator variables: i, j, val, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool check ( List < int > v ) { HashSet < int > digits = new HashSet < int > ( ) ; for ( int i = 0 ; i < v . Count ; i ++ ) { HashSet < int > d = new HashSet < int > ( ) ; while ( v [ i ] > 0 ) { d . Add ( v [ i ] % 10 ) ; v [ i ] = v [ i ] / 10 ; } foreach ( int it in d ) { if ( digits . Contains ( it ) ) return false ; } foreach ( int it in d ) digits . Add ( it ) ; } return true ; } static int numberOfSubarrays ( int [ ] a , int n ) { int answer = 0 ; for ( int i = 1 ; i < ( 1 << n ) ; i ++ ) { List < int > temp = new List < int > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) > 0 ) temp . Add ( a [ j ] ) ; } if ( check ( temp ) ) answer ++ ; } return answer ; } public static void Main ( String [ ] args ) { int N = 4 ; int [ ] A = { 1 , 12 , 23 , 34 } ; Console . Write ( numberOfSubarrays ( A , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: answer, i, j
Iterator variables: i, it, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int MAX = 100005 ; static int totBackEdges ; static int [ ] countAdj = new int [ MAX ] ; static int [ ] small = new int [ MAX ] ; static int [ ] isPossible = new int [ MAX ] ; static int [ ] depth = new int [ MAX ] ; static ArrayList adj = new ArrayList ( ) ; static int [ ] vis = new int [ MAX ] ; class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void change ( ref pair p , int x ) { if ( p . second > x ) p . second = x ; if ( p . first > p . second ) { int tmp = p . first ; p . first = p . second ; p . second = tmp ; } } static pair dfs ( int v , int p = - 1 , int de = 0 ) { pair answer = new pair ( 100000000 , 100000000 ) ; depth [ v ] = de ; vis [ v ] = 1 ; isPossible [ v ] = 1 ; foreach ( int u in ( ArrayList ) adj [ v ] ) { if ( ( u ^ p ) != 0 ) { if ( vis [ u ] == 0 ) { pair x = dfs ( u , v , de + 1 ) ; small [ v ] += small [ u ] ; change ( ref answer , x . second ) ; change ( ref answer , x . first ) ; if ( x . second < de ) isPossible [ v ] = 0 ; } else if ( vis [ u ] == 1 ) { totBackEdges ++ ; countAdj [ v ] ++ ; countAdj [ u ] ++ ; small [ p ] ++ ; small [ u ] -- ; change ( ref answer , depth [ u ] ) ; } } } vis [ v ] = 2 ; return answer ; } static int minNodetoRemove ( int n , ArrayList edges ) { for ( int i = 0 ; i < edges . Count ; i ++ ) { ( ( ArrayList ) adj [ ( ( pair ) edges [ i ] ) . first ] ) . Add ( ( ( pair ) edges [ i ] ) . second ) ; ( ( ArrayList ) adj [ ( ( pair ) edges [ i ] ) . second ] ) . Add ( ( ( pair ) edges [ i ] ) . first ) ; } Array . Fill ( vis , 0 ) ; totBackEdges = 0 ; for ( int v = 1 ; v <= n ; v ++ ) { if ( vis [ v ] == 0 ) dfs ( v ) ; } if ( totBackEdges == 0 ) return - 1 ; int node = - 1 ; for ( int v = 1 ; v <= n ; v ++ ) { if ( ( countAdj [ v ] + small [ v ] == totBackEdges ) && isPossible [ v ] != 0 ) { node = v ; } if ( node != - 1 ) break ; } return node ; } static void Main ( ) { int N = 5 ; ArrayList edges = new ArrayList ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { adj . Add ( new ArrayList ( ) ) ; } edges . Add ( new pair ( 5 , 1 ) ) ; edges . Add ( new pair ( 5 , 2 ) ) ; edges . Add ( new pair ( 1 , 2 ) ) ; edges . Add ( new pair ( 2 , 3 ) ) ; edges . Add ( new pair ( 2 , 4 ) ) ; Console . Write ( minNodetoRemove ( N , edges ) ) ; } }

Index/key variables: MAX, i, p, u, v
Accumulator variables: i, totBackEdges, v
Iterator variables: i, u, v
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int N = 3 ; static readonly int M = 5 ; static int Large = ( int ) 1e6 ; static List < int > prime = new List < int > ( ) ; static void SieveOfEratosthenes ( ) { bool [ ] isPrime = new bool [ Large + 1 ] ; for ( int p = 0 ; p <= Large ; p ++ ) isPrime [ p ] = true ; for ( int p = 2 ; p * p <= Large ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * 2 ; i <= Large ; i += p ) isPrime [ i ] = false ; } } for ( int p = 2 ; p <= Large ; p ++ ) if ( isPrime [ p ] ) prime . Add ( p ) ; } static void Display ( int [ , ] arr , int row ) { for ( int i = 0 ; i < M ; i ++ ) Console . Write ( arr [ row , i ] + " ▁ " ) ; } static void countDivisorsMult ( int [ , ] arr ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int row_no = 0 ; long max_factor = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int no = arr [ i , j ] ; for ( int k = 0 ; k < prime . Count ; k ++ ) { while ( no > 1 && no % prime [ k ] == 0 ) { no /= prime [ k ] ; if ( mp . ContainsKey ( prime [ k ] ) ) mp [ prime [ k ] ] = prime [ k ] + 1 ; else mp . Add ( prime [ k ] , 1 ) ; } if ( no == 1 ) break ; } } int res = 1 ; foreach ( KeyValuePair < int , int > it in mp ) { res *= ( it . Value + 1 ) ; } if ( max_factor < res ) { row_no = i ; max_factor = res ; } mp . Clear ( ) ; } Display ( arr , row_no ) ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , 2 , 3 , 10 , 23 } , { 4 , 5 , 6 , 7 , 8 } , { 7 , 8 , 9 , 15 , 45 } } ; SieveOfEratosthenes ( ) ; countDivisorsMult ( arr ) ; } }

Index/key variables: i, k, p
Accumulator variables: i, j, k, no, p, res
Iterator variables: i, it, j, k, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int isSquare ( int n ) { int k = ( int ) Math . Sqrt ( n ) ; return k * k == n ? 1 : 0 ; } static int calculate ( int pos , int prev , int sum , int [ ] v ) { if ( pos == v . Length ) return isSquare ( sum ) ; for ( int i = prev ; i <= 9 ; i ++ ) { v [ pos ] = i ; sum += i * i ; if ( calculate ( pos + 1 , i , sum , v ) != 0 ) return 1 ; sum -= i * i ; } return 0 ; } static string minValue ( int n ) { int [ ] v = new int [ n ] ; if ( calculate ( 0 , 1 , 0 , v ) != 0 ) { string answer = " " ; for ( int i = 0 ; i < v . Length ; i ++ ) answer += ( char ) ( v [ i ] + '0' ) ; return answer ; } else return " - 1" ; } public static void Main ( ) { int N = 2 ; Console . Write ( minValue ( N ) ) ; } }

Index/key variables: i, n, pos
Accumulator variables: answer, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int checkOdd ( string number ) { int n = number . Length ; int num = number [ n - 1 ] - '0' ; return ( num & 1 ) ; } static int splitIntoOdds ( string number ) { int numLen = number . Length ; int [ ] splitDP = new int [ numLen + 1 ] ; for ( int i = 0 ; i < numLen + 1 ; i ++ ) splitDP [ i ] = - 1 ; for ( int i = 1 ; i <= numLen ; i ++ ) { if ( i <= 9 && ( checkOdd ( number . Substring ( 0 , i ) ) == 1 ) ) splitDP [ i ] = 1 ; if ( splitDP [ i ] != - 1 ) { for ( int j = 1 ; j <= 9 && i + j <= numLen ; j ++ ) { if ( checkOdd ( number . Substring ( i , j ) ) == 1 ) { if ( splitDP [ i + j ] == - 1 ) splitDP [ i + j ] = 1 + splitDP [ i ] ; else splitDP [ i + j ] = Math . Min ( splitDP [ i + j ] , 1 + splitDP [ i ] ) ; } } } } return splitDP [ numLen ] ; } public static void Main ( string [ ] args ) { Console . WriteLine ( splitIntoOdds ( "123456789123456789123" ) ) ; } }

Index/key variables: i, numLen
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class Graph { static int m , n , d ; static List < int > v = new List < int > ( ) ; static int k = ( int ) 1e9 + 7 ; static int [ , , ] dp = new int [ 2001 , 2001 , 2 ] ; static void init ( string l ) { for ( int i = 0 ; i < 2001 ; i ++ ) { for ( int j = 0 ; j < 2001 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } v . Clear ( ) ; for ( int i = 0 ; i < l . Length ; i ++ ) { v . Add ( l [ i ] - '0' ) ; } n = l . Length ; } static string number_minus_one ( string a ) { string s = a . Substring ( 1 ) ; string s1 = " " ; for ( int i = 0 ; i < s . Length - 1 ; i ++ ) s1 += '0' ; if ( a [ 0 ] == '1' && String . Compare ( s , s1 ) == 0 ) { int l = s . Length ; a = a . Replace ( a [ 0 ] , '0' ) ; for ( int i = 0 ; i < l ; i ++ ) a += '9' ; } else { for ( int i = a . Length - 1 ; i >= 0 ; i -- ) { if ( a [ i ] == '0' ) a = a . Replace ( a [ i ] , '9' ) ; else { a = a . Replace ( a [ i ] , ( char ) ( ( ( a [ i ] - '0' ) - 1 ) + '0' ) ) ; break ; } } } return a . ToString ( ) ; } static int fun ( int pos , int sum , int f ) { if ( pos == n ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ pos , sum , f ] != - 1 ) return dp [ pos , sum , f ] ; int lmt = 9 ; if ( f == 0 ) lmt = v [ pos ] ; int ans = 0 ; for ( int i = 0 ; i <= lmt ; i ++ ) { if ( i == d && pos % 2 == 1 ) ans += 0 ; else if ( i != d && pos % 2 == 0 ) ans += 0 ; else { int new_f = f ; if ( f == 0 && i < lmt ) new_f = 1 ; int new_sum = sum ; new_sum *= 10 ; new_sum += i ; new_sum %= m ; ans += fun ( pos + 1 , new_sum , new_f ) ; ans %= k ; } } dp [ pos , sum , f ] = ans ; return dp [ pos , sum , f ] ; } static void operations ( string L , string R ) { init ( R ) ; int ans = fun ( 0 , 0 , 0 ) ; L = number_minus_one ( L ) ; init ( L ) ; ans -= fun ( 0 , 0 , 0 ) ; if ( ans < 0 ) ans += k ; Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { m = 2 ; d = 2 ; int Q = 1 ; string [ , ] arr = { { "20" , "32" } } ; for ( int i = 0 ; i < Q ; i ++ ) { operations ( arr [ i , 0 ] , arr [ i , 1 ] ) ; } } }

Index/key variables: i, pos
Accumulator variables: a, ans, i, j, k, new_sum, s1
Iterator variables: i, j, k
Class/struct names: Graph
C# program:
using System ; class GFG { static bool checkPrime ( String number ) { int num = Int32 . Parse ( number ) ; for ( int i = 2 ; i * i <= num ; i ++ ) if ( ( num % i ) == 0 ) return false ; return true ; } static int splitIntoPrimes ( String number ) { if ( number . Length == 0 ) return 0 ; if ( number . Length <= 6 && checkPrime ( number ) ) return 1 ; else { int numLen = number . Length ; int ans = 1000000 ; for ( int i = 1 ; i <= 6 && i <= numLen ; i ++ ) { if ( checkPrime ( number . Substring ( 0 , i ) ) ) { int val = splitIntoPrimes ( number . Substring ( i ) ) ; if ( val != - 1 ) { ans = Math . Min ( ans , 1 + val ) ; } } } if ( ans == 1000000 ) return - 1 ; return ans ; } } public static void Main ( String [ ] args ) { Console . Write ( splitIntoPrimes ( "13499315" ) + " STRNEWLINE " ) ; Console . Write ( splitIntoPrimes ( "43" ) + " STRNEWLINE " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int k_nonzero_numbers ( string s , int n , int k ) { int [ , , ] dp = new int [ n + 1 , 2 , k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j < 2 ; j ++ ) for ( int x = 0 ; x <= k ; x ++ ) dp [ i , j , x ] = 0 ; dp [ 0 , 0 , 0 ] = 1 ; for ( int i = 0 ; i < n ; ++ i ) { int sm = 0 ; while ( sm < 2 ) { for ( int j = 0 ; j < k + 1 ; ++ j ) { int x = 0 ; while ( x <= ( sm != 0 ? 9 : s [ i ] - '0' ) ) { if ( j + ( x > 0 ? 1 : 0 ) < k + 1 ) { dp [ i + 1 , ( ( sm != 0 || x < ( s [ i ] - '0' ) ) ? 1 : 0 ) , j + ( x > 0 ? 1 : 0 ) ] += dp [ i , sm , j ] ; } ++ x ; } } ++ sm ; } } return dp [ n , 0 , k ] + dp [ n , 1 , k ] ; } public static void Main ( string [ ] args ) { string s = "25" ; int k = 2 ; int n = s . Length ; Console . Write ( k_nonzero_numbers ( s , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, x
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maximumOccurrence ( string s ) { int n = s . Length ; Dictionary < string , int > freq = new Dictionary < string , int > ( ) ; int i , j ; for ( i = 0 ; i < n ; i ++ ) { string temp = " " ; temp += s [ i ] ; if ( freq . ContainsKey ( temp ) ) { freq [ temp ] ++ ; } else { freq [ temp ] = 1 ; } } for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { string temp = " " ; temp += s [ i ] ; temp += s [ j ] ; if ( freq . ContainsKey ( temp ) ) freq [ temp ] ++ ; else freq [ temp ] = 1 ; } } int answer = int . MinValue ; foreach ( KeyValuePair < string , int > it in freq ) answer = Math . Max ( answer , it . Value ) ; return answer ; } public static void Main ( string [ ] args ) { string s = " xxxyy " ; Console . Write ( maximumOccurrence ( s ) ) ; } }

Index/key variables: i, j, temp
Accumulator variables: i, j, temp
Iterator variables: i, it, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int distinctChars ( string s ) { int [ ] freq = new int [ 26 ] ; int count = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) freq [ s [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] > 0 ) count ++ ; } return count ; } static int waysToSplit ( string s ) { int n = s . Length ; int answer = 0 ; for ( int i = 1 ; i < n ; i ++ ) { string left = s . Substring ( 0 , i ) ; string right = s . Substring ( i , n - i ) ; if ( distinctChars ( left ) == distinctChars ( right ) ) answer ++ ; } return answer ; } public static void Main ( string [ ] args ) { string s = " ababa " ; Console . WriteLine ( waysToSplit ( s ) ) ; } }

Index/key variables: i
Accumulator variables: answer, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int waysToSplit ( string s ) { int n = s . Length ; int answer = 0 ; int [ ] prefix = new int [ n ] ; int [ ] suffix = new int [ n ] ; int [ ] seen = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { int prev = ( i - 1 >= 0 ? prefix [ i - 1 ] : 0 ) ; if ( seen [ s [ i ] - ' a ' ] == 0 ) { prefix [ i ] += ( prev + 1 ) ; } else prefix [ i ] = prev ; seen [ s [ i ] - ' a ' ] = 1 ; } for ( int i = 0 ; i < 26 ; i ++ ) seen [ i ] = 0 ; suffix [ n - 1 ] = 0 ; for ( int i = n - 1 ; i >= 1 ; i -- ) { int prev = suffix [ i ] ; if ( seen [ s [ i ] - ' a ' ] == 0 ) { suffix [ i - 1 ] += ( prev + 1 ) ; } else suffix [ i - 1 ] = prev ; seen [ s [ i ] - ' a ' ] = 1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( prefix [ i ] == suffix [ i ] ) answer ++ ; } return answer ; } public static void Main ( string [ ] args ) { string s = " ababa " ; Console . WriteLine ( waysToSplit ( s ) ) ; } }

Index/key variables: i, n
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long Count_Paths ( int x , int y ) { if ( x == 0 && y == 0 ) return 0 ; if ( x == 0 y == 0 ) return 1 ; int [ ] dp = new int [ Math . Max ( x , y ) + 1 ] ; int p = Math . Max ( x , y ) , q = Math . Min ( x , y ) ; for ( int i = 0 ; i <= p ; i ++ ) dp [ i ] = 1 ; for ( int i = 1 ; i <= q ; i ++ ) for ( int j = 1 ; j <= p ; j ++ ) dp [ j ] += dp [ j - 1 ] ; return dp [ p ] ; } public static void Main ( String [ ] args ) { int x = 3 , y = 3 ; Console . Write ( " Number ▁ of ▁ Paths ▁ " + Count_Paths ( x , y ) ) ; } }

Index/key variables: i, j, p
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_SIZE = 100005 ; static int [ ] fib = new int [ MAX_SIZE + 1 ] ; static void fibonacci ( ) { int i ; fib [ 0 ] = 0 ; fib [ 1 ] = 1 ; for ( i = 2 ; i <= MAX_SIZE ; i ++ ) { fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } } static void printLevel ( int level ) { int left_index = ( int ) Math . Pow ( 2 , level - 1 ) ; int right_index = ( int ) ( Math . Pow ( 2 , level ) - 1 ) ; for ( int i = left_index ; i <= right_index ; i ++ ) { Console . Write ( fib [ i - 1 ] + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void Main ( string [ ] args ) { fibonacci ( ) ; int K = 4 ; printLevel ( K ) ; } }

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