dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static bool hasCrest ( int [ ] arr , int n , int L , int R ) { int [ ] present = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { present [ i ] = 0 ; } for ( int i = 1 ; i <= n - 2 ; i ++ ) { if ( ( arr [ i ] <= arr [ i + 1 ] ) && ( arr [ i ] <= arr [ i - 1 ] ) ) { present [ i ] = 1 ; } } for ( int i = 1 ; i < n ; i ++ ) { present [ i ] += present [ i - 1 ] ; } if ( present [ L ] == present [ R - 1 ] ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 3 , 5 , 12 , 11 , 7 , 9 } ; int N = arr . Length ; int L = 2 ; int R = 6 ; if ( hasCrest ( arr , N , L , R ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: L, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ ] arr1 , int [ ] arr2 , int n ) { int initialParity = 0 , finalParity = 0 ; int sum = 0 , minPositive = int . MaxValue , maxNegative = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { initialParity += arr2 [ i ] ; if ( arr1 [ i ] >= 0 ) { finalParity += 1 ; sum += arr1 [ i ] ; minPositive = Math . Min ( minPositive , arr1 [ i ] ) ; } else { maxNegative = Math . Max ( maxNegative , arr1 [ i ] ) ; } } if ( initialParity % 2 == finalParity % 2 ) { return sum ; } else { if ( minPositive + maxNegative >= 0 ) { return sum + maxNegative ; } else { return sum - minPositive ; } } } public static void Main ( String [ ] args ) { int [ ] arr1 = { 2 , - 4 , 5 , 3 } ; int [ ] arr2 = { 0 , 1 , 0 , 1 } ; int n = arr1 . Length ; Console . WriteLine ( maxSum ( arr1 , arr2 , n ) ) ; } }

Index/key variables: i
Accumulator variables: finalParity, i, initialParity, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool IsLarger ( int [ ] X , int [ ] Y , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( X [ i ] < Y [ i ] ) { return false ; } } return true ; } static int solve ( int [ ] X , int [ ] Y , int n ) { int ans = 0 ; if ( IsLarger ( X , Y , n ) ) ans = 0 ; else { int d = Y [ 0 ] - X [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) X [ i ] += d ; if ( IsLarger ( X , Y , n ) ) ans = d ; else { ans = d + 1 ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] X = { 2 , 3 , 6 , 9 } ; int [ ] Y = { 3 , 4 , 8 , 1 } ; int n = X . Length ; Console . WriteLine ( solve ( X , Y , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int max_bitwise_or ( int L , int R ) { List < int > v1 = new List < int > ( ) , v2 = new List < int > ( ) , v3 = new List < int > ( ) ; int z = 0 , i , ans = 0 , cnt = 1 ; while ( L > 0 ) { v1 . Add ( L % 2 ) ; L = L / 2 ; } while ( R > 0 ) { v2 . Add ( R % 2 ) ; R = R / 2 ; } while ( v1 . Count != v2 . Count ) { v1 . Add ( 0 ) ; } for ( i = v2 . Count - 1 ; i >= 0 ; i -- ) { if ( v2 [ i ] == 1 && v1 [ i ] == 0 && z == 0 ) { z = 1 ; continue ; } if ( z == 1 ) { v1 . RemoveAt ( i ) ; v1 . Insert ( i , 1 ) ; } } for ( i = 0 ; i < v2 . Count ; i ++ ) { v3 . Add ( v2 [ i ] v1 [ i ] ) ; } for ( i = 0 ; i < v2 . Count ; i ++ ) { if ( v3 [ i ] == 1 ) { ans += cnt ; } cnt *= 2 ; } return ans ; } public static void Main ( String [ ] args ) { int L = 10 , R = 20 ; Console . WriteLine ( max_bitwise_or ( L , R ) ) ; } }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int valueofX ( int [ ] ar , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ar [ i ] ; } if ( sum % n == 0 ) { return sum / n ; } else { int A = sum / n , B = sum / n + 1 ; int ValueA = 0 , ValueB = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ValueA += ( ar [ i ] - A ) * ( ar [ i ] - A ) ; ValueB += ( ar [ i ] - B ) * ( ar [ i ] - B ) ; } if ( ValueA < ValueB ) { return A ; } else { return B ; } } } public static void Main ( String [ ] args ) { int n = 7 ; int [ ] arr = { 6 , 9 , 1 , 6 , 1 , 3 , 7 } ; Console . WriteLine ( valueofX ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ValueA, ValueB, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minLength ( int n ) { int ans = n / 26 ; if ( n % 26 != 0 ) ans ++ ; return ans ; } static String minString ( int n ) { int ans = n / 26 ; String res = " " ; while ( ans -- != 0 ) { res = res + " z " ; } if ( n % 26 != 0 ) { res = res + ( char ) ( ( n % 26 ) + 96 ) ; } return res ; } public static void Main ( String [ ] args ) { int n = 50 ; Console . WriteLine ( minLength ( n ) ) ; Console . WriteLine ( minString ( n ) ) ; } }

Accumulator variables: ans
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100001 ; static int minHalls ( int [ , ] lectures , int n ) { int [ ] prefix_sum = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { prefix_sum [ lectures [ i , 0 ] ] ++ ; prefix_sum [ lectures [ i , 1 ] + 1 ] -- ; } int ans = prefix_sum [ 0 ] ; for ( int i = 1 ; i < MAX ; i ++ ) { prefix_sum [ i ] += prefix_sum [ i - 1 ] ; ans = Math . Max ( ans , prefix_sum [ i ] ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ , ] lectures = { { 0 , 5 } , { 1 , 2 } , { 1 , 10 } } ; int n = lectures . GetLength ( 0 ) ; Console . WriteLine ( minHalls ( lectures , n ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCapacity ( int [ ] enter , int [ ] exit , int n ) { int minCap = 0 ; int currCap = 0 ; for ( int i = 0 ; i < n ; i ++ ) { currCap = currCap + enter [ i ] - exit [ i ] ; minCap = Math . Max ( minCap , currCap ) ; } return minCap ; } public static void Main ( String [ ] args ) { int [ ] enter = { 3 , 5 , 2 , 0 } ; int [ ] exit = { 0 , 2 , 4 , 4 } ; int n = enter . Length ; Console . WriteLine ( minCapacity ( enter , exit , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 543210 ; static List < String > ans = new List < String > ( ) ; static bool isValidNum ( String x ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < x . Length ; i ++ ) { if ( mp . ContainsKey ( x [ i ] - '0' ) ) { return false ; } else if ( x [ i ] - '0' > 5 ) { return false ; } else { mp . Add ( x [ i ] - '0' , 1 ) ; } } return true ; } static void generate ( ) { Queue < String > q = new Queue < String > ( ) ; q . Enqueue ( "1" ) ; q . Enqueue ( "2" ) ; q . Enqueue ( "3" ) ; q . Enqueue ( "4" ) ; q . Enqueue ( "5" ) ; bool flag = true ; ans . Add ( "0" ) ; while ( q . Count != 0 ) { String x = q . Peek ( ) ; q . Dequeue ( ) ; if ( isValidNum ( x ) ) { ans . Add ( x ) ; } if ( x . Length == 6 ) continue ; for ( int i = 0 ; i <= 5 ; i ++ ) { String z = i . ToString ( ) ; String temp = x + z ; q . Enqueue ( temp ) ; } } } static bool comp ( String a , String b ) { if ( a . Length == b . Length ) { int i = a . CompareTo ( b ) ; return i < 0 ? true : false ; } else return a . Length < b . Length ; } static int findcount ( String l , String r ) { generate ( ) ; int count = 0 ; for ( int i = 0 ; i < ans . Count ; i ++ ) { String a = ans [ i ] ; if ( comp ( l , a ) && comp ( a , r ) ) { count ++ ; } else if ( a == l a == r ) { count ++ ; } } return count ; } public static void Main ( String [ ] args ) { String l = "1" , r = "1000" ; Console . WriteLine ( findcount ( l , r ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] Findpermutation ( int n ) { int [ ] a = new int [ n + 1 ] ; a [ 1 ] = n ; for ( int i = 2 ; i <= n ; i ++ ) a [ i ] = i - 1 ; return a ; } public static void Main ( String [ ] args ) { int n = 8 ; int [ ] v = Findpermutation ( n ) ; for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( v [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static char [ ] lexo_small ( int n , int k ) { char [ ] arr = new char [ n ] ; int i ; for ( i = 0 ; i < n ; i ++ ) arr [ i ] = ' a ' ; for ( i = n - 1 ; i >= 0 ; i -- ) { k -= i ; if ( k >= 0 ) { if ( k >= 26 ) { arr [ i ] = ' z ' ; k -= 26 ; } else { arr [ i ] = ( char ) ( k + 97 - 1 ) ; k -= arr [ i ] - ' a ' + 1 ; } } else break ; k += i ; } return arr ; } public static void Main ( ) { int n = 5 , k = 42 ; char [ ] arr = lexo_small ( n , k ) ; Console . WriteLine ( new string ( arr ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool IsPossible ( String s ) { int n = s . Length ; HashSet < char > count = new HashSet < char > ( ) ; Dictionary < char , int > map = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { count . Add ( s [ i ] ) ; if ( map . ContainsKey ( s [ i ] ) ) map [ s [ i ] ] = map [ s [ i ] ] + 1 ; else map . Add ( s [ i ] , 1 ) ; } if ( count . Count == 1 ) return true ; if ( count . Count > 2 ) return false ; String newString = count . ToString ( ) ; int j = 0 ; char it = newString [ j ] ; int x = 0 , y = 0 ; x = ! map . ContainsKey ( it ) ? 0 : map [ it ] ; j ++ ; it = newString [ j ] ; y = ! map . ContainsKey ( it ) ? 0 : map [ it ] ; if ( Math . Abs ( x - y ) <= 1 ) return true ; return false ; } public static void Main ( String [ ] args ) { String s = " aaaddad " ; if ( IsPossible ( s ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Index/key variables: i, it, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int getMin ( int [ ] arr , int n ) { int minVal = arr . Min ( ) ; return minVal ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 3 , 1 , 6 , 9 } ; int n = arr . Length ; Console . WriteLine ( getMin ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int Substring ( String s ) { int ans = 1 , temp = 1 ; for ( int i = 1 ; i < s . Length ; i ++ ) { if ( s [ i ] == s [ i - 1 ] ) { ++ temp ; } else { ans = Math . Max ( ans , temp ) ; temp = 1 ; } } ans = Math . Max ( ans , temp ) ; return ans ; } public static void Main ( String [ ] args ) { String s = " abcdddddeff " ; Console . WriteLine ( Substring ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int Balanced_Substring ( String str , int n ) { int ans = 0 ; int [ ] arr = new int [ n / 2 + 1 ] ; int d = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ( ' ) d ++ ; else { if ( d == 1 ) { for ( int j = 2 ; j <= n / 2 + 1 && arr [ j ] != 0 ; j ++ ) arr [ j ] = 0 ; } ++ ans ; ans += arr [ d ] ; arr [ d ] ++ ; d -- ; } } return ans ; } public static void Main ( String [ ] args ) { String str = " ( ) ( ) ( ) " ; int n = str . Length ; Console . WriteLine ( Balanced_Substring ( str , n ) ) ; } }

Index/key variables: d, i, j
Accumulator variables: ans, d, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( long x , int y , int mod ) { long res = 1 ; while ( y != 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % mod ; x = ( x * x ) % mod ; y = ( y >> 1 ) ; } return ( int ) ( res % mod ) ; } static int ncr ( int n , int r , int mod ) { long res = 1 ; for ( int i = 1 ; i <= r ; i += 1 ) { res = ( res * ( n - i + 1 ) ) % mod ; int inv = power ( i , mod - 2 , mod ) ; res = ( res * inv ) % mod ; } return ( int ) ( res % mod ) ; } static int NoOfChords ( int A ) { int mod = ( int ) ( 1e9 + 7 ) ; long ans = ncr ( 2 * A , A , mod ) ; int inv = power ( A + 1 , mod - 2 , mod ) ; ans = ( ans * inv ) % mod ; return ( int ) ( ans % mod ) ; } public static void Main ( ) { int N = 2 ; Console . WriteLine ( NoOfChords ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int StrictlyPositiveXor ( int [ ] A , int N ) { int allxor = 0 ; bool checkallzero = true ; for ( int i = 0 ; i < N ; i += 1 ) { allxor ^= A [ i ] ; if ( A [ i ] > 0 ) checkallzero = false ; } if ( allxor != 0 ) return N ; if ( checkallzero ) return - 1 ; int l = N , r = - 1 ; for ( int i = 0 ; i < N ; i += 1 ) { if ( A [ i ] > 0 ) { l = i + 1 ; break ; } } for ( int i = N - 1 ; i >= 0 ; i -= 1 ) { if ( A [ i ] > 0 ) { r = i + 1 ; break ; } } return Math . Max ( N - l , r - 1 ) ; } public static void Main ( ) { int [ ] A = { 1 , 0 , 0 , 1 } ; int N = A . Length ; Console . WriteLine ( StrictlyPositiveXor ( A , N ) ) ; } }

Index/key variables: i
Accumulator variables: allxor, i
Iterator variables: i
Boolean variables: checkallzero
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_INT = 1000000 ; static int solve ( int [ ] array , int N ) { int [ , ] pos = new int [ 5 , 10000 ] ; int [ ] pref = new int [ 5 ] ; if ( array [ 0 ] == 0 ) { pref [ 0 ] = 1 ; pos [ 0 , pos . GetLength ( 0 ) - 1 ] = 0 ; } int ans = MAX_INT ; for ( int i = 1 ; i < N ; i ++ ) { if ( array [ i ] == 0 ) { pref [ 0 ] ++ ; pos [ 0 , pos . GetLength ( 0 ) - 1 ] = i ; } else { if ( pref [ array [ i ] - 1 ] > 0 ) { pref [ array [ i ] ] ++ ; pos [ array [ i ] , pos . GetLength ( 1 ) - 1 ] = i ; if ( array [ i ] == 4 ) { int end = i ; int start = i ; for ( int j = 3 ; j >= 0 ; j -- ) { int s = 0 ; int e = pos . GetLength ( 1 ) - 1 ; int temp = - 1 ; while ( s <= e ) { int m = ( s + e ) / 2 ; if ( pos [ j , m ] <= start ) { temp = pos [ j , m ] ; s = m + 1 ; } else e = m - 1 ; } start = temp ; } ans = Math . Min ( ans , end - start + 1 ) ; } } } } return ans ; } public static void Main ( String [ ] args ) { int [ ] array = { 0 , 1 , 2 , 3 , 4 , 2 , 0 , 3 , 4 } ; int N = array . Length ; Console . WriteLine ( solve ( array , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findWeights ( int X ) { int sum = 0 ; int power = 0 ; int number = 3 ; while ( sum < X ) { sum = number - 1 ; sum /= 2 ; power ++ ; number *= 3 ; } int ans = 1 ; for ( int i = 1 ; i <= power ; i ++ ) { Console . Write ( ans + " ▁ " ) ; ans = ans * 3 ; } } static public void Main ( ) { int X = 2 ; findWeights ( X ) ; } }

Accumulator variables: i, number, power, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > solve ( int X , List < int > A ) { int min = int . MaxValue ; int ind = - 1 ; for ( int i = 0 ; i < A . Count ; i ++ ) { if ( A [ i ] < min ) { min = A [ i ] ; ind = i ; } } int maxIndChosen = X / min ; List < int > ans = new List < int > ( ) ; if ( maxIndChosen == 0 ) { return ans ; } for ( int i = 0 ; i < maxIndChosen ; i ++ ) { ans . Add ( ind ) ; } int temp = maxIndChosen ; int sum = maxIndChosen * A [ ind ] ; for ( int i = 0 ; i < ind ; i ++ ) { if ( sum - X == 0 temp == 0 ) break ; while ( ( sum - A [ ind ] + A [ i ] ) <= X && temp != 0 ) { ans . RemoveAt ( 0 ) ; ans . Add ( i ) ; temp -- ; sum += ( A [ i ] - A [ ind ] ) ; } } ans . Sort ( ) ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 6 , 4 , 8 } ; List < int > A = new List < int > ( arr ) ; int X = 18 ; List < int > ans = solve ( X , A ) ; for ( int i = 0 ; i < ans . Count ; i ++ ) Console . Write ( ans [ i ] + " ▁ " ) ; } }

Index/key variables: i, ind
Accumulator variables: i, sum, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool matrix_exist ( int [ ] row , int [ ] column , int r , int c ) { int row_sum = 0 ; int column_sum = 0 ; int row_max = - 1 ; int column_max = - 1 ; int row_non_zero = 0 ; int column_non_zero = 0 ; for ( int i = 0 ; i < r ; i ++ ) { row_sum += row [ i ] ; row_max = Math . Max ( row_max , row [ i ] ) ; if ( row [ i ] > 0 ) { row_non_zero ++ ; } } for ( int i = 0 ; i < c ; i ++ ) { column_sum += column [ i ] ; column_max = Math . Max ( column_max , column [ i ] ) ; if ( column [ i ] > 0 ) { column_non_zero ++ ; } } if ( ( row_sum != column_sum ) || ( row_max > column_non_zero ) || ( column_max > row_non_zero ) ) { return false ; } return true ; } static public void Main ( ) { int [ ] row = { 2 , 2 , 2 , 2 , 2 } ; int [ ] column = { 5 , 5 , 0 , 0 } ; int r = row . Length ; int c = column . Length ; if ( matrix_exist ( row , column , r , c ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: column_non_zero, column_sum, i, row_non_zero, row_sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestSubarray ( int [ ] arr , int n ) { int maxMean = 0 ; for ( int i = 1 ; i < n ; i ++ ) maxMean = Math . Max ( maxMean , ( arr [ i ] + arr [ i - 1 ] ) / 2 ) ; int ans = 0 ; int subarrayLength = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] >= maxMean ) ans = Math . Max ( ans , ++ subarrayLength ) ; else subarrayLength = 0 ; return ans ; } public static void Main ( ) { int [ ] arr = { 4 , 3 , 3 , 2 , 1 , 4 } ; int n = arr . Length ; Console . WriteLine ( longestSubarray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxDistance ( int [ ] arr , int n ) { if ( arr [ 0 ] != arr [ n - 1 ] ) return ( n - 1 ) ; int i = n - 1 ; while ( i > 0 ) { if ( arr [ i ] != arr [ 0 ] ) break ; i -- ; } int distFirst = ( i == 0 ) ? - 1 : i ; i = 0 ; while ( i < n - 1 ) { if ( arr [ i ] != arr [ n - 1 ] ) break ; i ++ ; } int distLast = ( i == n - 1 ) ? - 1 : ( n - 1 - i ) ; int maxDist = Math . Max ( distFirst , distLast ) ; return maxDist ; } static public void Main ( ) { int [ ] arr = { 4 , 4 , 1 , 2 , 1 , 4 } ; int n = arr . Length ; Console . WriteLine ( maxDistance ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( int n , int k ) { int mini = 0 ; int x1 = 1 ; int [ ] a = new int [ k ] ; for ( int i = 1 ; i <= k ; i ++ ) { mini += x1 ; a [ i - 1 ] = x1 ; x1 += 1 ; } if ( n < mini ) { Console . Write ( " - 1" ) ; return ; } int rem = n - mini ; int cnt = rem / k ; rem = rem % k ; for ( int i = 0 ; i < k ; i ++ ) a [ i ] += cnt ; for ( int i = k - 1 ; i > 0 && rem > 0 ; i -- ) { int xx = a [ i - 1 ] * 2 ; int left = xx - a [ i ] ; if ( rem >= left ) { a [ i ] = xx ; rem -= left ; } else { a [ i ] += rem ; rem = 0 ; } } int sum = a [ 0 ] ; for ( int i = 1 ; i < k ; i ++ ) { if ( a [ i ] > 2 * a [ i - 1 ] ) { Console . Write ( " - 1" ) ; return ; } sum += a [ i ] ; } if ( sum != n ) { Console . Write ( " - 1" ) ; return ; } for ( int i = 0 ; i < k ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; } public static void Main ( ) { int n = 26 , k = 6 ; solve ( n , k ) ; } }

Index/key variables: i, k
Accumulator variables: i, mini, rem, sum, x1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 25 ; static int getMinSum ( int [ ] arr , int n ) { int [ ] bits_count = new int [ MAX ] ; int max_bit = 0 , sum = 0 , ans = 0 ; for ( int d = 0 ; d < n ; d ++ ) { int e = arr [ d ] , f = 0 ; while ( e > 0 ) { int rem = e % 2 ; e = e / 2 ; if ( rem == 1 ) { bits_count [ f ] += rem ; } f ++ ; } max_bit = Math . Max ( max_bit , f ) ; } for ( int d = 0 ; d < max_bit ; d ++ ) { int temp = ( int ) Math . Pow ( 2 , d ) ; if ( bits_count [ d ] > n / 2 ) ans = ans + temp ; } for ( int d = 0 ; d < n ; d ++ ) { arr [ d ] = arr [ d ] ^ ans ; sum = sum + arr [ d ] ; } return sum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 7 , 11 , 15 } ; int n = arr . Length ; Console . WriteLine ( getMinSum ( arr , n ) ) ; } }

Index/key variables: MAX, d, f
Accumulator variables: d, f
Iterator variables: d
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxCoins ( int X , int Y ) { if ( X < Y ) { swap ( X , Y ) ; } int coins = X ; X -- ; coins += Math . Max ( X , Y ) ; return coins ; } static void swap ( int X , int Y ) { int temp = X ; X = Y ; Y = temp ; } public static void Main ( String [ ] args ) { int X = 7 , Y = 5 ; Console . WriteLine ( maxCoins ( X , Y ) ) ; } }

Accumulator variables: X, coins
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findMinimumX ( int [ ] a , int n ) { List < int > st = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( ! st . Contains ( a [ i ] ) ) st . Add ( a [ i ] ) ; if ( st . Count == 1 ) return 0 ; if ( st . Count == 2 ) { int el1 = st [ 0 ] ; int el2 = st [ 1 ] ; if ( ( el2 - el1 ) % 2 == 0 ) return ( el2 - el1 ) / 2 ; else return ( el2 - el1 ) ; } if ( st . Count == 3 ) { int el1 = st [ 0 ] ; int el2 = st [ 1 ] ; int el3 = st [ 2 ] ; if ( ( el2 - el1 ) == ( el3 - el2 ) ) return el2 - el1 ; else return - 1 ; } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 4 , 4 , 7 , 4 , 1 } ; int n = a . Length ; Console . WriteLine ( findMinimumX ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findElementsCrossed ( int [ ] arr , int a , int b , int n ) { int aa = a ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a == 0 && b == 0 ) break ; else if ( a == 0 ) { if ( arr [ i ] == 1 ) { b -= 1 ; a = Math . Min ( aa , a + 1 ) ; } else b -= 1 ; } else if ( b == 0 ) a -- ; else if ( arr [ i ] == 1 && a < aa ) { b -= 1 ; a = Math . Min ( aa , a + 1 ) ; } else a -- ; ans ++ ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 0 , 1 , 0 , 1 } ; int n = arr . Length ; int a = 1 ; int b = 2 ; Console . WriteLine ( findElementsCrossed ( arr , a , b , n ) ) ; } }

Index/key variables: i
Accumulator variables: a, ans, b, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void pushBinaryToBorder ( int [ ] arr , int n ) { int count1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != 1 ) arr [ count1 ++ ] = arr [ i ] ; while ( count1 < n ) arr [ count1 ++ ] = 1 ; int lastNonOne = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == 1 ) continue ; if ( lastNonOne == 0 ) { lastNonOne = i ; } if ( arr [ i ] != 0 ) arr [ lastNonOne -- ] = arr [ i ] ; } while ( lastNonOne >= 0 ) arr [ lastNonOne -- ] = 0 ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 0 , 0 , 0 , 3 , 6 } ; int n = arr . Length ; pushBinaryToBorder ( arr , n ) ; printArr ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: count1, i, lastNonOne
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isVowel ( char ch ) { switch ( ch ) { case ' a ' : case ' e ' : case ' i ' : case ' o ' : case ' u ' : return true ; default : return false ; } } static int vowelPairs ( string s , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( isVowel ( s [ i ] ) && isVowel ( s [ i + 1 ] ) ) cnt ++ ; } return cnt ; } public static void Main ( ) { string s = " abaebio " ; int n = s . Length ; Console . WriteLine ( vowelPairs ( s , n ) ) ; } }

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