dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isPossible ( string A , string B , int b , int m ) { List < List < int > > S = new List < List < int > > ( ) ; for ( int i = 0 ; i < 26 ; i ++ ) { S . Add ( new List < int > ( ) ) ; } int [ ] box = new int [ A . Length ] ; for ( int i = 0 ; i < A . Length ; i ++ ) { S [ A [ i ] - ' a ' ] . Add ( i ) ; } int low = 0 ; for ( int i = 0 ; i < B . Length ; i ++ ) { List < int > indexes = S [ B [ i ] - ' a ' ] ; int it = lower_bound ( indexes , low ) ; if ( it == indexes . Count ) return false ; int count = indexes [ it ] / b ; box [ count ] = box [ count ] + 1 ; if ( box [ count ] >= m ) { count ++ ; low = ( count ) * b ; } else low = indexes [ it ] + 1 ; } return true ; } static int lower_bound ( List < int > indexes , int k ) { int low = 0 , high = indexes . Count - 1 ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( indexes [ mid ] < k ) low = mid + 1 ; else high = mid ; } return ( indexes [ low ] < k ) ? low + 1 : low ; } static void Main ( ) { string A = " abcbbcdefxyz " ; string B = " acdxyz " ; int b = 5 ; int m = 2 ; if ( isPossible ( A , B , b , m ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: count, i, it, low, mid
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxSumArray ( int [ ] arr , int n ) { int sum = 0 ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( m . ContainsKey ( arr [ i ] ) ) { var val = m [ arr [ i ] ] ; m . Remove ( arr [ i ] ) ; m . Add ( arr [ i ] , val + 1 ) ; } else { m . Add ( arr [ i ] , 1 ) ; } } int minimum = int . MaxValue ; foreach ( KeyValuePair < int , int > x in m ) minimum = Math . Min ( minimum , ( x . Value * x . Key ) ) ; return ( sum - minimum ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 3 , 3 , 2 , 2 , 1 , 1 , 1 } ; int n = arr . Length ; Console . WriteLine ( maxSumArray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1001 ; static int [ , ] prefix = new int [ MAX , MAX ] ; static int [ ] ar = new int [ MAX ] ; static void cal_prefix ( int n , int [ ] arr ) { int i , j ; for ( i = 0 ; i < n ; i ++ ) ar [ i + 1 ] = arr [ i ] ; for ( i = 1 ; i <= 1000 ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) prefix [ i , j ] = 0 ; for ( j = 1 ; j <= n ; j ++ ) { prefix [ i , j ] = prefix [ i , j - 1 ] + ( int ) ( ar [ j ] <= i ? 1 : 0 ) ; } } } static int ksub ( int l , int r , int n , int k ) { int lo , hi , mid ; lo = 1 ; hi = 1000 ; while ( lo + 1 < hi ) { mid = ( lo + hi ) / 2 ; if ( prefix [ mid , r ] - prefix [ mid , l - 1 ] >= k ) hi = mid ; else lo = mid + 1 ; } if ( prefix [ lo , r ] - prefix [ lo , l - 1 ] >= k ) hi = lo ; return hi ; } static void Main ( ) { int [ ] arr = { 1 , 4 , 2 , 3 , 5 , 7 , 6 } ; int n = arr . Length ; cal_prefix ( n , arr ) ; int [ , ] queries = { { 1 , n , 1 } , { 2 , n - 2 , 2 } , { 3 , n - 1 , 3 } } ; int q = queries . Length / queries . Rank - 1 ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( ksub ( queries [ i , 0 ] , queries [ i , 1 ] , n , queries [ i , 2 ] ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { class DisjointUnionSets { int [ ] rank , parent ; int n ; public DisjointUnionSets ( int n ) { rank = new int [ n ] ; parent = new int [ n ] ; this . n = n ; makeSet ( ) ; } public void makeSet ( ) { for ( int i = 0 ; i < n ; i ++ ) parent [ i ] = i ; } public int find ( int x ) { if ( parent [ x ] != x ) { return find ( parent [ x ] ) ; } return x ; } public void union ( int x , int y ) { int xRoot = find ( x ) ; int yRoot = find ( y ) ; if ( xRoot == yRoot ) return ; if ( rank [ xRoot ] < rank [ yRoot ] ) parent [ xRoot ] = yRoot ; else if ( rank [ yRoot ] < rank [ xRoot ] ) parent [ yRoot ] = xRoot ; else { parent [ yRoot ] = xRoot ; rank [ xRoot ] = rank [ xRoot ] + 1 ; } } } static int countIslands ( int [ , ] a ) { int n = a . GetLength ( 0 ) ; int m = a . GetLength ( 1 ) ; DisjointUnionSets dus = new DisjointUnionSets ( n * m ) ; for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < m ; k ++ ) { if ( a [ j , k ] == 0 ) continue ; if ( j + 1 < n && a [ j + 1 , k ] == 1 ) dus . union ( j * ( m ) + k , ( j + 1 ) * ( m ) + k ) ; if ( j - 1 >= 0 && a [ j - 1 , k ] == 1 ) dus . union ( j * ( m ) + k , ( j - 1 ) * ( m ) + k ) ; if ( k + 1 < m && a [ j , k + 1 ] == 1 ) dus . union ( j * ( m ) + k , ( j ) * ( m ) + k + 1 ) ; if ( k - 1 >= 0 && a [ j , k - 1 ] == 1 ) dus . union ( j * ( m ) + k , ( j ) * ( m ) + k - 1 ) ; if ( j + 1 < n && k + 1 < m && a [ j + 1 , k + 1 ] == 1 ) dus . union ( j * ( m ) + k , ( j + 1 ) * ( m ) + k + 1 ) ; if ( j + 1 < n && k - 1 >= 0 && a [ j + 1 , k - 1 ] == 1 ) dus . union ( j * m + k , ( j + 1 ) * ( m ) + k - 1 ) ; if ( j - 1 >= 0 && k + 1 < m && a [ j - 1 , k + 1 ] == 1 ) dus . union ( j * m + k , ( j - 1 ) * m + k + 1 ) ; if ( j - 1 >= 0 && k - 1 >= 0 && a [ j - 1 , k - 1 ] == 1 ) dus . union ( j * m + k , ( j - 1 ) * m + k - 1 ) ; } } int [ ] c = new int [ n * m ] ; int numberOfIslands = 0 ; for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < m ; k ++ ) { if ( a [ j , k ] == 1 ) { int x = dus . find ( j * m + k ) ; if ( c [ x ] == 0 ) { numberOfIslands ++ ; c [ x ] ++ ; } else c [ x ] ++ ; } } } return numberOfIslands ; } } public static void ( [ ] args ) { int [ , ] = new int [ , ] {{ 1 , 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 0 , 1 , 1 } , { 0 , 0 , 0 , 0 , 0 } , { 1 , 0 , 1 , 0 , 1 } } ; Console . WriteLine ( " Number ▁ of ▁ Islands ▁ is : ▁ " + countIslands ( a ) ) ; }

Index/key variables: i, n, x, xRoot, yRoot
Accumulator variables: i, j, k, numberOfIslands
Iterator variables: i, j, k
Class/struct names: DisjointUnionSets, GFG
C# program:
using System ; class GFG { static long squareSum ( long N ) { long sum = ( long ) ( N * ( N + 1 ) * ( 2 * N + 1 ) ) / 6 ; return sum ; } static long findMaxN ( long X ) { long N = ( long ) Math . Sqrt ( X ) ; for ( long i = 1 ; i <= N ; i ++ ) { if ( squareSum ( i ) > X ) return i - 1 ; } return - 1 ; } public static void Main ( string [ ] args ) { long X = 25 ; Console . WriteLine ( findMaxN ( X ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int max_min ( int [ ] a , int n ) { if ( n <= 1 ) return Int32 . MaxValue ; int f_min = a [ 0 ] , s_min = Int32 . MaxValue ; int f_max = a [ 0 ] , s_max = Int32 . MinValue ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] <= f_min ) { s_min = f_min ; f_min = a [ i ] ; } else if ( a [ i ] < s_min ) { s_min = a [ i ] ; } if ( a [ i ] >= f_max ) { s_max = f_max ; f_max = a [ i ] ; } else if ( a [ i ] > s_max ) { s_max = a [ i ] ; } } return Math . Min ( ( f_max - s_min ) , ( s_max - f_min ) ) ; } public static void Main ( ) { int [ ] a = { 1 , 3 , 3 , 7 } ; int n = a . Length ; Console . WriteLine ( max_min ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Solution { static int minimal ( int [ ] a , int n ) { int lo = 0 , hi = n - 1 ; while ( lo < hi ) { int mid = ( lo + hi ) >> 1 ; if ( a [ mid ] < a [ mid + 1 ] ) { hi = mid ; } else { lo = mid + 1 ; } } return lo ; } public static void Main ( ) { int [ ] a = { 8 , 5 , 4 , 3 , 4 , 10 } ; int n = a . Length ; int ind = minimal ( a , n ) ; Console . WriteLine ( a [ ind ] ) ; } }

Index/key variables: ind, mid
Class/struct names: Solution
C# program:
using System ; class GFG { static void findIndices ( int [ ] arr , int n ) { int leftMin = 0 , rightMin = 0 ; int leftMax = 0 , rightMax = 0 ; int min = arr [ 0 ] , max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < min ) { leftMin = rightMin = i ; min = arr [ i ] ; } else if ( arr [ i ] == min ) rightMin = i ; if ( arr [ i ] > max ) { leftMax = rightMax = i ; max = arr [ i ] ; } else if ( arr [ i ] == max ) rightMax = i ; } Console . WriteLine ( " Minimum ▁ left ▁ : ▁ " + leftMin ) ; Console . WriteLine ( " Minimum ▁ right ▁ : ▁ " + rightMin ) ; Console . WriteLine ( " Maximum ▁ left ▁ : ▁ " + leftMax ) ; Console . WriteLine ( " Maximum ▁ right ▁ : ▁ " + rightMax ) ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 1 , 2 , 1 , 5 , 6 , 5 } ; int n = arr . Length ; findIndices ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void diagonalsMinMax ( int [ , ] mat ) { int n = mat . GetLength ( 0 ) ; if ( n == 0 ) return ; int principalMin = mat [ 0 , 0 ] , principalMax = mat [ 0 , 0 ] ; int secondaryMin = mat [ n - 1 , 0 ] , secondaryMax = mat [ n - 1 , 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { if ( i == j ) { if ( mat [ i , j ] < principalMin ) { principalMin = mat [ i , j ] ; } if ( mat [ i , j ] > principalMax ) { principalMax = mat [ i , j ] ; } } if ( ( i + j ) == ( n - 1 ) ) { if ( mat [ i , j ] < secondaryMin ) { secondaryMin = mat [ i , j ] ; } if ( mat [ i , j ] > secondaryMax ) { secondaryMax = mat [ i , j ] ; } } } } Console . WriteLine ( " Principal ▁ Diagonal ▁ Smallest ▁ Element : ▁ " + principalMin ) ; Console . WriteLine ( " Principal ▁ Diagonal ▁ Greatest ▁ Element ▁ : ▁ " + principalMax ) ; Console . WriteLine ( " Secondary ▁ Diagonal ▁ Smallest ▁ Element : ▁ " + secondaryMin ) ; Console . WriteLine ( " Secondary ▁ Diagonal ▁ Greatest ▁ Element : ▁ " + secondaryMax ) ; } static void Main ( ) { int [ , ] matrix = { { 1 , 2 , 3 , 4 , - 10 } , { 5 , 6 , 7 , 8 , 6 } , { 1 , 2 , 11 , 3 , 4 } , { 5 , 6 , 70 , 5 , 8 } , { 4 , 9 , 7 , 1 , - 5 } } ; diagonalsMinMax ( matrix ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void indexedSequentialSearch ( int [ ] arr , int n , int k ) { int [ ] elements = new int [ 20 ] ; int [ ] indices = new int [ 20 ] ; int i ; int j = 0 , ind = 0 , start = 0 , end = 0 , set = 0 ; for ( i = 0 ; i < n ; i += 3 ) { elements [ ind ] = arr [ i ] ; indices [ ind ] = i ; ind ++ ; } if ( k < elements [ 0 ] ) { Console . Write ( " Not ▁ found " ) ; return ; } else { for ( i = 1 ; i <= ind ; i ++ ) if ( k <= elements [ i ] ) { start = indices [ i - 1 ] ; set = 1 ; end = indices [ i ] ; break ; } } if ( set == 0 ) { start = indices [ i - 1 ] ; end = n - 1 ; } for ( i = start ; i <= end ; i ++ ) { if ( k == arr [ i ] ) { j = 1 ; break ; } } if ( j == 1 ) Console . WriteLine ( " Found ▁ at ▁ index ▁ " + i ) ; else Console . WriteLine ( " Not ▁ found " ) ; } public static void Main ( ) { int [ ] arr = { 6 , 7 , 8 , 9 , 10 } ; int n = arr . Length ; int k = 8 ; indexedSequentialSearch ( arr , n , k ) ; } }

Index/key variables: i, ind
Accumulator variables: i, ind
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getCount ( int [ ] v , int n ) { Array . Sort ( v ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = n - 1 - upperBound ( v , n , v [ i ] - 1 ) ; if ( tmp == v [ i ] ) cnt ++ ; } return cnt ; } static int upperBound ( int [ ] array , int length , int value ) { int low = 0 ; int high = length ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( value >= array [ mid ] ) { low = mid + 1 ; } else { high = mid ; } } return low ; } public static void Main ( String [ ] args ) { int n = 4 ; int [ ] v = { 1 , 2 , 3 , 4 } ; Console . WriteLine ( getCount ( v , n ) ) ; } }

Index/key variables: i, mid
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countSegments ( int [ ] a , int n , int x ) { bool flag = false ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > x ) { flag = true ; } else { if ( flag ) count += 1 ; flag = false ; } } if ( flag ) count += 1 ; return count ; } static public void Main ( ) { int [ ] a = { 8 , 25 , 10 , 19 , 19 , 18 , 20 , 11 , 18 } ; int n = a . Length ; int x = 13 ; Console . WriteLine ( countSegments ( a , n , x ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findElements ( int [ ] arr , int n , int l , int r ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { int a = 0 ; if ( ! mp . ContainsKey ( arr [ i ] ) ) { a = 1 ; } else { a = mp [ arr [ i ] ] + 1 ; } if ( ! mp . ContainsKey ( arr [ i ] ) ) { mp . Add ( arr [ i ] , a ) ; } else { mp . Remove ( arr [ i ] ) ; mp . Add ( arr [ i ] , a ) ; } } for ( int i = 0 ; i < n ; ++ i ) { if ( mp . ContainsKey ( arr [ i ] ) && l <= mp [ arr [ i ] ] && ( mp [ arr [ i ] ] <= r ) ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 3 , 2 , 2 , 5 } ; int n = arr . Length ; int l = 2 , r = 3 ; findElements ( arr , n , l , r ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long count_triples ( int n , int k ) { int i = 0 , j = 0 , l = 0 ; int count = 0 ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j <= n ; j ++ ) { for ( l = 1 ; l <= n ; l ++ ) { if ( ( i + j ) % k == 0 && ( i + l ) % k == 0 && ( j + l ) % k == 0 ) count ++ ; } } } return count ; } public static void Main ( ) { int n = 3 ; int k = 2 ; long ans = count_triples ( n , k ) ; Console . WriteLine ( ans ) ; } }

Accumulator variables: count, i, j, l
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int maxs = 1000001 ; static int kthSmallestLargest ( int [ ] arr , int n , int k ) { int max_val = arr . Max ( ) ; int [ ] hash = new int [ max_val + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { hash [ arr [ i ] ] ++ ; } int count = 0 ; for ( int i = 0 ; i <= max_val ; i ++ ) { while ( hash [ i ] > 0 ) { count ++ ; if ( count == k ) { return i ; } hash [ i ] -- ; } } return - 1 ; } public static void Main ( ) { int [ ] arr = { 11 , 6 , 2 , 9 , 4 , 3 , 16 } ; int n = arr . Length , k = 3 ; Console . WriteLine ( " kth ▁ smallest ▁ number ▁ is : ▁ " + kthSmallestLargest ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int minEle , int maxEle ) { return minEle + maxEle ; } static int findProduct ( int minEle , int maxEle ) { return minEle * maxEle ; } public static void Main ( ) { int [ ] arr = { 12 , 1234 , 45 , 67 , 1 } ; int n = arr . Length ; Array . Sort ( arr ) ; int minEle = arr [ 0 ] ; int maxEle = arr [ n - 1 ] ; Console . WriteLine ( " Sum ▁ = ▁ " + findSum ( minEle , maxEle ) ) ; Console . WriteLine ( " Product ▁ = ▁ " + findProduct ( minEle , maxEle ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int bsearch ( List < int > A , int key_to_search ) { int n = ( int ) A . Count ; int lg = ( int ) Math . Log ( n - 1 , 2.0 ) + 1 ; int pos = 0 ; for ( int i = lg - 1 ; i >= 0 ; i -- ) { if ( A [ pos ] == key_to_search ) { return pos ; } int new_pos = pos | ( 1 << i ) ; if ( ( new_pos < n ) && ( A [ new_pos ] <= key_to_search ) ) { pos = new_pos ; } } return ( ( A [ pos ] == key_to_search ) ? pos : - 1 ) ; } static public void Main ( ) { List < int > A = new List < int > ( ) ; int [ ] arr = { - 2 , 10 , 100 , 250 , 32315 } ; for ( int i = 0 ; i < arr . Length ; i ++ ) { A . Add ( arr [ i ] ) ; } Console . WriteLine ( bsearch ( A , 10 ) ) ; } }

Index/key variables: i, new_pos, pos
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void answerQueries ( int [ , ] a , int n , int [ ] queries , int q ) { List < int > v = new List < int > ( ) ; Dictionary < int , int > mpp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { v . Add ( a [ i , 0 ] ) ; if ( ! mpp . ContainsKey ( a [ i , 0 ] ) ) mpp . Add ( a [ i , 0 ] , 1 ) ; v . Add ( a [ i , 1 ] ) ; if ( ! mpp . ContainsKey ( a [ i , 1 ] ) ) mpp . Add ( a [ i , 1 ] , 2 ) ; } v . Sort ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int num = queries [ i ] ; int ind = lowerBound ( v , num ) ; if ( ind >= 0 && v [ ind ] == num ) Console . WriteLine ( " Yes " ) ; else { if ( ind >= 0 && mpp [ v [ ind ] ] == 2 ) Console . WriteLine ( " Yes " ) ; Console . WriteLine ( " No " ) ; } } } static int lowerBound ( List < int > array , int value ) { int low = 0 ; int high = array . Count ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( value <= array [ mid ] ) { high = mid ; } else { low = mid + 1 ; } } return low ; } public static void Main ( String [ ] args ) { int [ , ] a = { { 5 , 6 } , { 1 , 3 } , { 8 , 10 } } ; int n = 3 ; int [ ] queries = { 2 , 3 , 4 , 7 } ; int q = queries . Length ; answerQueries ( a , n , queries , q ) ; } }

Index/key variables: i, ind, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float findmedian ( int [ ] a , int n1 , int [ ] b , int n2 ) { int i = 0 ; int j = 0 ; int k ; int m1 = - 1 , m2 = - 1 ; for ( k = 0 ; k <= ( n1 + n2 ) / 2 ; k ++ ) { if ( i < n1 && j < n2 ) { if ( a [ i ] < b [ j ] ) { m2 = m1 ; m1 = a [ i ] ; i ++ ; } else { m2 = m1 ; m1 = b [ j ] ; j ++ ; } } else if ( i == n1 ) { m2 = m1 ; m1 = b [ j ] ; j ++ ; } else if ( j == n2 ) { m2 = m1 ; m1 = a [ i ] ; i ++ ; } } if ( ( n1 + n2 ) % 2 == 0 ) { return ( m1 + m2 ) * ( float ) 1.0 / 2 ; } return m1 ; } public static void Main ( ) { int [ ] a = { 1 , 12 , 15 , 26 , 38 } ; int [ ] b = { 2 , 13 , 24 } ; int n1 = a . Length ; int n2 = b . Length ; Console . WriteLine ( findmedian ( a , n1 , b , n2 ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static void printNSE ( int [ ] arr , int n ) { int next , i , j ; for ( i = 0 ; i < n ; i ++ ) { next = - 1 ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] > arr [ j ] ) { next = arr [ j ] ; break ; } } Console . WriteLine ( arr [ i ] + " ▁ - - ▁ " + next ) ; } } public static void Main ( ) { int [ ] arr = { 11 , 13 , 21 , 3 } ; int n = arr . Length ; printNSE ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int longestSubarray ( int [ ] input ) { int prev = - 1 ; int current , next ; int prevCount = 0 , currentCount = 1 ; int longest = 1 ; current = input [ 0 ] ; for ( int i = 1 ; i < input . Length ; i ++ ) { next = input [ i ] ; if ( next == current ) { currentCount ++ ; } else if ( next == prev ) { prevCount += currentCount ; prev = current ; current = next ; currentCount = 1 ; } else { longest = Math . Max ( longest , currentCount + prevCount ) ; prev = current ; prevCount = currentCount ; current = next ; currentCount = 1 ; } } return Math . Max ( longest , currentCount + prevCount ) ; } public static void Main ( String [ ] args ) { int [ ] input = { 5 , 5 , 6 , 7 , 6 } ; Console . WriteLine ( longestSubarray ( input ) ) ; } }

Index/key variables: i
Accumulator variables: currentCount, i, prevCount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int data ; public Node left , right ; } public class INT { public int data ; } public static Node reverseTreePathUtil ( Node root , int data , IDictionary < int , int > temp , int level , INT nextpos ) { if ( root == null ) { return null ; } if ( data == root . data ) { temp [ level ] = root . data ; root . data = temp [ nextpos . data ] ; nextpos . data ++ ; return root ; } temp [ level ] = root . data ; Node left , right = null ; left = reverseTreePathUtil ( root . left , data , temp , level + 1 , nextpos ) ; if ( left == null ) { right = reverseTreePathUtil ( root . right , data , temp , level + 1 , nextpos ) ; } if ( left != null right != null ) { root . data = temp [ nextpos . data ] ; nextpos . data ++ ; return ( left != null ? left : right ) ; } return null ; } public static void reverseTreePath ( Node root , int data ) { IDictionary < int , int > temp = new Dictionary < int , int > ( ) ; INT nextpos = new INT ( ) ; nextpos . data = 0 ; reverseTreePathUtil ( root , data , temp , 0 , nextpos ) ; } public static void inorder ( Node root ) { if ( root != null ) { inorder ( root . left ) ; Console . Write ( root . data + " ▁ " ) ; inorder ( root . right ) ; } } public static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static void Main ( string [ ] args ) { Node root = newNode ( 7 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . left = newNode ( 2 ) ; root . right . right = newNode ( 1 ) ; int data = 4 ; reverseTreePath ( root , data ) ; inorder ( root ) ; } }

Index/key variables: level
Accumulator variables: data
Class/struct names: GFG, INT, Node
C# program:
using System ; class GFG { static int binarySearch ( int [ ] searchSpace , int s , int e , int num ) { int ans = 0 ; while ( s <= e ) { int mid = ( s + e ) / 2 ; if ( searchSpace [ mid ] >= num ) { ans = mid ; e = mid - 1 ; } else s = mid + 1 ; } return ans ; } static int longestSubArr ( int [ ] arr , int n ) { int [ ] searchSpace = new int [ n ] ; int [ ] index = new int [ n ] ; int j = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( j == 0 searchSpace [ j - 1 ] < arr [ i ] ) { searchSpace [ j ] = arr [ i ] ; index [ j ] = i ; j ++ ; } int idx = binarySearch ( searchSpace , 0 , j - 1 , arr [ i ] ) ; ans = Math . Max ( ans , i - index [ idx ] + 1 ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { - 5 , - 1 , 7 , 5 , 1 , - 2 } ; int n = arr . Length ; Console . Write ( longestSubArr ( arr , n ) ) ; } }

Index/key variables: i, idx, j, mid, n
Accumulator variables: j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class SumOfPairs { public void pairedElements ( int [ ] arr , int sum ) { int low = 0 ; int high = arr . Length - 1 ; while ( low < high ) { if ( arr [ low ] + arr [ high ] == sum ) { Console . WriteLine ( " The ▁ pair ▁ is ▁ : ▁ ( " + arr [ low ] + " , ▁ " + arr [ high ] + " ) " ) ; } if ( arr [ low ] + arr [ high ] > sum ) { high -- ; } else { low ++ ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , - 2 , 6 , 8 , 9 , 11 } ; Array . Sort ( arr ) ; SumOfPairs sp = new SumOfPairs ( ) ; sp . pairedElements ( arr , 6 ) ; } }

Index/key variables: high, low
Accumulator variables: high, low
Class/struct names: SumOfPairs
C# program:
using System ; class GFG { static bool isSuffix ( string s1 , string s2 ) { int n1 = s1 . Length , n2 = s2 . Length ; if ( n1 > n2 ) return false ; for ( int i = 0 ; i < n1 ; i ++ ) if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) return false ; return true ; } public static void Main ( ) { string s1 = " geeks " , s2 = " geeksforgeeks " ; bool result = isSuffix ( s1 , s2 ) ; if ( result ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG