dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void thirdLargest ( int [ ] arr , int arr_size ) { if ( arr_size < 3 ) { Console . Write ( " ▁ Invalid ▁ Input ▁ " ) ; return ; } int first = arr [ 0 ] ; for ( int i = 1 ; i < arr_size ; i ++ ) if ( arr [ i ] > first ) first = arr [ i ] ; int second = - int . MaxValue ; for ( int i = 0 ; i < arr_size ; i ++ ) if ( arr [ i ] > second && arr [ i ] < first ) second = arr [ i ] ; int third = - int . MaxValue ; for ( int i = 0 ; i < arr_size ; i ++ ) if ( arr [ i ] > third && arr [ i ] < second ) third = arr [ i ] ; Console . Write ( " The ▁ third ▁ Largest ▁ " + " element ▁ is ▁ " + third ) ; } public static void Main ( ) { int [ ] arr = { 12 , 13 , 1 , 10 , 34 , 16 } ; int n = arr . Length ; thirdLargest ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void thirdLargest ( int [ ] arr , int arr_size ) { if ( arr_size < 3 ) { Console . Write ( " ▁ Invalid ▁ Input ▁ " ) ; return ; } int first = arr [ 0 ] , second = int . MinValue , third = int . MinValue ; for ( int i = 1 ; i < arr_size ; i ++ ) { if ( arr [ i ] > first ) { third = second ; second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second ) { third = second ; second = arr [ i ] ; } else if ( arr [ i ] > third ) { third = arr [ i ] ; } } Console . Write ( " The ▁ third ▁ Largest ▁ element ▁ is ▁ " + third ) ; } public static void Main ( ) { int [ ] arr = { 12 , 13 , 1 , 10 , 34 , 16 } ; int n = arr . Length ; thirdLargest ( arr , n ) ; } }

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 bool checkPair ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } if ( sum % 2 != 0 ) { return false ; } sum = sum / 2 ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int val = sum - arr [ i ] ; if ( s . Contains ( val ) ) { Console . Write ( " Pair ▁ elements ▁ are ▁ { 0 } ▁ and ▁ { 1 } STRNEWLINE " , arr [ i ] , val ) ; return true ; } s . Add ( arr [ i ] ) ; } return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 11 , 5 , 1 , 4 , 7 } ; int n = arr . Length ; if ( checkPair ( arr , n ) == false ) { Console . Write ( " No ▁ pair ▁ found " ) ; } } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String search ( int [ ] arr , int n , int x ) { if ( arr [ n - 1 ] == x ) return " Found " ; int backup = arr [ n - 1 ] ; arr [ n - 1 ] = x ; for ( int i = 0 ; ; i ++ ) { if ( arr [ i ] == x ) { arr [ n - 1 ] = backup ; if ( i < n - 1 ) return " Found " ; return " Not ▁ Found " ; } } } public static void Main ( ) { int [ ] arr = { 4 , 6 , 1 , 5 , 8 } ; int n = arr . Length ; int x = 1 ; Console . WriteLine ( search ( arr , n , x ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Point { public int first , second ; public Point ( int first , int second ) { this . first = first ; this . second = second ; } } public class Test { static Point sequence ( List < int > a ) { if ( a . Count == 0 ) return new Point ( 0 , 0 ) ; int s = 0 ; int e = a . Count - 1 ; while ( s < e ) { int m = ( s + e ) / 2 ; if ( a [ m ] >= m + a [ 0 ] ) s = m + 1 ; else e = m ; } return new Point ( a [ s ] , a . Count - ( a [ a . Count - 1 ] - a [ 0 ] ) ) ; } public static void Main ( String [ ] args ) { int [ ] array = new int [ ] { 1 , 2 , 3 , 4 , 4 , 4 , 5 , 6 } ; Point p = sequence ( new List < int > ( array ) ) ; Console . WriteLine ( " Repeated ▁ element ▁ is ▁ " + p . first + " , ▁ it ▁ appears ▁ " + p . second + " ▁ times " ) ; } }

Index/key variables: m, s
Class/struct names: Point, Test
C# program:
using System ; public class GFG { public static int findMajority ( int [ ] arr , int n ) { return arr [ n / 2 ] ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 2 , 3 } ; int n = arr . Length ; Console . WriteLine ( findMajority ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void minAdjDifference ( int [ ] arr , int n ) { if ( n < 2 ) return ; int res = Math . Abs ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < n ; i ++ ) res = Math . Min ( res , Math . Abs ( arr [ i ] - arr [ i - 1 ] ) ) ; res = Math . Min ( res , Math . Abs ( arr [ n - 1 ] - arr [ 0 ] ) ) ; Console . Write ( " Min ▁ Difference ▁ = ▁ " + res ) ; } public static void Main ( ) { int [ ] a = { 10 , 12 , 13 , 15 , 10 } ; int n = a . Length ; minAdjDifference ( a , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void Print3Smallest ( int [ ] array , int n ) { int firstmin = int . MaxValue ; int secmin = int . MaxValue ; int thirdmin = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( array [ i ] < firstmin ) { thirdmin = secmin ; secmin = firstmin ; firstmin = array [ i ] ; } else if ( array [ i ] < secmin ) { thirdmin = secmin ; secmin = array [ i ] ; } else if ( array [ i ] < thirdmin ) thirdmin = array [ i ] ; } Console . WriteLine ( " First ▁ min ▁ = ▁ " + firstmin ) ; Console . WriteLine ( " Second ▁ min ▁ = ▁ " + secmin ) ; Console . WriteLine ( " Third ▁ min ▁ = ▁ " + thirdmin ) ; } static void Main ( ) { int [ ] array = new int [ ] { 4 , 9 , 1 , 32 , 12 } ; int n = array . Length ; Print3Smallest ( array , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMin ( int [ ] arr , int i , int n ) { return ( n == 1 ) ? arr [ i ] : Math . Min ( arr [ i ] , getMin ( arr , i + 1 , n - 1 ) ) ; } static int getMax ( int [ ] arr , int i , int n ) { return ( n == 1 ) ? arr [ i ] : Math . Max ( arr [ i ] , getMax ( arr , i + 1 , n - 1 ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 1234 , 45 , 67 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ element ▁ of ▁ array : ▁ " + getMin ( arr , 0 , n ) ) ; Console . WriteLine ( " Maximum ▁ element ▁ of ▁ array : ▁ " + getMax ( arr , 0 , n ) ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int getMin ( int [ ] arr , int n ) { return arr . Min ( ) ; } static int getMax ( int [ ] arr , int n ) { return arr . Max ( ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 1234 , 45 , 67 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ element ▁ of ▁ array : ▁ " + getMin ( arr , n ) ) ; Console . WriteLine ( " Maximum ▁ element ▁ of ▁ array : ▁ " + getMax ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void findCounts ( int [ ] arr , int n ) { int [ ] hash = new int [ n ] ; int i = 0 ; while ( i < n ) { hash [ arr [ i ] - 1 ] ++ ; i ++ ; } Console . WriteLine ( " STRNEWLINE Below ▁ are ▁ counts ▁ " + " of ▁ all ▁ elements " ) ; for ( i = 0 ; i < n ; i ++ ) { Console . WriteLine ( ( i + 1 ) + " ▁ - > ▁ " + hash [ i ] ) ; } } static public void Main ( ) { int [ ] arr = new int [ ] { 2 , 3 , 3 , 2 , 5 } ; findCounts ( arr , arr . Length ) ; int [ ] arr1 = new int [ ] { 1 } ; findCounts ( arr1 , arr1 . Length ) ; int [ ] arr3 = new int [ ] { 4 , 4 , 4 , 4 } ; findCounts ( arr3 , arr3 . Length ) ; int [ ] arr2 = new int [ ] { 1 , 3 , 5 , 7 , 9 , 1 , 3 , 5 , 7 , 9 , 1 } ; findCounts ( arr2 , arr2 . Length ) ; int [ ] arr4 = new int [ ] { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ; findCounts ( arr4 , arr4 . Length ) ; int [ ] arr5 = new int [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 } ; findCounts ( arr5 , arr5 . Length ) ; int [ ] arr6 = new int [ ] { 11 , 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 } ; findCounts ( arr6 , arr6 . Length ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { void findCounts ( int [ ] arr , int n ) { int i = 0 ; while ( i < n ) { if ( arr [ i ] <= 0 ) { i ++ ; continue ; } int elementIndex = arr [ i ] - 1 ; if ( arr [ elementIndex ] > 0 ) { arr [ i ] = arr [ elementIndex ] ; arr [ elementIndex ] = - 1 ; } else { arr [ elementIndex ] -- ; arr [ i ] = 0 ; i ++ ; } } Console . Write ( " STRNEWLINE Below ▁ are ▁ counts ▁ of ▁ " + " all ▁ elements " + " STRNEWLINE " ) ; for ( int j = 0 ; j < n ; j ++ ) Console . Write ( j + 1 + " - > " + Math . Abs ( arr [ j ] ) + " STRNEWLINE " ) ; } public static void Main ( ) { GFG count = new GFG ( ) ; int [ ] arr = { 2 , 3 , 3 , 2 , 5 } ; count . findCounts ( arr , arr . Length ) ; int [ ] arr1 = { 1 } ; count . findCounts ( arr1 , arr1 . Length ) ; int [ ] arr3 = { 4 , 4 , 4 , 4 } ; count . findCounts ( arr3 , arr3 . Length ) ; int [ ] arr2 = { 1 , 3 , 5 , 7 , 9 , 1 , 3 , 5 , 7 , 9 , 1 } ; count . findCounts ( arr2 , arr2 . Length ) ; int [ ] arr4 = { 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 } ; count . findCounts ( arr4 , arr4 . Length ) ; int [ ] arr5 = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 } ; count . findCounts ( arr5 , arr5 . Length ) ; int [ ] arr6 = { 11 , 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 } ; count . findCounts ( arr6 , arr6 . Length ) ; } }

Index/key variables: elementIndex, i, j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; internal class CountFrequency { internal virtual void printfrequency ( int [ ] arr , int n ) { for ( int j = 0 ; j < n ; j ++ ) { arr [ j ] = arr [ j ] - 1 ; } for ( int i = 0 ; i < n ; i ++ ) { arr [ arr [ i ] % n ] = arr [ arr [ i ] % n ] + n ; } for ( int i = 0 ; i < n ; i ++ ) { Console . WriteLine ( i + 1 + " - > " + arr [ i ] / n ) ; } } public static void Main ( string [ ] args ) { CountFrequency count = new CountFrequency ( ) ; int [ ] arr = new int [ ] { 2 , 3 , 3 , 2 , 5 } ; int n = arr . Length ; count . printfrequency ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: CountFrequency
C# program:
using System ; class GFG { static int deleteElement ( int [ ] arr , int n , int x ) { int i ; for ( i = 0 ; i < n ; i ++ ) if ( arr [ i ] == x ) break ; if ( i < n ) { n = n - 1 ; for ( int j = i ; j < n ; j ++ ) arr [ j ] = arr [ j + 1 ] ; } return n ; } public static void Main ( ) { int [ ] arr = { 11 , 15 , 6 , 8 , 9 , 10 } ; int n = arr . Length ; int x = 6 ; n = deleteElement ( arr , n , x ) ; Console . WriteLine ( " Modified ▁ array ▁ is " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

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 deleteElement ( int [ ] arr , int n , int x ) { if ( arr [ n - 1 ] == x ) return ( n - 1 ) ; int prev = arr [ n - 1 ] , i ; for ( i = n - 2 ; i >= 0 && arr [ i ] != x ; i -- ) { int curr = arr [ i ] ; arr [ i ] = prev ; prev = curr ; } if ( i < 0 ) return 0 ; arr [ i ] = prev ; return ( n - 1 ) ; } public static void Main ( ) { int [ ] arr = { 11 , 15 , 6 , 8 , 9 , 10 } ; int n = arr . Length ; int x = 6 ; n = deleteElement ( arr , n , x ) ; Console . WriteLine ( " Modified ▁ array ▁ is " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Inversion { static int getInvCount ( int [ ] arr , int n ) { int invcount = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int small = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] > arr [ j ] ) small ++ ; int great = 0 ; for ( int j = i - 1 ; j >= 0 ; j -- ) if ( arr [ i ] < arr [ j ] ) great ++ ; invcount += great * small ; } return invcount ; } public static void Main ( ) { int [ ] arr = new int [ ] { 8 , 4 , 2 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Inversion ▁ count ▁ : ▁ " + getInvCount ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: great, i, invcount, j, small
Iterator variables: i, j
Class/struct names: Inversion
C# program:
using System ; class GFG { public static int maxWater ( int [ ] arr , int n ) { int res = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { int left = arr [ i ] ; for ( int j = 0 ; j < i ; j ++ ) { left = Math . Max ( left , arr [ j ] ) ; } int right = arr [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { right = Math . Max ( right , arr [ j ] ) ; } res += Math . Min ( left , right ) - arr [ i ] ; } return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 } ; int n = arr . Length ; Console . Write ( maxWater ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Test { static int [ ] arr = new int [ ] { 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 } ; static int findWater ( int n ) { int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; int water = 0 ; left [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) left [ i ] = Math . Max ( left [ i - 1 ] , arr [ i ] ) ; right [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) right [ i ] = Math . Max ( right [ i + 1 ] , arr [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) water += Math . Min ( left [ i ] , right [ i ] ) - arr [ i ] ; return water ; } public static void Main ( ) { Console . WriteLine ( " Maximum ▁ water ▁ that ▁ can ▁ be ▁ accumulated ▁ is ▁ " + findWater ( arr . Length ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, water
Iterator variables: i
Class/struct names: Test
C# program:
using System ; class GFG { static int findWater ( int [ ] arr , int n ) { int result = 0 ; int left_max = 0 , right_max = 0 ; int lo = 0 , hi = n - 1 ; while ( lo <= hi ) { if ( arr [ lo ] < arr [ hi ] ) { if ( arr [ lo ] > left_max ) left_max = arr [ lo ] ; else result += left_max - arr [ lo ] ; lo ++ ; } else { if ( arr [ hi ] > right_max ) right_max = arr [ hi ] ; else result += right_max - arr [ hi ] ; hi -- ; } } return result ; } public static void Main ( ) { int [ ] arr = { 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 } ; int result = Trap . findWater ( arr , arr . length ) ; System . out . print ( " ▁ Total ▁ trapping ▁ water : ▁ " + result ) ; } }

Index/key variables: hi, lo
Accumulator variables: hi, lo, result
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxWater ( int [ ] arr , int n ) { int size = n - 1 ; int prev = arr [ 0 ] ; int prev_index = 0 ; int water = 0 ; int temp = 0 ; for ( int i = 1 ; i <= size ; i ++ ) { if ( arr [ i ] >= prev ) { prev = arr [ i ] ; prev_index = i ; temp = 0 ; } else { water += prev - arr [ i ] ; temp += prev - arr [ i ] ; } } if ( prev_index < size ) { water -= temp ; prev = arr [ size ] ; for ( int i = size ; i >= prev_index ; i -- ) { if ( arr [ i ] >= prev ) { prev = arr [ i ] ; } else { water += prev - arr [ i ] ; } } } return water ; } static void Main ( ) { int [ ] arr = { 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 } ; int n = arr . Length ; Console . WriteLine ( maxWater ( arr , n ) ) ; } }

Index/key variables: i, size
Accumulator variables: i, temp, water
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public static int maxWater ( int [ ] height ) { Stack stack = new Stack ( ) ; int n = height . Length ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( ( stack . Count != 0 ) && ( height [ ( int ) stack . Peek ( ) ] < height [ i ] ) ) { int pop_height = height [ ( int ) stack . Peek ( ) ] ; stack . Pop ( ) ; if ( stack . Count == 0 ) break ; int distance = i - ( int ) stack . Peek ( ) - 1 ; int min_height = Math . Min ( height [ ( int ) stack . Peek ( ) ] , height [ i ] ) - pop_height ; ans += distance * min_height ; } stack . Push ( i ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 } ; Console . Write ( maxWater ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxWater ( int [ ] arr , int n ) { int left = 0 ; int right = n - 1 ; int l_max = 0 ; int r_max = 0 ; int result = 0 ; while ( left <= right ) { if ( r_max <= l_max ) { result += Math . Max ( 0 , r_max - arr [ right ] ) ; r_max = Math . Max ( r_max , arr [ right ] ) ; right -= 1 ; } else { result += Math . Max ( 0 , l_max - arr [ left ] ) ; l_max = Math . Max ( l_max , arr [ left ] ) ; left += 1 ; } } return result ; } static void Main ( ) { int [ ] arr = { 0 , 1 , 0 , 2 , 1 , 0 , 1 , 3 , 2 , 1 , 2 , 1 } ; int n = arr . Length ; Console . WriteLine ( maxWater ( arr , n ) ) ; } }

Index/key variables: left, right
Accumulator variables: left, result, right
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximum ( int a , int b ) { return a > b ? a : b ; } static int minimum ( int a , int b ) { return a < b ? a : b ; } static double findMedianSortedArrays ( ref int [ ] a , int n , ref int [ ] b , int m ) { int min_index = 0 , max_index = n , i = 0 , j = 0 , median = 0 ; while ( min_index <= max_index ) { i = ( min_index + max_index ) / 2 ; j = ( ( n + m + 1 ) / 2 ) - i ; if ( i < n && j > 0 && b [ j - 1 ] > a [ i ] ) min_index = i + 1 ; else if ( i > 0 && j < m && b [ j ] < a [ i - 1 ] ) max_index = i - 1 ; else { if ( i == 0 ) median = b [ j - 1 ] ; else if ( j == 0 ) median = a [ i - 1 ] ; else median = maximum ( a [ i - 1 ] , b [ j - 1 ] ) ; break ; } } if ( ( n + m ) % 2 == 1 ) return ( double ) median ; if ( i == n ) return ( median + b [ j ] ) / 2.0 ; if ( j == m ) return ( median + a [ i ] ) / 2.0 ; return ( median + minimum ( a [ i ] , b [ j ] ) ) / 2.0 ; } static void Main ( ) { int [ ] a = new int [ ] { 900 } ; int [ ] b = new int [ ] { 10 , 13 , 14 } ; int n = a . Length ; int m = b . Length ; if ( n < m ) Console . Write ( " The ▁ median ▁ is ▁ : ▁ " + findMedianSortedArrays ( ref a , n , ref b , m ) ) ; else Console . Write ( " The ▁ median ▁ is ▁ : ▁ " + findMedianSortedArrays ( ref b , m , ref a , n ) ) ; } }

Index/key variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMedianSortedArrays ( ref int [ ] a , int n , ref int [ ] b , int m ) { int min_index = 0 , max_index = n , i , j ; while ( min_index <= max_index ) { i = ( min_index + max_index ) / 2 ; j = ( ( n + m + 1 ) / 2 ) - i ; if ( i < n && j > 0 && b [ j - 1 ] > a [ i ] ) min_index = i + 1 ; else if ( i > 0 && j < m && b [ j ] < a [ i - 1 ] ) max_index = i - 1 ; else { if ( i == 0 ) return b [ j - 1 ] ; if ( j == 0 ) return a [ i - 1 ] ; else return maximum ( a [ i - 1 ] , b [ j - 1 ] ) ; } } Console . Write ( " ERROR ! ! ! ▁ " + " returning STRNEWLINE " ) ; return 0 ; } static int maximum ( int a , int b ) { return a > b ? a : b ; } static void Main ( ) { int [ ] a = new int [ ] { 900 } ; int [ ] b = new int [ ] { 10 , 13 , 14 } ; int n = a . Length ; int m = b . Length ; if ( n < m ) Console . Write ( " The ▁ median ▁ is : ▁ " + findMedianSortedArrays ( ref a , n , ref b , m ) ) ; else Console . Write ( " The ▁ median ▁ is : ▁ " + findMedianSortedArrays ( ref b , m , ref a , n ) ) ; } }

Index/key variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printUncommon ( int [ ] arr1 , int [ ] arr2 , int n1 , int n2 ) { int i = 0 , j = 0 , k = 0 ; while ( i < n1 && j < n2 ) { if ( arr1 [ i ] < arr2 [ j ] ) { Console . Write ( arr1 [ i ] + " ▁ " ) ; i ++ ; k ++ ; } else if ( arr2 [ j ] < arr1 [ i ] ) { Console . Write ( arr2 [ j ] + " ▁ " ) ; k ++ ; j ++ ; } else { i ++ ; j ++ ; } } while ( i < n1 ) { Console . Write ( arr1 [ i ] + " ▁ " ) ; i ++ ; k ++ ; } while ( j < n2 ) { Console . Write ( arr2 [ j ] + " ▁ " ) ; j ++ ; k ++ ; } } public static void Main ( ) { int [ ] arr1 = { 10 , 20 , 30 } ; int [ ] arr2 = { 20 , 25 , 30 , 40 , 50 } ; int n1 = arr1 . Length ; int n2 = arr2 . Length ; printUncommon ( arr1 , arr2 , n1 , n2 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int leastFrequent ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int min_count = n + 1 , res = - 1 ; int curr_count = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) curr_count ++ ; else { if ( curr_count < min_count ) { min_count = curr_count ; res = arr [ i - 1 ] ; } curr_count = 1 ; } } if ( curr_count < min_count ) { min_count = curr_count ; res = arr [ n - 1 ] ; } return res ; } static public void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 1 , 2 , 2 , 3 , 1 } ; int n = arr . Length ; Console . Write ( leastFrequent ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: curr_count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int leastFrequent ( int [ ] arr , int n ) { Dictionary < int , int > count = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int key = arr [ i ] ; if ( count . ContainsKey ( key ) ) { int freq = count [ key ] ; freq ++ ; count [ key ] = freq ; } else count . Add ( key , 1 ) ; } int min_count = n + 1 , res = - 1 ; foreach ( KeyValuePair < int , int > pair in count ) { if ( min_count >= pair . Value ) { res = pair . Key ; min_count = pair . Value ; } } return res ; } static void Main ( ) { int [ ] arr = new int [ ] { 1 , 3 , 2 , 1 , 2 , 2 , 3 , 1 } ; int n = arr . Length ; Console . Write ( leastFrequent ( arr , n ) ) ; } }

Index/key variables: i, key
Accumulator variables: freq, i
Iterator variables: i, pair
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 4 ; static void sort ( ref int [ , ] a , int row , int n ) { for ( int i = 0 ; i < M - 1 ; i ++ ) { if ( a [ row , i ] > a [ row , i + 1 ] ) { int temp = a [ row , i ] ; a [ row , i ] = a [ row , i + 1 ] ; a [ row , i + 1 ] = temp ; } } } static int maximumSum ( int [ , ] a , int n ) { int i = 0 , j = 0 ; for ( i = 0 ; i < n ; i ++ ) sort ( ref a , i , n ) ; int sum = a [ n - 1 , M - 1 ] ; int prev = a [ n - 1 , M - 1 ] ; for ( i = n - 2 ; i >= 0 ; i -- ) { for ( j = M - 1 ; j >= 0 ; j -- ) { if ( a [ i , j ] < prev ) { prev = a [ i , j ] ; sum += prev ; break ; } } if ( j == - 1 ) return 0 ; } return sum ; } static void Main ( ) { int [ , ] arr = new int [ , ] { { 1 , 7 , 3 , 4 } , { 4 , 2 , 5 , 1 } , { 9 , 5 , 1 , 8 } } ; int n = arr . GetLength ( 0 ) ; Console . Write ( maximumSum ( arr , n ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 4 ; static int maximumSum ( int [ , ] a , int n ) { int prev = Math . Max ( a [ n - 1 , 0 ] , a [ n - 1 , M - 1 ] + 1 ) ; int sum = prev ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int max_smaller = Int32 . MinValue ; for ( int j = M - 1 ; j >= 0 ; j -- ) { if ( a [ i , j ] < prev && a [ i , j ] > max_smaller ) { max_smaller = a [ i , j ] ; } } if ( max_smaller == Int32 . MinValue ) { return 0 ; } prev = max_smaller ; sum += max_smaller ; } return sum ; } static public void Main ( ) { int [ , ] arr = { { 1 , 7 , 3 , 4 } , { 4 , 2 , 5 , 1 } , { 9 , 5 , 1 , 8 } } ; int n = arr . GetLength ( 0 ) ; Console . Write ( maximumSum ( arr , n ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] A , int n , int k ) { int ans = 0 ; Array . Sort ( A ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int x = 0 ; while ( ( A [ i ] * Math . Pow ( k , x ) ) <= A [ j ] ) { if ( ( A [ i ] * Math . Pow ( k , x ) ) == A [ j ] ) { ans ++ ; break ; } x ++ ; } } } return ans ; } public static void Main ( ) { int [ ] A = { 3 , 8 , 9 , 12 , 18 , 4 , 24 , 2 , 6 } ; int n = A . Length ; int k = 3 ; Console . WriteLine ( countPairs ( A , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, x
Iterator variables: i, j
Class/struct names: GFG