dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int processDiagonal ( vector < int > arr ) { int ans = 0 ; int getBit = 1 ; for ( int i = 0 ; i < 32 ; i ++ ) { int S = 0 ; int NS = 0 ; for ( auto j : arr ) { if ( getBit & j ) S += 1 ; else NS += 1 ; } if ( S > NS ) ans += pow ( 2 , i ) ; getBit <<= 1 ; } return ans ; } int findSum ( vector < vector < int > > mat ) { int i = 0 ; int j = 0 ; vector < int > priDiag ; while ( i < mat . size ( ) ) { priDiag . push_back ( mat [ i ] [ j ] ) ; i += 1 ; j += 1 ; } i = 0 ; j = mat . size ( ) - 1 ; vector < int > secDiag ; while ( i < mat . size ( ) ) { secDiag . push_back ( mat [ i ] [ j ] ) ; i += 1 ; j -= 1 ; } return processDiagonal ( priDiag ) + processDiagonal ( secDiag ) ; } int main ( ) { vector < vector < int > > mat { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; cout << findSum ( mat ) << endl ; }

Index/key variables: i, j
Accumulator variables: NS, S, ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumDifference ( int N ) { int sum1 = ( 1 << N ) , sum2 = 0 ; for ( int i = 1 ; i < N / 2 ; i ++ ) sum1 += ( 1 << i ) ; for ( int i = N / 2 ; i < N ; i ++ ) sum2 += ( 1 << i ) ; cout << sum1 - sum2 ; } int main ( ) { int N = 4 ; minimumDifference ( N ) ; return 0 ; }

Accumulator variables: i, stdc, sum1, sum2
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectCube ( int x ) { int cr = round ( cbrt ( x ) ) ; return ( cr * cr * cr == x ) ; } void canBePerfectCube ( int N , int K ) { if ( isPerfectCube ( N + K ) || isPerfectCube ( N - K ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; } int main ( ) { int N = 7 , K = 1 ; canBePerfectCube ( N , K ) ; N = 5 , K = 4 ; canBePerfectCube ( N , K ) ; N = 7 , K = 2 ; canBePerfectCube ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sqrtSearch ( int low , int high , int N ) { if ( low <= high ) { int mid = ( low + high ) / 2 ; if ( ( mid * mid <= N ) && ( ( mid + 1 ) * ( mid + 1 ) > N ) ) { return mid ; } else if ( mid * mid < N ) { return sqrtSearch ( mid + 1 , high , N ) ; } else { return sqrtSearch ( low , mid - 1 , N ) ; } } return low ; } int main ( ) { int N = 25 ; cout << sqrtSearch ( 0 , N , N ) << endl ; return 0 ; }

Accumulator variables: stdc
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 ) ; } void printAllDivisors ( int arr [ ] , int N ) { int g = arr [ 0 ] ; set < int > divisors ; for ( int i = 1 ; i < N ; i ++ ) { g = gcd ( arr [ i ] , g ) ; } for ( int i = 1 ; i * i <= g ; i ++ ) { if ( g % i == 0 ) { divisors . insert ( i ) ; if ( g / i != i ) divisors . insert ( g / i ) ; } } for ( auto & it : divisors ) cout << it << " ▁ " ; } int main ( ) { int arr [ ] = { 6 , 90 , 12 , 18 , 30 , 24 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printAllDivisors ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } int getSmallestPrimefactor ( int n ) { for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) return i ; } } int main ( ) { int N = 100 ; int a ; a = getSmallestPrimefactor ( N ) ; if ( isPrime ( N / a ) ) { cout << " - 1" ; } else { cout << N / a ; } return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkEqualNo ( int m , int n , int a , int b ) { if ( m <= n ) { if ( ( n - m ) % ( a + b ) == 0 ) { return true ; } else { return false ; } } else { return false ; } } int main ( ) { int M = 2 , N = 8 ; int A = 3 , B = 3 ; if ( checkEqualNo ( M , N , A , B ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool ispalin ( int num ) { string s = to_string ( num ) ; int st = 0 , ed = s . size ( ) - 1 ; while ( st <= ed ) { if ( s [ st ] != s [ ed ] ) return false ; st ++ ; ed -- ; } return true ; } void CalculateXORandOR ( int n ) { int CalculateXOR = 0 ; int CalculateOR = 0 ; int start = pow ( 10 , n - 1 ) ; int end = pow ( 10 , n ) - 1 ; for ( int i = start ; i <= end ; i ++ ) { if ( ispalin ( i ) ) { CalculateXOR = CalculateXOR ^ i ; CalculateOR = CalculateOR | i ; } } cout << " XOR ▁ = ▁ " << CalculateXOR ; cout << " ▁ OR ▁ = ▁ " << CalculateOR ; } int main ( ) { int n = 4 ; CalculateXORandOR ( n ) ; return 0 ; }

Index/key variables: ed, st
Accumulator variables: ed, i, st, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long pref [ 100001 ] ; int checkPalindrome ( int num ) { string str = to_string ( num ) ; int l = 0 , r = str . length ( ) - 1 ; while ( l < r ) { if ( str [ l ] != str [ r ] ) { return 0 ; } l ++ ; r -- ; } return num ; } void preCompute ( ) { for ( int i = 1 ; i <= 100000 ; ++ i ) { pref [ i ] = pref [ i - 1 ] + checkPalindrome ( i ) ; } } void printSum ( int L , int R ) { cout << pref [ R ] - pref [ L - 1 ] << endl ; } void printSumPalindromic ( int arr [ ] [ 2 ] , int Q ) { preCompute ( ) ; for ( int i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } } int main ( ) { int Q = 2 ; int arr [ ] [ 2 ] = { { 10 , 13 } , { 12 , 21 } } ; printSumPalindromic ( arr , Q ) ; return 0 ; }

Index/key variables: R, i, l, r
Accumulator variables: i, l, r, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int summation ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 == 1 ) sum += ( i * i ) ; else 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>
using namespace std ; int countPairs ( int n ) { int count = 0 ; for ( int x = 1 ; x < n ; x ++ ) { for ( int y = x + 1 ; y <= n ; y ++ ) { if ( ( y + x ) % ( y ^ x ) == 0 ) count ++ ; } } return count ; } int main ( ) { int n = 6 ; cout << countPairs ( n ) ; return 0 ; }

Accumulator variables: count, stdc, x, y
Iterator variables: x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPower ( int x , int y ) { int res1 = log ( y ) / log ( x ) ; double res2 = log ( y ) / log ( x ) ; return ( res1 == res2 ) ; } int countPower ( int arr [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( isPower ( arr [ i ] , arr [ j ] ) || isPower ( arr [ j ] , arr [ i ] ) ) res ++ ; return res ; } int main ( ) { int a [ ] = { 16 , 2 , 3 , 9 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << countPower ( a , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xor_all_elements ( int n ) { switch ( n & 3 ) { case 0 : return n ; case 1 : return 1 ; case 2 : return n + 1 ; case 3 : return 0 ; } } vector < int > findArray ( int xorr [ ] , int n ) { vector < int > arr ; int xor_all = xor_all_elements ( n ) ; int xor_adjacent = 0 ; for ( int i = 0 ; i < n - 1 ; i += 2 ) { xor_adjacent = xor_adjacent ^ xorr [ i ] ; } int last_element = xor_all ^ xor_adjacent ; arr . push_back ( last_element ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { last_element = xorr [ i ] ^ last_element ; arr . push_back ( last_element ) ; } return arr ; } int main ( ) { vector < int > arr ; int xorr [ ] = { 7 , 5 , 3 , 7 } ; int n = 5 ; arr = findArray ( xorr , n ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { cout << arr [ i ] << " ▁ " ; } }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfParts ( int * arr , int N ) { int sum_part1 = 0 , sum_part2 = 0 , sum_part3 = 0 , sum_part4 = 0 ; int totalsum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i + j < N - 1 ) { if ( i < j and i != j and i + j ) sum_part1 += ( arr + i * N ) [ j ] ; else if ( i != j ) sum_part2 += ( arr + i * N ) [ j ] ; } else { if ( i > j and i + j != N - 1 ) sum_part3 += ( arr + i * N ) [ j ] ; else { if ( i + j != N - 1 and i != j ) sum_part4 += ( arr + i * N ) [ j ] ; } } } } totalsum = sum_part1 + sum_part2 + sum_part3 + sum_part4 ; return totalsum ; } int main ( ) { int N = 4 ; int arr [ N ] [ N ] = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; cout << sumOfParts ( ( int * ) arr , N ) ; }

Index/key variables: N, j
Accumulator variables: i, j, stdc, sum_part1, sum_part2, sum_part3, sum_part4
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void ifPossible ( int X , int Y ) { if ( X > Y ) swap ( X , Y ) ; if ( ( X + Y ) % 5 == 0 and 3 * X >= 2 * Y ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int X = 33 , Y = 27 ; ifPossible ( X , Y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( int n ) { string ans = string ( n - 1 , ' F ' ) ; string even = ans + ' E ' ; string odd = ans + ' F ' ; cout << " Even : ▁ " << even << endl ; cout << " Odd : ▁ " << odd << endl ; } int main ( ) { int n = 2 ; findNumbers ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int log_a_to_base_b ( int a , int b ) { return log ( a ) / log ( b ) ; } int main ( ) { int a = 3 ; int b = 2 ; cout << log_a_to_base_b ( a , b ) << endl ; a = 256 ; b = 4 ; cout << log_a_to_base_b ( a , b ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findLargest ( int N ) { string largest = string ( N , ' F ' ) ; return largest ; } string findSmallest ( int N ) { string smallest = "1" + string ( ( N - 1 ) , '0' ) ; return smallest ; } void print ( int largest ) { cout << " Largest : ▁ " << findLargest ( largest ) << endl ; cout << " Smallest : ▁ " << findSmallest ( largest ) << endl ; } int main ( ) { int N = 4 ; print ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int prevPowerofK ( int n , int k ) { int p = ( int ) ( log ( n ) / log ( k ) ) ; return ( int ) pow ( k , p ) ; } int nextPowerOfK ( int n , int k ) { return prevPowerofK ( n , k ) * k ; } void printResult ( int n , int k ) { cout << prevPowerofK ( n , k ) << " ▁ " << nextPowerOfK ( n , k ) << endl ; } int main ( ) { int n = 25 , k = 3 ; printResult ( n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canMake ( int n , int ar [ ] ) { int sum = 0 , maxx = -1 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ar [ i ] ; maxx = max ( maxx , ar [ i ] ) ; } if ( n == 1 sum % 2 == 1 sum - maxx < maxx ) { cout << " No STRNEWLINE " ; } else { cout << " Yes STRNEWLINE " ; } } int main ( ) { int n = 6 ; int arr [ ] = { 1 , 1 , 2 , 3 , 6 , 11 } ; canMake ( n , arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  int
using namespace std ; long long pref [ 100010 ] ; int isPerfectSquare ( long long int x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ? x : 0 ; } void compute ( ) { for ( int i = 1 ; i <= 100000 ; ++ i ) { pref [ i ] = pref [ i - 1 ] + isPerfectSquare ( i ) ; } } void printSum ( int L , int R ) { int sum = pref [ R ] - pref [ L - 1 ] ; cout << sum << " ▁ " ; } int main ( ) { compute ( ) ; int Q = 4 ; int arr [ ] [ 2 ] = { { 1 , 10 } , { 1 , 100 } , { 2 , 25 } , { 4 , 50 } } ; for ( int i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } return 0 ; }

Index/key variables: R, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void factors ( int n , int i ) { if ( i <= n ) { if ( n % i == 0 ) { cout << i << " ▁ " ; } factors ( n , i + 1 ) ; } } int main ( ) { int N = 16 ; factors ( N , 1 ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxValue ( int n ) { return n ; } int main ( ) { int n = 1 ; cout << maxValue ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( int n ) { int ans = ( n * n / 4 ) ; return ans ; } int main ( ) { int n = 10 ; cout << solve ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; void printMultiples ( int N ) { for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { cout << ( i * j ) << " ▁ " ; } cout << endl ; } } int main ( ) { int N = 5 ; printMultiples ( N ) ; return 0 ; }

Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nature_of_roots ( int a , int b , int c ) { if ( a == 0 ) { cout << " Not ▁ a ▁ Quadratic ▁ Equation " << endl ; return ; } int D = b * b - 4 * a * c ; if ( D > 0 ) { cout << " Real ▁ Roots " << endl ; } else if ( D == 0 ) { cout << " Equal ▁ Roots " << endl ; } else { cout << " Imaginary ▁ Roots " << endl ; } } void checkForAllTestCase ( ) { cout << " Testcase " << " TABSYMBOL a TABSYMBOL b TABSYMBOL c TABSYMBOL Actual ▁ Output " << endl ; cout << endl ; int a , b , c ; int testcase = 1 ; while ( testcase <= 13 ) { if ( testcase == 1 ) { a = 0 ; b = 50 ; c = 50 ; } else if ( testcase == 2 ) { a = 1 ; b = 50 ; c = 50 ; } else if ( testcase == 3 ) { a = 50 ; b = 50 ; c = 50 ; } else if ( testcase == 4 ) { a = 99 ; b = 50 ; c = 50 ; } else if ( testcase == 5 ) { a = 100 ; b = 50 ; c = 50 ; } else if ( testcase == 6 ) { a = 50 ; b = 0 ; c = 50 ; } else if ( testcase == 7 ) { a = 50 ; b = 1 ; c = 50 ; } else if ( testcase == 8 ) { a = 50 ; b = 99 ; c = 50 ; } else if ( testcase == 9 ) { a = 50 ; b = 100 ; c = 50 ; } else if ( testcase == 10 ) { a = 50 ; b = 50 ; c = 0 ; } else if ( testcase == 11 ) { a = 50 ; b = 50 ; c = 1 ; } else if ( testcase == 12 ) { a = 50 ; b = 50 ; c = 99 ; } else if ( testcase == 13 ) { a = 50 ; b = 50 ; c = 100 ; } cout << " TABSYMBOL " << testcase << " TABSYMBOL " << a << " TABSYMBOL " << b << " TABSYMBOL " << c << " TABSYMBOL " ; nature_of_roots ( a , b , c ) ; cout << endl ; testcase ++ ; } } int main ( ) { checkForAllTestCase ( ) ; return 0 ; }

Accumulator variables: stdc, testcase
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isPossible ( int N , int S , int C , int H , int L , int T ) { int total_time_required = S * C * H ; int available_time_after_vacation = ( N - L ) * T ; if ( available_time_after_vacation >= total_time_required ) return 1 ; return 0 ; } int main ( ) { int N = 12 , S = 5 , C = 8 , H = 3 , L = 2 , T = 20 ; if ( isPossible ( N , S , C , H , L , T ) ) cout << " Yes " << endl ; else cout << " No " << endl ; N = 1 , S = 2 , C = 3 , H = 4 , L = 5 , T = 6 ; if ( isPossible ( N , S , C , H , L , T ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximum ( int x , int y ) { return ( ( x + y + abs ( x - y ) ) / 2 ) ; } int minimum ( int x , int y ) { return ( ( x + y - abs ( x - y ) ) / 2 ) ; } int main ( ) { int x = 99 , y = 18 ; cout << " Maximum : ▁ " << maximum ( x , y ) << endl ; cout << " Minimum : ▁ " << minimum ( x , y ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void SubarraysWithSumS ( int n , int k , int s ) { for ( int i = 0 ; i < k ; i ++ ) cout << s << " ▁ " ; for ( int i = k ; i < n ; i ++ ) cout << s + 1 << " ▁ " ; } int main ( ) { int n = 4 , k = 2 , s = 3 ; SubarraysWithSumS ( n , k , s ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pay ( int n ) { int cuts = int ( log ( n ) / log ( 2 ) ) ; return cuts ; } int main ( ) { int n = 5 ; int cuts = pay ( n ) ; cout << cuts << endl ; n = 15 ; cuts = pay ( n ) ; cout << ( cuts ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100000 ; int max_prime [ MAX ] ; int min_prime [ MAX ] ; void sieve ( int n ) { for ( int i = 2 ; i <= n ; ++ i ) { if ( min_prime [ i ] > 0 ) { continue ; } min_prime [ i ] = i ; max_prime [ i ] = i ; int j = i + i ; while ( j <= n ) { if ( min_prime [ j ] == 0 ) { min_prime [ j ] = i ; } max_prime [ j ] = i ; j += i ; } } } void findSum ( int arr [ ] , int n ) { sieve ( MAX ) ; for ( int i = 0 ; i < n ; i ++ ) { int sum = min_prime [ arr [ i ] ] + max_prime [ arr [ i ] ] ; cout << sum << " ▁ " ; } } int main ( ) { int arr [ ] = { 5 , 10 , 15 , 20 , 25 , 30 } ; int n = sizeof ( arr ) / sizeof ( int ) ; findSum ( arr , n ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pairCount ( int n , int m ) { int cnt = 0 , b , a ; for ( b = 0 ; b <= sqrt ( m ) ; b ++ ) { a = m - b * b ; if ( a * a + b == n ) { cnt ++ ; } } return cnt ; } int main ( ) { int n = 9 , m = 3 ; cout << pairCount ( n , m ) << endl ; return 0 ; }

Accumulator variables: b, cnt, stdc
Iterator variables: b
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define int  long long
const int maxin = 100001 ; int divisors [ maxin ] ; void Calc_Max_Div ( int arr [ ] , int n ) { bool vis [ maxin ] ; memset ( vis , 1 , maxin ) ; vis [ 0 ] = vis [ 1 ] = 0 ; for ( int i = 1 ; i <= maxin ; i ++ ) divisors [ i ] = i ; for ( int i = 4 ; i <= maxin ; i += 2 ) { vis [ i ] = 0 ; divisors [ i ] = i / 2 ; } for ( int i = 3 ; i <= maxin ; i += 2 ) { if ( divisors [ i ] != i ) { divisors [ i ] = i / divisors [ i ] ; } if ( vis [ i ] == 1 ) { for ( int j = i * i ; j < maxin ; j += i ) { vis [ j ] = 0 ; if ( divisors [ j ] == j ) divisors [ j ] = i ; } } } for ( int i = 0 ; i < n ; i ++ ) { if ( divisors [ arr [ i ] ] == arr [ i ] ) cout << " - 1 ▁ " ; else cout << divisors [ arr [ i ] ] << " ▁ " ; } } int32_t main ( ) { int arr [ ] = { 5 , 6 , 7 , 8 , 9 , 10 } ; int n = sizeof ( arr ) / sizeof ( int ) ; Calc_Max_Div ( arr , n ) ; return 0 ; }

Index/key variables: i, j, maxin
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int sumOfDigit ( int n , int b ) { int unitDigit , sum = 0 ; while ( n > 0 ) { unitDigit = n % b ; sum += unitDigit ; n = n / b ; } return sum ; } int main ( ) { int n = 50 ; int b = 2 ; cout << sumOfDigit ( n , b ) ; return 0 ; }

Accumulator variables: sum
C++ program:
#include <iostream>
using namespace std ; int nthDigit ( int a , int n , int b ) { for ( int i = 1 ; i < n ; i ++ ) a = a / b ; return a % b ; } int main ( ) { int a = 100 ; int n = 3 ; int b = 4 ; cout << nthDigit ( a , n , b ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100001 ; vector < int > primes ; void initialize ( ) { bool numbers [ MAX ] = { } ; int n = MAX ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( ! numbers [ i ] ) for ( int j = i * i ; j <= n ; j += i ) numbers [ j ] = true ; for ( int i = 2 ; i <= n ; i ++ ) if ( numbers [ i ] == false ) primes . push_back ( i ) ; } void findNums ( int num ) { bool ans = false ; int first = -1 , second = -1 , third = -1 ; for ( int i = 0 ; i < num ; i ++ ) { first = primes [ i ] ; for ( int j = 0 ; j < num ; j ++ ) { second = primes [ j ] ; third = num - first - second ; if ( binary_search ( primes . begin ( ) , primes . end ( ) , third ) ) { ans = true ; break ; } } if ( ans ) break ; } if ( ans ) cout << first << " ▁ " << second << " ▁ " << third << endl ; else cout << -1 << endl ; } int main ( ) { int n = 101 ; initialize ( ) ; findNums ( n ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Boolean variables: ans
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printmaxSubseq ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) cout << arr [ i ] << " ▁ " ; else cout << arr [ i ] << " STRNEWLINE " ; } } int main ( ) { int arr [ ] = { 9 , 8 , 11 , 13 , 10 , 15 , 14 , 16 , 20 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printmaxSubseq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSum ( int N , int L , int R ) { if ( L > R ) { return 0 ; } if ( N == 1 ) { return R - L + 1 ; } if ( N > 1 ) { return ( N - 2 ) * ( R - L ) + 1 ; } } int main ( ) { int N = 4 , L = 4 , R = 6 ; cout << countSum ( N , L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define lli  long long int
lli solve ( lli arr [ ] , lli n , lli k ) { lli i , minx = INT_MAX ; for ( i = 0 ; i < n ; i ++ ) { minx = min ( minx , arr [ i ] ) ; } lli decrements = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] - minx ) % k != 0 ) { return -1 ; } else { decrements += ( ( arr [ i ] - minx ) / k ) ; } } return decrements ; } int main ( ) { lli n , k ; n = 3 ; k = 3 ; lli arr [ n ] = { 12 , 9 , 15 } ; cout << solve ( arr , n , k ) ; }

Index/key variables: i, n
Accumulator variables: decrements, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int C [ k + 1 ] ; memset ( C , 0 , sizeof ( C ) ) ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } int count_of_subarrays ( int N ) { int count = binomialCoeff ( 2 * N - 1 , N ) ; return count ; } int main ( ) { int N = 3 ; cout << count_of_subarrays ( N ) << " STRNEWLINE " ; }

Index/key variables: j, k
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void distribution ( int n , int k , int l , int r , int S , int Sk ) { int a [ n ] ; int len = k , temp , rem , s ; int diff = S - Sk ; for ( int i = 0 ; i < len ; i ++ ) { temp = Sk / k ; rem = Sk % k ; if ( temp + rem >= l && temp + rem <= r ) { a [ i ] = temp ; } else if ( temp + rem > r ) { a [ i ] = r ; } else if ( temp + rem < r ) { cout << " - 1" ; return ; } Sk = Sk - a [ i ] ; k = k - 1 ; } if ( Sk > 0 ) { cout << " - 1" ; return ; } if ( len ) { k = n - len ; for ( int i = len ; i < n ; i ++ ) { temp = diff / k ; rem = diff % k ; if ( temp + rem >= l && temp + rem <= r ) { a [ i ] = temp ; } else if ( temp + rem > r ) { a [ i ] = r ; } else if ( temp + rem < r ) { cout << " - 1" ; return ; } diff = diff - a [ i ] ; k = k - 1 ; } if ( diff ) { cout << " - 1" ; return ; } } for ( int i = 0 ; i < n ; i ++ ) { cout << a [ i ] << " ▁ " ; } } int main ( ) { int n = 5 , k = 3 , l = 1 , r = 5 , S = 13 , Sk = 9 ; distribution ( n , k , l , r , S , Sk ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_index ( int p [ ] , int n ) { int ans = 0 ; int mini = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] <= mini ) mini = p [ i ] ; if ( mini == p [ i ] ) ans ++ ; } return ans ; } int main ( ) { int P [ ] = { 4 , 2 , 5 , 1 , 3 } ; int n = sizeof ( P ) / sizeof ( int ) ; cout << min_index ( P , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int equal_xor_sum ( int arr [ ] , int n ) { int Sum = 0 ; int Xor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { Sum = Sum + arr [ i ] ; Xor = Xor ^ arr [ i ] ; } if ( Sum == Xor ) cout << " YES " ; else cout << " NO " ; return 0 ; } int main ( ) { int arr [ ] = { 6 , 3 , 7 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; equal_xor_sum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i