dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int [ ] findLargest ( int beg , int end , int [ ] arr , int n ) { if ( beg == end ) { int [ ] compared = new int [ n ] ; compared [ 0 ] = 1 ; compared [ 1 ] = arr [ beg ] ; return compared ; } int [ ] compared1 = findLargest ( beg , ( beg + end ) / 2 , arr , n ) ; int [ ] compared2 = findLargest ( ( beg + end ) / 2 + 1 , end , arr , n ) ; if ( compared1 [ 1 ] > compared2 [ 1 ] ) { int k = compared1 [ 0 ] + 1 ; compared1 [ 0 ] = k ; compared1 [ k ] = compared2 [ 1 ] ; return compared1 ; } else { int k = compared2 [ 0 ] + 1 ; compared2 [ 0 ] = k ; compared2 [ k ] = compared1 [ 1 ] ; return compared2 ; } } static void findSecondLargest ( int end , int [ ] arr ) { int [ ] compared1 = findLargest ( 0 , end - 1 , arr , end ) ; int [ ] compared2 = findLargest ( 2 , compared1 [ 0 ] + 2 , compared1 , compared1 [ 0 ] ) ; Console . WriteLine ( compared2 [ 1 ] ) ; } static public void Main ( ) { int N = 10 ; int [ ] arr = { 20 , 1990 , 12 , 1110 , 1 , 59 , 12 , 15 , 120 , 1110 } ; findSecondLargest ( N , arr ) ; } }

Index/key variables: beg, k, n
Class/struct names: GFG
C# program:
using System ; class GFG { public static int CountsubString ( char [ ] str , int n ) { int c = 0 ; for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; char temp = str [ i ] , f = '0' ; if ( j == i ) { c ++ ; continue ; } int k = i + 1 ; while ( temp > str [ k ] && k <= j ) { temp = str [ k ] ; k ++ ; } if ( k > j ) { c ++ ; f = '2' ; } while ( k <= j && temp < str [ k ] && f != '2' ) { temp = str [ k ] ; k ++ ; } if ( k > j && f != 2 ) { c ++ ; f = '0' ; } } } return c ; } public static void Main ( String [ ] args ) { char [ ] str = { ' b ' , ' a ' , ' d ' , ' e ' } ; Console . WriteLine ( CountsubString ( str , str . Length ) - 1 ) ; } }

Index/key variables: i, k
Accumulator variables: c, i, k, len
Iterator variables: i, len
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSubsetSum ( int [ ] arr , int n , int sum ) { bool [ , ] subset = new bool [ n + 1 , sum + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) subset [ i , 0 ] = true ; for ( int i = 1 ; i <= sum ; i ++ ) subset [ 0 , i ] = false ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= sum ; j ++ ) { if ( j < arr [ i - 1 ] ) subset [ i , j ] = subset [ i - 1 , j ] ; if ( j >= arr [ i - 1 ] ) subset [ i , j ] = subset [ i - 1 , j ] || subset [ i - 1 , j - arr [ i - 1 ] ] ; } } return subset [ n , sum ] ; } static int findSum ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } int val = ( int ) Math . Sqrt ( sum ) ; for ( int i = val ; i >= 0 ; i -- ) { if ( isSubsetSum ( arr , n , i * i ) ) { return i * i ; } } return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = arr . Length ; Console . WriteLine ( findSum ( 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 int findsubArray ( int [ ] arr , int N , int K ) { int res = N + 1 ; for ( int i = 0 ; i < N ; i ++ ) { int curr_prod = 1 ; for ( int j = i ; j < N ; j ++ ) { curr_prod = curr_prod * arr [ j ] ; if ( curr_prod % N == K && res > ( j - i + 1 ) ) { res = Math . Min ( res , j - i + 1 ) ; break ; } } } return ( res == N + 1 ) ? 0 : res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 2 , 3 } ; int N = arr . Length ; int K = 1 ; int answer = findsubArray ( arr , N , K ) ; if ( answer != 0 ) Console . WriteLine ( answer ) ; else Console . WriteLine ( " - 1" ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maximumCount ( int [ ] A , int [ ] B , int n ) { Queue < int > q = new Queue < int > ( ) ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s . Add ( B [ i ] ) ; q . Enqueue ( B [ i ] ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! s . Contains ( A [ i ] ) ) continue ; while ( q . Count != 0 && q . Peek ( ) != A [ i ] ) { s . Remove ( q . Peek ( ) ) ; q . Dequeue ( ) ; count ++ ; } if ( A [ i ] == q . Peek ( ) ) { q . Dequeue ( ) ; s . Remove ( A [ i ] ) ; } if ( q . Count == 0 ) break ; } Console . Write ( count + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int N = 4 ; int [ ] A = { 1 , 2 , 3 , 4 } ; int [ ] B = { 1 , 2 , 4 , 3 } ; maximumCount ( A , B , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { readonly static int N = 3 , M = 3 ; static bool checkBitonic ( int [ ] arr , int n ) { int i , j , f = 0 ; for ( i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) continue ; if ( arr [ i ] == arr [ i - 1 ] ) return false ; else { f = 1 ; break ; } } if ( i == n ) return true ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] < arr [ j - 1 ] ) continue ; if ( arr [ i ] == arr [ i - 1 ] ) return false ; else { if ( f == 1 ) return false ; } } return true ; } static void check ( int [ , ] arr ) { int f = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! checkBitonic ( GetRow ( arr , i ) , M ) ) { Console . WriteLine ( " NO " ) ; return ; } } for ( int i = 0 ; i < N ; i ++ ) { int [ ] temp = new int [ N ] ; for ( int j = 0 ; j < N ; j ++ ) { temp [ j ] = arr [ j , i ] ; } if ( ! checkBitonic ( temp , N ) ) { Console . WriteLine ( " NO " ) ; return ; } } Console . WriteLine ( " YES " ) ; } public static int [ ] GetRow ( int [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new int [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } public static void Main ( String [ ] args ) { int [ , ] m = { { 1 , 2 , 3 } , { 3 , 4 , 5 } , { 2 , 6 , 4 } } ; check ( m ) ; } }

Index/key variables: N, i, j, rowLength
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int getMaxGcd ( int N ) { int maxGcd = int . MinValue , A , B ; for ( int i = 1 ; i <= Math . Sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { A = i ; B = N / i ; maxGcd = Math . Max ( maxGcd , gcd ( A , B ) ) ; } } return maxGcd ; } public static void Main ( String [ ] s ) { int N = 18 ; Console . WriteLine ( getMaxGcd ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool can_place ( int [ ] A , int n , int B , int mid ) { int count = 1 ; int last_position = A [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( A [ i ] - last_position >= mid ) { last_position = A [ i ] ; count ++ ; if ( count == B ) { return true ; } } } return false ; } static int find_min_difference ( int [ ] A , int n , int B ) { Array . Sort ( A ) ; int s = 0 ; int e = A [ n - 1 ] - A [ 0 ] ; int ans = 0 ; while ( s <= e ) { int mid = ( s + e ) / 2 ; if ( can_place ( A , n , B , mid ) ) { ans = mid ; s = mid + 1 ; } else { e = mid - 1 ; } } return ans ; } public static void Main ( string [ ] args ) { int [ ] A = { 1 , 2 , 3 , 5 } ; int n = A . Length ; int B = 3 ; int min_difference = find_min_difference ( A , n , B ) ; Console . Write ( min_difference ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countTriplets ( int [ ] A , int N ) { int ans = 0 ; Dictionary < int , int > map = new Dictionary < int , int > ( ) ; for ( int j = N - 2 ; j >= 1 ; j -- ) { if ( map . ContainsKey ( A [ j + 1 ] ) ) map [ A [ j + 1 ] ] = map [ A [ j + 1 ] ] + 1 ; else map . Add ( A [ j + 1 ] , 1 ) ; for ( int i = 0 ; i < j ; i ++ ) { int target = A [ i ] * A [ j ] ; if ( map . ContainsKey ( target ) ) ans += map [ target ] ; } } return ans ; } public static void Main ( String [ ] args ) { int N = 5 ; int [ ] A = { 2 , 3 , 4 , 6 , 12 } ; Console . Write ( countTriplets ( A , N ) ) ; } }

Index/key variables: i, j, target
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void MissingPoint ( List < pair > V , int N ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < V . Count ; i ++ ) { if ( mp . ContainsKey ( V [ i ] . first ) ) mp [ V [ i ] . first ] = mp [ V [ i ] . first ] + 1 ; else mp . Add ( V [ i ] . first , 1 ) ; } int x = 0 , y = 0 ; foreach ( KeyValuePair < int , int > it in mp ) { if ( it . Value % 2 == 1 ) { x = it . Key ; break ; } } mp . Clear ( ) ; for ( int i = 0 ; i < V . Count ; i ++ ) { if ( mp . ContainsKey ( V [ i ] . second ) ) mp [ V [ i ] . second ] = mp [ V [ i ] . second ] + 1 ; else mp . Add ( V [ i ] . second , 1 ) ; } foreach ( KeyValuePair < int , int > it in mp ) { if ( it . Value % 2 == 1 ) { y = it . Key ; break ; } } Console . Write ( x + " ▁ " + y ) ; } public static void Main ( String [ ] args ) { int N = 2 ; List < pair > V = new List < pair > ( ) ; V . Add ( new pair ( 1 , 1 ) ) ; V . Add ( new pair ( 1 , 2 ) ) ; V . Add ( new pair ( 4 , 6 ) ) ; V . Add ( new pair ( 2 , 1 ) ) ; V . Add ( new pair ( 9 , 6 ) ) ; V . Add ( new pair ( 9 , 3 ) ) ; V . Add ( new pair ( 4 , 3 ) ) ; MissingPoint ( V , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int sign ( int x ) { if ( x > 0 ) return 1 ; else return - 1 ; } static int findMaxSum ( int [ ] arr , int size ) { int max_sum = 0 , pres , i , j ; for ( i = 0 ; i < size ; i ++ ) { pres = arr [ i ] ; j = i ; while ( j < size && sign ( arr [ i ] ) == sign ( arr [ j ] ) ) { pres = Math . Max ( pres , arr [ j ] ) ; j ++ ; } max_sum = max_sum + pres ; i = j - 1 ; } return max_sum ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 2 , 8 , 3 , 8 , - 4 , - 15 , 5 , - 2 , - 3 , 1 } ; int size = arr . Length ; Console . WriteLine ( findMaxSum ( arr , size ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; using System . Linq ; class GFG { static bool groupInKConsecutive ( int [ ] arr , int K ) { Dictionary < int , int > count = new Dictionary < int , int > ( ) ; foreach ( int h in arr ) { if ( count . ContainsKey ( h ) ) count [ h ] ++ ; else count [ h ] = 1 ; } foreach ( int c in count . Keys . ToList ( ) ) { int cur = c ; int n = count ; if ( n > 0 ) { for ( int i = 1 ; i < K ; ++ i ) { if ( ! count . ContainsKey ( cur + i ) ) { return false ; } count [ cur + i ] -= n ; if ( count [ cur + i ] < 0 ) return false ; } } } return true ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 6 , 2 , 3 , 4 , 7 , 8 } ; int k = 3 ; if ( groupInKConsecutive ( arr , k ) ) { Console . Write ( " True " ) ; } else { Console . Write ( " False " ) ; } } }

Index/key variables: h
Iterator variables: c, h, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubAllOnes ( String s ) { int l = 0 , r = 0 , ans = 0 ; while ( l <= r ) { if ( r == s . Length ) { ans += ( ( r - l ) * ( r - l + 1 ) ) / 2 ; break ; } if ( s [ r ] == '1' ) r ++ ; else { ans += ( ( r - l ) * ( r - l + 1 ) ) / 2 ; l = r + 1 ; r ++ ; } } return ans ; } static String flip ( char [ ] s ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' ) s [ i ] = '0' ; else s [ i ] = '1' ; } return String . Join ( " " , s ) ; } static int countSubAllZerosOnes ( String s ) { int only_1s = countSubAllOnes ( s ) ; s = flip ( s . ToCharArray ( ) ) ; int only_0s = countSubAllOnes ( s ) ; return only_0s + only_1s ; } public static void Main ( String [ ] args ) { String s = "011" ; Console . Write ( countSubAllZerosOnes ( s ) + " STRNEWLINE " ) ; } }

Index/key variables: i, r
Accumulator variables: ans, i, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool sumSquare ( int p ) { return ( p - 1 ) % 4 == 0 ; } static bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int countOfPrimes ( int L , int R ) { int count = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( isPrime ( i ) ) { if ( sumSquare ( i ) ) count ++ ; } } return count ; } public static void Main ( String [ ] args ) { int L = 5 , R = 41 ; Console . WriteLine ( countOfPrimes ( L , R ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count_elements ( int [ ] arr , int n ) { int count = 1 ; int max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { count += 1 ; max = arr [ i ] ; } } return count ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 4 , 6 , 3 } ; int n = arr . Length ; Console . Write ( count_elements ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void subString ( char [ ] str , int n ) { int c = 0 ; for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; char temp = str [ i ] , f = ( char ) 0 ; if ( j == i ) { c ++ ; continue ; } int k = i + 1 ; while ( k < n && temp < str [ k ] ) { temp = str [ k ] ; k ++ ; f = ( char ) 2 ; } if ( k > j ) { c ++ ; f = ( char ) 2 ; } while ( k < n && temp > str [ k ] && f != 2 ) { k ++ ; f = ( char ) 0 ; } if ( k > j && f != 2 ) { c ++ ; f = ( char ) 0 ; } } } Console . Write ( c + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { char [ ] str = " bade " . ToCharArray ( ) ; subString ( str , str . Length ) ; } }

Index/key variables: i, k
Accumulator variables: c, i, k, len
Iterator variables: i, len
Class/struct names: GFG
C# program:
using System ; class GFG { static int findNumberDivByPowerofTwo ( int [ ] ar , int k , int n ) { int found = - 1 , m = k ; while ( m > 0 ) { int l = 0 ; int r = n - 1 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; if ( ar [ mid ] == m ) { found = m ; break ; } else if ( ar [ mid ] > m ) { r = mid - 1 ; } else if ( ar [ mid ] < m ) { l = mid + 1 ; } } if ( found != - 1 ) { break ; } m = m / 2 ; } return found ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 7 , 8 , 10 } ; int k = 4 , n = 5 ; Console . WriteLine ( findNumberDivByPowerofTwo ( arr , k , n ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int findSubset ( int [ ] a , int n ) { int sum = 0 ; int cnt = 0 ; List < int > v = new List < int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( a [ i - 1 ] - i <= 0 ) { sum += a [ i - 1 ] - i ; cnt += 1 ; } else { v . Add ( a [ i - 1 ] - i ) ; } } v . Sort ( ) ; int ptr = 0 ; while ( ptr < v . Count && sum + v [ ptr ] <= 0 ) { cnt += 1 ; ptr += 1 ; sum += v [ ptr ] ; } return cnt ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 1 , 6 , 7 , 8 , 2 } ; int n = arr . Length ; Console . WriteLine ( findSubset ( arr , n ) ) ; } }

Index/key variables: ptr
Accumulator variables: cnt, i, ptr, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void setElement ( int [ ] arr , int n , int index , int x ) { arr [ index ] = x ; } static int getCount ( int [ ] arr , int n , int l , int r ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= l && arr [ i ] <= r ) count += 1 ; } return count ; } static void SolveQuery ( int [ ] arr , int n , List < List < int > > Q ) { int x ; for ( int i = 0 ; i < Q . Count ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) { x = getCount ( arr , n , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] ) ; Console . Write ( x + " ▁ " ) ; } else { setElement ( arr , n , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] ) ; } } } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 3 , 4 , 4 , 5 , 6 } ; int n = arr . Length ; List < List < int > > myList = new List < List < int > > ( ) ; myList . Add ( new List < int > { 1 , 3 , 5 } ) ; myList . Add ( new List < int > { 1 , 2 , 4 } ) ; myList . Add ( new List < int > { 1 , 1 , 2 } ) ; myList . Add ( new List < int > { 2 , 1 , 7 } ) ; myList . Add ( new List < int > { 1 , 1 , 2 } ) ; SolveQuery ( arr , n , myList ) ; } }

Index/key variables: i, index
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > generateSequence ( int [ ] freq , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m . Add ( i , freq [ i ] ) ; total += freq [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( m . ContainsKey ( i ) ) { List < int > sequence = new List < int > ( ) ; Dictionary < int , int > mcopy = new Dictionary < int , int > ( m ) ; if ( mcopy . ContainsKey ( i ) && mcopy [ i ] > 0 ) mcopy [ i ] = mcopy [ i ] - 1 ; sequence . Add ( i ) ; int last = i ; for ( int i1 = 0 ; i1 < total - 1 ; i1 ++ ) { if ( mcopy . ContainsKey ( last - 1 ) && mcopy [ last - 1 ] > 0 ) { mcopy [ last - 1 ] = mcopy [ last - 1 ] - 1 ; sequence . Add ( last - 1 ) ; last -- ; } else if ( mcopy . ContainsKey ( last + 1 ) ) { mcopy [ last + 1 ] = mcopy [ last + 1 ] - 1 ; sequence . Add ( last + 1 ) ; last ++ ; } else break ; } if ( sequence . Count == total ) { return sequence ; } } } List < int > empty = new List < int > ( ) ; return empty ; } static void PrintSequence ( int [ ] freq , int n ) { List < int > sequence = generateSequence ( freq , n ) ; if ( sequence . Count == 0 ) { Console . Write ( " - 1" ) ; } else { for ( int i = 0 ; i < sequence . Count ; i ++ ) { Console . Write ( sequence [ i ] + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] freq = { 2 , 2 , 2 , 3 , 1 } ; int N = 5 ; PrintSequence ( freq , N ) ; } }

Index/key variables: i
Accumulator variables: i, i1, last, total
Iterator variables: i, i1
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void getMinimumDistance ( int [ ] a , int n ) { HashSet < int > min_set = new HashSet < int > ( ) ; HashSet < int > max_set = new HashSet < int > ( ) ; int max = 0 , min = Int32 . MaxValue ; Dictionary < int , int > frequency = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! frequency . ContainsKey ( a [ i ] ) ) frequency . Add ( a [ i ] , 0 ) ; frequency [ a [ i ] ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { int count = frequency [ a [ i ] ] ; if ( count == max ) { max_set . Add ( a [ i ] ) ; } else if ( count > max ) { max_set . Clear ( ) ; max = count ; max_set . Add ( a [ i ] ) ; } if ( count == min ) { min_set . Add ( a [ i ] ) ; } else if ( count < min ) { min_set . Clear ( ) ; min = count ; min_set . Add ( a [ i ] ) ; } } int min_dist = Int32 . MaxValue ; int last_min_found = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( min_set . Contains ( a [ i ] ) ) last_min_found = i ; if ( max_set . Contains ( a [ i ] ) && last_min_found != - 1 ) { min_dist = Math . Min ( min_dist , i - last_min_found ) ; } } last_min_found = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( min_set . Contains ( a [ i ] ) ) last_min_found = i ; if ( max_set . Contains ( a [ i ] ) && last_min_found != - 1 ) { min_dist = Math . Min ( min_dist , last_min_found - i ) ; } } Console . WriteLine ( min_dist ) ; } static public void Main ( ) { int [ ] arr = { 1 , 1 , 2 , 3 , 2 , 3 , 3 } ; int N = arr . Length ; getMinimumDistance ( 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 void printSubsequenceString ( String str , int k ) { int n = str . Length ; int i ; List < int > factors = new List < int > ( ) ; for ( i = 2 ; i <= Math . Sqrt ( k ) ; i ++ ) { while ( k % i == 0 ) { factors . Add ( i ) ; k /= i ; } } if ( k > 1 ) factors . Add ( k ) ; int [ ] count = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) count [ i ] = 1 ; int index = 0 ; while ( factors . Count > 0 ) { count [ index ++ ] *= factors [ factors . Count - 1 ] ; factors . Remove ( factors [ factors . Count - 1 ] ) ; if ( index == n ) index = 0 ; } String s = " " ; for ( i = 0 ; i < n ; i ++ ) { while ( count [ i ] -- > 0 ) { s += str [ i ] ; } } Console . Write ( s ) ; } public static void Main ( String [ ] args ) { String str = " code " ; int k = 20 ; printSubsequenceString ( str , k ) ; } }

Index/key variables: i, n
Accumulator variables: i, index, k, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Text ; class GFG { static void changeArr ( int [ ] input ) { int [ ] newArray = new int [ input . Length ] ; Array . Copy ( input , newArray , input . Length ) ; Array . Sort ( newArray ) ; Dictionary < int , int > ranks = new Dictionary < int , int > ( ) ; int rank = 1 ; for ( int index = 0 ; index < newArray . Length ; index ++ ) { int element = newArray [ index ] ; if ( ! ranks . ContainsKey ( element ) ) { ranks [ element ] = rank ; rank ++ ; } } for ( int index = 0 ; index < input . Length ; index ++ ) { input [ index ] = ranks [ input [ index ] ] ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 100 , 2 , 70 , 2 } ; changeArr ( arr ) ; Console . WriteLine ( " [ { 0 } ] " , string . Join ( " , ▁ " , arr ) ) ; } }

Index/key variables: element, index
Accumulator variables: index, rank
Iterator variables: index
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void findPair ( int [ ] arr , int n ) { int i , j ; if ( n < 2 ) { Console . Write ( " - 1" ) ; } HashSet < int > hashMap = new HashSet < int > ( ) ; foreach ( int k in arr ) { hashMap . Add ( k ) ; } for ( i = 0 ; i < n - 1 ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { int sum = arr [ i ] + arr [ j ] ; if ( ! hashMap . Contains ( sum ) ) { Console . Write ( " ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) STRNEWLINE " ) ; } } } } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 4 , 2 , 6 } ; int n = arr . Length ; findPair ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findLengthOfMaxSubset ( int [ ] arr , int n , int m ) { HashSet < int > s = new HashSet < int > ( ) ; int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = arr [ i ] ; if ( tmp != m ) { s . Add ( tmp ) ; answer ++ ; } } int min = 1 ; while ( s . Contains ( min ) ) { min ++ ; } if ( min != m ) { answer = - 1 ; } return answer ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 4 } ; int N = arr . Length ; int M = 3 ; Console . Write ( findLengthOfMaxSubset ( arr , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, min
Iterator variables: i
Class/struct names: GFG