dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getArea ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { return abs ( ( x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ) / 2 ) ; } int isInside ( vector < vector < int > > triangle , vector < int > point ) { vector < int > A = triangle [ 0 ] ; vector < int > B = triangle [ 1 ] ; vector < int > C = triangle [ 2 ] ; int x = point [ 0 ] ; int y = point [ 1 ] ; int ABC = getArea ( A [ 0 ] , A [ 1 ] , B [ 0 ] , B [ 1 ] , C [ 0 ] , C [ 1 ] ) ; int BPC = getArea ( x , y , B [ 0 ] , B [ 1 ] , C [ 0 ] , C [ 1 ] ) ; int APC = getArea ( A [ 0 ] , A [ 1 ] , x , y , C [ 0 ] , C [ 1 ] ) ; int APB = getArea ( A [ 0 ] , A [ 1 ] , B [ 0 ] , B [ 1 ] , x , y ) ; return ABC == ( APC + APB + BPC ) ; } void countPoints ( vector < vector < int > > rectangle , vector < vector < int > > triangle , vector < vector < int > > points ) { int n = rectangle . size ( ) ; vector < vector < int > > triangle1 ; for ( int i = 1 ; i < n ; i ++ ) triangle1 . push_back ( rectangle [ i ] ) ; vector < vector < int > > triangle2 ; for ( int i = 0 ; i < 3 ; i ++ ) triangle2 . push_back ( rectangle [ i ] ) ; vector < vector < int > > triangle3 ; for ( int i = 0 ; i < 2 ; i ++ ) triangle3 . push_back ( rectangle [ i ] ) ; triangle3 . push_back ( rectangle [ 3 ] ) ; vector < vector < int > > triangle4 ; for ( int i = n - 2 ; i < n ; i ++ ) triangle4 . push_back ( rectangle [ i ] ) ; triangle4 . push_back ( rectangle [ 0 ] ) ; int ans = 0 ; for ( auto point : points ) { int condOne = isInside ( triangle1 , point ) ; int condTwo = isInside ( triangle2 , point ) ; int condThree = isInside ( triangle3 , point ) ; int condFour = isInside ( triangle4 , point ) ; int condFive = isInside ( triangle , point ) ; if ( ( condOne condTwo condThree condFour ) && condFive ) ans += 1 ; } cout << ans ; } int main ( ) { vector < vector < int > > rectangle = { { 6 , 5 } , { 2 , 2 } , { 2 , 1 } , { 5 , 5 } } ; vector < vector < int > > points = { { 1 , 1 } , { 6 , 1 } , { 6 , 6 } , { 1 , 6 } } ; vector < vector < int > > triangle = { { 4 , 4 } , { 0 , 4 } , { 0 , -2 } } ; countPoints ( points , triangle , rectangle ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i, point
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumOperations ( int A [ ] , int n ) { int cnt = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( A [ i ] != ( i + 1 ) ) { if ( ( ( i - 1 ) >= 0 ) && A [ i - 1 ] == ( i + 1 ) ) { cnt ++ ; swap ( A [ i ] , A [ i - 1 ] ) ; } else if ( ( ( i - 2 ) >= 0 ) && A [ i - 2 ] == ( i + 1 ) ) { cnt += 2 ; A [ i - 2 ] = A [ i - 1 ] ; A [ i - 1 ] = A [ i ] ; A [ i ] = i + 1 ; } else { cout << -1 ; return ; } } } cout << cnt ; } int main ( ) { int A [ ] = { 7 , 3 , 2 , 1 , 4 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; minimumOperations ( A , 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 countOccurrences ( int n , int x ) { int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( x % i == 0 ) { if ( x / i <= n ) count ++ ; } } cout << count ; } int main ( ) { int N = 7 , X = 12 ; countOccurrences ( N , X ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void ConvertArray ( int arr [ ] , int N ) { if ( N == 1 ) { cout << " Operation ▁ 1 ▁ : ▁ " << 1 << " ▁ " << 1 << endl ; cout << " Added ▁ elements : ▁ " << -1 * arr [ 0 ] << endl ; cout << endl ; cout << " Operation ▁ 2 ▁ : ▁ " << 1 << " ▁ " << 1 << endl ; cout << " Added ▁ elements : ▁ " << 1 * arr [ 0 ] << endl ; cout << endl ; cout << " Operation ▁ 3 ▁ : ▁ " << 1 << " ▁ " << 1 << endl ; cout << " Added ▁ elements : ▁ " << -1 * arr [ 0 ] << endl ; } else { cout << " Operation ▁ 1 ▁ : ▁ " << 1 << " ▁ " << N << endl ; cout << " Added ▁ elements : ▁ " ; for ( int i = 0 ; i < N ; i ++ ) { cout << -1 * arr [ i ] * N << " ▁ " ; } cout << endl ; cout << endl ; cout << " Operation ▁ 2 ▁ : ▁ " << 1 << " ▁ " << N - 1 << endl ; cout << " Added ▁ elements : ▁ " ; for ( int i = 0 ; i < N - 1 ; i ++ ) { cout << arr [ i ] * ( N - 1 ) << " ▁ " ; } cout << endl ; cout << endl ; cout << " Operation ▁ 3 ▁ : ▁ " << N << " ▁ " << N << endl ; cout << " Added ▁ elements : ▁ " ; cout << arr [ N - 1 ] * ( N - 1 ) << endl ; } } int main ( ) { int arr [ ] = { 1 , 3 , 2 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; ConvertArray ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000000
void countOfPrimefactors ( vector < int > & CountDistinct ) { bool prime [ MAX + 1 ] ; for ( int i = 0 ; i <= MAX ; i ++ ) { CountDistinct [ i ] = 0 ; prime [ i ] = true ; } for ( long long int i = 2 ; i <= MAX ; i ++ ) { if ( prime [ i ] == true ) { CountDistinct [ i ] = 1 ; for ( long long int j = i * 2 ; j <= MAX ; j += i ) { CountDistinct [ j ] ++ ; prime [ j ] = false ; } } } } int CountEvenPair ( int A [ ] , int B [ ] , int N , int M ) { vector < int > countDistinct ( MAX + 1 ) ; countOfPrimefactors ( countDistinct ) ; int evenCount = 0 ; int oddCount = 0 ; int evenPairs = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( countDistinct [ B [ i ] ] == 0 ) continue ; if ( countDistinct [ B [ i ] ] & 1 ) { oddCount ++ ; } else { evenCount ++ ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( countDistinct [ A [ i ] ] == 0 ) continue ; if ( countDistinct [ A [ i ] ] & 1 ) { evenPairs += ( evenCount ) ; } else { evenPairs += evenCount + oddCount ; } } return evenPairs ; } int main ( ) { int A [ ] = { 1 , 2 , 3 } ; int B [ ] = { 4 , 5 , 6 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int M = sizeof ( B ) / sizeof ( B [ 0 ] ) ; cout << CountEvenPair ( A , B , N , M ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: evenCount, evenPairs, i, j, oddCount, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubarray ( int arr [ ] , int N , int K ) { unordered_map < int , int > um ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; if ( sum == K ) maxLen = i + 1 ; if ( um . find ( sum ) == um . end ( ) ) um [ sum ] = i ; if ( um . find ( sum - K ) != um . end ( ) ) { if ( maxLen < ( i - um [ sum - K ] ) ) maxLen = i - um [ sum - K ] ; } } return maxLen ; } void minRequiredOperation ( int arr [ ] , int N , int K ) { int TotalSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) TotalSum += arr [ i ] ; int maxLen = longestSubarray ( arr , N , TotalSum - K ) ; if ( maxLen == -1 ) { cout << -1 ; } else cout << N - maxLen ; } int main ( ) { int arr [ ] = { 1 , 3 , 1 , 1 , 2 } ; int K = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minRequiredOperation ( arr , N , K ) ; return 0 ; }

Index/key variables: i, sum
Accumulator variables: TotalSum, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumDeletions ( string s ) { int n = s . length ( ) ; int ans = n ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int t = s [ i ] - '0' ; if ( t % 2 == 0 ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { int num = ( s [ j ] - '0' ) * 10 + t ; if ( num % 4 == 0 ) { int k1 = i - j - 1 ; int k2 = n - i - 1 ; ans = min ( ans , k1 + k2 ) ; } } } } if ( ans == n ) { for ( int i = 0 ; i < n ; i ++ ) { int num = s [ i ] - '0' ; if ( num % 4 == 0 ) { ans = n - 1 ; } } } cout << ans ; } int main ( ) { string str = "12367" ; minimumDeletions ( str ) ; 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 ; void generateSequence ( int arr [ ] , int n ) { string ans ; ans = to_string ( arr [ 0 ] ) ; if ( n == 1 ) cout << ans ; else if ( n == 2 ) { cout << ans + " / " << to_string ( arr [ 1 ] ) ; } else { ans += " / ( " + to_string ( arr [ 1 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { ans += " / " + to_string ( arr [ i ] ) ; } ans += " ) " ; cout << ans ; } } int main ( ) { int arr [ ] = { 1000 , 100 , 10 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; generateSequence ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void LCMPairs ( int arr [ ] , int N ) { int total_pairs = ( N * ( N - 1 ) ) / 2 ; int odd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] & 1 ) odd ++ ; } odd = ( odd * ( odd - 1 ) ) / 2 ; cout << " Even ▁ = ▁ " << total_pairs - odd << " , ▁ Odd ▁ = ▁ " << odd ; } int main ( ) { int arr [ ] = { 3 , 6 , 5 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; LCMPairs ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countEvenOdd ( int L , int R ) { int range = R - L + 1 ; int even = ( range / 4 ) * 2 ; if ( ( L & 1 ) && ( range % 4 == 3 ) ) { even ++ ; } else if ( ! ( L & 1 ) && ( range % 4 ) ) { even ++ ; } cout << " Even ▁ = ▁ " << even << " , ▁ Odd ▁ = ▁ " << range - even ; } int main ( ) { int L = 2 , R = 7 ; countEvenOdd ( L , R ) ; return 0 ; }

Accumulator variables: even, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countSwaps ( string S , string T ) { int value [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) value [ i ] = i + 1 ; int N = S . size ( ) ; int sum1 = 0 ; int sum2 = 0 ; bool flag = false ; for ( int i = 0 ; i < N ; i ++ ) { sum1 += value [ S [ i ] - ' a ' ] ; sum2 += value [ T [ i ] - ' a ' ] ; if ( ( value [ S [ i ] - ' a ' ] % 2 == 0 && value [ T [ i ] - ' a ' ] % 2 == 1 ) || ( value [ S [ i ] - ' a ' ] % 2 == 1 && value [ T [ i ] - ' a ' ] % 2 == 0 ) ) flag = false ; } if ( sum1 % 2 == 1 && sum2 % 2 == 1 ) cout << "0 STRNEWLINE " ; else if ( sum1 % 2 == 0 && sum2 % 2 == 0 ) { if ( flag ) cout << "1" ; else cout << " - 1" ; } else { cout << " - 1" ; } } int main ( ) { string S = " acd " ; string T = " dbf " ; countSwaps ( S , T ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum1, sum2
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int N ) { if ( N <= 1 ) return false ; for ( int i = 2 ; i <= sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) return false ; } return true ; } void countPrimeTuples ( int N ) { int count = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { if ( isPrime ( i ) && isPrime ( i - 2 ) ) count ++ ; } cout << count ; } int main ( ) { int N = 6 ; countPrimeTuples ( N ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countPairs ( int A [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( ( A [ i ] A [ j ] ) > ( A [ i ] & A [ j ] ) ) { count ++ ; } } cout << count ; } int main ( ) { int A [ ] = { 1 , 4 , 7 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; countPairs ( A , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumCandy ( int candies [ ] , int safety [ ] , int N , int M ) { int total = 0 ; int ans = INT_MAX ; bool all_safe = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( candies [ i ] + M > safety [ i ] ) { all_safe = false ; ans = min ( ans , safety [ i ] ) ; } else { ans = min ( ans , candies [ i ] + M ) ; } total += candies [ i ] ; } if ( all_safe ) return total ; else return ans ; } int main ( ) { int A [ ] = { 2 , 4 , 1 , 9 , 6 } ; int B [ ] = { 8 , 7 , 3 , 12 , 7 } ; int M = 0 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << maximumCandy ( A , B , N , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, total
Iterator variables: i
Boolean variables: all_safe
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkArrays ( int arr1 [ ] , int arr2 [ ] , int N ) { int count = 0 ; bool flag = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr1 [ i ] != arr2 [ i ] ) { if ( arr1 [ i ] == 0 ) count ++ ; else { count -- ; if ( count < 0 ) { flag = 0 ; break ; } } } } if ( flag && count == 0 ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { int arr1 [ ] = { 0 , 0 , 1 , 1 } ; int arr2 [ ] = { 1 , 1 , 0 , 0 } ; int N = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; checkArrays ( arr1 , arr2 , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canArrayBeReduced ( int arr [ ] , int N ) { if ( N == 1 ) { cout << arr [ 0 ] ; return ; } if ( arr [ 0 ] < arr [ N - 1 ] ) { cout << arr [ N - 1 ] ; } else cout << " Not ▁ Possible " ; } int main ( ) { int arr [ ] = { 6 , 5 , 2 , 4 , 1 , 3 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; canArrayBeReduced ( arr , N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinimumMoves ( int A [ ] , int B [ ] , int N ) { int totalOperations = 0 ; int carry = 0 ; int K = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int nearestMultiple = ceil ( ( double ) ( A [ i ] + carry ) / ( double ) ( B [ i ] ) ) * B [ i ] ; K = nearestMultiple - ( A [ i ] + carry ) ; totalOperations += K ; carry += K ; } return totalOperations ; } int main ( ) { int A [ ] = { 3 , 4 , 5 , 2 , 5 , 5 , 9 } ; int B [ ] = { 1 , 1 , 9 , 6 , 3 , 8 , 7 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << MinimumMoves ( A , B , N ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: carry, i, stdc, totalOperations
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumDeviation ( int A [ ] , int N ) { set < int > s ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 0 ) s . insert ( A [ i ] ) ; else s . insert ( 2 * A [ i ] ) ; } int diff = * s . rbegin ( ) - * s . begin ( ) ; while ( ( int ) s . size ( ) && * s . rbegin ( ) % 2 == 0 ) { int maxEl = * s . rbegin ( ) ; s . erase ( maxEl ) ; s . insert ( maxEl / 2 ) ; diff = min ( diff , * s . rbegin ( ) - * s . begin ( ) ) ; } cout << diff ; } int main ( ) { int A [ ] = { 4 , 1 , 5 , 20 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; minimumDeviation ( A , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxNum ( int num ) { bitset < 4 > b ( num ) ; string binaryNumber = b . to_string ( ) ; string maxBinaryNumber = " " ; int count0 = 0 , count1 = 0 ; int N = 4 ; for ( int i = 0 ; i < N ; i ++ ) { if ( binaryNumber [ i ] == '1' ) { count1 ++ ; } else { count0 ++ ; } } for ( int i = 0 ; i < count1 ; i ++ ) { maxBinaryNumber += '1' ; } for ( int i = 0 ; i < count0 ; i ++ ) { maxBinaryNumber += '0' ; } return stoi ( maxBinaryNumber , 0 , 2 ) ; } int main ( ) { int N = 11 ; cout << findMaxNum ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count0, count1, i, maxBinaryNumber, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOperations ( string & N ) { int even = 0 ; int odd = 0 ; for ( auto it : N ) { if ( ( it - '0' ) % 2 == 0 ) { even ++ ; } else { odd ++ ; } } if ( odd == 0 odd == 1 ) { cout << " Not ▁ Possible " << " STRNEWLINE " ; } else { int ans = 0 ; for ( auto it : N ) { if ( ( it - '0' ) % 2 == 0 ) { ans ++ ; } else { ans = 0 ; } } if ( odd % 2 ) { ans ++ ; } cout << ans << endl ; } } int main ( ) { string N = "12345" ; minOperations ( N ) ; }

Accumulator variables: ans, even, odd, stdc
Iterator variables: it
C++ program:
#include <bits/stdc++.h>
using namespace std ; void FindwinnerOfGame ( string & S ) { int cntZero = 0 ; int cntConOne = 0 ; int nimSum = 0 ; int N = S . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == '1' ) { cntConOne += 1 ; } else { nimSum ^= cntConOne ; cntConOne = 0 ; cntZero ++ ; } } nimSum ^= cntConOne ; if ( cntZero % 2 == 0 ) { cout << " Tie " ; } else if ( nimSum ) { cout << " player ▁ 1" ; } else { cout << " player ▁ 2" ; } } int main ( ) { string S = "0110011" ; FindwinnerOfGame ( S ) ; }

Index/key variables: i
Accumulator variables: cntConOne, cntZero, i, nimSum, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generatepermutation ( int N ) { vector < int > answer ; answer . push_back ( N ) ; for ( int i = 1 ; i < N ; i ++ ) { answer . push_back ( i ) ; } for ( int i : answer ) cout << i << " ▁ " ; } int main ( ) { int N = 4 ; generatepermutation ( N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxValueAtIndexK ( int N , int K , int M ) { int S1 = 0 , S2 = 0 ; S1 = K * ( K + 1 ) / 2 ; S2 = ( N - K - 1 ) * ( N - K ) / 2 ; int X = ( M + S1 + S2 ) / N ; cout << X ; } int main ( ) { int N = 3 , K = 1 , M = 7 ; maxValueAtIndexK ( N , K , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void farthestCellDistance ( int N , int M , int R , int C ) { int d1 = N + M - R - C ; int d2 = R + C - 2 ; int d3 = N - R + C - 1 ; int d4 = M - C + R - 1 ; int maxDistance = max ( d1 , max ( d2 , max ( d3 , d4 ) ) ) ; cout << maxDistance ; } int main ( ) { int N = 15 , M = 12 , R = 1 , C = 6 ; farthestCellDistance ( N , M , R , C ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSum ( int arr [ ] , int N ) { int ans = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int t = i ; if ( t + arr [ i ] < N ) { arr [ i ] += arr [ t + arr [ i ] ] ; } } for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << ' ▁ ' ; } } int main ( ) { int arr [ ] = { 1 , 2 , 7 , 1 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxSum ( 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 long long ll ; void PrintPathNodes ( ll N ) { vector < ll > arr ; arr . push_back ( 1 ) ; ll k = 1 ; bool flag = true ; while ( k < N ) { if ( flag == true ) { k *= 2 ; flag = false ; } else { k *= 4 ; flag = true ; } if ( k > N ) { break ; } arr . push_back ( k ) ; } ll len = arr . size ( ) ; vector < ll > prefix ( len ) ; prefix [ 0 ] = 1 ; for ( ll i = 1 ; i < len ; ++ i ) { prefix [ i ] = arr [ i ] + prefix [ i - 1 ] ; } vector < ll > :: iterator it = lower_bound ( prefix . begin ( ) , prefix . end ( ) , N ) ; ll ind = it - prefix . begin ( ) ; ll temp = N ; vector < int > path ; path . push_back ( N ) ; while ( ind > 1 ) { ll val = temp - prefix [ ind - 1 ] ; if ( ind % 2 != 0 ) { temp = prefix [ ind - 2 ] + ( val + 1 ) / 2 ; } else { temp = prefix [ ind - 2 ] + ( val + 3 ) / 4 ; } -- ind ; path . push_back ( temp ) ; } if ( N != 1 ) path . push_back ( 1 ) ; for ( int i = path . size ( ) - 1 ; i >= 0 ; i -- ) { cout << path [ i ] << " ▁ " ; } } int main ( ) { ll N = 14 ; PrintPathNodes ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOpsToTurnArrToZero ( int arr [ ] , int N ) { unordered_set < int > st ; for ( int i = 0 ; i < N ; i ++ ) { if ( st . find ( arr [ i ] ) != st . end ( ) arr [ i ] == 0 ) { continue ; } else { st . insert ( arr [ i ] ) ; } } cout << st . size ( ) << endl ; } int main ( ) { int arr [ ] = { 3 , 7 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minOpsToTurnArrToZero ( 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 gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } void splitArray ( int arr [ ] , int N ) { map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } int G = 0 ; for ( auto i : mp ) { G = gcd ( G , i . second ) ; } if ( G > 1 ) cout << " YES " ; else cout << " NO " ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; splitArray ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool CheckAllEqual ( int arr [ ] , int N ) { for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ 0 ] != arr [ i ] ) { return false ; } } return true ; } int minCntOperations ( int arr [ ] , int N ) { int Max = * max_element ( arr , arr + N ) ; bool isPower2 = ! ( Max && ( Max & ( Max - 1 ) ) ) ; if ( isPower2 && CheckAllEqual ( arr , N ) ) { return log2 ( Max ) ; } else { return ceil ( log2 ( Max ) ) + 1 ; } } int main ( ) { int arr [ ] = { 2 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minCntOperations ( arr , N ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string greatestReducedNumber ( string num , string s ) { vector < bool > vis_s ( 10 , false ) ; for ( int i = 0 ; i < ( int ) s . size ( ) ; i ++ ) { vis_s [ int ( s [ i ] ) - 48 ] = true ; } int n = num . size ( ) ; int in = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis_s [ ( int ) num [ i ] - '0' ] ) { in = i ; break ; } } if ( in == -1 ) { return num ; } for ( char dig = num [ in ] ; dig >= '0' ; dig -- ) { if ( vis_s [ ( int ) dig - '0' ] == 0 ) { num [ in ] = dig ; break ; } } char LargestDig = '0' ; for ( char dig = '9' ; dig >= '0' ; dig -- ) { if ( vis_s [ dig - '0' ] == false ) { LargestDig = dig ; break ; } } for ( int i = in + 1 ; i < n ; i ++ ) { num [ i ] = LargestDig ; } int Count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( num [ i ] == '0' ) Count ++ ; else break ; } num . erase ( 0 , Count ) ; if ( ( int ) num . size ( ) == 0 ) return "0" ; return num ; } int main ( ) { string N = "12345" ; string S = "23" ; cout << greatestReducedNumber ( N , S ) ; return 0 ; }

Index/key variables: i, in
Accumulator variables: Count, dig, i, stdc
Iterator variables: dig, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minXOR ( vector < int > & Arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( Arr [ i ] == 2 ) { cout << ( Arr [ i ] ^ 3 ) << " ▁ " ; } else { cout << ( Arr [ i ] ^ 2 ) << " ▁ " ; } } } int main ( ) { vector < int > Arr = { 5 , 4 , 7 , 6 } ; int N = Arr . size ( ) ; minXOR ( Arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > findArray ( int n ) { vector < int > Arr ( n + 1 ) ; Arr [ 0 ] = 0 ; Arr [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { Arr [ i ] = Arr [ i / 2 ] ; } else { Arr [ i ] = Arr [ ( i - 1 ) / 2 ] + Arr [ ( i - 1 ) / 2 + 1 ] ; } } return Arr ; } int maxElement ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 ) return 1 ; vector < int > Arr = findArray ( n ) ; return * max_element ( Arr . begin ( ) , Arr . end ( ) ) ; } int main ( ) { int N = 7 ; cout << maxElement ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <vector>
using namespace std ; void constGraphWithCon ( int N , int K ) { int Max = ( ( N - 1 ) * ( N - 2 ) ) / 2 ; if ( K > Max ) { cout << -1 << endl ; return ; } vector < pair < int , int > > ans ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = i + 1 ; j <= N ; j ++ ) { ans . emplace_back ( make_pair ( i , j ) ) ; } } for ( int i = 0 ; i < ( N - 1 ) + Max - K ; i ++ ) { cout << ans [ i ] . first << " ▁ " << ans [ i ] . second << endl ; } } int main ( ) { int N = 5 , K = 3 ; constGraphWithCon ( N , K ) ; return 0 ; }

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