dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 25 ; int getMinSum ( int arr [ ] , int n ) { int bits_count [ MAX ] , max_bit = 0 , sum = 0 , ans = 0 ; memset ( bits_count , 0 , sizeof ( bits_count ) ) ; for ( int d = 0 ; d < n ; d ++ ) { int e = arr [ d ] , f = 0 ; while ( e > 0 ) { int rem = e % 2 ; e = e / 2 ; if ( rem == 1 ) { bits_count [ f ] += rem ; } f ++ ; } max_bit = max ( max_bit , f ) ; } for ( int d = 0 ; d < max_bit ; d ++ ) { int temp = pow ( 2 , d ) ; if ( bits_count [ d ] > n / 2 ) ans = ans + temp ; } for ( int d = 0 ; d < n ; d ++ ) { arr [ d ] = arr [ d ] ^ ans ; sum = sum + arr [ d ] ; } return sum ; } int main ( ) { int arr [ ] = { 3 , 5 , 7 , 11 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << getMinSum ( arr , n ) ; return 0 ; }

Index/key variables: MAX, d, f
Accumulator variables: d, f, stdc
Iterator variables: d
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxCoins ( int X , int Y ) { if ( X < Y ) swap ( X , Y ) ; int coins = X ; X -- ; coins += max ( X , Y ) ; return coins ; } int main ( ) { int X = 7 , Y = 5 ; cout << maxCoins ( X , Y ) ; return 0 ; }

Accumulator variables: X, coins, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinimumX ( int a [ ] , int n ) { set < int > st ; for ( int i = 0 ; i < n ; i ++ ) st . insert ( a [ i ] ) ; if ( st . size ( ) == 1 ) return 0 ; if ( st . size ( ) == 2 ) { int el1 = * st . begin ( ) ; int el2 = * st . rbegin ( ) ; if ( ( el2 - el1 ) % 2 == 0 ) return ( el2 - el1 ) / 2 ; else return ( el2 - el1 ) ; } if ( st . size ( ) == 3 ) { auto it = st . begin ( ) ; int el1 = * it ; it ++ ; int el2 = * it ; it ++ ; int el3 = * it ; if ( ( el2 - el1 ) == ( el3 - el2 ) ) return el2 - el1 ; else return -1 ; } return -1 ; } int main ( ) { int a [ ] = { 1 , 4 , 4 , 7 , 4 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findMinimumX ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, it, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findElementsCrossed ( int arr [ ] , int a , int b , int n ) { int aa = a ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a == 0 && b == 0 ) break ; else if ( a == 0 ) { if ( arr [ i ] == 1 ) { b -= 1 ; a = min ( aa , a + 1 ) ; } else b -= 1 ; } else if ( b == 0 ) a -- ; else if ( arr [ i ] == 1 && a < aa ) { b -= 1 ; a = min ( aa , a + 1 ) ; } else a -- ; ans ++ ; } return ans ; } int main ( ) { int arr [ ] = { 1 , 0 , 0 , 1 , 0 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int a = 1 ; int b = 2 ; cout << findElementsCrossed ( arr , a , b , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, ans, b, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } void pushBinaryToBorder ( int arr [ ] , int n ) { int count1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != 1 ) arr [ count1 ++ ] = arr [ i ] ; while ( count1 < n ) arr [ count1 ++ ] = 1 ; int lastNonOne = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == 1 ) continue ; if ( ! lastNonOne ) { lastNonOne = i ; } if ( arr [ i ] != 0 ) arr [ lastNonOne -- ] = arr [ i ] ; } while ( lastNonOne >= 0 ) arr [ lastNonOne -- ] = 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 0 , 0 , 0 , 3 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; pushBinaryToBorder ( arr , n ) ; printArr ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count1, i, lastNonOne
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char ch ) { switch ( ch ) { case ' a ' : case ' e ' : case ' i ' : case ' o ' : case ' u ' : return true ; default : return false ; } } int vowelPairs ( string s , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( isVowel ( s [ i ] ) && isVowel ( s [ i + 1 ] ) ) cnt ++ ; } return cnt ; } int main ( ) { string s = " abaebio " ; int n = s . length ( ) ; cout << vowelPairs ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } int solve ( int * health , int n ) { int currentgcd = gcd ( health [ 0 ] , health [ 1 ] ) ; for ( int i = 2 ; i < n ; ++ i ) { currentgcd = gcd ( currentgcd , health [ i ] ) ; } return currentgcd ; } int main ( ) { int health [ ] = { 4 , 6 , 8 , 12 } ; int n = sizeof ( health ) / sizeof ( health [ 0 ] ) ; cout << solve ( health , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Find_Sequence ( int arr [ ] , int n ) { vector < int > inc_arr , dec_arr ; int flag = 0 ; long inc = -1 , dec = 1e7 ; for ( int i = 0 ; i < n ; i ++ ) { if ( inc < arr [ i ] && arr [ i ] < dec ) { if ( arr [ i ] < arr [ i + 1 ] ) { inc = arr [ i ] ; inc_arr . emplace_back ( arr [ i ] ) ; } else { dec = arr [ i ] ; dec_arr . emplace_back ( arr [ i ] ) ; } } else if ( inc < arr [ i ] ) { inc = arr [ i ] ; inc_arr . emplace_back ( arr [ i ] ) ; } else if ( dec > arr [ i ] ) { dec = arr [ i ] ; dec_arr . emplace_back ( arr [ i ] ) ; } else { cout << -1 << endl ; flag = 1 ; break ; } } if ( ! flag ) { for ( auto i = inc_arr . begin ( ) ; i != inc_arr . end ( ) ; i ++ ) cout << * i << " ▁ " ; cout << endl ; for ( auto i = dec_arr . begin ( ) ; i != dec_arr . end ( ) ; i ++ ) cout << * i << " ▁ " ; cout << endl ; } } int main ( ) { int arr [ ] = { 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; Find_Sequence ( arr , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int reverse ( int n ) { int rev = 0 ; while ( n != 0 ) { rev = ( rev * 10 ) + ( n % 10 ) ; n /= 10 ; } return rev ; } void getSum ( int n ) { n = reverse ( n ) ; int sumOdd = 0 , sumEven = 0 , c = 1 ; while ( n != 0 ) { if ( c % 2 == 0 ) sumEven += n % 10 ; else sumOdd += n % 10 ; n /= 10 ; c ++ ; } cout << " Sum ▁ odd ▁ = ▁ " << sumOdd << " STRNEWLINE " ; cout << " Sum ▁ even ▁ = ▁ " << sumEven ; } int main ( ) { int n = 457892 ; getSum ( n ) ; return 0 ; }

Accumulator variables: c, n, stdc, sumEven, sumOdd
C++ program:
#include <bits/stdc++.h>
using namespace std ; void getSum ( int n ) { bool isOdd = ( n % 2 == 1 ) ? true : false ; int sumOdd = 0 , sumEven = 0 ; while ( n != 0 ) { if ( isOdd ) sumOdd += n % 10 ; else sumEven += n % 10 ; isOdd = ! isOdd ; n /= 10 ; } cout << " Sum ▁ odd ▁ = ▁ " << sumOdd << " STRNEWLINE " ; cout << " Sum ▁ even ▁ = ▁ " << sumEven ; } int main ( ) { int n = 457892 ; getSum ( n ) ; return 0 ; }

Accumulator variables: n, stdc, sumEven, sumOdd
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bankNotes ( int A , int B , int S , int N ) { int numerator = S - ( B * N ) ; int denominator = A - B ; if ( numerator % denominator == 0 ) return ( numerator / denominator ) ; return -1 ; } int main ( ) { int A = 1 , B = 2 , S = 7 , N = 5 ; cout << bankNotes ( A , B , S , N ) << endl ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void twoParts ( string str ) { int flag = 0 ; string a = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == '4' ) { str [ i ] = '3' ; a += '1' ; flag = 1 ; } else if ( flag ) a += '0' ; } cout << str << " ▁ " << a ; } int main ( ) { string str = "9441" ; twoParts ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubstring ( string s ) { int cnt = 1 ; int maxi = 1 ; int n = s . length ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] != s [ i - 1 ] ) cnt ++ ; else { maxi = max ( cnt , maxi ) ; cnt = 1 ; } } maxi = max ( cnt , maxi ) ; return maxi ; } int main ( ) { string s = " ccccdeededff " ; cout << longestSubstring ( 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 Minimum_Operations ( int a [ ] , int n ) { int np [ n + 1 ] ; np [ n ] = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { np [ i ] = np [ i + 1 ] ; if ( a [ i ] <= 0 ) np [ i ] ++ ; } int pos = 0 ; int ans = n ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] >= 0 ) pos ++ ; ans = min ( ans , pos + np [ i + 1 ] ) ; } return ans ; } int main ( ) { int a [ ] = { -1 , 0 , 1 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << Minimum_Operations ( a , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, pos, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int findSumofEle ( int arr1 [ ] , int m , int arr2 [ ] , int n , int k ) { float arraySum = 0 ; for ( int i = 0 ; i < n ; i ++ ) arraySum += arr2 [ i ] ; float mean = arraySum / n ; int sumOfElements = 0 ; float difference ; for ( int i = 0 ; i < m ; i ++ ) { difference = arr1 [ i ] - mean ; if ( ( difference < 0 ) && ( k > ( -1 ) * difference ) ) { sumOfElements += arr1 [ i ] ; } if ( ( difference >= 0 ) && ( k > difference ) ) { sumOfElements += arr1 [ i ] ; } } return sumOfElements ; } int main ( ) { int arr1 [ ] = { 1 , 2 , 3 , 4 , 7 , 9 } ; int arr2 [ ] = { 0 , 1 , 2 , 1 , 1 , 4 } ; int k = 2 ; int m , n ; m = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; n = sizeof ( arr2 ) / sizeof ( arr2 [ 0 ] ) ; cout << findSumofEle ( arr1 , m , arr2 , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: arraySum, i, sumOfElements
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findIntegers ( int n , int x , int y ) { vector < int > ans ; for ( int i = 0 ; i < n - 1 ; i ++ ) ans . push_back ( 1 ) ; if ( y - ( n - 1 ) <= 0 ) { cout << " - 1" ; return ; } ans . push_back ( y - ( n - 1 ) ) ; int store = 0 ; for ( int i = 0 ; i < n ; i ++ ) store += ans [ i ] * ans [ i ] ; if ( store < x ) { cout << " - 1" ; return ; } for ( int i = 0 ; i < n ; i ++ ) cout << ans [ i ] << " ▁ " ; } int main ( ) { int n = 3 , x = 254 , y = 18 ; findIntegers ( n , x , y ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, store
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Minsteps ( int n , int m ) { int ans = 0 ; while ( m > n ) { if ( m & 1 ) { m ++ ; ans ++ ; } m /= 2 ; ans ++ ; } return ans + n - m ; } int main ( ) { int n = 4 , m = 6 ; cout << Minsteps ( n , m ) ; return 0 ; }

Accumulator variables: ans, m, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getsum ( int x ) { return ( x * ( x + 1 ) ) / 2 ; } int countJumps ( int n ) { n = abs ( n ) ; int ans = 0 ; while ( getsum ( ans ) < n or ( getsum ( ans ) - n ) & 1 ) ans ++ ; return ans ; } int main ( ) { int n = 9 ; cout << countJumps ( n ) ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxCandies ( int arr [ ] , int n ) { int prevBought = arr [ n - 1 ] ; int candies = prevBought ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int x = min ( prevBought - 1 , arr [ i ] ) ; if ( x >= 0 ) { candies += x ; prevBought = x ; } } return candies ; } int main ( ) { int arr [ ] = { 1 , 2 , 1 , 3 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxCandies ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: candies, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void printArray ( int N , int arr [ ] ) { for ( int i = 0 ; i < N ; i ++ ) cout << arr [ i ] << " ▁ " ; cout << endl ; } void replacedArray ( int N , int arr [ ] ) { int pos_sum , neg_sum , i , j , diff ; for ( i = 0 ; i < N ; i ++ ) { pos_sum = 0 ; neg_sum = 0 ; for ( j = i + 1 ; j < N ; j ++ ) { if ( arr [ j ] > 0 ) pos_sum += arr [ j ] ; else neg_sum += arr [ j ] ; } diff = abs ( pos_sum ) - abs ( neg_sum ) ; arr [ i ] = abs ( diff ) ; } } int main ( ) { int N = 5 ; int arr [ ] = { 1 , -1 , 2 , 3 , -2 } ; replacedArray ( N , arr ) ; printArray ( N , arr ) ; N = 6 ; int arr1 [ ] = { -3 , -4 , -2 , 5 , 1 , -2 } ; replacedArray ( N , arr1 ) ; printArray ( N , arr1 ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, neg_sum, pos_sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string s ) { for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( s [ i ] != s [ s . length ( ) - i - 1 ] ) { return false ; } } return true ; } bool ans ( string s ) { string s2 = s ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { s2 = s2 . back ( ) + s2 ; s2 . pop_back ( ) ; if ( s != s2 && isPalindrome ( s2 ) ) { return true ; } } return false ; } int solve ( string s ) { if ( s . length ( ) <= 3 ) { return -1 ; } int cnt [ 25 ] = { } ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } if ( * max_element ( cnt , cnt + 25 ) >= ( s . length ( ) - 1 ) ) { return -1 ; } else { return ( ans ( s ) ? 1 : 2 ) ; } } int main ( ) { string s = " nolon " ; cout << solve ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solveEven ( string s ) { if ( s . length ( ) % 2 == 1 ) return 2 ; string ls = s . substr ( 0 , s . length ( ) / 2 ) ; string rs = s . substr ( s . length ( ) / 2 , s . length ( ) ) ; if ( ls != rs ) return 1 ; return solveEven ( ls ) ; } int solveOdd ( string s ) { return 2 ; } int solve ( string s ) { if ( s . length ( ) <= 3 ) { return -1 ; } int cnt [ 25 ] = { } ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { cnt [ s [ i ] - ' a ' ] ++ ; } if ( * max_element ( cnt , cnt + 25 ) >= s . length ( ) - 1 ) { return -1 ; } if ( s . length ( ) % 2 == 0 ) return solveEven ( s ) ; if ( s . length ( ) % 2 == 1 ) return solveOdd ( s ) ; } int main ( ) { string s = " nolon " ; cout << solve ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minChanges ( string str , int n ) { int count = 0 , zeros = 0 , ones = 0 ; if ( str [ 0 ] != '1' ) { count ++ ; ones ++ ; } for ( int i = 1 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) zeros ++ ; else ones ++ ; if ( zeros > ones ) { zeros -- ; ones ++ ; count ++ ; } } return count ; } int main ( ) { string str = "0000" ; int n = str . length ( ) ; cout << minChanges ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, ones, stdc, zeros
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define int  long long
using namespace std ; int steps ( int cur , int x , int n ) { if ( x == 0 ) return INT_MAX ; if ( x > 0 ) return abs ( ( n - cur ) / x ) ; else return abs ( ( cur - 1 ) / x ) ; } int countSteps ( int curx , int cury , int n , int m , vector < pair < int , int > > moves ) { int count = 0 ; int k = moves . size ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int x = moves [ i ] . first ; int y = moves [ i ] . second ; int stepct = min ( steps ( curx , x , n ) , steps ( cury , y , m ) ) ; count += stepct ; curx += stepct * x ; cury += stepct * y ; } return count ; } main ( ) { int n = 4 , m = 5 , x = 1 , y = 1 ; vector < pair < int , int > > moves = { { 1 , 1 } , { 1 , 1 } , { 0 , -2 } } ; int k = moves . size ( ) ; cout << countSteps ( x , y , n , m , moves ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, curx, cury, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumRemoval ( int n , int a [ ] ) { map < int , int > c ; for ( int i = 0 ; i < n ; i ++ ) c [ a [ i ] ] ++ ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { bool ok = false ; for ( int j = 0 ; j < 31 ; j ++ ) { int x = ( 1 << j ) - a [ i ] ; if ( c . count ( x ) && ( c [ x ] > 1 || ( c [ x ] == 1 && x != a [ i ] ) ) ) { ok = true ; break ; } } if ( ! ok ) ans ++ ; } return ans ; } int main ( ) { int a [ ] = { 4 , 7 , 1 , 5 , 4 , 9 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << minimumRemoval ( n , a ) ; return 0 ; }

Index/key variables: i, x
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
Boolean variables: ok
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_elimination ( int n , int arr [ ] ) { int count = 0 ; int prev_val = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { int curr_val = arr [ i ] ; if ( curr_val % 2 == prev_val % 2 ) count ++ ; prev_val = curr_val ; } return count ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 7 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << min_elimination ( n , arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getCount ( int N ) { if ( N % 2 == 1 ) return 0 ; string result = "9" ; for ( int i = 1 ; i <= N / 2 - 1 ; i ++ ) result += "0" ; return result ; } int main ( ) { int N = 4 ; cout << getCount ( N ) ; return 0 ; }

Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canFormTeam ( int n , int m ) { if ( n >= 1 && m >= 2 ) return true ; if ( m >= 1 && n >= 2 ) return true ; return false ; } int maxTeams ( int n , int m ) { int count = 0 ; while ( canFormTeam ( n , m ) ) { if ( n > m ) { n -= 2 ; m -= 1 ; } else { m -= 2 ; n -= 1 ; } count ++ ; } return count ; } int main ( ) { int n = 4 , m = 5 ; cout << maxTeams ( n , m ) ; return 0 ; }

Accumulator variables: count, m, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int max ( long long a , long long b ) { if ( a > b ) return a ; else return b ; } long long int smallestSide ( long long int a [ ] ) { sort ( a , a + 4 ) ; long long side1 , side2 , side3 , side4 , side11 , side12 , sideOfSquare ; side1 = a [ 0 ] + a [ 3 ] ; side2 = a [ 1 ] + a [ 2 ] ; side3 = a [ 0 ] + a [ 1 ] ; side4 = a [ 2 ] + a [ 3 ] ; side11 = max ( side1 , side2 ) ; side12 = max ( side3 , side4 ) ; sideOfSquare = max ( side11 , side12 ) ; return sideOfSquare ; } int main ( ) { long long int side [ 4 ] ; cout << " Test ▁ Case ▁ 1 STRNEWLINE " ; side [ 0 ] = 2 ; side [ 1 ] = 2 ; side [ 2 ] = 2 ; side [ 3 ] = 2 ; cout << smallestSide ( side ) << endl ; cout << " Test Case 2 " side [ 0 ] = 100000000000000 ; side [ 1 ] = 123450000000000 ; side [ 2 ] = 987650000000000 ; side [ 3 ] = 987654321000000 ; cout << smallestSide ( side ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_rectangle ( int area ) { int l , b ; int M = sqrt ( area ) , ans ; for ( int i = M ; i >= 1 ; i -- ) { if ( area % i == 0 ) { l = ( area / i ) ; b = i ; break ; } } cout << " l ▁ = ▁ " << l << " , ▁ b ▁ = ▁ " << b << endl ; } int main ( ) { int area = 99 ; find_rectangle ( area ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_rectangle ( int area ) { for ( int i = ceil ( sqrt ( area ) ) ; i <= area ; i ++ ) { if ( area / i * i == area ) { printf ( " % d ▁ % d " , i , area / i ) ; return ; } } } int main ( ) { int area = 99 ; find_rectangle ( area ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sizeSubSet ( int a [ ] , int k , int n ) { sort ( a , a + n ) ; unordered_set < int > s ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % k != 0 || s . count ( a [ i ] / k ) == 0 ) s . insert ( a [ i ] ) ; } return s . size ( ) ; } int main ( ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int k = 2 ; cout << sizeSubSet ( a , k , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumSets ( string s , int y ) { int cnt = 0 ; int num = 0 ; int l = s . length ( ) ; int f = 0 ; for ( int i = 0 ; i < l ; i ++ ) { num = num * 10 + ( s [ i ] - '0' ) ; if ( num <= y ) f = 1 ; { if ( f ) cnt += 1 ; num = s [ i ] - '0' ; f = 0 ; if ( num <= y ) f = 1 ; else num = 0 ; } } if ( f ) cnt += 1 ; return cnt ; } int main ( ) { string s = "1234" ; int y = 30 ; cout << minimumSets ( s , y ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArr ( int b [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << b [ i ] << " ▁ " ; } void ModifiedArray ( int a [ ] , int n ) { int l = 0 , r = INT_MAX ; int b [ n ] = { 0 } ; for ( int i = 0 ; i < n / 2 ; i ++ ) { b [ i ] = max ( l , a [ i ] - r ) ; b [ n - i - 1 ] = a [ i ] - b [ i ] ; l = b [ i ] ; r = b [ n - i - 1 ] ; } printArr ( b , n ) ; } int main ( ) { int a [ ] = { 5 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; ModifiedArray ( a , 2 * n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; pair < int , int > numberOfLines ( string S , int * widths ) { if ( S . empty ( ) ) return { 0 , 0 } ; int lines = 1 , width = 0 ; for ( auto character : S ) { int w = widths [ character - ' a ' ] ; width += w ; if ( width >= 10 ) { lines ++ ; width = w ; } } return { lines , width } ; } int main ( ) { string S = " bbbcccdddaa " ; int widths [ ] = { 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ; pair < int , int > ans = numberOfLines ( S , widths ) ; cout << ans . first << " ▁ " << ans . second << endl ; return 0 ; }

Accumulator variables: lines, stdc, width
Iterator variables: character
C++ program:
#include <bits/stdc++.h>
using namespace std ; string canReorder ( int A [ ] , int n ) { map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ A [ i ] ] ++ ; sort ( A , A + n ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( m [ A [ i ] ] == 0 ) continue ; if ( m [ 2 * A [ i ] ] ) { count += 2 ; m [ A [ i ] ] -= 1 ; m [ 2 * A [ i ] ] -= 1 ; } } if ( count == n ) return " true " ; else return " false " ; } int main ( ) { int A [ ] = { 4 , -2 , 2 , -4 } ; int n = sizeof ( A ) / sizeof ( int ) ; cout << ( canReorder ( A , n ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSubArraySum ( int a [ ] , int size ) { int max_so_far = INT_MIN , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } int maxSum ( int a [ ] , int n ) { int S = 0 ; int S1 = maxSubArraySum ( a , n ) ; for ( int i = 0 ; i < n ; i ++ ) S += a [ i ] ; return ( 2 * S1 - S ) ; } int main ( ) { int a [ ] = { -35 , 32 , -24 , 0 , 27 , -10 , 0 , -19 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << maxSum ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: S, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimizeDiff ( int * arr , int n , int k ) { int max = * ( max_element ( arr , arr + n ) ) ; int min = * ( min_element ( arr , arr + n ) ) ; if ( ( max - min ) <= k ) { return ( max - min ) ; } int avg = ( max + min ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > avg ) arr [ i ] -= k ; else arr [ i ] += k ; } max = * ( max_element ( arr , arr + n ) ) ; min = * ( min_element ( arr , arr + n ) ) ; return ( max - min ) ; } int main ( ) { int arr [ ] = { 3 , 16 , 12 , 9 , 20 } ; int n = 5 ; int k = 3 ; cout << " Max ▁ height ▁ difference ▁ = ▁ " << minimizeDiff ( arr , n , k ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i