dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long int ll ; ll spellsCount ( string num ) { int n = num . length ( ) ; ll result = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int count = 1 ; while ( i < n - 1 && num [ i + 1 ] == num [ i ] ) { count ++ ; i ++ ; } result = result * pow ( 2 , count - 1 ) ; } return result ; } int main ( ) { string num = "11112" ; cout << spellsCount ( num ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numSquareSum ( int n ) { int squareSum = 0 ; while ( n ) { squareSum += ( n % 10 ) * ( n % 10 ) ; n /= 10 ; } return squareSum ; } bool isHappynumber ( int n ) { int slow , fast ; slow = fast = n ; do { slow = numSquareSum ( slow ) ; fast = numSquareSum ( numSquareSum ( fast ) ) ; } while ( slow != fast ) ; return ( slow == 1 ) ; } int main ( ) { int n = 13 ; if ( isHappynumber ( n ) ) cout << n << " ▁ is ▁ a ▁ Happy ▁ number STRNEWLINE " ; else cout << n << " ▁ is ▁ not ▁ a ▁ Happy ▁ number STRNEWLINE " ; }

Accumulator variables: n, squareSum, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef unsigned long long int ull ; vector < ull > allPrimes ; void sieve ( int n ) { vector < bool > prime ( n + 1 , true ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) allPrimes . push_back ( p ) ; } ull factorialDivisors ( ull n ) { ull result = 1 ; for ( int i = 0 ; i < allPrimes . size ( ) ; i ++ ) { ull p = allPrimes [ i ] ; ull exp = 0 ; while ( p <= n ) { exp = exp + ( n / p ) ; p = p * allPrimes [ i ] ; } result = result * ( exp + 1 ) ; } return result ; } int main ( ) { cout << factorialDivisors ( 6 ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nonFibonacci ( int n ) { int prevPrev = 1 , prev = 2 , curr = 3 ; while ( n > 0 ) { prevPrev = prev ; prev = curr ; curr = prevPrev + prev ; n = n - ( curr - prev - 1 ) ; } n = n + ( curr - prev - 1 ) ; return prev + n ; } int main ( ) { cout << nonFibonacci ( 5 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( a == 0 ) return b ; if ( b == 0 ) return a ; int k ; for ( k = 0 ; ( ( a b ) & 1 ) == 0 ; ++ k ) { a >>= 1 ; b >>= 1 ; } while ( ( a & 1 ) == 0 ) a >>= 1 ; do { while ( ( b & 1 ) == 0 ) b >>= 1 ; if ( a > b ) swap ( a , b ) ; b = ( b - a ) ; } while ( b != 0 ) ; return a << k ; } int main ( ) { int a = 34 , b = 17 ; printf ( " Gcd ▁ of ▁ given ▁ numbers ▁ is ▁ % d STRNEWLINE " , gcd ( a , b ) ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: k
C++ program:
#include <iostream>
using namespace std ; string one [ ] = { " " , " one ▁ " , " two ▁ " , " three ▁ " , " four ▁ " , " five ▁ " , " six ▁ " , " seven ▁ " , " eight ▁ " , " nine ▁ " , " ten ▁ " , " eleven ▁ " , " twelve ▁ " , " thirteen ▁ " , " fourteen ▁ " , " fifteen ▁ " , " sixteen ▁ " , " seventeen ▁ " , " eighteen ▁ " , " nineteen ▁ " } ; string ten [ ] = { " " , " " , " twenty ▁ " , " thirty ▁ " , " forty ▁ " , " fifty ▁ " , " sixty ▁ " , " seventy ▁ " , " eighty ▁ " , " ninety ▁ " } ; string numToWords ( int n , string s ) { string str = " " ; if ( n > 19 ) str += ten [ n / 10 ] + one [ n % 10 ] ; else str += one [ n ] ; if ( n ) str += s ; return str ; } string convertToWords ( long n ) { string out ; out += numToWords ( ( n / 10000000 ) , " crore ▁ " ) ; out += numToWords ( ( ( n / 100000 ) % 100 ) , " lakh ▁ " ) ; out += numToWords ( ( ( n / 1000 ) % 100 ) , " thousand ▁ " ) ; out += numToWords ( ( ( n / 100 ) % 10 ) , " hundred ▁ " ) ; if ( n > 100 && n % 100 ) out += " and ▁ " ; out += numToWords ( ( n % 100 ) , " " ) ; return out ; } int main ( ) { long n = 438237764 ; cout << convertToWords ( n ) << endl ; return 0 ; }

Index/key variables: n
Accumulator variables: out, str
C++ program:
#include <iostream>
using namespace std ; long long countEvenSum ( int a [ ] , int n ) { long long res = 0 ; int s = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] % 2 == 1 ) { s = n - i - 1 - s ; } else { s = s + 1 ; } res = res + s ; } return res ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 3 , 4 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " The ▁ Number ▁ of ▁ Subarrays ▁ with ▁ even " " ▁ sum ▁ is ▁ " << countEvenSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { return ( a % b == 0 ) ? abs ( b ) : gcd ( b , a % b ) ; } bool isPossible ( int a , int b , int c ) { return ( c % gcd ( a , b ) == 0 ) ; } int main ( ) { int a = 3 , b = 6 , c = 9 ; isPossible ( a , b , c ) ? cout << " Possible STRNEWLINE " : cout << " Not ▁ Possible STRNEWLINE " ; a = 3 , b = 6 , c = 8 ; isPossible ( a , b , c ) ? cout << " Possible STRNEWLINE " : cout << " Not ▁ Possible STRNEWLINE " ; a = 2 , b = 5 , c = 1 ; isPossible ( a , b , c ) ? cout << " Possible STRNEWLINE " : cout << " Not ▁ Possible STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void farey ( int n ) { double x1 = 0 , y1 = 1 , x2 = 1 , y2 = n ; printf ( " % .0f / % . 0f ▁ % .0f / % . 0f " , x1 , y1 , x2 , y2 ) ; while ( y != 1.0 ) { x = floor ( ( y1 + n ) / y2 ) * x2 - x1 ; y = floor ( ( y1 + n ) / y2 ) * y2 - y1 ; printf ( " ▁ % .0f / % . 0f " , x , y ) ; x1 = x2 , x2 = x , y1 = y2 , y2 = y ; } } int main ( ) { int n = 7 ; cout << " Farey ▁ Sequence ▁ of ▁ order ▁ " << n << " ▁ is STRNEWLINE " ; farey ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int x , unsigned int y , int p ) { while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } int modInverse ( int a , int p ) { return power ( a , p - 2 , p ) ; } int modFact ( int n , int p ) { if ( p <= n ) return 0 ; int res = ( p - 1 ) ; for ( int i = n + 1 ; i < p ; i ++ ) res = ( res * modInverse ( i , p ) ) % p ; return res ; } int main ( ) { int n = 25 , p = 29 ; cout << modFact ( n , p ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countWays ( int n ) { for ( int i = 1 ; i < n ; i ++ ) for ( int j = i ; j < n ; j ++ ) for ( int k = j ; k < n ; k ++ ) for ( int l = k ; l < n ; l ++ ) if ( i + j + k + l == n ) counter ++ ; return counter ; } int main ( ) { int n = 8 ; cout << countWays ( n ) ; return 0 ; }

Accumulator variables: counter, i, j, k, l, stdc
Iterator variables: i, j, k, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pairAndSum ( 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 ; } int main ( ) { int arr [ ] = { 5 , 10 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << pairAndSum ( arr , n ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } int main ( ) { isPrime ( 11 ) ? cout << " ▁ true STRNEWLINE " : cout << " ▁ false STRNEWLINE " ; isPrime ( 15 ) ? cout << " ▁ true STRNEWLINE " : cout << " ▁ false STRNEWLINE " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void computeTotient ( int n ) { long long phi [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) for ( int p = 2 ; p <= n ; p ++ ) { if ( phi [ p ] == p ) { phi [ p ] = p - 1 ; for ( int i = 2 * p ; i <= n ; i += p ) { phi [ i ] = ( phi [ i ] / p ) * ( p - 1 ) ; } } } for ( int i = 1 ; i <= n ; i ++ ) cout << " Totient ▁ of ▁ " << i << " ▁ is ▁ " << phi [ i ] << endl ; } int main ( ) { int n = 12 ; computeTotient ( n ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
ll Euler_totient_function ( ll n ) { ll result = 1 ; for ( ll i = 2 ; i * i <= n ; i ++ ) { ll c = 0 ; if ( n % i == 0 ) { while ( n % i == 0 ) { c ++ ; n /= i ; } } if ( c > 0 ) { ll power = ( ll ) pow ( i , c - 1 ) ; ll sm = ( ll ) pow ( i , c - 1 ) * ( i - 1 ) ; result *= sm ; } } if ( n > 1 ) { result *= ( n - 1 ) ; } return result ; } int main ( ) { for ( ll i = 1 ; i < 13 ; i ++ ) { cout << " Euler _ totient _ function ( " << i << " ) : ▁ " ; cout << Euler_totient_function ( i ) << endl ; } } #praveeny182

Accumulator variables: c, i, n, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPower ( unsigned n ) { float p ; if ( n <= 1 ) return 1 ; for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) { p = log2 ( n ) / log2 ( i ) ; if ( ( ceil ( p ) == floor ( p ) ) && p > 1 ) return true ; } return false ; } int main ( ) { for ( int i = 2 ; i < 100 ; i ++ ) if ( isPower ( i ) ) cout << i << " ▁ " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumBetweenTwoKth ( int arr [ ] , int n , int k1 , int k2 ) { sort ( arr , arr + n ) ; int result = 0 ; for ( int i = k1 ; i < k2 - 1 ; i ++ ) result += arr [ i ] ; return result ; } int main ( ) { int arr [ ] = { 20 , 8 , 22 , 4 , 12 , 10 , 14 } ; int k1 = 3 , k2 = 6 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << sumBetweenTwoKth ( arr , n , k1 , k2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthMagicNo ( int n ) { int pow = 1 , answer = 0 ; while ( n ) { pow = pow * 5 ; if ( n & 1 ) answer += pow ; } return answer ; } int main ( ) { int n = 5 ; cout << " nth ▁ magic ▁ number ▁ is ▁ " << nthMagicNo ( n ) << endl ; return 0 ; }

Accumulator variables: answer, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int XorSum ( int A [ ] , int B [ ] , int N , int M ) { int ans1 = 0 , ans2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) ans1 = ans1 ^ A [ i ] ; for ( int i = 0 ; i < M ; i ++ ) ans2 = ans2 ^ B [ i ] ; return ( ans1 & ans2 ) ; } int main ( ) { int A [ ] = { 3 , 5 } ; int B [ ] = { 2 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int M = sizeof ( B ) / sizeof ( B [ 0 ] ) ; cout << XorSum ( A , B , N , M ) << endl ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct TreeNode { int val = 0 ; TreeNode * left , * right ; TreeNode ( int x ) { val = x ; left = NULL ; right = NULL ; } } ; void uniqueLevels ( TreeNode * root ) { int uniqueLevels = 0 ; queue < TreeNode * > que ; que . push ( root ) ; while ( que . size ( ) > 0 ) { int length = que . size ( ) ; int prefix_XOR = 0 ; int prefix_OR = 0 ; bool flag = true ; for ( int i = 0 ; i < length ; i ++ ) { TreeNode * temp = que . front ( ) ; que . pop ( ) ; prefix_OR |= temp -> val ; prefix_XOR ^= temp -> val ; if ( prefix_XOR != prefix_OR ) flag = false ; if ( temp -> left ) que . push ( temp -> left ) ; if ( temp -> right ) que . push ( temp -> right ) ; } if ( flag ) uniqueLevels += 1 ; } cout << uniqueLevels ; } int main ( ) { TreeNode * root = new TreeNode ( 5 ) ; root -> left = new TreeNode ( 6 ) ; root -> right = new TreeNode ( 9 ) ; root -> left -> left = new TreeNode ( 1 ) ; root -> left -> right = new TreeNode ( 4 ) ; root -> right -> right = new TreeNode ( 7 ) ; uniqueLevels ( root ) ; return 0 ; }

Accumulator variables: i, prefix_OR, prefix_XOR, stdc, uniqueLevels
Iterator variables: i
Boolean variables: flag
Class/struct names: TreeNode
C++ program:
#include <bits/stdc++.h>
using namespace std ; int n = 7 ; void minheapify ( int a [ ] , int index ) { int small = index ; int l = 2 * index + 1 ; int r = 2 * index + 2 ; if ( l < n && a [ l ] < a [ small ] ) small = l ; if ( r < n && a [ r ] < a [ small ] ) small = r ; if ( small != index ) { swap ( a [ small ] , a [ index ] ) ; minheapify ( a , small ) ; } } int main ( ) { int i = 0 ; int k1 = 3 ; int k2 = 6 ; int a [ ] = { 20 , 8 , 22 , 4 , 12 , 10 , 14 } ; int ans = 0 ; for ( i = ( n / 2 ) - 1 ; i >= 0 ; i -- ) { minheapify ( a , i ) ; } k1 -- ; k2 -- ; for ( i = 0 ; i <= k1 ; i ++ ) { a [ 0 ] = a [ n - 1 ] ; n -- ; minheapify ( a , 0 ) ; } for ( i = k1 + 1 ; i < k2 ; i ++ ) { ans += a [ 0 ] ; a [ 0 ] = a [ n - 1 ] ; n -- ; minheapify ( a , 0 ) ; } cout << ans ; return 0 ; }

Index/key variables: index, l, r, small
Accumulator variables: ans, i, k1, k2, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  5
#define M  2
list < int > ConstructList ( int Q [ N ] [ M ] ) { int xr = 0 ; list < int > ans ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( Q [ i ] [ 0 ] == 0 ) ans . push_back ( Q [ i ] [ 1 ] ^ xr ) ; else xr ^= Q [ i ] [ 1 ] ; } ans . push_back ( xr ) ; ans . sort ( ) ; return ans ; } int main ( ) { int Q [ N ] [ M ] = { { 0 , 6 } , { 0 , 3 } , { 0 , 2 } , { 1 , 4 } , { 1 , 5 } } ; list < int > ans = ConstructList ( Q ) ; for ( auto it = ans . begin ( ) ; it != ans . end ( ) ; ++ it ) cout << ' ▁ ' << * it ; }

Index/key variables: M, N, i
Accumulator variables: i, stdc, xr
Iterator variables: i, it
C++ program:
#include <iostream>
using namespace std ; int build_num ( int bit [ ] ) { int ans = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) if ( bit [ i ] ) ans += ( 1 << i ) ; return ans ; } int maximumOR ( int arr [ ] , int n , int k ) { int bit [ 32 ] = { 0 } ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < 32 ; j ++ ) { if ( arr [ i ] & ( 1 << j ) ) bit [ j ] ++ ; } } int max_or = build_num ( bit ) ; for ( int i = k ; i < n ; i ++ ) { for ( int j = 0 ; j < 32 ; j ++ ) { if ( arr [ i - k ] & ( 1 << j ) ) bit [ j ] -- ; } for ( int j = 0 ; j < 32 ; j ++ ) { if ( arr [ i ] & ( 1 << j ) ) bit [ j ] ++ ; } max_or = max ( build_num ( bit ) , max_or ) ; } return max_or ; } int main ( ) { int arr [ ] = { 2 , 5 , 3 , 6 , 11 , 13 } ; int k = 3 ; int n = sizeof arr / sizeof arr [ 0 ] ; cout << maximumOR ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * newNode = new Node ; newNode -> data = data ; newNode -> left = newNode -> right = NULL ; return ( newNode ) ; } void Solve ( Node * root , int xr , int & max_xor ) { xr = xr ^ root -> data ; if ( root -> left == NULL && root -> right == NULL ) { max_xor = max ( max_xor , xr ) ; return ; } if ( root -> left != NULL ) { Solve ( root -> left , xr , max_xor ) ; } if ( root -> right != NULL ) { Solve ( root -> right , xr , max_xor ) ; } return ; } int findMaxXor ( Node * root ) { int xr = 0 , max_xor = 0 ; Solve ( root , xr , max_xor ) ; return max_xor ; } int main ( void ) { struct Node * root = newNode ( 2 ) ; root -> left = newNode ( 1 ) ; root -> right = newNode ( 4 ) ; root -> left -> left = newNode ( 10 ) ; root -> left -> right = newNode ( 8 ) ; root -> right -> left = newNode ( 5 ) ; root -> right -> right = newNode ( 10 ) ; cout << findMaxXor ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void constructXORArray ( int A [ ] , int n , int K ) { int B [ n ] ; for ( int i = 0 ; i < n ; i ++ ) B [ i ] = A [ i ] ^ K ; for ( int i = 0 ; i < n ; i ++ ) cout << B [ i ] << " ▁ " ; cout << endl ; } int main ( ) { int A [ ] = { 2 , 4 , 1 , 3 , 5 } ; int K = 5 ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; constructXORArray ( A , n , K ) ; int B [ ] = { 4 , 75 , 45 , 42 } ; K = 2 ; n = sizeof ( B ) / sizeof ( B [ 0 ] ) ; constructXORArray ( B , n , K ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_and ( int arr [ ] , int len ) { int ans = arr [ 0 ] ; for ( int i = 0 ; i < len ; i ++ ) { ans = ( ans & arr [ i ] ) ; } return ans ; } int main ( ) { int arr [ ] = { 1 , 3 , 5 , 9 , 11 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << find_and ( 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 maxsize = 100005 ; vector < int > xor_tree ( maxsize ) ; void construct_Xor_Tree_Util ( vector < int > current , int start , int end , int x ) { if ( start == end ) { xor_tree [ x ] = current [ start ] ; return ; } int left = x * 2 + 1 ; int right = x * 2 + 2 ; int mid = start + ( end - start ) / 2 ; construct_Xor_Tree_Util ( current , start , mid , left ) ; construct_Xor_Tree_Util ( current , mid + 1 , end , right ) ; xor_tree [ x ] = ( xor_tree [ left ] ^ xor_tree [ right ] ) ; } void construct_Xor_Tree ( vector < int > arr , int n ) { construct_Xor_Tree_Util ( arr , 0 , n - 1 , 0 ) ; } int main ( ) { vector < int > leaf_nodes = { 40 , 32 , 12 , 1 , 4 , 3 , 2 , 7 } ; int n = leaf_nodes . size ( ) ; construct_Xor_Tree ( leaf_nodes , n ) ; int x = ( int ) ( ceil ( log2 ( n ) ) ) ; int max_size = 2 * ( int ) pow ( 2 , x ) - 1 ; cout << " Nodes ▁ of ▁ the ▁ XOR ▁ Tree : STRNEWLINE " ; for ( int i = 0 ; i < max_size ; i ++ ) { cout << xor_tree [ i ] << " ▁ " ; } int root = 0 ; cout << " Root : " }

Index/key variables: i, left, right, start, x
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int arr [ ] , int n , int m , int d ) { int i = 0 ; while ( i < n && m > 0 ) { m -- ; i += d ; } return m == 0 ? true : false ; } int maximumDistance ( int arr [ ] , int n , int m ) { int low = 1 , high = n - 1 ; int ans = 0 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; bool flag = check ( arr , n , m , mid ) ; if ( flag ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } int main ( ) { int n = 5 , m = 3 ; int arr [ n ] = { 0 } ; cout << maximumDistance ( arr , n , m ) ; return 0 ; }

Index/key variables: n
Accumulator variables: i, m, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumXor ( int arr [ ] , int n ) { stack < int > sForward , sBackward ; int ans = -1 ; for ( int i = 0 ; i < n ; i ++ ) { while ( ! sForward . empty ( ) && arr [ i ] < arr [ sForward . top ( ) ] ) { ans = max ( ans , arr [ i ] ^ arr [ sForward . top ( ) ] ) ; sForward . pop ( ) ; } sForward . push ( i ) ; while ( ! sBackward . empty ( ) && arr [ n - i - 1 ] < arr [ sBackward . top ( ) ] ) { ans = max ( ans , arr [ n - i - 1 ] ^ arr [ sBackward . top ( ) ] ) ; sBackward . pop ( ) ; } sBackward . push ( n - i - 1 ) ; } return ans ; } int main ( ) { int arr [ ] = { 8 , 1 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maximumXor ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int minTrees ( int n ) { int count = 0 ; while ( n ) { n &= ( n - 1 ) ; count ++ ; } return count ; } int main ( ) { int n = 7 ; cout << minTrees ( n ) ; return 0 ; }

Accumulator variables: count, n
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMinSteps ( int K ) { return __builtin_popcount ( k ) ; } int main ( ) { int n = 343 ; cout << getMinSteps ( n ) << ' ' ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDefeat ( string s1 , string s2 , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( ( s1 [ i ] == '0' && s2 [ i ] == '1' ) || ( s1 [ i ] == '1' && s2 [ i ] == '0' ) ) continue ; else if ( ( s1 [ i ] == '0' && s2 [ i ] == ' Z ' ) || ( s1 [ i ] == ' Z ' && s2 [ i ] == '0' ) ) continue ; else { return true ; } } return false ; } int main ( ) { string s1 = { "01001101ZZ " } ; string s2 = { "10Z1001000" } ; int n = 10 ; if ( isDefeat ( s1 , s2 , n ) ) cout << " Defeat " ; else cout << " Victory " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  3
#define M  3
bool check ( int a [ N ] [ M ] , int b [ N ] [ M ] ) { for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j < M ; j ++ ) { if ( a [ i ] [ j ] != b [ i ] [ j ] ) { a [ i ] [ j ] ^= 1 ; a [ 0 ] [ 0 ] ^= 1 ; a [ 0 ] [ j ] ^= 1 ; a [ i ] [ 0 ] ^= 1 ; } } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( a [ i ] [ j ] != b [ i ] [ j ] ) return false ; } } return true ; } int main ( ) { int a [ N ] [ N ] = { { 0 , 1 , 0 } , { 0 , 1 , 0 } , { 1 , 0 , 0 } } ; int b [ N ] [ N ] = { { 1 , 0 , 0 } , { 1 , 0 , 0 } , { 1 , 0 , 0 } } ; if ( check ( a , b ) ) cout << " Yes " ; else cout << " No " ; }

Index/key variables: M, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int FindIndexKthBit ( int n , int k ) { int cnt = 0 ; int ind = 0 ; while ( n ) { if ( n & 1 ) cnt ++ ; if ( cnt == k ) return ind ; ind ++ ; n = n >> 1 ; } return -1 ; } int main ( ) { int n = 15 , k = 3 ; int ans = FindIndexKthBit ( n , k ) ; if ( ans != -1 ) cout << ans ; else cout << " No ▁ k - th ▁ set ▁ bit " ; return 0 ; }

Accumulator variables: cnt, ind, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void hasEqualBlockFrequency ( int N ) { string S = bitset < 3 > ( N ) . to_string ( ) ; set < int > p ; int c = 1 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S [ i ] == S [ i + 1 ] ) c += 1 ; else { p . insert ( c ) ; c = 1 ; } p . insert ( c ) ; } if ( p . size ( ) == 1 ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { int N = 5 ; hasEqualBlockFrequency ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDistance ( int n1 , int n2 ) { int bitCount1 = floor ( log2 ( n1 ) ) + 1 ; int bitCount2 = floor ( log2 ( n2 ) ) + 1 ; int bitDiff = abs ( bitCount1 - bitCount2 ) ; int maxBitCount = max ( bitCount1 , bitCount2 ) ; if ( bitCount1 > bitCount2 ) { n2 = n2 * pow ( 2 , bitDiff ) ; } else { n1 = n1 * pow ( 2 , bitDiff ) ; } int xorValue = n1 ^ n2 ; int bitCountXorValue ; if ( xorValue == 0 ) bitCountXorValue = 1 ; else { bitCountXorValue = floor ( log2 ( xorValue ) ) + 1 ; } int disSimilarBitPosition = maxBitCount - bitCountXorValue ; int result = bitCount1 + bitCount2 - 2 * disSimilarBitPosition ; return result ; } int main ( ) { int n1 = 12 , n2 = 5 ; cout << minDistance ( n1 , n2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int printMaxAfterRemoval ( string s ) { bool flag = false ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' && flag == false ) { flag = true ; continue ; } else cout << s [ i ] ; } } int main ( ) { string s = "1001" ; printMaxAfterRemoval ( s ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bitPos ( int n1 , int n2 ) { if ( n1 == n2 ) return 0 ; int bitCount1 = floor ( log2 ( n1 ) ) + 1 ; int bitCount2 = floor ( log2 ( n2 ) ) + 1 ; int bitDiff = abs ( bitCount1 - bitCount2 ) ; int maxBitCount = max ( bitCount1 , bitCount2 ) ; if ( bitCount1 > bitCount2 ) { n2 = n2 * pow ( 2 , bitDiff ) ; } else { n1 = n1 * pow ( 2 , bitDiff ) ; } int xorValue = n1 ^ n2 ; int bitCountXorValue = floor ( log2 ( xorValue ) ) + 1 ; int disSimilarBitPosition = maxBitCount - bitCountXorValue + 1 ; return disSimilarBitPosition ; } int main ( ) { int n1 = 53 , n2 = 55 ; cout << bitPos ( n1 , n2 ) ; return 0 ; }

Accumulator variables: stdc