dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int value ; int max_set_bits ; } ; Node tree [ 4 * 10000 ] ; int setBits ( int x ) { int parity = 0 ; while ( x != 0 ) { if ( x & 1 ) parity ++ ; x = x >> 1 ; } return parity ; } void buildSegmentTree ( int a [ ] , int index , int beg , int end ) { if ( beg == end ) { tree [ index ] . value = a [ beg ] ; tree [ index ] . max_set_bits = setBits ( a [ beg ] ) ; } else { int mid = ( beg + end ) / 2 ; buildSegmentTree ( a , 2 * index + 1 , beg , mid ) ; buildSegmentTree ( a , 2 * index + 2 , mid + 1 , end ) ; if ( tree [ 2 * index + 1 ] . max_set_bits > tree [ 2 * index + 2 ] . max_set_bits ) { tree [ index ] . max_set_bits = tree [ 2 * index + 1 ] . max_set_bits ; tree [ index ] . value = tree [ 2 * index + 1 ] . value ; } else if ( tree [ 2 * index + 2 ] . max_set_bits > tree [ 2 * index + 1 ] . max_set_bits ) { tree [ index ] . max_set_bits = tree [ 2 * index + 2 ] . max_set_bits ; tree [ index ] . value = tree [ 2 * index + 2 ] . value ; } else { tree [ index ] . max_set_bits = tree [ 2 * index + 2 ] . max_set_bits ; tree [ index ] . value = max ( tree [ 2 * index + 2 ] . value , tree [ 2 * index + 1 ] . value ) ; } } } Node query ( int index , int beg , int end , int l , int r ) { Node result ; result . value = result . max_set_bits = -1 ; if ( beg > r end < l ) return result ; if ( beg >= l && end <= r ) return tree [ index ] ; int mid = ( beg + end ) / 2 ; if ( l > mid ) return query ( 2 * index + 2 , mid + 1 , end , l , r ) ; if ( r <= mid ) return query ( 2 * index + 1 , beg , mid , l , r ) ; Node left = query ( 2 * index + 1 , beg , mid , l , r ) ; Node right = query ( 2 * index + 2 , mid + 1 , end , l , r ) ; if ( left . max_set_bits > right . max_set_bits ) { result . max_set_bits = left . max_set_bits ; result . value = left . value ; } else if ( right . max_set_bits > left . max_set_bits ) { result . max_set_bits = right . max_set_bits ; result . value = right . value ; } else { result . max_set_bits = left . max_set_bits ; result . value = max ( right . value , left . value ) ; } return result ; } int main ( ) { int a [ ] = { 18 , 9 , 8 , 15 , 14 , 5 } ; int N = sizeof ( a ) / sizeof ( a [ 0 ] ) ; buildSegmentTree ( a , 0 , 0 , N - 1 ) ; cout << query ( 0 , 0 , N - 1 , 1 , 4 ) . value << endl ; cout << query ( 0 , 0 , N - 1 , 0 , 2 ) . value << endl ; return 0 ; }

Index/key variables: beg, index
Accumulator variables: parity, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; set < int > fibonacci ; int getMid ( int s , int e ) { return s + ( e - s ) / 2 ; } void createHash ( int maxElement ) { int prev = 0 , curr = 1 ; fibonacci . insert ( prev ) ; fibonacci . insert ( curr ) ; while ( curr <= maxElement ) { int temp = curr + prev ; fibonacci . insert ( temp ) ; prev = curr ; curr = temp ; } } int MaxUtil ( int * st , int ss , int se , int l , int r , int node ) { if ( l <= ss && r >= se ) return st [ node ] ; if ( se < l ss > r ) return -1 ; int mid = getMid ( ss , se ) ; return max ( MaxUtil ( st , ss , mid , l , r , 2 * node + 1 ) , MaxUtil ( st , mid + 1 , se , l , r , 2 * node + 2 ) ) ; } void updateValue ( int arr [ ] , int * st , int ss , int se , int index , int value , int node ) { if ( index < ss index > se ) { cout << " Invalid ▁ Input " << endl ; return ; } if ( ss == se ) { arr [ index ] = value ; if ( fibonacci . find ( value ) != fibonacci . end ( ) ) st [ node ] = value ; else st [ node ] = -1 ; } else { int mid = getMid ( ss , se ) ; if ( index >= ss && index <= mid ) updateValue ( arr , st , ss , mid , index , value , 2 * node + 1 ) ; else updateValue ( arr , st , mid + 1 , se , index , value , 2 * node + 2 ) ; st [ node ] = max ( st [ 2 * node + 1 ] , st [ 2 * node + 2 ] ) ; } return ; } int getMax ( int * st , int n , int l , int r ) { if ( l < 0 r > n - 1 l > r ) { printf ( " Invalid ▁ Input " ) ; return -1 ; } return MaxUtil ( st , 0 , n - 1 , l , r , 0 ) ; } int constructSTUtil ( int arr [ ] , int ss , int se , int * st , int si ) { if ( ss == se ) { if ( fibonacci . find ( arr [ ss ] ) != fibonacci . end ( ) ) st [ si ] = arr [ ss ] ; else st [ si ] = -1 ; return st [ si ] ; } int mid = getMid ( ss , se ) ; st [ si ] = max ( constructSTUtil ( arr , ss , mid , st , si * 2 + 1 ) , constructSTUtil ( arr , mid + 1 , se , st , si * 2 + 2 ) ) ; return st [ si ] ; } int * constructST ( int arr [ ] , int n ) { int x = ( int ) ( ceil ( log2 ( n ) ) ) ; int max_size = 2 * ( int ) pow ( 2 , x ) - 1 ; int * st = new int [ max_size ] ; constructSTUtil ( arr , 0 , n - 1 , st , 0 ) ; return st ; } int main ( ) { int arr [ ] = { 1 , 3 , 5 , 7 , 9 , 11 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int maxEle = * max_element ( arr , arr + n ) ; createHash ( maxEle ) ; int * st = constructST ( arr , n ) ; cout << " Maximum ▁ fibonacci ▁ number " << " ▁ in ▁ given ▁ range ▁ = ▁ " << getMax ( st , n , 1 , 3 ) << endl ; updateValue ( arr , st , 0 , n - 1 , 3 , 8 , 0 ) ; cout << " Updated ▁ Maximum ▁ Fibonacci " << " ▁ number ▁ in ▁ given ▁ range ▁ = ▁ " << getMax ( st , n , 1 , 3 ) << endl ; return 0 ; }

Index/key variables: index, max_size, node, si, ss
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define maxSize  50
using namespace std ; vector < vector < double > > matrix_product ( vector < vector < double > > a , vector < vector < double > > b ) { vector < vector < double > > c ( 7 ) ; for ( int i = 0 ; i < 7 ; i ++ ) c [ i ] . resize ( 7 , 0 ) ; for ( int i = 0 ; i < 7 ; i ++ ) for ( int j = 0 ; j < 7 ; j ++ ) for ( int k = 0 ; k < 7 ; k ++ ) c [ i ] [ j ] += a [ i ] [ k ] * b [ k ] [ j ] ; return c ; } vector < vector < double > > mul_expo ( vector < vector < double > > mul , int p ) { vector < vector < double > > s = { { 1 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 1 } } ; while ( p != 1 ) { if ( p % 2 == 1 ) s = matrix_product ( s , mul ) ; mul = matrix_product ( mul , mul ) ; p /= 2 ; } return matrix_product ( mul , s ) ; } double expectedSteps ( int x ) { if ( x == 0 ) return 0 ; if ( x <= 6 ) return 6 ; vector < vector < double > > mul = { { ( double ) 7 / 6 , 1 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 1 } , { ( double ) -1 / 6 , 0 , 0 , 0 , 0 , 0 , 0 } } ; mul = mul_expo ( mul , x - 6 ) ; return ( mul [ 0 ] [ 0 ] + mul [ 1 ] [ 0 ] + mul [ 2 ] [ 0 ] + mul [ 3 ] [ 0 ] + mul [ 4 ] [ 0 ] + mul [ 5 ] [ 0 ] ) * 6 ; } int main ( ) { int n = 10 ; cout << expectedSteps ( n - 1 ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, p, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canPlace ( int a [ ] , int n , int p , int sep ) { int prisoners_placed = 1 ; int last_prisoner_placed = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { int current_cell = a [ i ] ; if ( current_cell - last_prisoner_placed >= sep ) { prisoners_placed ++ ; last_prisoner_placed = current_cell ; if ( prisoners_placed == p ) { return true ; } } } return false ; } int maxDistance ( int cell [ ] , int n , int p ) { sort ( cell , cell + n ) ; int start = 0 ; int end = cell [ n - 1 ] - cell [ 0 ] ; int ans = 0 ; while ( start <= end ) { int mid = start + ( ( end - start ) / 2 ) ; if ( canPlace ( cell , n , p , mid ) ) { ans = mid ; start = mid + 1 ; } else { end = mid - 1 ; } } return ans ; } int main ( ) { int cell [ ] = { 1 , 2 , 8 , 4 , 9 } ; int n = sizeof ( cell ) / sizeof ( int ) ; int p = 3 ; cout << maxDistance ( cell , n , p ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, prisoners_placed, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; pair < int , int > solve ( int n ) { int low = 1 , high = 1e4 , x = n , p = 0 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int sum = ( mid * ( mid + 1 ) ) / 2 ; if ( x - sum >= 1 ) { p = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } int start = 1 , end = 1e4 , y = 1 , q = 0 ; while ( start <= end ) { int mid = ( start + end ) / 2 ; int sum = ( mid * ( mid + 1 ) ) / 2 ; if ( y + sum <= n ) { q = mid ; start = mid + 1 ; } else { end = mid - 1 ; } } x = x - ( p * ( p + 1 ) ) / 2 ; y = y + ( q * ( q + 1 ) ) / 2 ; int r = x ; int c = q + 1 - n + y ; pair < int , int > ans = { r , c } ; return ans ; } int main ( ) { int n = 5 ; pair < int , int > p = solve ( n ) ; cout << p . first << " ▁ " << p . second ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long query ( int start , int end , int left , int right , int node , long long seg [ ] ) { if ( end < left start > right ) { return 0 ; } else if ( start >= left && end <= right ) { return seg [ node ] ; } else { int mid = ( start + end ) / 2 ; long long leftChild = query ( start , mid , left , right , 2 * node , seg ) ; long long rightChild = query ( mid + 1 , end , left , right , 2 * node + 1 , seg ) ; return ( leftChild rightChild ) ; } } void update ( int left , int right , int index , int Value , int node , int ar [ ] , long long seg [ ] ) { if ( left == right ) { ar [ index ] = Value ; seg [ node ] = ( 1LL << Value ) ; return ; } int mid = ( left + right ) / 2 ; if ( index > mid ) { update ( mid + 1 , right , index , Value , 2 * node + 1 , ar , seg ) ; } else { update ( left , mid , index , Value , 2 * node , ar , seg ) ; } seg [ node ] = ( seg [ 2 * node ] seg [ 2 * node + 1 ] ) ; } void build ( int left , int right , int node , int ar [ ] , long long seg [ ] ) { if ( left == right ) { seg [ node ] = ( 1LL << ar [ left ] ) ; return ; } int mid = ( left + right ) / 2 ; build ( left , mid , 2 * node , ar , seg ) ; build ( mid + 1 , right , 2 * node + 1 , ar , seg ) ; seg [ node ] = ( seg [ 2 * node ] seg [ 2 * node + 1 ] ) ; } void getDistinctCount ( vector < vector < int > > & queries , int ar [ ] , long long seg [ ] , int n ) { for ( int i = 0 ; i < queries . size ( ) ; i ++ ) { int op = queries [ i ] [ 0 ] ; if ( op == 2 ) { int l = queries [ i ] [ 1 ] , r = queries [ i ] [ 2 ] ; long long tempMask = query ( 0 , n - 1 , l - 1 , r - 1 , 1 , seg ) ; int countOfBits = 0 ; for ( int i = 63 ; i >= 0 ; i -- ) { if ( tempMask & ( 1LL << i ) ) { countOfBits ++ ; } } cout << countOfBits << ' ' ; } else { int index = queries [ i ] [ 1 ] ; int val = queries [ i ] [ 2 ] ; update ( 0 , n - 1 , index - 1 , val , 1 , ar , seg ) ; } } } int main ( ) { int n = 7 ; int ar [ ] = { 1 , 2 , 1 , 3 , 1 , 2 , 1 } ; long long seg [ 4 * n ] = { 0 } ; build ( 0 , n - 1 , 1 , ar , seg ) ; int q = 5 ; vector < vector < int > > queries = { { 2 , 1 , 4 } , { 1 , 4 , 2 } , { 1 , 5 , 2 } , { 2 , 4 , 6 } , { 2 , 1 , 7 } } ; getDistinctCount ( queries , ar , seg , n ) ; return 0 ; }

Index/key variables: i, index, left, node
Accumulator variables: countOfBits, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define maxLen  30
int seg [ 3 * maxLen ] ; int build ( int l , int r , int in , int * arr ) { if ( l == r ) return seg [ in ] = arr [ l ] ; int mid = ( l + r ) / 2 ; return seg [ in ] = __gcd ( build ( l , mid , 2 * in + 1 , arr ) , build ( mid + 1 , r , 2 * in + 2 , arr ) ) ; } int query ( int l , int r , int l1 , int r1 , int in ) { if ( l1 <= l and r <= r1 ) return seg [ in ] ; if ( l > r1 or r < l1 ) return 0 ; int mid = ( l + r ) / 2 ; return __gcd ( query ( l , mid , l1 , r1 , 2 * in + 1 ) , query ( mid + 1 , r , l1 , r1 , 2 * in + 2 ) ) ; } int findLen ( int * arr , int n ) { build ( 0 , n - 1 , 0 , arr ) ; int i = 0 , j = 0 ; int ans = INT_MAX ; while ( i < n ) { while ( j < n and query ( 0 , n - 1 , i , j , 0 ) != 1 ) j ++ ; if ( j == n ) break ; ans = min ( ( j - i + 1 ) , ans ) ; i ++ ; j = max ( j , i ) ; } if ( ans == INT_MAX ) return -1 ; else return ans ; } int main ( ) { int arr [ ] = { 2 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << findLen ( arr , n ) ; return 0 ; }

Index/key variables: in, l
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findGrid ( int n ) { int arr [ n ] [ n ] ; int x = 0 ; for ( int i = 0 ; i < n / 4 ; i ++ ) { for ( int j = 0 ; j < n / 4 ; j ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { for ( int l = 0 ; l < 4 ; l ++ ) { arr [ i * 4 + k ] [ j * 4 + l ] = x ; x ++ ; } } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cout << arr [ i ] [ j ] << " ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { int n = 4 ; findGrid ( n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, k, l, stdc, x
Iterator variables: i, j, k, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define maxLen  30
struct node { int data ; node * left ; node * right ; node ( int data ) { left = NULL ; right = NULL ; this -> data = data ; } } ; int segtree [ maxLen * 4 ] ; int buildTree ( int l , int r , int i , int * arr ) { if ( l == r ) { segtree [ i ] = l ; return l ; } int l1 = buildTree ( l , ( l + r ) / 2 , 2 * i + 1 , arr ) ; int r1 = buildTree ( ( l + r ) / 2 + 1 , r , 2 * i + 2 , arr ) ; if ( arr [ l1 ] > arr [ r1 ] ) segtree [ i ] = l1 ; else segtree [ i ] = r1 ; return segtree [ i ] ; } int rangeMax ( int l , int r , int rl , int rr , int i , int * arr ) { if ( r < rl l > rr ) return -1 ; if ( l >= rl and r <= rr ) return segtree [ i ] ; int l1 = rangeMax ( l , ( l + r ) / 2 , rl , rr , 2 * i + 1 , arr ) ; int r1 = rangeMax ( ( l + r ) / 2 + 1 , r , rl , rr , 2 * i + 2 , arr ) ; if ( l1 == -1 ) return r1 ; if ( r1 == -1 ) return l1 ; if ( arr [ l1 ] > arr [ r1 ] ) return l1 ; else return r1 ; } void inorder ( node * curr ) { if ( curr == NULL ) return ; inorder ( curr -> left ) ; cout << curr -> data << " ▁ " ; inorder ( curr -> right ) ; } node * createCartesianTree ( int l , int r , int * arr , int n ) { if ( r < l ) return NULL ; int m = rangeMax ( 0 , n - 1 , l , r , 0 , arr ) ; node * curr = new node ( arr [ m ] ) ; curr -> left = createCartesianTree ( l , m - 1 , arr , n ) ; curr -> right = createCartesianTree ( m + 1 , r , arr , n ) ; return curr ; } int main ( ) { int arr [ ] = { 8 , 11 , 21 , 100 , 5 , 70 , 55 } ; int n = sizeof ( arr ) / sizeof ( int ) ; buildTree ( 0 , n - 1 , 0 , arr ) ; inorder ( createCartesianTree ( 0 , n - 1 , arr , n ) ) ; }

Index/key variables: i, l1, m, r1
Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int kthSmallest ( int * arr , int k , int n ) { int low = * min_element ( arr , arr + n ) ; int high = * max_element ( arr , arr + n ) ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; int countless = 0 , countequal = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( arr [ i ] < mid ) ++ countless ; else if ( arr [ i ] == mid ) ++ countequal ; } if ( countless < k && ( countless + countequal ) >= k ) { return mid ; } else if ( countless >= k ) { high = mid - 1 ; } else if ( countless < k && countless + countequal < k ) { low = mid + 1 ; } } } int main ( ) { int arr [ ] = { 7 , 10 , 4 , 3 , 20 , 15 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int k = 3 ; cout << kthSmallest ( arr , k , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000
int tree [ MAX ] = { 0 } ; int lazy [ MAX ] = { 0 } ; void updateRangeUtil ( int si , int ss , int se , int us , int ue , int diff ) { if ( lazy [ si ] != 0 ) { tree [ si ] += lazy [ si ] ; if ( ss != se ) { lazy [ si * 2 + 1 ] += lazy [ si ] ; lazy [ si * 2 + 2 ] += lazy [ si ] ; } lazy [ si ] = 0 ; } if ( ss > se ss > ue se < us ) return ; if ( ss >= us && se <= ue ) { tree [ si ] += diff ; if ( ss != se ) { lazy [ si * 2 + 1 ] += diff ; lazy [ si * 2 + 2 ] += diff ; } return ; } int mid = ( ss + se ) / 2 ; updateRangeUtil ( si * 2 + 1 , ss , mid , us , ue , diff ) ; updateRangeUtil ( si * 2 + 2 , mid + 1 , se , us , ue , diff ) ; tree [ si ] = max ( tree [ si * 2 + 1 ] , tree [ si * 2 + 2 ] ) ; } void updateRange ( int n , int us , int ue , int diff ) { updateRangeUtil ( 0 , 0 , n - 1 , us , ue , diff ) ; } int getMaxUtil ( int ss , int se , int qs , int qe , int si ) { if ( lazy [ si ] != 0 ) { tree [ si ] += lazy [ si ] ; if ( ss != se ) { lazy [ si * 2 + 1 ] += lazy [ si ] ; lazy [ si * 2 + 2 ] += lazy [ si ] ; } lazy [ si ] = 0 ; } if ( ss > se ss > qe se < qs ) return 0 ; if ( ss >= qs && se <= qe ) return tree [ si ] ; int mid = ( ss + se ) / 2 ; return max ( getSumUtil ( ss , mid , qs , qe , 2 * si + 1 ) , getSumUtil ( mid + 1 , se , qs , qe , 2 * si + 2 ) ) ; } int getMax ( int n , int qs , int qe ) { if ( qs < 0 qe > n - 1 qs > qe ) { printf ( " Invalid ▁ Input " ) ; return -1 ; } return getSumUtil ( 0 , n - 1 , qs , qe , 0 ) ; } void constructSTUtil ( int arr [ ] , int ss , int se , int si ) { if ( ss > se ) return ; if ( ss == se ) { tree [ si ] = arr [ ss ] ; return ; } int mid = ( ss + se ) / 2 ; constructSTUtil ( arr , ss , mid , si * 2 + 1 ) ; constructSTUtil ( arr , mid + 1 , se , si * 2 + 2 ) ; tree [ si ] = max ( tree [ si * 2 + 1 ] , tree [ si * 2 + 2 ] ) ; } void constructST ( int arr [ ] , int n ) { constructSTUtil ( arr , 0 , n - 1 , 0 ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; constructST ( arr , n ) ; updateRange ( n , 0 , 3 , 4 ) ; cout << getSum ( n , 1 , 4 ) ; return 0 ; }

Index/key variables: MAX, si, ss
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
ll F ( ll A , ll B ) { if ( A == 1 ) return ( 4 % B ) ; else { ll temp = F ( A - 1 , B ) ; return ( temp * temp ) % B ; } } int main ( ) { ll A = 25 , B = 50 ; cout << F ( A , B ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MOD  1000000007
int rangeSum ( int l , int r ) { int a = 1 , b = 9 , res = 0 ; for ( int i = 1 ; i <= 10 ; i ++ ) { int L = max ( l , a ) ; int R = min ( r , b ) ; if ( L <= R ) { int sum = ( L + R ) * ( R - L + 1 ) / 2 ; res += ( i * i ) * ( sum % MOD ) ; res %= MOD ; } a = a * 10 ; b = b * 10 + 9 ; } return res ; } int main ( ) { int l = 98 , r = 102 ; cout << rangeSum ( l , r ) ; return 0 ; }

Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > permutation ; void printPermutation ( ) { for ( auto i : permutation ) cout << i << " ▁ " ; } int give_random_number ( int l , int r ) { int x = rand ( ) % ( r - l + 1 ) + l ; return x ; } void generate_random_permutation ( int l , int r ) { if ( l > r ) return ; int n = give_random_number ( l , r ) ; permutation . push_back ( n ) ; generate_random_permutation ( l , n - 1 ) ; generate_random_permutation ( n + 1 , r ) ; } int main ( ) { int l = 5 ; int r = 15 ; generate_random_permutation ( l , r ) ; printPermutation ( ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define INF  99999
#define size  10
int getSetBitsFromOneToN ( int N ) { int two = 2 , ans = 0 ; int n = N ; while ( n ) { ans += ( N / two ) * ( two >> 1 ) ; if ( ( N & ( two - 1 ) ) > ( two >> 1 ) - 1 ) ans += ( N & ( two - 1 ) ) - ( two >> 1 ) + 1 ; two <<= 1 ; n >>= 1 ; } return ans ; } int findMinimum ( int x ) { int low = 0 , high = 100000 ; int ans = high ; while ( low <= high ) { int mid = ( low + high ) >> 1 ; if ( getSetBitsFromOneToN ( mid ) >= x ) { ans = min ( ans , mid ) ; high = mid - 1 ; } else low = mid + 1 ; } return ans ; } int main ( ) { int x = 20 ; cout << findMinimum ( x ) ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MOD = 1e9 ; const int MAX = 100 ; const int SZ = 40 ; int BIT [ MAX + 1 ] , fact [ SZ + 1 ] ; struct queries { int type , l , r ; } ; void update ( int x , int val , int n ) { for ( x ; x <= n ; x += x & - x ) BIT [ x ] += val ; } int sum ( int x ) { int s = 0 ; for ( x ; x > 0 ; x -= x & - x ) s += BIT [ x ] ; return s ; } void answerQueries ( int arr [ ] , queries que [ ] , int n , int q ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < 41 ; i ++ ) fact [ i ] = ( fact [ i - 1 ] * i ) % MOD ; set < int > s ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < 40 ) { s . insert ( i ) ; update ( i , fact [ arr [ i ] ] , n ) ; } else update ( i , 0 , n ) ; } for ( int i = 0 ; i < q ; i ++ ) { if ( que [ i ] . type == 1 ) { while ( true ) { auto it = s . lower_bound ( que [ i ] . l ) ; if ( it == s . end ( ) * it > que [ i ] . r ) break ; que [ i ] . l = * it ; int val = arr [ * it ] + 1 ; update ( * it , fact [ val ] - fact [ arr [ * it ] ] , n ) ; arr [ * it ] ++ ; if ( arr [ * it ] >= 40 ) s . erase ( * it ) ; que [ i ] . l ++ ; } } else if ( que [ i ] . type == 2 ) { int idx = que [ i ] . l ; int val = que [ i ] . r ; update ( idx , fact [ val ] - fact [ arr [ idx ] ] , n ) ; arr [ idx ] = val ; if ( val < 40 ) s . insert ( idx ) ; else s . erase ( idx ) ; } else cout << ( sum ( que [ i ] . r ) - sum ( que [ i ] . l - 1 ) ) << endl ; } } int main ( ) { int q = 6 ; int arr [ ] = { 0 , 1 , 2 , 1 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; queries que [ q + 1 ] ; que [ 0 ] . type = 3 , que [ 0 ] . l = 1 , que [ 0 ] . r = 5 ; que [ 1 ] . type = 1 , que [ 1 ] . l = 1 , que [ 1 ] . r = 3 ; que [ 2 ] . type = 2 , que [ 2 ] . l = 2 , que [ 2 ] . r = 4 ; que [ 3 ] . type = 3 , que [ 3 ] . l = 2 , que [ 3 ] . r = 4 ; que [ 4 ] . type = 1 , que [ 4 ] . l = 2 , que [ 4 ] . r = 5 ; que [ 5 ] . type = 3 , que [ 5 ] . l = 1 , que [ 5 ] . r = 5 ; answerQueries ( arr , que , n , q ) ; return 0 ; }

Index/key variables: i, idx, val, x
Accumulator variables: i, l, s, stdc, x
Iterator variables: i
Class/struct names: queries
C++ program:
#include <bits/stdc++.h>
using namespace std ; int trailingZeroes ( int n ) { int cnt = 0 ; while ( n > 0 ) { n /= 5 ; cnt += n ; } return cnt ; } void binarySearch ( int n ) { int low = 0 ; while ( low < high ) { int mid = ( low + high ) / 2 ; int count = trailingZeroes ( mid ) ; if ( count < n ) low = mid + 1 ; else high = mid ; } vector < int > result ; while ( trailingZeroes ( low ) == n ) { result . push_back ( low ) ; low ++ ; } for ( int i = 0 ; i < result . size ( ) ; i ++ ) cout << result [ i ] << " ▁ " ; } int main ( ) { int n = 2 ; binarySearch ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, low, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getCumulateSum ( int n ) { return ( n * ( n + 1 ) ) / 2 ; } int minDaysToEmpty ( int C , int l ) { if ( C <= l ) return C ; int lo = 0 ; int hi = 1e4 ; int mid ; while ( lo < hi ) { mid = ( lo + hi ) / 2 ; if ( getCumulateSum ( mid ) >= ( C - l ) ) hi = mid ; else lo = mid + 1 ; } return ( l + lo ) ; } int main ( ) { int C = 5 ; int l = 2 ; cout << minDaysToEmpty ( C , l ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDaysToEmpty ( int C , int l ) { if ( l >= C ) return C ; double eq_root = ( std :: sqrt ( 1 + 8 * ( C - l ) ) - 1 ) / 2 ; return std :: ceil ( eq_root ) + l ; } int main ( ) { cout << minDaysToEmpty ( 5 , 2 ) << endl ; cout << minDaysToEmpty ( 6514683 , 4965 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int kth ( int arr1 [ ] , int arr2 [ ] , int m , int n , int k ) { int sorted1 [ m + n ] ; int i = 0 , j = 0 , d = 0 ; while ( i < m && j < n ) { if ( arr1 [ i ] < arr2 [ j ] ) sorted1 [ d ++ ] = arr1 [ i ++ ] ; else sorted1 [ d ++ ] = arr2 [ j ++ ] ; } while ( i < m ) sorted1 [ d ++ ] = arr1 [ i ++ ] ; while ( j < n ) sorted1 [ d ++ ] = arr2 [ j ++ ] ; return sorted1 [ k - 1 ] ; } int main ( ) { int arr1 [ 5 ] = { 2 , 3 , 6 , 7 , 9 } ; int arr2 [ 4 ] = { 1 , 4 , 8 , 10 } ; int k = 5 ; cout << kth ( arr1 , arr2 , 5 , 4 , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: d, i, j