dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxSum ( int arr [ ] , int n ) { int sum = 0 ; int max_neg = INT_MAX ; int tempsum = 0 ; int small = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; small = min ( small , arr [ i ] ) ; if ( arr [ i ] > 0 ) { tempsum = 0 ; } else { tempsum += arr [ i ] ; } max_neg = min ( max_neg , tempsum ) ; } if ( max_neg == 0 ) { max_neg = small ; } cout << sum - max_neg ; } int main ( ) { int arr [ ] = { -2 , -3 , 4 , -1 , -2 , 1 , 5 , -3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum, tempsum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string largestString ( string s , int k ) { for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] != ' z ' && k > 0 ) { s [ i ] = ' z ' ; k -- ; } } return s ; } int main ( ) { string s = " dbza " ; int k = 1 ; cout << largestString ( s , k ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void RemoveOneChar ( string A , string B , int N , int M ) { int X = 0 ; int Y = N - 1 ; for ( int i = 0 ; i < M ; i ++ ) { if ( A [ X ] != B [ i ] ) break ; X ++ ; } for ( int i = M - 1 ; i >= 0 ; i -- ) { if ( A [ Y ] != B [ i ] ) break ; Y -- ; } if ( N - M == 1 && Y < X ) { cout << X - Y + 1 << endl ; for ( int i = Y ; i <= X ; i ++ ) cout << i + 1 << " ▁ " ; cout << endl ; } else cout << -1 << endl ; } int main ( ) { string A = " abaac " ; string B = " abac " ; int N = A . length ( ) ; int M = B . length ( ) ; RemoveOneChar ( A , B , N , M ) ; }

Index/key variables: X, Y, i
Accumulator variables: X, Y, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumOperation ( string a , string b ) { int n = a . length ( ) ; int i = 0 ; int minoperation = 0 ; while ( i < n ) { if ( a [ i ] == b [ i ] ) { i = i + 1 ; continue ; } else if ( a [ i ] == b [ i + 1 ] && a [ i + 1 ] == b [ i ] && i < n - 1 ) { minoperation ++ ; i = i + 2 ; } else if ( a [ i ] != b [ i ] ) { minoperation ++ ; i = i + 1 ; } else { ++ i ; } } cout << minoperation ; } int main ( ) { string a = "10010010" , b = "00001000" ; minimumOperation ( a , b ) ; return 0 ; }

Index/key variables: i
Accumulator variables: minoperation, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinOperations ( int arr [ ] , int N , int K ) { int operations = 0 ; for ( int i = 0 ; i < K ; i ++ ) { unordered_map < int , int > freq ; for ( int j = i ; j < N ; j += K ) freq [ arr [ j ] ] ++ ; int max1 = 0 , num ; for ( auto x : freq ) { if ( x . second > max1 ) { max1 = x . second ; num = x . first ; } } for ( auto x : freq ) { if ( x . first != num ) operations += x . second ; } } cout << operations ; } int main ( ) { int arr [ ] = { 3 , 4 , 3 , 5 , 6 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMinOperations ( arr , N , K ) ; return 0 ; }

Index/key variables: j
Accumulator variables: i, j, operations, stdc
Iterator variables: i, j, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countOfPairs ( int x , int y ) { int count = 0 ; for ( int k = 1 ; k * k <= x ; ++ k ) { count += max ( 0 , min ( y , x / k - 1 ) - k ) ; } cout << count << " STRNEWLINE " ; } int main ( ) { int x = 4 ; int y = 5 ; countOfPairs ( x , y ) ; return 0 ; }

Accumulator variables: count, stdc
Iterator variables: k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPermutations ( int N ) { vector < vector < int > > adj ( 105 ) ; int indeg = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { if ( i == j ) continue ; int sum = i + j ; if ( ceil ( sqrt ( sum ) ) == floor ( sqrt ( sum ) ) ) { adj [ i ] . push_back ( j ) ; } } if ( adj [ i ] . size ( ) == 1 ) indeg ++ ; } if ( indeg == 0 ) return N ; else if ( indeg <= 2 ) return 2 ; else return 0 ; } int main ( ) { int N = 17 ; cout << countPermutations ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, indeg, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void makeList ( int N , int K ) { int list [ N ] ; int left = 1 ; int right = N ; for ( int i = 0 ; i < N ; i ++ ) { if ( K % 2 == 0 ) { list [ i ] = left ; left = left + 1 ; } else { list [ i ] = right ; right = right - 1 ; } if ( K > 1 ) K -- ; } for ( int i = 0 ; i < N ; i ++ ) { cout << list [ i ] << " ▁ " ; } } int main ( ) { int N = 6 ; int K = 3 ; makeList ( N , K ) ; }

Index/key variables: N, i
Accumulator variables: K, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void getDate ( int d , string m ) { int days [ ] = { 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; string month [ ] = { " January " , " February " , " March " , " April " , " May " , " June " , " July " , " August " , " September " , " October " , " November " , " December " } ; int cnt = 183 ; int cur_month ; for ( int i = 0 ; i < 12 ; i ++ ) if ( m == month [ i ] ) cur_month = i ; int cur_date = d ; while ( 1 ) { while ( cnt > 0 && cur_date <= days [ cur_month ] ) { cnt -= 1 ; cur_date += 1 ; } if ( cnt == 0 ) break ; cur_month = ( cur_month + 1 ) % 12 ; cur_date = 1 ; } cout << cur_date << " ▁ " << month [ cur_month ] << endl ; } int main ( ) { int D = 15 ; string M = " January " ; getDate ( D , M ) ; return 0 ; }

Index/key variables: cur_month, i
Accumulator variables: cnt, cur_date, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long largestNumber ( int N ) { if ( N > 45 ) return -1 ; int num = 0 , digit = 9 ; while ( N > 0 && digit > 0 ) { if ( digit <= N ) { num *= 10 ; num += digit ; N -= digit ; } digit -= 1 ; } return num * 10 ; } int main ( ) { int N = 25 ; cout << largestNumber ( N ) ; return 0 ; }

Accumulator variables: N, digit, num, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumSum ( int A [ ] , int N , string S ) { int mul = 0 ; for ( int i = 0 ; i < ( int ) S . size ( ) ; i ++ ) { if ( S [ i ] == ' * ' ) mul += 1 ; } int ans = 1000000 ; for ( int i = 0 ; i < ( 1 << ( N - 1 ) ) ; i ++ ) { int cnt = 0 ; vector < char > v ; for ( int j = 0 ; j < N - 1 ; j ++ ) { if ( ( 1 << j ) & ( i ) ) { cnt += 1 ; v . push_back ( ' * ' ) ; } else { v . push_back ( ' + ' ) ; } } if ( cnt == mul ) { deque < int > d ; d . push_back ( A [ 0 ] ) ; for ( int j = 0 ; j < N - 1 ; j ++ ) { if ( v [ j ] == ' * ' ) { int x = d . back ( ) ; d . pop_back ( ) ; x = x * A [ j + 1 ] ; d . push_back ( x ) ; } else { d . push_back ( A [ j + 1 ] ) ; } } int sum = 0 ; while ( d . size ( ) > 0 ) { int x = d . front ( ) ; sum += x ; d . pop_front ( ) ; } ans = min ( ans , sum ) ; } } return ans ; } int main ( ) { int A [ ] = { 2 , 2 , 2 , 2 } ; string S = " * * + " ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << minimumSum ( A , N , S ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: cnt, i, j, mul, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sumOfMedians ( int arr [ ] , int N , int K ) { int selectMedian = ( K + 1 ) / 2 ; int totalArrays = N / K ; int minSum = 0 ; int i = selectMedian - 1 ; while ( i < N and totalArrays != 0 ) { minSum = minSum + arr [ i ] ; i = i + selectMedian ; totalArrays -- ; } cout << minSum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = sizeof ( arr ) / sizeof ( int ) ; int K = 2 ; sumOfMedians ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc, totalArrays
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( int S , int K , int N ) { if ( K > N ) { cout << " - 1" << endl ; return ; } int max_sum = 0 , min_sum = 0 ; for ( int i = 1 ; i <= K ; i ++ ) { min_sum += i ; max_sum += N - i + 1 ; } if ( S < min_sum S > max_sum ) { cout << " - 1" << endl ; return ; } int s1 = 0 ; vector < int > nums ; for ( int i = 1 ; i <= N ; i ++ ) { if ( s1 > S ) break ; s1 += i ; nums . push_back ( i ) ; } vector < int > answer ; int s2 = 0 ; for ( int i = 0 ; i < K - 1 ; i ++ ) { answer . push_back ( nums [ i ] ) ; s2 += nums [ i ] ; } answer . push_back ( S - s2 ) ; int Max = N ; for ( int i = answer . size ( ) - 1 ; i >= 0 ; i -- ) { if ( answer [ i ] > Max ) { int extra = answer [ i ] - Max ; if ( i - 1 >= 0 ) answer [ i - 1 ] += extra ; answer [ i ] = Max ; Max -- ; } else break ; } for ( auto x : answer ) cout << x << " ▁ " ; cout << endl ; } int main ( ) { int S = 15 , K = 4 , N = 8 ; solve ( S , K , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: Max, i, max_sum, min_sum, s1, s2, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSizeArr ( int A [ ] , int N , int K ) { int leftTaken = N , rightTaken = N ; int leftSum = 0 , rightSum = 0 ; for ( int left = -1 ; left < N ; left ++ ) { if ( left != -1 ) leftSum += A [ left ] ; rightSum = 0 ; for ( int right = N - 1 ; right > left ; right -- ) { rightSum += A [ right ] ; if ( leftSum + rightSum == K ) { if ( leftTaken + rightTaken > ( left + 1 ) + ( N - right ) ) { leftTaken = left + 1 ; rightTaken = N - right ; } break ; } if ( leftSum + rightSum > K ) break ; } } if ( leftTaken + rightTaken <= N ) { for ( int i = 0 ; i < leftTaken ; i ++ ) cout << A [ i ] << " ▁ " ; for ( int i = 0 ; i < rightTaken ; i ++ ) cout << A [ N - i - 1 ] << " ▁ " ; } else cout << -1 ; } int main ( ) { int N = 7 ; int A [ ] = { 3 , 2 , 1 , 1 , 1 , 1 , 3 } ; int K = 10 ; minSizeArr ( A , N , K ) ; return 0 ; }

Index/key variables: i, left, right
Accumulator variables: i, left, leftSum, right, rightSum, stdc
Iterator variables: i, left, right
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minSizeArr ( int A [ ] , int N , int K ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += A [ i ] ; if ( K > sum ) { cout << -1 ; return ; } if ( K == sum ) { for ( int i = 0 ; i < N ; i ++ ) { cout << A [ i ] << " ▁ " ; } return ; } int tar = sum - K ; unordered_map < int , int > um ; um [ 0 ] = -1 ; int left , right ; int cur = 0 , maxi = -1 ; for ( int i = 0 ; i < N ; i ++ ) { cur += A [ i ] ; if ( um . find ( cur - tar ) != um . end ( ) && i - um [ cur - tar ] > maxi ) { maxi = i - um [ cur - tar ] ; right = i ; left = um [ cur - tar ] ; } if ( um . find ( cur ) == um . end ( ) ) um [ cur ] = i ; } if ( maxi == -1 ) cout << -1 ; else { for ( int i = 0 ; i <= left ; i ++ ) cout << A [ i ] << " ▁ " ; for ( int i = 0 ; i < right ; i ++ ) cout << A [ N - i - 1 ] << " ▁ " ; } } int main ( ) { int N = 7 ; int A [ ] = { 3 , 2 , 1 , 1 , 1 , 1 , 3 } ; int K = 10 ; minSizeArr ( A , N , K ) ; return 0 ; }

Index/key variables: cur, i
Accumulator variables: cur, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long
using namespace std ; void minModulo ( int L , int R , int N ) { if ( R - L < N ) { int ans = INT_MAX ; for ( ll i = L ; i <= R ; i ++ ) for ( ll j = L ; j <= R ; j ++ ) if ( i != j ) ans = min ( 0ll + ans , ( i * j ) % N ) ; cout << ans ; } else { cout << 0 ; } } int main ( ) { int L = 6 , R = 10 , N = 2019 ; minModulo ( L , R , N ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumbers ( int N ) { int count = 0 ; for ( int i = 1 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { count ++ ; if ( N / i != i ) { count ++ ; } } } return count ; } int main ( ) { int N = 10 ; cout << countNumbers ( N ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumSize ( int a [ ] , int k , int n ) { int low = 1 ; int high = * max_element ( a , a + n ) ; int ans = -1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; int count = 0 ; for ( int c = 0 ; c < n ; c ++ ) { count += a / mid ; } if ( count >= k ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 9 } ; int K = 6 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( maximumSize ( arr , K , n ) ) ; }

Accumulator variables: c, count, stdc
Iterator variables: c
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findEquation ( int A , int B , int C , int K ) { cout << A << " ▁ " << K * B << " ▁ " << K * K * C ; } int main ( ) { int A = 1 , B = 2 , C = 1 , K = 2 ; findEquation ( A , B , C , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMaxValueOfEquation ( vector < vector < int > > & arr , int K ) { priority_queue < vector < int > > pq ; int res = INT_MIN ; for ( auto point : arr ) { while ( ! pq . empty ( ) && point [ 0 ] - pq . top ( ) [ 1 ] > K ) { pq . pop ( ) ; } if ( ! pq . empty ( ) ) { res = max ( res , pq . top ( ) [ 0 ] + point [ 0 ] + point [ 1 ] ) ; } pq . push ( { point [ 1 ] - point [ 0 ] , point [ 0 ] } ) ; } cout << res ; } int main ( ) { vector < vector < int > > arr = { { 1 , 3 } , { 2 , 0 } , { 5 , 10 } , { 6 , -10 } } ; int K = 1 ; findMaxValueOfEquation ( arr , K ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: point
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOperations ( int arr [ ] , int n ) { int oddcount = 0 , evencount = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) oddcount ++ ; else evencount ++ ; } return min ( oddcount , evencount ) ; } int main ( ) { int arr [ ] = { 2 , 4 , 3 , 1 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minOperations ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: evencount, i, oddcount, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long gcd ( long long a , long long b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } void countDistinctNumbers ( long long A , long long B , long long C ) { long long g = gcd ( A , B ) ; long long count = C / g ; cout << count ; } int main ( ) { long long A = 2 , B = 3 , C = 5 ; countDistinctNumbers ( A , B , C ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printLastElement ( int arr [ ] , int N ) { bool leftTurn = true ; int remainElements = N ; int step = 1 ; int head = 1 ; while ( remainElements > 1 ) { if ( leftTurn ) { head = head + step ; } else { if ( remainElements % 2 == 1 ) head = head + step ; } remainElements = remainElements / 2 ; step = step * 2 ; leftTurn = ! leftTurn ; } cout << arr [ head - 1 ] ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printLastElement ( arr , N ) ; return 0 ; }

Accumulator variables: stdc
Boolean variables: leftTurn
C++ program:
#include <bits/stdc++.h>
using namespace std ; int max_min ( int N , int C , int K ) { int maximum , minimum ; if ( N == 1 ) { maximum = minimum = C ; } else if ( K >= C ) { maximum = C ; minimum = 0 ; } else { maximum = K ; minimum = 0 ; int remain_candy = C - K ; maximum += remain_candy / N ; minimum = remain_candy / N ; if ( remain_candy % N == N - 1 ) { minimum ++ ; } } cout << " Maximum ▁ = ▁ " << maximum << endl ; cout << " Minimum ▁ = ▁ " << minimum ; return 0 ; } int main ( ) { int N = 4 ; int C = 12 ; int K = 3 ; max_min ( N , C , K ) ; return 0 ; }

Accumulator variables: maximum, minimum, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void shortestSubarray ( int * A , int N ) { int i ; int left_index ; for ( i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] + 1 != A [ i + 1 ] ) break ; } left_index = i ; int right_index ; for ( i = N - 1 ; i >= 1 ; i -- ) { if ( A [ i ] != A [ i - 1 ] + 1 ) break ; } right_index = i ; int updated_right ; int minLength = min ( N - left_index - 1 , right_index ) ; if ( A [ right_index ] <= A [ left_index ] + 1 ) { updated_right = right_index + A [ left_index ] - A [ right_index ] + 1 ; if ( updated_right < N ) minLength = min ( minLength , updated_right - left_index - 1 ) ; } cout << minLength ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 7 , 4 , 3 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; shortestSubarray ( arr , N ) ; return 0 ; }

Index/key variables: i, left_index, right_index
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string freqCheck ( string S , int N ) { int hash [ 26 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { hash [ S [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( hash [ i ] > 2 ) { return " Yes " ; } } return " No " ; } int main ( ) { string S = " geekseekforgeeks " ; int N = S . length ( ) ; cout << freqCheck ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minLength ( string s ) { int i = 0 , j = s . length ( ) - 1 ; for ( ; i < j && s [ i ] == s [ j ] ; ) { char d = s [ i ] ; while ( i <= j && s [ i ] == d ) i ++ ; while ( i <= j && s [ j ] == d ) j -- ; } return j - i + 1 ; } int main ( ) { string S = " aacbcca " ; cout << minLength ( S ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int mod = 1000000007 ; int power ( long long x , unsigned int y ) { int res = 1 ; x = x % mod ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % mod ; y = y >> 1 ; x = ( x * x ) % mod ; } return res ; } int CountBST ( int H ) { return power ( 2 , H ) ; } int main ( ) { int H = 2 ; cout << CountBST ( H ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rotateString ( int n , int m , string s ) { vector < int > v ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { v . push_back ( i ) ; } } for ( int i = 1 ; i < ( int ) v . size ( ) ; i ++ ) { if ( ( v [ i ] - v [ i - 1 ] - 1 ) > m ) { cnt ++ ; } } if ( v . size ( ) >= 2 && ( n - ( v . back ( ) - v [ 0 ] ) - 1 ) > m ) { cnt ++ ; } if ( cnt <= 1 ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { string S = "101001" ; int M = 1 ; int N = S . size ( ) ; rotateString ( N , M , S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumber ( int N ) { int ans [ 6 ] = { 1 , 2 , 4 , 8 , 7 , 5 } ; return ans [ N % 6 ] ; } int main ( ) { int N = 6 ; cout << findNumber ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canBeEmptied ( int A , int B ) { if ( max ( A , B ) > 2 * min ( A , B ) ) { cout << " No " ; return ; } if ( ( A + B ) % 3 == 0 ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int A = 1 , B = 2 ; canBeEmptied ( A , B ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumIndex ( int N , int B ) { int i = 0 , j = 1 ; int cnt = 0 ; int sum = N * ( N + 1 ) / 2 ; bool flag = false ; while ( cnt < N ) { i += j ; j ++ ; cnt ++ ; if ( i == B ) { flag = true ; break ; } } if ( ! flag ) { cout << sum ; } else cout << sum - 1 ; } int main ( ) { int N = 4 , B = 6 ; maximumIndex ( N , B ) ; return 0 ; }

Accumulator variables: cnt, i, j, stdc
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findLongestArray ( int K ) { vector < pair < int , int > > primefactors ; int K_temp = K ; for ( int i = 2 ; i * i <= K ; i ++ ) { int count = 0 ; while ( K_temp % i == 0 ) { K_temp /= i ; count ++ ; } if ( count > 0 ) primefactors . push_back ( { count , i } ) ; } if ( K_temp != 1 ) primefactors . push_back ( { 1 , K_temp } ) ; sort ( primefactors . rbegin ( ) , primefactors . rend ( ) ) ; vector < int > answer ( primefactors [ 0 ] . first , primefactors [ 0 ] . second ) ; answer . back ( ) *= K ; for ( int i = 0 ; i < primefactors [ 0 ] . first ; i ++ ) { answer . back ( ) /= primefactors [ 0 ] . second ; } cout << " { " ; for ( int i = 0 ; i < ( int ) answer . size ( ) ; i ++ ) { if ( i == answer . size ( ) - 1 ) cout << answer [ i ] << " } " ; else cout << answer [ i ] << " , ▁ " ; } } int main ( ) { int K = 4 ; findLongestArray ( K ) ; }

Index/key variables: i
Accumulator variables: K_temp, count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minsteps ( vector < int > & A ) { int n = A . size ( ) ; vector < int > left ( n , 0 ) , right ( n , 0 ) , res ( n , 0 ) ; int count = A [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { left [ i ] = left [ i - 1 ] + count ; count += A [ i ] ; } count = A [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { right [ i ] = right [ i + 1 ] + count ; count += A [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { res [ i ] = left [ i ] + right [ i ] ; cout << res [ i ] << " ▁ " ; } cout << " STRNEWLINE " ; } int main ( ) { vector < int > A = { 1 , 0 , 1 , 0 } ; minsteps ( A ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumOperations ( vector < int > & A , int K ) { vector < int > isflipped ( A . size ( ) , 0 ) ; int ans = 0 ; for ( int i = 0 ; i < A . size ( ) ; i ++ ) { if ( i > 0 ) { isflipped [ i ] += isflipped [ i - 1 ] ; isflipped [ i ] %= 2 ; } if ( A [ i ] == 0 && ! isflipped [ i ] ) { if ( ( A . size ( ) - i + 1 ) <= K ) { cout << -1 ; return ; } ans ++ ; isflipped [ i ] ++ ; isflipped [ i + K ] -- ; } else if ( A [ i ] == 1 && isflipped [ i ] ) { if ( ( A . size ( ) - i + 1 ) <= K ) { cout << -1 ; return ; } ans ++ ; isflipped [ i ] ++ ; isflipped [ i + K ] -- ; } } cout << ans ; } int main ( ) { vector < int > arr = { 0 , 1 , 0 } ; int K = 1 ; minimumOperations ( arr , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findScoreSum ( int n ) { int total = 0 ; int prev_monday = 0 , curr_day = 0 ; for ( int day = 1 ; day <= n ; day ++ ) { if ( day % 7 == 1 ) { prev_monday ++ ; curr_day = prev_monday ; } total += curr_day ++ ; } cout << total ; } int main ( ) { int N = 8 ; findScoreSum ( N ) ; return 0 ; }

Accumulator variables: curr_day, day, prev_monday, stdc, total
Iterator variables: day
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findScoreSum ( int n ) { int F = n / 7 ; int D = n % 7 ; int fullWeekScore = ( 49 + 7 * F ) * F / 2 ; int lastNonFullWeekScore = ( 2 * F + D + 1 ) * D / 2 ; cout << fullWeekScore + lastNonFullWeekScore ; } int main ( ) { int N = 8 ; findScoreSum ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long maximumNum ( long long X , long long Y , long long N ) { long long num = 0 ; if ( N - N % X + Y <= N ) { num = N - N % X + Y ; } else { num = N - N % X - ( X - Y ) ; } return num ; } int main ( ) { long long X = 10 ; long long Y = 5 ; long long N = 15 ; cout << maximumNum ( X , Y , N ) ; return 0 ; }

Accumulator variables: stdc