dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
#include <time.h>
#define e  2.71828
using namespace std ; int roundNo ( float num ) { return num < 0 ? num - 0.5 : num + 0.5 ; } void printBestCandidate ( int candidate [ ] , int n ) { int sample_size = roundNo ( n / e ) ; cout << " Sample size is " int best = 0 ; for ( int i = 1 ; i < sample_size ; i ++ ) if ( candidate [ i ] > candidate [ best ] ) best = i ; for ( int i = sample_size ; i < n ; i ++ ) if ( candidate [ i ] >= candidate [ best ] ) { best = i ; break ; } if ( best >= sample_size ) cout << endl << " Best ▁ candidate ▁ found ▁ is ▁ " << best + 1 << " ▁ with ▁ talent ▁ " << candidate [ best ] << endl ; else cout << " Couldn ' t ▁ find ▁ a ▁ best ▁ candidate STRNEWLINE " ; } int main ( ) { int n = 8 ; int candidate [ n ] ; srand ( time ( 0 ) ) ; for ( int i = 0 ; i < n ; i ++ ) candidate [ i ] = 1 + rand ( ) % 8 ; cout << " Candidate ▁ : ▁ " ; for ( int i = 0 ; i < n ; i ++ ) cout << i + 1 << " ▁ " ; cout << endl ; cout << " ▁ Talents ▁ : ▁ " ; for ( int i = 0 ; i < n ; i ++ ) cout << candidate [ i ] << " ▁ " ; printBestCandidate ( candidate , n ) ; return 0 ; }

Index/key variables: best, i, n
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float u_cal ( float u , int n ) { float temp = u ; for ( int i = 1 ; i < n ; i ++ ) temp = temp * ( u + i ) ; return temp ; } int fact ( int n ) { int f = 1 ; for ( int i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } int main ( ) { int n = 5 ; float x [ ] = { 1891 , 1901 , 1911 , 1921 , 1931 } ; float y [ n ] [ n ] ; y [ 0 ] [ 0 ] = 46 ; y [ 1 ] [ 0 ] = 66 ; y [ 2 ] [ 0 ] = 81 ; y [ 3 ] [ 0 ] = 93 ; y [ 4 ] [ 0 ] = 101 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = n - 1 ; j >= i ; j -- ) y [ j ] [ i ] = y [ j ] [ i - 1 ] - y [ j - 1 ] [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) cout << setw ( 4 ) << y [ i ] [ j ] << " TABSYMBOL " ; cout << endl ; } float value = 1925 ; float sum = y [ n - 1 ] [ 0 ] ; float u = ( value - x [ n - 1 ] ) / ( x [ 1 ] - x [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { sum = sum + ( u_cal ( u , i ) * y [ n - 1 ] [ i ] ) / fact ( i ) ; } cout << " Value at " ▁ < < ▁ value ▁ < < ▁ " is " << sum << endl ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: f, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumDigitSquare ( int n ) { int sq = 0 ; while ( n ) { int digit = n % 10 ; sq += digit * digit ; n = n / 10 ; } return sq ; } bool isHappy ( int n ) { while ( 1 ) { if ( n == 1 ) return true ; n = sumDigitSquare ( n ) ; if ( n == 4 ) return false ; } return false ; } int main ( ) { int n = 23 ; if ( isHappy ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMin ( int a [ ] , int n ) { double sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) int x = exp ( sum / n ) ; return x + 1 ; } int main ( ) { int a [ ] = { 3 , 2 , 1 , 4 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findMin ( a , n ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countdigits ( int N ) { int count = 0 ; while ( N ) { count ++ ; N = N / 10 ; } return count ; } void cyclic ( int N ) { int num = N ; int n = countdigits ( N ) ; while ( 1 ) { cout << num << endl ; int rem = num % 10 ; int div = num / 10 ; num = ( pow ( 10 , n - 1 ) ) * rem + div ; if ( num == N ) break ; } } int main ( ) { int N = 5674 ; cyclic ( N ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool sackRace ( int p1 , int s1 , int p2 , int s2 ) { return ( ( s1 > s2 && ( p2 - p1 ) % ( s1 - s2 ) == 0 ) || ( s2 > s1 && ( p1 - p2 ) % ( s2 - s1 ) == 0 ) ) ; } int main ( ) { int p1 = 4 , s1 = 4 , p2 = 8 , s2 = 2 ; sackRace ( p1 , s1 , p2 , s2 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int a , int b ) { int count = 0 ; int p = abs ( a * b ) ; if ( p == 0 ) return 1 ; while ( p > 0 ) { count ++ ; p = p / 10 ; } return count ; } int main ( ) { int a = 33 ; int b = -24 ; cout << " Number ▁ of ▁ digits ▁ = ▁ " << countDigits ( a , b ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void multiple ( int a , int b , int x ) { if ( b < 0 ) { if ( a == 1 && x == 1 ) cout << "1" ; else cout << "0" ; } int mul = pow ( a , b ) ; int ans = mul / x ; int ans1 = x * ans ; int ans2 = x * ( ans + 1 ) ; cout << ( ( ( mul - ans1 ) <= ( ans2 - mul ) ) ? ans1 : ans2 ) ; } int main ( ) { int a = 349 , b = 1 , x = 4 ; multiple ( a , b , x ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int compute_average ( int a , int b ) { return ( a + b ) / 2 ; } int main ( ) { int a = INT_MAX , b = INT_MAX ; cout << " Actual ▁ average ▁ : ▁ " << INT_MAX << endl ; cout << " Computed ▁ average ▁ : ▁ " << compute_average ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int minNum ( int arr [ ] , int n ) { bool odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 ) odd = ! odd ; if ( odd ) return 1 ; return 2 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minNum ( arr , n ) << " n " ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int msbPos ( int n ) { int pos = 0 ; while ( n != 0 ) { pos ++ ; n = n >> 1 ; } return pos ; } int josephify ( int n ) { int position = msbPos ( n ) ; int j = 1 << ( position - 1 ) ; n = n ^ j ; n = n << 1 ; n = n | 1 ; return n ; } int main ( ) { int n = 41 ; cout << josephify ( n ) ; return 0 ;

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

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int powmod ( int x , int y , int p ) { while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } int discreteLogarithm ( int a , int b , int m ) { int n = ( int ) sqrt ( m ) + 1 ; unordered_map < int , int > value ; for ( int i = n ; i >= 1 ; -- i ) value [ powmod ( a , i * n , m ) ] = i ; for ( int j = 0 ; j < n ; ++ j ) { int cur = ( powmod ( a , j , m ) * b ) % m ; if ( value [ cur ] ) { int ans = value [ cur ] * n - j ; if ( ans < m ) return ans ; } } return -1 ; } int main ( ) { int a = 2 , b = 3 , m = 5 ; cout << discreteLogarithm ( a , b , m ) << endl ; a = 3 , b = 7 , m = 11 ; cout << discreteLogarithm ( a , b , m ) ; }

Index/key variables: cur
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int discreteLogarithm ( int a , int b , int m ) { int n = ( int ) sqrt ( m ) + 1 ; int an = 1 ; for ( int i = 0 ; i < n ; ++ i ) an = ( an * a ) % m ; unordered_map < int , int > value ; for ( int i = 1 , cur = an ; i <= n ; ++ i ) { if ( ! value [ cur ] ) value [ cur ] = i ; cur = ( cur * an ) % m ; } for ( int i = 0 , cur = b ; i <= n ; ++ i ) { if ( value [ cur ] ) { int ans = value [ cur ] * n - i ; if ( ans < m ) return ans ; } cur = ( cur * a ) % m ; } return -1 ; } int main ( ) { int a = 2 , b = 3 , m = 5 ; cout << discreteLogarithm ( a , b , m ) << endl ; a = 3 , b = 7 , m = 11 ; cout << discreteLogarithm ( a , b , m ) ; }

Index/key variables: cur
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std ; string nthprimedigitsnumber ( int number ) { int rem ; string num ; while ( number ) { rem = number % 4 ; switch ( rem ) { case 1 : num . push_back ( '2' ) ; break ; case 2 : num . push_back ( '3' ) ; break ; case 3 : num . push_back ( '5' ) ; break ; case 0 : num . push_back ( '7' ) ; break ; } if ( number % 4 == 0 ) number -- ; number = number / 4 ; } reverse ( num . begin ( ) , num . end ( ) ) ; return num ; } int main ( ) { int number = 21 ; cout << nthprimedigitsnumber ( 10 ) << " STRNEWLINE " ; cout << nthprimedigitsnumber ( 21 ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: number
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int N ) { int count = 0 ; for ( int i = 1 ; i <= cbrt ( N ) ; i ++ ) { int cb = i * i * i ; int diff = N - cb ; int cbrtDiff = cbrt ( diff ) ; if ( cbrtDiff * cbrtDiff * cbrtDiff == diff ) count ++ ; } return count ; } int main ( ) { for ( int i = 1 ; i <= 10 ; i ++ ) cout << " For ▁ n ▁ = ▁ " << i << " , ▁ " << countPairs ( i ) << " ▁ pair ▁ exists STRNEWLINE " ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ull  unsigned long long
map < ull , int > primeFactors ( ull num ) { map < ull , int > ans ; for ( ull i = 2 ; i * i <= num ; i ++ ) { while ( num % i == 0 ) { num /= i ; ans [ i ] ++ ; } } if ( num > 1 ) ans [ num ] ++ ; return ans ; } ull legendre ( ull factor , ull num ) { ull count = 0 , fac2 = factor ; while ( num >= factor ) { count += num / factor ; factor *= fac2 ; } return count ; } bool possible ( map < ull , int > & factors , ull num ) { for ( map < ull , int > :: iterator it = factors . begin ( ) ; it != factors . end ( ) ; ++ it ) { if ( legendre ( it -> first , num ) < it -> second ) return false ; } return true ; } ull search ( ull start , ull end , map < ull , int > & factors ) { ull mid = ( start + end ) / 2 ; if ( ! possible ( factors , mid ) ) return search ( mid + 1 , end , factors ) ; if ( start == mid ) return mid ; return search ( start , mid , factors ) ; } ull findFact ( ull num ) { map < ull , int > factors = primeFactors ( num ) ; return search ( 1 , num , factors ) ; } int main ( ) { cout << findFact ( 6 ) << " n " ; cout << findFact ( 997587429953 ) << " n " ; return 0 ; }

Index/key variables: i, num
Accumulator variables: count, factor, i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printEqualModNumbers ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; int d = arr [ n - 1 ] - arr [ 0 ] ; if ( d == 0 ) { cout << " Infinite ▁ solution " ; return ; } vector < int > v ; for ( int i = 1 ; i * i <= d ; i ++ ) { if ( d % i == 0 ) { v . push_back ( i ) ; if ( i != d / i ) v . push_back ( d / i ) ; } } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { int temp = arr [ 0 ] % v [ i ] ; int j ; for ( j = 1 ; j < n ; j ++ ) if ( arr [ j ] % v [ i ] != temp ) break ; if ( j == n ) cout << v [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 38 , 6 , 34 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printEqualModNumbers ( 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 FirstDigit ( int arr [ ] , int n ) { double S = 0 ; for ( int i = 0 ; i < n ; i ++ ) S = S + log10 ( arr [ i ] * 1.0 ) ; double fract_S = S - floor ( S ) ; int ans = pow ( 10 , fract_S ) ; return ans ; } int main ( ) { int arr [ ] = { 5 , 8 , 3 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << FirstDigit ( arr , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigit ( int n ) { int temp = n , count = 0 ; while ( temp != 0 ) { int d = temp % 10 ; temp /= 10 ; if ( d > 0 && n % d == 0 ) count ++ ; } return count ; } int main ( ) { int n = 1012 ; cout << countDigit ( n ) << endl ; return 0 ; }

Accumulator variables: count, stdc, temp
C++ program:
#include <iostream>
using namespace std ; int makeOdd ( int n ) { if ( n % 2 != 0 ) return 1 ; int resul = 1 ; while ( n % 2 == 0 ) { n /= 2 ; resul *= 2 ; } return resul ; } int main ( ) { int n = 36 ; cout << makeOdd ( n ) ; return 0 ; }

Accumulator variables: n, resul
C++ program:
#include <bits/stdc++.h>
using namespace std ; int closestMultiple ( int n , int x ) { if ( x > n ) return x ; n = n + x / 2 ; n = n - ( n % x ) ; return n ; } int main ( ) { int n = 9 , x = 4 ; printf ( " % d " , closestMultiple ( n , x ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; void printCubes ( int a , int b ) { int acrt = cbrt ( a ) ; int bcrt = cbrt ( b ) ; for ( int i = acrt ; i <= bcrt ; i ++ ) if ( i * i * i >= a && i * i * i <= b ) cout << i * i * i << " ▁ " ; } int main ( ) { int a = 24 , b = 576 ; cout << " Perfect ▁ cubes ▁ in ▁ given ▁ range : STRNEWLINE " << printCubes ( a , b ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int number0f2s ( int n ) { int count = 0 ; while ( n > 0 ) { if ( n % 10 == 2 ) count ++ ; n = n / 10 ; } return count ; } int numberOf2sinRange ( int n ) { int count = 0 ; for ( int i = 2 ; i <= n ; i ++ ) count += number0f2s ( i ) ; return count ; } int main ( ) { cout << numberOf2sinRange ( 22 ) ; cout << endl ; cout << numberOf2sinRange ( 100 ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minToggle ( int arr [ ] , int n ) { int zero [ n + 1 ] ; zero [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { if ( arr [ i - 1 ] == 0 ) zero [ i ] = zero [ i - 1 ] + 1 ; else zero [ i ] = zero [ i - 1 ] ; } int ans = n ; for ( int i = 1 ; i <= n ; ++ i ) ans = min ( ans , i - zero [ i ] + zero [ n ] - zero [ i ] ) ; return ans ; } int main ( ) { int arr [ ] = { 1 , 0 , 1 , 1 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minToggle ( arr , n ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, n
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string str ) { int n = str . length ( ) ; if ( ( str [ n - 1 ] - '0' ) % 2 != 0 ) return false ; 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 ; int res = 0 ; int checkRecursive ( int num , int x , int k , int n ) { if ( x == 0 ) res ++ ; int r = ( int ) floor ( pow ( num , 1.0 / n ) ) ; for ( int i = k + 1 ; i <= r ; i ++ ) { int a = x - ( int ) pow ( i , n ) ; if ( a >= 0 ) checkRecursive ( num , x - ( int ) pow ( i , n ) , i , n ) ; } return res ; } int check ( int x , int n ) { return checkRecursive ( x , x , 0 , n ) ; } int main ( ) { cout << ( check ( 10 , 2 ) ) ; return 0 ; }

Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int reverseNum ( int n ) { int rem , rev = 0 ; while ( n ) { rem = n % 10 ; rev = rev * 10 + rem ; n /= 10 ; } return rev ; } bool isPalindrom ( int num ) { return num == reverseNum ( num ) ; } int nthPalindrome ( int n , int k ) { int num = ( int ) pow ( 10 , k - 1 ) ; while ( true ) { if ( isPalindrom ( num ) ) -- n ; if ( ! n ) break ; ++ num ; } return num ; } int main ( ) { int n = 6 , k = 5 ; printf ( " % dth ▁ palindrome ▁ of ▁ % d ▁ digit ▁ = ▁ % d STRNEWLINE " , n , k , nthPalindrome ( n , k ) ) ; n = 10 , k = 6 ; printf ( " % dth ▁ palindrome ▁ of ▁ % d ▁ digit ▁ = ▁ % d " , n , k , nthPalindrome ( n , k ) ) ; return 0 ; }

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nthPalindrome ( int n , int k ) { int temp = ( k & 1 ) ? ( k / 2 ) : ( k / 2 - 1 ) ; int palindrome = ( int ) pow ( 10 , temp ) ; palindrome += n - 1 ; printf ( " % d " , palindrome ) ; if ( k & 1 ) palindrome /= 10 ; while ( palindrome ) { printf ( " % d " , palindrome % 10 ) ; palindrome /= 10 ; } printf ( " STRNEWLINE " ) ; } int main ( ) { int n = 6 , k = 5 ; printf ( " % dth ▁ palindrome ▁ of ▁ % d ▁ digit ▁ = ▁ " , n , k ) ; nthPalindrome ( n , k ) ; n = 10 , k = 6 ; printf ( " % dth ▁ palindrome ▁ of ▁ % d ▁ digit ▁ = ▁ " , n , k ) ; nthPalindrome ( n , k ) ; return 0 ; }

Accumulator variables: palindrome, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMax ( int n , int a [ ] , int b [ ] , int k [ ] , int m ) { int arr [ n ] ; memset ( arr , 0 , sizeof ( arr ) ) ; for ( int i = 0 ; i < m ; i ++ ) { int lowerbound = a [ i ] ; int upperbound = b [ i ] ; for ( int j = lowerbound ; j <= upperbound ; j ++ ) arr [ j ] += k [ i ] ; } int res = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) res = max ( res , arr [ i ] ) ; return res ; } int main ( ) { int n = 5 ; int a [ ] = { 0 , 1 , 2 } ; int b [ ] = { 1 , 4 , 3 } ; int k [ ] = { 100 , 100 , 100 } ; int m = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << " Maximum ▁ value ▁ after ▁ ' m ' ▁ operations ▁ is ▁ " << findMax ( n , a , b , k , m ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100001
long long phi [ MAX ] , result [ MAX ] ; void computeTotient ( ) { phi [ 1 ] = 1 ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( ! phi [ i ] ) { phi [ i ] = i - 1 ; for ( int j = ( i << 1 ) ; j < MAX ; j += i ) { if ( ! phi [ j ] ) phi [ j ] = j ; phi [ j ] = ( phi [ j ] / i ) * ( i - 1 ) ; } } } } void sumOfGcdPairs ( ) { computeTotient ( ) ; for ( int i = 1 ; i < MAX ; ++ i ) { for ( int j = 2 ; i * j < MAX ; ++ j ) result [ i * j ] += i * phi [ j ] ; } for ( int i = 2 ; i < MAX ; i ++ ) result [ i ] += result [ i - 1 ] ; } int main ( ) { sumOfGcdPairs ( ) ; int N = 4 ; cout << " Summation ▁ of ▁ " << N << " ▁ = ▁ " << result [ N ] << endl ; ; N = 12 ; cout << " Summation ▁ of ▁ " << N << " ▁ = ▁ " << result [ N ] << endl ; N = 5000 ; cout << " Summation ▁ of ▁ " << N << " ▁ = ▁ " << result [ N ] ; return 0 ; }

Index/key variables: MAX, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define N  3
using namespace std ; vector < int > solve ( int v [ ] ) { vector < int > res ; int all3 = v [ 0 ] + v [ 1 ] + v [ 2 ] ; res . push_back ( all3 - v [ 1 ] * 2 ) ; res . push_back ( all3 - v [ 2 ] * 2 ) ; res . push_back ( all3 - v [ 0 ] * 2 ) ; return res ; } void findVertex ( int xmid [ ] , int ymid [ ] ) { vector < int > V1 = solve ( xmid ) ; vector < int > V2 = solve ( ymid ) ; for ( int i = 0 ; i < 3 ; i ++ ) cout << V1 [ i ] << " ▁ " << V2 [ i ] << endl ; } int main ( ) { int xmid [ N ] = { 5 , 4 , 5 } ; int ymid [ N ] = { 3 , 4 , 5 } ; findVertex ( xmid , ymid ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthElement ( int a , int b , int n ) { vector < int > seq ; for ( int i = 1 ; i <= n ; i ++ ) seq . push_back ( a * i ) ; sort ( seq . begin ( ) , seq . end ( ) ) ; for ( int i = 1 , k = n ; i <= n && k ; i ++ ) { if ( ! binary_search ( seq . begin ( ) , seq . end ( ) , b * i ) ) { seq . push_back ( b * i ) ; sort ( seq . begin ( ) , seq . end ( ) ) ; k -- ; } } return seq [ n - 1 ] ; } int main ( ) { int a = 3 , b = 5 , n = 5 ; cout << nthElement ( a , b , n ) << endl ; return 0 ; }

Accumulator variables: i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { return b ? gcd ( b , a % b ) : a ; } int countGCD ( int L , int R , int g ) { L = ( L + g - 1 ) / g ; R = R / g ; int ans = 0 ; for ( int i = L ; i <= R ; i ++ ) for ( int j = L ; j <= R ; j ++ ) if ( gcd ( i , j ) == 1 ) ans ++ ; return ans ; } int main ( ) { int L = 1 , R = 11 , g = 5 ; cout << countGCD ( L , R , g ) << endl ; return 0 ; }

Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dig [ ] = { 1 , 1 , 2 , 6 , 4 , 2 , 2 , 4 , 2 , 8 } ; int lastNon0Digit ( int n ) { if ( n < 10 ) return dig [ n ] ; if ( ( ( n / 10 ) % 10 ) % 2 == 0 ) return ( 6 * lastNon0Digit ( n / 5 ) * dig [ n % 10 ] ) % 10 ; else return ( 4 * lastNon0Digit ( n / 5 ) * dig [ n % 10 ] ) % 10 ; } int main ( ) { int n = 14 ; cout << lastNon0Digit ( n ) ; return 0 ; }

Index/key variables: n
Accumulator variables: stdc
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 main ( void ) { int x = 16 ; cout << firstFactorialDivisibleNumber ( x ) ; return 0 ; }

Accumulator variables: i, new_x, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sieve ( bool prime [ ] , int n ) { prime [ 0 ] = prime [ 1 ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == false ) for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = true ; } } int maxDigitInPrimes ( int L , int R ) { bool prime [ R + 1 ] ; memset ( prime , 0 , sizeof ( prime ) ) ; sieve ( prime , R ) ; int freq [ 10 ] = { 0 } ; int val ; for ( int i = L ; i <= R ; i ++ ) { if ( ! prime [ i ] ) { while ( p ) { freq [ p % 10 ] ++ ; p /= 10 ; } } } int max = freq [ 0 ] , ans = 0 ; for ( int j = 1 ; j < 10 ; j ++ ) { if ( max <= freq [ j ] ) { max = freq [ j ] ; ans = j ; } } return ( max != 0 ) ? ans : -1 ; } int main ( ) { int L = 1 , R = 20 ; cout << maxDigitInPrimes ( L , R ) << endl ; return 0 ; }

Index/key variables: i, j, p
Accumulator variables: i, j, p, stdc
Iterator variables: i, j, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool arr [ 1001 ] ; void simpleSieve ( ) { memset ( arr , true , sizeof ( arr ) ) ; for ( int p = 2 ; p * p < 1001 ; p ++ ) { if ( arr [ p ] ) { for ( int i = p * 2 ; i < 1001 ; i = i + p ) arr [ i ] = false ; } } } int find_sphene ( int N ) { int arr1 [ 8 ] = { 0 } ; int count = 0 ; int j = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( N % i == 0 && count < 9 ) { count ++ ; arr1 [ j ++ ] = i ; } } if ( count == 8 && ( arr [ arr1 [ 1 ] ] && arr [ arr1 [ 2 ] ] && arr [ arr1 [ 3 ] ] ) ) return 1 ; return 0 ; } int main ( ) { int n = 60 ; simpleSieve ( ) ; int ans = find_sphene ( n ) ; if ( ans ) cout << " Yes " ; else cout << " NO " ; }

Index/key variables: i, p
Accumulator variables: count, i, j, p, stdc
Iterator variables: i, p
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 commDiv ( int a , int b ) { int n = gcd ( a , b ) ; int result = 0 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) result += 1 ; else result += 2 ; } } return result ; } int main ( ) { int a = 12 , b = 24 ; cout << commDiv ( a , b ) ; return 0 ; }

Accumulator variables: i, result, stdc
Iterator variables: i