dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
ll factorial ( int f ) { ll fact = 1 ; for ( int i = 2 ; i <= f ; i ++ ) fact *= ( ll ) i ; return fact ; } ll findPermutation ( int N , int M ) { ll permutation = factorial ( N + M - 1 ) / ( factorial ( N ) * factorial ( M - 1 ) ) ; return permutation ; } int main ( ) { int N = 3 , M = 3 ; cout << findPermutation ( N , M ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ull  unsigned long long
void findCount ( int n ) { ull a = 1 , b = 0 , c = 0 ; int x = n / 60 ; a = ( ull ) pow ( 32 , x ) ; x = 60 * x ; for ( int i = x + 1 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { b += a ; a = 0 ; } if ( i % 5 == 0 ) { c += b ; b = 0 ; } if ( i % 12 == 0 ) { a += ( 2 * c ) ; c = 0 ; } } cout << " a ▁ = ▁ " << a << " , ▁ " ; cout << " b ▁ = ▁ " << b << " , ▁ " ; cout << " c ▁ = ▁ " << c ; } int main ( ) { int n = 72 ; findCount ( n ) ; return 0 ; }

Accumulator variables: a, b, c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int n ) { return ( n == 1 n == 0 ) ? 1 : factorial ( n - 1 ) * n ; } int gcdOfFactorial ( int arr [ ] , int n ) { int minm = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) minm = minm > arr [ i ] ? arr [ i ] : minm ; return factorial ( minm ) ; } int main ( ) { int arr [ ] = { 9 , 12 , 122 , 34 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << gcdOfFactorial ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
ll sum ( int n ) { if ( n == 1 ) return 1 ; else return ( ( ll ) pow ( n , n ) + sum ( n - 1 ) ) ; } int main ( ) { int n = 2 ; cout << sum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define ll  long long
using namespace std ; const int mod = 1000000007 ; ll power ( ll a , ll n ) { if ( n == 0 ) return 1 ; ll p = power ( a , n / 2 ) % mod ; p = ( p * p ) % mod ; if ( n & 1 ) p = ( p * a ) % mod ; return p ; } int countPermutations ( int n ) { if ( n == 1 ) { return 0 ; } return ( power ( 2 , n - 1 ) - 2 ) % mod ; } int main ( ) { int n = 5 ; cout << countPermutations ( n ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long NumberofWays ( int n ) { long long x = ( 1LL * ( n ) * ( n - 1 ) * ( n - 2 ) * ( n - 3 ) ) / ( 4 * 3 * 2 * 1 ) ; long long y = ( 1LL * ( n ) * ( n - 1 ) * ( n - 2 ) * ( n - 3 ) ) ; return ( 1LL * x * y ) ; } int main ( ) { int n = 4 ; cout << NumberofWays ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTerm ( int N ) { int nth = 0 ; nth = ( N * N * ( N + 1 ) ) / 2 ; return nth ; } int main ( ) { int N = 5 ; cout << nthTerm ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( int n ) { int i = 1 ; while ( i <= n ) { cout << ( ( 2 * i ) - 1 ) << " ▁ " ; i ++ ; } } int main ( ) { int n = 3 ; findNumbers ( n ) ; }

Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMissingNums ( int even [ ] , int sizeEven , int odd [ ] , int sizeOdd ) { int minEven = INT_MAX ; int maxEven = INT_MIN ; int minOdd = INT_MAX ; int maxOdd = INT_MIN ; int sumEvenArr = 0 , sumOddArr = 0 ; for ( int i = 0 ; i < sizeEven ; i ++ ) { minEven = min ( minEven , even [ i ] ) ; maxEven = max ( maxEven , even [ i ] ) ; sumEvenArr += even [ i ] ; } for ( int i = 0 ; i < sizeOdd ; i ++ ) { minOdd = min ( minOdd , odd [ i ] ) ; maxOdd = max ( maxOdd , odd [ i ] ) ; sumOddArr += odd [ i ] ; } int totalTerms = 0 , reqSum = 0 ; totalTerms = minEven / 2 ; int evenSumMin = totalTerms * ( totalTerms + 1 ) ; totalTerms = maxEven / 2 ; int evenSumMax = totalTerms * ( totalTerms + 1 ) ; reqSum = evenSumMax - evenSumMin + minEven ; cout << " Even ▁ = ▁ " << reqSum - sumEvenArr << " STRNEWLINE " ; totalTerms = ( minOdd / 2 ) + 1 ; int oddSumMin = totalTerms * totalTerms ; totalTerms = ( maxOdd / 2 ) + 1 ; int oddSumMax = totalTerms * totalTerms ; reqSum = oddSumMax - oddSumMin + minOdd ; cout << " Odd ▁ = ▁ " << reqSum - sumOddArr ; } int main ( ) { int even [ ] = { 6 , 4 , 8 , 14 , 10 } ; int sizeEven = sizeof ( even ) / sizeof ( even [ 0 ] ) ; int odd [ ] = { 7 , 5 , 3 , 11 , 13 } ; int sizeOdd = sizeof ( odd ) / sizeof ( odd [ 0 ] ) ; findMissingNums ( even , sizeEven , odd , sizeOdd ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sumEvenArr, sumOddArr
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinimum ( int x , int y ) { int low = 0 , high = y ; while ( low <= high ) { int mid = ( low + high ) >> 1 ; if ( ( mid * 2 + ( y - mid ) ) >= x ) high = mid - 1 ; else low = mid + 1 ; } return low ; } int main ( ) { int x = 6 , y = 5 ; cout << findMinimum ( x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; void getResult ( int n ) { int proOdd = 1 ; int proEven = 1 ; string num = to_string ( n ) ; for ( int i = 0 ; i < num . size ( ) ; i ++ ) if ( i % 2 == 0 ) proOdd = proOdd * ( num [ i ] - '0' ) ; else proEven = proEven * ( num [ i ] - '0' ) ; if ( proOdd == proEven ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int n = 4324 ; getResult ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfDigits ( int x ) { int sum = 0 ; while ( x != 0 ) { sum += x % 10 ; x = x / 10 ; } return sum ; } int countNumbers ( int l , int r ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( i % 2 == 0 && sumOfDigits ( i ) % 3 == 0 ) count ++ ; } return count ; } int main ( ) { int l = 1000 , r = 6000 ; cout << countNumbers ( l , r ) ; return 0 ; }

Accumulator variables: count, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinSum ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] * ( n - i ) ; return sum ; } int main ( ) { int arr [ ] = { 3 , 5 , 7 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMinSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxLenSubArr ( int a [ ] , int n ) { int count , j ; int cm = 1 , max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) max = a [ i ] ; } for ( int i = 0 ; i < n - 1 ; ) { count = 1 ; if ( a [ i ] == a [ i + 1 ] && a [ i ] == max ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( a [ j ] == max ) { count ++ ; i ++ ; } else break ; } if ( count > cm ) cm = count ; } else i ++ ; } return cm ; } int main ( ) { int arr [ ] = { 6 , 1 , 6 , 6 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxLenSubArr ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
ll minSum ( int arr [ ] , int n , int x ) { ll sum = 0 ; int largestDivisible = -1 , minimum = arr [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( arr [ i ] % x == 0 && largestDivisible < arr [ i ] ) largestDivisible = arr [ i ] ; if ( arr [ i ] < minimum ) minimum = arr [ i ] ; } if ( largestDivisible == -1 ) return sum ; ll sumAfterOperation = sum - minimum - largestDivisible + ( x * minimum ) + ( largestDivisible / x ) ; return min ( sum , sumAfterOperation ) ; } int main ( ) { int arr [ ] = { 5 , 5 , 5 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int x = 3 ; cout << minSum ( arr , n , x ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkSpecialPrime ( bool * sieve , int num ) { while ( num ) { if ( ! sieve [ num ] ) { return false ; } num /= 10 ; } return true ; } void findSpecialPrime ( int N ) { bool sieve [ N * 10 ] ; memset ( sieve , true , sizeof ( sieve ) ) ; sieve [ 0 ] = sieve [ 1 ] = false ; for ( long long i = 2 ; i <= N * 10 ; i ++ ) { if ( sieve [ i ] ) { for ( long long j = i * i ; j <= N * 10 ; j += i ) { sieve [ j ] = false ; } } } while ( true ) { if ( checkSpecialPrime ( sieve , N ) ) { cout << N << ' ' ; break ; } else N ++ ; } } int main ( ) { int N = 379 ; findSpecialPrime ( N ) ; N = 100 ; findSpecialPrime ( N ) ; return 0 ; }

Index/key variables: i, j, num
Accumulator variables: N, i, j, num, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minMoves ( long long n ) { string s = to_string ( n ) ; int ans = INT_MAX ; int len = s . size ( ) ; for ( int i = 0 ; i < len ; ++ i ) { for ( int j = 0 ; j < len ; ++ j ) { if ( i == j ) continue ; string t = s ; int cur = 0 ; for ( int k = i ; k < len - 1 ; ++ k ) { swap ( t [ k ] , t [ k + 1 ] ) ; ++ cur ; } for ( int k = j - ( j > i ) ; k < len - 2 ; ++ k ) { swap ( t [ k ] , t [ k + 1 ] ) ; ++ cur ; } int pos = -1 ; for ( int k = 0 ; k < len ; ++ k ) { if ( t [ k ] != '0' ) { pos = k ; break ; } } for ( int k = pos ; k > 0 ; -- k ) { swap ( t [ k ] , t [ k - 1 ] ) ; ++ cur ; } long long nn = atoll ( t . c_str ( ) ) ; if ( nn % 25 == 0 ) ans = min ( ans , cur ) ; } } if ( ans == INT_MAX ) return -1 ; return ans ; } int main ( ) { long long n = 509201 ; cout << minMoves ( n ) ; return 0 ; }

Index/key variables: k
Accumulator variables: stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getPairs ( int a [ ] ) { int n = sizeof ( a [ 0 ] ) ; int count = ( n * ( n - 1 ) ) / 2 ; return count ; } int main ( ) { int a [ ] = { 2 , 4 , 3 , 1 } ; cout << getPairs ( a ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSquares ( int row , int column ) { int topLeft = min ( row , column ) - 1 ; int bottomRight = 8 - max ( row , column ) ; int topRight = min ( row , 9 - column ) - 1 ; int bottomLeft = 8 - max ( row , 9 - column ) ; return ( topLeft + topRight + bottomRight + bottomLeft ) ; } int main ( ) { int row = 4 , column = 4 ; cout << countSquares ( row , column ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canTakeDown ( int bishopX , int bishopY , int pawnX , int pawnY ) { if ( pawnX - bishopX == pawnY - bishopY ) return true ; else if ( - pawnX + bishopX == pawnY - bishopY ) return true ; else return false ; } int main ( ) { int bishopX = 5 , bishopY = 5 ; int pawnX = 1 , pawnY = 1 ; if ( canTakeDown ( bishopX , bishopY , pawnX , pawnY ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  1000005
int primeFactors [ N ] ; void findPrimeFactors ( ) { for ( int i = 2 ; i < N ; i ++ ) if ( primeFactors [ i ] == 0 ) for ( int j = i ; j < N ; j += i ) primeFactors [ j ] = primeFactors [ j / i ] + 1 ; for ( int i = 1 ; i < N ; i ++ ) primeFactors [ i ] += primeFactors [ i - 1 ] ; } int main ( ) { findPrimeFactors ( ) ; int a = 6 , b = 3 ; cout << primeFactors [ a ] - primeFactors [ b ] ; return 0 ; }

Index/key variables: N, a, b, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digitSum ( int n ) { int ans = 0 ; while ( n ) { ans += n % 10 ; n /= 10 ; } return ans ; } int findInt ( int n , int m ) { int minDigit = floor ( m / 9 ) ; int start = pow ( 10 , minDigit ) - ( int ) pow ( 10 , minDigit ) % n ; while ( start < INT_MAX ) { if ( digitSum ( start ) == m ) return start ; else start += n ; } return -1 ; } int main ( ) { int n = 13 , m = 32 ; cout << findInt ( n , m ) ; return 0 ; }

Accumulator variables: ans, n, start, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestDivisor ( int n ) { int mx = sqrt ( n ) ; for ( int i = 2 ; i <= mx ; i ++ ) if ( n % i == 0 ) return i ; return n ; } int maxSum ( int n ) { long long res = n ; while ( n > 1 ) { int divi = smallestDivisor ( n ) ; n /= divi ; res += n ; } return res ; } int main ( ) { int n = 34 ; cout << maxSum ( n ) ; return 0 ; }

Accumulator variables: i, n, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int n , int k , int arr [ ] ) { int sum = arr [ 0 ] , maxVal = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { sum += arr [ i ] ; maxVal = max ( maxVal , arr [ i ] ) ; } if ( ( float ) maxVal > ( float ) ( sum + k ) / n ) return false ; return true ; } int main ( ) { int k = 8 ; int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isPossible ( n , k , arr ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxResult ( int n , int a , int b , int c ) { int maxVal = 0 ; for ( int i = 0 ; i <= n ; i += a ) { for ( int j = 0 ; j <= n - i ; j += b ) { float z = ( float ) ( n - ( i + j ) ) / ( float ) ( c ) ; if ( floor ( z ) == ceil ( z ) ) { int x = i / a ; int y = j / b ; maxVal = max ( maxVal , x + y + ( int ) z ) ; } } } return maxVal ; } int main ( ) { int n = 10 , a = 5 , b = 3 , c = 4 ; cout << maxResult ( n , a , b , c ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool EqualNumbers ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { while ( a [ i ] % 2 == 0 ) a [ i ] /= 2 ; while ( a [ i ] % 3 == 0 ) a [ i ] /= 3 ; if ( a [ i ] != a [ 0 ] ) { return false ; } } return true ; } int main ( ) { int a [ ] = { 50 , 75 , 150 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; if ( EqualNumbers ( a , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long max_gcd ( long n , long p ) { int count = 0 ; long gcd = 1 ; while ( p % 2 == 0 ) { p >>= 1 ; count ++ ; } if ( count > 0 ) gcd *= ( long ) pow ( 2 , count / n ) ; for ( long i = 3 ; i <= sqrt ( p ) ; i += 2 ) { count = 0 ; while ( p % i == 0 ) { count ++ ; p = p / i ; } if ( count > 0 ) { gcd *= ( long ) pow ( i , count / n ) ; } } if ( p > 2 ) gcd *= ( long ) pow ( p , 1 / n ) ; return gcd ; } int main ( ) { long n = 3 ; long p = 80 ; cout << max_gcd ( n , p ) ; }

Accumulator variables: count, gcd, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int n ) { if ( n == 2 ) return 4 ; int num = ( ( n / 2 ) + 1 ) ; int max = n % num ; int count = n - max ; return count ; } int main ( ) { int n = 5 ; cout << countPairs ( n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkSub ( string sub , string s ) { int j = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) if ( sub [ j ] == s [ i ] ) j ++ ; return j == ( int ) sub . size ( ) ; } int getMultiple ( string s ) { for ( int i = 0 ; i < 1e3 ; i += 8 ) { if ( checkSub ( to_string ( i ) , s ) ) return i ; } return -1 ; } int main ( ) { string s = "3454" ; cout << getMultiple ( s ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getResult ( int n ) { string st = to_string ( n ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { int d = st [ i ] - 48 ; if ( n % d == 0 ) { return " Yes " ; } } return " No " ; } int main ( ) { int n = 9876543 ; cout << getResult ( n ) ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; pair < double , double > findingValues ( double m , double n , double mth , double nth ) { double d = ( abs ( mth - nth ) ) / abs ( ( m - 1 ) - ( n - 1 ) ) ; double a = mth - ( ( m - 1 ) * d ) ; return make_pair ( a , d ) ; } double findSum ( int m , int n , int mth , int nth , int p ) { pair < double , double > ad ; ad = findingValues ( m , n , mth , nth ) ; double a = ad . first , d = ad . second ; double sum = ( p * ( 2 * a + ( p - 1 ) * d ) ) / 2 ; return sum ; } int main ( ) { double m = 6 , n = 10 , mTerm = 12 , nTerm = 20 , p = 5 ; cout << findSum ( m , n , mTerm , nTerm , p ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void powerfulIntegers ( int x , int y , int bound ) { set < int > s ; vector < int > powersOfY ; int i ; powersOfY . push_back ( 1 ) ; for ( i = y ; i < bound && y != 1 ; i = i * y ) powersOfY . push_back ( i ) ; i = 0 ; while ( true ) { int xPowI = pow ( x , i ) ; for ( auto j = powersOfY . begin ( ) ; j != powersOfY . end ( ) ; ++ j ) { int num = xPowI + * j ; if ( num <= bound ) s . insert ( num ) ; else break ; } if ( xPowI >= bound x == 1 ) break ; i ++ ; } set < int > :: iterator itr ; for ( itr = s . begin ( ) ; itr != s . end ( ) ; itr ++ ) { cout << * itr << " ▁ " ; } } int main ( ) { int x = 2 , y = 3 , bound = 10 ; powerfulIntegers ( x , y , bound ) ; return 0 ; }

Accumulator variables: i, itr, stdc
Iterator variables: i, itr, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void candies ( int n , int k ) { int count = 0 ; int ind = 1 ; int arr [ k ] ; memset ( arr , 0 , sizeof ( arr ) ) ; while ( n ) { int f1 = ( ind - 1 ) * k ; int f2 = ind * k ; int sum1 = ( f1 * ( f1 + 1 ) ) / 2 ; int sum2 = ( f2 * ( f2 + 1 ) ) / 2 ; int res = sum2 - sum1 ; if ( res <= n ) { count ++ ; n -= res ; ind ++ ; } { int i = 0 ; int term = ( ( ind - 1 ) * k ) + 1 ; while ( n > 0 ) { if ( term <= n ) { arr [ i ++ ] = term ; n -= term ; term ++ ; } else { arr [ i ++ ] = n ; n = 0 ; } } } } for ( int i = 0 ; i < k ; i ++ ) arr [ i ] += ( count * ( i + 1 ) ) + ( k * ( count * ( count - 1 ) ) / 2 ) ; for ( int i = 0 ; i < k ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int n = 10 , k = 3 ; candies ( n , k ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: count, i, ind, n, stdc, term
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void candies ( int n , int k ) { int count = 0 ; int ind = 1 ; int arr [ k ] ; memset ( arr , 0 , sizeof ( arr ) ) ; int low = 0 , high = n ; while ( low <= high ) { int mid = ( low + high ) >> 1 ; int sum = ( mid * ( mid + 1 ) ) >> 1 ; if ( sum <= n ) { count = mid / k ; low = mid + 1 ; } else { high = mid - 1 ; } } int last = ( count * k ) ; n -= ( last * ( last + 1 ) ) / 2 ; int i = 0 ; int term = ( count * k ) + 1 ; while ( n ) { if ( term <= n ) { arr [ i ++ ] = term ; n -= term ; term ++ ; } else { arr [ i ] += n ; n = 0 ; } } for ( int i = 0 ; i < k ; i ++ ) arr [ i ] += ( count * ( i + 1 ) ) + ( k * ( count * ( count - 1 ) ) / 2 ) ; for ( int i = 0 ; i < k ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int n = 7 , k = 4 ; candies ( n , k ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: i, n, stdc, term
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int printSmallest ( int a [ 3 ] ) { int sum , sum1 ; sort ( a , a + 3 ) ; int i , j , k , num ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( a [ i ] % 3 == 0 ) return a [ i ] ; } for ( i = 0 ; i < 3 ; i ++ ) { for ( j = 0 ; j < 3 ; j ++ ) { num = ( a [ i ] * 10 ) + a [ j ] ; if ( num % 3 == 0 ) return num ; } } return a [ 0 ] * 100 + a [ 0 ] * 10 + a [ 0 ] ; } int main ( ) { int arr [ ] = { 7 , 7 , 1 } ; cout << printSmallest ( arr ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void updateMatrix ( int n , int q [ 3 ] [ 4 ] ) { int i , j ; int mat [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) mat [ i ] [ j ] = 0 ; for ( i = 0 ; i < 3 ; i ++ ) { int X1 = q [ i ] [ 0 ] ; int Y1 = q [ i ] [ 1 ] ; int X2 = q [ i ] [ 2 ] ; int Y2 = q [ i ] [ 3 ] ; mat [ X1 ] [ Y1 ] ++ ; if ( Y2 + 1 < n ) mat [ X2 ] [ Y2 + 1 ] -- ; else if ( X2 + 1 < n ) mat [ X2 + 1 ] [ 0 ] -- ; } int sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < n ; j ++ ) { sum += mat [ i ] [ j ] ; cout << sum << " ▁ " ; } cout << endl ; } } int main ( ) { int n = 5 ; int q [ 3 ] [ 4 ] = { { 0 , 0 , 1 , 2 } , { 1 , 2 , 3 , 4 } , { 1 , 4 , 3 , 4 } } ; updateMatrix ( n , q ) ; return 0 ; }

Index/key variables: X1, X2, Y1, i, j, n
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArr ( float arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } void replaceMax ( float arr [ ] , int n ) { float max = * std :: max_element ( arr , arr + n ) ; float min = * std :: min_element ( arr , arr + n ) ; float range = max - min ; float coeffOfRange = range / ( max + min ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == max ) { arr [ i ] = coeffOfRange ; break ; } } printArr ( arr , n ) ; } int main ( ) { float arr [ ] = { 15 , 16 , 10 , 9 , 6 , 7 , 17 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; replaceMax ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void divide ( int a , int b ) { for ( int i = 2 ; i <= min ( a , b ) ; i ++ ) { while ( a % i == 0 && b % i == 0 ) { a = a / i ; b = b / i ; } } cout << " A ▁ = ▁ " << a << " , ▁ B ▁ = ▁ " << b << endl ; } int main ( ) { int A = 10 , B = 15 ; divide ( A , B ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
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 commDiv ( int a , int b ) { int n = gcd ( a , b ) ; a = a / n ; b = b / n ; cout << " A ▁ = ▁ " << a << " , ▁ B ▁ = ▁ " << b << endl ; } int main ( ) { int a = 10 , b = 15 ; commDiv ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minAbsDiff ( int n ) { int left = 1 << ( ( int ) floor ( log2 ( n ) ) ) ; int right = left * 2 ; return min ( ( n - left ) , ( right - n ) ) ; } int main ( ) { int n = 15 ; cout << minAbsDiff ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double find_probability ( double p , double q , double r , double s ) { double t = ( 1 - p / q ) * ( 1 - r / s ) ; double ans = ( p / q ) / ( 1 - t ) ; return ans ; } int main ( ) { double p = 1 , q = 2 , r = 1 , s = 2 ; cout << fixed << setprecision ( 9 ) << find_probability ( p , q , r , s ) ; return 0 ; }

Accumulator variables: stdc