dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAXN  100000
vector < int > bit1 ( MAXN , 0 ) ; vector < int > bit2 ( MAXN , 0 ) ; void update ( int idx , int val , vector < int > & bit ) { while ( idx < bit . size ( ) ) { bit [ idx ] += val ; idx += idx & ( - idx ) ; } } int query ( int idx , vector < int > & bit ) { int res = 0 ; while ( idx > 0 ) { res += bit [ idx ] ; idx -= idx & ( - idx ) ; } return res ; } void buildFenwickTree ( int a [ ] , int n ) { for ( int i = 1 ; i <= n ; i ++ ) { update ( i , a [ i - 1 ] , bit1 ) ; update ( i , a [ i - 1 ] * a [ i - 1 ] , bit2 ) ; } } void pairwiseProductSum ( int a [ ] , int l , int r ) { int sum , e , q ; e = query ( r , bit1 ) - query ( l - 1 , bit1 ) ; e = e * e ; q = query ( r , bit2 ) - query ( l - 1 , bit2 ) ; sum = ( e - q ) / 2 ; cout << sum << endl ; } void updateArray ( int * a , int p , int x ) { update ( p , - a [ p - 1 ] , bit1 ) ; update ( p , x , bit1 ) ; update ( p , - a [ p - 1 ] * a [ p - 1 ] , bit2 ) ; update ( p , x * x , bit2 ) ; a [ p - 1 ] = x ; } void solveQueries ( int * a , int n , int Q , int query [ ] [ 3 ] ) { buildFenwickTree ( a , n ) ; for ( int i = 0 ; i < Q ; i ++ ) { if ( query [ i ] [ 0 ] == 1 ) pairwiseProductSum ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; else updateArray ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; } } int main ( ) { int A [ ] = { 5 , 7 , 2 , 3 , 1 } ; int N = sizeof ( A ) / sizeof ( int ) ; int Q = 3 ; int query [ Q ] [ 3 ] = { { 1 , 1 , 3 } , { 2 , 2 , 5 } , { 1 , 2 , 5 } } ; solveQueries ( A , N , Q , query ) ; return 0 ; }

Index/key variables: Q, i, idx
Accumulator variables: i, idx, res, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countTriplets ( int arr [ ] , int n ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) odd ++ ; else even ++ ; } int c1 = odd * ( even * ( even - 1 ) ) / 2 ; int c2 = ( odd * ( odd - 1 ) * ( odd - 2 ) ) / 6 ; return c1 + c2 ; } int main ( ) { int arr [ ] = { 4 , 5 , 6 , 4 , 5 , 10 , 1 , 7 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int ans = countTriplets ( arr , n ) ; cout << ans ; return 0 ; }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxUniqueElements ( int A [ ] , int N ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ A [ i ] ] ++ ; } int cnt = 0 ; for ( auto x : mp ) { if ( x . second % 2 == 0 ) { cnt ++ ; } } int ans = mp . size ( ) ; if ( cnt % 2 == 1 ) { ans -- ; } return ans ; } int main ( ) { int N = 5 ; int A [ ] = { 1 , 2 , 1 , 3 , 7 } ; cout << maxUniqueElements ( A , N ) ; }

Index/key variables: i
Accumulator variables: ans, cnt, i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long countCells ( int n , int m , int s ) { int mx1 = -1 ; int cont1 = 0 ; for ( int i = 0 ; i < s && i < n ; ++ i ) { int aux = ( n - ( i + 1 ) ) / s + 1 ; if ( aux > mx1 ) { mx1 = cont1 = aux ; } else if ( aux == mx1 ) cont1 += aux ; } int mx2 = -1 ; int cont2 = 0 ; for ( int i = 0 ; i < s && i < m ; ++ i ) { int aux = ( m - ( i + 1 ) ) / s + 1 ; if ( aux > mx2 ) mx2 = cont2 = aux ; else if ( aux == mx2 ) cont2 += aux ; } return ( long long ) ( cont1 * cont2 ) ; } int main ( ) { int N = 5 , M = 5 , K = 2 ; cout << countCells ( N , M , K ) ; return 0 ; }

Accumulator variables: cont1, cont2, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countTotalPairs ( int N , int K ) { if ( K == 0 ) { return N * N ; } int ans = 0 ; for ( int b = K + 1 ; b <= N ; b ++ ) { ans += ( N / b ) * ( b - K ) ; ans += max ( N % b - K + 1 , 0 ) ; } return ans ; } int main ( ) { int N = 5 , K = 2 ; cout << countTotalPairs ( N , K ) ; return 0 ; }

Accumulator variables: ans, b, stdc
Iterator variables: b
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { int arr [ ] = { 4 , 2 , 4 , 1 , 4 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int maxi = 0 , remain , ans ; map < int , int > freq ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } for ( auto it : freq ) { maxi = max ( maxi , it . second ) ; } remain = n - maxi ; if ( maxi >= remain ) { ans = remain ; } else { ans = n / 2 ; } cout << ans ; freq . clear ( ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSumDifference ( int ar [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += ar [ i ] ; int rem = sum % n ; return rem * ( n - rem ) ; } int main ( ) { int arr [ ] = { 3 , 6 , 8 , 5 , 2 , 1 , 11 , 7 , 10 , 4 } ; int N = sizeof ( arr ) / sizeof ( int ) ; cout << minSumDifference ( 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 m = 1000000007 ; int power ( int x , int y ) { int res = 1 ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % m ; y = y >> 1 ; x = ( x * x ) % m ; } return res ; } int countNDigitNumber ( int N ) { int ne = N / 2 + N % 2 ; int no = floor ( N / 2 ) ; return power ( 4 , ne ) * power ( 5 , no ) ; } int main ( ) { int N = 5 ; cout << countNDigitNumber ( N ) % m << endl ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSteps ( int N ) { int count = 1 , res = 0 ; for ( int i = 1 ; i <= N ; i += count ) { res = max ( res , count ) ; count ++ ; } return res ; } int main ( ) { int N = 6 ; cout << minSteps ( N ) << " STRNEWLINE " ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSteps ( int N ) { int res = ( sqrt ( 1 + 8 * N ) - 1 ) / 2 ; return res ; } int main ( ) { int N = 6 ; cout << minSteps ( N ) << " STRNEWLINE " ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int oppositeFaceOfDice ( int N ) { int ans = 7 - N ; cout << ans ; } int main ( ) { int N = 2 ; oppositeFaceOfDice ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countReachablePoints ( int X , int Y , int L , int R ) { int diff_arr [ 100000 ] = { 0 } ; int count = 0 ; diff_arr [ X ] = 1 ; diff_arr [ X + 1 ] = -1 ; for ( int i = X ; i <= Y ; i ++ ) { diff_arr [ i ] += diff_arr [ i - 1 ] ; if ( diff_arr [ i ] >= 1 ) { diff_arr [ i + L ] += 1 ; diff_arr [ i + R + 1 ] -= 1 ; count ++ ; } } return count ; } int main ( ) { int X = 3 , Y = 12 , L = 2 , R = 3 ; cout << countReachablePoints ( X , Y , L , R ) ; return 0 ; }

Index/key variables: X, i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; Node * newNode ( int data ) { Node * new_node = new Node ; new_node -> data = data ; new_node -> next = NULL ; return new_node ; } Node * reverse ( Node * head ) { Node * prev = NULL ; Node * current = head ; Node * next ; while ( current != NULL ) { next = current -> next ; current -> next = prev ; prev = current ; current = next ; } return prev ; } Node * multiplyHelp ( Node * head , int M ) { Node * res = head ; Node * prev = NULL ; int carry = 0 , product = 1 ; while ( head != NULL ) { product = head -> data * M ; product += carry ; carry = product / 10 ; head -> data = product % 10 ; prev = head ; head = head -> next ; } if ( carry > 0 ) prev -> next = newNode ( carry ) ; return res ; } Node * multiply ( Node * head , int M ) { head = reverse ( head ) ; head = multiplyHelp ( head , M ) ; return reverse ( head ) ; } void printList ( Node * node ) { while ( node != NULL ) { cout << node -> data ; node = node -> next ; } } int main ( ) { Node * head = newNode ( 1 ) ; head -> next = newNode ( 2 ) ; head -> next -> next = newNode ( 7 ) ; head -> next -> next -> next = newNode ( 3 ) ; int M = 3 ; head = multiply ( head , M ) ; printList ( head ) ; return 0 ; }

Accumulator variables: product, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > s ( 11 , 0 ) ; void sieveOfEratosthenes ( int N ) { bool prime [ N + 1 ] ; memset ( prime , false , sizeof ( false ) ) ; for ( int i = 2 ; i < N + 1 ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i < N + 1 ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j < N / i + 1 ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } int generatePrimeFactors ( int N ) { int curr = s [ N ] ; map < int , int > cnt ; cnt [ s [ N ] ] = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( N and s [ N ] ) if ( cnt . find ( s [ N ] ) == cnt . end ( ) ) cnt [ s [ N ] ] = 1 ; else cnt [ s [ N ] ] += 1 ; } if ( cnt . find ( 0 ) != cnt . end ( ) ) cnt . erase ( 0 ) ; int totfactor = 1 ; for ( auto i : cnt ) totfactor *= i . second + 1 ; return totfactor ; } int countTriplets ( int N ) { int CountTriplet = 0 ; for ( int z = 1 ; z < N + 1 ; z ++ ) { int p = generatePrimeFactors ( N - z ) ; if ( p > 1 ) CountTriplet += p ; } return CountTriplet + 1 ; } int main ( ) { int N = 10 ; sieveOfEratosthenes ( N ) ; cout << countTriplets ( N ) ; }

Index/key variables: N, i
Accumulator variables: CountTriplet, N, i, j, stdc, totfactor, z
Iterator variables: i, j, z
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumSubarray ( vector < int > arr , int n , int m ) { vector < int > mapu ( m + 1 , 0 ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mapu [ arr [ i ] ] ++ ; if ( mapu [ arr [ i ] ] == ( n / m ) + 1 ) c ++ ; } if ( c == 0 ) return 0 ; int ans = n ; int l = 0 , r = 0 ; while ( r < n ) { if ( -- mapu [ arr [ r ] ] == ( n / m ) ) c -- ; if ( c == 0 ) { while ( l <= r && c == 0 ) { ans = min ( ans , r - l + 1 ) ; if ( ++ mapu [ arr [ l ] ] > ( n / m ) ) c ++ ; l ++ ; } } r ++ ; } return ans ; } int main ( ) { vector < int > arr = { 1 , 1 , 2 , 1 , 1 , 2 } ; int M = 2 ; int N = arr . size ( ) ; cout << minimumSubarray ( arr , N , M ) ; return 0 ; }

Index/key variables: i, l, r
Accumulator variables: c, i, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string checkSum ( int arr [ ] , int n , int k ) { unordered_map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ arr [ i ] ] ++ ; vector < int > freq [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { int f = m [ arr [ i ] ] ; if ( f != -1 ) { freq [ f ] . push_back ( arr [ i ] ) ; m [ arr [ i ] ] = -1 ; } } int count = 0 ; int kleastfreqsum = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int x : freq [ i ] ) { kleastfreqsum += x ; count ++ ; if ( count == k ) break ; } if ( count == k ) break ; } count = 0 ; int kmostfreqsum = 0 ; for ( int i = n ; i >= 0 ; i -- ) { for ( int x : freq [ i ] ) { kmostfreqsum += x ; count ++ ; if ( count == k ) break ; } if ( count == k ) break ; } if ( kleastfreqsum == kmostfreqsum ) return " Yes " ; return " No " ; } int main ( ) { int arr [ ] = { 3 , 2 , 1 , 2 , 3 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 2 ; cout << checkSum ( arr , N , K ) ; return 0 ; }

Index/key variables: f, i
Accumulator variables: count, i, kleastfreqsum, kmostfreqsum, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > solve ( int start , int end ) { string num = " " ; vector < int > ans ; for ( int i = 1 ; i <= 9 ; i ++ ) { num = to_string ( i ) ; int value = stoi ( num ) ; if ( value >= start and value <= end ) { ans . push_back ( value ) ; } for ( int j = i + 1 ; j <= 9 ; j ++ ) { num += to_string ( j ) ; value = stoi ( num ) ; if ( value >= start and value <= end ) { ans . push_back ( value ) ; } } } sort ( ans . begin ( ) , ans . end ( ) ) ; return ans ; } int main ( ) { int L = 12 , R = 87 ; vector < int > ans = solve ( 12 , 87 ) ; for ( auto & it : ans ) cout << it << ' ▁ ' ; return 0 ; }

Accumulator variables: i, j, num, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minDistance ( int start [ ] , int end [ ] , int n , int d ) { int left = INT_MIN ; int right = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { left = max ( left , start [ i ] ) ; right = min ( right , end [ i ] ) ; } if ( left > right ) return -1 ; if ( d >= left && d <= right ) return 0 ; if ( d < left ) return ( left - d ) ; if ( d > right ) return ( d - right ) ; } int main ( ) { int start [ ] = { 0 , 2 , 4 } ; int end [ ] = { 7 , 14 , 6 } ; int n = sizeof ( start ) / sizeof ( int ) ; int d = 3 ; cout << minDistance ( start , end , n , d ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int x , unsigned int y ) { if ( y == 0 ) return 1 ; if ( y % 2 == 0 ) return power ( x , y / 2 ) * power ( x , y / 2 ) ; return x * power ( x , y / 2 ) * power ( x , y / 2 ) ; } int order ( int num ) { int count = 0 ; while ( num ) { count ++ ; num = num / 10 ; } return count ; } int isArmstrong ( int N ) { int r = order ( N ) ; int temp = N , sum = 0 ; while ( temp ) { int d = temp % 10 ; sum += power ( d , r ) ; temp = temp / 10 ; } return ( sum == N ) ; } int maxSum ( int arr [ ] , int N , int K ) { if ( N < K ) { return -1 ; } int res = 0 ; for ( int i = 0 ; i < K ; i ++ ) { res += arr [ i ] ; } int curr_sum = res ; for ( int i = K ; i < N ; i ++ ) { curr_sum += arr [ i ] - arr [ i - K ] ; res = max ( res , curr_sum ) ; } return res ; } int maxArmstrong ( int arr [ ] , int N , int K ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = isArmstrong ( arr [ i ] ) ; } return maxSum ( arr , N , K ) ; } int main ( ) { int arr [ ] = { 28 , 2 , 3 , 6 , 153 , 99 , 828 , 24 } ; int K = 6 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxArmstrong ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, curr_sum, i, res, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( long long x , unsigned int y , int p ) { int res = 1 ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } int countArrays ( int n , int k ) { int mod = 1000000007 ; int ans = power ( n , k , mod ) ; return ans ; } int main ( ) { int n = 3 , k = 5 ; int ans = countArrays ( n , k ) ; cout << ans << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { res = res * i ; } return res ; } int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } void countWays ( string s , string t ) { int n = s . length ( ) ; int sum1 = 0 , sum2 = 0 , K = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { sum1 ++ ; } else sum1 -- ; } int m = t . length ( ) ; for ( int i = 0 ; i < m ; i ++ ) { if ( t [ i ] == '1' ) { sum2 ++ ; } else if ( t [ i ] == '0' ) { sum2 -- ; } else K ++ ; } int P = abs ( sum1 - sum2 ) ; if ( P > K or ( K - P ) % 2 ) { cout << 0 ; return ; } cout << nCr ( K , ( P + K ) / 2 ) ; } int main ( ) { string S1 = "1010" ; string S2 = "10 ? ? " ; countWays ( S1 , S2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: K, i, stdc, sum1, sum2
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countPairs ( int arr [ ] , int N ) { int answer = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] + arr [ j ] == i + j ) { answer ++ ; } } } cout << answer ; } int main ( ) { int arr [ ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: answer, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkDistribution ( int R , int B , int D ) { if ( max ( R , B ) <= min ( R , B ) * ( D + 1 ) ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { int R = 1 , B = 1 , D = 0 ; checkDistribution ( R , B , D ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < pair < int , int > > primeFactor ( int N ) { vector < pair < int , int > > v ; int count = 0 ; while ( ! ( N % 2 ) ) { N >>= 1 ; count ++ ; } if ( count ) v . push_back ( { 2 , count } ) ; for ( int i = 3 ; i <= sqrt ( N ) ; i += 2 ) { count = 0 ; while ( N % i == 0 ) { count ++ ; N = N / i ; } if ( count ) { v . push_back ( { i , count } ) ; } } if ( N > 2 ) v . push_back ( { N , 1 } ) ; return v ; } void printAnswer ( int n ) { vector < pair < int , int > > v = primeFactor ( n ) ; int maxi_size = 0 , prime_factor = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( maxi_size < v [ i ] . second ) { maxi_size = v [ i ] . second ; prime_factor = v [ i ] . first ; } } if ( maxi_size < 2 ) { cout << 1 << ' ▁ ' << n ; } else { int product = 1 ; cout << maxi_size << endl ; for ( int i = 0 ; i < maxi_size - 1 ; i ++ ) { cout << prime_factor << " ▁ " ; product *= prime_factor ; } cout << ( n / product ) ; } } int main ( ) { int N = 360 ; printAnswer ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, product, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void IsEvenPath ( int Source [ ] , int Destination [ ] ) { int x_dif = abs ( Source [ 0 ] - Destination [ 0 ] ) ; int y_dif = abs ( Source [ 1 ] - Destination [ 1 ] ) ; int minsteps = x_dif + y_dif ; if ( minsteps % 2 == 0 ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int Source [ ] = { 2 , 1 } ; int Destination [ ] = { 1 , 4 } ; IsEvenPath ( Source , Destination ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long ABS ( long long x ) { return max ( x , - x ) ; } void findFraction ( long long x , long long y , long long n ) { long long A = -1 , B = -1 ; for ( long long i = 1 ; i <= n ; i ++ ) { long long d = ( i * x ) / y ; if ( d >= 0 && ( A == -1 || ABS ( B * x - y * A ) * ABS ( i * y ) > ABS ( i * x - y * d ) * ABS ( B * y ) ) ) A = d , B = i ; d ++ ; if ( d >= 0 && ( A == -1 || ABS ( B * x - y * A ) * ABS ( i * y ) > ABS ( i * x - y * d ) * ABS ( B * y ) ) ) A = d , B = i ; } cout << A << " / " << B << endl ; } int main ( ) { long long x = 3 , y = 7 , n = 6 ; findFraction ( x , y , n ) ; return 0 ; }

Accumulator variables: d, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string BaseConversion ( int N ) { string s = " " ; while ( N != 0 ) { if ( N % 2 == 0 ) { s = "0" + s ; } else { s = "1" + s ; N -- ; } N /= -2 ; } if ( s == " " ) { s = "0" ; } return s ; } int main ( ) { int N = -9 ; cout << BaseConversion ( N ) ; return 0 ; }

Accumulator variables: N, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void finalInstances ( int instances , int arr [ ] , int N ) { int i = 0 ; while ( i < N ) { if ( arr [ i ] < 25 && instances > 1 ) { double temp = ( instances / 2.0 ) ; instances = ( int ) ( ceil ( temp ) ) ; i = i + 10 ; } else if ( arr [ i ] > 60 && instances <= ( 2 * pow ( 10 , 8 ) ) ) { instances = instances * 2 ; i = i + 10 ; } i = i + 1 ; } cout << instances ; } int main ( ) { int instances = 2 ; int arr [ ] = { 25 , 23 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 76 , 80 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; finalInstances ( instances , arr , N ) ; }

Index/key variables: i
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isMakeZero ( int arr [ ] , int N , int K ) { map < int , int > MP ; vector < int > V ; int X = 1 ; int i ; while ( X > 0 && X < INT_MAX ) { V . push_back ( X ) ; X *= K ; } for ( i = 0 ; i < N ; i ++ ) { for ( int j = V . size ( ) - 1 ; j >= 0 ; j -- ) { if ( MP [ V [ j ] ] == 0 && V [ j ] <= arr [ i ] ) { arr [ i ] -= V [ j ] ; MP [ V [ j ] ] = 1 ; } } if ( arr [ i ] != 0 ) break ; } if ( i < N ) return " No " ; else return " Yes " ; } int main ( ) { int arr [ ] = { 8 , 0 , 3 , 4 , 80 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 2 ; cout << isMakeZero ( arr , N , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: X, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string perfectSquare ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int p = sqrt ( arr [ i ] ) ; if ( p * p != arr [ i ] ) { return " No " ; } } return " Yes " ; } int main ( ) { int arr [ ] = { 1 , 4 , 100 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << perfectSquare ( 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 countKAverageSubarrays ( int arr [ ] , int n , int k ) { int res = 0 ; for ( int L = 0 ; L < n ; L ++ ) { int sum = 0 ; for ( int R = L ; R < n ; R ++ ) { sum += arr [ R ] ; int len = ( R - L + 1 ) ; if ( sum % len == 0 ) { int avg = sum / len ; if ( avg == k ) res ++ ; } } } return res ; } int main ( ) { int K = 6 ; int arr [ ] = { 12 , 5 , 3 , 10 , 4 , 8 , 10 , 12 , -6 , -1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countKAverageSubarrays ( arr , N , K ) ; }

Index/key variables: R
Accumulator variables: L, R, res, stdc, sum
Iterator variables: L, R
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumElement ( int arr [ ] , int N , int K ) { int minElement = arr [ 0 ] ; for ( int i = 0 ; i < N ; ++ i ) { minElement = min ( minElement , arr [ i ] ) ; } int reqOperations = 0 ; for ( int i = 0 ; i < N ; ++ i ) { reqOperations += arr [ i ] - minElement ; } if ( reqOperations < K ) { K -= reqOperations ; minElement -= ( K + N - 1 ) / N ; } return minElement ; } int main ( ) { int arr [ ] = { 10 , 10 , 10 , 10 } ; int K = 7 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumElement ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: K, minElement, reqOperations, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > FractionSplit ( long long n , long long d ) { vector < string > UnitFactions ; while ( n > 0 ) { long long x = ( d + n - 1 ) / n ; string s = "1 / " + to_string ( x ) ; UnitFactions . push_back ( s ) ; n = n * x - d ; d = d * x ; } return UnitFactions ; } int main ( ) { long long n = 13 , d = 18 ; auto res = FractionSplit ( n , d ) ; for ( string s : res ) cout << s << " , ▁ " ; return 0 ; }

Accumulator variables: stdc
Iterator variables: s
C++ program:
#include <iostream>
using namespace std ; void swap ( int & a , int & b ) { int temp = a ; a = b ; b = temp ; } void findPermutation ( int N ) { int arr [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = i + 1 ; } for ( int i = 1 ; i < N ; i += 2 ) { swap ( arr [ i ] , arr [ i - 1 ] ) ; } if ( N % 2 == 1 && N > 1 ) { swap ( arr [ N - 1 ] , arr [ N - 2 ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } int main ( ) { int N = 7 ; findPermutation ( N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void addAP ( int A [ ] , int Q , int operations [ 2 ] [ 4 ] ) { for ( int j = 0 ; j < 2 ; ++ j ) { int L = operations [ j ] [ 0 ] , R = operations [ j ] [ 1 ] , a = operations [ j ] [ 2 ] , d = operations [ j ] [ 3 ] ; int curr = a ; for ( int i = L - 1 ; i < R ; i ++ ) { A [ i ] += curr ; curr += d ; } } for ( int i = 0 ; i < 4 ; ++ i ) cout << A [ i ] << " ▁ " ; } int main ( ) { int A [ ] = { 5 , 4 , 2 , 8 } ; int Q = 2 ; int Query [ 2 ] [ 4 ] = { { 1 , 2 , 1 , 3 } , { 1 , 4 , 4 , 1 } } ; addAP ( A , Q , Query ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: curr, i
Iterator variables: i, j