dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; void multiply ( int T [ 3 ] [ 3 ] , int M [ 3 ] [ 3 ] ) { int a , b , c , d , e , f , g , h , i ; a = T [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + T [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] + T [ 0 ] [ 2 ] * M [ 2 ] [ 0 ] ; b = T [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + T [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] + T [ 0 ] [ 2 ] * M [ 2 ] [ 1 ] ; c = T [ 0 ] [ 0 ] * M [ 0 ] [ 2 ] + T [ 0 ] [ 1 ] * M [ 1 ] [ 2 ] + T [ 0 ] [ 2 ] * M [ 2 ] [ 2 ] ; d = T [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + T [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] + T [ 1 ] [ 2 ] * M [ 2 ] [ 0 ] ; e = T [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + T [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] + T [ 1 ] [ 2 ] * M [ 2 ] [ 1 ] ; f = T [ 1 ] [ 0 ] * M [ 0 ] [ 2 ] + T [ 1 ] [ 1 ] * M [ 1 ] [ 2 ] + T [ 1 ] [ 2 ] * M [ 2 ] [ 2 ] ; g = T [ 2 ] [ 0 ] * M [ 0 ] [ 0 ] + T [ 2 ] [ 1 ] * M [ 1 ] [ 0 ] + T [ 2 ] [ 2 ] * M [ 2 ] [ 0 ] ; h = T [ 2 ] [ 0 ] * M [ 0 ] [ 1 ] + T [ 2 ] [ 1 ] * M [ 1 ] [ 1 ] + T [ 2 ] [ 2 ] * M [ 2 ] [ 1 ] ; i = T [ 2 ] [ 0 ] * M [ 0 ] [ 2 ] + T [ 2 ] [ 1 ] * M [ 1 ] [ 2 ] + T [ 2 ] [ 2 ] * M [ 2 ] [ 2 ] ; T [ 0 ] [ 0 ] = a ; T [ 0 ] [ 1 ] = b ; T [ 0 ] [ 2 ] = c ; T [ 1 ] [ 0 ] = d ; T [ 1 ] [ 1 ] = e ; T [ 1 ] [ 2 ] = f ; T [ 2 ] [ 0 ] = g ; T [ 2 ] [ 1 ] = h ; T [ 2 ] [ 2 ] = i ; } void power ( int T [ 3 ] [ 3 ] , int n ) { if ( n == 0 n == 1 ) return ; int M [ 3 ] [ 3 ] = { { 1 , 1 , 1 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } } ; power ( T , n / 2 ) ; multiply ( T , T ) ; if ( n % 2 ) multiply ( T , M ) ; } int tribonacci ( int n ) { int T [ 3 ] [ 3 ] = { { 1 , 1 , 1 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } } ; if ( n == 0 n == 1 ) return 0 ; else power ( T , n - 2 ) ; return T [ 0 ] [ 0 ] ; } int main ( ) { int n = 10 ; for ( int i = 0 ; i < n ; i ++ ) cout << tribonacci ( i ) << " ▁ " ; cout << endl ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float geometricMean ( int arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + log ( arr [ i ] ) ; sum = sum / n ; return exp ( sum ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << geometricMean ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int smallestNumber ( int n ) { if ( n >= 0 && n <= 9 ) return n ; stack < int > digits ; for ( int i = 9 ; i >= 2 && n > 1 ; i -- ) { while ( n % i == 0 ) { digits . push ( i ) ; n = n / i ; } } if ( n != 1 ) return -1 ; long long int k = 0 ; while ( ! digits . empty ( ) ) { k = k * 10 + digits . top ( ) ; digits . pop ( ) ; } return k ; } int main ( ) { int n = 100 ; cout << smallestNumber ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isMagic ( int n ) { int sum = 0 ; while ( n > 0 sum > 9 ) { if ( n == 0 ) { n = sum ; sum = 0 ; } sum += n % 10 ; n /= 10 ; } return ( sum == 1 ) ; } int main ( ) { int n = 1234 ; if ( isMagic ( n ) ) cout << " Magic ▁ Number " ; else cout << " Not ▁ a ▁ magic ▁ Number " ; return 0 ; }

Accumulator variables: n, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; void storeDigitCounts ( int n , vector < int > & hash ) { while ( n ) { hash [ n % 10 ] ++ ; n /= 10 ; } } int rearrange ( int n ) { vector < int > hash_n ( 10 , 0 ) ; storeDigitCounts ( n , hash_n ) ; for ( int mult = 2 ; mult < 10 ; mult ++ ) { int curr = n * mult ; vector < int > hash_curr ( 10 , 0 ) ; storeDigitCounts ( curr , hash_curr ) ; if ( equal ( hash_n . begin ( ) , hash_n . end ( ) , hash_curr . begin ( ) ) ) return curr ; } return -1 ; } int main ( ) { int n = 10035 ; cout << rearrange ( n ) ; return 0 ; }

Accumulator variables: mult, n, stdc
Iterator variables: mult
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  1000000007
void printSequence ( int n ) { int a = 1 ; int ans = 2 ; for ( int i = 1 ; i <= n ; i ++ ) { cout << ans << " ▁ " ; ans = ( ( a % N ) * ( ans % N ) ) % N ; a = ans ; ans = ( ans + 1 ) % N ; } } int main ( ) { int n = 6 ; printSequence ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int HailstoneNumbers ( int N ) { static int c ; cout << N << " ▁ " ; if ( N == 1 && c == 0 ) { return c ; } else if ( N == 1 && c != 0 ) { c ++ ; return c ; } else if ( N % 2 == 0 ) { c ++ ; HailstoneNumbers ( N / 2 ) ; } else if ( N % 2 != 0 ) { c ++ ; HailstoneNumbers ( 3 * N + 1 ) ; } } int main ( ) { int N = 7 ; int x ; x = HailstoneNumbers ( N ) ; cout << endl ; cout << " Number ▁ of ▁ Steps : ▁ " << x ; return 0 ; }

Accumulator variables: c, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int SUM ( int n , int m ) { if ( m == 1 ) return ( n * ( n + 1 ) / 2 ) ; int sum = SUM ( n , m - 1 ) ; return ( sum * ( sum + 1 ) / 2 ) ; } int main ( ) { int n = 5 ; int m = 3 ; cout << " SUM ( " << n << " , ▁ " << m << " ) : ▁ " << SUM ( n , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int x , int y ) { unordered_map < int , int > m ; while ( x % y != 0 ) { x = x % y ; ans ++ ; if ( m . find ( x ) != m . end ( ) ) return -1 ; m [ x ] = 1 ; x = x * 10 ; } return ans ; } int main ( ) { int res = count ( 1 , 2 ) ; ( res == -1 ) ? cout << " INF " : cout << res ; cout << endl ; res = count ( 5 , 3 ) ; ( res == -1 ) ? cout << " INF " : cout << res ; cout << endl ; res = count ( 3 , 5 ) ; ( res == -1 ) ? cout << " INF " : cout << res ; return 0 ; }

Index/key variables: x
Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xorCalc ( int k ) { if ( k == 1 ) return 2 ; if ( ( ( k + 1 ) & k ) == 0 ) return k / 2 ; return -1 ; } int main ( ) { int k = 31 ; cout << xorCalc ( k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findNthNo ( int n ) { string res = " " ; while ( n >= 1 ) { if ( n & 1 ) { res = res + "4" ; n = ( n - 1 ) / 2 ; } else { res = res + "7" ; n = ( n - 2 ) / 2 ; } } reverse ( res . begin ( ) , res . end ( ) ) ; return res ; } int main ( ) { int n = 13 ; cout << findNthNo ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divCount ( int n ) { bool hash [ n + 1 ] ; memset ( hash , true , sizeof ( hash ) ) ; for ( int p = 2 ; p * p < n ; p ++ ) if ( hash [ p ] == true ) for ( int i = p * 2 ; i < n ; i += p ) hash [ i ] = false ; int total = 1 ; for ( int p = 2 ; p <= n ; p ++ ) { if ( hash [ p ] ) { int count = 0 ; if ( n % p == 0 ) { while ( n % p == 0 ) { n = n / p ; count ++ ; } total = total * ( count + 1 ) ; } } } return total ; } int main ( ) { int n = 24 ; cout << divCount ( n ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: count, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPrimefactorNum ( int N ) { int arr [ N + 1 ] ; memset ( arr , 0 , sizeof ( arr ) ) ; for ( int i = 2 ; i * i <= N ; i ++ ) { if ( ! arr [ i ] ) for ( int j = 2 * i ; j <= N ; j += i ) arr [ j ] ++ ; arr [ i ] = 1 ; } return * max_element ( arr , arr + N ) ; } int main ( ) { int N = 40 ; cout << maxPrimefactorNum ( N ) << endl ; 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 ; string decToBin ( int n ) { if ( n == 0 ) return "0" ; string bin = " " ; while ( n > 0 ) { bin = ( ( n & 1 ) == 0 ? '0' : '1' ) + bin ; n >>= 1 ; } return bin ; } int main ( ) { int n = 38 ; cout << decToBin ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int removeColon ( string s ) { if ( s . size ( ) == 4 ) s . replace ( 1 , 1 , " " ) ; if ( s . size ( ) == 5 ) s . replace ( 2 , 1 , " " ) ; return stoi ( s ) ; } string diff ( string s1 , string s2 ) { int time1 = removeColon ( s1 ) ; int time2 = removeColon ( s2 ) ; int hourDiff = time2 / 100 - time1 / 100 - 1 ; int minDiff = time2 % 100 + ( 60 - time1 % 100 ) ; if ( minDiff >= 60 ) { hourDiff ++ ; minDiff = minDiff - 60 ; } string res = to_string ( hourDiff ) + ' : ' + to_string ( minDiff ) ; return res ; } int main ( ) { string s1 = "14:00" ; string s2 = "16:45" ; cout << diff ( s1 , s2 ) << endl ; return 0 ; }

Accumulator variables: hourDiff, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isBalancePossible ( int T , int a ) { vector < int > baseForm ; while ( T ) { baseForm . push_back ( T % a ) ; T /= a ; } baseForm . push_back ( 0 ) ; for ( int i = 0 ; i < baseForm . size ( ) ; i ++ ) { if ( baseForm [ i ] != 0 && baseForm [ i ] != 1 && baseForm [ i ] != ( a - 1 ) && baseForm [ i ] != a ) return false ; if ( baseForm [ i ] == a || baseForm [ i ] == ( a - 1 ) ) baseForm [ i + 1 ] += 1 ; } return true ; } int main ( ) { int T = 11 ; int a = 4 ; bool balancePossible = isBalancePossible ( T , a ) ; if ( balancePossible ) cout << " Balance ▁ is ▁ possible " << endl ; else cout << " Balance ▁ is ▁ not ▁ possible " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: T, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int a , int b ) { if ( a == 0 b == 0 ) return 1 ; return floor ( log10 ( abs ( a ) ) + log10 ( abs ( b ) ) ) + 1 ; } int main ( ) { int a = 33 ; int b = -24 ; cout << countDigits ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lastPosition ( int n , int m , int k ) { if ( m <= n - k + 1 ) return m + k - 1 ; m = m - ( n - k + 1 ) ; return ( m % n == 0 ) ? n : ( m % n ) ; } int main ( ) { int n = 5 ; int m = 8 ; int k = 2 ; cout << lastPosition ( n , m , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void primesInRange ( int n ) { int fact = 1 ; for ( int k = 2 ; k < n ; k ++ ) { fact = fact * ( k - 1 ) ; if ( ( fact + 1 ) % k == 0 ) cout << k << endl ; } } int main ( ) { int n = 15 ; primesInRange ( n ) ; }

Accumulator variables: k, stdc
Iterator variables: k
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define EPS  1e-9
void productPuzzle ( int a [ ] , int n ) { long double sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += ( long double ) log10 ( a [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) cout << ( int ) ( EPS + pow ( ( long double ) 10.00 , sum - log10 ( a [ i ] ) ) ) << " ▁ " ; } int main ( ) { int a [ ] = { 10 , 3 , 5 , 6 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << " The ▁ product ▁ array ▁ is : ▁ STRNEWLINE " ; productPuzzle ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int changeEvenBits ( int n ) { int to_subtract = 0 ; int m = 0 ; for ( int x = n ; x ; x >>= 2 ) { if ( x & 1 ) to_subtract += ( 1 << m ) ; m += 2 ; } return n - to_subtract ; } int main ( ) { int n = 30 ; cout << changeEvenBits ( n ) << endl ; return 0 ; }

Accumulator variables: m, stdc, to_subtract
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int closestNumber ( int n , int m ) { int q = n / m ; int n1 = m * q ; int n2 = ( n * m ) > 0 ? ( m * ( q + 1 ) ) : ( m * ( q - 1 ) ) ; if ( abs ( n - n1 ) < abs ( n - n2 ) ) return n1 ; return n2 ; } int main ( ) { int n = 13 , m = 4 ; cout << closestNumber ( n , m ) << endl ; n = -15 ; m = 6 ; cout << closestNumber ( n , m ) << endl ; n = 0 ; m = 8 ; cout << closestNumber ( n , m ) << endl ; n = 18 ; m = -7 ; cout << closestNumber ( n , m ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <math.h>
using namespace std ; bool checkPronic ( int x ) { for ( int i = 0 ; i <= ( int ) ( sqrt ( x ) ) ; i ++ ) if ( x == i * ( i + 1 ) ) return true ; return false ; } int main ( void ) { for ( int i = 0 ; i <= 200 ; i ++ ) if ( checkPronic ( i ) ) cout << i << " ▁ " ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinSum ( int num ) { int sum = 0 ; for ( int i = 2 ; i * i <= num ; i ++ ) { while ( num % i == 0 ) { sum += i ; num /= i ; } } sum += num ; return sum ; } int main ( ) { int num = 12 ; cout << findMinSum ( num ) ; return 0 ; }

Accumulator variables: i, num, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMin ( int sum ) { int a = 0 , b = 0 ; while ( sum > 0 ) { if ( sum % 7 == 0 ) { b ++ ; sum -= 7 ; } else if ( sum % 4 == 0 ) { a ++ ; sum -= 4 ; } else { a ++ ; sum -= 4 ; } } if ( sum < 0 ) { printf ( " - 1n " ) ; return ; } for ( int i = 0 ; i < a ; i ++ ) printf ( "4" ) ; for ( int i = 0 ; i < b ; i ++ ) printf ( "7" ) ; printf ( " n " ) ; } int main ( ) { findMin ( 15 ) ; return 0 ; }

Accumulator variables: a, b, i, stdc, sum
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int minNum ( int arr [ ] , int n ) { int odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 ) odd += 1 ; return ( odd % 2 ) ? 1 : 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, odd
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int printMaxNum ( int num ) { int count [ 10 ] = { 0 } ; string str = to_string ( num ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) count [ str [ i ] - '0' ] ++ ; int result = 0 , multiplier = 1 ; for ( int i = 0 ; i <= 9 ; i ++ ) { while ( count [ i ] > 0 ) { result = result + ( i * multiplier ) ; count [ i ] -- ; multiplier = multiplier * 10 ; } } return result ; } int main ( ) { int num = 38293367 ; cout << printMaxNum ( num ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string largestNumber ( string num ) { int n = num . size ( ) ; int rightMax [ n ] , right ; rightMax [ n - 1 ] = -1 ; right = n - 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( num [ i ] < num [ right ] ) rightMax [ i ] = right ; else { rightMax [ i ] = -1 ; right = i ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( rightMax [ i ] != -1 ) { swap ( num [ i ] , num [ rightMax [ i ] ] ) ; break ; } } return num ; } int main ( ) { string num = "8725634" ; cout << " Largest ▁ number : " << largestNumber ( num ) ; return 0 ; }

Index/key variables: i, n, right
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <cmath>
using namespace std ; int nCr ( int n , int r ) { if ( r > n / 2 ) r = n - r ; int answer = 1 ; for ( int i = 1 ; i <= r ; i ++ ) { answer *= ( n - r + i ) ; answer /= i ; } return answer ; } float binomialProbability ( int n , int k , float p ) { return nCr ( n , k ) * pow ( p , k ) * pow ( 1 - p , n - k ) ; } int main ( ) { int n = 10 ; int k = 5 ; float p = 1.0 / 3 ; float probability = binomialProbability ( n , k , p ) ; cout << " Probability ▁ of ▁ " << k ; cout << " ▁ heads ▁ when ▁ a ▁ coin ▁ is ▁ tossed ▁ " << n ; cout << " ▁ times ▁ where ▁ probability ▁ of ▁ each ▁ head ▁ is ▁ " << p << endl ; cout << " ▁ is ▁ = ▁ " << probability << endl ; }

Accumulator variables: answer, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxGCD ( int arr [ ] , int n ) { int high = 0 ; for ( int i = 0 ; i < n ; i ++ ) high = max ( high , arr [ i ] ) ; int divisors [ high + 1 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= sqrt ( arr [ i ] ) ; j ++ ) { if ( arr [ i ] % j == 0 ) { divisors [ j ] ++ ; if ( j != arr [ i ] / j ) divisors [ arr [ i ] / j ] ++ ; } } } for ( int i = high ; i >= 1 ; i -- ) if ( divisors [ i ] > 1 ) return i ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 8 , 8 , 12 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMaxGCD ( 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 findMaxGCD ( int arr [ ] , int n ) { int high = 0 ; for ( int i = 0 ; i < n ; i ++ ) high = max ( high , arr [ i ] ) ; int count [ high + 1 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) count [ arr [ i ] ] ++ ; int counter = 0 ; for ( int i = high ; i >= 1 ; i -- ) { int j = i ; counter = 0 ; while ( j <= high ) { if ( count [ j ] >= 2 ) return j ; else if ( count [ j ] == 1 ) counter ++ ; j += i ; if ( counter == 2 ) return i ; } } } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 8 , 8 , 12 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMaxGCD ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: counter, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountPairs ( int n ) { int k = n ; int imin = 1 ; int ans = 0 ; while ( imin <= n ) { int imax = n / k ; ans += k * ( imax - imin + 1 ) ; imin = imax + 1 ; k = n / imin ; } return ans ; } int main ( ) { cout << CountPairs ( 1 ) << endl ; cout << CountPairs ( 2 ) << endl ; cout << CountPairs ( 3 ) << endl ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long powermod ( long long x , long long y , long long p ) { while ( y > 0 ) { if ( y & 1LL ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } long long modInverse ( long long a , long long m ) { long long m0 = m , t , q ; long long x0 = 0 , x1 = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { q = a / m ; t = m ; m = a % m , a = t ; t = x0 ; x0 = x1 - q * x0 ; x1 = t ; } if ( x1 < 0 ) x1 += m0 ; return x1 ; } long long evaluteExpression ( long long & n ) { long long firstsum = 0 , mod = 10 ; for ( long long i = 2 , j = 0 ; ( 1LL << j ) <= n ; i *= i , ++ j ) firstsum = ( firstsum + i ) % mod ; long long secondsum = ( powermod ( 4LL , n + 1 , mod ) - 1 ) * modInverse ( 3LL , mod ) ; return ( firstsum * secondsum ) % mod ; } int main ( ) { long long n = 3 ; cout << evaluteExpression ( n ) << endl ; n = 10 ; cout << evaluteExpression ( n ) ; return 0 ; }

Accumulator variables: i, stdc, x1
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000001
#define pii  pair<int, int>
#define F  first
#define S  second
vector < pii > factors [ MAX ] ; void sieveOfEratothenese ( ) { bool isPrime [ MAX ] ; memset ( isPrime , true , sizeof ( isPrime ) ) ; isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( isPrime [ i ] ) { for ( int j = i ; j < MAX ; j += i ) { int k , l ; isPrime [ j ] = false ; for ( k = j , l = 0 ; k % i == 0 ; l ++ , k /= i ) ; factors [ j ] . push_back ( make_pair ( i , l ) ) ; } } } } int sumOfProperDivisors ( int num ) { int mul = 1 ; for ( int i = 0 ; i < factors [ num ] . size ( ) ; i ++ ) mul *= ( ( pow ( factors [ num ] [ i ] . F , factors [ num ] [ i ] . S + 1 ) - 1 ) / ( factors [ num ] [ i ] . F - 1 ) ) ; return mul - num ; } int main ( ) { sieveOfEratothenese ( ) ; int arr [ ] = { 8 , 13 , 24 , 36 , 59 , 75 , 91 } ; for ( int i = 0 ; i < sizeof ( arr ) / sizeof ( int ) ; i ++ ) cout << sumOfProperDivisors ( arr [ i ] ) << " ▁ " ; cout << endl ; return 0 ; }

Index/key variables: MAX, i, j, num
Accumulator variables: i, j, k, l, mul, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int PowerOFPINnfactorial ( int n , int p ) { int ans = 0 ; int temp = p ; while ( temp <= n ) { ans += n / temp ; temp = temp * p ; } return ans ; } int main ( ) { cout << PowerOFPINnfactorial ( 4 , 2 ) << endl ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; #define ull  unsigned long long int
int decimalToBinary ( int N ) { ull B_Number = 0 ; int cnt = 0 ; while ( N != 0 ) { int rem = N % 2 ; ull c = pow ( 10 , cnt ) ; B_Number += rem * c ; N /= 2 ; cnt ++ ; } return B_Number ; } int main ( ) { int N = 17 ; cout << decimalToBinary ( N ) ; return 0 ; }

Accumulator variables: B_Number, N, cnt
C++ program:
#include <iostream>
using namespace std ; int binaryToDecimal ( int n ) { int num = n ; int dec_value = 0 ; int base = 1 ; int temp = num ; while ( temp ) { int last_digit = temp % 10 ; temp = temp / 10 ; dec_value += last_digit * base ; base = base * 2 ; } return dec_value ; } int main ( ) { int num = 10101001 ; cout << binaryToDecimal ( num ) << endl ; }

Accumulator variables: dec_value
C++ program:
#include <bits/stdc++.h>
using namespace std ; long int stirlingFactorial ( int n ) { if ( n == 1 ) return 1 ; long int z ; z = sqrt ( 2 * 3.14 * n ) * pow ( ( n / e ) , n ) ; return z ; } int main ( ) { cout << stirlingFactorial ( 1 ) << endl ; cout << stirlingFactorial ( 2 ) << endl ; cout << stirlingFactorial ( 3 ) << endl ; cout << stirlingFactorial ( 4 ) << endl ; cout << stirlingFactorial ( 5 ) << endl ; cout << stirlingFactorial ( 6 ) << endl ; cout << stirlingFactorial ( 7 ) << endl ; return 0 ; }

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

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; long reverse ( long ) ; bool isPalindrome ( long ) ; static int MAX_ITERATIONS = 20 ; string isLychrel ( long number ) { for ( int i = 0 ; i < MAX_ITERATIONS ; i ++ ) { number = number + reverse ( number ) ; if ( isPalindrome ( number ) ) return " false " ; } return " true " ; } bool isPalindrome ( long number ) { return number == reverse ( number ) ; } long reverse ( long number ) { long reverse = 0 ; while ( number > 0 ) { long remainder = number % 10 ; reverse = ( reverse * 10 ) + remainder ; number = number / 10 ; } return reverse ; } int main ( ) { long number = 295 ; cout << number << " ▁ is ▁ lychrel ? ▁ " << isLychrel ( number ) ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_ITERATIONS = 10000 ; float f ( float x ) { return 1 * pow ( x , 3 ) + 2 * x * x + 10 * x - 20 ; } void Muller ( float a , float b , float c ) { int i ; float res ; for ( i = 0 ; ; ++ i ) { float f1 = f ( a ) ; float f2 = f ( b ) ; float f3 = f ( c ) ; float d1 = f1 - f3 ; float d2 = f2 - f3 ; float h1 = a - c ; float h2 = b - c ; float a0 = f3 ; float a1 = ( ( ( d2 * pow ( h1 , 2 ) ) - ( d1 * pow ( h2 , 2 ) ) ) / ( ( h1 * h2 ) * ( h1 - h2 ) ) ) ; float a2 = ( ( ( d1 * h2 ) - ( d2 * h1 ) ) / ( ( h1 * h2 ) * ( h1 - h2 ) ) ) ; float x = ( ( -2 * a0 ) / ( a1 + abs ( sqrt ( a1 * a1 - 4 * a0 * a2 ) ) ) ) ; float y = ( ( -2 * a0 ) / ( a1 - abs ( sqrt ( a1 * a1 - 4 * a0 * a2 ) ) ) ) ; if ( x >= y ) res = x + c ; else res = y + c ; float m = res * 100 ; float n = c * 100 ; m = floor ( m ) ; n = floor ( n ) ; if ( m == n ) break ; a = b ; b = c ; c = res ; if ( i > MAX_ITERATIONS ) { cout << " Root ▁ cannot ▁ be ▁ found ▁ using " << " ▁ Muller ' s ▁ method " ; break ; } } if ( i <= MAX_ITERATIONS ) cout << " The ▁ value ▁ of ▁ the ▁ root ▁ is ▁ " << res ; } int main ( ) { float a = 0 , b = 1 , c = 2 ; Muller ( a , b , c ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i