dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void Query ( int [ ] arr , int N , int [ , ] Q ) { int mul = 1 ; int add = 0 ; for ( int i = 0 ; i < Q . GetLength ( 0 ) ; i ++ ) { if ( Q [ i , 0 ] == 0 ) { add = add + Q [ i , 1 ] ; } else if ( Q [ i , 0 ] == 1 ) { mul = mul * Q [ i , 1 ] ; add = add * Q [ i , 1 ] ; } else { int ans = arr [ Q [ i , 1 ] ] * mul + add ; Console . Write ( ans + " ▁ " ) ; } } } public static void Main ( ) { int [ ] arr = { 3 , 1 , 23 , 45 , 100 } ; int N = arr . Length ; int [ , ] Q = { { 1 , 2 } , { 0 , 10 } , { 2 , 3 } , { 1 , 5 } , { 2 , 4 } } ; Query ( arr , N , Q ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int nthFibo ( int n ) { double a = ( Math . Pow ( 5 , 0.5 ) + 1 ) / 2 ; double b = ( - 1 * ( Math . Pow ( 5 , 0.5 ) ) + 1 ) / 2 ; double r = Math . Pow ( 5 , 0.5 ) ; double ans = ( Math . Pow ( a , n ) - Math . Pow ( b , n ) ) / r ; return ( int ) ans ; } static int nearFibo ( int X ) { double a = ( Math . Pow ( 5 , 0.5 ) + 1 ) / 2 ; int n = ( int ) ( Math . Log ( ( Math . Pow ( 5 , 0.5 ) ) * X ) / Math . Log ( a ) ) ; int nth = nthFibo ( n ) ; int nplus = nthFibo ( n + 1 ) ; if ( Math . Abs ( X - nth ) < Math . Abs ( X - nplus ) ) return nth ; else return nplus ; } static int getCost ( int [ ] arr , int n ) { int cost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int fibo = nearFibo ( arr [ i ] ) ; cost += Math . Abs ( arr [ i ] - fibo ) ; } return cost ; } public static void Main ( String [ ] args ) { int [ ] arr = { 56 , 34 , 23 , 98 , 7 } ; int n = arr . Length ; Console . WriteLine ( getCost ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMaxPairSum ( int [ ] arr , int N , int K ) { int [ ] preMax = new int [ N ] ; preMax [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { preMax [ i ] = Math . Max ( preMax [ i - 1 ] , arr [ i ] ) ; } int res = Int32 . MinValue ; for ( int i = K ; i < N ; i ++ ) { res = Math . Max ( res , arr [ i ] + preMax [ i - K ] ) ; } return res ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 8 , 6 , 3 } ; int K = 3 ; int N = arr . Length ; Console . Write ( getMaxPairSum ( arr , N , K ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sumOfInfiniteAGP ( double a , double d , double r ) { double ans = a / ( 1 - r ) + ( d * r ) / ( 1 - r * r ) ; Console . Write ( ans ) ; } public static void Main ( ) { double a = 0 , d = 1 , r = 0.5 ; sumOfInfiniteAGP ( a , d , r ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int countPairs ( int [ ] arr , int N ) { int count = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] % arr [ j ] == 0 arr [ j ] % arr [ i ] == 0 ) { count ++ ; } } } return count ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 1 , 2 } ; int N = arr . Length ; Console . WriteLine ( countPairs ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int CountPairs ( int [ ] arr , int N ) { int res = 0 ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) mp [ arr [ i ] ] ++ ; else mp . Add ( arr [ i ] , 1 ) ; } foreach ( KeyValuePair < int , int > kvp in mp ) { int x = kvp . Key ; int y = kvp . Value ; if ( x == 1 ) { res += N - 1 ; continue ; } res += ( y * ( y - 1 ) ) / 2 ; for ( int j = 2 ; j <= Math . Sqrt ( x ) ; j ++ ) { if ( x % j == 0 ) { res += mp [ j ] ; if ( j != x / j ) res += mp [ x / j ] ; } } } return res ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 1 , 2 } ; int N = arr . Length ; Console . Write ( CountPairs ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j, kvp
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countbits ( int n ) { int count = 0 ; while ( n != 0 ) { if ( ( n & 1 ) != 0 ) count ++ ; n = n / 2 ; } return count ; } static int BitProduct ( int [ ] arr , int N ) { int product = 1 ; for ( int i = 0 ; i < N ; i ++ ) { int bits = countbits ( arr [ i ] ) ; product *= bits ; } return product ; } public static void Main ( string [ ] args ) { int [ ] arr = { 3 , 2 , 4 , 1 , 5 } ; int N = arr . Length ; Console . Write ( BitProduct ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, product
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void OddDivisorsSum ( int n , int q , int [ ] a , int [ , ] Query ) { int [ ] DP = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = ( int ) ( Math . Sqrt ( a [ i ] ) ) ; if ( x * x == a [ i ] ) DP [ i ] = a [ i ] ; } for ( int i = 1 ; i < n ; i ++ ) { DP [ i ] = DP [ i - 1 ] + DP [ i ] ; } for ( int i = 0 ; i < q ; i ++ ) { int l = Query [ i , 0 ] ; int r = Query [ i , 1 ] ; if ( l == 0 ) { Console . Write ( DP [ r ] + " ▁ " ) ; } else { Console . Write ( DP [ r ] - DP [ l - 1 ] + " ▁ " ) ; } } } public static void Main ( ) { int [ ] arr = { 2 , 4 , 5 , 6 , 9 } ; int N = arr . Length ; int Q = 3 ; int [ , ] Query = { { 0 , 2 } , { 1 , 3 } , { 1 , 4 } } ; OddDivisorsSum ( N , Q , arr , Query ) ; } }

Index/key variables: i, n, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findSubset ( List < int > arr ) { int N = arr . Count ; int i ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int totSum = 0 ; int s = 0 ; int flag = 0 ; List < int > ans = new List < int > ( ) ; for ( i = 0 ; i < arr . Count ; i ++ ) { totSum += arr [ i ] ; if ( mp . ContainsKey ( arr [ i ] ) ) mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; else mp . Add ( arr [ i ] , 1 ) ; } arr . Sort ( ) ; i = N - 1 ; while ( i >= 0 ) { int frq = mp [ arr [ i ] ] ; if ( ( frq + ans . Count ) < ( N - ( frq + ans . Count ) ) ) { for ( int k = 0 ; k < frq ; k ++ ) { ans . Add ( arr [ i ] ) ; totSum -= arr [ i ] ; s += arr [ i ] ; i -- ; } } else { i -= frq ; } if ( s > totSum ) { flag = 1 ; break ; } } if ( flag == 1 ) { for ( i = ans . Count - 1 ; i >= 0 ; i -- ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } else { Console . Write ( - 1 ) ; } } public static void Main ( ) { List < int > arr = new List < int > ( ) { 5 , 3 , 2 , 4 , 1 , 2 } ; findSubset ( arr ) ; } }

Index/key variables: i
Accumulator variables: i, k, s, totSum
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int minStepK ( int [ ] arr , int N , int K ) { int E = 0 ; int S = 0 ; for ( int i = 0 ; i < N ; i ++ ) { S += arr [ i ] ; if ( arr [ i ] % 2 == 0 ) E += 1 ; } if ( S >= K ) return 0 ; else if ( S + E < K ) return - 1 ; else return K - S ; } public static void Main ( ) { int [ ] arr = { 0 , 1 , 1 , 0 , 1 } ; int N = arr . Length ; int K = 4 ; Console . WriteLine ( minStepK ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: E, S, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int Rotate ( int n , int f ) { int temp = n ; int maxi = n ; int mini = n ; for ( int idx = 0 ; idx < 7 ; idx ++ ) { if ( temp % 2 == 1 ) { temp >>= 1 ; temp += ( int ) Math . Pow ( 2 , 7 ) ; } else temp >>= 1 ; mini = Math . Min ( mini , temp ) ; maxi = Math . Max ( maxi , temp ) ; } if ( f == 1 ) return ( maxi ) ; else return ( mini ) ; } static int calcMinDiff ( int [ ] arr , int n ) { int caseOne = 0 ; int sumOfodd = 0 ; int sumOfeven = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) sumOfodd += Rotate ( arr [ i ] , 0 ) ; else sumOfeven += Rotate ( arr [ i ] , 1 ) ; } caseOne = Math . Abs ( sumOfodd - sumOfeven ) ; int caseTwo = 0 ; sumOfodd = 0 ; sumOfeven = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) sumOfodd += Rotate ( arr [ i ] , 1 ) ; else sumOfeven += Rotate ( arr [ i ] , 0 ) ; } caseTwo = Math . Abs ( sumOfodd - sumOfeven ) ; return Math . Max ( caseOne , caseTwo ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 123 , 86 , 234 , 189 } ; int n = arr . Length ; Console . WriteLine ( ( calcMinDiff ( arr , n ) ) ) ; } }

Index/key variables: i
Accumulator variables: i, idx, sumOfeven, sumOfodd, temp
Iterator variables: i, idx
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumDiff ( int [ ] arr , int N ) { int res = arr [ 0 ] , sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; int min_diff = sum ; for ( int i = 0 ; i < N ; i ++ ) { if ( Math . Abs ( sum - ( arr [ i ] * N ) ) < min_diff ) { min_diff = Math . Abs ( sum - ( arr [ i ] * N ) ) ; res = arr [ i ] ; } } Console . Write ( res ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . Length ; minimumDiff ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int sum ( int [ ] arr , int N , int K ) { int sum = 0 ; List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { v . Add ( arr [ i ] ) ; } bool flag = false ; for ( int i = 0 ; i < v . Count ; i ++ ) { if ( ! flag && v [ i ] % K == 0 ) v . Add ( v [ i ] / K ) ; else { flag = true ; } sum = sum + v [ i % N ] ; } return sum ; } static void Main ( ) { int [ ] arr = { 4 , 6 , 8 , 2 } ; int K = 2 ; int N = arr . Length ; Console . WriteLine ( sum ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int primeDivisors ( int [ ] arr , int N ) { int K = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { K = Math . Max ( K , arr [ i ] ) ; } int [ ] prime = new int [ K + 1 ] ; prime [ 0 ] = 1 ; prime [ 1 ] = 1 ; for ( int i = 2 ; i < K + 1 ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = 2 * i ; j < K + 1 ; j += i ) { prime [ j ] = 1 ; } } } int [ ] factor = new int [ K + 1 ] ; factor [ 0 ] = 0 ; factor [ 1 ] = 1 ; for ( int i = 2 ; i < K + 1 ; i ++ ) { factor [ i ] += 1 ; for ( int j = i ; j < K + 1 ; j += i ) { factor [ j ] += 1 ; } } int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( prime [ factor [ arr [ i ] ] ] == 0 ) count ++ ; } return count ; } public static void Main ( ) { int [ ] arr = { 10 , 13 , 17 , 25 } ; int N = arr . Length ; Console . WriteLine ( primeDivisors ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void SieveOfEratosthenes ( int n , bool [ ] prime ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) { prime [ i ] = false ; } } } } static void countPrime ( int n ) { bool [ ] prime = new bool [ n + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) { prime [ i ] = true ; } SieveOfEratosthenes ( n , prime ) ; int [ ] dp = new int [ n + 1 ] ; for ( int i = 0 ; i < dp . Length ; i ++ ) { dp [ i ] = 0 ; } dp [ 1 ] = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { dp [ i ] += dp [ i - 1 ] ; if ( prime [ i ] == true && prime [ i - 2 ] == true ) { dp [ i ] ++ ; } } Console . Write ( dp [ n ] ) ; } static void Main ( ) { int N = 6 ; countPrime ( N ) ; } }

Index/key variables: i, n, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinSum ( int [ , ] mat , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int res = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( i != j ) { res |= mat [ i , j ] ; } } sum += res ; } return sum ; } public static void Main ( string [ ] args ) { int [ , ] mat = { { - 1 , 2 , 3 } , { 9 , - 1 , 7 } , { 4 , 5 , - 1 } } ; int N = mat . GetLength ( 0 ) ; Console . WriteLine ( findMinSum ( mat , N ) ) ; } }

Accumulator variables: i, j, res, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findGCD ( int a , int b ) { if ( b == 0 ) return a ; return findGCD ( b , a % b ) ; } static int findLCM ( int a , int b ) { return ( a * b ) / findGCD ( a , b ) ; } static void uniqueElementsLCM ( 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 ] ] ++ ; else freq . Add ( arr [ i ] , 1 ) ; } int lcm = 1 ; foreach ( KeyValuePair < int , int > kvp in freq ) { if ( kvp . Value == 1 ) { lcm = findLCM ( lcm , kvp . Key ) ; } } if ( lcm == 1 ) lcm = - 1 ; Console . Write ( lcm ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 1 , 3 , 3 , 4 } ; int N = arr . Length ; uniqueElementsLCM ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, kvp
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxAdjacentDifference ( List < int > A ) { int diff = 0 ; for ( int i = 1 ; i < A . Count ; i ++ ) { diff = Math . Max ( diff , A [ i ] - A [ i - 1 ] ) ; } return diff ; } static int MinimumValue ( int [ ] arr , int N ) { int MinValue = Int32 . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { List < int > new_arr = new List < int > ( ) ; for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) continue ; new_arr . Add ( arr [ j ] ) ; } MinValue = Math . Min ( MinValue , maxAdjacentDifference ( new_arr ) ) ; } return MinValue ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 3 , 7 , 8 } ; int N = arr . Length ; Console . WriteLine ( MinimumValue ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int mod = 1000000007 ; static int power ( int x , int y ) { int res = 1 ; x = x % mod ; while ( y > 0 ) { if ( ( y & 1 ) > 0 ) res = ( res * x ) % mod ; y = y >> 1 ; x = ( x * x ) % mod ; } return res ; } static int antisymmetricRelation ( int N ) { return ( power ( 2 , N ) * power ( 3 , ( N * N - N ) / 2 ) ) % mod ; } public static void Main ( ) { int N = 2 ; Console . Write ( antisymmetricRelation ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { const int mod = 1000000007 ; static int power ( int x , int y ) { int res = 1 ; x = x % mod ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % mod ; y = y >> 1 ; x = ( x * x ) % mod ; } return res ; } static int asymmetricRelation ( int N ) { return power ( 3 , ( N * N - N ) / 2 ) ; } public static void Main ( string [ ] args ) { int N = 2 ; Console . WriteLine ( asymmetricRelation ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void crossProduct ( int [ ] vect_A , int [ ] vect_B , int [ ] cross_P ) { cross_P [ 0 ] = vect_A [ 1 ] * vect_B [ 2 ] - vect_A [ 2 ] * vect_B [ 1 ] ; cross_P [ 1 ] = vect_A [ 2 ] * vect_B [ 0 ] - vect_A [ 0 ] * vect_B [ 2 ] ; cross_P [ 2 ] = vect_A [ 0 ] * vect_B [ 1 ] - vect_A [ 1 ] * vect_B [ 0 ] ; } static void checkCollinearity ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 ) { int [ ] A = { x1 , y1 , z1 } ; int [ ] B = { x2 , y2 , z2 } ; int [ ] cross_P = new int [ 3 ] ; crossProduct ( A , B , cross_P ) ; if ( cross_P [ 0 ] == 0 && cross_P [ 1 ] == 0 && cross_P [ 2 ] == 0 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( string [ ] args ) { int x1 = 4 , y1 = 8 , z1 = 12 ; int x2 = 8 , y2 = 16 , z2 = 24 ; checkCollinearity ( x1 , y1 , z1 , x2 , y2 , z2 ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static double kineticEnergy ( double M , double V ) { double KineticEnergy ; KineticEnergy = 0.5 * M * V * V ; return KineticEnergy ; } static double potentialEnergy ( double M , double H ) { double PotentialEnergy ; PotentialEnergy = M * 9.8 * H ; return PotentialEnergy ; } public static void Main ( ) { double M = 5.5 , H = 23.5 , V = 10.5 ; Console . WriteLine ( " Kinetic ▁ Energy ▁ = ▁ " + kineticEnergy ( M , V ) ) ; Console . Write ( " Potential ▁ Energy ▁ = ▁ " + potentialEnergy ( M , H ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void countPairs ( int [ ] arr , int N ) { int even = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; } if ( N - even >= 1 ) { Console . WriteLine ( even ) ; return ; } Console . WriteLine ( 0 ) ; } static void Main ( ) { int [ ] arr = { 5 , 4 , 7 , 2 } ; int N = arr . Length ; countPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: even, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void distribute ( int N , int K , int M , int [ ] arr ) { int [ ] distribution = new int [ N ] ; int ptr = K - 1 ; int rem = M ; while ( rem > 0 ) { if ( rem >= arr [ ptr ] ) { distribution [ ptr ] += arr [ ptr ] ; rem -= arr [ ptr ] ; } else { distribution [ ptr ] += rem ; rem = 0 ; } ptr = ( ptr + 1 ) % N ; } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( distribution [ i ] + " ▁ " ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 2 , 1 , 4 } ; int M = 11 , S = 2 ; int N = arr . Length ; distribute ( N , S , M , arr ) ; } }

Index/key variables: N, i, ptr
Accumulator variables: i, rem
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sumOfSquaredDifferences ( int [ ] arr , int N ) { int ans = 0 ; int sumA = 0 , sumB = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sumA += ( arr [ i ] * arr [ i ] ) ; sumB += arr [ i ] ; } sumA = N * sumA ; sumB = ( sumB * sumB ) ; ans = sumA - sumB ; Console . WriteLine ( ans ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 8 , 4 } ; int N = arr . Length ; sumOfSquaredDifferences ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sumA, sumB
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void waysToRemove ( int n , int m ) { int ans = 0 ; if ( m == 1 ) { Console . Write ( n ) ; return ; } for ( int d = 0 ; d >= 0 ; d ++ ) { int len = m + ( m - 1 ) * d ; if ( len > n ) break ; ans += ( n - len ) + 1 ; } Console . Write ( ans ) ; } static void Main ( ) { int N = 5 , M = 3 ; waysToRemove ( N , M ) ; } }

Accumulator variables: ans, d
Iterator variables: d
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countStairs ( int n , int x , int a , int b ) { int [ ] vis = new int [ n + 1 ] ; Array . Clear ( vis , 0 , vis . Length ) ; int [ ] moves = { + a , - a , + b , - b } ; Queue < int > q = new Queue < int > ( ) ; q . Enqueue ( x ) ; vis [ x ] = 1 ; while ( q . Count > 0 ) { int currentStair = q . Peek ( ) ; q . Dequeue ( ) ; for ( int j = 0 ; j < 4 ; j ++ ) { int newStair = currentStair + moves [ j ] ; if ( newStair > 0 && newStair <= n && vis [ newStair ] == 0 ) { q . Enqueue ( newStair ) ; vis [ newStair ] = 1 ; } } } int cnt = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( vis [ i ] == 1 ) cnt ++ ; Console . WriteLine ( cnt ) ; } public static void Main ( ) { int N = 10 , S = 2 , A = 5 , B = 7 ; countStairs ( N , S , A , B ) ; } }

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

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } static void minimumOperations ( int X , int Y ) { int GCD = gcd ( X , Y ) ; X = X / GCD ; Y = Y / GCD ; int count = 0 ; while ( X != Y ) { if ( Y > X ) { int t = X ; X = Y ; Y = t ; } if ( X % 2 == 0 ) { X = X / 2 ; } else if ( X % 3 == 0 ) { X = X / 3 ; } else if ( X % 5 == 0 ) { X = X / 5 ; } else { Console . WriteLine ( " - 1" ) ; return ; } count ++ ; } Console . WriteLine ( count ) ; } static public void Main ( ) { int X = 15 , Y = 20 ; minimumOperations ( X , Y ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( int [ ] a , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += a [ i ] ; } ans -= n ; for ( int x = 1 ; ; x ++ ) { int curPow = 1 , curCost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { curCost += Math . Abs ( a [ i ] - curPow ) ; curPow *= x ; } if ( curPow / x > ans + a [ n - 1 ] ) break ; ans = Math . Min ( ans , curCost ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 7 } ; int N = arr . Length ; Console . WriteLine ( minOperations ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, curCost, curPow, i, x
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int floorMod ( int a , int n ) { int q = ( int ) Math . Floor ( ( double ) a / n ) ; return a - n * q ; } static public void Main ( ) { int a , b ; a = 9 ; b = 4 ; Console . WriteLine ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + floorMod ( a , b ) ) ; a = - 9 ; b = 4 ; Console . WriteLine ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + floorMod ( a , b ) ) ; a = 9 ; b = - 4 ; Console . WriteLine ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + floorMod ( a , b ) ) ; a = - 9 ; b = - 4 ; Console . WriteLine ( a + " ▁ % ▁ " + b + " ▁ = ▁ " + floorMod ( a , b ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static void printArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static void nearestPowerDiff ( int [ ] arr , int N , int a , int b ) { for ( int i = 0 ; i < N ; i ++ ) { int log_a = ( int ) ( Math . Log ( arr [ i ] ) / Math . Log ( a ) ) ; int A = ( int ) ( Math . Pow ( a , log_a ) ) ; int B = ( int ) ( Math . Pow ( a , log_a + 1 ) ) ; if ( ( arr [ i ] - A ) < ( B - arr [ i ] ) ) log_a = A ; else log_a = B ; int log_b = ( int ) ( Math . Log ( arr [ i ] ) / Math . Log ( b ) ) ; A = ( int ) ( Math . Pow ( b , log_b ) ) ; B = ( int ) ( Math . Pow ( b , log_b + 1 ) ) ; if ( ( arr [ i ] - A ) < ( B - arr [ i ] ) ) log_b = A ; else log_b = B ; arr [ i ] = Math . Abs ( log_a - log_b ) ; } printArray ( arr , N ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , 12 , 25 } ; int A = 2 , B = 3 ; int N = arr . Length ; nearestPowerDiff ( arr , N , A , B ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int bitOr ( int [ ] arr , int N ) { int count = 0 ; int length = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { length ++ ; } else { if ( length != 0 ) { count += ( ( length ) * ( length + 1 ) ) / 2 ; } length = 0 ; } } count += ( ( length ) * ( length + 1 ) ) / 2 ; return count ; } static void Main ( ) { int [ ] arr = { 1 , 5 , 4 , 2 , 6 } ; int N = arr . Length ; Console . Write ( bitOr ( arr , N ) ) ; } }

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