dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printNum ( int n , int k ) { int x = __builtin_popcount ( n ) ; if ( k < x k > n ) { cout << " - 1" ; return ; } priority_queue < int > pq ; int two = 1 ; while ( n ) { if ( n & 1 ) { pq . push ( two ) ; } two = two * 2 ; n = n >> 1 ; } while ( pq . size ( ) < k ) { int el = pq . top ( ) ; pq . pop ( ) ; pq . push ( el / 2 ) ; pq . push ( el / 2 ) ; } int ind = 0 ; while ( ind < k ) { cout << pq . top ( ) << " ▁ " ; pq . pop ( ) ; ind ++ ; } } int main ( ) { int n = 9 , k = 4 ; printNum ( n , k ) ; return 0 ; }

Accumulator variables: ind, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define n  1000002
#define ll  long long int
ll phi [ n + 2 ] , ans [ n + 2 ] ; void ETF ( ) { for ( int i = 1 ; i <= n ; i ++ ) { phi [ i ] = i ; } for ( int i = 2 ; i <= n ; i ++ ) { if ( phi [ i ] == i ) { phi [ i ] = i - 1 ; for ( int j = 2 * i ; j <= n ; j += i ) { phi [ j ] = ( phi [ j ] * ( i - 1 ) ) / i ; } } } } ll LcmSum ( int m ) { ETF ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i ; j <= n ; j += i ) { ans [ j ] += ( i * phi [ i ] ) ; } } ll answer = ans [ m ] ; answer = ( answer + 1 ) * m ; answer = answer / 2 ; return answer ; } int main ( ) { int m = 5 ; cout << LcmSum ( m ) ; return 0 ; }

Index/key variables: i, j, m
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int n ) { int fact = 1 ; for ( int i = 2 ; i <= n ; i ++ ) fact = fact * i ; return fact ; } int ncr ( int n , int r ) { return factorial ( n ) / ( factorial ( r ) * factorial ( n - r ) ) ; } int countWays ( string str ) { int freq [ 26 ] = { 0 } ; int nvowels = 0 , nconsonants = 0 ; int vplaces , cways , vways ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) ++ freq [ str [ i ] - ' a ' ] ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( i == 0 i == 4 i == 8 i == 14 i == 20 ) nvowels += freq [ i ] ; else nconsonants += freq [ i ] ; } vplaces = nconsonants + 1 ; cways = factorial ( nconsonants ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( i != 0 && i != 4 && i != 8 && i != 14 && i != 20 && freq [ i ] > 1 ) { cways = cways / factorial ( freq [ i ] ) ; } } vways = ncr ( vplaces , nvowels ) * factorial ( nvowels ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( i == 0 i == 4 i == 8 i == 14 i == 20 && freq [ i ] > 1 ) { vways = vways / factorial ( freq [ i ] ) ; } } return cways * vways ; } int main ( ) { string str = " permutation " ; cout << countWays ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, nconsonants, nvowels, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int setBits ( int n ) { int count = 0 ; while ( n ) { n = n & ( n - 1 ) ; count ++ ; } return count ; } int countPairs ( int a [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int setbits_x = setBits ( a [ i ] ) ; for ( int j = i + 1 ; j < n ; j ++ ) { int setbits_y = setBits ( a [ j ] ) ; int setbits_xor_xy = setBits ( a [ i ] ^ a [ j ] ) ; if ( setbits_x + setbits_y == setbits_xor_xy ) count ++ ; } } return count ; } int main ( ) { int a [ ] = { 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << countPairs ( a , n ) ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
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 findPossibleDerivables ( int arr [ ] , int n , int D , int A , int B ) { int gcdAB = gcd ( A , B ) ; int counter = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( abs ( arr [ i ] - D ) % gcdAB ) == 0 ) { counter ++ ; } } return counter ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 7 , 13 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int D = 5 , A = 4 , B = 2 ; cout << findPossibleDerivables ( arr , n , D , A , B ) << " STRNEWLINE " ; int a [ ] = { 1 , 2 , 3 } ; n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; D = 6 , A = 3 , B = 2 ; cout << findPossibleDerivables ( a , n , D , A , B ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: counter, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calSum ( int n ) { return ( n * ( 2 * n * n * n + 12 * n * n + 25 * n + 21 ) ) / 2 ; } int main ( ) { int n = 3 ; cout << calSum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void getElements ( int a , int arr [ ] , int n ) { int elements [ n + 1 ] ; elements [ 0 ] = a ; for ( int i = 0 ; i < n ; i ++ ) { elements [ i + 1 ] = arr [ i ] ^ elements [ i ] ; } for ( int i = 0 ; i < n + 1 ; i ++ ) cout << elements [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 13 , 2 , 6 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int a = 5 ; getElements ( a , arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxGCD ( int N , int P ) { int ans = 1 ; unordered_map < int , int > prime_factors ; for ( int i = 2 ; i * i <= P ; i ++ ) { while ( P % i == 0 ) { prime_factors [ i ] ++ ; P /= i ; } } if ( P != 1 ) prime_factors [ P ] ++ ; for ( auto v : prime_factors ) ans *= pow ( v . first , v . second / N ) ; return ans ; } int main ( ) { int N = 3 , P = 24 ; cout << maxGCD ( N , P ) ; return 0 ; }

Index/key variables: P, i
Accumulator variables: P, ans, i, stdc
Iterator variables: i, v
C++ program:
#include <iostream>
using namespace std ; int distinctDigitSum ( int n ) { bool used [ 10 ] ; int sum = 0 ; while ( n > 0 ) { int digit = n % 10 ; if ( ! used [ digit ] ) { used [ digit ] = true ; sum += digit ; } n = ( int ) n / 10 ; } return sum ; } string checkSum ( int m , int n ) { int sumM = distinctDigitSum ( m ) ; int sumN = distinctDigitSum ( n ) ; if ( sumM != sumN ) return " YES " ; return " NO " ; } int main ( ) { int m = 2452 , n = 9222 ; cout << ( checkSum ( m , n ) ) ; return 0 ; }

Index/key variables: digit
Accumulator variables: sum
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 ; } int countPairs ( int a [ ] , int n ) { int count = 0 ; unordered_map < int , int > m ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( isPrime ( a [ i ] ^ a [ j ] ) && m [ a [ i ] ^ a [ j ] ] == 0 ) { m [ ( a [ i ] ^ a [ j ] ) ] ++ ; count ++ ; } } } return count ; } int main ( ) { int a [ ] = { 10 , 12 , 23 , 45 , 5 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << countPairs ( a , n ) ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAXN  1000001
int spf [ MAXN ] ; void sieve ( ) { spf [ 1 ] = 1 ; for ( int i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } int sumFactors ( int arr [ ] , int n ) { sieve ( ) ; std :: map < int , int > map ; for ( int i = 0 ; i < n ; ++ i ) map [ arr [ i ] ] = 1 ; int sum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int num = arr [ i ] ; while ( num != 1 && map [ spf [ num ] ] == 1 ) { num /= spf [ num ] ; } if ( num == 1 ) sum += arr [ i ] ; } return sum ; } int main ( ) { int arr [ ] = { 5 , 11 , 55 , 25 , 100 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << sumFactors ( arr , n ) ; return 0 ; }

Index/key variables: MAXN, i, j, num
Accumulator variables: i, j, num, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int doubleFactorial ( int n ) { int fact = 1 ; for ( int i = 1 ; i <= n ; i = i + 2 ) { fact = fact * i ; } return fact ; } int hermiteNumber ( int n ) { if ( n % 2 == 1 ) return 0 ; else { int number = ( pow ( 2 , n / 2 ) ) * doubleFactorial ( n - 1 ) ; if ( ( n / 2 ) % 2 == 1 ) number = number * -1 ; return number ; } } int main ( ) { int n = 6 ; cout << hermiteNumber ( n ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  1000005
#define MAX  1e18
vector < long int > powers ; set < long int > squares ; set < long int > s ; void powersPrecomputation ( ) { for ( long int i = 2 ; i < N ; i ++ ) { squares . insert ( i * i ) ; if ( squares . find ( i ) != squares . end ( ) ) continue ; long int temp = i ; while ( i * i <= MAX / temp ) { temp *= ( i * i ) ; s . insert ( temp ) ; } } for ( auto x : s ) powers . push_back ( x ) ; } long int calculateAnswer ( long int L , long int R ) { powersPrecomputation ( ) ; long int perfectSquares = floor ( sqrtl ( R ) ) - floor ( sqrtl ( L - 1 ) ) ; long int high = upper_bound ( powers . begin ( ) , powers . end ( ) , R ) - powers . begin ( ) ; long int low = lower_bound ( powers . begin ( ) , powers . end ( ) , L ) - powers . begin ( ) ; long perfectPowers = perfectSquares + ( high - low ) ; long ans = ( R - L + 1 ) - perfectPowers ; return ans ; } int main ( ) { long int L = 13 , R = 20 ; cout << calculateAnswer ( L , R ) ; return 0 ; }

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

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int N ) { for ( int i = 2 ; i <= sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) return false ; } return true ; } int getDifference ( int N ) { if ( N == 0 ) return 2 ; else if ( N == 1 ) return 1 ; else if ( isPrime ( N ) ) return 0 ; int aboveN = -1 , belowN = -1 ; int n1 ; n1 = N + 1 ; while ( true ) { if ( isPrime ( n1 ) ) { aboveN = n1 ; break ; } else n1 ++ ; } n1 = N - 1 ; while ( true ) { if ( isPrime ( n1 ) ) { belowN = n1 ; break ; } else n1 -- ; } int diff1 = aboveN - N ; int diff2 = N - belowN ; return min ( diff1 , diff2 ) ; } int main ( ) { int N = 25 ; cout << getDifference ( N ) << endl ; return 0 ; }

Accumulator variables: i, n1, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int arr [ ] , int x , int n ) { long long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { double x = sqrt ( arr [ i ] ) ; if ( floor ( x ) == ceil ( x ) ) { sum += arr [ i ] ; } } if ( sum % x == 0 ) return true ; else return false ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 9 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int x = 13 ; if ( check ( arr , x , n ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 1e5 ; int findLargestDivisor ( int n ) { int m = n ; set < int , greater < int > > s ; s . insert ( 1 ) ; s . insert ( n ) ; for ( int i = 2 ; i < sqrt ( n ) + 1 ; i ++ ) { if ( n % i == 0 ) { s . insert ( n / i ) ; s . insert ( i ) ; while ( m % i == 0 ) m /= i ; } } if ( m > 1 ) s . insert ( m ) ; vector < int > vec ; for ( int i = 2 ; i <= MAX ; i ++ ) vec . push_back ( i * i ) ; for ( auto d : s ) { int divi = 0 ; for ( int j = 0 ; j < vec . size ( ) && vec [ j ] <= d ; j ++ ) { if ( d % vec [ j ] == 0 ) { divi = 1 ; break ; } } if ( ! divi ) return d ; } } int main ( ) { int n = 12 ; cout << findLargestDivisor ( n ) << endl ; n = 97 ; cout << findLargestDivisor ( n ) << endl ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, m, stdc
Iterator variables: d, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int NCR ( int n , int r ) { int numerator = 1 ; int denominator = 1 ; while ( r > 0 ) { numerator *= n ; denominator *= r ; n -- ; r -- ; } return ( numerator / denominator ) ; } int findWays ( int arr [ ] , int n ) { map < int , int > count ; if ( n < 4 ) return 0 ; for ( int i = 0 ; i < n ; i ++ ) { count [ arr [ i ] ] ++ ; } int remaining_choices = 4 ; int ans = 1 ; for ( auto iter = count . rbegin ( ) ; iter != count . rend ( ) ; ++ iter ) { int number = iter -> first ; int frequency = iter -> second ; int toSelect = min ( remaining_choices , frequency ) ; ans = ans * NCR ( frequency , toSelect ) ; remaining_choices -= toSelect ; if ( ! remaining_choices ) { break ; } } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 , 3 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int maxQuadrupleWays = findWays ( arr , n ) ; cout << maxQuadrupleWays ; return 0 ; }

Index/key variables: i
Accumulator variables: denominator, i, n, numerator, r, remaining_choices, stdc
Iterator variables: i, iter
C++ program:
#include <bits/stdc++.h>
using namespace std ; void MinimumMaximumPairs ( int n , int m ) { int max_pairs = ( ( n - m + 1 ) * ( n - m ) ) / 2 ; int min_pairs = m * ( ( ( n - m ) / m + 1 ) * ( ( n - m ) / m ) ) / 2 + ceil ( ( n - m ) / double ( m ) ) * ( ( n - m ) % m ) ; cout << " Minimum ▁ no . ▁ of ▁ pairs ▁ = ▁ " << min_pairs << " STRNEWLINE " ; cout << " Maximum ▁ no . ▁ of ▁ pairs ▁ = ▁ " << max_pairs << " STRNEWLINE " ; } int main ( ) { int n = 5 , m = 2 ; MinimumMaximumPairs ( n , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findGreater ( int a , int b ) { long double x = ( long double ) a * ( long double ) ( log ( ( long double ) ( b ) ) ) ; long double y = ( long double ) b * ( long double ) ( log ( ( long double ) ( a ) ) ) ; if ( y > x ) { cout << " a ^ b ▁ is ▁ greater " << endl ; } else if ( y < x ) { cout << " b ^ a ▁ is ▁ greater " << endl ; } else { cout << " Both ▁ are ▁ equal " << endl ; } } int main ( ) { int a = 3 , b = 5 , c = 2 , d = 4 ; findGreater ( a , b ) ; findGreater ( c , d ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
#define m  1000000007
int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } ll modexp ( ll x , ll n ) { if ( n == 0 ) { return 1 ; } else if ( n % 2 == 0 ) { return modexp ( ( x * x ) % m , n / 2 ) ; } else { return ( x * modexp ( ( x * x ) % m , ( n - 1 ) / 2 ) % m ) ; } } ll getFractionModulo ( ll a , ll b ) { ll c = gcd ( a , b ) ; a = a / c ; b = b / c ; ll d = modexp ( b , m - 2 ) ; ll ans = ( ( a % m ) * ( d % m ) ) % m ; return ans ; } int main ( ) { ll a = 2 , b = 6 ; cout << getFractionModulo ( a , b ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; int maxPrimeFactors ( int n ) { int num = n ; int maxPrime = -1 ; while ( n % 2 == 0 ) { maxPrime = 2 ; n /= 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { maxPrime = i ; n = n / i ; } } if ( n > 2 ) maxPrime = n ; int sum = maxPrime + num ; return sum ; } int main ( ) { int n = 19 ; cout << maxPrimeFactors ( n ) ; return 0 ; }

Accumulator variables: i, n
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int sumOfDigits ( int n ) { int res = 0 ; while ( n > 0 ) { res += n % 10 ; n /= 10 ; } return res ; } int findNumber ( int n ) { int i = n - 1 ; while ( i > 0 ) { if ( sumOfDigits ( i ) > sumOfDigits ( n ) ) return i ; i -- ; } return -1 ; } int main ( ) { int n = 824 ; cout << findNumber ( n ) ; return 0 ; }

Accumulator variables: i, n, res
C++ program:
#include <iostream>
using namespace std ; int findNth ( int N ) { int b = 14 ; int i ; for ( i = 2 ; i <= N ; i ++ ) { if ( i % 2 == 0 ) b = b * 2 ; else b = b - 8 ; } return b ; } int main ( ) { int N = 6 ; cout << findNth ( N ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; #define N  4
void predictMatrix ( int arr [ N ] [ N ] , int range1a , int range1b , int range0a , int range0b , int K , int b [ N ] [ N ] ) { int c = 0 ; while ( K -- ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { c = 0 ; if ( i > 0 && arr [ i - 1 ] [ j ] == 1 ) c ++ ; if ( j > 0 && arr [ i ] [ j - 1 ] == 1 ) c ++ ; if ( i > 0 && j > 0 && arr [ i - 1 ] [ j - 1 ] == 1 ) c ++ ; if ( i < N - 1 && arr [ i + 1 ] [ j ] == 1 ) c ++ ; if ( j < N - 1 && arr [ i ] [ j + 1 ] == 1 ) c ++ ; if ( i < N - 1 && j < N - 1 && arr [ i + 1 ] [ j + 1 ] == 1 ) c ++ ; if ( i < N - 1 && j > 0 && arr [ i + 1 ] [ j - 1 ] == 1 ) c ++ ; if ( i > 0 && j < N - 1 && arr [ i - 1 ] [ j + 1 ] == 1 ) c ++ ; if ( arr [ i ] [ j ] == 1 ) { if ( c >= range1a && c <= range1b ) b [ i ] [ j ] = 1 ; else b [ i ] [ j ] = 0 ; } if ( arr [ i ] [ j ] == 0 ) { if ( c >= range0a && c <= range0b ) b [ i ] [ j ] = 1 ; else b [ i ] [ j ] = 0 ; } } } for ( int k = 0 ; k < N ; k ++ ) for ( int m = 0 ; m < N ; m ++ ) arr [ k ] [ m ] = b [ k ] [ m ] ; } } int main ( ) { int arr [ N ] [ N ] = { 0 , 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 , 1 } ; int range1a = 2 , range1b = 2 ; int range0a = 2 , range0b = 3 ; int K = 3 , b [ N ] [ N ] = { 0 } ; predictMatrix ( arr , range1a , range1b , range0a , range0b , K , b ) ; for ( int i = 0 ; i < N ; i ++ ) { cout << endl ; for ( int j = 0 ; j < N ; j ++ ) cout << b [ i ] [ j ] << " ▁ " ; } return 0 ; }

Index/key variables: N, i, j, k, m
Accumulator variables: K, c, i, j, k, m
Iterator variables: i, j, k, m
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMoves ( int n ) { int ct = 0 ; for ( int i = 1 ; i <= n ; i ++ ) ct += i * ( n - i ) ; ct += n ; return ct ; } int main ( ) { int n = 3 ; cout << countMoves ( n ) ; return 0 ; }

Accumulator variables: ct, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > getPerfectSquares ( int n ) { vector < int > perfectSquares ; int current = 1 , i = 1 ; while ( current <= n ) { perfectSquares . push_back ( current ) ; current = pow ( ++ i , 2 ) ; } return perfectSquares ; } int countTriplets ( int n ) { vector < int > perfectSquares = getPerfectSquares ( pow ( n , 2 ) ) ; int count = 0 ; for ( int a = 1 ; a <= n ; a ++ ) { int aSquare = pow ( a , 2 ) ; for ( int i = 0 ; i < perfectSquares . size ( ) ; i ++ ) { int cSquare = perfectSquares [ i ] ; int bSquare = abs ( cSquare - aSquare ) ; int b = sqrt ( bSquare ) ; int c = sqrt ( cSquare ) ; if ( c < a || ( find ( perfectSquares . begin ( ) , perfectSquares . end ( ) , bSquare ) == perfectSquares . end ( ) ) ) continue ; if ( ( b >= a ) && ( b <= c ) && ( aSquare + bSquare == cSquare ) ) count ++ ; } } return count ; } int main ( ) { int n = 10 ; cout << countTriplets ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, count, i, stdc
Iterator variables: a, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int N ) { return ( pow ( 10 , N ) - 1 ) - ( pow ( 10 , N ) - pow ( 8 , N ) ) / 2 ; } int main ( ) { int n = 2 ; cout << countNumbers ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define N  3
using namespace std ; int calcDeterminant ( int arr [ ] ) { int determinant = 0 ; for ( int i = 0 ; i < N ; i ++ ) { determinant += pow ( arr [ i ] , 3 ) ; } determinant -= 3 * arr [ 0 ] * arr [ 1 ] * arr [ 2 ] ; return determinant ; } int main ( ) { int arr [ ] = { 4 , 5 , 3 } ; cout << calcDeterminant ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: determinant, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumMoves ( int k , int l , int r ) { int count = r - l + 1 ; if ( count % k == 0 ) return 0 ; return ( k - ( count % k ) ) ; } int main ( ) { int k = 3 , l = 10 , r = 10 ; cout << minimumMoves ( k , l , r ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumNatural ( int n ) { int sum = ( n * ( n + 1 ) ) ; return sum ; } int sumEven ( int l , int r ) { return sumNatural ( r / 2 ) - sumNatural ( ( l - 1 ) / 2 ) ; } int main ( ) { int l = 2 , r = 5 ; cout << " Sum ▁ of ▁ Natural ▁ numbers ▁ from ▁ L ▁ to ▁ R ▁ is ▁ " << sumEven ( l , r ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDivisibleRec ( int x , int a , int b , int n ) { if ( x > n ) return false ; if ( n % x == 0 ) return true ; return ( isDivisibleRec ( x * 10 + a , a , b , n ) || isDivisibleRec ( x * 10 + b , a , b , n ) ) ; } bool isDivisible ( int a , int b , int n ) { return isDivisibleRec ( a , a , b , n ) || isDivisibleRec ( b , a , b , n ) ; } int main ( ) { int a = 3 , b = 5 , n = 53 ; if ( isDivisible ( a , b , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void MinSteps ( int SourceX , int SourceY , int DestX , int DestY ) { cout << max ( abs ( SourceX - DestX ) , abs ( SourceY - DestY ) ) << endl ; while ( ( SourceX != DestX ) || ( SourceY != DestY ) ) { if ( SourceX < DestX ) { cout << ' U ' ; SourceX ++ ; } if ( SourceX > DestX ) { cout << ' D ' ; SourceX -- ; } if ( SourceY > DestY ) { cout << ' L ' ; SourceY -- ; } if ( SourceY < DestY ) { cout << ' R ' ; SourceY ++ ; } cout << endl ; } } int main ( ) { int sourceX = 4 , sourceY = 4 ; int destinationX = 7 , destinationY = 0 ; MinSteps ( sourceX , sourceY , destinationX , destinationY ) ; return 0 ; }

Accumulator variables: SourceX, SourceY, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > getPerfectSquares ( int n ) { vector < int > perfectSquares ; int current = 1 , i = 1 ; while ( current <= n ) { perfectSquares . push_back ( current ) ; current = static_cast < int > ( pow ( ++ i , 2 ) ) ; } return perfectSquares ; } int maxPairSum ( vector < int > & arr ) { int n = arr . size ( ) ; int max , secondMax ; if ( arr [ 0 ] > arr [ 1 ] ) { max = arr [ 0 ] ; secondMax = arr [ 1 ] ; } else { max = arr [ 1 ] ; secondMax = arr [ 0 ] ; } for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { secondMax = max ; max = arr [ i ] ; } else if ( arr [ i ] > secondMax ) { secondMax = arr [ i ] ; } } return ( max + secondMax ) ; } int countPairsWith ( int n , vector < int > & perfectSquares , unordered_set < int > & nums ) { int count = 0 ; for ( int i = 0 ; i < perfectSquares . size ( ) ; i ++ ) { int temp = perfectSquares [ i ] - n ; if ( temp > n && find ( nums . begin ( ) , nums . end ( ) , temp ) != nums . end ( ) ) { count ++ ; } } return count ; } int countPairs ( vector < int > & arr ) { int i , n = arr . size ( ) ; int max = maxPairSum ( arr ) ; vector < int > perfectSquares = getPerfectSquares ( max ) ; unordered_set < int > nums ; for ( i = 0 ; i < n ; i ++ ) { nums . insert ( arr [ i ] ) ; } int count = 0 ; for ( i = 0 ; i < n ; i ++ ) { count += countPairsWith ( arr [ i ] , perfectSquares , nums ) ; } return count ; } int main ( ) { vector < int > arr = { 2 , 3 , 6 , 9 , 10 , 20 } ; cout << countPairs ( arr ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; int findEle ( int arr [ ] , int n ) { ll sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == sum - arr [ i ] ) return arr [ i ] ; return -1 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findEle ( arr , 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 sumNatural ( int n ) { int sum = ( n * ( n + 1 ) ) / 2 ; return sum ; } int suminRange ( int l , int r ) { return sumNatural ( r ) - sumNatural ( l - 1 ) ; } int main ( ) { int l = 2 , r = 5 ; cout << " Sum ▁ of ▁ Natural ▁ numbers ▁ from ▁ L ▁ to ▁ R ▁ is ▁ " << suminRange ( l , r ) ; return 0 ; }

Accumulator variables: stdc