dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static String getLargestString ( String s , int k ) { int [ ] frequency_array = new int [ 26 ] ; for ( int i = 0 ; i < s . Length ; i ++ ) { frequency_array [ s [ i ] - ' a ' ] ++ ; } String ans = " " ; for ( int i = 25 ; i >= 0 ; ) { if ( frequency_array [ i ] > k ) { int temp = k ; String st = String . Join ( " " , ( char ) ( i + ' a ' ) ) ; while ( temp > 0 ) { ans += st ; temp -- ; } frequency_array [ i ] -= k ; int j = i - 1 ; while ( frequency_array [ j ] <= 0 && j >= 0 ) { j -- ; } if ( frequency_array [ j ] > 0 && j >= 0 ) { String str = String . Join ( " " , ( char ) ( j + ' a ' ) ) ; ans += str ; frequency_array [ j ] -= 1 ; } else { break ; } } else if ( frequency_array [ i ] > 0 ) { int temp = frequency_array [ i ] ; frequency_array [ i ] -= temp ; String st = String . Join ( " " , ( char ) ( i + ' a ' ) ) ; while ( temp > 0 ) { ans += st ; temp -- ; } } else { i -- ; } } return ans ; } public static void Main ( String [ ] args ) { String S = " xxxxzza " ; int k = 3 ; Console . Write ( getLargestString ( S , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int minOperations ( int [ ] a , int [ ] b , int n ) { int minA = a . Max ( ) ; for ( int x = minA ; x >= 0 ; x -- ) { bool check = true ; int operations = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( x % b [ i ] == a [ i ] % b [ i ] ) { operations += ( a [ i ] - x ) / b [ i ] ; } else { check = false ; break ; } } if ( check ) return operations ; } return - 1 ; } public static void Main ( string [ ] args ) { int N = 5 ; int [ ] A = { 5 , 7 , 10 , 5 , 15 } ; int [ ] B = { 2 , 2 , 1 , 3 , 5 } ; Console . WriteLine ( minOperations ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, operations, x
Iterator variables: i, x
Boolean variables: check
Class/struct names: GFG
C# program:
using System ; class GFG { static int getLargestSum ( int N ) { int max_sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i + 1 ; j <= N ; j ++ ) { if ( i * j % ( i + j ) == 0 ) max_sum = Math . Max ( max_sum , i + j ) ; } } return max_sum ; } public static void Main ( string [ ] args ) { int N = 25 ; int max_sum = getLargestSum ( N ) ; Console . WriteLine ( max_sum ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubArraySum ( int [ ] a , int size ) { int max_so_far = int . MinValue , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_ending_here < 0 ) max_ending_here = 0 ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; } return max_so_far ; } static int maxSum ( int [ ] a , int n ) { int S = 0 ; int i ; for ( i = 0 ; i < n ; i ++ ) S += a [ i ] ; int X = maxSubArraySum ( a , n ) ; return 2 * X - S ; } public static void Main ( String [ ] args ) { int [ ] a = { - 1 , - 2 , - 3 } ; int n = a . Length ; int max_sum = maxSum ( a , n ) ; Console . Write ( max_sum ) ; } }

Index/key variables: i
Accumulator variables: S, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isPrime ( int n ) { int flag = 1 ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { flag = 0 ; break ; } } return ( flag == 1 ? true : false ) ; } static bool isPerfectSquare ( int x ) { double sr = Math . Sqrt ( x ) ; return ( ( sr - Math . Floor ( sr ) ) == 0 ) ; } static int countInterestingPrimes ( int n ) { int answer = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( isPrime ( i ) ) { for ( int j = 1 ; j * j * j * j <= i ; j ++ ) { if ( isPerfectSquare ( i - j * j * j * j ) ) { answer ++ ; break ; } } } } return answer ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . Write ( countInterestingPrimes ( N ) ) ; } }

Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void decBinary ( int [ ] arr , int n ) { int k = ( int ) ( Math . Log ( n ) / Math . Log ( 2 ) ) ; while ( n > 0 ) { arr [ k -- ] = n % 2 ; n /= 2 ; } } static int binaryDec ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += arr [ i ] << ( n - i - 1 ) ; return ans ; } static int maxNum ( int n , int k ) { int l = ( int ) ( Math . Log ( n ) / Math . Log ( 2 ) ) + 1 ; int [ ] a = new int [ l ] ; decBinary ( a , n ) ; int cn = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( a [ i ] == 0 && cn < k ) { a [ i ] = 1 ; cn ++ ; } } return binaryDec ( a , l ) ; } public static void Main ( String [ ] args ) { int n = 4 , k = 1 ; Console . WriteLine ( maxNum ( n , k ) ) ; } }

Index/key variables: i, l
Accumulator variables: ans, cn, i, k, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSubSeq ( int [ ] arr , int n , int sum ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( sum < arr [ i ] ) arr [ i ] = - 1 ; else sum -= arr [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != - 1 ) Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 17 , 25 , 46 , 94 , 201 , 400 } ; int n = arr . Length ; int sum = 272 ; findSubSeq ( arr , n , sum ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 26 ; static char maxAlpha ( String str , int len ) { int [ ] first = new int [ MAX ] ; int [ ] last = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { first [ i ] = - 1 ; last [ i ] = - 1 ; } for ( int i = 0 ; i < len ; i ++ ) { int index = ( str [ i ] - ' a ' ) ; if ( first [ index ] == - 1 ) first [ index ] = i ; last [ index ] = i ; } int ans = - 1 , maxVal = - 1 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( first [ i ] == - 1 ) continue ; if ( ( last [ i ] - first [ i ] ) > maxVal ) { maxVal = last [ i ] - first [ i ] ; ans = i ; } } return ( char ) ( ans + ' a ' ) ; } public static void Main ( String [ ] args ) { String str = " abbba " ; int len = str . Length ; Console . Write ( maxAlpha ( str , len ) ) ; } }

Index/key variables: MAX, i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100001 ; static void find_distinct ( int [ ] a , int n , int q , int [ ] queries ) { int [ ] check = new int [ MAX ] ; int [ ] idx = new int [ MAX ] ; int cnt = 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( check [ a [ i ] ] == 0 ) { idx [ i ] = cnt ; check [ a [ i ] ] = 1 ; cnt ++ ; } else { idx [ i ] = cnt - 1 ; } } for ( int i = 0 ; i < q ; i ++ ) { int m = queries [ i ] ; Console . Write ( idx [ m ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 1 , 2 , 3 , 4 , 5 } ; int n = a . Length ; int [ ] queries = { 0 , 3 , 5 , 7 } ; int q = queries . Length ; find_distinct ( a , n , q , queries ) ; } }

Index/key variables: MAX, i, m
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 24 ; static int countOp ( int x ) { int [ ] arr = new int [ MAX ] ; arr [ 0 ] = 1 ; for ( int i = 1 ; i < MAX ; i ++ ) arr [ i ] = arr [ i - 1 ] * 2 ; int temp = x ; bool flag = true ; int ans = 0 ; int operations = 0 ; bool flag2 = false ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( arr [ i ] - 1 == x ) flag2 = true ; if ( arr [ i ] > x ) { ans = i ; break ; } } if ( flag2 ) return 0 ; while ( flag ) { if ( arr [ ans ] < x ) ans ++ ; operations ++ ; for ( int i = 0 ; i < MAX ; i ++ ) { int take = x ^ ( arr [ i ] - 1 ) ; if ( take <= arr [ ans ] - 1 ) { if ( take > temp ) temp = take ; } } if ( temp == arr [ ans ] - 1 ) { flag = false ; break ; } temp ++ ; operations ++ ; x = temp ; if ( x == arr [ ans ] - 1 ) flag = false ; } return operations ; } static public void Main ( ) { int x = 39 ; Console . WriteLine ( countOp ( x ) ) ; } }

Index/key variables: MAX, ans, i
Accumulator variables: ans, i, operations, temp
Iterator variables: i
Boolean variables: flag, flag2
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int minOperations ( int [ ] arr , int n ) { int maxi , result = 0 ; int [ ] freq = new int [ 1000001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = arr [ i ] ; freq [ x ] ++ ; } maxi = arr . Max ( ) ; for ( int i = 1 ; i <= maxi ; i ++ ) { if ( freq [ i ] != 0 ) { for ( int j = i * 2 ; j <= maxi ; j = j + i ) { freq [ j ] = 0 ; } result ++ ; } } return result ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 2 , 4 , 4 , 4 } ; int n = arr . Length ; Console . WriteLine ( minOperations ( arr , n ) ) ; } }

Index/key variables: i, j, x
Accumulator variables: i, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int __gcd ( int a , int b ) { if ( a == 0 ) return b ; return __gcd ( b % a , a ) ; } static int minGCD ( int [ ] arr , int n ) { int minGCD = 0 ; for ( int i = 0 ; i < n ; i ++ ) minGCD = __gcd ( minGCD , arr [ i ] ) ; return minGCD ; } static int minLCM ( int [ ] arr , int n ) { int minLCM = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) minLCM = Math . Min ( minLCM , arr [ i ] ) ; return minLCM ; } public static void Main ( ) { int [ ] arr = { 2 , 66 , 14 , 521 } ; int n = arr . Length ; Console . WriteLine ( " LCM ▁ = ▁ " + minLCM ( arr , n ) + " , ▁ GCD ▁ = ▁ " + minGCD ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String formStringMinOperations ( char [ ] s ) { int [ ] count = new int [ 3 ] ; foreach ( char c in s ) { count [ ( int ) c - 48 ] += 1 ; } int [ ] processed = new int [ 3 ] ; int reqd = ( int ) s . Length / 3 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( count [ s [ i ] - '0' ] == reqd ) { continue ; } if ( s [ i ] == '0' && count [ 0 ] > reqd && processed [ 0 ] >= reqd ) { if ( count [ 1 ] < reqd ) { s [ i ] = '1' ; count [ 1 ] ++ ; count [ 0 ] -- ; } else if ( count [ 2 ] < reqd ) { s [ i ] = '2' ; count [ 2 ] ++ ; count [ 0 ] -- ; } } if ( s [ i ] == '1' && count [ 1 ] > reqd ) { if ( count [ 0 ] < reqd ) { s [ i ] = '0' ; count [ 0 ] ++ ; count [ 1 ] -- ; } else if ( count [ 2 ] < reqd && processed [ 1 ] >= reqd ) { s [ i ] = '2' ; count [ 2 ] ++ ; count [ 1 ] -- ; } } if ( s [ i ] == '2' && count [ 2 ] > reqd ) { if ( count [ 0 ] < reqd ) { s [ i ] = '0' ; count [ 0 ] ++ ; count [ 2 ] -- ; } else if ( count [ 1 ] < reqd ) { s [ i ] = '1' ; count [ 1 ] ++ ; count [ 2 ] -- ; } } processed [ s [ i ] - '0' ] ++ ; } return String . Join ( " " , s ) ; } public static void Main ( String [ ] args ) { String s = "011200" ; Console . WriteLine ( formStringMinOperations ( s . ToCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: c, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinimumAdjacentSwaps ( int [ ] arr , int N ) { bool [ ] visited = new bool [ N + 1 ] ; int minimumSwaps = 0 ; for ( int i = 0 ; i < 2 * N ; i ++ ) { if ( visited [ arr [ i ] ] == false ) { visited [ arr [ i ] ] = true ; int count = 0 ; for ( int j = i + 1 ; j < 2 * N ; j ++ ) { if ( visited [ arr [ j ] ] == false ) count ++ ; else if ( arr [ i ] == arr [ j ] ) minimumSwaps += count ; } } } return minimumSwaps ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 3 , 1 , 2 } ; int N = arr . Length ; N /= 2 ; Console . WriteLine ( findMinimumAdjacentSwaps ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: N, count, i, j, minimumSwaps
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool possibility ( Dictionary < int , int > m , int length , string s ) { int countodd = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( ( m [ s [ i ] - '0' ] & 1 ) != 0 ) countodd ++ ; if ( countodd > 1 ) return false ; } return true ; } static void largestPalindrome ( string s ) { int l = s . Length ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < 10 ; i ++ ) m [ i ] = 0 ; for ( int i = 0 ; i < l ; i ++ ) m [ s [ i ] - '0' ] ++ ; if ( possibility ( m , l , s ) == false ) { Console . Write ( " Palindrome ▁ cannot ▁ be ▁ formed " ) ; return ; } char [ ] largest = new char [ l ] ; int front = 0 ; for ( int i = 9 ; i >= 0 ; i -- ) { if ( ( m [ i ] & 1 ) != 0 ) { largest [ l / 2 ] = ( char ) ( i + '0' ) ; m [ i ] -- ; while ( m [ i ] > 0 ) { largest [ front ] = ( char ) ( i + '0' ) ; largest [ l - front - 1 ] = ( char ) ( i + '0' ) ; m [ i ] -= 2 ; front ++ ; } } else { while ( m [ i ] > 0 ) { largest [ front ] = ( char ) ( i + '0' ) ; largest [ l - front - 1 ] = ( char ) ( i + '0' ) ; m [ i ] -= 2 ; front ++ ; } } } for ( int i = 0 ; i < l ; i ++ ) { Console . Write ( largest [ i ] ) ; } } public static void Main ( string [ ] args ) { string s = "313551" ; largestPalindrome ( s ) ; } }

Index/key variables: front, i, l
Accumulator variables: countodd, front, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System . IO ; using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static long swapCount ( string s ) { List < int > pos = new List < int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == ' [ ' ) { pos . Add ( i ) ; } } int count = 0 ; int p = 0 ; long sum = 0 ; char [ ] S = s . ToCharArray ( ) ; for ( int i = 0 ; i < S . Length ; i ++ ) { if ( S [ i ] == ' [ ' ) { ++ count ; ++ p ; } else if ( S [ i ] == ' ] ' ) { -- count ; } if ( count < 0 ) { sum += pos [ p ] - i ; char temp = S [ i ] ; S [ i ] = S [ pos [ p ] ] ; S [ pos [ p ] ] = temp ; ++ p ; count = 1 ; } } return sum ; } static void Main ( ) { string s = " [ ] ] [ ] [ " ; Console . WriteLine ( swapCount ( s ) ) ; s = " [ [ ] [ ] ] " ; Console . WriteLine ( swapCount ( s ) ) ; } }

Index/key variables: i, p
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumCostOfBreaking ( int [ ] X , int [ ] Y , int m , int n ) { int res = 0 ; Array . Sort < int > ( X , new Comparison < int > ( ( i1 , i2 ) => i2 . CompareTo ( i1 ) ) ) ; Array . Sort < int > ( Y , new Comparison < int > ( ( i1 , i2 ) => i2 . CompareTo ( i1 ) ) ) ; int hzntl = 1 , vert = 1 ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( X [ i ] > Y [ j ] ) { res += X [ i ] * vert ; hzntl ++ ; i ++ ; } else { res += Y [ j ] * hzntl ; vert ++ ; j ++ ; } } int total = 0 ; while ( i < m ) total += X [ i ++ ] ; res += total * vert ; total = 0 ; while ( j < n ) total += Y [ j ++ ] ; res += total * hzntl ; return res ; } public static void Main ( String [ ] arg ) { int m = 6 , n = 4 ; int [ ] X = { 2 , 1 , 3 , 1 , 4 } ; int [ ] Y = { 4 , 1 , 2 } ; Console . WriteLine ( minimumCostOfBreaking ( X , Y , m - 1 , n - 1 ) ) ; } }

Index/key variables: i, j
Accumulator variables: hzntl, i, j, res, total, vert
Class/struct names: GFG
C# program:
using System ; public class GFG { static int getMin ( int x , int y , int z ) { return Math . Min ( Math . Min ( x , y ) , z ) ; } static int editDistance ( string str1 , string str2 , int m , int n ) { int [ , ] dp = new int [ m + 1 , n + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 ) dp [ i , j ] = j ; else if ( j == 0 ) dp [ i , j ] = i ; else if ( str1 [ i - 1 ] == str2 [ j - 1 ] ) dp [ i , j ] = dp [ i - 1 , j - 1 ] ; else { dp [ i , j ] = 1 + getMin ( dp [ i , j - 1 ] , dp [ i - 1 , j ] , dp [ i - 1 , j - 1 ] ) ; } } } return dp [ m , n ] ; } static void minimumSteps ( string S , int N ) { int ans = int . MaxValue ; for ( int i = 1 ; i < N ; i ++ ) { string S1 = S . Substring ( 0 , i ) ; string S2 = S . Substring ( i ) ; int count = editDistance ( S1 , S2 , S1 . Length , S2 . Length ) ; ans = Math . Min ( ans , count ) ; } Console . Write ( ans ) ; } public static void Main ( string [ ] args ) { string S = " aabb " ; int N = S . Length ; minimumSteps ( S , N ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumOperations ( int N ) { int [ ] dp = new int [ N + 1 ] ; int i ; for ( i = 0 ; i <= N ; i ++ ) { dp [ i ] = ( int ) 1e9 ; } dp [ 2 ] = 0 ; for ( i = 2 ; i <= N ; i ++ ) { if ( dp [ i ] == ( int ) 1e9 ) continue ; if ( i * 5 <= N ) { dp [ i * 5 ] = Math . Min ( dp [ i * 5 ] , dp [ i ] + 1 ) ; } if ( i + 3 <= N ) { dp [ i + 3 ] = Math . Min ( dp [ i + 3 ] , dp [ i ] + 1 ) ; } } if ( dp [ N ] == 1e9 ) return - 1 ; return dp [ N ] ; } public static void Main ( String [ ] args ) { int N = 25 ; Console . Write ( minimumOperations ( N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaxProfit ( int [ ] arr , int n , int transactionFee ) { int buy = - arr [ 0 ] ; int sell = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int temp = buy ; buy = Math . Max ( buy , sell - arr [ i ] ) ; sell = Math . Max ( sell , temp + arr [ i ] - transactionFee ) ; } return Math . Max ( sell , buy ) ; } public static void Main ( ) { int [ ] arr = { 6 , 1 , 7 , 2 , 8 , 4 } ; int n = arr . Length ; int transactionFee = 2 ; Console . WriteLine ( MaxProfit ( arr , n , transactionFee ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] start = new int [ 3 , 3 ] ; static int [ , ] ending = new int [ 3 , 3 ] ; static void calculateStart ( int n , int m ) { for ( int i = 1 ; i < m ; ++ i ) { start [ 0 , i ] += start [ 0 , i - 1 ] ; } for ( int i = 1 ; i < n ; ++ i ) { start [ i , 0 ] += start [ i - 1 , 0 ] ; } for ( int i = 1 ; i < n ; ++ i ) { for ( int j = 1 ; j < m ; ++ j ) { start [ i , j ] += Math . Max ( start [ i - 1 , j ] , start [ i , j - 1 ] ) ; } } } static void calculateEnd ( int n , int m ) { for ( int i = n - 2 ; i >= 0 ; -- i ) { ending [ i , m - 1 ] += ending [ i + 1 , m - 1 ] ; } for ( int i = m - 2 ; i >= 0 ; -- i ) { ending [ n - 1 , i ] += ending [ n - 1 , i + 1 ] ; } for ( int i = n - 2 ; i >= 0 ; -- i ) { for ( int j = m - 2 ; j >= 0 ; -- j ) { ending [ i , j ] += Math . Max ( ending [ i + 1 , j ] , ending [ i , j + 1 ] ) ; } } } static void maximumPathSum ( int [ , ] mat , int n , int m , int q , int [ , ] coordinates ) { for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { start [ i , j ] = mat [ i , j ] ; ending [ i , j ] = mat [ i , j ] ; } } calculateStart ( n , m ) ; calculateEnd ( n , m ) ; int ans = 0 ; for ( int i = 0 ; i < q ; ++ i ) { int X = coordinates [ i , 0 ] - 1 ; int Y = coordinates [ i , 1 ] - 1 ; ans = Math . Max ( ans , start [ X , Y ] + ending [ X , Y ] - mat [ X , Y ] ) ; } Console . Write ( ans ) ; } public static void Main ( ) { int [ , ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int N = 3 ; int M = 3 ; int Q = 2 ; int [ , ] coordinates = { { 1 , 2 } , { 2 , 2 } } ; maximumPathSum ( mat , N , M , Q , coordinates ) ; } }

Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaxSubsetlength ( string [ ] arr , int A , int B ) { int [ , ] dp = new int [ A + 1 , B + 1 ] ; foreach ( string str in arr ) { int zeros = 0 , ones = 0 ; foreach ( char ch in str . ToCharArray ( ) ) { if ( ch == '0' ) zeros ++ ; else ones ++ ; } for ( int i = A ; i >= zeros ; i -- ) for ( int j = B ; j >= ones ; j -- ) dp [ i , j ] = Math . Max ( dp [ i , j ] , dp [ i - zeros , j - ones ] + 1 ) ; } return dp [ A , B ] ; } public static void Main ( string [ ] args ) { string [ ] arr = { "1" , "0" , "0001" , "10" , "111001" } ; int A = 5 , B = 3 ; Console . WriteLine ( MaxSubsetlength ( arr , A , B ) ) ; } }

Accumulator variables: i, j, ones, zeros
Iterator variables: ch, i, j, str
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int numOfWays ( int [ , ] a , int n , int i , HashSet < int > blue ) { if ( i == n ) return 1 ; int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( a [ i , j ] == 1 && ! blue . Contains ( j ) ) { blue . Add ( j ) ; count += numOfWays ( a , n , i + 1 , blue ) ; blue . Remove ( j ) ; } } return count ; } public static void Main ( ) { int n = 3 ; int [ , ] mat = { { 0 , 1 , 1 } , { 1 , 0 , 1 } , { 1 , 1 , 1 } } ; HashSet < int > mpp = new HashSet < int > ( ) ; Console . WriteLine ( ( numOfWays ( mat , n , 0 , mpp ) ) ) ; } }

Accumulator variables: count, j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; public class GFG { static void minCost ( int [ ] arr , int n ) { if ( n < 3 ) { Console . WriteLine ( arr [ 0 ] ) ; return ; } int [ ] dp = new int [ n ] ; dp [ 0 ] = arr [ 0 ] ; dp [ 1 ] = dp [ 0 ] + arr [ 1 ] + arr [ 2 ] ; for ( int i = 2 ; i < n - 1 ; i ++ ) dp [ i ] = Math . Min ( dp [ i - 2 ] + arr [ i ] , dp [ i - 1 ] + arr [ i ] + arr [ i + 1 ] ) ; dp [ n - 1 ] = Math . Min ( dp [ n - 2 ] , dp [ n - 3 ] + arr [ n - 1 ] ) ; Console . WriteLine ( dp [ n - 1 ] ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 9 , 4 , 6 , 8 , 5 } ; int N = arr . Length ; minCost ( arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 1000000007 ; static int power ( int X , int Y ) { int res = 1 ; X = X % M ; if ( X == 0 ) return 0 ; while ( Y > 0 ) { if ( ( Y & 1 ) != 0 ) { res = ( res * X ) % M ; } Y = Y >> 1 ; X = ( X * X ) % M ; } return res ; } static int findValue ( int n ) { int X = 0 ; int pow_10 = 1 ; while ( n != 0 ) { if ( ( n & 1 ) != 0 ) { X += pow_10 ; } pow_10 *= 10 ; n /= 2 ; } X = ( X * 2 ) % M ; int res = power ( 2 , X ) ; return res ; } public static void Main ( String [ ] args ) { int n = 2 ; Console . WriteLine ( findValue ( n ) ) ; } }

Accumulator variables: X, n, pow_10
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly long M = 1000000007 ; static long power ( long X , long Y ) { long res = 1 ; X = X % M ; if ( X == 0 ) return 0 ; while ( Y > 0 ) { if ( Y % 2 == 1 ) { res = ( res * X ) % M ; } Y = Y >> 1 ; X = ( X * X ) % M ; } return res ; } static long findValue ( int N ) { long [ ] dp = new long [ N + 1 ] ; dp [ 1 ] = 2 ; dp [ 2 ] = 1024 ; for ( int i = 3 ; i <= N ; i ++ ) { int y = ( i & ( - i ) ) ; int x = i - y ; if ( x == 0 ) { dp [ i ] = power ( dp [ i / 2 ] , 10 ) ; } else { dp [ i ] = ( dp [ x ] * dp [ y ] ) % M ; } } return ( dp [ N ] * dp [ N ] ) % M ; } public static void Main ( String [ ] args ) { int n = 150 ; Console . Write ( findValue ( n ) ) ; } }

Index/key variables: N, i, x, y
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findWays ( int N ) { if ( N == 0 ) { return 1 ; } int cnt = 0 ; for ( int i = 1 ; i <= 6 ; i ++ ) { if ( N - i >= 0 ) { cnt = cnt + findWays ( N - i ) ; } } return cnt ; } public static void Main ( ) { int N = 4 ; Console . Write ( findWays ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int checkEqualSumUtil ( int [ ] arr , int N , int sm1 , int sm2 , int sm3 , int j ) { if ( j == N ) { if ( sm1 == sm2 && sm2 == sm3 ) return 1 ; else return 0 ; } else { int l = checkEqualSumUtil ( arr , N , sm1 + arr [ j ] , sm2 , sm3 , j + 1 ) ; int m = checkEqualSumUtil ( arr , N , sm1 , sm2 + arr [ j ] , sm3 , j + 1 ) ; int r = checkEqualSumUtil ( arr , N , sm1 , sm2 , sm3 + arr [ j ] , j + 1 ) ; return Math . Max ( Math . Max ( l , m ) , r ) ; } } static void checkEqualSum ( int [ ] arr , int N ) { int sum1 , sum2 , sum3 ; sum1 = sum2 = sum3 = 0 ; if ( checkEqualSumUtil ( arr , N , sum1 , sum2 , sum3 , 0 ) == 1 ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } public static void Main ( ) { int [ ] arr = { 17 , 34 , 59 , 23 , 17 , 67 , 57 , 2 , 18 , 59 , 1 } ; int N = arr . Length ; checkEqualSum ( arr , N ) ; } }

Index/key variables: j
Class/struct names: GFG