dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int no_of_ways ( int a [ ] , int n ) { int count_0 = 0 , count_1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) count_0 ++ ; else count_1 ++ ; } if ( count_1 % 2 == 0 ) return count_0 ; else return count_1 ; } int main ( ) { int n = 4 ; int a1 [ 4 ] = { 1 , 1 , 0 , 0 } ; cout << no_of_ways ( a1 , n ) << endl ; n = 5 ; int a2 [ 5 ] = { 1 , 1 , 1 , 0 , 0 } ; cout << no_of_ways ( a2 , n ) << endl ; n = 5 ; int a3 [ 5 ] = { 1 , 1 , 0 , 0 , 0 } ; cout << no_of_ways ( a3 , n ) << endl ; n = 6 ; int a4 [ 6 ] = { 1 , 1 , 1 , 0 , 0 , 0 } ; cout << no_of_ways ( a4 , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count_0, count_1, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int prevPowerof2 ( int n ) { int p = ( int ) log2 ( n ) ; return ( int ) pow ( 2 , p ) ; } int nextPowerOf2 ( int n ) { int p = 1 ; if ( n && ! ( n & ( n - 1 ) ) ) return n ; while ( p < n ) p <<= 1 ; return p ; } int minDiff ( int n ) { int low = prevPowerof2 ( n ) ; int high = nextPowerOf2 ( n ) ; return min ( n - low , high - n ) ; } int main ( ) { int n = 6 ; cout << minDiff ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string maxInt ( string str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] < '5' ) { str [ i ] = ( '9' - str [ i ] ) + '0' ; } } if ( str [ 0 ] == '0' ) str [ 0 ] = '9' ; return str ; } int main ( ) { string str = "42" ; cout << maxInt ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void FindRatio ( int a , int b , int c ) { int up = abs ( b - c ) ; int down = abs ( c - a ) ; int g = __gcd ( up , down ) ; up /= g ; down /= g ; cout << up << " : " << down << " STRNEWLINE " ; } int main ( ) { int a = 4 , b = 10 , c = 6 ; FindRatio ( a , b , c ) ; return 0 ; }

Accumulator variables: down, stdc, up
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longest_gap ( int N ) { int distance = 0 , count = 0 , first_1 = -1 , last_1 = -1 ; while ( N ) { count ++ ; int r = N & 1 ; if ( r == 1 ) { first_1 = first_1 == -1 ? count : first_1 ; last_1 = count ; } N = N / 2 ; } if ( last_1 <= first_1 ) { return -1 ; } else { distance = ( last_1 - first_1 - 1 ) ; return distance ; } } int main ( ) { int N = 131 ; cout << longest_gap ( N ) << endl ; N = 8 ; cout << longest_gap ( N ) << endl ; N = 17 ; cout << longest_gap ( N ) << endl ; N = 33 ; cout << longest_gap ( N ) << endl ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int x , int y , int k ) { int minMoves = abs ( x ) + abs ( y ) ; if ( k >= minMoves && ( k - minMoves ) % 2 == 0 ) return true ; return false ; } int main ( ) { int x = 5 , y = 8 , k = 20 ; if ( isPossible ( x , y , k ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  10
bool isFactorion ( int n ) { int fact [ MAX ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i < MAX ; i ++ ) fact [ i ] = i * fact [ i - 1 ] ; int org = n ; int sum = 0 ; while ( n > 0 ) { int d = n % 10 ; sum += fact [ d ] ; n /= 10 ; } if ( sum == org ) return true ; return false ; } int main ( ) { int n = 40585 ; if ( isFactorion ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: MAX, d, i
Accumulator variables: i, n, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int TOTAL_BITS = 32 ; bool isPossible ( int n ) { int cnt = __builtin_popcount ( n ) ; if ( cnt == TOTAL_BITS / 2 ) return true ; return false ; } int main ( ) { int n = 524280 ; if ( isPossible ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int TEN = 10 ; void updateFreq ( int n , int freq [ ] ) { while ( n ) { int digit = n % TEN ; freq [ digit ] ++ ; n /= TEN ; } } bool areAnagrams ( int a , int b ) { int freqA [ TEN ] = { 0 } ; int freqB [ TEN ] = { 0 } ; updateFreq ( a , freqA ) ; updateFreq ( b , freqB ) ; for ( int i = 0 ; i < TEN ; i ++ ) { if ( freqA [ i ] != freqB [ i ] ) return false ; } return true ; } int main ( ) { int a = 240 , b = 204 ; if ( areAnagrams ( a , b ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: TEN, digit, i
Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Max_Sum ( int n ) { return ( n * ( n - 1 ) ) / 2 ; } int main ( ) { int n = 8 ; cout << Max_Sum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long gcd ( long a , long b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } long divTermCount ( long a , long b , long c , long num ) { return ( ( num / a ) + ( num / b ) + ( num / c ) - ( num / ( ( a * b ) / gcd ( a , b ) ) ) - ( num / ( ( c * b ) / gcd ( c , b ) ) ) - ( num / ( ( a * c ) / gcd ( a , c ) ) ) + ( num / ( ( a * b * c ) / gcd ( gcd ( a , b ) , c ) ) ) ) ; } int main ( ) { long a = 7 , b = 3 , c = 5 , n = 100 ; cout << divTermCount ( a , b , c , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < long > getArray ( int n ) { vector < long > ans ; long p2 = 1 ; while ( n > 0 ) { if ( n & 1 ) ans . push_back ( p2 ) ; n >>= 1 ; p2 *= 2 ; } return ans ; } int main ( ) { long n = 15 ; vector < long > ans = getArray ( n ) ; for ( int i : ans ) cout << i << " ▁ " ; return 0 ; }

Accumulator variables: p2, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int M = 3 , N = 2 ; void getIndex ( int n , int shuffle [ ] [ N ] ) { for ( int i = 0 ; i < 3 ; i ++ ) { if ( shuffle [ i ] [ 0 ] == n ) n = shuffle [ i ] [ 1 ] ; else if ( shuffle [ i ] [ 1 ] == n ) n = shuffle [ i ] [ 0 ] ; } cout << n ; } int main ( ) { int n = 3 ; int shuffle [ M ] [ N ] = { { 3 , 1 } , { 2 , 1 } , { 1 , 2 } } ; getIndex ( n , shuffle ) ; }

Index/key variables: M, N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long fact ( int n ) { long long res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } long long nCr ( int n , int r ) { return fact ( n ) / ( 1LL * fact ( r ) * fact ( n - r ) ) ; } long long number_of_subsequences ( int arr [ ] , int k , int n ) { long long s = 0 ; map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) { m [ arr [ i ] ] ++ ; } for ( auto j : m ) { s = s + 1LL * nCr ( j . second , k ) ; } return s ; } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 1 , 2 , 2 , 2 } ; int k = 2 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << number_of_subsequences ( arr , k , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumPairs ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ( arr [ i ] * ( 2 * n ) ) ; } return sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << sumPairs ( 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 minSum ( int arr [ ] , int n ) { int sum = 0 ; sort ( arr , arr + n , greater < int > ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 4 < 2 ) sum = sum + arr [ i ] ; } return sum ; } int main ( ) { int arr [ ] = { 1 , 1 , 10 , 2 , 2 , 2 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minSum ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long countTriplets ( int A , int B , int C ) { long long ans = 0 ; for ( int i = 1 ; i <= A ; i ++ ) { for ( int j = 1 ; j <= B ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { if ( i * k > j * j ) ans ++ ; } } } return ans ; } int main ( ) { int A , B , C ; A = 3 , B = 2 , C = 2 ; cout << countTriplets ( A , B , C ) ; }

Accumulator variables: ans, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long getCount ( int A , int B2 , int C ) { long long count = 0 ; for ( int i = 1 ; i <= A ; i ++ ) { long long j = ( B2 / i ) + 1 ; if ( C >= j ) count = ( count + C - j + 1 ) ; if ( A >= j && C >= i ) count = ( count + ( C - i + 1 ) * ( A - j + 1 ) ) ; if ( A >= j ) A = j - 1 ; } return count ; } long long countTriplets ( int A , int B , int C ) { long long ans = 0 ; for ( int i = 1 ; i <= B ; i ++ ) { ans = ( ans + getCount ( A , i * i , C ) ) ; } return ans ; } int main ( ) { int A , B , C ; A = 3 , B = 2 , C = 2 ; cout << countTriplets ( A , B , C ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int getSum ( int n ) { long long int sum = 0 ; int k = sqrt ( n ) ; for ( int i = 1 ; i <= k ; i ++ ) { sum += floor ( n / i ) ; } sum *= 2 ; sum -= pow ( k , 2 ) ; return sum ; } int main ( ) { int n = 5 ; cout << getSum ( n ) ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int distinctRemainders ( int n ) { if ( n % 2 == 0 ) return ( n / 2 ) ; return ( 1 + ( n / 2 ) ) ; } int main ( ) { int n = 5 ; cout << distinctRemainders ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countUnsetBits ( int n ) { int cnt = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int temp = i ; while ( temp ) { if ( temp % 2 == 0 ) cnt ++ ; temp = temp / 2 ; } } return cnt ; } int main ( ) { int n = 5 ; cout << countUnsetBits ( n ) ; return 0 ; }

Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool graphExists ( vector < int > & a , int n ) { while ( 1 ) { sort ( a . begin ( ) , a . end ( ) , greater < > ( ) ) ; if ( a [ 0 ] == 0 ) return true ; int v = a [ 0 ] ; a . erase ( a . begin ( ) + 0 ) ; if ( v > a . size ( ) ) return false ; for ( int i = 0 ; i < v ; i ++ ) { a [ i ] -- ; if ( a [ i ] < 0 ) return false ; } } } int main ( ) { vector < int > a = { 3 , 3 , 3 , 3 } ; int n = a . size ( ) ; graphExists ( a , n ) ? cout << " Yes " : cout << " NO " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int negProdSubArr ( int arr [ ] , int n ) { int positive = 1 , negative = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) arr [ i ] = 1 ; else arr [ i ] = -1 ; if ( i > 0 ) arr [ i ] *= arr [ i - 1 ] ; if ( arr [ i ] == 1 ) positive ++ ; else negative ++ ; } return ( positive * negative ) ; } int main ( ) { int arr [ ] = { 5 , -4 , -3 , 2 , -5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << negProdSubArr ( arr , n ) ; return ( 0 ) ; }

Index/key variables: i
Accumulator variables: i, negative, positive, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int sum ( int n ) { int sum = ( n * ( n + 1 ) ) / 2 ; return sum ; } int repeatedSum ( int n , int k ) { for ( int i = 0 ; i < k ; i ++ ) { n = sum ( n ) ; } return n ; } int main ( ) { int n = 2 , k = 2 ; cout << repeatedSum ( n , k ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int difference ( int n ) { int S , res ; S = ( n * ( n + 1 ) ) / 2 ; res = S * ( S - 1 ) ; return res ; } int main ( ) { int n = 5 ; cout << difference ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDivisible ( long long int n ) { long long int temp = n ; int sum = 0 ; while ( n ) { int digit = n % 10 ; sum += digit ; n /= 10 ; } n = temp ; while ( n ) { int digit = n % 10 ; if ( sum % digit != 0 ) return false ; n /= 10 ; } return true ; } int main ( ) { long long int n = 123 ; if ( isDivisible ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: n, stdc, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
int lpf [ N ] ; void least_prime_factor ( ) { for ( int i = 2 ; i < N ; i ++ ) if ( ! lpf [ i ] ) for ( int j = i ; j < N ; j += i ) if ( ! lpf [ j ] ) lpf [ j ] = i ; } void Mobius ( int n ) { int mobius [ N ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( i == 1 ) mobius [ i ] = 1 ; else { if ( lpf [ i / lpf [ i ] ] == lpf [ i ] ) mobius [ i ] = 0 ; else mobius [ i ] = -1 * mobius [ i / lpf [ i ] ] ; } } for ( int i = 1 ; i <= n ; i ++ ) cout << mobius [ i ] << " ▁ " ; } int main ( ) { int n = 5 ; least_prime_factor ( ) ; Mobius ( n ) ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int DIGITS = 4 , MIN = 1000 , MAX = 9999 ; int getBest ( int prev , int cur ) { int maximum = max ( MIN , prev ) ; for ( int i = maximum ; i <= MAX ; i ++ ) { int cnt = 0 ; int a = i ; int b = cur ; for ( int k = 0 ; k < DIGITS ; k ++ ) { if ( a % 10 != b % 10 ) cnt += 1 ; a /= 10 ; b /= 10 ; } if ( cnt <= 1 ) return i ; } return -1 ; } void getList ( int arr [ ] , int n ) { vector < int > myList ; int i , cur ; bool possible = true ; myList . push_back ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) { cur = arr [ i ] ; myList . push_back ( getBest ( myList . back ( ) , cur ) ) ; if ( myList . back ( ) == -1 ) { possible = false ; break ; } } if ( possible ) { for ( i = 1 ; i < myList . size ( ) ; i ++ ) cout << myList [ i ] << " ▁ " ; } else cout << " - 1" ; } int main ( ) { int arr [ ] = { 1095 , 1094 , 1095 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; getList ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, b, cnt, i, k, stdc
Iterator variables: i, k
Boolean variables: possible
C++ program:
#include <iostream>
using namespace std ; int countFactors ( int n , int p ) { int pwr = 0 ; while ( n > 0 && n % p == 0 ) { n /= p ; pwr ++ ; } return pwr ; } int getCount ( int l , int r , int p ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { cnt += countFactors ( i , p ) ; } return cnt ; } int main ( ) { int l = 2 , r = 8 , p = 2 ; cout << getCount ( l , r , p ) ; return 0 ; }

Accumulator variables: cnt, i, n, pwr
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int getCount ( int l , int r , int p ) { int cnt = 0 ; int val = p ; while ( 1 ) { int a = r / val ; int b = ( l - 1 ) / val ; val *= p ; if ( a - b ) { cnt += ( a - b ) ; } else break ; } return cnt ; } int main ( ) { int l = 2 , r = 8 , p = 2 ; cout << getCount ( l , r , p ) ; return 0 ; }

Accumulator variables: cnt, val
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool topsyTurvy ( string str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == '2' str [ i ] == '4' str [ i ] == '5' str [ i ] == '6' str [ i ] == '7' str [ i ] == '9' ) { return false ; } } return true ; } int main ( ) { string str = "1234" ; if ( topsyTurvy ( str ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

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

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; #define MAX  1000001
int countNum ( int N , int K ) { int sumPF [ MAX ] = { 0 } ; for ( int i = 2 ; i < N ; i ++ ) { if ( sumPF [ i ] == 0 ) { for ( int j = i ; j < N ; j += i ) { sumPF [ j ] += i ; } } } int count = 0 ; for ( int i = 2 ; i < N ; i ++ ) { if ( sumPF [ i ] == K ) count ++ ; } return count ; } int main ( ) { int N = 20 , K = 7 ; cout << countNum ( N , K ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100000
bool prime [ MAX + 1 ] ; void SieveOfEratosthenes ( ) { memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= MAX ; i += p ) prime [ i ] = false ; } } } int smallestPrime ( int d ) { int l = pow ( 10 , d - 1 ) ; int r = pow ( 10 , d ) - 1 ; for ( int i = l ; i <= r ; i ++ ) { if ( prime [ i ] ) { return i ; } } return -1 ; } int largestPrime ( int d ) { int l = pow ( 10 , d - 1 ) ; int r = pow ( 10 , d ) - 1 ; for ( int i = r ; i >= l ; i -- ) { if ( prime [ i ] ) { return i ; } } return -1 ; } int main ( ) { SieveOfEratosthenes ( ) ; int queries [ ] = { 2 , 5 } ; int q = sizeof ( queries ) / sizeof ( queries [ 0 ] ) ; for ( int i = 0 ; i < q ; i ++ ) { cout << smallestPrime ( queries [ i ] ) << " ▁ " << largestPrime ( queries [ i ] ) << endl ; } return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMatrix ( int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) cout << k << " ▁ " ; else cout << "0 ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { int n = 3 , k = 7 ; printMatrix ( n , k ) ; return ( 0 ) ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int findNthNumber ( int A , int B , int N ) { int sum = 0 ; for ( int i = 2 ; i < N ; i ++ ) { sum = A + B ; A = B ; B = sum ; } return sum ; } int main ( ) { int A = 5 , B = 7 , N = 10 ; cout << findNthNumber ( A , B , N ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkType ( int arr [ ] , int n ) { if ( arr [ 0 ] <= arr [ 1 ] && arr [ n - 2 ] <= arr [ n - 1 ] ) cout << " Increasing " ; else if ( arr [ 0 ] >= arr [ 1 ] && arr [ n - 2 ] >= arr [ n - 1 ] ) cout << " Decreasing " ; else if ( arr [ 0 ] <= arr [ 1 ] && arr [ n - 2 ] >= arr [ n - 1 ] ) cout << " Increasing ▁ then ▁ decreasing " ; else cout << " Decreasing ▁ then ▁ increasing " ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; checkType ( arr , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int arr [ ] , int p , int n , int m ) { int sum = 0 ; for ( int i = 0 ; i < p ; i ++ ) sum += arr [ i ] ; if ( sum == ( n * m ) ) return true ; return false ; } int main ( ) { int n = 3 , m = 4 ; int arr [ ] = { 6 , 3 , 2 , 1 } ; int p = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isPossible ( arr , p , n , m ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinStep ( int a [ ] , int n ) { int positive = 0 , negative = 0 , zero = 0 ; int step = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { zero ++ ; } else if ( a [ i ] < 0 ) { negative ++ ; step = step + ( -1 - a [ i ] ) ; } else { positive ++ ; step = step + ( a [ i ] - 1 ) ; } } if ( negative % 2 == 0 ) { step = step + zero ; } else { if ( zero > 0 ) { step = step + zero ; } else { step = step + 2 ; } } return step ; } int main ( ) { int a [ ] = { 0 , -2 , -1 , -3 , 4 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << MinStep ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, negative, positive, stdc, zero
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum ( int n ) { int sum = 0 ; while ( n ) { sum = sum + n % 10 ; n = n / 10 ; } return sum ; } void firstN ( int n ) { int num = 19 , cnt = 1 ; while ( cnt != n ) { if ( sum ( num ) == 10 ) { cout << num << " ▁ " ; cnt ++ ; } num += 9 ; } } int main ( ) { int n = 10 ; firstN ( n ) ; return 0 ; }

Accumulator variables: cnt, num, stdc
C++ program:
#include <iostream>
using namespace std ; #define long  long long
long sumOfLastDig ( long n , long m ) { long sum = 0 , k ; k = n / m ; long arr [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { arr [ i ] = m * ( i + 1 ) % 10 ; sum += arr [ i ] ; } long rem = k % 10 ; long ans = ( k / 10 ) * sum ; for ( int i = 0 ; i < rem ; i ++ ) { ans += arr [ i ] ; } return ans ; } int main ( ) { long n = 100 , m = 3 ; cout << sumOfLastDig ( n , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; pair < int , int > countSum ( int arr [ ] , int n ) { int NumberOfOdds = 0 , NumberOfEvens = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] & 1 ) NumberOfOdds ++ ; NumberOfEvens = n - NumberOfOdds ; int NumberOfOddSubsequences = ( 1 << NumberOfEvens ) * ( 1 << ( NumberOfOdds - 1 ) ) ; int NumberOfEvenSubsequences = ( 1 << n ) - 1 - NumberOfOddSubsequences ; return { NumberOfEvenSubsequences , NumberOfOddSubsequences } ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; pair < int , int > ans = countSum ( arr , n ) ; cout << " EvenSum ▁ = ▁ " << ans . first ; cout << " ▁ OddSum ▁ = ▁ " << ans . second ; return 0 ; }

Index/key variables: i
Accumulator variables: NumberOfOdds, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } int nextPrime ( int N ) { if ( N <= 1 ) return 2 ; int prime = N ; bool found = false ; while ( ! found ) { prime ++ ; if ( isPrime ( prime ) ) found = true ; } return prime ; } int main ( ) { int N = 3 ; cout << nextPrime ( N ) ; return 0 ; }

Accumulator variables: prime, stdc
Iterator variables: i
Boolean variables: found
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool Survives ( int n ) { int i ; for ( int i = 2 ; ; i ++ ) { if ( i > n ) return true ; if ( n % i == 0 ) return false ; n -= n / i ; } } int main ( ) { int n = 17 ; if ( Survives ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthXorFib ( int n , int a , int b ) { if ( n == 0 ) return a ; if ( n == 1 ) return b ; if ( n == 2 ) return ( a ^ b ) ; return nthXorFib ( n % 3 , a , b ) ; } int main ( ) { int a = 1 , b = 2 , n = 10 ; cout << nthXorFib ( n , a , b ) ; return 0 ; }

Accumulator variables: stdc
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 flip ( int a , int b ) { int lcm = ( a * b ) / gcd ( a , b ) ; a = lcm / a ; b = lcm / b ; cout << a - 1 << " ▁ " << b - 1 ; } int main ( ) { int a = 10 ; int b = 5 ; flip ( a , b ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_Solution ( double x , int n ) { double sum = x , e = 2 , o = 1 , p = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { p += 2 ; sum += ( double ) ( o / e ) * ( double ) ( pow ( x , p ) / p ) ; o = o * ( o + 2 ) ; e = e * ( e + 2 ) ; } cout << setprecision ( 10 ) << sum ; } int main ( ) { double x = -0.5 ; if ( abs ( x ) >= 1 ) { cout << " Invalid ▁ Input STRNEWLINE " ; return 0 ; } int n = 8 ; find_Solution ( x , n ) ; return 0 ; }

Accumulator variables: i, p, stdc, sum
Iterator variables: i