dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int Segment ( int [ ] x , int [ ] l , int n ) { if ( n == 1 ) return 1 ; int ans = 2 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( x [ i ] - l [ i ] > x [ i - 1 ] ) ans ++ ; else if ( x [ i ] + l [ i ] < x [ i + 1 ] ) { x [ i ] = x [ i ] + l [ i ] ; ans ++ ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] x = { 1 , 3 , 4 , 5 , 8 } ; int [ ] l = { 10 , 1 , 2 , 2 , 5 } ; int n = x . Length ; Console . WriteLine ( Segment ( x , l , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MinimizeleftOverSum ( int [ ] a , int n ) { List < int > v1 = new List < int > ( ) , v2 = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) v1 . Add ( a [ i ] ) ; else v2 . Add ( a [ i ] ) ; } if ( v1 . Count > v2 . Count ) { v1 . Sort ( ) ; v2 . Sort ( ) ; int x = v1 . Count - v2 . Count - 1 ; int sum = 0 ; int i = 0 ; while ( i < x ) { sum += v1 [ i ++ ] ; } return sum ; } else if ( v2 . Count > v1 . Count ) { v1 . Sort ( ) ; v2 . Sort ( ) ; int x = v2 . Count - v1 . Count - 1 ; int sum = 0 ; int i = 0 ; while ( i < x ) { sum += v2 [ i ++ ] ; } return sum ; } else return 0 ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 2 , 2 , 2 } ; int n = a . Length ; Console . WriteLine ( MinimizeleftOverSum ( a , 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 void minOperation ( string S , int N , int K ) { if ( N % K != 0 ) { Console . WriteLine ( " Not ▁ Possible " ) ; } else { int [ ] count = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { count [ ( S [ i ] - 97 ) ] ++ ; } int E = N / K ; List < int > greaterE = new List < int > ( ) ; List < int > lessE = new List < int > ( ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( count [ i ] < E ) lessE . Add ( E - count [ i ] ) ; else greaterE . Add ( count [ i ] - E ) ; } greaterE . Sort ( ) ; lessE . Sort ( ) ; int mi = Int32 . MaxValue ; for ( int i = 0 ; i <= K ; i ++ ) { int set1 = i ; int set2 = K - i ; if ( greaterE . Count >= set1 && lessE . Count >= set2 ) { int step1 = 0 ; int step2 = 0 ; for ( int j = 0 ; j < set1 ; j ++ ) step1 += greaterE [ j ] ; for ( int j = 0 ; j < set2 ; j ++ ) step2 += lessE [ j ] ; mi = Math . Min ( mi , Math . Max ( step1 , step2 ) ) ; } } Console . WriteLine ( mi ) ; } } public static void Main ( ) { string S = " accb " ; int N = S . Length ; int K = 2 ; minOperation ( S , N , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, step1, step2
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minMovesToSort ( int [ ] arr , int n ) { int moves = 0 ; int i , mn = arr [ n - 1 ] ; for ( i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > mn ) moves += arr [ i ] - mn ; } return moves ; } static public void Main ( ) { int [ ] arr = { 3 , 5 , 2 , 8 , 4 } ; int n = arr . Length ; Console . WriteLine ( minMovesToSort ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, moves
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool [ ] prime = new bool [ 100005 ] ; static void SieveOfEratosthenes ( int n ) { for ( int i = 0 ; i < 100005 ; i ++ ) prime [ i ] = true ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i < n ; i += p ) { prime [ i ] = false ; } } } } static void sortPrimes ( int [ ] arr , int n ) { SieveOfEratosthenes ( 100005 ) ; List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { v . Add ( arr [ i ] ) ; } } v . Sort ( ) ; v . Reverse ( ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { arr [ i ] = v [ j ++ ] ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 3 , 2 , 6 , 100 , 17 } ; int n = arr . Length ; sortPrimes ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i, p
Accumulator variables: i, j, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findOptimalPairs ( int [ ] arr , int N ) { Array . Sort ( arr ) ; for ( int i = 0 , j = N - 1 ; i <= j ; i ++ , j -- ) Console . Write ( " ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) " + " ▁ " ) ; } static public void Main ( ) { int [ ] arr = { 9 , 6 , 5 , 1 } ; int N = arr . Length ; findOptimalPairs ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countBits ( int a ) { int count = 0 ; while ( a > 0 ) { if ( ( a & 1 ) > 0 ) count += 1 ; a = a >> 1 ; } return count ; } static void insertionSort ( int [ ] arr , int [ ] aux , int n ) { for ( int i = 1 ; i < n ; i ++ ) { int key1 = aux [ i ] ; int key2 = arr [ i ] ; int j = i - 1 ; while ( j >= 0 && aux [ j ] < key1 ) { aux [ j + 1 ] = aux [ j ] ; arr [ j + 1 ] = arr [ j ] ; j = j - 1 ; } aux [ j + 1 ] = key1 ; arr [ j + 1 ] = key2 ; } } static void sortBySetBitCount ( int [ ] arr , int n ) { int [ ] aux = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) aux [ i ] = countBits ( arr [ i ] ) ; insertionSort ( arr , aux , n ) ; } static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; sortBySetBitCount ( arr , n ) ; printArr ( arr , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countBits ( int a ) { int count = 0 ; while ( a > 0 ) { if ( ( a & 1 ) > 0 ) count += 1 ; a = a >> 1 ; } return count ; } static void sortBySetBitCount ( int [ ] arr , int n ) { List < int > [ ] count = new List < int > [ 32 ] ; for ( int i = 0 ; i < count . Length ; i ++ ) count [ i ] = new List < int > ( ) ; int setbitcount = 0 ; for ( int i = 0 ; i < n ; i ++ ) { setbitcount = countBits ( arr [ i ] ) ; count [ setbitcount ] . Add ( arr [ i ] ) ; } int j = 0 ; for ( int i = 31 ; i >= 0 ; i -- ) { List < int > v1 = count [ i ] ; for ( int p = 0 ; p < v1 . Count ; p ++ ) arr [ j ++ ] = v1 [ p ] ; } } static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; sortBySetBitCount ( arr , n ) ; printArr ( arr , n ) ; } }

Index/key variables: i, p, setbitcount
Accumulator variables: count, i, j, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void generateString ( int k1 , int k2 , char [ ] s ) { int C1s = 0 , C0s = 0 ; int flag = 0 ; List < int > pos = new List < int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '0' ) { C0s ++ ; if ( ( i + 1 ) % k1 != 0 && ( i + 1 ) % k2 != 0 ) { pos . Add ( i ) ; } } else { C1s ++ ; } if ( C0s >= C1s ) { if ( pos . Count == 0 ) { Console . WriteLine ( - 1 ) ; flag = 1 ; break ; } else { int k = pos [ ( pos . Count - 1 ) ] ; s [ k ] = '1' ; C0s -- ; C1s ++ ; pos . Remove ( pos . Count - 1 ) ; } } } if ( flag == 0 ) { Console . WriteLine ( s ) ; } } public static void Main ( ) { int K1 = 2 , K2 = 4 ; string S = "11000100" ; generateString ( K1 , K2 , S . ToCharArray ( ) ) ; } }

Index/key variables: i, k
Accumulator variables: C0s, C1s, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maximizeProduct ( int N ) { int MSB = ( int ) ( Math . Log ( N ) / Math . Log ( 2 ) ) ; int X = 1 << MSB ; int Y = N - ( 1 << MSB ) ; for ( int i = 0 ; i < MSB ; i ++ ) { if ( ( N & ( 1 << i ) ) == 0 ) { X += 1 << i ; Y += 1 << i ; } } Console . Write ( X + " ▁ " + Y ) ; } public static void Main ( ) { int N = 45 ; maximizeProduct ( N ) ; } }

Accumulator variables: X, Y, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool check ( int num ) { int sm = 0 ; int num2 = num * num ; while ( num > 0 ) { sm += num % 10 ; num /= 10 ; } int sm2 = 0 ; while ( num2 > 0 ) { sm2 += num2 % 10 ; num2 /= 10 ; } return ( ( sm * sm ) == sm2 ) ; } static int convert ( string s ) { int val = 0 ; char [ ] charArray = s . ToCharArray ( ) ; Array . Reverse ( charArray ) ; s = new string ( charArray ) ; int cur = 1 ; for ( int i = 0 ; i < s . Length ; i ++ ) { val += ( ( int ) s [ i ] - ( int ) '0' ) * cur ; cur *= 10 ; } return val ; } static void generate ( string s , int len , HashSet < int > uniq ) { if ( s . Length == len ) { if ( check ( convert ( s ) ) ) { uniq . Add ( convert ( s ) ) ; } return ; } for ( int i = 0 ; i <= 3 ; i ++ ) { generate ( s + Convert . ToChar ( i + ( int ) '0' ) , len , uniq ) ; } } static int totalNumbers ( int L , int R ) { int ans = 0 ; int max_len = ( int ) Math . Log10 ( R ) + 1 ; HashSet < int > uniq = new HashSet < int > ( ) ; for ( int i = 1 ; i <= max_len ; i ++ ) { generate ( " " , i , uniq ) ; } foreach ( int x in uniq ) { if ( x >= L && x <= R ) { ans ++ ; } } return ans ; } public static void Main ( ) { int L = 22 , R = 22 ; Console . Write ( totalNumbers ( L , R ) ) ; } }

Index/key variables: i
Accumulator variables: ans, cur, i, num, num2, sm, sm2, val
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void convertXintoY ( int X , int Y ) { while ( Y > X ) { if ( Y % 2 == 0 ) Y /= 2 ; else if ( Y % 10 == 1 ) Y /= 10 ; else break ; } if ( X == Y ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( String [ ] args ) { int X = 100 , Y = 40021 ; convertXintoY ( X , Y ) ; } }

Accumulator variables: Y
Class/struct names: GFG
C# program:
using System ; class GFG { static void generateString ( int K ) { string s = " " ; for ( int i = 97 ; i < 97 + K ; i ++ ) { s = s + ( char ) ( i ) ; for ( int j = i + 1 ; j < 97 + K ; j ++ ) { s += ( char ) ( i ) ; s += ( char ) ( j ) ; } } s += ( char ) ( 97 ) ; Console . Write ( s ) ; } public static void Main ( ) { int K = 4 ; generateString ( K ) ; } }

Accumulator variables: i, j, s
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void findEquation ( int S , int M ) { Console . Write ( "1 ▁ " + ( ( - 1 ) * S ) + " ▁ " + M ) ; } static void Main ( ) { int S = 5 , M = 6 ; findEquation ( S , M ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minSteps ( List < int > a , int n ) { int [ ] prefix_sum = new int [ n ] ; prefix_sum [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefix_sum [ i ] += prefix_sum [ i - 1 ] + a [ i ] ; int mx = - 1 ; foreach ( int subgroupsum in prefix_sum ) { int sum = 0 ; int i = 0 ; int grp_count = 0 ; while ( i < n ) { sum += a [ i ] ; if ( sum == subgroupsum ) { grp_count += 1 ; sum = 0 ; } else if ( sum > subgroupsum ) { grp_count = - 1 ; break ; } i += 1 ; } if ( grp_count > mx ) mx = grp_count ; } return n - mx ; } public static void Main ( ) { List < int > A = new List < int > ( ) { 1 , 2 , 3 , 2 , 1 , 3 } ; int N = A . Count ; Console . Write ( minSteps ( A , N ) ) ; } }

Index/key variables: i, n
Accumulator variables: grp_count, i, sum
Iterator variables: i, subgroupsum
Class/struct names: GFG
C# program:
using System ; public class GFG { public static void maxOccuringCharacter ( string s ) { int count0 = 0 , count1 = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' ) { count1 ++ ; } else if ( s [ i ] == '0' ) { count0 ++ ; } } int prev = - 1 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' ) { prev = i ; break ; } } for ( int i = prev + 1 ; i < s . Length ; i ++ ) { if ( s [ i ] != ' X ' ) { if ( s [ i ] == '1' ) { count1 += i - prev - 1 ; prev = i ; } else { bool flag = true ; for ( int j = i + 1 ; j < s . Length ; j ++ ) { if ( s [ j ] == '1' ) { flag = false ; prev = j ; break ; } } if ( ! flag ) { i = prev ; } else { i = s . Length ; } } } } prev = - 1 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '0' ) { prev = i ; break ; } } for ( int i = prev + 1 ; i < s . Length ; i ++ ) { if ( s [ i ] != ' X ' ) { if ( s [ i ] == '0' ) { count0 += i - prev - 1 ; prev = i ; } else { bool flag = true ; for ( int j = i + 1 ; j < s . Length ; j ++ ) { if ( s [ j ] == '0' ) { prev = j ; flag = false ; break ; } } if ( ! flag ) { i = prev ; } else { i = s . Length ; } } } } if ( s [ 0 ] == ' X ' ) { int count = 0 ; int i = 0 ; while ( s [ i ] == ' X ' ) { count ++ ; i ++ ; } if ( s [ i ] == '1' ) { count1 += count ; } } if ( s [ s . Length - 1 ] == ' X ' ) { int count = 0 ; int i = s . Length - 1 ; while ( s [ i ] == ' X ' ) { count ++ ; i -- ; } if ( s [ i ] == '0' ) { count0 += count ; } } if ( count0 == count1 ) { Console . WriteLine ( " X " ) ; } else if ( count0 > count1 ) { Console . WriteLine ( 0 ) ; } else Console . WriteLine ( 1 ) ; } public static void Main ( string [ ] args ) { string S = " XX10XX10XXX1XX " ; maxOccuringCharacter ( S ) ; } }

Index/key variables: i, j
Accumulator variables: count, count0, count1, i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSheets ( int A , int B ) { int area = A * B ; int count = 1 ; while ( area % 2 == 0 ) { area /= 2 ; count *= 2 ; } return count ; } public static void Main ( ) { int A = 5 , B = 10 ; Console . WriteLine ( maxSheets ( A , B ) ) ; } }

Accumulator variables: area, count
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMinMoves ( int a , int b ) { int ans = 0 ; if ( a == b || Math . Abs ( a - b ) == 1 ) { ans = a + b ; } else { int k = Math . Min ( a , b ) ; int j = Math . Max ( a , b ) ; ans = 2 * k + 2 * ( j - k ) - 1 ; } Console . Write ( ans ) ; } public static void Main ( ) { int a = 3 , b = 5 ; findMinMoves ( a , b ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static long cntEvenSumPairs ( long X , long Y ) { long cntXEvenNums = X / 2 ; long cntXOddNums = ( X + 1 ) / 2 ; long cntYEvenNums = Y / 2 ; long cntYOddNums = ( Y + 1 ) / 2 ; long cntPairs = ( cntXEvenNums * cntYEvenNums ) + ( cntXOddNums * cntYOddNums ) ; return cntPairs ; } public static void Main ( string [ ] args ) { long X = 2 ; long Y = 3 ; Console . WriteLine ( cntEvenSumPairs ( X , Y ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minMoves ( List < int > arr ) { int N = arr . Count ; if ( N <= 2 ) return 0 ; int ans = Int32 . MaxValue ; for ( int i = - 1 ; i <= 1 ; i ++ ) { for ( int j = - 1 ; j <= 1 ; j ++ ) { int num1 = arr [ 0 ] + i ; int num2 = arr [ 1 ] + j ; int flag = 1 ; int moves = Math . Abs ( i ) + Math . Abs ( j ) ; for ( int idx = 2 ; idx < N ; idx ++ ) { int num = num1 + num2 ; if ( Math . Abs ( arr [ idx ] - num ) > 1 ) flag = 0 ; else moves += Math . Abs ( arr [ idx ] - num ) ; num1 = num2 ; num2 = num ; } if ( flag != 0 ) ans = Math . Min ( ans , moves ) ; } } if ( ans == Int32 . MaxValue ) return - 1 ; return ans ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 4 , 8 , 9 , 17 , 27 } ; Console . WriteLine ( minMoves ( arr ) ) ; } }

Index/key variables: idx
Accumulator variables: i, idx, j, moves
Iterator variables: i, idx, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void querySum ( int [ ] arr , int N , int [ , ] Q , int M ) { for ( int i = 0 ; i < M ; i ++ ) { int x = Q [ i , 0 ] ; int y = Q [ i , 1 ] ; int sum = 0 ; while ( x < N ) { sum += arr [ x ] ; x += y ; } Console . Write ( sum + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 7 , 5 , 4 } ; int [ , ] Q = { { 2 , 1 } , { 3 , 2 } } ; int N = arr . Length ; int M = Q . GetLength ( 0 ) ; querySum ( arr , N , Q , M ) ; } }

Index/key variables: x
Accumulator variables: i, sum, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findBitwiseORGivenXORAND ( int X , int Y ) { return X + Y ; } public static void Main ( string [ ] args ) { int X = 5 , Y = 2 ; Console . Write ( findBitwiseORGivenXORAND ( X , Y ) ) ; } }

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 void canReach ( int N , int A , int B , int K ) { int gcd = GCD ( N , K ) ; if ( Math . Abs ( A - B ) % gcd == 0 ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } public static void Main ( ) { int N = 5 , A = 2 , B = 1 , K = 2 ; canReach ( N , A , B , K ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countOfSubarray ( int [ ] arr , int N ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int answer = 0 ; int sum = 0 ; mp [ 1 ] = 1 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; if ( mp . ContainsKey ( sum - i ) ) answer += mp [ sum - i ] ; if ( mp . ContainsKey ( sum - 1 ) ) mp [ sum - 1 ] ++ ; else mp [ sum - 1 ] = 1 ; } Console . Write ( answer - 2 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 2 , 1 , 2 , - 2 , 2 , 4 } ; int N = arr . Length ; countOfSubarray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: answer, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minAbsDiff ( int N ) { int sumSet1 = 0 ; int sumSet2 = 0 ; for ( int i = N ; i > 0 ; i -- ) { if ( sumSet1 <= sumSet2 ) { sumSet1 += i ; } else { sumSet2 += i ; } } return Math . Abs ( sumSet1 - sumSet2 ) ; } static void Main ( ) { int N = 6 ; Console . Write ( minAbsDiff ( N ) ) ; } }

Accumulator variables: i, sumSet1, sumSet2
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkDigits ( int n ) { do { int r = n % 10 ; if ( r == 3 r == 4 r == 6 r == 7 r == 9 ) return false ; n /= 10 ; } while ( n != 0 ) ; return true ; } static bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } static bool isAllPrime ( int n ) { return isPrime ( n ) && checkDigits ( n ) ; } public static void Main ( String [ ] args ) { int N = 101 ; if ( isAllPrime ( N ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minCost ( String str , int a , int b ) { int openUnbalanced = 0 ; int closedUnbalanced = 0 ; int openCount = 0 ; int closedCount = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' ( ' ) { openUnbalanced ++ ; openCount ++ ; } else { if ( openUnbalanced == 0 ) closedUnbalanced ++ ; else openUnbalanced -- ; closedCount ++ ; } } int result = a * ( Math . Abs ( openCount - closedCount ) ) ; if ( closedCount > openCount ) closedUnbalanced -= ( closedCount - openCount ) ; if ( openCount > closedCount ) openUnbalanced -= ( openCount - closedCount ) ; result += Math . Min ( a * ( openUnbalanced + closedUnbalanced ) , b * closedUnbalanced ) ; Console . Write ( result + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String str = " ) ) ( ) ( ( ) ( ) ( " ; int A = 1 , B = 3 ; minCost ( str , A , B ) ; } }

Index/key variables: i
Accumulator variables: closedCount, closedUnbalanced, i, openCount, openUnbalanced, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void countEvenSum ( int low , int high , int k ) { int even_count = high / 2 - ( low - 1 ) / 2 ; int odd_count = ( high + 1 ) / 2 - low / 2 ; long even_sum = 1 ; long odd_sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { long prev_even = even_sum ; long prev_odd = odd_sum ; even_sum = ( prev_even * even_count ) + ( prev_odd * odd_count ) ; odd_sum = ( prev_even * odd_count ) + ( prev_odd * even_count ) ; } Console . WriteLine ( even_sum ) ; } public static void Main ( String [ ] args ) { int low = 4 ; int high = 5 ; int K = 3 ; countEvenSum ( low , high , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void count ( int n , int k ) { long count = ( long ) ( Math . Pow ( 10 , k ) - Math . Pow ( 10 , k - 1 ) ) ; Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int n = 2 , k = 1 ; count ( n , k ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int func ( int N , int P ) { int sumUptoN = ( N * ( N + 1 ) / 2 ) ; int sumOfMultiplesOfP ; if ( N < P ) { return sumUptoN ; } else if ( ( N / P ) == 1 ) { return sumUptoN - P + 1 ; } sumOfMultiplesOfP = ( ( N / P ) * ( 2 * P + ( N / P - 1 ) * P ) ) / 2 ; return ( sumUptoN + func ( N / P , P ) - sumOfMultiplesOfP ) ; } public static void Main ( String [ ] args ) { int N = 10 , P = 5 ; Console . WriteLine ( func ( N , P ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void findShifts ( int [ ] A , int N ) { int [ ] shift = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( i == A [ i ] - 1 ) shift [ i ] = 0 ; else shift [ i ] = ( A [ i ] - 1 - i + N ) % N ; } for ( int i = 0 ; i < N ; i ++ ) Console . Write ( shift [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 4 , 3 , 2 , 5 } ; int N = arr . Length ; findShifts ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void constructmatrix ( int N ) { bool check = true ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) { Console . Write ( "1 ▁ " ) ; } else if ( check ) { Console . Write ( "2 ▁ " ) ; check = false ; } else { Console . Write ( " - 2 ▁ " ) ; check = true ; } } Console . WriteLine ( ) ; } } static public void Main ( ) { int N = 5 ; constructmatrix ( N ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: check
Class/struct names: GFG
C# program:
using System ; class GFG { static int check ( int unit_digit , int X ) { int times , digit ; for ( times = 1 ; times <= 10 ; times ++ ) { digit = ( X * times ) % 10 ; if ( digit == unit_digit ) return times ; } return - 1 ; } static int getNum ( int N , int X ) { int unit_digit ; unit_digit = N % 10 ; int times = check ( unit_digit , X ) ; if ( times == - 1 ) return times ; else { if ( N >= ( times * X ) ) return times ; else return - 1 ; } } public static void Main ( ) { int N = 58 , X = 7 ; Console . Write ( getNum ( N , X ) ) ; } }

Accumulator variables: times
Iterator variables: times
Class/struct names: GFG
C# program:
using System ; class GFG { static int minPoints ( int n , int m ) { int ans = 0 ; if ( ( n % 2 != 0 ) && ( m % 2 != 0 ) ) { ans = ( ( n * m ) / 2 ) + 1 ; } else { ans = ( n * m ) / 2 ; } return ans ; } public static void Main ( String [ ] args ) { int N = 5 , M = 7 ; Console . Write ( minPoints ( N , M ) ) ; } }

Class/struct names: GFG