dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int n = 3 ; static int m = 4 ; static int maxMatrixScore ( int [ , ] A , int K ) { Dictionary < int , int > update = new Dictionary < int , int > ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( A [ i , 0 ] == 0 ) { ans = 0 ; for ( int j = 1 ; j < m ; ++ j ) ans = ( int ) ( ans + A [ i , j ] * Math . Pow ( 2 , m - j - 1 ) ) ; update . Add ( ( int ) ans , i ) ; } } foreach ( KeyValuePair < int , int > it in update ) if ( K > 0 ) { int idx = it . Value ; for ( int j = 0 ; j < m ; ++ j ) A [ idx , j ] = ( A [ idx , j ] + 1 ) % 2 ; K -- ; } ans = 0 ; for ( int j = 0 ; j < m ; ++ j ) { int zero = 0 , one = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( A [ i , j ] == 0 ) zero ++ ; else one ++ ; } if ( K > 0 && zero > one ) { ans += zero * ( int ) Math . Pow ( 2 , m - j - 1 ) ; K -- ; } else ans += one * ( int ) Math . Pow ( 2 , m - j - 1 ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ , ] A = { { 0 , 0 , 1 , 1 } , { 1 , 0 , 1 , 0 } , { 1 , 1 , 0 , 0 } } ; int K = 2 ; Console . Write ( maxMatrixScore ( A , K ) ) ; } }

Accumulator variables: K, ans, one, zero
Iterator variables: i, it, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSellingPossible ( int n , int [ ] a ) { int i , c25 = 0 , c50 = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 25 ) c25 ++ ; else if ( a [ i ] == 50 ) { c50 ++ ; if ( c25 == 0 ) break ; c25 -- ; } else { if ( c50 > 0 && c25 > 0 ) { c50 -- ; c25 -- ; } else if ( c25 >= 3 ) c25 -= 3 ; else break ; } } if ( i == n ) return true ; else return false ; } public static void Main ( ) { int [ ] a = { 25 , 25 , 50 , 100 } ; int n = a . Length ; if ( isSellingPossible ( n , a ) ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Index/key variables: i
Accumulator variables: c25, c50, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkIfOverlap ( String str ) { int len = str . Length ; int [ ] visited = new int [ len + 1 ] ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' . ' ) continue ; for ( int j = Math . Max ( 0 , i - str [ i ] ) ; j <= Math . Min ( len , i + str [ i ] ) ; j ++ ) visited [ j ] ++ ; } for ( int i = 0 ; i < len ; i ++ ) { if ( visited [ i ] > 1 ) { return true ; } } return false ; } public static void Main ( ) { String str = " . 2 . . 2 . " ; if ( checkIfOverlap ( str ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isCorrectOrder ( int n ) { bool flag = true ; int prev = - 1 ; int type = - 1 ; while ( n != 0 ) { if ( type == - 1 ) { if ( prev == - 1 ) { prev = n % 10 ; n = n / 10 ; continue ; } if ( prev == n % 10 ) { flag = false ; break ; } if ( prev > n % 10 ) { type = 1 ; prev = n % 10 ; n = n / 10 ; continue ; } prev = n % 10 ; n = n / 10 ; } else { if ( prev == n % 10 ) { flag = false ; break ; } if ( prev < n % 10 ) { flag = false ; break ; } prev = n % 10 ; n = n / 10 ; } } return flag ; } public static void Main ( ) { int n = 123454321 ; if ( isCorrectOrder ( n ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static void printCoins ( int [ ] arr , int n ) { int oddSum = 0 ; for ( int i = 0 ; i < n ; i += 2 ) oddSum += arr [ i ] ; int evenSum = 0 ; for ( int i = 1 ; i < n ; i += 2 ) evenSum += arr [ i ] ; int start = ( ( oddSum > evenSum ) ? 0 : 1 ) ; for ( int i = start ; i < n ; i += 2 ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr1 = { 8 , 15 , 3 , 7 } ; int n = arr1 . Length ; printCoins ( arr1 , n ) ; Console . Write ( " STRNEWLINE " ) ; int [ ] arr2 = { 2 , 2 , 2 , 2 } ; n = arr2 . Length ; printCoins ( arr2 , n ) ; Console . Write ( " STRNEWLINE " ) ; int [ ] arr3 = { 20 , 30 , 2 , 2 , 2 , 10 } ; n = arr3 . Length ; printCoins ( arr3 , n ) ; } }

Index/key variables: i
Accumulator variables: evenSum, i, oddSum
Iterator variables: i
Class/struct names: GFG
C# program:
class GFG { static void finalPos ( string command , int n , int x , int y ) { int cup , cdown , cleft , cright ; int final_x , final_y ; cup = cdown = cleft = cright = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( command [ i ] == ' U ' ) cup ++ ; else if ( command [ i ] == ' D ' ) cdown ++ ; else if ( command [ i ] == ' L ' ) cleft ++ ; else if ( command [ i ] == ' R ' ) cright ++ ; } final_x = x + ( cright - cleft ) ; final_y = y + ( cdown - cup ) ; System . Console . WriteLine ( " Final ▁ Position : ▁ " + " ( " + final_x + " , ▁ " + final_y + " ) " ) ; } public static void Main ( ) { string command = " DDLRULL " ; int n = command . Length ; int x = 3 , y = 4 ; finalPos ( command , n , x , y ) ; } }

Index/key variables: i
Accumulator variables: cdown, cleft, cright, cup, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int V = 5 ; static int INT_MAX = int . MaxValue ; static bool isValidEdge ( int u , int v , bool [ ] inMST ) { if ( u == v ) return false ; if ( inMST [ u ] == false && inMST [ v ] == false ) return false ; else if ( inMST [ u ] == true && inMST [ v ] == true ) return false ; return true ; } static void primMST ( int [ , ] cost ) { bool [ ] inMST = new bool [ V ] ; inMST [ 0 ] = true ; int edge_count = 0 , mincost = 0 ; while ( edge_count < V - 1 ) { int min = INT_MAX , a = - 1 , b = - 1 ; for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { if ( cost [ i , j ] < min ) { if ( isValidEdge ( i , j , inMST ) ) { min = cost [ i , j ] ; a = i ; b = j ; } } } } if ( a != - 1 && b != - 1 ) { Console . Write ( " Edge ▁ { 0 } : ( { 1 } , ▁ { 2 } ) ▁ cost : ▁ { 3 } ▁ STRNEWLINE " , edge_count ++ , a , b , min ) ; mincost = mincost + min ; inMST [ b ] = inMST [ a ] = true ; } } Console . Write ( " cost = { 0 } " , mincost ) ; } public static void Main ( String [ ] args ) { int [ , ] cost = { { INT_MAX , 2 , INT_MAX , 6 , INT_MAX } , { 2 , INT_MAX , 3 , 8 , 5 } , { INT_MAX , 3 , INT_MAX , INT_MAX , 7 } , { 6 , 8 , INT_MAX , INT_MAX , 9 } , { INT_MAX , 5 , 7 , 9 , INT_MAX } } ; primMST ( cost ) ; } }

Index/key variables: V, a, b, u, v
Accumulator variables: edge_count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findLandB ( int [ ] arr , int n ) { Array . Sort ( arr ) ; List < Double > arr_pairs = new List < Double > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { arr_pairs . Add ( ( double ) arr [ i ] ) ; i ++ ; } } double length = arr_pairs [ 0 ] ; double breadth = arr_pairs [ 1 ] ; double size = arr_pairs . Count ; for ( int i = 2 ; i < size ; i ++ ) { if ( ( length / breadth + breadth / length ) > ( arr_pairs [ i ] / arr_pairs [ i - 1 ] + arr_pairs [ i - 1 ] / arr_pairs [ i ] ) ) { length = arr_pairs [ i ] ; breadth = arr_pairs [ i - 1 ] ; } } Console . Write ( ( int ) length + " , ▁ " + ( int ) breadth + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 2 , 2 , 5 , 6 , 5 , 6 , 7 , 2 } ; int n = arr . Length ; findLandB ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int smallestSumSubarr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = - arr [ i ] ; int sum_here = arr [ 0 ] , max_sum = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { sum_here = Math . Max ( sum_here + arr [ i ] , arr [ i ] ) ; max_sum = Math . Max ( max_sum , sum_here ) ; } return ( - 1 ) * max_sum ; } public static void Main ( ) { int [ ] arr = { 3 , - 4 , 2 , - 3 , - 1 , 7 , - 5 } ; int n = arr . Length ; Console . WriteLine ( " Smallest ▁ sum : ▁ " + smallestSumSubarr ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public class _pair { public int first , second ; } ; static void printKPairs ( int [ ] a1 , int [ ] a2 , int size1 , int size2 , int k ) { if ( k > ( size2 * size1 ) ) { Console . Write ( " k ▁ pairs ▁ don ' t ▁ exist STRNEWLINE " ) ; return ; } _pair _one = new _pair ( ) ; _pair _two = new _pair ( ) ; _one . first = _one . second = _two . first = _two . second = 0 ; int cnt = 0 ; while ( cnt < k ) { if ( _one . first == _two . second && _two . first == _one . second ) { if ( a1 [ _one . first ] < a2 [ _one . second ] ) { Console . Write ( " [ " + a1 [ _one . first ] + " , ▁ " + a2 [ _one . second ] + " ] ▁ " ) ; _one . second = ( _one . second + 1 ) % size2 ; if ( _one . second == 0 ) _one . first = ( _one . first + 1 ) % size1 ; _two . second = ( _two . second + 1 ) % size2 ; if ( _two . second == 0 ) _two . first = ( _two . first + 1 ) % size2 ; } else { Console . Write ( " [ " + a2 [ _one . second ] + " , ▁ " + a1 [ _one . first ] + " ] ▁ " ) ; _one . first = ( _one . first + 1 ) % size1 ; if ( _one . first == 0 ) _one . second = ( _one . second + 1 ) % size2 ; _two . first = ( _two . first + 1 ) % size2 ; if ( _two . first == 0 ) _two . second = ( _two . second + 1 ) % size1 ; } } else if ( a1 [ _one . first ] + a2 [ _one . second ] <= a2 [ _two . first ] + a1 [ _two . second ] ) { if ( a1 [ _one . first ] < a2 [ _one . second ] ) { Console . Write ( " [ " + a1 [ _one . first ] + " , ▁ " + a2 [ _one . second ] + " ] ▁ " ) ; _one . second = ( ( _one . second + 1 ) % size2 ) ; if ( _one . second == 0 ) _one . first = ( _one . first + 1 ) % size1 ; } else { Console . Write ( " [ " + a2 [ _one . second ] + " , ▁ " + a1 [ _one . first ] + " ] ▁ " ) ; _one . first = ( ( _one . first + 1 ) % size1 ) ; if ( _one . first == 0 ) _one . second = ( _one . second + 1 ) % size2 ; } } else if ( a1 [ _one . first ] + a2 [ _one . second ] > a2 [ _two . first ] + a1 [ _two . second ] ) { if ( a2 [ _two . first ] < a1 [ _two . second ] ) { Console . Write ( " [ " + a2 [ _two . first ] + " , ▁ " + a1 [ _two . second ] + " ] ▁ " ) ; _two . first = ( ( _two . first + 1 ) % size2 ) ; if ( _two . first == 0 ) _two . second = ( _two . second + 1 ) % size1 ; } else { Console . Write ( " [ " + a1 [ _two . second ] + " , ▁ " + a2 [ _two . first ] + " ] ▁ " ) ; _two . second = ( ( _two . second + 1 ) % size1 ) ; if ( _two . second == 0 ) _two . first = ( _two . first + 1 ) % size1 ; } } cnt ++ ; } } public static void Main ( String [ ] args ) { int [ ] a1 = { 2 , 3 , 4 } ; int [ ] a2 = { 1 , 6 , 5 , 8 } ; int size1 = a1 . Length ; int size2 = a2 . Length ; int k = 4 ; printKPairs ( a1 , a2 , size1 , size2 , k ) ; } }

Accumulator variables: cnt
Class/struct names: GFG, _pair
C# program:
using System ; class GFG { static void printLargest ( int [ ] a , int n ) { int max = - 1 ; int ind = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int num = a [ i ] ; while ( num > 0 ) { int r = num % 10 ; num = num / 10 ; if ( num == 0 ) { if ( max < r ) { max = r ; ind = i ; } } } } for ( int i = ind ; i < n ; i ++ ) Console . Write ( a [ i ] ) ; for ( int i = 0 ; i < ind ; i ++ ) Console . Write ( a [ i ] ) ; } public static void Main ( ) { int [ ] a = { 54 , 546 , 548 , 60 } ; int n = 4 ; printLargest ( a , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { class pair { public double first , second ; public pair ( double first , double second ) { this . first = first ; this . second = second ; } } static void construct ( int n , pair ans_pair ) { if ( ans_pair . first == - 1 ) { Console . Write ( " Not ▁ possible " ) ; return ; } double a1 = ans_pair . first ; double a2 = ans_pair . second ; double r = a2 / a1 ; Console . Write ( " The ▁ resultant ▁ sequence ▁ is : STRNEWLINE " ) ; for ( int i = 1 ; i <= n ; i ++ ) { int ai = ( int ) ( a1 * Math . Pow ( r , i - 1 ) ) ; Console . Write ( ai + " ▁ " ) ; } } static void findMinimumOperations ( double [ ] a , int n ) { int ans = int . MaxValue ; int [ ] c = { - 1 , 0 , 1 } ; int possibilities = 3 ; int pos1 = - 1 , pos2 = - 1 ; for ( int i = 0 ; i < possibilities ; i ++ ) { for ( int j = 0 ; j < possibilities ; j ++ ) { double a1 = a [ 1 ] + c [ i ] ; double a2 = a [ 2 ] + c [ j ] ; int temp = ( int ) ( Math . Abs ( a1 - a [ 1 ] ) + Math . Abs ( a2 - a [ 2 ] ) ) ; if ( a1 == 0 a2 == 0 ) continue ; double r = a2 / a1 ; for ( int pos = 3 ; pos <= n ; pos ++ ) { double ai = a1 * Math . Pow ( r , pos - 1 ) ; if ( a [ pos ] == ai ) { continue ; } else if ( a [ pos ] + 1 == ai a [ pos ] - 1 == ai ) { temp ++ ; } else { temp = int . MaxValue ; break ; } } if ( temp < ans ) { ans = temp ; pos1 = ( int ) a1 ; pos2 = ( int ) a2 ; } } } if ( ans == - 1 ) { Console . Write ( " - 1" ) ; return ; } Console . Write ( " Minimum ▁ Number ▁ of ▁ Operations ▁ are ▁ " + ans + " STRNEWLINE " ) ; pair ans_pair = new pair ( pos1 , pos2 ) ; construct ( n , ans_pair ) ; } public static void Main ( String [ ] args ) { double [ ] a = { 0 , 7 , 20 , 49 , 125 } ; int n = a . Length ; findMinimumOperations ( a , n - 1 ) ; } }

Index/key variables: i, j, pos
Accumulator variables: i, j, pos, temp
Iterator variables: i, j, pos
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static void findOrderMRT ( int [ ] L , int n ) { Array . Sort ( L ) ; Console . Write ( " Optimal ▁ order ▁ in ▁ " + " which ▁ programs ▁ are " + " ▁ to ▁ be ▁ stored ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( L [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; double MRT = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j <= i ; j ++ ) sum += L [ j ] ; MRT += sum ; } MRT /= n ; Console . WriteLine ( " Minimum ▁ Retrieval ▁ " + " Time ▁ of ▁ this ▁ order ▁ is ▁ " + MRT ) ; } public static void Main ( ) { int [ ] L = { 2 , 5 , 4 } ; int n = L . Length ; findOrderMRT ( L , n ) ; } }

Index/key variables: i, j
Accumulator variables: MRT, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MinOperation ( int [ ] a , int n , int k ) { int result = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( a [ i ] != 1 && a [ i ] > k ) { result = result + Math . Min ( a [ i ] % k , k - a [ i ] % k ) ; } else { result = result + k - a [ i ] ; } } return result ; } static public void Main ( ) { int [ ] arr = { 4 , 5 , 6 } ; int n = arr . Length ; int k = 5 ; Console . WriteLine ( MinOperation ( arr , n , k ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProductSubset ( int [ ] a , int n ) { if ( n == 1 ) { return a [ 0 ] ; } int max_neg = int . MinValue ; int count_neg = 0 , count_zero = 0 ; int prod = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { count_zero ++ ; continue ; } if ( a [ i ] < 0 ) { count_neg ++ ; max_neg = Math . Max ( max_neg , a [ i ] ) ; } prod = prod * a [ i ] ; } if ( count_zero == n ) { return 0 ; } if ( count_neg % 2 == 1 ) { if ( count_neg == 1 && count_zero > 0 && count_zero + count_neg == n ) { return 0 ; } prod = prod / max_neg ; } return prod ; } public static void Main ( ) { int [ ] a = { - 1 , - 1 , - 2 , 4 , 3 } ; int n = a . Length ; Console . Write ( maxProductSubset ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count_neg, count_zero, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void calcFiboTerms ( List < int > fiboterms , int k ) { int i = 3 , nextTerm = 0 ; fiboterms . Add ( 0 ) ; fiboterms . Add ( 1 ) ; fiboterms . Add ( 1 ) ; while ( true ) { nextTerm = fiboterms [ i - 1 ] + fiboterms [ i - 2 ] ; if ( nextTerm > k ) return ; fiboterms . Add ( nextTerm ) ; i ++ ; } } public static int fibMinTerms ( int k ) { List < int > fiboterms = new List < int > ( ) ; calcFiboTerms ( fiboterms , k ) ; int count = 0 , j = fiboterms . Count - 1 ; while ( k > 0 ) { count += ( k / fiboterms [ j ] ) ; k %= ( fiboterms [ j ] ) ; j -- ; } return count ; } public static void Main ( String [ ] args ) { int k = 17 ; Console . WriteLine ( fibMinTerms ( k ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void digitsNum ( int N ) { if ( N == 0 ) Console . Write ( "0" ) ; if ( N % 9 != 0 ) Console . Write ( ( N % 9 ) ) ; for ( int i = 1 ; i <= ( N / 9 ) ; ++ i ) Console . Write ( "9" ) ; for ( int i = 1 ; i <= N ; ++ i ) Console . Write ( "0" ) ; Console . WriteLine ( " " ) ; } public static void Main ( ) { int N = 5 ; Console . Write ( " The ▁ number ▁ is ▁ : ▁ " ) ; digitsNum ( N ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void printVector ( ArrayList v ) { Console . WriteLine ( v . Count ) ; for ( int i = 0 ; i < v . Count ; i ++ ) Console . Write ( v [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } static void findTwoGroup ( int n ) { int sum = n * ( n + 1 ) / 2 ; int group1Sum = sum / 2 ; ArrayList group1 = new ArrayList ( ) ; ArrayList group2 = new ArrayList ( ) ; for ( int i = n ; i > 0 ; i -- ) { if ( group1Sum - i >= 0 ) { group1 . Add ( i ) ; group1Sum -= i ; } else { group2 . Add ( i ) ; } } printVector ( group1 ) ; printVector ( group2 ) ; } public static void Main ( ) { int n = 5 ; findTwoGroup ( n ) ; } }

Index/key variables: i
Accumulator variables: group1Sum, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxDifference ( int [ ] arr , int N , int k ) { int M , S = 0 , S1 = 0 , max_difference = 0 ; for ( int i = 0 ; i < N ; i ++ ) S += arr [ i ] ; int temp ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] < arr [ j ] ) { temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } } M = Math . Max ( k , N - k ) ; for ( int i = 0 ; i < M ; i ++ ) S1 += arr [ i ] ; max_difference = S1 - ( S - S1 ) ; return max_difference ; } public static void Main ( ) { int [ ] arr = { 8 , 4 , 5 , 2 , 10 } ; int N = arr . Length ; int k = 2 ; Console . Write ( maxDifference ( arr , N , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: S, S1, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minproduct ( int [ ] a , int [ ] b , int n , int k ) { int diff = 0 , res = 0 ; int temp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int pro = a [ i ] * b [ i ] ; res = res + pro ; if ( pro < 0 && b [ i ] < 0 ) temp = ( a [ i ] + 2 * k ) * b [ i ] ; else if ( pro < 0 && a [ i ] < 0 ) temp = ( a [ i ] - 2 * k ) * b [ i ] ; else if ( pro > 0 && a [ i ] < 0 ) temp = ( a [ i ] + 2 * k ) * b [ i ] ; else if ( pro > 0 && a [ i ] > 0 ) temp = ( a [ i ] - 2 * k ) * b [ i ] ; int d = Math . Abs ( pro - temp ) ; if ( d > diff ) diff = d ; } return res - diff ; } public static void Main ( ) { int [ ] a = { 2 , 3 , 4 , 5 , 4 } ; int [ ] b = { 3 , 4 , 2 , 3 , 2 } ; int n = 5 , k = 3 ; Console . WriteLine ( minproduct ( a , b , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( int n ) { if ( n < 4 ) return - 1 ; int rem = n % 4 ; if ( rem == 0 ) return n / 4 ; if ( rem == 1 ) { if ( n < 9 ) return - 1 ; return ( n - 9 ) / 4 + 1 ; } if ( rem == 2 ) return ( n - 6 ) / 4 + 1 ; if ( rem == 3 ) { if ( n < 15 ) return - 1 ; return ( n - 15 ) / 4 + 2 ; } return 0 ; } public static void Main ( ) { int n = 90 ; Console . WriteLine ( count ( n ) ) ; n = 143 ; Console . WriteLine ( count ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int minRotation ( int input , int unlock_code ) { int rotation = 0 ; int input_digit , code_digit ; while ( input > 0 unlock_code > 0 ) { input_digit = input % 10 ; code_digit = unlock_code % 10 ; rotation += Math . Min ( Math . Abs ( input_digit - code_digit ) , 10 - Math . Abs ( input_digit - code_digit ) ) ; input /= 10 ; unlock_code /= 10 ; } return rotation ; } public static void Main ( ) { int input = 28756 ; int unlock_code = 98234 ; Console . Write ( " Minimum ▁ Rotation ▁ = ▁ " + minRotation ( input , unlock_code ) ) ; } }

Accumulator variables: input, rotation, unlock_code
Class/struct names: GFG
C# program:
using System ; public class GFG { static void preprocess ( int [ ] coin , int n ) { Array . Sort ( coin ) ; for ( int i = 1 ; i <= n - 1 ; i ++ ) coin [ i ] += coin [ i - 1 ] ; } static int minCost ( int [ ] coin , int n , int k ) { int coins_needed = ( int ) Math . Ceiling ( 1.0 * n / ( k + 1 ) ) ; return coin [ coins_needed - 1 ] ; } static public void Main ( ) { int [ ] coin = { 8 , 5 , 3 , 10 , 2 , 1 , 15 , 25 } ; int n = coin . Length ; preprocess ( coin , n ) ; int k = 3 ; Console . WriteLine ( minCost ( coin , n , k ) ) ; k = 7 ; Console . WriteLine ( minCost ( coin , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void worstFit ( int [ ] blockSize , int m , int [ ] processSize , int n ) { int [ ] allocation = new int [ n ] ; for ( int i = 0 ; i < allocation . Length ; i ++ ) allocation [ i ] = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int wstIdx = - 1 ; for ( int j = 0 ; j < m ; j ++ ) { if ( blockSize [ j ] >= processSize [ i ] ) { if ( wstIdx == - 1 ) wstIdx = j ; else if ( blockSize [ wstIdx ] < blockSize [ j ] ) wstIdx = j ; } } if ( wstIdx != - 1 ) { allocation [ i ] = wstIdx ; blockSize [ wstIdx ] -= processSize [ i ] ; } } Console . WriteLine ( " STRNEWLINE Process ▁ No . TABSYMBOL Process ▁ Size TABSYMBOL Block ▁ no . " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( " ▁ " + ( i + 1 ) + " TABSYMBOL TABSYMBOL TABSYMBOL " + processSize [ i ] + " TABSYMBOL TABSYMBOL TABSYMBOL " ) ; if ( allocation [ i ] != - 1 ) Console . Write ( allocation [ i ] + 1 ) ; else Console . Write ( " Not ▁ Allocated " ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ ] blockSize = { 100 , 500 , 200 , 300 , 600 } ; int [ ] processSize = { 212 , 417 , 112 , 426 } ; int m = blockSize . Length ; int n = processSize . Length ; worstFit ( blockSize , m , processSize , n ) ; } }

Index/key variables: i, j, n, wstIdx
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumSum ( int [ ] arr , int n , int k ) { for ( int i = 1 ; i <= k ; i ++ ) { int min = + 2147483647 ; int index = - 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] < min ) { min = arr [ j ] ; index = j ; } } if ( min == 0 ) break ; arr [ index ] = - arr [ index ] ; } int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return sum ; } public static void Main ( ) { int [ ] arr = { - 2 , 0 , 5 , - 1 , 2 } ; int k = 4 ; int n = arr . Length ; Console . Write ( maximumSum ( arr , n , k ) ) ; } }

Index/key variables: i, index, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int sol ( int [ ] arr , int k ) { Array . Sort ( arr ) ; int sum = 0 ; int i = 0 ; while ( k > 0 ) { if ( arr [ i ] >= 0 ) k = 0 ; else { arr [ i ] = ( - 1 ) * arr [ i ] ; k = k - 1 ; } i ++ ; } for ( int j = 0 ; j < arr . Length ; j ++ ) { sum += arr [ j ] ; } return sum ; } public static void Main ( string [ ] args ) { int [ ] arr = { - 2 , 0 , 5 , - 1 , 2 } ; Console . Write ( sol ( arr , 4 ) ) ; } }

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