dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } bool isSunnyNum ( int n ) { if ( isPerfectSquare ( n + 1 ) ) return true ; return false ; } int main ( ) { int n = 3 ; if ( isSunnyNum ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOperations ( int n , int a [ ] , int m ) { int k = n / m ; vector < vector < int > > val ( m ) ; for ( int i = 0 ; i < n ; ++ i ) { val [ a [ i ] % m ] . push_back ( i ) ; } long long ans = 0 ; vector < pair < int , int > > extra ; for ( int i = 0 ; i < 2 * m ; ++ i ) { int cur = i % m ; while ( int ( val [ cur ] . size ( ) ) > k ) { int elem = val [ cur ] . back ( ) ; val [ cur ] . pop_back ( ) ; extra . push_back ( make_pair ( elem , i ) ) ; } while ( int ( val [ cur ] . size ( ) ) < k && ! extra . empty ( ) ) { int elem = extra . back ( ) . first ; int mmod = extra . back ( ) . second ; extra . pop_back ( ) ; val [ cur ] . push_back ( elem ) ; ans += i - mmod ; } } return ans ; } int main ( ) { int m = 3 ; int a [ ] = { 3 , 2 , 0 , 6 , 10 , 12 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << minOperations ( n , a , m ) ; return 0 ; }

Index/key variables: cur, i
Accumulator variables: ans, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
bool isprime [ N ] ; bool can [ N ] ; vector < int > SieveOfEratosthenes ( ) { memset ( isprime , true , sizeof ( isprime ) ) ; for ( int p = 2 ; p * p < N ; p ++ ) { if ( isprime [ p ] == true ) { for ( int i = p * p ; i < N ; i += p ) isprime [ i ] = false ; } } vector < int > primes ; for ( int i = 2 ; i < N ; i ++ ) if ( isprime [ i ] ) primes . push_back ( i ) ; return primes ; } int Prime_Numbers ( int n ) { vector < int > primes = SieveOfEratosthenes ( ) ; for ( int i = 0 ; i < ( int ) ( primes . size ( ) ) - 1 ; i ++ ) if ( primes [ i ] + primes [ i + 1 ] + 1 < N ) can [ primes [ i ] + primes [ i + 1 ] + 1 ] = true ; int ans = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( can [ i ] and isprime [ i ] ) { ans ++ ; } } return ans ; } int main ( ) { int n = 50 ; cout << Prime_Numbers ( n ) ; return 0 ; }

Index/key variables: N, i, p
Accumulator variables: ans, i, p, stdc
Iterator variables: i, p
C++ program:
#include <iostream>
#include <vector>
using namespace std ; int findAndSum ( int arr [ ] , int n ) { int sum = 0 ; int mul = 1 ; for ( int i = 0 ; i < 30 ; i ++ ) { bool count_on = 0 ; int l = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) if ( count_on ) l ++ ; else { count_on = 1 ; l ++ ; } else if ( count_on ) { sum += ( ( mul * l * ( l + 1 ) ) / 2 ) ; count_on = 0 ; l = 0 ; } } if ( count_on ) { sum += ( ( mul * l * ( l + 1 ) ) / 2 ) ; count_on = 0 ; l = 0 ; } mul *= 2 ; } return sum ; } int main ( ) { int arr [ ] = { 7 , 1 , 1 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findAndSum ( arr , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, l, mul, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int Sx , int Sy , int Dx , int Dy , int x , int y ) { if ( abs ( Sx - Dx ) % x == 0 and abs ( Sy - Dy ) % y == 0 and ( abs ( Sx - Dx ) / x ) % 2 == ( abs ( Sy - Dy ) / y ) % 2 ) return true ; return false ; } int main ( ) { int Sx = 0 , Sy = 0 , Dx = 0 , Dy = 0 ; int x = 3 , y = 4 ; if ( isPossible ( Sx , Sy , Dx , Dy , x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int getPairs ( int a [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( a [ i ] < a [ j ] ) count ++ ; } } return count ; } int main ( ) { int a [ ] = { 2 , 4 , 3 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << getPairs ( a , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; bool isComposite ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } bool isDigitSumOne ( int nm ) { while ( nm > 9 ) { int sum_digit = 0 ; while ( nm > 0 ) { int digit = nm % 10 ; sum_digit = sum_digit + digit ; nm = nm / 10 ; } nm = sum_digit ; } if ( nm == 1 ) return true ; else return false ; } void printValidNums ( int l , int r ) { for ( int i = l ; i <= r ; i ++ ) { if ( isComposite ( i ) && isDigitSumOne ( i ) ) cout << i << " ▁ " ; } } int main ( void ) { int l = 10 , r = 100 ; printValidNums ( l , r ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calcNodes ( int N , int I ) { int result = 0 ; result = I * ( N - 1 ) + 1 ; return result ; } int main ( ) { int N = 5 , I = 2 ; cout << " Leaf ▁ nodes ▁ = ▁ " << calcNodes ( N , I ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
ll mod = 1000000007 ; ll arr [ 1000001 ] = { 0 } ; void cal_factorial ( ) { arr [ 0 ] = 1 ; for ( int i = 1 ; i <= 1000000 ; i ++ ) { arr [ i ] = ( arr [ i - 1 ] * i ) % mod ; } } ll mod_exponent ( ll num , ll p ) { if ( p == 0 ) return 1 ; if ( p & 1 ) { return ( ( num % mod ) * ( mod_exponent ( ( num * num ) % mod , p / 2 ) ) % mod ) % mod ; } else if ( ! ( p & 1 ) ) return ( mod_exponent ( ( num * num ) % mod , p / 2 ) ) % mod ; } ll getCount ( ll x , ll y ) { ll ans = arr [ x + y - 1 ] ; ans *= mod_exponent ( arr [ x ] , mod - 2 ) ; ans %= mod ; ans *= mod_exponent ( arr [ y ] , mod - 2 ) ; ans %= mod ; ans *= ( x - y ) ; ans %= mod ; return ans ; } int main ( ) { cal_factorial ( ) ; ll x = 3 , y = 1 ; cout << getCount ( x , y ) ; return 0 ; }

Index/key variables: i, x, y
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findValues ( int a , int b ) { if ( ( a - b ) % 2 == 1 ) { cout << " - 1" ; return ; } cout << ( a - b ) / 2 << " ▁ " << ( a + b ) / 2 ; } int main ( ) { int a = 12 , b = 8 ; findValues ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Data { double x , y ; } ; double inv_interpolate ( Data d [ ] , int n , double y ) { double x = 0 ; int i , j ; for ( i = 0 ; i < n ; i ++ ) { double xi = d [ i ] . x ; for ( j = 0 ; j < n ; j ++ ) { if ( j != i ) { xi = xi * ( y - d [ j ] . y ) / ( d [ i ] . y - d [ j ] . y ) ; } } x += xi ; } return x ; } int main ( ) { Data d [ ] = { { 1.27 , 2.3 } , { 2.25 , 2.95 } , { 2.5 , 3.5 } , { 3.6 , 5.1 } } ; int n = 4 ; double y = 4.5 ; cout << " Value ▁ of ▁ x ▁ at ▁ y ▁ = ▁ 4.5 ▁ : ▁ " << inv_interpolate ( d , n , y ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, x
Iterator variables: i, j
Class/struct names: Data
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countTriplets ( int n , vector < pair < int , int > > points ) { set < pair < int , int > > pts ; int ct = 0 ; for ( int i = 0 ; i < n ; i ++ ) pts . insert ( points [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) { int x = points [ i ] . first + points [ j ] . first ; int y = points [ i ] . second + points [ j ] . second ; if ( x % 2 == 0 && y % 2 == 0 ) if ( pts . find ( make_pair ( x / 2 , y / 2 ) ) != pts . end ( ) ) ct ++ ; } return ct ; } int main ( ) { vector < pair < int , int > > points = { { 1 , 1 } , { 2 , 2 } , { 3 , 3 } } ; int n = points . size ( ) ; cout << countTriplets ( n , points ) ; }

Index/key variables: i, j
Accumulator variables: ct, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; double mixtureConcentration ( int n , int p [ ] ) { double res = 0 ; for ( int i = 0 ; i < n ; i ++ ) res += p [ i ] ; res /= n ; return res ; } int main ( ) { int arr [ ] = { 0 , 20 , 20 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << mixtureConcentration ( n , arr ) ; }

Index/key variables: i
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 1e5 + 5 ; const int MOD = 1e9 + 7 ; #define ll  long long
int check ( int num , int a , int b ) { while ( num ) { int rem = num % 10 ; num /= 10 ; if ( rem != a && rem != b ) return 0 ; } return 1 ; } ll power ( ll x , ll y ) { ll ans = 1 ; while ( y ) { if ( y & 1 ) ans = ( ans * x ) % MOD ; y >>= 1 ; x = ( x * x ) % MOD ; } return ans % MOD ; } int modInverse ( int x ) { return power ( x , MOD - 2 ) ; } ll countNumbers ( int n , int a , int b ) { ll fact [ MAX ] , inv [ MAX ] ; ll ans = 0 ; fact [ 0 ] = 1 ; for ( int i = 1 ; i < MAX ; i ++ ) { fact [ i ] = ( 1LL * fact [ i - 1 ] * i ) ; fact [ i ] %= MOD ; } inv [ MAX - 1 ] = modInverse ( fact [ MAX - 1 ] ) ; for ( int i = MAX - 2 ; i >= 0 ; i -- ) { inv [ i ] = ( inv [ i + 1 ] * ( i + 1 ) ) ; inv [ i ] %= MOD ; } if ( a < b ) swap ( a , b ) ; for ( int s = n ; s <= 9 * n ; s ++ ) { if ( ! check ( s , a , b ) ) continue ; if ( s < n * b || ( s - n * b ) % ( a - b ) != 0 ) continue ; int numDig = ( s - n * b ) / ( a - b ) ; if ( numDig > n ) continue ; ll curr = fact [ n ] ; curr = ( curr * inv [ numDig ] ) % MOD ; curr = ( curr * inv [ n - numDig ] ) % MOD ; ans = ( ans + curr ) % MOD ; } return ans ; } int main ( ) { int n = 3 , a = 1 , b = 3 ; cout << countNumbers ( n , a , b ) ; return 0 ; }

Index/key variables: MAX, i, n, numDig
Accumulator variables: i, num, s, stdc
Iterator variables: i, s
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOddSquares ( int n , int m ) { return ( int ) pow ( m , 0.5 ) - ( int ) pow ( n - 1 , 0.5 ) ; } int main ( ) { int n = 5 , m = 100 ; cout << " Count ▁ is ▁ " << ( m - n + 1 ) - countOddSquares ( n , m ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkTriangularSumRepresentation ( int n ) { unordered_set < int > tri ; int i = 1 ; while ( 1 ) { int x = i * ( i + 1 ) / 2 ; if ( x >= n ) break ; tri . insert ( x ) ; i ++ ; } for ( auto tm : tri ) if ( tri . find ( n - tm ) != tri . end ( ) ) return true ; return false ; } int main ( ) { int n = 24 ; checkTriangularSumRepresentation ( n ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: tm
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long digitsCount ( long long n ) { int len = 0 ; while ( n > 0 ) { len ++ ; n /= 10 ; } return len ; } long long absoluteFirstLast ( long long n , int x ) { int i = 0 , mod = 1 ; while ( i < x ) { mod *= 10 ; i ++ ; } int last = n % mod ; long long len = digitsCount ( n ) ; while ( len != x ) { n /= 10 ; len -- ; } int first = n ; return abs ( first - last ) ; } int main ( ) { long long n = 21546 , x = 2 ; cout << absoluteFirstLast ( n , x ) ; return 0 ; }

Accumulator variables: i, len, mod, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void make_sequence ( int N ) { int arr [ N + 1 ] , sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) arr [ i ] = 1 ; else arr [ i ] = 2 ; sum += arr [ i ] ; } if ( sum % 2 == 1 ) arr [ 2 ] = 3 ; for ( int i = 1 ; i <= N ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int N = 9 ; make_sequence ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOdd ( int L , int R ) { int N = ( R - L ) / 2 ; if ( R % 2 != 0 L % 2 != 0 ) N += 1 ; return N ; } int main ( ) { int L = 3 , R = 7 ; int odds = countOdd ( L , R ) ; int evens = ( R - L + 1 ) - odds ; cout << " Count ▁ of ▁ odd ▁ numbers ▁ is ▁ " << odds << endl ; cout << " Count ▁ of ▁ even ▁ numbers ▁ is ▁ " << evens << endl ; return 0 ; }

Accumulator variables: N, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMinCost ( int n , int m ) { int cost = ( n - 1 ) * m + ( m - 1 ) * n ; return cost ; } int main ( ) { int n = 4 , m = 5 ; cout << getMinCost ( n , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOperation ( int n , int k , int a [ ] ) { for ( int i = k ; i < n ; i ++ ) { if ( a [ i ] != a [ k - 1 ] ) cout << ( -1 ) << endl ; } for ( int i = k - 2 ; i > -1 ; i -- ) { if ( a [ i ] != a [ k - 1 ] ) cout << ( i + 1 ) << endl ; } } int main ( ) { int n = 5 ; int k = 3 ; int a [ ] = { 2 , 1 , 1 , 1 , 1 } ; minOperation ( n , k , a ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { if ( k > n ) return 0 ; int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } int main ( ) { int N = 5 , M = 1 ; int P = ( N * ( N - 1 ) ) / 2 ; cout << binomialCoeff ( P , M ) ; return 0 ; }

Accumulator variables: res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateSequence ( int n , int g ) { for ( int i = 1 ; i <= n ; i ++ ) cout << i * g << " ▁ " ; } int main ( ) { int n = 6 , g = 5 ; generateSequence ( n , g ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 1000 ; int f [ MAX ] = { 0 } ; int fib ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] ) return f [ n ] ; int k = ( n & 1 ) ? ( n + 1 ) / 2 : n / 2 ; f [ n ] = ( n & 1 ) ? ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) : ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } int findLCMFibonacci ( int a , int b ) { return ( fib ( a ) * fib ( b ) ) / fib ( gcd ( a , b ) ) ; } int main ( ) { int a = 3 , b = 12 ; cout << findLCMFibonacci ( a , b ) ; return 0 ; }

Index/key variables: MAX, n
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isEvenOrOdd ( int L , int R ) { int oddCount = ( R - L ) / 2 ; if ( R % 2 == 1 L % 2 == 1 ) oddCount ++ ; if ( oddCount % 2 == 0 ) return " Even " ; else return " Odd " ; } int main ( ) { int L = 5 , R = 15 ; cout << isEvenOrOdd ( L , R ) ; return 0 ; }

Accumulator variables: oddCount, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int trailing_zeros ( int N ) { int count_of_two = 0 , count_of_five = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { int val = i ; while ( val % 2 == 0 && val > 0 ) { val /= 2 ; count_of_two += i ; } while ( val % 5 == 0 && val > 0 ) { val /= 5 ; count_of_five += i ; } } int ans = min ( count_of_two , count_of_five ) ; return ans ; } int main ( ) { int N = 12 ; cout << trailing_zeros ( N ) ; return 0 ; }

Accumulator variables: count_of_five, count_of_two, i, stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define limit  1000000000
#define MAX_PRIME  2000000
#define MAX  1000000
#define I_MAX  50000
map < int , int > mp ; int b [ MAX ] ; int p [ MAX ] ; int j = 0 ; bool prime [ MAX_PRIME + 1 ] ; void SieveOfEratosthenes ( int n ) { memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { b [ j ++ ] = p ; } } } int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } void printSeries ( int n ) { SieveOfEratosthenes ( MAX_PRIME ) ; int i , g , k , l , m , d ; int ar [ I_MAX + 2 ] ; for ( i = 0 ; i < j ; i ++ ) { if ( ( b [ i ] * b [ i + 1 ] ) > limit ) break ; p [ i ] = b [ i ] ; mp [ b [ i ] * b [ i + 1 ] ] = 1 ; } d = 550 ; bool flag = false ; for ( k = 2 ; ( k < d - 1 ) && ! flag ; k ++ ) { for ( m = 2 ; ( m < d ) && ! flag ; m ++ ) { for ( l = m + k ; l < d ; l += k ) { if ( ( ( b [ l ] * b [ l + k ] ) < limit ) && ( l + k ) < d && p [ i - 1 ] != b [ l + k ] && p [ i - 1 ] != b [ l ] && mp [ b [ l ] * b [ l + k ] ] != 1 ) { if ( mp [ p [ i - 1 ] * b [ l ] ] != 1 ) { p [ i ] = b [ l ] ; mp [ p [ i - 1 ] * b [ l ] ] = 1 ; i ++ ; } } if ( i >= I_MAX ) { flag = true ; break ; } } } } for ( i = 0 ; i < n ; i ++ ) ar [ i ] = p [ i ] * p [ i + 1 ] ; for ( i = 0 ; i < n - 1 ; i ++ ) cout << ar [ i ] << " ▁ " ; g = gcd ( ar [ n - 1 ] , ar [ n - 2 ] ) ; cout << g * 2 << endl ; } int main ( ) { int n = 4 ; printSeries ( n ) ; return 0 ; }

Index/key variables: MAX, i, l, p
Accumulator variables: i, j, k, l, m, p, stdc
Iterator variables: i, k, l, m, p
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 620000 ; int prime [ MAX ] ; void Sieve ( ) { for ( int i = 2 ; i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = 2 * i ; j < MAX ; j += i ) { prime [ j ] = 1 ; } } } } void printSequence ( int n ) { Sieve ( ) ; vector < int > v , u ; for ( int i = 13 ; i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { v . push_back ( i ) ; } } if ( n == 3 ) { cout << 6 << " ▁ " << 10 << " ▁ " << 15 ; return ; } int k ; for ( k = 0 ; k < n - 2 ; k ++ ) { if ( k % 3 == 0 ) { u . push_back ( v [ k ] * 6 ) ; } else if ( k % 3 == 1 ) { u . push_back ( v [ k ] * 15 ) ; } else { u . push_back ( v [ k ] * 10 ) ; } } k -- ; u . push_back ( v [ k ] * 7 ) ; u . push_back ( 7 * 11 ) ; u [ 0 ] = u [ 0 ] * 11 ; for ( int i = 0 ; i < u . size ( ) ; i ++ ) { cout << u [ i ] << " ▁ " ; } } int main ( ) { int n = 4 ; printSequence ( n ) ; return 0 ; }

Index/key variables: MAX, i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void midptellipse ( int rx , int ry , int xc , int yc ) { float dx , dy , d1 , d2 , x , y ; x = 0 ; y = ry ; d1 = ( ry * ry ) - ( rx * rx * ry ) + ( 0.25 * rx * rx ) ; dx = 2 * ry * ry * x ; dy = 2 * rx * rx * y ; while ( dx < dy ) { cout << x + xc << " ▁ , ▁ " << y + yc << endl ; cout << - x + xc << " ▁ , ▁ " << y + yc << endl ; cout << x + xc << " ▁ , ▁ " << - y + yc << endl ; cout << - x + xc << " ▁ , ▁ " << - y + yc << endl ; if ( d1 < 0 ) { x ++ ; dx = dx + ( 2 * ry * ry ) ; d1 = d1 + dx + ( ry * ry ) ; } else { x ++ ; y -- ; dx = dx + ( 2 * ry * ry ) ; dy = dy - ( 2 * rx * rx ) ; d1 = d1 + dx - dy + ( ry * ry ) ; } } d2 = ( ( ry * ry ) * ( ( x + 0.5 ) * ( x + 0.5 ) ) ) + ( ( rx * rx ) * ( ( y - 1 ) * ( y - 1 ) ) ) - ( rx * rx * ry * ry ) ; while ( y >= 0 ) { cout << x + xc << " ▁ , ▁ " << y + yc << endl ; cout << - x + xc << " ▁ , ▁ " << y + yc << endl ; cout << x + xc << " ▁ , ▁ " << - y + yc << endl ; cout << - x + xc << " ▁ , ▁ " << - y + yc << endl ; if ( d2 > 0 ) { y -- ; dy = dy - ( 2 * rx * rx ) ; d2 = d2 + ( rx * rx ) - dy ; } else { y -- ; x ++ ; dx = dx + ( 2 * ry * ry ) ; dy = dy - ( 2 * rx * rx ) ; d2 = d2 + dx - dy + ( rx * rx ) ; } } } int main ( ) { midptellipse ( 10 , 15 , 50 , 50 ) ; return 0 ; }

Accumulator variables: stdc, x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isDivisible ( long long int n ) { long long int temp = n ; int sum = 0 ; while ( n ) { int k = n % 10 ; sum += k ; n /= 10 ; } if ( temp % sum == 0 ) return " YES " ; return " NO " ; } int main ( ) { long long int n = 123 ; cout << isDivisible ( n ) ; return 0 ; }

Accumulator variables: n, stdc, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getResult ( long long int n ) { string st = std :: to_string ( n ) ; int sum = 0 ; for ( char i : st ) { sum = sum + ( int ) i ; } if ( n % sum == 0 ) return " Yes " ; else return " No " ; } int main ( ) { int n = 123 ; cout << getResult ( n ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digitProduct ( int n ) { int prod = 1 ; while ( n ) { prod = prod * ( n % 10 ) ; n = n / 10 ; } return prod ; } void printMultiplicativePrimes ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] && prime [ digitProduct ( i ) ] ) cout << i << " ▁ " ; } } int main ( ) { int n = 10 ; printMultiplicativePrimes ( n ) ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; ll gcd ( ll a , ll b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } bool coPrime ( ll n1 , ll n2 ) { if ( gcd ( n1 , n2 ) == 1 ) return true ; else return false ; } ll largestCoprime ( ll N ) { ll half = floor ( N / 2 ) ; while ( coPrime ( N , half ) == false ) half -- ; return half ; } int main ( ) { ll n = 50 ; cout << largestCoprime ( n ) ; return 0 ; }

Accumulator variables: half, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long largestCoprime ( long long N ) { if ( N == 6 ) return 1 ; else if ( N % 4 == 0 ) return ( N / 2 ) - 1 ; else if ( N % 2 == 0 ) return ( N / 2 ) - 2 ; else return ( ( N - 1 ) / 2 ) ; } int main ( ) { long long int n = 50 ; cout << largestCoprime ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSafePrimes ( int n ) { int prime [ n + 1 ] ; for ( int i = 2 ; i <= n ; i ++ ) prime [ i ] = 1 ; prime [ 0 ] = prime [ 1 ] = 0 ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == 1 ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = 0 ; } } for ( int i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] != 0 ) { int temp = ( 2 * i ) + 1 ; if ( temp <= n && prime [ temp ] != 0 ) prime [ temp ] = 2 ; } } for ( int i = 5 ; i <= n ; i ++ ) if ( prime [ i ] == 2 ) cout << i << " ▁ " ; } int main ( ) { int n = 20 ; printSafePrimes ( n ) ; return 0 ; }

Index/key variables: i, p, temp
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > Divisors ( int x ) { int c = 0 ; vector < int > v ; while ( x % 2 == 0 ) { c ++ ; x /= 2 ; } v . push_back ( c ) ; c = 0 ; while ( x % 3 == 0 ) { c ++ ; x /= 3 ; } v . push_back ( c ) ; c = 0 ; while ( x % 7 == 0 ) { c ++ ; x /= 7 ; } v . push_back ( c ) ; v . push_back ( x ) ; return v ; } int MinOperations ( int a , int b ) { vector < int > va = Divisors ( a ) ; vector < int > vb = Divisors ( b ) ; if ( va [ 3 ] != vb [ 3 ] ) return -1 ; int minOperations = abs ( va [ 0 ] - vb [ 0 ] ) + abs ( va [ 1 ] - vb [ 1 ] ) + abs ( va [ 2 ] - vb [ 2 ] ) ; return minOperations ; } int main ( ) { int a = 14 , b = 28 ; cout << MinOperations ( a , b ) ; return 0 ; }

Accumulator variables: c, stdc, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int largestOddDigit ( int n ) { int maxOdd = -1 ; while ( n > 0 ) { int digit = n % 10 ; if ( digit % 2 == 1 && digit > maxOdd ) maxOdd = digit ; n = n / 10 ; } return maxOdd ; } int getProduct ( int n ) { int maxOdd = largestOddDigit ( n ) ; if ( maxOdd == -1 ) return -1 ; return ( n * maxOdd ) ; } int main ( ) { int n = 12345 ; cout << getProduct ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( int x ) { long long left = 1 , right = x ; while ( left <= right ) { long long mid = ( left + right ) / 2 ; if ( mid * mid == x ) { return true ; } if ( mid * mid < x ) { left = mid + 1 ; } else { right = mid - 1 ; } } return false ; } int main ( ) { int x = 2500 ; if ( isPerfectSquare ( x ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc