dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isSemiprime ( int num ) { int cnt = 0 ; for ( int i = 2 ; cnt < 2 && i * i <= num ; ++ i ) while ( num % i == 0 ) num /= I ; ++ cnt ; if ( num > 1 ) ++ cnt ; return cnt == 2 ; } bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } bool isChenPrime ( int n ) { if ( isPrime ( n ) && ( isSemiprime ( n + 2 ) || isPrime ( n + 2 ) ) ) return true ; else return false ; } int main ( ) { int n = 7 ; if ( isChenPrime ( n ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Accumulator variables: num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPowerOfTwo ( int n ) { return ( n && ! ( n & ( n - 1 ) ) ) ; } bool isThabitNumber ( int n ) { n = n + 1 ; if ( n % 3 == 0 ) n = n / 3 ; else return false ; if ( isPowerOfTwo ( n ) ) return true ; else return false ; } int main ( ) { int n = 47 ; if ( isThabitNumber ( n ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1000 ; int dp [ N + 1 ] ; void sieve ( ) { int arr [ N + 1 ] ; arr [ 0 ] = 1 ; arr [ 1 ] = 1 ; for ( int i = 2 ; i <= sqrt ( N ) ; i ++ ) if ( arr [ i ] == 0 ) for ( int j = i * i ; j <= N ; j += i ) arr [ j ] = 1 ; long runningPrimeSum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( arr [ i ] == 0 ) runningPrimeSum += i ; dp [ i ] = runningPrimeSum ; } } int main ( ) { int l = 4 , r = 13 ; sieve ( ) ; cout << dp [ r ] - dp [ l - 1 ] ; return 0 ; }

Index/key variables: i, j, r
Accumulator variables: i, j, runningPrimeSum, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinEqualSums ( int a [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; } int sum1 = 0 , sum2 = 0 ; int min = INT_MAX ; for ( int i = 0 ; i < N ; i ++ ) { sum1 += a [ i ] ; sum2 = sum - sum1 ; if ( abs ( sum1 - sum2 ) < min ) { min = abs ( sum1 - sum2 ) ; } if ( min == 0 ) { break ; } } return min ; } int main ( ) { int a [ ] = { 3 , 2 , 1 , 5 , 7 , 8 } ; int N = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << ( findMinEqualSums ( a , N ) ) ; }

Index/key variables: i
Accumulator variables: i, stdc, sum, sum1
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  10000
bool prime [ MAX + 1 ] ; void SieveOfEratosthenes ( ) { memset ( prime , true , sizeof ( prime ) ) ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } } int solve ( int n ) { int count = 0 , num = 1 ; long long int sum = 0 ; while ( count < n ) { if ( prime [ num ] ) { sum += num ; count ++ ; } num ++ ; } return sum ; } int main ( ) { SieveOfEratosthenes ( ) ; int n = 4 ; cout << " Sum ▁ of ▁ 1st ▁ N ▁ prime ▁ numbers ▁ are ▁ : " << solve ( n ) ; return 0 ; }

Index/key variables: i, num, p
Accumulator variables: count, i, num, p, stdc, sum
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; long fact ( const int & p ) { if ( p <= 1 ) return 1 ; return p * fact ( p - 1 ) ; } bool isPrime ( const int & p ) { if ( p == 4 ) return false ; return bool ( fact ( p >> 1 ) % p ) ; } int main ( ) { cout << isPrime ( 127 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountDigits ( int n ) { if ( n == 1 ) return 1 ; double sum = 0 ; for ( int i = 2 ; i <= n ; ++ i ) { sum += ( double ) log ( i ) / ( double ) log ( 10 ) ; } sum *= ( double ) n ; } int main ( ) { int N = 5 ; cout << CountDigits ( N ) ; return 0 ; }

Accumulator variables: stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
#define MAX  200006
#define CONS  32766
void calc ( ll a [ ] , ll b [ ] , ll lr [ ] , ll q , ll n ) { ll M , m , i , j , k , l , r , suma , sumb , cc ; cc = 0 ; for ( i = 0 ; i < n - 1 ; ++ i ) { a [ i + 1 ] += a [ i ] ; b [ i + 1 ] += b [ i ] ; } while ( q -- ) { l = lr [ cc ++ ] ; r = lr [ cc ++ ] ; l -= 2 ; r -= 1 ; suma = a [ r ] ; sumb = b [ r ] ; if ( l >= 0 ) { suma -= a [ l ] ; sumb -= b [ l ] ; } M = max ( CONS * suma + CONS * sumb , - CONS * suma - CONS * sumb ) ; M = max ( M , max ( CONS * suma - CONS * sumb , - CONS * suma + CONS * sumb ) ) ; m = min ( CONS * suma + CONS * sumb , - CONS * suma - CONS * sumb ) ; m = min ( m , min ( CONS * suma - CONS * sumb , - CONS * suma + CONS * sumb ) ) ; cout << ( M - m ) << " STRNEWLINE " ; } } int main ( ) { ll n = 5 , q = 2 ; ll a [ 5 ] = { 0 , 7 , 3 , 4 , 5 } ; ll b [ 5 ] = { 0 , 3 , 1 , 2 , 3 } ; ll lr [ q * 2 ] ; lr [ 0 ] = 1 ; lr [ 1 ] = 1 ; lr [ 2 ] = 1 ; lr [ 3 ] = 3 ; calc ( a , b , lr , q , n ) ; return 0 ; }

Index/key variables: i, l, r
Accumulator variables: cc, l, q, r, stdc, suma, sumb
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define mod  1000000009
int NthTerm ( long long n ) { long long x = ( 3 * n * n ) % mod ; return ( x - n + mod ) % mod ; } int main ( ) { long long N = 4 ; cout << NthTerm ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power [ 31 ] ; int pre [ 31 ] ; void PowerOfTwo ( ) { int x = 1 ; for ( int i = 0 ; i < 31 ; i ++ ) { power [ i ] = x ; x *= 2 ; } pre [ 0 ] = 1 ; for ( int i = 1 ; i < 31 ; i ++ ) pre [ i ] = pre [ i - 1 ] + power [ i ] ; } int Sum ( int n ) { int ans = n * ( n + 1 ) / 2 ; for ( int i = 0 ; i < 31 ; i ++ ) { if ( power [ i ] > n ) { ans -= 2 * pre [ i - 1 ] ; break ; } } return ans ; } int main ( ) { PowerOfTwo ( ) ; int n = 4 ; cout << Sum ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } int main ( ) { int n = 17 ; if ( isPrime ( n ) && ( n % 16 == 1 ) ) { cout << " YES " ; } else { cout << " NO " ; } return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumber ( int n ) { for ( int i = n - 1 ; > = 0 ; i -- ) { int count [ 10 ] = { 0 } ; int x = i ; int count1 = 0 , count2 = 0 ; while ( x ) { count [ x % 10 ] ++ ; x /= 10 ; count1 ++ ; } for ( int j = 0 ; j < 10 ; j ++ ) { if ( count [ j ] == 1 ) count2 ++ ; } if ( count1 == count2 ) return i ; } } int main ( ) { int n = 8490 ; cout << findNumber ( n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: count1, count2, i, j, stdc, x
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; } ; bool isPermutation ( struct Node * first , struct Node * second ) { int sum1 = 0 , sum2 = 0 , mul1 = 1 , mul2 = 1 ; struct Node * temp1 = first ; while ( temp1 != NULL ) { sum1 += temp1 -> data ; mul1 *= temp1 -> data ; temp1 = temp1 -> next ; } struct Node * temp2 = second ; while ( temp2 != NULL ) { sum2 += temp2 -> data ; mul2 *= temp2 -> data ; temp2 = temp2 -> next ; } return ( ( sum1 == sum2 ) && ( mul1 == mul2 ) ) ; } void push ( struct Node * * head_ref , int new_data ) { struct Node * new_node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int main ( ) { struct Node * first = NULL ; push ( & first , 1 ) ; push ( & first , 34 ) ; push ( & first , 10 ) ; push ( & first , 1 ) ; push ( & first , 35 ) ; push ( & first , 12 ) ; struct Node * second = NULL ; push ( & second , 35 ) ; push ( & second , 1 ) ; push ( & second , 12 ) ; push ( & second , 1 ) ; push ( & second , 10 ) ; push ( & second , 34 ) ; if ( isPermutation ( first , second ) ) { cout << " Yes " << endl ; } else { cout << " No " << endl ; } return 0 ; }

Accumulator variables: mul1, mul2, stdc, sum1, sum2
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solveProportion ( int a , int b1 , int b2 , int c ) { int A = a * b2 ; int B = b1 * b2 ; int C = b1 * c ; int gcd = __gcd ( __gcd ( A , B ) , C ) ; cout << A / gcd << " : " << B / gcd << " : " << C / gcd ; } int main ( ) { int a , b1 , b2 , c ; a = 3 ; b1 = 4 ; b2 = 8 ; c = 9 ; solveProportion ( a , b1 , b2 , c ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int countDivisors ( int n , int k ) { int count = 0 , i ; for ( i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 && i % k == 0 ) { count ++ ; } } return count ; } int main ( ) { int n = 12 , k = 3 ; cout << countDivisors ( n , k ) ; return 0 ; }

Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int n ) { int ans = ( n * ( n - 1 ) ) / 2 ; return ans ; } int main ( ) { int n = 5 ; cout << sum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long ll ; const long long MOD = 1000000007 ; ll power ( ll x , unsigned long long y , ll p ) { ll res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } ll sumProd ( ll n , ll t ) { ll dino = power ( t + 1 , MOD - 2 , MOD ) ; unsigned long long ans = 1 ; for ( ll i = n + t + 1 ; i > n ; -- i ) ans = ( ans % MOD * i % MOD ) % MOD ; ll tfact = 1 ; for ( int i = 1 ; i <= t ; ++ i ) tfact = ( tfact * i ) % MOD ; ans = ans * dino - tfact + MOD ; return ans % MOD ; } int main ( ) { ll n = 3 , t = 2 ; cout << sumProd ( n , t ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define mod  1000000007
long long int power ( long long int a , long long int b ) { long long int res = 1 ; while ( b ) { if ( b & 1 ) { res *= a ; res %= mod ; } b /= 2 ; a *= a ; a %= mod ; } return res ; } long long int minPlayer ( long long int n , long long int k ) { long long int num = ( ( power ( k , n ) - 1 ) + mod ) % mod ; long long int den = ( power ( k - 1 , mod - 2 ) + mod ) % mod ; long long int ans = ( ( ( num * den ) % mod ) * k ) % mod ; return ans ; } int main ( ) { long long int n = 3 , k = 3 ; cout << minPlayer ( n , k ) ; return 0 ; }

Accumulator variables: a, b, res, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sieveOfEratosthenes ( int N , int s [ ] ) { vector < bool > prime ( N + 1 , false ) ; for ( int i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j * i <= N ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } int findSum ( int N ) { int s [ N + 1 ] ; int ans = 1 ; sieveOfEratosthenes ( N , s ) ; int currFactor = s [ N ] ; int power = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( currFactor == s [ N ] ) { power ++ ; continue ; } int sum = 0 ; for ( int i = 0 ; i <= power ; i ++ ) sum += pow ( currFactor , i ) ; ans *= sum ; currFactor = s [ N ] ; power = 1 ; } return ans ; } int main ( ) { int n = 12 ; cout << " Sum ▁ of ▁ the ▁ factors ▁ is ▁ : ▁ " ; cout << findSum ( n ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: N, ans, i, j, power, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMultiples ( int n ) { int multiple [ ] = { 2 , 3 , 5 } ; int count = 0 , mask = pow ( 2 , 3 ) ; for ( int i = 1 ; i < mask ; i ++ ) { int prod = 1 ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( i & 1 << j ) prod = prod * multiple [ j ] ; } if ( __builtin_popcount ( i ) % 2 == 1 ) count = count + n / prod ; else count = count - n / prod ; } return count ; } int main ( ) { int n = 10 ; cout << countMultiples ( n ) << endl ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findN ( int k ) { int ans ; if ( k == 0 ) ans = 3 ; if ( k == 1 ) ans = 1 ; else if ( k % 4 == 0 ) ans = k ; else if ( k % 4 == 3 ) ans = k - 1 ; else ans = -1 ; return ans ; } int main ( ) { int k = 7 ; int res = findN ( k ) ; if ( res == -1 ) cout << " Not ▁ possible " ; else cout << res ; return 0 ; }

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

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float calTime ( float arr [ ] , int n ) { float work = 0 ; for ( int i = 0 ; i < n ; i ++ ) work += 1 / arr [ i ] ; return 1 / work ; } int main ( ) { float arr [ ] = { 6.0 , 3.0 , 4.0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << calTime ( arr , n ) << " ▁ Hours " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, work
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printTwins ( int low , int high ) { bool prime [ high + 1 ] , twin = false ; memset ( prime , true , sizeof ( prime ) ) ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p <= floor ( sqrt ( high ) ) + 1 ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= high ; i += p ) prime [ i ] = false ; } } for ( int i = high ; i >= low ; i -- ) { if ( prime [ i ] && ( i - 2 >= low && prime [ i - 2 ] == true ) ) { cout << " Largest ▁ twins ▁ in ▁ given ▁ range : ▁ ( " << i - 2 << " , ▁ " << i << " ) " ; twin = true ; break ; } } if ( twin == false ) cout << " No ▁ such ▁ pair ▁ exists " << endl ; } int main ( ) { printTwins ( 10 , 100 ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
Boolean variables: twin
C++ program:
#include <iostream>
#include <cmath>
using namespace std ; int prevComplement ( int n , int b ) { int maxDigit , maxNum = 0 , digits = 0 , num = n ; while ( n != 0 ) { digits ++ ; n = n / 10 ; } maxDigit = b - 1 ; while ( digits -- ) { maxNum = maxNum * 10 + maxDigit ; } return maxNum - num ; } int complement ( int n , int b ) { return prevComplement ( n , b ) + 1 ; } int main ( ) { cout << prevComplement ( 25 , 7 ) << endl ; cout << complement ( 25 , 7 ) ; return 0 ; }

Accumulator variables: digits
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } int main ( ) { int a = 2 ; int b = 4 ; cout << gcd ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaximumDivisors ( int X , int Y ) { int arr [ Y - X + 1 ] ; memset ( arr , 0 , sizeof ( arr ) ) ; int mx = INT_MIN ; int cnt = 0 ; for ( int i = 1 ; i * i <= Y ; i ++ ) { int sq = i * i ; int first_divisible ; if ( ( X / i ) * i >= X ) first_divisible = ( X / i ) * i ; else first_divisible = ( X / i + 1 ) * i ; for ( int j = first_divisible ; j <= Y ; j += i ) { if ( j < sq ) continue ; else if ( j == sq ) arr [ j - X ] ++ ; else arr [ j - X ] += 2 ; } } for ( int i = X ; i <= Y ; i ++ ) { if ( arr [ i - X ] > mx ) { cnt = 1 ; mx = arr [ i - X ] ; } else if ( arr [ i - X ] == mx ) cnt ++ ; } return cnt ; } int main ( ) { int X = 1 , Y = 10 ; cout << MaximumDivisors ( X , Y ) << endl ; return 0 ; }

Accumulator variables: cnt, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } int NearestElement ( int A , int D , int P ) { if ( A == 0 ) return 0 ; else if ( D == 0 ) return -1 ; else { int X = power ( D , P - 2 , P ) ; return ( X * ( P - A ) ) % P ; } } int main ( ) { int A = 4 , D = 9 , P = 11 ; A %= P ; D %= P ; cout << NearestElement ( A , D , P ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print ( int p0 ) { int p1 , i = 0 , x , flag , k ; while ( 1 ) { flag = 1 ; x = ( int ) ( pow ( 2 , i ) ) ; p1 = x * p0 + ( x - 1 ) ; for ( k = 2 ; k < p1 ; k ++ ) { if ( p1 % k == 0 ) { flag = 0 ; break ; } } if ( flag == 0 ) break ; printf ( " % d ▁ " , p1 ) ; i ++ ; } } int main ( ) { int p0 = 2 ; print ( p0 ) ; return 0 ; }

Accumulator variables: i, k, stdc
Iterator variables: k
C++ program:
#include <iostream>
using namespace std ; int findOddPair ( int A [ ] , int N ) { int i , j ; int oddPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] & A [ j ] ) % 2 != 0 ) oddPair ++ ; } } return oddPair ; } int main ( ) { int a [ ] = { 5 , 1 , 3 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findOddPair ( a , n ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, oddPair
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int summ ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } void printDigitalRoot ( int n ) { int maxi = 1 ; int dig = 1 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { int d1 = summ ( n / i ) ; int d2 = summ ( i ) ; if ( d1 > maxi ) { dig = n / i ; maxi = d1 ; } if ( d2 > maxi ) { dig = i ; maxi = d2 ; } if ( d1 == maxi ) { if ( dig < ( n / i ) ) { dig = n / i ; maxi = d1 ; } } if ( d2 == maxi ) { if ( dig < i ) { dig = i ; maxi = d2 ; } } } } cout << dig << " ▁ " << maxi << endl ; } int main ( ) { int n = 10 ; printDigitalRoot ( n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Divide ( int a , int b ) { long long dividend = ( long long ) a ; long long divisor = ( long long ) b ; long long sign = ( dividend < 0 ) ^ ( divisor < 0 ) ? -1 : 1 ; dividend = abs ( dividend ) ; divisor = abs ( divisor ) ; if ( divisor == 0 ) { cout << " Cannot ▁ Divide ▁ by ▁ 0" << endl ; return ; } if ( dividend == 0 ) { cout << a << " ▁ / ▁ " << b << " ▁ is ▁ equal ▁ to ▁ : ▁ " << 0 << endl ; return ; } if ( divisor == 1 ) { cout << a << " ▁ / ▁ " << b << " ▁ is ▁ equal ▁ to ▁ : ▁ " << sign * dividend << endl ; return ; } cout << a << " ▁ / ▁ " << b << " ▁ is ▁ equal ▁ to ▁ : ▁ " << sign * exp ( log ( dividend ) - log ( divisor ) ) << endl ; } int main ( ) { int a = 10 , b = 5 ; Divide ( a , b ) ; a = 49 , b = -7 ; Divide ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string calculateFraction ( int num , int den ) { if ( num == 0 ) return "0" ; int sign = ( num < 0 ) ^ ( den < 0 ) ? -1 : 1 ; num = abs ( num ) ; den = abs ( den ) ; int initial = num / den ; string res ; if ( sign == -1 ) res += " - " ; res += to_string ( initial ) ; if ( num % den == 0 ) return res ; res += " . " ; int rem = num % den ; map < int , int > mp ; int index ; bool repeating = false ; while ( rem > 0 && ! repeating ) { if ( mp . find ( rem ) != mp . end ( ) ) { index = mp [ rem ] ; repeating = true ; break ; } else mp [ rem ] = res . size ( ) ; rem = rem * 10 ; int temp = rem / den ; res += to_string ( temp ) ; rem = rem % den ; } if ( repeating ) { res += " ) " ; res . insert ( index , " ( " ) ; } return res ; } int main ( ) { int num = 50 , den = 22 ; cout << calculateFraction ( num , den ) << endl ; num = -1 , den = 2 ; cout << calculateFraction ( num , den ) << endl ; return 0 ; }

Index/key variables: rem
Accumulator variables: res, stdc
Boolean variables: repeating
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findNature ( int a , int b , int n ) { if ( n == 0 ) return ( a & 1 ) ; if ( n == 1 ) return ( b & 1 ) ; if ( ! ( a & 1 ) ) { if ( ! ( b & 1 ) ) return false ; else return ( n % 3 != 0 ) ; } else { if ( ! ( b & 1 ) ) return ( ( n - 1 ) % 3 != 0 ) ; else return ( ( n + 1 ) % 3 != 0 ) ; } } int main ( ) { int a = 2 , b = 4 ; int n = 3 ; ( findNature ( a , b , n ) ? ( cout << " Odd " << " ▁ " ) : ( cout << " Even " << " ▁ " ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string checkEqual ( string S ) { for ( int i = 0 ; i < S . size ( ) ; i ++ ) { if ( S [ i ] != '1' && S [ i ] != '0' && S [ i ] != '8' ) { return " No " ; } } int start = 0 , end = S . size ( ) - 1 ; while ( start < end ) { if ( S [ start ] != S [ end ] ) { return " No " ; } start ++ ; end -- ; } return " Yes " ; } int main ( ) { string S = "101" ; cout << checkEqual ( S ) << endl ; return 0 ; }

Index/key variables: end, i, start
Accumulator variables: end, i, start, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void check_polydivisible ( int n ) { int N = n ; vector < int > digit ; while ( n > 0 ) { digit . push_back ( n % 10 ) ; n /= 10 ; } reverse ( digit . begin ( ) , digit . end ( ) ) ; bool flag = true ; n = digit [ 0 ] ; for ( int i = 1 ; i < digit . size ( ) ; i ++ ) { n = n * 10 + digit [ i ] ; if ( n % ( i + 1 ) != 0 ) { flag = false ; break ; } } if ( flag ) cout << N << " ▁ is ▁ Polydivisible ▁ number . " ; else cout << N << " ▁ is ▁ Not ▁ Polydivisible ▁ number . " ; } int main ( ) { int n = 345654 ; check_polydivisible ( n ) ; }

Index/key variables: i
Accumulator variables: i, n, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <stdio.h>
unsigned int Log2n ( unsigned int n ) { return ( n > 1 ) ? 1 + Log2n ( n / 2 ) : 0 ; } bool isPowerOfd ( unsigned int n , unsigned int d ) { int count = 0 ; if ( n && ! ( n & ( n - 1 ) ) ) { while ( n > 1 ) { n >>= 1 ; count += 1 ; } return ( count % ( Log2n ( d ) ) == 0 ) ; } return false ; } int main ( ) { int n = 64 , d = 8 ; if ( isPowerOfd ( n , d ) ) printf ( " % d ▁ is ▁ a ▁ power ▁ of ▁ % d " , n , d ) ; else printf ( " % d ▁ is ▁ not ▁ a ▁ power ▁ of ▁ % d " , n , d ) ; return 0 ; }

Accumulator variables: count
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1001
vector < int > adj [ MAX ] ; void add_edge ( int u , int v ) { adj [ u ] . push_back ( v ) ; } void checkTotalNumberofNodes ( int actualAnswer , int size ) { int calculatedAnswer = size ; for ( int i = 1 ; i <= size ; i ++ ) calculatedAnswer += adj [ i ] . size ( ) ; if ( actualAnswer == calculatedAnswer ) cout << " Calculated ▁ Answer ▁ is ▁ " << calculatedAnswer << " ▁ and ▁ is ▁ Equal ▁ to ▁ Actual ▁ Answer STRNEWLINE " ; else cout << " Calculated ▁ Answer ▁ is ▁ Incorrect STRNEWLINE " ; } int main ( ) { int N = 8 ; add_edge ( 1 , 2 ) ; add_edge ( 1 , 3 ) ; add_edge ( 2 , 4 ) ; add_edge ( 2 , 5 ) ; add_edge ( 3 , 6 ) ; add_edge ( 3 , 7 ) ; add_edge ( 6 , 8 ) ; checkTotalNumberofNodes ( 2 * N - 1 , N ) ; for ( int i = 1 ; i <= N ; i ++ ) adj [ i ] . clear ( ) ; N = 9 ; add_edge ( 1 , 2 ) ; add_edge ( 1 , 3 ) ; add_edge ( 2 , 4 ) ; add_edge ( 2 , 5 ) ; add_edge ( 2 , 6 ) ; add_edge ( 3 , 9 ) ; add_edge ( 5 , 7 ) ; add_edge ( 5 , 8 ) ; checkTotalNumberofNodes ( 2 * N - 1 , N ) ; return 0 ; }

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

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

Accumulator variables: stdc