dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long nondecdigits ( long long n ) { long long int x = 0 ; for ( x = n ; x >= 1 ; x -- ) { int no = x ; int prev_dig = 11 ; bool flag = true ; while ( no != 0 ) { if ( prev_dig < no % 10 ) { flag = false ; break ; } prev_dig = no % 10 ; no /= 10 ; } if ( flag == true ) break ; } return x ; } int main ( ) { long long n = 200 ; cout << nondecdigits ( n ) ; return 0 ; }

Accumulator variables: no, stdc, x
Iterator variables: x
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nondecdigits ( string s ) { long long m = s . size ( ) ; long long a [ m ] ; for ( long long i = 0 ; i < m ; i ++ ) a [ i ] = s [ i ] - '0' ; long long level = m - 1 ; for ( long long i = m - 1 ; i > 0 ; i -- ) { if ( a [ i ] < a [ i - 1 ] ) { a [ i - 1 ] -- ; level = i - 1 ; } } if ( a [ 0 ] != 0 ) { for ( long long i = 0 ; i <= level ; i ++ ) cout << a [ i ] ; for ( long long i = level + 1 ; i < m ; i ++ ) cout << "9" ; } else { for ( long long i = 1 ; i < level ; i ++ ) cout << a [ i ] ; for ( long long i = level + 1 ; i < m ; i ++ ) cout << "9" ; } } int main ( ) { string n = "200" ; nondecdigits ( n ) ; return 0 ; }

Index/key variables: i, m
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDivisors ( int n ) { int cnt = 0 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) cnt ++ ; cnt = cnt + 2 ; } } return cnt ; } int main ( ) { printf ( " Total ▁ distinct ▁ divisors ▁ of ▁ 100 ▁ are ▁ : ▁ % d " , countDivisors ( 100 ) ) ; return 0 ; }

Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool hasEvenNumberOfFactors ( int n ) { int root_n = sqrt ( n ) ; if ( ( root_n * root_n ) == n ) return false ; return true ; } void printStatusOfDoors ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { if ( hasEvenNumberOfFactors ( i ) ) cout << " closed " << " ▁ " ; else cout << " open " << " ▁ " ; } } int main ( ) { int n = 5 ; printStatusOfDoors ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool validate ( long long int n ) { for ( int i = 0 ; i < 10 ; i ++ ) { long long int temp = n ; int count = 0 ; while ( temp ) { if ( temp % 10 == i ) count ++ ; if ( count > i ) return false ; temp /= 10 ; } } return true ; } int main ( ) { long long int n = 1552793 ; if ( validate ( n ) ) cout << " True " ; else cout << " False " ; return 0 ; }

Accumulator variables: count, i, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string divisibleBy36 ( string num ) { int l = num . length ( ) ; if ( l == 0 ) return " No " ; if ( l == 1 && num [ 0 ] != '0' ) return " No " ; int two_digit_num = ( num [ l - 2 ] - '0' ) * 10 + ( num [ l - 1 ] - '0' ) ; if ( two_digit_num % 4 != 0 ) return " No " ; int sum = 0 ; for ( int i = 0 ; i < l ; i ++ ) sum += ( num [ i ] - '0' ) ; if ( sum % 9 != 0 ) return " No " ; return " Yes " ; } int main ( ) { string num = "92567812197966231384" ; cout << divisibleBy36 ( num ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string str ) { int n = str . length ( ) ; if ( n == 0 ) return false ; if ( n == 1 ) return ( ( str [ 0 ] - '0' ) % 8 == 0 ) ; if ( n == 2 ) return ( ( ( str [ n - 2 ] - '0' ) * 10 + ( str [ n - 1 ] - '0' ) ) % 8 == 0 ) ; int last = str [ n - 1 ] - '0' ; int second_last = str [ n - 2 ] - '0' ; int third_last = str [ n - 3 ] - '0' ; return ( ( third_last * 100 + second_last * 10 + last ) % 8 == 0 ) ; } int main ( ) { string str = "76952" ; check ( str ) ? cout << " Yes " : cout << " No ▁ " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int n ) { int count = 0 ; while ( n > 0 ) { count ++ ; n = n / 10 ; } return count ; } int checkPrime ( int n ) { if ( n <= 1 ) return -1 ; if ( n <= 3 ) return 0 ; if ( n % 2 == 0 n % 3 == 0 ) return -1 ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return -1 ; return 0 ; } void printPrimePoints ( int n ) { int count = countDigits ( n ) ; if ( count == 1 count == 2 ) { cout << " - 1" ; return ; } bool found = false ; for ( int i = 1 ; i < ( count - 1 ) ; i ++ ) { int left = n / ( ( int ) pow ( 10 , count - i ) ) ; int right = n % ( ( int ) pow ( 10 , count - i - 1 ) ) ; if ( checkPrime ( left ) == 0 && checkPrime ( right ) == 0 ) { cout << i << " ▁ " ; found = true ; } } if ( found == false ) cout << " - 1" ; } int main ( ) { int n = 2317 ; printPrimePoints ( n ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
Boolean variables: found
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int num , unsigned int n ) { if ( n == 0 ) return 1 ; else if ( n % 2 == 0 ) return power ( num , n / 2 ) * power ( num , n / 2 ) ; else return num * power ( num , n / 2 ) * power ( num , n / 2 ) ; } int checkRecursive ( int x , int n , int curr_num = 1 , int curr_sum = 0 ) { int results = 0 ; int p = power ( curr_num , n ) ; while ( p + curr_sum < x ) { results += checkRecursive ( x , n , curr_num + 1 , p + curr_sum ) ; curr_num ++ ; p = power ( curr_num , n ) ; } if ( p + curr_sum == x ) results ++ ; return results ; } int main ( ) { int x = 10 , n = 2 ; cout << checkRecursive ( x , n ) ; return 0 ; }

Accumulator variables: curr_num, results, stdc
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 printGenerators ( unsigned int n ) { cout << "1 ▁ " ; for ( int i = 2 ; i < n ; i ++ ) if ( gcd ( i , n ) == 1 ) cout << i << " ▁ " ; } int main ( ) { int n = 10 ; printGenerators ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int check ( string str ) { int n = str . length ( ) ; int digitSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) digitSum += ( str [ i ] - '0' ) ; return ( digitSum % 3 == 0 ) ; } int main ( ) { string str = "1332" ; check ( str ) ? cout << " Yes " : cout << " No ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: digitSum, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100001
int perfectDiv [ MAX ] ; void precomputeCounts ( ) { for ( int i = 1 ; i * i < MAX ; ++ i ) { for ( int j = i * i ; j < MAX ; j += i * i ) ++ perfectDiv [ j ] ; } } int countPerfectDivisors ( int n ) { return perfectDiv [ n ] ; } int main ( ) { precomputeCounts ( ) ; int n = 16 ; cout << " Total ▁ perfect ▁ divisors ▁ of ▁ " << n << " ▁ = ▁ " << countPerfectDivisors ( n ) << " STRNEWLINE " ; n = 12 ; cout << " Total ▁ perfect ▁ divisors ▁ of ▁ " << n << " ▁ = ▁ " << countPerfectDivisors ( n ) ; return 0 ; }

Index/key variables: MAX, j, n
Accumulator variables: j, stdc
Iterator variables: i, j
C++ program:
#include " bits / stdc + + . h "
using namespace std ; #define MAXN  100001
int spf [ MAXN ] ; void sieve ( ) { spf [ 1 ] = 1 ; for ( int i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } vector < int > getFactorization ( int x ) { vector < int > ret ; while ( x != 1 ) { ret . push_back ( spf [ x ] ) ; x = x / spf [ x ] ; } return ret ; } int main ( int argc , char const * argv [ ] ) { sieve ( ) ; int x = 12246 ; cout << " prime ▁ factorization ▁ for ▁ " << x << " ▁ : ▁ " ; vector < int > p = getFactorization ( x ) ; for ( int i = 0 ; i < p . size ( ) ; i ++ ) cout << p [ i ] << " ▁ " ; cout << endl ; return 0 ; }

Index/key variables: MAXN, i, j, x
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100001 ; const int INF = INT_MAX ; int primedivisor [ MAX ] , dist [ MAX ] , pos [ MAX ] , divInd [ MAX ] ; vector < int > divisors [ MAX ] ; void sieveOfEratosthenes ( ) { for ( int i = 2 ; i * i < MAX ; ++ i ) { if ( ! primedivisor [ i ] ) for ( int j = i * i ; j < MAX ; j += i ) primedivisor [ j ] = i ; } for ( int i = 1 ; i < MAX ; ++ i ) if ( ! primedivisor [ i ] ) primedivisor [ i ] = i ; } void findDivisors ( int arr [ ] , int n ) { for ( int i = 0 ; i < MAX ; ++ i ) pos [ i ] = divInd [ i ] = -1 , dist [ i ] = INF ; for ( int i = 0 ; i < n ; ++ i ) { int num = arr [ i ] ; while ( num > 1 ) { int div = primedivisor [ num ] ; divisors [ i ] . push_back ( div ) ; while ( num % div == 0 ) num /= div ; } } } void nearestGCD ( int arr [ ] , int n ) { findDivisors ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) { for ( auto & div : divisors [ i ] ) { if ( divInd [ div ] == -1 ) divInd [ div ] = i ; else { int ind = divInd [ div ] ; divInd [ div ] = i ; if ( dist [ i ] > abs ( ind - i ) ) { dist [ i ] = abs ( ind - i ) ; pos [ i ] = ind + 1 ; } if ( dist [ ind ] > abs ( ind - i ) ) { dist [ ind ] = abs ( ind - i ) ; pos [ ind ] = i + 1 ; } } } } } int main ( ) { sieveOfEratosthenes ( ) ; int arr [ ] = { 2 , 9 , 4 , 3 , 13 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; nearestGCD ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) cout << pos [ i ] << " ▁ " ; return 0 ; }

Index/key variables: MAX, div, i, ind, j, num
Accumulator variables: j, num, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int largestGCDSubsequence ( int arr [ ] , int n ) { int ans = 0 ; int maxele = * max_element ( arr , arr + n ) ; for ( int i = 2 ; i <= maxele ; ++ i ) { int count = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( arr [ j ] % i == 0 ) ++ count ; } ans = max ( ans , count ) ; } return ans ; } int main ( ) { int arr [ ] = { 3 , 6 , 2 , 5 , 4 } ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << largestGCDSubsequence ( arr , size ) ; return 0 ; }

Index/key variables: j
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct data { int val ; int steps ; data ( int val , int steps ) : val ( val ) , steps ( steps ) { } } ; int minStepToReachOne ( int N ) { queue < data > q ; q . push ( data ( N , 0 ) ) ; set < int > st ; while ( ! q . empty ( ) ) { data t = q . front ( ) ; q . pop ( ) ; if ( t . val == 1 ) return t . steps ; if ( st . find ( t . val - 1 ) == st . end ( ) ) { q . push ( data ( t . val - 1 , t . steps + 1 ) ) ; st . insert ( t . val - 1 ) ; } for ( int i = 2 ; i * i <= t . val ; i ++ ) { if ( t . val % i == 0 && st . find ( t . val / i ) == st . end ( ) ) { q . push ( data ( t . val / i , t . steps + 1 ) ) ; st . insert ( t . val / i ) ; } } } } int main ( ) { int N = 17 ; cout << minStepToReachOne ( N ) << endl ; }

Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: data
C++ program:
#include <bits/stdc++.h>
#define MAX  1000006
using namespace std ; void sieve ( int count [ ] ) { for ( int i = 2 ; i * i <= MAX ; i ++ ) { if ( count [ i ] == 0 ) { for ( int j = 2 * i ; j < MAX ; j += i ) count [ j ] ++ ; count [ i ] = 1 ; } } } int query ( int count [ ] , int l , int r ) { int sum = 0 ; for ( int i = l ; i <= r ; i ++ ) sum += count [ i ] ; return sum ; } int main ( ) { int count [ MAX ] ; memset ( count , 0 , sizeof count ) ; sieve ( count ) ; cout << query ( count , 6 , 10 ) << endl << query ( count , 1 , 5 ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateNumbers ( int factor [ ] , int n , int k ) { int next [ k ] = { 0 } ; for ( int i = 0 ; i < n ; ) { int toincrement = 0 ; for ( int j = 0 ; j < k ; j ++ ) if ( next [ j ] < next [ toincrement ] ) toincrement = j ; if ( output != next [ toincrement ] ) { output = next [ toincrement ] ; printf ( " % d ▁ " , next [ toincrement ] ) ; i ++ ; } next [ toincrement ] += factor [ toincrement ] ; } } int main ( ) { int factor [ ] = { 3 , 5 , 7 } ; int n = 10 ; int k = sizeof ( factor ) / sizeof ( factor [ 0 ] ) ; generateNumbers ( factor , n , k ) ; return 0 ; }

Index/key variables: j, k, toincrement
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#include <cmath>
using namespace std ; void checkReversible ( int n ) { int rev = 0 , rem ; int flag = n ; while ( flag ) { rem = flag % 10 ; rev *= 10 ; rev += rem ; flag /= 10 ; } int sum = rev + n ; while ( sum && ( rem % 2 != 0 ) ) { rem = sum % 10 ; sum /= 10 ; } if ( sum == 0 ) cout << " Reversible ▁ Number " ; else cout << " Non - Reversible ▁ Number " ; } int main ( ) { int n = 36 ; checkReversible ( n ) ; return 0 ; }

Accumulator variables: flag, rev, sum
C++ program:
#include <iostream>
#include <cmath>
using namespace std ; void countReversible ( int n ) { int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { switch ( i % 4 ) { case 0 : case 2 : count += 20 * pow ( 30 , ( i / 2 - 1 ) ) ; break ; case 3 : count += 100 * pow ( 500 , i / 4 ) ; break ; case 1 : break ; } } cout << count ; } int main ( ) { int n = 9 ; countReversible ( n ) ; return 0 ; }

Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int GCD ( int a , int b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } int multiplicativeOrder ( int A , int N ) { if ( GCD ( A , N ) != 1 ) return -1 ; unsigned int result = 1 ; int K = 1 ; while ( K < N ) { result = ( result * A ) % N ; if ( result == 1 ) return K ; K ++ ; } return -1 ; } int main ( ) { int A = 4 , N = 7 ; cout << multiplicativeOrder ( A , N ) ; return 0 ; }

Accumulator variables: K, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfRange ( int a , int b ) { int i = ( a * ( a + 1 ) ) >> 1 ; int j = ( b * ( b + 1 ) ) >> 1 ; return ( i - j ) ; } int sumofproduct ( int n ) { int sum = 0 ; int root = sqrt ( n ) ; for ( int i = 1 ; i <= root ; i ++ ) { int up = n / i ; int low = max ( n / ( i + 1 ) , root ) ; sum += ( i * sumOfRange ( up , low ) ) ; sum += ( i * ( n / i ) ) ; } return sum ; } int main ( ) { int n = 10 ; cout << sumofproduct ( n ) << endl ; return 0 ; }

Accumulator variables: i, stdc, sum
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 power ( int x , unsigned int y , int p ) { while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } void findPrimefactors ( unordered_set < int > & s , int n ) { while ( n % 2 == 0 ) { s . insert ( 2 ) ; n = n / 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { s . insert ( i ) ; n = n / i ; } } if ( n > 2 ) s . insert ( n ) ; } int findPrimitive ( int n ) { unordered_set < int > s ; if ( isPrime ( n ) == false ) return -1 ; int phi = n - 1 ; findPrimefactors ( s , phi ) ; for ( int r = 2 ; r <= phi ; r ++ ) { bool flag = false ; for ( auto it = s . begin ( ) ; it != s . end ( ) ; it ++ ) { if ( power ( r , phi / ( * it ) , n ) == 1 ) { flag = true ; break ; } } if ( flag == false ) return r ; } return -1 ; } int main ( ) { int n = 761 ; cout << " ▁ Smallest ▁ primitive ▁ root ▁ of ▁ " << n << " ▁ is ▁ " << findPrimitive ( n ) ; return 0 ; }

Accumulator variables: it, r, stdc
Iterator variables: i, it, r
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minPower ( int n , int x ) { if ( x == 1 ) return n ; int ans = 0 ; while ( n > 0 ) { ans += ( n % x ) ; n /= x ; } return ans ; } int main ( ) { int n = 5 , x = 3 ; cout << minPower ( n , x ) << endl ; return 0 ; }

Accumulator variables: ans, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calSum ( int n ) { int a = 3 , b = 0 , c = 2 ; return 3 ; return 3 ; return 5 ; int sum = 5 ; while ( n > 2 ) { sum += d ; a = b ; b = c ; c = d ; n -- ; } return sum ; } int main ( ) { int n = 9 ; cout << calSum ( n ) ; return 0 ; }

Accumulator variables: n, stdc, sum
C++ program:
#include <iostream>
using namespace std ; int findKCF ( int x , int y , int k ) { int small = min ( x , y ) ; int count = 1 ; for ( int i = 2 ; i <= small ; i ++ ) { if ( x % i == 0 && y % i == 0 ) count ++ ; if ( count == k ) return i ; } return -1 ; } int main ( ) { int x = 4 , y = 24 , k = 3 ; cout << findKHCF ( x , y , k ) ; return 0 ; }

Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinNumber ( int n ) { int count = 0 , ans = 1 ; while ( n % 2 == 0 ) { count ++ ; n /= 2 ; } if ( count % 2 ) ans *= 2 ; for ( int i = 3 ; i <= sqrt ( n ) ; i += 2 ) { count = 0 ; while ( n % i == 0 ) { count ++ ; n /= i ; } if ( count % 2 ) ans *= i ; } if ( n > 2 ) ans *= n ; return ans ; } int main ( ) { int n = 72 ; cout << findMinNumber ( n ) << endl ; return 0 ; }

Accumulator variables: ans, count, i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isToOneRec ( int n , unordered_set < int > & s ) { if ( n == 1 ) return true ; if ( s . find ( n ) != s . end ( ) ) return false ; return ( n % 2 ) ? isToOneRec ( 3 * n + 1 , s ) : isToOneRec ( n / 2 , s ) ; } bool isToOne ( int n ) { unordered_set < int > s ; return isToOneRec ( n , s ) ; } int main ( ) { int n = 5 ; isToOne ( n ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isToOne ( int n ) { return ( n > 0 ) ; } int main ( ) { int n = 5 ; isToOne ( n ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Accumulator variables: stdc
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 ) ; } void findgcd ( int n , int x , int y ) { int g = gcd ( x , y ) ; for ( int i = 0 ; i < g ; i ++ ) cout << n ; } int main ( ) { int n = 123 , x = 5 , y = 2 ; findgcd ( n , x , y ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( ( a % b ) == 0 ) return b ; return gcd ( b , a % b ) ; } int firstFactorialDivisibleNumber ( int x ) { int new_x = x ; for ( i = 1 ; i < x ; i ++ ) { new_x /= gcd ( i , new_x ) ; if ( new_x == 1 ) break ; } return i ; } int countFactorialXNotY ( int x , int y ) { return ( firstFactorialDivisibleNumber ( y ) - firstFactorialDivisibleNumber ( x ) ) ; } int main ( void ) { int x = 15 , y = 25 ; cout << countFactorialXNotY ( x , y ) ; return 0 ; }

Accumulator variables: i, new_x, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int firstFactorialDivisibleNumber ( int x ) { int fact = 1 ; for ( i = 1 ; i < x ; i ++ ) { fact = fact * i ; if ( fact % x == 0 ) break ; } return i ; } int main ( void ) { int x = 16 ; cout << firstFactorialDivisibleNumber ( x ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool SieveOfEratosthenes ( int n , bool isPrime [ ] ) { isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i <= n ; i ++ ) isPrime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) isPrime [ i ] = false ; } } } void findPrimePair ( int n ) { bool isPrime [ n + 1 ] ; SieveOfEratosthenes ( n , isPrime ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPrime [ i ] && isPrime [ n - i ] ) { cout << i << " ▁ " << ( n - i ) ; return ; } } } int main ( ) { int n = 74 ; findPrimePair ( n ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getFirstDigit ( int x ) { while ( x >= 10 ) x /= 10 ; return x ; } int getCountWithSameStartAndEndFrom1 ( int x ) { if ( x < 10 ) return x ; int tens = x / 10 ; int res = tens + 9 ; int firstDigit = getFirstDigit ( x ) ; int lastDigit = x % 10 ; if ( lastDigit < firstDigit ) res -- ; return res ; } int getCountWithSameStartAndEnd ( int start , int end ) { return getCountWithSameStartAndEndFrom1 ( end ) - getCountWithSameStartAndEndFrom1 ( start - 1 ) ; } int main ( ) { int start = 5 , end = 40 ; cout << getCountWithSameStartAndEnd ( start , end ) ; return 0 ; }

Accumulator variables: res, stdc, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool sieveOfEratosthenes ( int n , bool isPrime [ ] ) { isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i <= n ; i ++ ) isPrime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) isPrime [ i ] = false ; } } } bool rightTruPrime ( int n ) { bool isPrime [ n + 1 ] ; sieveOfEratosthenes ( n , isPrime ) ; while ( n ) { if ( isPrime [ n ] ) n = n / 10 ; else return false ; } return true ; } int main ( ) { int n = 59399 ; if ( rightTruPrime ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Index/key variables: i, n, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SieveOfEratosthenes ( int n , bool prime [ ] ) { for ( int i = 0 ; i <= n ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } } void mersennePrimes ( int n ) { bool prime [ n + 1 ] ; SieveOfEratosthenes ( n , prime ) ; for ( int k = 2 ; ( ( 1 << k ) - 1 ) <= n ; k ++ ) { long long num = ( 1 << k ) - 1 ; if ( prime [ num ] ) cout << num << " ▁ " ; } } int main ( ) { int n = 31 ; cout << " Mersenne ▁ prime ▁ numbers ▁ smaller ▁ " << " than ▁ or ▁ equal ▁ to ▁ " << n << endl ; mersennePrimes ( n ) ; return 0 ; }

Index/key variables: i, num, p
Accumulator variables: i, k, p, stdc
Iterator variables: i, k, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( int N , int K ) { int ans = 0 ; for ( int i = 1 ; i <= N ; i ++ ) ans += ( i % K ) ; return ans ; } int main ( ) { int N = 10 , K = 2 ; cout << findSum ( N , K ) << endl ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( int N , int K ) { int ans = 0 ; int y = N / K ; int x = N % K ; ans = ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) / 2 ; return ans ; } int main ( ) { int N = 10 , K = 2 ; cout << findSum ( N , K ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } int findnum ( string & str ) { int n = str . length ( ) ; int count_after_dot = 0 ; bool dot_seen = false ; int num = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] != ' . ' ) { num = num * 10 + ( str [ i ] - '0' ) ; if ( dot_seen == true ) count_after_dot ++ ; } else dot_seen = true ; } if ( dot_seen == false ) return 1 ; int dem = ( int ) pow ( 10 , count_after_dot ) ; return ( dem / gcd ( num , dem ) ) ; } int main ( ) { string str = "5.125" ; cout << findnum ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count_after_dot, i, stdc
Iterator variables: i
Boolean variables: dot_seen
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxHandshake ( int n ) { return ( n * ( n - 1 ) ) / 2 ; } int main ( ) { int n = 10 ; cout << maxHandshake ( n ) << endl ; return 0 ; }

Accumulator variables: stdc