dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isTriangular ( int num ) { if ( num < 0 ) return false ; int c = ( -2 * num ) ; int b = 1 , a = 1 ; int d = ( b * b ) - ( 4 * a * c ) ; if ( d < 0 ) return -1 ; float root1 = ( - b + sqrt ( d ) ) / ( 2 * a ) ; float root2 = ( - b - sqrt ( d ) ) / ( 2 * a ) ; if ( root1 > 0 && floor ( root1 ) == root1 ) return root1 ; if ( root2 > 0 && floor ( root2 ) == root2 ) return root2 ; return -1 ; } int isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; if ( ( sr - floor ( sr ) ) == 0 ) return floor ( sr ) ; else return -1 ; } int findS ( int s ) { int sr = isPerfectSquare ( s ) ; if ( sr == -1 ) return -1 ; return isTriangular ( sr ) ; } int main ( ) { int s = 9 ; int n = findS ( s ) ; n == -1 ? cout << " - 1" : cout << n ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int trickyCase ( string s , int index ) { int index1 = -1 ; for ( int i = index - 1 ; i >= 0 ; i -- ) { int digit = s [ i ] - '0' ; if ( digit != 8 ) { index1 = i ; break ; } } if ( index1 == -1 ) return 2 * pow ( 10 , s . length ( ) ) ; int num = 0 ; for ( int i = 0 ; i < index1 ; i ++ ) num = num * 10 + ( s [ i ] - '0' ) ; if ( s [ index1 ] % 2 == 0 ) num = num * 10 + ( s [ index1 ] - '0' + 2 ) ; else num = num * 10 + ( s [ index1 ] - '0' + 1 ) ; for ( int i = index1 + 1 ; i < s . length ( ) ; i ++ ) num = num * 10 ; return num ; } int smallestNumber ( int n ) { int num = 0 ; string s = " " ; int duplicate = n ; while ( n ) { s = char ( n % 10 + 48 ) + s ; n /= 10 ; } int index = -1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int digit = s [ i ] - '0' ; if ( digit & 1 ) { index = i ; break ; } } if ( index == -1 ) return duplicate ; if ( s [ index ] == '9' ) { num = trickyCase ( s , index ) ; return num ; } for ( int i = 0 ; i < index ; i ++ ) num = num * 10 + ( s [ i ] - '0' ) ; num = num * 10 + ( s [ index ] - '0' + 1 ) ; for ( int i = index + 1 ; i < s . length ( ) ; i ++ ) num = num * 10 ; return num ; } int main ( ) { int N = 2397 ; cout << smallestNumber ( N ) ; return 0 ; }

Index/key variables: i, index, index1
Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNth ( int n ) { int count = 0 ; for ( int curr = 19 ; ; curr += 9 ) { int sum = 0 ; for ( int x = curr ; x > 0 ; x = x / 10 ) sum = sum + x % 10 ; if ( sum == 10 ) count ++ ; if ( count == n ) return curr ; } return -1 ; } int main ( ) { printf ( " % d STRNEWLINE " , findNth ( 5 ) ) ; return 0 ; }

Accumulator variables: count, curr, stdc
Iterator variables: curr, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int findSum ( int n ) { long long int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = i ; j <= n ; j ++ ) sum = sum + i * j ; return sum ; } int main ( ) { int n = 5 ; cout << findSum ( n ) ; return 0 ; }

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

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n < 2 ) return false ; for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } void lemoine ( int n ) { map < int , int > pr ; map < int , int > :: iterator it ; it = pr . begin ( ) ; for ( int q = 1 ; q <= n / 2 ; q ++ ) { int p = n - 2 * q ; if ( isPrime ( p ) && isPrime ( q ) ) pr . insert ( it , pair < int , int > ( p , q ) ) ; } for ( it = pr . begin ( ) ; it != pr . end ( ) ; ++ it ) cout << n << " ▁ = ▁ " << it -> first << " ▁ + ▁ ( 2 ▁ * ▁ " << it -> second << " ) STRNEWLINE " ; } int main ( ) { int n = 39 ; cout << n << " ▁ can ▁ be ▁ expressed ▁ as ▁ " << endl ; lemoine ( n ) ; return 0 ; }

Accumulator variables: i, q, stdc
Iterator variables: i, it, q
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Nth_of_AP ( int a , int d , int N ) { return ( a + ( N - 1 ) * d ) ; } int main ( ) { int a = 2 ; int d = 1 ; int N = 5 ; cout << " The ▁ " << N << " th ▁ term ▁ of ▁ the ▁ series ▁ is ▁ : ▁ " << Nth_of_AP ( a , d , N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfSeries ( int n ) { return 0.6172 * ( pow ( 10 , n ) - 1 ) - 0.55 * n ; } int main ( ) { int n = 2 ; cout << sumOfSeries ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Nonagonal ( int n ) { return n * ( 7 * n - 5 ) / 2 ; } int main ( ) { int n = 10 ; cout << Nonagonal ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; bool isDvisibleBy12 ( string num ) { if ( num . length ( ) >= 3 ) { int d1 = ( int ) num [ num . length ( ) - 1 ] ; if ( d1 % 2 != 0 ) return ( 0 ) ; int d2 = ( int ) num [ num . length ( ) - 2 ] ; int sum = 0 ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) sum += num [ i ] ; return ( sum % 3 == 0 && ( d2 * 10 + d1 ) % 4 == 0 ) ; } else { int number = stoi ( num ) ; return ( number % 12 == 0 ) ; } } int main ( ) { string num = "12244824607284961224" ; if ( isDvisibleBy12 ( num ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int n ) { int d = sqrt ( n ) ; if ( d * d == n ) return true ; return false ; } int largestNonPerfectSquareNumber ( int a [ ] , int n ) { int maxi = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! check ( a [ i ] ) ) maxi = max ( a [ i ] , maxi ) ; } return maxi ; } int main ( ) { int a [ ] = { 16 , 20 , 25 , 2 , 3 , 10 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << largestNonPerfectSquareNumber ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printAP ( int a , int d , int n ) { int curr_term ; curr_term = a ; for ( int i = 1 ; i <= n ; i ++ ) { cout << curr_term << " ▁ " ; curr_term = curr_term + d ; } } int main ( ) { int a = 2 ; int d = 1 ; int n = 5 ; printAP ( a , d , n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <assert.h>
#include <math.h>
#include <stdio.h>
void printNonSquare ( int n ) { int curr_count = 2 , num = 2 , count = 0 ; while ( count < n ) { for ( int i = 0 ; i < curr_count && count < n ; i ++ ) { printf ( " % d ▁ " , num ) ; count ++ ; num ++ ; } num ++ ; curr_count += 2 ; } } int main ( ) { int n = 10 ; printNonSquare ( n ) ; return 0 ; }

Accumulator variables: count, curr_count, i, num
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countZeros ( int a [ ] , int n ) { int count2 = 0 , count5 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( a [ i ] % 2 == 0 ) { a [ i ] = a [ i ] / 2 ; count2 ++ ; } while ( a [ i ] % 5 == 0 ) { a [ i ] = a [ i ] / 5 ; count5 ++ ; } } return ( count2 < count5 ) ? count2 : count5 ; } int main ( ) { int a [ ] = { 10 , 100 , 20 , 30 , 50 , 90 , 12 , 80 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << countZeros ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count2, count5, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned pwr [ 10 ] ; bool isMunchhausen ( unsigned n ) { unsigned sum = 0 ; int temp = n ; while ( temp ) { sum += pwr [ ( temp % 10 ) ] ; temp /= 10 ; } return ( sum == n ) ; } void printMunchhausenNumbers ( int n ) { for ( int i = 0 ; i < 10 ; i ++ ) pwr [ i ] = ( unsigned ) pow ( ( float ) i , ( float ) i ) ; for ( unsigned i = 1 ; i <= n ; i ++ ) if ( isMunchhausen ( i ) ) cout << i << " STRNEWLINE " ; } int main ( ) { int n = 10000 ; printMunchhausenNumbers ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int kthdigit ( int a , int b , int k ) { int p = pow ( a , b ) ; int count = 0 ; while ( p > 0 && count < k ) { int rem = p % 10 ; count ++ ; if ( count == k ) return rem ; p = p / 10 ; } return 0 ; } int main ( ) { int a = 5 , b = 2 ; int k = 1 ; cout << kthdigit ( a , b , k ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long digSum ( long n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } long PowDigSum ( long n , long x ) { long sum = digSum ( n ) ; long rem = x % 6 ; if ( ( sum == 3 sum == 6 ) && x > 1 ) return 9 ; else if ( x == 1 ) return sum ; else if ( x == 0 ) return 1 ; else if ( rem == 0 ) return digSum ( ( long ) pow ( sum , 6 ) ) ; else return digSum ( ( long ) pow ( sum , rem ) ) ; } int main ( ) { int n = 33333 ; int x = 332654 ; cout << PowDigSum ( n , x ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int maxArea ( int A [ ] , int len ) { int l = 0 ; int r = len - 1 ; int area = 0 ; while ( l < r ) { area = max ( area , min ( A [ l ] , A [ r ] ) * ( r - l ) ) ; if ( A [ l ] < A [ r ] ) l += 1 ; else r -= 1 ; } return area ; } int main ( ) { int a [ ] = { 1 , 5 , 4 , 3 } ; int b [ ] = { 3 , 1 , 2 , 4 , 5 } ; int len1 = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << maxArea ( a , len1 ) ; int len2 = sizeof ( b ) / sizeof ( b [ 0 ] ) ; cout << endl << maxArea ( b , len2 ) ; }

Index/key variables: l, r
Accumulator variables: l, r
C++ program:
# include <bits/stdc++.h>
using namespace std ; int mobius ( int n ) { int p = 0 ; if ( n % 2 == 0 ) { n = n / 2 ; p ++ ; if ( n % 2 == 0 ) return 0 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { n = n / i ; p ++ ; if ( n % i == 0 ) return 0 ; } } return ( p % 2 == 0 ) ? -1 : 1 ; } int main ( ) { int N = 17 ; cout << " Mobius ▁ Functions ▁ M ( N ) ▁ at ▁ N ▁ = ▁ " << N << " ▁ is : ▁ " << mobius ( N ) << endl ; cout << " Mobius ▁ Functions ▁ M ( N ) ▁ at ▁ N ▁ = ▁ " << 25 << " ▁ is : ▁ " << mobius ( 25 ) << endl ; cout << " Mobius ▁ Functions ▁ M ( N ) ▁ at ▁ N ▁ = ▁ " << 6 << " ▁ is : ▁ " << mobius ( 6 ) << endl ; }

Accumulator variables: p, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int start , int end ) { int res = 1 ; for ( int i = start ; i <= end ; i ++ ) res *= i ; return res ; } int sumofsquare ( int n ) { return factorial ( n + 1 , 2 * n ) / factorial ( 1 , n ) ; } int main ( ) { int n = 4 ; cout << sumofsquare ( n ) << endl ; return 0 ; }

Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double PHI = 1.6180339 ; int f [ 6 ] = { 0 , 1 , 1 , 2 , 3 , 5 } ; int fib ( int n ) { if ( n < 6 ) return f [ n ] ; int t = 5 , fn = 5 ; while ( t < n ) { fn = round ( fn * PHI ) ; t ++ ; } return fn ; } int main ( ) { int n = 9 ; cout << n << " th ▁ Fibonacci ▁ Number ▁ = ▁ " << fib ( n ) << endl ; return 0 ; }

Index/key variables: n
Accumulator variables: stdc, t
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solution ( int a , int b , int n ) { for ( int i = 0 ; i * a <= n ; i ++ ) { if ( ( n - ( i * a ) ) % b == 0 ) { cout << " x ▁ = ▁ " << i << " , ▁ y ▁ = ▁ " << ( n - ( i * a ) ) / b ; return ; } } cout << " No ▁ solution " ; } int main ( ) { int a = 2 , b = 3 , n = 7 ; solution ( a , b , n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeffSum ( int n ) { return ( 1 << n ) ; } int main ( ) { int n = 4 ; printf ( " % d " , binomialCoeffSum ( n ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void precisionCompute ( int x , int y , int n ) { if ( y == 0 ) { cout << " Infinite " << endl ; return ; } if ( x == 0 ) { cout << 0 << endl ; return ; } if ( n <= 0 ) { cout << x / y << endl ; return ; } if ( ( ( x > 0 ) && ( y < 0 ) ) || ( ( x < 0 ) && ( y > 0 ) ) ) { cout << " - " ; x = x > 0 ? x : - x ; y = y > 0 ? y : - y ; } int d = x / y ; for ( int i = 0 ; i <= n ; i ++ ) { cout << d ; x = x - ( y * d ) ; if ( x == 0 ) break ; x = x * 10 ; d = x / y ; if ( i == 0 ) cout << " . " ; } } int main ( ) { int x = 22 , y = 7 , n = 15 ; precisionCompute ( x , y , n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void quadrant ( int x , int y ) { if ( x > 0 and y > 0 ) cout << " lies ▁ in ▁ First ▁ quadrant " ; else if ( x < 0 and y > 0 ) cout << " lies ▁ in ▁ Second ▁ quadrant " ; else if ( x < 0 and y < 0 ) cout << " lies ▁ in ▁ Third ▁ quadrant " ; else if ( x > 0 and y < 0 ) cout << " lies ▁ in ▁ Fourth ▁ quadrant " ; else if ( x == 0 and y > 0 ) cout << " lies ▁ at ▁ positive ▁ y ▁ axis " ; else if ( x == 0 and y < 0 ) cout << " lies ▁ at ▁ negative ▁ y ▁ axis " ; else if ( y == 0 and x < 0 ) cout << " lies ▁ at ▁ negative ▁ x ▁ axis " ; else if ( y == 0 and x > 0 ) cout << " lies ▁ at ▁ positive ▁ x ▁ axis " ; else cout << " lies ▁ at ▁ origin " ; } int main ( ) { int x = 1 , y = 1 ; quadrant ( x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkDigits ( int n ) { while ( n ) { int dig = n % 10 ; if ( dig != 2 && dig != 3 && dig != 5 && dig != 7 ) return false ; n /= 10 ; } return true ; } bool prime ( int n ) { if ( n == 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } int isFullPrime ( int n ) { return ( checkDigits ( n ) && prime ( n ) ) ; } int main ( ) { int n = 53 ; if ( isFullPrime ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <string.h>
using namespace std ; string getResult ( string st ) { int sum = 0 ; int length = st . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { sum = sum + pow ( st [ i ] - '0' , length ) ; } int number = stoi ( st ) ; if ( number == sum ) return " yes " ; else return " no " ; } int main ( ) { string st = "153" ; cout << getResult ( st ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define MAX  500
using namespace std ; int nthSHN ( int n , int dp [ ] ) { if ( n == 1 n == 2 ) return dp [ n ] = 1 ; if ( dp [ n ] != -1 ) return dp [ n ] ; return dp [ n ] = ( ( 6 * n - 9 ) * nthSHN ( n - 1 , dp ) - ( n - 3 ) * nthSHN ( n - 2 , dp ) ) / n ; } int main ( ) { int n = 6 ; int dp [ MAX ] ; memset ( dp , -1 , sizeof dp ) ; cout << nthSHN ( n , dp ) << endl ; return 0 ; }

Index/key variables: MAX, n
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int evenSum ( int n ) { int curr = 2 , sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { sum += curr ; curr += 2 ; } return sum ; } int main ( ) { int n = 20 ; cout << " Sum ▁ of ▁ first ▁ " << n << " ▁ Even ▁ numbers ▁ is : ▁ " << evenSum ( n ) ; return 0 ; }

Accumulator variables: curr, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int evenSum ( int n ) { return ( n * ( n + 1 ) ) ; } int main ( ) { int n = 20 ; cout << " Sum ▁ of ▁ first ▁ " << n << " ▁ Even ▁ numbers ▁ is : ▁ " << evenSum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double kmphTOmph ( double kmph ) { return 0.6214 * kmph ; } double mphTOkmph ( double mph ) { return mph * 1.60934 ; } int main ( ) { double kmph = 150 ; double mph = 100 ; cout << " the ▁ speed ▁ in ▁ mph ▁ is ▁ " << kmphTOmph ( kmph ) << endl ; cout << " the ▁ speed ▁ in ▁ kmph ▁ is ▁ " << mphTOkmph ( mph ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long subsequences ( int a [ ] , int n , int r ) { unordered_map < int , int > left , right ; long long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int i = 0 ; i < n ; i ++ ) { long long c1 = 0 , c2 = 0 ; if ( a [ i ] % r == 0 ) c1 = left [ a [ i ] / r ] ; right [ a [ i ] ] -- ; c2 = right [ a [ i ] * r ] ; ans += c1 * c2 ; left [ a [ i ] ] ++ ; } return ans ; } int main ( ) { int a [ ] = { 1 , 2 , 6 , 2 , 3 , 6 , 9 , 18 , 3 , 9 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int r = 3 ; cout << subsequences ( a , n , r ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
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 findNumber ( int arr [ ] , int n ) { int ans = arr [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) ans = gcd ( ans , arr [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == ans ) return ans ; return -1 ; } int main ( ) { int arr [ ] = { 2 , 2 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findNumber ( 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 ; vector < int > primes ; void SieveofEratosthenes ( int n ) { bool visited [ n ] ; for ( int i = 2 ; i <= n + 1 ; i ++ ) if ( ! visited [ i ] ) { for ( int j = i * i ; j <= n + 1 ; j += i ) visited [ j ] = true ; primes . push_back ( i ) ; } } bool specialPrimeNumbers ( int n , int k ) { SieveofEratosthenes ( n ) ; int count = 0 ; for ( int i = 0 ; i < primes . size ( ) ; i ++ ) { for ( int j = 0 ; j < i - 1 ; j ++ ) { if ( primes [ j ] + primes [ j + 1 ] + 1 == primes [ i ] ) { count ++ ; break ; } } if ( count == k ) return true ; } return false ; } int main ( ) { int n = 27 , k = 2 ; if ( specialPrimeNumbers ( n , k ) ) cout << " YES " << endl ; else cout << " NO " << endl ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void factorize ( long long n ) { int count = 0 ; while ( ! ( n % 2 ) ) { count ++ ; } if ( count ) cout << 2 << " ▁ " << count << endl ; for ( long long i = 3 ; i <= sqrt ( n ) ; i += 2 ) { count = 0 ; while ( n % i == 0 ) { count ++ ; n = n / i ; } if ( count ) cout << i << " ▁ " << count << endl ; } if ( n > 2 ) cout << n << " ▁ " << 1 << endl ; } int main ( ) { long long n = 1000000000000000000 ; factorize ( n ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumMoves ( int A [ ] , int N ) { int one = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( A [ i ] == 1 ) one ++ ; if ( one != 0 ) return N - one ; int minimum = INT_MAX ; for ( int i = 0 ; i < N ; i ++ ) { int g = A [ i ] ; for ( int j = i + 1 ; j < N ; j ++ ) { g = __gcd ( A [ j ] , g ) ; if ( g == 1 ) { minimum = min ( minimum , j - i ) ; break ; } } } if ( minimum == INT_MAX ) return -1 ; else return N + minimum - 1 ; } int main ( ) { int A [ ] = { 2 , 4 , 3 , 9 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << minimumMoves ( A , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, one, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void series ( int n , int d ) { if ( d == 0 ) { for ( int i = 0 ; i < n ; i ++ ) cout << "0 ▁ " ; cout << endl ; return ; } if ( n % 2 == 0 ) { for ( int i = 1 ; i <= n ; i ++ ) { cout << pow ( -1 , i ) * d << " ▁ " ; } cout << endl ; } else { float m = n ; float r = ( m / ( m - 1 ) ) ; float g = ( float ) ( d * ( float ) sqrtf ( r ) ) ; cout << "0 ▁ " ; for ( int i = 1 ; i < n ; i ++ ) { cout << pow ( -1 , i ) * g << " ▁ " ; } cout << endl ; } } int main ( ) { int n = 3 , d = 3 ; series ( n , d ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigitOne ( int n ) { int countr = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { string str = to_string ( i ) ; countr += count ( str . begin ( ) , str . end ( ) , '1' ) ; } return countr ; } int main ( ) { int n = 13 ; cout << countDigitOne ( n ) << endl ; n = 131 ; cout << countDigitOne ( n ) << endl ; n = 159 ; cout << countDigitOne ( n ) << endl ; return 0 ; }

Accumulator variables: countr, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long exponentiation ( long base , long exp ) { long t = 1L ; while ( exp > 0 ) { if ( exp % 2 != 0 ) t = ( t * base ) % N ; base = ( base * base ) % N ; exp /= 2 ; } return t % N ; } int main ( ) { long base = 5 ; long exp = 100000 ; long modulo = exponentiation ( base , exp ) ; cout << ( modulo ) ; return 0 ; }

Accumulator variables: exp, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int x ) { if ( x <= 1 ) return 1 ; int res = 2 ; for ( int i = 3 ; i <= x ; i ++ ) res = res * i ; return res ; } int gcdOfFactorial ( int m , int n ) { return factorial ( min ( m , n ) ) ; } int main ( ) { int m = 5 , n = 9 ; cout << gcdOfFactorial ( m , n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumber ( int n ) { int x = ( int ) floor ( ( -1 + sqrt ( 1 + 8 * n - 8 ) ) / 2 ) ; int base = ( x * ( x + 1 ) ) / 2 + 1 ; return n - base + 1 ; } int main ( ) { int n = 55 ; cout << findNumber ( n ) << endl ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void calculate ( int a [ ] , int b [ ] , int n , int m ) { int mul = 1 ; for ( int i = 0 ; i < m ; i ++ ) if ( b [ i ] != 0 ) mul = mul * b [ i ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = floor ( a [ i ] / mul ) ; cout << x << " ▁ " ; } } int main ( ) { int a [ ] = { 5 , 100 , 8 } ; int b [ ] = { 2 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int m = sizeof ( b ) / sizeof ( b [ 0 ] ) ; calculate ( a , b , n , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findPowerOfP ( int n , int p ) { int count = 0 ; int r = p ; while ( r <= n ) { count += ( n / r ) ; r = r * p ; } return count ; } vector < pair < int , int > > primeFactorsofK ( int k ) { vector < pair < int , int > > ans ; for ( int i = 2 ; k != 1 ; i ++ ) { if ( k % i == 0 ) { int count = 0 ; while ( k % i == 0 ) { k = k / i ; count ++ ; } ans . push_back ( make_pair ( i , count ) ) ; } } return ans ; } int largestPowerOfK ( int n , int k ) { vector < pair < int , int > > vec ; vec = primeFactorsofK ( k ) ; int ans = INT_MAX ; for ( int i = 0 ; i < vec . size ( ) ; i ++ ) ans = min ( ans , findPowerOfP ( n , vec [ i ] . first ) / vec [ i ] . second ) ; return ans ; } int main ( ) { cout << largestPowerOfK ( 7 , 2 ) << endl ; cout << largestPowerOfK ( 10 , 9 ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print ( int n ) { cout << n + n / 2 << endl ; for ( int i = 2 ; i <= n ; i += 2 ) cout << i << " ▁ " ; for ( int i = 1 ; i <= n ; i += 2 ) cout << i << " ▁ " ; for ( int i = 2 ; i <= n ; i += 2 ) cout << i << " ▁ " ; } int main ( ) { int n = 3 ; print ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i