dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { static void build_tree ( int [ ] b , int [ ] seg_tree , int l , int r , int vertex ) { if ( l == r ) { seg_tree [ vertex ] = b [ l ] ; return ; } int mid = ( l + r ) / 2 ; build_tree ( b , seg_tree , l , mid , 2 * vertex ) ; build_tree ( b , seg_tree , mid + 1 , r , 2 * vertex + 1 ) ; seg_tree [ vertex ] = __gcd ( seg_tree [ 2 * vertex ] , seg_tree [ 2 * vertex + 1 ] ) ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static int range_gcd ( int [ ] seg_tree , int v , int tl , int tr , int l , int r ) { if ( l > r ) return 0 ; if ( l == tl && r == tr ) return seg_tree [ v ] ; int tm = ( tl + tr ) / 2 ; return __gcd ( range_gcd ( seg_tree , 2 * v , tl , tm , l , Math . Min ( tm , r ) ) , range_gcd ( seg_tree , 2 * v + 1 , tm + 1 , tr , Math . Max ( tm + 1 , l ) , r ) ) ; } static void maxSubarrayLen ( int [ ] arr , int n ) { int [ ] seg_tree = new int [ 4 * ( n ) + 1 ] ; build_tree ( arr , seg_tree , 0 , n - 1 , 1 ) ; int maxLen = 0 ; int l = 0 , r = 0 ; while ( r < n && l < n ) { if ( range_gcd ( seg_tree , 1 , 0 , n - 1 , l , r ) == 1 ) { l ++ ; } maxLen = Math . Max ( maxLen , r - l + 1 ) ; r ++ ; } Console . Write ( maxLen ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 410 , 52 , 51 , 180 , 222 , 33 , 33 } ; int N = arr . Length ; maxSubarrayLen ( arr , N ) ; } }

Index/key variables: l, v, vertex
Accumulator variables: l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static void findAandB ( int N ) { int K = ( int ) ( Math . Log ( N ) / Math . Log ( 2 ) ) ; int B = ( 1 << K ) ; int A = B ^ N ; Console . Write ( A + " ▁ " + B ) ; } public static void Main ( String [ ] args ) { int N = 26 ; findAandB ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void findValuesOfK ( int g ) { int count = 0 ; for ( int i = 1 ; i * i <= g ; i ++ ) { if ( g % i == 0 ) { if ( i != g / i ) { if ( i % 2 == 1 ) { count ++ ; } if ( ( g / i ) % 2 == 1 ) { count ++ ; } } else if ( i % 2 == 1 ) { count ++ ; } } } Console . WriteLine ( count ) ; } public static void Main ( ) { int G = 125 ; findValuesOfK ( G ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static double Avgdifference ( double [ ] arr , int N , int K ) { double sum = 0 ; for ( int i = 0 ; i < K ; i ++ ) sum += arr [ i ] ; double min = sum ; double max = sum ; for ( int i = K ; i <= N - K + 1 ; i ++ ) { sum += arr [ i ] - arr [ i - K ] ; if ( min > sum ) min = sum ; if ( max < sum ) max = sum ; } return ( max - min ) / K ; } public static void Main ( String [ ] args ) { double [ ] arr = { 3 , 8 , 9 , 15 } ; int N = arr . Length ; int K = 2 ; Console . Write ( Avgdifference ( arr , N , K ) ) ; } }

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 void findSet ( int N , int K ) { List < int > a = new List < int > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i != K ) a . Add ( i ) ; } int MaxDistinct = ( N - K ) + ( K / 2 ) ; a . Reverse ( ) ; for ( int i = 0 ; i < MaxDistinct ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; } public static void Main ( ) { int N = 5 , K = 3 ; findSet ( N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static long [ ] ExtendedEuclidAlgo ( long a , long b ) { if ( a == 0 ) { return new long [ ] { b , 0 , 1 } ; } else { long x1 = 1 , y1 = 1 ; long [ ] gcdy = ExtendedEuclidAlgo ( b % a , a ) ; long gcd = gcdy [ 0 ] ; x1 = gcdy [ 1 ] ; y1 = gcdy [ 2 ] ; long y = x1 ; long x = y1 - ( long ) ( b / a ) * x1 ; return new long [ ] { gcd , x , y } ; } } public static void linearCongruence ( long A , long B , long N ) { A = A % N ; B = B % N ; long u = 0 , v = 0 ; long [ ] person = ExtendedEuclidAlgo ( A , N ) ; long d = person [ 0 ] ; u = person [ 1 ] ; v = person [ 2 ] ; if ( B % d != 0 ) { Console . WriteLine ( - 1 ) ; return ; } long x0 = ( u * ( B / d ) ) % N ; if ( x0 < 0 ) x0 += N ; for ( long i = 0 ; i <= d - 1 ; i ++ ) { long an = ( x0 + i * ( N / d ) ) % N ; Console . Write ( an + " ▁ " ) ; } } static public void Main ( ) { long A = 15 ; long B = 9 ; long N = 18 ; linearCongruence ( A , B , N ) ; } }

Accumulator variables: i, x0
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int factorialWithoutMul ( int N ) { int ans = N ; for ( int i = N - 1 ; i > 0 ; i -- ) { int sum = 0 ; for ( int j = 0 ; j < i ; j ++ ) sum += ans ; ans = sum ; } return ans ; } public static void Main ( ) { int N = 5 ; Console . Write ( factorialWithoutMul ( N ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void tripletAndSum ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { ans += arr [ i ] & arr [ j ] & arr [ k ] ; } } } Console . WriteLine ( ans ) ; } static public void Main ( ) { int [ ] arr = { 3 , 5 , 4 , 7 } ; int N = arr . Length ; tripletAndSum ( arr , N ) ; } }

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int tripletAndSum ( int [ ] arr , int n ) { int ans = 0 ; for ( int bit = 0 ; bit < 32 ; bit ++ ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & ( 1 << bit ) ) != 0 ) cnt ++ ; } ans += ( 1 << bit ) * cnt * ( cnt - 1 ) * ( cnt - 2 ) / 6 ; } return ans ; } public static void Main ( ) { int [ ] arr = { 3 , 5 , 4 , 7 } ; int N = arr . Length ; Console . Write ( tripletAndSum ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, bit, cnt, i
Iterator variables: bit, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void smallestPermutation ( int [ ] arr , int N ) { bool [ ] w = new bool [ 2 * N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ arr [ i ] ] = true ; } HashSet < int > S = new HashSet < int > ( ) ; for ( int i = 1 ; i <= 2 * N ; i ++ ) { if ( ! w [ i ] ) S . Add ( i ) ; } bool found = true ; List < int > P = new List < int > ( ) ; int [ ] p = { 4 , 5 , 1 , 2 , 3 , 6 } ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . Contains ( arr [ i ] ) ) { found = false ; break ; } P . Add ( arr [ i ] ) ; P . Add ( arr [ i ] ) ; S . Remove ( arr [ i ] ) ; } if ( ! found ) { Console . WriteLine ( " - 1" ) ; } else { for ( int i = 0 ; i < 2 * N ; i ++ ) Console . Write ( p [ i ] + " ▁ " ) ; } } static void Main ( ) { int [ ] arr = { 4 , 1 , 3 } ; int N = arr . Length ; smallestPermutation ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: found
Class/struct names: GFG
C# program:
using System . Collections . Generic ; using System ; class GFG { static void maximumSubsequenceSum ( int [ ] A , int N ) { int ans = 0 ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( A [ i ] - i ) ) mp [ A [ i ] - i ] += A [ i ] ; else mp [ A [ i ] - i ] = A [ i ] ; ans = Math . Max ( ans , mp [ A [ i ] - i ] ) ; } Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 10 , 7 , 1 , 9 , 10 , 1 } ; int N = A . Length ; maximumSubsequenceSum ( A , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void nearestPerfectSquare ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int sr = ( int ) Math . Sqrt ( arr [ i ] ) ; int a = sr * sr ; int b = ( sr + 1 ) * ( sr + 1 ) ; if ( ( arr [ i ] - a ) < ( b - arr [ i ] ) ) Console . Write ( a + " ▁ " ) ; else Console . Write ( b + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 5 , 2 , 7 , 13 } ; int N = arr . Length ; nearestPerfectSquare ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool [ ] prime = new bool [ 100001 ] ; static void SieveOfEratosthenes ( int n ) { for ( int i = 0 ; i < 100001 ; i ++ ) prime [ i ] = true ; 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 NumberofSets ( int N ) { SieveOfEratosthenes ( N ) ; if ( N == 2 ) { Console . Write ( 1 ) ; } else if ( N == 3 ) { Console . Write ( 2 ) ; } else { int ans = 1 ; for ( int i = N / 2 + 1 ; i <= N ; i ++ ) { if ( prime [ i ] ) { ans += 1 ; } } Console . Write ( ans ) ; } } public static void Main ( ) { int N = 9 ; NumberofSets ( N ) ; } }

Index/key variables: i, p
Accumulator variables: ans, i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int floorDifference ( int [ ] A , int N , int X ) { int totalSum = 0 ; int perElementSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalSum += A [ i ] ; perElementSum += A [ i ] / X ; } int totalFloorSum = totalSum / X ; return Math . Abs ( totalFloorSum - perElementSum ) ; } static void Main ( ) { int [ ] A = { 1 , 2 , 3 , 4 , 5 , 6 } ; int X = 4 ; int N = A . Length ; Console . Write ( floorDifference ( A , N , X ) ) ; } }

Index/key variables: i
Accumulator variables: i, perElementSum, totalSum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int val ( char c ) { if ( c >= '0' && c <= '9' ) return ( int ) c - '0' ; else return ( int ) c - ' A ' + 10 ; } static int toDeci ( string str , int basse ) { int len = str . Length ; int power = 1 ; int num = 0 ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( val ( str [ i ] ) >= basse ) { Console . Write ( " Invalid ▁ Number " ) ; return - 1 ; } num += val ( str [ i ] ) * power ; power = power * basse ; } return num ; } static char reVal ( int num ) { if ( num >= 0 && num <= 9 ) return ( char ) ( num + '0' ) ; else return ( char ) ( num - 10 + ' A ' ) ; } static string fromDeci ( int basse , int inputNum ) { string res = " " ; while ( inputNum > 0 ) { res += reVal ( inputNum % basse ) ; inputNum /= basse ; } res = reverse ( res ) ; return res ; } static void convertbasse ( string s , int a , int b ) { int num = toDeci ( s , a ) ; string ans = fromDeci ( b , num ) ; Console . Write ( ans ) ; } static string reverse ( string input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return new string ( a ) ; } static public void Main ( ) { string s = "10B " ; int a = 16 , b = 10 ; convertbasse ( s , a , b ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, inputNum, l, num, r, res
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int fact ( int N ) { if ( N == 1 N == 0 ) return 1 ; return N * fact ( N - 1 ) ; } static void prefixFactorialArray ( int [ ] arr , int N ) { for ( int i = 1 ; i < N ; i ++ ) { arr [ i ] += arr [ i - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = fact ( arr [ i ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; prefixFactorialArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > removeEveryKth ( List < int > l , int k ) { for ( int i = 0 ; i < l . Count ; i ++ ) { if ( i % k == 0 ) l [ i ] = 0 ; } List < int > arr = new List < int > ( ) ; arr . Add ( 0 ) ; for ( int i = 1 ; i < l . Count ; i ++ ) { if ( l [ i ] != 0 ) arr . Add ( l [ i ] ) ; } return arr ; } static void printArray ( List < int > l ) { for ( int i = 1 ; i < l . Count ; i ++ ) Console . Write ( l [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } static void printSequence ( int n , int k ) { List < int > l = new List < int > ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) l . Add ( i ) ; int x = 1 ; for ( int i = 0 ; i < k ; i ++ ) { int p = l [ x ] + l [ x + 1 ] ; l = removeEveryKth ( l , p ) ; x += 1 ; } printArray ( l ) ; } public static void Main ( ) { int N = 8 ; int K = 2 ; printSequence ( N , K ) ; } }

Index/key variables: i, x
Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int makeEqual ( int [ ] arr , int n ) { int [ ] fre0 = new int [ 33 ] ; int [ ] fre1 = new int [ 33 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = arr [ i ] ; for ( int j = 0 ; j < 33 ; j ++ ) { if ( ( x & 1 ) != 0 ) { fre1 [ j ] += 1 ; } else { fre0 [ j ] += 1 ; } x = x >> 1 ; } } int ans = 0 ; for ( int i = 0 ; i < 33 ; i ++ ) { ans += Math . Min ( fre0 [ i ] , fre1 [ i ] ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 3 , 5 } ; int N = arr . Length ; Console . WriteLine ( makeEqual ( arr , N ) ) ; } }

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 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 ] ) ; } for ( int i = 0 ; i < v . Count ; i ++ ) { if ( v [ i ] % K == 0 ) { int x = v [ i ] / K ; for ( int j = 0 ; j < K ; j ++ ) { v . Add ( x ) ; } } else break ; } for ( int i = 0 ; i < v . Count ; i ++ ) sum = sum + v [ i ] ; return sum ; } public static void Main ( string [ ] args ) { 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, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void check ( int [ ] arr , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum == 0 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , - 1 , 3 , - 2 , - 1 } ; int N = arr . Length ; check ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void expectedValue ( int P , int a , int b , int N ) { double expValue = P + ( N * 0.5 * ( a + b ) ) ; Console . Write ( expValue ) ; } static void Main ( ) { int P = 3000 , a = 20 , b = 10 , N = 30 ; expectedValue ( P , a , b , N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int startingPoint ( int [ ] A , int N ) { int sum = 0 ; int ind = 0 ; int min = Int32 . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; if ( sum < min ) { min = sum ; ind = i + 1 ; } } if ( sum < 0 ) { return - 1 ; } return ind % N ; } public static void Main ( ) { int [ ] arr = { 3 , - 6 , 7 , - 4 , - 4 , 6 , - 1 } ; int N = arr . Length ; Console . Write ( startingPoint ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int nearestPow ( int x , int y ) { if ( y == 1 ) return 1 ; int k = ( int ) ( Math . Log ( x , y ) ) ; if ( Math . Abs ( Math . Pow ( y , k ) - x ) < Math . Abs ( Math . Pow ( y , ( k + 1 ) ) - x ) ) return ( int ) ( Math . Pow ( y , k ) ) ; return ( int ) ( Math . Pow ( y , ( k + 1 ) ) ) ; } static void replacebyNearestPower ( int [ ] arr ) { int prev = arr [ arr . Length - 1 ] ; int lastNext = arr [ 0 ] ; int next = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { int temp = arr [ i ] ; if ( i == arr . Length - 1 ) next = lastNext ; else next = arr [ ( i + 1 ) % arr . Length ] ; int prevPow = nearestPow ( arr [ i ] , prev ) ; int nextPow = nearestPow ( arr [ i ] , next ) ; if ( Math . Abs ( arr [ i ] - prevPow ) < Math . Abs ( arr [ i ] - nextPow ) ) arr [ i ] = prevPow ; else arr [ i ] = nextPow ; prev = temp ; } for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 1 , 2 } ; replacebyNearestPower ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool makeSumX ( int [ ] arr , int X , int S , int i ) { if ( i == arr . Length ) { return S == X ; } string a = Convert . ToString ( arr [ i ] ) ; int l = Int32 . Parse ( a . Substring ( 0 , a . Length - 1 ) ) ; int r = Int32 . Parse ( a . Substring ( 1 ) ) ; bool x = makeSumX ( arr , X , S + l , i + 1 ) ; bool y = makeSumX ( arr , X , S + r , i + 1 ) ; return ( x y ) ; } static void Check ( int [ ] arr , int X ) { if ( makeSumX ( arr , X , 0 , 0 ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } public static void Main ( ) { int [ ] arr = { 545 , 433 , 654 , 23 } ; int X = 134 ; Check ( arr , X ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPower ( int m , int y ) { int res1 = ( int ) Math . Log ( y ) / ( int ) Math . Log ( m ) ; double res2 = ( int ) Math . Log ( y ) / ( int ) Math . Log ( m ) ; return ( res1 == res2 ) ; } static int numSub ( int [ ] arr , int n , int m ) { int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPower ( m , arr [ i ] ) ) { cnt ++ ; ans += ( cnt * ( cnt - 1 ) ) / 2 ; } else { cnt = 0 ; } } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 1 , 3 } ; int m = 3 ; int n = arr . Length ; Console . Write ( numSub ( arr , n , m ) ) ; } }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int cntPairs ( int [ ] arr , int N ) { int res = 0 ; int [ ] bit = new int [ 32 ] ; for ( int i = 0 ; i < N ; i ++ ) { int pos = ( int ) ( Math . Log ( arr [ i ] ) / Math . Log ( 2 ) ) ; bit [ pos ] ++ ; } for ( int i = 0 ; i < 32 ; i ++ ) { res += ( bit [ i ] * ( bit [ i ] - 1 ) ) / 2 ; } return res ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; Console . Write ( cntPairs ( arr , N ) ) ; } }

Index/key variables: i, pos
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void minimumMEX ( int [ ] arr , int N , int K ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 1 ; i <= N + 1 ; i ++ ) s . Add ( i ) ; for ( int i = 0 ; i < K ; i ++ ) s . Remove ( arr [ i ] ) ; int mex = s . First ( ) ; for ( int i = K ; i < N ; i ++ ) { s . Remove ( arr [ i ] ) ; s . Add ( arr [ i - K ] ) ; int firstElem = s . First ( ) ; mex = Math . Min ( mex , firstElem ) ; } Console . Write ( mex + " ▁ " ) ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int K = 3 ; int N = arr . Length ; minimumMEX ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void smallerNumbers ( int [ ] arr , int N ) { int [ ] hash = new int [ 100000 ] ; for ( int i = 0 ; i < N ; i ++ ) hash [ arr [ i ] ] ++ ; for ( int i = 1 ; i < 100000 ; i ++ ) { hash [ i ] += hash [ i - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { Console . WriteLine ( "0" ) ; continue ; } Console . Write ( hash [ arr [ i ] - 1 ] + " ▁ " ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 3 , 4 , 1 , 1 , 2 } ; int N = arr . Length ; smallerNumbers ( arr , N ) ; } }

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

Class/struct names: GFG
C# program:
using System ; class GFG { static double average ( int [ ] arr , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; return ( double ) ( sum / N ) ; } static double mean ( int [ ] arr , int N ) { double avg = 0.0 ; for ( int i = 0 ; i < N ; i ++ ) { avg += ( ( double ) ( ( arr [ i ] - avg ) / ( i + 1 ) ) ) ; } return avg ; } static public void Main ( ) { int [ ] arr = { Int32 . MaxValue , 1 , 2 } ; int N = arr . Length ; Console . WriteLine ( " Average ▁ by ▁ Standard ▁ method : ▁ " + ( average ( arr , N ) ) . ToString ( " F10" ) ) ; Console . WriteLine ( " Average ▁ by ▁ Efficient ▁ method : ▁ " + ( mean ( arr , N ) ) . ToString ( " F10" ) ) ; } }

Index/key variables: i
Accumulator variables: avg, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countPairs ( int [ ] arr , int N ) { int count = 0 ; Dictionary < double , int > mp = new Dictionary < double , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { double val = 1.0 * arr [ i ] ; double idx = 1.0 * ( i + 1 ) ; if ( mp . ContainsKey ( val / idx ) ) count += mp [ val / idx ] ; if ( mp . ContainsKey ( val / idx ) ) mp [ val / idx ] ++ ; else mp [ val / idx ] = 1 ; } Console . WriteLine ( count ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 6 , 5 } ; int N = arr . Length ; countPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void add_edge ( List < List < int > > adj , int u , int v ) { adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } static void dfs ( List < int > parent , List < List < int > > adj , int u , int par = - 1 ) { parent [ u ] = par ; foreach ( int child in adj [ u ] ) { if ( child != par ) dfs ( parent , adj , child , u ) ; } } static void countSmallerAncestors ( List < List < int > > adj , int n ) { List < int > parent = new List < int > ( ) ; for ( int i = 0 ; i < ( int ) ( 1e5 ) ; i ++ ) { parent . Add ( 0 ) ; } dfs ( parent , adj , 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) { int node = i ; int cnt = 0 ; while ( parent [ node ] != - 1 ) { if ( parent [ node ] < i ) cnt += 1 ; node = parent [ node ] ; } Console . Write ( cnt + " ▁ " ) ; } } static void Main ( ) { int N = 6 ; List < List < int > > adj = new List < List < int > > ( ) ; for ( int i = 0 ; i < ( int ) ( 1e5 ) ; i ++ ) { adj . Add ( new List < int > ( ) ) ; } add_edge ( adj , 1 , 5 ) ; add_edge ( adj , 1 , 4 ) ; add_edge ( adj , 4 , 6 ) ; add_edge ( adj , 5 , 3 ) ; add_edge ( adj , 5 , 2 ) ; countSmallerAncestors ( adj , N ) ; } }

Index/key variables: node, u, v
Accumulator variables: cnt, i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static void countSubsequences ( int [ ] A ) { int odd = 0 ; int even = 0 ; foreach ( int el in A ) { if ( el % 2 == 1 ) odd ++ ; else even ++ ; } if ( odd == 0 ) Console . WriteLine ( 0 ) ; else Console . WriteLine ( 1 << ( A . Length - 1 ) ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 3 , 4 } ; countSubsequences ( A ) ; } }

Accumulator variables: even, odd
Iterator variables: el
Class/struct names: GFG