dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfTheSeries ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int k = 2 ; for ( int j = 1 ; j <= i ; j ++ ) { sum += k ; k += 2 ; } } return sum ; } int main ( ) { int n = 5 ; cout << " Sum ▁ = ▁ " << sumOfTheSeries ( n ) ; return 0 ; }

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

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <math.h>
#include <stdio.h>
double Series ( double x , int n ) { double sum = 1 , term = 1 , fct = 1 , p = 1 , multi = 1 ; for ( int i = 1 ; i < n ; i ++ ) { fct = fct * multi * ( multi + 1 ) ; p = p * x * x ; term = ( -1 ) * term ; multi += 2 ; sum = sum + ( term * p ) / fct ; } return sum ; } int main ( ) { double x = 9 ; int n = 10 ; printf ( " % .4f " , Series ( x , n ) ) ; return 0 ; }

Accumulator variables: i, multi
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int two_factor ( int n ) { int twocount = 0 ; while ( n % 2 == 0 ) { twocount ++ ; n = n / 2 ; } return twocount ; } int five_factor ( int n ) { int fivecount = 0 ; while ( n % 5 == 0 ) { fivecount ++ ; n = n / 5 ; } return fivecount ; } int find_con_zero ( int arr [ ] , int n ) { int twocount = 0 ; int fivecount = 0 ; for ( int i = 0 ; i < n ; i ++ ) { twocount += two_factor ( arr [ i ] ) ; fivecount += five_factor ( arr [ i ] ) ; } if ( twocount < fivecount ) return twocount ; else return fivecount ; } int main ( ) { int arr [ ] = { 100 , 10 , 5 , 25 , 35 , 14 } ; int n = 6 ; cout << find_con_zero ( arr , n ) ; }

Index/key variables: i
Accumulator variables: fivecount, i, twocount
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int first ( int a , int b , int c ) { a %= b ; for ( int i = 1 ; i <= b ; i ++ ) { a = a * 10 ; if ( a / b == c ) return i ; a %= b ; } return -1 ; } int main ( ) { int a = 1 , b = 4 , c = 5 ; cout << first ( a , b , c ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void subsetDifference ( int n ) { int s = n * ( n + 1 ) / 2 ; if ( n % 4 == 0 ) { cout << " First ▁ subset ▁ sum ▁ = ▁ " << s / 2 ; cout << " Second subset sum = " << s / 2 ; cout << " Difference = " } else { if ( n % 4 == 1 n % 4 == 2 ) { cout << " First ▁ subset ▁ sum ▁ = ▁ " << s / 2 ; cout << " Second subset sum = " << s / 2 + 1 ; cout << " Difference = " } else { cout << " First ▁ subset ▁ sum ▁ = ▁ " << s / 2 ; cout << " Second subset sum = " << s / 2 ; cout << " Difference = " } } } int main ( ) { int n = 6 ; subsetDifference ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void timeToMeet ( double s , double v ) { double V = 3 * v / 2 ; double time = s / V ; cout << time ; } int main ( void ) { double s = 25 , v = 56 ; timeToMeet ( s , v ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfTheSeries ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int k = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { sum += k ; k += 2 ; } } return sum ; } int main ( ) { int n = 5 ; cout << " Sum ▁ = ▁ " << sumOfTheSeries ( n ) ; return 0 ; }

Accumulator variables: i, j, k, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checksum ( int n ) { if ( n == 0 ) { cout << " - 1 ▁ 0 ▁ 1" << endl ; return ; } int inc ; if ( n > 0 ) inc = 1 ; else inc = -1 ; for ( int i = 0 ; i <= n - 2 ; i += inc ) { if ( i + i + 1 + i + 2 == n ) { cout << i << " ▁ " << i + 1 << " ▁ " << i + 2 ; return ; } } cout << " - 1" ; } int main ( ) { int n = 6 ; checksum ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divisorSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { for ( int j = 1 ; j * j <= i ; ++ j ) { if ( i % j == 0 ) { if ( i / j == j ) sum += j ; else sum += j + i / j ; } } } return sum ; } int main ( ) { int n = 4 ; cout << " ▁ " << divisorSum ( n ) << endl ; n = 5 ; cout << " ▁ " << divisorSum ( n ) ; return 0 ; }

Accumulator variables: stdc, sum
Iterator variables: i, j
C++ program:
#include <stdio.h>
int printbinomial ( int max ) { for ( int m = 0 ; m <= max ; m ++ ) { printf ( " % 2d " , m ) ; int binom = 1 ; for ( int x = 0 ; x <= m ; x ++ ) { if ( m != 0 && x != 0 ) binom = binom * ( m - x + 1 ) / x ; printf ( " % 4d " , binom ) ; } printf ( " STRNEWLINE " ) ; } } int main ( ) { int max = 10 ; printbinomial ( max ) ; return 0 ; }

Accumulator variables: m, x
Iterator variables: m, x
C++ program:
#include <iostream>
#include <bits/stdc++.h>
using namespace std ; long long maxPrimeFactors ( long long n ) { long long maxPrime = -1 ; while ( n % 2 == 0 ) { maxPrime = 2 ; } while ( n % 3 == 0 ) { maxPrime = 3 ; n = n / 3 ; } for ( int i = 5 ; i <= sqrt ( n ) ; i += 6 ) { while ( n % i == 0 ) { maxPrime = i ; n = n / i ; } while ( n % ( i + 2 ) == 0 ) { maxPrime = i + 2 ; n = n / ( i + 2 ) ; } } if ( n > 4 ) maxPrime = n ; return maxPrime ; } int main ( ) { long long n = 15 ; cout << maxPrimeFactors ( n ) << endl ; n = 25698751364526 ; cout << maxPrimeFactors ( n ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned int countSetBits ( int n ) { unsigned int count = 0 ; while ( n ) { n &= ( n - 1 ) ; count ++ ; } return count ; } unsigned int countUnsetBitsInGivenRange ( unsigned int n , unsigned int l , unsigned int r ) { int num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; return ( r - l + 1 ) - countSetBits ( n & num ) ; } int main ( ) { unsigned int n = 80 ; unsigned int l = 1 , r = 4 ; cout << countUnsetBitsInGivenRange ( n , l , r ) ; return 0 ; }

Accumulator variables: count, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string fractionToDecimal ( int numerator , int denominator ) { string res ; map < int , int > mp ; mp . clear ( ) ; int rem = numerator % denominator ; while ( ( rem != 0 ) && ( mp . find ( rem ) == mp . end ( ) ) ) { mp [ rem ] = res . length ( ) ; rem = rem * 10 ; int res_part = rem / denominator ; res += to_string ( res_part ) ; rem = rem % denominator ; } return ( rem == 0 ) ? " - 1" : res . substr ( mp [ rem ] ) ; } bool isPrime ( int n ) { for ( int i = 2 ; i <= n / 2 ; i ++ ) if ( n % i == 0 ) return false ; return true ; } void Midys ( string str , int n ) { int l = str . length ( ) ; int part1 = 0 , part2 = 0 ; if ( ! isPrime ( n ) ) { cout << " Denominator ▁ is ▁ not ▁ prime , ▁ " << " thus ▁ Midy ' s ▁ theorem ▁ is ▁ not ▁ applicable " ; } else if ( l % 2 == 0 ) { for ( int i = 0 ; i < l / 2 ; i ++ ) { part1 = part1 * 10 + ( str [ i ] - '0' ) ; part2 = part2 * 10 + ( str [ l / 2 + i ] - '0' ) ; } cout << part1 << " ▁ + ▁ " << part2 << " ▁ = ▁ " << ( part1 + part2 ) << endl ; cout << " Midy ' s ▁ theorem ▁ holds ! " ; } else { cout << " The ▁ repeating ▁ decimal ▁ is ▁ of ▁ odd ▁ length ▁ " << " thus ▁ Midy ' s ▁ theorem ▁ is ▁ not ▁ applicable " ; } } int main ( ) { int numr = 2 , denr = 11 ; string res = fractionToDecimal ( numr , denr ) ; if ( res == " - 1" ) cout << " The ▁ fraction ▁ does ▁ not ▁ have ▁ repeating ▁ decimal " ; else { cout << " Repeating ▁ decimal ▁ = ▁ " << res << endl ; Midys ( res , denr ) ; } return 0 ; }

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

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int evenPowerSum ( int n ) { return ( 8 * n * ( n + 1 ) * ( 2 * n + 1 ) * ( 3 * n * n + 3 * n - 1 ) ) / 15 ; } int main ( ) { int n = 4 ; cout << evenPowerSum ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define MAX  501
using namespace std ; int balancedprime ( int n ) { bool prime [ MAX + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } vector < int > v ; for ( int p = 3 ; p <= MAX ; p += 2 ) if ( prime [ p ] ) v . push_back ( p ) ; int count = 0 ; for ( int i = 1 ; i < v . size ( ) ; i ++ ) { if ( v [ i ] == ( v [ i + 1 ] + v [ i - 1 ] ) / 2 ) count ++ ; if ( count == n ) return v [ i ] ; } } int main ( ) { int n = 4 ; cout << balancedprime ( n ) << endl ; 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 ; const int MAX = 1000001 ; int factor [ MAX ] = { 0 } ; void generatePrimeFactors ( ) { factor [ 1 ] = 1 ; for ( int i = 2 ; i < MAX ; i ++ ) factor [ i ] = i ; for ( int i = 4 ; i < MAX ; i += 2 ) factor [ i ] = 2 ; for ( int i = 3 ; i * i < MAX ; i ++ ) { if ( factor [ i ] == i ) { for ( int j = i * i ; j < MAX ; j += i ) { if ( factor [ j ] == j ) factor [ j ] = i ; } } } } int calculateNoOFactors ( int n ) { if ( n == 1 ) return 1 ; int ans = 1 ; int dup = factor [ n ] ; int c = 1 ; int j = n / factor [ n ] ; while ( j != 1 ) { if ( factor [ j ] == dup ) c += 1 ; else { dup = factor [ j ] ; ans = ans * ( c + 1 ) ; c = 1 ; } j = j / factor [ j ] ; } ans = ans * ( c + 1 ) ; return ans ; } int smallest ( int n ) { for ( int i = 1 ; ; i ++ ) if ( calculateNoOFactors ( i ) >= n ) return i ; } int main ( ) { generatePrimeFactors ( ) ; int n = 4 ; cout << smallest ( n ) ; return 0 ; }

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

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isPrime ( int n ) { int i = 2 ; while ( i * i <= n ) { if ( n % i == 0 ) return false ; i ++ ; } return true ; } int minimumSum ( int n ) { if ( isPrime ( n ) ) return 1 ; if ( n % 2 == 0 ) return 2 ; if ( isPrime ( n - 2 ) ) return 2 ; return 3 ; } int main ( ) { int n = 27 ; cout << minimumSum ( n ) ; return 0 ; }

Accumulator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int firstDigit ( int n ) { while ( n >= 10 ) n /= 10 ; return n ; } int lastDigit ( int n ) { return ( n % 10 ) ; } int main ( ) { int n = 98562 ; cout << firstDigit ( n ) << " ▁ " << lastDigit ( n ) << endl ; return 0 ; }

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int firstDigit ( int n ) { int digits = ( int ) log10 ( n ) ; n = ( int ) ( n / pow ( 10 , digits ) ) ; return n ; } int lastDigit ( int n ) { return ( n % 10 ) ; } int main ( ) { int n = 98562 ; cout << firstDigit ( n ) << " ▁ " << lastDigit ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int x ) { if ( x == 0 x == 1 ) return false ; for ( int i = 2 ; i * i <= x ; ++ i ) if ( x % i == 0 ) return false ; return true ; } void findPrimes ( int n ) { cout << n << endl ; cout << 2 << " ▁ " << n - 2 << endl ; { cout << 3 << " ▁ " ; n = n - 3 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPrime ( i ) && isPrime ( n - i ) ) { cout << i << " ▁ " << ( n - i ) ; break ; } } } } int main ( ) { int n = 27 ; findPrimes ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long c [ 100 ] ; void coef ( int n ) { c [ 0 ] = 1 ; for ( int i = 0 ; i < n ; c [ 0 ] = - c [ 0 ] , i ++ ) { c [ 1 + i ] = 1 ; for ( int j = i ; j > 0 ; j -- ) c [ j ] = c [ j - 1 ] - c [ j ] ; } } bool isPrime ( int n ) { coef ( n ) ; c [ 0 ] ++ , c [ n ] -- ; int i = n ; while ( i -- && c [ i ] % n == 0 ) ; return i < 0 ; } int main ( ) { int n = 37 ; if ( isPrime ( n ) ) cout << " Prime " << endl ; else cout << " Not ▁ Prime " << endl ; return 0 ; }

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

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigit ( int n ) { if ( n == 0 ) return 0 ; return 1 + countDigit ( n / 10 ) ; } bool check ( int n ) { int l = countDigit ( n ) ; int dup = n ; int sum = 0 ; while ( dup ) { sum += pow ( dup % 10 , l ) ; dup /= 10 ; } return ( n == sum ) ; } int main ( ) { int n = 1634 ; if ( check ( n ) ) cout << " yes " ; else cout << " no " ; return 0 ; }

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

Accumulator variables: i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define MAX  100
using namespace std ; void leyland ( int n ) { vector < int > ans ; for ( int x = 2 ; x <= n ; x ++ ) { for ( int y = 2 ; y <= x ; y ++ ) { int temp = pow ( x , y ) + pow ( y , x ) ; ans . push_back ( temp ) ; } } sort ( ans . begin ( ) , ans . end ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) cout << ans [ i ] << " ▁ " ; } int main ( ) { int n = 6 ; leyland ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, x, y
Iterator variables: i, x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; int kthgroupsum ( int k ) { int cur = ( k * ( k - 1 ) ) + 1 ; int sum = 0 ; while ( k -- ) { sum += cur ; cur += 2 ; } return sum ; } int main ( ) { int k = 3 ; cout << kthgroupsum ( k ) << endl ; return 0 ; }

Accumulator variables: cur, k, stdc, sum
C++ program:
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
#include <vector>
using namespace std ; using boost :: multiprecision :: cpp_int ; vector < cpp_int > find_factorial ( int num1 , int num2 ) { vector < cpp_int > vec ; cpp_int fac = 1 ; int temp = num1 ; while ( 1 ) { if ( temp == 1 ) break ; fac *= temp ; temp -- ; } vec . push_back ( fac ) ; num1 ++ ; while ( num1 <= num2 ) { fac *= num1 ; vec . push_back ( fac ) ; num1 ++ ; } return ( vec ) ; } void print_format ( vector < cpp_int > & result ) { int digits = result . back ( ) . str ( ) . size ( ) ; for ( int i = 0 ; i < result . size ( ) ; i ++ ) { cout << setw ( digits + 1 ) << right << result [ i ] << endl ; } } int main ( ) { int m = 10 , n = 20 ; vector < cpp_int > result_fac ; result_fac = find_factorial ( m , n ) ; print_format ( result_fac ) ; return 0 ; }

Index/key variables: i
Accumulator variables: fac, i, num1, temp
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int term ( int n ) { int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) ans += i ; return ans ; } int main ( ) { int n = 4 ; cout << term ( n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
int summation ( int n ) { int sum ; sum = ( pow ( 10 , n + 1 ) - 10 - ( 9 * n ) ) / 81 ; return sum ; } int main ( ) { int n = 5 ; printf ( " % d " , summation ( n ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double sum ( int x , int n ) { double i , total = 1.0 , multi = x ; for ( i = 1 ; i <= n ; i ++ ) { total = total + multi / i ; multi = multi * x ; } return total ; } int main ( ) { int x = 2 ; int n = 5 ; cout << fixed << setprecision ( 2 ) << sum ( x , n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <math.h>
using namespace std ; int countDigits ( int n ) { int c = 0 ; do { c ++ ; n = n / 10 ; } while ( n != 0 ) ; return c ; } bool isDeserium ( int x ) { int temp = x ; int p = countDigits ( x ) ; int sum = 0 ; while ( x != 0 ) { int digit = x % 10 ; sum += pow ( digit , p ) ; p -- ; x = x / 10 ; } return ( sum == temp ) ; } int main ( ) { int x = 135 ; if ( isDeserium ( x ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: c, p, sum
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 sameRemainder ( int a , int b , int c ) { int a1 = ( b - a ) , b1 = ( c - b ) , c1 = ( c - a ) ; return gcd ( a1 , gcd ( b1 , c1 ) ) ; } int main ( ) { int a = 62 , b = 132 , c = 237 ; cout << sameRemainder ( a , b , c ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float mean ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; float mean = ( float ) sum / n ; return mean ; } float sd ( int arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ; float sdd = sum / n ; return sdd ; } float combinedVariance ( int arr1 [ ] , int arr2 [ ] , int n , int m ) { float mean1 = mean ( arr1 , n ) ; float mean2 = mean ( arr2 , m ) ; cout << " Mean1 : ▁ " << mean1 << " ▁ mean2 : ▁ " << mean2 << endl ; float sd1 = sd ( arr1 , n ) ; float sd2 = sd ( arr2 , m ) ; cout << " StandardDeviation1 : ▁ " << sd1 << " ▁ StandardDeviation2 : ▁ " << sd2 << endl ; float combinedMean = ( float ) ( n * mean1 + m * mean2 ) / ( n + m ) ; cout << " Combined ▁ Mean : ▁ " << combinedMean << endl ; float d1_square = ( mean1 - combinedMean ) * ( mean1 - combinedMean ) ; float d2_square = ( mean2 - combinedMean ) * ( mean2 - combinedMean ) ; cout << " d1 ▁ square : ▁ " << d1_square << " ▁ d2 _ square : ▁ " << d2_square << endl ; float combinedVar = ( n * ( sd1 + d1_square ) + m * ( sd2 + d2_square ) ) / ( n + m ) ; return combinedVar ; } int main ( ) { int arr1 [ ] = { 23 , 45 , 34 , 78 , 12 , 76 , 34 } ; int arr2 [ ] = { 65 , 67 , 34 , 23 , 45 } ; int n = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; int m = sizeof ( arr2 ) / sizeof ( arr2 [ 0 ] ) ; cout << " Combined ▁ Variance : ▁ " << combinedVariance ( arr1 , arr2 , n , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool checkDivisibility ( string num ) { int length = num . size ( ) ; if ( length == 1 && num [ 0 ] == '0' ) return true ; if ( length % 3 == 1 ) { num += "00" ; length += 2 ; } else if ( length % 3 == 2 ) { num += "0" ; length += 1 ; } int sum = 0 , p = 1 ; for ( int i = length - 1 ; i >= 0 ; i -- ) { int group = 0 ; group += num [ i -- ] - '0' ; group += ( num [ i -- ] - '0' ) * 10 ; group += ( num [ i ] - '0' ) * 100 ; sum = sum + group * p ; p *= ( -1 ) ; } sum = abs ( sum ) ; return ( sum % 13 == 0 ) ; } int main ( ) { string number = "83959092724" ; if ( checkDivisibility ( number ) ) cout << number << " ▁ is ▁ divisible ▁ by ▁ 13 . " ; else cout << number << " ▁ is ▁ not ▁ divisible ▁ by ▁ 13 . " ; return 0 ; }

Index/key variables: i
Accumulator variables: group, i, length, num, p
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void modularEquation ( int a , int b ) { if ( a < b ) { cout << " No ▁ solution ▁ possible ▁ " << endl ; return ; } if ( a == b ) { cout << " Infinite ▁ Solution ▁ possible ▁ " << endl ; return ; } int count = 0 ; int n = a - b ; int y = sqrt ( a - b ) ; for ( int i = 1 ; i <= y ; ++ i ) { if ( n % i == 0 ) { if ( n / i > b ) count ++ ; if ( i > b ) count ++ ; } } if ( y * y == n && y > b ) count -- ; cout << count << endl ; } int main ( ) { int a = 21 , b = 5 ; modularEquation ( a , b ) ; return 0 ; }

Accumulator variables: count, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countWays ( int num ) { int dp [ num + 1 ] ; const int MOD = 1e9 + 7 ; dp [ 1 ] = 2 ; for ( int i = 2 ; i <= num ; ++ i ) { dp [ i ] = 0 ; for ( int j = 1 ; j <= 3 ; ++ j ) { if ( i - j == 0 ) dp [ i ] += 1 ; else if ( j == 1 ) dp [ i ] += dp [ i - j ] * 2 ; else if ( i - j > 0 ) dp [ i ] += dp [ i - j ] ; if ( dp [ i ] >= MOD ) dp [ i ] %= MOD ; } } return dp [ num ] ; } int main ( ) { int n = 3 ; cout << countWays ( n ) ; return 0 ; }

Index/key variables: i, num
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool sumSquare ( int n ) { unordered_map < int , int > s ; for ( int i = 0 ; i * i <= n ; ++ i ) { s [ i * i ] = 1 ; if ( s . find ( n - i * i ) != s . end ( ) ) { cout << sqrt ( n - i * i ) << " ^ 2 ▁ + ▁ " << i << " ^ 2" << endl ; return true ; } } return false ; } int main ( ) { int n = 169 ; if ( sumSquare ( n ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool judgeSquareSum ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { int count = 0 ; if ( n % i == 0 ) { while ( n % i == 0 ) { count ++ ; n /= i ; } if ( i % 4 == 3 && count % 2 != 0 ) return false ; } } return n % 4 != 3 ; } int main ( ) { int n = 17 ; if ( judgeSquareSum ( n ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: count, i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigitOne ( int n ) { int countr = 0 ; for ( int i = 1 ; i <= n ; i *= 10 ) { int divider = i * 10 ; countr += ( n / divider ) * i + min ( max ( n % divider - i + 1 , 0 ) , i ) ; } return countr ; } int main ( ) { int n = 13 ; cout << countDigitOne ( n ) << endl ; n = 113 ; cout << countDigitOne ( n ) << endl ; n = 205 ; cout << countDigitOne ( n ) << endl ; }

Accumulator variables: countr, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( char c ) { return ( c == '2' c == '3' c == '5' c == '7' ) ; } void decrease ( string & s , int i ) { if ( s [ i ] <= '2' ) { s . erase ( i , 1 ) ; s [ i ] = '7' ; } else if ( s [ i ] == '3' ) s [ i ] = '2' ; else if ( s [ i ] <= '5' ) s [ i ] = '3' ; else if ( s [ i ] <= '7' ) s [ i ] = '5' ; else s [ i ] = '7' ; return ; } string primeDigits ( string s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! isPrime ( s [ i ] ) ) { while ( s [ i ] <= '2' && i >= 0 ) i -- ; if ( i < 0 ) { i = 0 ; decrease ( s , i ) ; } else decrease ( s , i ) ; for ( int j = i + 1 ; j < s . length ( ) ; j ++ ) s [ j ] = '7' ; break ; } } return s ; } int main ( ) { string s = "45" ; cout << primeDigits ( s ) << endl ; s = "1000" ; cout << primeDigits ( s ) << endl ; s = "7721" ; cout << primeDigits ( s ) << endl ; s = "7221" ; cout << primeDigits ( s ) << endl ; s = "74545678912345689748593275897894708927680" ; cout << primeDigits ( s ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j