dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool divisible ( string N , int digit ) { int ans = 0 ; for ( int i = 0 ; i < N . length ( ) ; i ++ ) { ans = ( ans * 10 + ( N [ i ] - '0' ) ) ; ans %= digit ; } return ( ans == 0 ) ; } int allDigits ( string N ) { bool divide [ 10 ] = { false } ; for ( int digit = 2 ; digit <= 9 ; digit ++ ) { if ( divisible ( N , digit ) ) divide [ digit ] = true ; } int result = 0 ; for ( int i = 0 ; i < N . length ( ) ; i ++ ) { if ( divide [ N [ i ] - '0' ] == true ) result ++ ; } return result ; } int main ( ) { string N = "122324" ; cout << allDigits ( N ) ; return 0 ; }

Index/key variables: digit, i
Accumulator variables: digit, i, result, stdc
Iterator variables: digit, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getSum ( int n ) { for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) sum = sum + i ; { sum = sum + i ; sum = sum + ( n / i ) ; } } } return sum - n ; } void printAliquot ( int n ) { printf ( " % d ▁ " , n ) ; unordered_set < int > s ; s . insert ( n ) ; int next = 0 ; while ( n > 0 ) { n = getSum ( n ) ; if ( s . find ( n ) != s . end ( ) ) { cout << " Repeats with " break ; } cout << n << " ▁ " ; s . insert ( n ) ; } } int main ( ) { printAliquot ( 12 ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 10000 ; void sieveSundaram ( vector < int > & primes ) { bool marked [ MAX / 2 + 1 ] = { 0 } ; for ( int i = 1 ; i <= ( sqrt ( MAX ) - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= MAX / 2 ; j = j + 2 * i + 1 ) marked [ j ] = true ; primes . push_back ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked [ i ] == false ) primes . push_back ( 2 * i + 1 ) ; } int LSCPUtil ( int limit , vector < int > & prime , long long int sum_prime [ ] ) { int max_length = -1 ; int prime_number = -1 ; for ( int i = 0 ; prime [ i ] <= limit ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( sum_prime [ i ] - sum_prime [ j ] > limit ) break ; long long int consSum = sum_prime [ i ] - sum_prime [ j ] ; if ( binary_search ( prime . begin ( ) , prime . end ( ) , consSum ) ) { if ( max_length < i - j + 1 ) { max_length = i - j + 1 ; prime_number = consSum ; } } } } return prime_number ; } void LSCP ( int arr [ ] , int n ) { vector < int > primes ; sieveSundaram ( primes ) ; long long int sum_prime [ primes . size ( ) + 1 ] ; sum_prime [ 0 ] = 0 ; for ( int i = 1 ; i <= primes . size ( ) ; i ++ ) sum_prime [ i ] = primes [ i - 1 ] + sum_prime [ i - 1 ] ; for ( int i = 0 ; i < n ; i ++ ) cout << LSCPUtil ( arr [ i ] , primes , sum_prime ) << " ▁ " ; } int main ( ) { int arr [ ] = { 10 , 30 , 40 , 50 , 1000 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; LSCP ( arr , n ) ; 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 ; int countNums ( int n , int x , int y ) { vector < bool > arr ( n + 1 , false ) ; if ( x <= n ) arr [ x ] = true ; if ( y <= n ) arr [ y ] = true ; int result = 0 ; for ( int i = min ( x , y ) ; i <= n ; i ++ ) { if ( arr [ i ] ) { if ( i + x <= n ) arr [ i + x ] = true ; if ( i + y <= n ) arr [ i + y ] = true ; result ++ ; } } return result ; } int main ( ) { int n = 15 , x = 5 , y = 7 ; cout << countNums ( n , x , y ) ; return 0 ; }

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

Index/key variables: i, p, rev
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) sum = sum + i ; { sum = sum + i ; sum = sum + ( n / i ) ; } } } sum = sum - n ; return sum ; } bool checkAbundant ( int n ) { return ( getSum ( n ) > n ) ; } int main ( ) { checkAbundant ( 12 ) ? cout << " YES STRNEWLINE " : cout << " NO STRNEWLINE " ; checkAbundant ( 15 ) ? cout << " YES STRNEWLINE " : cout << " NO STRNEWLINE " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPowerful ( int n ) { while ( n % 2 == 0 ) { int power = 0 ; while ( n % 2 == 0 ) { n /= 2 ; power ++ ; } if ( power == 1 ) return false ; } for ( int factor = 3 ; factor <= sqrt ( n ) ; factor += 2 ) { int power = 0 ; while ( n % factor == 0 ) { n = n / factor ; power ++ ; } if ( power == 1 ) return false ; } return ( n == 1 ) ; } int main ( ) { isPowerful ( 20 ) ? cout << " YES STRNEWLINE " : cout << " NO STRNEWLINE " ; isPowerful ( 27 ) ? cout << " YES STRNEWLINE " : cout << " NO STRNEWLINE " ; return 0 ; }

Accumulator variables: factor, n, power, stdc
Iterator variables: factor
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divisorsSum ( int n ) { for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { sum = sum + i ; } { sum = sum + i ; sum = sum + ( n / i ) ; } } } return sum ; } bool isDeficient ( int n ) { return ( divisorsSum ( n ) < ( 2 * n ) ) ; } int main ( ) { isDeficient ( 12 ) ? cout << " YES STRNEWLINE " : cout << " NO STRNEWLINE " ; isDeficient ( 15 ) ? cout << " YES STRNEWLINE " : cout << " NO STRNEWLINE " ; return 0 ; }

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

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 10000 ; vector < int > primes ; void sieveSundaram ( ) { bool marked [ MAX / 2 + 100 ] = { 0 } ; for ( int i = 1 ; i <= ( sqrt ( MAX ) - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= MAX / 2 ; j = j + 2 * i + 1 ) marked [ j ] = true ; primes . push_back ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked [ i ] == false ) primes . push_back ( 2 * i + 1 ) ; } bool isSmith ( int n ) { int original_no = n ; int pDigitSum = 0 ; for ( int i = 0 ; primes [ i ] <= n / 2 ; i ++ ) { while ( n % primes [ i ] == 0 ) { int p = primes [ i ] ; n = n / p ; while ( p > 0 ) { pDigitSum += ( p % 10 ) ; p = p / 10 ; } } } if ( n != 1 && n != original_no ) { while ( n > 0 ) { pDigitSum = pDigitSum + n % 10 ; n = n / 10 ; } } int sumDigits = 0 ; while ( original_no > 0 ) { sumDigits = sumDigits + original_no % 10 ; original_no = original_no / 10 ; } return ( pDigitSum == sumDigits ) ; } int main ( ) { sieveSundaram ( ) ; cout << " Printing ▁ first ▁ few ▁ Smith ▁ Numbers " " ▁ using ▁ isSmith ( ) n " ; for ( int i = 1 ; i < 500 ; i ++ ) if ( isSmith ( i ) ) cout << i << " ▁ " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, pDigitSum, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool iskaprekar ( int n ) { if ( n == 1 ) return true ; int sq_n = n * n ; int count_digits = 0 ; while ( sq_n ) { count_digits ++ ; sq_n /= 10 ; } for ( int r_digits = 1 ; r_digits < count_digits ; r_digits ++ ) { int eq_parts = pow ( 10 , r_digits ) ; if ( eq_parts == n ) continue ; int sum = sq_n / eq_parts + sq_n % eq_parts ; if ( sum == n ) return true ; } return false ; } int main ( ) { cout << " Printing ▁ first ▁ few ▁ Kaprekar ▁ Numbers " " ▁ using ▁ iskaprekar ( ) STRNEWLINE " ; for ( int i = 1 ; i < 10000 ; i ++ ) if ( iskaprekar ( i ) ) cout << i << " ▁ " ; return 0 ; }

Accumulator variables: count_digits, i, r_digits, sq_n, stdc
Iterator variables: i, r_digits
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isKeith ( int x ) { vector < int > terms ; while ( temp > 0 ) { terms . push_back ( temp % 10 ) ; temp = temp / 10 ; n ++ ; } reverse ( terms . begin ( ) , terms . end ( ) ) ; int next_term = 0 , i = n ; while ( next_term < x ) { next_term = 0 ; for ( int j = 1 ; j <= n ; j ++ ) next_term += terms [ i - j ] ; terms . push_back ( next_term ) ; i ++ ; } return ( next_term == x ) ; } int main ( ) { isKeith ( 14 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; isKeith ( 12 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; isKeith ( 197 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: i, j, n, next_term, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canBeSumofConsec ( unsigned int n ) { return ( ( n & ( n - 1 ) ) && n ) ; } int main ( ) { unsigned int n = 15 ; canBeSumofConsec ( n ) ? cout << " true " : cout << " false " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int canBeSumofConsec ( long long int n ) { n = 2 * n ; return ( ( n & ( n - 1 ) ) != 0 ) ; } int main ( ) { long long int n = 10 ; cout << canBeSumofConsec ( n ) << " STRNEWLINE " ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int evenFibSum ( int limit ) { if ( limit < 2 ) return 0 ; long long int ef1 = 0 , ef2 = 2 ; long long int sum = ef1 + ef2 ; while ( ef2 <= limit ) { long long int ef3 = 4 * ef2 + ef1 ; if ( ef3 > limit ) break ; ef1 = ef2 ; ef2 = ef3 ; sum += ef2 ; } return sum ; } int main ( ) { int limit = 400 ; cout << evenFibSum ( limit ) ; return 0 ; }

Accumulator variables: sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfect ( int n ) { int s = sqrt ( n ) ; return ( s * s == n ) ; } int divisorsCount ( int n ) { int count = 0 ; for ( int i = 1 ; i <= sqrt ( n ) + 1 ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) count += 1 ; else count += 2 ; } } return count ; } int kDivisors ( int a , int b , int k ) { for ( int i = a ; i <= b ; i ++ ) { if ( isPerfect ( i ) ) if ( divisors ( i ) == k ) count ++ ; } return count ; } int main ( ) { int a = 2 , b = 49 , k = 3 ; cout << kDivisors ( a , b , k ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define maxn  1000005
#define INF  99999999
int smallest_prime [ maxn ] ; int divisors [ maxn ] ; int segmentTree [ 4 * maxn ] ; void findSmallestPrimeFactors ( ) { for ( int i = 0 ; i < maxn ; i ++ ) smallest_prime [ i ] = INF ; for ( long long i = 2 ; i < maxn ; i ++ ) { if ( smallest_prime [ i ] == INF ) { smallest_prime [ i ] = i ; for ( long long j = i * i ; j < maxn ; j += i ) if ( smallest_prime [ j ] > i ) smallest_prime [ j ] = i ; } } } void buildDivisorsArray ( ) { for ( int i = 1 ; i < maxn ; i ++ ) { divisors [ i ] = 1 ; int n = i , p = smallest_prime [ i ] , k = 0 ; while ( n > 1 ) { n = n / p ; k ++ ; if ( smallest_prime [ n ] != p ) { divisors [ i ] = divisors [ i ] * ( k + 1 ) ; k = 0 ; } p = smallest_prime [ n ] ; } } } void buildSegtmentTree ( int node , int a , int b ) { if ( a == b ) { segmentTree [ node ] = divisors [ a ] ; return ; } buildSegtmentTree ( 2 * node , a , ( a + b ) / 2 ) ; buildSegtmentTree ( 2 * node + 1 , ( ( a + b ) / 2 ) + 1 , b ) ; segmentTree [ node ] = max ( segmentTree [ 2 * node ] , segmentTree [ 2 * node + 1 ] ) ; } int query ( int node , int a , int b , int l , int r ) { if ( l > b a > r ) return -1 ; if ( a >= l && b <= r ) return segmentTree [ node ] ; return max ( query ( 2 * node , a , ( a + b ) / 2 , l , r ) , query ( 2 * node + 1 , ( ( a + b ) / 2 ) + 1 , b , l , r ) ) ; } int main ( ) { findSmallestPrimeFactors ( ) ; buildDivisorsArray ( ) ; buildSegtmentTree ( 1 , 1 , maxn - 1 ) ; cout << " Maximum ▁ divisors ▁ that ▁ a ▁ number ▁ has ▁ " << " ▁ in ▁ [ 1 , ▁ 100 ] ▁ are ▁ " << query ( 1 , 1 , maxn - 1 , 1 , 100 ) << endl ; cout << " Maximum ▁ divisors ▁ that ▁ a ▁ number ▁ has " << " ▁ in ▁ [ 10 , ▁ 48 ] ▁ are ▁ " << query ( 1 , 1 , maxn - 1 , 10 , 48 ) << endl ; cout << " Maximum ▁ divisors ▁ that ▁ a ▁ number ▁ has " << " ▁ in ▁ [ 1 , ▁ 10 ] ▁ are ▁ " << query ( 1 , 1 , maxn - 1 , 1 , 10 ) << endl ; return 0 ; }

Index/key variables: a, i, j, maxn, n, node
Accumulator variables: i, j, k, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 3000 ; int smartNumber ( int n ) { int primes [ MAX ] = { 0 } ; vector < int > result ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( primes [ i ] == 0 ) { primes [ i ] = 1 ; for ( int j = i * 2 ; j < MAX ; j = j + i ) { primes [ j ] -= 1 ; if ( ( primes [ j ] + 3 ) == 0 ) result . push_back ( j ) ; } } } sort ( result . begin ( ) , result . end ( ) ) ; return result [ n - 1 ] ; } int main ( ) { int n = 50 ; cout << smartNumber ( n ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSteps ( int x , int y ) { if ( x % y == 0 ) return x / y ; return x / y + countSteps ( y , x % y ) ; } int main ( ) { int x = 100 , y = 19 ; cout << countSteps ( x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; map < int , int > ma ; void primeFactorize ( int a ) { for ( int i = 2 ; i * i <= a ; i += 2 ) { int cnt = 0 ; while ( a % i == 0 ) { cnt ++ ; a /= i ; } ma [ i ] = cnt ; } if ( a > 1 ) { ma [ a ] = 1 ; } } int commDiv ( int a , int b ) { primeFactorize ( a ) ; int res = 1 ; for ( auto m = ma . begin ( ) ; m != ma . end ( ) ; m ++ ) { int cnt = 0 ; int key = m -> first ; int value = m -> second ; while ( b % key == 0 ) { b /= key ; cnt ++ ; } res *= ( min ( cnt , value ) + 1 ) ; } return res ; } int main ( ) { int a = 12 , b = 24 ; cout << commDiv ( a , b ) << endl ; return 0 ; }

Index/key variables: a, i
Accumulator variables: a, b, cnt, i, m, res, stdc
Iterator variables: i, m
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long ll ; int findCountOfSolutions ( int n , int p ) { ll ans = 0 ; for ( ll x = 1 ; x < p ; x ++ ) { if ( ( x * x ) % p == 1 ) { ll last = x + p * ( n / p ) ; if ( last > n ) last -= p ; ans += ( ( last - x ) / p + 1 ) ; } } return ans ; } int main ( ) { ll n = 10 , p = 5 ; printf ( " % lld STRNEWLINE " , findCountOfSolutions ( n , p ) ) ; return 0 ; }

Accumulator variables: ans, last, stdc, x
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int kaprekarRec ( int n , int & prev ) { if ( n == 0 ) return 0 ; prev = n ; int digits [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { digits [ i ] = n % 10 ; n = n / 10 ; } sort ( digits , digits + 4 ) ; int asc = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) asc = asc * 10 + digits [ i ] ; sort ( digits , digits + 4 , std :: greater < int > ( ) ) ; int desc = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) desc = desc * 10 + digits [ i ] ; int diff = abs ( asc - desc ) ; if ( diff == prev ) return diff ; return kaprekarRec ( diff , prev ) ; } int kaprekar ( int n ) { int prev = 0 ; return kaprekarRec ( n , prev ) ; } int main ( ) { cout << kaprekar ( 1000 ) << endl ; cout << kaprekar ( 1112 ) << endl ; cout << kaprekar ( 9812 ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
float sqroot ( float s ) { int pSq = 0 ; int N = 0 ; for ( int i = static_cast < int > ( s ) ; i > 0 ; i -- ) { for ( int j = 1 ; j < i ; j ++ ) { if ( j * j == i ) { pSq = i ; N = j ; break ; } } if ( pSq > 0 ) break ; } float d = s - pSq ; float P = d / ( 2.0 * N ) ; float A = N + P ; float sqrt_of_s = A - ( ( P * P ) / ( 2.0 * A ) ) ; return sqrt_of_s ; } int main ( ) { float num = 9.2345 ; float sqroot_of_num = sqroot ( num ) ; std :: cout << " Square ▁ root ▁ of ▁ " << num << " ▁ = ▁ " << sqroot_of_num ; return 0 ; }

Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int x , int a ) { int res = 1 ; while ( a ) { if ( a & 1 ) res = res * x ; x = x * x ; a >>= 1 ; } return res ; } int breakInteger ( int N ) { if ( N == 2 ) return 1 ; if ( N == 3 ) return 2 ; int maxProduct ; switch ( N % 3 ) { case 0 : maxProduct = power ( 3 , N / 3 ) ; break ; case 1 : maxProduct = 2 * 2 * power ( 3 , ( N / 3 ) - 1 ) ; break ; case 2 : maxProduct = 2 * power ( 3 , N / 3 ) ; break ; } return maxProduct ; } int main ( ) { int maxProduct = breakInteger ( 10 ) ; cout << maxProduct << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digSum ( int n ) { int sum = 0 ; while ( n > 0 sum > 9 ) { if ( n == 0 ) { n = sum ; sum = 0 ; } sum += n % 10 ; n /= 10 ; } return sum ; } int main ( ) { int n = 1234 ; cout << digSum ( n ) ; return 0 ; }

Accumulator variables: n, stdc, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digSum ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } int main ( ) { int n = 9999 ; cout << digSum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Modulo ( int a , char b [ ] ) { int mod = 0 ; for ( int i = 0 ; i < strlen ( b ) ; i ++ ) mod = ( mod * 10 + b [ i ] - '0' ) % a ; } int LastDigit ( char a [ ] , char b [ ] ) { int len_a = strlen ( a ) , len_b = strlen ( b ) ; if ( len_a == 1 && len_b == 1 && b [ 0 ] == '0' && a [ 0 ] == '0' ) return 1 ; if ( len_b == 1 && b [ 0 ] == '0' ) return 1 ; if ( len_a == 1 && a [ 0 ] == '0' ) return 0 ; int exp = ( Modulo ( 4 , b ) == 0 ) ? 4 : Modulo ( 4 , b ) ; int res = pow ( a [ len_a - 1 ] - '0' , exp ) ; return res % 10 ; } int main ( ) { char a [ ] = "117" , b [ ] = "3" ; cout << LastDigit ( a , b ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long reversDigits ( long long num ) { long long rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } bool isPalindrome ( long long num ) { return ( reversDigits ( num ) == num ) ; } void ReverseandAdd ( long long num ) { long long rev_num = 0 ; while ( num <= 4294967295 ) { rev_num = reversDigits ( num ) ; num = num + rev_num ; if ( isPalindrome ( num ) ) { printf ( " % lld STRNEWLINE " , num ) ; break ; } else if ( num > 4294967295 ) { printf ( " No ▁ palindrome ▁ exist " ) ; } } } int main ( ) { ReverseandAdd ( 195 ) ; ReverseandAdd ( 265 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( a == b ) return a ; if ( a == 0 ) return b ; if ( b == 0 ) return a ; { return gcd ( a >> 1 , b ) ; return gcd ( a >> 1 , b >> 1 ) << 1 ; } return gcd ( a , b >> 1 ) ; if ( a > b ) return gcd ( ( a - b ) >> 1 , b ) ; return gcd ( ( b - a ) >> 1 , a ) ; } int main ( ) { int a = 34 , b = 17 ; printf ( " Gcd ▁ of ▁ given ▁ numbers ▁ is ▁ % d STRNEWLINE " , gcd ( a , b ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int sum [ 1000005 ] ; int toInt ( char x ) { return int ( x ) - '0' ; } void prepareSum ( string s ) { sum [ 0 ] = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) sum [ i + 1 ] = sum [ i ] + toInt ( s [ i ] ) ; } void query ( int l , int r ) { if ( ( sum [ r + 1 ] - sum [ l ] ) % 3 == 0 ) cout << " Divisible ▁ by ▁ 3 STRNEWLINE " ; else cout << " Not ▁ divisible ▁ by ▁ 3 STRNEWLINE " ; } int main ( ) { string n = "12468236544" ; prepareSum ( n ) ; query ( 0 , 1 ) ; query ( 1 , 2 ) ; query ( 3 , 6 ) ; query ( 0 , 10 ) ; return 0 ; }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int oneDigit ( int num ) { return ( num >= 0 && num < 10 ) ; } bool isPalUtil ( int num , int * dupNum ) { if ( oneDigit ( num ) ) return ( num == ( * dupNum ) % 10 ) ; if ( ! isPalUtil ( num / 10 , dupNum ) ) return false ; * dupNum /= 10 ; return ( num % 10 == ( * dupNum ) % 10 ) ; } int isPal ( int num ) { if ( num < 0 ) num = - num ; return isPalUtil ( num , dupNum ) ; } void printPalPrimesLessThanN ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] && isPal ( p ) ) cout << p << " ▁ " ; } int main ( ) { int n = 100 ; printf ( " Palindromic ▁ primes ▁ smaller ▁ than ▁ or ▁ " " equal ▁ to ▁ % d ▁ are ▁ : STRNEWLINE " , n ) ; printPalPrimesLessThanN ( n ) ; }

Index/key variables: i, p
Accumulator variables: dupNum, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPrimeFactors ( int n ) { int count = 0 ; while ( n % 2 == 0 ) { n = n / 2 ; count ++ ; } for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { n = n / i ; count ++ ; } } if ( n > 2 ) count ++ ; return ( count ) ; } void printKAlmostPrimes ( int k , int n ) { for ( int i = 1 , num = 2 ; i <= n ; num ++ ) { if ( countPrimeFactors ( num ) == k ) { printf ( " % d ▁ " , num ) ; i ++ ; } } return ; } int main ( ) { int n = 10 , k = 2 ; printf ( " First ▁ % d ▁ % d - almost ▁ prime ▁ numbers ▁ : ▁ STRNEWLINE " , n , k ) ; printKAlmostPrimes ( k , n ) ; return 0 ; }

Accumulator variables: count, i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long findDigits ( int n ) { if ( n < 0 ) return 0 ; if ( n <= 1 ) return 1 ; double x = ( ( n * log10 ( n / M_E ) + log10 ( 2 * M_PI * n ) / 2.0 ) ) ; return floor ( x ) + 1 ; } int main ( ) { cout << findDigits ( 1 ) << endl ; cout << findDigits ( 50000000 ) << endl ; cout << findDigits ( 1000000000 ) << endl ; cout << findDigits ( 120 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findDigits ( int n ) { if ( n < 0 ) return 0 ; if ( n <= 1 ) return 1 ; double digits = 0 ; for ( int i = 2 ; i <= n ; i ++ ) digits += log10 ( i ) ; return floor ( digits ) + 1 ; } int main ( ) { cout << findDigits ( 1 ) << endl ; cout << findDigits ( 5 ) << endl ; cout << findDigits ( 10 ) << endl ; cout << findDigits ( 120 ) << endl ; return 0 ; }

Accumulator variables: digits, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countEvenSum ( int arr [ ] , int n ) { int result = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { int sum = 0 ; for ( int j = i ; j <= n - 1 ; j ++ ) { sum = sum + arr [ j ] ; if ( sum % 2 == 0 ) result ++ ; } } return ( result ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 3 , 4 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " The ▁ Number ▁ of ▁ Subarrays ▁ with ▁ even " " ▁ sum ▁ is ▁ " << countEvenSum ( arr , n ) ; return ( 0 ) ; }

Index/key variables: j
Accumulator variables: i, j, result
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int countEvenSum ( int arr [ ] , int n ) { int temp [ 2 ] = { 1 , 0 } ; int result = 0 , sum = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { sum = ( ( sum + arr [ i ] ) % 2 + 2 ) % 2 ; temp [ sum ] ++ ; } result = result + ( temp [ 0 ] * ( temp [ 0 ] - 1 ) / 2 ) ; result = result + ( temp [ 1 ] * ( temp [ 1 ] - 1 ) / 2 ) ; return ( result ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 3 , 4 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " The ▁ Number ▁ of ▁ Subarrays ▁ with ▁ even " " ▁ sum ▁ is ▁ " << countEvenSum ( arr , n ) ; return ( 0 ) ; }

Index/key variables: i, sum
Accumulator variables: i
Iterator variables: i