dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_steps_required ( int n , int m , int r , int c ) { int i , j ; int corner_steps_req = INT_MAX ; i = 1 ; j = 1 ; corner_steps_req = min ( corner_steps_req , abs ( r - i ) + abs ( j - c ) ) ; i = n ; j = 1 ; corner_steps_req = min ( corner_steps_req , abs ( r - i ) + abs ( j - c ) ) ; i = 1 ; j = m ; corner_steps_req = min ( corner_steps_req , abs ( r - i ) + abs ( j - c ) ) ; i = n ; j = m ; corner_steps_req = min ( corner_steps_req , abs ( r - i ) + abs ( j - c ) ) ; int minimum_steps = min ( 2 * ( n - 1 ) + m - 1 , 2 * ( m - 1 ) + n - 1 ) ; return minimum_steps + corner_steps_req ; } int main ( ) { int n = 3 ; int m = 2 ; int r = 1 ; int c = 1 ; cout << min_steps_required ( n , m , r , c ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_elements ( int arr [ ] , int N , int K ) { map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } vector < int > Freq ; for ( auto it : mp ) { int i = it . first ; Freq . push_back ( mp [ i ] ) ; } sort ( Freq . rbegin ( ) , Freq . rend ( ) ) ; int len = Freq . size ( ) ; if ( len <= K ) { return 0 ; } int cntMin = 0 ; for ( int i = K ; i < len ; i ++ ) { cntMin += Freq [ i ] ; } return cntMin ; } int main ( ) { int arr [ ] = { 5 , 1 , 3 , 2 , 4 , 1 , 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 3 ; cout << min_elements ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntMin, i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumzero ( int arr [ ] , int N , int K ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } if ( sum == 0 ) cout << " Yes " ; else if ( sum > 0 ) { if ( sum % K == 0 ) cout << " Yes " ; else cout << " No " ; } else cout << " No " ; return 0 ; } int main ( ) { int K , N ; int arr1 [ ] = { 1 , -6 , 2 , 2 } ; K = 1 ; N = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; sumzero ( arr1 , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntOnesArrWithGivenOp ( int arr [ ] , int N ) { int cntOnes = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i - 1 ; j < N ; j += i ) { arr [ j ] = ! ( arr [ j ] ) ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { cntOnes += 1 ; } } return cntOnes ; } int main ( ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntOnesArrWithGivenOp ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: cntOnes, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntOnesArrWithGivenOp ( int arr [ ] , int N ) { int cntOnes = 0 ; cntOnes = sqrt ( N ) ; return cntOnes ; } int main ( ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntOnesArrWithGivenOp ( arr , N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntKnightsAttackPawn ( int knights [ ] [ 2 ] , int pawn [ ] , int M ) { int cntKnights = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int X = abs ( knights [ i ] [ 0 ] - pawn [ 0 ] ) ; int Y = abs ( knights [ i ] [ 1 ] - pawn [ 1 ] ) ; if ( ( X == 1 && Y == 2 ) || ( X == 2 && Y == 1 ) ) { cntKnights ++ ; } } return cntKnights ; } int main ( ) { int knights [ ] [ 2 ] = { { 0 , 4 } , { 4 , 5 } , { 1 , 4 } , { 3 , 1 } } ; int pawn [ ] = { 2 , 3 } ; int M = sizeof ( knights ) / sizeof ( knights [ 0 ] ) ; cout << cntKnightsAttackPawn ( knights , pawn , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntKnights, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findWinnerGameRemoveGCD ( int arr [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 2 ; j * j <= arr [ i ] ; j ++ ) { if ( arr [ i ] % j == 0 ) { mp [ j ] ++ ; while ( arr [ i ] % j == 0 ) { arr [ i ] = arr [ i ] / j ; } } } if ( arr [ i ] > 1 ) { mp [ arr [ i ] ] ++ ; } } int maxCnt = 0 ; for ( auto i : mp ) { maxCnt = max ( maxCnt , i . second ) ; } if ( n % 2 == 0 ) { if ( maxCnt >= n - 1 ) { cout << " Player ▁ 1" ; } else { cout << " Player ▁ 2" ; } } else { if ( maxCnt == n ) { cout << " Player ▁ 1" ; } else { cout << " Player ▁ 2" ; } } } int main ( ) { int arr [ ] = { 2 , 4 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findWinnerGameRemoveGCD ( arr , N ) ; 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 maxksum ( int L , int R , int K ) { int N = ( R / 10 - L / 10 ) + 1 ; if ( K > N ) { cout << -1 ; return ; } R = R / 10 ; int X = R - K ; int sum = 10 * ( ( R * ( R + 1 ) ) / 2 - ( X * ( X + 1 ) ) / 2 ) ; cout << sum ; } int main ( ) { int L = 16 , R = 60 , K = 4 ; maxksum ( L , R , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumSwaps ( int arr1 [ ] , int arr2 [ ] , int n ) { int sumArr1 = 0 , sumArr2 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { sumArr1 += arr1 [ i ] ; sumArr2 += arr2 [ i ] ; } if ( sumArr1 % 2 == 0 && sumArr2 % 2 == 0 ) { cout << 0 ; return ; } if ( sumArr1 % 2 != 0 && sumArr2 % 2 != 0 ) { int flag = -1 ; for ( int i = 0 ; i < n ; ++ i ) { if ( ( arr1 [ i ] + arr2 [ i ] ) % 2 == 1 ) { flag = 1 ; break ; } } cout << flag ; return ; } cout << -1 ; } int main ( ) { int arr1 [ ] = { 11 , 14 , 20 , 2 } ; int arr2 [ ] = { 5 , 9 , 6 , 3 } ; int N = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; minimumSwaps ( arr1 , arr2 , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc, sumArr1, sumArr2
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void corpFlightBookings ( vector < vector < int > > & Bookings , int N ) { vector < int > res ( N , 0 ) ; for ( int i = 0 ; i < Bookings . size ( ) ; i ++ ) { int l = Bookings [ i ] [ 0 ] ; int r = Bookings [ i ] [ 1 ] ; int K = Bookings [ i ] [ 2 ] ; res [ l - 1 ] = res [ l - 1 ] + K ; if ( r <= res . size ( ) - 1 ) res [ r ] = ( - K ) + res [ r ] ; } for ( int i = 1 ; i < res . size ( ) ; i ++ ) res [ i ] = res [ i ] + res [ i - 1 ] ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) { cout << res [ i ] << " ▁ " ; } } int main ( ) { vector < vector < int > > bookings { { 1 , 3 , 100 } , { 2 , 6 , 100 } , { 3 , 4 , 100 } } ; int N = 6 ; corpFlightBookings ( bookings , N ) ; return 0 ; }

Index/key variables: i, r
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findXOR ( int n ) { switch ( n & 3 ) { case 0 : return n ; case 1 : return 1 ; case 2 : return n + 1 ; case 3 : return 0 ; } } void findOddXOR ( int n ) { if ( n % 2 == 0 ) cout << ( ( findXOR ( n ) ) ^ ( 2 * findXOR ( n / 2 ) ) ) ; else cout << ( ( findXOR ( n ) ) ^ ( 2 * findXOR ( ( n - 1 ) / 2 ) ) ) ; } int main ( ) { int N = 11 ; findOddXOR ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSmallestNumber ( int n ) { for ( int i = n ; i <= ( n + 2520 ) ; ++ i ) { bool possible = 1 ; int temp = i ; while ( temp ) { if ( temp % 10 != 0 ) { int digit = temp % 10 ; if ( i % digit != 0 ) { possible = 0 ; break ; } } temp /= 10 ; } if ( possible == 1 ) { cout << i ; return ; } } } int main ( ) { int N = 31 ; findSmallestNumber ( N ) ; return 0 ; }

Accumulator variables: stdc, temp
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void path_to_root ( int node ) { while ( node >= 1 ) { cout << node << ' ▁ ' ; node /= 2 ; } } int main ( ) { int N = 7 ; path_to_root ( N ) ; return 0 ; }

Accumulator variables: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSmallestNumberPossible ( int N , int K ) { if ( N > 45 * K ) { cout << " - 1" ; return ; } string res = " " ; int count = 0 ; for ( int i = 9 ; i >= 1 ; ) { if ( count == K ) { i -- ; count = 0 ; } if ( N > i ) { N -= i ; res += ( char ) 48 + i ; } else { res += ( char ) N + 48 ; N = 0 ; break ; } count ++ ; } reverse ( res . begin ( ) , res . end ( ) ) ; cout << res ; } int main ( ) { int N = 25 , K = 3 ; findSmallestNumberPossible ( N , K ) ; return 0 ; }

Accumulator variables: N, count, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minValue ( int arr [ ] , int n ) { int minimum = * min_element ( arr , arr + n ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ( arr [ i ] - minimum ) ; } return sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minValue ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void result ( int n ) { if ( n > 45 ) { cout << -1 ; return ; } string res ; int digit = 9 ; while ( n > digit ) { res = char ( '0' + digit ) + res ; n -= digit ; digit -= 1 ; } if ( n > 0 ) { res = char ( '0' + n ) + res ; } cout << res ; } int main ( ) { int N = 19 ; result ( N ) ; return 0 ; }

Accumulator variables: digit, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countEvenPairs ( int N , int M ) { int count = 0 ; int nEven = floor ( N / 2 ) ; int nOdd = ceil ( N / 2 ) ; int mEven = floor ( M / 2 ) ; int mOdd = ceil ( M / 2 ) ; count = nEven * mEven + nOdd * mOdd ; return count ; } int main ( ) { int N = 4 ; int M = 6 ; cout << countEvenPairs ( N , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; char lastRemovedCharacter ( string str ) { int n = str . length ( ) ; if ( n == 1 ) return str [ 0 ] ; if ( str [ n - 2 ] == '0' ) { return ( '1' - str [ n - 1 ] + '0' ) ; } else return str [ n - 1 ] ; } int main ( ) { string str = "10010" ; cout << lastRemovedCharacter ( str ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( int aXORb , int aANDb , int aXORc , int aANDc , int bXORc , int bANDc ) { int a , b , c ; int aSUMb ; int aSUMc ; int bSUMc ; aSUMb = aXORb + aANDb * 2 ; aSUMc = aXORc + aANDc * 2 ; bSUMc = bXORc + bANDc * 2 ; a = ( aSUMb - bSUMc + aSUMc ) / 2 ; b = aSUMb - a ; c = aSUMc - a ; cout << " a ▁ = ▁ " << a ; cout << " , ▁ b ▁ = ▁ " << b ; cout << " , ▁ c ▁ = ▁ " << c ; } int main ( ) { int aXORb = 30 , aANDb = 0 , aXORc = 20 , aANDc = 10 , bXORc = 10 , bANDc = 20 ; findNumbers ( aXORb , aANDb , aXORc , aANDc , bXORc , bANDc ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findArray ( int N , int K ) { if ( N == 1 ) { cout << " ▁ " << K ; return ; } if ( N == 2 ) { cout << 0 << " ▁ " << K ; return ; } int P = N - 2 ; int Q = N - 1 ; int VAL = 0 ; for ( int i = 1 ; i <= ( N - 3 ) ; i ++ ) { cout << " ▁ " << i ; VAL ^= i ; } if ( VAL == K ) { cout << P << " ▁ " << Q << " ▁ " << ( P ^ Q ) ; } else { cout << 0 << " ▁ " << P << " ▁ " << ( P ^ K ^ VAL ) ; } } int main ( ) { int N = 4 , X = 6 ; findArray ( N , X ) ; return 0 ; }

Accumulator variables: VAL, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumber ( int N ) { int count = 0 ; while ( ( N & 1 ) == 1 ) { N = N >> 1 ; count ++ ; } return N << count ; } int main ( ) { int N = 39 ; cout << findNumber ( N ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findNumber ( int N ) { return N & ( N + 1 ) ; } int main ( ) { int N = 39 ; cout << findNumber ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > subString ( string s , int n ) { vector < string > v ; for ( int i = 0 ; i < n ; i ++ ) { for ( int len = 1 ; len <= n - i ; len ++ ) { string find = s . substr ( i , len ) ; v . push_back ( find ) ; } } return v ; } int IsPresent ( string & str , string & target ) { if ( str . find ( target ) != string :: npos ) { return 1 ; } return -1 ; } void countSubstrings ( string & S , string & T ) { vector < string > v = subString ( S , S . length ( ) ) ; int ans = 0 ; for ( auto it : v ) { if ( IsPresent ( it , T ) != -1 ) { ans ++ ; } } cout << ans ; } int main ( ) { string S = " dabc " ; string T = " ab " ; countSubstrings ( S , T ) ; return 0 ; }

Accumulator variables: ans, i, len, stdc
Iterator variables: i, it, len
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOperation ( int X [ ] , int Y [ ] , int n ) { int C = 0 ; int count = 0 ; for ( int i = 1 ; i < n ; i = i + 2 ) { if ( X [ i ] != Y [ i ] ) { count ++ ; } else { if ( count != 0 ) C ++ ; count = 0 ; } } if ( count != 0 ) C ++ ; count = 0 ; for ( int i = 0 ; i < n ; i = i + 2 ) { if ( X [ i ] != Y [ i ] ) { count ++ ; } else { if ( count != 0 ) C ++ ; count = 0 ; } } if ( count != 0 ) C ++ ; cout << C ; } int main ( ) { int X [ ] = { 1 , 0 , 0 , 0 , 0 , 1 } ; int Y [ ] = { 1 , 1 , 0 , 1 , 1 , 1 } ; int N = sizeof ( X ) / sizeof ( X [ 0 ] ) ; minOperation ( X , Y , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: C, count, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumcntOperationReq ( int arr [ ] , int N ) { int cntOp = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { cntOp ++ ; } } return ( cntOp + 1 ) / 2 ; } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 0 , 1 , 0 , 0 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumcntOperationReq ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntOp, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isSequenceValid ( vector < int > & B , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( i + 1 ) % B [ i ] != 0 ) { cout << " No " ; return ; } } cout << " Yes " ; } int main ( ) { int N = 4 ; vector < int > arr { 1 , 2 , 3 , 2 } ; isSequenceValid ( arr , N ) ; return 0 ; }

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

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxEqrows ( vector < vector < int > > & mat , int N , int M ) { map < vector < int > , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ mat [ i ] ] ++ ; } int cntMaxRows = 0 ; for ( int i = 0 ; i < N ; i ++ ) { vector < int > onesCompRow ( M , 0 ) ; for ( int j = 0 ; j < M ; j ++ ) { onesCompRow [ j ] = ( mat [ i ] [ j ] ^ 1 ) ; } cntMaxRows = max ( cntMaxRows , mp [ mat [ i ] ] + mp [ onesCompRow ] ) ; } return cntMaxRows ; } int main ( ) { vector < vector < int > > mat = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 1 , 0 , 1 , 1 } , { 1 , 0 , 1 , 1 , 0 } } ; int N = mat . size ( ) ; int M = mat [ 0 ] . size ( ) ; cout << maxEqrows ( mat , N , M ) ; }

Index/key variables: i, j, onesCompRow
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumCost ( string a , string b ) { vector < int > fre1 ( 256 ) , fre2 ( 256 ) ; for ( char c : a ) fre1 [ ( int ) ( c ) ] ++ ; for ( char c : b ) fre2 [ ( int ) ( c ) ] ++ ; int mincost = 0 ; for ( int i = 0 ; i < 256 ; i ++ ) { mincost += abs ( fre1 [ i ] - fre2 [ i ] ) ; } cout << mincost << endl ; } int main ( ) { string A = "1AB + - " , B = " cc " ; minimumCost ( A , B ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, mincost, stdc
Iterator variables: c, i
C++ program:
#include <iostream>
using namespace std ; int minCost ( int arr [ ] , int arr_size ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < arr_size ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; else odd ++ ; } cout << min ( even , odd ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minCost ( arr , arr_size ) ; }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxSumByAlternatingSign ( int arr [ ] , int N ) { int cntNeg = 0 ; int MaxAltSum = 0 ; int SmValue = 0 ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < 0 ) { cntNeg += 1 ; } sum += abs ( arr [ i ] ) ; SmValue = min ( SmValue , abs ( arr [ i ] ) ) ; } MaxAltSum = sum ; if ( cntNeg & 1 ) { MaxAltSum -= 2 * SmValue ; } return MaxAltSum ; } int main ( ) { int arr [ ] = { 1 , 1 , -2 , -4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMaxSumByAlternatingSign ( arr , N ) ; }

Index/key variables: i
Accumulator variables: MaxAltSum, cntNeg, i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void constructNewArraySumZero ( int arr [ ] , int N ) { int newArr [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { newArr [ i ] = arr [ i + 1 ] ; } else { newArr [ i ] = - arr [ i - 1 ] ; } } for ( int i = 0 ; i < N ; i ++ ) { cout << newArr [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , -5 , -6 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; constructNewArraySumZero ( arr , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void bitonicSequence ( int num , int lower , int upper ) { if ( num > ( upper - lower ) * 2 + 1 ) { cout << -1 ; return ; } deque < int > ans ; deque < int > :: iterator j = ans . begin ( ) ; for ( int i = 0 ; i < min ( upper - lower + 1 , num - 1 ) ; i ++ ) ans . push_back ( upper - i ) ; for ( int i = 0 ; i < num - ans . size ( ) ; i ++ ) ans . push_front ( upper - i - 1 ) ; cout << ' [ ' ; for ( j = ans . begin ( ) ; j != ans . end ( ) ; ++ j ) cout << ' ▁ ' << * j ; cout << ' ▁ ' << ' ] ' ; } int main ( ) { int N = 5 , L = 3 , R = 10 ; bitonicSequence ( N , L , R ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstrings ( string s , string t ) { int answ = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { for ( int j = 0 ; j < t . size ( ) ; j ++ ) { if ( t [ j ] != s [ i ] ) { answ += 1 ; int k = 1 ; int z = -1 ; int q = 1 ; while ( j + z >= 0 && 0 <= i + z && s [ i + z ] == t [ j + z ] ) { z -= 1 ; answ += 1 ; q += 1 ; } while ( s . size ( ) > i + k && j + k < t . size ( ) && s [ i + k ] == t [ j + k ] ) { k += 1 ; answ += q ; z = -1 ; } } } } return answ ; } int main ( ) { string S = " aba " ; string T = " baba " ; cout << ( countSubstrings ( S , T ) ) ; }

Index/key variables: i, j
Accumulator variables: answ, i, j, k, q, stdc, z
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumCntOfFlipsRequired ( string str ) { int n = str . length ( ) ; int zeros = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) { zeros ++ ; } } if ( zeros == 0 zeros == n ) { return 0 ; } int minFlips = INT_MAX ; int currOnes = 0 ; int flips ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '1' ) { currOnes ++ ; } flips = currOnes + ( zeros - ( i + 1 - currOnes ) ) ; minFlips = min ( minFlips , flips ) ; } return minFlips ; } int main ( ) { string str = "100101" ; cout << minimumCntOfFlipsRequired ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: currOnes, i, stdc, zeros
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLongestNonDecreasing ( int A [ ] , int N ) { int res = 0 ; int start = 0 ; int end = N - 1 ; int prev = -1 ; while ( start <= end ) { if ( A [ start ] <= A [ end ] ) { if ( prev == -1 ) { prev = A [ start ] ; res ++ ; start ++ ; } else { if ( A [ start ] >= prev ) { res ++ ; prev = A [ start ] ; start ++ ; } else if ( A [ end ] >= prev ) { res ++ ; prev = A [ end ] ; end -- ; } else { break ; } } } else { if ( prev == -1 ) { prev = A [ end ] ; res ++ ; end -- ; } else { if ( A [ end ] >= prev ) { res ++ ; prev = A [ end ] ; end -- ; } else if ( A [ start ] >= prev ) { res ++ ; prev = A [ start ] ; start ++ ; } else { break ; } } } } return res ; } int main ( ) { int A [ ] = { 1 , 1 , 3 , 5 , 4 , 3 , 6 , 2 , 1 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << findLongestNonDecreasing ( A , N ) ; return 0 ; }

Index/key variables: end, start
Accumulator variables: end, res, start, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPairs ( int N ) { for ( int i = 0 ; i <= N ; i ++ ) { cout << " ( " << i << " , ▁ " << N - i << " ) , ▁ " ; } } int main ( ) { int N = 5 ; findPairs ( N ) ; return 0 ; }

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 ) ; } int findPartition ( int nums [ ] , int N ) { int prefix [ N ] , suffix [ N ] , i , k ; prefix [ 0 ] = nums [ 0 ] ; for ( i = 1 ; i < N ; i ++ ) { prefix [ i ] = prefix [ i - 1 ] * nums [ i ] ; } suffix [ N - 1 ] = nums [ N - 1 ] ; for ( i = N - 2 ; i >= 0 ; i -- ) { suffix [ i ] = suffix [ i + 1 ] * nums [ i ] ; } for ( k = 0 ; k < N - 1 ; k ++ ) { if ( GCD ( prefix [ k ] , suffix [ k + 1 ] ) == 1 ) { return k ; } } return -1 ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findPartition ( arr , N ) ; return 0 ; }

Index/key variables: N, i, k
Accumulator variables: i, k, stdc
Iterator variables: i, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int separate ( int arr [ ] , int n , int parity ) { int count = 1 , res = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ( ( arr [ i ] + parity ) & 1 ) && ( ( arr [ i - 1 ] + parity ) & 1 ) ) count ++ ; else { if ( count > 1 ) res += count - 1 ; count = 1 ; } } return res ; } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } void requiredOps ( int arr [ ] , int N ) { int res1 = separate ( arr , N , 0 ) ; int res2 = separate ( arr , N , 1 ) ; cout << max ( res1 , res2 ) ; } int main ( ) { int arr [ ] = { 13 , 2 , 6 , 8 , 3 , 5 , 7 , 10 , 14 , 15 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; requiredOps ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < bool > SieveOfEratosthenes ( int N ) { vector < bool > isPrime ( N , true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int p = 2 ; p * p <= N ; p ++ ) { if ( isPrime [ p ] ) { for ( int i = p * p ; i <= N ; i += p ) { isPrime [ i ] = false ; } } } return isPrime ; } int cntPairsdiffOfPrimeisPrime ( int N ) { int cntPairs = 0 ; vector < bool > isPrime = SieveOfEratosthenes ( N ) ; for ( int i = 2 ; i <= N ; i ++ ) { if ( isPrime [ i ] && isPrime [ i - 2 ] ) { cntPairs += 2 ; } } return cntPairs ; } int main ( ) { int N = 5 ; cout << cntPairsdiffOfPrimeisPrime ( N ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: cntPairs, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void longestSubsequence ( int arr [ ] , int N ) { int count = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] ) { count ++ ; } } cout << count << endl ; } int main ( ) { int arr [ ] = { 7 , 8 , 1 , 2 , 2 , 5 , 5 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; longestSubsequence ( arr , N ) ; return 0 ; }

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