dhyuti-n/xlcost-variable-roles huggingface dataset:
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 ; } bool isInterprime ( int n ) { if ( n < 4 ) return false ; int prev_prime = n ; int next_prime = n ; while ( ! isPrime ( prev_prime ) ) { prev_prime -- ; } while ( ! isPrime ( next_prime ) ) { next_prime ++ ; } if ( ( prev_prime + next_prime ) == 2 * n ) return true ; else return false ; } int main ( ) { int n = 9 ; if ( isInterprime ( n ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Accumulator variables: next_prime, prev_prime, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int get_unit_digit ( long long int N ) { if ( N == 0 N == 1 ) return 1 ; else if ( N == 2 ) return 3 ; else if ( N == 3 ) return 9 ; return 3 ; } int main ( ) { long long int N = 1 ; for ( N = 0 ; N <= 10 ; N ++ ) cout << " For ▁ N ▁ = ▁ " << N << " ▁ : ▁ " << get_unit_digit ( N ) << endl ; return 0 ; }

Accumulator variables: N
Iterator variables: N
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 1000 ; int f [ MAX ] = { 0 } ; int fib ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] ) return f [ n ] ; int k = ( n & 1 ) ? ( n + 1 ) / 2 : n / 2 ; f [ n ] = ( n & 1 ) ? ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) : ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } int calculateSumOfSquares ( int n ) { return fib ( n ) * fib ( n + 1 ) ; } int main ( ) { int n = 6 ; cout << " Sum ▁ of ▁ Squares ▁ of ▁ Fibonacci ▁ numbers ▁ is ▁ : ▁ " << calculateSumOfSquares ( n ) << endl ; return 0 ; }

Index/key variables: MAX, n
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int NumberOfSolutions ( int x , int y , int z , int n ) { int ans = 0 ; for ( int i = 0 ; i <= x ; i ++ ) { for ( int j = 0 ; j <= y ; j ++ ) { int temp = n - i - j ; if ( temp >= 0 ) { temp = min ( temp , z ) ; ans += temp + 1 ; } } } return ans ; } int main ( ) { int x = 1 , y = 2 , z = 3 , n = 4 ; cout << NumberOfSolutions ( x , y , z , n ) ; return 0 ; }

Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } bool isProduct ( int num ) { int cnt = 0 ; for ( int i = 2 ; cnt < 2 && i * i <= num ; ++ i ) { while ( num % i == 0 ) { num /= i ; ++ cnt ; } } if ( num > 1 ) ++ cnt ; return cnt == 2 ; } void findNumbers ( int N ) { vector < int > vec ; for ( int i = 1 ; i <= N ; i ++ ) { if ( isProduct ( i ) && ! isPerfectSquare ( i ) ) { vec . push_back ( i ) ; } } for ( int i = 0 ; i < vec . size ( ) ; i ++ ) { cout << vec [ i ] << " ▁ " ; } } int main ( ) { int N = 30 ; findNumbers ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define mod  1000000009
int NthTerm ( long long n ) { long long x = ( 2 * n * n ) % mod ; return ( x - n + mod ) % mod ; } int main ( ) { long long N = 4 ; cout << NthTerm ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
#define MAX  16
using namespace std ; ll nCr [ MAX ] [ MAX ] = { 0 } ; void binomial ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { if ( j == 0 j == i ) nCr [ i ] [ j ] = 1 ; else nCr [ i ] [ j ] = nCr [ i - 1 ] [ j ] + nCr [ i - 1 ] [ j - 1 ] ; } } } double findTanNTheta ( double tanTheta , ll n ) { double ans = 0 , numerator = 0 , denominator = 0 ; ll toggle = 1 ; for ( int i = 1 ; i <= n ; i += 2 ) { numerator = numerator + nCr [ n ] [ i ] * pow ( tanTheta , i ) * toggle ; toggle = toggle * -1 ; } denominator = 1 ; toggle = -1 ; for ( int i = 2 ; i <= n ; i += 2 ) { numerator = numerator + nCr [ n ] [ i ] * pow ( tanTheta , i ) * toggle ; toggle = toggle * -1 ; } ans = numerator / denominator ; return ans ; } int main ( ) { binomial ( ) ; double tanTheta = 0.3 ; ll n = 10 ; cout << findTanNTheta ( tanTheta , n ) << endl ; return 0 ; }

Index/key variables: MAX, i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculateSum ( int n ) { return ( n * ( 4 * n * n + 6 * n - 1 ) / 3 ) ; } int main ( ) { int n = 4 ; cout << " Sum ▁ = ▁ " << calculateSum ( n ) ; return 0 ; }

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

Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAXN  100005
int spf [ MAXN ] = { 0 } ; int sum_digits [ MAXN ] = { 0 } ; bool isValid [ MAXN ] = { 0 } ; int ans [ MAXN ] = { 0 } ; void Smallest_prime_factor ( ) { for ( int i = 1 ; 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 += 2 ) if ( spf [ i ] == i ) for ( int j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } int Digit_Sum ( int copy ) { int d = 0 ; while ( copy ) { d += copy % 10 ; copy /= 10 ; } return d ; } void Sum_Of_All_Digits ( ) { for ( int n = 2 ; n < MAXN ; n ++ ) { sum_digits [ n ] = sum_digits [ n / spf [ n ] ] + Digit_Sum ( spf [ n ] ) ; if ( Digit_Sum ( n ) == sum_digits [ n ] ) isValid [ n ] = true ; } for ( int n = 2 ; n < MAXN ; n ++ ) { if ( isValid [ n ] ) ans [ n ] = 1 ; ans [ n ] += ans [ n - 1 ] ; } } int main ( ) { Smallest_prime_factor ( ) ; Sum_Of_All_Digits ( ) ; int l , r ; l = 2 , r = 3 ; cout << " Valid ▁ numbers ▁ in ▁ the ▁ range ▁ " << l << " ▁ " << r << " ▁ are ▁ " << ans [ r ] - ans [ l - 1 ] << endl ; l = 2 , r = 10 ; cout << " Valid ▁ numbers ▁ in ▁ the ▁ range ▁ " << l << " ▁ " << r << " ▁ are ▁ " << ans [ r ] - ans [ l - 1 ] << endl ; return 0 ; }

Index/key variables: MAXN, i, j, n, r
Accumulator variables: copy, d, i, j, n, stdc
Iterator variables: i, j, n
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculate ( int * array , int size ) { int count = 0 ; for ( int i = 0 ; i < size ; i ++ ) if ( array [ i ] % 2 == 0 && array [ i ] != 0 && array [ i ] != 2 ) count ++ ; return count ; } int main ( ) { int a [ ] = { 1 , 3 , 4 , 6 } ; int size = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << calculate ( a , size ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1000001 ; vector < int > v [ N ] ; void preprocess ( ) { for ( int i = 1 ; i < N ; i ++ ) { int num = i ; for ( int j = 2 ; j <= sqrt ( num ) ; j ++ ) { if ( num % j == 0 ) { v [ i ] . push_back ( j ) ; while ( num % j == 0 ) { num = num / j ; } } } if ( num > 2 ) v [ i ] . push_back ( num ) ; } } int query ( int number , int n ) { return v [ number ] [ n - 1 ] ; } int main ( ) { preprocess ( ) ; int number = 6 , n = 1 ; cout << query ( number , n ) << endl ; number = 210 , n = 3 ; cout << query ( number , n ) << endl ; number = 210 , n = 2 ; cout << query ( number , n ) << endl ; number = 60 , n = 2 ; cout << query ( number , n ) << endl ; return 0 ; }

Index/key variables: N, i, number
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int twoEggDrop ( int k ) { return ceil ( ( -1.0 + sqrt ( 1 + 8 * k ) ) / 2.0 ) ; } int main ( ) { int k = 100 ; cout << twoEggDrop ( k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float findArea ( float a ) { float area ; area = 5 * sqrt ( 3 ) * a * a ; return area ; } float findVolume ( float a ) { float volume ; volume = ( ( float ) 5 / 12 ) * ( 3 + sqrt ( 5 ) ) * a * a * a ; return volume ; } int main ( ) { float a = 5 ; cout << " Area : ▁ " << findArea ( a ) << endl ; cout << " Volume : ▁ " << findVolume ( a ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int ways ( int n ) { int first = 2 ; int second = 3 ; int res = 0 ; for ( int i = 3 ; i <= n ; i ++ ) { res = first + second ; first = second ; second = res ; } return res ; } int main ( ) { int n = 7 ; cout << " Total ▁ ways ▁ are ▁ : ▁ " ; cout << ways ( n ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int n ) { double ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) ans += log10 ( i ) ; ans = ans * n ; return 1 + floor ( ans ) ; } int main ( ) { int n = 4 ; cout << countDigits ( n ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { float cm , meter , kilometer ; cm = 1000 ; meter = cm / 100.0 ; kilometer = cm / 100000.0 ; cout << " Length ▁ in ▁ meter ▁ = ▁ " << meter << " m " << " STRNEWLINE " ; cout << " Length ▁ in ▁ Kilometer ▁ = ▁ " << kilometer << " km " << " STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool everMeet ( int x1 , int x2 , int v1 , int v2 ) { if ( x1 < x2 && v1 <= v2 ) return false ; if ( x1 > x2 && v1 >= v2 ) return false ; if ( x1 < x2 ) { swap ( x1 , x2 ) ; swap ( v1 , v2 ) ; } return ( ( x1 - x2 ) % ( v1 - v2 ) == 0 ) ; } int main ( ) { int x1 = 5 , v1 = 8 , x2 = 4 , v2 = 7 ; if ( everMeet ( x1 , x2 , v1 , v2 ) ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
ll sumTillX ( ll x , ll n ) { ll odd = ceil ( n / 2.0 ) ; if ( x <= odd ) return x * x ; ll even = x - odd ; return ( ( odd * odd ) + ( even * even ) + even ) ; } int rangeSum ( int N , int L , int R ) { return sumTillX ( R , N ) - sumTillX ( L - 1 , N ) ; } int main ( ) { ll N = 10 , L = 1 , R = 6 ; cout << rangeSum ( N , L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printTwinPrime ( int n ) { bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n - 2 ; p ++ ) if ( prime [ p ] && prime [ p + 2 ] ) cout << " ( " << p << " , ▁ " << p + 2 << " ) " ; } int main ( ) { int n = 25 ; printTwinPrime ( 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 ; bool isCubeFree ( int n ) { if ( n == 1 ) return false ; for ( int i = 2 ; i * i * i <= n ; i ++ ) if ( n % ( i * i * i ) == 0 ) return false ; return true ; } void printCubeFree ( int n ) { for ( int i = 2 ; i <= n ; i ++ ) if ( isCubeFree ( i ) ) cout << i << " ▁ " ; } int main ( ) { int n = 20 ; printCubeFree ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int inversegrayCode ( int n ) { int inv = 0 ; for ( ; n ; n = n >> 1 ) inv ^= n ; return inv ; } int main ( ) { int n = 15 ; cout << inversegrayCode ( n ) << endl ; return 0 ; }

Accumulator variables: inv, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int productPrimeFactors ( int n ) { long long int product = 1 ; if ( n % 2 == 0 ) { product *= 2 ; while ( n % 2 == 0 ) n = n / 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { product = product * i ; while ( n % i == 0 ) n = n / i ; } } if ( n > 2 ) product = product * n ; return product ; } int main ( ) { int n = 44 ; cout << productPrimeFactors ( n ) ; return 0 ; }

Accumulator variables: product, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double calculateProbability ( int N ) { double probability = ( double ) N / ( N + 1 ) ; return probability ; } int main ( ) { int N ; double probabilityMax ; N = 1 ; probabilityMax = calculateProbability ( N ) ; cout << " Maximum ▁ Probability ▁ for ▁ N ▁ = ▁ " << N << " ▁ is , ▁ " << setprecision ( 4 ) << fixed << probabilityMax << endl ; N = 2 ; probabilityMax = calculateProbability ( N ) ; cout << " Maximum ▁ Probability ▁ for ▁ N ▁ = ▁ " << N << " ▁ is , ▁ " << setprecision ( 4 ) << fixed << probabilityMax << endl ; N = 10 ; probabilityMax = calculateProbability ( N ) ; cout << " Maximum ▁ Probability ▁ for ▁ N ▁ = ▁ " << N << " ▁ is , ▁ " << setprecision ( 4 ) << fixed << probabilityMax << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float mean ( float mid [ ] , int freq [ ] , int n ) { float sum = 0 , freqSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + mid [ i ] * freq [ i ] ; freqSum = freqSum + freq [ i ] ; } return sum / freqSum ; } float groupedSD ( float lower_limit [ ] , float upper_limit [ ] , int freq [ ] , int n ) { float mid [ n ] , sum = 0 , freqSum = 0 , sd ; for ( int i = 0 ; i < n ; i ++ ) { mid [ i ] = ( lower_limit [ i ] + upper_limit [ i ] ) / 2 ; sum = sum + freq [ i ] * mid [ i ] * mid [ i ] ; freqSum = freqSum + freq [ i ] ; } sd = sqrt ( ( sum - freqSum * mean ( mid , freq , n ) * mean ( mid , freq , n ) ) / ( freqSum - 1 ) ) ; return sd ; } int main ( ) { float lower_limit [ ] = { 50 , 61 , 71 , 86 , 96 } ; float upper_limit [ ] = { 60 , 70 , 85 , 95 , 100 } ; int freq [ ] = { 9 , 7 , 9 , 12 , 8 } ; int n = sizeof ( lower_limit ) / sizeof ( lower_limit [ 0 ] ) ; cout << groupedSD ( lower_limit , upper_limit , freq , n ) ; return 0 ; }

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

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n % 2 == 0 ) return false ; for ( int i = 3 ; i * i <= n ; i += 2 ) if ( n % i == 0 ) return false ; return true ; } int nextPrime ( int start ) { int next = start + 1 ; while ( ! isPrime ( next ) ) next ++ ; return next ; } bool areAdjacentPrimes ( int a , int b , int c ) { if ( ! isPrime ( a ) || ! isPrime ( b ) || ! isPrime ( c ) ) return false ; int next = nextPrime ( a ) ; if ( next != b ) return false ; if ( nextPrime ( b ) != c ) return false ; return true ; } int main ( ) { if ( areAdjacentPrimes ( 11 , 13 , 19 ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: i, next, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkSemiprime ( int num ) { int cnt = 0 ; for ( int i = 2 ; cnt < 2 && i * i <= num ; ++ i ) while ( num % i == 0 ) num /= i , ++ cnt ; if ( num > 1 ) ++ cnt ; return cnt == 2 ; } void semiprime ( int n ) { if ( checkSemiprime ( n ) ) cout << " True STRNEWLINE " ; else cout << " False STRNEWLINE " ; } int main ( ) { int n = 6 ; semiprime ( n ) ; n = 8 ; semiprime ( n ) ; return 0 ; }

Accumulator variables: num, stdc
Iterator variables: i
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 ; return sum ; } int main ( ) { int n = 10 ; cout << sumOfSeries ( n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int C [ n + 1 ] [ k + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int 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 maxcoefficientvalue ( int n ) { if ( n % 2 == 0 ) return binomialCoeff ( n , n / 2 ) ; else return binomialCoeff ( n , ( n + 1 ) / 2 ) ; } int main ( ) { int n = 4 ; cout << maxcoefficientvalue ( n ) << endl ; 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 LCM ( int x , int y , int z ) { int ans = ( ( x * y ) / ( __gcd ( x , y ) ) ) ; return ( ( z * ans ) / ( __gcd ( ans , z ) ) ) ; } int findDivisible ( int n , int x , int y , int z ) { int lcm = LCM ( x , y , z ) ; int ndigitnumber = pow ( 10 , n - 1 ) ; int reminder = ndigitnumber % lcm ; if ( reminder == 0 ) return ndigitnumber ; ndigitnumber += lcm - reminder ; if ( ndigitnumber < pow ( 10 , n ) ) return ndigitnumber ; else return 0 ; } int main ( ) { int n = 4 , x = 2 , y = 3 , z = 5 ; int res = findDivisible ( n , x , y , z ) ; if ( res != 0 ) cout << res ; else cout << " Not ▁ possible " ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float distance ( int x1 , int y1 , int x2 , int y2 ) { return sqrt ( pow ( x2 - x1 , 2 ) + pow ( y2 - y1 , 2 ) * 1.0 ) ; } int main ( ) { cout << distance ( 3 , 4 , 4 , 3 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDivisible ( string s ) { int n = s . length ( ) ; if ( s [ n - 1 ] != '5' and s [ n - 1 ] != '0' ) return false ; int sum = accumulate ( begin ( s ) , end ( s ) , 0 ) - '0' * n ; return ( sum % 3 == 0 ) ; } int main ( ) { string s = "15645746327462384723984023940239" ; isDivisible ( s ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; string s1 = "15645746327462384723984023940235" ; isDivisible ( s1 ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define V  4
#define INF  INT_MAX
int shortestPath ( int graph [ ] [ V ] , int u , int v , int k ) { if ( k == 0 && u == v ) return 0 ; if ( k == 1 && graph [ u ] [ v ] != INF ) return graph [ u ] [ v ] ; if ( k <= 0 ) return INF ; int res = INF ; for ( int i = 0 ; i < V ; i ++ ) { if ( graph [ u ] [ i ] != INF && u != i && v != i ) { int rec_res = shortestPath ( graph , i , v , k - 1 ) ; if ( rec_res != INF ) res = min ( res , graph [ u ] [ i ] + rec_res ) ; } } return res ; } int main ( ) { int graph [ V ] [ V ] = { { 0 , 10 , 3 , 2 } , { INF , 0 , INF , 7 } , { INF , INF , 0 , 6 } , { INF , INF , INF , 0 } } ; int u = 0 , v = 3 , k = 2 ; cout << " Weight ▁ of ▁ the ▁ shortest ▁ path ▁ is ▁ " << shortestPath ( graph , u , v , k ) ; return 0 ; }

Index/key variables: V, i, u, v
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <climits>
using namespace std ; #define V  4
#define INF  INT_MAX
int shortestPath ( int graph [ ] [ V ] , int u , int v , int k ) { int sp [ V ] [ V ] [ k + 1 ] ; for ( int e = 0 ; e <= k ; e ++ ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { sp [ i ] [ j ] [ e ] = INF ; if ( e == 0 && i == j ) sp [ i ] [ j ] [ e ] = 0 ; if ( e == 1 && graph [ i ] [ j ] != INF ) sp [ i ] [ j ] [ e ] = graph [ i ] [ j ] ; if ( e > 1 ) { for ( int a = 0 ; a < V ; a ++ ) { if ( graph [ i ] [ a ] != INF && i != a && j != a && sp [ a ] [ j ] [ e - 1 ] != INF ) sp [ i ] [ j ] [ e ] = min ( sp [ i ] [ j ] [ e ] , graph [ i ] [ a ] + sp [ a ] [ j ] [ e - 1 ] ) ; } } } } } return sp [ u ] [ v ] [ k ] ; } int main ( ) { int graph [ V ] [ V ] = { { 0 , 10 , 3 , 2 } , { INF , 0 , INF , 7 } , { INF , INF , 0 , 6 } , { INF , INF , INF , 0 } } ; int u = 0 , v = 3 , k = 2 ; cout << shortestPath ( graph , u , v , k ) ; return 0 ; }

Index/key variables: V, a, e, i, j, k, u, v
Accumulator variables: a, e, i, j
Iterator variables: a, e, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  8
#define INF  INT_MAX
int shortestDist ( int graph [ N ] [ N ] ) { int dist [ N ] ; dist [ N - 1 ] = 0 ; for ( int i = N - 2 ; i >= 0 ; i -- ) { dist [ i ] = INF ; for ( int j = i ; j < N ; j ++ ) { if ( graph [ i ] [ j ] == INF ) continue ; dist [ i ] = min ( dist [ i ] , graph [ i ] [ j ] + dist [ j ] ) ; } } return dist [ 0 ] ; } int main ( ) { int graph [ N ] [ N ] = { { INF , 1 , 2 , 5 , INF , INF , INF , INF } , { INF , INF , INF , INF , 4 , 11 , INF , INF } , { INF , INF , INF , INF , 9 , 5 , 16 , INF } , { INF , INF , INF , INF , INF , INF , 2 , INF } , { INF , INF , INF , INF , INF , INF , INF , 18 } , { INF , INF , INF , INF , INF , INF , INF , 13 } , { INF , INF , INF , INF , INF , INF , INF , 2 } , { INF , INF , INF , INF , INF , INF , INF , INF } } ; cout << shortestDist ( graph ) ; 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 ; class node { public : int data ; node * left ; node * right ; } ; void printGivenLevel ( node * root , int level ) ; int height ( node * node ) ; node * newNode ( int data ) ; void reverseLevelOrder ( node * root ) { int h = height ( root ) ; int i ; for ( i = h ; i >= 1 ; i -- ) printGivenLevel ( root , i ) ; } void printGivenLevel ( node * root , int level ) { if ( root == NULL ) return ; if ( level == 1 ) cout << root -> data << " ▁ " ; else if ( level > 1 ) { printGivenLevel ( root -> left , level - 1 ) ; printGivenLevel ( root -> right , level - 1 ) ; } } int height ( node * node ) { if ( node == NULL ) return 0 ; else { int lheight = height ( node -> left ) ; int rheight = height ( node -> right ) ; if ( lheight > rheight ) return ( lheight + 1 ) ; else return ( rheight + 1 ) ; } } node * newNode ( int data ) { node * Node = new node ( ) ; Node -> data = data ; Node -> left = NULL ; Node -> right = NULL ; return ( Node ) ; } int main ( ) { node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; cout << " Level ▁ Order ▁ traversal ▁ of ▁ binary ▁ tree ▁ is ▁ STRNEWLINE " ; reverseLevelOrder ( root ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: node