dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
#include <cmath>
using namespace std ; #define PI  3.1415926535
double findAnglesA ( double a , double b , double c ) { double A = acos ( ( b * b + c * c - a * a ) / ( 2 * b * c ) ) ; return A * 180 / PI ; } double findAnglesB ( double a , double b , double c ) { double B = acos ( ( a * a + c * c - b * b ) / ( 2 * a * c ) ) ; return B * 180 / PI ; } void printAngles ( int a , int b , int c ) { double x = ( double ) a ; double y = ( double ) b ; double z = ( double ) c ; double A = findAnglesA ( x , y , z ) ; double B = findAnglesB ( x , y , z ) ; cout << " Angles ▁ are ▁ A ▁ = ▁ " << A << " , ▁ B ▁ = ▁ " << B << " , ▁ C ▁ = ▁ " << 90 << endl ; } void printOtherSides ( int n ) { int b , c ; if ( n & 1 ) { if ( n == 1 ) cout << -1 << endl ; else { b = ( n * n - 1 ) / 2 ; c = ( n * n + 1 ) / 2 ; cout << " Side ▁ b ▁ = ▁ " << b << " , ▁ Side ▁ c ▁ = ▁ " << c << endl ; } } else { if ( n == 2 ) cout << -1 << endl ; else { b = n * n / 4 - 1 ; c = n * n / 4 + 1 ; cout << " Side ▁ b ▁ = ▁ " << b << " , ▁ Side ▁ c ▁ = ▁ " << c << endl ; } } printAngles ( n , b , c ) ; } int main ( ) { int a = 12 ; printOtherSides ( a ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkIfPowerIsolated ( int num ) { int input = num ; int count = 0 ; int factor [ num + 1 ] = { 0 } ; if ( num % 2 == 0 ) { while ( num % 2 == 0 ) { ++ count ; num /= 2 ; } factor [ 2 ] = count ; } for ( int i = 3 ; i * i <= num ; i += 2 ) { count = 0 ; while ( num % i == 0 ) { ++ count ; num /= i ; } if ( count > 0 ) factor [ i ] = count ; } if ( num > 1 ) factor [ num ] = 1 ; int product = 1 ; for ( int i = 0 ; i < num + 1 ; i ++ ) { if ( factor [ i ] > 0 ) product = product * factor [ i ] * i ; } if ( product == input ) cout << " Power - isolated ▁ Integer STRNEWLINE " ; else cout << " Not ▁ a ▁ Power - isolated ▁ Integer STRNEWLINE " ; } int main ( ) { checkIfPowerIsolated ( 12 ) ; checkIfPowerIsolated ( 18 ) ; checkIfPowerIsolated ( 35 ) ; return 0 ; }

Index/key variables: i, num
Accumulator variables: i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; ll findSum ( int n ) { ll sum2 , sum5 , sum10 ; sum2 = ( ( n / 2 ) * ( 4 + ( n / 2 - 1 ) * 2 ) ) / 2 ; sum5 = ( ( n / 5 ) * ( 10 + ( n / 5 - 1 ) * 5 ) ) / 2 ; sum10 = ( ( n / 10 ) * ( 20 + ( n / 10 - 1 ) * 10 ) ) / 2 ; return sum2 + sum5 - sum10 ; } int main ( ) { int n = 5 ; cout << findSum ( n ) << endl ; return 0 ; }

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 ; } void factors ( int N , vector < int > & v [ ] ) { for ( int i = 2 ; i < N ; i ++ ) { for ( int j = 1 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { if ( i / j == j ) v [ i ] . push_back ( j ) ; else { v [ i ] . push_back ( j ) ; v [ i ] . push_back ( i / j ) ; } } } sort ( v [ i ] . begin ( ) , v [ i ] . end ( ) ) ; } } int product ( int n ) { vector < int > v [ n + 100 ] ; factors ( n + 100 , v ) ; if ( n % 4 == 0 ) { int x = n / 4 ; x *= x ; return x * x ; } else { if ( isPrime [ n ] ) return -1 ; else { int ans = -1 ; if ( v [ n ] . size ( ) > 2 ) { int fac = v [ n ] [ v [ n ] . size ( ) - 3 ] ; for ( int i = v [ n ] . size ( ) - 1 ; i >= 0 ; i -- ) { for ( int j = v [ n ] . size ( ) - 1 ; j >= 0 ; j -- ) { if ( ( fac * 2 ) + ( v [ n ] [ j ] + v [ n ] [ i ] ) == n ) ans = max ( ans , fac * fac * v [ n ] [ j ] * v [ n ] [ i ] ) ; } } return ans ; } } } } int main ( ) { int n = 24 ; cout << product ( n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc, x
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; float CalculateRatio ( float m , float n ) { return ( 2 * m - 1 ) / ( 2 * n - 1 ) ; } int main ( ) { float m = 6 , n = 2 ; cout << CalculateRatio ( m , n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digSum ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } int powerDigitSum ( int a , int n ) { int res = 1 ; while ( n ) { if ( n % 2 == 1 ) { res = res * digSum ( a ) ; res = digSum ( res ) ; } a = digSum ( digSum ( a ) * digSum ( a ) ) ; n /= 2 ; } return res ; } int main ( ) { int a = 9 , n = 4 ; cout << powerDigitSum ( a , n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000005
vector < bool > prime ( MAX , true ) ; void sieve ( int N ) { prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i <= N ; i ++ ) { if ( prime [ i ] ) { for ( int j = 2 ; i * j <= N ; j ++ ) prime [ i * j ] = false ; } } } int countLogNeeded ( int N ) { int count = 0 ; sieve ( N ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( prime [ i ] ) count ++ ; } return count ; } int main ( ) { int N = 6 ; cout << countLogNeeded ( N ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int coin ( int totalRupees , int X , int Y , int Z ) { float one = 0 , fifty = 0 , twentyfive = 0 , result = 0 , total = 0 ; one = X * 1 ; fifty = ( ( Y * 1 ) / 2.0 ) ; twentyfive = ( ( Z * 1 ) / 4.0 ) ; total = one + fifty + twentyfive ; result = ( ( totalRupees ) / total ) ; return result ; } int main ( ) { int totalRupees = 1800 ; int X = 1 , Y = 2 , Z = 4 ; int Rupees = coin ( totalRupees , X , Y , Z ) ; cout << "1 ▁ rupess ▁ coins ▁ = ▁ " << Rupees * 1 << endl ; cout << "50 ▁ paisa ▁ coins ▁ = ▁ " << Rupees * 2 << endl ; cout << "25 ▁ paisa ▁ coins ▁ = ▁ " << Rupees * 4 << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float sumOfSeries ( int x , int k ) { return ( float ( x ) / 81 ) * ( 9 * k - 1 + pow ( 10 , ( -1 ) * k ) ) ; } int main ( ) { int x = 9 ; int k = 20 ; cout << sumOfSeries ( x , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findfactors ( int n ) { unordered_map < int , int > mpp ; vector < int > v , v1 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v . push_back ( i ) ; if ( i != ( n / i ) && i != 1 ) v . push_back ( n / i ) ; } } int s = v . size ( ) ; int maxi = -1 ; pair < int , int > mp1 [ n + 5 ] ; for ( int i = 0 ; i < s ; i ++ ) { for ( int j = i ; j < s ; j ++ ) { if ( v [ i ] + v [ j ] < n ) { v1 . push_back ( v [ i ] + v [ j ] ) ; mp1 [ v [ i ] + v [ j ] ] = { v [ i ] , v [ j ] } ; mpp [ v [ i ] + v [ j ] ] = 1 ; } } } s = v1 . size ( ) ; for ( int i = 0 ; i < s ; i ++ ) { int el = n - ( v1 [ i ] ) ; if ( mpp [ el ] == 1 ) { int a = mp1 [ v1 [ i ] ] . first ; int b = mp1 [ v1 [ i ] ] . second ; int c = mp1 [ n - v1 [ i ] ] . first ; int d = mp1 [ n - v1 [ i ] ] . second ; maxi = max ( a * b * c * d , maxi ) ; } } if ( maxi == -1 ) cout << " Not ▁ Possible STRNEWLINE " ; else { cout << " The ▁ maximum ▁ product ▁ is ▁ " << maxi << endl ; } } int main ( ) { int n = 50 ; findfactors ( n ) ; return 0 ; }

Index/key variables: el, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > factors ; void findFactors ( int n ) { for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( ( n / i ) == i ) factors . push_back ( i ) ; else { factors . push_back ( n / i ) ; factors . push_back ( i ) ; } } } } int findProduct ( int n ) { int product = -1 ; int si = factors . size ( ) ; for ( int i = 0 ; i < si ; i ++ ) for ( int j = 0 ; j < si ; j ++ ) for ( int k = 0 ; k < si ; k ++ ) for ( int l = 0 ; l < si ; l ++ ) { int s = factors [ i ] + factors [ j ] + factors [ k ] + factors [ l ] ; if ( s == n ) { int p = factors [ i ] * factors [ j ] * factors [ k ] * factors [ l ] ; if ( p > product ) product = p ; } } return product ; } int main ( ) { int n = 10 ; findFactors ( n ) ; cout << findProduct ( n ) ; return 0 ; }

Index/key variables: i, j, k, l
Accumulator variables: i, j, k, l, stdc
Iterator variables: i, j, k, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; int modExp ( int a , int b ) { int result = 1 ; while ( b > 0 ) { if ( b & 1 ) result = result * a ; a = a * a ; b /= 2 ; } return result ; } int check ( int num ) { if ( num & 1 num < 3 ) return -1 ; else if ( num % 4 == 0 ) return modExp ( num / 4 , 4 ) ; else if ( num % 6 == 0 ) return modExp ( num / 3 , 2 ) * modExp ( num / 6 , 2 ) ; else if ( num % 10 == 0 ) return modExp ( num / 5 , 2 ) * ( num / 10 ) * ( num / 2 ) ; else return -1 ; } int main ( ) { int num = 10 ; cout << check ( num ) ; return 0 ; }

Accumulator variables: b, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDivisible ( long long int n ) { while ( n / 100 ) { int d = n % 10 ; n /= 10 ; n -= d * 5 ; } return ( n % 17 == 0 ) ; } int main ( ) { long long int n = 19877658 ; if ( isDivisible ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned int nextPowerOf2 ( unsigned int n ) { unsigned count = 0 ; if ( n && ! ( n & ( n - 1 ) ) ) return n ; while ( n != 0 ) { n >>= 1 ; count += 1 ; } return 1 << count ; } int removeElement ( unsigned int n ) { if ( n == 1 n == 2 ) return 0 ; unsigned int a = nextPowerOf2 ( n ) ; if ( n == a n == a - 1 ) return 1 ; else if ( n == a - 2 ) return 0 ; else if ( n % 2 == 0 ) return 1 ; else return 2 ; } int main ( ) { unsigned int n = 5 ; cout << removeElement ( n ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bridge_length ( int trainLength , int Speed , int Time ) { return ( ( Time * Speed ) - trainLength ) ; } int main ( ) { int trainLength = 120 ; int Speed = 30 ; int Time = 18 ; cout << " Length ▁ of ▁ bridge ▁ = ▁ " << bridge_length ( trainLength , Speed , Time ) << " ▁ meters " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const long long MOD = 1000000007 ; long long modInv ( long long x ) { long long n = MOD - 2 ; long long result = 1 ; while ( n ) { if ( n & 1 ) result = result * x % MOD ; x = x * x % MOD ; n = n / 2 ; } return result ; } long long getSum ( long long n , long long k ) { long long ans = 1 ; for ( long long i = n + 1 ; i > n - k ; i -- ) ans = ans * i % MOD ; ans = ans * modInv ( k + 1 ) % MOD ; return ans ; } int main ( ) { long long n = 3 , k = 2 ; cout << getSum ( n , k ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printCombination ( int n ) { cout << 1 << " ▁ " ; if ( ( n - 2 ) % 3 == 0 ) cout << 2 << " ▁ " << n - 3 ; else cout << 1 << " ▁ " << n - 2 ; } int main ( ) { int n = 233 ; printCombination ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkPairs ( int l , int r ) { if ( ( l - r ) % 2 == 0 ) return false ; return true ; } int main ( ) { int l = 1 , r = 8 ; if ( checkPairs ( l , r ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( int n ) { if ( n % 11 == 0 ) { return true ; } return false ; } int main ( ) { isPalindrome ( 123321 ) ? cout << " Palindrome " : cout << " Not ▁ Palindrome " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int main ( ) { int target = 93 ; int arr [ ] = { 1 , 31 , 3 , 1 , 93 , 3 , 31 , 1 , 93 } ; int length = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int totalCount = 0 ; for ( int i = 0 ; i < length - 2 ; i ++ ) { if ( target % arr [ i ] == 0 ) { for ( int j = i + 1 ; j < length - 1 ; j ++ ) { if ( target % ( arr [ i ] * arr [ j ] ) == 0 ) { int toFind = target / ( arr [ i ] * arr [ j ] ) ; for ( int k = j + 1 ; k < length ; k ++ ) { if ( arr [ k ] == toFind ) { totalCount ++ ; } } } } } } cout << " Total ▁ number ▁ of ▁ triplets ▁ found ▁ : ▁ " << totalCount ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, totalCount
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isFascinating ( int num ) { int freq [ 10 ] = { 0 } ; string val = " " + to_string ( num ) + to_string ( num * 2 ) + to_string ( num * 3 ) ; for ( int i = 0 ; i < val . length ( ) ; i ++ ) { int digit = val [ i ] - '0' ; if ( freq [ digit ] and digit != 0 > 0 ) return false ; else freq [ digit ] ++ ; } for ( int i = 1 ; i < 10 ; i ++ ) { if ( freq [ i ] == 0 ) return false ; } return true ; } int main ( ) { int num = 192 ; if ( num < 100 ) cout << " No " << endl ; else { bool ans = isFascinating ( num ) ; if ( ans ) cout << " Yes " ; else cout << " No " ; } }

Index/key variables: digit, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomial_coefficient ( int n , int m ) { int res = 1 ; if ( m > n - m ) m = n - m ; for ( int i = 0 ; i < m ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } int calculate_ways ( int m , int n ) { if ( m < n ) return 0 ; int ways = binomial_coefficient ( n + m - 1 , n - 1 ) ; return ways ; } int main ( ) { int m = 7 , n = 5 ; int result = calculate_ways ( m , n ) ; printf ( " % d STRNEWLINE " , result ) ; return 0 ; }

Accumulator variables: res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
int phi [ N ] ; int S [ N ] ; void computeTotient ( ) { for ( int i = 1 ; i < N ; i ++ ) phi [ i ] = i ; for ( int p = 2 ; p < N ; p ++ ) { if ( phi [ p ] == p ) { phi [ p ] = p - 1 ; for ( int i = 2 * p ; i < N ; i += p ) { phi [ i ] = ( phi [ i ] / p ) * ( p - 1 ) ; } } } } void CoPrimes ( ) { computeTotient ( ) ; for ( int i = 1 ; i < N ; i ++ ) S [ i ] = S [ i - 1 ] + phi [ i ] ; } int main ( ) { CoPrimes ( ) ; int q [ ] = { 3 , 4 } ; int n = sizeof ( q ) / sizeof ( q [ 0 ] ) ; for ( int i = 0 ; i < n ; i ++ ) cout << " Number ▁ of ▁ unordered ▁ coprime STRNEWLINE " << " pairs ▁ of ▁ integers ▁ from ▁ 1 ▁ to ▁ " << q [ i ] << " ▁ are ▁ " << S [ q [ i ] ] << endl ; return 0 ; }

Index/key variables: N, i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binaryToDecimal ( string n ) { string num = n ; int dec_value = 0 ; int base = 1 ; int len = num . length ( ) ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( num [ i ] == '1' ) dec_value += base ; base = base * 2 ; } return dec_value ; } int numberSequence ( int n ) { if ( n == 1 ) return 1 ; string s = " " ; for ( int i = 1 ; i < n ; i ++ ) s += '1' ; s += '0' ; for ( int i = 1 ; i <= n ; i ++ ) s += '1' ; int num = binaryToDecimal ( s ) ; return num ; } int main ( ) { int n = 4 ; cout << numberSequence ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: dec_value, i, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberSequence ( int n ) { int num = pow ( 4 , n ) - pow ( 2 , n ) - 1 ; return num ; } int main ( ) { int n = 4 ; cout << numberSequence ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int prime ( int num ) { int i , flag = 0 ; for ( i = 2 ; i <= num / 2 ; i ++ ) { if ( num % i == 0 ) { flag = 1 ; break ; } } if ( flag == 0 ) return 1 ; else return 0 ; } void print_alternate_prime ( int n ) { int counter = 0 ; for ( int num = 2 ; num < n ; num ++ ) { if ( prime ( num ) == 1 ) { if ( counter % 2 == 0 ) cout << num << " ▁ " ; counter ++ ; } } } int main ( ) { int n = 15 ; cout << " Following ▁ are ▁ the ▁ alternate ▁ prime " << " ▁ number ▁ smaller ▁ than ▁ or ▁ equal ▁ to ▁ " << n << endl ; print_alternate_prime ( n ) ; }

Accumulator variables: counter, i, num, stdc
Iterator variables: i, num
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SieveOfEratosthenes ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } bool flag = true ; for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { if ( flag ) { cout << p << " ▁ " ; flag = false ; } else { flag = true ; } } } } int main ( ) { int n = 15 ; cout << " Following ▁ are ▁ the ▁ alternate " << " ▁ prime ▁ numbers ▁ smaller ▁ " << " ▁ than ▁ or ▁ equal ▁ to ▁ " << n << endl ; SieveOfEratosthenes ( n ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findGreater ( int x , int y ) { if ( x > y ) { return false ; } else { return true ; } } int main ( ) { int x = 4 ; int y = 9 ; findGreater ( x , y ) ? cout << "1 STRNEWLINE " : cout << "2 STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int max_profit ( int a [ ] , int b [ ] , int n , int fee ) { int i , j , profit ; int l , r , diff_day = 1 , sum = 0 ; b [ 0 ] = 0 ; b [ 1 ] = diff_day ; for ( i = 1 ; i < n ; i ++ ) { l = 0 ; r = diff_day ; sum = 0 ; for ( j = n - 1 ; j >= i ; j -- ) { profit = ( a [ r ] - a [ l ] ) - fee ; if ( profit > 0 ) { sum = sum + profit ; } l ++ ; r ++ ; } if ( b [ 0 ] < sum ) { b [ 0 ] = sum ; b [ 1 ] = diff_day ; } diff_day ++ ; } return 0 ; } int main ( ) { int arr [ ] = { 6 , 1 , 7 , 2 , 8 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int b [ 2 ] ; int tranFee = 2 ; max_profit ( arr , b , n , tranFee ) ; cout << b [ 0 ] << " , ▁ " << b [ 1 ] << endl ; return 0 ; }

Index/key variables: l, r
Accumulator variables: diff_day, i, j, l, r, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int x , int n , int k ) { int sum = 0 , term = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { term *= x - i + 1 ; term /= i ; sum += term ; if ( sum > k ) return sum ; } return sum ; } int minTrials ( int n , int k ) { int low = 1 , high = k ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( binomialCoeff ( mid , n , k ) < k ) low = mid + 1 ; else high = mid ; } return low ; } int main ( ) { cout << minTrials ( 2 , 10 ) ; return 0 ; }

Accumulator variables: stdc, sum, term
Iterator variables: i
C++ program:
#include <iostream>
#include <string>
using namespace std ; bool isPrime ( int num ) { if ( num < 2 num % 2 == 0 ) return num == 2 ; for ( int i = 3 ; i * i <= num ; i += 2 ) if ( num % i == 0 ) return false ; return true ; } int primePalindrome ( int N ) { if ( 8 <= N && N <= 11 ) return 11 ; for ( int x = 1 ; x < 100000 ; ++ x ) { string s = to_string ( x ) , r ( s . rbegin ( ) , s . rend ( ) ) ; int y = stoi ( s + r . substr ( 1 ) ) ; if ( y >= N && isPrime ( y ) ) return y ; } return -1 ; } int main ( ) { cout << primePalindrome ( 112 ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getsum ( int a ) { int r = 0 , sum = 0 ; while ( a > 0 ) { r = a % 10 ; sum = sum + r ; a = a / 10 ; } return sum ; } void value ( int a , int b , int c ) { int co = 0 , p = 0 ; int no , r = 0 , x = 0 , q = 0 , w = 0 ; vector < int > v ; for ( int i = 1 ; i < 82 ; i ++ ) { no = pow ( ( double ) i , double ( a ) ) ; no = b * no + c ; if ( no > 0 && no < 1000000000 ) { x = getsum ( no ) ; if ( x == i ) { q ++ ; v . push_back ( no ) ; w ++ ; } } } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { cout << v [ i ] << " ▁ " ; } } int main ( ) { int a = 2 , b = 2 , c = -1 ; value ( a , b , c ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, q, stdc, w
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print ( int p0 ) { int p1 , i = 0 , x , flag , k ; while ( 1 ) { flag = 1 ; x = ( int ) ( pow ( 2 , i ) ) ; p1 = x * p0 - ( x - 1 ) ; for ( k = 2 ; k < p1 ; k ++ ) { if ( p1 % k == 0 ) { flag = 0 ; break ; } } if ( flag == 0 ) break ; printf ( " % d ▁ " , p1 ) ; i ++ ; } } int main ( ) { int p0 = 19 ; print ( p0 ) ; return 0 ; }

Accumulator variables: i, k, stdc
Iterator variables: k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countTriangles ( int p ) { vector < pair < int , int > > store ; if ( p % 2 != 0 ) return 0 ; else { int count = 1 ; for ( int b = 1 ; b < p / 2 ; b ++ ) { float a = ( float ) p / 2.0f * ( ( float ) ( ( float ) p - 2.0 * ( float ) b ) / ( ( float ) p - ( float ) b ) ) ; int inta = ( int ) ( a ) ; if ( a == inta ) { pair < int , int > ab ; if ( inta < b ) { ab = { inta , b } ; } else { ab = { b , inta } ; } if ( find ( store . begin ( ) , store . end ( ) , ab ) == store . end ( ) ) { count += 1 ; store . push_back ( ab ) ; } } } return count ; } } int main ( ) { int p = 840 ; cout << " number ▁ of ▁ right ▁ triangles ▁ = ▁ " << countTriangles ( p ) ; return 0 ; }

Accumulator variables: b, count, stdc
Iterator variables: b
C++ program:
#include <iostream>
using namespace std ; int findOddPair ( int A [ ] , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( ( A [ i ] % 2 == 1 ) ) count ++ ; return count * ( count - 1 ) / 2 ; } int main ( ) { int a [ ] = { 5 , 1 , 3 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findOddPair ( a , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSurd ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { int j = i ; while ( j < n ) j = j * i ; if ( j == n ) return false ; } return true ; } int main ( ) { int n = 15 ; if ( isSurd ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LastTwoDigit ( long long int num ) { int one = num % 10 ; num /= 10 ; int tens = num % 10 ; tens *= 10 ; num = tens + one ; return num ; } int main ( ) { int n = 10 ; long long int num = 1 ; num = pow ( 2 , n ) ; cout << " Last ▁ " << 2 ; cout << " ▁ digits ▁ of ▁ " << 2 ; cout << " ^ " << n << " ▁ = ▁ " ; cout << LastTwoDigit ( num ) << endl ; return 0 ; }

Accumulator variables: num, stdc, tens
C++ program:
#include <iostream>
using namespace std ; int power ( long long int x , long long int y , long long int p ) { while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } int numberOfDigits ( int x ) { int i = 0 ; while ( x ) { x /= 10 ; i ++ ; } return i ; } void LastTwoDigit ( int n ) { cout << " Last ▁ " << 2 ; cout << " ▁ digits ▁ of ▁ " << 2 ; cout << " ^ " << n << " ▁ = ▁ " ; int temp = 1 ; for ( int i = 1 ; i <= 2 ; i ++ ) temp *= 10 ; temp = power ( 2 , n , temp ) ; for ( int i = 0 ; i < 2 - numberOfDigits ( temp ) ; i ++ ) cout << 0 ; if ( temp ) cout << temp ; } int main ( ) { int n = 72 ; LastTwoDigit ( n ) ; return 0 ; }

Accumulator variables: i, temp, x
Iterator variables: i