dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public class Date { public int d , m , y ; public Date ( int d , int m , int y ) { this . d = d ; this . m = m ; this . y = y ; } } ; static int [ ] monthDays = { 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; static int countLeapYears ( Date d ) { int years = d . y ; if ( d . m <= 2 ) { years -- ; } return years / 4 - years / 100 + years / 400 ; } static int getDifference ( Date dt1 , Date dt2 ) { int n1 = dt1 . y * 365 + dt1 . d ; for ( int i = 0 ; i < dt1 . m - 1 ; i ++ ) { n1 += monthDays [ i ] ; } n1 += countLeapYears ( dt1 ) ; int n2 = dt2 . y * 365 + dt2 . d ; for ( int i = 0 ; i < dt2 . m - 1 ; i ++ ) { n2 += monthDays [ i ] ; } n2 += countLeapYears ( dt2 ) ; return ( n2 - n1 ) ; } public static void Main ( String [ ] args ) { Date dt1 = new Date ( 1 , 2 , 2000 ) ; Date dt2 = new Date ( 1 , 2 , 2004 ) ; Console . WriteLine ( " Difference ▁ between ▁ two ▁ dates ▁ is ▁ " + getDifference ( dt1 , dt2 ) ) ; } }

Index/key variables: i
Accumulator variables: i, n1, n2, years
Iterator variables: i
Class/struct names: Date, GFG
C# program:
using System ; class GFG { static int getPeriod ( int n ) { int rem = 1 ; for ( int i = 1 ; i <= n + 1 ; i ++ ) rem = ( 10 * rem ) % n ; int d = rem ; int count = 0 ; do { rem = ( 10 * rem ) % n ; count ++ ; } while ( rem != d ) ; return count ; } public static void Main ( ) { Console . Write ( getPeriod ( 3 ) + " STRNEWLINE " ) ; Console . Write ( getPeriod ( 7 ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int replace0with5 ( int number ) { return number += calculateAddedValue ( number ) ; } static int calculateAddedValue ( int number ) { int result = 0 ; int decimalPlace = 1 ; if ( number == 0 ) { result += ( 5 * decimalPlace ) ; } while ( number > 0 ) { if ( number % 10 == 0 ) result += ( 5 * decimalPlace ) ; number /= 10 ; decimalPlace *= 10 ; } return result ; } static public void Main ( ) { Console . WriteLine ( replace0with5 ( 1020 ) ) ; } }

Accumulator variables: decimalPlace, number, result
Class/struct names: GFG
C# program:
using System ; class GFG { static int getRemainder ( int num , int divisor ) { return ( num - divisor * ( num / divisor ) ) ; } public static void Main ( ) { Console . Write ( getRemainder ( 100 , 7 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static double sum ( int n ) { double sum = 0 ; int fact = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { fact *= i ; sum += 1.0 / fact ; } return sum ; } public static void Main ( ) { int n = 5 ; Console . WriteLine ( sum ( n ) ) ; } }

Accumulator variables: fact, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void print ( int n , int k ) { int rem = 1 ; for ( int i = 0 ; i < k ; i ++ ) { Console . Write ( ( 10 * rem ) / n ) ; rem = ( 10 * rem ) % n ; } } public static void Main ( ) { int n = 7 , k = 3 ; print ( n , k ) ; Console . WriteLine ( ) ; n = 21 ; k = 4 ; print ( n , k ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Rearrange { void rearrange ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) arr [ i ] += ( arr [ arr [ i ] ] % n ) * n ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] /= n ; } void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( " " ) ; } public static void Main ( ) { Rearrange rearrange = new Rearrange ( ) ; int [ ] arr = { 3 , 2 , 0 , 1 } ; int n = arr . Length ; Console . Write ( " Given ▁ Array ▁ is ▁ : " ) ; rearrange . printArr ( arr , n ) ; rearrange . rearrange ( arr , n ) ; Console . Write ( " Modified ▁ Array ▁ is ▁ : " ) ; rearrange . printArr ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Rearrange
C# program:
using System ; class GFG { static void printArray ( int [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; return ; } static void printSequencesRecur ( int [ ] arr , int n , int k , int index ) { int i ; if ( k == 0 ) { printArray ( arr , index ) ; } if ( k > 0 ) { for ( i = 1 ; i <= n ; ++ i ) { arr [ index ] = i ; printSequencesRecur ( arr , n , k - 1 , index + 1 ) ; } } } static void printSequences ( int n , int k ) { int [ ] arr = new int [ k ] ; printSequencesRecur ( arr , n , k , 0 ) ; return ; } public static void Main ( ) { int n = 3 ; int k = 2 ; printSequences ( n , k ) ; } }

Index/key variables: i, index, k
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isMultipleof5 ( int n ) { while ( n > 0 ) n = n - 5 ; if ( n == 0 ) return true ; return false ; } public static void Main ( ) { int n = 19 ; if ( isMultipleof5 ( n ) == true ) Console . Write ( n + " ▁ is ▁ multiple ▁ of ▁ 5 STRNEWLINE " ) ; else Console . Write ( n + " ▁ is ▁ not ▁ a ▁ multiple ▁ of ▁ 5 STRNEWLINE " ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void countPairs ( int [ ] arr , int N , int K ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( K - arr [ i ] ) ) cnt += mp [ K - arr [ i ] ] ; if ( mp . ContainsKey ( arr [ i ] ) ) { var val = mp [ arr [ i ] ] ; mp . Remove ( arr [ i ] ) ; mp . Add ( arr [ i ] , val + 1 ) ; } else { mp . Add ( arr [ i ] , 1 ) ; } } Console . WriteLine ( cnt ) ; } static public void Main ( ) { int [ ] arr = { 1 , 5 , 4 , 8 , 7 } ; int N = arr . Length ; int K = 9 ; countPairs ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int check ( int x ) { if ( ( ( x ) & ( x - 1 ) ) == 0 ) return 1 ; return 0 ; } static int query ( int l , int r , int [ ] pre ) { if ( l == 0 ) return pre [ r ] ; else return pre [ r ] - pre [ l - 1 ] ; } static void countInRange ( int [ ] arr , int N , List < Tuple < int , int > > queries , int Q ) { int [ ] pre = new int [ N ] ; pre [ 0 ] = check ( arr [ 0 ] ) ; for ( int i = 1 ; i < N ; i ++ ) { pre [ i ] = pre [ i - 1 ] + check ( arr [ i ] ) ; } int c = 0 ; int q = 0 ; while ( q < Q ) { int l = queries [ q ] . Item1 ; int r = queries [ q ] . Item2 ; c ++ ; q ++ ; Console . Write ( query ( l , r , pre ) + " ▁ " ) ; } } static void Main ( ) { int [ ] arr = { 12 , 11 , 16 , 8 , 2 , 5 , 1 , 3 , 256 , 1 } ; int N = arr . Length ; List < Tuple < int , int > > queries = new List < Tuple < int , int > > ( ) ; queries . Add ( new Tuple < int , int > ( 0 , 9 ) ) ; queries . Add ( new Tuple < int , int > ( 4 , 9 ) ) ; int Q = queries . Count ; countInRange ( arr , N , queries , Q ) ; } }

Index/key variables: N, i, q, r
Accumulator variables: c, i, q
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int build_num ( int [ ] bit , int k ) { int ans = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) if ( bit [ i ] == k ) ans += ( 1 << i ) ; return ans ; } static int minimumAND ( int [ ] arr , int n , int k ) { int [ ] bit = new int [ 32 ] ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < 32 ; j ++ ) { if ( ( arr [ i ] & ( 1 << j ) ) > 0 ) bit [ j ] ++ ; } } int min_and = build_num ( bit , k ) ; for ( int i = k ; i < n ; i ++ ) { for ( int j = 0 ; j < 32 ; j ++ ) { if ( ( arr [ i - k ] & ( 1 << j ) ) > 0 ) bit [ j ] -- ; } for ( int j = 0 ; j < 32 ; j ++ ) { if ( ( arr [ i ] & ( 1 << j ) ) > 0 ) bit [ j ] ++ ; } min_and = Math . Min ( build_num ( bit , k ) , min_and ) ; } return min_and ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 5 , 3 , 6 , 11 , 13 } ; int k = 3 ; int n = arr . Length ; Console . Write ( minimumAND ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long calculate ( int bit_cnt ) { long res = 1 ; while ( bit_cnt -- > 0 ) { res = res * 3 ; } return res ; } static int unset_bit_count ( long n ) { int count = 0 ; while ( n > 0 ) { if ( ( n & 1 ) == 0 ) count ++ ; n = n >> 1 ; } return count ; } public static void Main ( String [ ] args ) { long n ; n = 2 ; int count = unset_bit_count ( n ) ; long ans = calculate ( count ) ; Console . WriteLine ( ans ) ; } }

Accumulator variables: bit_cnt, count
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int [ ] A , int [ ] B , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( countSetBits ( A [ i ] & A [ j ] ) == B [ j ] ) { cnt ++ ; } } } return cnt ; } static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 3 , 1 , 4 , 5 } ; int [ ] B = { 2 , 2 , 1 , 4 , 2 } ; int size = A . Length ; Console . WriteLine ( solve ( A , B , size ) ) ; } }

Index/key variables: i, j
Accumulator variables: cnt, count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void CalculatePairs ( int [ ] a , int n ) { int cnt_zero = 0 ; int cnt_one = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 0 ) cnt_zero += 1 ; else cnt_one += 1 ; } int total_XOR_pairs = cnt_zero * cnt_one ; int total_AND_pairs = ( cnt_one ) * ( cnt_one - 1 ) / 2 ; int total_OR_pairs = cnt_zero * cnt_one + ( cnt_one ) * ( cnt_one - 1 ) / 2 ; Console . WriteLine ( " cntXOR ▁ = ▁ " + total_XOR_pairs ) ; Console . WriteLine ( " cntAND ▁ = ▁ " + total_AND_pairs ) ; Console . WriteLine ( " cntOR ▁ = ▁ " + total_OR_pairs ) ; } public static void Main ( ) { int [ ] a = { 1 , 3 , 4 , 2 } ; int n = a . Length ; CalculatePairs ( a , n ) ; } }

Index/key variables: i
Accumulator variables: cnt_one, cnt_zero, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class gfg { public void alternate ( ref int a , ref int b , ref int x ) { x = a + b - x ; } } class geek { public static int Main ( ) { gfg g = new gfg ( ) ; int a = - 10 ; int b = 15 ; int x = a ; Console . WriteLine ( " x ▁ is ▁ : ▁ { 0 } " , x ) ; g . alternate ( ref a , ref b , ref x ) ; Console . WriteLine ( " After ▁ change ▁ " ) ; Console . WriteLine ( " x ▁ is ▁ : ▁ { 0 } " , x ) ; return 0 ; } }

Class/struct names: geek, gfg
C# program:
using System ; class GFG { static int highestPowerOf2 ( int n ) { return ( n & ( ~ ( n - 1 ) ) ) ; } public static void Main ( ) { int n = 48 ; Console . Write ( highestPowerOf2 ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void isSubsetAndZero ( int [ ] array , int length , int N ) { int arrAnd = array [ 0 ] ; for ( int i = 1 ; i < length ; i ++ ) { arrAnd = arrAnd & array [ i ] ; } if ( ( arrAnd & N ) == 0 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } public static void Main ( ) { int [ ] array = { 1 , 2 , 4 } ; int length = array . Length ; int N = 3 ; isSubsetAndZero ( array , length , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool findParity ( int x ) { int y = x ^ ( x >> 1 ) ; y = y ^ ( y >> 2 ) ; y = y ^ ( y >> 4 ) ; y = y ^ ( y >> 8 ) ; y = y ^ ( y >> 16 ) ; if ( ( y & 1 ) > 0 ) return true ; return false ; } public static void Main ( ) { if ( ( findParity ( 9 ) == false ) ) Console . WriteLine ( " Even ▁ Parity " ) ; else Console . WriteLine ( " Odd ▁ Parity " ) ; if ( findParity ( 13 ) == false ) Console . WriteLine ( " Even ▁ Parity " ) ; else Console . WriteLine ( " Odd ▁ Parity " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool allBitsSetInTheGivenRange ( int n , int l , int r ) { int num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; int new_num = n & num ; if ( num == new_num ) return true ; return false ; } static bool bitsAreComplement ( int a , int b , int l , int r ) { int xor_value = a ^ b ; return allBitsSetInTheGivenRange ( xor_value , l , r ) ; } static public void Main ( ) { int a = 10 , b = 5 ; int l = 1 , r = 3 ; if ( bitsAreComplement ( a , b , l , r ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int calculateSum ( int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ( 1 << i ) ; } return sum ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( " Sum ▁ of ▁ the ▁ series ▁ : ▁ " + calculateSum ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printCombinations ( int [ ] a , int n , int m ) { for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { int sum = 0 ; int num = 1 << ( n - 1 ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & num ) > 0 ) sum += a [ j ] ; else sum += ( - 1 * a [ j ] ) ; num = num >> 1 ; } if ( sum % m == 0 ) { num = 1 << ( n - 1 ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & num ) > 0 ) Console . Write ( " + " + a [ j ] + " ▁ " ) ; else Console . Write ( " - " + a [ j ] + " ▁ " ) ; num = num >> 1 ; } Console . Write ( " STRNEWLINE " ) ; } } } public static void Main ( ) { int [ ] a = { 3 , 5 , 6 , 8 } ; int n = a . Length ; int m = 5 ; printCombinations ( a , n , m ) ; } }

Index/key variables: j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int __builtin_popcount ( int n ) { int d , t = 0 ; while ( n > 0 ) { d = n % 2 ; n = n / 2 ; if ( d == 1 ) t ++ ; } return t ; } static int smallerNumsWithSameSetBits ( int n ) { int temp = __builtin_popcount ( n ) ; int count = 0 ; for ( int i = n - 1 ; i > 0 ; i -- ) { if ( temp == __builtin_popcount ( i ) ) count ++ ; } return count ; } static public void Main ( String [ ] args ) { int n = 4 ; Console . WriteLine ( smallerNumsWithSameSetBits ( n ) ) ; } }

Accumulator variables: count, i, t
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int multiplyWith4 ( int n ) { return ( n << 2 ) ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . Write ( multiplyWith4 ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int N = 1000 ; static int [ ] tree = new int [ N ] ; static int [ ] level = new int [ N ] ; static void constructTree ( int low , int high , int pos , int [ ] a ) { if ( low == high ) { level [ pos ] = 0 ; tree [ pos ] = a [ high ] ; return ; } int mid = ( low + high ) / 2 ; constructTree ( low , mid , 2 * pos + 1 , a ) ; constructTree ( mid + 1 , high , 2 * pos + 2 , a ) ; level [ pos ] = level [ 2 * pos + 1 ] + 1 ; if ( ( level [ pos ] & 1 ) > 0 ) tree [ pos ] = tree [ 2 * pos + 1 ] | tree [ 2 * pos + 2 ] ; else tree [ pos ] = tree [ 2 * pos + 1 ] ^ tree [ 2 * pos + 2 ] ; } static void update ( int low , int high , int pos , int index , int [ ] a ) { if ( low == high && low == index ) { tree [ pos ] = a [ low ] ; return ; } if ( index < low index > high ) return ; if ( low != high ) { int mid = ( low + high ) / 2 ; update ( low , mid , 2 * pos + 1 , index , a ) ; update ( mid + 1 , high , 2 * pos + 2 , index , a ) ; if ( ( level [ pos ] & 1 ) > 0 ) tree [ pos ] = tree [ 2 * pos + 1 ] | tree [ 2 * pos + 2 ] ; else tree [ pos ] = tree [ 2 * pos + 1 ] ^ tree [ 2 * pos + 2 ] ; } } static void updateValue ( int index , int value , int [ ] a , int n ) { a [ index ] = value ; update ( 0 , n - 1 , 0 , index , a ) ; } static public void Main ( ) { int [ ] a = { 1 , 4 , 5 , 6 } ; int n = a . Length ; ; constructTree ( 0 , n - 1 , 0 , a ) ; int index = 0 ; int value = 2 ; updateValue ( index , value , a , n ) ; Console . WriteLine ( tree [ 0 ] ) ; index = 3 ; value = 5 ; updateValue ( index , value , a , n ) ; Console . WriteLine ( tree [ 0 ] ) ; } }

Index/key variables: N, high, index, low, pos
Class/struct names: GFG
C# program:
using System ; class GFG { static int evenbitsetnumber ( int n ) { int count = 0 , res = 0 ; for ( int temp = n ; temp > 0 ; temp >>= 1 ) { if ( count % 2 == 1 ) res |= ( 1 << count ) ; count ++ ; } return ( n res ) ; } public static void Main ( ) { int n = 4 ; Console . WriteLine ( evenbitsetnumber ( n ) ) ; } }

Accumulator variables: count, res
Iterator variables: temp
Class/struct names: GFG
C# program:
using System ; class GFG { static int getmsb ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return ( n + 1 ) >> 1 ; } static int getevenbits ( int n ) { n = getmsb ( n ) ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; if ( ( n & 1 ) == 1 ) n = n >> 1 ; return n ; } static int setallevenbits ( int n ) { return n | getevenbits ( n ) ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( setallevenbits ( n ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { static int oddbitsetnumber ( int n ) { int count = 0 ; int res = 0 ; for ( int temp = n ; temp > 0 ; temp >>= 1 ) { if ( count % 2 == 0 ) res |= ( 1 << count ) ; count ++ ; } return ( n res ) ; } static public void Main ( ) { int n = 10 ; Console . WriteLine ( oddbitsetnumber ( n ) ) ; } }

Accumulator variables: count, res
Iterator variables: temp
Class/struct names: GFG
C# program:
using System ; class GFG { static int getmsb ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return ( n + 1 ) >> 1 ; } static int getevenbits ( int n ) { n = getmsb ( n ) ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; if ( ( n & 1 ) == 0 ) n = n >> 1 ; return n ; } static int setalloddbits ( int n ) { return n | getevenbits ( n ) ; } static public void Main ( ) { int n = 10 ; Console . WriteLine ( setalloddbits ( n ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { public static void printNumHavingAltBitPatrn ( int n ) { int curr_num = 1 , i = 1 ; Console . Write ( curr_num + " ▁ " ) ; while ( i != 0 ) { curr_num <<= 1 ; if ( n < curr_num ) break ; Console . Write ( curr_num + " ▁ " ) ; curr_num = ( ( curr_num ) << 1 ) ^ 1 ; if ( n < curr_num ) break ; Console . Write ( curr_num + " ▁ " ) ; } } public static void Main ( ) { int n = 50 ; printNumHavingAltBitPatrn ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int perfectPowerOf2 ( int n ) { int per_pow = 1 ; while ( n > 0 ) { per_pow = per_pow << 1 ; n = n >> 1 ; } return per_pow ; } public static void Main ( ) { int n = 128 ; Console . WriteLine ( " Perfect ▁ power ▁ of ▁ 2 ▁ greater ▁ than ▁ " + n + " : ▁ " + perfectPowerOf2 ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void findUniquePair ( int [ ] arr , int n ) { int XOR = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) XOR = XOR ^ arr [ i ] ; int set_bit_no = XOR & ~ ( XOR - 1 ) ; int x = 0 , y = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & set_bit_no ) > 0 ) x = x ^ arr [ i ] ; else y = y ^ arr [ i ] ; } Console . WriteLine ( " The ▁ unique ▁ pair ▁ is ▁ ( " + x + " , ▁ " + y + " ) " ) ; } public static void Main ( ) { int [ ] a = { 6 , 1 , 3 , 5 , 1 , 3 , 7 , 6 } ; int n = a . Length ; findUniquePair ( a , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countUnsetBits ( int n ) { int x = n ; n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return BitCount ( x ^ n ) ; } static int BitCount ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int n = 17 ; Console . WriteLine ( countUnsetBits ( n ) ) ; } }

Accumulator variables: n, setBits
Class/struct names: GFG
C# program:
using System ; class GFG { static int countBits ( int n ) { int count = 0 ; while ( n != 0 ) { count ++ ; n >>= 1 ; } return count ; } static public void Main ( ) { int i = 65 ; Console . Write ( countBits ( i ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; class GFG { static int toggle ( int n ) { int temp = 1 ; while ( temp <= n ) { n = n ^ temp ; temp = temp << 1 ; } return n ; } public static void Main ( ) { int n = 10 ; n = toggle ( n ) ; Console . Write ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int INT_MAX = 2147483647 ; static int isKthBitSet ( int x , int k ) { return ( ( x & ( 1 << ( k - 1 ) ) ) > 0 ) ? 1 : 0 ; } static int leftmostSetBit ( int x ) { int count = 0 ; while ( x > 0 ) { count ++ ; x = x >> 1 ; } return count ; } static int isBinPalindrome ( int x ) { int l = leftmostSetBit ( x ) ; int r = 1 ; while ( l > r ) { if ( isKthBitSet ( x , l ) != isKthBitSet ( x , r ) ) return 0 ; l -- ; r ++ ; } return 1 ; } static int findNthPalindrome ( int n ) { int pal_count = 0 ; int i = 0 ; for ( i = 1 ; i <= INT_MAX ; i ++ ) { if ( isBinPalindrome ( i ) > 0 ) { pal_count ++ ; } if ( pal_count == n ) break ; } return i ; } static public void Main ( ) { int n = 9 ; Console . WriteLine ( findNthPalindrome ( n ) ) ; } }

Accumulator variables: count, i, l, pal_count, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool LSB ( int num , int K ) { bool x = ( num & ( 1 << ( K - 1 ) ) ) != 0 ; return ( x ) ; } static void Main ( ) { int num = 10 , K = 4 ; if ( LSB ( num , K ) ) Console . Write ( "1" ) ; else Console . Write ( "0" ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void areSame ( int a , int b ) { if ( ( a - b ) == 0 ) Console . Write ( " Same " ) ; else Console . Write ( " Not ▁ Same " ) ; } public static void Main ( ) { areSame ( 10 , 20 ) ; } }

Class/struct names: GFG
C# program:
using System ; namespace Toggle { public class GFG { static int toggleBitsFromLToR ( int n , int l , int r ) { int num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; return ( n ^ num ) ; } public static void Main ( ) { int n = 50 ; int l = 2 , r = 5 ; Console . Write ( toggleBitsFromLToR ( n , l , r ) ) ; } } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int getRightMostSetBit ( int n ) { if ( n == 0 ) return 0 ; return ( int ) ( ( Math . Log10 ( n & - n ) ) / Math . Log10 ( 2 ) ) + 1 ; } static int posOfRightMostDiffBit ( int m , int n ) { return getRightMostSetBit ( m ^ n ) ; } public static void Main ( ) { int m = 52 , n = 4 ; Console . Write ( " Position ▁ = ▁ " + posOfRightMostDiffBit ( m , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int getNext ( int n ) { int c = n ; int c0 = 0 ; int c1 = 0 ; while ( ( ( c & 1 ) == 0 ) && ( c != 0 ) ) { c0 ++ ; c >>= 1 ; } while ( ( c & 1 ) == 1 ) { c1 ++ ; c >>= 1 ; } if ( c0 + c1 == 31 c0 + c1 == 0 ) return - 1 ; return n + ( 1 << c0 ) + ( 1 << ( c1 - 1 ) ) - 1 ; } static public void Main ( ) { int n = 5 ; Console . WriteLine ( getNext ( n ) ) ; n = 8 ; Console . WriteLine ( getNext ( n ) ) ; } }

Accumulator variables: c0, c1
Class/struct names: GFG
C# program:
using System ; class GFG { static int totalFlips ( string A , string B , string C , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( A [ i ] == B [ i ] && C [ i ] == '1' ) ++ count ; else if ( A [ i ] != B [ i ] && C [ i ] == '0' ) ++ count ; } return count ; } public static void Main ( ) { int N = 5 ; string a = "10100" ; string b = "00010" ; string c = "10011" ; Console . Write ( totalFlips ( a , b , c , N ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void swapThree ( ref int a , ref int b , ref int c ) { a = a ^ b ^ c ; b = a ^ b ^ c ; c = a ^ b ^ c ; a = a ^ b ^ c ; } static void Main ( String [ ] args ) { int a = 10 , b = 20 , c = 30 ; Console . WriteLine ( " Before ▁ swapping ▁ a ▁ = ▁ " + a + " , ▁ b ▁ = ▁ " + b + " , c ▁ = ▁ " + c ) ; swapThree ( ref a , ref b , ref c ) ; Console . Write ( " After ▁ swapping ▁ a ▁ = ▁ " + a + " , ▁ b ▁ = ▁ " + b + " , ▁ c ▁ = ▁ " + c ) ; } }

Class/struct names: GFG