dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factors ( long long n ) { unordered_map < int , int > prime ; for ( int i = 2 ; i <= sqrt ( n ) ; ++ i ) { while ( n % i == 0 ) { ++ prime [ i ] ; n = n / i ; } } if ( n > 2 ) ++ prime [ n ] ; int ans1 = 1 , ans2 = 1 ; for ( auto it : prime ) { ans1 *= 2 * it . second + 1 ; ans2 *= it . second + 1 ; } return ans1 - ans2 ; } int main ( ) { long long n = 5 ; cout << factors ( n ) << endl ; n = 8 ; cout << factors ( n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: ans1, ans2, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; void greatest ( string s ) { int n = s . length ( ) ; int a [ n ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = s [ i ] - '0' ; sum += a [ i ] ; } { if ( a [ n - 2 ] % 2 != 0 or ( sum - a [ n - 1 ] ) % 3 != 0 ) { cout << " - 1" << endl ; } else { cout << n << endl ; } } else { int re = sum % 3 ; int del = -1 ; int flag = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( ( a [ i ] ) % 3 == re ) { if ( a [ i + 1 ] > a [ i ] ) { del = i ; flag = 1 ; break ; } else { del = i ; } } } if ( flag == 0 ) { if ( a [ n - 2 ] % 2 == 0 and re == a [ n - 1 ] % 3 ) del = n - 1 ; } if ( del == -1 ) cout << -1 << endl ; else { cout << del + 1 << endl ; } } } int main ( ) { string s = "7510222" ; greatest ( s ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool asPowerSum ( int w , int m ) { while ( m ) { if ( ( m - 1 ) % w == 0 ) m = ( m - 1 ) / w ; else if ( ( m + 1 ) % w == 0 ) m = ( m + 1 ) / w ; else if ( m % w == 0 ) m = m / w ; else } return ( m == 0 ) ; } int main ( ) { int w = 3 , m = 7 ; if ( asPowerSum ( w , m ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int divisible ( string num ) { int n = num . length ( ) ; int sum = accumulate ( begin ( num ) , end ( num ) , 0 ) - '0' * 1 ; if ( sum % 3 == 0 ) return 0 ; if ( n == 1 ) return -1 ; for ( int i = 0 ; i < n ; i ++ ) if ( sum % 3 == ( num [ i ] - '0' ) % 3 ) return 1 ; if ( n == 2 ) return -1 ; return 2 ; } int main ( ) { string num = "1234" ; cout << divisible ( num ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define n  3
using namespace std ; int dotProduct ( int vect_A [ ] , int vect_B [ ] ) { int product = 0 ; for ( int i = 0 ; i < n ; i ++ ) product = product + vect_A [ i ] * vect_B [ i ] ; return product ; } void crossProduct ( int vect_A [ ] , int vect_B [ ] , int cross_P [ ] ) { cross_P [ 0 ] = vect_A [ 1 ] * vect_B [ 2 ] - vect_A [ 2 ] * vect_B [ 1 ] ; cross_P [ 1 ] = vect_A [ 2 ] * vect_B [ 0 ] - vect_A [ 0 ] * vect_B [ 2 ] ; cross_P [ 2 ] = vect_A [ 0 ] * vect_B [ 1 ] - vect_A [ 1 ] * vect_B [ 0 ] ; } int main ( ) { int vect_A [ ] = { 3 , -5 , 4 } ; int vect_B [ ] = { 2 , 6 , 5 } ; int cross_P [ n ] ; cout << " Dot ▁ product : " ; cout << dotProduct ( vect_A , vect_B ) << endl ; cout << " Cross ▁ product : " ; crossProduct ( vect_A , vect_B , cross_P ) ; for ( int i = 0 ; i < n ; i ++ ) cout << cross_P [ i ] << " ▁ " ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; const int MAX = 1000001 ; int factor [ MAX ] = { 0 } ; void cal_factor ( ) { 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 no_of_representations ( int a [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = a [ i ] ; int flag = 0 ; while ( factor [ temp ] != 1 ) { flag = -1 ; count ++ ; temp = temp / factor [ temp ] ; } count += flag ; } return count ; } int main ( ) { cal_factor ( ) ; int a [ ] = { 4 , 4 , 4 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << no_of_representations ( a , n ) ; return 0 ; }

Index/key variables: MAX, i, j, temp
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int coutSubSeq ( int A [ ] , int N , int M ) { int sum = 0 ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { for ( int k = j + 1 ; k < N ; k ++ ) { sum = A [ i ] + A [ j ] + A [ k ] ; if ( sum % M == 0 ) ans ++ ; } } } return ans ; } int main ( ) { int M = 3 ; int A [ ] = { 1 , 2 , 4 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << coutSubSeq ( A , N , M ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <iostream>
using namespace std ; int countSubSeq ( int A [ ] , int N , int M ) { int ans = 0 ; int h [ M ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = A [ i ] % M ; h [ A [ i ] ] ++ ; } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = i ; j < M ; j ++ ) { int rem = ( M - ( i + j ) % M ) % M ; if ( rem < j ) continue ; if ( i == j && rem == j ) ans += h [ i ] * ( h [ i ] - 1 ) * ( h [ i ] - 2 ) / 6 ; else if ( i == j ) ans += h [ i ] * ( h [ i ] - 1 ) * h [ rem ] / 2 ; else if ( i == rem ) ans += h [ i ] * ( h [ i ] - 1 ) * h [ j ] / 2 ; else if ( rem == j ) ans += h [ j ] * ( h [ j ] - 1 ) * h [ i ] / 2 ; else ans = ans + h [ i ] * h [ j ] * h [ rem ] ; } } return ans ; } int main ( ) { int M = 3 ; int A [ ] = { 1 , 2 , 4 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << countSubSeq ( A , N , M ) ; return 0 ; }

Index/key variables: M, i, j, rem
Accumulator variables: ans, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findTerm ( int n ) { if ( n == 1 ) return n ; else { int term = 7 ; for ( int i = 2 ; i <= n ; i ++ ) term = term * 2 + ( i - 1 ) ; return term ; } } int main ( ) { int n = 5 ; cout << findTerm ( n ) ; return 0 ; }

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

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void result ( long long n , long long k , long long t ) { if ( t <= k ) cout << t ; else if ( t <= n ) cout << k ; else { long long temp = t - n ; temp = k - temp ; cout << temp ; } } int main ( ) { long long n , k , t ; n = 10 ; k = 5 ; t = 12 ; result ( n , k , t ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float weightedMean ( int X [ ] , int W [ ] , int n ) { int sum = 0 , numWeight = 0 ; for ( int i = 0 ; i < n ; i ++ ) { numWeight = numWeight + X [ i ] * W [ i ] ; sum = sum + W [ i ] ; } return ( float ) numWeight / sum ; } int main ( ) { int X [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int W [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int n = sizeof ( X ) / sizeof ( X [ 0 ] ) ; int m = sizeof ( W ) / sizeof ( W [ 0 ] ) ; if ( n == m ) cout << weightedMean ( X , W , n ) ; else cout << " - 1" ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float harmonicMean ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( float ) 1 / arr [ i ] ; return ( float ) n / sum ; } int main ( ) { float arr [ ] = { 13.5 , 14.5 , 14.8 , 15.2 , 16.1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << harmonicMean ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float harmonicMean ( int arr [ ] , int freq [ ] , int n ) { float sum = 0 , frequency_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ( float ) freq [ i ] / arr [ i ] ; frequency_sum = frequency_sum + freq [ i ] ; } return frequency_sum / sum ; } int main ( ) { int num [ ] = { 13 , 14 , 15 , 16 , 17 } ; int freq [ ] = { 2 , 5 , 13 , 7 , 3 } ; int n = sizeof ( num ) / sizeof ( num [ 0 ] ) ; cout << harmonicMean ( num , freq , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void point ( int a , int b , int c , int d , int n ) { int x , flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x = b + i * a ; if ( ( x - d ) % c == 0 and x - d >= 0 ) { cout << x << endl ; flag = 1 ; break ; } } if ( flag == 0 ) { cout << " No ▁ collision ▁ point " << endl ; } } int main ( ) { int a = 20 ; int b = 2 ; int c = 9 ; int d = 19 ; int n = 20 ; point ( a , b , c , d , n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findArmstrong ( int low , int high ) { for ( int i = low + 1 ; i < high ; ++ i ) { int x = i ; int n = 0 ; while ( x != 0 ) { x /= 10 ; ++ n ; } int pow_sum = 0 ; x = i ; while ( x != 0 ) { int digit = x % 10 ; pow_sum += pow ( digit , n ) ; x /= 10 ; } if ( pow_sum == i ) cout << i << " ▁ " ; } } int main ( ) { int num1 = 100 ; int num2 = 400 ; findArmstrong ( num1 , num2 ) ; cout << ' ' ; return 0 ; }

Accumulator variables: pow_sum, stdc, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void primeFactors ( int n , vector < int > & factors ) { if ( n % 2 == 0 ) factors . push_back ( 2 ) ; while ( n % 2 == 0 ) n = n / 2 ; for ( int i = 3 ; i <= sqrt ( n ) ; i += 2 ) { if ( n % i == 0 ) factors . push_back ( i ) ; while ( n % i == 0 ) n = n / i ; } if ( n > 2 ) factors . push_back ( n ) ; } int power ( int n , int r , int q ) { int total = n ; for ( int i = 1 ; i < r ; i ++ ) total = ( total * n ) % q ; return total ; } string lucasTest ( int n ) { if ( n == 1 ) return " neither ▁ prime ▁ nor ▁ composite " ; if ( n == 2 ) return " prime " ; if ( n % 2 == 0 ) return " composite1" ; vector < int > factors ; primeFactors ( n - 1 , factors ) ; int random [ n - 3 ] ; for ( int i = 0 ; i < n - 2 ; i ++ ) random [ i ] = i + 2 ; shuffle ( random , random + n - 3 , default_random_engine ( time ( 0 ) ) ) ; for ( int i = 0 ; i < n - 2 ; i ++ ) { int a = random [ i ] ; if ( power ( a , n - 1 , n ) != 1 ) return " composite " ; bool flag = true ; for ( int k = 0 ; k < factors . size ( ) ; k ++ ) { if ( power ( a , ( n - 1 ) / factors [ k ] , n ) == 1 ) { flag = false ; break ; } } if ( flag ) return " prime " ; } return " probably ▁ composite " ; } int main ( ) { cout << 7 << " ▁ is ▁ " << lucasTest ( 7 ) << endl ; cout << 9 << " ▁ is ▁ " << lucasTest ( 9 ) << endl ; cout << 37 << " ▁ is ▁ " << lucasTest ( 37 ) << endl ; return 0 ; }

Index/key variables: i, k
Accumulator variables: i, k, stdc
Iterator variables: i, k
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void gcdMax ( int a [ ] , int b [ ] , int n , int N ) { int cnt [ N ] = { 0 } ; int first [ N ] = { 0 } , second [ N ] = { 0 } ; for ( int i = 0 ; i < n ; ++ i ) cnt [ a [ i ] ] = 1 ; for ( int i = 1 ; i < N ; ++ i ) for ( int j = i ; j < N ; j += i ) if ( cnt [ j ] ) first [ i ] = max ( first [ i ] , j ) ; memset ( cnt , 0 , sizeof ( cnt ) ) ; for ( int i = 0 ; i < n ; ++ i ) cnt [ b [ i ] ] = true ; for ( int i = 1 ; i < N ; ++ i ) for ( int j = i ; j < N ; j += i ) if ( cnt [ j ] ) second [ i ] = max ( second [ i ] , j ) ; int i ; for ( i = N - 1 ; i >= 0 ; i -- ) if ( first [ i ] && second [ i ] ) break ; cout << " Maximum ▁ GCD ▁ pair ▁ with ▁ maximum ▁ " " sum ▁ is ▁ " << first [ i ] << " ▁ " << second [ i ] << endl ; } int main ( ) { int a [ ] = { 3 , 1 , 4 , 2 , 8 } ; int b [ ] = { 5 , 2 , 12 , 8 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int N = 20 ; gcdMax ( a , b , n , N ) ; 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 ; bool printPierpont ( int n ) { bool arr [ n + 1 ] ; memset ( arr , false , sizeof arr ) ; int two = 1 , three = 1 ; while ( two + 1 < n ) { arr [ two ] = true ; while ( two * three + 1 < n ) { arr [ three ] = true ; arr [ two * three ] = true ; three *= 3 ; } three = 1 ; two *= 2 ; } vector < int > v ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] ) v . push_back ( i + 1 ) ; memset ( arr , false , sizeof arr ) ; for ( int p = 2 ; p * p < n ; p ++ ) { if ( arr [ p ] == false ) for ( int i = p * 2 ; i < n ; i += p ) arr [ i ] = true ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) if ( ! arr [ v [ i ] ] ) cout << v [ i ] << " ▁ " ; } int main ( ) { int n = 200 ; printPierpont ( n ) ; return 0 ; }

Index/key variables: i, p, three, two
Accumulator variables: i, p, stdc, three, two
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isWoodall ( int x ) { if ( x % 2 == 0 ) return false ; if ( x == 1 ) return true ; int p = 0 ; while ( x % 2 == 0 ) { x = x / 2 ; p ++ ; if ( p == x ) return true ; } return false ; } int main ( ) { int x = 383 ; ( isWoodall ( x ) ) ? ( cout << " Yes " << endl ) : ( cout << " No " << endl ) ; return 0 ; }

Accumulator variables: p, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print_result ( int a [ ] , int n , int k , int m ) { vector < int > v [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { int rem = a [ i ] % m ; v [ rem ] . push_back ( a [ i ] ) ; if ( v [ rem ] . size ( ) == k ) { for ( int j = 0 ; j < k ; j ++ ) cout << v [ rem ] [ j ] << " ▁ " ; return ; } } cout << " - 1" ; } int main ( ) { int a [ ] = { 1 , 8 , 4 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; print_result ( a , n , 2 , 3 ) ; return 0 ; }

Index/key variables: i, j, m, rem
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; char * PrimeDigitNumber ( char N [ ] , int size ) { char * ans = ( char * ) malloc ( size * sizeof ( char ) ) ; int ns = 0 ; int small = 0 ; int i ; int p [ ] = { 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 0 } ; int prevprime [ ] = { 0 , 0 , 0 , 2 , 3 , 3 , 5 , 5 , 7 , 7 } ; if ( size == 1 ) { ans [ 0 ] = prevprime [ N [ 0 ] - '0' ] + '0' ; ans [ 1 ] = ' \0' ; return ans ; } if ( N [ 0 ] == '1' ) { for ( int i = 0 ; i < size - 1 ; i ++ ) ans [ i ] = '7' ; ans [ size - 1 ] = ' \0' ; return ans ; } for ( i = 0 ; i < size && small == 0 ; i ++ ) { if ( p [ N [ i ] - '0' ] == 1 ) { ans [ ns ++ ] = N [ i ] ; } else { if ( p [ N [ i ] - '0' ] == 0 && prevprime [ N [ i ] - '0' ] != 0 ) { ans [ ns ++ ] = prevprime [ N [ i ] - '0' ] + '0' ; small = 1 ; } else if ( p [ N [ i ] - '0' ] == 0 && prevprime [ N [ i ] - '0' ] == 0 ) { int j = i ; while ( j > 0 && p [ N [ j ] - '0' ] == 0 && prevprime [ N [ j ] - '0' ] == 0 ) { ans [ j ] = N [ j ] = '7' ; N [ j - 1 ] = prevprime [ N [ j - 1 ] - '0' ] + '0' ; ans [ j - 1 ] = N [ j - 1 ] ; small = 1 ; j -- ; } i = ns ; } } } if ( small == 0 ) { if ( prevprime [ N [ size - 1 ] - '0' ] + '0' != '0' ) ans [ size - 1 ] = prevprime [ N [ size - 1 ] - '0' ] + '0' ; else { int j = size - 1 ; while ( j > 0 && prevprime [ N [ j ] - '0' ] == 0 ) { ans [ j ] = N [ j ] = '7' ; N [ j - 1 ] = prevprime [ N [ j - 1 ] - '0' ] + '0' ; ans [ j - 1 ] = N [ j - 1 ] ; small = 1 ; j -- ; } } } for ( ; ns < size ; ns ++ ) ans [ ns ] = '7' ; ans [ ns ] = ' \0' ; int k = 0 ; while ( ans [ k ] == '0' ) k ++ ; return ans + k ; } int main ( ) { char N [ ] = "1000" ; int size = strlen ( N ) ; cout << PrimeDigitNumber ( N , size ) << endl ; return 0 ; }

Index/key variables: i, j, k, ns
Accumulator variables: i, j, k, ns, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestX ( int n ) { int temp [ 10 ] = { 0 } ; if ( n == 0 ) return -1 ; int count = 0 , x = 0 ; for ( x = 1 ; count < 10 ; x ++ ) { int y = x * n ; while ( y ) { if ( temp [ y % 10 ] == false ) { count ++ ; temp [ y % 10 ] = true ; } y /= 10 ; } } return x - 1 ; } int main ( ) { int n = 5 ; cout << smallestX ( n ) ; return 0 ; }

Accumulator variables: count, stdc, x, y
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digSum ( int n ) { int sum = 0 , rem = 0 ; while ( n ) { rem = n % 10 ; sum += rem ; n /= 10 ; } return sum ; } int findX ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) if ( i + digSum ( i ) == n ) return i ; return -1 ; } int main ( ) { int n = 43 ; cout << " x ▁ = ▁ " << findX ( n ) ; return 0 ; }

Accumulator variables: i, n, stdc, sum
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void complement ( string number ) { for ( int i = 0 ; i < number . length ( ) ; i ++ ) if ( number [ i ] != ' . ' ) number [ i ] = '9' - number [ i ] + '0' ; cout << "9 ' s ▁ complement ▁ is ▁ : ▁ " << number ; } int main ( ) { string number = "345.45" ; complement ( number ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countWays ( int n ) { int count = 0 ; for ( int i = 1 ; i * i < n ; i ++ ) if ( n % i == 0 ) count ++ ; return count ; } int main ( ) { int n = 12 ; cout << countWays ( n ) << endl ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDigitPresent ( int m , bool hash [ ] ) { while ( m ) { if ( hash [ m % 10 ] ) return true ; m = m / 10 ; } return false ; } int countDivisibles ( int n ) { bool hash [ 10 ] = { 0 } ; int m = n ; while ( m ) { hash [ m % 10 ] = true ; m = m / 10 ; } int ans = 0 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( isDigitPresent ( i , hash ) ) ans ++ ; if ( n / i != i ) { if ( isDigitPresent ( n / i , hash ) ) ans ++ ; } } } return ans ; } int main ( ) { int n = 15 ; cout << countDivisibles ( n ) ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100 ; void luDecomposition ( int mat [ ] [ MAX ] , int n ) { int lower [ n ] [ n ] , upper [ n ] [ n ] ; memset ( lower , 0 , sizeof ( lower ) ) ; memset ( upper , 0 , sizeof ( upper ) ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int k = i ; k < n ; k ++ ) { int sum = 0 ; for ( int j = 0 ; j < i ; j ++ ) sum += ( lower [ i ] [ j ] * upper [ j ] [ k ] ) ; upper [ i ] [ k ] = mat [ i ] [ k ] - sum ; } for ( int k = i ; k < n ; k ++ ) { if ( i == k ) else { int sum = 0 ; for ( int j = 0 ; j < i ; j ++ ) sum += ( lower [ k ] [ j ] * upper [ j ] [ i ] ) ; lower [ k ] [ i ] = ( mat [ k ] [ i ] - sum ) / upper [ i ] [ i ] ; } } } cout << setw ( 6 ) << " TABSYMBOL Lower ▁ Triangular " << setw ( 32 ) << " Upper ▁ Triangular " << endl ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) cout << setw ( 6 ) << lower [ i ] [ j ] << " TABSYMBOL " ; cout << " TABSYMBOL " ; for ( int j = 0 ; j < n ; j ++ ) cout << setw ( 6 ) << upper [ i ] [ j ] << " TABSYMBOL " ; cout << endl ; } } int main ( ) { int mat [ ] [ MAX ] = { { 2 , -1 , -2 } , { -4 , 6 , 3 } , { -4 , -2 , 8 } } ; luDecomposition ( mat , 3 ) ; return 0 ; }

Index/key variables: MAX, i, j, k, n
Accumulator variables: i, j, k, stdc, sum
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printTwoDivisibleParts ( string num , int f , int s ) { int N = num . length ( ) ; int prefixReminder [ N + 1 ] ; int suffixReminder [ N + 1 ] ; suffixReminder [ 0 ] = 0 ; for ( int i = 1 ; i < N ; i ++ ) suffixReminder [ i ] = ( suffixReminder [ i - 1 ] * 10 + ( num [ i - 1 ] - '0' ) ) % f ; prefixReminder [ N ] = 0 ; int base = 1 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { prefixReminder [ i ] = ( prefixReminder [ i + 1 ] + ( num [ i ] - '0' ) * base ) % s ; base = ( base * 10 ) % s ; } for ( int i = 0 ; i < N ; i ++ ) { if ( prefixReminder [ i ] == 0 && suffixReminder [ i ] == 0 && num [ i ] != '0' ) { cout << num . substr ( 0 , i ) << " ▁ " << num . substr ( i ) << endl ; return ; } } cout << " Not ▁ Possible STRNEWLINE " ; } int main ( ) { string num = "246904096" ; int f = 12345 ; int s = 1024 ; printTwoDivisibleParts ( num , f , s ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculate ( int a [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int r = i + 1 ; for ( int j = r ; j < n ; j ++ ) { if ( a [ i ] == a [ j ] ) r += 1 ; else break ; } int d = r - i ; ans += ( d * ( d + 1 ) / 2 ) ; i = r - 1 ; } return ans ; } int main ( ) { int a [ ] = { 2 , 4 , 5 , 3 , 3 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << calculate ( a , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, r, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int n ) { int rem = 0 ; int sum_of_digits = 0 ; while ( n > 0 ) { rem = n % 10 ; sum_of_digits += rem ; n = n / 10 ; } return sum_of_digits ; } int count ( int n ) { int c = 0 ; for ( int i = n - 97 ; i <= n ; i ++ ) { int a = sum ( i ) ; int b = sum ( a ) ; if ( ( i + a + b ) == n ) { c += 1 ; } } return c ; } int main ( ) { int n = 9939 ; cout << count ( n ) << endl ; return 0 ; }

Accumulator variables: c, i, stdc, sum_of_digits
Iterator variables: i
C++ program:
#include <iostream>
#include <algorithm>
using namespace std ; bool isPowerOfK ( unsigned int n , unsigned int k ) { bool oneSeen = false ; while ( n > 0 ) { int digit = n % k ; if ( digit > 1 ) return false ; if ( digit == 1 ) { if ( oneSeen ) return false ; oneSeen = true ; } n /= k ; } return true ; } int main ( ) { int n = 64 , k = 4 ; if ( isPowerOfK ( n , k ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: n
Boolean variables: oneSeen
C++ program:
#include <iostream>
using namespace std ; const int MAX_DIGITS = 20 ; bool isOctal ( long n ) { while ( n ) { if ( ( n % 10 ) >= 8 ) return false ; else n = n / 10 ; } return true ; } int isPalindrome ( long n ) { int divide = ( isOctal ( n ) == false ) ? 8 : 10 ; int octal [ MAX_DIGITS ] ; int i = 0 ; while ( n != 0 ) { octal [ i ++ ] = n % divide ; n = n / divide ; } for ( int j = i - 1 , k = 0 ; k <= j ; j -- , k ++ ) if ( octal [ j ] != octal [ k ] ) return false ; return true ; } int main ( ) { long n = 97 ; if ( isPalindrome ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: MAX_DIGITS, j, k
Accumulator variables: i, j, k
Iterator variables: j
C++ program:
#include <iostream>
using namespace std ; void printFactorialNums ( int n ) { int fact = 1 ; int x = 2 ; while ( fact <= n ) { cout << fact << " ▁ " ; fact = fact * x ; x ++ ; } } int main ( ) { int n = 100 ; printFactorialNums ( n ) ; return 0 ; }

Accumulator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumDigitSquare ( int n ) { int sq = 0 ; while ( n ) { int digit = n % 10 ; sq += digit * digit ; n = n / 10 ; } return sq ; } bool isHappy ( int n ) { set < int > s ; s . insert ( n ) ; while ( 1 ) { if ( n == 1 ) return true ; n = sumDigitSquare ( n ) ; if ( s . find ( n ) != s . end ( ) ) return false ; s . insert ( n ) ; } return false ; } int main ( ) { int n = 23 ; if ( isHappy ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: sq, stdc