dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestNum ( int n ) { cout << pow ( 10 , n * n / 9 ) << endl ; return ( n * n % 9 + 1 ) * pow ( 10 , n * n / 9 ) - 1 ; } int main ( ) { int n = 4 ; cout << smallestNum ( n ) ; return 0 ; }

Accumulator variables: stdc
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 isWeaklyPrimeNum ( int N ) { if ( ! isPrime ( N ) ) return false ; string s = to_string ( N ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { string str = s ; for ( int i = 0 ; i <= 9 ; i ++ ) { char c = '0' + i ; str [ j ] = c ; int Num = stoi ( str ) ; if ( str [ j ] != s [ j ] && isPrime ( Num ) ) { return false ; } } } return true ; } int main ( ) { int n = 294001 ; if ( isWeaklyPrimeNum ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
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 isUnPrimeableNum ( int N ) { if ( isPrime ( N ) ) return false ; string s = to_string ( N ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { string str = s ; for ( int i = 0 ; i <= 9 ; i ++ ) { char c = '0' + i ; str [ j ] = c ; int Num = stoi ( str ) ; if ( str [ j ] != s [ j ] && isPrime ( Num ) ) { return false ; } } } return true ; } int main ( ) { int n = 200 ; if ( isUnPrimeableNum ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > getRow ( int rowIndex ) { vector < int > currow ; currow . push_back ( 1 ) ; if ( rowIndex == 0 ) { return currow ; } vector < int > prev = getRow ( rowIndex - 1 ) ; for ( int i = 1 ; i < prev . size ( ) ; i ++ ) { int curr = prev [ i - 1 ] + prev [ i ] ; currow . push_back ( curr ) ; } currow . push_back ( 1 ) ; return currow ; } int main ( ) { int n = 3 ; vector < int > arr = getRow ( n ) ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { if ( i == arr . size ( ) - 1 ) cout << arr [ i ] ; else cout << arr [ i ] << " , ▁ " ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void allQuotients ( int N ) { set < int > s ; for ( int k = 1 ; k <= N + 1 ; k ++ ) { s . insert ( N / k ) ; } for ( auto it : s ) cout << it << " ▁ " ; } int main ( ) { int N = 5 ; allQuotients ( N ) ; return 0 ; }

Accumulator variables: k, stdc
Iterator variables: it, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int greatestOddFactor ( int n ) { int pow_2 = ( int ) ( log ( n ) ) ; int i = 1 ; while ( i <= pow_2 ) { int fac_2 = ( 2 * i ) ; if ( n % fac_2 == 0 ) { if ( ( n / fac_2 ) % 2 == 1 ) { return ( n / fac_2 ) ; } } i += 1 ; } } int main ( ) { int N = 8642 ; cout << greatestOddFactor ( N ) ; return 0 ; }

Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { string i ; node * next = NULL ; } ; struct node * newnode ( string s ) { struct node * temp = ( struct node * ) malloc ( sizeof ( struct node ) ) ; temp -> i = s ; temp -> next = NULL ; return temp ; } string Majority_in_linklist ( node * head ) { string s = " " , t = " " ; int p = 0 , q = 0 ; node * ptr = NULL ; while ( head != NULL ) { if ( s . compare ( head -> i ) == 0 ) { p = p + 1 ; } else { if ( t . compare ( head -> i ) == 0 ) { q = q + 1 ; } else { if ( p == 0 ) { s = head -> i ; p = 1 ; } else { if ( q == 0 ) { t = head -> i ; q = 1 ; } else { p = p - 1 ; q = q - 1 ; } } } } head = head -> next ; } head = ptr ; p = 0 ; q = 0 ; while ( head != NULL ) { if ( s . compare ( head -> i ) == 0 ) { p = 1 ; } else { if ( t . compare ( head -> i ) == 0 ) { q = 1 ; } } head = head -> next ; } if ( p > q ) { return s ; } else { return t ; } } int main ( ) { node * ptr = NULL ; node * head = newnode ( " geeks " ) ; head -> next = newnode ( " geeks " ) ; head -> next -> next = newnode ( " abcd " ) ; head -> next -> next -> next = newnode ( " game " ) ; head -> next -> next -> next -> next = newnode ( " game " ) ; head -> next -> next -> next -> next -> next = newnode ( " knight " ) ; head -> next -> next -> next -> next -> next -> next = newnode ( " harry " ) ; head -> next -> next -> next -> next -> next -> next -> next = newnode ( " geeks " ) ; cout << Majority_in_linklist ( head ) << endl ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; string max_number ( int arr [ ] , int sum ) { int frac [ 9 ] ; int maxi = INT_MIN ; string ans ; int pos ; for ( int i = 0 ; i < 9 ; i ++ ) { frac [ i ] = sum / arr [ i ] ; if ( frac [ i ] > maxi ) { pos = i ; maxi = frac [ i ] ; } } ans . insert ( 0 , string ( maxi , ( pos + 1 ) + '0' ) ) ; sum -= maxi * arr [ pos ] ; for ( int i = 0 ; i < maxi ; i ++ ) { for ( int j = 1 ; j <= 9 ; j ++ ) { if ( sum + arr [ pos ] - arr [ j - 1 ] >= 0 ) { ans [ i ] = ( j + '0' ) ; sum += arr [ pos ] - arr [ j - 1 ] ; break ; } } } if ( maxi == 0 ) { return 0 ; } else { return ans ; } } int main ( ) { int arr [ 9 ] = { 3 , 4 , 2 , 4 , 6 , 5 , 4 , 2 , 3 } ; int s = 13 ; cout << max_number ( arr , s ) ; return 0 ; }

Index/key variables: i, pos
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkOverlapping ( vector < int > a , vector < int > b ) { if ( a [ 0 ] < b [ 0 ] ) { a . swap ( b ) ; } if ( b [ 0 ] <= a [ 0 ] <= b [ 1 ] ) return true ; return false ; } int find ( int a [ ] , int i ) { if ( a [ i ] == i ) return i ; a [ i ] = find ( a , a [ i ] ) ; return a [ i ] ; } bool Union ( int a [ ] , int x , int y ) { int xs = find ( a , x ) ; int ys = find ( a , y ) ; if ( xs == ys ) { return true ; } a [ ys ] = xs ; return false ; } bool checkNonOverlapping ( vector < vector < int > > arr , int n ) { int dsu [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) dsu [ i ] = i ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( checkOverlapping ( arr [ i ] , arr [ j ] ) ) { if ( Union ( dsu , i , j ) ) { return false ; } } } } return true ; } int main ( ) { vector < vector < int > > arr = { { 1 , 4 } , { 2 , 2 } , { 2 , 3 } } ; int n = arr . size ( ) ; if ( checkNonOverlapping ( arr , n ) ) { cout << " YES " << endl ; } else { cout << " NO " << endl ; } return 0 ; }

Index/key variables: i, j, ys
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#include <cmath>
using namespace std ; void FindValue ( int N , int K ) { if ( N % 2 == 0 ) { N = N + 2 * K ; } else { int i ; for ( i = 2 ; i < sqrt ( N ) + 1 ; i ++ ) { if ( N % i == 0 ) break ; } N = N + i ; N = N + 2 * ( K - 1 ) ; } cout << N << endl ; } int main ( ) { int N = 9 ; int K = 4 ; FindValue ( N , K ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void HexaDecimaltoBCD ( string s ) { int len = s . length ( ) , check = 0 ; int num = 0 , sum = 0 , mul = 1 ; for ( int i = 0 ; i <= len - 1 ; i ++ ) { if ( s [ i ] >= 47 && s [ i ] <= 52 ) cout << bitset < 4 > ( s [ i ] ) << " ▁ " ; else cout << bitset < 4 > ( s [ i ] - 55 ) << " ▁ " ; } } int main ( ) { string s = "11F " ; HexaDecimaltoBCD ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int heptadecagonal_num ( int n ) { return ( ( 15 * n * n ) - 13 * n ) / 2 ; } int sum_heptadecagonal_num ( int n ) { int summ = 0 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { summ += heptadecagonal_num ( i ) ; } return summ ; } int main ( ) { int n = 5 ; cout << sum_heptadecagonal_num ( n ) ; }

Accumulator variables: i, stdc, summ
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isCenteredpentagonal ( int N ) { float n = ( 5 + sqrt ( 40 * N - 15 ) ) / 10 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int N = 6 ; if ( isCenteredpentagonal ( N ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isdodecagonal ( int N ) { float n = ( 4 + sqrt ( 20 * N + 16 ) ) / 10 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int N = 12 ; if ( isdodecagonal ( N ) ) { cout << " Yes " ; } else { cout << " No " ; } 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 ; } int main ( ) { int N = 7 ; int K = 2 ; cout << prevPowerofK ( N , K ) << " ▁ " ; cout << nextPowerOfK ( N , K ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long pref [ 100001 ] ; int isComposite ( int n ) { if ( n <= 1 ) return 0 ; if ( n <= 3 ) return 0 ; if ( n % 2 == 0 n % 3 == 0 ) return n ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return n ; return 0 ; } void preCompute ( ) { for ( int i = 1 ; i <= 100000 ; ++ i ) { pref [ i ] = pref [ i - 1 ] + isComposite ( i ) ; } } void printSum ( int L , int R ) { cout << pref [ R ] - pref [ L - 1 ] << endl ; } void printSumComposite ( 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 } } ; printSumComposite ( arr , Q ) ; return 0 ; }

Index/key variables: R, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float findProb ( int l , int r ) { float countOfPS = floor ( sqrt ( r ) ) - ceil ( sqrt ( l ) ) + 1 ; float total = r - l + 1 ; float prob = ( float ) countOfPS / ( float ) total ; return prob ; } int main ( ) { int L = 16 , R = 25 ; cout << findProb ( L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumDigits ( int n ) { int sum = 0 ; while ( n ) { sum += n % 10 ; n /= 10 ; } return sum ; } map < int , int > constDict ( int n ) { map < int , int > d ; for ( int i = 1 ; i < n + 1 ; ++ i ) { int sum1 = sumDigits ( i ) ; if ( d . find ( sum1 ) == d . end ( ) ) d [ sum1 ] = 1 ; else d [ sum1 ] += 1 ; } return d ; } int countLargest ( int n ) { map < int , int > d = constDict ( n ) ; int size = 0 ; int count = 0 ; for ( auto it = d . begin ( ) ; it != d . end ( ) ; ++ it ) { int k = it -> first ; int val = it -> second ; if ( val > size ) { size = val ; count = 1 ; } else if ( val == size ) count += 1 ; } return count ; } int main ( ) { int n = 13 ; int group = countLargest ( n ) ; cout << group << endl ; return 0 ; }

Index/key variables: sum1
Accumulator variables: count, n, stdc, sum
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long findDigits ( int n , int b ) { if ( n < 0 ) return 0 ; if ( n <= 1 ) return 1 ; double x = ( ( n * log10 ( n / M_E ) + log10 ( 2 * M_PI * n ) / 2.0 ) ) / ( log10 ( b ) ) ; return floor ( x ) + 1 ; } int main ( ) { cout << findDigits ( 4 , 16 ) << endl ; cout << findDigits ( 5 , 8 ) << endl ; cout << findDigits ( 12 , 16 ) << endl ; cout << findDigits ( 19 , 13 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define ll  int
using namespace std ; long long pref [ 100010 ] ; bool isPerfectSquare ( int x ) { int s = sqrt ( x ) ; return ( s * s == x ) ; } int isNonFibonacci ( int n ) { if ( isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ) return 0 ; else return n ; } void compute ( ) { for ( int i = 1 ; i <= 100000 ; ++ i ) { pref [ i ] = pref [ i - 1 ] + isNonFibonacci ( i ) ; } } void printSum ( int L , int R ) { int sum = pref [ R ] - pref [ L - 1 ] ; cout << sum << " ▁ " ; } int main ( ) { compute ( ) ; int Q = 2 ; int arr [ ] [ 2 ] = { { 1 , 5 } , { 6 , 10 } } ; 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 ; 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 += 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } bool twinPrime ( int n1 , int n2 ) { return ( isPrime ( n1 ) && isPrime ( n2 ) && abs ( n1 - n2 ) == 2 ) ; } int countTwinPairs ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( twinPrime ( arr [ i ] , arr [ j ] ) ) { count ++ ; } } } return count ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 11 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countTwinPairs ( 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 ; void printArray ( int [ ] , int ) ; void solve ( int arr [ ] , int n ) { set < int > unfilled_indices ; set < int > missing ; for ( int i = 1 ; i < n ; i ++ ) missing . insert ( i ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) unfilled_indices . insert ( i ) ; else { auto it = missing . find ( arr [ i ] ) ; missing . erase ( it ) ; } } auto it2 = missing . end ( ) ; it2 -- ; for ( auto it = unfilled_indices . begin ( ) ; it != unfilled_indices . end ( ) ; it ++ , it2 -- ) { arr [ * it ] = * it2 ; } int pos = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == i ) { pos = i ; } } int x ; if ( pos != 0 ) { for ( int i = 1 ; i < n ; i ++ ) { if ( pos != i ) { if ( unfilled_indices . find ( i ) != unfilled_indices . end ( ) ) { x = arr [ i ] ; arr [ i ] = pos ; arr [ pos ] = x ; break ; } } } } printArray ( arr , n ) ; } void printArray ( int arr [ ] , int n ) { for ( int i = 1 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 0 , 7 , 4 , 0 , 3 , 0 , 5 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; solve ( arr , n ) ; return 0 ; }

Index/key variables: i, pos
Accumulator variables: i, it, it2, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Line { int m , c ; public : bool operator< ( Line l ) { if ( m != l . m ) return m > l . m ; else return c > l . c ; } bool check ( Line L1 , Line L2 , Line L3 ) { return ( L3 . c - L1 . c ) * ( L1 . m - L2 . m ) < ( L2 . c - L1 . c ) * ( L1 . m - L3 . m ) ; } } ; struct Convex_HULL_Trick { vector < Line > l ; void add ( Line newLine ) { int n = l . size ( ) ; while ( n >= 2 && newLine . check ( l [ n - 2 ] , l [ n - 1 ] , newLine ) ) { n -- ; } l . resize ( n ) ; l = new Line [ n ] ; l . push_back ( newLine ) ; } int value ( int in , int x ) { return l [ in ] . m * x + l [ in ] . c ; } int minQuery ( int x ) { if ( l . empty ( ) ) return INT_MAX ; int low = 0 , high = ( int ) l . size ( ) - 2 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( value ( mid , x ) > value ( mid + 1 , x ) ) low = mid + 1 ; else high = mid - 1 ; } return value ( low , x ) ; } } ; int main ( ) { Line lines [ ] = { { 1 , 1 } , { 0 , 0 } , { -3 , 3 } } ; int Q [ ] = { -2 , 2 , 0 } ; int n = 3 , q = 3 ; Convex_HULL_Trick cht ; sort ( lines , lines + n ) ; for ( int i = 0 ; i < n ; i ++ ) cht . add ( lines [ i ] ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = Q [ i ] ; cout << cht . minQuery ( x ) << endl ; } return 0 ; }

Index/key variables: i, in, n
Accumulator variables: i, n, stdc
Iterator variables: i
Class/struct names: Convex_HULL_Trick, Line
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( long long x , vector < int > & pos , vector < int > & neg , int k ) { long long pairs = 0 ; int p = neg . size ( ) - 1 ; int nn = neg . size ( ) - 1 ; int pp = pos . size ( ) - 1 ; for ( int i = 0 ; i < neg . size ( ) ; i ++ ) { while ( p >= 0 and neg [ i ] * neg [ p ] <= x ) p -- ; pairs += min ( nn - p , nn - i ) ; } p = 0 ; for ( int i = pos . size ( ) - 1 ; i >= 0 ; i -- ) { while ( p < pos . size ( ) and pos [ i ] * pos [ p ] <= x ) p ++ ; pairs += min ( p , i ) ; } p = pos . size ( ) - 1 ; for ( int i = neg . size ( ) - 1 ; i >= 0 ; i -- ) { while ( p >= 0 and neg [ i ] * pos [ p ] <= x ) p -- ; pairs += pp - p ; } return ( pairs >= k ) ; } long long kth_element ( int a [ ] , int n , int k ) { vector < int > pos , neg ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] >= 0 ) pos . push_back ( a [ i ] ) ; else neg . push_back ( a [ i ] ) ; } sort ( pos . begin ( ) , pos . end ( ) ) ; sort ( neg . begin ( ) , neg . end ( ) ) ; long long l = -1e18 , ans = 0 , r = 1e18 ; while ( l <= r ) { long long mid = ( l + r ) >> 1 ; if ( check ( mid , pos , neg , k ) ) { ans = mid ; r = mid - 1 ; } else l = mid + 1 ; } return ans ; } int main ( ) { int a [ ] = { -4 , -2 , 3 , 3 } , k = 3 ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << kth_element ( a , n , k ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, pairs, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double squareRoot ( double n , float l ) { double x = n ; double root ; int count = 0 ; while ( 1 ) { count ++ ; root = 0.5 * ( x + ( n / x ) ) ; if ( abs ( root - x ) < l ) break ; x = root ; } return root ; } int main ( ) { double n = 327 ; float l = 0.00001 ; cout << squareRoot ( n , l ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100000
int sequence [ MAX + 1 ] ; void vanEckSequence ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { sequence [ i ] = 0 ; } for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( sequence [ j ] == sequence [ i ] ) { sequence [ i + 1 ] = i - j ; break ; } } } } int getCount ( int n ) { int nthTerm = sequence [ n - 1 ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( sequence [ i ] == nthTerm ) count ++ ; } return count ; } int main ( ) { vanEckSequence ( ) ; int n = 5 ; cout << getCount ( n ) << endl ; n = 11 ; cout << getCount ( n ) << endl ; 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 MAX  100000
int sequence [ MAX + 1 ] ; void vanEckSequence ( ) { for ( int i = 0 ; i < MAX ; i ++ ) { sequence [ i ] = 0 ; } for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( sequence [ j ] == sequence [ i ] ) { sequence [ i + 1 ] = i - j ; break ; } } } } int getCount ( int n ) { int count = 1 ; int i = n - 1 ; while ( sequence [ i + 1 ] != 0 ) { count ++ ; i = i - sequence [ i + 1 ] ; } return count ; } int main ( ) { vanEckSequence ( ) ; int n = 5 ; cout << getCount ( n ) << endl ; n = 11 ; cout << getCount ( n ) << endl ; 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 ; void remainingTime ( int h , int m ) { int totalMin , hoursRemaining , minRemaining ; totalMin = 1440 - 60 * h - m ; hoursRemaining = totalMin / 60 ; minRemaining = totalMin % 60 ; cout << hoursRemaining << " : : " << minRemaining << endl ; } int main ( ) { int h = 0 , m = 1 ; remainingTime ( h , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void check ( int n ) { if ( n % 2 == 1 && n > 5 ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; } int main ( ) { int a = 3 ; int b = 7 ; check ( a ) ; check ( b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  1000005
#define mod  (int)(1e9 + 7)
int factorial [ N ] , modinverse [ N ] ; int power ( int a , int m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( 1LL * a * a ) % mod ; else if ( m1 & 1 ) return ( 1LL * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } void factorialfun ( ) { factorial [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) factorial [ i ] = ( 1LL * factorial [ i - 1 ] * i ) % mod ; } void modinversefun ( ) { modinverse [ N - 1 ] = power ( factorial [ N - 1 ] , mod - 2 ) % mod ; for ( int i = N - 2 ; i >= 0 ; i -- ) modinverse [ i ] = ( 1LL * modinverse [ i + 1 ] * ( i + 1 ) ) % mod ; } int binomial ( int n , int r ) { if ( r > n ) return 0 ; int a = ( 1LL * factorial [ n ] * modinverse [ n - r ] ) % mod ; a = ( 1LL * a * modinverse [ r ] ) % mod ; return a ; } int ways ( int x , int y ) { factorialfun ( ) ; modinversefun ( ) ; if ( ( 2 * x - y ) % 3 == 0 && ( 2 * y - x ) % 3 == 0 ) { int m = ( 2 * x - y ) / 3 ; int n = ( 2 * y - x ) / 3 ; return binomial ( n + m , n ) ; } return 0 ; } System . out . println ( n + m + " ▁ " + n ) ; int main ( ) { int x = 3 , y = 3 ; cout << ways ( x , y ) ; return 0 ; }

Index/key variables: N, i, n, r
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string solve ( int n , char x , char y ) { int length = ceil ( log2 ( n + 2 ) ) - 1 ; int rank = n - ( 1 << length ) + 1 ; string left = " " , right = " " ; for ( int i = length - 1 ; i >= 0 ; i -- ) { int mask = 1 << i ; bool bit = mask & rank ; if ( bit ) { left += y ; right += y ; } else { left += x ; right += x ; } } reverse ( right . begin ( ) , right . end ( ) ) ; return left + right ; } int main ( ) { int n = 23 ; char x = '4' , y = '5' ; string ans = solve ( n , x , y ) ; cout << ans << ' ' ; return 0 ; }

Accumulator variables: i, left, right, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int C [ n + 1 ] [ k + 1 ] ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( 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 findMax ( int n ) { return binomialCoeff ( n , n / 2 ) ; } int main ( ) { int n = 5 ; cout << findMax ( n ) ; 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 ; void findNumbers ( int a , int b ) { int gcd = __gcd ( a , b ) ; cout << ( a / gcd ) << " ▁ " << ( b / gcd ) ; } int main ( ) { int a = 12 , b = 16 ; findNumbers ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findBalance ( int x , float bal ) { if ( x % 10 == 0 && ( ( float ) x + 1.50 ) <= bal ) { cout << fixed << setprecision ( 2 ) << ( bal - x - 1.50 ) << endl ; } else { cout << fixed << setprecision ( 2 ) << ( bal ) << endl ; } } int main ( ) { int x = 50 ; float bal = 100.50 ; findBalance ( x , bal ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countKdivPairs ( int A [ ] , int n , int K ) { int freq [ K ] = { 0 } ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int rem = A [ i ] % K ; ans += freq [ ( K - rem ) % K ] ; freq [ rem ] ++ ; } return ans ; } int main ( ) { int A [ ] = { 2 , 2 , 1 , 7 , 5 , 3 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int K = 4 ; cout << countKdivPairs ( A , n , K ) ; return 0 ; }

Index/key variables: K, i, rem
Accumulator variables: ans, i, stdc
Iterator variables: i