dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void add ( int [ ] arr , int N , int lo , int hi , int val ) { arr [ lo ] += val ; if ( hi != N - 1 ) arr [ hi + 1 ] -= val ; } static void updateArray ( int [ ] arr , int N ) { for ( int i = 1 ; i < N ; i ++ ) arr [ i ] += arr [ i - 1 ] ; } static void printArr ( int [ ] arr , int N ) { updateArray ( arr , N ) ; for ( int i = 0 ; i < N ; i ++ ) Console . Write ( " " + arr [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( ) { int N = 6 ; int [ ] arr = new int [ N ] ; add ( arr , N , 0 , 2 , 100 ) ; add ( arr , N , 1 , 5 , 100 ) ; add ( arr , N , 2 , 3 , 100 ) ; printArr ( arr , N ) ; } }

Index/key variables: N, i, lo
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int find_count ( int [ ] arr , int k ) { int ans = 0 ; foreach ( int i in arr ) { int x = countSetBits ( i ) ; if ( x % k == 0 ) ans += 1 ; } return ans ; } static int countSetBits ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 345 , 2 , 68 , 7896 } ; int K = 2 ; Console . Write ( find_count ( arr , K ) ) ; } }

Accumulator variables: ans, setBits
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void KPrimeDivisors ( int N , int K ) { int maximum_split = 0 ; while ( N % 2 == 0 ) { maximum_split ++ ; N /= 2 ; } for ( int i = 3 ; i * i <= N ; i = i + 2 ) { while ( N % i == 0 ) { N = N / i ; maximum_split ++ ; } } if ( N > 2 ) maximum_split ++ ; if ( maximum_split < K ) { Console . WriteLine ( " No " ) ; return ; } Console . WriteLine ( " Yes " ) ; } public static void Main ( String [ ] args ) { int N = 12 ; int K = 3 ; KPrimeDivisors ( N , K ) ; } }

Accumulator variables: N, maximum_split
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { private static int [ ] st ; public static int constructST ( int [ ] arr , int ss , int se , int si ) { if ( ss == se ) { st [ si ] = arr [ ss ] ; return st [ si ] ; } int mid = ss + ( se - ss ) / 2 ; st [ si ] = gcd ( constructST ( arr , ss , mid , si * 2 + 1 ) , constructST ( arr , mid + 1 , se , si * 2 + 2 ) ) ; return st [ si ] ; } public static int [ ] constructSegmentTree ( int [ ] arr ) { int height = ( int ) Math . Ceiling ( Math . Log ( arr . Length ) / Math . Log ( 2 ) ) ; int size = 2 * ( int ) Math . Pow ( 2 , height ) - 1 ; st = new int [ size ] ; constructST ( arr , 0 , arr . Length - 1 , 0 ) ; return st ; } private static int gcd ( int a , int b ) { if ( a < b ) { int temp = b ; b = a ; a = temp ; } if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static int findGcd ( int ss , int se , int qs , int qe , int si ) { if ( ss > qe se < qs ) return 0 ; if ( qs <= ss && qe >= se ) return st [ si ] ; int mid = ss + ( se - ss ) / 2 ; return gcd ( findGcd ( ss , mid , qs , qe , si * 2 + 1 ) , findGcd ( mid + 1 , se , qs , qe , si * 2 + 2 ) ) ; } public static int findRangeGcd ( int ss , int se , int [ ] arr ) { int n = arr . Length ; if ( ss < 0 se > n - 1 ss > se ) { Console . WriteLine ( " Invalid ▁ arguments " ) ; return int . MinValue ; } return findGcd ( 0 , n - 1 , ss , se , 0 ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 6 , 9 , 5 } ; constructSegmentTree ( a ) ; int l = 1 ; int r = 3 ; Console . Write ( " GCD ▁ of ▁ the ▁ given ▁ range ▁ is : ▁ " ) ; Console . Write ( findRangeGcd ( l , r , a ) ) ; } }

Index/key variables: si, size, ss
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { public static int findSum ( int L , int R ) { ArrayList arr = new ArrayList ( ) ; int i = 0 ; int x = 2 ; while ( i <= R ) { arr . Add ( i + x ) ; if ( i + 1 <= R ) arr . Add ( i + 1 + x ) ; x *= - 1 ; i += 2 ; } int sum = 0 ; for ( i = L ; i <= R ; ++ i ) sum += ( int ) arr [ i ] ; return sum ; } public static void Main ( string [ ] args ) { int L = 0 , R = 5 ; Console . Write ( findSum ( L , R ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int GCD ( int a , int b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } static void FillPrefixSuffix ( int [ ] prefix , int [ ] arr , int [ ] suffix , int n ) { prefix [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefix [ i ] = GCD ( prefix [ i - 1 ] , arr [ i ] ) ; suffix [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) suffix [ i ] = GCD ( suffix [ i + 1 ] , arr [ i ] ) ; } static int GCDoutsideRange ( int l , int r , int [ ] prefix , int [ ] suffix , int n ) { if ( l == 0 ) return suffix [ r + 1 ] ; if ( r == n - 1 ) return prefix [ l - 1 ] ; return GCD ( prefix [ l - 1 ] , suffix [ r + 1 ] ) ; } public static void Main ( ) { int [ ] arr = { 2 , 6 , 9 } ; int n = arr . Length ; int [ ] prefix = new int [ n ] ; int [ ] suffix = new int [ n ] ; FillPrefixSuffix ( prefix , arr , suffix , n ) ; int l = 0 , r = 0 ; Console . WriteLine ( GCDoutsideRange ( l , r , prefix , suffix , n ) ) ; l = 1 ; r = 1 ; Console . WriteLine ( GCDoutsideRange ( l , r , prefix , suffix , n ) ) ; l = 1 ; r = 2 ; Console . Write ( GCDoutsideRange ( l , r , prefix , suffix , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int check ( int [ ] A , int [ ] B , int N ) { List < int > pq1 = new List < int > ( ) ; List < int > pq2 = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { pq1 . Add ( A [ i ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { pq2 . Add ( B [ i ] ) ; } pq1 . Sort ( ) ; pq1 . Reverse ( ) ; pq2 . Sort ( ) ; pq2 . Reverse ( ) ; int c = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( pq1 [ 0 ] > pq2 [ 0 ] ) { c ++ ; pq1 . RemoveAt ( 0 ) ; pq2 . RemoveAt ( 0 ) ; } else { if ( pq2 . Count == 0 ) { break ; } pq2 . RemoveAt ( 0 ) ; } } return c ; } static public void Main ( ) { int [ ] A = { 10 , 3 , 7 , 5 , 8 } ; int [ ] B = { 8 , 6 , 2 , 5 , 9 } ; int N = A . Length ; Console . WriteLine ( check ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 10001 ; static void update ( int idx , int blk , int val , int [ , ] bit ) { for ( ; idx < MAX ; idx += ( idx & - idx ) ) bit [ blk , idx ] += val ; } static int query ( int l , int r , int k , int [ ] arr , int blk_sz , int [ , ] bit ) { int sum = 0 ; while ( l < r && l % blk_sz != 0 && l != 0 ) { if ( arr [ l ] <= k ) sum ++ ; l ++ ; } while ( l + blk_sz <= r ) { int idx = k ; for ( ; idx > 0 ; idx -= idx & - idx ) sum += bit [ l / blk_sz , idx ] ; l += blk_sz ; } while ( l <= r ) { if ( arr [ l ] <= k ) sum ++ ; l ++ ; } return sum ; } static void preprocess ( int [ ] arr , int blk_sz , int n , int [ , ] bit ) { for ( int i = 0 ; i < n ; i ++ ) update ( arr [ i ] , i / blk_sz , 1 , bit ) ; } static void preprocessUpdate ( int i , int v , int blk_sz , int [ ] arr , int [ , ] bit ) { update ( arr [ i ] , i / blk_sz , - 1 , bit ) ; update ( v , i / blk_sz , 1 , bit ) ; arr [ i ] = v ; } public static void Main ( ) { int [ ] arr = { 5 , 1 , 2 , 3 , 4 } ; int blk_sz = ( int ) Math . Sqrt ( arr . Length ) ; int [ , ] bit = new int [ blk_sz + 1 , MAX ] ; preprocess ( arr , blk_sz , arr . Length , bit ) ; Console . WriteLine ( query ( 1 , 3 , 1 , arr , blk_sz , bit ) ) ; preprocessUpdate ( 3 , 10 , blk_sz , arr , bit ) ; Console . WriteLine ( query ( 3 , 3 , 4 , arr , blk_sz , bit ) ) ; preprocessUpdate ( 2 , 1 , blk_sz , arr , bit ) ; preprocessUpdate ( 0 , 2 , blk_sz , arr , bit ) ; Console . WriteLine ( query ( 0 , 4 , 5 , arr , blk_sz , bit ) ) ; } }

Index/key variables: i, l
Accumulator variables: i, idx, l, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countInRange ( int [ ] arr , int n , int x , int y ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= x && arr [ i ] <= y ) count ++ ; } return count ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 4 , 9 , 10 , 3 } ; int n = arr . Length ; int i = 1 , j = 4 ; Console . WriteLine ( countInRange ( arr , n , i , j ) ) ; i = 9 ; j = 12 ; Console . WriteLine ( countInRange ( arr , n , i , j ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int lowerIndex ( int [ ] arr , int n , int x ) { int l = 0 , h = n - 1 ; while ( l <= h ) { int mid = ( l + h ) / 2 ; if ( arr [ mid ] >= x ) h = mid - 1 ; else l = mid + 1 ; } return l ; } static int upperIndex ( int [ ] arr , int n , int y ) { int l = 0 , h = n - 1 ; while ( l <= h ) { int mid = ( l + h ) / 2 ; if ( arr [ mid ] <= y ) l = mid + 1 ; else h = mid - 1 ; } return h ; } static int countInRange ( int [ ] arr , int n , int x , int y ) { int count = 0 ; count = upperIndex ( arr , n , y ) - lowerIndex ( arr , n , x ) + 1 ; return count ; } public static void Main ( ) { int [ ] arr = { 1 , 4 , 4 , 9 , 10 , 3 } ; int n = arr . Length ; Array . Sort ( arr ) ; int i = 1 , j = 4 ; Console . WriteLine ( countInRange ( arr , n , i , j ) ) ; ; i = 9 ; j = 12 ; Console . WriteLine ( countInRange ( arr , n , i , j ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { static void precompute ( int [ ] arr , int n , int [ ] pre ) { for ( int i = 0 ; i < n ; i ++ ) pre [ i ] = 0 ; pre [ n - 1 ] = arr [ n - 1 ] * ( int ) ( Math . Pow ( 2 , 0 ) ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) pre [ i ] = pre [ i + 1 ] + arr [ i ] * ( 1 << ( n - 1 - i ) ) ; } static int decimalOfSubarr ( int [ ] arr , int l , int r , int n , int [ ] pre ) { if ( r != n - 1 ) return ( pre [ l ] - pre [ r + 1 ] ) / ( 1 << ( n - 1 - r ) ) ; return pre [ l ] / ( 1 << ( n - 1 - r ) ) ; } public static void Main ( ) { int [ ] arr = { 1 , 0 , 1 , 0 , 1 , 1 } ; int n = arr . Length ; int [ ] pre = new int [ n ] ; precompute ( arr , n , pre ) ; Console . WriteLine ( decimalOfSubarr ( arr , 2 , 4 , n , pre ) ) ; Console . WriteLine ( decimalOfSubarr ( arr , 4 , 5 , n , pre ) ) ; } }

Index/key variables: i, l, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int answerQuery ( int [ ] a , int n , int l , int r ) { int count = 0 ; l = l - 1 ; for ( int i = l ; i < r ; i ++ ) { int divisors = 0 ; for ( int j = l ; j < r ; j ++ ) { if ( a [ j ] % a [ i ] == 0 ) divisors ++ ; else break ; } if ( divisors == ( r - l ) ) count ++ ; } return count ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 , 5 } ; int n = a . Length ; int l = 1 , r = 4 ; Console . WriteLine ( answerQuery ( a , n , l , r ) ) ; l = 2 ; r = 4 ; Console . WriteLine ( answerQuery ( a , n , l , r ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, divisors, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void minBinary ( int n ) { int [ ] digit = new int [ 10 ] ; int len = 0 ; while ( n > 0 ) { digit [ len ++ ] = n % 10 ; n /= 10 ; } digit = reverse ( digit , 0 , len - 1 ) ; int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { ans = Math . Max ( ans , digit [ i ] ) ; } Console . Write ( " Minimum ▁ Number ▁ of ▁ binary " + " ▁ Strings ▁ needed : ▁ " + ans + " STRNEWLINE " ) ; for ( int i = 1 ; i <= ans ; i ++ ) { int num = 0 ; for ( int j = 0 ; j < len ; j ++ ) { if ( digit [ j ] > 0 ) { num = num * 10 + 1 ; digit [ j ] -- ; } else { num *= 10 ; } } Console . Write ( num + " ▁ " ) ; } } static int [ ] reverse ( int [ ] str , int start , int end ) { int temp ; while ( start <= end ) { temp = str [ start ] ; str [ start ] = str [ end ] ; str [ end ] = temp ; start ++ ; end -- ; } return str ; } public static void Main ( String [ ] args ) { int n = 564 ; minBinary ( n ) ; } }

Index/key variables: end, i, j, start
Accumulator variables: end, i, j, len, n, num, start
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 2147483647 ; static int [ , ] one = new int [ 100001 , 32 ] ; static void make_prefix ( int [ ] A , int n ) { for ( int j = 0 ; j < 32 ; j ++ ) one [ 0 , j ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int a = A [ i - 1 ] ; for ( int j = 0 ; j < 32 ; j ++ ) { int x = ( int ) Math . Pow ( 2 , j ) ; if ( ( a & x ) != 0 ) one [ i , j ] = 1 + one [ i - 1 , j ] ; else one [ i , j ] = one [ i - 1 , j ] ; } } } static int Solve ( int L , int R ) { int l = L , r = R ; int tot_bits = r - l + 1 ; int X = MAX ; for ( int i = 0 ; i < 31 ; i ++ ) { int x = one [ r , i ] - one [ l - 1 , i ] ; if ( x >= tot_bits - x ) { int ith_bit = ( int ) Math . Pow ( 2 , i ) ; X = X ^ ith_bit ; } } return X ; } public static void Main ( ) { int n = 5 , q = 3 ; int [ ] A = { 210 , 11 , 48 , 22 , 133 } ; int [ ] L = { 1 , 4 , 2 } ; int [ ] R = { 3 , 14 , 4 } ; make_prefix ( A , n ) ; for ( int j = 0 ; j < q ; j ++ ) Console . WriteLine ( Solve ( L [ j ] , R [ j ] ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void type1 ( int [ ] arr , int start , int limit ) { for ( int i = start ; i <= limit ; i ++ ) arr [ i ] ++ ; } static void type2 ( int [ ] arr , int [ , ] query , int start , int limit ) { for ( int i = start ; i <= limit ; i ++ ) { if ( query [ i , 0 ] == 1 ) type1 ( arr , query [ i , 1 ] , query [ i , 2 ] ) ; else if ( query [ i , 0 ] == 2 ) type2 ( arr , query , query [ i , 1 ] , query [ i , 2 ] ) ; } } public static void Main ( ) { int n = 5 , m = 5 ; int [ ] arr = new int [ n + 1 ] ; int [ ] temp = { 1 , 1 , 2 , 1 , 4 , 5 , 2 , 1 , 2 , 2 , 1 , 3 , 2 , 3 , 4 } ; int [ , ] query = new int [ 6 , 4 ] ; int j = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { query [ i , 0 ] = temp [ j ++ ] ; query [ i , 1 ] = temp [ j ++ ] ; query [ i , 2 ] = temp [ j ++ ] ; } for ( int i = 1 ; i <= m ; i ++ ) if ( query [ i , 0 ] == 1 ) type1 ( arr , query [ i , 1 ] , query [ i , 2 ] ) ; else if ( query [ i , 0 ] == 2 ) type2 ( arr , query , query [ i , 1 ] , query [ i , 2 ] ) ; for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void record_sum ( int [ ] record , int l , int r , int n , int adder ) { for ( int i = l ; i <= r ; i ++ ) { record [ i ] += adder ; } } public static void Main ( String [ ] args ) { int n = 5 , m = 5 ; int [ ] arr = new int [ n ] ; int [ , ] query = { { 1 , 1 , 2 } , { 1 , 4 , 5 } , { 2 , 1 , 2 } , { 2 , 1 , 3 } , { 2 , 3 , 4 } } ; int [ ] record = new int [ m ] ; for ( int i = m - 1 ; i >= 0 ; i -- ) { if ( query [ i , 0 ] == 2 ) { record_sum ( record , query [ i , 1 ] - 1 , query [ i , 2 ] - 1 , m , record [ i ] + 1 ) ; } else { record_sum ( record , i , i , m , 1 ) ; } } for ( int i = 0 ; i < m ; i ++ ) { if ( query [ i , 0 ] == 1 ) { record_sum ( arr , query [ i , 1 ] - 1 , query [ i , 2 ] - 1 , n , record [ i ] ) ; } } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i, m, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static readonly int max = 10000 ; static void update ( int [ ] arr , int l ) { arr [ l ] += arr [ l - 1 ] ; } static void record_func ( int block_size , int [ ] block , int [ ] record , int l , int r , int value ) { while ( l < r && l % block_size != 0 && l != 0 ) { record [ l ] += value ; l ++ ; } while ( l + block_size <= r + 1 ) { block [ l / block_size ] += value ; l += block_size ; } while ( l <= r ) { record [ l ] += value ; l ++ ; } } static void print ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { int n = 5 , m = 5 ; int [ ] arr = new int [ n ] ; int [ ] record = new int [ m ] ; int block_size = ( int ) Math . Sqrt ( m ) ; int [ ] block = new int [ max ] ; int [ , ] command = { { 1 , 1 , 2 } , { 1 , 4 , 5 } , { 2 , 1 , 2 } , { 2 , 1 , 3 } , { 2 , 3 , 4 } } ; for ( int i = m - 1 ; i >= 0 ; i -- ) { if ( command [ i , 0 ] == 2 ) { int x = i / ( block_size ) ; record_func ( block_size , block , record , command [ i , 1 ] - 1 , command [ i , 2 ] - 1 , ( block [ x ] + record [ i ] + 1 ) ) ; } else { record [ i ] ++ ; } } for ( int i = 0 ; i < m ; i ++ ) { int check = ( i / block_size ) ; record [ i ] += block [ check ] ; } for ( int i = 0 ; i < m ; i ++ ) { if ( command [ i , 0 ] == 1 ) { arr [ command [ i , 1 ] - 1 ] += record [ i ] ; if ( ( command [ i , 2 ] - 1 ) < n - 1 ) { arr [ ( command [ i , 2 ] ) ] -= record [ i ] ; } } } for ( int i = 1 ; i < n ; i ++ ) { update ( arr , i ) ; } print ( arr , n ) ; } }

Index/key variables: check, i, l, m, max, n, x
Accumulator variables: i, l
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void updateBIT ( int [ ] BITree , int n , int index , int val ) { index = index + 1 ; while ( index <= n ) { BITree [ index ] = ( val + BITree [ index ] ) ; index = ( index + ( index & ( - index ) ) ) ; } return ; } static int [ ] constructBITree ( int n ) { int [ ] BITree = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) BITree [ i ] = 0 ; return BITree ; } static int getSum ( int [ ] BITree , int index ) { int sum = 0 ; index = index + 1 ; while ( index > 0 ) { sum = ( sum + BITree [ index ] ) ; index -= index & ( - index ) ; } return sum ; } static void update ( int [ ] BITree , int l , int r , int n , int val ) { updateBIT ( BITree , n , l , val ) ; updateBIT ( BITree , n , r + 1 , - val ) ; return ; } static public void Main ( ) { int n = 5 , m = 5 ; int [ ] temp = { 1 , 1 , 2 , 1 , 4 , 5 , 2 , 1 , 2 , 2 , 1 , 3 , 2 , 3 , 4 } ; int [ , ] q = new int [ 6 , 3 ] ; int j = 0 ; for ( int i = 1 ; i <= m ; i ++ ) { q [ i , 0 ] = temp [ j ++ ] ; q [ i , 1 ] = temp [ j ++ ] ; q [ i , 2 ] = temp [ j ++ ] ; } int [ ] BITree = constructBITree ( m ) ; int [ ] BITree2 = constructBITree ( n ) ; for ( int i = m ; i >= 1 ; i -- ) if ( q [ i , 0 ] == 2 ) update ( BITree , q [ i , 1 ] - 1 , q [ i , 2 ] - 1 , m , 1 ) ; for ( int i = m ; i >= 1 ; i -- ) { if ( q [ i , 0 ] == 2 ) { int val = getSum ( BITree , i - 1 ) ; update ( BITree , q [ i , 1 ] - 1 , q [ i , 2 ] - 1 , m , val ) ; } } for ( int i = m ; i >= 1 ; i -- ) { if ( q [ i , 0 ] == 1 ) { int val = getSum ( BITree , i - 1 ) ; update ( BITree2 , q [ i , 1 ] - 1 , q [ i , 2 ] - 1 , n , ( val + 1 ) ) ; } } for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( getSum ( BITree2 , i - 1 ) + " ▁ " ) ; } }

Index/key variables: i, index
Accumulator variables: i, index, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public class Query { public int L , R , X ; public Query ( int L , int R , int X ) { this . L = L ; this . R = R ; this . X = X ; } } ; static int maxn = 100 ; static int [ ] root = new int [ maxn ] ; static int find ( int x ) { if ( x == root [ x ] ) return x ; else return root [ x ] = find ( root [ x ] ) ; } static void uni ( int x , int y ) { int p = find ( x ) , q = find ( y ) ; if ( p != q ) { root [ p ] = root [ q ] ; } } static void initialize ( int [ ] a , int n , Query [ ] q , int m ) { for ( int i = 0 ; i < n ; i ++ ) root [ i ] = i ; for ( int i = 1 ; i < n ; i ++ ) if ( a [ i ] == a [ i - 1 ] ) uni ( i , i - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 1 , 5 , 4 , 5 } ; int n = a . Length ; Query [ ] q = { new Query ( 0 , 2 , 2 ) , new Query ( 1 , 4 , 1 ) , new Query ( 2 , 4 , 5 ) } ; int m = q . Length ; initialize ( a , n , q , m ) ; for ( int i = 0 ; i < m ; i ++ ) { int flag = 0 ; int l = q [ i ] . L , r = q [ i ] . R , x = q [ i ] . X ; int p = r ; while ( p >= l ) { if ( a [ p ] == x ) { flag = 1 ; break ; } p = find ( p ) - 1 ; } if ( flag != 0 ) Console . WriteLine ( x + " ▁ exists ▁ between ▁ [ " + l + " , ▁ " + r + " ] ▁ " ) ; else Console . WriteLine ( x + " ▁ does ▁ not ▁ exist ▁ between ▁ [ " + l + " , ▁ " + r + " ] ▁ " ) ; } } }

Index/key variables: i, maxn, p, q, x
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Query
C# program:
using System ; class GFG { static int findCountOfPairs ( int a , int b , int n ) { int ans = 0 ; for ( int i = 1 ; i <= a ; i ++ ) { ans += b / n ; ans += ( i % n + b % n ) >= n ? 1 : 0 ; } return ans ; } static public void Main ( ) { int a = 5 , b = 13 , n = 3 ; Console . WriteLine ( findCountOfPairs ( a , b , n ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCountOfPairs ( int a , int b , int n ) { if ( a > b ) { int temp1 = a ; a = b ; b = temp1 ; } int temp = 1 , count = 0 ; for ( int i = n ; temp > 0 ; i += n ) { if ( a >= i ) { temp = i - 1 ; } else if ( b >= i ) { temp = a ; } else if ( i > b ) { temp = a - ( i - b ) + 1 ; } if ( temp > 0 ) { count += temp ; } } return count ; } static void Main ( ) { int a = 5 , b = 13 , n = 3 ; Console . WriteLine ( findCountOfPairs ( a , b , n ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int solveQuery ( int start , int end , int [ ] arr ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = start ; i <= end ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) mp [ arr [ i ] ] ++ ; else mp . Add ( arr [ i ] , 1 ) ; } int count = 0 ; foreach ( KeyValuePair < int , int > entry in mp ) { if ( entry . Key == entry . Value ) count ++ ; } return count ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 2 , 2 , 3 , 3 , 3 } ; int n = A . Length ; int [ , ] queries = { { 0 , 1 } , { 1 , 1 } , { 0 , 2 } , { 1 , 3 } , { 3 , 5 } , { 0 , 5 } } ; int q = queries . Length ; for ( int i = 0 ; i < q ; i ++ ) { int start = queries [ i , 0 ] ; int end = queries [ i , 1 ] ; Console . WriteLine ( " Answer ▁ for ▁ Query ▁ " + ( i + 1 ) + " ▁ = ▁ " + solveQuery ( start , end , A ) ) ; } } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minItems ( int k , int r ) { for ( int i = 1 ; i < 10 ; i ++ ) if ( ( i * k - r ) % 10 == 0 || ( i * k ) % 10 == 0 ) return i ; return 10 ; } public static void Main ( ) { int k = 15 ; int r = 2 ; Console . WriteLine ( minItems ( k , r ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int answer_query ( int [ ] a , int n , int l , int r ) { int count = 0 ; for ( int i = l ; i < r ; i ++ ) if ( a [ i ] == a [ i + 1 ] ) count += 1 ; return count ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 2 , 2 , 3 , 3 , 4 , 4 , 4 } ; int n = a . Length ; int L , R ; L = 1 ; R = 8 ; Console . WriteLine ( answer_query ( a , n , L , R ) ) ; L = 0 ; R = 4 ; Console . WriteLine ( answer_query ( a , n , L , R ) ) ; } }

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