dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { static void hasArrayTwoPairs ( int [ ] nums , int n , int target ) { Array . Sort ( nums ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = target - nums [ i ] ; int low = 0 , high = n - 1 ; while ( low <= high ) { int mid = low + ( ( high - low ) / 2 ) ; if ( nums [ mid ] > x ) { high = mid - 1 ; } else if ( nums [ mid ] < x ) { low = mid + 1 ; } else { if ( mid == i ) { if ( ( mid - 1 >= 0 ) && nums [ mid - 1 ] == x ) { Console . Write ( nums [ i ] + " , ▁ " ) ; Console . Write ( nums [ mid - 1 ] ) ; return ; } if ( ( mid + 1 < n ) && nums [ mid + 1 ] == x ) { Console . Write ( nums [ i ] + " , ▁ " ) ; Console . Write ( nums [ mid + 1 ] ) ; return ; } break ; } else { Console . Write ( nums [ i ] + " , ▁ " ) ; Console . Write ( nums [ mid ] ) ; return ; } } } } Console . Write ( - 1 ) ; } static public void Main ( ) { int [ ] A = { 0 , - 1 , 2 , - 3 , 1 } ; int X = - 2 ; int N = A . Length ; hasArrayTwoPairs ( A , N , X ) ; } }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findClosest ( int N , int target ) { int closest = - 1 ; int diff = Int32 . MaxValue ; for ( int i = 1 ; i <= Math . Sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { if ( N / i == i ) { if ( Math . Abs ( target - i ) < diff ) { diff = Math . Abs ( target - i ) ; closest = i ; } } else { if ( Math . Abs ( target - i ) < diff ) { diff = Math . Abs ( target - i ) ; closest = i ; } if ( Math . Abs ( target - N / i ) < diff ) { diff = Math . Abs ( target - N / i ) ; closest = N / i ; } } } } Console . Write ( closest ) ; } static void Main ( ) { int N = 16 , X = 5 ; findClosest ( N , X ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( int A , int N ) { int count = 0 ; if ( A == 1 ) return 0 ; while ( N > 0 ) { count ++ ; N /= A ; } return count ; } static void Pairs ( int N , int A , int B ) { int powerA , powerB ; powerA = power ( A , N ) ; powerB = power ( B , N ) ; int intialB = B , intialA = A ; A = 1 ; for ( int i = 0 ; i <= powerA ; i ++ ) { B = 1 ; for ( int j = 0 ; j <= powerB ; j ++ ) { if ( B == N - A ) { Console . WriteLine ( i + " ▁ " + j ) ; return ; } B *= intialB ; } A *= intialA ; } Console . WriteLine ( " - 1" ) ; return ; } public static void Main ( String [ ] args ) { int N = 106 , A = 3 , B = 5 ; Pairs ( N , A , B ) ; } }

Accumulator variables: A, B, N, count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int findNonMultiples ( int [ ] arr , int n , int k ) { HashSet < int > multiples = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( ! multiples . Contains ( arr [ i ] ) ) { for ( int j = 1 ; j <= k / arr [ i ] ; j ++ ) { multiples . Add ( arr [ i ] * j ) ; } } } return k - multiples . Count ; } public static int countValues ( int [ ] arr , int N , int L , int R ) { return findNonMultiples ( arr , N , R ) - findNonMultiples ( arr , N , L - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 6 } ; int N = arr . Length ; int L = 1 ; int R = 20 ; Console . WriteLine ( countValues ( arr , N , L , R ) ) ; } }

Index/key variables: i
Accumulator variables: j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void minCollectingSpeed ( int [ ] piles , int H ) { int ans = - 1 ; int low = 1 , high ; Array . Sort ( piles ) ; high = piles [ piles . Length - 1 ] ; while ( low <= high ) { int K = low + ( high - low ) / 2 ; int time = 0 ; foreach ( int ai in piles ) { time += ( ai + K - 1 ) / K ; } if ( time <= H ) { ans = K ; high = K - 1 ; } else { low = K + 1 ; } } Console . Write ( ans ) ; } static public void Main ( string [ ] args ) { int [ ] arr = { 3 , 6 , 7 , 11 } ; int H = 8 ; minCollectingSpeed ( arr , H ) ; } }

Accumulator variables: time
Iterator variables: ai
Class/struct names: GFG
C# program:
using System ; class GFG { static int cntDisPairs ( int [ ] arr , int N , int K ) { int cntPairs = 0 ; Array . Sort ( arr ) ; int i = 0 ; int j = N - 1 ; while ( i < j ) { if ( arr [ i ] + arr [ j ] == K ) { while ( i < j && arr [ i ] == arr [ i + 1 ] ) { i ++ ; } while ( i < j && arr [ j ] == arr [ j - 1 ] ) { j -- ; } cntPairs += 1 ; i ++ ; j -- ; } else if ( arr [ i ] + arr [ j ] < K ) { i ++ ; } else { j -- ; } } return cntPairs ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 6 , 5 , 7 , 7 , 8 } ; int N = arr . Length ; int K = 13 ; Console . WriteLine ( cntDisPairs ( arr , N , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntPairs, i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int cntDisPairs ( int [ ] arr , int N , int K ) { int cntPairs = 0 ; Dictionary < int , int > cntFre = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( cntFre . ContainsKey ( arr [ i ] ) ) cntFre [ arr [ i ] ] = cntFre [ arr [ i ] ] + 1 ; else cntFre . Add ( arr [ i ] , 1 ) ; } foreach ( KeyValuePair < int , int > it in cntFre ) { int i = it . Key ; if ( 2 * i == K ) { if ( cntFre [ i ] > 1 ) cntPairs += 2 ; } else { if ( cntFre . ContainsKey ( K - i ) ) { cntPairs += 1 ; } } } cntPairs = cntPairs / 2 ; return cntPairs ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 6 , 5 , 7 , 7 , 8 } ; int N = arr . Length ; int K = 13 ; Console . Write ( cntDisPairs ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: cntPairs, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void longestSubsequence ( int N , int Q , int [ ] arr , int [ , ] Queries ) { for ( int i = 0 ; i < Q ; i ++ ) { int x = Queries [ i , 0 ] ; int y = Queries [ i , 1 ] ; arr [ x - 1 ] = y ; int count = 1 ; for ( int j = 1 ; j < N ; j ++ ) { if ( arr [ j ] != arr [ j - 1 ] ) { count += 1 ; } } Console . Write ( count + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 5 , 2 } ; int N = arr . Length ; int Q = 2 ; int [ , ] Queries = { { 1 , 3 } , { 4 , 2 } } ; longestSubsequence ( N , Q , arr , Queries ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void longestSubsequence ( int N , int Q , int [ ] arr , int [ , ] Queries ) { int count = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] ) { count += 1 ; } } for ( int i = 0 ; i < Q ; i ++ ) { int x = Queries [ i , 0 ] ; int y = Queries [ i , 1 ] ; if ( x > 1 ) { if ( arr [ x - 1 ] != arr [ x - 2 ] ) { count -= 1 ; } if ( arr [ x - 2 ] != y ) { count += 1 ; } } if ( x < N ) { if ( arr [ x ] != arr [ x - 1 ] ) { count -= 1 ; } if ( y != arr [ x ] ) { count += 1 ; } } Console . Write ( count + " ▁ " ) ; arr [ x - 1 ] = y ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 5 , 2 } ; int N = arr . Length ; int Q = 2 ; int [ , ] Queries = { { 1 , 3 } , { 4 , 2 } } ; longestSubsequence ( N , Q , arr , Queries ) ; } }

Index/key variables: i, x
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void sum ( int [ ] arr , int n ) { Dictionary < int , List < int > > mp = new Dictionary < int , List < int > > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { List < int > v = new List < int > ( ) ; v . Add ( i ) ; if ( mp . ContainsKey ( arr [ i ] ) ) v . AddRange ( mp [ arr [ i ] ] ) ; mp [ arr [ i ] ] = v ; } int [ ] ans = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; foreach ( int it in mp [ arr [ i ] ] ) { sum += Math . Abs ( it - i ) ; } ans [ i ] = sum ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } return ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 1 , 1 , 2 } ; int n = arr . Length ; sum ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i, sum
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static void conVowUpp ( char [ ] str ) { int N = str . Length ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' a ' str [ i ] == ' e ' str [ i ] == ' i ' str [ i ] == ' o ' str [ i ] == ' u ' ) { char c = char . ToUpperInvariant ( str [ i ] ) ; str [ i ] = c ; } } foreach ( char c in str ) Console . Write ( c ) ; } public static void Main ( String [ ] args ) { String str = " eutopia " ; conVowUpp ( str . ToCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: c, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; static int N , P ; static bool helper ( int mid ) { int cnt = 0 ; foreach ( KeyValuePair < int , int > i in mp ) { int temp = i . Value ; while ( temp >= mid ) { temp -= mid ; cnt ++ ; } } return cnt >= N ; } static int findMaximumDays ( int [ ] arr ) { for ( int i = 0 ; i < P ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } int start = 0 , end = P , ans = 0 ; while ( start <= end ) { int mid = start + ( ( end - start ) / 2 ) ; if ( mid != 0 && helper ( mid ) ) { ans = mid ; start = mid + 1 ; } else if ( mid == 0 ) { start = mid + 1 ; } else { end = mid - 1 ; } } return ans ; } public static void Main ( String [ ] args ) { N = 3 ; P = 10 ; int [ ] arr = { 1 , 2 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 4 } ; Console . Write ( findMaximumDays ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countSubarrays ( int [ ] a , int n , int k ) { int ans = 0 ; List < int > pref = new List < int > ( ) ; pref . Add ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) pref . Add ( ( a [ i ] + pref [ i ] ) % k ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i ; j <= n ; j ++ ) { if ( ( pref [ j ] - pref [ i - 1 ] + k ) % k == j - i + 1 ) { ans ++ ; } } } Console . WriteLine ( ans ) ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 3 , 1 , 5 } ; int N = arr . Length ; int K = 4 ; countSubarrays ( arr , N , K ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countSubarrays ( int [ ] a , int n , int k ) { Dictionary < int , int > cnt = new Dictionary < int , int > ( ) ; long ans = 0 ; List < int > pref = new List < int > ( ) ; pref . Add ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) pref . Add ( ( a [ i ] + pref [ i ] ) % k ) ; cnt . Add ( 0 , 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) { int remIdx = i - k ; if ( remIdx >= 0 ) { if ( cnt . ContainsKey ( ( pref [ remIdx ] - remIdx % k + k ) % k ) ) cnt [ ( pref [ remIdx ] - remIdx % k + k ) % k ] = cnt [ ( pref [ remIdx ] - remIdx % k + k ) % k ] - 1 ; else cnt . Add ( ( pref [ remIdx ] - remIdx % k + k ) % k , - 1 ) ; } if ( cnt . ContainsKey ( ( pref [ i ] - i % k + k ) % k ) ) ans += cnt [ ( pref [ i ] - i % k + k ) % k ] ; if ( cnt . ContainsKey ( ( pref [ i ] - i % k + k ) % k ) ) cnt [ ( pref [ i ] - i % k + k ) % k ] = cnt [ ( pref [ i ] - i % k + k ) % k ] + 1 ; else cnt . Add ( ( pref [ i ] - i % k + k ) % k , 1 ) ; } Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 3 , 1 , 5 } ; int N = arr . Length ; int K = 4 ; countSubarrays ( arr , N , K ) ; } }

Index/key variables: i, remIdx
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( String s , int k ) { int n = s . Length ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = i ; j < n ; j += k ) { if ( s [ i ] != s [ j ] ) return false ; } } int c = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( s [ i ] == '0' ) c ++ ; else c -- ; } if ( c == 0 ) return true ; else return false ; } public static void Main ( String [ ] args ) { String s = "101010" ; int k = 2 ; if ( check ( s , k ) ) Console . Write ( " Yes " + " STRNEWLINE " ) ; else Console . Write ( " No " + " STRNEWLINE " ) ; } }

Index/key variables: i, j
Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isSame ( String str , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( mp . ContainsKey ( str [ i ] - ' a ' ) ) { mp [ str [ i ] - ' a ' ] = mp [ str [ i ] - ' a ' ] + 1 ; } else { mp . Add ( str [ i ] - ' a ' , 1 ) ; } } foreach ( KeyValuePair < int , int > it in mp ) { if ( ( it . Value ) >= n ) { return true ; } } return false ; } public static void Main ( String [ ] args ) { String str = " ccabcba " ; int n = 4 ; if ( isSame ( str , n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly double eps = 1e-6 ; static double func ( double a , double b , double c , double x ) { return a * x * x + b * x + c ; } static double findRoot ( double a , double b , double c , double low , double high ) { double x = - 1 ; while ( Math . Abs ( high - low ) > eps ) { x = ( low + high ) / 2 ; if ( func ( a , b , c , low ) * func ( a , b , c , x ) <= 0 ) { high = x ; } else { low = x ; } } return x ; } static void solve ( double a , double b , double c , double A , double B ) { if ( func ( a , b , c , A ) * func ( a , b , c , B ) > 0 ) { Console . WriteLine ( " No ▁ solution " ) ; } else { Console . Write ( " { 0 : F4 } " , findRoot ( a , b , c , A , B ) ) ; } } public static void Main ( String [ ] args ) { double a = 2 , b = - 3 , c = - 2 , A = 0 , B = 3 ; solve ( a , b , c , A , B ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool possible ( long mid , int [ ] a ) { long n = a . Length ; long total = ( n * ( n - 1 ) ) / 2 ; long need = ( total + 1 ) / 2 ; long count = 0 ; long start = 0 , end = 1 ; while ( end < n ) { if ( a [ ( int ) end ] - a [ ( int ) start ] <= mid ) { end ++ ; } else { count += ( end - start - 1 ) ; start ++ ; } } if ( end == n && start < end && a [ ( int ) end - 1 ] - a [ ( int ) start ] <= mid ) { long t = end - start - 1 ; count += ( t * ( t + 1 ) / 2 ) ; } if ( count >= need ) return true ; else return false ; } static long findMedian ( int [ ] a ) { long n = a . Length ; long low = 0 , high = a [ ( int ) n - 1 ] - a [ 0 ] ; while ( low <= high ) { long mid = ( low + high ) / 2 ; if ( possible ( mid , a ) ) high = mid - 1 ; else low = mid + 1 ; } return high + 1 ; } public static void Main ( string [ ] args ) { int [ ] a = { 1 , 7 , 5 , 2 } ; Array . Sort ( a ) ; Console . Write ( findMedian ( a ) ) ; } }

Accumulator variables: count, end, start
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void UniversalSubset ( List < String > A , List < String > B ) { int n1 = A . Count ; int n2 = B . Count ; List < String > res = new List < String > ( ) ; int [ , ] A_fre = new int [ n1 , 26 ] ; for ( int i = 0 ; i < n1 ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) A_fre [ i , j ] = 0 ; } for ( int i = 0 ; i < n1 ; i ++ ) { for ( int j = 0 ; j < A [ i ] . Length ; j ++ ) { A_fre [ i , A [ i ] [ j ] - ' a ' ] ++ ; } } int [ ] B_fre = new int [ 26 ] ; for ( int i = 0 ; i < n2 ; i ++ ) { int [ ] arr = new int [ 26 ] ; for ( int j = 0 ; j < B [ i ] . Length ; j ++ ) { arr [ B [ i ] [ j ] - ' a ' ] ++ ; B_fre [ B [ i ] [ j ] - ' a ' ] = Math . Max ( B_fre [ B [ i ] [ j ] - ' a ' ] , arr [ B [ i ] [ j ] - ' a ' ] ) ; } } for ( int i = 0 ; i < n1 ; i ++ ) { int flag = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( A_fre [ i , j ] < B_fre [ j ] ) { flag = 1 ; break ; } } if ( flag == 0 ) res . Add ( A [ i ] ) ; } if ( res . Count != 0 ) { for ( int i = 0 ; i < res . Count ; i ++ ) { for ( int j = 0 ; j < res [ i ] . Length ; j ++ ) Console . Write ( res [ i ] [ j ] ) ; } Console . Write ( " ▁ " ) ; } else Console . Write ( " - 1" ) ; } public static void Main ( String [ ] args ) { List < String > A = new List < String > ( ) ; A . Add ( " geeksforgeeks " ) ; A . Add ( " topcoder " ) ; A . Add ( " leetcode " ) ; List < String > B = new List < String > ( ) ; B . Add ( " geek " ) ; B . Add ( " ee " ) ; UniversalSubset ( A , B ) ; } }

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 void findPair ( int [ ] a , int n ) { int min_dist = int . MaxValue ; int index_a = - 1 , index_b = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( j - i < min_dist ) { if ( a [ i ] % a [ j ] == 0 a [ j ] % a [ i ] == 0 ) { min_dist = j - i ; index_a = i ; index_b = j ; } } } } if ( index_a == - 1 ) { Console . WriteLine ( " - 1" ) ; } else { Console . Write ( " ( " + a [ index_a ] + " , ▁ " + a [ index_b ] + " ) " ) ; } } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 4 , 5 , 6 } ; int n = a . Length ; findPair ( a , n ) ; } }

Index/key variables: i, index_a, index_b, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printNum ( int L , int R ) { for ( int i = L ; i <= R ; i ++ ) { int temp = i ; int c = 10 ; int flag = 0 ; while ( temp > 0 ) { if ( temp % 10 >= c ) { flag = 1 ; break ; } c = temp % 10 ; temp /= 10 ; } if ( flag == 0 ) Console . Write ( i + " ▁ " ) ; } } public static void Main ( ) { int L = 10 , R = 15 ; printNum ( L , R ) ; } }

Accumulator variables: i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMissing ( int [ ] arr , int left , int right , int diff ) { if ( right <= left ) return 0 ; int mid = left + ( right - left ) / 2 ; if ( arr [ mid + 1 ] - arr [ mid ] != diff ) return ( arr [ mid ] + diff ) ; if ( mid > 0 && arr [ mid ] - arr [ mid - 1 ] != diff ) return ( arr [ mid - 1 ] + diff ) ; if ( arr [ mid ] == arr [ 0 ] + mid * diff ) return findMissing ( arr , mid + 1 , right , diff ) ; return findMissing ( arr , left , mid - 1 , diff ) ; } static int missingElement ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int diff = ( arr [ n - 1 ] - arr [ 0 ] ) / n ; return findMissing ( arr , 0 , n - 1 , diff ) ; } public static void Main ( String [ ] args ) { int [ ] arr = new int [ ] { 2 , 8 , 6 , 10 } ; int n = arr . Length ; Console . WriteLine ( missingElement ( arr , n ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( int x , int y ) { int temp ; if ( y == 0 ) return 1 ; temp = power ( x , y / 2 ) ; if ( y % 2 == 0 ) return temp * temp ; else return x * temp * temp ; } static int nthRootSearch ( int low , int high , int N , int K ) { if ( low <= high ) { int mid = ( low + high ) / 2 ; if ( ( power ( mid , K ) <= N ) && ( power ( mid + 1 , K ) > N ) ) { return mid ; } else if ( power ( mid , K ) < N ) { return nthRootSearch ( mid + 1 , high , N , K ) ; } else { return nthRootSearch ( low , mid - 1 , N , K ) ; } } return low ; } public static void Main ( ) { int N = 16 , K = 4 ; Console . Write ( nthRootSearch ( 0 , N , N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int get_subset_count ( int [ ] arr , int K , int N ) { Array . Sort ( arr ) ; int left , right ; left = 0 ; right = N - 1 ; int ans = 0 ; while ( left <= right ) { if ( arr [ left ] + arr [ right ] < K ) { ans += 1 << ( right - left ) ; left ++ ; } else { right -- ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 5 , 7 } ; int K = 8 ; int N = arr . Length ; Console . Write ( get_subset_count ( arr , K , N ) ) ; } }

Index/key variables: left, right
Accumulator variables: ans, left, right
Class/struct names: GFG
C# program:
using System ; class GFG { static int minMaxDiff ( int [ ] arr , int n , int k ) { int max_adj_dif = int . MinValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) max_adj_dif = Math . Max ( max_adj_dif , Math . Abs ( arr [ i ] - arr [ i + 1 ] ) ) ; if ( max_adj_dif == 0 ) return 0 ; int best = 1 ; int worst = max_adj_dif ; int mid , required ; while ( best < worst ) { mid = ( best + worst ) / 2 ; required = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { required += ( Math . Abs ( arr [ i ] - arr [ i + 1 ] ) - 1 ) / mid ; } if ( required > k ) best = mid + 1 ; else worst = mid ; } return worst ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 12 , 25 , 50 } ; int n = arr . Length ; int k = 7 ; Console . WriteLine ( minMaxDiff ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, required
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkMin ( int [ ] arr , int len ) { int smallest = int . MaxValue ; int secondSmallest = int . MaxValue ; for ( int i = 0 ; i < len ; i ++ ) { if ( arr [ i ] < smallest ) { secondSmallest = smallest ; smallest = arr [ i ] ; } else if ( arr [ i ] < secondSmallest ) { secondSmallest = arr [ i ] ; } } if ( 2 * smallest <= secondSmallest ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 } ; int len = arr . Length ; checkMin ( arr , len ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static void createHash ( HashSet < int > hash , int maxElement ) { int prev = 0 , curr = 1 ; hash . Add ( prev ) ; hash . Add ( curr ) ; while ( curr <= maxElement ) { int temp = curr + prev ; hash . Add ( temp ) ; prev = curr ; curr = temp ; } } static void fibonacci ( int [ ] arr , int n ) { int max_val = arr . Max ( ) ; HashSet < int > hash = new HashSet < int > ( ) ; createHash ( hash , max_val ) ; int minimum = int . MaxValue ; int maximum = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash . Contains ( arr [ i ] ) ) { minimum = Math . Min ( minimum , arr [ i ] ) ; maximum = Math . Max ( maximum , arr [ i ] ) ; } } Console . Write ( minimum + " , ▁ " + maximum + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; int n = arr . Length ; fibonacci ( arr , n ) ; } }

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