dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < pair < int , int > > adj [ 100005 ] ; int visited [ 100005 ] = { 0 } ; int ans = 0 ; void dfs ( int node , int xorr , int k ) { visited [ node ] = 1 ; if ( node != 1 && xorr == k ) ans ++ ; for ( auto x : adj [ node ] ) { if ( ! visited [ x . first ] ) { int xorr1 = xorr ^ x . second ; dfs ( x . first , xorr1 , k ) ; } } } void countNodes ( int N , int K , int R , vector < vector < int > > edges ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { int u = edges [ i ] [ 0 ] , v = edges [ i ] [ 1 ] , w = edges [ i ] [ 2 ] ; adj [ u ] . push_back ( { v , w } ) ; adj [ v ] . push_back ( { u , w } ) ; } dfs ( R , 0 , K ) ; cout << ans << " STRNEWLINE " ; } int main ( ) { int K = 0 , R = 1 ; vector < vector < int > > edges = { { 1 , 2 , 3 } , { 1 , 3 , 1 } , { 2 , 4 , 3 } , { 2 , 5 , 4 } , { 3 , 6 , 1 } , { 3 , 7 , 2 } } ; int N = edges . size ( ) ; countNodes ( N , K , R , edges ) ; return 0 ; }

Index/key variables: i, node, u, v
Accumulator variables: ans, i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinXORSubarray ( int arr [ ] , int n , int k ) { if ( n < k ) return ; int res_index = 0 ; int curr_xor = 0 ; for ( int i = 0 ; i < k ; i ++ ) curr_xor ^= arr [ i ] ; int min_xor = curr_xor ; for ( int i = k ; i < n ; i ++ ) { curr_xor ^= ( arr [ i ] ^ arr [ i - k ] ) ; if ( curr_xor < min_xor ) { min_xor = curr_xor ; res_index = ( i - k + 1 ) ; } } cout << min_xor << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 3 , 7 , 90 , 20 , 10 , 50 , 40 } ; int k = 3 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMinXORSubarray ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: curr_xor, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findmax ( int arr [ ] , int n , int k ) { int trav , i ; int c = 0 , maximum = 0 ; for ( i = 0 ; i < n - k + 1 ; i ++ ) { trav = i - 1 ; c = 0 ; while ( trav >= 0 && arr [ trav ] == 1 ) { trav -- ; c ++ ; } trav = i + k ; while ( trav < n && arr [ trav ] == 1 ) { trav ++ ; c ++ ; } c += k ; if ( c > maximum ) maximum = c ; } return maximum ; } int main ( ) { int k = 3 ; int arr [ ] = { 0 , 0 , 1 , 1 , 0 , 0 , 0 , 0 } ; int n = sizeof arr / sizeof arr [ 0 ] ; int ans = findmax ( arr , n , k ) ; cout << ans << ' ' ; }

Index/key variables: trav
Accumulator variables: c, i, stdc, trav
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int powerOfTwo ( int a [ ] , int n ) { map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) mp [ a [ i ] ] ++ ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { bool f = false ; for ( int j = 0 ; j < 31 ; j ++ ) { int s = ( 1 << j ) - a [ i ] ; if ( mp . count ( s ) && ( mp [ s ] > 1 || mp [ s ] == 1 && s != a [ i ] ) ) f = true ; } if ( f == false ) count ++ ; } return count ; } int main ( ) { int a [ ] = { 6 , 2 , 11 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << powerOfTwo ( a , n ) ; return 0 ; }

Index/key variables: i, s
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
Boolean variables: f
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findArray ( int n , int a , int b , int c ) { int arr [ n + 1 ] = { } ; for ( int bit = 30 ; bit >= 0 ; bit -- ) { int set = a & ( 1 << bit ) ; if ( set ) { for ( int i = 0 ; i < n ; i ++ ) arr [ i ] |= set ; } else { if ( b & ( 1 << bit ) ) { arr [ 0 ] |= ( 1 << bit ) ; if ( ! ( c & ( 1 << bit ) ) ) { arr [ 1 ] |= ( 1 << bit ) ; } } } } int aa = INT_MAX , bb = 0 , cc = 0 ; for ( int i = 0 ; i < n ; i ++ ) { aa &= arr [ i ] ; bb |= arr [ i ] ; cc ^= arr [ i ] ; } if ( a == aa && b == bb && c == cc ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } else cout << " - 1" ; } int main ( ) { int n = 3 , a = 4 , b = 6 , c = 6 ; findArray ( n , a , b , c ) ; return 0 ; }

Index/key variables: i
Accumulator variables: aa, bb, bit, cc, i, stdc
Iterator variables: bit, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxAndXor ( int arr [ ] , int n ) { int ans = INT_MAX ; sort ( arr , arr + n ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans = min ( ans , arr [ i ] ^ arr [ i + 1 ] ) ; } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxAndXor ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubarray ( int arr [ ] , int K , int N ) { if ( K % 2 != 0 ) return 0 ; if ( N < K ) return 0 ; int start = 0 ; int i = 0 ; int count = 0 ; int currXor = arr [ i ++ ] ; while ( i < K ) { currXor ^= arr [ i ] ; i ++ ; } if ( currXor == 0 ) count ++ ; currXor ^= arr [ start ++ ] ; while ( i < N ) { currXor ^= arr [ i ] ; i ++ ; if ( currXor == 0 ) count ++ ; currXor ^= arr [ start ++ ] ; } return count ; } int main ( ) { int arr [ ] = { 2 , 4 , 4 , 2 , 2 , 4 } ; int K = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( countSubarray ( arr , K , N ) ) ; }

Index/key variables: i
Accumulator variables: count, currXor, i, start, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void keep_count ( int arr [ ] , int & even , int & odd , int N ) { int count ; for ( int i = 0 ; i < N ; i ++ ) { count = 0 ; while ( arr [ i ] != 0 ) { arr [ i ] = ( arr [ i ] - 1 ) & arr [ i ] ; count ++ ; } if ( count % 2 == 0 ) even ++ ; else odd ++ ; } return ; } void solveQueries ( int arr [ ] , int n , int q [ ] , int m ) { int even_count = 0 , odd_count = 0 ; keep_count ( arr , even_count , odd_count , n ) ; for ( int i = 0 ; i < m ; i ++ ) { int X = q [ i ] ; int count = 0 ; while ( X != 0 ) { X = ( X - 1 ) & X ; count ++ ; } if ( count % 2 == 0 ) { cout << even_count << " ▁ " << odd_count << " STRNEWLINE " ; } else { cout << odd_count << " ▁ " << even_count << " STRNEWLINE " ; } } } int main ( ) { int arr [ ] = { 2 , 7 , 4 , 5 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int q [ ] = { 3 , 4 , 12 , 6 } ; int m = sizeof ( q ) / sizeof ( q [ 0 ] ) ; solveQueries ( arr , n , q , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, even, i, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pref [ 100001 ] = { 0 } ; int isEvenParity ( int num ) { int parity = 0 ; int x = num ; while ( x != 0 ) { if ( x & 1 ) parity ++ ; x = x >> 1 ; } if ( parity % 2 == 0 ) return num ; else return 0 ; } void preCompute ( ) { for ( int i = 1 ; i < 100001 ; i ++ ) { pref [ i ] = pref [ i - 1 ] + isEvenParity ( i ) ; } } void printSum ( int L , int R ) { cout << ( pref [ R ] - pref [ L - 1 ] ) << endl ; } void printSum ( int arr [ 2 ] [ 2 ] , int Q ) { preCompute ( ) ; for ( int i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } } int main ( ) { int N = 2 ; int Q [ 2 ] [ 2 ] = { { 1 , 10 } , { 121 , 211 } } ; printSum ( Q , N ) ; return 0 ; }

Index/key variables: R, i
Accumulator variables: i, parity, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLargestNumber ( vector < int > & arr ) { int k = * max_element ( arr . begin ( ) , arr . end ( ) ) ; int m [ k ] = { } ; for ( auto n : arr ) ++ m [ n ] ; for ( auto n = arr . size ( ) ; n > 0 ; -- n ) { if ( n == m [ n ] ) return n ; } return -1 ; } int main ( ) { vector < int > arr = { 3 , 2 , 5 , 2 , 4 , 5 } ; cout << findLargestNumber ( arr ) << endl ; return 0 ; }

Index/key variables: k, n
Accumulator variables: stdc
Iterator variables: n
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLargestNumber ( vector < int > & arr ) { for ( auto n : arr ) { n &= 0xFFFF ; if ( n <= arr . size ( ) ) { arr [ n - 1 ] += 0x10000 ; } } for ( auto i = arr . size ( ) ; i > 0 ; -- i ) { if ( ( arr [ i - 1 ] >> 16 ) == i ) return i ; } return -1 ; } int main ( ) { vector < int > arr = { 3 , 2 , 5 , 5 , 2 , 4 , 5 } ; cout << findLargestNumber ( arr ) << endl ; return 0 ; }

Accumulator variables: n, stdc
Iterator variables: i, n
C++ program:
#include <bits/stdc++.h>
using namespace std ; int NoCarrySum ( int N , int M ) { return N ^ M ; } int main ( ) { int N = 37 ; int M = 12 ; cout << NoCarrySum ( N , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool CheckBits ( int N , int K ) { int check = 0 ; int count = 0 ; for ( int i = 31 ; i >= 0 ; i -- ) { if ( ( 1 << i ) & N ) { if ( check == 0 ) { check = 1 ; } else { if ( count < K ) { return false ; } } count = 0 ; } else { count ++ ; } } return true ; } int main ( ) { int N = 5 ; int K = 1 ; if ( CheckBits ( N , K ) ) { cout << " YES " ; } else { cout << " NO " ; } return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumFlips ( int X , int Y , int Z ) { int res = 0 ; while ( X > 0 Y > 0 Z > 0 ) { if ( ( ( X & 1 ) || ( Y & 1 ) ) && ( Z & 1 ) ) { X = X >> 1 ; Y = Y >> 1 ; Z = Z >> 1 ; continue ; } else if ( ! ( X & 1 ) && ! ( Y & 1 ) && ( Z & 1 ) ) { res ++ ; } else if ( ( X & 1 ) || ( Y & 1 ) == 1 ) { if ( ( X & 1 ) && ( Y & 1 ) && ! ( Z & 1 ) ) { res += 2 ; } else if ( ( ( X & 1 ) || ( Y & 1 ) ) && ! ( Z & 1 ) ) { res ++ ; } } X = X >> 1 ; Y = Y >> 1 ; Z = Z >> 1 ; } return res ; } int main ( ) { int X = 5 , Y = 8 , Z = 6 ; cout << minimumFlips ( X , Y , Z ) ; return 0 ; }

Accumulator variables: res, stdc
C++ program:
int countSubseq ( int arr [ ] , int n ) { int count = 0 ; unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) mp [ arr [ i ] ] ++ ; for ( auto i : mp ) { if ( i . first == 0 ) count += pow ( 2 , i . second ) - 1 ; else count += pow ( 2 , i . second - 1 ) ; } return count ; } int main ( ) { int arr [ ] = { 2 , 2 , 2 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countSubseq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculate ( vector < int > & section , int pos ) { if ( pos < 0 ) return 0 ; vector < int > on_section , off_section ; for ( auto el : section ) { if ( ( ( el >> pos ) & 1 ) == 0 ) off_section . push_back ( el ) ; else on_section . push_back ( el ) ; } if ( off_section . size ( ) == 0 ) return calculate ( on_section , pos - 1 ) ; if ( on_section . size ( ) == 0 ) return calculate ( off_section , pos - 1 ) ; return min ( calculate ( off_section , pos - 1 ) , calculate ( on_section , pos - 1 ) ) + ( 1 << pos ) ; } int minXorValue ( int a [ ] , int n ) { vector < int > section ; for ( int i = 0 ; i < n ; i ++ ) section . push_back ( a [ i ] ) ; return calculate ( section , 30 ) ; } int main ( ) { int N = 4 ; int A [ N ] = { 3 , 2 , 5 , 6 } ; cout << minXorValue ( A , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: el, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNthNum ( long long int N ) { long long int bit_L = 1 , last_num = 0 ; while ( bit_L * ( bit_L + 1 ) / 2 < N ) { last_num = last_num + bit_L ; bit_L ++ ; } int bit_R = N - last_num - 1 ; cout << ( 1 << bit_L ) + ( 1 << bit_R ) << endl ; } int main ( ) { long long int N = 13 ; findNthNum ( N ) ; return 0 ; }

Accumulator variables: bit_L, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000005
void SieveOfEratosthenes ( vector < bool > & prime ) { prime [ 1 ] = false ; prime [ 0 ] = false ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } } void prime_xor ( int arr [ ] , int n , int k ) { vector < bool > prime ( MAX , true ) ; SieveOfEratosthenes ( prime ) ; long long int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { if ( ( i + 1 ) % k == 0 ) { ans ^= arr [ i ] ; } } } cout << ans << endl ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 7 , 11 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 2 ; prime_xor ( arr , n , K ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: ans, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xorOfArray ( int arr [ ] , int n ) { int xor_arr = 0 ; for ( int i = 0 ; i < n ; i ++ ) { xor_arr = xor_arr ^ arr [ i ] ; } return xor_arr ; } int main ( ) { int arr [ ] = { 3 , 9 , 12 , 13 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << xorOfArray ( arr , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countEvenBit ( int A [ ] , int B [ ] , int n , int m ) { int i , j , cntOdd = 0 , cntEven = 0 ; for ( i = 0 ; i < n ; i ++ ) { int x = __builtin_popcount ( A [ i ] ) ; if ( x & 1 ) { cntEven ++ ; } else { cntOdd ++ ; } } int CountB [ m ] ; for ( i = 0 ; i < m ; i ++ ) { int x = __builtin_popcount ( B [ i ] ) ; if ( x & 1 ) { CountB [ i ] = cntEven ; } else { CountB [ i ] = cntOdd ; } } for ( i = 0 ; i < m ; i ++ ) { cout << CountB [ i ] << ' ▁ ' ; } } int main ( ) { int A [ ] = { 4 , 2 , 15 , 9 , 8 , 8 } ; int B [ ] = { 3 , 4 , 22 } ; countEvenBit ( A , B , 6 , 3 ) ; return 0 ; }

Index/key variables: i, m
Accumulator variables: cntEven, cntOdd, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int bitwiseOrTillN ( int n ) { int result = 2 ; for ( int i = 4 ; i <= n ; i = i + 2 ) { result = result | i ; } return result ; } int main ( ) { int n = 10 ; cout << bitwiseOrTillN ( n ) ; return 0 ; }

Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void genSequence ( int n , int val ) { for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { int x = i ^ ( i >> 1 ) ^ val ; cout << x << " ▁ " ; } } int main ( ) { int n = 3 , k = 2 ; genSequence ( n , k ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string winner ( string moves ) { map < char , int > data ; data [ ' R ' ] = 0 ; data [ ' P ' ] = 1 ; data [ ' S ' ] = 2 ; if ( moves [ 0 ] == moves [ 1 ] ) { return " Draw " ; } if ( ( ( data [ moves [ 0 ] ] | 1 << ( 2 ) ) - ( data [ moves [ 1 ] ] | 0 << ( 2 ) ) ) % 3 ) { return " A " ; } return " B " ; } void performQueries ( string arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << winner ( arr [ i ] ) << endl ; } int main ( ) { string arr [ ] = { " RS " , " SR " , " SP " , " PP " } ; int n = sizeof ( arr ) / sizeof ( string ) ; performQueries ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int graph [ 18 ] [ 18 ] [ 2 ] ; long long dp [ 1 << 18 ] [ 18 ] [ 2 ] ; long long minCost ( int n , int m , int mask , int prev , int col ) { if ( mask == ( ( 1 << n ) - 1 ) ) { return 0 ; } if ( dp [ mask ] [ prev ] [ col == 1 ] != 0 ) { return dp [ mask ] [ prev ] [ col == 1 ] ; } long long ans = 1e9 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { if ( graph [ prev ] [ i ] [ j ] && ! ( mask & ( 1 << i ) ) && ( j != col ) ) { long long z = graph [ prev ] [ i ] [ j ] + minCost ( n , m , mask | ( 1 << i ) , i , j ) ; ans = min ( z , ans ) ; } } } return dp [ mask ] [ prev ] [ col == 1 ] = ans ; } void makeGraph ( vector < pair < pair < int , int > , pair < int , char > > > & vp , int m ) { for ( int i = 0 ; i < m ; i ++ ) { int a = vp [ i ] . first . first - 1 ; int b = vp [ i ] . first . second - 1 ; int cost = vp [ i ] . second . first ; char color = vp [ i ] . second . second ; graph [ a ] [ b ] [ color == ' W ' ] = cost ; graph [ b ] [ a ] [ color == ' W ' ] = cost ; } } int getCost ( int n , int m ) { long long ans = 1e9 ; for ( int i = 0 ; i < n ; i ++ ) { ans = min ( ans , minCost ( n , m , 1 << i , i , 2 ) ) ; } if ( ans != 1e9 ) { return ans ; } else { return -1 ; } } int main ( ) { int n = 3 , m = 4 ; vector < pair < pair < int , int > , pair < int , char > > > vp = { { { 1 , 2 } , { 2 , ' B ' } } , { { 1 , 2 } , { 3 , ' W ' } } , { { 2 , 3 } , { 4 , ' W ' } } , { { 2 , 3 } , { 5 , ' B ' } } } ; makeGraph ( vp , m ) ; cout << getCost ( n , m ) << ' ' ; return 0 ; }

Index/key variables: a, b, i, j, mask, prev
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int maxConsecutiveOnes ( int x ) { int count = 0 ; while ( x != 0 ) { x = ( x & ( x << 1 ) ) ; count ++ ; } return count ; } int maxOnes ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int currMax = maxConsecutiveOnes ( arr [ i ] ) ; ans = max ( ans , currMax ) ; } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << maxOnes ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <climits>
#include <iostream>
using namespace std ; int maxOR ( int L , int R ) { int maximum = INT_MIN ; for ( int i = L ; i < R ; i ++ ) for ( int j = i + 1 ; j <= R ; j ++ ) maximum = max ( maximum , ( i j ) ) ; return maximum ; } int main ( ) { int L = 4 , R = 5 ; cout << maxOR ( L , R ) ; return 0 ; }

Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; const int MAX = 64 ; int maxOR ( int L , int R ) { if ( L == R ) { return L ; } int ans = 0 ; for ( int i = MAX - 1 ; i >= 0 ; i -- ) { int p , lbit , rbit ; p = 1 << i ; if ( ( rbit == 1 ) && ( lbit == 0 ) ) { ans += ( p << 1 ) - 1 ; break ; } if ( rbit == 1 ) { ans += p ; } } return ans ; } int main ( ) { int L = 4 , R = 5 ; cout << maxOR ( L , R ) ; return 0 ; }

Accumulator variables: ans, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLen ( int * arr , int n , int m ) { vector < int > filter ; for ( int i = 0 ; i < n ; i ++ ) if ( ( arr [ i ] & m ) == m ) filter . push_back ( arr [ i ] ) ; if ( filter . size ( ) == 0 ) return 0 ; int c_and = filter [ 0 ] ; for ( int i = 1 ; i < filter . size ( ) ; i ++ ) c_and &= filter [ i ] ; if ( c_and == m ) return filter . size ( ) ; return 0 ; } int main ( ) { int arr [ ] = { 7 , 3 , 3 , 1 , 3 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int m = 3 ; cout << findLen ( arr , n , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c_and, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int toggleBit ( int n , int k ) { return ( n ^ ( 1 << ( k - 1 ) ) ) ; } int main ( ) { int n = 5 , k = 2 ; cout << toggleBit ( n , k ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int clearBit ( int n , int k ) { return ( n & ( ~ ( 1 << ( k - 1 ) ) ) ) ; } int main ( ) { int n = 5 , k = 1 ; cout << clearBit ( n , k ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; #define MAX  32
int maximizeExpression ( int a , int b ) { int result = a ; for ( int bit = MAX - 1 ; bit >= 0 ; bit -- ) { int bitOfD = 1 << bit ; int x = b & bitOfD ; if ( x == bitOfD ) { int y = result & bitOfD ; if ( y == 0 ) { result = result ^ bitOfD ; } } } return result ; } int main ( ) { int a = 11 , b = 14 ; cout << maximizeExpression ( a , b ) ; return 0 ; }

Accumulator variables: bit
Iterator variables: bit
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
#define MAX  10
using namespace std ; int findSubarray ( int array [ ] , int n ) { unordered_map < int , int > mp ; mp . insert ( { 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 . find ( Y ) != mp . end ( ) ) { answer += mp [ Y ] ; } value *= 2 ; } if ( mp . find ( preXor ) != mp . end ( ) ) { mp [ preXor ] ++ ; } else { mp . insert ( { preXor , 1 } ) ; } } return answer ; } int main ( ) { int array [ ] = { 2 , 6 , 7 , 5 , 8 } ; int n = sizeof ( array ) / sizeof ( array [ 0 ] ) ; cout << findSubarray ( array , n ) << endl ; return 0 ; }

Index/key variables: Y, i, preXor
Accumulator variables: answer, i, j, preXor, stdc, value
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 = max ( maxXor , arr [ i ] ^ arr [ j ] ) ; } } return maxXor ; } int main ( ) { int arr [ ] = { 25 , 10 , 2 , 8 , 5 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << max_xor ( arr , n ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int max_xor ( int arr [ ] , int n ) { int maxx = 0 , mask = 0 ; set < int > se ; for ( int i = 30 ; i >= 0 ; i -- ) { mask |= ( 1 << i ) ; for ( int i = 0 ; i < n ; ++ i ) { se . insert ( arr [ i ] & mask ) ; } int newMaxx = maxx | ( 1 << i ) ; for ( int prefix : se ) { if ( se . count ( newMaxx ^ prefix ) ) { maxx = newMaxx ; break ; } } se . clear ( ) ; } return maxx ; } int main ( ) { int arr [ ] = { 25 , 10 , 2 , 8 , 5 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << max_xor ( arr , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, mask, stdc
Iterator variables: i, prefix
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 ; } int main ( ) { int arr [ ] = { 2 , 5 , 6 , 4 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << CountTriplets ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, first, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; void findMajority ( int arr [ ] , int n ) { int len = sizeof ( int ) * 8 ; int number = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] & ( 1 << i ) ) count ++ ; } if ( count > ( n / 2 ) ) number += ( 1 << i ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == number ) count ++ ; if ( count > ( n / 2 ) ) cout << number ; else cout << " Majority ▁ Element ▁ Not ▁ Present " ; } int main ( ) { int arr [ ] = { 3 , 3 , 4 , 2 , 4 , 4 , 2 , 4 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMajority ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, number
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countBits ( int a , int b ) { int count = 0 ; while ( a b ) { 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 ; } int main ( ) { int a = 10 , b = 7 ; cout << countBits ( a , b ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountSetBits ( int n ) { if ( n == 0 ) return 0 ; if ( ( n & 1 ) == 1 ) return 1 + CountSetBits ( n >> 1 ) ; else return CountSetBits ( n >> 1 ) ; } int main ( ) { int n = 21 ; cout << CountSetBits ( n ) << endl ; return 0 ; }

Accumulator variables: stdc