dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxLitres ( int budget , int plastic , int glass , int refund ) { if ( glass - refund < plastic ) { int ans = max ( ( budget - refund ) / ( glass - refund ) , 0 ) ; budget -= ans * ( glass - refund ) ; ans += budget / plastic ; cout << ans << endl ; } else cout << ( budget / plastic ) << endl ; } int main ( ) { int budget = 10 , plastic = 11 , glass = 9 , refund = 8 ; maxLitres ( budget , plastic , glass , refund ) ; }

Accumulator variables: ans, budget, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int leastValue ( int P , int A , int N , int a [ ] ) { int ans = -1 ; float tmp = ( float ) INFINITY ; for ( int i = 0 ; i < N ; i ++ ) { float t = P - a [ i ] * 0.006 ; if ( abs ( t - A ) < tmp ) { tmp = abs ( t - A ) ; ans = i ; } } return a [ ans ] ; } int main ( ) { int N = 2 , P = 12 , A = 2005 ; int a [ ] = { 1000 , 2000 } ; cout << leastValue ( P , A , N , a ) << endl ; }

Index/key variables: ans, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findPermutation ( int n ) { int len = ceil ( log10 ( n ) ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( n % 2 != 0 ) { return n ; } else { n = ( n / 10 ) + ( n % 10 ) * pow ( 10 , len - i - 1 ) ; continue ; } } return -1 ; } int main ( ) { int n = 132 ; cout << findPermutation ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int n = 3 ; const int m = 4 ; int maxMatrixScore ( int A [ n ] [ m ] , int K ) { map < int , int > update ; for ( int i = 0 ; i < n ; ++ i ) { if ( A [ i ] [ 0 ] == 0 ) { int ans = 0 ; for ( int j = 1 ; j < m ; ++ j ) ans = ans + A [ i ] [ j ] * pow ( 2 , m - j - 1 ) ; update [ ans ] = i ; } } map < int , int > :: iterator it = update . begin ( ) ; while ( K > 0 && it != update . end ( ) ) { int idx = it -> second ; for ( int j = 0 ; j < m ; ++ j ) A [ idx ] [ j ] = ( A [ idx ] [ j ] + 1 ) % 2 ; it ++ ; K -- ; } int ans = 0 ; for ( int j = 0 ; j < m ; ++ j ) { int zero = 0 , one = 0 ; for ( int i = 0 ; i < n ; ++ i ) { A [ i ] [ j ] == 0 ? zero ++ : one ++ ; } if ( K > 0 && zero > one ) { ans += zero * pow ( 2 , m - j - 1 ) ; K -- ; } else ans += one * pow ( 2 , m - j - 1 ) ; } return ans ; } int main ( ) { int A [ n ] [ m ] = { { 0 , 0 , 1 , 1 } , { 1 , 0 , 1 , 0 } , { 1 , 1 , 0 , 0 } } ; int K = 2 ; cout << maxMatrixScore ( A , K ) ; return 0 ; }

Index/key variables: ans, i, idx, j, m, n
Accumulator variables: K, ans, it, one, stdc, zero
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSellingPossible ( int n , int a [ ] ) { int i , c25 = 0 , c50 = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 25 ) c25 ++ ; else if ( a [ i ] == 50 ) { c50 ++ ; if ( c25 == 0 ) break ; c25 -- ; } else { if ( c50 > 0 && c25 > 0 ) { c50 -- ; c25 -- ; } else if ( c25 >= 3 ) c25 -= 3 ; else break ; } } if ( i == n ) return true ; else return false ; } int main ( ) { int a [ ] = { 25 , 25 , 50 , 100 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; if ( isSellingPossible ( n , a ) ) { cout << " YES " ; } else { cout << " NO " ; } }

Index/key variables: i
Accumulator variables: c25, c50, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkIfOverlap ( string str ) { int len = str . length ( ) ; int visited [ len + 1 ] = { 0 } ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' . ' ) continue ; for ( int j = max ( 0 , i - str [ i ] ) ; j <= min ( len , i + str [ i ] ) ; j ++ ) visited [ j ] ++ ; } for ( int i = 0 ; i < len ; i ++ ) { if ( visited [ i ] > 1 ) { return true ; } } return false ; } int main ( ) { string str = " . 2 . . 2 . " ; if ( checkIfOverlap ( str ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isCorrectOrder ( int n ) { bool flag = true ; int prev = -1 ; int type = -1 ; while ( n != 0 ) { if ( type == -1 ) { if ( prev == -1 ) { prev = n % 10 ; n = n / 10 ; continue ; } if ( prev == n % 10 ) { flag = false ; break ; } if ( prev > n % 10 ) { type = 1 ; prev = n % 10 ; n = n / 10 ; continue ; } prev = n % 10 ; n = n / 10 ; } else { if ( prev == n % 10 ) { flag = false ; break ; } if ( prev < n % 10 ) { flag = false ; break ; } prev = n % 10 ; n = n / 10 ; } } return flag ; } int main ( ) { int n = 123454321 ; if ( isCorrectOrder ( n ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Accumulator variables: stdc
Boolean variables: flag
C++ program:
#include <iostream>
using namespace std ; void printCoins ( int arr [ ] , int n ) { int oddSum = 0 ; for ( int i = 0 ; i < n ; i += 2 ) oddSum += arr [ i ] ; int evenSum = 0 ; for ( int i = 1 ; i < n ; i += 2 ) evenSum += arr [ i ] ; int start = ( ( oddSum > evenSum ) ? 0 : 1 ) ; for ( int i = start ; i < n ; i += 2 ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr1 [ ] = { 8 , 15 , 3 , 7 } ; int n = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; printCoins ( arr1 , n ) ; cout << endl ; int arr2 [ ] = { 2 , 2 , 2 , 2 } ; n = sizeof ( arr2 ) / sizeof ( arr2 [ 0 ] ) ; printCoins ( arr2 , n ) ; cout << endl ; int arr3 [ ] = { 20 , 30 , 2 , 2 , 2 , 10 } ; n = sizeof ( arr3 ) / sizeof ( arr3 [ 0 ] ) ; printCoins ( arr3 , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: evenSum, i, oddSum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void finalPos ( char command [ ] , int n , int x , int y ) { int cup , cdown , cleft , cright ; int final_x , final_y ; cup = cdown = cleft = cright = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( command [ i ] == ' U ' ) cup ++ ; else if ( command [ i ] == ' D ' ) cdown ++ ; else if ( command [ i ] == ' L ' ) cleft ++ ; else if ( command [ i ] == ' R ' ) cright ++ ; } final_x = x + ( cright - cleft ) ; final_y = y + ( cdown - cup ) ; cout << " Final ▁ Position : ▁ " << " ( " << final_x << " , ▁ " << final_y << " ) " ; } int main ( ) { char command [ ] = " DDLRULL " ; int n = ( sizeof ( command ) / sizeof ( char ) ) - 1 ; int x = 3 , y = 4 ; finalPos ( command , n , x , y ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cdown, cleft, cright, cup, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define V  5
bool isValidEdge ( int u , int v , vector < bool > inMST ) { if ( u == v ) return false ; if ( inMST [ u ] == false && inMST [ v ] == false ) return false ; else if ( inMST [ u ] == true && inMST [ v ] == true ) return false ; return true ; } void primMST ( int cost [ ] [ V ] ) { vector < bool > inMST ( V , false ) ; inMST [ 0 ] = true ; int edge_count = 0 , mincost = 0 ; while ( edge_count < V - 1 ) { int min = INT_MAX , a = -1 , b = -1 ; for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { if ( cost [ i ] [ j ] < min ) { if ( isValidEdge ( i , j , inMST ) ) { min = cost [ i ] [ j ] ; a = i ; b = j ; } } } } if ( a != -1 && b != -1 ) { printf ( " Edge ▁ % d : ( % d , ▁ % d ) ▁ cost : ▁ % d ▁ STRNEWLINE " , edge_count ++ , a , b , min ) ; mincost = mincost + min ; inMST [ b ] = inMST [ a ] = true ; } } printf ( " Minimum cost = % d " , mincost ) ; } int main ( ) { int cost [ ] [ V ] = { { INT_MAX , 2 , INT_MAX , 6 , INT_MAX } , { 2 , INT_MAX , 3 , 8 , 5 } , { INT_MAX , 3 , INT_MAX , INT_MAX , 7 } , { 6 , 8 , INT_MAX , INT_MAX , 9 } , { INT_MAX , 5 , 7 , 9 , INT_MAX } , } ; primMST ( cost ) ; return 0 ; }

Index/key variables: V, a, b, i, j, u, v
Accumulator variables: edge_count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Pair { int f , s , t ; Pair ( int f , int s , int t ) { this -> f = f ; this -> s = s ; this -> t = t ; } } ; Pair * getSubArray ( int * arr , int n , int K ) { int currSum = 0 ; int prevDif = 0 ; int currDif = 0 ; Pair * result = new Pair ( -1 , -1 , abs ( K - abs ( currSum ) ) ) ; Pair * resultTmp = result ; int i = 0 ; int j = 0 ; while ( i <= j && j < n ) { currSum += arr [ j ] ; prevDif = currDif ; currDif = K - abs ( currSum ) ; if ( currDif <= 0 ) { if ( abs ( currDif ) < abs ( prevDif ) ) { resultTmp = new Pair ( i , j , currDif ) ; } else { resultTmp = new Pair ( i , j - 1 , prevDif ) ; currSum -= ( arr [ i ] + arr [ j ] ) ; i += 1 ; } } else { resultTmp = new Pair ( i , j , currDif ) ; j += 1 ; } if ( abs ( resultTmp -> t ) < abs ( result -> t ) ) { result = resultTmp ; } } return result ; } int main ( ) { int arr [ ] = { 15 , -3 , 5 , 2 , 7 , 6 , 34 , -6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 50 ; Pair * tmp = getSubArray ( arr , n , K ) ; int i = tmp -> f ; int j = tmp -> s ; int minDev = tmp -> t ; if ( i == -1 ) { cout << " The ▁ empty ▁ array ▁ shows ▁ minimum ▁ Deviation " << endl ; return 0 ; } for ( int k = i + 1 ; k < j + 1 ; k ++ ) { cout << arr [ k ] << " ▁ " ; } return 0 ; }

Index/key variables: i, j, k
Accumulator variables: currSum, i, j, k, stdc
Iterator variables: k
Class/struct names: Pair
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findLandB ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; vector < double > arr_pairs ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { arr_pairs . push_back ( arr [ i ] ) ; i ++ ; } } double length = arr_pairs [ 0 ] ; double breadth = arr_pairs [ 1 ] ; double size = arr_pairs . size ( ) ; for ( int i = 2 ; i < size ; i ++ ) { if ( ( length / breadth + breadth / length ) > ( arr_pairs [ i ] / arr_pairs [ i - 1 ] + arr_pairs [ i - 1 ] / arr_pairs [ i ] ) ) { length = arr_pairs [ i ] ; breadth = arr_pairs [ i - 1 ] ; } } cout << length << " , ▁ " << breadth << endl ; } int main ( ) { int arr [ ] = { 4 , 2 , 2 , 2 , 5 , 6 , 5 , 6 , 7 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findLandB ( 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 smallestSumSubarr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = - arr [ i ] ; int sum_here = arr [ 0 ] , max_sum = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { sum_here = max ( sum_here + arr [ i ] , arr [ i ] ) ; max_sum = max ( max_sum , sum_here ) ; } return ( -1 ) * max_sum ; } int main ( ) { int arr [ ] = { 3 , -4 , 2 , -3 , -1 , 7 , -5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Smallest ▁ sum : ▁ " << smallestSumSubarr ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef struct _pair { int first , second ; } _pair ; void printKPairs ( int a1 [ ] , int a2 [ ] , int size1 , int size2 , int k ) { if ( k > ( size2 * size1 ) ) { cout << " k ▁ pairs ▁ don ' t ▁ exist STRNEWLINE " ; return ; } _pair _one , _two ; _one . first = _one . second = _two . first = _two . second = 0 ; int cnt = 0 ; while ( cnt < k ) { if ( _one . first == _two . second && _two . first == _one . second ) { if ( a1 [ _one . first ] < a2 [ _one . second ] ) { cout << " [ " << a1 [ _one . first ] << " , ▁ " << a2 [ _one . second ] << " ] ▁ " ; _one . second = ( _one . second + 1 ) % size2 ; _one . first = ( _one . first + 1 ) % size1 ; _two . second = ( _two . second + 1 ) % size2 ; if ( _two . second == 0 ) _two . first = ( _two . first + 1 ) % size2 ; } else { cout << " [ " << a2 [ _one . second ] << " , ▁ " << a1 [ _one . first ] << " ] ▁ " ; _one . first = ( _one . first + 1 ) % size1 ; _one . second = ( _one . second + 1 ) % size2 ; _two . first = ( _two . first + 1 ) % size2 ; _two . second = ( _two . second + 1 ) % size1 ; } } else if ( a1 [ _one . first ] + a2 [ _one . second ] <= a2 [ _two . first ] + a1 [ _two . second ] ) { if ( a1 [ _one . first ] < a2 [ _one . second ] ) { cout << " [ " << a1 [ _one . first ] << " , ▁ " << a2 [ _one . second ] << " ] ▁ " ; _one . second = ( ( _one . second + 1 ) % size2 ) ; _one . first = ( _one . first + 1 ) % size1 ; } else { cout << " [ " << a2 [ _one . second ] << " , ▁ " << a1 [ _one . first ] << " ] ▁ " ; _one . first = ( ( _one . first + 1 ) % size1 ) ; _one . second = ( _one . second + 1 ) % size2 ; } } else if ( a1 [ _one . first ] + a2 [ _one . second ] > a2 [ _two . first ] + a1 [ _two . second ] ) { if ( a2 [ _two . first ] < a1 [ _two . second ] ) { cout << " [ " << a2 [ _two . first ] << " , ▁ " << a1 [ _two . second ] << " ] ▁ " ; _two . first = ( ( _two . first + 1 ) % size2 ) ; _two . second = ( _two . second + 1 ) % size1 ; } else { cout << " [ " << a1 [ _two . second ] << " , ▁ " << a2 [ _two . first ] << " ] ▁ " ; _two . second = ( ( _two . second + 1 ) % size1 ) ; _two . first = ( _two . first + 1 ) % size1 ; } } cnt ++ ; } } int main ( ) { int a1 [ ] = { 2 , 3 , 4 } ; int a2 [ ] = { 1 , 6 , 5 , 8 } ; int size1 = sizeof ( a1 ) / sizeof ( a1 [ 0 ] ) ; int size2 = sizeof ( a2 ) / sizeof ( a2 [ 0 ] ) ; int k = 4 ; printKPairs ( a1 , a2 , size1 , size2 , k ) ; return 0 ; }

Accumulator variables: cnt, stdc
Class/struct names: _pair
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printLargest ( int a [ ] , int n ) { int max = -1 ; int ind = -1 ; for ( int i = 0 ; i < n ; i ++ ) { int num = a [ i ] ; while ( num ) { int r = num % 10 ; num = num / 10 ; if ( num == 0 ) { if ( max < r ) { max = r ; ind = i ; } } } } for ( int i = ind ; i < n ; i ++ ) cout << a [ i ] ; for ( int i = 0 ; i < ind ; i ++ ) cout << a [ i ] ; } int main ( ) { int a [ ] = { 54 , 546 , 548 , 60 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; printLargest ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void construct ( int n , pair < double , double > ans_pair ) { if ( ans_pair . first == -1 ) { cout << " Not ▁ possible " ; return ; } double a1 = ans_pair . first ; double a2 = ans_pair . second ; double r = a2 / a1 ; cout << " The ▁ resultant ▁ sequence ▁ is : STRNEWLINE " ; for ( int i = 1 ; i <= n ; i ++ ) { double ai = a1 * pow ( r , i - 1 ) ; cout << ai << " ▁ " ; } } void findMinimumOperations ( double * a , int n ) { int ans = INT_MAX ; int c [ ] = { -1 , 0 , 1 } ; int possibilities = 3 ; int pos1 = -1 , pos2 = -1 ; for ( int i = 0 ; i < possibilities ; i ++ ) { for ( int j = 0 ; j < possibilities ; j ++ ) { double a1 = a [ 1 ] + c [ i ] ; double a2 = a [ 2 ] + c [ j ] ; int temp = abs ( a1 - a [ 1 ] ) + abs ( a2 - a [ 2 ] ) ; if ( a1 == 0 a2 == 0 ) continue ; double r = a2 / a1 ; for ( int pos = 3 ; pos <= n ; pos ++ ) { double ai = a1 * pow ( r , pos - 1 ) ; if ( a [ pos ] == ai ) { continue ; } else if ( a [ pos ] + 1 == ai a [ pos ] - 1 == ai ) { temp ++ ; } else { temp = INT_MAX ; break ; } } if ( temp < ans ) { ans = temp ; pos1 = a1 ; pos2 = a2 ; } } } if ( ans == -1 ) { cout << " - 1" ; return ; } cout << " Minimum ▁ Number ▁ of ▁ Operations ▁ are ▁ " << ans << " STRNEWLINE " ; pair < double , double > ans_pair = { pos1 , pos2 } ; construct ( n , ans_pair ) ; } int main ( ) { double a [ ] = { 0 , 7 , 20 , 49 , 125 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; findMinimumOperations ( a , n - 1 ) ; return 0 ; }

Index/key variables: i, j, pos
Accumulator variables: i, j, pos, stdc, temp
Iterator variables: i, j, pos
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findOrderMRT ( int L [ ] , int n ) { sort ( L , L + n ) ; cout << " Optimal ▁ order ▁ in ▁ which ▁ programs ▁ are ▁ to ▁ be " " stored ▁ is : ▁ " ; for ( int i = 0 ; i < n ; i ++ ) cout << L [ i ] << " ▁ " ; cout << endl ; double MRT = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j <= i ; j ++ ) sum += L [ j ] ; MRT += sum ; } MRT /= n ; cout << " Minimum ▁ Retrieval ▁ Time ▁ of ▁ this " " ▁ order ▁ is ▁ " << MRT ; } int main ( ) { int L [ ] = { 2 , 5 , 4 } ; int n = sizeof ( L ) / sizeof ( L [ 0 ] ) ; findOrderMRT ( L , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: MRT, i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinOperation ( int a [ ] , int n , int k ) { int result = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( a [ i ] != 1 && a [ i ] > k ) { result = result + min ( a [ i ] % k , k - a [ i ] % k ) ; } else { result = result + k - a [ i ] ; } } return result ; } int main ( ) { int arr [ ] = { 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 5 ; cout << MinOperation ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxProductSubset ( int a [ ] , int n ) { if ( n == 1 ) return a [ 0 ] ; int max_neg = INT_MIN ; int count_neg = 0 , count_zero = 0 ; int prod = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { count_zero ++ ; continue ; } if ( a [ i ] < 0 ) { count_neg ++ ; max_neg = max ( max_neg , a [ i ] ) ; } prod = prod * a [ i ] ; } if ( count_zero == n ) return 0 ; if ( count_neg & 1 ) { if ( count_neg == 1 && count_zero > 0 && count_zero + count_neg == n ) return 0 ; prod = prod / max_neg ; } return prod ; } int main ( ) { int a [ ] = { -1 , -1 , -2 , 4 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << maxProductSubset ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count_neg, count_zero, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find ( vector < int > arr , int pos , int m , vector < bool > isRunning ) { vector < int > d ( m + 1 , 0 ) ; for ( int i = m ; i > pos ; i -- ) { if ( isRunning [ arr [ i ] ] ) d [ arr [ i ] ] = i ; } int maxipos = 0 ; for ( int ele : d ) maxipos = max ( ele , maxipos ) ; return maxipos ; } int mincost ( int n , int m , vector < int > arr ) { vector < vector < int > > freqarr ( m ) ; vector < int > newvec ( m + 1 , 0 ) ; freqarr [ m - 1 ] = newvec ; for ( int i = m - 2 ; i >= 0 ; i -- ) { vector < int > nv ; nv = freqarr [ i + 1 ] ; nv [ arr [ i + 1 ] ] += 1 ; freqarr [ i ] = nv ; } vector < bool > isRunning ( m + 1 , false ) ; int cost = 0 ; int truecount = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int ele = arr [ i ] ; if ( isRunning [ ele ] == true ) continue ; else { if ( truecount < n ) { cost += 1 ; truecount += 1 ; isRunning [ ele ] = true ; } else { int mini = 100000 ; int miniind = 0 ; for ( int j = 1 ; j <= m ; j ++ ) { if ( isRunning [ j ] && mini > freqarr [ i ] [ j ] ) { mini = freqarr [ i ] [ j ] ; miniind = j ; } } if ( mini == 0 ) { isRunning [ miniind ] = false ; isRunning [ ele ] = true ; cost += 1 ; } else { int farpos = find ( arr , i , m , isRunning ) ; isRunning [ arr [ farpos ] ] = false ; isRunning [ ele ] = true ; cost += 1 ; } } } } return cost ; } int main ( ) { int n1 = 3 ; int m1 = 6 ; vector < int > arr1 { 1 , 2 , 1 , 3 , 4 , 1 } ; cout << mincost ( n1 , m1 , arr1 ) << endl ; int n2 = 2 ; int m2 = 6 ; vector < int > arr2 { 1 , 2 , 1 , 3 , 2 , 1 } ; cout << mincost ( n2 , m2 , arr2 ) << endl ; int n3 = 3 ; int m3 = 31 ; vector < int > arr3 { 7 , 11 , 17 , 10 , 7 , 10 , 2 , 9 , 2 , 18 , 8 , 10 , 20 , 10 , 3 , 20 , 17 , 17 , 17 , 1 , 15 , 10 , 8 , 3 , 3 , 18 , 13 , 2 , 10 , 10 , 11 } ; cout << mincost ( n3 , m3 , arr3 ) << endl ; return 0 ; }

Index/key variables: ele, farpos, i, j, miniind
Accumulator variables: cost, i, j, stdc, truecount
Iterator variables: ele, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void calcFiboTerms ( vector < int > & fiboTerms , int K ) { int i = 3 , nextTerm ; fiboTerms . push_back ( 0 ) ; fiboTerms . push_back ( 1 ) ; fiboTerms . push_back ( 1 ) ; while ( 1 ) { nextTerm = fiboTerms [ i - 1 ] + fiboTerms [ i - 2 ] ; if ( nextTerm > K ) return ; fiboTerms . push_back ( nextTerm ) ; i ++ ; } } int findMinTerms ( int K ) { vector < int > fiboTerms ; calcFiboTerms ( fiboTerms , K ) ; int count = 0 , j = fiboTerms . size ( ) - 1 ; while ( K > 0 ) { count += ( K / fiboTerms [ j ] ) ; K %= ( fiboTerms [ j ] ) ; j -- ; } return count ; } int main ( ) { int K = 17 ; cout << findMinTerms ( K ) ; return 0 ; }

Index/key variables: j
Accumulator variables: count, i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void digitsNum ( int N ) { if ( N == 0 ) cout << "0 STRNEWLINE " ; if ( N % 9 != 0 ) cout << ( N % 9 ) ; for ( int i = 1 ; i <= ( N / 9 ) ; ++ i ) cout << "9" ; for ( int i = 1 ; i <= N ; ++ i ) cout << "0" ; cout << " STRNEWLINE " ; } int main ( ) { int N = 5 ; cout << " The ▁ number ▁ is ▁ : ▁ " ; digitsNum ( N ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printVector ( vector < int > v ) { cout << v . size ( ) << endl ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) cout << v [ i ] << " ▁ " ; cout << endl ; } void findTwoGroup ( int n ) { int sum = n * ( n + 1 ) / 2 ; int group1Sum = sum / 2 ; vector < int > group1 , group2 ; for ( int i = n ; i > 0 ; i -- ) { if ( group1Sum - i >= 0 ) { group1 . push_back ( i ) ; group1Sum -= i ; } else { group2 . push_back ( i ) ; } } printVector ( group1 ) ; printVector ( group2 ) ; } int main ( ) { int n = 5 ; findTwoGroup ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: group1Sum, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < pair < long long , int > > v ; void solve ( int n , int d , int a , int b , int arr [ ] [ 2 ] ) { for ( int i = 0 ; i < n ; i ++ ) { int m = arr [ i ] [ 0 ] , t = arr [ i ] [ 1 ] ; v . push_back ( make_pair ( ( a * m + b * t ) , i + 1 ) ) ; } sort ( v . begin ( ) , v . end ( ) ) ; vector < int > ans ; for ( int i = 0 ; i < n ; i ++ ) { if ( v [ i ] . first <= d ) { ans . push_back ( v [ i ] . second ) ; d -= v [ i ] . first ; } } cout << ans . size ( ) << endl ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) cout << ans [ i ] << " ▁ " ; } int main ( ) { int n = 5 ; long d = 5 ; int a = 1 , b = 1 ; int arr [ ] [ 2 ] = { { 2 , 0 } , { 3 , 2 } , { 4 , 4 } , { 10 , 0 } , { 0 , 1 } } ; solve ( n , d , a , b , arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: d, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxDifference ( int arr [ ] , int N , int k ) { int M , S = 0 , S1 = 0 , max_difference = 0 ; for ( int i = 0 ; i < N ; i ++ ) S += arr [ i ] ; sort ( arr , arr + N , greater < int > ( ) ) ; M = max ( k , N - k ) ; for ( int i = 0 ; i < M ; i ++ ) S1 += arr [ i ] ; max_difference = S1 - ( S - S1 ) ; return max_difference ; } int main ( ) { int arr [ ] = { 8 , 4 , 5 , 2 , 10 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 ; cout << maxDifference ( arr , N , k ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: S, S1, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minproduct ( int a [ ] , int b [ ] , int n , int k ) { int diff = 0 , res = 0 ; int temp ; for ( int i = 0 ; i < n ; i ++ ) { int pro = a [ i ] * b [ i ] ; res = res + pro ; if ( pro < 0 && b [ i ] < 0 ) temp = ( a [ i ] + 2 * k ) * b [ i ] ; else if ( pro < 0 && a [ i ] < 0 ) temp = ( a [ i ] - 2 * k ) * b [ i ] ; else if ( pro > 0 && a [ i ] < 0 ) temp = ( a [ i ] + 2 * k ) * b [ i ] ; else if ( pro > 0 && a [ i ] > 0 ) temp = ( a [ i ] - 2 * k ) * b [ i ] ; int d = abs ( pro - temp ) ; if ( d > diff ) diff = d ; } return res - diff ; } int main ( ) { int a [ ] = { 2 , 3 , 4 , 5 , 4 } ; int b [ ] = { 3 , 4 , 2 , 3 , 2 } ; int n = 5 , k = 3 ; cout << minproduct ( a , b , n , k ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int n ) { if ( n < 4 ) return -1 ; int rem = n % 4 ; if ( rem == 0 ) return n / 4 ; if ( rem == 1 ) { if ( n < 9 ) return -1 ; return ( n - 9 ) / 4 + 1 ; } if ( rem == 2 ) return ( n - 6 ) / 4 + 1 ; if ( rem == 3 ) { if ( n < 15 ) return -1 ; return ( n - 15 ) / 4 + 2 ; } } int main ( ) { int n = 90 ; cout << count ( n ) << endl ; n = 143 ; cout << count ( n ) << endl ; return 0 ; }

Accumulator variables: stdc