dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static int [ ] minMaxRange ( int [ ] arr , int D , int N ) { int max = 1 , min = N ; for ( int i = 0 ; i < N ; i ++ ) { int dist = leftSearch ( arr , arr [ i ] - D , i ) ; min = Math . Min ( min , dist ) ; max = Math . Max ( max , dist ) ; dist = rightSearch ( arr , arr [ i ] + D , i ) ; min = Math . Min ( min , dist ) ; max = Math . Max ( max , dist ) ; } return new int [ ] { min , max } ; } public static int leftSearch ( int [ ] arr , int val , int i ) { if ( i == 0 ) return 1 ; int left = 0 , right = i - 1 ; int ind = - 1 ; while ( left <= right ) { int mid = ( left + right ) / 2 ; if ( arr [ mid ] < val ) { left = mid + 1 ; } else { right = mid - 1 ; ind = mid ; } } return ind != - 1 ? i - ind + 1 : 1 ; } public static int rightSearch ( int [ ] arr , int val , int i ) { if ( i == arr . Length - 1 ) return 1 ; int left = i + 1 ; int right = arr . Length - 1 ; int ind = - 1 ; while ( left <= right ) { int mid = ( left + right ) / 2 ; if ( arr [ mid ] > val ) { right = mid - 1 ; } else { left = mid + 1 ; ind = mid ; } } return ind != - 1 ? ind - i + 1 : 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 9 , 14 } ; int N = arr . Length ; int D = 4 ; int [ ] minMax = minMaxRange ( arr , D , N ) ; Console . Write ( minMax [ 0 ] + " ▁ " + minMax [ 1 ] ) ; } }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findPairs ( int [ ] arr1 , int [ ] arr2 , int n , int m , int x ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) if ( arr1 [ i ] + arr2 [ j ] == x ) Console . WriteLine ( arr1 [ i ] + " ▁ " + arr2 [ j ] ) ; } static void Main ( ) { int [ ] arr1 = { 1 , 2 , 3 , 7 , 5 , 4 } ; int [ ] arr2 = { 0 , 7 , 4 , 3 , 2 , 1 } ; int x = 8 ; findPairs ( arr1 , arr2 , arr1 . Length , arr2 . Length , x ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static bool isvalid ( int [ ] arr , int K , int N , int M ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += ( int ) Math . Ceiling ( arr [ i ] * 1.0 / K ) ; } return sum <= M ; } static int smallestValueForK ( int [ ] arr , int N , int M ) { int low = 1 ; int high = arr . Max ( ) ; int mid ; while ( high - low > 1 ) { mid = ( high + low ) / 2 ; if ( ! isvalid ( arr , mid , N , M ) ) low = mid + 1 ; else high = mid ; } return isvalid ( arr , low , N , M ) ? low : high ; } public static void Main ( ) { int [ ] arr = { 4 , 3 , 2 , 7 } ; int N = arr . Length ; int M = 5 ; Console . WriteLine ( smallestValueForK ( arr , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void findPairs ( int [ ] arr1 , int [ ] arr2 , int n , int m , int x ) { Dictionary < int , int > s = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s [ arr1 [ i ] ] = 0 ; } for ( int j = 0 ; j < m ; j ++ ) { if ( s . ContainsKey ( x - arr2 [ j ] ) ) { Console . WriteLine ( x - arr2 [ j ] + " ▁ " + arr2 [ j ] ) ; } } } public static void Main ( string [ ] args ) { int [ ] arr1 = new int [ ] { 1 , 0 , - 4 , 7 , 6 , 4 } ; int [ ] arr2 = new int [ ] { 0 , 2 , 4 , - 3 , 2 , 1 } ; int x = 8 ; findPairs ( arr1 , arr2 , arr1 . Length , arr2 . Length , x ) ; } }

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 largestAltitude ( int L , int B ) { if ( L > B ) { int t = L ; L = B ; B = t ; } int res = Math . Min ( B / 2 , L ) ; return res ; } public static void Main ( String [ ] args ) { int L = 3 ; int B = 4 ; Console . Write ( largestAltitude ( L , B ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int key ; public Node left , right ; public Node ( int key ) { left = null ; right = null ; this . key = key ; } } public class INT { public int d ; public INT ( ) { d = 0 ; } } static bool isBalancedUtil ( Node root , INT maxh , INT minh ) { if ( root == null ) { maxh . d = minh . d = 0 ; return true ; } INT lmxh = new INT ( ) , lmnh = new INT ( ) ; INT rmxh = new INT ( ) , rmnh = new INT ( ) ; if ( isBalancedUtil ( root . left , lmxh , lmnh ) == false ) return false ; if ( isBalancedUtil ( root . right , rmxh , rmnh ) == false ) return false ; maxh . d = Math . Max ( lmxh . d , rmxh . d ) + 1 ; minh . d = Math . Min ( lmnh . d , rmnh . d ) + 1 ; if ( maxh . d <= 2 * minh . d ) return true ; return false ; } static bool isBalanced ( Node root ) { INT maxh = new INT ( ) , minh = new INT ( ) ; return isBalancedUtil ( root , maxh , minh ) ; } public static void Main ( String [ ] args ) { Node root = new Node ( 10 ) ; root . left = new Node ( 5 ) ; root . right = new Node ( 100 ) ; root . right . left = new Node ( 50 ) ; root . right . right = new Node ( 150 ) ; root . right . left . left = new Node ( 40 ) ; Console . WriteLine ( isBalanced ( root ) ? " Balanced " : " Not ▁ Balanced " ) ; } }

Class/struct names: GFG, INT, Node
C# program:
using System ; class GFG { static void findLargestIndex ( int [ ] arr , int n ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == i ) { Console . Write ( i ) ; return ; } } Console . Write ( - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 10 , - 5 , 0 , 3 , 7 } ; int n = arr . Length ; findLargestIndex ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countFreq ( int [ ] a , int n ) { int [ ] hm = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) hm [ a [ i ] ] ++ ; int cumul = 0 ; for ( int i = 0 ; i < n ; i ++ ) { cumul += hm [ a [ i ] ] ; if ( hm [ a [ i ] ] != 0 ) { Console . WriteLine ( a [ i ] + " - > " + cumul ) ; } hm [ a [ i ] ] = 0 ; } } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 3 , 2 , 4 , 2 , 1 } ; int n = a . Length ; countFreq ( a , n ) ; } }

Index/key variables: i, n
Accumulator variables: cumul, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findPair ( int [ ] arr , int n ) { bool found = false ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { if ( arr [ i ] + arr [ j ] == arr [ k ] ) { Console . WriteLine ( arr [ i ] + " ▁ " + arr [ j ] ) ; found = true ; } } } } if ( found == false ) Console . WriteLine ( " Not ▁ exist " ) ; } static public void Main ( String [ ] args ) { int [ ] arr = { 10 , 4 , 8 , 13 , 5 } ; int n = arr . Length ; findPair ( arr , n ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Boolean variables: found
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int n , int m , int x , int y , int vl ) { int temp = m ; if ( vl > n ) return false ; int ex = n - vl ; ex *= y ; temp += ex ; int cr = temp / x ; if ( cr >= vl ) return true ; return false ; } static int maximizeMangoes ( int n , int m , int x , int y ) { int l = 0 , r = n ; int ans = 0 ; while ( l <= r ) { int mid = l + ( r - l ) / 2 ; if ( check ( n , m , x , y , mid ) ) { ans = mid ; l = mid + 1 ; } else r = mid - 1 ; } return ans ; } public static void Main ( ) { int W = 4 , C = 8 , x = 4 , y = 4 ; Console . Write ( maximizeMangoes ( W , C , x , y ) ) ; } }

Accumulator variables: ex, temp
Class/struct names: GFG
C# program:
using System . IO ; using System ; class GFG { public static int findkthElement ( int [ ] arr , int n , int K ) { int l = 0 ; int h = n - 1 , r ; while ( l + 1 < h ) { int mid = ( l + h ) / 2 ; if ( arr [ l ] >= arr [ mid ] ) l = mid ; else h = mid ; } if ( arr [ l ] < arr [ h ] ) r = l ; else r = h ; if ( K <= r + 1 ) return arr [ r + 1 - K ] ; else return arr [ n - ( K - ( r + 1 ) ) ] ; } static void Main ( ) { int [ ] arr = { 10 , 8 , 6 , 5 , 2 , 1 , 13 , 12 } ; int n = arr . Length ; int K = 3 ; Console . WriteLine ( findkthElement ( arr , n , K ) ) ; } }

Index/key variables: h, l, mid
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool printPairs ( int [ ] arr , int n , int k ) { bool isPairFound = true ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i != j && arr [ i ] % arr [ j ] == k ) { Console . Write ( " ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) " + " ▁ " ) ; isPairFound = true ; } } } return isPairFound ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 4 , 7 } ; int k = 3 ; if ( printPairs ( arr , arr . Length , k ) == false ) Console . WriteLine ( " No ▁ such ▁ pair ▁ exists " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: isPairFound
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static List < int > findDivisors ( int n ) { List < int > v = new List < int > ( ) ; for ( int i = 1 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { v . Add ( i ) ; } else { v . Add ( i ) ; v . Add ( n / i ) ; } } } return v ; } public static bool printPairs ( int [ ] arr , int n , int k ) { Dictionary < int , bool > occ = new Dictionary < int , bool > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { occ [ arr [ i ] ] = true ; } bool isPairFound = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( occ [ k ] && k < arr [ i ] ) { Console . Write ( " ( " + k + " , ▁ " + arr [ i ] + " ) ▁ " ) ; isPairFound = true ; } if ( arr [ i ] >= k ) { List < int > v = findDivisors ( arr [ i ] - k ) ; for ( int j = 0 ; j < v . Count ; j ++ ) { if ( arr [ i ] % v [ j ] == k && arr [ i ] != v [ j ] && occ [ v [ j ] ] ) { Console . Write ( " ( " + arr [ i ] + " , ▁ " + v [ j ] + " ) ▁ " ) ; isPairFound = true ; } } v . Clear ( ) ; } } return isPairFound ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 3 , 1 , 2 , 5 , 4 } ; int k = 2 ; if ( printPairs ( arr , arr . Length , k ) == false ) { Console . WriteLine ( " No ▁ such ▁ pair ▁ exists " ) ; } } }

Index/key variables: i, j, k
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: isPairFound
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int val ; public Node left , right ; } ; static Node newNode ( int item ) { Node temp = new Node ( ) ; temp . val = item ; temp . left = temp . right = null ; return temp ; } static int sum = 0 ; static int rangeSumBST ( Node root , int low , int high ) { if ( root == null ) return 0 ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { Node curr = q . Peek ( ) ; q . Dequeue ( ) ; if ( curr . val >= low && curr . val <= high ) { sum += curr . val ; } if ( curr . left != null && curr . val > low ) q . Enqueue ( curr . left ) ; if ( curr . right != null && curr . val < high ) q . Enqueue ( curr . right ) ; } return sum ; } static Node insert ( Node node , int data ) { if ( node == null ) return newNode ( data ) ; if ( data <= node . val ) node . left = insert ( node . left , data ) ; else node . right = insert ( node . right , data ) ; return node ; } public static void Main ( String [ ] args ) { Node root = null ; root = insert ( root , 10 ) ; insert ( root , 5 ) ; insert ( root , 15 ) ; insert ( root , 3 ) ; insert ( root , 7 ) ; insert ( root , 18 ) ; int L = 7 , R = 15 ; Console . Write ( rangeSumBST ( root , L , R ) ) ; } }

Accumulator variables: sum
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { public static void convert ( int [ ] arr , int n ) { int [ ] temp = new int [ arr . Length ] ; Array . Copy ( arr , 0 , temp , 0 , arr . Length ) ; Array . Sort ( temp ) ; Dictionary < int , int > umap = new Dictionary < int , int > ( ) ; int val = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( umap . ContainsKey ( temp [ i ] ) ) umap [ temp [ i ] ] = val ++ ; else umap . Add ( temp [ i ] , val ++ ) ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = umap [ arr [ i ] ] ; } public static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 20 , 15 , 12 , 11 , 50 } ; int n = arr . Length ; Console . WriteLine ( " Given ▁ Array ▁ is ▁ " ) ; printArr ( arr , n ) ; convert ( arr , n ) ; Console . WriteLine ( " STRNEWLINE STRNEWLINE Converted ▁ Array ▁ is ▁ " ) ; printArr ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i, val
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubstrings ( string S , string S1 , string S2 ) { int N = S . Length ; int N1 = S1 . Length ; int N2 = S2 . Length ; int count = 0 , totalcount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { String prefix = S . Substring ( i , ( i + N1 < N ) ? N1 : ( N - i ) ) ; String suffix = S . Substring ( i , ( i + N2 < N ) ? N2 : ( N - i ) ) ; if ( S1 . Equals ( prefix ) ) count ++ ; if ( S2 . Equals ( suffix ) ) totalcount += count ; } return totalcount ; } static void checkSubstrings ( string S , string S1 , string S2 ) { int x = countSubstrings ( S , S1 , S2 ) ; int y = countSubstrings ( S , S2 , S1 ) ; if ( x == y ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } static void Main ( ) { string S = " opencloseopencloseopen " ; string S1 = " open " ; string S2 = " close " ; checkSubstrings ( S , S1 , S2 ) ; } }

Accumulator variables: count, i, totalcount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int ASCII_SIZE = 256 ; static char getMaxOccuringChar ( String str ) { int [ ] count = new int [ ASCII_SIZE ] ; int len = str . Length ; for ( int i = 0 ; i < len ; i ++ ) count [ str [ i ] ] ++ ; int max = - 1 ; char result = ' ▁ ' ; for ( int i = 0 ; i < len ; i ++ ) { if ( max < count [ str [ i ] ] ) { max = count [ str [ i ] ] ; result = str [ i ] ; } } return result ; } public static void Main ( ) { String str = " sample ▁ string " ; Console . Write ( " Max ▁ occurring ▁ character ▁ is ▁ " + getMaxOccuringChar ( str ) ) ; } }

Index/key variables: ASCII_SIZE, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int MAX_CHAR = 26 ; static String getKey ( String str ) { bool [ ] visited = new bool [ MAX_CHAR ] ; for ( int j = 0 ; j < str . Length ; j ++ ) visited [ str [ j ] - ' a ' ] = true ; String key = " " ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) if ( visited [ j ] ) key = key + ( char ) ( ' a ' + j ) ; return key ; } static void wordsWithSameCharSet ( String [ ] words , int n ) { Dictionary < String , List < int > > Hash = new Dictionary < String , List < int > > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String key = getKey ( words [ i ] ) ; if ( Hash . ContainsKey ( key ) ) { List < int > get_al = Hash [ key ] ; get_al . Add ( i ) ; Hash [ key ] = get_al ; } else { List < int > new_al = new List < int > ( ) ; new_al . Add ( i ) ; Hash . Add ( key , new_al ) ; } } foreach ( KeyValuePair < String , List < int > > it in Hash ) { List < int > get = it . Value ; foreach ( int v in get ) Console . Write ( words [ v ] + " , ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { String [ ] words = { " may " , " student " , " students " , " dog " , " studentssess " , " god " , " cat " , " act " , " tab " , " bat " , " flow " , " wolf " , " lambs " , " amy " , " yam " , " balms " , " looped " , " poodle " } ; int n = words . Length ; wordsWithSameCharSet ( words , n ) ; } }

Index/key variables: MAX_CHAR, i, j, key, v
Accumulator variables: i, j
Iterator variables: i, it, j, v
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String secMostRepeated ( List < String > seq ) { Dictionary < String , int > occ = new Dictionary < String , int > ( ) ; for ( int i = 0 ; i < seq . Count ; i ++ ) if ( occ . ContainsKey ( seq [ i ] ) ) occ [ seq [ i ] ] = occ [ seq [ i ] ] + 1 ; else occ . Add ( seq [ i ] , 1 ) ; int first_max = int . MinValue , sec_max = int . MinValue ; foreach ( KeyValuePair < String , int > entry in occ ) { int v = entry . Value ; if ( v > first_max ) { sec_max = first_max ; first_max = v ; } else if ( v > sec_max && v != first_max ) sec_max = v ; } foreach ( KeyValuePair < String , int > entry in occ ) { int v = entry . Value ; if ( v == sec_max ) return entry . Key ; } return null ; } public static void Main ( String [ ] args ) { String [ ] arr = { " ccc " , " aaa " , " ccc " , " ddd " , " aaa " , " aaa " } ; List < String > seq = new List < String > ( arr ) ; Console . WriteLine ( secMostRepeated ( seq ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class CheckDuplicateValues { public static Boolean checkDupUtil ( Node root , HashSet < int > s ) { if ( root == null ) return false ; if ( s . Contains ( root . data ) ) return true ; s . Add ( root . data ) ; return checkDupUtil ( root . left , s ) || checkDupUtil ( root . right , s ) ; } public static Boolean checkDup ( Node root ) { HashSet < int > s = new HashSet < int > ( ) ; return checkDupUtil ( root , s ) ; } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 2 ) ; root . left . left = new Node ( 3 ) ; if ( checkDup ( root ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } } public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; } } ;

Class/struct names: CheckDuplicateValues, Node
C# program:
using System ; using System . Collections ; public class Node { public char value ; public Node left , right ; public Node ( char item ) { value = item ; left = right = null ; } } class ExpressionTree { Boolean isOperator ( char c ) { if ( c == ' + ' c == ' - ' c == ' * ' c == ' / ' c == ' ^ ' ) { return true ; } return false ; } void inorder ( Node t ) { if ( t != null ) { inorder ( t . left ) ; Console . Write ( t . value + " ▁ " ) ; inorder ( t . right ) ; } } Node constructTree ( char [ ] postfix ) { Stack st = new Stack ( ) ; Node t , t1 , t2 ; for ( int i = 0 ; i < postfix . Length ; i ++ ) { if ( ! isOperator ( postfix [ i ] ) ) { t = new Node ( postfix [ i ] ) ; st . Push ( t ) ; } else { t = new Node ( postfix [ i ] ) ; t1 = ( Node ) st . Pop ( ) ; t2 = ( Node ) st . Pop ( ) ; t . right = t1 ; t . left = t2 ; st . Push ( t ) ; } } t = ( Node ) st . Peek ( ) ; st . Pop ( ) ; return t ; } public static void Main ( String [ ] args ) { ExpressionTree et = new ExpressionTree ( ) ; String postfix = " ab + ef * g * - " ; char [ ] charArray = postfix . ToCharArray ( ) ; Node root = et . constructTree ( charArray ) ; Console . WriteLine ( " infix ▁ expression ▁ is " ) ; et . inorder ( root ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: ExpressionTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void totalCount ( int [ , ] A , int N , int M , int [ , ] queries , int Q ) { int [ ] row_sum = new int [ N ] ; int [ ] col_sum = new int [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { row_sum [ i ] += A [ i , j ] ; col_sum [ j ] += A [ i , j ] ; } } List < int > sum_list = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) sum_list . Add ( row_sum [ i ] ) ; for ( int i = 0 ; i < M ; i ++ ) sum_list . Add ( col_sum [ i ] ) ; sum_list . Sort ( ) ; for ( int i = 0 ; i < Q ; i ++ ) { int L = queries [ i , 0 ] ; int R = queries [ i , 1 ] ; int l = left_search ( sum_list , L ) ; int r = right_search ( sum_list , R ) ; Console . Write ( r - l + 1 + " ▁ " ) ; } } static int left_search ( List < int > A , int num ) { int low = 0 , high = A . Count - 1 ; int ans = 0 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( A [ mid ] >= num ) { ans = mid ; high = mid - 1 ; } else { low = mid + 1 ; } } return ans ; } static int right_search ( List < int > A , int num ) { int low = 0 , high = A . Count - 1 ; int ans = high ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( A [ mid ] <= num ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } static void Main ( ) { int N = 3 , M = 2 ; int [ , ] A = new int [ , ] { { 13 , 3 } , { 9 , 4 } , { 6 , 10 } } ; int Q = 2 ; int [ , ] queries = new int [ , ] { { 10 , 20 } , { 25 , 35 } } ; totalCount ( A , N , M , queries , Q ) ; } }

Index/key variables: M, N, i, j, mid
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { public static int smallestKFreq ( int [ ] a , int n , int k ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( m . ContainsKey ( a [ i ] ) ) { var v = m [ a [ i ] ] ; m . Remove ( a [ i ] ) ; m . Add ( a [ i ] , v + 1 ) ; } else m . Add ( a [ i ] , 1 ) ; int res = int . MaxValue ; HashSet < int > s = new HashSet < int > ( m . Keys . ToArray ( ) ) ; foreach ( int temp in s ) if ( m [ temp ] == k ) res = Math . Min ( res , temp ) ; return ( res != int . MaxValue ) ? res : - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; Console . WriteLine ( smallestKFreq ( arr , arr . Length , k ) ) ; } }

Index/key variables: i, temp
Accumulator variables: i
Iterator variables: i, temp
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maximumProfit ( int [ ] arr ) { int ans = Int32 . MinValue ; int price = 0 ; Array . Sort ( arr ) ; int N = arr . Length ; for ( int i = 0 ; i < N ; i ++ ) { int count = ( N - i ) ; if ( ans < count * arr [ i ] ) { price = arr [ i ] ; ans = count * arr [ i ] ; } } return price ; } public static void Main ( String [ ] args ) { int [ ] arr = { 22 , 87 , 9 , 50 , 56 , 43 } ; Console . WriteLine ( maximumProfit ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void print ( int [ ] arr ) { foreach ( int element in arr ) { Console . Write ( element + " ▁ " ) ; } } static void makeLexicographically ( int [ ] arr , int length ) { int index = 0 ; int temp = 0 ; int check = 0 ; int condition = 0 ; int element = 0 ; for ( int i = 0 ; i < length ; ++ i ) { if ( element == arr [ i ] ) { check = i ; break ; } else if ( arr [ i ] != i + 1 && check == 0 ) { index = i ; check = 1 ; condition = - 1 ; element = i + 1 ; } } if ( condition == - 1 ) { temp = arr [ index ] ; arr [ index ] = arr [ check ] ; arr [ check ] = temp ; } print ( arr ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; makeLexicographically ( arr , N ) ; } }

Index/key variables: check, i, index
Iterator variables: element, i
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool isLower ( char c ) { return c >= ' a ' && c <= ' z ' ; } static bool isUpper ( char c ) { return c >= ' A ' && c <= ' Z ' ; } static bool detectUppercaseUseUtil ( string S ) { int N = S . Length ; int i ; if ( isLower ( S [ 0 ] ) ) { i = 1 ; while ( i < N && isLower ( S [ i ] ) ) ++ i ; return i == N ? true : false ; } else { i = 1 ; while ( i < N && isUpper ( S [ i ] ) ) ++ i ; if ( i == N ) return true ; else if ( i > 1 ) return false ; while ( i < N && isLower ( S [ i ] ) ) ++ i ; return i == N ? true : false ; } } static void detectUppercaseUse ( string S ) { bool check = detectUppercaseUseUtil ( S ) ; if ( check ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static public void Main ( ) { string S = " GeeKs " ; detectUppercaseUse ( S ) ; } }

Index/key variables: i
Class/struct names: GFG