dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sumFib ( int N ) { long num = ( long ) round ( pow ( ( sqrt ( 5 ) + 1 ) / 2.0 , N + 2 ) / sqrt ( 5 ) ) ; cout << ( num - 1 ) ; } int main ( ) { int N = 3 ; sumFib ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sumFib ( int N ) { double num = ( 1 - sqrt ( 5 ) ) / 2 ; long val = round ( abs ( 1 / ( pow ( num , N + 2 ) + pow ( num , N + 1 ) + pow ( num , N ) + pow ( num , N - 1 ) ) ) - 1 ) ; cout << val ; } int main ( ) { int N = 3 ; sumFib ( N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOperations ( int arr [ ] , int n , int k ) { map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) { mp [ arr [ i ] ] ++ ; } int ans = 0 ; while ( mp [ k ] < n ) { for ( int i = 1 ; i <= k - 1 ; i ++ ) { if ( mp [ i ] ) { mp [ i ] -- ; mp [ i + 1 ] ++ ; if ( mp [ i + 1 ] == 1 ) { i ++ ; } } } ans ++ ; } cout << ans ; } int main ( ) { int arr [ ] = { 2 , 3 , 3 , 4 } ; int K = 5 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minOperations ( arr , N , K ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void poorPigs ( int buckets , int minutesToDie , int minutesToTest ) { cout << ceil ( log ( buckets ) / log ( ( minutesToTest / minutesToDie ) + 1 ) ) ; } int main ( ) { int N = 1000 , M = 15 , P = 60 ; poorPigs ( N , M , P ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxProduct ( int arr [ ] , int N ) { int max_product = INT_MIN ; int prefix_sum = 0 ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { prefix_sum += arr [ i ] ; int X = prefix_sum ; int Y = sum - prefix_sum ; max_product = max ( max_product , X * Y ) ; } cout << max_product ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 6 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxProduct ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, prefix_sum, stdc, sum
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; int findMask ( int K ) { int mask = 1 ; while ( ( K & mask ) == 0 ) { mask = mask << 1 ; } return mask ; } void sameRightSetBitPos ( int arr [ ] , int N , int K ) { int mask = findMask ( K ) ; int pos = ( K & mask ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & mask ) == pos ) cout << arr [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 3 , 4 , 6 , 7 , 9 , 12 , 15 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 7 ; sameRightSetBitPos ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100001
int maxSum ( int arr [ ] , int N , int K ) { if ( N < K ) { cout << " Invalid " ; return -1 ; } int CountDistinct [ MAX + 1 ] ; bool prime [ MAX + 1 ] ; for ( int i = 0 ; i <= MAX ; i ++ ) { CountDistinct [ i ] = 0 ; prime [ i ] = true ; } for ( long long int i = 2 ; i <= MAX ; i ++ ) { if ( prime [ i ] == true ) { CountDistinct [ i ] = 1 ; for ( long long int j = i * 2 ; j <= MAX ; j += i ) { CountDistinct [ j ] ++ ; prime [ j ] = false ; } } } int Maxarr_sum = 0 , DistPrimeSum = 0 ; for ( int i = 0 ; i < K ; i ++ ) { Maxarr_sum += arr [ i ] ; DistPrimeSum += CountDistinct [ arr [ i ] ] ; } int curr_sum = DistPrimeSum ; int curr_arrSum = Maxarr_sum ; for ( int i = K ; i < N ; i ++ ) { curr_sum += CountDistinct [ arr [ i ] ] - CountDistinct [ arr [ i - K ] ] ; curr_arrSum += arr [ i ] - arr [ i - K ] ; if ( curr_sum > DistPrimeSum ) { DistPrimeSum = curr_sum ; Maxarr_sum = curr_arrSum ; } else if ( curr_sum == DistPrimeSum ) { Maxarr_sum = max ( curr_arrSum , Maxarr_sum ) ; } } cout << Maxarr_sum ; } int main ( ) { int arr [ ] = { 1 , 4 , 2 , 10 , 3 } ; int K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxSum ( arr , N , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: DistPrimeSum, Maxarr_sum, curr_arrSum, curr_sum, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkPronic ( int x ) { for ( int i = 0 ; i <= ( int ) ( sqrt ( x ) ) ; i ++ ) { if ( x == i * ( i + 1 ) ) { return true ; } } return false ; } void countPronic ( int A , int B ) { int count = 0 ; for ( int i = A ; i <= B ; i ++ ) { if ( checkPronic ( i ) ) { count ++ ; } } cout << count ; } int main ( ) { int A = 3 , B = 20 ; countPronic ( A , B ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pronic ( int num ) { int N = ( int ) sqrt ( num ) ; if ( N * ( N + 1 ) <= num ) { return N ; } return N - 1 ; } int countPronic ( int A , int B ) { return pronic ( B ) - pronic ( A - 1 ) ; } int main ( ) { int A = 3 ; int B = 20 ; cout << countPronic ( A , B ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void oddDivisors ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int powerOfTwo = 2 ; int count = 0 ; while ( powerOfTwo <= arr [ i ] ) { count ++ ; powerOfTwo = 2 * powerOfTwo ; } cout << count << " ▁ " ; } return ; } int main ( ) { int arr [ ] = { 15 , 16 , 20 , 35 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; oddDivisors ( 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 ; void checkPossible ( int * arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { cout << " No STRNEWLINE " ; return ; } else { arr [ i ] -= arr [ i - 1 ] ; arr [ i - 1 ] = 0 ; } } if ( arr [ n - 1 ] == 0 ) { cout << " Yes STRNEWLINE " ; } else { cout << " No STRNEWLINE " ; } } int main ( ) { int arr [ ] = { 2 , 3 , 3 , 4 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; checkPossible ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void highestPowerOfTwo ( int num ) { string s = to_string ( num ) ; for ( int i = 0 ; i < ( int ) s . size ( ) ; i ++ ) { if ( s [ i ] == '0' ) { cout << "0" ; continue ; } int lg = log2 ( int ( s [ i ] ) - 48 ) ; int p = pow ( 2 , lg ) ; cout << char ( p + 48 ) ; } } int main ( ) { int num = 4317 ; highestPowerOfTwo ( num ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSumAfterKReverse ( int arr [ ] , int K , int N ) { int sum = INT_MIN ; if ( K & 1 ) reverse ( arr , arr + N ) ; int currsum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { currsum += arr [ i ] ; sum = max ( sum , currsum ) ; } cout << sum ; } int main ( ) { int arr [ ] = { 1 , 5 , 8 , 9 , 11 , 2 } ; int K = 1 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxSumAfterKReverse ( arr , K , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: currsum, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SubMasks ( int N ) { for ( int S = N ; S ; S = ( S - 1 ) & N ) { cout << S << " ▁ " ; } } int main ( ) { int N = 25 ; SubMasks ( N ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: S
C++ program:
#include <bits/stdc++.h>
#define MOD  1000000007
using namespace std ; long long int power ( int x , int y ) { long long int res = 1 ; x = x % MOD ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % MOD ; y = y >> 1 ; x = ( x * x ) % MOD ; } return res ; } void countPairs ( int N ) { long long int high = power ( 2 , N ) ; int count = 0 ; for ( int i = 0 ; i < high ; i ++ ) { for ( int j = 0 ; j < high ; j ++ ) { int X = ( i ^ j ) ; int Y = ( i j ) ; if ( X == Y ) { count ++ ; } } } cout << count % MOD << endl ; } int main ( ) { int N = 10 ; countPairs ( N ) ; return 0 ; }

Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define MOD  1000000007
using namespace std ; long long int power ( int x , int y ) { long long int res = 1 ; x = x % MOD ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % MOD ; y = y >> 1 ; x = ( x * x ) % MOD ; } return res ; } void countPairs ( int N ) { cout << power ( 3 , N ) ; } int main ( ) { int N = 10 ; countPairs ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumMoves ( int * a , int n ) { int min_element = INT_MAX ; int max_element = INT_MIN ; int min_ind = -1 ; int max_ind = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] <= min_element ) { min_element = a [ i ] ; min_ind = i ; } if ( a [ i ] > max_element ) { max_element = a [ i ] ; max_ind = i ; } } if ( max_ind == min_ind ) { return 0 ; } else if ( max_ind > min_ind ) { return max_ind + ( n - min_ind - 2 ) ; } else { return max_ind + n - min_ind - 1 ; } } int main ( ) { int arr [ ] = { 35 , 46 , 17 , 23 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumMoves ( arr , N ) << endl ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findIndex ( int arr [ ] , int n , int K ) { int sum = 0 ; int res = -1 ; int mini = 1e9 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { int temp = sum - arr [ i ] ; if ( temp % K == 0 ) { if ( res == -1 mini > arr [ i ] ) { res = i + 1 ; mini = arr [ i ] ; } } } return res ; } int main ( ) { int arr [ ] = { 14 , 7 , 8 , 2 , 4 } ; int K = 7 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findIndex ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void divisionalArrays ( int arr [ 3 ] , int N ) { int sum = N ; unordered_map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } for ( auto x : mp ) { if ( x . second > 1 ) { sum += x . second - 1 ; } } cout << sum << endl ; } int main ( ) { int arr [ ] = { 1 , 1 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; divisionalArrays ( arr , N ) ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void totalInversions ( int arr [ ] , int K , int N ) { int inv = 0 ; int X = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( arr [ i ] > arr [ j ] and i < j ) inv ++ ; if ( arr [ i ] > arr [ j ] ) X ++ ; } } int totalInv = X * K * ( K - 1 ) / 2 + inv * K ; cout << totalInv << endl ; } int main ( ) { int arr [ ] = { 2 , 1 , 3 } ; int K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; totalInversions ( arr , K , N ) ; }

Index/key variables: i, j
Accumulator variables: X, i, inv, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int Fact ( int N ) { long long int result = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { result = ( result * i ) ; } return result ; } void numberOfWays ( int M , int arr [ ] , int N ) { int B [ M ] = { 0 } ; int counter [ M + 1 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] != 0 ) { if ( B [ i % M ] == 0 ) { B [ i % M ] = arr [ i ] ; counter [ arr [ i ] ] ++ ; if ( counter [ arr [ i ] ] > 1 ) { cout << 0 << endl ; return ; } } else if ( B [ i % M ] != arr [ i ] ) { cout << 0 << endl ; return ; } } } int cnt = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( B [ i ] == 0 ) { cnt ++ ; } } cout << Fact ( cnt ) << endl ; } int main ( ) { int M = 4 ; int arr [ ] = { 1 , 0 , 3 , 0 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; numberOfWays ( M , arr , N ) ; }

Index/key variables: M, i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaximumSum ( vector < vector < int > > & arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = 0 , y = i , sum = 0 ; for ( int j = i ; j < n ; j ++ ) { sum += arr [ x ++ ] [ y ++ ] ; } if ( sum > ans ) ans = sum ; } for ( int i = 1 ; i < n ; i ++ ) { int x = i , y = 0 , sum = 0 ; for ( int j = i ; j < n ; j ++ ) { sum += arr [ x ++ ] [ y ++ ] ; } if ( sum > ans ) ans = sum ; } return ans ; } int main ( ) { vector < vector < int > > arr ; arr = { { 1 , 2 , 3 } , { 3 , 5 , 10 } , { 1 , 3 , 5 } } ; int n = arr . size ( ) ; cout << MaximumSum ( arr , n ) ; return 0 ; }

Accumulator variables: i, j, stdc, sum, x, y
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberOfIntegers ( int arr [ ] , int N ) { int cur_max = 0 , count = 0 ; if ( N == 1 ) { count = 1 ; } else { for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] > cur_max ) { cur_max = arr [ i ] ; if ( arr [ i ] > arr [ i + 1 ] ) { count ++ ; } } } if ( arr [ N - 1 ] > cur_max ) count ++ ; } cout << count ; } int main ( ) { int arr [ ] = { 1 , 2 , 0 , 7 , 2 , 0 , 2 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; numberOfIntegers ( 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 ; int numberOfWays ( int n , int k ) { if ( n == 0 ) return 1 ; if ( k == 0 ) return 1 ; if ( n >= pow ( 2 , k ) ) { int curr_val = pow ( 2 , k ) ; return numberOfWays ( n - curr_val , k ) + numberOfWays ( n , k - 1 ) ; } else return numberOfWays ( n , k - 1 ) ; } int main ( ) { int n = 4 ; int k = log2 ( n ) ; cout << numberOfWays ( n , k ) << endl ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int possibleTriplets ( int arr [ ] , int N ) { int freq = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] > 0 ) { freq ++ ; } } return ( freq * 1LL * ( freq - 1 ) * ( freq - 2 ) ) / 6 ; } int main ( ) { int arr [ ] = { 2 , 5 , -9 , -3 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << possibleTriplets ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: freq, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPossibleDiff ( vector < int > & arr , int N ) { arr . push_back ( -1 ) ; reverse ( arr . begin ( ) , arr . end ( ) ) ; arr . push_back ( -1 ) ; reverse ( arr . begin ( ) , arr . end ( ) ) ; int maxDiff = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] && arr [ i ] > arr [ i + 1 ] ) { maxDiff += arr [ i ] ; } if ( arr [ i ] < arr [ i - 1 ] && arr [ i ] < arr [ i + 1 ] ) { maxDiff -= arr [ i ] ; } } cout << maxDiff ; } int main ( ) { vector < int > arr = { 3 , 2 , 1 , 4 , 5 , 2 , 1 , 7 , 8 , 9 } ; int N = arr . size ( ) ; maxPossibleDiff ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, maxDiff, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } void reverseCircularArray ( int arr [ ] , int N , int K ) { int start = K , end = K - 1 ; int count = N / 2 ; while ( count -- ) { int temp = arr [ start % N ] ; arr [ start % N ] = arr [ end % N ] ; arr [ end % N ] = temp ; start ++ ; end -- ; if ( end == -1 ) { end = N - 1 ; } } printArray ( arr , N ) ; } int main ( ) { int arr [ ] = { 3 , 5 , 2 , 4 , 1 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; reverseCircularArray ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, end, i, start, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findOriginalMatrix ( vector < vector < int > > B , int N , int M ) { int A [ N ] [ M ] ; for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < M ; ++ j ) { A [ i ] [ j ] = 1 ; } } for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < M ; ++ j ) { if ( B [ i ] [ j ] == 0 ) { for ( int k = 0 ; k < M ; ++ k ) { A [ i ] [ k ] = 0 ; } for ( int k = 0 ; k < N ; ++ k ) { A [ k ] [ j ] = 0 ; } } } } for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < M ; ++ j ) { int c = 0 ; for ( int k = 0 ; k < M ; ++ k ) { if ( c == 1 ) break ; c += A [ i ] [ k ] ; } for ( int k = 0 ; k < N ; ++ k ) { if ( c == 1 ) break ; c += A [ k ] [ j ] ; } if ( c != B [ i ] [ j ] ) { cout << " Not ▁ Possible " ; return ; } } } for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < M ; ++ j ) { cout << A [ i ] [ j ] << " ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { vector < vector < int > > B { { 1 , 1 , 1 } , { 1 , 1 , 1 } } ; int N = B . size ( ) ; int M = B [ 0 ] . size ( ) ; findOriginalMatrix ( B , N , M ) ; return 0 ; }

Index/key variables: M, N, i, j, k
Accumulator variables: c, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
#define mod  1000000007
using namespace std ; long long int power ( long long a , long long n , long long int d ) { long long int res = 1 ; while ( n ) { if ( n % 2 ) { res = ( ( res % d ) * ( a % d ) ) % d ; } a = ( ( a % d ) * ( a % d ) ) % d ; n /= 2 ; } return res ; } long long int gcd ( long long p , long long q , long long n ) { if ( p == q ) { return ( power ( p , n , mod ) + power ( q , n , mod ) ) % mod ; } long long int candidate = 1 ; long long int num = p - q ; long long int sq = sqrt ( num ) ; for ( long long i = 1 ; i <= sq ; ++ i ) { if ( num % i == 0 ) { long long int X = power ( p , n , i ) ; long long int Y = power ( q , n , i ) ; long long int temp = ( X + Y ) % i ; if ( temp == 0 ) { candidate = max ( candidate , i ) ; } temp = ( power ( p , n , num / i ) + power ( q , n , num / i ) ) % ( num / i ) ; if ( temp == 0 ) { candidate = max ( candidate , num / i ) ; } } } return candidate % mod ; } int main ( ) { long long int p , q , n ; p = 10 ; q = 6 ; n = 5 ; cout << gcd ( p , q , n ) ; return 0 ; }

Accumulator variables: n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPoint ( int n , int h ) { for ( int i = 1 ; i < n ; i ++ ) printf ( " % .2f ▁ " , sqrt ( i / ( n * 1.0 ) ) * h ) ; } int main ( ) { int n = 3 ; int h = 2 ; findPoint ( n , h ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } int calculateK ( int x , int y ) { int g = gcd ( x , y ) ; int n = y / g ; int res = n ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { res -= ( res / i ) ; while ( n % i == 0 ) n /= i ; } } if ( n != 1 ) res -= ( res / n ) ; return res ; } int main ( ) { int x = 3 , y = 15 ; cout << calculateK ( x , y ) << endl ; }

Accumulator variables: i, n, res
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isInteger ( double N ) { int X = N ; double temp2 = N - X ; if ( temp2 > 0 ) { return false ; } return true ; } int main ( ) { double N = 1.5 ; if ( isInteger ( N ) ) { cout << " YES " ; } else { cout << " NO " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nearestPowerOfTwo ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int lg = log2 ( arr [ i ] ) ; int a = pow ( 2 , lg ) ; int b = pow ( 2 , lg + 1 ) ; if ( ( arr [ i ] - a ) < ( b - arr [ i ] ) ) cout << a << " ▁ " ; else cout << b << " ▁ " ; } } int main ( ) { int arr [ ] = { 5 , 2 , 7 , 12 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; nearestPowerOfTwo ( 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 countSetBits ( int n ) { int count = 0 ; while ( n ) { n &= ( n - 1 ) ; count ++ ; } return count ; } int invertBits ( int n ) { int x = log2 ( n ) ; int m = 1 << x ; m = m | m - 1 ; n = n ^ m ; return n ; } void invertSum ( int A , int B ) { int temp = countSetBits ( A ) + countSetBits ( B ) ; cout << invertBits ( temp ) << endl ; } int main ( ) { int A = 5 ; int B = 7 ; invertSum ( A , B ) ; return 0 ; }

Accumulator variables: count, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void XOR_for_every_i ( int A [ ] , int N ) { int frequency_of_bits [ 32 ] { } ; for ( int i = 0 ; i < N ; i ++ ) { int bit_position = 0 ; int M = A [ i ] ; while ( M ) { if ( M & 1 ) { frequency_of_bits [ bit_position ] += 1 ; } bit_position += 1 ; M >>= 1 ; } } for ( int i = 0 ; i < N ; i ++ ) { int M = A [ i ] ; int value_at_that_bit = 1 ; int XOR_sum = 0 ; for ( int bit_position = 0 ; bit_position < 32 ; bit_position ++ ) { if ( M & 1 ) { XOR_sum += ( N - frequency_of_bits [ bit_position ] ) * value_at_that_bit ; } else { XOR_sum += ( frequency_of_bits [ bit_position ] ) * value_at_that_bit ; } M >>= 1 ; value_at_that_bit <<= 1 ; } cout << XOR_sum << ' ▁ ' ; } return ; } int main ( ) { int A [ ] = { 1 , 2 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; XOR_for_every_i ( A , N ) ; return 0 ; }

Index/key variables: bit_position, i
Accumulator variables: XOR_sum, bit_position, i, stdc
Iterator variables: bit_position, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumMaxDiff ( vector < int > & nums ) { set < int > s ; for ( int i = 0 ; i < nums . size ( ) ; i ++ ) { if ( nums [ i ] % 2 == 0 ) s . insert ( nums [ i ] ) ; else s . insert ( nums [ i ] * 2 ) ; } int res = * s . rbegin ( ) - * s . begin ( ) ; while ( * s . rbegin ( ) % 2 == 0 ) { int x = * s . rbegin ( ) ; s . erase ( x ) ; s . insert ( x / 2 ) ; res = min ( res , * s . rbegin ( ) - * s . begin ( ) ) ; } return res ; } int main ( ) { vector < int > arr = { 1 , 2 , 5 , 9 } ; cout << minimumMaxDiff ( arr ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bitwiseXorRange ( int n ) { if ( n % 4 == 0 ) return n ; if ( n % 4 == 1 ) return 1 ; if ( n % 4 == 2 ) return n + 1 ; return 0 ; } int evenXorRange ( int l , int r ) { int xor_l ; int xor_r ; xor_r = 2 * bitwiseXorRange ( r / 2 ) ; xor_l = 2 * bitwiseXorRange ( ( l - 1 ) / 2 ) ; return xor_l ^ xor_r ; } int main ( ) { int l = 10 ; int r = 20 ; cout << evenXorRange ( l , r ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long double find_Variance ( int n ) { long long int numerator = n * n - 1 ; long double ans = ( numerator * 1.0 ) / 12 ; return ans ; } int main ( ) { int N = 5 ; cout << fixed << setprecision ( 6 ) << find_Variance ( N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int M = 3 ; const int N = 3 ; void countDigit ( int arr [ M ] [ N ] ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { int X = arr [ i ] [ j ] ; int d = floor ( log10 ( X ) * 1.0 ) + 1 ; cout << d << " ▁ " ; } cout << endl ; } } int main ( ) { int arr [ ] [ 3 ] = { { 27 , 173 , 5 } , { 21 , 6 , 624 } , { 5 , 321 , 49 } } ; countDigit ( arr ) ; return 0 ; }

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 findSum ( int arr [ ] , int N ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } int sum_odd = 0 , sum_even = 0 ; for ( auto itr = mp . begin ( ) ; itr != mp . end ( ) ; itr ++ ) { if ( itr -> second % 2 != 0 ) sum_odd += ( itr -> first ) * ( itr -> second ) ; if ( itr -> second % 2 == 0 ) sum_even += ( itr -> first ) * ( itr -> second ) ; } int diff = sum_even - sum_odd ; return diff ; } int main ( ) { int arr [ ] = { 1 , 5 , 5 , 2 , 4 , 3 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findSum ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, itr, stdc, sum_even, sum_odd
Iterator variables: i, itr
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long ll ; void noOfArraysPossible ( ll N , ll M ) { ll ans = 1 ; for ( ll i = 0 ; i < N ; ++ i ) { ans = ans * ( M - i ) ; } cout << ans ; } int main ( ) { ll N = 2 , M = 3 ; noOfArraysPossible ( N , M ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i