dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int substringCount ( string s ) { vector < int > freq ( 26 , 0 ) ; char max_char = ' # ' ; int maxfreq = INT_MIN ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { freq [ s [ i ] - ' a ' ] ++ ; if ( maxfreq < freq [ s [ i ] - ' a ' ] ) maxfreq = freq [ s [ i ] - ' a ' ] ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( maxfreq == freq [ i ] ) { max_char = ( char ) ( i + ' a ' ) ; break ; } } int ans = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { char ch = s [ i ] ; if ( max_char == ch ) { ans += ( s . size ( ) - i ) ; } } return ans ; } int main ( ) { string S = " abcab " ; cout << ( substringCount ( S ) ) ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minSum ( int * arr , int n ) { vector < int > ans ( n , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) { ans [ i ] = max ( ans [ i ] , ans [ i - 1 ] + 1 ) ; } } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > arr [ i + 1 ] ) { ans [ i ] = max ( ans [ i ] , ans [ i + 1 ] + 1 ) ; } } int s = 0 ; for ( auto x : ans ) { s = s + x ; } cout << s << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minSum ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMax ( string s , int n , int k ) { int ans = 0 ; int l = 0 ; int ind = -1 ; int indf = -1 ; multiset < int > ls ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) l ++ ; else if ( s [ i ] == '1' && l > 0 && ans != 0 ) { ls . insert ( l ) ; l = 0 ; } if ( s [ i ] == '1' ) { ind = i ; l = 0 ; if ( indf == -1 ) indf = i ; if ( i > 0 && s [ i - 1 ] == '1' ) ans += 2 ; else ans += 1 ; } } int curr ; while ( k > 0 && ! ls . empty ( ) ) { curr = * ls . begin ( ) ; if ( k >= curr ) { ans += ( 2 * curr + 1 ) ; k -= curr ; } else { ans += ( 2 * k ) ; k = 0 ; } ls . erase ( ls . begin ( ) ) ; } if ( k > 0 ) { ans += ( 2 * min ( k , n - ( ind + 1 ) ) - 1 ) ; k -= min ( k , n - ( ind + 1 ) ) ; if ( ind > -1 ) ans ++ ; } if ( k > 0 ) { ans += ( min ( indf , k ) * 2 - 1 ) ; if ( indf > -1 ) ans ++ ; } return ans ; } int main ( ) { string str = "1110000101" ; int N = str . length ( ) ; int K = 3 ; cout << findMax ( str , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, k, l, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSteps ( string S ) { string new_str ; int N = S . length ( ) ; int i = 0 ; while ( i < N ) { new_str += S [ i ] ; int j = i ; while ( i < N && S [ i ] == S [ j ] ) ++ i ; } cout << ceil ( ( new_str . size ( ) + 1 ) / 2.0 ) ; } int main ( ) { string S = "0010100" ; minSteps ( S ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: new_str, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int arr [ ] , int N ) { int cntPairs = 0 ; map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } for ( auto freq : mp ) { cntPairs += ( freq . second * ( freq . second - 1 ) ) / 2 ; } return cntPairs ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 1 , 2 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( arr , N ) ; }

Index/key variables: i
Accumulator variables: cntPairs, i, stdc
Iterator variables: freq, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int palindromeMatrix ( int N , int M , vector < vector < int > > arr ) { int ans = 0 ; for ( int i = 0 ; i < ( N + 1 ) / 2 ; i ++ ) { for ( int j = 0 ; j < ( M + 1 ) / 2 ; j ++ ) { set < pair < int , int > > s ; s . insert ( { i , j } ) ; s . insert ( { i , M - j - 1 } ) ; s . insert ( { N - i - 1 , j } ) ; s . insert ( { N - i - 1 , M - j - 1 } ) ; vector < int > values ; for ( pair < int , int > p : s ) { values . push_back ( arr [ p . first ] [ p . second ] ) ; } int max = * max_element ( values . begin ( ) , values . end ( ) ) ; for ( int k = 0 ; k < values . size ( ) ; k ++ ) { ans += max - values [ k ] ; } } } cout << ans ; } int main ( ) { int N = 3 , M = 3 ; vector < vector < int > > arr = { { 1 , 2 , 1 } , { 3 , 4 , 1 } , { 1 , 2 , 1 } } ; palindromeMatrix ( N , M , arr ) ; return 0 ; }

Index/key variables: k
Accumulator variables: ans, i, j, k, stdc
Iterator variables: i, j, k, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumMoves ( int n ) { int cnt2 = 0 , cnt5 = 0 ; while ( n % 2 == 0 ) { n /= 2 ; cnt2 ++ ; } while ( n % 5 == 0 ) { n /= 5 ; cnt5 ++ ; } if ( n == 1 && cnt2 <= cnt5 ) { return 2 * cnt5 - cnt2 ; } else return -1 ; } int main ( ) { int N = 25 ; cout << minimumMoves ( N ) ; return 0 ; }

Accumulator variables: cnt2, cnt5, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void check ( int n ) { if ( ( n & n - 1 ) != 0 ) cout << " YES " << endl ; else cout << " NO " << endl ; } int main ( ) { int n = 5 ; check ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinOperation ( int arr [ ] , int N , int K ) { int cntOpe = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( K > arr [ i ] ) { if ( ( K - arr [ i ] ) % 2 == 0 ) { cntOpe += 2 ; } else { cntOpe += 1 ; } } else if ( K < arr [ i ] ) { if ( ( K - arr [ i ] ) % 2 == 0 ) { cntOpe += 1 ; } else { cntOpe += 2 ; } } } return cntOpe ; } int main ( ) { int arr [ ] = { 8 , 7 , 2 , 1 , 3 } ; int K = 5 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << MinOperation ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntOpe, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > rearrangeArray ( vector < int > & A , vector < int > & B , int N ) { map < int , int > m ; int xor_value = 0 ; for ( int i = 0 ; i < N ; i ++ ) { xor_value ^= A [ i ] ; xor_value ^= B [ i ] ; m [ B [ i ] ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { B [ i ] = A [ i ] ^ xor_value ; if ( m [ B [ i ] ] ) { m [ B [ i ] ] -- ; } else return vector < int > { } ; } return B ; } void rearrangeArrayUtil ( vector < int > & A , vector < int > & B , int N ) { vector < int > ans = rearrangeArray ( A , B , N ) ; if ( ans . size ( ) ) { for ( auto x : ans ) { cout << x << " ▁ " ; } } else { cout << " - 1" ; } } int main ( ) { vector < int > A = { 13 , 21 , 33 , 49 , 53 } ; vector < int > B = { 54 , 50 , 34 , 22 , 14 } ; int N = ( int ) A . size ( ) ; rearrangeArrayUtil ( A , B , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, xor_value
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned long int binCoff ( unsigned int n , unsigned int r ) { unsigned long int val = 1 ; int i ; if ( r > ( n - r ) ) r = ( n - r ) ; for ( i = 0 ; i < r ; i ++ ) { val *= ( n - i ) ; val /= ( i + 1 ) ; } return val ; } void findWays ( int M ) { int n = M / 2 ; unsigned long int a , b , ans ; a = binCoff ( 2 * n , n ) ; b = a / ( n + 1 ) ; cout << b ; } int main ( ) { int M = 4 , X = 5 ; findWays ( M ) ; return 0 ; }

Accumulator variables: i, stdc, val
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 ) ; } void countInverse ( int arr [ ] , int N , int M ) { int XOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int gcdOfMandelement = gcd ( M , arr [ i ] ) ; if ( gcdOfMandelement == 1 ) { XOR ^= arr [ i ] ; } } cout << XOR << ' ▁ ' ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int M = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countInverse ( arr , N , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: XOR, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int Moves_Calculator ( int x , int y , int row , int col ) { int total_moves = 0 ; if ( ( row - x ) > 0 && ( col - y ) > 0 ) total_moves += min ( ( row - x ) , ( col - y ) ) ; if ( ( y - 1 ) > 0 && ( x - 1 ) > 0 ) total_moves += min ( ( y - 1 ) , ( x - 1 ) ) ; if ( ( x - 1 ) > 0 && ( col - y ) > 0 ) total_moves += min ( ( x - 1 ) , ( col - y ) ) ; if ( ( row - x ) > 0 && ( y - 1 ) > 0 ) total_moves += min ( ( row - x ) , ( y - 1 ) ) ; total_moves += ( row - 1 ) + ( col - 1 ) ; int king_moves = 0 ; if ( x + 1 <= row ) king_moves += 1 ; if ( x - 1 > 0 ) king_moves += 1 ; if ( y + 1 <= col ) king_moves += 1 ; if ( y - 1 > 0 ) king_moves += 1 ; if ( x + 1 <= row && y + 1 <= col ) king_moves += 1 ; if ( x + 1 <= row && y - 1 > 0 ) king_moves += 1 ; if ( x - 1 > 0 && y - 1 > 0 ) king_moves += 1 ; if ( x - 1 > 0 && y + 1 <= col ) king_moves += 1 ; return total_moves - king_moves ; } int main ( ) { int n = 8 , m = 8 ; int x = 1 , y = 1 ; cout << ( Moves_Calculator ( x , y , m , n ) ) ; return 0 ; }

Accumulator variables: king_moves, total_moves
C++ program:
#include <bits/stdc++.h>
using namespace std ; int clstNum ( int N ) { return ( N - 1 ) ; } int main ( ) { int N = 11 ; cout << clstNum ( N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int equvInverse ( int arr [ ] , int N , int P ) { int cntElem = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] * arr [ i ] ) % P == 1 ) { cntElem ++ ; } } return cntElem ; } int main ( ) { int arr [ ] = { 1 , 6 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int P = 7 ; cout << equvInverse ( arr , N , P ) ; }

Index/key variables: i
Accumulator variables: cntElem, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int K , int M ) { int res = 1 ; while ( M > 0 ) { if ( ( M & 1 ) == 1 ) { res = ( res * K ) ; } M = M >> 1 ; K = ( K * K ) ; } return res ; } int cntWays ( int arr [ ] , int N , int K ) { int cntways = 0 ; int M = 0 ; unordered_set < int > st ; for ( int i = 0 ; i < N ; i ++ ) { st . insert ( arr [ i ] ) ; } M = st . size ( ) ; cntways = power ( K , M ) ; return cntways ; } int main ( ) { int arr [ ] = { 2 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 2 ; cout << cntWays ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mod = 1e9 + 7 ; void minProduct ( int n ) { int ans = 1 ; for ( int i = 1 ; i <= ( n - 4 ) / 2 ; i ++ ) { ans = ( 1LL * ans * ( n - 2 ) ) % mod ; } ans = ( 1LL * ans * ( n - 2 ) * ( n - 1 ) ) % mod ; cout << ans << endl ; } int main ( ) { int N = 8 ; minProduct ( N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int TotalXorPair ( int arr [ ] , int N ) { int totalXOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { totalXOR ^= arr [ i ] ^ arr [ j ] ; } } return totalXOR ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << TotalXorPair ( arr , N ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, totalXOR
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void possibleAcyclicGraph ( int N ) { cout << pow ( 2 , N - 1 ) ; return ; } int main ( ) { int N = 4 ; possibleAcyclicGraph ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minProd ( int X , int Y , int N ) { if ( X <= Y ) { if ( N < X ) return ( X - N ) * Y ; else { return max ( Y - ( N - X + 1 ) , 1 ) ; } } if ( Y >= N ) return ( Y - N ) * X ; return max ( X - ( N - Y + 1 ) , 1 ) ; ; } int main ( ) { int X = 47 , Y = 42 , N = 167 ; cout << minProd ( X , Y , N ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int arr [ ] , int n ) { int oneCount = 0 ; int desiredPair = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) { oneCount ++ ; } if ( arr [ i ] == 0 ) { desiredPair += oneCount ; } } return desiredPair ; } int main ( ) { int arr [ ] = { 3 , 1 , 1 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: desiredPair, i, oneCount, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void smlstNonNeg ( int arr [ ] , int N ) { int smNonNeg = 0 ; bool hash [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= 0 and arr [ i ] < N ) { hash [ arr [ i ] ] = true ; } while ( hash [ smNonNeg ] ) { smNonNeg ++ ; } cout << smNonNeg << " ▁ " ; } } int main ( ) { int arr [ ] = { 0 , 1 , 2 , 3 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; smlstNonNeg ( arr , N ) ; }

Index/key variables: i, smNonNeg
Accumulator variables: i, smNonNeg, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( int arr [ ] , int N , int X ) { vector < int > A , B ; int c = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( 2 * arr [ i ] ) < X ) { A . push_back ( arr [ i ] ) ; } else if ( ( 2 * arr [ i ] ) > X ) { B . push_back ( arr [ i ] ) ; } else { if ( c % 2 == 0 ) { A . push_back ( arr [ i ] ) ; } else { B . push_back ( arr [ i ] ) ; } c ++ ; } } cout << " The ▁ First ▁ Array ▁ is ▁ - ▁ " ; for ( int i = 0 ; i < A . size ( ) ; i ++ ) { cout << A [ i ] << " ▁ " ; } cout << endl ; cout << " The ▁ Second ▁ Array ▁ is ▁ - ▁ " ; for ( int i = 0 ; i < B . size ( ) ; i ++ ) { cout << B [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , 5 , 4 , 3 , 6 , 2 , 4 , 3 } ; int X = 7 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; solve ( arr , N , X ) ; }

Index/key variables: i
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntMinSub ( int arr [ ] , int N , int K ) { int res = 0 ; int start = 0 ; int end = N - 1 ; sort ( arr , arr + N ) ; while ( end - start > 1 ) { if ( arr [ start ] + arr [ end ] <= K ) { start ++ ; } else { res ++ ; end -- ; } } if ( end - start == 1 ) { if ( arr [ start ] + arr [ end ] <= K ) { res ++ ; start ++ ; end -- ; } else { res ++ ; end -- ; } } if ( start == end ) { res ++ ; } return res ; } int main ( ) { int arr [ ] = { 2 , 6 , 8 , 10 , 20 , 25 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 26 ; cout << cntMinSub ( arr , N , K ) ; }

Index/key variables: end, start
Accumulator variables: end, res, start, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int condition ( int a , int b ) { int d = abs ( a - b ) , count = 0 ; for ( int i = 1 ; i <= sqrt ( d ) ; i ++ ) { if ( d % i == 0 ) { if ( d / i == i ) count += 1 ; else count += 2 ; } } return count ; } int main ( ) { int x = 2 , y = 6 ; cout << condition ( x , y ) << endl ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isComposite ( int N ) { for ( int i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { return true ; } } return false ; } int compositePair ( int arr [ ] , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { int prod = arr [ i ] * arr [ j ] ; if ( isComposite ( prod ) ) { res ++ ; } } } return res ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 2 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << compositePair ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int mod = 1e9 + 7 ; long long power ( int x , int y ) { if ( y == 0 ) return 1 ; long long int p = power ( x , y / 2 ) % mod ; p = ( p * p ) % mod ; if ( y & 1 ) { p = ( x * p ) % mod ; } return p ; } int TotalNumber ( int N ) { int ans = ( power ( 10 , N ) - 2 * power ( 9 , N ) + power ( 8 , N ) + 2 * mod ) % mod ; return ans ; } int main ( ) { int N = 10 , X = 3 , Y = 4 ; cout << TotalNumber ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateArray ( int arr [ ] , int n ) { deque < int > ans ; for ( int i = 0 ; i < n ; i ++ ) { if ( i & 1 ) ans . push_front ( arr [ i ] ) ; else ans . push_back ( arr [ i ] ) ; } if ( n & 1 ) { reverse ( ans . begin ( ) , ans . end ( ) ) ; } for ( auto x : ans ) { cout << x << " ▁ " ; } cout << endl ; } int32_t main ( ) { int n = 4 ; int arr [ n ] = { 1 , 2 , 3 , 4 } ; generateArray ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; string closestgtNum ( string str ) { string res = " " ; int n = str . length ( ) ; if ( str [ 0 ] < '9' ) { res . push_back ( str [ 0 ] + 1 ) ; } else { res . push_back ( '1' ) ; res . push_back ( '0' ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { res . push_back ( '0' ) ; } return res ; } int main ( ) { string str = "120" ; cout << closestgtNum ( str ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumSubarrays ( int arr [ ] , int N , int target ) { int ans = 0 ; int availIdx = -1 ; int cur_sum = 0 ; unordered_map < int , int > mp ; mp [ 0 ] = -1 ; for ( int i = 0 ; i < N ; i ++ ) { cur_sum += arr [ i ] ; if ( mp . find ( cur_sum - target ) != mp . end ( ) && mp [ cur_sum - target ] >= availIdx ) { ans ++ ; availIdx = i ; } mp [ cur_sum ] = i ; } return ans ; } int main ( ) { int arr [ ] = { 2 , -1 , 4 , 3 , 6 , 4 , 5 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int target = 6 ; cout << maximumSubarrays ( arr , N , target ) ; return 0 ; }

Index/key variables: cur_sum, i
Accumulator variables: ans, cur_sum, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int x , int y ) { int temp ; if ( y == 0 ) return 1 ; temp = power ( x , y / 2 ) ; if ( y % 2 == 0 ) return temp * temp ; else return x * temp * temp ; } void maximumPossibleSum ( int N , int X ) { cout << ( X * ( power ( 2 , N ) - 1 ) ) << endl ; } int main ( ) { int N = 3 , X = 5 ; maximumPossibleSum ( N , X ) ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int countOfPairs ( int x , int y ) { int counter = 1 ; while ( x y ) { int bit1 = x % 2 ; int bit2 = y % 2 ; x >>= 1 ; y >>= 1 ; if ( bit1 == 1 and bit2 == 0 ) { counter *= 2 ; continue ; } if ( bit1 & bit2 ) { counter = 0 ; break ; } } return counter ; } int main ( ) { int X = 2 , Y = 5 ; cout << countOfPairs ( X , Y ) ; return 0 ; }

Accumulator variables: counter
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 findGCD ( int arr [ ] , int N ) { int result = 0 ; for ( int i = 0 ; i < N ; i ++ ) { result = gcd ( result , arr [ i ] ) ; if ( result == 1 ) { return 1 ; } } return result ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findGCD ( 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 factorsOf3 ( int arr [ ] , int N ) { int a = 0 , b = 0 , c = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 3 == 0 ) a ++ ; else if ( arr [ i ] % 3 == 1 ) b ++ ; else if ( arr [ i ] % 3 == 2 ) c ++ ; } if ( a >= 1 && a <= b + c + 1 ) cout << " Yes " << endl ; else if ( a == 0 && b == 0 && c > 0 ) cout << " Yes " << endl ; else if ( a == 0 && c == 0 && b > 0 ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; factorsOf3 ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, b, c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check_digits ( long N ) { while ( N > 0 ) { int n = N % 10 ; if ( ( n != 0 ) && ( n != 1 ) && ( n != 4 ) && ( n != 9 ) ) { return 0 ; } N = N / 10 ; } return 1 ; } bool is_perfect ( long N ) { long double n = sqrt ( N ) ; if ( floor ( n ) != ceil ( n ) ) { return 0 ; } return 1 ; } void isFullSquare ( long N ) { if ( is_perfect ( N ) && check_digits ( N ) ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { long N = 144 ; isFullSquare ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstring ( string s , int n ) { map < char , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ s [ i ] ] ++ ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = 0 ; m [ s [ i ] ] -- ; for ( auto value : m ) { if ( value . first == s [ i ] ) { continue ; } else { cnt += value . second ; } } ans += cnt ; } cout << ans ; } int main ( ) { string S = " abcab " ; int N = 5 ; countSubstring ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, cnt, i, stdc
Iterator variables: i, value
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxBottles ( int n , int e ) { int s = 0 , b = 0 ; int a = n ; while ( a != 0 ) { s = s + a ; a = ( a + b ) / e ; b = n - ( a * e ) ; n = a + b ; } return s ; } int main ( ) { int n = 9 , e = 3 ; int s = maxBottles ( n , e ) ; cout << s << endl ; }

Accumulator variables: stdc
C++ program:
#include <stdio.h>
#define ll  long long
ll power ( ll x , ll n ) { ll temp ; if ( n == 0 ) return 1 ; temp = power ( x , n / 2 ) ; if ( n % 2 == 0 ) return temp * temp ; else return x * temp * temp ; } ll count_Total_Numbers ( ll n , ll x ) { ll total , multiples = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) { if ( i % x == 0 ) multiples ++ ; } if ( n == 1 ) return multiples ; total = ( multiples - 1 ) * power ( multiples , n - 1 ) ; return total ; } int main ( ) { ll N = 1 , X = 3 ; printf ( " % lld ▁ " , count_Total_Numbers ( N , X ) ) ; return 0 ; }

Accumulator variables: i, multiples
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getPosition ( int N , int M ) { if ( M > ( N / 2 ) ) { return ( M - ( N / 2 ) ) ; } return ( M + ( N / 2 ) ) ; } int main ( ) { int N = 8 , M = 5 ; cout << getPosition ( N , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void number_of_strings ( int N , int M ) { int ans = 0 ; while ( N > 0 && M > 0 ) { if ( N > M ) { if ( N >= 2 ) { N -= 2 ; -- M ; ++ ans ; } else { break ; } } else { if ( M >= 2 ) { M -= 2 ; -- N ; ++ ans ; } else { break ; } } } cout << ans ; } int main ( ) { int N = 4 , M = 19 ; number_of_strings ( N , M ) ; return 0 ; }

Accumulator variables: M, N, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minLength ( int A [ ] , int N ) { int elem = A [ 0 ] , count = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( A [ i ] == elem ) { count ++ ; } else { break ; } } if ( count == N ) return N ; else return 1 ; } int main ( ) { int arr [ ] = { 2 , 1 , 3 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minLength ( arr , N ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool NegEqu ( int N , int X , int Y ) { while ( X -- and N > N / 2 + 10 ) { N = N / 2 + 10 ; } while ( Y -- ) { N = N - 10 ; } if ( N <= 0 ) return true ; return false ; } int main ( ) { int N = 100 ; int X = 3 ; int Y = 4 ; if ( NegEqu ( N , X , Y ) ) { cout << " Yes " ; } else { cout << " No " ; } }

Accumulator variables: X, Y, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSubarrays ( int arr [ ] , int n ) { int right = n - 1 ; int left = 0 ; int subarrays = 0 ; while ( right >= 0 ) { for ( left = 0 ; left <= right ; left += 1 ) { if ( __gcd ( arr [ left ] , arr [ right ] ) > 1 ) { subarrays += 1 ; right = left - 1 ; break ; } if ( left == right && __gcd ( arr [ left ] , arr [ right ] ) == 1 ) { return 0 ; } } } return subarrays ; } int main ( ) { int N = 6 ; int arr [ ] = { 2 , 3 , 4 , 4 , 4 , 3 } ; cout << minSubarrays ( arr , N ) ; return 0 ; }

Index/key variables: left, right
Accumulator variables: left, stdc, subarrays
Iterator variables: left