dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static void Main ( ) { string s = " ABCdcba " ; int [ ] u = new int [ 26 ] ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( Char . IsUpper ( s [ i ] ) ) { u [ s [ i ] - 65 ] += 1 ; } else { u [ s [ i ] - 97 ] -= 1 ; } } int po = 0 ; int ne = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( u [ i ] > 0 ) po += u [ i ] ; if ( u [ i ] < 0 ) ne += u [ i ] ; } if ( po == 0 && ne == 0 ) Console . Write ( " YES " + " STRNEWLINE " ) ; else if ( po == 1 && ne == 0 ) Console . Write ( " YES " + " STRNEWLINE " ) ; else if ( po == 0 && ne == - 1 ) Console . Write ( " YES " + " STRNEWLINE " ) ; else Console . Write ( " NO " + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i, ne, po
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static bool find ( char [ ] x , char c ) { for ( int i = 0 ; i < x . Length ; i ++ ) if ( x [ i ] == c ) return true ; return false ; } static bool find ( ArrayList v , char c ) { for ( int i = 0 ; i < v . Count ; i ++ ) if ( ( char ) v [ i ] == c ) return true ; return false ; } static void addAllVowel ( string str ) { char [ ] x = { ' A ' , ' E ' , ' I ' , ' O ' , ' U ' } ; ArrayList y = new ArrayList ( ) ; int length = str . Length ; if ( length < 5 ) Console . Write ( " Impossible " ) ; else { for ( int i = 0 ; i < length ; i ++ ) { if ( find ( x , str [ i ] ) && ! find ( y , str [ i ] ) ) y . Add ( str [ i ] ) ; } ArrayList z = new ArrayList ( ) ; for ( int i = 0 ; i < 5 ; i ++ ) if ( ! find ( y , x [ i ] ) ) z . Add ( x [ i ] ) ; if ( z . Count == 0 ) Console . Write ( str ) ; else { int cc = 0 ; ArrayList y1 = new ArrayList ( ) ; string ans = " " ; for ( int i = 0 ; i < length ; i ++ ) { if ( find ( x , str [ i ] ) && ! find ( y1 , str [ i ] ) ) { ans += str [ i ] ; y1 . Add ( str [ i ] ) ; } else { ans += ( char ) z [ cc ] ; cc ++ ; } if ( cc == z . Count ) { for ( int j = i + 1 ; j < length ; j ++ ) ans += str [ j ] ; break ; } } Console . Write ( ans ) ; } } } public static void Main ( string [ ] args ) { string str = " ABCDEFGHI " ; addAllVowel ( str ) ; } }

Index/key variables: cc, i, j
Accumulator variables: ans, cc, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int [ , ] v , int n ) { int ans , ul , ll ; int first = 0 ; int second = 1 ; ll = v [ 0 , first ] ; ul = v [ 0 , second ] ; ans = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ( v [ i , first ] <= ul && v [ i , first ] >= ll ) || ( v [ i , second ] >= ll && v [ i , second ] <= ul ) ) { if ( v [ i , first ] > ll ) { ll = v [ i , first ] ; } if ( v [ i , second ] < ul ) { ul = v [ i , second ] ; } } else if ( v [ i , first ] > ul ) { ans += Math . Abs ( ul - v [ i , first ] ) ; ul = v [ i , first ] ; ll = v [ i , first ] ; } else if ( v [ i , second ] < ll ) { ans += Math . Abs ( ll - v [ i , second ] ) ; ul = v [ i , second ] ; ll = v [ i , second ] ; } } return ans ; } static void Main ( ) { int [ , ] v = new int [ 5 , 2 ] { { 1 , 3 } , { 2 , 5 } , { 6 , 8 } , { 1 , 2 } , { 2 , 3 } } ; int n = 5 ; Console . WriteLine ( solve ( v , n ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < String > preProcess ( int n ) { List < String > preProcessedCubes = new List < String > ( ) ; for ( int i = 1 ; i * i * i <= n ; i ++ ) { int iThCube = i * i * i ; String cubeString = String . Join ( " " , iThCube ) ; preProcessedCubes . Add ( cubeString ) ; } return preProcessedCubes ; } static String findLargestCubeUtil ( String num , List < String > preProcessedCubes ) { preProcessedCubes . Reverse ( ) ; int totalCubes = preProcessedCubes . Count ; for ( int i = 0 ; i < totalCubes ; i ++ ) { String currCube = preProcessedCubes [ i ] ; int digitsInCube = currCube . Length ; int index = 0 ; int digitsInNumber = num . Length ; for ( int j = 0 ; j < digitsInNumber ; j ++ ) { if ( num [ j ] == currCube [ index ] ) { index ++ ; } if ( digitsInCube == index ) { return currCube ; } } } return " Not ▁ Possible " ; } static void findLargestCube ( int n ) { List < String > preProcessedCubes = preProcess ( n ) ; String num = String . Join ( " " , n ) ; String ans = findLargestCubeUtil ( num , preProcessedCubes ) ; Console . WriteLine ( " Largest ▁ Cube ▁ that ▁ can ▁ be ▁ formed ▁ from ▁ " + n + " ▁ is ▁ " + ans ) ; } public static void Main ( String [ ] args ) { int n ; n = 4125 ; findLargestCube ( n ) ; n = 876 ; findLargestCube ( n ) ; } }

Index/key variables: i, index, j
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static int n , p ; static int [ ] rd = new int [ 1100 ] ; static int [ ] wt = new int [ 1100 ] ; static int [ ] cd = new int [ 1100 ] ; static List < int > a = new List < int > ( ) ; static List < int > b = new List < int > ( ) ; static List < int > c = new List < int > ( ) ; static int ans ; static int dfs ( int w ) { if ( cd [ w ] == 0 ) return w ; if ( wt [ w ] < ans ) ans = wt [ w ] ; return dfs ( cd [ w ] ) ; } static void solve ( int [ , ] arr ) { int i = 0 ; while ( i < p ) { int q = arr [ i , 0 ] ; int h = arr [ i , 1 ] ; int t = arr [ i , 2 ] ; cd [ q ] = h ; wt [ q ] = t ; rd [ h ] = q ; i ++ ; } a = new List < int > ( ) ; b = new List < int > ( ) ; c = new List < int > ( ) ; for ( int j = 1 ; j <= n ; ++ j ) if ( rd [ j ] == 0 && cd [ j ] > 0 ) { ans = 1000000000 ; int w = dfs ( j ) ; a . Add ( j ) ; b . Add ( w ) ; c . Add ( ans ) ; } Console . WriteLine ( a . Count ) ; for ( int j = 0 ; j < a . Count ; ++ j ) Console . WriteLine ( a [ j ] + " ▁ " + b [ j ] + " ▁ " + c [ j ] ) ; } for ( int i = 0 ; i < 1100 ; i ++ ) [ i ] = cd [ i ] = wt [ i ] = 0 ; int [ , ] arr = { { 7 , 4 , 98 } , { 5 , 9 , 72 } , { 4 , 6 , 10 } , { 2 , 8 , 22 } , { 9 , 7 , 17 } , { 3 , 1 , 66 } } ; solve ( arr ) ; } }

Index/key variables: h, i, j, q, w
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { public static String noAdjacentDup ( String s1 ) { int n = s1 . Length ; char [ ] s = s1 . ToCharArray ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == s [ i - 1 ] ) { s [ i ] = ' a ' ; while ( s [ i ] == s [ i - 1 ] || ( i + 1 < n && s [ i ] == s [ i + 1 ] ) ) s [ i ] ++ ; i ++ ; } } return ( new String ( s ) ) ; } public static void Main ( String [ ] argc ) { String s = " geeksforgeeks " ; Console . Write ( noAdjacentDup ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int winner ( int [ ] a , int n , int k ) { if ( k >= n - 1 ) return n ; int best = 0 , times = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > best ) { best = a [ i ] ; if ( i == 1 ) times = 1 ; } else times += 1 ; if ( times >= k ) return best ; } return best ; } public static void Main ( ) { int [ ] a = { 2 , 1 , 3 , 4 , 5 } ; int n = a . Length ; int k = 2 ; Console . WriteLine ( winner ( a , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, times
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void swap ( int a , int b ) { int temp = a ; a = b ; b = temp ; } static int minimumSquare ( int a , int b ) { int result = 0 , rem = 0 ; if ( a < b ) swap ( a , b ) ; while ( b > 0 ) { result += a / b ; rem = a % b ; a = b ; b = rem ; } return result ; } public static void Main ( String [ ] args ) { int n = 13 , m = 29 ; Console . WriteLine ( minimumSquare ( n , m ) ) ; } }

Accumulator variables: result
Class/struct names: GFG
C# program:
using System ; class GFG { static int totalValidArrays ( int [ ] a , int [ ] b , int N ) { int [ , ] dp = new int [ N + 1 , b [ N - 1 ] + 1 ] ; int [ , ] pref = new int [ N + 1 , b [ N - 1 ] + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) for ( int j = 0 ; j < b [ N - 1 ] + 1 ; j ++ ) dp [ i , j ] = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) for ( int j = 0 ; j < b [ N - 1 ] + 1 ; j ++ ) pref [ i , j ] = 0 ; dp [ 0 , 0 ] = 1 ; for ( int i = 0 ; i <= b [ N - 1 ] ; i ++ ) { pref [ 0 , i ] = 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = a [ i - 1 ] ; j <= b [ i - 1 ] ; j ++ ) { dp [ i , j ] += pref [ i - 1 , j ] ; pref [ i , j ] += dp [ i , j ] ; } for ( int j = 0 ; j <= b [ N - 1 ] ; j ++ ) { if ( j > 0 ) { pref [ i , j ] += pref [ i , j - 1 ] ; } } } int ans = 0 ; for ( int i = a [ N - 1 ] ; i <= b [ N - 1 ] ; i ++ ) { ans += dp [ N , i ] ; } return ans ; } public static void Main ( ) { int [ ] A = { 1 , 1 } ; int [ ] B = { 2 , 3 } ; int N = A . Length ; Console . WriteLine ( totalValidArrays ( A , B , N ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static string s ; static int [ , , , ] dp = new int [ 1024 , 10 , 2 , 2 ] ; static int calcCnt ( int mask , int len , int smaller , int started ) { if ( len == s . Length ) { if ( mask == 0 && started != 0 ) return 1 ; else return 0 ; } if ( dp [ mask , len , smaller , started ] != - 1 ) return dp [ mask , len , smaller , started ] ; int mx = 9 ; if ( smaller == 0 ) { mx = ( int ) s [ len ] - 48 ; } int ans = 0 ; if ( started != 0 ) { for ( int i = 0 ; i <= mx ; i ++ ) { ans += calcCnt ( mask ^ ( 1 << i ) , len + 1 , Convert . ToBoolean ( smaller ) || ( i < ( int ) s [ len ] - 48 ) ? 1 : 0 , 1 ) ; } } else { ans = calcCnt ( mask , len + 1 , 1 , 0 ) ; for ( int i = 1 ; i <= mx ; i ++ ) { ans += calcCnt ( mask ^ ( 1 << i ) , len + 1 , Convert . ToBoolean ( smaller ) || ( i < ( int ) s [ len ] - 48 ) ? 1 : 0 , 1 ) ; } } dp [ mask , len , smaller , started ] = ans ; return ans ; } static int countInt ( int x ) { for ( int i = 0 ; i < 1024 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { for ( int l = 0 ; l < 2 ; l ++ ) dp [ i , j , k , l ] = - 1 ; } } } s = x . ToString ( ) ; return calcCnt ( 0 , 0 , 0 , 0 ) ; } static int countIntInRange ( int L , int R ) { return countInt ( R ) - countInt ( L - 1 ) ; } public static void Main ( ) { int L = 32 , R = 1010 ; Console . Write ( countIntInRange ( L , R ) ) ; } }

Index/key variables: len
Accumulator variables: ans, i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Query { public int L , R ; public Query ( int l , int r ) { this . L = l ; this . R = r ; } } ; static int MAX = 5000 ; static void minDifference ( int [ ] arr , int n , Query [ ] q , int m ) { for ( int i = 0 ; i < m ; i ++ ) { int L = q [ i ] . L , R = q [ i ] . R ; int ans = MAX ; for ( int j = L ; j < R ; j ++ ) { ans = Math . Min ( ans , arr [ j ] ) ; } Console . WriteLine ( ans ) ; } } static void minimumDifference ( int [ ] arr , Query [ ] q , int N , int m ) { int [ ] diff = new int [ N ] ; for ( int i = 0 ; i < N - 1 ; i ++ ) diff [ i ] = Math . Abs ( arr [ i ] - arr [ i + 1 ] ) ; minDifference ( diff , N - 1 , q , m ) ; } public static void Main ( ) { int [ ] arr = { 2 , 6 , 1 , 8 , 3 , 4 } ; int N = arr . Length ; Query [ ] Q = { new Query ( 0 , 3 ) , new Query ( 1 , 5 ) , new Query ( 4 , 5 ) } ; int M = Q . Length ; minimumDifference ( arr , Q , N , M ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Query
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static int [ , ] dp = new int [ 100 , ( 1 << 4 ) ] ; public static Dictionary < int , int > primeIndex = new Dictionary < int , int > ( ) ; public static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } public static int countOfNumbers ( int index , int mask , int N ) { if ( index == N + 1 ) { int countOfPrimes = countSetBits ( mask ) ; if ( countOfPrimes == 4 ) { return 1 ; } return 0 ; } int val = dp [ index , mask ] ; if ( val != - 1 ) { return val ; } val = 0 ; if ( index == 1 ) { for ( int digit = ( N == 1 ? 0 : 1 ) ; digit <= 9 ; ++ digit ) { if ( primeIndex . ContainsKey ( digit ) ) { int newMask = mask | ( 1 << primeIndex [ digit ] ) ; val += countOfNumbers ( index + 1 , newMask , N ) ; } else { val += countOfNumbers ( index + 1 , mask , N ) ; } } } else { for ( int digit = 0 ; digit <= 9 ; ++ digit ) { if ( primeIndex . ContainsKey ( digit ) ) { int newMask = mask | ( 1 << primeIndex [ digit ] ) ; val += countOfNumbers ( index + 1 , newMask , N ) ; } else { val += countOfNumbers ( index + 1 , mask , N ) ; } } } return val ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < ( 1 << 4 ) ; j ++ ) { dp [ i , j ] = - 1 ; } } primeIndex . Add ( 2 , 0 ) ; primeIndex . Add ( 3 , 1 ) ; primeIndex . Add ( 5 , 2 ) ; primeIndex . Add ( 7 , 3 ) ; int N = 4 ; Console . WriteLine ( countOfNumbers ( 1 , 0 , N ) ) ; } }

Index/key variables: digit
Accumulator variables: count, i, j, val
Iterator variables: digit, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , , ] dp = new int [ 100 , 1 << 5 , 1 << 5 ] ; static int __builtin_popcount ( int n ) { int d , t = 0 ; while ( n > 0 ) { d = n % 2 ; n = n / 2 ; if ( d == 1 ) t ++ ; } return t ; } static int countOfNumbers ( int index , int evenMask , int oddMask , int N ) { if ( index == N + 1 ) { int countOfEvenDigits = __builtin_popcount ( evenMask ) ; int countOfOddDigits = __builtin_popcount ( oddMask ) ; if ( countOfOddDigits == countOfEvenDigits ) { return 1 ; } return 0 ; } int val = dp [ index , evenMask , oddMask ] ; if ( val != - 1 ) return val ; val = 0 ; if ( index == 1 ) { for ( int digit = ( N == 1 ? 0 : 1 ) ; digit <= 9 ; ++ digit ) { if ( ( digit & 1 ) != 0 ) { val += countOfNumbers ( index + 1 , evenMask , oddMask | ( 1 << ( digit / 2 ) ) , N ) ; } else { val += countOfNumbers ( index + 1 , evenMask | ( 1 << ( digit / 2 ) ) , oddMask , N ) ; } } } else { for ( int digit = 0 ; digit <= 9 ; ++ digit ) { if ( ( digit & 1 ) != 0 ) { val += countOfNumbers ( index + 1 , evenMask , oddMask | ( 1 << ( digit / 2 ) ) , N ) ; } else { val += countOfNumbers ( index + 1 , evenMask | ( 1 << ( digit / 2 ) ) , oddMask , N ) ; } } } return val ; } static void countNDigitNumber ( int N ) { for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < ( 1 << 5 ) ; j ++ ) { for ( int k = 0 ; k < ( 1 << 5 ) ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } Console . Write ( countOfNumbers ( 1 , 0 , 0 , N ) ) ; } public static void Main ( ) { int N = 3 ; countNDigitNumber ( N ) ; } }

Accumulator variables: i, j, k, t, val
Iterator variables: digit, i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int countMinSteps ( string A , string B , int N ) { int [ ] dp = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { dp [ i ] = 0 ; } for ( int i = 1 ; i <= N ; i ++ ) { if ( A [ i - 1 ] == B [ i - 1 ] ) { dp [ i ] = dp [ i - 1 ] ; } else { dp [ i ] = dp [ i - 1 ] + 1 ; } if ( i >= 2 && A [ i - 2 ] == B [ i - 1 ] && A [ i - 1 ] == B [ i - 2 ] ) { dp [ i ] = Math . Min ( dp [ i ] , dp [ i - 2 ] + 1 ) ; } } return dp [ N ] ; } public static void Main ( String [ ] args ) { string A = "0101" ; string B = "0011" ; int N = A . Length ; Console . Write ( countMinSteps ( A , B , N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int [ , , ] dp = new int [ 50 , 1 << 10 , 2 ] ; public static int countOfNumbers ( int digit , int mask , int repeated , int n ) { if ( digit == n + 1 ) { if ( repeated == 1 ) { return 1 ; } return 0 ; } if ( repeated == 1 ) { return ( int ) Math . Pow ( 10 , n - digit + 1 ) ; } int val = dp [ digit , mask , repeated ] ; if ( val != - 1 ) { return val ; } val = 0 ; if ( digit == 1 ) { for ( int i = ( n == 1 ? 0 : 1 ) ; i <= 9 ; ++ i ) { if ( ( mask & ( 1 << i ) ) > 0 ) { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 1 , n ) ; } else { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 0 , n ) ; } } } else { for ( int i = 0 ; i <= 9 ; ++ i ) { if ( ( mask & ( 1 << i ) ) > 0 ) { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 1 , n ) ; } else { val += countOfNumbers ( digit + 1 , mask | ( 1 << i ) , 0 , n ) ; } } } return val ; } public static void countNDigitNumber ( int N ) { for ( int i = 0 ; i < 50 ; i ++ ) { for ( int j = 0 ; j < 1 << 10 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } Console . Write ( countOfNumbers ( 1 , 0 , 0 , N ) ) ; } public static void Main ( ) { int N = 2 ; countNDigitNumber ( N ) ; } }

Accumulator variables: i, j, k, val
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static string getMaximum ( string S , string T ) { if ( S . IndexOf ( "0" ) > - 1 ) return T ; if ( T . IndexOf ( "0" ) > - 1 ) return S ; return ( S . Length > T . Length ? S : T ) ; } static string recursion ( int [ ] arr , int idx , int N , int K , List < List < string > > dp ) { if ( K == 0 ) { return " " ; } if ( K < 0 idx == N ) { return "0" ; } if ( dp [ idx ] [ K ] != " - 1" ) return dp [ idx ] [ K ] ; string include = ( idx + 1 ) . ToString ( ) + recursion ( arr , 0 , N , K - arr [ idx ] , dp ) ; string exclude = recursion ( arr , idx + 1 , N , K , dp ) ; return dp [ idx ] [ K ] = getMaximum ( include , exclude ) ; } static string largestNumber ( int [ ] arr , int N , int K ) { List < List < string > > dp = new List < List < string > > ( ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) { dp . Add ( new List < string > ( ) ) ; for ( int j = 0 ; j < K + 1 ; j ++ ) { dp [ i ] . Add ( " - 1" ) ; } } string ans = recursion ( arr , 0 , N , K , dp ) ; return ( ans == " " ? "0" : ans ) ; } static void Main ( ) { int [ ] arr = { 3 , 12 , 9 , 5 , 3 , 4 , 6 , 5 , 10 } ; int K = 14 ; int N = arr . Length ; Console . Write ( largestNumber ( arr , N , K ) ) ; } }

Index/key variables: K, i, idx
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] dp = new int [ 100 , 10 ] ; static int countOfNumbers ( int digit , int prev , int n ) { if ( digit == n + 1 ) { return 1 ; } int val = dp [ digit , prev ] ; if ( val != - 1 ) { return val ; } val = 0 ; if ( digit == 1 ) { for ( int i = ( n == 1 ? 0 : 1 ) ; i <= 9 ; ++ i ) { val += countOfNumbers ( digit + 1 , i , n ) ; } } else { for ( int i = 0 ; i <= 9 ; ++ i ) { if ( ( i & prev ) == 0 ) { val += countOfNumbers ( digit + 1 , i , n ) ; } } } return val ; } public static void Main ( string [ ] args ) { for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { dp [ i , j ] = - 1 ; } } int N = 3 ; Console . WriteLine ( countOfNumbers ( 1 , 0 , N ) ) ; } }

Accumulator variables: i, j, val
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static void preProcess ( int [ , ] mat , int [ , ] dp , int n , int m ) { for ( int i = 0 ; i < m ; i ++ ) { dp [ 0 , i ] = mat [ 0 , i ] ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { dp [ i , j ] = dp [ i - 1 , j ] + mat [ i , j ] ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j < m ; j ++ ) { dp [ i , j ] += dp [ i , j - 1 ] ; } } } static int sumQuery ( int [ , ] dp , int tli , int tlj , int rbi , int rbj ) { int res = dp [ rbi , rbj ] ; if ( tli > 0 ) res = res - dp [ tli - 1 , rbj ] ; if ( tlj > 0 ) res = res - dp [ rbi , tlj - 1 ] ; if ( tli > 0 && tlj > 0 ) res = res + dp [ tli - 1 , tlj - 1 ] ; return res ; } static int [ ] maxSubMatrixSumQueries ( int [ , ] mat , int n , int m , int [ , ] queries , int q ) { int [ , ] dp = new int [ n , m ] ; preProcess ( mat , dp , n , m ) ; int [ ] maxSum = new int [ queries . GetLength ( 0 ) ] ; for ( int qi = 0 ; qi < q ; qi ++ ) { for ( int i = 0 ; i < n - queries [ qi , 0 ] + 1 ; i ++ ) { for ( int j = 0 ; j < m - queries [ qi , 1 ] + 1 ; j ++ ) { maxSum [ qi ] = Math . Max ( maxSum [ qi ] , sumQuery ( dp , i , j , i + queries [ qi , 0 ] - 1 , j + queries [ qi , 1 ] - 1 ) ) ; } } } return maxSum ; } static public void Main ( ) { int n = 3 , m = 4 ; int [ , ] mat = { { 1 , 2 , 3 , 9 } , { 4 , 5 , 6 , 2 } , { 8 , 3 , 2 , 6 } } ; int Q = 3 ; int [ , ] Queries = { { 1 , 1 } , { 2 , 2 } , { 3 , 3 } } ; int [ ] maxSum = maxSubMatrixSumQueries ( mat , n , m , Queries , Q ) ; for ( int i = 0 ; i < Q ; i ++ ) { Console . Write ( maxSum [ i ] + " ▁ " ) ; } } }

Index/key variables: i, qi
Accumulator variables: i, j, qi
Iterator variables: i, j, qi
Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ , ] dp = new int [ 1005 , 1005 ] ; static int KvisibleFromLeft ( int N , int K ) { if ( dp [ N , K ] != - 1 ) return dp [ N , K ] ; if ( N == K ) return dp [ N , K ] = 1 ; if ( K == 1 ) { int ans = 1 ; for ( int i = 1 ; i < N ; i ++ ) ans *= i ; return dp [ N , K ] = ans ; } return dp [ N , K ] = KvisibleFromLeft ( N - 1 , K - 1 ) + ( N - 1 ) * KvisibleFromLeft ( N - 1 , K ) ; } public static void Main ( String [ ] args ) { int N = 5 , K = 2 ; for ( int i = 0 ; i < 1005 ; i ++ ) { for ( int j = 0 ; j < 1005 ; j ++ ) { dp [ i , j ] = - 1 ; } } Console . Write ( KvisibleFromLeft ( N , K ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } static int kvowelwords ( int N , int K ) { int i , j ; int MOD = 1000000007 ; int [ , ] dp = new int [ N + 1 , K + 1 ] ; int sum = 1 ; for ( i = 1 ; i <= N ; i ++ ) { dp [ i , 0 ] = sum * 21 ; dp [ i , 0 ] %= MOD ; sum = dp [ i , 0 ] ; for ( j = 1 ; j <= K ; j ++ ) { if ( j > i ) dp [ i , j ] = 0 ; else if ( j == i ) { dp [ i , j ] = power ( 5 , i , MOD ) ; } else { dp [ i , j ] = dp [ i - 1 , j - 1 ] * 5 ; } dp [ i , j ] %= MOD ; sum += dp [ i , j ] ; sum %= MOD ; } } return sum ; } public static void Main ( ) { int N = 3 ; int K = 3 ; Console . Write ( kvowelwords ( N , K ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maxBoundary ( int N , List < Tuple < int , int > > V ) { int [ , ] dp = new int [ N , 2 ] ; dp [ 0 , 0 ] = V [ 0 ] . Item1 ; dp [ 0 , 1 ] = V [ 0 ] . Item2 ; for ( int i = 1 ; i < N ; i ++ ) { dp [ i , 0 ] = V [ i ] . Item1 ; int height1 = Math . Abs ( V [ i - 1 ] . Item2 - V [ i ] . Item2 ) ; int height2 = Math . Abs ( V [ i - 1 ] . Item1 - V [ i ] . Item2 ) ; dp [ i , 0 ] += Math . Max ( height1 + dp [ i - 1 , 0 ] , height2 + dp [ i - 1 , 1 ] ) ; dp [ i , 1 ] = V [ i ] . Item2 ; int vertical1 = Math . Abs ( V [ i ] . Item1 - V [ i - 1 ] . Item2 ) ; int vertical2 = Math . Abs ( V [ i ] . Item1 - V [ i - 1 ] . Item1 ) ; dp [ i , 1 ] += Math . Max ( vertical1 + dp [ i - 1 , 0 ] , vertical2 + dp [ i - 1 , 1 ] ) ; } Console . WriteLine ( Math . Max ( dp [ N - 1 , 0 ] , dp [ N - 1 , 1 ] ) ) ; } static void Main ( ) { int N = 5 ; List < Tuple < int , int > > V = new List < Tuple < int , int > > ( ) ; V . Add ( new Tuple < int , int > ( 2 , 5 ) ) ; V . Add ( new Tuple < int , int > ( 3 , 8 ) ) ; V . Add ( new Tuple < int , int > ( 1 , 10 ) ) ; V . Add ( new Tuple < int , int > ( 7 , 14 ) ) ; V . Add ( new Tuple < int , int > ( 2 , 5 ) ) ; maxBoundary ( N , V ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findNthNum ( int N ) { int a = 0 , b , left ; int right , mid ; int t ; left = 1 ; right = N ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; t = ( mid * ( mid + 1 ) ) / 2 ; if ( t < N ) { left = mid + 1 ; } else if ( t == N ) { a = mid ; break ; } else { a = mid ; right = mid - 1 ; } } t = a - 1 ; b = N - ( t * ( t + 1 ) ) / 2 - 1 ; Console . Write ( ( 1 << a ) + ( 1 << b ) ) ; } public static void Main ( ) { int N = 15 ; findNthNum ( N ) ; } }

Class/struct names: GFG