dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MaxXOR ( int [ ] arr , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { res |= arr [ i ] ; } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 7 } ; int N = arr . Length ; Console . Write ( MaxXOR ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countEqual ( int [ ] A , int [ ] B , int N ) { int first = 0 ; int second = N - 1 ; int count = 0 ; while ( first < N && second >= 0 ) { if ( A [ first ] < B [ second ] ) { first ++ ; } else if ( B [ second ] < A [ first ] ) { second -- ; } else { count ++ ; first ++ ; second -- ; } } return count ; } static void Main ( ) { int [ ] A = { 2 , 4 , 5 , 8 , 12 , 13 , 17 , 18 , 20 , 22 , 309 , 999 } ; int [ ] B = { 109 , 99 , 68 , 54 , 22 , 19 , 17 , 13 , 11 , 5 , 3 , 1 } ; int N = A . Length ; Console . WriteLine ( countEqual ( A , B , N ) ) ; } }

Index/key variables: first, second
Accumulator variables: count, first, second
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = new int [ 100005 ] ; static bool isPalindrome ( int N ) { int temp = N ; int res = 0 ; while ( temp != 0 ) { int rem = temp % 10 ; res = res * 10 + rem ; temp /= 10 ; } if ( res == N ) { return true ; } else { return false ; } } static int sumOfDigits ( int N ) { int sum = 0 ; while ( N != 0 ) { sum += N % 10 ; N /= 10 ; } return sum ; } static bool isPrime ( int n ) { if ( n <= 1 ) { return false ; } for ( int i = 2 ; i <= n / 2 ; ++ i ) { if ( n % i == 0 ) return false ; } return true ; } static void precompute ( ) { for ( int i = 1 ; i <= 100000 ; i ++ ) { if ( isPalindrome ( i ) ) { int sum = sumOfDigits ( i ) ; if ( isPrime ( sum ) ) arr [ i ] = 1 ; else arr [ i ] = 0 ; } else arr [ i ] = 0 ; } for ( int i = 1 ; i <= 100000 ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; } } static void countNumbers ( int [ , ] Q , int N ) { precompute ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Console . WriteLine ( ( arr [ Q [ i , 1 ] ] - arr [ Q [ i , 0 ] - 1 ] ) ) ; } } static public void Main ( ) { int [ , ] Q = { { 5 , 9 } , { 1 , 101 } } ; int N = Q . GetLength ( 0 ) ; countNumbers ( Q , N ) ; } }

Index/key variables: i
Accumulator variables: N, i, sum, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sum ( int n ) { int res = 0 ; while ( n > 0 ) { res += n % 10 ; n /= 10 ; } return res ; } static int smallestNumber ( int n , int s ) { if ( sum ( n ) <= s ) { return n ; } int ans = n , k = 1 ; for ( int i = 0 ; i < 9 ; ++ i ) { int digit = ( ans / k ) % 10 ; int add = k * ( ( 10 - digit ) % 10 ) ; ans += add ; if ( sum ( ans ) <= s ) { break ; } k *= 10 ; } return ans ; } public static void Main ( ) { int N = 3 , S = 2 ; Console . WriteLine ( smallestNumber ( N , S ) ) ; } }

Accumulator variables: ans, k, n, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxSubsequences ( int [ ] arr , int n ) { Dictionary < int , int > map = new Dictionary < int , int > ( ) ; int maxCount = 0 ; int count ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . ContainsKey ( arr [ i ] ) ) { count = map [ arr [ i ] ] ; if ( count > 1 ) { map . Add ( arr [ i ] , count - 1 ) ; } else map . Remove ( arr [ i ] ) ; if ( arr [ i ] - 1 > 0 ) if ( map . ContainsKey ( arr [ i ] - 1 ) ) map [ arr [ i ] - 1 ] ++ ; else map . Add ( arr [ i ] - 1 , 1 ) ; } else { maxCount ++ ; if ( arr [ i ] - 1 > 0 ) if ( map . ContainsKey ( arr [ i ] - 1 ) ) map [ arr [ i ] - 1 ] ++ ; else map . Add ( arr [ i ] - 1 , 1 ) ; } } return maxCount ; } public static void Main ( String [ ] args ) { int n = 5 ; int [ ] arr = { 4 , 5 , 2 , 1 , 4 } ; Console . WriteLine ( maxSubsequences ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, maxCount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String removeOcc ( String s , char ch ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == ch ) { s = s . Substring ( 0 , i ) + s . Substring ( i + 1 ) ; break ; } } for ( int i = s . Length - 1 ; i > - 1 ; i -- ) { if ( s [ i ] == ch ) { s = s . Substring ( 0 , i ) + s . Substring ( i + 1 ) ; break ; } } return s ; } public static void Main ( String [ ] args ) { String s = " hello ▁ world " ; char ch = ' l ' ; Console . Write ( removeOcc ( s , ch ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void minSteps ( int N , int [ ] increasing , int [ ] decreasing ) { int min = int . MaxValue ; foreach ( int i in increasing ) { if ( min > i ) min = i ; } int max = int . MinValue ; foreach ( int i in decreasing ) { if ( max < i ) max = i ; } int minSteps = Math . Max ( max , N - min ) ; Console . WriteLine ( minSteps ) ; } public static void Main ( String [ ] args ) { int N = 7 ; int [ ] increasing = { 3 , 5 } ; int [ ] decreasing = { 6 } ; minSteps ( N , increasing , decreasing ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( int [ ] P , int n ) { int [ ] arr = new int [ n + 1 ] ; arr [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) arr [ i + 1 ] = P [ i ] ; int cnt = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == i ) { int t = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ i ] ; arr [ i ] = t ; cnt ++ ; } } if ( arr [ n ] == n ) { int t = arr [ n - 1 ] ; arr [ n - 1 ] = arr [ n ] ; arr [ n ] = t ; cnt ++ ; } Console . WriteLine ( cnt ) ; } public static void Main ( String [ ] args ) { int N = 9 ; int [ ] P = { 1 , 2 , 4 , 9 , 5 , 8 , 7 , 3 , 6 } ; solve ( P , N ) ; } }

Index/key variables: i, n
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void SieveOfEratosthenes ( int n , HashSet < int > allPrimes ) { bool [ ] prime = new bool [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) allPrimes . Add ( p ) ; } static int countInterestingPrimes ( int n ) { HashSet < int > allPrimes = new HashSet < int > ( ) ; SieveOfEratosthenes ( n , allPrimes ) ; HashSet < int > intersetingPrimes = new HashSet < int > ( ) ; List < int > squares = new List < int > ( ) , quadruples = new List < int > ( ) ; for ( int i = 1 ; i * i <= n ; i ++ ) { squares . Add ( i * i ) ; } for ( int i = 1 ; i * i * i * i <= n ; i ++ ) { quadruples . Add ( i * i * i * i ) ; } foreach ( int a in squares ) { foreach ( int b in quadruples ) { if ( allPrimes . Contains ( a + b ) ) intersetingPrimes . Add ( a + b ) ; } } return intersetingPrimes . Count ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . Write ( countInterestingPrimes ( N ) ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: a, b, i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isWaveArray ( int [ ] arr , int n ) { bool result = true ; if ( arr [ 1 ] > arr [ 0 ] && arr [ 1 ] > arr [ 2 ] ) { for ( int i = 1 ; i < n - 1 ; i += 2 ) { if ( arr [ i ] > arr [ i - 1 ] && arr [ i ] > arr [ i + 1 ] ) { result = true ; } else { result = false ; break ; } } if ( result == true && n % 2 == 0 ) { if ( arr [ n - 1 ] <= arr [ n - 2 ] ) { result = false ; } } } else if ( arr [ 1 ] < arr [ 0 ] && arr [ 1 ] < arr [ 2 ] ) { for ( int i = 1 ; i < n - 1 ; i += 2 ) { if ( arr [ i ] < arr [ i - 1 ] && arr [ i ] < arr [ i + 1 ] ) { result = true ; } else { result = false ; break ; } } if ( result == true && n % 2 == 0 ) { if ( arr [ n - 1 ] >= arr [ n - 2 ] ) { result = false ; } } } return result ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 4 } ; int n = arr . Length ; if ( isWaveArray ( arr , n ) ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: result
Class/struct names: GFG
C# program:
using System ; class GFG { static void countPossiblities ( int [ ] arr , int n ) { int [ ] lastOccur = new int [ 100000 ] ; for ( int i = 0 ; i < n ; i ++ ) { lastOccur [ i ] = - 1 ; } int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { int curEle = arr [ i - 1 ] ; dp [ i ] = dp [ i - 1 ] ; if ( lastOccur [ curEle ] != - 1 & lastOccur [ curEle ] < i - 1 ) { dp [ i ] += dp [ lastOccur [ curEle ] ] ; } lastOccur [ curEle ] = i ; } Console . WriteLine ( dp [ n ] ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 1 , 2 , 2 } ; int N = arr . Length ; countPossiblities ( arr , N ) ; } }

Index/key variables: curEle, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxSum ( int [ , ] arr , int n , int m ) { int [ , ] dp = new int [ n , m + 1 ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { dp [ i , j ] = 0 ; } } dp [ 0 , m - 1 ] = arr [ 0 , m - 1 ] ; dp [ 1 , m - 1 ] = arr [ 1 , m - 1 ] ; for ( int j = m - 2 ; j >= 0 ; j -- ) { for ( int i = 0 ; i < 2 ; i ++ ) { if ( i == 1 ) { dp [ i , j ] = Math . Max ( arr [ i , j ] + dp [ 0 , j + 1 ] , arr [ i , j ] + dp [ 0 , j + 2 ] ) ; } else { dp [ i , j ] = Math . Max ( arr [ i , j ] + dp [ 1 , j + 1 ] , arr [ i , j ] + dp [ 1 , j + 2 ] ) ; } } } Console . WriteLine ( Math . Max ( dp [ 0 , 0 ] , dp [ 1 , 0 ] ) ) ; } public static void Main ( ) { int [ , ] arr = { { 1 , 50 , 21 , 5 } , { 2 , 10 , 10 , 5 } } ; int N = arr . GetLength ( 1 ) ; maxSum ( arr , 2 , N ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxSum ( int [ , ] arr , int n ) { int r1 = 0 , r2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = r1 ; r1 = Math . Max ( r1 , r2 + arr [ 0 , i ] ) ; r2 = Math . Max ( r2 , temp + arr [ 1 , i ] ) ; } Console . WriteLine ( Math . Max ( r1 , r2 ) ) ; } public static void Main ( ) { int [ , ] arr = { { 1 , 50 , 21 , 5 } , { 2 , 10 , 10 , 5 } } ; int n = arr . GetLength ( 1 ) ; maxSum ( arr , n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int mod = ( int ) ( 1e9 + 7 ) ; static int mx = ( int ) 1e6 ; static int [ ] fact = new int [ ( int ) mx + 1 ] ; static void Calculate_factorial ( ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i <= mx ; i ++ ) { fact [ i ] = i * fact [ i - 1 ] ; fact [ i ] %= mod ; } } static int UniModal_per ( int a , int b ) { int res = 1 ; while ( b > 0 ) { if ( b % 2 != 0 ) res = res * a ; res %= mod ; a = a * a ; a %= mod ; b /= 2 ; } return res ; } static void countPermutations ( int n ) { Calculate_factorial ( ) ; int uni_modal = UniModal_per ( 2 , n - 1 ) ; int nonuni_modal = fact [ n ] - uni_modal ; Console . Write ( uni_modal + " ▁ " + nonuni_modal ) ; return ; } public static void Main ( String [ ] args ) { int N = 4 ; countPermutations ( N ) ; } }

Index/key variables: i, n
Accumulator variables: b, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void longestSubseq ( String s , int length ) { int [ ] ones = new int [ length + 1 ] ; int [ ] zeroes = new int [ length + 1 ] ; for ( int i = 0 ; i < length ; i ++ ) { if ( s [ i ] == '1' ) { ones [ i + 1 ] = ones [ i ] + 1 ; zeroes [ i + 1 ] = zeroes [ i ] ; } else { zeroes [ i + 1 ] = zeroes [ i ] + 1 ; ones [ i + 1 ] = ones [ i ] ; } } int answer = int . MinValue ; int x = 0 ; for ( int i = 0 ; i <= length ; i ++ ) { for ( int j = i ; j <= length ; j ++ ) { x += ones [ i ] ; x += ( zeroes [ j ] - zeroes [ i ] ) ; x += ( ones [ length ] - ones [ j ] ) ; answer = Math . Max ( answer , x ) ; x = 0 ; } } Console . WriteLine ( answer ) ; } public static void Main ( String [ ] args ) { String s = "10010010111100101" ; int length = s . Length ; longestSubseq ( s , length ) ; } }

Index/key variables: i, j, length
Accumulator variables: i, j, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void largestSquare ( int [ , ] matrix , int R , int C , int [ ] q_i , int [ ] q_j , int K , int Q ) { for ( int q = 0 ; q < Q ; q ++ ) { int i = q_i [ q ] ; int j = q_j [ q ] ; int min_dist = Math . Min ( Math . Min ( i , j ) , Math . Min ( R - i - 1 , C - j - 1 ) ) ; int ans = - 1 ; for ( int k = 0 ; k <= min_dist ; k ++ ) { int count = 0 ; for ( int row = i - k ; row <= i + k ; row ++ ) for ( int col = j - k ; col <= j + k ; col ++ ) count += matrix [ row , col ] ; if ( count > K ) break ; ans = 2 * k + 1 ; } Console . Write ( ans + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ , ] matrix = { { 1 , 0 , 1 , 0 , 0 } , { 1 , 0 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 0 , 0 , 1 , 0 } } ; int K = 9 , Q = 1 ; int [ ] q_i = { 1 } ; int [ ] q_j = { 2 } ; largestSquare ( matrix , 4 , 5 , q_i , q_j , K , Q ) ; } }

Index/key variables: q
Accumulator variables: col, count, k, q, row
Iterator variables: col, k, q, row
Class/struct names: GFG
C# program:
using System ; class GFG { static void largestSquare ( int [ , ] matrix , int R , int C , int [ ] q_i , int [ ] q_j , int K , int Q ) { int [ , ] countDP = new int [ R , C ] ; countDP [ 0 , 0 ] = matrix [ 0 , 0 ] ; for ( int i = 1 ; i < R ; i ++ ) countDP [ i , 0 ] = countDP [ i - 1 , 0 ] + matrix [ i , 0 ] ; for ( int j = 1 ; j < C ; j ++ ) countDP [ 0 , j ] = countDP [ 0 , j - 1 ] + matrix [ 0 , j ] ; for ( int i = 1 ; i < R ; i ++ ) for ( int j = 1 ; j < C ; j ++ ) countDP [ i , j ] = matrix [ i , j ] + countDP [ i - 1 , j ] + countDP [ i , j - 1 ] - countDP [ i - 1 , j - 1 ] ; for ( int q = 0 ; q < Q ; q ++ ) { int i = q_i [ q ] ; int j = q_j [ q ] ; int min_dist = Math . Min ( Math . Min ( i , j ) , Math . Min ( R - i - 1 , C - j - 1 ) ) ; int ans = - 1 ; for ( int k = 0 ; k <= min_dist ; k ++ ) { int x1 = i - k , x2 = i + k ; int y1 = j - k , y2 = j + k ; int count = countDP [ x2 , y2 ] ; if ( x1 > 0 ) count -= countDP [ x1 - 1 , y2 ] ; if ( y1 > 0 ) count -= countDP [ x2 , y1 - 1 ] ; if ( x1 > 0 && y1 > 0 ) count += countDP [ x1 - 1 , y1 - 1 ] ; if ( count > K ) break ; ans = 2 * k + 1 ; } Console . Write ( ans + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ , ] matrix = { { 1 , 0 , 1 , 0 , 0 } , { 1 , 0 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 0 , 0 , 1 , 0 } } ; int K = 9 , Q = 1 ; int [ ] q_i = { 1 } ; int [ ] q_j = { 2 } ; largestSquare ( matrix , 4 , 5 , q_i , q_j , K , Q ) ; } }

Index/key variables: q
Accumulator variables: count, i, j, k, q
Iterator variables: i, j, k, q
Class/struct names: GFG
C# program:
using System ; class GFG { static int MinCost ( int [ ] arr , int n ) { int [ , ] dp = new int [ n + 5 , n + 5 ] ; int [ , ] sum = new int [ n + 5 , n + 5 ] ; for ( int i = 0 ; i < n ; i ++ ) { int k = arr [ i ] ; for ( int j = i ; j < n ; j ++ ) { if ( i == j ) sum [ i , j ] = k ; else { k += arr [ j ] ; sum [ i , j ] = k ; } } } for ( int i = n - 1 ; i >= 0 ; i -- ) { for ( int j = i ; j < n ; j ++ ) { dp [ i , j ] = int . MaxValue ; if ( i == j ) dp [ i , j ] = 0 ; else { for ( int k = i ; k < j ; k ++ ) { dp [ i , j ] = Math . Min ( dp [ i , j ] , dp [ i , k ] + dp [ k + 1 , j ] + sum [ i , j ] ) ; } } } } return dp [ 0 , n - 1 ] ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 6 , 8 , 6 , 1 , 1 } ; int n = arr . Length ; Console . WriteLine ( MinCost ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int f ( int i , int state , int [ ] A , int [ , ] dp , int N ) { if ( i >= N ) return 0 ; else if ( dp [ i , state ] != - 1 ) { return dp [ i , state ] ; } else { if ( i == N - 1 ) dp [ i , state ] = 1 ; else if ( state == 1 && A [ i ] > A [ i + 1 ] ) dp [ i , state ] = 1 ; else if ( state == 2 && A [ i ] < A [ i + 1 ] ) dp [ i , state ] = 1 ; else if ( state == 1 && A [ i ] <= A [ i + 1 ] ) dp [ i , state ] = 1 + f ( i + 1 , 2 , A , dp , N ) ; else if ( state == 2 && A [ i ] >= A [ i + 1 ] ) dp [ i , state ] = 1 + f ( i + 1 , 1 , A , dp , N ) ; return dp [ i , state ] ; } } static int maxLenSeq ( int [ ] A , int N ) { int i , j , tmp , y , ans ; int [ , ] dp = new int [ 1000 , 3 ] ; for ( i = 0 ; i < 1000 ; i ++ ) for ( j = 0 ; j < 3 ; j ++ ) dp [ i , j ] = - 1 ; for ( i = 0 ; i < N ; i ++ ) { tmp = f ( i , 1 , A , dp , N ) ; tmp = f ( i , 2 , A , dp , N ) ; } ans = - 1 ; for ( i = 0 ; i < N ; i ++ ) { y = dp [ i , 1 ] ; if ( i + y >= N ) ans = Math . Max ( ans , dp [ i , 1 ] + 1 ) ; else if ( y % 2 == 0 ) { ans = Math . Max ( ans , dp [ i , 1 ] + 1 + dp [ i + y , 2 ] ) ; } else if ( y % 2 == 1 ) { ans = Math . Max ( ans , dp [ i , 1 ] + 1 + dp [ i + y , 1 ] ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 10 , 3 , 20 , 25 , 24 } ; int n = A . Length ; Console . WriteLine ( maxLenSeq ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int MaxGCD ( int [ ] a , int n ) { int [ ] Prefix = new int [ n + 2 ] ; int [ ] Suffix = new int [ n + 2 ] ; Prefix [ 1 ] = a [ 0 ] ; for ( int i = 2 ; i <= n ; i += 1 ) { Prefix [ i ] = gcd ( Prefix [ i - 1 ] , a [ i - 1 ] ) ; } Suffix [ n ] = a [ n - 1 ] ; for ( int i = n - 1 ; i >= 1 ; i -= 1 ) { Suffix [ i ] = gcd ( Suffix [ i + 1 ] , a [ i - 1 ] ) ; } int ans = Math . Max ( Suffix [ 2 ] , Prefix [ n - 1 ] ) ; for ( int i = 2 ; i < n ; i += 1 ) { ans = Math . Max ( ans , gcd ( Prefix [ i - 1 ] , Suffix [ i + 1 ] ) ) ; } return ans ; } static public void Main ( ) { int [ ] a = { 14 , 17 , 28 , 70 } ; int n = a . Length ; Console . Write ( MaxGCD ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int right = 2 ; static int left = 4 ; static int [ , ] dp = new int [ left + 1 , right + 1 ] ; static int findSubarraySum ( int ind , int flips , int n , int [ ] a , int k ) { if ( flips > k ) return - ( int ) 1e9 ; if ( ind == n ) return 0 ; if ( dp [ ind , flips ] != - 1 ) return dp [ ind , flips ] ; int ans = 0 ; ans = Math . Max ( 0 , a [ ind ] + findSubarraySum ( ind + 1 , flips , n , a , k ) ) ; ans = Math . Max ( ans , - a [ ind ] + findSubarraySum ( ind + 1 , flips + 1 , n , a , k ) ) ; return dp [ ind , flips ] = ans ; } static int findMaxSubarraySum ( int [ ] a , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < k + 1 ; j ++ ) dp [ i , j ] = - 1 ; int ans = - ( int ) 1e9 ; for ( int i = 0 ; i < n ; i ++ ) ans = Math . Max ( ans , findSubarraySum ( i , 0 , n , a , k ) ) ; if ( ans == 0 && k == 0 ) return a . Max ( ) ; return ans ; } static void Main ( ) { int [ ] a = { - 1 , - 2 , - 100 , - 10 } ; int n = a . Length ; int k = 1 ; Console . WriteLine ( findMaxSubarraySum ( a , n , k ) ) ; } }

Index/key variables: ind
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int mod = 1000000007 ; static int sumOddFibonacci ( int n ) { int [ ] Sum = new int [ n + 1 ] ; Sum [ 0 ] = 0 ; Sum [ 1 ] = 1 ; Sum [ 2 ] = 2 ; Sum [ 3 ] = 5 ; Sum [ 4 ] = 10 ; Sum [ 5 ] = 23 ; for ( int i = 6 ; i <= n ; i ++ ) { Sum [ i ] = ( ( Sum [ i - 1 ] + ( 4 * Sum [ i - 2 ] ) % mod - ( 4 * Sum [ i - 3 ] ) % mod + mod ) % mod + ( Sum [ i - 4 ] - Sum [ i - 5 ] + mod ) % mod ) % mod ; } return Sum [ n ] ; } static public void Main ( ) { int n = 6 ; Console . WriteLine ( sumOddFibonacci ( n ) ) ; }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static long fun ( int [ ] marks , int n ) { long [ ] dp = new long [ n ] ; long temp ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( marks [ i ] > marks [ i + 1 ] ) { temp = i ; while ( true ) { if ( ( marks [ temp ] > marks [ temp + 1 ] ) && temp >= 0 ) { if ( dp [ temp ] > dp [ temp + 1 ] ) { temp -= 1 ; continue ; } else { dp [ temp ] = dp [ temp + 1 ] + 1 ; temp -= 1 ; } } else break ; } } else if ( marks [ i ] < marks [ i + 1 ] ) dp [ i + 1 ] = dp [ i ] + 1 ; } long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += dp [ i ] ; return sum ; } static void Main ( ) { int n = 6 ; int [ ] marks = new int [ ] { 1 , 4 , 5 , 2 , 2 , 1 } ; Console . Write ( fun ( marks , n ) ) ; } }

Index/key variables: i, n, temp
Accumulator variables: i, sum, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int N , int K ) { int [ ] combo ; combo = new int [ 50 ] ; combo [ 0 ] = 1 ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 0 ; j <= N ; j ++ ) { if ( j >= i ) { combo [ j ] += combo [ j - i ] ; } } } return combo [ N ] ; } public static void Main ( ) { int N = 29 ; int K = 5 ; Console . WriteLine ( solve ( N , K ) ) ; solve ( N , K ) ; } }

Index/key variables: N, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Test { static int computeLIS ( int [ ] circBuff , int start , int end , int n ) { int [ ] LIS = new int [ n + end - start ] ; for ( int i = start ; i < end ; i ++ ) LIS [ i ] = 1 ; for ( int i = start + 1 ; i < end ; i ++ ) for ( int j = start ; j < i ; j ++ ) if ( circBuff [ i ] > circBuff [ j ] && LIS [ i ] < LIS [ j ] + 1 ) LIS [ i ] = LIS [ j ] + 1 ; int res = int . MinValue ; for ( int i = start ; i < end ; i ++ ) res = Math . Max ( res , LIS [ i ] ) ; return res ; } static int LICS ( int [ ] arr , int n ) { int [ ] circBuff = new int [ 2 * n ] ; for ( int i = 0 ; i < n ; i ++ ) circBuff [ i ] = arr [ i ] ; for ( int i = n ; i < 2 * n ; i ++ ) circBuff [ i ] = arr [ i - n ] ; int res = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) res = Math . Max ( computeLIS ( circBuff , i , i + n , n ) , res ) ; return res ; } public static void Main ( ) { int [ ] arr = { 1 , 4 , 6 , 2 , 3 } ; Console . Write ( " Length ▁ of ▁ LICS ▁ is ▁ " + LICS ( arr , arr . Length ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Test
C# program:
using System ; class GFG { static int binomialCoeff ( int n , int k ) { int [ ] C = new int [ k + 1 ] ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . Min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } static void Main ( ) { int n = 3 , m = 2 ; Console . WriteLine ( " Number ▁ of ▁ Paths : ▁ " + binomialCoeff ( n + m , n ) ) ; } }

Index/key variables: j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int LCIS ( int [ ] arr1 , int n , int [ ] arr2 , int m ) { int [ ] table = new int [ m ] ; for ( int j = 0 ; j < m ; j ++ ) table [ j ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int current = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( arr1 [ i ] == arr2 [ j ] ) if ( current + 1 > table [ j ] ) table [ j ] = current + 1 ; if ( arr1 [ i ] > arr2 [ j ] ) if ( table [ j ] > current ) current = table [ j ] ; } } int result = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( table [ i ] > result ) result = table [ i ] ; return result ; } public static void Main ( ) { int [ ] arr1 = { 3 , 4 , 9 , 1 } ; int [ ] arr2 = { 5 , 3 , 8 , 9 , 10 , 2 , 1 } ; int n = arr1 . Length ; int m = arr2 . Length ; Console . Write ( " Length ▁ of ▁ LCIS ▁ is ▁ " + LCIS ( arr1 , n , arr2 , m ) ) ; } }

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