dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MAX = 32 ; static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int pairs ( int [ ] arr , int n , int k ) { int count = 0 ; int [ ] f = new int [ MAX + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) f [ countSetBits ( arr [ i ] ) ] ++ ; for ( int i = 0 ; i <= MAX ; i ++ ) { for ( int j = i ; j <= MAX ; j ++ ) { if ( i + j == k ) { if ( i == j ) count += ( ( f [ i ] * ( f [ i ] - 1 ) ) / 2 ) ; else count += ( f [ i ] * f [ j ] ) ; } } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; int k = 4 ; Console . WriteLine ( pairs ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, n
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void LowerHessenbergMatrix ( int n ) { Random rand = new Random ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( j > i + 1 ) Console . Write ( 0 + " ▁ " ) ; else Console . Write ( rand . Next ( 1 , 10 ) + " ▁ " ) ; } Console . WriteLine ( ) ; } } static public void Main ( ) { int n = 4 ; LowerHessenbergMatrix ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void UpperHessenbergMatrix ( int n ) { Random rand = new Random ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( i > j + 1 ) Console . Write ( 0 + " ▁ " ) ; else Console . Write ( rand . Next ( 1 , 10 ) + " ▁ " ) ; } Console . WriteLine ( ) ; } } static public void Main ( ) { int n = 4 ; UpperHessenbergMatrix ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int composite_factors ( int n ) { int count = 0 ; int i , j ; int [ ] a = new int [ n + 1 ] ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = 0 ; } for ( i = 1 ; i <= n ; ++ i ) { if ( n % i == 0 ) { a [ i ] = i ; } } for ( i = 2 ; i <= n ; i ++ ) { j = 2 ; int p = 1 ; while ( j < a [ i ] ) { if ( a [ i ] % j == 0 ) { p = 0 ; break ; } j += 1 ; } if ( p == 0 && a [ i ] != 0 ) { count += 1 ; } } return count ; } public static void Main ( ) { int n = 100 ; Console . WriteLine ( composite_factors ( n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isMersenne ( int n ) { while ( n != 0 ) { int r = n % 2 ; if ( r == 0 ) return false ; n /= 2 ; } return true ; } static int sumOfMersenne ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 && isMersenne ( arr [ i ] ) ) { sum += arr [ i ] ; } } return sum ; } static public void Main ( ) { int [ ] arr = { 17 , 6 , 7 , 63 , 3 } ; int n = arr . Length ; Console . WriteLine ( sumOfMersenne ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, n, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int sumOfFactors ( int n ) { int sum = 0 ; for ( int f = 1 ; f <= n / 2 ; f ++ ) { if ( n % f == 0 ) { sum += f ; } } return sum ; } static int getSum ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 && arr [ i ] == sumOfFactors ( arr [ i ] ) ) { sum += arr [ i ] ; } } return sum ; } static public void Main ( ) { int [ ] arr = { 17 , 6 , 10 , 6 , 4 } ; int n = arr . Length ; Console . WriteLine ( getSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: f, i, sum
Iterator variables: f, i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool sameLength ( int A , int B ) { while ( ( A > 0 ) && ( B > 0 ) ) { A = A / 10 ; B = B / 10 ; } if ( ( A == 0 ) && ( B == 0 ) ) return true ; return false ; } static public void Main ( ) { int A = 21 , B = 1 ; if ( sameLength ( A , B ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 2 ; static int M = 2 ; static void Matrix ( char [ , ] a ) { char ch = '1' ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( a [ i , j ] == ' . ' ) a [ i , j ] = ch ; ch = ( ch == '1' ) ? '0' : '1' ; Console . Write ( a [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; if ( i % 2 == 0 ) ch = '0' ; else ch = '1' ; } } public static void Main ( String [ ] args ) { char [ , ] a = { { ' . ' , ' _ ' } , { ' _ ' , ' . ' } } ; Matrix ( a ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int cnt_neg ; static bool exists_zero ; static void preProcess ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) cnt_neg ++ ; if ( arr [ i ] == 0 ) exists_zero = true ; } } static bool isPossible ( int k ) { if ( ! exists_zero ) { if ( k >= cnt_neg && ( k - cnt_neg ) % 2 == 0 ) return true ; else return false ; } else { if ( k >= cnt_neg ) return true ; else return false ; } } static public void Main ( ) { int [ ] arr = { - 1 , 2 , - 3 , 4 , 5 } ; int n = arr . Length ; preProcess ( arr , n ) ; int [ ] queries = { 1 , 2 , 3 , 4 } ; int q = arr . Length ; for ( int i = 0 ; i < q ; i ++ ) { if ( isPossible ( queries [ i ] ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: cnt_neg, i
Iterator variables: i
Boolean variables: exists_zero
Class/struct names: GFG
C# program:
using System ; class GFG { static int FindXorSum ( int [ ] arr , int k , int n ) { if ( n < k ) return 0 ; int [ ] x = new int [ n ] ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 ) x [ i ] = x [ i - 1 ] ^ arr [ i ] ; else x [ i ] = arr [ i ] ; if ( i >= k - 1 ) { int sum = 0 ; sum = x [ i ] ; if ( i - k > - 1 ) sum ^= x [ i - k ] ; result += sum ; } } return result ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = 4 , k = 2 ; Console . WriteLine ( FindXorSum ( arr , k , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, result, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int reverse ( int n ) { int rev = 0 ; while ( n > 0 ) { int d = n % 10 ; rev = rev * 10 + d ; n = n / 10 ; } return rev ; } static bool isPalin ( int n ) { return ( n == reverse ( n ) ) ; } static int countDigits ( int n ) { int c = 0 ; while ( n > 0 ) { n = n / 10 ; c ++ ; } return c ; } static int countPalinDigits ( int [ ] arr , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 10 || isPalin ( arr [ i ] ) ) { s += countDigits ( arr [ i ] ) ; } } return s ; } public static void Main ( ) { int [ ] arr = { 121 , 56 , 434 } ; int n = arr . Length ; Console . WriteLine ( countPalinDigits ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: c, i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int reverse ( int n ) { int d = 0 , s = 0 ; while ( n > 0 ) { d = n % 10 ; s = s * 10 + d ; n = n / 10 ; } return s ; } static bool isPalin ( int n ) { return n == reverse ( n ) ; } static int sumOfArray ( int [ ] arr , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] > 10 ) && isPalin ( arr [ i ] ) ) { s += arr [ i ] ; } } return s ; } public static void Main ( String [ ] args ) { int n = 6 ; int [ ] arr = { 12 , 313 , 11 , 44 , 9 , 1 } ; Console . WriteLine ( sumOfArray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000000 ; static int [ ] prime = new int [ MAX + 1 ] ; static void updatePrimes ( ) { for ( int i = 2 ; i <= MAX ; i ++ ) { prime [ i ] = 1 ; } prime [ 0 ] = prime [ 1 ] = 0 ; for ( int i = 2 ; i * i <= MAX ; i ++ ) { if ( prime [ i ] == 1 ) { for ( int j = i * i ; j <= MAX ; j += i ) { prime [ j ] = 0 ; } } } for ( int i = 1 ; i <= MAX ; i ++ ) { prime [ i ] += prime [ i - 1 ] ; } } static int getDifference ( int l , int r ) { int total = r - l + 1 ; int primes = prime [ r ] - prime [ l - 1 ] ; int composites = total - primes ; return ( Math . Abs ( primes - composites ) ) ; } public static void Main ( ) { int [ , ] queries = { { 1 , 10 } , { 5 , 30 } } ; int q = queries . GetLength ( 0 ) ; updatePrimes ( ) ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( getDifference ( queries [ i , 0 ] , queries [ i , 1 ] ) ) ; } }

Index/key variables: i, j, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static double p = 1 , f = 1 ; static double e ( int x , int n ) { double r ; if ( n == 0 ) return 1 ; r = e ( x , n - 1 ) ; p = p * x ; f = f * n ; return ( r + p / f ) ; } static void Main ( ) { int x = 4 , n = 15 ; Console . WriteLine ( Math . Round ( e ( x , n ) , 6 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000000 ; static int [ ] Sieve = new int [ MAX + 1 ] ; static void constructSieve ( ) { for ( int i = 2 ; i <= MAX ; i ++ ) { if ( Sieve [ i ] == 0 ) { for ( int j = 2 * i ; j <= MAX ; j += i ) { int temp = j ; while ( temp > 1 && temp % i == 0 ) { Sieve [ j ] ++ ; temp = temp / i ; } } } } } static void checkElements ( int [ ] A , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( Sieve [ A [ i ] ] == k ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " No " ) ; } } } public static void Main ( ) { constructSieve ( ) ; int k = 3 ; int [ ] A = { 12 , 36 , 42 , 72 } ; int n = A . Length ; checkElements ( A , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int mod = 1000000007 ; static long modularexpo ( long x , long y , long p ) { long res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } static void multiply ( long [ , ] F , long [ , ] M , long m ) { long x = ( ( F [ 0 , 0 ] * M [ 0 , 0 ] ) % m + ( F [ 0 , 1 ] * M [ 1 , 0 ] ) % m ) % m ; long y = ( ( F [ 0 , 0 ] * M [ 0 , 1 ] ) % m + ( F [ 0 , 1 ] * M [ 1 , 1 ] ) % m ) % m ; long z = ( ( F [ 1 , 0 ] * M [ 0 , 0 ] ) % m + ( F [ 1 , 1 ] * M [ 1 , 0 ] ) % m ) % m ; long w = ( ( F [ 1 , 0 ] * M [ 0 , 1 ] ) % m + ( F [ 1 , 1 ] * M [ 1 , 1 ] ) % m ) % m ; F [ 0 , 0 ] = x ; F [ 0 , 1 ] = y ; F [ 1 , 0 ] = z ; F [ 1 , 1 ] = w ; } static void power ( long [ , ] F , long n , long m ) { if ( n == 0 n == 1 ) return ; long [ , ] M = { { 1 , 1 } , { 1 , 0 } } ; power ( F , n / 2 , m ) ; multiply ( F , F , m ) ; if ( n % 2 != 0 ) multiply ( F , M , m ) ; } static long fib ( long n , long m ) { long [ , ] F = { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n - 1 , m ) ; return F [ 0 , 0 ] ; } public static void Main ( String [ ] args ) { long n = 4 ; long Base = fib ( n , mod ) % mod ; long expo = fib ( n , mod - 1 ) % ( mod - 1 ) ; long result = modularexpo ( Base , expo , mod ) % mod ; Console . WriteLine ( result ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int cntWays ( int [ ] arr , int n ) { if ( n == 1 ) { return 0 ; } int tot_sum = 0 , sum = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { tot_sum += arr [ i ] ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += arr [ i ] ; if ( sum == tot_sum / 2 ) { ans ++ ; } } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , - 1 , 1 , - 1 , 1 , - 1 } ; int n = arr . Length ; Console . WriteLine ( cntWays ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, sum, tot_sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 32 ; static long [ ] pow2 = new long [ MAX ] ; static bool [ ] visited = new bool [ MAX ] ; static List < long > ans = new List < long > ( ) ; static void power_2 ( ) { long ans = 1 ; for ( int i = 0 ; i < MAX ; i ++ ) { pow2 [ i ] = ans ; ans *= 2 ; } } static int countSetBits ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } static void add ( long num ) { long value = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( visited [ i ] ) continue ; else { if ( num % 2 == 1 ) { value += ( 1 << i ) ; } num /= 2 ; } } ans . Add ( value ) ; } static void solve ( long n , long k ) { ans . Add ( k ) ; int countk = countSetBits ( k ) ; if ( pow2 [ countk ] < n ) { Console . WriteLine ( - 1 ) ; return ; } int count = 0 ; for ( long i = 0 ; i < pow2 [ countk ] - 1 ; i ++ ) { add ( i ) ; count ++ ; if ( count == n ) break ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } public static void Main ( ) { long n = 3 , k = 5 ; power_2 ( ) ; solve ( n , k ) ; } }

Index/key variables: MAX, countk, i
Accumulator variables: ans, count, i, num, setBits, value
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countX ( int a , int b ) { if ( b > a ) return 0 ; else if ( a == b ) return - 1 ; else { int x = a - b , ans = 0 ; for ( int i = 1 ; i * i <= x ; i ++ ) { if ( x % i == 0 ) { int d1 = i , d2 = b - 1 ; if ( i * i != x ) d2 = x / i ; if ( d1 > b ) ans ++ ; if ( d2 > b ) ans ++ ; } } return ans ; } } static public void Main ( ) { int a = 21 , b = 5 ; Console . WriteLine ( countX ( a , b ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long sumPowersK ( long n , long k ) { long sum = 0 , num = 1 ; while ( num <= n ) { sum += num ; num *= k ; } return sum ; } static long getSum ( long n , long k ) { long pwrK = sumPowersK ( n , k ) ; long sumAll = ( n * ( n + 1 ) ) / 2 ; return ( sumAll - pwrK ) ; } public static void Main ( ) { long n = 10 , k = 3 ; Console . WriteLine ( getSum ( n , k ) ) ; } }

Accumulator variables: num, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxPeople ( int p ) { int tmp = 0 , count = 0 ; for ( int i = 1 ; i * i <= p ; i ++ ) { tmp = tmp + ( i * i ) ; if ( tmp <= p ) count ++ ; else break ; } return count ; } public static void Main ( ) { int p = 14 ; Console . WriteLine ( maxPeople ( p ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int kN = 1000000 ; static int maxPeople ( int p ) { long [ ] sums = new long [ kN ] ; sums [ 0 ] = 0 ; for ( int i = 1 ; i < kN ; i ++ ) sums [ i ] = ( long ) ( i * i ) + sums [ i - 1 ] ; int it = lower_bound ( sums , 0 , kN , p ) ; if ( it > p ) { -- it ; } return it ; } private static int lower_bound ( long [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } public static void Main ( String [ ] args ) { int p = 14 ; Console . WriteLine ( maxPeople ( p ) ) ; } }

Index/key variables: i, kN, middle
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long squareSeries ( long n ) { return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } static long maxPeople ( long n ) { long low = 0 ; long high = 1000000L ; long ans = 0L ; while ( low <= high ) { long mid = low + ( ( high - low ) / 2 ) ; long value = squareSeries ( mid ) ; if ( value <= n ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } public static void Main ( String [ ] args ) { long p = 14 ; Console . Write ( maxPeople ( p ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int findIndex ( int [ ] a , int n , int k ) { int index = - 1 , max_ceil = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = ( a [ i ] + k - 1 ) / k ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] >= max_ceil ) { max_ceil = a [ i ] ; index = i ; } } return index ; } static public void Main ( ) { int [ ] arr = { 31 , 12 , 25 , 27 , 32 , 19 } ; int K = 5 ; int N = arr . Length ; Console . WriteLine ( findIndex ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAXN = 60 ; static int solveQuery ( int L , int X ) { int res ; int [ ] a = new int [ MAXN ] ; int [ ] b = new int [ L ] ; int refer = X , size_a = 0 ; while ( refer > 0 ) { a [ size_a ] = refer % 2 ; refer /= 2 ; size_a ++ ; } for ( int i = 0 ; i < Math . Min ( size_a , L ) ; i ++ ) { if ( a [ i ] == 1 ) b [ i ] = 0 ; else b [ i ] = 1 ; } for ( int i = Math . Min ( size_a , L ) ; i < L ; i ++ ) b [ i ] = 1 ; b [ L - 1 ] = 1 ; int temp = 0 , p = 1 ; for ( int i = 0 ; i < L ; i ++ ) { temp += b [ i ] * p ; p *= 2 ; } res = temp ^ X ; return res ; } static public void Main ( ) { int [ , ] queries = { { 2 , 5 } , { 3 , 15 } } ; int q = queries . Length ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( solveQuery ( queries [ i , 0 ] , queries [ i , 1 ] ) ) ; } }

Index/key variables: L, MAXN, i, size_a
Accumulator variables: i, p, refer, size_a, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int Count_Segment ( int [ ] p , int n ) { int count = 0 ; int [ ] upto = new int [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) upto [ i ] = 0 ; int j = 0 , curr = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( p [ i ] > p [ i - 1 ] && p [ i ] > p [ i + 1 ] ) { curr = p [ i ] ; j = i - 1 ; while ( j >= 0 && p [ j ] < curr ) { upto [ p [ j ] ] = curr ; j = j - 1 ; } j = i + 1 ; while ( j < n && p [ j ] < curr ) { if ( upto [ curr - p [ j ] ] == curr ) count += 1 ; j = j + 1 ; } } } return count ; } static public void Main ( ) { int [ ] p = { 3 , 4 , 1 , 5 , 2 } ; int n = p . Length ; Console . WriteLine ( Count_Segment ( p , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool solve ( int n , int k ) { if ( n >= ( k * ( k + 1 ) ) / 2 ) { return true ; } return false ; } static public void Main ( ) { int n = 12 , k = 4 ; if ( solve ( n , k ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( long a , long b ) { if ( a > 0 && b > 0 ) { Console . WriteLine ( " Positive " ) ; } else if ( a <= 0 && b >= 0 ) { Console . WriteLine ( " Zero " ) ; } else { long n = Math . Abs ( a - b ) + 1 ; if ( n % 2 == 0 ) { Console . WriteLine ( " Positive " ) ; } else { Console . WriteLine ( " Negative " ) ; } } } public static void Main ( ) { int a = - 10 , b = - 2 ; solve ( a , b ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int closetAND ( int [ ] arr , int n , int k ) { int ans = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { int X = arr [ i ] ; for ( int j = i ; j < n ; j ++ ) { X &= arr [ j ] ; ans = Math . Min ( ans , Math . Abs ( k - X ) ) ; } } return ans ; } public static void Main ( ) { int [ ] arr = { 4 , 7 , 10 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( closetAND ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: X, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int Rate ( int N1 , int N2 ) { float rate = ( N2 - N1 ) * 100 / N1 ; return ( int ) rate ; } static public void Main ( ) { int N1 = 100 , N2 = 120 ; Console . WriteLine ( Rate ( N1 , N2 ) + " ▁ % " ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static int getPrime ( int [ ] arr , int n ) { int max_val = arr . Max ( ) ; List < Boolean > prime = new List < Boolean > ( max_val + 1 ) ; for ( int i = 0 ; i < max_val + 1 ; i ++ ) prime . Insert ( i , true ) ; prime . Insert ( 1 , false ) ; prime . Insert ( 2 , false ) ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime . Insert ( i , false ) ; } } int maximum = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { maximum = Math . Max ( maximum , arr [ i ] ) ; } } return maximum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 10 , 15 , 7 , 6 , 8 , 13 } ; int n = arr . Length ; Console . WriteLine ( getPrime ( arr , n ) ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static long getMinNum ( int N ) { int lcm = 1 ; for ( int i = 2 ; i <= N ; i ++ ) lcm = ( ( i * lcm ) / ( __gcd ( i , lcm ) ) ) ; return ( lcm + 1 ) ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void Main ( ) { int N = 5 ; Console . WriteLine ( getMinNum ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static double maxEdges ( double N ) { double edges = 0 ; edges = Math . Floor ( ( N * N ) / 4 ) ; return edges ; } static public void Main ( ) { double N = 5 ; Console . WriteLine ( maxEdges ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSafe ( int N , int M , char [ ] str ) { int coll = 0 , colr = 0 , rowu = 0 , rowd = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' L ' ) { coll ++ ; if ( colr > 0 ) { colr -- ; } if ( coll == M ) { break ; } } else if ( str [ i ] == ' R ' ) { colr ++ ; if ( coll > 0 ) { coll -- ; } if ( colr == M ) { break ; } } else if ( str [ i ] == ' U ' ) { rowu ++ ; if ( rowd > 0 ) { rowd -- ; } if ( rowu == N ) { break ; } } else if ( str [ i ] == ' D ' ) { rowd ++ ; if ( rowu > 0 ) { rowu -- ; } if ( rowd == N ) { break ; } } } if ( Math . Abs ( rowd ) < N && Math . Abs ( rowu ) < N && Math . Abs ( coll ) < M && Math . Abs ( colr ) < M ) { return true ; } return false ; } public static void Main ( String [ ] args ) { int N = 1 , M = 1 ; String str = " R " ; if ( isSafe ( N , M , str . ToCharArray ( ) ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: coll, colr, i, rowd, rowu
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void Permutation ( int n , int k ) { int [ ] p = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) p [ i ] = i ; for ( int i = 1 ; i < n - k ; i ++ ) p [ i + 1 ] = i ; p [ 1 ] = n - k ; for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( p [ i ] + " ▁ " ) ; } static public void Main ( ) { int n = 5 , k = 2 ; Permutation ( n , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOnes ( int [ ] arr , int N ) { for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i ; j <= N ; j ++ ) { if ( j % i == 0 ) { if ( arr [ j - 1 ] == 0 ) { } else { } } } } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = new int [ 10 ] ; int ans = countOnes ( arr , N ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int validPosition ( int [ ] arr , int N , int K ) { int count = 0 , sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] + K ) > ( sum - arr [ i ] ) ) count ++ ; } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 6 , 7 } ; int K = 4 ; int N = arr . Length ; Console . WriteLine ( validPosition ( arr , N , K ) ) ; } }

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