dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System . Collections . Generic ; using System ; class GFG { static int splitstring ( string s ) { int n = s . Length ; int zeros = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( s [ i ] == '0' ) zeros ++ ; if ( zeros % 3 != 0 ) return 0 ; if ( zeros == 0 ) return ( ( n - 1 ) * ( n - 2 ) ) / 2 ; int zerosInEachSubstring = zeros / 3 ; int waysOfFirstCut = 0 ; int waysOfSecondCut = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) count ++ ; if ( count == zerosInEachSubstring ) waysOfFirstCut ++ ; else if ( count == 2 * zerosInEachSubstring ) waysOfSecondCut ++ ; } return waysOfFirstCut * waysOfSecondCut ; } public static void Main ( ) { string s = "01010" ; Console . WriteLine ( " The ▁ number ▁ of ▁ ways ▁ " + " to ▁ split ▁ is ▁ " + splitstring ( s ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, waysOfFirstCut, waysOfSecondCut, zeros
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool canTransform ( string str1 , string str2 ) { string s1 = " " ; string s2 = " " ; foreach ( char c in str1 . ToCharArray ( ) ) { if ( c != ' C ' ) { s1 += c ; } } foreach ( char c in str2 . ToCharArray ( ) ) { if ( c != ' C ' ) { s2 += c ; } } if ( s1 != s2 ) return false ; int i = 0 ; int j = 0 ; int n = str1 . Length ; while ( i < n && j < n ) { if ( str1 [ i ] == ' C ' ) { i ++ ; } else if ( str2 [ j ] == ' C ' ) { j ++ ; } else { if ( ( str1 [ i ] == ' A ' && i < j ) || ( str1 [ i ] == ' B ' && i > j ) ) { return false ; } i ++ ; j ++ ; } } return true ; } public static void Main ( string [ ] args ) { string str1 = " BCCABCBCA " ; string str2 = " CBACCBBAC " ; if ( canTransform ( str1 , str2 ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j, s1, s2
Iterator variables: c
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxsubStringLength ( char [ ] S , int N ) { int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) if ( S [ i ] == ' a ' S [ i ] == ' e ' S [ i ] == ' i ' S [ i ] == ' o ' S [ i ] == ' u ' ) arr [ i ] = 1 ; else arr [ i ] = - 1 ; int maxLen = 0 ; int curr_sum = 0 ; Dictionary < int , int > hash = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { curr_sum += arr [ i ] ; if ( curr_sum == 0 ) maxLen = Math . Max ( maxLen , i + 1 ) ; if ( hash . ContainsKey ( curr_sum ) ) maxLen = Math . Max ( maxLen , i - hash [ curr_sum ] ) ; else hash . Add ( curr_sum , i ) ; } return maxLen ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; int n = S . Length ; Console . Write ( maxsubStringLength ( S . ToCharArray ( ) , n ) ) ; } }

Index/key variables: N, curr_sum, i
Accumulator variables: curr_sum, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int [ , ] mat = new int [ 1001 , 1001 ] ; static int r , c , x , y ; static int [ ] dx = { 0 , - 1 , - 1 , - 1 , 0 , 1 , 1 , 1 } ; static int [ ] dy = { 1 , 1 , 0 , - 1 , - 1 , - 1 , 0 , 1 } ; static void FindMinimumDistance ( ) { Queue < pair > q = new Queue < pair > ( ) ; q . Enqueue ( new pair ( x , y ) ) ; mat [ x , y ] = 0 ; while ( q . Count != 0 ) { x = q . Peek ( ) . first ; y = q . Peek ( ) . second ; q . Dequeue ( ) ; for ( int i = 0 ; i < 8 ; i ++ ) { int a = x + dx [ i ] ; int b = y + dy [ i ] ; if ( a < 0 a >= r b >= c b < 0 ) continue ; if ( mat [ a , b ] == 0 ) { mat [ a , b ] = mat [ x , y ] + 1 ; q . Enqueue ( new pair ( a , b ) ) ; } } } } public static void Main ( String [ ] args ) { r = 5 ; c = 5 ; x = 1 ; y = 1 ; int t = x ; int l = y ; mat [ x , y ] = 0 ; FindMinimumDistance ( ) ; mat [ t , l ] = 0 ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, pair
C# program:
using System ; class GFG { public static int minOperations ( String S , int K ) { int ans = 0 ; for ( int i = 0 ; i < K ; i ++ ) { int zero = 0 , one = 0 ; for ( int j = i ; j < S . Length ; j += K ) { if ( S [ j ] == '0' ) zero ++ ; else one ++ ; } ans += Math . Min ( zero , one ) ; } return ans ; } public static void Main ( String [ ] args ) { String S = "110100101" ; int K = 3 ; Console . WriteLine ( minOperations ( S , K ) ) ; } }

Index/key variables: j
Accumulator variables: ans, i, j, one, zero
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int missingElement ( int [ ] arr , int n ) { int max_ele = arr [ 0 ] ; int min_ele = arr [ 0 ] ; int x = 0 ; int d ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max_ele ) max_ele = arr [ i ] ; if ( arr [ i ] < min_ele ) min_ele = arr [ i ] ; } d = ( max_ele - min_ele ) / n ; for ( int i = 0 ; i < n ; i ++ ) { x = x ^ arr [ i ] ; } for ( int i = 0 ; i <= n ; i ++ ) { x = x ^ ( min_ele + ( i * d ) ) ; } return x ; } public static void Main ( ) { int [ ] arr = new int [ ] { 12 , 3 , 6 , 15 , 18 } ; int n = arr . Length ; int element = missingElement ( arr , n ) ; Console . Write ( element ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void Printksubstring ( String str , int n , int k ) { int total = ( n * ( n + 1 ) ) / 2 ; if ( k > total ) { Console . Write ( " - 1 STRNEWLINE " ) ; return ; } int [ ] substring = new int [ n + 1 ] ; substring [ 0 ] = 0 ; int temp = n ; for ( int i = 1 ; i <= n ; i ++ ) { substring [ i ] = substring [ i - 1 ] + temp ; temp -- ; } int l = 1 ; int h = n ; int start = 0 ; while ( l <= h ) { int m = ( l + h ) / 2 ; if ( substring [ m ] > k ) { start = m ; h = m - 1 ; } else if ( substring [ m ] < k ) { l = m + 1 ; } else { start = m ; break ; } } int end = n - ( substring [ start ] - k ) ; for ( int i = start - 1 ; i < end ; i ++ ) { Console . Write ( str [ i ] ) ; } } public static void Main ( String [ ] args ) { String str = " abc " ; int k = 4 ; int n = str . Length ; Printksubstring ( str , n , k ) ; } }

Index/key variables: i, m, start
Accumulator variables: i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int LowerInsertionPoint ( int [ ] arr , int n , int X ) { if ( X < arr [ 0 ] ) return 0 ; else if ( X > arr [ n - 1 ] ) return n ; int lowerPnt = 0 ; int i = 1 ; while ( i < n && arr [ i ] < X ) { lowerPnt = i ; i = i * 2 ; } while ( lowerPnt < n && arr [ lowerPnt ] < X ) lowerPnt ++ ; return lowerPnt ; } static public void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 4 , 5 , 6 , 7 , 9 } ; int n = arr . Length ; int X = 4 ; Console . WriteLine ( LowerInsertionPoint ( arr , n , X ) ) ; } }

Index/key variables: i, lowerPnt
Accumulator variables: lowerPnt
Class/struct names: GFG
C# program:
using System ; class GFG { static int getCount ( int M , int N ) { int count = 0 ; if ( M == 1 ) return N ; if ( N == 1 ) return M ; if ( N > M ) { for ( int i = 1 ; i <= M ; i ++ ) { int numerator = N * i - N + M - i ; int denominator = M - 1 ; if ( numerator % denominator == 0 ) { int j = numerator / denominator ; if ( j >= 1 && j <= N ) count ++ ; } } } else { for ( int j = 1 ; j <= N ; j ++ ) { int numerator = M * j - M + N - j ; int denominator = N - 1 ; if ( numerator % denominator == 0 ) { int i = numerator / denominator ; if ( i >= 1 && i <= M ) count ++ ; } } } return count ; } public static void Main ( ) { int M = 3 , N = 5 ; Console . WriteLine ( getCount ( M , N ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool swapElement ( int [ ] arr1 , int [ ] arr2 , int n ) { int wrongIdx = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr1 [ i ] < arr1 [ i - 1 ] ) { wrongIdx = i ; } } int maximum = int . MinValue ; int maxIdx = - 1 ; bool res = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr2 [ i ] > maximum && arr2 [ i ] >= arr1 [ wrongIdx - 1 ] ) { if ( wrongIdx + 1 <= n - 1 && arr2 [ i ] <= arr1 [ wrongIdx + 1 ] ) { maximum = arr2 [ i ] ; maxIdx = i ; res = true ; } } } if ( res ) { swap ( arr1 , wrongIdx , arr2 , maxIdx ) ; } return res ; } static void swap ( int [ ] a , int wrongIdx , int [ ] b , int maxIdx ) { int c = a [ wrongIdx ] ; a [ wrongIdx ] = b [ maxIdx ] ; b [ maxIdx ] = c ; } static void getSortedArray ( int [ ] arr1 , int [ ] arr2 , int n ) { if ( swapElement ( arr1 , arr2 , n ) ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr1 [ i ] + " ▁ " ) ; } } else { Console . Write ( " Not ▁ Possible " ) ; } } public static void Main ( ) { int [ ] arr1 = { 1 , 3 , 7 , 4 , 10 } ; int [ ] arr2 = { 2 , 1 , 6 , 8 , 9 } ; int n = arr1 . Length ; getSortedArray ( arr1 , arr2 , n ) ; } }

Index/key variables: i, maxIdx, wrongIdx
Accumulator variables: i
Iterator variables: i
Boolean variables: res
Class/struct names: GFG
C# program:
using System ; class Middle { public static int middleOfThree ( int a , int b , int c ) { if ( a > b ) { if ( b > c ) return b ; else if ( a > c ) return c ; else return a ; } else { if ( a > c ) return a ; else if ( b > c ) return c ; else return b ; } } public static void Main ( ) { int a = 20 , b = 30 , c = 40 ; Console . WriteLine ( middleOfThree ( a , b , c ) ) ; } }

Class/struct names: Middle
C# program:
using System ; using System . Collections . Generic ; class GFG { static void largestArea ( int N , int M , int [ ] H , int [ ] V ) { HashSet < int > s1 = new HashSet < int > ( ) ; HashSet < int > s2 = new HashSet < int > ( ) ; for ( int i = 1 ; i <= N + 1 ; i ++ ) s1 . Add ( i ) ; for ( int i = 1 ; i <= M + 1 ; i ++ ) s2 . Add ( i ) ; for ( int i = 0 ; i < H . Length ; i ++ ) { s1 . Remove ( H [ i ] ) ; } for ( int i = 0 ; i < V . Length ; i ++ ) { s2 . Remove ( V [ i ] ) ; } int [ ] list1 = new int [ s1 . Count ] ; int [ ] list2 = new int [ s2 . Count ] ; int I = 0 ; foreach ( int it1 in s1 ) { list1 [ I ++ ] = it1 ; } I = 0 ; foreach ( int it2 in s2 ) { list2 [ I ++ ] = it2 ; } Array . Sort ( list1 ) ; Array . Sort ( list2 ) ; int maxH = 0 , p1 = 0 , maxV = 0 , p2 = 0 ; for ( int j = 0 ; j < list1 . Length ; j ++ ) { maxH = Math . Max ( maxH , list1 [ j ] - p1 ) ; p1 = list1 [ j ] ; } for ( int j = 0 ; j < list2 . Length ; j ++ ) { maxV = Math . Max ( maxV , list2 [ j ] - p2 ) ; p2 = list2 [ j ] ; } Console . WriteLine ( maxV * maxH ) ; } static void Main ( ) { int N = 3 , M = 3 ; int [ ] H = { 2 } ; int [ ] V = { 2 } ; largestArea ( N , M , H , V ) ; } }

Index/key variables: i, j
Accumulator variables: I, i, j
Iterator variables: i, it1, it2, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool checkifSorted ( int [ ] A , int [ ] B , int N ) { bool flag = false ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] > A [ i + 1 ] ) { flag = true ; break ; } } if ( ! flag ) { return true ; } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( B [ i ] == 0 ) { count ++ ; break ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( B [ i ] == 1 ) { count ++ ; break ; } } if ( count == 2 ) { return true ; } return false ; } public static void Main ( string [ ] args ) { int [ ] A = { 3 , 1 , 2 } ; int [ ] B = { 0 , 1 , 1 } ; int N = A . Length ; bool check = checkifSorted ( A , B , N ) ; if ( check ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; using System . Text ; public class GFG { static int minSteps ( StringBuilder A , StringBuilder B , int M , int N ) { if ( A [ 0 ] > B [ 0 ] ) return 0 ; if ( B [ 0 ] > A [ 0 ] ) { return 1 ; } if ( M <= N && A [ 0 ] == B [ 0 ] && count ( A , A [ 0 ] ) == M && count ( B , B [ 0 ] ) == N ) return - 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( B [ i ] > B [ 0 ] ) return 1 ; } for ( int i = 1 ; i < M ; i ++ ) { if ( A [ i ] < A [ 0 ] ) return 1 ; } for ( int i = 1 ; i < M ; i ++ ) { if ( A [ i ] > A [ 0 ] ) { swap ( A , i , B , 0 ) ; swap ( A , 0 , B , 0 ) ; return 2 ; } } for ( int i = 1 ; i < N ; i ++ ) { if ( B [ i ] < B [ 0 ] ) { swap ( A , 0 , B , i ) ; swap ( A , 0 , B , 0 ) ; return 2 ; } } return 0 ; } static int count ( StringBuilder a , char c ) { int count = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) if ( a [ i ] == c ) count ++ ; return count ; } static void swap ( StringBuilder s1 , int index1 , StringBuilder s2 , int index2 ) { char c = s1 [ index1 ] ; s1 [ index1 ] = s2 [ index2 ] ; s2 [ index2 ] = c ; } static public void Main ( ) { StringBuilder A = new StringBuilder ( " adsfd " ) ; StringBuilder B = new StringBuilder ( " dffff " ) ; int M = A . Length ; int N = B . Length ; Console . WriteLine ( minSteps ( A , B , M , N ) ) ; } }

Index/key variables: i, index1, index2
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { const int maxN = 201 ; static int n1 , n2 , n3 ; static int [ , , ] dp = new int [ maxN , maxN , maxN ] ; static int getMaxSum ( int i , int j , int k , int [ ] arr1 , int [ ] arr2 , int [ ] arr3 ) { int cnt = 0 ; if ( i >= n1 ) cnt ++ ; if ( j >= n2 ) cnt ++ ; if ( k >= n3 ) cnt ++ ; if ( cnt >= 2 ) return 0 ; if ( dp [ i , j , k ] != - 1 ) return dp [ i , j , k ] ; int ans = 0 ; if ( i < n1 && j < n2 ) ans = Math . Max ( ans , getMaxSum ( i + 1 , j + 1 , k , arr1 , arr2 , arr3 ) + arr1 [ i ] * arr2 [ j ] ) ; if ( i < n1 && k < n3 ) ans = Math . Max ( ans , getMaxSum ( i + 1 , j , k + 1 , arr1 , arr2 , arr3 ) + arr1 [ i ] * arr3 [ k ] ) ; if ( j < n2 && k < n3 ) ans = Math . Max ( ans , getMaxSum ( i , j + 1 , k + 1 , arr1 , arr2 , arr3 ) + arr2 [ j ] * arr3 [ k ] ) ; dp [ i , j , k ] = ans ; return dp [ i , j , k ] ; } static void reverse ( int [ ] tmp ) { int i , t ; int n = tmp . Length ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = tmp [ i ] ; tmp [ i ] = tmp [ n - i - 1 ] ; tmp [ n - i - 1 ] = t ; } } static int maxProductSum ( int [ ] arr1 , int [ ] arr2 , int [ ] arr3 ) { for ( int i = 0 ; i < maxN ; i ++ ) for ( int j = 0 ; j < maxN ; j ++ ) for ( int k = 0 ; k < maxN ; k ++ ) dp [ i , j , k ] = - 1 ; Array . Sort ( arr1 ) ; reverse ( arr1 ) ; Array . Sort ( arr2 ) ; reverse ( arr2 ) ; Array . Sort ( arr3 ) ; reverse ( arr3 ) ; return getMaxSum ( 0 , 0 , 0 , arr1 , arr2 , arr3 ) ; } public static void Main ( string [ ] args ) { n1 = 2 ; int [ ] arr1 = { 3 , 5 } ; n2 = 2 ; int [ ] arr2 = { 2 , 1 } ; n3 = 3 ; int [ ] arr3 = { 4 , 3 , 5 } ; Console . Write ( maxProductSum ( arr1 , arr2 , arr3 ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: cnt, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void findTriplet ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int flag = 0 , i ; for ( i = N - 1 ; i - 2 >= 0 ; i -- ) { if ( arr [ i - 2 ] + arr [ i - 1 ] > arr [ i ] ) { flag = 1 ; break ; } } if ( flag != 0 ) { Console . Write ( arr [ i - 2 ] + " ▁ " + arr [ i - 1 ] + " ▁ " + arr [ i ] ) ; } else { Console . Write ( - 1 ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 4 , 2 , 10 , 3 , 5 } ; int N = arr . Length ; findTriplet ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numberofpairs ( int [ ] arr , int N ) { int answer = 0 ; Array . Sort ( arr ) ; int minDiff = 10000000 ; for ( int i = 0 ; i < N - 1 ; i ++ ) minDiff = Math . Min ( minDiff , arr [ i + 1 ] - arr [ i ] ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i + 1 ] - arr [ i ] == minDiff ) answer ++ ; } return answer ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 1 , 3 } ; int N = arr . Length ; Console . Write ( numberofpairs ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int max_length = 0 ; static List < int > store = new List < int > ( ) ; static List < int > ans = new List < int > ( ) ; static void find_max_length ( int [ ] arr , int index , int sum , int k ) { sum = sum + arr [ index ] ; store . Add ( arr [ index ] ) ; if ( sum == k ) { if ( max_length < store . Count ) { max_length = store . Count ; ans = store ; } } for ( int i = index + 1 ; i < arr . Length ; i ++ ) { if ( sum + arr [ i ] <= k ) { find_max_length ( arr , i , sum , k ) ; store . RemoveAt ( store . Count - 1 ) ; } else return ; } return ; } static int longestSubsequence ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( max_length >= n - i ) break ; store . Clear ( ) ; find_max_length ( arr , i , 0 , k ) ; } return max_length ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 3 , 0 , 1 , 1 , 2 } ; int n = arr . Length ; int k = 1 ; Console . Write ( longestSubsequence ( arr , n , k ) ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortArray ( int [ ] A , int N ) { int x = 0 , y = 0 , z = 0 ; if ( N % 4 == 0 N % 4 == 1 ) { for ( int i = 0 ; i < N / 2 ; i ++ ) { x = i ; if ( i % 2 == 0 ) { y = N - i - 2 ; z = N - i - 1 ; } A [ z ] = A [ y ] ; A [ y ] = A [ x ] ; A [ x ] = x + 1 ; } Console . Write ( " Sorted ▁ Array : ▁ " ) ; for ( int i = 0 ; i < N ; i ++ ) Console . Write ( A [ i ] + " ▁ " ) ; } else { Console . Write ( " - 1" ) ; } } public static void Main ( String [ ] args ) { int [ ] A = { 5 , 4 , 3 , 2 , 1 } ; int N = A . Length ; sortArray ( A , N ) ; } }

Index/key variables: i, x, y, z
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findK ( int [ ] arr , int size , int N ) { Array . Sort ( arr ) ; int temp_sum = 0 ; for ( int i = 0 ; i < size ; i ++ ) { temp_sum += arr [ i ] ; if ( N - temp_sum == arr [ i ] * ( size - i - 1 ) ) { return arr [ i ] ; } } return - 1 ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 10 , 4 , 8 } ; int size = arr . Length ; int N = 16 ; Console . Write ( findK ( arr , size , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, temp_sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool existsTriplet ( int [ ] a , int [ ] b , int [ ] c , int x , int l1 , int l2 , int l3 ) { if ( l2 <= l1 && l2 <= l3 ) { swap ( l2 , l1 ) ; swap ( a , b ) ; } else if ( l3 <= l1 && l3 <= l2 ) { swap ( l3 , l1 ) ; swap ( a , c ) ; } for ( int i = 0 ; i < l1 ; i ++ ) { int j = 0 , k = l3 - 1 ; while ( j < l2 && k >= 0 ) { if ( a [ i ] + b [ j ] + c [ k ] == x ) return true ; if ( a [ i ] + b [ j ] + c [ k ] < x ) j ++ ; else k -- ; } } return false ; } private static void swap ( int x , int y ) { int temp = x ; x = y ; y = temp ; } private static void swap ( int [ ] x , int [ ] y ) { int [ ] temp = x ; x = y ; y = temp ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 7 , 8 , 10 , 15 } ; int [ ] b = { 1 , 6 , 7 , 8 } ; int [ ] c = { 4 , 5 , 5 } ; int l1 = a . Length ; int l2 = b . Length ; int l3 = c . Length ; int x = 14 ; if ( existsTriplet ( a , b , c , x , l1 , l2 , l3 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] ) ; } public static int compare ( int num1 , int num2 ) { String A = num1 . ToString ( ) ; String B = num2 . ToString ( ) ; return ( A + B ) . CompareTo ( B + A ) ; } public static void printSmallest ( int N , int [ ] arr ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( compare ( arr [ i ] , arr [ j ] ) > 0 ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } } printArr ( arr , N ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 6 , 2 , 9 , 21 , 1 } ; int N = arr . Length ; printSmallest ( N , arr ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void stableSelectionSort ( int [ ] a , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { int min = i ; for ( int j = i + 1 ; j < n ; j ++ ) if ( a [ min ] > a [ j ] ) min = j ; int key = a [ min ] ; while ( min > i ) { a [ min ] = a [ min - 1 ] ; min -- ; } a [ i ] = key ; } } static void printArray ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] a = { 4 , 5 , 3 , 2 , 4 , 1 } ; int n = a . Length ; stableSelectionSort ( a , n ) ; printArray ( a , n ) ; } }

Index/key variables: i, j, min
Accumulator variables: i, j, min
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPossible ( int [ ] a , int [ ] b , int n , int k ) { Array . Sort ( a ) ; Array . Reverse ( b ) ; for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] + b [ i ] < k ) return false ; return true ; } public static void Main ( ) { int [ ] a = { 2 , 1 , 3 } ; int [ ] b = { 7 , 8 , 9 } ; int k = 10 ; int n = a . Length ; if ( isPossible ( a , b , n , k ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

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 setBitCount ( int num ) { int count = 0 ; while ( num != 0 ) { if ( ( num & 1 ) != 0 ) count ++ ; num >>= 1 ; } return count ; } static void sortBySetBitCount ( int [ ] arr , int n ) { List < Tuple < int , int > > count = new List < Tuple < int , int > > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { count . Add ( new Tuple < int , int > ( ( - 1 ) * setBitCount ( arr [ i ] ) , arr [ i ] ) ) ; } count . Sort ( ) ; foreach ( Tuple < int , int > i in count ) { Console . Write ( i . Item2 + " ▁ " ) ; } Console . WriteLine ( ) ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; sortBySetBitCount ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int canReach ( String s , int L , int R ) { int [ ] dp = new int [ s . Length ] ; dp [ 0 ] = 1 ; int pre = 0 ; for ( int i = 1 ; i < s . Length ; i ++ ) { if ( i >= L ) { pre += dp [ i - L ] ; } if ( i > R ) { pre -= dp [ i - R - 1 ] ; } if ( pre > 0 && s [ i ] == '0' ) dp [ i ] = 1 ; else dp [ i ] = 0 ; } return dp [ s . Length - 1 ] ; } public static void Main ( ) { String S = "01101110" ; int L = 2 , R = 3 ; if ( canReach ( S , L , R ) == 1 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, pre
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxXORUtil ( int [ ] arr , int N , int xrr , int orr ) { if ( N == 0 ) return xrr ^ orr ; int x = maxXORUtil ( arr , N - 1 , xrr ^ orr , arr [ N - 1 ] ) ; int y = maxXORUtil ( arr , N - 1 , xrr , orr arr [ N - 1 ] ) ; return Math . Max ( x , y ) ; } static int maximumXOR ( int [ ] arr , int N ) { return maxXORUtil ( arr , N , 0 , 0 ) ; } static void Main ( ) { int [ ] arr = { 1 , 5 , 7 } ; int N = arr . Length ; Console . Write ( maximumXOR ( arr , N ) ) ; } }

Class/struct names: GFG