dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; int countOddPair ( int A [ ] , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( ! ( A [ i ] & 1 ) ) count ++ ; int evenPairCount = count * ( count - 1 ) / 2 ; int totPairs = N * ( N - 1 ) / 2 ; return totPairs - evenPairCount ; } int main ( ) { int A [ ] = { 5 , 6 , 2 , 8 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << countOddPair ( A , N ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void ReplaceElements ( int arr [ ] , int n ) { if ( n <= 1 ) return ; int prev = arr [ 0 ] ; arr [ 0 ] = arr [ 0 ] ^ arr [ 1 ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { int curr = arr [ i ] ; arr [ i ] = prev ^ arr [ i + 1 ] ; prev = curr ; } arr [ n - 1 ] = prev ^ arr [ n - 1 ] ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; ReplaceElements ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int luckiest_person ( int n ) { int len = log2 ( n ) + 1 ; int n2 = n ; for ( int i = 0 ; i < len ; i ++ ) { n2 = n2 ^ ( 1 << i ) ; } return abs ( n - n2 ) ; } int main ( ) { int N = 3 ; int lucky_p = luckiest_person ( N ) ; cout << lucky_p ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int setBitNumber ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; n = n + 1 ; return ( n >> 1 ) ; } int luckiest_person ( int n ) { int nearestPower = setBitNumber ( n ) ; return 2 * ( n - nearestPower ) + 1 ; } int main ( ) { int N = 8 ; int lucky_p = luckiest_person ( N ) ; cout << lucky_p ; return 0 ; }

Accumulator variables: n, stdc
C++ program:
#include " cmath "
#include " cstring "
#include " iostream "
using namespace std ; int maxTriplet ( int a [ ] , int n ) { bool f [ n ] ; memset ( f , true , sizeof ( f ) ) ; int bits [ n ] [ 33 ] ; memset ( bits , 0 , sizeof ( bits ) ) ; for ( int i = 0 ; i < n ; ++ i ) { int num = a [ i ] ; int j = 32 ; while ( num ) { if ( num & 1 ) { bits [ i ] [ j ] = 1 ; } j -- ; num >>= 1 ; } } long long ans = 0 ; for ( long long i = 0 ; i <= 32 ; ++ i ) { int cnt = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( bits [ j ] [ i ] and f [ j ] ) { cnt ++ ; } } if ( cnt >= 3 ) { ans += pow ( 2LL , 32 - i ) ; for ( int j = 0 ; j < n ; ++ j ) { if ( ! bits [ j ] [ i ] ) { f [ j ] = false ; } } } } int cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( f [ i ] ) { cnt ++ ; } } long long NumberOfTriplets = ( cnt * ( cnt - 1 ) * ( cnt - 2 ) ) / 6 ; cout << NumberOfTriplets << " ▁ " << ans ; } int main ( int argc , char const * argv [ ] ) { int a [ ] = { 4 , 11 , 10 , 15 , 26 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; maxTriplet ( a , n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: ans, cnt, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int OR ( int a [ ] , int n ) { int ans = a [ 0 ] ; for ( int i = 1 ; i < n ; ++ i ) ans |= a [ i ] ; return ans ; } int main ( ) { int a [ ] = { 1 , 4 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << OR ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bit ( int n ) { int count = 0 ; while ( n ) { count ++ ; n = n & ( n - 1 ) ; } return count ; } int maxSumOfBits ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = bit ( arr [ i ] ) ; } int incl = arr [ 0 ] ; int excl = 0 ; int excl_new ; for ( int i = 1 ; i < n ; i ++ ) { excl_new = ( incl > excl ) ? incl : excl ; incl = excl + arr [ i ] ; excl = excl_new ; } return ( ( incl > excl ) ? incl : excl ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 5 , 6 , 7 , 20 , 25 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxSumOfBits ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char increment ( unsigned char i ) { i = - ( ~ i ) ; return i ; } int main ( ) { char n = ' a ' ; cout << increment ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int findOddPair ( int A [ ] , int N ) { int i , count = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 0 ) count ++ ; } return count * ( N - count ) ; } int main ( ) { int a [ ] = { 5 , 4 , 7 , 2 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findOddPair ( a , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MSBPosition ( long long int N ) { int msb_p = -1 ; while ( N ) { N = N >> 1 ; msb_p ++ ; } return msb_p ; } long long int findBitwiseOR ( long long int L , long long int R ) { long long int res = 0 ; int msb_p1 = MSBPosition ( L ) ; int msb_p2 = MSBPosition ( R ) ; while ( msb_p1 == msb_p2 ) { long long int res_val = ( 1 << msb_p1 ) ; res += res_val ; L -= res_val ; R -= res_val ; msb_p1 = MSBPosition ( L ) ; msb_p2 = MSBPosition ( R ) ; } msb_p1 = max ( msb_p1 , msb_p2 ) ; for ( int i = msb_p1 ; i >= 0 ; i -- ) { long long int res_val = ( 1 << i ) ; res += res_val ; } return res ; } int main ( ) { int L = 12 , R = 18 ; cout << findBitwiseOR ( L , R ) << endl ; return 0 ; }

Accumulator variables: L, R, i, msb_p, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxOR ( long long arr [ ] , int n , int k , int x ) { long long preSum [ n + 1 ] , suffSum [ n + 1 ] ; long long res , pow = 1 ; for ( int i = 0 ; i < k ; i ++ ) pow *= x ; preSum [ 0 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) preSum [ i + 1 ] = preSum [ i ] | arr [ i ] ; suffSum [ n ] = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) suffSum [ i ] = suffSum [ i + 1 ] | arr [ i ] ; res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res = max ( res , preSum [ i ] | ( arr [ i ] * pow ) suffSum [ i + 1 ] ) ; return res ; } int main ( ) { long long arr [ ] = { 1 , 2 , 4 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 , x = 3 ; cout << maxOR ( arr , n , k , x ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, pow, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSum ( int a [ ] , int n ) { sort ( a , a + n ) ; int num1 = 0 ; int num2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) num1 = num1 * 10 + a [ i ] ; else num2 = num2 * 10 + a [ i ] ; } return num2 + num1 ; } int main ( ) { int arr [ ] = { 5 , 3 , 0 , 7 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " The ▁ required ▁ sum ▁ is ▁ " << minSum ( 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 printKthBit ( unsigned int n , unsigned int k ) { cout << ( ( n & ( 1 << ( k - 1 ) ) ) >> ( k - 1 ) ) ; } int main ( ) { unsigned int n = 13 , k = 2 ; printKthBit ( n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100010
struct Edge { int u , v ; } ; int id [ N ] , sz [ N ] ; int Root ( int idx ) { int i = idx ; while ( i != id [ i ] ) id [ i ] = id [ id [ i ] ] , i = id [ i ] ; return i ; } void Union ( int a , int b ) { int i = Root ( a ) , j = Root ( b ) ; if ( i != j ) { if ( sz [ i ] >= sz [ j ] ) { id [ j ] = i , sz [ i ] += sz [ j ] ; sz [ j ] = 0 ; } else { id [ i ] = j , sz [ j ] += sz [ i ] ; sz [ i ] = 0 ; } } } void UnionUtil ( struct Edge e [ ] , int W [ ] , int q ) { for ( int i = 0 ; i < q ; i ++ ) { int u , v ; u = e [ i ] . u , v = e [ i ] . v ; u -- , v -- ; if ( W [ u ] % 2 == 0 && W [ v ] % 2 == 0 ) Union ( u , v ) ; } } int findMax ( int n , int W [ ] ) { int maxi = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( W [ i ] % 2 == 0 ) maxi = max ( maxi , sz [ i ] ) ; return maxi ; } int main ( ) { int W [ ] = { 1 , 2 , 6 , 4 , 2 , 0 , 3 } ; int n = sizeof ( W ) / sizeof ( W [ 0 ] ) ; for ( int i = 0 ; i < n ; i ++ ) id [ i ] = i , sz [ i ] = 1 ; Edge e [ ] = { { 1 , 2 } , { 1 , 3 } , { 2 , 4 } , { 2 , 5 } , { 4 , 6 } , { 6 , 7 } } ; int q = sizeof ( e ) / sizeof ( e [ 0 ] ) ; UnionUtil ( e , W , q ) ; int maxi = findMax ( n , W ) ; printf ( " Maximum ▁ size ▁ of ▁ the ▁ subtree ▁ with ▁ " ) ; printf ( " even ▁ weighted ▁ nodes ▁ = ▁ % d STRNEWLINE " , maxi ) ; return 0 ; }

Index/key variables: N, i, j, u, v
Accumulator variables: i, stdc, u, v
Iterator variables: i
Class/struct names: Edge
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSetBits ( int n ) { unsigned int count = 0 ; while ( n ) { count += n & 1 ; n >>= 1 ; } return count ; } int countOfOddsPascal ( int n ) { int c = countSetBits ( n ) ; return pow ( 2 , c ) ; } int main ( ) { int n = 20 ; cout << countOfOddsPascal ( n ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
#define N  100
using namespace std ; void ansQueries ( int prefeven [ ] , int prefodd [ ] , int l , int r ) { if ( ( r - l + 1 ) % 2 == 0 ) cout << "0" ; else { if ( l % 2 == 0 ) cout << ( prefeven [ r ] ^ prefeven [ l - 1 ] ) ; else cout << ( prefodd [ r ] ^ prefodd [ l - 1 ] ) ; } cout << endl ; } void wrapper ( int arr [ ] , int n , int l [ ] , int r [ ] , int q ) { int prefodd [ N ] = { 0 } , prefeven [ N ] = { 0 } ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ( i ) % 2 == 0 ) { prefeven [ i ] = arr [ i - 1 ] ^ prefeven [ i - 1 ] ; prefodd [ i ] = prefodd [ i - 1 ] ; } else { prefeven [ i ] = prefeven [ i - 1 ] ; prefodd [ i ] = prefodd [ i - 1 ] ^ arr [ i - 1 ] ; } } int i = 0 ; while ( i != q ) { query ( prefeven , prefodd , l [ i ] , r [ i ] ) ; i ++ ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int l [ ] = { 1 , 1 , 2 } ; int r [ ] = { 2 , 3 , 4 } ; int q = sizeof ( l ) / sizeof ( l [ 0 ] ) ; ansQueries ( arr , n , l , r , q ) ; return 0 ; }

Index/key variables: N, i, r
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( int p [ ] , int n ) { int G = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] & 1 ) G ^= ( p [ i ] + 1 ) ; G ^= ( p [ i ] - 1 ) ; } return G ; } int main ( ) { int n = 3 ; int p [ 3 ] = { 32 , 49 , 58 } ; int res = solve ( p , n ) ; cout << " Player ▁ 2 ▁ wins " ; cout << " Player ▁ 1 ▁ wins " ; return 0 ; }

Index/key variables: i
Accumulator variables: G, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkBit ( int pattern , int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( ( pattern & arr [ i ] ) == pattern ) count ++ ; return count ; } int maxAND ( int arr [ ] , int n ) { int res = 0 , count ; for ( int bit = 31 ; bit >= 0 ; bit -- ) { count = checkBit ( res | ( 1 << bit ) , arr , n ) ; if ( count >= 2 ) res |= ( 1 << bit ) ; } return res ; } int main ( ) { int arr [ ] = { 4 , 8 , 6 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Maximum ▁ AND ▁ Value ▁ = ▁ " << maxAND ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: bit, count, i, res, stdc
Iterator variables: bit, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countones ( long n ) ; int findMiniFlip ( int nums [ ] , int n ) { string s = " " ; for ( int i = 0 ; i < n ; i ++ ) s += nums [ i ] ; char * end ; char tmp [ s . length ( ) ] ; strcpy ( tmp , s . c_str ( ) ) ; long num = strtol ( tmp , & end , 2 ) ; int minXor = n ; long mask = ( 1 << ( n - 1 ) ) ; while ( n - 1 > 0 ) { long temp = ( num ^ mask ) ; minXor = min ( minXor , countones ( temp ) ) ; n -- ; mask = ( mask | ( 1 << ( n - 1 ) ) ) ; } return minXor ; } int countones ( long n ) { int c = 0 ; while ( n > 0 ) { n = n & ( n - 1 ) ; c ++ ; } return c ; } int main ( ) { int nums [ ] = { 1 , 0 , 1 , 1 , 0 , 0 , 0 } ; int size = sizeof ( nums ) / sizeof ( nums [ 0 ] ) ; int n = findMiniFlip ( nums , size ) ; cout << n ; }

Index/key variables: i
Accumulator variables: c, i, n, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int convertStringToInt ( string s ) { int num = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { num = num * 2 + ( s [ i ] - '0' ) ; } return num ; } int getNthNumber ( int n ) { queue < string > q ; if ( n == 1 ) return 1 ; n -- ; q . push ( "11" ) ; while ( ! q . empty ( ) ) { string curr = q . front ( ) ; q . pop ( ) ; n -- ; if ( ! n ) { return convertStringToInt ( curr ) ; } int mid = curr . size ( ) / 2 ; if ( curr . size ( ) % 2 == 0 ) { string s0 = curr , s1 = curr ; s0 . insert ( mid , "0" ) ; s1 . insert ( mid , "1" ) ; q . push ( s0 ) ; q . push ( s1 ) ; } else { string ch ( 1 , curr [ mid ] ) ; string temp = curr ; temp . insert ( mid , ch ) ; q . push ( temp ) ; } } return 0 ; } int main ( ) { int n = 9 ; cout << getNthNumber ( n ) ; }

Index/key variables: i, mid
Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ull  unsigned long long int
using namespace std ; const int ULL_SIZE = 8 * sizeof ( ull ) ; bool bit_anagram_check ( ull a ) { return ( _popcnt64 ( a ) == ( ULL_SIZE >> 1 ) ) ; } int main ( ) { ull a = 4294967295 ; cout << bit_anagram_check ( a ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( int n ) { int sum = 0 ; for ( int i = 1 ; ( 1 << i ) < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { int num = ( 1 << i ) + ( 1 << j ) ; if ( num <= n ) sum += num ; } } return sum ; } int main ( ) { int n = 10 ; cout << findSum ( n ) ; return 0 ; }

Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int posOfRightMostDiffBit ( int m , int n ) { return ffs ( m ^ n ) ; } int main ( ) { int m = 52 , n = 4 ; cout << " Position ▁ = ▁ " << posOfRightMostDiffBit ( m , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int setKthBit ( int n , int k ) { return ( ( 1 << k ) n ) ; } int main ( ) { int n = 10 , k = 2 ; cout << " Kth ▁ bit ▁ set ▁ number ▁ = ▁ " << setKthBit ( n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void reverseArray ( int arr [ ] , int n ) { int x = ( INT_MIN / INT_MAX ) ; for ( int i = 0 ; i < n / 2 ; i ++ ) swap ( arr [ i ] , arr [ n + ( x * i ) + x ] ) ; } int main ( ) { int arr [ ] = { 5 , 3 , 7 , 2 , 1 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; reverseArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void reverseArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n / 2 ; i ++ ) swap ( arr [ i ] , arr [ ( n + ~ i + 1 ) + ~ 1 + 1 ] ) ; } int main ( ) { int arr [ ] = { 5 , 3 , 7 , 2 , 1 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; reverseArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxXORInRange ( int L , int R ) { int LXR = L ^ R ; int msbPos = 0 ; while ( LXR ) { msbPos ++ ; LXR >>= 1 ; } int maxXOR = 0 ; int two = 1 ; while ( msbPos -- ) { maxXOR += two ; two <<= 1 ; } return maxXOR ; } int main ( ) { int L = 8 ; int R = 20 ; cout << maxXORInRange ( L , R ) << endl ; return 0 ; }

Accumulator variables: maxXOR, msbPos, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned int CountZeroBit ( int n ) { unsigned int count = 0 ; while ( n ) { if ( ! ( n & 1 ) ) count ++ ; n >>= 1 ; } return count ; } int CountORandSumEqual ( int N ) { int count = CountZeroBit ( N ) ; return ( 1 << count ) ; } int main ( ) { int N = 10 ; cout << CountORandSumEqual ( N ) ; return 0 ; }

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

Accumulator variables: count, k, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xorPairCount ( int arr [ ] , int n , int x ) { unordered_set < int > s ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . find ( x ^ arr [ i ] ) != s . end ( ) ) result ++ ; s . insert ( arr [ i ] ) ; } return result ; } int main ( ) { int arr [ ] = { 5 , 4 , 10 , 15 , 7 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int x = 5 ; cout << " Count ▁ of ▁ pairs ▁ with ▁ given ▁ XOR ▁ = ▁ " << xorPairCount ( arr , n , x ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isMultipleOf4 ( int n ) { if ( n == 1 ) return false ; int XOR = 0 ; for ( int i = 1 ; i <= n ; i ++ ) XOR = XOR ^ i ; return ( XOR == n ) ; } int main ( ) { for ( int n = 0 ; n <= 42 ; n ++ ) if ( isMultipleOf4 ( n ) ) cout << n << " ▁ " ; return 0 ; }

Accumulator variables: i, n, stdc
Iterator variables: i, n
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isMultipleOf4 ( long long n ) { if ( n == 0 ) return true ; return ( ( ( n >> 2 ) << 2 ) == n ) ; } int main ( ) { for ( int n = 0 ; n <= 42 ; n ++ ) if ( isMultipleOf4 ( n ) ) cout << n << " ▁ " ; return 0 ; }

Accumulator variables: n, stdc
Iterator variables: n
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; struct Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return ( temp ) ; } int sum ( Node * t ) { if ( t == NULL ) return 0 ; return t -> key + sum ( t -> left ) + sum ( t -> right ) ; } int uncoveredSumLeft ( Node * t ) { if ( t -> left == NULL && t -> right == NULL ) return t -> key ; if ( t -> left != NULL ) return t -> key + uncoveredSumLeft ( t -> left ) ; else return t -> key + uncoveredSumLeft ( t -> right ) ; } int uncoveredSumRight ( Node * t ) { if ( t -> left == NULL && t -> right == NULL ) return t -> key ; if ( t -> right != NULL ) return t -> key + uncoveredSumRight ( t -> right ) ; else return t -> key + uncoveredSumRight ( t -> left ) ; } int uncoverSum ( Node * t ) { int lb = 0 , rb = 0 ; if ( t -> left != NULL ) lb = uncoveredSumLeft ( t -> left ) ; if ( t -> right != NULL ) rb = uncoveredSumRight ( t -> right ) ; return t -> key + lb + rb ; } bool isSumSame ( Node * root ) { int sumUC = uncoverSum ( root ) ; int sumT = sum ( root ) ; return ( sumUC == ( sumT - sumUC ) ) ; } void inorder ( Node * root ) { if ( root ) { inorder ( root -> left ) ; printf ( " % d ▁ " , root -> key ) ; inorder ( root -> right ) ; } } int main ( ) { Node * root = newNode ( 8 ) ; root -> left = newNode ( 3 ) ; root -> left -> left = newNode ( 1 ) ; root -> left -> right = newNode ( 6 ) ; root -> left -> right -> left = newNode ( 4 ) ; root -> left -> right -> right = newNode ( 7 ) ; root -> right = newNode ( 10 ) ; root -> right -> right = newNode ( 14 ) ; root -> right -> right -> left = newNode ( 13 ) ; if ( isSumSame ( root ) ) printf ( " Sum ▁ of ▁ covered ▁ and ▁ uncovered ▁ is ▁ same STRNEWLINE " ) ; else printf ( " Sum ▁ of ▁ covered ▁ and ▁ uncovered ▁ is ▁ not ▁ same STRNEWLINE " ) ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSetBits ( int x ) { unsigned int count = 0 ; while ( x ) { x &= ( x - 1 ) ; count ++ ; } return count ; } int ceilLog2 ( int x ) { int count = 0 ; x -- ; while ( x > 0 ) { x = x >> 1 ; count ++ ; } return count ; } bool isBleak ( int n ) { for ( int x = n - ceilLog2 ( n ) ; x < n ; x ++ ) if ( x + countSetBits ( x ) == n ) return false ; return true ; } int main ( ) { isBleak ( 3 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; isBleak ( 4 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: count, stdc, x
Iterator variables: x
C++ program:
#include <iostream>
using namespace std ; int countStrings ( int n ) { int a [ n ] , b [ n ] ; a [ 0 ] = b [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = a [ i - 1 ] + b [ i - 1 ] ; b [ i ] = a [ i - 1 ] ; } return ( 1 << n ) - a [ n - 1 ] - b [ n - 1 ] ; } int main ( ) { cout << countStrings ( 5 ) << endl ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int swapBits ( int n , int p1 , int p2 ) { n ^= 1 << p1 ; n ^= 1 << p2 ; return n ; } int main ( ) { cout << " Result ▁ = ▁ " << swapBits ( 28 , 0 , 3 ) ; return 0 ; }

Accumulator variables: n
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 4 ; int final_path [ N + 1 ] ; bool visited [ N ] ; int final_res = INT_MAX ; void copyToFinal ( int curr_path [ ] ) { for ( int i = 0 ; i < N ; i ++ ) final_path [ i ] = curr_path [ i ] ; final_path [ N ] = curr_path [ 0 ] ; } int firstMin ( int adj [ N ] [ N ] , int i ) { int min = INT_MAX ; for ( int k = 0 ; k < N ; k ++ ) if ( adj [ i ] [ k ] < min && i != k ) min = adj [ i ] [ k ] ; return min ; } int secondMin ( int adj [ N ] [ N ] , int i ) { int first = INT_MAX , second = INT_MAX ; for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) continue ; if ( adj [ i ] [ j ] <= first ) { second = first ; first = adj [ i ] [ j ] ; } else if ( adj [ i ] [ j ] <= second && adj [ i ] [ j ] != first ) second = adj [ i ] [ j ] ; } return second ; } void TSPRec ( int adj [ N ] [ N ] , int curr_bound , int curr_weight , int level , int curr_path [ ] ) { if ( level == N ) { if ( adj [ curr_path [ level - 1 ] ] [ curr_path [ 0 ] ] != 0 ) { int curr_res = curr_weight + adj [ curr_path [ level - 1 ] ] [ curr_path [ 0 ] ] ; if ( curr_res < final_res ) { copyToFinal ( curr_path ) ; final_res = curr_res ; } } return ; } for ( int i = 0 ; i < N ; i ++ ) { if ( adj [ curr_path [ level - 1 ] ] [ i ] != 0 && visited [ i ] == false ) { int temp = curr_bound ; curr_weight += adj [ curr_path [ level - 1 ] ] [ i ] ; if ( level == 1 ) curr_bound -= ( ( firstMin ( adj , curr_path [ level - 1 ] ) + firstMin ( adj , i ) ) / 2 ) ; else curr_bound -= ( ( secondMin ( adj , curr_path [ level - 1 ] ) + firstMin ( adj , i ) ) / 2 ) ; if ( curr_bound + curr_weight < final_res ) { curr_path [ level ] = i ; visited [ i ] = true ; TSPRec ( adj , curr_bound , curr_weight , level + 1 , curr_path ) ; } curr_weight -= adj [ curr_path [ level - 1 ] ] [ i ] ; curr_bound = temp ; memset ( visited , false , sizeof ( visited ) ) ; for ( int j = 0 ; j <= level - 1 ; j ++ ) visited [ curr_path [ j ] ] = true ; } } } void TSP ( int adj [ N ] [ N ] ) { int curr_path [ N + 1 ] ; int curr_bound = 0 ; memset ( curr_path , -1 , sizeof ( curr_path ) ) ; memset ( visited , 0 , sizeof ( curr_path ) ) ; for ( int i = 0 ; i < N ; i ++ ) curr_bound += ( firstMin ( adj , i ) + secondMin ( adj , i ) ) ; curr_bound = ( curr_bound & 1 ) ? curr_bound / 2 + 1 : curr_bound / 2 ; visited [ 0 ] = true ; curr_path [ 0 ] = 0 ; TSPRec ( adj , curr_bound , 0 , 1 , curr_path ) ; } int main ( ) { int adj [ N ] [ N ] = { { 0 , 10 , 15 , 20 } , { 10 , 0 , 35 , 25 } , { 15 , 35 , 0 , 30 } , { 20 , 25 , 30 , 0 } } ; TSP ( adj ) ; printf ( " Minimum ▁ cost ▁ : ▁ % d STRNEWLINE " , final_res ) ; printf ( " Path ▁ Taken ▁ : ▁ " ) ; for ( int i = 0 ; i <= N ; i ++ ) printf ( " % d ▁ " , final_path [ i ] ) ; return 0 ; }

Index/key variables: N, i, j, k, level
Accumulator variables: curr_bound, curr_weight, i, j, k, stdc
Iterator variables: i, j, k