dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int productSum ( int [ ] arr ) { int cntOne = 0 ; int N = arr . Length ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) cntOne ++ ; } return cntOne * ( cntOne - 1 ) / 2 ; } public static void Main ( ) { int [ ] arr = { 0 , 1 , 1 , 0 , 1 } ; Console . Write ( productSum ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: cntOne, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDigits ( int N , int K ) { int digits_num = ( int ) Math . Floor ( Math . Log ( N ) + 1 ) ; int temp_sum = 0 ; int temp = digits_num ; int result = 0 ; int X , var ; int sum = 0 ; int num2 = N ; while ( num2 != 0 ) { sum += num2 % 10 ; num2 /= 10 ; } if ( sum <= K ) { X = 0 ; } else { while ( temp > 0 ) { var = ( N / ( ( int ) Math . Pow ( 10 , temp - 1 ) ) ) ; . temp_sum += var % 10 ; if ( temp_sum >= K ) { var /= 10 ; var ++ ; result = var * ( int ) Math . Pow ( 10 , temp ) ; break ; } temp -- ; } X = result - N ; return X ; } return - 1 ; } public static void Main ( String [ ] args ) { int N = 11 ; int K = 1 ; Console . WriteLine ( minDigits ( N , K ) ) ; } }

Accumulator variables: num2, sum, temp, temp_sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int findWays ( int [ ] nums , int S ) { int sum = 0 ; for ( int i = 0 ; i < nums . Length ; i ++ ) sum += nums [ i ] ; int [ , ] memo = new int [ nums . Length + 1 , 2 * sum + 1 ] ; for ( int i = 0 ; i < memo . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < memo . GetLength ( 1 ) ; j ++ ) { memo [ i , j ] = int . MinValue ; } } return dfs ( memo , nums , S , 0 , 0 , sum ) ; } static int dfs ( int [ , ] memo , int [ ] nums , int S , int curr_sum , int index , int sum ) { if ( index == nums . Length ) { if ( S == curr_sum ) return 1 ; else return 0 ; } if ( memo [ index , curr_sum + sum ] != int . MinValue ) { return memo [ index , curr_sum + sum ] ; } int ans = dfs ( memo , nums , index + 1 , curr_sum + nums [ index ] , S , sum ) + dfs ( memo , nums , index + 1 , curr_sum - nums [ index ] , S , sum ) ; memo [ index , curr_sum + sum ] = ans ; return ans ; } public static void Main ( String [ ] args ) { int S = 3 ; int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 } ; int answer = findWays ( arr , S ) ; Console . WriteLine ( answer ) ; } }

Index/key variables: i, index
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void max_length ( int N , int x , int [ ] v ) { int i , a ; List < int > preff = new List < int > ( ) ; List < int > suff = new List < int > ( ) ; int ct = 0 ; for ( i = 0 ; i < N ; i ++ ) { a = v [ i ] ; if ( a % x == 0 ) { ct += 1 ; } } if ( ct == N ) { Console . Write ( - 1 + " STRNEWLINE " ) ; return ; } v = reverse ( v ) ; suff . Add ( v [ 0 ] ) ; for ( i = 1 ; i < N ; i ++ ) { suff . Add ( v [ i ] + suff [ i - 1 ] ) ; } v = reverse ( v ) ; suff . Reverse ( ) ; preff . Add ( v [ 0 ] ) ; for ( i = 1 ; i < N ; i ++ ) { preff . Add ( v [ i ] + preff [ i - 1 ] ) ; } int ans = 0 ; int lp = 0 ; int rp = N - 1 ; for ( i = 0 ; i < N ; i ++ ) { if ( suff [ i ] % x != 0 && ( ans < ( N - 1 ) ) ) { lp = i ; rp = N - 1 ; ans = Math . Max ( ans , N - i ) ; } if ( preff [ i ] % x != 0 && ( ans < ( i + 1 ) ) ) { lp = 0 ; rp = i ; ans = Math . Max ( ans , i + 1 ) ; } } for ( i = lp ; i <= rp ; i ++ ) { Console . Write ( v [ i ] + " ▁ " ) ; } } static int [ ] reverse ( int [ ] a ) { int i , n = a . Length , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } public static void Main ( String [ ] args ) { int x = 3 ; int [ ] v = { 1 , 3 , 2 , 6 } ; int N = v . Length ; max_length ( N , x , v ) ; } }

Index/key variables: i
Accumulator variables: ct, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxUpdated ( int [ ] arr ) { int h_score = arr [ 0 ] ; int l_score = arr [ 0 ] ; int i = 1 , j = 1 ; foreach ( int n in arr ) { if ( h_score < n ) { h_score = n ; i ++ ; } if ( l_score > n ) { l_score = n ; j ++ ; } } Console . Write ( " Number ▁ of ▁ times ▁ maximum ▁ value ▁ " ) ; Console . Write ( " updated ▁ = ▁ " + i + " STRNEWLINE " ) ; Console . Write ( " Number ▁ of ▁ times ▁ minimum ▁ value ▁ " ) ; Console . Write ( " updated ▁ = ▁ " + j ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 5 , 20 , 22 } ; maxUpdated ( arr ) ; } }

Accumulator variables: i, j
Iterator variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { static void farthest_min ( int [ ] a , int n ) { int [ ] suffix_min = new int [ n ] ; suffix_min [ n - 1 ] = a [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { suffix_min [ i ] = Math . Min ( suffix_min [ i + 1 ] , a [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { int low = i + 1 , high = n - 1 , ans = - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( suffix_min [ mid ] < a [ i ] ) { ans = mid ; low = mid + 1 ; } else high = mid - 1 ; } Console . Write ( ans + " ▁ " ) ; } } public static void Main ( ) { int [ ] a = { 3 , 1 , 5 , 2 , 4 } ; int n = a . Length ; farthest_min ( a , n ) ; } }

Index/key variables: i, mid, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printElements ( int [ ] a , int n ) { Array . Sort ( a ) ; a = reverse ( a ) ; int cnt = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] != a [ i + 1 ] ) { Console . Write ( a [ i ] + " ▁ occurs ▁ " + cnt + " ▁ times STRNEWLINE " ) ; cnt = 1 ; } else cnt += 1 ; } Console . Write ( a [ n - 1 ] + " ▁ occurs ▁ " + cnt + " ▁ times STRNEWLINE " ) ; } static int [ ] reverse ( int [ ] a ) { int i , n = a . Length , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 1 , 1 , 2 , 3 , 4 , 9 , 9 , 10 } ; int n = a . Length ; printElements ( a , n ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static Boolean checkSorted ( int n , int [ ] arr ) { int [ ] b = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = arr [ i ] ; Array . Sort ( b , 0 , n ) ; int ct = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != b [ i ] ) ct ++ ; if ( ct == 0 ct == 2 ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 3 , 4 , 2 } ; int n = arr . Length ; if ( checkSorted ( n , arr ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, n
Accumulator variables: ct, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkIndices ( int [ ] Arr , int N ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( Arr [ i ] != Arr [ j ] ) { if ( Arr [ Arr [ i ] - 1 ] == Arr [ Arr [ j ] - 1 ] ) return true ; } } } return false ; } static public void Main ( ) { int [ ] Arr = { 3 , 2 , 1 , 1 , 4 } ; int N = Arr . Length ; if ( checkIndices ( Arr , N ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class Pair { public int x , y ; public Pair ( int x , int y ) { this . x = x ; this . y = y ; } } class GFG { public static void findPairs ( int [ ] A ) { Dictionary < int , List < Pair > > map = new Dictionary < int , List < Pair > > ( ) ; for ( int i = 0 ; i < A . Length - 1 ; i ++ ) { for ( int j = i + 1 ; j < A . Length ; j ++ ) { int sum = A [ i ] + A [ j ] ; if ( map . ContainsKey ( sum ) ) { foreach ( Pair pair in map [ sum ] ) { int x = pair . x ; int y = pair . y ; if ( ( x != i && x != j ) && ( y != i && y != j ) ) { Console . WriteLine ( " Pair ▁ First ( " + A [ i ] + " , ▁ " + A [ j ] + " ) " ) ; Console . WriteLine ( " Pair ▁ Second ▁ ( " + A [ x ] + " , ▁ " + A [ y ] + " ) " ) ; return ; } } } map [ sum ] = new List < Pair > ( ) ; map [ sum ] . Add ( new Pair ( i , j ) ) ; } } Console . Write ( " No ▁ such ▁ non - overlapping ▁ pairs ▁ present " ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 8 , 4 , 7 , 8 , 4 } ; findPairs ( A ) ; } }

Index/key variables: i, j, sum, x, y
Accumulator variables: i, j
Iterator variables: i, j, pair
Class/struct names: GFG, Pair
C# program:
using System ; class GFG { static void printPairs ( int [ ] arr , int n , int sum ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] + arr [ j ] == sum ) Console . Write ( " ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) " + " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 7 , - 1 , 5 } ; int n = arr . Length ; int sum = 6 ; printPairs ( arr , n , sum ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countTripletsLessThanL ( int n , int L , int [ ] arr ) { Array . Sort ( arr ) ; int ways = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int indexGreater = upper_bound ( arr , 0 , n , arr [ i ] + L ) ; int numberOfElements = indexGreater - ( i + 1 ) ; if ( numberOfElements >= 2 ) { ways += ( numberOfElements * ( numberOfElements - 1 ) / 2 ) ; } } return ways ; } static int upper_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; int L = 4 ; int ans = countTripletsLessThanL ( n , L , arr ) ; Console . WriteLine ( " Total ▁ Number ▁ of ▁ ways ▁ = ▁ " + ans ) ; } }

Index/key variables: i, middle
Accumulator variables: i, ways
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSum ( int [ ] arr , int n ) { int sum = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) { int j = i ; while ( j < n && arr [ j ] <= arr [ j - 1 ] ) { arr [ j ] = arr [ j ] + 1 ; j ++ ; } } sum = sum + arr [ i ] ; } return sum ; } public static void Main ( ) { int [ ] arr = { 2 , 2 , 3 , 5 , 6 } ; int n = arr . Length ; Console . WriteLine ( minSum ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSum ( int [ ] arr , int n ) { int sum = arr [ 0 ] , prev = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] <= prev ) { prev = prev + 1 ; sum = sum + prev ; } else { sum = sum + arr [ i ] ; prev = arr [ i ] ; } } return sum ; } public static void Main ( ) { int [ ] arr = { 2 , 2 , 3 , 5 , 6 } ; int n = arr . Length ; Console . WriteLine ( minSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class RandomizedBinarySearch { public static int getRandom ( int x , int y ) { Random r = new Random ( ) ; return ( x + ( int ) ( r . Next ( ) % ( y - x + 1 ) ) ) ; } public static int randomizedBinarySearch ( int [ ] arr , int low , int high , int key ) { if ( high >= low ) { int mid = getRandom ( low , high ) ; if ( arr [ mid ] == key ) return mid ; if ( arr [ mid ] > key ) return randomizedBinarySearch ( arr , low , mid - 1 , key ) ; return randomizedBinarySearch ( arr , mid + 1 , high , key ) ; } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 10 , 40 } ; int n = arr . Length ; int key = 10 ; int result = randomizedBinarySearch ( arr , 0 , n - 1 , key ) ; Console . WriteLine ( ( result == - 1 ) ? " Element ▁ is ▁ not ▁ present ▁ in ▁ array " : " Element ▁ is ▁ present ▁ at ▁ index ▁ " + result ) ; } }

Index/key variables: mid
Class/struct names: RandomizedBinarySearch
C# program:
using System ; using System . Text ; using System . Linq ; using System . Collections . Generic ; public class Test { static String remVowel ( String str ) { char [ ] vowels = { ' a ' , ' e ' , ' i ' , ' o ' , ' u ' , ' A ' , ' E ' , ' I ' , ' O ' , ' U ' } ; List < char > al = vowels . OfType < char > ( ) . ToList ( ) ; ; StringBuilder sb = new StringBuilder ( str ) ; for ( int i = 0 ; i < sb . Length ; i ++ ) { if ( al . Contains ( sb [ i ] ) ) { sb . Replace ( sb [ i ] . ToString ( ) , " " ) ; i -- ; } } return sb . ToString ( ) ; } public static void Main ( ) { String str = " GeeeksforGeeks ▁ - ▁ A ▁ Computer ▁ Science ▁ Portal ▁ for ▁ Geeks " ; Console . Write ( remVowel ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minCostToMakeElementEqual ( int [ ] a , int n ) { int y ; if ( n % 2 == 1 ) y = a [ n / 2 ] ; else y = ( a [ n / 2 ] + a [ ( n - 2 ) / 2 ] ) / 2 ; int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) s += Math . Abs ( a [ i ] - y ) ; return s ; } static void Main ( ) { int [ ] a = { 1 , 100 , 101 } ; int n = a . Length ; Console . WriteLine ( minCostToMakeElementEqual ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool isSorted ( int [ ] arr , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) return false ; } return true ; } public static bool sortPoss ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int idx = - 1 ; int minVar = arr [ i ] ; int j = i ; while ( j < n ) { if ( arr [ j ] < minVar ) { minVar = arr [ j ] ; idx = j ; } j = j + 2 ; } if ( idx != - 1 ) { int t ; t = arr [ i ] ; arr [ i ] = arr [ idx ] ; arr [ idx ] = t ; } } if ( isSorted ( arr , n ) ) return true ; else return false ; } static public void Main ( ) { int [ ] arr = { 3 , 5 , 1 , 2 , 6 } ; int n = arr . Length ; if ( sortPoss ( arr , n ) ) Console . WriteLine ( " True " ) ; else Console . WriteLine ( " False " ) ; } }

Index/key variables: i, idx, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int upperBound ( int [ ] arr , int N , int K ) { int l = 0 ; int r = N ; while ( l < r ) { int mid = ( l + r ) / 2 ; if ( arr [ mid ] <= K ) { l = mid + 1 ; } else { r = mid ; } } return l ; } static void NDivKWithFreq ( int [ ] arr , int N , int K ) { Array . Sort ( arr ) ; int i = 0 ; while ( i < N ) { int X = upperBound ( arr , N , arr [ i ] ) ; if ( ( X - i ) > N / 4 ) { Console . Write ( arr [ i ] + " ▁ " ) ; } i = X ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 6 , 6 , 6 , 6 , 7 , 10 } ; int N = arr . Length ; int K = 4 ; NDivKWithFreq ( arr , N , K ) ; } }

Index/key variables: i, mid
Class/struct names: GFG
C# program:
using System ; class GFG { static long maxSum ( int [ ] a ) { int n = a . Length ; int [ ] count = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) count [ Math . Min ( a [ i ] , n ) ] ++ ; int size = 0 ; long ans = 0 ; for ( int k = 1 ; k <= n ; k ++ ) { while ( count [ k ] > 0 && size < k ) { size ++ ; ans += size ; count [ k ] -- ; } ans += k * count [ k ] ; } return ans ; } public static void Main ( ) { int [ ] arr = { 3 , 5 , 1 } ; Console . Write ( maxSum ( arr ) ) ; } }

Index/key variables: i, k
Accumulator variables: ans, i, k, size
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void answerQueries ( int [ ] arr , int n , int [ , ] queries ) { for ( int i = 0 ; i < queries . GetLength ( 0 ) ; i ++ ) { int ans = 0 ; int l = queries [ i , 0 ] - 1 ; int r = queries [ i , 1 ] - 1 ; Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int j = l ; j < r + 1 ; j ++ ) { freq [ arr [ j ] ] = freq . GetValueOrDefault ( arr [ j ] , 0 ) + 1 ; } foreach ( int k in freq . Keys ) { ans += k * freq [ k ] ; } Console . WriteLine ( ans ) ; } } static public void Main ( ) { int [ ] arr = { 1 , 2 , 1 } ; int n = arr . Length ; int [ , ] queries = { { 1 , 2 } , { 1 , 3 } } ; answerQueries ( arr , n , queries ) ; } }

Index/key variables: j, k
Accumulator variables: ans, i, j
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool PandigitalProduct_1_9 ( int n ) { for ( int i = 1 ; i * i <= n ; i ++ ) if ( n % i == 0 && isPandigital ( " " + n + i + n / i ) ) return true ; return false ; } public static bool isPandigital ( String str ) { if ( str . Length != 9 ) return false ; char [ ] ch = str . ToCharArray ( ) ; Array . Sort ( ch ) ; return new String ( ch ) . Equals ( "123456789" ) ; } public static void Main ( ) { int n = 6952 ; if ( PandigitalProduct_1_9 ( n ) == true ) Console . Write ( " yes " ) ; else Console . Write ( " no " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static void printModeMedian ( int [ ] a , int n ) { int [ ] b = new int [ n ] ; int max = a . Max ( ) ; int t = max + 1 ; int [ ] count = new int [ t ] ; for ( int i = 0 ; i < t ; i ++ ) { count [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { count [ a [ i ] ] ++ ; } int mode = 0 ; int k = count [ 0 ] ; for ( int i = 1 ; i < t ; i ++ ) { if ( count [ i ] > k ) { k = count [ i ] ; mode = i ; } } for ( int i = 1 ; i < t ; i ++ ) { count [ i ] = count [ i ] + count [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { b [ count [ a [ i ] ] - 1 ] = a [ i ] ; count [ a [ i ] ] -- ; } float median ; if ( n % 2 != 0 ) { median = b [ n / 2 ] ; } else { median = ( float ) ( ( b [ ( n - 1 ) / 2 ] + b [ ( n / 2 ) ] ) / 2.0 ) ; } Console . WriteLine ( " median ▁ = ▁ " + median ) ; Console . WriteLine ( " mode ▁ = ▁ " + mode ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 4 , 1 , 2 , 7 , 1 , 2 , 5 , 3 , 6 } ; int n = a . Length ; printModeMedian ( a , n ) ; } }

Index/key variables: i, n, t
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GeeksforGeeks { static int MAX = 26 ; static bool function ( String str ) { int l = str . Length ; int [ ] counter1 = new int [ MAX ] ; int [ ] counter2 = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { counter1 [ i ] = 0 ; counter2 [ i ] = 0 ; } for ( int i = 0 ; i < l / 2 ; i ++ ) counter1 [ str [ i ] - ' a ' ] ++ ; for ( int i = l / 2 ; i < l ; i ++ ) counter2 [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( counter2 [ i ] != counter1 [ i ] ) return true ; } return false ; } public static void Main ( ) { String str = " abcasdsabcae " ; if ( function ( str ) ) Console . WriteLine ( " Yes , ▁ both ▁ halves ▁ " + " differ ▁ by ▁ at ▁ least ▁ one ▁ character " ) ; else Console . WriteLine ( " No , ▁ both ▁ halves ▁ " + " do ▁ not ▁ differ ▁ at ▁ all " ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GeeksforGeeks
C# program:
using System ; class GFG { static int MAX = 26 ; static bool function ( String str ) { int l = str . Length ; int [ ] counter = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) counter [ i ] = 0 ; for ( int i = 0 ; i < l / 2 ; i ++ ) counter [ str [ i ] - ' a ' ] ++ ; for ( int i = l / 2 ; i < l ; i ++ ) counter [ str [ i ] - ' a ' ] -- ; for ( int i = 0 ; i < MAX ; i ++ ) if ( counter [ i ] != 0 ) return true ; return false ; } public static void Main ( ) { string str = " abcasdsabcae " ; if ( function ( str ) ) Console . Write ( " Yes , ▁ both ▁ halves " + " ▁ differ ▁ by ▁ at ▁ least ▁ one ▁ " + " character " ) ; else Console . Write ( " No , ▁ both ▁ halves " + " ▁ do ▁ not ▁ differ ▁ at ▁ all " ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDifferenceAmongMaxMin ( int [ ] arr , int N , int K ) { Array . Sort ( arr ) ; int res = 2147483647 ; for ( int i = 0 ; i <= ( N - K ) ; i ++ ) { int curSeqDiff = arr [ i + K - 1 ] - arr [ i ] ; res = Math . Min ( res , curSeqDiff ) ; } return res ; } public static void Main ( ) { int [ ] arr = { 10 , 20 , 30 , 100 , 101 , 102 } ; int N = arr . Length ; int K = 3 ; Console . Write ( minDifferenceAmongMaxMin ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class ArrayIndex { static int getIndexInSortedArray ( int [ ] arr , int n , int idx ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ idx ] ) result ++ ; if ( arr [ i ] == arr [ idx ] && i < idx ) result ++ ; } return result ; } public static void Main ( ) { int [ ] arr = { 3 , 4 , 3 , 5 , 2 , 3 , 4 , 3 , 1 , 5 } ; int n = arr . Length ; int idxOfEle = 5 ; Console . WriteLine ( getIndexInSortedArray ( arr , n , idxOfEle ) ) ; } }

Index/key variables: i, idx
Accumulator variables: i, result
Iterator variables: i
Class/struct names: ArrayIndex
C# program:
using System ; using System . Collections . Generic ; class GFG { public static bool possible ( int x , int S , int N ) { int minSum = ( x * ( x + 1 ) ) / 2 ; int maxSum = ( x * ( ( 2 * N ) - x + 1 ) ) / 2 ; if ( S < minSum S > maxSum ) { return false ; } return true ; } public static void findPermutation ( int N , int L , int R , int S ) { int x = R - L + 1 ; if ( ! possible ( x , S , N ) ) { Console . WriteLine ( - 1 ) ; return ; } else { List < int > v = new List < int > ( ) ; for ( int i = N ; i >= 1 ; -- i ) { if ( ( S - i ) >= 0 && possible ( x - 1 , S - i , i - 1 ) ) { S = S - i ; x -- ; v . Add ( i ) ; } if ( S == 0 ) { break ; } } if ( S != 0 ) { Console . WriteLine ( - 1 ) ; return ; } List < int > v1 = new List < int > ( ) ; for ( int i = 1 ; i <= N ; ++ i ) { bool it = v . Contains ( i ) ; if ( ! it ) { v1 . Add ( i ) ; } } int j = 0 , f = 0 ; for ( int i = 1 ; i < L ; ++ i ) { Console . Write ( v1 [ j ] + " ▁ " ) ; j ++ ; } for ( int i = L ; i <= R ; ++ i ) { Console . Write ( v [ f ] + " ▁ " ) ; f ++ ; } for ( int i = R + 1 ; i <= N ; ++ i ) { Console . Write ( v1 [ j ] + " ▁ " ) ; j ++ ; } } return ; } public static void Main ( ) { int N = 6 , L = 3 , R = 5 , S = 8 ; findPermutation ( N , L , R , S ) ; } }

Index/key variables: f, j
Accumulator variables: f, j, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countTriplets ( int N , int K ) { if ( K % 2 == 0 ) { int x = N / K ; int y = ( N + ( K / 2 ) ) / K ; return x * x * x + y * y * y ; } else { int x = N / K ; return x * x * x ; } } static void Main ( ) { int N = 2 , K = 2 ; Console . Write ( countTriplets ( N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void Main ( String [ ] args ) { string S = " geeksforg " ; Console . WriteLine ( maxNumPalindrome ( S ) ) ; } static int maxNumPalindrome ( string S ) { int i = 0 ; int [ ] freq = new int [ 26 ] ; int freqPair = 0 ; int len = S . Length / 3 ; while ( i < S . Length ) { freq [ S [ i ] - ' a ' ] ++ ; i ++ ; } for ( i = 0 ; i < 26 ; i ++ ) { freqPair += ( freq [ i ] / 2 ) ; } return Math . Min ( freqPair , len ) ; } }

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