dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void TwoscomplementbyXOR ( string str ) { int n = str . Length ; bool check_bit = false ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == '0' && check_bit == false ) { continue ; } else { if ( check_bit == true ) { if ( str [ i ] == '0' ) str = str . Substring ( 0 , i ) + '1' + str . Substring ( i + 1 ) ; else str = str . Substring ( 0 , i ) + '0' + str . Substring ( i + 1 ) ; } check_bit = true ; } } if ( check_bit == false ) { Console . WriteLine ( "1" + str ) ; } else Console . WriteLine ( str ) ; } static void Main ( ) { string str = "101" ; TwoscomplementbyXOR ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: check_bit
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isKthBitSet ( int n , int k ) { if ( ( n >> ( k - 1 ) ) == 1 ) return true ; return false ; } static int setKthBit ( int n , int k ) { return ( ( 1 << ( k - 1 ) ) n ) ; } static bool allBitsAreSet ( int n ) { if ( ( ( n + 1 ) & n ) == 0 ) return true ; return false ; } static bool bitsAreInAltOrder ( int n ) { int num = n ^ ( n >> 1 ) ; return allBitsAreSet ( num ) ; } static bool bitsAreInAltPatrnInGivenRange ( int n , int l , int r ) { int num , left_shift ; if ( isKthBitSet ( n , r ) ) { num = n ; left_shift = r ; } else { num = setKthBit ( n , ( r + 1 ) ) ; left_shift = r + 1 ; } num = num & ( ( 1 << left_shift ) - 1 ) ; num = num >> ( l - 1 ) ; return bitsAreInAltOrder ( num ) ; } public static void Main ( ) { int n = 18 ; int l = 1 , r = 3 ; if ( bitsAreInAltPatrnInGivenRange ( n , l , r ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool bitsAreInAltPatrnInGivenTRange ( int n , int l , int r ) { int num , prev , curr ; num = n >> ( l - 1 ) ; prev = num & 1 ; num = num >> 1 ; for ( int i = 1 ; i <= ( r - l ) ; i ++ ) { curr = num & 1 ; if ( curr == prev ) return false ; prev = curr ; num = num >> 1 ; } return true ; } static void Main ( ) { int n = 18 ; int l = 1 , r = 3 ; if ( bitsAreInAltPatrnInGivenTRange ( n , l , r ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long increment ( long i ) { i = - ( ~ i ) ; return i ; } public static void Main ( ) { long n = 3 ; Console . WriteLine ( increment ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void MakePreSum ( int [ ] arr , int [ ] presum , int n ) { presum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) presum [ i ] = presum [ i - 1 ] + arr [ i ] ; } static int BinaryLifting ( int [ ] presum , int n , int x ) { int pos = 0 ; int LOGN = ( int ) Math . Log ( n ) ; if ( x <= presum [ 0 ] ) return 0 ; for ( int i = LOGN ; i >= 0 ; i -- ) { if ( pos + ( 1 << i ) < n && presum [ pos + ( 1 << i ) ] < x ) { pos += ( 1 << i ) ; } } return pos + 1 ; } public static void Main ( ) { int [ ] arr = { 2 , 5 , 7 , 1 , 6 , 9 , 12 , 4 , 6 } ; int x = 8 ; int n = arr . Length ; int [ ] presum = new int [ n ] ; MakePreSum ( arr , presum , n ) ; Console . WriteLine ( BinaryLifting ( presum , n , x ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, pos
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int bit_count ( int n ) { int count = 0 ; while ( n > 0 ) { count ++ ; n = n & ( n - 1 ) ; } return count ; } static int maxsum ( int [ ] arr , int n ) { int [ ] bits = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { bits [ i ] = bit_count ( arr [ i ] ) ; } int [ ] sum = new int [ 32 ] ; for ( int i = 0 ; i < n ; i ++ ) { sum [ bits [ i ] ] += arr [ i ] ; } int maximum = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { maximum = Math . Max ( sum [ i ] , maximum ) ; } return maximum ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 8 , 5 , 6 , 7 } ; int n = arr . Length ; Console . WriteLine ( maxsum ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int xorPairSum ( int [ ] ar , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum ^ ar [ i ] ; return 2 * sum ; } static public void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 } ; int n = arr . Length ; Console . WriteLine ( xorPairSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findEvenPair ( int [ ] A , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( ( ! ( ( A [ i ] & 1 ) > 0 ) ) ) count ++ ; return count * ( count - 1 ) / 2 ; } public static void Main ( String [ ] args ) { int [ ] A = { 5 , 6 , 2 , 8 } ; 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 bool allBitsSetInTheGivenRange ( int n , int l , int r ) { int num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; int new_num = n & num ; if ( new_num == 0 ) return true ; return false ; } public static void Main ( ) { int n = 17 ; int l = 2 , r = 4 ; if ( allBitsSetInTheGivenRange ( n , l , r ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static bool checkSame ( int n ) { int set = 0 ; int unset = 0 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) set ++ ; else unset ++ ; n = n >> 1 ; } if ( set == unset ) return true ; else return false ; } static public void Main ( ) { int n = 12 ; if ( checkSame ( n ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Accumulator variables: set, unset
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isBalanced ( String s ) { Stack < char > st = new Stack < char > ( ) ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ( ' ) { st . Push ( s [ i ] ) ; } else if ( st . Count == 0 ) { return false ; } else { st . Pop ( ) ; } } if ( st . Count != 0 ) { return false ; } return true ; } static bool isBalancedSeq ( String s1 , String s2 ) { if ( isBalanced ( s1 + s2 ) ) { return true ; } return isBalanced ( s2 + s1 ) ; } public static void Main ( String [ ] args ) { String s1 = " ) ( ) ( ( ) ) ) ) " ; String s2 = " ( ( ) ( ( ) ( " ; if ( isBalancedSeq ( s1 , s2 ) ) { Console . WriteLine ( " Balanced " ) ; } else { Console . WriteLine ( " Not ▁ Balanced " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void KthCharacter ( int m , int n , int k ) { int distance = ( int ) Math . Pow ( 2 , n ) ; int Block_number = k / distance ; int remaining = k % distance ; int [ ] s = new int [ 32 ] ; int x = 0 ; for ( ; m > 0 ; x ++ ) { s [ x ] = m % 2 ; m = m / 2 ; } int root = s [ x - 1 - Block_number ] ; if ( remaining == 0 ) { Console . WriteLine ( root ) ; return ; } Boolean flip = true ; while ( remaining > 1 ) { if ( ( remaining & 1 ) > 0 ) { flip = ! flip ; } remaining = remaining >> 1 ; } if ( flip ) { Console . WriteLine ( ! ( root > 0 ) ) ; } else { Console . WriteLine ( root ) ; } } public static void Main ( ) { int m = 5 , k = 5 , n = 3 ; KthCharacter ( m , n , k ) ; } }

Index/key variables: x
Accumulator variables: x
Boolean variables: flip
Class/struct names: GFG
C# program:
using System ; class GFG { static bool onlyFirstAndLastAreSet ( int n ) { if ( n == 1 ) return true ; if ( n == 2 ) return false ; return ( ( ( n - 1 ) & ( n - 2 ) ) == 0 ) ; } public static void Main ( ) { int n = 9 ; if ( onlyFirstAndLastAreSet ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int getInteger ( int L , int R ) { int number = 0 ; for ( int i = L ; i <= R ; i ++ ) number += ( int ) Math . Pow ( 2 , i ) ; return number ; } public static void Main ( ) { int L = 2 , R = 5 ; Console . Write ( getInteger ( L , R ) ) ; } }

Accumulator variables: i, number
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int setbitsfromLtoR ( int L , int R ) { return ( 1 << ( R + 1 ) ) - ( 1 << L ) ; } public static void Main ( ) { int L = 2 , R = 5 ; Console . WriteLine ( setbitsfromLtoR ( L , R ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int findXor ( int [ ] arr , int n ) { int xoR = 0 ; for ( int i = 0 ; i < n ; i ++ ) { xoR = xoR ^ arr [ i ] ; } return xoR * 2 ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 6 } ; int n = arr . Length ; Console . WriteLine ( findXor ( 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 void setBitwiseORk ( int n ) { List < int > v = new List < int > ( ) ; for ( int i = 0 ; i <= n ; i ++ ) { if ( ( i n ) == n ) { v . Add ( i ) ; } } for ( int i = 0 ; i < v . Count ; i ++ ) { Console . Write ( v [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int n = 5 ; setBitwiseORk ( n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printOdds ( int [ ] arr , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res = res ^ arr [ i ] ; int set_bit = res & ( ~ ( res - 1 ) ) ; int x = 0 , y = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & set_bit ) != 0 ) x = x ^ arr [ i ] ; else y = y ^ arr [ i ] ; } Console . WriteLine ( x + " ▁ " + y ) ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 3 , 4 , 4 , 5 } ; int n = arr . Length ; printOdds ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void subsetBitwiseORk ( int [ ] arr , int n , int k ) { ArrayList v = new ArrayList ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] k ) == k ) { v . Add ( arr [ i ] ) ; } } int ans = 0 ; for ( int i = 0 ; i < v . Count ; i ++ ) ans = ans | ( int ) v [ i ] ; if ( ans != k ) { Console . WriteLine ( " Subset ▁ does " + " ▁ not ▁ exist " ) ; return ; } for ( int i = 0 ; i < v . Count ; i ++ ) Console . Write ( ( int ) v [ i ] + " ▁ " ) ; } static public void Main ( String [ ] args ) { int k = 3 ; int [ ] arr = { 1 , 4 , 2 } ; int n = arr . Length ; subsetBitwiseORk ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findEletobeInserted ( int [ ] A , int n , int k ) { int ans = k ; for ( int i = 0 ; i < n ; i ++ ) ans ^= A [ i ] ; return ans ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 3 , 4 , 5 } ; int n = A . Length ; int k = 10 ; Console . WriteLine ( findEletobeInserted ( A , n , k ) + " ▁ has ▁ to ▁ be ▁ inserted ▁ in ▁ " + " the ▁ given ▁ array ▁ to ▁ make " + " ▁ xor ▁ sum ▁ of ▁ " + k ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] BitCount = new int [ 10000 ] ; static void fillSetBitsMatrix ( int [ ] arr , int n ) { for ( int i = 0 ; i < 32 ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { long temp = arr [ j ] >> i ; if ( temp % 2 != 0 ) BitCount [ j ] += 1 ; } } for ( int i = 1 ; i < n ; i ++ ) BitCount [ i ] += BitCount [ i - 1 ] ; } static void Query ( int [ , ] Q , int q ) { for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( ( BitCount [ Q [ i , 1 ] ] - BitCount [ Q [ i , 0 ] - 1 ] ) ) ; } public static void Main ( ) { int [ ] Arr = { 1 , 5 , 6 , 10 , 9 , 4 , 67 } ; int n = Arr . Length ; fillSetBitsMatrix ( Arr , n ) ; int q = 2 ; int [ , ] Q = { { 1 , 5 } , { 2 , 6 } } ; Query ( Q , q ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void decimalToBinaryNumber ( int x , int n ) { int [ ] binaryNumber = new int [ x ] ; int i = 0 ; while ( x > 0 ) { binaryNumber [ i ] = x % 2 ; x = x / 2 ; i ++ ; } for ( int j = 0 ; j < n - i ; j ++ ) Console . Write ( '0' ) ; for ( int j = i - 1 ; j >= 0 ; j -- ) Console . Write ( binaryNumber [ j ] ) ; } static void generateGrayarr ( int n ) { int N = 1 << n ; for ( int i = 0 ; i < N ; i ++ ) { int x = i ^ ( i >> 1 ) ; decimalToBinaryNumber ( x , n ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { int n = 3 ; generateGrayarr ( n ) ; } }

Index/key variables: i, j, x
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int BITS = 32 ; static int andSum ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < BITS ; i ++ ) { int countSetBits = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) != 0 ) countSetBits ++ ; } int subset = ( 1 << countSetBits ) - 1 ; subset = ( subset * ( 1 << i ) ) ; ans += subset ; } return ans ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 } ; int size = 3 ; Console . WriteLine ( andSum ( arr , size ) ) ; } }

Index/key variables: j
Accumulator variables: ans, countSetBits, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long _popcnt32 ( long n ) { long count = 0 ; while ( n != 0 ) { n = n & ( n - 1 ) ; count ++ ; } return count ; } static long maximize ( long a ) { long n = _popcnt32 ( a ) ; if ( n == 32 ) return a ; long res = ( 1 << Convert . ToInt32 ( n ) ) - 1 ; return ( res << ( 32 - Convert . ToInt32 ( n ) ) ) ; } static void Main ( ) { long a = 3 ; Console . WriteLine ( maximize ( a ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static long minimize ( long a ) { string binaryString = Convert . ToString ( a , 2 ) ; int n = binaryString . Split ( new [ ] { '0' } , StringSplitOptions . RemoveEmptyEntries ) . Length + 1 ; return ( ( long ) Math . Pow ( 2 , n ) - 1 ) ; } static void Main ( ) { long a = 11 ; Console . Write ( minimize ( a ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { 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 i = 3 ; Console . Write ( countSetBits ( i ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool isEven ( int n ) { bool isEven = true ; for ( int i = 1 ; i <= n ; i ++ ) isEven = ! isEven ; return isEven ; } public static void Main ( ) { int n = 101 ; if ( isEven ( n ) ) Console . Write ( " Even " ) ; else Console . Write ( " Odd " ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: isEven
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isEven ( int n ) { return ( ( n / 2 ) * 2 == n ) ; } public static void Main ( String [ ] args ) { int n = 101 ; if ( isEven ( n ) != false ) Console . Write ( " Even " ) ; else Console . Write ( " Odd " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int add ( int x , int y ) { int keep = ( x & y ) << 1 ; int res = x ^ y ; if ( keep == 0 ) return res ; return add ( keep , res ) ; } public static void Main ( ) { Console . Write ( add ( 15 , 38 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkValidPair ( int num1 , int num2 ) { string s1 = num1 . ToString ( ) ; string s2 = num2 . ToString ( ) ; for ( int i = 0 ; i < s1 . Length ; i ++ ) for ( int j = 0 ; j < s2 . Length ; j ++ ) if ( s1 [ i ] == s2 [ j ] ) return true ; return false ; } static int countPairs ( int [ ] arr , int n ) { int numberOfPairs = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( checkValidPair ( arr [ i ] , arr [ j ] ) ) numberOfPairs ++ ; return numberOfPairs ; } static void Main ( ) { int [ ] arr = new int [ ] { 10 , 12 , 24 } ; int n = arr . Length ; Console . WriteLine ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, numberOfPairs
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int NUM_BITS = 32 ; static bool isPowerOf2 ( int num ) { if ( num != 0 && ( num & ( num - 1 ) ) == 0 ) return true ; return false ; } static bool checkSubsequence ( int [ ] arr , int n ) { if ( n == 1 ) return isPowerOf2 ( arr [ 0 ] ) ; int total = 0 ; for ( int i = 0 ; i < NUM_BITS ; i ++ ) total = total | ( 1 << i ) ; for ( int i = 0 ; i < NUM_BITS ; i ++ ) { int ans = total ; for ( int j = 0 ; j < n ; j ++ ) { int p = arr [ j ] & ( 1 << i ) ; if ( p == 0 ) ans = ans & arr [ j ] ; } if ( isPowerOf2 ( ans ) ) return true ; } return false ; } public static void Main ( ) { int [ ] arr = { 12 , 13 , 7 } ; int n = arr . Length ; if ( checkSubsequence ( arr , n ) ) Console . Write ( " YES STRNEWLINE " ) ; else Console . Write ( " NO STRNEWLINE " ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMid ( int s , int e ) { return s + ( e - s ) / 2 ; } static void constructSTUtil ( int [ ] arr , int ss , int se , int [ ] st , int si , bool operation ) { if ( ss == se ) { st [ si ] = arr [ ss ] ; return ; } int mid = getMid ( ss , se ) ; constructSTUtil ( arr , ss , mid , st , si * 2 + 1 , ! operation ) ; constructSTUtil ( arr , mid + 1 , se , st , si * 2 + 2 , ! operation ) ; if ( operation ) { st [ si ] = ( st [ 2 * si + 1 ] st [ 2 * si + 2 ] ) ; } else { st [ si ] = ( st [ 2 * si + 1 ] ^ st [ 2 * si + 2 ] ) ; } } static int [ ] constructST ( int [ ] arr , int n ) { int x = ( int ) ( Math . Ceiling ( Math . Log ( n ) / Math . Log ( 2 ) ) ) ; int max_size = 2 * ( int ) Math . Pow ( 2 , x ) - 1 ; int [ ] st = new int [ max_size ] ; bool operationAtRoot = ! ( x % 2 == 0 ) ; constructSTUtil ( arr , 0 , n - 1 , st , 0 , operationAtRoot ) ; return st ; } static public void Main ( ) { int [ ] leaves = { 1 , 6 , 3 , 7 , 5 , 9 , 10 , 4 } ; int n = leaves . Length ; int [ ] segmentTree = constructST ( leaves , n ) ; int rootIndex = 0 ; Console . WriteLine ( " Value ▁ at ▁ Root ▁ Node ▁ = ▁ " + segmentTree [ rootIndex ] ) ; } }

Index/key variables: max_size, rootIndex, si, ss
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 1000 ; static int lastElement ( int [ ] a , int n ) { int steps = 1 ; List < int > [ ] v = new List < int > [ N ] ; for ( int i = 0 ; i < N ; i ++ ) v [ i ] = new List < int > ( ) ; if ( n == 1 ) return a [ 0 ] ; for ( int i = 0 ; i < n ; i += 2 ) v [ steps ] . Add ( a [ i ] a [ i + 1 ] ) ; while ( v [ steps ] . Count > 1 ) { steps += 1 ; for ( int i = 0 ; i < v [ steps - 1 ] . Count ; i += 2 ) { if ( steps % 2 == 1 ) v [ steps ] . Add ( v [ steps - 1 ] [ i ] v [ steps - 1 ] [ i + 1 ] ) ; v [ steps ] . Add ( v [ steps - 1 ] [ i ] ^ v [ steps - 1 ] [ i + 1 ] ) ; } } return v [ steps ] [ 0 ] ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 4 , 5 , 6 } ; int n = a . Length ; int index = 0 ; int value = 2 ; a [ 0 ] = 2 ; Console . WriteLine ( lastElement ( a , n ) ) ; index = 3 ; value = 5 ; a [ index ] = value ; Console . WriteLine ( lastElement ( a , n ) ) ; } }

Index/key variables: N, i, index, steps
Accumulator variables: i, steps
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String findWinner ( int [ ] A , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res ^= A [ i ] ; if ( res == 0 n % 2 == 0 ) return " Alice " ; else return " Bob " ; } public static void Main ( ) { int [ ] A = { 1 , 4 , 3 , 5 } ; int n = A . Length ; Console . WriteLine ( " Winner ▁ = ▁ " + findWinner ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isFibbinaryNum ( int n ) { if ( ( n & ( n >> 1 ) ) == 0 ) return true ; return false ; } public static void Main ( ) { int n = 10 ; if ( isFibbinaryNum ( n ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxXOR ( int n , int k ) { int c = ( int ) ( Math . Log ( n ) / Math . Log ( 2 ) ) + 1 ; return ( ( 1 << c ) - 1 ) ; } public static void Main ( String [ ] args ) { int n = 12 ; int k = 3 ; Console . Write ( maxXOR ( n , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static long divide ( long dividend , long divisor ) { long sign = ( ( dividend < 0 ) ^ ( divisor < 0 ) ) ? - 1 : 1 ; dividend = Math . Abs ( dividend ) ; divisor = Math . Abs ( divisor ) ; long quotient = 0 , temp = 0 ; for ( int i = 31 ; i >= 0 ; -- i ) { if ( temp + ( divisor << i ) <= dividend ) { temp += divisor << i ; quotient |= 1L L << i ; } } if ( sign == - 1 ) quotient = - quotient ; return quotient ; } public static void Main ( ) { int a = 10 , b = 3 ; Console . WriteLine ( divide ( a , b ) ) ; int a1 = 43 , b1 = - 8 ; Console . WriteLine ( divide ( a1 , b1 ) ) ; } }

Accumulator variables: quotient, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( int n ) { int c = 0 ; while ( n != 0 ) { c ++ ; n = n >> 1 ; } return c ; } static int XOR ( int a , int b ) { int c = Math . Min ( a , b ) ; int d = Math . Max ( a , b ) ; if ( count ( c ) < count ( d ) ) c = c << ( count ( d ) - count ( c ) ) ; return ( c ^ d ) ; } public static void Main ( ) { int a = 13 , b = 5 ; Console . WriteLine ( XOR ( a , b ) ) ; } }

Accumulator variables: c
Class/struct names: GFG
C# program:
using System ; public class GFG { static void CheckDivisibilty ( String A ) { int oddbits = 0 , evenbits = 0 ; for ( int counter = 0 ; counter < A . Length ; counter ++ ) { if ( A [ counter ] == '1' ) { if ( counter % 2 == 0 ) { evenbits ++ ; } else { oddbits ++ ; } } } if ( Math . Abs ( oddbits - evenbits ) % 3 == 0 ) { Console . Write ( " Yes " + " STRNEWLINE " ) ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { String A = "10101" ; CheckDivisibilty ( A ) ; } }

Index/key variables: counter
Accumulator variables: counter, evenbits, oddbits
Iterator variables: counter
Class/struct names: GFG
C# program:
using System ; public class GFG { static uint swapBitsInPair ( uint x ) { return ( ( x & 010101010 ) >> 1 ) | ( ( x & 001010101 ) << 1 ) ; } static public void Main ( ) { uint x = 4 ; Console . WriteLine ( swapBitsInPair ( x ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int setevenbits ( int n ) { int temp = n ; int count = 0 ; int res = 0 ; for ( temp = n ; temp > 0 ; temp >>= 1 ) { if ( count % 2 == 1 ) res |= ( 1 << count ) ; count ++ ; } return ( n & res ) ; } static int setoddbits ( int m ) { int count = 0 ; int res = 0 ; for ( int temp = m ; temp > 0 ; temp >>= 1 ) { if ( count % 2 == 0 ) res |= ( 1 << count ) ; count ++ ; } return ( m & res ) ; } static int getAlternateBits ( int n , int m ) { int tempn = setevenbits ( n ) ; int tempm = setoddbits ( m ) ; return ( tempn tempm ) ; } public static void Main ( ) { int n = 10 ; int m = 11 ; Console . WriteLine ( getAlternateBits ( n , m ) ) ; } }

Accumulator variables: count, res
Iterator variables: temp
Class/struct names: GFG