dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static void distanceSort ( int [ ] arr , int K , int n ) { List < int > [ ] vd = new List < int > [ n ] ; int i ; for ( i = 0 ; i < n ; i ++ ) { vd [ i ] = new List < int > ( ) ; } int pos = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == K ) { pos = i ; break ; } } int j = pos + 1 ; i = pos - 1 ; vd [ 0 ] . Add ( arr [ pos ] ) ; while ( i >= 0 ) { vd [ pos - i ] . Add ( arr [ i ] ) ; -- i ; } while ( j < n ) { vd [ j - pos ] . Add ( arr [ j ] ) ; ++ j ; } for ( i = 0 ; i <= Math . Max ( pos , n - pos - 1 ) ; ++ i ) { vd [ i ] . Sort ( ) ; for ( j = 0 ; j < vd [ i ] . Count ; j ++ ) { int element = ( int ) vd [ i ] [ j ] ; Console . Write ( element + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 14 , 1101 , 10 , 35 , 0 } ; int K = 35 ; int n = arr . Length ; distanceSort ( arr , K , n ) ; } }

Index/key variables: i, j, n, pos
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ ] find ( int dividend , int divisor , int start , int end ) { if ( start > end ) return new int [ ] { 0 , dividend } ; int mid = start + ( end - start ) / 2 ; int n = dividend - divisor * mid ; if ( n > divisor ) start = mid + 1 ; else if ( n < 0 ) end = mid - 1 ; else { if ( n == divisor ) { ++ mid ; n = 0 ; } return new int [ ] { mid , n } ; } return find ( dividend , divisor , start , end ) ; } static int [ ] divide ( int dividend , int divisor ) { return find ( dividend , divisor , 1 , dividend ) ; } public static void Main ( String [ ] args ) { int dividend = 10 , divisor = 3 ; int [ ] ans = divide ( dividend , divisor ) ; Console . Write ( ans [ 0 ] + " , ▁ " ) ; Console . Write ( ans [ 1 ] + " STRNEWLINE " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countTriplets ( int [ ] a , int n , int x ) { int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { int [ ] temp = { a [ i ] , a [ j ] , a [ k ] } ; Array . Sort ( temp ) ; if ( temp [ 0 ] < temp [ 1 ] && temp [ 1 ] < temp [ 2 ] && temp [ 0 ] * temp [ 1 ] * temp [ 2 ] <= x ) answer ++ ; } } } return answer ; } public static void Main ( ) { int [ ] A = { 3 , 2 , 5 , 7 } ; int N = A . Length ; int X = 42 ; Console . WriteLine ( countTriplets ( A , N , X ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: answer, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int log ( int a , int b ) { return ( int ) ( Math . Log10 ( a ) / Math . Log10 ( b ) ) ; } static int get ( int a , int b , int n ) { int lo = 0 , hi = ( int ) 1e6 ; int ans = 0 ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; int dig = ( int ) Math . Ceiling ( ( double ) ( mid * log ( mid , b ) + log ( a , b ) ) ) ; if ( dig > n ) { hi = mid - 1 ; } else { ans = mid ; lo = mid + 1 ; } } return ans ; } public static void Main ( String [ ] args ) { int a = 2 , b = 2 , n = 6 ; Console . Write ( get ( a , b , n ) + " STRNEWLINE " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void findMaxMatrixSize ( int [ , ] arr , int K ) { int i , j ; int n = arr . GetLength ( 0 ) ; int m = arr . GetLength ( 1 ) ; int [ , ] sum = new int [ n + 1 , m + 1 ] ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= m ; j ++ ) { if ( i == 0 j == 0 ) { sum [ i , j ] = 0 ; continue ; } sum [ i , j ] = arr [ i - 1 , j - 1 ] + sum [ i - 1 , j ] + sum [ i , j - 1 ] - sum [ i - 1 , j - 1 ] ; } } int ans = 0 ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j <= m ; j ++ ) { if ( i + ans - 1 > n j + ans - 1 > m ) break ; int mid , lo = ans ; int hi = Math . Min ( n - i + 1 , m - j + 1 ) ; while ( lo < hi ) { mid = ( hi + lo + 1 ) / 2 ; if ( sum [ i + mid - 1 , j + mid - 1 ] + sum [ i - 1 , j - 1 ] - sum [ i + mid - 1 , j - 1 ] - sum [ i - 1 , j + mid - 1 ] <= K ) { lo = mid ; } else { hi = mid - 1 ; } } ans = Math . Max ( ans , lo ) ; } } Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , 1 , 3 , 2 , 4 , 3 , 2 } , { 1 , 1 , 3 , 2 , 4 , 3 , 2 } , { 1 , 1 , 3 , 2 , 4 , 3 , 2 } } ; int K = 4 ; findMaxMatrixSize ( arr , K ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void FindRank ( int [ ] arr , int length ) { Console . Write ( "1" + " ▁ " ) ; for ( int i = 1 ; i < arr . Length ; i ++ ) { int rank = 1 ; for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ j ] > arr [ i ] ) rank ++ ; } Console . Write ( rank + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 88 , 14 , 69 , 30 , 29 , 89 } ; int len = arr . Length ; FindRank ( arr , len ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, rank
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int longestPermutation ( int [ ] arr , int n ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . ContainsKey ( arr [ i ] ) ) { freq [ arr [ i ] ] = freq [ arr [ i ] ] + 1 ; } else { freq . Add ( arr [ i ] , 1 ) ; } } int len = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! freq . ContainsKey ( i ) ) { break ; } len ++ ; } return len ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 , 6 , 5 } ; int n = arr . Length ; Console . Write ( longestPermutation ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 100005 ; static HashSet < int > fib = new HashSet < int > ( ) ; static void fibonacci ( ) { int prev = 0 , curr = 1 , len = 2 ; fib . Add ( prev ) ; fib . Add ( curr ) ; while ( len <= MAX ) { int temp = curr + prev ; fib . Add ( temp ) ; prev = curr ; curr = temp ; len ++ ; } } static void findFibonacci ( int N ) { for ( int i = N / 2 ; i > 1 ; i -- ) { if ( fib . Contains ( i ) && fib . Contains ( N - i ) ) { Console . WriteLine ( i + " ▁ " + ( N - i ) ) ; return ; } } Console . WriteLine ( " - 1" ) ; } public static void Main ( String [ ] args ) { fibonacci ( ) ; int sum = 199 ; findFibonacci ( sum ) ; } }

Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int MAX = 100005 ; static HashSet < int > fibonacci = new HashSet < int > ( ) ; static void createHash ( ) { int prev = 0 , curr = 1 ; fibonacci . Add ( prev ) ; fibonacci . Add ( curr ) ; while ( curr <= MAX ) { int temp = curr + prev ; fibonacci . Add ( temp ) ; prev = curr ; curr = temp ; } } static bool checkArray ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( fibonacci . Contains ( arr [ i ] ) ) sum += arr [ i ] ; if ( fibonacci . Contains ( sum ) ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 8 , 2 } ; int n = arr . Length ; createHash ( ) ; if ( checkArray ( arr , n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000005 ; static int [ ] fibUpto = new int [ MAX + 1 ] ; static void compute ( int sz ) { bool [ ] isFib = new bool [ sz + 1 ] ; int prev = 0 , curr = 1 ; isFib [ prev ] = isFib [ curr ] = true ; while ( curr <= sz ) { int temp = curr + prev ; if ( temp <= sz ) isFib [ temp ] = true ; prev = curr ; curr = temp ; } fibUpto [ 0 ] = 1 ; for ( int i = 1 ; i <= sz ; i ++ ) { fibUpto [ i ] = fibUpto [ i - 1 ] ; if ( isFib [ i ] ) fibUpto [ i ] ++ ; } } static int countOfNumbers ( int N , int K ) { compute ( N ) ; int low = 1 , high = N , ans = 0 ; while ( low <= high ) { int mid = ( low + high ) >> 1 ; if ( mid - fibUpto [ mid ] >= K ) { ans = mid ; high = mid - 1 ; } else low = mid + 1 ; } return ( ans > 0 ? N - ans + 1 : 0 ) ; } public static void Main ( ) { int N = 10 , K = 3 ; Console . WriteLine ( countOfNumbers ( N , K ) ) ; } }

Index/key variables: curr, i, mid, prev, temp
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 100001 ; static int [ , ] f = new int [ 26 , N ] ; static void precompute ( String s , int n ) { for ( int i = 0 ; i < n ; i ++ ) { f [ s [ i ] - ' a ' , i ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { f [ i , j ] += f [ i , j - 1 ] ; } } } static int palindromicSubsequencesUtil ( int L , int R ) { int c = 0 , ok = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int cnt = f [ i , R ] ; if ( L > 0 ) cnt -= f [ i , L - 1 ] ; if ( cnt > 1 ) { ok = 1 ; c = i ; break ; } } if ( ok == 0 ) { return - 1 ; } return c ; } static void palindromicSubsequences ( int [ , ] Q , int l ) { for ( int i = 0 ; i < l ; i ++ ) { int x = palindromicSubsequencesUtil ( Q [ i , 0 ] , Q [ i , 1 ] ) ; if ( x == - 1 ) { Console . Write ( - 1 + " STRNEWLINE " ) ; } else { char c = ( char ) ( ' a ' + x ) ; Console . Write ( ( char ) c + " " + ( char ) c + " STRNEWLINE " ) ; } } } public static void Main ( String [ ] args ) { String str = " dbdeke " ; int [ , ] Q = { { 0 , 5 } , { 1 , 5 } , { 1 , 3 } } ; int n = str . Length ; int l = Q . GetLength ( 0 ) ; precompute ( str , n ) ; palindromicSubsequences ( Q , l ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static readonly int N = 100000 ; 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 int longestFibSubarray ( int [ ] arr , int n ) { int max_val = arr . Max ( ) ; HashSet < int > hash = new HashSet < int > ( ) ; createHash ( hash , max_val ) ; int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; int fibcount = 0 , res = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { left [ i ] = fibcount ; if ( hash . Contains ( arr [ i ] ) ) { fibcount ++ ; } else fibcount = 0 ; } fibcount = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { right [ i ] = fibcount ; if ( hash . Contains ( arr [ i ] ) ) { fibcount ++ ; } else fibcount = 0 ; } for ( int i = 0 ; i < n ; i ++ ) res = Math . Max ( res , left [ i ] + right [ i ] ) ; return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 8 , 5 , 7 , 3 , 5 , 7 } ; int n = arr . Length ; Console . Write ( longestFibSubarray ( arr , n ) + " STRNEWLINE " ) ; } }

Index/key variables: i, n
Accumulator variables: fibcount, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPrime ( int N ) { if ( N < 2 ) return false ; if ( N < 4 ) return true ; if ( ( N & 1 ) == 0 ) return false ; if ( N % 3 == 0 ) return false ; int curr = 5 , s = ( int ) Math . Sqrt ( N ) ; while ( curr <= s ) { if ( N % curr == 0 ) return false ; curr += 2 ; if ( N % curr == 0 ) return false ; curr += 4 ; } return true ; } static bool check ( int s , int p , int [ ] prefix_sum , int n ) { bool satisfies = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( i + s - 1 >= n ) break ; if ( prefix_sum [ i + s - 1 ] - ( i - 1 >= 0 ? prefix_sum [ i - 1 ] : 0 ) < p ) satisfies = false ; } return satisfies ; } static int minimumWindowSize ( int x , int y , int p ) { int [ ] prefix_sum = new int [ y - x + 1 ] ; for ( int i = x ; i <= y ; i ++ ) { if ( isPrime ( i ) ) prefix_sum [ i - x ] = 1 ; } for ( int i = 1 ; i < y - x + 1 ; i ++ ) prefix_sum [ i ] += prefix_sum [ i - 1 ] ; int low = 1 , high = y - x + 1 ; int mid ; while ( high - low > 1 ) { mid = ( low + high ) / 2 ; if ( check ( mid , p , prefix_sum , y - x + 1 ) ) { high = mid ; } else low = mid ; } if ( check ( low , p , prefix_sum , y - x + 1 ) ) return low ; return high ; } public static void Main ( String [ ] args ) { int x = 12 ; int y = 42 ; int p = 3 ; Console . Write ( minimumWindowSize ( x , y , p ) ) ; } }

Index/key variables: i
Accumulator variables: curr, i
Iterator variables: i
Boolean variables: satisfies
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int xorOfSum ( int [ ] a , int n ) { int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) answer ^= ( a [ i ] + a [ j ] ) ; } return answer ; } public static void Main ( String [ ] args ) { int n = 3 ; int [ ] A = { 1 , 2 , 3 } ; Console . Write ( xorOfSum ( A , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static readonly int N = 4 ; static readonly int M = 5 ; static void preProcess ( int [ , ] mat , int [ , ] aux ) { for ( int i = 0 ; i < M ; i ++ ) aux [ 0 , i ] = mat [ 0 , i ] ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 0 ; j < M ; j ++ ) aux [ i , j ] = mat [ i , j ] + aux [ i - 1 , j ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 1 ; j < M ; j ++ ) aux [ i , j ] += aux [ i , j - 1 ] ; } static int sumQuery ( int [ , ] aux , int tli , int tlj , int rbi , int rbj ) { int res = aux [ rbi , rbj ] ; if ( tli > 0 ) res = res - aux [ tli - 1 , rbj ] ; if ( tlj > 0 ) res = res - aux [ rbi , tlj - 1 ] ; if ( tli > 0 && tlj > 0 ) res = res + aux [ tli - 1 , tlj - 1 ] ; return res ; } static int maximumSquareSize ( int [ , ] mat , int K ) { int [ , ] aux = new int [ N , M ] ; preProcess ( mat , aux ) ; for ( int i = Math . Min ( N , M ) ; i >= 1 ; i -- ) { bool satisfies = true ; for ( int x = 0 ; x < N ; x ++ ) { for ( int y = 0 ; y < M ; y ++ ) { if ( x + i - 1 <= N - 1 && y + i - 1 <= M - 1 ) { if ( sumQuery ( aux , x , y , x + i - 1 , y + i - 1 ) > K ) satisfies = false ; } } } if ( satisfies == true ) return ( i ) ; } return 0 ; } public static void Main ( String [ ] args ) { int K = 30 ; int [ , ] mat = { { 1 , 2 , 3 , 4 , 6 } , { 5 , 3 , 8 , 1 , 2 } , { 4 , 6 , 7 , 5 , 5 } , { 2 , 4 , 8 , 9 , 4 } } ; Console . Write ( maximumSquareSize ( mat , K ) ) ; } }

Accumulator variables: i, j, x, y
Iterator variables: i, j, x, y
Boolean variables: satisfies
Class/struct names: GFG
C# program:
using System ; 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 findFibonacciPair ( int n ) { HashSet < int > hash = new HashSet < int > ( ) ; createHash ( hash , n ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash . Contains ( i ) && hash . Contains ( n - i ) ) { Console . Write ( i + " , ▁ " + ( n - i ) + " STRNEWLINE " ) ; return ; } } Console . Write ( " - 1 STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int N = 90 ; findFibonacciPair ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void add_factors ( int n , Dictionary < int , int > mp ) { for ( int i = 1 ; i <= ( Math . Sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { if ( mp . ContainsKey ( i ) ) mp [ i ] = mp [ i ] + 1 ; else mp . Add ( i , 1 ) ; } else { if ( mp . ContainsKey ( i ) ) mp [ i ] = mp [ i ] + 1 ; else mp . Add ( i , 1 ) ; if ( mp . ContainsKey ( n / i ) ) mp [ n / i ] = mp [ n / i ] + 1 ; else mp . Add ( n / i , 1 ) ; } } } } static void count_divisors ( int [ ] a , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( ! mp . ContainsKey ( a [ i ] ) ? 0 + " ▁ " : mp [ a [ i ] ] + " ▁ " ) ; add_factors ( a [ i ] , mp ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 8 , 1 , 28 , 4 , 2 , 6 , 7 } ; int n = arr . Length ; count_divisors ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void removeDuplicates ( int [ ] arr , int n ) { int st = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < n - 2 && arr [ i ] == arr [ i + 1 ] && arr [ i ] == arr [ i + 2 ] ) continue ; else { arr [ st ] = arr [ i ] ; st ++ ; } } Console . Write ( " { " ) ; for ( int i = 0 ; i < st ; i ++ ) { Console . Write ( arr [ i ] ) ; if ( i != st - 1 ) Console . Write ( " , ▁ " ) ; } Console . Write ( " } " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 , 4 , 5 } ; int n = arr . Length ; removeDuplicates ( arr , n ) ; } }

Index/key variables: i, st
Accumulator variables: i, st
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool permutation ( int [ ] arr , int n ) { HashSet < int > hash = new HashSet < int > ( ) ; int maxEle = 0 ; for ( int i = 0 ; i < n ; i ++ ) { hash . Add ( arr [ i ] ) ; maxEle = Math . Max ( maxEle , arr [ i ] ) ; } if ( maxEle != n ) return false ; if ( hash . Count == n ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 5 , 3 , 2 } ; int n = arr . Length ; if ( permutation ( arr , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountSubSet ( int [ ] arr , int n , int X ) { int N = ( int ) Math . Pow ( 2 , n ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) if ( arr [ j ] == X ) count += 1 ; } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 5 , 6 , 7 } ; int X = 5 ; int n = arr . Length ; Console . Write ( CountSubSet ( arr , n , X ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculatePower ( int b , int e ) { int ans = 1 ; while ( e > 0 ) { if ( e % 2 == 1 ) ans = ans * b ; e = e / 2 ; b = b * b ; } return ans ; } static int CountSubSet ( int [ ] arr , int n , int X ) { int count = 0 , checkX = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == X ) { checkX = 1 ; break ; } } if ( checkX == 1 ) count = calculatePower ( 2 , n - 1 ) ; else count = 0 ; return count ; } public static void Main ( ) { int [ ] arr = { 4 , 5 , 6 , 7 } ; int X = 5 ; int n = arr . Length ; Console . WriteLine ( CountSubSet ( arr , n , X ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int [ ] height = { 1 , 2 , 1 , 2 } ; public static int woodCollected ( int n , int m ) { int sum = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( height [ i ] - m <= 0 ) break ; sum += ( height [ i ] - m ) ; } return sum ; } public static int collectKWood ( int n , int k ) { Array . Sort ( height ) ; int low = 0 , high = height [ n - 1 ] ; while ( low <= high ) { int mid = low + ( ( high - low ) / 2 ) ; int collected = woodCollected ( n , mid ) ; if ( collected == k ) return mid ; if ( collected > k ) low = mid + 1 ; else high = mid - 1 ; } return - 1 ; } public static void Main ( ) { int k = 2 ; int n = height . Length ; Console . WriteLine ( collectKWood ( n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 10 ; static bool isDigit ( char ch ) { if ( ch >= '0' && ch <= '9' ) return true ; return false ; } static bool allDigits ( String str , int len ) { bool [ ] present = new bool [ MAX ] ; for ( int i = 0 ; i < len ; i ++ ) { if ( isDigit ( str [ i ] ) ) { int digit = str [ i ] - '0' ; present [ digit ] = true ; } } for ( int i = 0 ; i < MAX ; i ++ ) { if ( ! present [ i ] ) return false ; } return true ; } public static void Main ( String [ ] args ) { String str = " Geeks12345for69708" ; int len = str . Length ; if ( allDigits ( str , len ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: MAX, digit, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isPlusPossible ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } } bool foundModOne = false ; foreach ( KeyValuePair < int , int > x in mp ) { int element = x . Key ; int frequency = x . Value ; if ( frequency % 4 == 0 ) continue ; if ( frequency % 4 == 1 ) { if ( foundModOne ) return false ; foundModOne = true ; } else return false ; } return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 2 } ; int n = arr . Length ; if ( isPlusPossible ( arr , n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, x
Boolean variables: foundModOne
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > merge ( List < int > v1 , List < int > v2 ) { int i = 0 , j = 0 ; List < int > v = new List < int > ( ) ; while ( i < v1 . Count && j < v2 . Count ) { if ( v1 [ i ] <= v2 [ j ] ) { v . Add ( v1 [ i ] ) ; i ++ ; } else { v . Add ( v2 [ j ] ) ; j ++ ; } } for ( int k = i ; k < v1 . Count ; k ++ ) v . Add ( v1 [ k ] ) ; for ( int k = j ; k < v2 . Count ; k ++ ) v . Add ( v2 [ k ] ) ; return v ; } static void buildTree ( List < int > [ ] tree , int [ ] arr , int index , int s , int e ) { if ( s == e ) { tree [ index ] . Add ( arr [ s ] ) ; return ; } int mid = ( s + e ) / 2 ; buildTree ( tree , arr , 2 * index , s , mid ) ; buildTree ( tree , arr , 2 * index + 1 , mid + 1 , e ) ; tree [ index ] = merge ( tree [ 2 * index ] , tree [ 2 * index + 1 ] ) ; } static int query ( List < int > [ ] tree , int index , int s , int e , int l , int r , int k ) { if ( r < s l > e ) return 0 ; if ( s >= l && e <= r ) { return ( tree [ index ] . Count - lowerBound ( tree [ index ] , tree [ index ] . Count , k ) ) ; } int mid = ( s + e ) / 2 ; return ( query ( tree , 2 * index , s , mid , l , r , k ) + query ( tree , 2 * index + 1 , mid + 1 , e , l , r , k ) ) ; } static void performQueries ( int [ ] L , int [ ] R , int [ ] K , int n , int q , List < int > [ ] tree ) { for ( int i = 0 ; i < q ; i ++ ) { Console . WriteLine ( query ( tree , 1 , 0 , n - 1 , L [ i ] - 1 , R [ i ] - 1 , K [ i ] ) ) ; } } static int lowerBound ( List < int > array , int length , int value ) { int low = 0 ; int high = length ; 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 [ ] arr = { 7 , 3 , 9 , 13 , 5 , 4 } ; int n = arr . Length ; List < int > [ ] tree = new List < int > [ 4 * n + 1 ] ; for ( int i = 0 ; i < ( 4 * n + 1 ) ; i ++ ) { tree [ i ] = new List < int > ( ) ; } buildTree ( tree , arr , 1 , 0 , n - 1 ) ; int [ ] L = { 1 , 2 } ; int [ ] R = { 4 , 6 } ; int [ ] K = { 6 , 8 } ; int q = L . Length ; performQueries ( L , R , K , n , q , tree ) ; } }

Index/key variables: i, index, j, k, mid, s
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG