dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 10 ; static int findSubarray ( int [ ] array , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; mp . Add ( 0 , 1 ) ; int answer = 0 ; int preXor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int value = 1 ; preXor ^= array [ i ] ; for ( int j = 1 ; j <= MAX ; j ++ ) { int Y = value ^ preXor ; if ( mp . ContainsKey ( Y ) ) { answer += mp [ Y ] ; } value *= 2 ; } if ( mp . ContainsKey ( preXor ) ) { mp [ preXor ] = mp [ preXor ] + 1 ; } else { mp . Add ( preXor , 1 ) ; } } return answer ; } public static void Main ( String [ ] args ) { int [ ] array = { 2 , 6 , 7 , 5 , 8 } ; int n = array . Length ; Console . WriteLine ( findSubarray ( array , n ) ) ; } }

Index/key variables: Y, i, preXor
Accumulator variables: answer, i, j, preXor, value
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int max_xor ( int [ ] arr , int n ) { int maxXor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { maxXor = Math . Max ( maxXor , arr [ i ] ^ arr [ j ] ) ; } } return maxXor ; } public static void Main ( ) { int [ ] arr = { 25 , 10 , 2 , 8 , 5 , 3 } ; int n = arr . Length ; Console . WriteLine ( max_xor ( 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 max_xor ( int [ ] arr , int n ) { int maxx = 0 , mask = 0 ; HashSet < int > se = new HashSet < int > ( ) ; for ( int i = 30 ; i >= 0 ; i -- ) { mask |= ( 1 << i ) ; for ( int j = 0 ; j < n ; ++ j ) { se . Add ( arr [ j ] & mask ) ; } int newMaxx = maxx | ( 1 << i ) ; foreach ( int prefix in se ) { if ( se . Contains ( newMaxx ^ prefix ) ) { maxx = newMaxx ; break ; } } se . Clear ( ) ; } return maxx ; } public static void Main ( String [ ] args ) { int [ ] arr = { 25 , 10 , 2 , 8 , 5 , 3 } ; int n = arr . Length ; Console . WriteLine ( max_xor ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: i, mask
Iterator variables: i, j, prefix
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountTriplets ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int first = arr [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { first ^= arr [ j ] ; if ( first == 0 ) ans += ( j - i ) ; } } return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 5 , 6 , 4 , 2 } ; int n = arr . Length ; Console . WriteLine ( CountTriplets ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, first, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMajority ( int [ ] arr , int n ) { int len = 32 ; int number = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int countt = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) != 0 ) countt ++ ; } if ( countt > ( n / 2 ) ) number += ( 1 << i ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == number ) count ++ ; if ( count > ( n / 2 ) ) Console . Write ( number ) ; else Console . Write ( " Majority ▁ Element ▁ Not ▁ Present " ) ; } static public void Main ( ) { int [ ] arr = { 3 , 3 , 4 , 2 , 4 , 4 , 2 , 4 , 4 } ; int n = arr . Length ; findMajority ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: count, countt, i, j, number
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countBits ( int a , int b ) { int count = 0 ; while ( a > 0 b > 0 ) { int last_bit_a = a & 1 ; int last_bit_b = b & 1 ; if ( last_bit_a != last_bit_b ) count ++ ; a = a >> 1 ; b = b >> 1 ; } return count ; } public static void Main ( String [ ] args ) { int a = 10 , b = 7 ; Console . WriteLine ( countBits ( a , b ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountSetBits ( int n ) { if ( n == 0 ) return 0 ; if ( ( n & 1 ) == 1 ) return 1 + CountSetBits ( n >> 1 ) ; else return CountSetBits ( n >> 1 ) ; } public static void Main ( ) { int n = 21 ; Console . WriteLine ( CountSetBits ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int getSum ( int [ ] BITree , int index ) { int sum = 0 ; while ( index > 0 ) { sum += BITree [ index ] ; index -= index & ( - index ) ; } return sum ; } public static void updateBIT ( int [ ] BITree , int n , int index , int val ) { while ( index <= n ) { BITree [ index ] += val ; index += index & ( - index ) ; } } public static void convert ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) temp [ i ] = arr [ i ] ; Array . Sort ( temp ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Array . BinarySearch ( temp , arr [ i ] ) + 1 ; } } public static void findElements ( int [ ] arr , int n ) { convert ( arr , n ) ; int [ ] BIT = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) BIT [ i ] = 0 ; int [ ] smaller_right = new int [ n ] ; int [ ] greater_left = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { smaller_right [ i ] = getSum ( BIT , arr [ i ] - 1 ) ; updateBIT ( BIT , n , arr [ i ] , 1 ) ; } Console . Write ( " Smaller ▁ right : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( smaller_right [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; for ( int i = 1 ; i <= n ; i ++ ) BIT [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { greater_left [ i ] = i - getSum ( BIT , arr [ i ] ) ; updateBIT ( BIT , n , arr [ i ] , 1 ) ; } Console . Write ( " Greater ▁ left : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( greater_left [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 1 , 2 , 3 , 0 , 11 , 4 } ; int n = arr . Length ; findElements ( arr , n ) ; } }

Index/key variables: i, index, n
Accumulator variables: i, index, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int pairORSum ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) ans += arr [ i ] | arr [ j ] ; return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; Console . Write ( pairORSum ( arr , n ) ) ; } }

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 bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) { if ( ( n % i ) == 0 ) return false ; } return true ; } static void countPrimePosition ( int [ ] arr ) { int c0 = 0 , c1 = 0 ; int n = arr . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] == 0 ) && ( isPrime ( i ) ) ) c0 ++ ; if ( ( arr [ i ] == 1 ) && ( isPrime ( i ) ) ) c1 ++ ; } Console . WriteLine ( " Number ▁ of ▁ 0s ▁ = ▁ " + c0 ) ; Console . WriteLine ( " Number ▁ of ▁ 1s ▁ = ▁ " + c1 ) ; } static public void Main ( ) { int [ ] arr = { 1 , 0 , 1 , 0 , 1 } ; countPrimePosition ( arr ) ; } }

Index/key variables: i
Accumulator variables: c0, c1, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long multiplyByFifteen ( long n ) { long prod = ( n << 4 ) ; prod = prod - n ; return prod ; } public static void Main ( ) { long n = 7 ; Console . Write ( multiplyByFifteen ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static long multiplyByFifteen ( long n ) { long prod = ( n << 3 ) ; prod += ( n << 2 ) ; prod += ( n << 1 ) ; prod += n ; return prod ; } public static void Main ( ) { long n = 7 ; Console . Write ( multiplyByFifteen ( n ) ) ; } }

Accumulator variables: prod
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { public static void findX ( int [ ] a , int n ) { int itr = a . Max ( ) ; int p = ( int ) Math . Log ( itr , 2 ) + 1 ; int x = 0 ; for ( int i = 0 ; i < p ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( a [ j ] & ( 1 << i ) ) != 0 ) count ++ ; } if ( count > ( n / 2 ) ) { x += 1 << i ; } } long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += ( x ^ a [ i ] ) ; Console . Write ( " X ▁ = ▁ " + x + " , ▁ Sum ▁ = ▁ " + sum ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 4 , 5 , 6 } ; int n = a . Length ; findX ( a , n ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, sum, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = new int [ 33 ] ; static void balTernary ( int ter ) { int carry = 0 , b = 10 ; int i = 32 ; while ( ter > 0 ) { int rem = ter % b ; rem = rem + carry ; if ( rem == 0 ) { arr [ i -- ] = 0 ; carry = 0 ; } else if ( rem == 1 ) { arr [ i -- ] = 1 ; carry = 0 ; } else if ( rem == 2 ) { arr [ i -- ] = - 1 ; carry = 1 ; } else if ( rem == 3 ) { arr [ i -- ] = 0 ; carry = 1 ; } ter = ( int ) ( ter / b ) ; } if ( carry == 1 ) arr [ i ] = 1 ; } static int ternary ( int number ) { int ans = 0 , rem = 1 , b = 1 ; while ( number > 0 ) { rem = number % 3 ; ans = ans + rem * b ; number = ( int ) ( number / 3 ) ; b = b * 10 ; } return ans ; } public static void Main ( String [ ] args ) { int number = 3056 ; int ter = ternary ( number ) ; balTernary ( ter ) ; int i = 0 ; while ( arr [ i ] == 0 ) { i ++ ; } for ( int j = i ; j <= 32 ; j ++ ) { if ( arr [ j ] == - 1 ) Console . Write ( ' Z ' ) ; else Console . Write ( arr [ j ] ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
C# program:
class GFG { static void minAND ( int [ ] arr , int n ) { int s = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { s = s & arr [ i ] ; } System . Console . WriteLine ( s ) ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 } ; int n = arr . Length ; minAND ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( a [ i ] == 1 ) return true ; return false ; } public static void Main ( ) { int [ ] a = { 0 , 1 , 0 , 1 } ; int n = a . Length ; if ( check ( a , n ) == true ) Console . Write ( " YES STRNEWLINE " ) ; else Console . Write ( " NO STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void findArray ( int [ ] q , int n ) { int ans ; int [ ] arr = new int [ n ] ; for ( int k = 0 , j = 0 ; j < n / 4 ; j ++ ) { ans = q [ k ] ^ q [ k + 3 ] ; arr [ k + 1 ] = q [ k + 1 ] ^ ans ; arr [ k + 2 ] = q [ k + 2 ] ^ ans ; arr [ k ] = q [ k ] ^ ( ( arr [ k + 1 ] ) ^ ( arr [ k + 2 ] ) ) ; arr [ k + 3 ] = q [ k + 3 ] ^ ( arr [ k + 1 ] ^ arr [ k + 2 ] ) ; k += 4 ; } printArray ( arr , n ) ; } public static void Main ( ) { int [ ] q = { 4 , 1 , 7 , 0 } ; int n = q . Length ; findArray ( q , n ) ; } }

Index/key variables: i, k, n
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int countX ( int n ) { string binary = Convert . ToString ( n , 2 ) ; int count = 0 ; for ( int i = 0 ; i < binary . Length ; i ++ ) { if ( binary [ i ] == '1' ) count ++ ; } int answer = ( int ) Math . Pow ( 2 , count ) ; return answer ; } public static void Main ( ) { int n = 5 ; int answer = countX ( n ) ; Console . WriteLine ( answer ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isEqualBlock ( int n ) { int first_bit = n % 2 ; int first_count = 1 ; n = n / 2 ; while ( n % 2 == first_bit && n > 0 ) { n = n / 2 ; first_count ++ ; } if ( n == 0 ) return false ; while ( n > 0 ) { first_bit = n % 2 ; int curr_count = 1 ; n = n / 2 ; while ( n % 2 == first_bit ) { n = n / 2 ; curr_count ++ ; } if ( curr_count != first_count ) return false ; } return true ; } public static void Main ( ) { int n = 51 ; if ( isEqualBlock ( n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: curr_count, first_count
Class/struct names: GFG
C# program:
using System ; class GFG { static void binToDecimal3 ( int n ) { int [ ] a = new int [ 64 ] ; int x = 0 , i ; for ( i = 0 ; n > 0 ; i ++ ) { a [ i ] = n % 2 ; n /= 2 ; } x = ( i < 3 ) ? 3 : i ; int d = 0 , p = 0 ; for ( int j = x - 3 ; j < x ; j ++ ) d += a [ j ] * ( int ) Math . Pow ( 2 , p ++ ) ; int d1 = d ; d = 0 ; p = 0 ; for ( int k = 0 ; k < 3 ; k ++ ) d += a [ k ] * ( int ) Math . Pow ( 2 , p ++ ) ; Console . WriteLine ( d1 + " ▁ " + d ) ; } static void Main ( ) { int n = 86 ; binToDecimal3 ( n ) ; } }

Index/key variables: i, j, k
Accumulator variables: d, i, j, k, n, p
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void binToDecimal3 ( int n ) { int last_3 = ( ( n & 4 ) + ( n & 2 ) + ( n & 1 ) ) ; n = n >> 3 ; while ( n > 7 ) n = n >> 1 ; int first_3 = ( ( n & 4 ) + ( n & 2 ) + ( n & 1 ) ) ; Console . WriteLine ( first_3 + " ▁ " + last_3 ) ; } static public void Main ( ) { int n = 86 ; binToDecimal3 ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPowerOfTwo ( int x ) { if ( x == 0 ) return false ; if ( ( x & ( x - 1 ) ) == 0 ) return true ; else return false ; } static int countNum ( int [ ] a , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPowerOfTwo ( a [ i ] ) || isPowerOfTwo ( a [ i ] + 1 ) ) count ++ ; } return count ; } public static void Main ( ) { int [ ] arr = { 5 , 6 , 9 , 3 , 1 } ; int n = arr . Length ; Console . WriteLine ( countNum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkEvenParity ( int x ) { int parity = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; parity ++ ; } if ( parity % 2 == 0 ) return true ; else return false ; } static long sumlist ( int [ ] a , int n ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( checkEvenParity ( a [ i ] ) ) sum += a [ i ] ; } return sum ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 3 , 5 , 9 } ; int n = arr . Length ; Console . WriteLine ( sumlist ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, parity, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findOddPair ( int [ ] A , int N ) { int oddPair = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] A [ j ] ) % 2 != 0 ) oddPair ++ ; } } return oddPair ; } static public void Main ( ) { int [ ] A = { 5 , 6 , 2 , 8 } ; int N = A . Length ; Console . WriteLine ( findOddPair ( A , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, oddPair
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findevenPair ( int [ ] A , int N ) { int i , j ; int evenPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] ^ A [ j ] ) % 2 == 0 ) evenPair ++ ; } } return evenPair ; } public static void Main ( ) { int [ ] A = { 5 , 4 , 7 , 2 , 1 } ; int N = A . Length ; Console . WriteLine ( findevenPair ( A , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: evenPair, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findEvenPair ( int [ ] A , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 != 0 ) count ++ ; } int totalPairs = ( N * ( N - 1 ) / 2 ) ; int oddEvenPairs = count * ( N - count ) ; return totalPairs - oddEvenPairs ; } public static void Main ( ) { int [ ] a = { 5 , 4 , 7 , 2 , 1 } ; int n = a . Length ; Console . Write ( findEvenPair ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findevenPair ( int [ ] A , int N ) { int i , j ; int evenPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] & A [ j ] ) % 2 == 0 ) evenPair ++ ; } } return evenPair ; } public static void Main ( ) { int [ ] a = { 5 , 1 , 3 , 2 } ; int n = a . Length ; Console . WriteLine ( findevenPair ( a , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: evenPair, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findevenPair ( int [ ] A , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( A [ i ] % 2 != 0 ) count ++ ; int oddCount = count * ( count - 1 ) / 2 ; return ( N * ( N - 1 ) / 2 ) - oddCount ; } static public void Main ( ) { int [ ] a = { 5 , 1 , 3 , 2 } ; int n = a . Length ; Console . WriteLine ( findevenPair ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculate ( int X ) { int number_of_bits = 8 ; return ( ( 1 << number_of_bits ) - 1 ) ^ X ; } public static void Main ( ) { int X = 4 ; Console . WriteLine ( " Required ▁ Number ▁ is ▁ : ▁ " + calculate ( X ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Linq ; class GFG { static int xorGivenSetBits ( int [ ] arr , int n , int k ) { ArrayList v = new ArrayList ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( Convert . ToString ( arr [ i ] , 2 ) . Count ( c => c == '1' ) == k ) { v . Add ( arr [ i ] ) ; } } int result = ( int ) v [ 0 ] ; for ( int i = 1 ; i < v . Count ; i ++ ) result = result ^ ( int ) v [ i ] ; return result ; } static void Main ( ) { int [ ] arr = { 2 , 13 , 1 , 19 , 7 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( xorGivenSetBits ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void ReplaceElements ( int [ ] arr , int n ) { int X = 0 ; for ( int i = 0 ; i < n ; ++ i ) { X ^= arr [ i ] ; } for ( int i = 0 ; i < n ; ++ i ) { arr [ i ] = X ^ arr [ i ] ; } } static public void Main ( ) { int [ ] arr = { 2 , 3 , 3 , 5 , 5 } ; int n = arr . Length ; ReplaceElements ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i
Accumulator variables: X
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countLeadingZeros ( int x ) { int y ; int n ; n = 32 ; y = x >> 16 ; if ( y != 0 ) { n = n - 16 ; x = y ; } y = x >> 8 ; if ( y != 0 ) { n = n - 8 ; x = y ; } y = x >> 4 ; if ( y != 0 ) { n = n - 4 ; x = y ; } y = x >> 2 ; if ( y != 0 ) { n = n - 2 ; x = y ; } y = x >> 1 ; if ( y != 0 ) return n - 2 ; return n - x ; } static int FindStringof1s ( int x , int n ) { int k , p ; p = 0 ; while ( x != 0 ) { k = countLeadingZeros ( x ) ; x = x << k ; p = p + k ; k = countLeadingZeros ( ~ x ) ; if ( k >= n ) return p + 1 ; x = x << k ; p = p + k ; } return - 1 ; } static public void Main ( ) { int x = 35 ; int n = 2 ; Console . WriteLine ( FindStringof1s ( x , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int alternate ( int a , int b , int x ) { return x = a ^ b ^ x ; } public static void Main ( ) { int a = - 10 ; int b = 15 ; int x = a ; Console . Write ( " x ▁ is ▁ : ▁ " + x ) ; x = alternate ( a , b , x ) ; Console . Write ( " STRNEWLINE After ▁ exchange ▁ " ) ; Console . Write ( " x is : " } }

Class/struct names: GFG
C# program:
using System ; class GFG { static byte sizeofInt = 8 ; static int countZeros ( int x ) { int total_bits = sizeofInt * 8 ; int res = 0 ; while ( ( x & ( 1 << ( total_bits - 1 ) ) ) == 0 ) { x = ( x << 1 ) ; res ++ ; } return res ; } public static void Main ( String [ ] args ) { int x = 101 ; Console . WriteLine ( countZeros ( x ) ) ; } }

Accumulator variables: res
Class/struct names: GFG
C# program:
using System ; class GFG { static int countZeros ( int x ) { int y ; int n = 32 ; y = x >> 16 ; if ( y != 0 ) { n = n - 16 ; x = y ; } y = x >> 8 ; if ( y != 0 ) { n = n - 8 ; x = y ; } y = x >> 4 ; if ( y != 0 ) { n = n - 4 ; x = y ; } y = x >> 2 ; if ( y != 0 ) { n = n - 2 ; x = y ; } y = x >> 1 ; if ( y != 0 ) return n - 2 ; return n - x ; } static public void Main ( ) { int x = 101 ; Console . WriteLine ( countZeros ( x ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void LeadingZeros ( int x , int y ) { if ( ( x ^ y ) <= ( x & y ) ) Console . WriteLine ( " STRNEWLINE Equal " ) ; else if ( ( x & ( ~ y ) ) > y ) Console . WriteLine ( y ) ; else Console . WriteLine ( x ) ; } static public void Main ( ) { int x = 10 , y = 16 ; LeadingZeros ( x , y ) ; } }

Class/struct names: GFG
C# program:
using System ; class GfG { static void printSubSets ( int numOfBits , int num ) { if ( num >= 0 ) { Console . Write ( " { ▁ " ) ; subset ( numOfBits - 1 , num , numOfBits ) ; Console . WriteLine ( " } " ) ; printSubSets ( numOfBits , num - 1 ) ; } else return ; } static void subset ( int nthBit , int num , int numOfBits ) { if ( nthBit >= 0 ) { if ( ( num & ( 1 << nthBit ) ) != 0 ) { Console . Write ( numOfBits - nthBit + " ▁ " ) ; } subset ( nthBit - 1 , num , numOfBits ) ; } else return ; } public static void Main ( String [ ] args ) { int n = 4 ; printSubSets ( n , ( int ) ( Math . Pow ( 2 , n ) ) - 1 ) ; } }

Class/struct names: GfG
C# program:
using System ; class GFG { static void solve ( int A , int B ) { int count = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { if ( ( ( A >> i ) & 1 ) != ( ( B >> i ) & 1 ) ) { count ++ ; } } Console . WriteLine ( " Number ▁ of ▁ different ▁ bits ▁ : ▁ " + count ) ; } public static void Main ( ) { int A = 12 , B = 15 ; solve ( A , B ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int setRightmostUnsetBit ( int n ) { if ( ( n & ( n + 1 ) ) == 0 ) return n ; return n | ( n + 1 ) ; } public static void Main ( ) { int n = 21 ; Console . WriteLine ( setRightmostUnsetBit ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static void printSetBit ( Node root ) { if ( root == null ) return ; Console . Write ( " Set ▁ bits ▁ in ▁ Node ▁ " + root . data + " ▁ = ▁ " + bitCount ( root . data ) + " STRNEWLINE " ) ; printSetBit ( root . left ) ; printSetBit ( root . right ) ; } static int bitCount ( int x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { Node root = newNode ( 16 ) ; root . left = newNode ( 13 ) ; root . left . left = newNode ( 14 ) ; root . left . right = newNode ( 12 ) ; root . right = newNode ( 11 ) ; root . right . left = newNode ( 10 ) ; root . right . right = newNode ( 16 ) ; printSetBit ( root ) ; } }

Accumulator variables: setBits
Class/struct names: GFG, Node
C# program:
using System ; public class GFG { static int AND ( int [ ] a , int n ) { int ans = a [ 0 ] ; for ( int i = 0 ; i < n ; ++ i ) ans &= a [ i ] ; return ans ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 } ; int n = a . Length ; Console . WriteLine ( AND ( a , n ) ) ; } }

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