dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isValidLen ( String s , int len , int k ) { int n = s . Length ; Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; int right = 0 ; while ( right < len ) { if ( mp . ContainsKey ( s [ right ] ) ) { mp [ s [ right ] ] = mp [ s [ right ] ] + 1 ; } else { mp . Add ( s [ right ] , 1 ) ; } right ++ ; } if ( mp . Count <= k ) return true ; while ( right < n ) { if ( mp . ContainsKey ( s [ right ] ) ) { mp [ s [ right ] ] = mp [ s [ right ] ] + 1 ; } else { mp . Add ( s [ right ] , 1 ) ; } if ( mp . ContainsKey ( s [ right - len ] ) ) { mp [ s [ right - len ] ] = mp [ s [ right - len ] ] - 1 ; } if ( mp [ s [ right - len ] ] == 0 ) mp . Remove ( s [ right - len ] ) ; if ( mp . Count <= k ) return true ; right ++ ; } return mp . Count <= k ; } static int maxLenSubStr ( String s , int k ) { HashSet < char > uni = new HashSet < char > ( ) ; foreach ( char x in s . ToCharArray ( ) ) uni . Add ( x ) ; if ( uni . Count < k ) return - 1 ; int n = s . Length ; int lo = - 1 , hi = n + 1 ; while ( hi - lo > 1 ) { int mid = lo + hi >> 1 ; if ( isValidLen ( s , mid , k ) ) lo = mid ; else hi = mid ; } return lo ; } public static void Main ( String [ ] args ) { String s = " aabacbebebe " ; int k = 3 ; Console . Write ( maxLenSubStr ( s , k ) ) ; } }

Index/key variables: right
Accumulator variables: right
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSquarePossible ( int [ ] arr , int n , int l ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= l ) cnt ++ ; if ( cnt >= l ) return true ; } return false ; } static int maxArea ( int [ ] arr , int n ) { int l = 0 , r = n ; int len = 0 ; while ( l <= r ) { int m = l + ( ( r - l ) / 2 ) ; if ( isSquarePossible ( arr , n , m ) ) { len = m ; l = m + 1 ; } else r = m - 1 ; } return ( len * len ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 4 , 5 , 5 } ; int n = arr . Length ; Console . WriteLine ( maxArea ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void insertNames ( String [ ] arr , int n ) { HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! set . Contains ( arr [ i ] ) ) { Console . Write ( " No STRNEWLINE " ) ; set . Add ( arr [ i ] ) ; } else { Console . Write ( " Yes STRNEWLINE " ) ; } } } public static void Main ( String [ ] args ) { String [ ] arr = { " geeks " , " for " , " geeks " } ; int n = arr . Length ; insertNames ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countLessThan ( int [ ] arr , int n , int key ) { int l = 0 , r = n - 1 ; int index = - 1 ; while ( l <= r ) { int m = ( l + r ) / 2 ; if ( arr [ m ] < key ) { l = m + 1 ; index = m ; } else { r = m - 1 ; } } return ( index + 1 ) ; } static int countGreaterThan ( int [ ] arr , int n , int key ) { int l = 0 , r = n - 1 ; int index = - 1 ; while ( l <= r ) { int m = ( l + r ) / 2 ; if ( arr [ m ] <= key ) { l = m + 1 ; } else { r = m - 1 ; index = m ; } } if ( index == - 1 ) return 0 ; return ( n - index ) ; } static int countTriplets ( int n , int [ ] a , int [ ] b , int [ ] c ) { Array . Sort ( a ) ; Array . Sort ( b ) ; Array . Sort ( c ) ; int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int current = b [ i ] ; int low = countLessThan ( a , n , current ) ; int high = countGreaterThan ( c , n , current ) ; count += ( low * high ) ; } return count ; } public static void Main ( ) { int [ ] a = { 1 , 5 } ; int [ ] b = { 2 , 4 } ; int [ ] c = { 3 , 6 } ; int size = a . Length ; Console . WriteLine ( countTriplets ( size , a , b , c ) ) ; } }

Index/key variables: i, m
Accumulator variables: count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int costToBalance ( string s ) { if ( s . Length == 0 ) Console . WriteLine ( 0 ) ; int ans = 0 ; int o = 0 , c = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == ' ( ' ) o ++ ; if ( s [ i ] == ' ) ' ) c ++ ; } if ( o != c ) return - 1 ; int [ ] a = new int [ s . Length ] ; if ( s [ 0 ] == ' ( ' ) a [ 0 ] = 1 ; else a [ 0 ] = - 1 ; if ( a [ 0 ] < 0 ) ans += Math . Abs ( a [ 0 ] ) ; for ( int i = 1 ; i < s . Length ; i ++ ) { if ( s [ i ] == ' ( ' ) a [ i ] = a [ i - 1 ] + 1 ; else a [ i ] = a [ i - 1 ] - 1 ; if ( a [ i ] < 0 ) ans += Math . Abs ( a [ i ] ) ; } return ans ; } static void Main ( ) { string s ; s = " ) ) ) ( ( ( " ; Console . WriteLine ( costToBalance ( s ) ) ; s = " ) ) ( ( " ; Console . WriteLine ( costToBalance ( s ) ) ; } }

Index/key variables: i
Accumulator variables: ans, c, i, o
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Middle { public static int middleOfThree ( int a , int b , int c ) { int x = a - b ; int y = b - c ; int z = a - c ; if ( x * y > 0 ) return b ; else if ( x * z > 0 ) return c ; else return a ; } 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 ; class Missing4 { public static void missing4 ( int [ ] arr ) { int [ ] helper = new int [ 4 ] ; for ( int i = 0 ; i < arr . Length ; i ++ ) { int temp = Math . Abs ( arr [ i ] ) ; if ( temp <= arr . Length ) arr [ temp - 1 ] *= ( - 1 ) ; else if ( temp > arr . Length ) { if ( temp % arr . Length != 0 ) helper [ temp % arr . Length - 1 ] = - 1 ; else helper [ ( temp % arr . Length ) + arr . Length - 1 ] = - 1 ; } } for ( int i = 0 ; i < arr . Length ; i ++ ) if ( arr [ i ] > 0 ) Console . Write ( i + 1 + " ▁ " ) ; for ( int i = 0 ; i < helper . Length ; i ++ ) if ( helper [ i ] >= 0 ) Console . Write ( arr . Length + i + 1 + " ▁ " ) ; return ; } public static void Main ( ) { int [ ] arr = { 1 , 7 , 3 , 12 , 5 , 10 , 8 , 4 , 9 } ; missing4 ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Missing4
C# program:
using System ; using System . Collections . Generic ; class GFG { static void lexiMiddleSmallest ( int K , int N ) { if ( K % 2 == 0 ) { Console . Write ( K / 2 + " ▁ " ) ; for ( int i = 0 ; i < N - 1 ; ++ i ) { Console . Write ( K + " ▁ " ) ; } Console . WriteLine ( ) ; return ; } List < int > a = new List < int > ( ) ; for ( int i = 0 ; i < N / 2 ; ++ i ) { if ( a [ a . Count - 1 ] == 1 ) { a . Remove ( a . Count - 1 ) ; } else { a [ a . Count - 1 ] -= 1 ; while ( ( int ) a . Count < N ) { a . Add ( K ) ; } } } foreach ( int i in a ) { Console . Write ( i + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void Main ( ) { int K = 2 , N = 4 ; lexiMiddleSmallest ( K , N ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findLastElement ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int i = 0 ; for ( i = 1 ; i < N ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] != 0 && arr [ i ] - arr [ i - 1 ] != 2 ) { Console . WriteLine ( " - 1" ) ; return ; } } Console . WriteLine ( arr [ N - 1 ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 6 , 8 , 0 , 8 } ; int N = arr . Length ; findLastElement ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxDivisions ( int [ ] arr , int N , int X ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int maxSub = 0 ; int size = 0 ; for ( int i = 0 ; i < N ; i ++ ) { size ++ ; if ( arr [ i ] * size >= X ) { maxSub ++ ; size = 0 ; } } Console . WriteLine ( maxSub ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 3 , 7 } ; int N = arr . Length ; int X = 3 ; maxDivisions ( arr , N , X ) ; } }

Index/key variables: i
Accumulator variables: i, maxSub, size
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static void maxPossibleSum ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int sum = 0 ; int j = N - 3 ; while ( j >= 0 ) { sum += arr [ j ] ; j -= 3 ; } Console . WriteLine ( sum ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 4 , 5 , 2 , 3 , 1 , 5 , 9 } ; int N = arr . Length ; maxPossibleSum ( arr , N ) ; } }

Index/key variables: j
Accumulator variables: j, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static void insertionSort ( int [ ] arr , int n ) { int i , key , j ; for ( i = 1 ; i < n ; i ++ ) { key = arr [ i ] ; j = i - 1 ; while ( j >= 0 && arr [ j ] > key ) { arr [ j + 1 ] = arr [ j ] ; j = j - 1 ; } arr [ j + 1 ] = key ; } } static void printArray ( int [ ] arr , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; } static public void Main ( ) { int [ ] arr = new int [ ] { 12 , 11 , 13 , 5 , 6 } ; int N = arr . Length ; insertionSort ( arr , N ) ; printArray ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void getPairs ( int [ ] arr , int N , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] > K * arr [ i + 1 ] ) count ++ ; } } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 6 , 2 , 1 } ; int N = arr . Length ; int K = 2 ; getPairs ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int merge ( int [ ] arr , int [ ] temp , int l , int m , int r , int K ) { int i = l ; int j = m + 1 ; int cnt = 0 ; for ( i = l ; i <= m ; i ++ ) { bool found = false ; while ( j <= r ) { if ( arr [ i ] >= K * arr [ j ] ) { found = true ; } else break ; j ++ ; } if ( found == true ) { cnt += j - ( m + 1 ) ; j -- ; } } int k = l ; i = l ; j = m + 1 ; while ( i <= m && j <= r ) { if ( arr [ i ] <= arr [ j ] ) temp [ k ++ ] = arr [ i ++ ] ; else temp [ k ++ ] = arr [ j ++ ] ; } while ( i <= m ) temp [ k ++ ] = arr [ i ++ ] ; while ( j <= r ) temp [ k ++ ] = arr [ j ++ ] ; for ( i = l ; i <= r ; i ++ ) arr [ i ] = temp [ i ] ; return cnt ; } static int mergeSortUtil ( int [ ] arr , int [ ] temp , int l , int r , int K ) { int cnt = 0 ; if ( l < r ) { int m = ( l + r ) / 2 ; cnt += mergeSortUtil ( arr , temp , l , m , K ) ; cnt += mergeSortUtil ( arr , temp , m + 1 , r , K ) ; cnt += merge ( arr , temp , l , m , r , K ) ; } return cnt ; } static void mergeSort ( int [ ] arr , int N , int K ) { int [ ] temp = new int [ N ] ; Console . WriteLine ( mergeSortUtil ( arr , temp , 0 , N - 1 , K ) ) ; } static public void Main ( ) { int [ ] arr = new int [ ] { 5 , 6 , 2 , 5 } ; int N = arr . Length ; int K = 2 ; mergeSort ( arr , N , K ) ; } }

Index/key variables: N, i, j
Accumulator variables: cnt, i, j, k
Iterator variables: i
Boolean variables: found
Class/struct names: GFG
C# program:
using System ; class GFG { static void minRemovals ( int [ ] A , int N ) { Array . Sort ( A ) ; int mx = A [ N - 1 ] ; int sum = 1 ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; } if ( sum - mx >= mx ) { Console . WriteLine ( 0 ) ; } else { Console . WriteLine ( 2 * mx - sum ) ; } } public static void Main ( String [ ] args ) { int [ ] A = { 3 , 3 , 2 } ; int N = A . Length ; minRemovals ( A , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void rearrangeArray ( int [ ] a , int n ) { Array . Sort ( a ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] == i + 1 ) { int temp = a [ i ] ; a [ i ] = a [ i + 1 ] ; a [ i + 1 ] = temp ; } } if ( a [ n - 1 ] == n ) { int temp = a [ n - 1 ] ; a [ n - 1 ] = a [ n - 2 ] ; a [ n - 2 ] = temp ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( a [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 3 , 2 , 4 } ; int N = arr . Length ; rearrangeArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( int [ ] arr1 , int [ ] arr2 , int i , int j ) { if ( arr1 . Equals ( arr2 ) ) return 0 ; if ( i >= arr1 . Length j >= arr2 . Length ) return 0 ; if ( arr1 [ i ] < arr2 [ j ] ) return 1 + minOperations ( arr1 , arr2 , i + 1 , j + 1 ) ; return Math . Max ( minOperations ( arr1 , arr2 , i , j + 1 ) , minOperations ( arr1 , arr2 , i + 1 , j ) ) ; } static void minOperationsUtil ( int [ ] arr ) { int [ ] brr = new int [ arr . Length ] ; for ( int i = 0 ; i < arr . Length ; i ++ ) brr [ i ] = arr [ i ] ; Array . Sort ( brr ) ; if ( arr . Equals ( brr ) ) Console . Write ( "0" ) ; else Console . WriteLine ( minOperations ( arr , brr , 0 , 0 ) ) ; } static void Main ( ) { int [ ] arr = { 4 , 7 , 2 , 3 , 9 } ; minOperationsUtil ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void canTransform ( String s , String t ) { int n = s . Length ; List < int > [ ] occur = new List < int > [ 26 ] ; for ( int i = 0 ; i < occur . Length ; i ++ ) occur [ i ] = new List < int > ( ) ; for ( int x = 0 ; x < n ; x ++ ) { char ch = ( char ) ( s [ x ] - ' a ' ) ; occur [ ch ] . Add ( x ) ; } int [ ] idx = new int [ 26 ] ; bool poss = true ; for ( int x = 0 ; x < n ; x ++ ) { char ch = ( char ) ( t [ x ] - ' a ' ) ; if ( idx [ ch ] >= occur [ ch ] . Count ) { poss = false ; break ; } for ( int small = 0 ; small < ch ; small ++ ) { if ( idx [ small ] < occur [ small ] . Count && occur [ small ] [ idx [ small ] ] < occur [ ch ] [ idx [ ch ] ] ) { poss = false ; break ; } } idx [ ch ] ++ ; } if ( poss ) { Console . Write ( " Yes " + " STRNEWLINE " ) ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { String s , t ; s = " hdecb " ; t = " cdheb " ; canTransform ( s , t ) ; } }

Index/key variables: ch, i, small, x
Accumulator variables: i, small, x
Iterator variables: i, small, x
Boolean variables: poss
Class/struct names: GFG
C# program:
using System ; class GFG { static int inversionCount ( String s ) { int [ ] freq = new int [ 26 ] ; int inv = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { int temp = 0 ; for ( int j = 0 ; j < ( int ) ( s [ i ] - ' a ' ) ; j ++ ) temp += freq [ j ] ; inv += ( i - temp ) ; freq [ s [ i ] - ' a ' ] ++ ; } return inv ; } static bool haveRepeated ( String S1 , String S2 ) { int [ ] freq = new int [ 26 ] ; foreach ( char i in S1 . ToCharArray ( ) ) { if ( freq [ i - ' a ' ] > 0 ) return true ; freq [ i - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) freq [ i ] = 0 ; foreach ( char i in S2 . ToCharArray ( ) ) { if ( freq [ i - ' a ' ] > 0 ) return true ; freq [ i - ' a ' ] ++ ; } return false ; } static void checkToMakeEqual ( String S1 , String S2 ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < S1 . Length ; i ++ ) { freq [ S1 [ i ] - ' a ' ] ++ ; } bool flag = false ; for ( int i = 0 ; i < S2 . Length ; i ++ ) { if ( freq [ S2 [ i ] - ' a ' ] == 0 ) { flag = true ; break ; } freq [ S2 [ i ] - ' a ' ] -- ; } if ( flag == true ) { Console . WriteLine ( " No " ) ; return ; } int invCount1 = inversionCount ( S1 ) ; int invCount2 = inversionCount ( S2 ) ; if ( invCount1 == invCount2 || ( invCount1 & 1 ) == ( invCount2 & 1 ) || haveRepeated ( S1 , S2 ) ) { Console . WriteLine ( " Yes " ) ; } else Console . WriteLine ( " No " ) ; } public static void Main ( String [ ] args ) { String S1 = " abbca " , S2 = " acabb " ; checkToMakeEqual ( S1 , S2 ) ; } }

Index/key variables: i, j
Accumulator variables: i, inv, j, temp
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortArr ( int [ ] a , int n ) { int i , k ; k = ( int ) ( Math . Log ( n ) / Math . Log ( 2 ) ) ; k = ( int ) Math . Pow ( 2 , k ) ; while ( k > 0 ) { for ( i = 0 ; i + k < n ; i ++ ) if ( a [ i ] > a [ i + k ] ) { int tmp = a [ i ] ; a [ i ] = a [ i + k ] ; a [ i + k ] = tmp ; } k = k / 2 ; } for ( i = 0 ; i < n ; i ++ ) { Console . Write ( a [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 20 , 30 , 40 , 36 , 33 , 25 , 15 , 10 } ; int n = arr . Length ; sortArr ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maximumSum ( int [ ] arr , int n , int k ) { int elt = n / k ; int sum = 0 ; Array . Sort ( arr ) ; int count = 0 ; int i = n - 1 ; while ( count < k ) { sum += arr [ i ] ; i -- ; count ++ ; } count = 0 ; i = 0 ; while ( count < k ) { sum += arr [ i ] ; i += elt - 1 ; count ++ ; } Console . WriteLine ( sum ) ; } public static void Main ( String [ ] args ) { int [ ] Arr = { 1 , 13 , 7 , 17 , 6 , 5 } ; int K = 2 ; int size = Arr . Length ; maximumSum ( Arr , size , K ) ; } }

Index/key variables: i
Accumulator variables: count, i, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinSum ( int [ ] arr , int K , int L , int size ) { if ( K * L > size ) return - 1 ; int minsum = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < K ; i ++ ) minsum += arr [ i ] ; return minsum ; } public static void Main ( ) { int [ ] arr = { 2 , 15 , 5 , 1 , 35 , 16 , 67 , 10 } ; int K = 3 ; int L = 2 ; int length = arr . Length ; Console . Write ( findMinSum ( arr , K , L , length ) ) ; } }

Index/key variables: i
Accumulator variables: i, minsum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findKthSmallest ( int [ ] arr , int n , int k ) { int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; } int [ ] counter = new int [ max + 1 ] ; int smallest = 0 ; for ( int i = 0 ; i < n ; i ++ ) { counter [ arr [ i ] ] ++ ; } for ( int num = 1 ; num <= max ; num ++ ) { if ( counter [ num ] > 0 ) { smallest += counter [ num ] ; } if ( smallest >= k ) { return num ; } } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 1 , 4 , 4 , 20 , 15 , 8 } ; int N = arr . Length ; int K = 5 ; Console . Write ( findKthSmallest ( arr , N , K ) ) ; } }

Index/key variables: i, num
Accumulator variables: i, num, smallest
Iterator variables: i, num
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void lexNumbers ( int n ) { List < String > s = new List < String > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { s . Add ( String . Join ( " " , i ) ) ; } s . Sort ( ) ; List < int > ans = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) ans . Add ( Int32 . Parse ( s [ i ] ) ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( ans [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int n = 15 ; lexNumbers ( n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 4 ; static void func ( int [ , ] a ) { int i , j , k ; for ( i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { for ( j = 0 ; j < N ; j ++ ) { for ( k = j + 1 ; k < N ; ++ k ) { if ( a [ i , j ] > a [ i , k ] ) { int temp = a [ i , j ] ; a [ i , j ] = a [ i , k ] ; a [ i , k ] = temp ; } } } } else { for ( j = 0 ; j < N ; j ++ ) { for ( k = j + 1 ; k < N ; ++ k ) { if ( a [ i , j ] < a [ i , k ] ) { int temp = a [ i , j ] ; a [ i , j ] = a [ i , k ] ; a [ i , k ] = temp ; } } } } } for ( i = 0 ; i < N ; i ++ ) { for ( j = 0 ; j < N ; j ++ ) { Console . Write ( a [ i , j ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ , ] a = { { 5 , 7 , 3 , 4 } , { 9 , 5 , 8 , 2 } , { 6 , 3 , 8 , 1 } , { 5 , 8 , 9 , 3 } } ; func ( a ) ; } }

Accumulator variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static Dictionary < int , int > [ ] g = new Dictionary < int , int > [ 200005 ] ; static HashSet < int > s = new HashSet < int > ( ) ; static HashSet < int > ns = new HashSet < int > ( ) ; static void dfs ( int x ) { ArrayList v = new ArrayList ( ) ; ns . Clear ( ) ; foreach ( int it in s ) { if ( g [ x ] . ContainsKey ( it ) ) { v . Add ( it ) ; } else { ns . Add ( it ) ; } } s = ns ; foreach ( int i in v ) { dfs ( i ) ; } } static void weightOfMST ( int N ) { int cnt = 0 ; for ( int i = 1 ; i <= N ; ++ i ) { s . Add ( i ) ; } ArrayList qt = new ArrayList ( ) ; foreach ( int t in s ) qt . Add ( t ) ; while ( qt . Count != 0 ) { ++ cnt ; int t = ( int ) qt [ 0 ] ; qt . RemoveAt ( 0 ) ; dfs ( t ) ; } Console . Write ( cnt - 4 ) ; } public static void Main ( string [ ] args ) { int N = 6 , M = 11 ; int [ , ] edges = { { 1 , 3 } , { 1 , 4 } , { 1 , 5 } , { 1 , 6 } , { 2 , 3 } , { 2 , 4 } , { 2 , 5 } , { 2 , 6 } , { 3 , 4 } , { 3 , 5 } , { 3 , 6 } } ; for ( int i = 0 ; i < 11 ; i ++ ) g [ i ] = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < M ; ++ i ) { int u = edges [ i , 0 ] ; int v = edges [ i , 1 ] ; g [ u ] [ v ] = 1 ; g [ v ] [ u ] = 1 ; } weightOfMST ( N ) ; } }

Index/key variables: i, u, v, x
Accumulator variables: i
Iterator variables: i, it, t
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] A , int [ ] B ) { int n = A . Length ; int ans = 0 ; Array . Sort ( A ) ; Array . Sort ( B ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] > B [ ans ] ) { ans ++ ; } } return ans ; } public static void Main ( ) { int [ ] A = { 30 , 28 , 45 , 22 } ; int [ ] B = { 35 , 25 , 22 , 48 } ; Console . Write ( countPairs ( A , B ) ) ; } }

Index/key variables: ans, i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int max_element ( int [ ] arr , int n ) { int max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( max < arr [ i ] ) max = arr [ i ] ; } return max ; } static int maxMod ( int [ ] arr , int n ) { int maxVal = max_element ( arr , n ) ; int secondMax = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < maxVal && arr [ i ] > secondMax ) { secondMax = arr [ i ] ; } } return secondMax ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 1 , 5 , 3 , 6 } ; int n = arr . Length ; Console . WriteLine ( maxMod ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPossible ( int [ ] A , int [ ] B , int n , int m , int x , int y ) { if ( x > n y > m ) return false ; Array . Sort ( A ) ; Array . Sort ( B ) ; if ( A [ x - 1 ] < B [ m - y ] ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 1 , 1 , 1 , 1 } ; int [ ] B = { 2 , 2 } ; int n = A . Length ; int m = B . Length ; ; int x = 3 , y = 1 ; if ( isPossible ( A , B , n , m , x , y ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100005 ; static int Min_Replace ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; int [ ] freq = new int [ MAX ] ; int p = 0 ; freq [ p ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) ++ freq [ p ] ; else ++ freq [ ++ p ] ; } Array . Sort ( freq ) ; Array . Reverse ( freq ) ; int ans = 0 ; for ( int i = k ; i <= p ; i ++ ) ans += freq [ i ] ; return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 7 , 8 , 2 , 3 , 2 , 3 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( Min_Replace ( arr , n , k ) ) ; } }

Index/key variables: MAX, i, p
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG