dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void swap ( int a , int b , int c , int d ) { a = a + b ; b = a - b ; a = a - b ; b = b + c ; c = b - c ; b = b - c ; c = c + d ; d = c - d ; c = c - d ; cout << " values ▁ after ▁ swapping ▁ are ▁ : ▁ " << endl ; cout << " a ▁ = ▁ " << a << endl ; cout << " b ▁ = ▁ " << b << endl ; cout << " c ▁ = ▁ " << c << endl ; cout << " d ▁ = ▁ " << d << endl ; } int main ( ) { int a = 1 ; int b = 2 ; int c = 3 ; int d = 4 ; cout << " Values ▁ before ▁ swapping ▁ are ▁ : " << endl ; cout << " a ▁ = ▁ " << a << endl ; cout << " b ▁ = ▁ " << b << endl ; cout << " c ▁ = ▁ " << c << endl ; cout << " d ▁ = ▁ " << d << endl << endl ; swap ( a , b , c , d ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int seriesSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += i * ( i + 1 ) / 2 ; return sum ; } int main ( ) { int n = 4 ; cout << seriesSum ( n ) ; return 0 ; }

Accumulator variables: i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  3
bool checkCentrosymmetricted ( int n , int m [ N ] [ N ] ) { int mid_row ; if ( n & 1 ) mid_row = n / 2 + 1 ; else mid_row = n / 2 ; for ( int i = 0 ; i < mid_row ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( m [ i ] [ j ] != m [ n - i - 1 ] [ n - j - 1 ] ) return false ; } } return true ; } int main ( ) { int n = 3 ; int m [ N ] [ N ] = { { 1 , 3 , 5 } , { 6 , 8 , 6 } , { 5 , 3 , 1 } } ; ( checkCentrosymmetricted ( n , m ) ? ( cout << " Yes " ) : ( cout << " No " ) ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: 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 findGCD ( vector < int > arr , int n ) { int result = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) result = gcd ( arr [ i ] , result ) ; return result ; } void compute ( vector < int > arr , int n ) { vector < int > answer ; int GCD_of_array = findGCD ( arr , n ) ; if ( GCD_of_array == arr [ 0 ] ) { answer . push_back ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { answer . push_back ( arr [ 0 ] ) ; answer . push_back ( arr [ i ] ) ; } for ( int i = 0 ; i < answer . size ( ) ; i ++ ) cout << answer [ i ] << " ▁ " ; } else cout << " No ▁ array ▁ can ▁ be ▁ build " ; } int main ( ) { int n = 3 ; int input [ ] = { 2 , 5 , 6 , 7 , 11 } ; set < int > GCD ( input , input + n ) ; vector < int > arr ; set < int > :: iterator it ; for ( it = GCD . begin ( ) ; it != GCD . end ( ) ; ++ it ) arr . push_back ( * it ) ; compute ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int C [ n + 1 ] [ k + 1 ] = { 0 } ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } int k_Leaves ( int n , int k ) { int ans = ( binomialCoeff ( n , k ) * binomialCoeff ( n , k - 1 ) ) / n ; cout << " Number ▁ of ▁ trees ▁ having ▁ 4 ▁ edges " << " ▁ and ▁ exactly ▁ 2 ▁ leaves ▁ : ▁ " << ans << endl ; return 0 ; } int numberOfNodes ( int n , int d ) { int ans = binomialCoeff ( 2 * n - 1 - d , n - 1 ) ; cout << " Number ▁ of ▁ nodes ▁ of ▁ degree ▁ 1 ▁ in " << " ▁ a ▁ tree ▁ having ▁ 4 ▁ edges ▁ : ▁ " << ans << endl ; return 0 ; } int rootDegreeR ( int n , int r ) { int ans = r * binomialCoeff ( 2 * n - 1 - r , n - 1 ) ; ans = ans / n ; cout << " Number ▁ of ▁ trees ▁ having ▁ 4 ▁ edges " << " ▁ where ▁ root ▁ has ▁ degree ▁ 2 ▁ : ▁ " << ans << endl ; return 0 ; } int main ( ) { k_Leaves ( 3 , 2 ) ; numberOfNodes ( 3 , 1 ) ; rootDegreeR ( 3 , 2 ) ; return 0 ; }

Index/key variables: i, j, k, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int repUnitValue ( int n ) { if ( n % 2 == 0 n % 5 == 0 ) return 0 ; int rem = 1 ; int power = 1 ; int k = 1 ; while ( rem % n != 0 ) { k ++ ; power = power * 10 % n ; rem = ( rem + power ) % n ; } return k ; } int main ( ) { int n = 13 ; cout << repUnitValue ( n ) ; return 0 ; }

Accumulator variables: k, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSplittable ( int n , int m ) { int total_sum = ( n * ( n + 1 ) ) / 2 ; int sum_s1 = ( total_sum + m ) / 2 ; int sum_s2 = total_sum - sum_s1 ; if ( total_sum < m ) return false ; if ( sum_s1 + sum_s2 == total_sum && sum_s1 - sum_s2 == m ) return ( __gcd ( sum_s1 , sum_s2 ) == 1 ) ; return false ; } int main ( ) { int n = 5 , m = 7 ; if ( isSplittable ( n , m ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossibleToZero ( int a [ ] , int n ) { int num = 0 ; for ( int i = 0 ; i < n ; i ++ ) num = num * 10 + a [ i ] ; return ( num % 11 == 0 ) ; } int main ( ) { int arr [ ] = { 0 , 1 , 1 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isPossibleToZero ( arr , n ) ) cout << " YES " ; else cout << " NO " ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isBlumInteger ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( int j = i * 2 ; j <= n ; j += i ) prime [ j ] = false ; } } for ( int i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] ) { if ( ( n % i == 0 ) && ( ( i - 3 ) % 4 ) == 0 ) { int q = n / i ; return ( q != i && prime [ q ] && ( q - 3 ) % 4 == 0 ) ; } } } return false ; } int main ( ) { int n = 249 ; if ( isBlumInteger ( n ) ) cout << " Yes " ; else cout << " No " ; }

Index/key variables: i, j, q
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) ; int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } int main ( ) { int n = 5 , r = 3 ; cout << nCr ( n , r ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int summingSeries ( long n ) { return pow ( n , 2 ) ; } int main ( ) { int n = 100 ; cout << " The ▁ sum ▁ of ▁ n ▁ term ▁ is : ▁ " << summingSeries ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_sum_of_two_squares ( int a , int b ) { int ab = a * b ; for ( int i = 0 ; i * i <= ab ; i ++ ) { for ( int j = i ; i * i + j * j <= ab ; j ++ ) { if ( i * i + j * j == ab ) cout << i << " ^ 2 ▁ + ▁ " << j << " ^ 2 ▁ = ▁ " << ab << " STRNEWLINE " ; } } } int main ( ) { int a = 1 * 1 + 2 * 2 ; int b = 3 * 3 + 4 * 4 ; cout << " Representation ▁ of ▁ a ▁ * ▁ b ▁ as ▁ sum " " ▁ of ▁ 2 ▁ squares : STRNEWLINE " ; find_sum_of_two_squares ( a , b ) ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define show ( x )  cout << #x << " = " << x << "
" void check_euler_four_square_identity ( int a , int b , int ab ) { int s = 0 ; for ( int i = 0 ; i * i <= ab ; i ++ ) { s = i * i ; for ( int j = i ; j * j <= ab ; j ++ ) { s = j * j + i * i ; for ( int k = j ; k * k <= ab ; k ++ ) { s = k * k + j * j + i * i ; for ( int l = k ; l * l <= ab ; l ++ ) { s = l * l + k * k + j * j + i * i ; if ( s == ab ) { show ( i ) ; show ( j ) ; show ( k ) ; show ( l ) ; cout << " " << " Product ▁ of ▁ " << a << " ▁ and ▁ " << b ; cout << " ▁ can ▁ be ▁ written " << " ▁ as ▁ sum ▁ of ▁ squares ▁ of ▁ i , ▁ " << " j , ▁ k , ▁ l STRNEWLINE " ; cout << ab << " ▁ = ▁ " ; cout << i << " * " << i << " ▁ + ▁ " ; cout << j << " * " << j << " ▁ + ▁ " ; cout << k << " * " << k << " ▁ + ▁ " ; cout << l << " * " << l << " STRNEWLINE " ; cout << " STRNEWLINE " ; } } } } } } int main ( ) { int ab = a * b ; check_euler_four_square_identity ( a , b , ab ) ; return 0 ; }

Accumulator variables: i, j, k, l, stdc
Iterator variables: i, j, k, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculateDivisors ( int A , int B ) { int N = ( A - B ) ; int noOfDivisors = 0 ; for ( int i = 1 ; i <= sqrt ( N ) ; i ++ ) { if ( ( N % i ) == 0 ) { if ( i > B ) noOfDivisors ++ ; if ( ( N / i ) != i && ( N / i ) > B ) noOfDivisors ++ ; } } return noOfDivisors ; } int numberOfPossibleWaysUtil ( int A , int B ) { if ( A == B ) return -1 ; if ( A < B ) return 0 ; int noOfDivisors = 0 ; noOfDivisors = calculateDivisors ( A , B ) ; return noOfDivisors ; } void numberOfPossibleWays ( int A , int B ) { int noOfSolutions = numberOfPossibleWaysUtil ( A , B ) ; if ( noOfSolutions == -1 ) { cout << " For ▁ A ▁ = ▁ " << A << " ▁ and ▁ B ▁ = ▁ " << B << " , ▁ X ▁ can ▁ take ▁ Infinitely ▁ many ▁ values " " ▁ greater ▁ than ▁ " << A << " STRNEWLINE " ; } else { cout << " For ▁ A ▁ = ▁ " << A << " ▁ and ▁ B ▁ = ▁ " << B << " , ▁ X ▁ can ▁ take ▁ " << noOfSolutions << " ▁ values STRNEWLINE " ; } } int main ( ) { int A = 26 , B = 2 ; numberOfPossibleWays ( A , B ) ; A = 21 , B = 5 ; numberOfPossibleWays ( A , B ) ; return 0 ; }

Accumulator variables: i, noOfDivisors, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
int powerNumbers ( int n ) { vector < int > v ; for ( ll i = 2 ; i * i * i <= n ; i ++ ) { ll j = i * i ; while ( j * i <= n ) { j *= i ; ll s = sqrt ( j ) ; if ( s * s != j ) v . push_back ( j ) ; } } sort ( v . begin ( ) , v . end ( ) ) ; v . erase ( unique ( v . begin ( ) , v . end ( ) ) , v . end ( ) ) ; return v . size ( ) + ( ll ) sqrt ( n ) ; } int main ( ) { cout << powerNumbers ( 50 ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int variance ( int , int , int ) ; int mean ( int a [ ] [ 3 ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) sum += a [ i ] [ j ] ; return sum / ( n * n ) ; } int variance ( int a [ ] [ 3 ] , int n , int m ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] -= m ; a [ i ] [ j ] *= a [ i ] [ j ] ; } } for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) sum += a [ i ] [ j ] ; return sum / ( n * n ) ; } int main ( ) { int mat [ 3 ] [ 3 ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int m = mean ( mat , 3 ) ; int var = variance ( mat , 3 , m ) ; int dev = sqrt ( var ) ; cout << " Mean : ▁ " << m << " STRNEWLINE " << " Variance : ▁ " << var << " STRNEWLINE " << " Deviation : ▁ " << dev << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumofseries ( int n ) { return ( n * ( n + 1 ) * ( n + 2 ) * ( n + 3 ) / 4 ) ; } int main ( ) { cout << sumofseries ( 3 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( long long int i , long long int m ) { long long int sq_i = sqrt ( i ) ; long long int sq = min ( m , sq_i ) ; for ( long long int j = 2 ; j <= sq ; j ++ ) if ( i % j == 0 ) return false ; return true ; } void findLargestNum ( long long int n , long long int m ) { for ( long long int i = n ; i > m ; i -- ) { if ( isValid ( i , m ) ) { cout << i << ' ' ; return ; } } cout << " Number ▁ Doesn ' t ▁ Exists STRNEWLINE " ; } int main ( ) { long long int n = 16 , m = 3 ; findLargestNum ( n , m ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( long double x ) { if ( x >= 0 ) { long long sr = sqrt ( x ) ; return ( sr * sr == x ) ; } return false ; } int main ( ) { long long x = 2502 ; if ( isPerfectSquare ( x ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printGP ( int a , int r , int n ) { int curr_term ; for ( int i = 0 ; i < n ; i ++ ) { curr_term = a * pow ( r , i ) ; cout << curr_term << " ▁ " ; } } int main ( ) { int a = 2 ; int r = 3 ; int n = 5 ; printGP ( a , r , n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int gcd ( int a , int b ) { if ( a % b == 0 ) return b ; else return ( gcd ( b , a % b ) ) ; } int findHcf ( int * * arr , int size ) { int ans = arr [ 0 ] [ 0 ] ; for ( int i = 1 ; i < size ; i ++ ) ans = gcd ( ans , arr [ i ] [ 0 ] ) ; return ( ans ) ; } int findLcm ( int * * arr , int size ) { int ans = arr [ 0 ] [ 1 ] ; for ( int i = 1 ; i < size ; i ++ ) ans = ( ( ( arr [ i ] [ 1 ] * ans ) ) / ( gcd ( arr [ i ] [ 1 ] , ans ) ) ) ; return ( ans ) ; } int * hcfOfFraction ( int * * arr , int size ) { int hcf_of_num = findHcf ( arr , size ) ; int lcm_of_deno = findLcm ( arr , size ) ; int * result = new int [ 2 ] ; result [ 0 ] = hcf_of_num ; result [ 1 ] = lcm_of_deno ; for ( int i = result [ 0 ] / 2 ; i > 1 ; i -- ) { if ( ( result [ 1 ] % i == 0 ) && ( result [ 0 ] % i == 0 ) ) { result [ 1 ] /= i ; result [ 0 ] /= i ; } } return ( result ) ; } int main ( ) { int size = 4 ; int * * arr = new int * [ size ] ; for ( int i = 0 ; i < size ; i ++ ) arr [ i ] = new int [ 2 ] ; arr [ 0 ] [ 0 ] = 9 ; arr [ 0 ] [ 1 ] = 10 ; arr [ 1 ] [ 0 ] = 12 ; arr [ 1 ] [ 1 ] = 25 ; arr [ 2 ] [ 0 ] = 18 ; arr [ 2 ] [ 1 ] = 35 ; arr [ 3 ] [ 0 ] = 21 ; arr [ 3 ] [ 1 ] = 40 ; int * result = hcfOfFraction ( arr , size ) ; cout << result [ 0 ] << " , ▁ " << result [ 1 ] << endl ; return 0 ; }

Index/key variables: i, size
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMSB ( int n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return ( ( n + 1 ) >> 2 ) ; } void multiply ( int F [ 2 ] [ 2 ] , int M [ 2 ] [ 2 ] ) { int x = F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ; int y = F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ; int z = F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ; int w = F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } void power ( int F [ 2 ] [ 2 ] , int n ) { if ( n == 0 n == 1 ) return ; int M [ 2 ] [ 2 ] = { 1 , 1 , 1 , 0 } ; for ( int m = getMSB ( n ) ; m ; m = m >> 1 ) { multiply ( F , F ) ; if ( n & m ) { multiply ( F , M ) ; } } } int fib ( int n ) { int F [ 2 ] [ 2 ] = { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n - 1 ) ; return F [ 0 ] [ 0 ] ; } int main ( ) { int n = 6 ; cout << fib ( n ) << " ▁ " ; return 0 ; }

Accumulator variables: n, stdc
Iterator variables: m
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SternSequenceFunc ( vector < int > & BrocotSequence , int n ) { for ( int i = 1 ; BrocotSequence . size ( ) < n ; i ++ ) { int considered_element = BrocotSequence [ i ] ; int precedent = BrocotSequence [ i - 1 ] ; BrocotSequence . push_back ( considered_element + precedent ) ; BrocotSequence . push_back ( considered_element ) ; } for ( int i = 0 ; i < 15 ; ++ i ) cout << BrocotSequence [ i ] << " ▁ " ; } int main ( ) { int n = 15 ; vector < int > BrocotSequence ; BrocotSequence . push_back ( 1 ) ; BrocotSequence . push_back ( 1 ) ; SternSequenceFunc ( BrocotSequence , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isRevDiffDivisible ( int x , int k ) { int n = x ; int m = 0 ; int flag ; while ( x > 0 ) { m = m * 10 + x % 10 ; x /= 10 ; } return ( abs ( n - m ) % k == 0 ) ; } int countNumbers ( int l , int r , int k ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) if ( isRevDiffDivisible ( i , k ) ) ++ count ; return count ; } int main ( ) { int l = 20 , r = 23 , k = 6 ; cout << countNumbers ( l , r , k ) << endl ; return 0 ; }

Accumulator variables: i, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divSum ( int n ) { int result = 0 ; for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == ( n / i ) ) result += i ; else result += ( i + n / i ) ; } } return ( result + 1 ) ; } bool areAmicable ( int x , int y ) { if ( divSum ( x ) != y ) return false ; return ( divSum ( y ) == x ) ; } int main ( ) { int x = 220 , y = 284 ; if ( areAmicable ( x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( int n ) { if ( n < 0 ) return false ; int root = round ( sqrt ( n ) ) ) ; return n == root * root ; } void printnonsquare ( int n ) { int count = 0 ; for ( int i = 1 ; count < n ; ++ i ) { if ( ! isPerfectSquare ( i ) ) { cout << i << " ▁ " ; count ++ ; } } } int main ( ) { int n = 10 ; printnonsquare ( n ) ; return 0 ; }

Accumulator variables: count, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
int nonsquare ( int n ) { return n + ( int ) ( 0.5 + sqrt ( n ) ) ; } void printNonSquare ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) printf ( " % d ▁ " , nonsquare ( i ) ) ; } int main ( ) { int n = 10 ; printNonSquare ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > getLudic ( int n ) { vector < int > ludics ; for ( int i = 1 ; i <= n ; i ++ ) ludics . push_back ( i ) ; for ( int index = 1 ; index < ludics . size ( ) ; index ++ ) { int first_ludic = ludics [ index ] ; int remove_index = index + first_ludic ; while ( remove_index < ludics . size ( ) ) { auto it = ludics . begin ( ) ; it = it + remove_index ; ludics . erase ( it ) ; remove_index = remove_index + first_ludic - 1 ; } } return ludics ; } int main ( ) { int n = 25 ; vector < int > ans = getLudic ( n ) ; cout << " [ " ; for ( int i = 0 ; i < ans . size ( ) - 1 ; i ++ ) { cout << ans [ i ] << " , ▁ " ; } cout << ans [ ans . size ( ) - 1 ] << " ] " ; return 0 ; }

Index/key variables: i, index
Accumulator variables: i, index, stdc
Iterator variables: i, index
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sieve ( int n , bool 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 ; } } } void printPrimeTriplets ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; sieve ( n , prime ) ; cout << " The ▁ prime ▁ triplets ▁ from ▁ 1 ▁ to ▁ " << n << " are ▁ : " << endl ; for ( int i = 2 ; i <= n - 6 ; ++ i ) { if ( prime [ i ] && prime [ i + 2 ] && prime [ i + 6 ] ) cout << i << " ▁ " << ( i + 2 ) << " ▁ " << ( i + 6 ) << endl ; else if ( prime [ i ] && prime [ i + 4 ] && prime [ i + 6 ] ) cout << i << " ▁ " << ( i + 4 ) << " ▁ " << ( i + 6 ) << endl ; } } int main ( ) { int n = 25 ; printPrimeTriplets ( n ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Fraction { int num , den ; } ; Fraction maxFraction ( Fraction first , Fraction sec ) { int a = first . num ; int b = first . den ; int c = sec . num ; int d = sec . den ; int Y = a * d - b * c ; return ( Y > 0 ) ? first : sec ; } int main ( ) { Fraction first = { 3 , 2 } ; Fraction sec = { 3 , 4 } ; Fraction res = maxFraction ( first , sec ) ; cout << res . num << " / " << res . den ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Fraction
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nearestPerfectSquare ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int sr = sqrt ( arr [ i ] ) ; if ( ( sr & 1 ) == ( arr [ i ] & 1 ) ) cout << sr * sr << " ▁ " ; else { sr ++ ; cout << sr * sr << " ▁ " ; } } } int main ( ) { int arr [ ] = { 6 , 3 , 2 , 15 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; nearestPerfectSquare ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, sr, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isPentagonal ( int N ) { int i = 1 , M ; do { M = ( 3 * i * i - i ) / 2 ; i += 1 ; } while ( M < N ) ; return ( M == N ) ; } int main ( ) { int N = 12 ; if ( isPentagonal ( N ) ) cout << N << " ▁ is ▁ pentagonal ▁ " << endl ; else cout << N << " ▁ is ▁ not ▁ pentagonal " << endl ; return 0 ; }

Accumulator variables: i
C++ program:
#include <iostream>
using namespace std ; int aliquotSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i < n ; i ++ ) if ( n % i == 0 ) sum += i ; return sum ; } int main ( ) { int n = 12 ; cout << aliquotSum ( n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; float func ( float x ) { return ( 1 / ( 1 + x * x ) ) ; } float calculate ( float lower_limit , float upper_limit , int interval_limit ) { float value ; float interval_size = ( upper_limit - lower_limit ) / interval_limit ; float sum = func ( lower_limit ) + func ( upper_limit ) ; for ( int i = 1 ; i < interval_limit ; i ++ ) { if ( i % 3 == 0 ) sum = sum + 2 * func ( lower_limit + i * interval_size ) ; else sum = sum + 3 * func ( lower_limit + i * interval_size ) ; } return ( 3 * interval_size / 8 ) * sum ; } int main ( ) { int interval_limit = 10 ; float lower_limit = 1 ; float upper_limit = 10 ; float integral_res = calculate ( lower_limit , upper_limit , interval_limit ) ; cout << integral_res ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int maxArea ( int A [ ] , int len ) { int area = 0 ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = i + 1 ; j < len ; j ++ ) { area = max ( area , min ( A [ j ] , A [ i ] ) * ( j - i ) ) ; } } 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: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int n ) { int m = n ; while ( n ) { int r = n % 10 ; if ( r > 0 ) if ( ( m % r ) != 0 ) return false ; n /= 10 ; } return true ; } int count ( int l , int r ) { int ans = 0 ; for ( int i = l ; i <= r ; i ++ ) if ( check ( i ) ) ans += 1 ; return ans ; } int main ( ) { int l = 10 , r = 20 ; cout << count ( l , r ) ; return 0 ; }

Accumulator variables: ans, i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double sumOfTheSeries ( int n ) { double sum = 0.0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += 1.0 / ( i * ( i + 1 ) ) ; return sum ; } int main ( ) { int n = 10 ; cout << sumOfTheSeries ( n ) ; return 0 ; }

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

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfTheSeries ( int n ) { int sum_n = ( n * ( n + 1 ) / 2 ) ; int sum_sq_n = ( n * ( n + 1 ) / 2 ) * ( 2 * n + 1 ) / 3 ; return ( sum_n + sum_sq_n ) ; } int main ( ) { int n = 5 ; cout << " Sum ▁ = ▁ " << sumOfTheSeries ( n ) ; return 0 ; }

Accumulator variables: stdc