dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int exponent ( int A , int B ) { if ( A == 0 ) return 0 ; if ( B == 0 ) return 1 ; long y ; if ( B % 2 == 0 ) { y = exponent ( A , B / 2 ) ; y = ( y * y ) ; } else { y = A ; y = ( y * exponent ( A , B - 1 ) ) ; } return y ; } int sum ( int k , int n ) { int sum = exponent ( k , n + 1 ) - exponent ( k - 1 , n + 1 ) ; return sum ; } int main ( ) { int n = 3 ; int K = 3 ; cout << sum ( K , n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int x ) { for ( int i = 2 ; i * i <= x ; i ++ ) { if ( x % i == 0 ) return 0 ; } return 1 ; } int minimumCost ( int n ) { if ( isPrime ( n ) ) return 1 ; if ( n % 2 == 1 && isPrime ( n - 2 ) ) return 2 ; if ( n % 2 == 0 ) return 2 ; return 3 ; } int main ( ) { int n = 6 ; cout << minimumCost ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nDigitPerfectCubes ( int n ) { cout << pow ( ceil ( cbrt ( pow ( 10 , ( n - 1 ) ) ) ) , 3 ) << " ▁ " ; cout << ( int ) pow ( ceil ( cbrt ( pow ( 10 , ( n ) ) ) ) - 1 , 3 ) ; } int main ( ) { int n = 3 ; nDigitPerfectCubes ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int n ) { return ( n / 2520 ) ; } int main ( ) { int n = 3000 ; cout << countNumbers ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
const int MAX = 100001 ; ll prefix [ MAX ] ; void sieve_modified ( ) { for ( int i = 1 ; i < MAX ; i += 2 ) { for ( int j = i ; j < MAX ; j += i ) prefix [ j ] += i ; } for ( int i = 1 ; i < MAX ; i ++ ) prefix [ i ] += prefix [ i - 1 ] ; } ll sumOddFactors ( int L , int R ) { return ( prefix [ R ] - prefix [ L - 1 ] ) ; } int main ( ) { sieve_modified ( ) ; int l = 6 , r = 10 ; cout << sumOddFactors ( l , r ) ; return 0 ; }

Index/key variables: MAX, R, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define mod  1000000007
long long power ( long x , long y ) { long p = mod ; long res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } long long solve ( int n , int k ) { if ( n == 1 ) return 0LL ; return ( power ( ( k - 1 ) , n - 1 ) % mod - solve ( n - 1 , k ) + mod ) % mod ; } int main ( ) { int n = 4 , k = 5 ; cout << solve ( n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#define n  3
using namespace std ; void preComputeXor ( int arr [ ] [ n ] , int prefix_xor [ ] [ n ] ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) { if ( j == 0 ) prefix_xor [ i ] [ j ] = arr [ i ] [ j ] ; else prefix_xor [ i ] [ j ] = ( prefix_xor [ i ] [ j - 1 ] ^ arr [ i ] [ j ] ) ; } for ( int i = 0 ; i < n ; i ++ ) for ( int j = 1 ; j < n ; j ++ ) prefix_xor [ j ] [ i ] = ( prefix_xor [ j - 1 ] [ i ] ^ prefix_xor [ j ] [ i ] ) ; } int ansQuerie ( int prefix_xor [ ] [ n ] , int x1 , int y1 , int x2 , int y2 ) { int xor_1 = 0 , xor_2 = 0 , xor_3 = 0 ; if ( x1 != 0 ) xor_1 = prefix_xor [ x1 - 1 ] [ y2 ] ; if ( y1 != 0 ) xor_2 = prefix_xor [ x2 ] [ y1 - 1 ] ; if ( x1 != 0 and y1 != 0 ) xor_3 = prefix_xor [ x1 - 1 ] [ y1 - 1 ] ; return ( ( prefix_xor [ x2 ] [ y2 ] ^ xor_1 ) ^ ( xor_2 ^ xor_3 ) ) ; } int main ( ) { int arr [ ] [ n ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int prefix_xor [ n ] [ n ] ; preComputeXor ( arr , prefix_xor ) ; cout << ansQuerie ( prefix_xor , 1 , 1 , 2 , 2 ) << endl ; cout << ansQuerie ( prefix_xor , 1 , 2 , 2 , 2 ) << endl ; return 0 ; }

Index/key variables: i, j, n, x2, y2
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; bool isDigitSumOne ( int nm ) { if ( nm % 9 == 1 ) return true ; else return false ; } void printValidNums ( int n ) { int cbrt_n = ( int ) cbrt ( n ) ; for ( int i = 1 ; i <= cbrt_n ; i ++ ) { int cube = pow ( i , 3 ) ; if ( cube >= 1 && cube <= n && isDigitSumOne ( cube ) ) cout << cube << " ▁ " ; } } int main ( ) { int n = 1000 ; printValidNums ( n ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long countRhombi ( int h , int w ) { long long ct = 0 ; for ( int i = 2 ; i <= h ; i += 2 ) for ( int j = 2 ; j <= w ; j += 2 ) ct += ( h - i + 1 ) * ( w - j + 1 ) ; return ct ; } int main ( ) { int h = 2 , w = 2 ; cout << countRhombi ( h , w ) ; return 0 ; }

Accumulator variables: ct, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; double calculateArea ( int x , int y ) { double pi = 3.1415926536 ; double arx = pi * x * x ; double ary = pi * y * y ; return arx - ary ; } int main ( ) { int x = 2 ; int y = 1 ; cout << calculateArea ( x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; char getWinner ( int arr [ ] , int n ) { int gcd = arr [ 0 ] ; int maxEle = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { gcd = __gcd ( gcd , arr [ i ] ) ; maxEle = max ( maxEle , arr [ i ] ) ; } int totalMoves = ( maxEle / gcd ) - n ; if ( totalMoves % 2 == 1 ) return ' A ' ; return ' B ' ; } int main ( ) { int arr [ ] = { 5 , 6 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << getWinner ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int n ) { int num = ( ( n / 2 ) + 1 ) ; int max = n % num ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { int val = ( ( n % i ) % j ) % n ; if ( val == max ) count ++ ; } } return count ; } int main ( ) { int n = 5 ; cout << ( countPairs ( n ) ) ; }

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

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double sum ( int n ) { double i , s = 0.0 ; for ( i = 1 ; i <= n ; i ++ ) s = s + 1 / i ; return s ; } int main ( ) { int n = 5 ; cout << " Sum ▁ is ▁ " << sum ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
set < int > ABUNDANT ( ) { set < int > v ; for ( int i = 1 ; i < N ; i ++ ) { int sum = 1 ; for ( int j = 2 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { sum += j ; if ( i / j != j ) sum += i / j ; } } if ( sum > i ) v . insert ( i ) ; } return v ; } void SumOfAbundant ( int n ) { set < int > v = ABUNDANT ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( v . count ( i ) and v . count ( n - i ) ) { cout << i << " ▁ " << n - i ; return ; } } cout << -1 ; } int main ( ) { int n = 24 ; SumOfAbundant ( n ) ; return 0 ; }

Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTermOfTheSeries ( int n ) { int nthTerm ; if ( n % 2 == 0 ) nthTerm = pow ( n - 1 , 2 ) + n ; else nthTerm = pow ( n + 1 , 2 ) + n ; return nthTerm ; } int main ( ) { int n ; n = 8 ; cout << nthTermOfTheSeries ( n ) << endl ; n = 12 ; cout << nthTermOfTheSeries ( n ) << endl ; n = 102 ; cout << nthTermOfTheSeries ( n ) << endl ; n = 999 ; cout << nthTermOfTheSeries ( n ) << endl ; n = 9999 ; cout << nthTermOfTheSeries ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
string obtain_str ( ll n ) { ll len = ( int ) log2 ( n + 1 ) ; ll rel_ind = n + 1 - pow ( 2 , len ) ; ll i = 0 ; string str = " " ; for ( i = 0 ; i < len ; i ++ ) { str += ' a ' ; } i = 0 ; while ( rel_ind > 0 ) { if ( rel_ind % 2 == 1 ) str [ i ] = ' b ' ; rel_ind /= 2 ; i ++ ; } reverse ( str . begin ( ) , str . end ( ) ) ; return str ; } int main ( ) { ll n = 11 ; cout << obtain_str ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, rel_ind, stdc, str
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Nthterm ( int n ) { int numerator = pow ( n , 2 ) - 1 ; int denomenator = 2 * n - 3 ; cout << numerator << " / " << denomenator ; } int main ( ) { int n = 3 ; Nthterm ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int SquareCube ( long long int N ) { int cnt = 0 , i = 1 ; while ( int ( pow ( i , 6 ) ) <= N ) { ++ cnt ; ++ i ; } return cnt ; } int main ( ) { long long int N = 100000 ; cout << SquareCube ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
ll getSum ( int n , int d ) { ll sum = 0 ; while ( d <= n ) { sum += d ; d += 10 ; } return sum ; } int main ( ) { int n = 30 , d = 3 ; cout << getSum ( n , d ) ; return 0 ; }

Accumulator variables: d, stdc, sum
C++ program:
#include <iostream>
using namespace std ; # define MOD  1000000007
long sum ( long N ) { long val = N * ( N + 1 ) ; val = val % MOD ; return val ; } int sumX ( int N , int M , int K ) { for ( int i = 0 ; i < M ; i ++ ) { N = ( int ) sum ( K + N ) ; } N = N % MOD ; return N ; } int main ( ) { int N = 1 , M = 2 , K = 3 ; cout << sumX ( N , M , K ) << endl ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned int Log2n ( unsigned int n ) { return ( n > 1 ) ? 1 + Log2n ( n / 2 ) : 0 ; } int main ( ) { unsigned int n = 32 ; cout << Log2n ( n ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMode ( int a [ ] , int n ) { int b [ n ] ; int max = * max_element ( a , a + n ) ; int t = max + 1 ; int count [ t ] ; for ( int i = 0 ; i < t ; i ++ ) count [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) count [ a [ i ] ] ++ ; int mode = 0 ; int k = count [ 0 ] ; for ( int i = 1 ; i < t ; i ++ ) { if ( count [ i ] > k ) { k = count [ i ] ; mode = i ; } } cout << " mode ▁ = ▁ " << mode ; } int main ( ) { int a [ ] = { 1 , 4 , 1 , 2 , 7 , 1 , 2 , 5 , 3 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; printMode ( a , n ) ; return 0 ; }

Index/key variables: i, n, t
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkIsHP ( vector < double > & arr ) { int n = arr . size ( ) ; if ( n == 1 ) { return true ; } vector < int > rec ; for ( int i = 0 ; i < n ; i ++ ) { rec . push_back ( ( 1 / arr [ i ] ) ) ; } sort ( rec . begin ( ) , rec . end ( ) ) ; int d = ( rec [ 1 ] ) - ( rec [ 0 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { if ( rec [ i ] - rec [ i - 1 ] != d ) { return false ; } } return true ; } int main ( ) { vector < double > arr = { 1 / 5 , 1 / 10 , 1 / 15 , 1 / 20 , 1 / 25 } ; if ( checkIsHP ( arr ) ) { cout << " Yes " << std :: endl ; } else { cout << " No " << endl ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printAMeans ( int A , int B , int N ) { float d = ( float ) ( B - A ) / ( N + 1 ) ; for ( int i = 1 ; i <= N ; i ++ ) cout << ( A + i * d ) << " ▁ " ; } int main ( ) { int A = 20 , B = 32 , N = 5 ; printAMeans ( A , B , N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
# include <stdio.h>
# include <math.h>
void primeFactors ( int n ) { while ( n % 2 == 0 ) { printf ( " % d ▁ " , 2 ) ; n = n / 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { printf ( " % d ▁ " , i ) ; n = n / i ; } } if ( n > 2 ) printf ( " % d ▁ " , n ) ; } int main ( ) { int n = 315 ; primeFactors ( n ) ; return 0 ; }

Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int startingPoint ( int Length , int Speed1 , int Speed2 ) { int result1 = 0 , result2 = 0 ; int time1 = Length / Speed1 ; int time2 = Length / Speed2 ; result1 = __gcd ( time1 , time2 ) ; result2 = time1 * time2 / ( result1 ) ; return result2 ; } float firstTime ( int Length , int Speed1 , int Speed2 ) { float result = 0 ; int relativeSpeed = abs ( Speed1 - Speed2 ) ; result = ( ( float ) Length / relativeSpeed ) ; return result ; } int main ( ) { int L = 30 , S1 = 5 , S2 = 2 ; float first_Time = firstTime ( L , S1 , S2 ) ; int starting_Point = startingPoint ( L , S1 , S2 ) ; cout << " Met ▁ first ▁ time ▁ after ▁ " << first_Time << " ▁ hrs " << endl ; cout << " Met ▁ at ▁ starting ▁ point ▁ after ▁ " << starting_Point << " ▁ hrs " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool CheckArray ( int arr [ ] , int n ) { int prod = 1 ; for ( int i = 0 ; i < n ; ++ i ) prod *= arr [ i ] ; for ( int i = 0 ; i < n ; ++ i ) if ( arr [ i ] == prod / arr [ i ] ) return true ; return false ; } int main ( ) { int arr [ ] = { 1 , 2 , 12 , 3 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( CheckArray ( arr , n ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Index/key variables: i
Accumulator variables: prod, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int a , int b ) { int sum = 0 ; for ( int i = 1 ; i <= min ( a , b ) ; i ++ ) if ( a % i == 0 && b % i == 0 ) sum += i ; return sum ; } int main ( ) { int A = 10 , B = 15 ; cout << " Sum ▁ = ▁ " << sum ( A , B ) << endl ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumCuts ( int a [ ] , int n ) { sort ( a , a + n ) ; int gcd = a [ 1 ] - a [ 0 ] ; int s = gcd ; for ( int i = 2 ; i < n ; i ++ ) { gcd = __gcd ( gcd , a [ i ] - a [ i - 1 ] ) ; s += a [ i ] - a [ i - 1 ] ; } if ( 360 - s > 0 ) gcd = __gcd ( gcd , 360 - s ) ; return ( 360 / gcd ) - n ; } int main ( ) { int arr [ ] = { 30 , 60 , 180 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumCuts ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, s, stdc
Iterator variables: i
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 ) { int temp = spf [ x ] ; ret . push_back ( temp ) ; while ( x % temp == 0 ) x = x / temp ; } return ret ; } int maxElement ( int A [ ] , int n ) { sieve ( ) ; map < int , int > m ; for ( int i = 0 ; i < n ; ++ i ) { vector < int > p = getFactorization ( A [ i ] ) ; for ( int i = 0 ; i < p . size ( ) ; i ++ ) m [ p [ i ] ] ++ ; } int cnt = 0 , ans = 1e+7 ; for ( auto i : m ) { if ( i . second >= cnt ) { cnt = i . second ; ans > i . first ? ans = i . first : ans = ans ; } } return ans ; } int main ( ) { int A [ ] = { 2 , 5 , 10 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << maxElement ( A , n ) ; return 0 ; }

Index/key variables: MAXN, i, j, x
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < bool > SieveOfEratosthenes ( int max_val ) { vector < bool > prime ( max_val + 1 , true ) ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } return prime ; } void compositeSumAndProduct ( int arr [ ] , int n , int k ) { int max_val = * max_element ( arr , arr + n ) ; vector < bool > prime = SieveOfEratosthenes ( max_val ) ; prime [ 0 ] = true ; prime [ 1 ] = true ; priority_queue < int > maxHeap ; priority_queue < int , vector < int > , greater < int > > minHeap ; for ( int i = 0 ; i < n ; i ++ ) if ( ! prime [ arr [ i ] ] ) { minHeap . push ( arr [ i ] ) ; maxHeap . push ( arr [ i ] ) ; } long long int minProduct = 1 , maxProduct = 1 , minSum = 0 , maxSum = 0 ; while ( k -- ) { minProduct *= minHeap . top ( ) ; maxProduct *= maxHeap . top ( ) ; minSum += minHeap . top ( ) ; maxSum += maxHeap . top ( ) ; minHeap . pop ( ) ; maxHeap . pop ( ) ; } cout << " Sum ▁ of ▁ k - minimum ▁ composite ▁ numbers ▁ is ▁ " << minSum << " STRNEWLINE " ; cout << " Sum ▁ of ▁ k - maximum ▁ composite ▁ numbers ▁ is ▁ " << maxSum << " STRNEWLINE " ; cout << " Product ▁ of ▁ k - minimum ▁ composite ▁ numbers ▁ is ▁ " << minProduct << " STRNEWLINE " ; cout << " Product ▁ of ▁ k - maximum ▁ composite ▁ numbers ▁ is ▁ " << maxProduct ; } int main ( ) { int arr [ ] = { 4 , 2 , 12 , 13 , 5 , 19 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; compositeSumAndProduct ( arr , n , k ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, k, maxProduct, maxSum, minProduct, minSum, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int compositeProduct ( int arr [ ] , int n ) { int max_val = * max_element ( arr , arr + n ) ; vector < bool > prime ( max_val + 1 , true ) ; prime [ 0 ] = true ; prime [ 1 ] = true ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } int product = 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( ! prime [ arr [ i ] ] ) { product *= arr [ i ] ; } return product ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << compositeProduct ( arr , n ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, product, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum_odd ( int n ) { int sum = 0 , pos = 1 ; while ( n ) { if ( pos % 2 == 1 ) sum += n % 10 ; n = n / 10 ; pos ++ ; } return sum ; } bool check_prime ( 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 = 223 ; int sum = sum_odd ( n ) ; if ( check_prime ( sum ) ) cout << " YES " << endl ; else cout << " NO " << endl ; return 0 ; }

Accumulator variables: pos, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int reverseNum ( int x ) { string s = to_string ( x ) ; reverse ( s . begin ( ) , s . end ( ) ) ; stringstream ss ( s ) ; int rev = 0 ; ss >> rev ; return rev ; } bool isMysteryNumber ( int n ) { for ( int i = 1 ; i <= n / 2 ; i ++ ) { int j = reverseNum ( i ) ; if ( i + j == n ) { cout << i << " ▁ " << j ; return true ; } } cout << " Not ▁ a ▁ Mystery ▁ Number " ; return false ; } int main ( ) { int n = 121 ; isMysteryNumber ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include " iostream "
using namespace std ; void ReplaceElements ( int arr [ ] , int n ) { int prod = 1 ; for ( int i = 0 ; i < n ; ++ i ) { prod *= arr [ i ] ; } for ( int i = 0 ; i < n ; ++ i ) { arr [ i ] = prod / arr [ i ] ; } } int main ( ) { int arr [ ] = { 2 , 3 , 3 , 5 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; ReplaceElements ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) { cout << arr [ i ] << " ▁ " ; } return 0 ; }

Index/key variables: i
Accumulator variables: prod
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool Check_is_possible ( int l , int r , int k ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( i % k == 0 ) count ++ ; } return ( count > 1 ) ; } int main ( ) { int l = 4 , r = 12 ; int k = 5 ; if ( Check_is_possible ( l , r , k ) ) cout << " YES STRNEWLINE " ; else cout << " NO STRNEWLINE " ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( long long int N , long long int K ) { multiset < int > m1 , m2 ; while ( N > 0 ) { m1 . insert ( N % 10 ) ; N /= 10 ; } while ( K > 0 ) { m2 . insert ( K % 10 ) ; K /= 10 ; } if ( m1 == m2 ) return true ; return false ; } string anyPermutation ( long long int N , long long int K ) { long long int powK [ 100 ] , Limit = pow ( 10 , 18 ) ; powK [ 0 ] = K ; int i = 1 ; while ( powK [ i - 1 ] * K < Limit ) { powK [ i ] = powK [ i - 1 ] * K ; i ++ ; } for ( int j = 0 ; j < i ; j ++ ) if ( isValid ( N , powK [ j ] ) ) { return " True " ; } return " False " ; } int main ( ) { long long int N = 96889010407 , K = 7 ; cout << anyPermutation ( N , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: K, N, i, j, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int N ) { int S1 , S2 , S3 ; S1 = ( ( N / 2 ) ) * ( 2 * 2 + ( N / 2 - 1 ) * 2 ) / 2 ; S2 = ( ( N / 7 ) ) * ( 2 * 7 + ( N / 7 - 1 ) * 7 ) / 2 ; S3 = ( ( N / 14 ) ) * ( 2 * 14 + ( N / 14 - 1 ) * 14 ) / 2 ; return S1 + S2 - S3 ; } int main ( ) { int N = 20 ; cout << sum ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fastPow ( int N , int K ) { if ( K == 0 ) return 1 ; int temp = fastPow ( N , K / 2 ) ; if ( K % 2 == 0 ) return temp * temp ; else return N * temp * temp ; } int countWays ( int N , int K ) { return K * fastPow ( K - 1 , N - 1 ) ; } int main ( ) { int N = 3 , K = 3 ; cout << countWays ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumNth ( int A [ ] , int B [ ] , int m , int n ) { int res = 0 ; if ( n == 1 ) { for ( int i = 0 ; i < m ; i ++ ) res = res + A [ i ] ; } else if ( n == 2 ) { for ( int i = 0 ; i < m ; i ++ ) res = res + B [ i ] * m ; } else { int f [ n ] ; f [ 0 ] = 0 , f [ 1 ] = 1 ; for ( int i = 2 ; i < n ; i ++ ) f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; for ( int i = 0 ; i < m ; i ++ ) { res = res + ( m * ( B [ i ] * f [ n - 1 ] ) ) + ( m * ( A [ i ] * f [ n - 2 ] ) ) ; } } return res ; } int main ( ) { int A [ ] = { 1 , 2 , 3 } ; int B [ ] = { 4 , 5 , 6 } ; int n = 3 ; int m = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << sumNth ( A , B , m , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; int main ( ) { ll a = 5 ; ll AC = a ; ll CE = 2 * a ; double shortestDistace = sqrt ( AC * AC + CE * CE ) ; cout << shortestDistace << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum_of_series ( int n ) { int result = 0 ; if ( n % 2 == 0 ) { result = - ( n * ( n + 1 ) ) / 2 ; } else { result = ( n * ( n + 1 ) ) / 2 ; } return result ; } int main ( void ) { int n = 3 ; cout << sum_of_series ( n ) << endl ; n = 10 ; cout << sum_of_series ( n ) << endl ; }

Accumulator variables: stdc
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 ; } bool isCousinPrime ( int n1 , int n2 ) { if ( abs ( n1 - n2 ) != 4 ) return false ; else return ( isPrime ( n1 ) && isPrime ( n2 ) ) ; } int main ( ) { int n1 = 7 , n2 = 11 ; if ( isCousinPrime ( n1 , n2 ) ) cout << " YES " << endl ; else cout << " NO " << endl ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i