dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { static bool checkIfAllTogether ( string s , char c ) { static bool checkIfAllTogether ( string s , char c ) { bool oneSeen = false ; int i = 0 , n = s . Length ; while ( i < n ) { if ( s [ i ] == c ) { if ( oneSeen == true ) return false ; while ( i < n && s [ i ] == c ) i ++ ; oneSeen = true ; } else i ++ ; } return true ; } public static void Main ( ) { string s = "110029" ; if ( checkIfAllTogether ( s , '1' ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Boolean variables: oneSeen
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool search ( int [ ] arr , int n , int x ) { int front = 0 , back = n - 1 ; while ( front <= back ) { if ( arr [ front ] == x arr [ back ] == x ) return true ; front ++ ; back -- ; } return false ; } static public void Main ( ) { int [ ] arr = { 10 , 20 , 80 , 30 , 60 , 50 , 110 , 100 , 130 , 170 } ; int x = 130 ; int n = arr . Length ; if ( search ( arr , n , x ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: back, front
Accumulator variables: back, front
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findValue ( int X , int Y , int P ) { if ( P % 2 == 0 ) return ( Math . Max ( X , Y ) / Math . Min ( X , Y ) ) ; else return ( Math . Max ( 2 * X , Y ) / Math . Min ( 2 * X , Y ) ) ; } public static void Main ( ) { int X = 1 , Y = 2 , P = 1 ; Console . WriteLine ( findValue ( X , Y , P ) ) ; X = 3 ; Y = 7 ; P = 2 ; Console . WriteLine ( findValue ( X , Y , P ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int sum ( int [ ] arr , int from , int to ) { int total = 0 ; for ( int i = from ; i <= to ; i ++ ) total += arr [ i ] ; return total ; } static int findMax ( int [ ] arr , int n , int k ) { int [ , ] dp = new int [ k + 1 , n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) dp [ 1 , i ] = sum ( arr , 0 , i - 1 ) ; for ( int i = 1 ; i <= k ; i ++ ) dp [ i , 1 ] = arr [ 0 ] ; for ( int j = 2 ; j <= n ; j ++ ) { int best = int . MaxValue ; for ( int p = 1 ; p <= j ; p ++ ) best = Math . Min ( best , Math . Max ( dp [ i - 1 , p ] , sum ( arr , p , j - 1 ) ) ) ; dp [ i , j ] = best ; } } return dp [ k , n ] ; } public static void ( ) { int [ ] arr = { 10 , 20 , 60 , 50 , 30 , 40 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( findMax ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, p, total
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int countCrossLine ( int [ ] arr , int n ) { int count_crossline = 0 ; 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 ; count_crossline ++ ; } arr [ j + 1 ] = key ; } return count_crossline ; } public static void Main ( ) { int [ ] arr = new int [ ] { 4 , 3 , 1 , 2 } ; int n = arr . Length ; Console . Write ( countCrossLine ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count_crossline, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findMaxRec ( int [ ] A , int n ) { if ( n == 1 ) return A [ 0 ] ; return Math . Max ( A [ n - 1 ] , findMaxRec ( A , n - 1 ) ) ; } static public void Main ( ) { int [ ] A = { 1 , 4 , 45 , 6 , - 50 , 10 , 2 } ; int n = A . Length ; Console . WriteLine ( findMaxRec ( A , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Text . RegularExpressions ; class GFG { static String remVowel ( String str ) { str = Regex . Replace ( str , " [ aeiouAEIOU ] " , " " ) ; return str ; } public static void Main ( ) { String str = " GeeeksforGeeks ▁ - ▁ A ▁ Computer ▁ Science ▁ Portal ▁ for ▁ Geeks " ; Console . WriteLine ( remVowel ( str ) ) ; } }

Index/key variables: aeiouAEIOU
Class/struct names: GFG
C# program:
using System ; class GFG { static void findAmountPlayers ( int [ ] arr , int N ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int amountA = 0 ; int amountB = 0 ; if ( N == 1 ) { amountA += arr [ 0 ] ; Console . WriteLine ( " ( A ▁ : ▁ " + amountA + " ) , ▁ " + " ( B ▁ : ▁ " + amountB + " ) " ) ; return ; } amountA = arr [ 0 ] ; amountB = arr [ 1 ] ; for ( int i = 2 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { amountB += arr [ i ] ; } else { amountA += arr [ i ] ; } } Console . WriteLine ( " ( A ▁ : ▁ " + amountA + " ) " ) ; Console . WriteLine ( " ( B ▁ : ▁ " + amountB + " ) " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 1 } ; int N = arr . Length ; findAmountPlayers ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: amountA, amountB, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortArray ( int [ ] arr , int N ) { int i = 0 , j = N - 1 , mid = 0 ; while ( mid <= j ) { if ( arr [ mid ] == 0 ) { int temp = arr [ i ] ; arr [ i ] = arr [ mid ] ; arr [ mid ] = temp ; i ++ ; mid ++ ; } else if ( arr [ mid ] == 3 ) { int temp = arr [ mid ] ; arr [ mid ] = arr [ j ] ; arr [ j ] = temp ; j -- ; } else if ( arr [ mid ] == 1 arr [ mid ] == 2 ) { mid ++ ; } } while ( i <= j ) { if ( arr [ i ] == 2 ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; j -- ; } else { i ++ ; } } for ( int k = 0 ; k < N ; k ++ ) { Console . Write ( arr [ k ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 3 , 2 , 1 , 0 , 2 , 3 , 1 , 0 } ; int N = arr . Length ; sortArray ( arr , N ) ; } }

Index/key variables: i, j, k, mid
Accumulator variables: i, j, k, mid
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool check ( int [ ] arr , int n ) { int count = 0 ; int index = - 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i - 1 ] >= arr [ i ] ) { count ++ ; index = i ; } } if ( count > 1 ) return false ; if ( count == 0 ) return true ; if ( index == n - 1 index == 1 ) return true ; if ( arr [ index - 1 ] < arr [ index + 1 ] ) return true ; if ( arr [ index - 2 ] < arr [ index ] ) return true ; return false ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 5 , 3 , 5 } ; int N = arr . Length ; if ( check ( arr , N ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, index
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void sortVowels ( string S ) { int n = S . Length ; string vow = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( S [ i ] == ' a ' S [ i ] == ' e ' S [ i ] == ' i ' S [ i ] == ' o ' S [ i ] == ' u ' ) { vow = vow . Substring ( 0 , vow . Length ) + S [ i ] ; } } if ( vow . Length == 0 ) { Console . Write ( S ) ; return ; } char [ ] tempArray = vow . ToCharArray ( ) ; Array . Sort ( tempArray ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( S [ i ] == ' a ' S [ i ] == ' e ' S [ i ] == ' i ' S [ i ] == ' o ' S [ i ] == ' u ' ) { S = S . Substring ( 0 , i ) + tempArray [ j ++ ] + S . Substring ( i + 1 , n - i - 1 ) ; } } Console . Write ( S ) ; } public static void Main ( string [ ] args ) { string S = " geeksforgeeks " ; sortVowels ( S ) ; } }

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

Index/key variables: i
Accumulator variables: i, sum
Class/struct names: GFG
C# program:
using System ; public class GFG { static void minimumIncreasingSubsequences ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int count = 0 ; int i = 0 ; while ( i < N ) { int x = arr [ i ] ; int freqX = 0 ; while ( i < N && arr [ i ] == x ) { freqX ++ ; i ++ ; } count = Math . Max ( count , freqX ) ; } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 2 , 1 , 4 , 3 } ; int N = arr . Length ; minimumIncreasingSubsequences ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: freqX, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getCount ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int count = 0 ; if ( N < 3 ) return 0 ; for ( int b = 0 ; b < N ; b ++ ) { int a = 0 , c = N - 1 ; int d = arr [ b ] * arr [ b ] / 4 ; while ( a < c ) { if ( a == b ) { a ++ ; continue ; } if ( c == b ) { c -- ; continue ; } if ( arr [ a ] * arr <= d ) { if ( a < b && b < c ) { count += c - a - 1 ; } else { count += c - a ; } a ++ ; } else { c -- ; } } } return count * 2 ; } static public void Main ( ) { int [ ] arr = { 3 , 6 , 10 , 13 , 21 } ; int N = arr . Length ; Console . Write ( getCount ( arr , N ) ) ; } }

Index/key variables: a, b
Accumulator variables: a, b, c, count
Iterator variables: b
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMaxDifference ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int Leftsum = 0 ; int Totalsum = 0 ; int Minn = Int32 . MaxValue , Maxx = Int32 . MinValue ; for ( int i = 0 ; i < n ; i ++ ) Totalsum += arr [ i ] ; for ( int i = 0 ; i < n ; i ++ ) { int leftNumbers = i ; int rightNumbers = n - i - 1 ; Totalsum = Totalsum - arr [ i ] ; int sum = ( leftNumbers * arr [ i ] ) - Leftsum + Totalsum - ( rightNumbers * arr [ i ] ) ; Minn = Math . Min ( Minn , sum ) ; Maxx = Math . Max ( Maxx , sum ) ; Leftsum += arr [ i ] ; } Console . WriteLine ( Maxx - Minn ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 7 } ; int N = arr . Length ; findMaxDifference ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: Leftsum, Totalsum, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxcntPairsSumKRemoved ( int [ ] arr , int k ) { int cntPairs = 0 ; if ( arr . Length <= 1 ) return cntPairs ; Array . Sort ( arr ) ; int left = 0 ; int right = arr . Length - 1 ; while ( left < right ) { int s = arr [ left ] + arr [ right ] ; if ( s == k ) { cntPairs += 1 ; left += 1 ; right -= 1 ; } else if ( s > k ) right -= 1 ; else left += 1 ; } return cntPairs ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int K = 5 ; Console . WriteLine ( maxcntPairsSumKRemoved ( arr , K ) ) ; } }

Index/key variables: left, right
Accumulator variables: cntPairs, left, right
Class/struct names: GFG
C# program:
using System ; class GFG { static void reverse ( int [ ] a , int n ) { int i , k , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } } static int getMinCost ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; reverse ( arr , n ) ; int min_cost = 0 ; int X = 0 ; for ( int i = 0 ; i < n ; i += k ) { for ( int j = i ; j < i + k && j < n ; j ++ ) { min_cost += arr [ j ] * ( X + 1 ) ; } X ++ ; } return min_cost ; } public static void Main ( String [ ] args ) { int [ ] arr = { 9 , 20 , 7 , 8 } ; int K = 2 ; int N = arr . Length ; Console . WriteLine ( getMinCost ( arr , N , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: X, i, j, min_cost
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDiff ( int [ ] A , int K ) { Array . Sort ( A ) ; int n = A . Length ; if ( n <= K ) return 0 ; int mindiff = A [ n - 1 ] - A [ 0 ] ; if ( K == 0 ) return mindiff ; for ( int i = 0 , j = n - 1 - K ; j < n ; ) { mindiff = Math . Min ( mindiff , A [ j ] - A [ i ] ) ; i ++ ; j ++ ; } return mindiff ; } public static void Main ( String [ ] args ) { int [ ] A = { - 1 , 3 , - 1 , 8 , 5 , 4 } ; int K = 3 ; Console . WriteLine ( minDiff ( A , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minDiff ( int [ ] A , int K ) { if ( A . Length <= K + 1 ) return 0 ; List < int > maxHeap = new List < int > ( ) ; List < int > minHeap = new List < int > ( ) ; foreach ( int n in A ) { maxHeap . Add ( n ) ; maxHeap . Sort ( ) ; if ( maxHeap . Count > K + 1 ) maxHeap . RemoveAt ( 0 ) ; minHeap . Add ( n ) ; minHeap . Sort ( ) ; minHeap . Reverse ( ) ; if ( minHeap . Count > K + 1 ) minHeap . RemoveAt ( 0 ) ; } List < int > maxList = new List < int > ( ) ; while ( maxHeap . Count > 0 ) { maxList . Add ( maxHeap [ 0 ] ) ; maxHeap . RemoveAt ( 0 ) ; } List < int > minList = new List < int > ( ) ; while ( minHeap . Count > 0 ) { minList . Add ( minHeap [ 0 ] ) ; minHeap . RemoveAt ( 0 ) ; } int mindiff = Int32 . MaxValue ; for ( int i = 0 ; i < K ; i ++ ) { mindiff = Math . Min ( mindiff , maxList [ i ] - minList [ K - i ] ) ; } return mindiff ; } static void Main ( ) { int [ ] A = { - 1 , 3 , - 1 , 8 , 5 , 4 } ; int K = 3 ; Console . WriteLine ( minDiff ( A , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, n
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortArrayInDescAsc ( int [ ] arr , int N , int K ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int temp = 0 ; for ( int i = K ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] > arr [ j ] ) { temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 7 , 6 , 8 , 9 , 0 , 1 , 2 , 2 , 1 , 8 , 9 , 6 , 7 } ; int N = arr . Length ; int K = 6 ; sortArrayInDescAsc ( arr , N , K ) ; } }

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 GFG { static int findMedianOfsubSum ( int [ ] arr , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } Array . Sort ( arr ) ; int [ , ] dp = new int [ N , sum + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < sum + 1 ; j ++ ) dp [ i , j ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { dp [ i , 0 ] = 1 ; } dp [ 0 , arr [ 0 ] ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j <= sum ; j ++ ) { if ( j >= arr [ i ] ) { dp [ i , j ] = dp [ i - 1 , j ] + dp [ i - 1 , j - arr [ i ] ] ; } else { dp [ i , j ] = dp [ i - 1 , j ] ; } } } List < int > sumSub = new List < int > ( ) ; for ( int j = 1 ; j <= sum ; j ++ ) { int M = dp [ N - 1 , j ] ; for ( int i = 1 ; i <= M ; i ++ ) { sumSub . Add ( j ) ; } } int mid = sumSub [ sumSub . Count / 2 ] ; return mid ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 3 } ; int N = arr . Length ; Console . Write ( findMedianOfsubSum ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printIndex ( int [ ] arr , int N ) { int [ ] B = new int [ N ] ; int save = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { B [ i ] = arr [ i ] ; } Array . Sort ( B ) ; for ( int i = N - 1 ; i >= 1 ; i -- ) { if ( B [ i ] != B [ i - 1 ] ) { save = B [ i ] ; break ; } } if ( save == - 1 ) { Console . Write ( - 1 + " STRNEWLINE " ) ; return ; } if ( save == arr [ 0 ] && save != arr [ 1 ] ) { Console . Write ( 1 ) ; } else if ( save == arr [ N - 1 ] && save != arr [ N - 2 ] ) { Console . Write ( N ) ; } for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( save == arr [ i ] && ( save != arr [ i - 1 ] save != arr [ i + 1 ] ) ) { Console . Write ( i + 1 ) ; break ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 3 , 4 , 4 , 5 } ; int N = arr . Length ; printIndex ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void firstSubsequence ( string s ) { List < string > allsubseq = new List < string > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { string k = " " ; for ( int j = 0 ; j < s . Length ; j ++ ) { if ( i != j ) { k += s [ j ] ; } } allsubseq . Add ( k ) ; } allsubseq . Sort ( ) ; Console . WriteLine ( allsubseq [ 0 ] ) ; } public static void Main ( ) { string S = " geeksforgeeks " ; firstSubsequence ( S ) ; } }

Index/key variables: j
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int evenSumK ( int [ ] arr , int N , int K ) { if ( K > N ) { return - 1 ; } int maxSum = 0 ; List < int > Even = new List < int > ( ) ; List < int > Odd = new List < int > ( ) ; for ( int l = 0 ; l < N ; l ++ ) { if ( arr [ l ] % 2 == 1 ) { Odd . Add ( arr [ l ] ) ; } else { Even . Add ( arr [ l ] ) ; } } Odd . Sort ( ) ; Even . Sort ( ) ; int i = Even . Count - 1 ; int j = Odd . Count - 1 ; while ( K > 0 ) { if ( K % 2 == 1 ) { if ( i >= 0 ) { maxSum += Even [ i ] ; i -- ; } else { return - 1 ; } K -- ; } else if ( i >= 1 && j >= 1 ) { if ( Even [ i ] + Even [ i - 1 ] <= Odd [ j ] + Odd [ j - 1 ] ) { maxSum += Odd [ j ] + Odd [ j - 1 ] ; j -= 2 ; } else { maxSum += Even [ i ] + Even [ i - 1 ] ; i -= 2 ; } K -= 2 ; } else if ( i >= 1 ) { maxSum += Even [ i ] + Even [ i - 1 ] ; i -= 2 ; K -= 2 ; } else if ( j >= 1 ) { maxSum += Odd [ j ] + Odd [ j - 1 ] ; j -= 2 ; K -= 2 ; } } return maxSum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 10 , 3 , 5 } ; int N = arr . Length ; int K = 3 ; Console . WriteLine ( evenSumK ( arr , N , K ) ) ; } }

Index/key variables: i, j, l
Accumulator variables: K, i, j, l, maxSum
Iterator variables: l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void weightedMedian ( int [ ] arr , float [ ] W ) { List < Tuple < int , float > > pr = new List < Tuple < int , float > > ( ) ; for ( int index = 0 ; index < arr . Length ; index ++ ) pr . Add ( new Tuple < int , float > ( arr [ index ] , W [ index ] ) ) ; pr . Sort ( ) ; if ( arr . Length % 2 != 0 ) { float sums = 0 ; foreach ( Tuple < int , float > element in pr ) { sums += element . Item2 ; if ( sums > 0.5 ) Console . WriteLine ( " The ▁ Weighted ▁ Median ▁ " + " is ▁ element ▁ " + element . Item1 ) ; } } else { float sums = 0 ; foreach ( Tuple < int , float > element in pr ) { sums += element . Item2 ; if ( sums >= 0.5 ) { Console . WriteLine ( " Lower ▁ Weighted ▁ Median ▁ " + " is ▁ element ▁ " + element . Item1 ) ; break ; } } sums = 0 ; for ( int index = pr . Count - 1 ; index >= 0 ; index -- ) { int element = pr [ index ] . Item1 ; float weight = pr [ index ] . Item2 ; sums += weight ; if ( sums >= 0.5 ) { Console . Write ( " Upper ▁ Weighted ▁ Median ▁ " + " is ▁ element ▁ " + element ) ; break ; } } } } static void Main ( ) { int [ ] arr = { 4 , 1 , 3 , 2 } ; float [ ] W = { 0.25f , 0.49f , 0.25f , 0.01f } ; weightedMedian ( arr , W ) ; } }

Index/key variables: index
Accumulator variables: index, sums
Iterator variables: element, index
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int KthSmallestNum ( int [ , ] arr , int n , int k ) { ArrayList pq = new ArrayList ( ) ; for ( int i = 0 ; i < n ; i ++ ) { pq . Add ( new Tuple < int , int > ( arr [ i , 0 ] , arr [ i , 1 ] ) ) ; } int cnt = 1 ; while ( cnt < k ) { pq . Sort ( ) ; pq . Reverse ( ) ; Tuple < int , int > interval = ( Tuple < int , int > ) pq [ 0 ] ; pq . RemoveAt ( 0 ) ; if ( interval . Item1 < interval . Item2 ) { pq . Add ( new Tuple < int , int > ( interval . Item1 + 1 , interval . Item2 ) ) ; } cnt += 1 ; } pq . Sort ( ) ; pq . Reverse ( ) ; return ( ( Tuple < int , int > ) pq [ 0 ] ) . Item1 + 1 ; } static void Main ( ) { int [ , ] arr = { { 5 , 11 } , { 10 , 15 } , { 12 , 20 } } ; int n = arr . GetLength ( 0 ) ; int k = 12 ; Console . WriteLine ( KthSmallestNum ( arr , n , k ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Pair { public int x ; public int y ; public Pair ( int x , int y ) { this . x = x ; this . y = y ; } } static void MaxDist ( List < Pair > A , int N ) { int maximum = int . MinValue ; for ( int i = 0 ; i < N ; i ++ ) { int sum = 0 ; for ( int j = i + 1 ; j < N ; j ++ ) { sum = Math . Abs ( A [ i ] . x - A [ j ] . x ) + Math . Abs ( A [ i ] . y - A [ j ] . y ) ; maximum = Math . Max ( maximum , sum ) ; } } Console . WriteLine ( maximum ) ; } public static void Main ( String [ ] args ) { int n = 3 ; List < Pair > al = new List < Pair > ( ) ; Pair p1 = new Pair ( 1 , 2 ) ; al . Add ( p1 ) ; Pair p2 = new Pair ( 2 , 3 ) ; al . Add ( p2 ) ; Pair p3 = new Pair ( 3 , 4 ) ; al . Add ( p3 ) ; MaxDist ( al , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Pair
C# program:
using System . Collections . Generic ; using System ; class GFG { static int LongestSequence ( int [ ] a , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; int [ ] ar = new int [ n + 1 ] ; int i = 0 ; int j = 0 ; for ( i = 1 ; i <= n ; i ++ ) { ar [ i ] = a [ i - 1 ] ; } Array . Sort ( a ) ; int c = 1 ; m [ a [ 0 ] ] = c ; for ( i = 1 ; i < n ; i ++ ) { if ( a [ i ] != a [ i - 1 ] ) { c ++ ; m [ a [ i ] ] = c ; } } Dictionary < int , int > cnt = new Dictionary < int , int > ( ) ; int [ , ] dp = new int [ n + 1 , 3 ] ; cnt [ 0 ] = 0 ; for ( i = 1 ; i <= n ; i ++ ) { ar [ i ] = m [ ar [ i ] ] ; if ( cnt . ContainsKey ( ar [ i ] ) ) cnt [ ar [ i ] ] = cnt [ ar [ i ] ] + 1 ; else cnt [ ar [ i ] ] = 1 ; } int ans = 0 , x ; for ( i = 1 ; i <= n ; i ++ ) { x = ar [ i ] ; if ( dp [ x , 0 ] == 0 ) { if ( dp [ x - 1 , 0 ] == cnt [ x - 1 ] ) { dp [ x , 1 ] = dp [ x - 1 , 1 ] ; dp [ x , 2 ] = dp [ x - 1 , 1 ] ; } else { dp [ x , 1 ] = dp [ x - 1 , 0 ] ; } } dp [ x , 2 ] = Math . Max ( dp [ x - 1 , 0 ] , dp [ x , 2 ] ) ; if ( dp [ x - 1 , 0 ] == cnt [ x - 1 ] ) { dp [ x , 2 ] = Math . Max ( dp [ x , 2 ] , dp [ x - 1 , 1 ] ) ; } for ( j = 0 ; j < 3 ; j ++ ) { dp [ x , j ] ++ ; ans = Math . Max ( ans , dp [ x , j ] ) ; } } return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 6 , 4 , 8 , 2 , 9 } ; int n = arr . Length ; Console . WriteLine ( LongestSequence ( arr , n ) ) ; } } Console . WriteLine ( LongestSequence ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] findMatrix ( int N , int K ) { int [ , ] mat = new int [ N , N ] ; int element = 1 ; for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < K - 1 ; ++ j ) { mat [ i , j ] = element ++ ; } } for ( int i = 0 ; i < N ; ++ i ) { for ( int j = K - 1 ; j < N ; ++ j ) { mat [ i , j ] = element ++ ; } } return mat ; } static void printMatrix ( int [ , ] mat , int N ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int N = 3 , K = 2 ; int [ , ] mat = findMatrix ( N , K ) ; printMatrix ( mat , N ) ; } }

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