dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minCost ( int arr [ ] , int n ) { priority_queue < int , vector < int > , greater < int > > pq ( arr , arr + n ) ; int res = 0 ; while ( pq . size ( ) > 1 ) { int first = pq . top ( ) ; pq . pop ( ) ; int second = pq . top ( ) ; pq . pop ( ) ; res += first + second ; pq . push ( first + second ) ; } return res ; } int main ( ) { int len [ ] = { 4 , 3 , 2 , 6 } ; int size = sizeof ( len ) / sizeof ( len [ 0 ] ) ; cout << " Total ▁ cost ▁ for ▁ connecting ▁ ropes ▁ is ▁ " << minCost ( len , size ) ; return 0 ; }

Accumulator variables: res, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define n  4
void mergeKArrays ( int arr [ ] [ n ] , int a , int output [ ] ) { int c = 0 ; for ( int i = 0 ; i < a ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) output [ c ++ ] = arr [ i ] [ j ] ; } sort ( output , output + n * a ) ; } void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr [ ] [ n ] = { { 2 , 6 , 12 , 34 } , { 1 , 9 , 20 , 1000 } , { 23 , 34 , 90 , 2000 } } ; int k = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int output [ n * k ] ; mergeKArrays ( arr , 3 , output ) ; cout << " Merged ▁ array ▁ is ▁ " << endl ; printArray ( output , n * k ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: c, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define n  4
void mergeArrays ( int arr1 [ ] , int arr2 [ ] , int n1 , int n2 , int arr3 [ ] ) { int i = 0 , j = 0 , k = 0 ; while ( i < n1 && j < n2 ) { if ( arr1 [ i ] < arr2 [ j ] ) arr3 [ k ++ ] = arr1 [ i ++ ] ; else arr3 [ k ++ ] = arr2 [ j ++ ] ; } while ( i < n1 ) arr3 [ k ++ ] = arr1 [ i ++ ] ; while ( j < n2 ) arr3 [ k ++ ] = arr2 [ j ++ ] ; } void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) cout << arr [ i ] << " ▁ " ; } void mergeKArrays ( int arr [ ] [ n ] , int i , int j , int output [ ] ) { if ( i == j ) { for ( int p = 0 ; p < n ; p ++ ) output [ p ] = arr [ i ] [ p ] ; return ; } if ( j - i == 1 ) { mergeArrays ( arr [ i ] , arr [ j ] , n , n , output ) ; return ; } int out1 [ n * ( ( ( i + j ) / 2 ) - i + 1 ) ] , out2 [ n * ( j - ( ( i + j ) / 2 ) ) ] ; mergeKArrays ( arr , i , ( i + j ) / 2 , out1 ) ; mergeKArrays ( arr , ( i + j ) / 2 + 1 , j , out2 ) ; mergeArrays ( out1 , out2 , n * ( ( ( i + j ) / 2 ) - i + 1 ) , n * ( j - ( ( i + j ) / 2 ) ) , output ) ; } int main ( ) { int arr [ ] [ n ] = { { 2 , 6 , 12 , 34 } , { 1 , 9 , 20 , 1000 } , { 23 , 34 , 90 , 2000 } } ; int k = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int output [ n * k ] ; mergeKArrays ( arr , 0 , 2 , output ) ; cout << " Merged ▁ array ▁ is ▁ " << endl ; printArray ( output , n * k ) ; return 0 ; }

Index/key variables: i, j, n, p
Accumulator variables: i, j, k, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generate_derangement ( int N ) { int S [ N + 1 ] ; priority_queue < int , vector < int > , greater < int > > PQ ; for ( int i = 1 ; i <= N ; i ++ ) { S [ i ] = i ; PQ . push ( S [ i ] ) ; } int D [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { int d = PQ . top ( ) ; PQ . pop ( ) ; if ( d != S [ i ] i == N ) { D [ i ] = d ; } else { D [ i ] = PQ . top ( ) ; PQ . pop ( ) ; PQ . push ( d ) ; } } if ( D [ N ] == S [ N ] ) swap ( D [ N - 1 ] , D [ N ] ) ; for ( int i = 1 ; i <= N ; i ++ ) printf ( " % d ▁ " , D [ i ] ) ; printf ( " STRNEWLINE " ) ; } int main ( ) { generate_derangement ( 10 ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
void generate_derangement ( int N ) { int S [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) S [ i ] = i ; int D [ N + 1 ] ; for ( int i = 1 ; i <= N ; i += 2 ) { if ( i == N && i % N != 0 ) { int temp = D [ N ] ; D [ N ] = D [ N - 1 ] ; D [ N - 1 ] = temp ; } else { D [ i ] = i + 1 ; D [ i + 1 ] = i ; } } for ( int i = 1 ; i <= N ; i ++ ) printf ( " % d ▁ " , D [ i ] ) ; printf ( " STRNEWLINE " ) ; } int main ( ) { generate_derangement ( 10 ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printLargest ( int seq [ ] , int N ) { int res [ N ] ; std :: priority_queue < int > pq ; for ( int i = 0 ; i < N ; i ++ ) pq . push ( seq [ i ] ) ; for ( int i = 0 ; i < N ; i ++ ) { int d = pq . top ( ) ; pq . pop ( ) ; if ( d != seq [ i ] i == N - 1 ) { res [ i ] = d ; } else { res [ i ] = pq . top ( ) ; pq . pop ( ) ; pq . push ( d ) ; } } if ( res [ N - 1 ] == seq [ N - 1 ] ) { res [ N - 1 ] = res [ N - 2 ] ; res [ N - 2 ] = seq [ N - 1 ] ; } printf ( " Largest Derangement " for ( int i = 0 ; i < N ; i ++ ) printf ( " % d ▁ " , res [ i ] ) ; } int main ( ) { int seq [ ] = { 92 , 3 , 52 , 13 , 2 , 31 , 1 } ; int n = sizeof ( seq ) / sizeof ( seq [ 0 ] ) ; printLargest ( seq , n ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSubstrings ( int n ) { int s = log10 ( n ) ; int d = ( int ) ( pow ( 10 , s ) + 0.5 ) ; int k = d ; while ( n ) { while ( d ) { cout << n / d << endl ; d = d / 10 ; } n = n % k ; k = k / 10 ; d = k ; } } int main ( ) { int n = 123 ; printSubstrings ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
const ll MOD = 1e9 + 7 ; ll powerLL ( ll x , ll n ) { ll result = 1 ; while ( n ) { if ( n & 1 ) result = result * x % MOD ; n = n / 2 ; x = x * x % MOD ; } return result ; } ll powerStrings ( string sa , string sb ) { ll a = 0 , b = 0 ; for ( int i = 0 ; i < sa . length ( ) ; i ++ ) a = ( a * 10 + ( sa [ i ] - '0' ) ) % MOD ; for ( int i = 0 ; i < sb . length ( ) ; i ++ ) b = ( b * 10 + ( sb [ i ] - '0' ) ) % ( MOD - 1 ) ; return powerLL ( a , b ) ; } int main ( ) { string sa = "2" , sb = "3" ; cout << powerStrings ( sa , sb ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPowerOfTwo ( int n ) { return ( n && ! ( n & ( n - 1 ) ) ) ; } int previousPowerOfTwo ( int n ) { while ( n & n - 1 ) { n = n & n - 1 ; } return n ; } bool checkSum ( int n ) { if ( n == 0 n == 1 ) return false ; else if ( isPowerOfTwo ( n ) ) { cout << " ▁ " << n / 2 << " ▁ " << n / 2 ; return true ; } else { int x = previousPowerOfTwo ( n ) ; int y = n - x ; if ( isPowerOfTwo ( y ) ) { cout << " ▁ " << x << " ▁ " << y ; return true ; } } return false ; } int main ( ) { int n1 = 20 ; if ( checkSum ( n1 ) == false ) cout << " No " ; cout << endl ; int n2 = 11 ; if ( checkSum ( n2 ) == false ) cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <cmath>
using namespace std ; int complement ( int num ) { int i , len = 0 , temp , comp ; temp = num ; while ( 1 ) { len ++ ; num = num / 10 ; if ( abs ( num ) == 0 ) break ; } num = temp ; comp = pow ( 10 , len ) - num ; return comp ; } int main ( ) { cout << complement ( 25 ) << endl ; cout << complement ( 456 ) ; return 0 ; }

Accumulator variables: len
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOddSum ( int a [ ] , int n ) { int odd = 0 , c_odd = 0 , result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] & 1 ) { odd = ! odd ; } if ( odd ) { c_odd ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { result += c_odd ; if ( a [ i ] & 1 ) { c_odd = ( n - i - c_odd ) ; } } return result ; } int main ( ) { int ar [ ] = { 5 , 4 , 4 , 5 , 1 , 3 } ; int n = sizeof ( ar ) / sizeof ( ar [ 0 ] ) ; cout << " The ▁ Number ▁ of ▁ Subarrays ▁ with ▁ odd ▁ sum ▁ is ▁ " << countOddSum ( ar , n ) ; return ( 0 ) ; }

Index/key variables: i
Accumulator variables: c_odd, i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNthRoot ( double x , int n ) { double low , high ; if ( x >= 0 and x <= 1 ) { low = x ; high = 1 ; } else { low = 1 ; high = x ; } double epsilon = 0.00000001 ; double guess = ( low + high ) / 2 ; while ( abs ( ( pow ( guess , n ) ) - x ) >= epsilon ) { if ( pow ( guess , n ) > x ) { high = guess ; } else { low = guess ; } guess = ( low + high ) / 2 ; } cout << fixed << setprecision ( 16 ) << guess ; } int main ( ) { double x = 5 ; int n = 2 ; findNthRoot ( x , n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int calculateSum ( int n ) { long long int sum = 0 ; for ( int row = 0 ; row < n ; row ++ ) { sum = sum + ( 1 << row ) ; } return sum ; } int main ( ) { int n = 10 ; cout << " ▁ Sum ▁ of ▁ all ▁ elements : " << calculateSum ( n ) ; return 0 ; }

Accumulator variables: row, stdc
Iterator variables: row
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findAllSequence ( int N ) { if ( N % 2 == 0 ) { return pow ( 2 , N / 2 + 1 ) + pow ( 2 , N / 2 ) - 2 ; } else { return pow ( 2 , ( N + 1 ) / 2 ) + pow ( 2 , ( N + 1 ) / 2 ) - 2 ; } } int main ( ) { int N = 2 ; cout << findAllSequence ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1000000 ; long long phi [ N + 5 ] ; void computeTotient ( ) { for ( int i = 1 ; i <= N ; i ++ ) phi [ i ] = 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 ) ; } } } } long long power ( long long x , long long y , long long p ) { while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } long long calculate ( long long x , long long k , long long mod ) { long long arr [ N ] ; long long count = 0 ; while ( mod > 1 ) { arr [ count ++ ] = mod ; mod = phi [ mod ] ; } long long result = 1 ; long long loop = count + 1 ; arr [ count ] = 1 ; for ( int i = min ( k , loop ) - 1 ; i >= 0 ; i -- ) result = power ( x , result , arr [ i ] ) ; return result ; } int main ( ) { computeTotient ( ) ; long long x = 3 , k = 2 , m = 3 ; cout << calculate ( x , k , m ) << endl ; return 0 ; }

Index/key variables: N, count, i, mod, p
Accumulator variables: count, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOnes ( int n ) { int count = 1 ; int rem = 1 ; while ( rem != 0 ) { rem = ( rem * 10 + 1 ) % n ; count ++ ; } return count ; } int main ( ) { int n = 13 ; cout << countOnes ( n ) ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { int c = a % b ; while ( c != 0 ) { a = b ; b = c ; c = a % b ; } return b ; } int numberOfmeet ( int a , int b ) { int ans ; if ( a > b ) ans = a - b ; else ans = b - a ; if ( a < 0 ) a = a * ( -1 ) ; if ( b < 0 ) b = b * ( -1 ) ; return ans / gcd ( a , b ) ; } int main ( ) { int a = 1 , b = -1 ; cout << numberOfmeet ( a , b ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1005
void SieveOfEratosthenes ( vector < int > & primes ) { bool prime [ MAX ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p < MAX ; p ++ ) if ( prime [ p ] ) primes . push_back ( p ) ; } int minimumSquareFreeDivisors ( int N ) { vector < int > primes ; SieveOfEratosthenes ( primes ) ; int max_count = 0 ; for ( int i = 0 ; i < primes . size ( ) && primes [ i ] * primes [ i ] <= N ; i ++ ) { if ( N % primes [ i ] == 0 ) { int tmp = 0 ; while ( N % primes [ i ] == 0 ) { tmp ++ ; N /= primes [ i ] ; } max_count = max ( max_count , tmp ) ; } } if ( max_count == 0 ) max_count = 1 ; return max_count ; } int main ( ) { int N = 24 ; cout << " Minimum ▁ Number ▁ of ▁ Square ▁ Free ▁ Divisors ▁ is ▁ " << minimumSquareFreeDivisors ( N ) << endl ; N = 6 ; cout << " Minimum ▁ Number ▁ of ▁ Square ▁ Free ▁ Divisors ▁ is ▁ " << minimumSquareFreeDivisors ( N ) << endl ; return 0 ; }

Index/key variables: MAX, i, p
Accumulator variables: N, i, p, stdc, tmp
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxGCD ( int arr [ ] , int n , int k ) { int high = * max_element ( arr , arr + n ) ; int divisors [ high + 1 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= sqrt ( arr [ i ] ) ; j ++ ) { if ( arr [ i ] % j == 0 ) { divisors [ j ] ++ ; if ( j != arr [ i ] / j ) divisors [ arr [ i ] / j ] ++ ; } } } for ( int i = high ; i >= 1 ; i -- ) if ( divisors [ i ] >= k ) return i ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 8 , 8 , 12 } ; int k = 3 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMaxGCD ( arr , n , k ) ; 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 ; double determinantOfMatrix ( double mat [ 3 ] [ 3 ] ) { double ans ; ans = mat [ 0 ] [ 0 ] * ( mat [ 1 ] [ 1 ] * mat [ 2 ] [ 2 ] - mat [ 2 ] [ 1 ] * mat [ 1 ] [ 2 ] ) - mat [ 0 ] [ 1 ] * ( mat [ 1 ] [ 0 ] * mat [ 2 ] [ 2 ] - mat [ 1 ] [ 2 ] * mat [ 2 ] [ 0 ] ) + mat [ 0 ] [ 2 ] * ( mat [ 1 ] [ 0 ] * mat [ 2 ] [ 1 ] - mat [ 1 ] [ 1 ] * mat [ 2 ] [ 0 ] ) ; return ans ; } void findSolution ( double coeff [ 3 ] [ 4 ] ) { double d [ 3 ] [ 3 ] = { { coeff [ 0 ] [ 0 ] , coeff [ 0 ] [ 1 ] , coeff [ 0 ] [ 2 ] } , { coeff [ 1 ] [ 0 ] , coeff [ 1 ] [ 1 ] , coeff [ 1 ] [ 2 ] } , { coeff [ 2 ] [ 0 ] , coeff [ 2 ] [ 1 ] , coeff [ 2 ] [ 2 ] } , } ; double d1 [ 3 ] [ 3 ] = { { coeff [ 0 ] [ 3 ] , coeff [ 0 ] [ 1 ] , coeff [ 0 ] [ 2 ] } , { coeff [ 1 ] [ 3 ] , coeff [ 1 ] [ 1 ] , coeff [ 1 ] [ 2 ] } , { coeff [ 2 ] [ 3 ] , coeff [ 2 ] [ 1 ] , coeff [ 2 ] [ 2 ] } , } ; double d2 [ 3 ] [ 3 ] = { { coeff [ 0 ] [ 0 ] , coeff [ 0 ] [ 3 ] , coeff [ 0 ] [ 2 ] } , { coeff [ 1 ] [ 0 ] , coeff [ 1 ] [ 3 ] , coeff [ 1 ] [ 2 ] } , { coeff [ 2 ] [ 0 ] , coeff [ 2 ] [ 3 ] , coeff [ 2 ] [ 2 ] } , } ; double d3 [ 3 ] [ 3 ] = { { coeff [ 0 ] [ 0 ] , coeff [ 0 ] [ 1 ] , coeff [ 0 ] [ 3 ] } , { coeff [ 1 ] [ 0 ] , coeff [ 1 ] [ 1 ] , coeff [ 1 ] [ 3 ] } , { coeff [ 2 ] [ 0 ] , coeff [ 2 ] [ 1 ] , coeff [ 2 ] [ 3 ] } , } ; double D = determinantOfMatrix ( d ) ; double D1 = determinantOfMatrix ( d1 ) ; double D2 = determinantOfMatrix ( d2 ) ; double D3 = determinantOfMatrix ( d3 ) ; printf ( " D ▁ is ▁ : ▁ % lf ▁ STRNEWLINE " , D ) ; printf ( " D1 ▁ is ▁ : ▁ % lf ▁ STRNEWLINE " , D1 ) ; printf ( " D2 ▁ is ▁ : ▁ % lf ▁ STRNEWLINE " , D2 ) ; printf ( " D3 ▁ is ▁ : ▁ % lf ▁ STRNEWLINE " , D3 ) ; if ( D != 0 ) { double x = D1 / D ; double y = D2 / D ; printf ( " Value ▁ of ▁ x ▁ is ▁ : ▁ % lf STRNEWLINE " , x ) ; printf ( " Value ▁ of ▁ y ▁ is ▁ : ▁ % lf STRNEWLINE " , y ) ; printf ( " Value ▁ of ▁ z ▁ is ▁ : ▁ % lf STRNEWLINE " , z ) ; } else { if ( D1 == 0 && D2 == 0 && D3 == 0 ) printf ( " Infinite ▁ solutions STRNEWLINE " ) ; else if ( D1 != 0 D2 != 0 D3 != 0 ) printf ( " No ▁ solutions STRNEWLINE " ) ; } } int main ( ) { double coeff [ 3 ] [ 4 ] = { { 2 , -1 , 3 , 9 } , { 1 , 1 , 1 , 6 } , { 1 , -1 , 1 , 2 } , } ; findSolution ( coeff ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printGreater ( double x , double y ) { long double X = y * log ( x ) ; long double Y = x * log ( y ) ; if ( abs ( X - Y ) < 1e-9 ) { cout << " Equal " ; } else if ( X > Y ) { cout << x << " ^ " << y ; } else { cout << y << " ^ " << x ; } } int main ( ) { double x = 5 , y = 8 ; printGreater ( x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfSeries ( int n ) { return n * ( n + 1 ) * ( 6 * n * n * n + 9 * n * n + n - 1 ) / 30 ; } int main ( ) { int n = 4 ; cout << sumOfSeries ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int mulmod ( long long int a , long long int b , long long int mod ) { a = a % mod ; while ( b > 0 ) { if ( b % 2 == 1 ) res = ( res + a ) % mod ; a = ( a * 2 ) % mod ; b /= 2 ; } return res % mod ; } long long int findProduct ( long long int N ) { long long int product = 1 , fact = 1 ; long long int MOD = 1e9 + 7 ; for ( int i = 1 ; i <= N ; i ++ ) { fact = mulmod ( fact , i , MOD ) ; product = mulmod ( product , fact , MOD ) ; if ( product == 0 ) return 0 ; } return product ; } int main ( ) { long long int N = 3 ; cout << findProduct ( N ) << endl ; N = 5 ; cout << findProduct ( N ) << endl ; return 0 ; }

Accumulator variables: b, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divSum ( int n ) { long long int sum = 1 ; for ( long long int i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) sum = sum + i + n / i ; return sum ; } bool areEquivalent ( int num1 , int num2 ) { return divSum ( num1 ) == divSum ( num2 ) ; } int main ( ) { int num1 = 559 , num2 = 703 ; areEquivalent ( num1 , num2 ) ? cout << " Equivalent " : cout << " Not ▁ Equivalent " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dodecahedral_num ( int n ) { return n * ( 3 * n - 1 ) * ( 3 * n - 2 ) / 2 ; } int main ( ) { int n = 5 ; cout << n << " th ▁ Dodecahedral ▁ number : ▁ " ; cout << dodecahedral_num ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bit ( int x ) { int ans = 0 ; while ( x ) { x /= 2 ; ans ++ ; } return ans ; } bool check ( int d , int x ) { if ( bit ( x / d ) <= bit ( d ) ) return true ; return false ; } int bs ( int n ) { int l = 1 , r = sqrt ( n ) ; while ( l < r ) { int m = ( l + r ) / 2 ; if ( check ( m , n ) ) r = m ; else l = m + 1 ; } if ( ! check ( l , n ) ) return l + 1 ; else return l ; } int countDivisor ( int n ) { return n - bs ( n ) + 1 ; } int main ( ) { int n = 5 ; cout << countDivisor ( n ) << endl ; return 0 ; }

Accumulator variables: ans, stdc, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool everMeet ( int x1 , int x2 , int v1 , int v2 ) { if ( x1 < x2 && v1 <= v2 ) return false ; if ( x1 > x2 && v1 >= v2 ) return false ; if ( x1 < x2 ) { swap ( x1 , x2 ) ; swap ( v1 , v2 ) ; } while ( x1 >= x2 ) { if ( x1 == x2 ) return true ; x1 = x1 + v1 ; x2 = x2 + v2 ; } return false ; } int main ( ) { int x1 = 5 , v1 = 8 , x2 = 4 , v2 = 7 ; if ( everMeet ( x1 , x2 , v1 , v2 ) ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string check ( long int k , int d0 , int d1 ) { long int s = ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 + ( 8 * ( d0 + d1 ) ) % 10 + ( 6 * ( d0 + d1 ) ) % 10 ; int a = ( k - 3 ) % 4 ; int x ; switch ( a ) { case 0 : x = 0 ; break ; case 1 : x = ( 2 * ( d0 + d1 ) ) % 10 ; break ; case 2 : x = ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 ; break ; case 3 : x = ( 2 * ( d0 + d1 ) ) % 10 + ( 4 * ( d0 + d1 ) ) % 10 + ( 8 * ( d0 + d1 ) ) % 10 ; break ; } long int sum = d0 + d1 + ( ( k - 3 ) / 4 ) * s + x ; if ( sum % 3 == 0 ) return " YES " ; return " NO " ; } int main ( ) { long int k , d0 , d1 ; k = 13 ; d0 = 8 ; d1 = 1 ; cout << check ( k , d0 , d1 ) << endl ; k = 5 ; d0 = 3 ; d1 = 4 ; cout << check ( k , d0 , d1 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printCollatz ( int n ) { while ( n != 1 ) { cout << n << " ▁ " ; if ( n & 1 ) n = 3 * n + 1 ; else n = n / 2 ; } cout << n ; } int main ( ) { printCollatz ( 6 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void block ( long int x ) { vector < long int > v ; cout << " Blocks ▁ for ▁ " << x << " ▁ : ▁ " ; while ( x > 0 ) { v . push_back ( x % 2 ) ; x = x / 2 ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( v [ i ] == 1 ) { cout << i ; if ( i != v . size ( ) - 1 ) cout << " , ▁ " ; } } cout << endl ; } int main ( ) { block ( 71307 ) ; block ( 1213 ) ; block ( 29 ) ; block ( 100 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValidNesbitt ( double a , double b , double c ) { double A = a / ( b + c ) ; double B = b / ( a + c ) ; double C = c / ( a + b ) ; double inequality = A + B + C ; return ( inequality >= 1.5 ) ; } int main ( ) { double a = 1.0 , b = 2.0 , c = 3.0 ; if ( isValidNesbitt ( a , b , c ) ) cout << " Nesbitt ' s ▁ inequality ▁ satisfied . " << " for ▁ real ▁ numbers ▁ " << a << " , ▁ " << b << " , ▁ " << c << " STRNEWLINE " ; else cout << " Not ▁ satisfied " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > primes ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( int j = i * 2 ; j <= n ; j += i ) prime [ j ] = false ; } } vector < int > arr ; for ( int i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] ) arr . push_back ( i ) ; } return arr ; } vector < int > signature ( int n ) { vector < int > r = primes ( n ) ; map < int , int > factor ; map < int , int > :: iterator it ; vector < int > sort_exp ; int k , t = n ; it = factor . begin ( ) ; for ( int i = 0 ; i < r . size ( ) ; i ++ ) { if ( n % r [ i ] == 0 ) { k = 0 ; while ( n % r [ i ] == 0 ) { n = n / r [ i ] ; k ++ ; } factor . insert ( it , pair < int , int > ( r [ i ] , k ) ) ; sort_exp . push_back ( k ) ; } } sort ( sort_exp . begin ( ) , sort_exp . end ( ) ) ; cout << " ▁ The ▁ Ordered ▁ Prime ▁ Signature ▁ of ▁ " << t << " ▁ is ▁ : ▁ STRNEWLINE { ▁ " ; for ( int i = 0 ; i < sort_exp . size ( ) ; i ++ ) { if ( i != sort_exp . size ( ) - 1 ) cout << sort_exp [ i ] << " , ▁ " ; else cout << sort_exp [ i ] << " ▁ } STRNEWLINE " ; } return sort_exp ; } void divisors ( int n ) { int f = 1 , l ; vector < int > div = signature ( n ) ; l = div . size ( ) ; for ( int i = 0 ; i < l ; i ++ ) { div [ i ] += 1 ; f *= div [ i ] ; } cout << " The ▁ total ▁ number ▁ of ▁ divisors ▁ of ▁ " << n << " ▁ is ▁ " << f << " STRNEWLINE " ; } int main ( ) { int n = 13 ; divisors ( n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: f, i, j, k, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printCubeFree ( int n ) { bool cubFree [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) cubFree [ i ] = true ; for ( int i = 2 ; i * i * i <= n ; i ++ ) { if ( cubFree [ i ] ) { for ( int multiple = 1 ; i * i * i * multiple <= n ; multiple ++ ) { cubFree [ i * i * i * multiple ] = false ; } } } for ( int i = 2 ; i <= n ; i ++ ) { if ( cubFree [ i ] == true ) cout << i << " ▁ " ; } } int main ( ) { printCubeFree ( 20 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, multiple, stdc
Iterator variables: i, multiple
C++ program:
#include <bits/stdc++.h>
using namespace std ; void heapify ( int arr [ ] , int n , int i ) { int smallest = i ; int l = 2 * i + 1 ; int r = 2 * i + 2 ; if ( l < n && arr [ l ] < arr [ smallest ] ) smallest = l ; if ( r < n && arr [ r ] < arr [ smallest ] ) smallest = r ; if ( smallest != i ) { swap ( arr [ i ] , arr [ smallest ] ) ; heapify ( arr , n , smallest ) ; } } void heapSort ( int arr [ ] , int n ) { for ( int i = n / 2 - 1 ; i >= 0 ; i -- ) heapify ( arr , n , i ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { swap ( arr [ 0 ] , arr [ i ] ) ; heapify ( arr , i , 0 ) ; } } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) cout << arr [ i ] << " ▁ " ; cout << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 4 , 6 , 3 , 2 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; heapSort ( arr , n ) ; cout << " Sorted ▁ array ▁ is ▁ STRNEWLINE " ; printArray ( arr , n ) ; }

Index/key variables: i, l, r, smallest
Accumulator variables: i, stdc
Iterator variables: i