dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int createPalindrome ( int input , int isOdd ) { int n = input ; int palin = input ; if ( isOdd % 2 == 1 ) { n /= 10 ; } while ( n > 0 ) { palin = palin * 10 + ( n % 10 ) ; n /= 10 ; } return palin ; } static List < int > generatePalindromes ( int N ) { List < int > palindromes = new List < int > ( ) ; int number ; for ( int j = 0 ; j < 2 ; j ++ ) { int i = 1 ; while ( ( number = createPalindrome ( i ++ , j ) ) <= N ) { palindromes . Add ( number ) ; } } return palindromes ; } static String reverse ( String input ) { char [ ] temparray = input . ToCharArray ( ) ; int left , right = 0 ; right = temparray . Length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . Join ( " " , temparray ) ; } static int minimumNoOfPalindromes ( int N ) { String a = String . Join ( " " , N ) ; String b = String . Join ( " " , N ) ; b = reverse ( b ) ; if ( a . Equals ( b ) ) { return 1 ; } List < int > palindromes = generatePalindromes ( N ) ; palindromes . Sort ( ) ; int l = 0 , r = palindromes . Count - 1 ; while ( l < r ) { if ( palindromes [ l ] + palindromes [ r ] == N ) { return 2 ; } else if ( palindromes [ l ] + palindromes [ r ] < N ) { ++ l ; } else { -- r ; } } return 3 ; } public static void Main ( String [ ] args ) { int N = 65 ; Console . WriteLine ( minimumNoOfPalindromes ( N ) ) ; } }

Index/key variables: l, left, r, right
Accumulator variables: i, j, left, n, right
Iterator variables: j, left
Class/struct names: GFG
C# program:
using System ; public class GFG { static int lcs ( int [ , ] dp , String a , String b , int m , int n ) { for ( int i = 0 ; i < 100 ; i ++ ) for ( int j = 0 ; j < 100 ; j ++ ) dp [ i , j ] = - 1 ; if ( m < 0 n < 0 ) { return 0 ; } if ( dp [ m , n ] != - 1 ) return dp [ m , n ] ; int ans = 0 ; if ( a [ m ] == b [ n ] ) { ans = ( a [ m ] - 48 ) + lcs ( dp , a , b , m - 1 , n - 1 ) ; } else ans = Math . Max ( lcs ( dp , a , b , m - 1 , n ) , lcs ( dp , a , b , m , n - 1 ) ) ; dp [ m , n ] = ans ; return ans ; } static int costOfString ( String str ) { int cost = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) cost += ( str [ i ] - 48 ) ; return cost ; } public static void Main ( ) { String a , b ; a = "9142" ; b = "1429" ; int [ , ] dp = new int [ 101 , 101 ] ; Console . Write ( ( costOfString ( a ) + costOfString ( b ) - 2 * lcs ( dp , a , b , a . Length - 1 , b . Length - 1 ) ) ) ; } }

Index/key variables: i, m, n
Accumulator variables: cost, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int maxSubArraySum ( int [ ] arr , int size ) { int max_so_far = arr [ 0 ] ; int curr_max = arr [ 0 ] ; for ( int i = 1 ; i < size ; i ++ ) { curr_max = Math . Max ( arr [ i ] , curr_max + arr [ i ] ) ; max_so_far = Math . Max ( max_so_far , curr_max ) ; } return max_so_far ; } static int lenOfLongSubarrWithGivenSum ( int [ ] arr , int n , int k ) { Dictionary < int , int > um = new Dictionary < int , int > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum == k ) maxLen = i + 1 ; if ( um . ContainsKey ( sum ) ) um . Add ( sum , i ) ; if ( um . ContainsKey ( sum - k ) ) { if ( maxLen < ( i - um [ sum - k ] ) ) maxLen = i - um [ sum - k ] ; } } return maxLen ; } static int lenLongSubarrWithMaxSum ( int [ ] arr , int n ) { int maxSum = maxSubArraySum ( arr , n ) ; return lenOfLongSubarrWithGivenSum ( arr , n , maxSum ) ; } public static void Main ( ) { int [ ] arr = { 5 , - 2 , - 1 , 3 , - 4 } ; int n = arr . Length ; Console . WriteLine ( " Length ▁ of ▁ longest ▁ subarray ▁ " + " having ▁ maximum ▁ sum ▁ = ▁ " + lenLongSubarrWithMaxSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 100 ; static int start , end ; static bool sumEqualToK ( int [ ] arr , int n , int k ) { Dictionary < int , int > um = new Dictionary < int , int > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum == k ) { maxLen = i + 1 ; start = 0 ; end = i ; } if ( ! um . ContainsKey ( sum ) ) um . Add ( sum , i ) ; if ( um . ContainsKey ( sum - k ) ) { if ( maxLen < ( i - um [ sum - k ] ) ) { maxLen = i - um [ sum - k ] ; start = um [ sum - k ] + 1 ; end = i ; } } } return ( maxLen != 0 ) ; } static void sumZeroMatrix ( int [ , ] mat , int row , int col , int k ) { int [ ] temp = new int [ row ] ; int area ; bool sum = false ; int fup = 0 , fdown = 0 , fleft = 0 , fright = 0 ; int maxArea = int . MinValue ; for ( int left = 0 ; left < col ; left ++ ) { temp = memset ( temp , 0 ) ; for ( int right = left ; right < col ; right ++ ) { for ( int i = 0 ; i < row ; i ++ ) temp [ i ] += mat [ i , right ] ; sum = sumEqualToK ( temp , row , k ) ; area = ( end - start + 1 ) * ( right - left + 1 ) ; if ( sum && maxArea < area ) { fup = start ; fdown = end ; fleft = left ; fright = right ; maxArea = area ; } } } if ( fup == 0 && fdown == 0 && fleft == 0 && fright == 0 && mat [ 0 , 0 ] != k ) { Console . Write ( " No ▁ sub - matrix ▁ with ▁ sum ▁ " + k + " ▁ exists " ) ; return ; } Console . Write ( " ( Top , ▁ Left ) : ▁ " + " ( " + fup + " , ▁ " + fleft + " ) " + " STRNEWLINE " ) ; Console . Write ( " ( Bottom , ▁ Right ) : ▁ " + " ( " + fdown + " , ▁ " + fright + " ) " + " STRNEWLINE " ) ; for ( int j = fup ; j <= fdown ; j ++ ) { for ( int i = fleft ; i <= fright ; i ++ ) Console . Write ( mat [ j , i ] + " ▁ " ) ; Console . WriteLine ( ) ; } } static int [ ] memset ( int [ ] arr , int val ) { for ( int i = 0 ; i < arr . Length ; i ++ ) arr [ i ] = val ; return arr ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 7 , - 6 , 5 } , { - 8 , 6 , 7 , - 2 } , { 10 , - 15 , 3 , 2 } , { - 5 , 2 , 0 , 9 } } ; int row = 4 , col = 4 ; int k = 7 ; sumZeroMatrix ( mat , row , col , k ) ; } }

Index/key variables: i, row
Accumulator variables: i, j, left, right, sum
Iterator variables: i, j, left, right
Boolean variables: sum
Class/struct names: GFG
C# program:
using System ; class GFG { public static long countPartitions ( int n , int k ) { long [ , ] dp = new long [ 201 , 201 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { dp [ i , j ] = - 1 ; } } if ( dp [ n , k ] >= 0 ) return dp [ n , k ] ; if ( n < k ) return 0 ; if ( n < 2 * k ) return 1 ; long answer = 1 ; for ( int i = k ; i < n ; i ++ ) answer = answer + countPartitions ( n - i , i ) ; dp [ n , k ] = answer ; return answer ; } static void Main ( ) { int n = 10 , k = 3 ; Console . Write ( " Total ▁ Aggregate ▁ sum ▁ of ▁ all ▁ Valid ▁ Partitions : ▁ " + countPartitions ( n , k ) * n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int GCD ( int a , int b ) { if ( b == 0 ) { return a ; } return GCD ( b , a % b ) ; } public static void makePairs ( List < int > pairs , int a , int b ) { for ( int i = a ; i <= b ; i ++ ) { int sumOfDigits = 0 , k = i ; while ( k > 0 ) { sumOfDigits += k % 10 ; k /= 10 ; } if ( sumOfDigits <= 162 ) { pairs . Add ( sumOfDigits ) ; } } } public static int countCoPrime ( int a , int b ) { List < int > pairs = new List < int > ( ) ; makePairs ( pairs , a , b ) ; int count = 0 ; for ( int i = 0 ; i < pairs . Count ; i ++ ) { for ( int j = i + 1 ; j < pairs . Count ; j ++ ) { if ( GCD ( pairs [ i ] , pairs [ j ] ) == 1 ) { count ++ ; } } } return count ; } public static void Main ( string [ ] args ) { int a = 12 , b = 15 ; Console . WriteLine ( countCoPrime ( a , b ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, k, sumOfDigits
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static long recursive ( long idx , long sum , long tight , string st , long [ , , ] dp , long num ) { if ( idx == num ) { return sum == 0 ? 1 : 0 ; } if ( dp [ ( int ) idx , ( int ) tight , ( int ) sum ] != - 1 ) return dp [ ( int ) idx , ( int ) tight , ( int ) sum ] ; long newTight ; long ans = 0 ; long d ; for ( d = 0 ; d < 10 ; ++ d ) { newTight = 0 ; if ( tight == 1 && st [ ( ( int ) idx ) ] - '0' < d ) continue ; if ( tight == 1 && st [ ( ( int ) idx ) ] - '0' == d ) newTight = 1 ; if ( sum >= d ) ans += recursive ( idx + 1 , sum - d , ( int ) newTight , st , dp , num ) ; } return dp [ ( int ) idx , ( int ) tight , ( int ) sum ] = ans ; } static List < long > formArray ( long N ) { long [ , , ] dp = new long [ 20 , 2 , 166 ] ; for ( int i = 0 ; i < 20 ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { for ( int k = 0 ; k < 166 ; k ++ ) { dp [ i , j , k ] = - 1 ; } } } string st = N . ToString ( ) ; long num = st . Length ; List < long > arr = new List < long > ( ) ; for ( int i = 1 ; i <= 162 ; ++ i ) { arr . Add ( recursive ( 0 , i , 1 , st , dp , num ) ) ; } return arr ; } static long findPair ( long a , long b ) { List < long > arr_smaller = formArray ( a - 1 ) ; List < long > arr_greater = formArray ( b ) ; for ( int i = 0 ; i < arr_greater . Count ; ++ i ) { arr_greater [ i ] = arr_greater [ i ] - arr_smaller [ i ] ; } long ans = 0 ; for ( int i = 1 ; i <= 162 ; ++ i ) { for ( int j = i + 1 ; j <= 162 ; ++ j ) { if ( gcd ( i , j ) == 1 ) { ans = ( ans + arr_greater [ i - 1 ] * arr_greater [ j - 1 ] ) ; } } } return ans ; } static public void Main ( ) { long a = 12 , b = 15 ; Console . WriteLine ( findPair ( a , b ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, j, k
Iterator variables: d, i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > factors ( int n ) { List < int > v = new List < int > ( ) ; v . Add ( 1 ) ; for ( int i = 2 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v . Add ( i ) ; if ( n / i != i ) { v . Add ( n / i ) ; } } } return v ; } static bool check ( int n ) { List < int > v = new List < int > ( ) ; v = factors ( n ) ; v . Sort ( ) ; int r = v . Count ; bool [ , ] subset = new bool [ r + 1 , n + 1 ] ; for ( int i = 0 ; i <= r ; i ++ ) subset [ i , 0 ] = true ; for ( int i = 1 ; i <= n ; i ++ ) subset [ 0 , i ] = false ; for ( int i = 1 ; i <= r ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( j < v [ i - 1 ] ) subset [ i , j ] = subset [ i - 1 , j ] ; else { subset [ i , j ] = subset [ i - 1 , j ] || subset [ i - 1 , ( j - v [ i - 1 ] ) ] ; } } } if ( ( subset [ r , n ] ) == false ) return false ; else return true ; } public static void Main ( String [ ] args ) { int n = 40 ; if ( check ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] fib = new int [ 43 ] ; public static void fibonacci ( ) { fib [ 0 ] = 1 ; fib [ 1 ] = 2 ; for ( int i = 2 ; i < 43 ; i ++ ) fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } public static int rec ( int x , int y , int last ) { if ( y == 0 ) { if ( x == 0 ) return 1 ; return 0 ; } int sum = 0 ; for ( int i = last ; i >= 0 && fib [ i ] * y >= x ; i -- ) { if ( fib [ i ] > x ) continue ; sum += rec ( x - fib [ i ] , y - 1 , i ) ; } return sum ; } static void Main ( ) { for ( int i = 0 ; i < 43 ; i ++ ) fib [ i ] = 0 ; fibonacci ( ) ; int n = 13 , k = 3 ; Console . Write ( " Possible ▁ ways ▁ are : ▁ " + rec ( n , k , 42 ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumCost ( int [ ] cost , int n ) { int [ ] dp = new int [ n ] ; if ( n == 1 ) return cost [ 0 ] ; dp [ 0 ] = cost [ 0 ] ; dp [ 1 ] = cost [ 1 ] ; for ( int i = 2 ; i < n ; i ++ ) { dp [ i ] = Math . Min ( dp [ i - 1 ] , dp [ i - 2 ] ) + cost [ i ] ; } return Math . Min ( dp [ n - 2 ] , dp [ n - 1 ] ) ; } public static void Main ( ) { int [ ] a = { 16 , 19 , 10 , 12 , 18 } ; int n = a . Length ; Console . WriteLine ( minimumCost ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumCost ( int [ ] cost , int n ) { int dp1 = 0 , dp2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int dp0 = cost [ i ] + Math . Min ( dp1 , dp2 ) ; dp2 = dp1 ; dp1 = dp0 ; } return Math . Min ( dp1 , dp2 ) ; } public static void Main ( ) { int [ ] a = { 2 , 5 , 3 , 1 , 7 , 3 , 4 } ; int n = a . Length ; Console . Write ( minimumCost ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int size = 1000 ; static int maxCost ( int [ , ] a , int m , int n , int [ , ] dp ) { if ( n < 0 m < 0 ) return ( int ) - 1e9 ; else if ( m == 0 && n == 0 ) return 0 ; else if ( dp [ m , n ] != - 1 ) return dp [ m , n ] ; else { int num = m + n ; if ( ( num & ( num - 1 ) ) == 0 ) return dp [ m , n ] = a [ m , n ] + maxCost ( a , m - 1 , n - 1 , dp ) ; else return dp [ m , n ] = ( a [ m , n ] + Math . Max ( maxCost ( a , m - 1 , n , dp ) , maxCost ( a , m , n - 1 , dp ) ) ) ; } } static int answer ( int [ , ] a , int n ) { int [ , ] dp = new int [ size , size ] ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size ; j ++ ) { dp [ i , j ] = - 1 ; } } return maxCost ( a , n - 1 , n - 1 , dp ) ; } public static void Main ( String [ ] args ) { int [ , ] a = { { 1 , 2 , 3 , 1 } , { 4 , 5 , 6 , 1 } , { 7 , 8 , 9 , 1 } , { 1 , 1 , 1 , 1 } } ; int n = 4 ; Console . WriteLine ( answer ( a , n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int editDistanceWith2Ops ( String X , String Y ) { int m = X . Length , n = Y . Length ; int [ , ] L = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) { L [ i , j ] = 0 ; } else if ( X [ i - 1 ] == Y [ j - 1 ] ) { L [ i , j ] = L [ i - 1 , j - 1 ] + 1 ; } else { L [ i , j ] = Math . Max ( L [ i - 1 , j ] , L [ i , j - 1 ] ) ; } } } int lcs = L [ m , n ] ; return ( m - lcs ) + ( n - lcs ) ; } public static void Main ( ) { String X = " abc " , Y = " acd " ; Console . Write ( editDistanceWith2Ops ( X , Y ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int lcs ( String X , String Y , int m , int n ) { if ( m == 0 n == 0 ) { return 0 ; } if ( X [ m - 1 ] == Y [ n - 1 ] ) { return 1 + lcs ( X , Y , m - 1 , n - 1 ) ; } else { return Math . Max ( lcs ( X , Y , m , n - 1 ) , lcs ( X , Y , m - 1 , n ) ) ; } } public static void Main ( ) { String X = " AGGTAB " ; String Y = " GXTXAYB " ; int m = X . Length ; int n = Y . Length ; Console . Write ( " Length ▁ of ▁ LCS : ▁ " + lcs ( X , Y , m , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countPaths ( int n ) { int zB = 1 ; int zADC = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int nzB = zADC * 3 ; int nzADC = ( zADC * 2 + zB ) ; zB = nzB ; zADC = nzADC ; } return zB ; } static public void Main ( ) { int n = 3 ; Console . WriteLine ( countPaths ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ , ] dp = new int [ 8 , 8 ] ; static int getsteps ( int x , int y , int tx , int ty ) { if ( x == tx && y == ty ) { return dp [ 0 , 0 ] ; if ( dp [ Math . Abs ( x - tx ) , Math . Abs ( y - ty ) ] != 0 ) { return dp [ Math . Abs ( x - tx ) , Math . Abs ( y - ty ) ] ; } else { int x1 , y1 , x2 , y2 ; if ( x <= tx ) { if ( y <= ty ) { x1 = x + 2 ; y1 = y + 1 ; x2 = x + 1 ; y2 = y + 2 ; } else { x1 = x + 2 ; y1 = y - 1 ; x2 = x + 1 ; y2 = y - 2 ; } } else if ( y <= ty ) { x1 = x - 2 ; y1 = y + 1 ; x2 = x - 1 ; y2 = y + 2 ; } else { x1 = x - 2 ; y1 = y - 1 ; x2 = x - 1 ; y2 = y - 2 ; } dp [ Math . Abs ( x - tx ) , Math . Abs ( y - ty ) ] = Math . Min ( getsteps ( x1 , y1 , tx , ty ) , getsteps ( x2 , y2 , tx , ty ) ) + 1 ; dp [ Math . Abs ( y - ty ) , Math . Abs ( x - tx ) ] = dp [ Math . Abs ( x - tx ) , Math . Abs ( y - ty ) ] ; return dp [ Math . Abs ( x - tx ) , Math . Abs ( y - ty ) ] ; } } static public void Main ( ) { int i , n , x , y , tx , ty , ans ; n = 100 ; x = 4 ; y = 5 ; tx = 1 ; ty = 1 ; if ( ( x == 1 && y == 1 && tx == 2 && ty == 2 ) || ( x == 2 && y == 2 && tx == 1 && ty == 1 ) ) { ans = 4 ; } else if ( ( x == 1 && y == n && tx == 2 && ty == n - 1 ) || ( x == 2 && y == n - 1 && tx == 1 && ty == n ) ) { ans = 4 ; } else if ( ( x == n && y == 1 && tx == n - 1 && ty == 2 ) || ( x == n - 1 && y == 2 && tx == n && ty == 1 ) ) { ans = 4 ; } else if ( ( x == n && y == n && tx == n - 1 && ty == n - 1 ) || ( x == n - 1 && y == n - 1 && tx == n && ty == n ) ) { ans = 4 ; } else { dp [ 1 , 0 ] = 3 ; dp [ 0 , 1 ] = 3 ; dp [ 1 , 1 ] = 2 ; dp [ 2 , 0 ] = 2 ; dp [ 0 , 2 ] = 2 ; dp [ 2 , 1 ] = 1 ; dp [ 1 , 2 ] = 1 ; ans = getsteps ( x , y , tx , ty ) ; } Console . WriteLine ( ans ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void getMinimumPenalty ( string x , string y , int pxy , int pgap ) { int [ , ] dp = new int [ n + m + 1 , n + m + 1 ] ; for ( int q = 0 ; q < n + m + 1 ; q ++ ) for ( int w = 0 ; w < n + m + 1 ; w ++ ) dp [ q , w ] = 0 ; for ( i = 0 ; i <= ( n + m ) ; i ++ ) { dp [ i , 0 ] = i * pgap ; dp [ 0 , i ] = i * pgap ; } for ( i = 1 ; i <= m ; i ++ ) { for ( j = 1 ; j <= n ; j ++ ) { if ( x [ i - 1 ] == y [ j - 1 ] ) { dp [ i , j ] = dp [ i - 1 , j - 1 ] ; } else { dp [ i , j ] = Math . Min ( Math . Min ( dp [ i - 1 , j - 1 ] + pxy , dp [ i - 1 , j ] + pgap ) , dp [ i , j - 1 ] + pgap ) ; } } } i = m ; j = n ; int xpos = l ; int ypos = l ; int [ ] xans = new int [ l + 1 ] ; int [ ] yans = new int [ l + 1 ] ; while ( ! ( i == 0 j == 0 ) ) { if ( x [ i - 1 ] == y [ j - 1 ] ) { xans [ xpos -- ] = ( int ) x [ i - 1 ] ; yans [ ypos -- ] = ( int ) y [ j - 1 ] ; i -- ; j -- ; } else if ( dp [ i - 1 , j - 1 ] + pxy == dp [ i , j ] ) { xans [ xpos -- ] = ( int ) x [ i - 1 ] ; yans [ ypos -- ] = ( int ) y [ j - 1 ] ; i -- ; j -- ; } else if ( dp [ i - 1 , j ] + pgap == dp [ i , j ] ) { xans [ xpos -- ] = ( int ) x [ i - 1 ] ; yans [ ypos -- ] = ( int ) ' _ ' ; i -- ; } else if ( dp [ i , j - 1 ] + pgap == dp [ i , j ] ) { xans [ xpos -- ] = ( int ) ' _ ' ; yans [ ypos -- ] = ( int ) y [ j - 1 ] ; j -- ; } } while ( xpos > 0 ) { if ( i > 0 ) xans [ xpos -- ] = ( int ) x [ -- i ] ; else xans [ xpos -- ] = ( int ) ' _ ' ; } while ( ypos > 0 ) { if ( j > 0 ) yans [ ypos -- ] = ( int ) y [ -- j ] ; else yans [ ypos -- ] = ( int ) ' _ ' ; } int id = 1 ; for ( i = l ; i >= 1 ; i -- ) { if ( ( char ) yans [ i ] == ' _ ' && ( char ) xans [ i ] == ' _ ' ) { id = i + 1 ; break ; } } Console . Write ( " Minimum ▁ Penalty ▁ in ▁ aligning ▁ the ▁ genes ▁ = ▁ " + dp [ m , n ] + " STRNEWLINE " ) ; Console . Write ( " The ▁ aligned ▁ genes ▁ are ▁ : STRNEWLINE " ) ; for ( i = id ; i <= l ; i ++ ) { Console . Write ( ( char ) xans [ i ] ) ; } Console . Write ( " STRNEWLINE " ) ; for ( i = id ; i <= l ; i ++ ) { Console . Write ( ( char ) yans [ i ] ) ; } return ; } static void Main ( ) { string gene1 = " AGGGCT " ; string gene2 = " AGGCA " ; int misMatchPenalty = 3 ; int gapPenalty = 2 ; getMinimumPenalty ( gene1 , gene2 , misMatchPenalty , gapPenalty ) ; } }

Index/key variables: i
Accumulator variables: i, j, q, w, xpos, ypos
Iterator variables: i, j, q, w
Class/struct names: GFG
C# program:
using System ; class GFG { static int sumSubSequence ( int [ ] arr , int len , int m ) { int sum = 0 ; foreach ( int x in arr ) { sum += x ; } int [ , ] dp = new int [ len + 1 , sum + 1 ] ; for ( int i = 0 ; i <= len ; i ++ ) dp [ i , 0 ] ++ ; for ( int i = 1 ; i <= len ; i ++ ) { dp [ i , arr [ i - 1 ] ] ++ ; for ( int j = 1 ; j <= sum ; j ++ ) { if ( dp [ i - 1 , j ] > 0 ) { dp [ i , j ] ++ ; dp [ i , j + arr [ i - 1 ] ] ++ ; } } } int count = 0 ; for ( int j = 1 ; j <= sum ; j ++ ) if ( dp [ len , j ] > 0 ) if ( j % m == 0 ) count += dp [ len , j ] ; return count ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 3 } ; int m = 3 ; int len = arr . Length ; Console . Write ( sumSubSequence ( arr , len , m ) + " STRNEWLINE " ) ; } }

Accumulator variables: count, i, j, sum
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int lds ( int [ ] arr , int n ) { int [ ] lds = new int [ n ] ; int i , j , max = 0 ; for ( i = 0 ; i < n ; i ++ ) lds [ i ] = 1 ; for ( i = 1 ; i < n ; i ++ ) for ( j = 0 ; j < i ; j ++ ) if ( arr [ i ] < arr [ j ] && lds [ i ] < lds [ j ] + 1 ) lds [ i ] = lds [ j ] + 1 ; for ( i = 0 ; i < n ; i ++ ) if ( max < lds [ i ] ) max = lds [ i ] ; return max ; } public static void Main ( ) { int [ ] arr = { 15 , 27 , 14 , 38 , 63 , 55 , 46 , 65 , 85 } ; int n = arr . Length ; Console . Write ( " Length ▁ of ▁ LDS ▁ is ▁ " + lds ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int CountDecreasingPathsCell ( int [ , ] mat , int [ , ] dp , int n , int x , int y ) { if ( dp [ x , y ] != - 1 ) return dp [ x , y ] ; int [ , ] delta = { { 0 , 1 } , { 1 , 0 } , { - 1 , 0 } , { 0 , - 1 } } ; int newx , newy ; int ans = 1 ; for ( int i = 0 ; i < 4 ; i ++ ) { newx = x + delta [ i , 0 ] ; newy = y + delta [ i , 1 ] ; if ( newx >= 0 && newx < n && newy >= 0 && newy < n && mat [ newx , newy ] < mat [ x , y ] ) { ans += CountDecreasingPathsCell ( mat , dp , n , newx , newy ) ; } } return dp [ x , y ] = ans ; } public static int countDecreasingPathsMatrix ( int n , int [ , ] mat ) { int [ , ] dp = new int [ n , n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) dp [ i , j ] = - 1 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) sum += CountDecreasingPathsCell ( mat , dp , n , i , j ) ; return sum ; } static public void Main ( ) { int n = 2 ; int [ , ] mat = { { 1 , 2 } , { 1 , 3 } } ; Console . WriteLine ( countDecreasingPathsMatrix ( n , mat ) ) ; } }

Accumulator variables: ans, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; static void binomialCoeff ( int [ ] C , int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . Min ( i , n ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } } static int sumOfproduct ( int n ) { int sum = 0 ; int [ ] C = new int [ MAX ] ; binomialCoeff ( C , n ) ; for ( int i = 0 ; i <= n ; i ++ ) sum += C [ i ] * C [ i + 1 ] ; return sum ; } public static void Main ( ) { int n = 3 ; Console . WriteLine ( sumOfproduct ( n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; static void binomialCoeff ( int n , int [ ] C ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . Min ( i , n ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } } static int summation ( int n ) { int [ ] C = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) C [ i ] = 0 ; binomialCoeff ( n , C ) ; int sum = 0 ; for ( int i = 0 ; i <= n ; i ++ ) sum += ( i * C [ i ] ) ; return sum ; } public static void Main ( ) { int n = 2 ; Console . Write ( summation ( n ) ) ; } }

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