dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; public class GFG { class pair : IComparable < pair > { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } public int CompareTo ( pair p ) { return this . first - p . first ; } } static int checkRBS ( String [ ] S ) { int N = S . Length ; pair [ ] v = new pair [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { String s = S [ i ] ; int sum = 0 ; int pre = 0 ; foreach ( char c in s . ToCharArray ( ) ) { if ( c == ' ( ' ) { ++ sum ; } else { -- sum ; } pre = Math . Min ( sum , pre ) ; } v [ i ] = new pair ( sum , pre ) ; } List < pair > pos = new List < pair > ( ) ; List < pair > neg = new List < pair > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( v [ i ] . first >= 0 ) { pos . Add ( new pair ( - v [ i ] . second , v [ i ] . first ) ) ; } else { neg . Add ( new pair ( v [ i ] . first - v [ i ] . second , - v [ i ] . first ) ) ; } } pos . Sort ( ) ; int open = 0 ; foreach ( pair p in pos ) { if ( open - p . first >= 0 ) { open += p . second ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; return 0 ; } } neg . Sort ( ) ; int negative = 0 ; foreach ( pair p in neg ) { if ( negative - p . first >= 0 ) { negative += p . second ; } else { Console . Write ( " No STRNEWLINE " ) ; return 0 ; } } if ( open != negative ) { Console . Write ( " No STRNEWLINE " ) ; return 0 ; } Console . Write ( " Yes STRNEWLINE " ) ; return 0 ; } public static void Main ( String [ ] args ) { String [ ] arr = { " ) " , " ( ) ( " } ; checkRBS ( arr ) ; } }

Index/key variables: N, i
Accumulator variables: negative, open
Iterator variables: c, i, p
Class/struct names: GFG, pair
C# program:
using System ; public class GFG { static int maximumUniqueSquares ( int N ) { int ans = 0 ; if ( N < 4 ) { return 0 ; } int len = ( int ) ( Math . Sqrt ( N ) ) ; N -= len * len ; for ( int i = 1 ; i < len ; i ++ ) { ans += i * i ; } if ( N >= len ) { N -= len ; for ( int i = 1 ; i < len ; i ++ ) { ans += i ; } } for ( int i = 1 ; i < N ; i ++ ) { ans += i ; } return ans ; } public static void Main ( string [ ] args ) { int N = 9 ; Console . WriteLine ( maximumUniqueSquares ( N ) ) ; } }

Accumulator variables: N, ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void findPermutation ( int K , ArrayList arr ) { ArrayList missing = new ArrayList ( ) ; bool [ ] visited = new bool [ K + 1 ] ; for ( int i = 0 ; i < arr . Count ; i ++ ) { visited [ ( int ) arr [ i ] ] = true ; } for ( int i = 1 ; i <= K ; i ++ ) { if ( ! visited [ i ] ) { missing . Add ( i ) ; } } arr . Add ( Int32 . MaxValue ) ; missing . Add ( Int32 . MaxValue ) ; int p1 = 0 ; int p2 = 0 ; ArrayList ans = new ArrayList ( ) ; while ( ans . Count < K ) { if ( ( int ) arr [ p1 ] < ( int ) missing [ p2 ] ) { ans . Add ( arr [ p1 ] ) ; p1 ++ ; } else { ans . Add ( missing [ p2 ] ) ; p2 ++ ; } } for ( int i = 0 ; i < K ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } public static void Main ( ) { int K = 7 ; int [ ] a = { 6 , 4 , 2 , 1 } ; ArrayList arr = new ArrayList ( a ) ; findPermutation ( K , arr ) ; } }

Index/key variables: i, p1, p2
Accumulator variables: i, p1, p2
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findRemainingIndex ( int N ) { int ans = N ; while ( N > 1 ) { int discard = ( int ) ( Math . Sqrt ( N ) ) ; if ( discard * discard == N ) { ans -- ; } N -= discard ; } return ans ; } static void findRemainingElement ( int [ ] arr , int N ) { int remainingIndex = findRemainingIndex ( N ) ; Console . Write ( arr [ remainingIndex - 1 ] ) ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 4 , 2 , 4 , - 3 , 1 , 1 } ; int N = 9 ; findRemainingElement ( arr , N ) ; } }

Accumulator variables: N, ans
Class/struct names: GFG
C# program:
using System ; class GFG { static string largestMerge ( string s1 , string s2 ) { if ( s1 . Length == 0 s2 . Length == 0 ) return s1 + s2 ; if ( string . Compare ( s1 , s2 ) == 1 ) { return s1 [ 0 ] + largestMerge ( s1 . Substring ( 1 ) , s2 ) ; } return s2 [ 0 ] + largestMerge ( s1 , s2 . Substring ( 1 ) ) ; } public static void Main ( ) { string s1 = " geeks " ; string s2 = " forgeeks " ; Console . Write ( largestMerge ( s1 , s2 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int shortestDistance ( String S , int N ) { Dictionary < char , int > dic = new Dictionary < char , int > ( ) ; List < int > dis = new List < int > ( ) ; int var ; for ( int i = 0 ; i < N ; i ++ ) { if ( dic . ContainsKey ( S [ i ] ) ) { var = i - dic [ S [ i ] ] ; dic [ S [ i ] ] = i ; dis . Add ( var ) ; } else { dic . Add ( S [ i ] , i ) ; } } dis . Sort ( ) ; if ( dis . Count == 0 ) return - 1 ; else return dis [ 0 ] - 1 ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; int N = 13 ; Console . WriteLine ( shortestDistance ( S , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOpenDoors ( int N ) { int doorsOpen = ( int ) Math . Sqrt ( N ) ; return doorsOpen ; } public static void Main ( ) { int N = 100 ; Console . Write ( countOpenDoors ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int countCandies ( int [ ] arr , int n ) { int sum = 0 ; int [ ] ans = new int [ n ] ; if ( n == 1 ) { return 1 ; } for ( int i = 0 ; i < n ; i ++ ) ans [ i ] = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i + 1 ] > arr [ i ] && ans [ i + 1 ] <= ans [ i ] ) { ans [ i + 1 ] = ans [ i ] + 1 ; } } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > arr [ i + 1 ] && ans [ i ] <= ans [ i + 1 ] ) { ans [ i ] = ans [ i + 1 ] + 1 ; } else if ( arr [ i ] == arr [ i + 1 ] && ans [ i ] < ans [ i + 1 ] ) { ans [ i ] = ans [ i + 1 ] + 1 ; } sum += ans [ i ] ; } sum += ans [ n - 1 ] ; return sum ; } static public void Main ( ) { int [ ] arr = { 1 , 0 , 2 } ; int N = arr . Length ; Console . WriteLine ( countCandies ( arr , N ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findMaximumProfit ( int [ ] arr , int M , int N ) { List < int > max_heap = new List < int > ( ) ; int maxProfit = 0 ; for ( int i = 0 ; i < N ; i ++ ) max_heap . Add ( arr [ i ] ) ; max_heap . Sort ( ) ; max_heap . Reverse ( ) ; while ( M > 0 ) { M -- ; int X = max_heap [ 0 ] ; max_heap . RemoveAt ( 0 ) ; maxProfit += X ; max_heap . Add ( X - 1 ) ; max_heap . Sort ( ) ; max_heap . Reverse ( ) ; } Console . Write ( maxProfit ) ; } static void Main ( ) { int [ ] arr = { 4 , 6 } ; int M = 4 ; int N = arr . Length ; findMaximumProfit ( arr , M , N ) ; } }

Index/key variables: i
Accumulator variables: M, i, maxProfit
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSequence ( int n , int k ) { int [ ] arr = new int [ n ] ; int sumPos = 0 , sumNeg = 0 ; for ( int i = 0 ; i < n - k ; i ++ ) { arr [ i ] = - ( i + 1 ) ; sumNeg += arr [ i ] ; } for ( int i = n - k ; i < n ; i ++ ) { arr [ i ] = i + 1 ; sumPos += arr [ i ] ; } if ( Math . Abs ( sumNeg ) >= sumPos ) { Console . Write ( - 1 ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int N = 10 , K = 6 ; findSequence ( N , K ) ; } }

Index/key variables: i, n
Accumulator variables: i, sumNeg, sumPos
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findPath ( int [ , ] arr , int M , int N ) { for ( int row = 0 ; row < M ; row ++ ) { char dir = ' L ' ; int i = row ; int j = 0 ; while ( j < N ) { if ( arr [ i , j ] == 1 ) { if ( dir == ' L ' ) { i -- ; dir = ' D ' ; } else if ( dir == ' U ' ) { j -- ; dir = ' R ' ; } else if ( dir == ' R ' ) { i ++ ; dir = ' U ' ; } else if ( dir == ' D ' ) { j ++ ; dir = ' L ' ; } } else { if ( dir == ' L ' ) { i ++ ; dir = ' U ' ; } else if ( dir == ' U ' ) { j ++ ; dir = ' L ' ; } else if ( dir == ' R ' ) { i -- ; dir = ' D ' ; } else if ( dir == ' D ' ) { j -- ; dir = ' R ' ; } } if ( i < 0 i == M j < 0 j == N ) break ; } if ( j == N ) Console . Write ( i + " ▁ " ) ; else Console . Write ( - 1 + " ▁ " ) ; } } public static void Main ( ) { int [ , ] arr = { { 1 , 1 , 0 , 1 } , { 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 0 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 } } ; int M = arr . GetLength ( 0 ) ; int N = arr . GetLength ( 1 ) ; findPath ( arr , M , N ) ; } }

Accumulator variables: i, j, row
Iterator variables: row
Class/struct names: GFG
C# program:
using System ; class GFG { static int getSum ( int n ) { int ans = 0 ; string str = n . ToString ( ) ; Char [ ] arr = str . ToCharArray ( ) ; foreach ( Char ch in arr ) { ans += ( int ) Char . GetNumericValue ( ch ) ; } return ans ; } static void getMax ( int [ ] arr ) { int maxRem0 = 0 ; int rem1 = 0 ; int rem2 = 0 ; foreach ( int i in arr ) { int digitSum = getSum ( i ) ; if ( digitSum % 3 == 0 ) maxRem0 = Math . Max ( maxRem0 , i ) ; else if ( digitSum % 3 == 1 ) rem1 += i ; else rem2 += i ; } Console . WriteLine ( maxRem0 + Math . Max ( rem1 , rem2 ) ) ; } static void Main ( ) { int [ ] arr = { 23 , 12 , 43 , 3 , 56 } ; getMax ( arr ) ; } }

Accumulator variables: ans, rem1, rem2
Iterator variables: ch, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class pair { public int first , second ; public pair ( int a , int b ) { first = a ; second = b ; } } static int dfs ( List < List < pair > > g , pair [ ] disRev , Boolean [ ] visit , int u ) { visit [ u ] = true ; int totalRev = 0 ; for ( int i = 0 ; i < g [ u ] . Count ; i ++ ) { int v = g [ u ] [ i ] . first ; if ( ! visit [ v ] ) { disRev [ v ] . first = disRev [ u ] . first + 1 ; disRev [ v ] . second = disRev [ u ] . second ; if ( g [ u ] [ i ] . second != 0 ) { disRev [ v ] . second = disRev [ u ] . second + 1 ; totalRev ++ ; } totalRev += dfs ( g , disRev , visit , v ) ; } } return totalRev ; } static void printMinEdgeReverseForRootNode ( int [ , ] edges , int e ) { int V = e + 1 ; List < List < pair > > g = new List < List < pair > > ( ) ; for ( int i = 0 ; i < V + 1 ; i ++ ) g . Add ( new List < pair > ( ) ) ; pair [ ] disRev = new pair [ V ] ; for ( int i = 0 ; i < V ; i ++ ) disRev [ i ] = new pair ( 0 , 0 ) ; Boolean [ ] visit = new Boolean [ V ] ; int u , v ; for ( int i = 0 ; i < e ; i ++ ) { u = edges [ i , 0 ] ; v = edges [ i , 1 ] ; g [ u ] . Add ( new pair ( v , 0 ) ) ; g [ v ] . Add ( new pair ( u , 1 ) ) ; } for ( int i = 0 ; i < V ; i ++ ) { visit [ i ] = false ; disRev [ i ] . first = disRev [ i ] . second = 0 ; } int root = 0 ; int totalRev = dfs ( g , disRev , visit , root ) ; int res = int . MaxValue ; for ( int i = 0 ; i < V ; i ++ ) { int edgesToRev = ( totalRev - disRev [ i ] . second ) + ( disRev [ i ] . first - disRev [ i ] . second ) ; if ( edgesToRev < res ) { res = edgesToRev ; root = i ; } } Console . WriteLine ( root + " ▁ " + res ) ; } public static void Main ( String [ ] args ) { int [ , ] edges = { { 0 , 1 } , { 2 , 1 } , { 3 , 2 } , { 3 , 4 } , { 5 , 4 } , { 5 , 6 } , { 7 , 6 } } ; int e = edges . GetLength ( 0 ) ; printMinEdgeReverseForRootNode ( edges , e ) ; } }

Index/key variables: V, i, u, v
Accumulator variables: i, totalRev
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static void checkString ( string s , int k ) { int n = s . Length ; if ( 2 * k + 1 > n ) { Console . Write ( " No " ) ; return ; } string a = s . Substring ( 0 , k ) ; string b = s . Substring ( n - k , k ) ; char [ ] arr = b . ToCharArray ( ) ; Array . Reverse ( arr ) ; b = new String ( arr ) ; if ( a == b ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( ) { string S = " qwqwq " ; int K = 1 ; checkString ( S , K ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int findMin ( int [ ] arr , int N , int k ) { int pairs = 0 ; for ( int i = 0 ; i < N ; i ++ ) { pairs += arr [ i ] / 2 ; } if ( k > pairs ) return - 1 ; else return 2 * k + N - 1 ; } public static void Main ( string [ ] args ) { int [ ] arr = { 4 , 5 , 6 } ; int K = 3 ; int N = arr . Length ; Console . WriteLine ( findMin ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, pairs
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumFlips ( int A , int B , int C ) { int res = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { int x = 0 , y = 0 , z = 0 ; if ( ( A & ( 1 << i ) ) != 0 ) { x = 1 ; } if ( ( B & ( 1 << i ) ) != 0 ) { y = 1 ; } if ( ( C & ( 1 << i ) ) != 0 ) { z = 1 ; } if ( z == 0 ) { if ( x == 1 ) { res ++ ; } if ( y == 1 ) { res ++ ; } } if ( z == 1 ) { if ( x == 0 && y == 0 ) { res ++ ; } } } return res ; } public static void Main ( string [ ] args ) { int A = 2 , B = 6 , C = 5 ; Console . WriteLine ( minimumFlips ( A , B , C ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ , ] prefixCount = new int [ 32 , 10000 ] ; static void findPrefixCount ( List < int > arr , int size ) { for ( int i = 0 ; i < 32 ; i ++ ) { prefixCount [ i , 0 ] = ( ( arr [ 0 ] >> i ) & 1 ) ; for ( int j = 1 ; j < size ; j ++ ) { prefixCount [ i , j ] = ( ( arr [ j ] >> i ) & 1 ) ; prefixCount [ i , j ] += prefixCount [ i , j - 1 ] ; } } } static void arrayBitwiseAND ( int size ) { int result = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { int temp = prefixCount [ i , size - 1 ] ; if ( temp == size ) result = ( result | ( 1 << i ) ) ; } Console . Write ( result + " ▁ " ) ; } static void applyQuery ( int currentVal , int newVal , int size ) { for ( int i = 0 ; i < 32 ; i ++ ) { int bit1 = ( ( currentVal >> i ) & 1 ) ; int bit2 = ( ( newVal >> i ) & 1 ) ; if ( bit2 > 0 && bit1 == 0 ) prefixCount [ i , size - 1 ] ++ ; else if ( bit1 > 0 && bit2 == 0 ) prefixCount [ i , size - 1 ] -- ; } } static void findbitwiseAND ( int [ , ] queries , List < int > arr , int N , int M ) { findPrefixCount ( arr , N ) ; for ( int i = 0 ; i < M ; i ++ ) { int id = queries [ i , 0 ] ; int newVal = queries [ i , 1 ] ; int currentVal = arr [ id ] ; arr [ id ] = newVal ; applyQuery ( currentVal , newVal , N ) ; arrayBitwiseAND ( N ) ; } } public static void Main ( ) { List < int > arr = new List < int > ( ) { 1 , 2 , 3 , 4 , 5 } ; int [ , ] queries = new int [ 3 , 2 ] { { 0 , 2 } , { 3 , 3 } , { 4 , 2 } } ; int N = arr . Count ; int M = 3 ; findbitwiseAND ( queries , arr , N , M ) ; } }

Index/key variables: id, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void stepscount ( int a , int b ) { int chanceA = 2 * a - 1 ; int chanceB = 2 * b ; if ( chanceA < chanceB ) { Console . Write ( " B " ) ; } else if ( chanceB < chanceA ) { Console . Write ( " A " ) ; } } static void Main ( ) { int A = 2 ; int B = 3 ; stepscount ( A , B ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void checkpoint ( int h , int k , int x , int y , int a , int b ) { int p = ( int ) ( Math . Pow ( ( x - h ) , 2 ) / Math . Pow ( a , 2 ) ) - ( int ) ( Math . Pow ( ( y - k ) , 2 ) / Math . Pow ( b , 2 ) ) ; if ( p > 1 ) { Console . WriteLine ( " Outside " ) ; } else if ( p == 1 ) { Console . WriteLine ( " On ▁ the ▁ Hyperbola " ) ; } else { Console . WriteLine ( " Inside " ) ; } } public static void Main ( string [ ] args ) { int h = 0 , k = 0 , x = 2 ; int y = 1 , a = 4 , b = 5 ; checkpoint ( h , k , x , y , a , b ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void evenXorSubarray ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int XOR = 0 ; for ( int j = i ; j < n ; j ++ ) { XOR = XOR ^ arr [ j ] ; if ( ( XOR & 1 ) == 0 ) ans ++ ; } } Console . WriteLine ( ans ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; evenXorSubarray ( arr , N ) ; } }

Index/key variables: j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findKthElement ( int N , int K ) { int ans = 0 ; if ( K <= N / 2 ) { ans = K * 2 ; } else { if ( N % 2 == 0 ) { ans = ( K * 2 ) - N - 1 ; } else { ans = ( K * 2 ) - N ; } } Console . Write ( ans ) ; } static void Main ( ) { int N = 10 , K = 3 ; findKthElement ( N , K ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { public static int makeSumEqual ( int [ ] a , int [ ] b , int K , int M , int N ) { int sum1 = 0 ; int sum2 = 0 ; foreach ( int el in a ) sum1 += el ; foreach ( int el in b ) sum2 += el ; int diff = sum1 - sum2 ; int l1 = 0 , r1 = M - 1 ; int l2 = 0 , r2 = N - 1 ; int res = 0 ; Array . Sort ( a ) ; Array . Sort ( b ) ; while ( l1 <= r1 l2 <= r2 ) { if ( diff == 0 ) { break ; } if ( diff > 0 ) { if ( l2 <= r2 && l1 <= r1 ) { if ( K - b [ l2 ] < a [ r1 ] - 1 ) { int sub = Math . Min ( a [ r1 ] - 1 , diff ) ; diff -= sub ; a [ r1 ] -= sub ; r1 -- ; } else { int sub = Math . Min ( K - b [ l2 ] , diff ) ; diff -= sub ; b [ l2 ] += sub ; l2 ++ ; } } else if ( l1 <= r1 ) { int sub = Math . Min ( a [ r1 ] - 1 , diff ) ; diff -= sub ; a [ r1 ] -= sub ; r1 -- ; } else { int sub = Math . Min ( K - b [ l2 ] , diff ) ; diff -= sub ; b [ l2 ] += sub ; l2 ++ ; } } else { if ( l1 <= r1 && l2 <= r2 ) { if ( K - a [ l1 ] < b [ r2 ] - 1 ) { int sub = Math . Min ( b [ r2 ] - 1 , - 1 * diff ) ; diff += sub ; b [ r2 ] -= sub ; r2 -- ; } else { int sub = Math . Min ( K - a [ l1 ] , - 1 * diff ) ; diff += sub ; a [ l1 ] -= sub ; l1 ++ ; } } else if ( l2 <= r2 ) { int sub = Math . Min ( b [ r2 ] - 1 , - 1 * diff ) ; diff += sub ; b [ r2 ] -= sub ; r2 -- ; } else { int sub = Math . Min ( K - a [ l1 ] , diff ) ; diff += sub ; a [ l1 ] += sub ; l1 ++ ; } } res ++ ; } if ( diff == 0 ) return res ; else return - 1 ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 4 , 3 } ; int [ ] B = { 6 , 6 , 6 } ; int M = A . Length ; int N = B . Length ; int K = 6 ; Console . WriteLine ( makeSumEqual ( A , B , K , M , N ) ) ; } }

Index/key variables: l1, l2, r1, r2
Accumulator variables: diff, l1, l2, r1, r2, res, sum1, sum2
Iterator variables: el
Class/struct names: GFG
C# program:
using System ; public class GFG { public static void findString ( char [ ] S , int N ) { int strLen = 4 * N ; for ( int i = 1 ; i <= N ; i ++ ) { S [ strLen - 1 ] = '1' ; strLen -= 2 ; } Console . WriteLine ( S ) ; } public static void Main ( String [ ] args ) { int N = 2 ; char [ ] S = new char [ 4 * N ] ; for ( int i = 0 ; i < 4 * N ; i ++ ) S [ i ] = '0' ; findString ( S , N ) ; } }

Index/key variables: i
Accumulator variables: i, strLen
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool isVowel ( char ch ) { if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) return true ; if ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) return true ; return false ; } public static String containsEqualStrings ( string S ) { int totalVowels = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) { if ( isVowel ( S [ i ] ) ) totalVowels ++ ; } int vowelsTillNow = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) { if ( isVowel ( S [ i ] ) ) { vowelsTillNow ++ ; totalVowels -- ; if ( vowelsTillNow == totalVowels ) { return " Yes " ; } } } return " No " ; } static public void Main ( ) { string S = " geeks " ; Console . WriteLine ( containsEqualStrings ( S ) ) ; } }

Index/key variables: i
Accumulator variables: i, totalVowels, vowelsTillNow
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void getMaxSum ( int [ , ] A , int M , int N ) { int sum = 0 ; int negative = 0 ; int minVal = Int32 . MaxValue ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { sum += Math . Abs ( A [ i , j ] ) ; if ( A [ i , j ] < 0 ) { negative ++ ; } minVal = Math . Min ( minVal , Math . Abs ( A [ i , j ] ) ) ; } } if ( negative % 2 != 0 ) { sum -= 2 * minVal ; } Console . Write ( sum ) ; } public static void Main ( ) { int [ , ] A = { { 4 , - 8 , 6 } , { 3 , 7 , 2 } } ; int M = A . GetLength ( 0 ) ; int N = A . GetLength ( 1 ) ; getMaxSum ( A , M , N ) ; } }

Accumulator variables: i, j, negative, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ , ] restoreGem ( int [ ] r , int [ ] c ) { int [ , ] dp = new int [ r . Length , c . Length ] ; for ( int i = 0 ; i < r . Length ; i ++ ) { for ( int j = 0 ; j < c . Length ; j ++ ) { int m = Math . Min ( r [ i ] , c [ j ] ) ; dp [ i , j ] = m ; r [ i ] -= m ; c [ j ] -= m ; } } return dp ; } static void printMatrix ( int [ , ] ans , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { Console . Write ( ans [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ ] rowSum = { 5 , 7 , 10 } ; int [ ] colSum = { 8 , 6 , 8 } ; int [ , ] ans = restoreGem ( rowSum , colSum ) ; printMatrix ( ans , rowSum . Length , colSum . Length ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int MAX = 1000000 ; static void maxSumOfDistinctPrimeFactors ( int [ ] arr , int N , int K ) { int [ ] CountDistinct = new int [ MAX + 1 ] ; bool [ ] prime = new bool [ MAX + 1 ] ; for ( int i = 0 ; i <= MAX ; i ++ ) { CountDistinct [ i ] = 0 ; prime [ i ] = true ; } for ( int i = 2 ; i <= MAX ; i ++ ) { if ( prime [ i ] == true ) { CountDistinct [ i ] = 1 ; for ( int j = i * 2 ; j <= MAX ; j += i ) { CountDistinct [ j ] ++ ; prime [ j ] = false ; } } } int sum = 0 ; int [ ] PrimeFactor = new int [ 20 ] ; for ( int i = 0 ; i < N ; i ++ ) { PrimeFactor [ CountDistinct [ arr [ i ] ] ] ++ ; } for ( int i = 19 ; i >= 1 ; i -- ) { while ( PrimeFactor [ i ] > 0 ) { sum += i ; PrimeFactor [ i ] -- ; K -- ; if ( K == 0 ) break ; } if ( K == 0 ) break ; } Console . Write ( sum ) ; } static public void Main ( ) { int [ ] arr = { 6 , 9 , 12 } ; int N = arr . Length ; int K = 2 ; maxSumOfDistinctPrimeFactors ( arr , N , K ) ; } }

Index/key variables: i, j
Accumulator variables: K, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maxChange ( char [ ] str ) { if ( str . Length <= 1 ) { return 0 ; } int minChanges = 0 ; for ( int i = 0 ; i < str . Length - 1 ; i ++ ) { if ( str [ i ] == str [ i + 1 ] ) { str [ i + 1 ] = ' N ' ; minChanges += 1 ; } else if ( i > 0 && str [ i - 1 ] == str [ i + 1 ] ) { str [ i + 1 ] = ' N ' ; minChanges += 1 ; } } return minChanges ; } public static void Main ( String [ ] args ) { String str = " bbbbbbb " ; Console . Write ( maxChange ( str . ToCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: i, minChanges
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findMinKToMakeAllEqual ( int N , int [ ] A ) { var B = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { B . Add ( A [ i ] ) ; } List < int > b = new List < int > ( B ) ; int M = b . Count ; int j = 0 ; if ( M > 3 ) { Console . Write ( " - 1" ) ; } else if ( M == 3 ) { int B_1 = b [ j ++ ] ; int B_2 = b [ j ++ ] ; int B_3 = b [ j ++ ] ; if ( B_2 - B_1 == B_3 - B_2 ) { Console . Write ( B_2 - B_1 ) ; } else { Console . Write ( " - 1" ) ; } } else if ( M == 2 ) { int B_1 = b [ j ++ ] ; int B_2 = b [ j ++ ] ; if ( ( B_2 - B_1 ) % 2 == 0 ) { Console . Write ( ( B_2 - B_1 ) / 2 ) ; } else { Console . Write ( B_2 - B_1 ) ; } } else { Console . Write ( 0 ) ; } } public static void Main ( string [ ] args ) { int [ ] A = { 1 , 3 , 5 , 1 } ; int N = A . Length ; findMinKToMakeAllEqual ( N , A ) ; } }

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