dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . util . * ; class GFG { static int getPosOfRightmostSetBit ( int n ) { return ( int ) ( Math . log ( n & - n ) / Math . log ( 2 ) ) ; } static int toggleLastKBits ( int n , int k ) { int num = ( 1 << k ) - 1 ; return ( n ^ num ) ; } static int incrementByOne ( int n ) { int k = getPosOfRightmostSetBit ( ~ n ) ; n = ( ( 1 << k ) n ) ; if ( k != 0 ) n = toggleLastKBits ( n , k ) ; return n ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . println ( incrementByOne ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static int xnor ( int a , int b ) { if ( a < b ) { int t = a ; a = b ; b = t ; } if ( a == 0 && b == 0 ) return 1 ; int a_rem = 0 ; int b_rem = 0 ; int count = 0 ; int xnornum = 0 ; while ( true ) { a_rem = a & 1 ; b_rem = b & 1 ; if ( a_rem == b_rem ) xnornum |= ( 1 << count ) ; count ++ ; a = a >> 1 ; b = b >> 1 ; if ( a < 1 ) break ; } return xnornum ; } public static void main ( String argc [ ] ) { int a = 10 , b = 50 ; System . out . println ( xnor ( a , b ) ) ; } }

Accumulator variables: count, xnornum
Class/struct names: GfG
Java program:
import java . io . * ; class GFG { static int togglebit ( int n ) { if ( n == 0 ) return 1 ; int i = n ; n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return i ^ n ; } static int xnor ( int num1 , int num2 ) { if ( num1 < num2 ) { int temp = num1 ; num1 = num2 ; num2 = temp ; } num1 = togglebit ( num1 ) ; return num1 ^ num2 ; } public static void main ( String [ ] args ) { int a = 10 , b = 20 ; System . out . println ( xnor ( a , b ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
Java program:
class GFG { static void MaximumSum ( int a [ ] , int b [ ] , int n ) { int sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum1 |= a [ i ] ; sum2 |= b [ i ] ; } System . out . println ( sum1 + sum2 ) ; } public static void main ( String arg [ ] ) { int A [ ] = { 1 , 2 , 4 , 3 , 2 } ; int B [ ] = { 2 , 3 , 3 , 12 , 1 } ; int n = A . length ; MaximumSum ( A , B , n ) ; } }

Index/key variables: i
Accumulator variables: i, sum1, sum2
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int posOfRightmostSetBit ( int n ) { return ( int ) ( Math . log ( n & - n ) / Math . log ( 2 ) ) + 1 ; } static int posOfCarryBit ( int a , int b ) { return posOfRightmostSetBit ( a & b ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 2 ; System . out . print ( posOfCarryBit ( a , b ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean isPowerOfTwo ( int x ) { return x != 0 && ( ( x & ( x - 1 ) ) == 0 ) ; } static boolean differAtOneBitPos ( int a , int b ) { return isPowerOfTwo ( a ^ b ) ; } public static void main ( String args [ ] ) { int a = 13 , b = 9 ; if ( differAtOneBitPos ( a , b ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static long power2 ( long n ) { if ( n == 0 ) return 1 ; if ( n == 1 ) return 2 ; return power2 ( n / 2 ) * power2 ( n / 2 ) ; } static long multiply ( long x , long n ) { return x * power2 ( n ) ; } public static void main ( String [ ] args ) { long x = 70 , n = 2 ; System . out . println ( multiply ( x , n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static long multiply ( long x , long n ) { return x << n ; } public static void main ( String [ ] args ) { long x = 70 , n = 2 ; System . out . println ( multiply ( x , n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isDivBy2PowerM ( int n , int m ) { if ( ( n & ( ( 1 << m ) - 1 ) ) == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 8 , m = 2 ; if ( isDivBy2PowerM ( n , m ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findWinner ( int N ) { return N & 1 ; } public static void main ( String [ ] args ) { int N = 15 ; if ( findWinner ( N ) == 1 ) System . out . println ( " Player ▁ A " ) ; else System . out . println ( " Player ▁ B " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int evenbittogglenumber ( int n ) { int res = 0 , count = 0 ; for ( int temp = n ; temp > 0 ; temp >>= 1 ) { if ( count % 2 == 0 ) res |= ( 1 << count ) ; count ++ ; } return n ^ res ; } public static void main ( String args [ ] ) { int n = 11 ; System . out . println ( evenbittogglenumber ( n ) ) ; } }

Accumulator variables: count, res
Iterator variables: temp
Class/struct names: GFG
Java program:
import java . io . * ; public class GFG { static void divide ( int n , int m ) { System . out . println ( " Remainder ▁ = ▁ " + ( ( n ) & ( m - 1 ) ) ) ; System . out . println ( " Quotient ▁ = ▁ " + ( n >> ( int ) ( Math . log ( m ) / Math . log ( 2 ) ) ) ) ; } static public void main ( String [ ] args ) { int n = 43 , m = 8 ; divide ( n , m ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GfG { static int maxAND ( int arr [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) res = res > ( arr [ i ] & arr [ j ] ) ? res : ( arr [ i ] & arr [ j ] ) ; return res ; } public static void main ( String argc [ ] ) { int arr [ ] = { 4 , 8 , 6 , 2 } ; int n = arr . length ; System . out . println ( " Maximum ▁ AND ▁ Value ▁ = ▁ " + maxAND ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GfG
Java program:
class GFG { static int index ( int i ) { return 1 + ( i >> 31 ) - ( - i >> 31 ) ; } static void check ( int n ) { String s [ ] = { " negative " , " zero " , " positive " } ; int val = index ( n ) ; System . out . println ( n + " ▁ is ▁ " + s [ val ] ) ; } public static void main ( String [ ] args ) { check ( 30 ) ; check ( - 20 ) ; check ( 0 ) ; } }

Index/key variables: val
Class/struct names: GFG
Java program:
class GFG { static void compute ( long S , long X ) { long A = ( S - X ) / 2 ; int a = 0 , b = 0 ; final int LONG_FIELD_SIZE = 8 ; for ( int i = 0 ; i < 8 * LONG_FIELD_SIZE ; i ++ ) { long Xi = ( X & ( 1 << i ) ) ; long Ai = ( A & ( 1 << i ) ) ; if ( Xi == 0 && Ai == 0 ) { } else if ( Xi == 0 && Ai > 0 ) { a = ( ( 1 << i ) a ) ; b = ( ( 1 << i ) b ) ; } else if ( Xi > 0 && Ai == 0 ) { a = ( ( 1 << i ) a ) ; } { System . out . println ( " Not ▁ Possible " ) ; return ; } } System . out . println ( " a ▁ = ▁ " + a + " b = " + b);  } public static void main ( String [ ] args ) { long S = 17 , X = 13 ; compute ( S , X ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean checking ( String s ) { int c = 0 ; int n = s . length ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '0' ) c ++ ; if ( c >= 6 && s . charAt ( i ) == '1' ) return true ; } return false ; } public static void main ( String [ ] args ) { String s = "100010001" ; if ( checking ( s ) ) System . out . println ( " Possible " ) ; else System . out . println ( " Not ▁ possible " ) ; } }

Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int modifyBit ( int n , int p , int b ) { int mask = 1 << p ; return ( n & ~ mask ) | ( ( b << p ) & mask ) ; } public static void main ( String [ ] args ) { System . out . println ( modifyBit ( 6 , 2 , 0 ) ) ; System . out . println ( modifyBit ( 6 , 5 , 1 ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int countSetBitsInGivenRange ( int n , int l , int r ) { int num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; return countSetBits ( n & num ) ; } public static void main ( String [ ] args ) { int n = 42 ; int l = 2 , r = 5 ; System . out . print ( countSetBitsInGivenRange ( n , l , r ) ) ; } }

Accumulator variables: count, n
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static boolean areAllBitsSet ( long n ) { if ( n == 0 ) return false ; if ( ( ( n + 1 ) & n ) == 0 ) return true ; return false ; } public static boolean isOnesComplementOfOther ( long a , long b ) { return areAllBitsSet ( a ^ b ) ; } public static void main ( String argc [ ] ) { long a = 10 , b = 5 ; if ( isOnesComplementOfOther ( a , b ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GfG
Java program:
class GFG { static int findUnique ( int a [ ] , int n , int k ) { byte sizeof_int = 4 ; int INT_SIZE = 8 * sizeof_int ; int count [ ] = new int [ INT_SIZE ] ; for ( int i = 0 ; i < INT_SIZE ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( ( a [ j ] & ( 1 << i ) ) != 0 ) count [ i ] += 1 ; int res = 0 ; for ( int i = 0 ; i < INT_SIZE ; i ++ ) res += ( count [ i ] % k ) * ( 1 << i ) ; return res ; } public static void main ( String [ ] args ) { int a [ ] = { 6 , 2 , 5 , 2 , 2 , 6 , 6 } ; int n = a . length ; int k = 3 ; System . out . println ( findUnique ( a , n , k ) ) ; } }

Index/key variables: INT_SIZE, i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean powerOfTwo ( int n ) { return ( ( n & n - 1 ) == 0 ) ; } static boolean onlyFirstAndLastAreSet ( int n ) { if ( n == 1 ) return true ; return powerOfTwo ( n - 1 ) ; } public static void main ( String [ ] args ) { int n = Integer . parseUnsignedInt ( "9" ) ; if ( onlyFirstAndLastAreSet ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
class AlternateSetBits { static boolean allBitsAreSet ( int n ) { if ( ( ( n + 1 ) & n ) == 0 ) return true ; return false ; } static boolean bitsAreInAltOrder ( int n ) { int num = n ^ ( n >>> 1 ) ; return allBitsAreSet ( num ) ; } public static void main ( String args [ ] ) { int n = 10 ; if ( bitsAreInAltOrder ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: AlternateSetBits
Java program:
import java . util . * ; class GFG { static int setBit ( int xorValue ) { int count = 0 ; while ( xorValue >= 1 ) { if ( xorValue % 2 == 1 ) count ++ ; xorValue /= 2 ; } return count ; } static int minFlip ( int n , int k ) { int size = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ; int max = ( int ) Math . pow ( 2 , k ) - 1 ; max = max << ( size - k ) ; int xorValue = ( n ^ max ) ; return ( setBit ( xorValue ) ) ; } public static void main ( String [ ] args ) { int n = 27 , k = 3 ; System . out . println ( " Min ▁ Flips ▁ = ▁ " + minFlip ( n , k ) ) ; } }

Accumulator variables: count, xorValue
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int setallbitgivenrange ( int n , int l , int r ) { int range = ( ( ( 1 << ( l - 1 ) ) - 1 ) ^ ( ( 1 << ( r ) ) - 1 ) ) ; return ( n range ) ; } public static void main ( String [ ] args ) { int n = 17 , l = 2 , r = 3 ; System . out . println ( setallbitgivenrange ( n , l , r ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countBits ( int number ) { return ( int ) ( Math . log ( number ) / Math . log ( 2 ) + 1 ) ; } public static void main ( String [ ] args ) { int num = 65 ; System . out . println ( countBits ( num ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String 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 " Yes " ; return " No " ; } public static void main ( String [ ] args ) { int n = 17 ; int l = 2 ; int r = 4 ; System . out . println ( allBitsSetInTheGivenRange ( n , l , r ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int setAllBitsAfterMSB ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return n ; } static int toggle ( int n ) { n = n ^ setAllBitsAfterMSB ( n ) ; return n ; } public static void main ( String arg [ ] ) { int n = 10 ; n = toggle ( n ) ; System . out . print ( n ) ; } }

Accumulator variables: n
Class/struct names: GFG
Java program:
class GFG { static boolean adjacentSet ( int n ) { int x = ( n & ( n >> 1 ) ) ; if ( x > 0 ) return true ; else return false ; } public static void main ( String args [ ] ) { int n = 3 ; if ( adjacentSet ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int getRightMostSetBit ( int n ) { return ( int ) ( ( Math . log ( n & - n ) ) / ( Math . log ( 2 ) ) ) + 1 ; } static int posOfRightMostSameBit ( int m , int n ) { return getRightMostSetBit ( ~ ( m ^ n ) ) ; } public static void main ( String [ ] args ) { int m = 16 , n = 7 ; System . out . print ( " Position ▁ = ▁ " + posOfRightMostSameBit ( m , n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int posOfRightMostSameBit ( int m , int n ) { int loopCounter = 1 ; while ( m > 0 n > 0 ) { boolean a = m % 2 == 1 ; boolean b = n % 2 == 1 ; if ( ! ( a ^ b ) ) { return loopCounter ; } m = m >> 1 ; n = n >> 1 ; loopCounter ++ ; } return - 1 ; } public static void main ( String [ ] args ) { int m = 16 , n = 7 ; System . out . print ( " Position ▁ = ▁ " + posOfRightMostSameBit ( m , n ) ) ; } }

Accumulator variables: loopCounter
Class/struct names: GFG
Java program:
class GFG { static String 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 " Yes " ; return " No " ; } public static void main ( String [ ] args ) { int n = 22 ; int l = 2 , r = 3 ; System . out . print ( allBitsSetInTheGivenRange ( n , l , r ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printNonConsecutive ( int n ) { int p = ( 1 << n ) ; for ( int i = 1 ; i < p ; i ++ ) if ( ( i & ( i << 1 ) ) == 0 ) System . out . print ( i + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 3 ; printNonConsecutive ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int INT_SIZE = 32 ; static int constructNthNumber ( int group_no , int aux_num , int op ) { int a [ ] = new int [ INT_SIZE ] ; int num = 0 , len_f ; int i = 0 ; if ( op == 2 ) { len_f = 2 * group_no ; a [ len_f - 1 ] = a [ 0 ] = 1 ; while ( aux_num > 0 ) { a [ group_no + i ] = a [ group_no - 1 - i ] = aux_num & 1 ; aux_num = aux_num >> 1 ; i ++ ; } } else if ( op == 0 ) { len_f = 2 * group_no + 1 ; a [ len_f - 1 ] = a [ 0 ] = 1 ; a [ group_no ] = 0 ; while ( aux_num > 0 ) { a [ group_no + 1 + i ] = a [ group_no - 1 - i ] = aux_num & 1 ; aux_num = aux_num >> 1 ; i ++ ; } } { len_f = 2 * group_no + 1 ; a [ len_f - 1 ] = a [ 0 ] = 1 ; a [ group_no ] = 1 ; while ( aux_num > 0 ) { a [ group_no + 1 + i ] = a [ group_no - 1 - i ] = aux_num & 1 ; aux_num = aux_num >> 1 ; i ++ ; } } for ( i = 0 ; i < len_f ; i ++ ) num += ( 1 << i ) * a [ i ] ; return num ; } static int getNthNumber ( int n ) { int group_no = 0 , group_offset ; int count_upto_group = 0 , count_temp = 1 ; int op , aux_num ; while ( count_temp < n ) { group_no ++ ; count_upto_group = count_temp ; count_temp += 3 * ( 1 << ( group_no - 1 ) ) ; } group_offset = n - count_upto_group - 1 ; if ( ( group_offset + 1 ) <= ( 1 << ( group_no - 1 ) ) ) { aux_num = group_offset ; } else { if ( ( ( group_offset + 1 ) - ( 1 << ( group_no - 1 ) ) ) % 2 == 1 ) else aux_num = ( ( group_offset ) - ( 1 << ( group_no - 1 ) ) ) / 2 ; } return constructNthNumber ( group_no , aux_num , op ) ; } public static void main ( String [ ] args ) { int n = 9 ; System . out . printf ( " % d " , getNthNumber ( n ) ) ; } }

Index/key variables: INT_SIZE, group_no, i
Accumulator variables: count_temp, group_no, i, num
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void shuffle ( int N , int key ) { int NO_OF_BITS = N ; int reverse_num = 0 , temp ; for ( int i = 0 ; i < NO_OF_BITS ; i ++ ) { temp = ( key & ( 1 << i ) ) ; if ( temp > 0 ) reverse_num |= ( 1 << ( ( NO_OF_BITS - 1 ) - i ) ) ; } System . out . print ( reverse_num ) ; } public static void main ( String [ ] args ) { int N = 3 ; int key = 3 ; shuffle ( N , key ) ; } }

Accumulator variables: i, reverse_num
Iterator variables: i
Class/struct names: GFG
Java program:
public class Main { static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { n &= ( n - 1 ) ; count ++ ; } return count ; } static int findSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( countSetBits ( i ) == 2 ) sum += i ; return sum ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( findSum ( n ) ) ; } }

Accumulator variables: count, i, n, sum
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static int toggleLastMBits ( int n , int m ) { int num = ( 1 << m ) - 1 ; return ( n ^ num ) ; } public static void main ( String argc [ ] ) { int n = 107 ; int m = 4 ; n = toggleLastMBits ( n , m ) ; System . out . println ( n ) ; } }

Class/struct names: GfG
Java program:
class GFG { static int getPosOfRightmostSetBit ( int n ) { return ( int ) ( ( Math . log10 ( n & - n ) ) / ( Math . log10 ( 2 ) ) ) + 1 ; } static int setRightmostUnsetBit ( int n ) { if ( n == 0 ) return 1 ; if ( ( n & ( n + 1 ) ) == 0 ) return n ; int pos = getPosOfRightmostSetBit ( ~ n ) ; return ( ( 1 << ( pos - 1 ) ) n ) ; } public static void main ( String arg [ ] ) { int n = 21 ; System . out . print ( setRightmostUnsetBit ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int getFirstSetBitPos ( int n ) { return ( int ) ( Math . log ( n & - n ) / Math . log ( 2 ) ) + 1 ; } static int previousSmallerInteger ( int n ) { int pos = getFirstSetBitPos ( n ) ; return ( n & ~ ( 1 << ( pos - 1 ) ) ) ; } public static void main ( String [ ] args ) { int n = 25 ; System . out . print ( " Previous ▁ smaller ▁ Integer ▁ = " + previousSmallerInteger ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void createMap ( Map < String , Character > um ) { um . put ( "000" , '0' ) ; um . put ( "001" , '1' ) ; um . put ( "010" , '2' ) ; um . put ( "011" , '3' ) ; um . put ( "100" , '4' ) ; um . put ( "101" , '5' ) ; um . put ( "110" , '6' ) ; um . put ( "111" , '7' ) ; } static String convertBinToOct ( String bin ) { int l = bin . length ( ) ; int t = bin . indexOf ( ' . ' ) ; int len_left = t != - 1 ? t : l ; for ( int i = 1 ; i <= ( 3 - len_left % 3 ) % 3 ; i ++ ) bin = '0' + bin ; if ( t != - 1 ) { int len_right = l - len_left - 1 ; for ( int i = 1 ; i <= ( 3 - len_right % 3 ) % 3 ; i ++ ) bin = bin + '0' ; } Map < String , Character > bin_oct_map = new HashMap < String , Character > ( ) ; createMap ( bin_oct_map ) ; int i = 0 ; String octal = " " ; while ( true ) { octal += bin_oct_map . get ( bin . substring ( i , i + 3 ) ) ; i += 3 ; if ( i == bin . length ( ) ) break ; if ( bin . charAt ( i ) == ' . ' ) { octal += ' . ' ; i ++ ; } } return octal ; } public static void main ( String [ ] args ) { String bin = "1111001010010100001.010110110011011" ; System . out . println ( " Octal ▁ number ▁ = ▁ " + convertBinToOct ( bin ) ) ; } }

Accumulator variables: i, octal
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String areAllBitsSet ( int n ) { if ( n == 0 ) return " No " ; while ( n > 0 ) { if ( ( n & 1 ) == 0 ) return " No " ; n = n >> 1 ; } return " Yes " ; } public static void main ( String [ ] args ) { int n = 7 ; System . out . println ( areAllBitsSet ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String areAllBitsSet ( int n ) { if ( n == 0 ) return " No " ; if ( ( ( n + 1 ) & n ) == 0 ) return " Yes " ; return " No " ; } public static void main ( String [ ] args ) { int n = 7 ; System . out . println ( areAllBitsSet ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int getFirstSetBitPos ( int n ) { return ( ( int ) ( Math . log ( n & - n ) / Math . log ( 2 ) ) + 1 ) - 1 ; } static int nextGreaterWithOneMoreSetBit ( int n ) { int pos = getFirstSetBitPos ( ~ n ) ; if ( pos > - 1 ) return ( 1 << pos ) | n ; return ( ( n << 1 ) + 1 ) ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . print ( " Next ▁ greater ▁ integer ▁ = ▁ " + nextGreaterWithOneMoreSetBit ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long CountZeroBit ( long x ) { long count = 0 ; while ( x > 0 ) { if ( ( x & 1L ) == 0 ) count ++ ; x >>= 1L ; } return count ; } static long CountXORandSumEqual ( long x ) { long count = CountZeroBit ( x ) ; return ( 1L << count ) ; } public static void main ( String [ ] args ) { long x = 10 ; System . out . println ( CountXORandSumEqual ( x ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
class GFG { static int missingNumber ( int arr1 [ ] , int arr2 [ ] , int n ) { int mnum = 0 ; for ( int i = 0 ; i < n ; i ++ ) mnum = mnum ^ arr1 [ i ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) mnum = mnum ^ arr2 [ i ] ; return mnum ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 4 , 8 , 1 , 3 , 7 } ; int arr2 [ ] = { 7 , 4 , 3 , 1 } ; int n = arr1 . length ; System . out . println ( " Missing ▁ number ▁ = ▁ " + missingNumber ( arr1 , arr2 , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class BitArray { int [ ] arr ; public BitArray ( int n ) { arr = new int [ ( n >> 5 ) + 1 ] ; } boolean get ( int pos ) { int index = ( pos >> 5 ) ; int bitNo = ( pos & 0x1F ) ; return ( arr [ index ] & ( 1 << bitNo ) ) != 0 ; } void set ( int pos ) { int index = ( pos >> 5 ) ; int bitNo = ( pos & 0x1F ) ; arr [ index ] |= ( 1 << bitNo ) ; } static void checkDuplicates ( int [ ] arr ) { BitArray ba = new BitArray ( 320000 ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { int num = arr [ i ] - 1 ; if ( ba . get ( num ) ) System . out . print ( num + " ▁ " ) ; else ba . set ( num ) ; } } public static void main ( String [ ] args ) throws java . lang . Exception { int [ ] arr = { 1 , 5 , 1 , 10 , 12 , 10 } ; checkDuplicates ( arr ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: BitArray
Java program:
class GFG { static int countValues ( int x ) { int count = 0 , n = 1 ; while ( x != 0 ) { if ( x % 2 == 0 ) count += n ; n *= 2 ; x /= 2 ; } return count ; } public static void main ( String [ ] args ) { int x = 10 ; System . out . println ( countValues ( x ) ) ; } }

Accumulator variables: count, n, x
Class/struct names: GFG
Java program:
class GFG { static void constructXOR ( int A [ ] , int n ) { int XOR = 0 ; for ( int i = 0 ; i < n ; i ++ ) XOR ^= A [ i ] ; for ( int i = 0 ; i < n ; i ++ ) A [ i ] = XOR ^ A [ i ] ; } public static void main ( String [ ] args ) { int A [ ] = { 2 , 4 , 1 , 3 , 5 } ; int n = A . length ; constructXOR ( A , n ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( A [ i ] + " ▁ " ) ; } }

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