dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  10
int countPalindromes ( int n , int m , int matrix [ MAX ] [ MAX ] ) { int count = n * m ; int length_of_sequence_row ; int length_of_sequence_column ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { length_of_sequence_row = min ( j , m - 1 - j ) ; length_of_sequence_column = min ( i , n - i - 1 ) ; for ( int k = 1 ; k <= length_of_sequence_row ; k ++ ) { if ( matrix [ i ] [ j - k ] == matrix [ i ] [ j + k ] ) { count ++ ; } else { break ; } } for ( int k = 1 ; k <= length_of_sequence_column ; k ++ ) { if ( matrix [ i - k ] [ j ] == matrix [ i + k ] [ j ] ) { count ++ ; } else { break ; } } } } return count ; } int main ( void ) { int m = 3 , n = 3 ; int matrix [ MAX ] [ MAX ] = { { 2 , 1 , 2 } , { 1 , 1 , 1 } , { 2 , 1 , 2 } } ; cout << countPalindromes ( n , m , matrix ) << endl ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: count, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int set_bits ( int n ) { int count = 0 ; while ( n ) { count += n % 2 ; n /= 2 ; } return count ; } int minSteps ( int n ) { int ans = 0 ; while ( n != 1 ) { if ( n % 2 == 0 ) n /= 2 ; else if ( n == 3 or set_bits ( n - 1 ) < set_bits ( n + 1 ) ) n -- ; else n ++ ; ans ++ ; } return ans ; } int main ( ) { int n = 15 ; cout << minSteps ( n ) ; return 0 ; }

Accumulator variables: ans, count, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumNo ( int n ) { int ans = 0 ; stack < int > stack1 ; stack < int > stack2 ; while ( n != 0 ) { int r = n % 10 ; if ( r % 2 == 0 ) { stack1 . push ( r ) ; } else { stack2 . push ( r ) ; } n = n / 10 ; } while ( ! stack1 . empty ( ) && ! stack2 . empty ( ) ) { if ( stack1 . top ( ) < stack2 . top ( ) ) { ans = ans * 10 + stack1 . top ( ) ; stack1 . pop ( ) ; } else { ans = ans * 10 + stack2 . top ( ) ; stack2 . pop ( ) ; } } while ( ! stack1 . empty ( ) ) { ans = ans * 10 + stack1 . top ( ) ; stack1 . pop ( ) ; } while ( ! stack2 . empty ( ) ) { ans = ans * 10 + stack2 . top ( ) ; stack2 . pop ( ) ; } return ans ; } int main ( ) { int n1 = 64432 ; cout << minimumNo ( n1 ) << endl ; int n2 = 3137 ; cout << minimumNo ( n2 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int power ( int a , int b ) { int result = 1 ; while ( b > 0 ) { if ( b % 2 == 1 ) { result = result * a ; } a = a * a ; b = b / 2 ; } return result ; } int factorial ( int n ) { int fact = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { fact = fact * i ; } return fact ; } void findNoOfArrays ( int * a , int n ) { int sum = 0 , s1 , c = 0 ; map < int , int > mp ; for ( int i = 0 ; i < 2 * n ; i ++ ) { mp [ a [ i ] ] ++ ; sum = sum + a [ i ] ; } bool isArrayPossible = true ; int ans = factorial ( n - 1 ) ; s1 = sum / ( n + 1 ) ; if ( mp [ s1 ] >= 2 ) { mp [ s1 ] = mp [ s1 ] - 2 ; } else { isArrayPossible = false ; } if ( isArrayPossible ) { for ( auto i : mp ) { if ( i . first == s1 - i . first ) { if ( mp [ i . first ] % 2 != 0 ) { isArrayPossible = false ; break ; } } if ( i . first != s1 - i . first ) { if ( mp [ i . first ] != mp [ s1 - i . first ] ) { isArrayPossible = false ; break ; } } if ( i . second > 0 ) { if ( i . first != s1 - i . first ) { c = c + i . second ; ans = ans * power ( 2 , i . second ) ; ans = ans / factorial ( i . second ) ; mp [ i . first ] = 0 ; mp [ s1 - i . first ] = 0 ; } if ( i . first == s1 - i . first ) { c = c + i . second / 2 ; ans = ans / factorial ( i . second / 2 ) ; mp [ i . first ] = 0 ; } } } } if ( c < n - 1 isArrayPossible == false ) { cout << "0" << endl ; } else { cout << ans << endl ; } } int main ( ) { int arr1 [ ] = { 5 , 2 , 3 , 5 } ; int n1 = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; findNoOfArrays ( arr1 , n1 / 2 ) ; int arr2 [ ] = { -1 , -1 , -1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 } ; int n2 = sizeof ( arr2 ) / sizeof ( arr2 [ 0 ] ) ; findNoOfArrays ( arr2 , n2 / 2 ) ; return 0 ; }

Index/key variables: i, s1
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: isArrayPossible
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lcm ( int a , int b ) { return ( a / __gcd ( a , b ) * b ) ; } void findNums ( int x ) { int ans ; for ( int i = 1 ; i <= sqrt ( x ) ; i ++ ) { if ( x % i == 0 && lcm ( i , x / i ) == x ) { ans = i ; } } cout << ans << " ▁ " << ( x / ans ) ; } int main ( ) { int x = 12 ; findNums ( x ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAXN  1000000
int maxCommonElement ( int A [ ] , int D [ ] , int N ) { int cnt [ MAXN ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = A [ i ] ; j < MAXN ; j += D [ i ] ) cnt [ j ] ++ ; } int com = max_element ( cnt , cnt + MAXN ) - cnt ; return com ; } int main ( ) { int A [ ] = { 13 , 1 , 2 , 5 } , D [ ] = { 5 , 10 , 1 , 12 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << maxCommonElement ( A , D , N ) ; return 0 ; }

Index/key variables: MAXN, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findTrailingZeros ( int n ) { if ( n & 1 ) return 0 ; else { int ans = 0 ; n /= 2 ; while ( n ) { ans += n / 5 ; n /= 5 ; } return ans ; } } int main ( ) { int n = 12 ; cout << findTrailingZeros ( n ) ; return 0 ; }

Accumulator variables: ans, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxGCD ( int N , int K ) { int minSum = ( K * ( K + 1 ) ) / 2 ; if ( N < minSum ) return -1 ; int i = sqrt ( N ) ; int res = 1 ; while ( i >= 1 ) { if ( N % i == 0 ) { if ( i >= minSum ) res = max ( res , N / i ) ; if ( N / i >= minSum ) res = max ( res , i ) ; } i -- ; } return res ; } int main ( ) { int N = 18 , K = 3 ; cout << maxGCD ( N , K ) ; return 0 ; }

Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double r1 , r2 , r3 ; double area ( double a , double b , double c ) { double p = ( a + b + c ) / 2 ; return sqrt ( p ) * sqrt ( p - a ) * sqrt ( p - b ) * sqrt ( p - c ) ; } double binary_search ( ) { double s = area ( r1 + r2 , r2 + r3 , r3 + r1 ) ; double l = 0 , h = s / ( r1 + r2 + r3 ) ; while ( h - l >= 1.e-7 ) { double mid = ( l + h ) / 2 ; double s1 = area ( mid + r1 , mid + r2 , r1 + r2 ) ; double s2 = area ( mid + r1 , mid + r3 , r1 + r3 ) ; double s3 = area ( mid + r2 , mid + r3 , r2 + r3 ) ; if ( s1 + s2 + s3 < s ) { l = mid ; } else { h = mid ; } } return ( l + h ) / 2 ; } int main ( ) { r1 = 1.0 ; r2 = 2.0 ; r3 = 3.0 ; cout << fixed << setprecision ( 6 ) << binary_search ( ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { double r1 , r2 , r3 ; r1 = 1 ; r2 = 2 ; r3 = 3 ; double r4 = ( r1 * r2 * r3 ) / ( r1 * r2 + r2 * r3 + r1 * r3 + 2.0 * sqrt ( r1 * r2 * r3 * ( r1 + r2 + r3 ) ) ) ; cout << fixed << setprecision ( 6 ) << r4 << ' ' ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkZeroArray ( int * arr , int n ) { int sum = 0 , maximum = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + arr [ i ] ; maximum = max ( maximum , arr [ i ] ) ; } if ( sum % 2 == 0 && maximum <= sum / 2 ) return true ; return false ; } int main ( ) { int arr [ ] = { 1 , 2 , 1 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( int ) ; if ( checkZeroArray ( arr , n ) ) 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 ; typedef long long int ll ; bool subArray ( ll * arr , ll n , ll m ) { ll i ; unordered_map < ll , ll > mp ; for ( i = 0 ; i < n ; i ++ ) { mp [ arr [ i ] ] = i + 1 ; } ll sumcur = 0 ; ll p = INT_MAX ; vector < ll > ans ; for ( i = 1 ; i <= m ; i ++ ) { sumcur += mp [ i ] ; p = min ( p , mp [ i ] ) ; ll val = p * i - i + ( i * ( i + 1 ) ) / 2 ; if ( i == m ) { if ( val == sumcur ) { return true ; } else return false ; } } } int main ( ) { ll arr [ ] = { 4 , 5 , 1 , 3 , 2 , 6 } ; int n = sizeof ( arr ) / sizeof ( int ) ; ll m = 3 ; if ( subArray ( arr , n , m ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sumcur
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string & s ) { int left = 0 , right = s . size ( ) - 1 ; while ( left <= right ) { if ( s [ left ] != s [ right ] ) { return false ; } left ++ ; right -- ; } return true ; } long long getSum ( int n ) { int start = pow ( 10 , n - 1 ) ; int end = pow ( 10 , n ) - 1 ; long long sum = 0 ; for ( int i = start ; i <= end ; i ++ ) { string s = to_string ( i ) ; if ( isPalindrome ( s ) ) { sum += i ; } } return sum ; } int main ( ) { int n = 1 ; long long ans = getSum ( n ) ; cout << ans << ' ' ; return 0 ; }

Index/key variables: left, right
Accumulator variables: i, left, right, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long double getSum ( int n ) { long double sum = 0 ; if ( n == 1 ) { sum = 45.0 ; } else { sum = ( 99.0 / 2.0 ) * pow ( 10 , n - 1 ) * pow ( 10 , ( n - 1 ) / 2 ) ; } return sum ; } int main ( ) { int n = 3 ; long double ans = getSum ( n ) ; cout << setprecision ( 12 ) << ans << ' ' ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; long countPairs ( int arr [ ] , int n ) { long count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] * arr [ j ] == arr [ i ] + arr [ j ] ) count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 2 , 0 , 3 , 2 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( arr , 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 ; long countPairs ( int arr [ ] , int n ) { int countZero = 0 ; int countTwo = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) countZero ++ ; else if ( arr [ i ] == 2 ) countTwo ++ ; } long pair0 = ( countZero * ( countZero - 1 ) ) / 2 ; long pair2 = ( countTwo * ( countTwo - 1 ) ) / 2 ; return pair0 + pair2 ; } int main ( ) { int arr [ ] = { 2 , 0 , 3 , 2 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: countTwo, countZero, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntSubSeq ( int arr [ ] , int n ) { int pos_count = 0 ; int neg_count = 0 ; int result ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) pos_count ++ ; if ( arr [ i ] < 0 ) neg_count ++ ; } result = pow ( 2 , pos_count ) ; if ( neg_count > 0 ) result *= pow ( 2 , neg_count - 1 ) ; result -= 1 ; return result ; } int main ( ) { int arr [ ] = { 2 , -3 , -1 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntSubSeq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, neg_count, pos_count, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMin ( int * arr , int n ) { int m = 0 ; for ( int i = 0 ; i < n ; i ++ ) m = max ( m , arr [ i ] ) ; int freq [ m + 2 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) freq [ arr [ i ] ] ++ ; for ( int i = 1 ; i <= m + 1 ; i ++ ) { int j = i ; int cnt = 0 ; while ( j <= m ) { cnt += freq [ j ] ; j += i ; } if ( ! cnt ) return i ; } return m + 1 ; } int main ( ) { int arr [ ] = { 2 , 12 , 6 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << findMin ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: cnt, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMin ( int * arr , int n ) { int m = 0 ; for ( int i = 0 ; i < n ; i ++ ) m = max ( m , arr [ i ] ) ; int cnt [ m + 2 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j * j <= arr [ i ] ; j ++ ) { if ( arr [ i ] % j == 0 ) { if ( j * j == arr [ i ] ) cnt [ j ] ++ ; else cnt [ j ] ++ , cnt [ arr [ i ] / j ] ++ ; } } } for ( int i = 1 ; i <= m + 1 ; i ++ ) if ( cnt [ i ] == 0 ) { return i ; } return -1 ; } int main ( ) { int arr [ ] = { 2 , 12 , 6 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << findMin ( 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 ; float findNumber ( int N , int S ) { float i = ( ( ( float ) ( N ) * ( float ) ( N + 1 ) ) / 4 ) - ( ( float ) ( S + 1 ) / 2 ) ; return i ; } void check ( int N , int S ) { float i = findNumber ( N , S ) ; int integerI = ( int ) i ; if ( i - integerI == 0 ) cout << " Yes : ▁ " << integerI << " , ▁ " << integerI + 1 << endl ; else cout << " No " << endl ; } int main ( ) { int N = 4 , S = 3 ; check ( N , S ) ; N = 5 , S = 3 ; check ( N , S ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int sz = 1e5 ; bool isPrime [ sz + 1 ] ; void sieve ( ) { memset ( isPrime , true , sizeof ( isPrime ) ) ; isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i * i <= sz ; i ++ ) { if ( isPrime [ i ] ) { for ( int j = i * i ; j < sz ; j += i ) { isPrime [ j ] = false ; } } } } void printArray ( int arr [ ] , int len ) { for ( int i = 0 ; i < len ; i ++ ) { cout << arr [ i ] << ' ▁ ' ; } } void removePrimes ( int arr [ ] , int len ) { sieve ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( isPrime [ arr [ i ] ] ) { for ( int j = i ; j < len ; j ++ ) { arr [ j ] = arr [ j + 1 ] ; } i -- ; len -- ; } } printArray ( arr , len ) ; } int main ( ) { int arr [ ] = { 4 , 6 , 5 , 3 , 8 , 7 , 10 , 11 , 14 , 15 } ; int len = sizeof ( arr ) / sizeof ( int ) ; removePrimes ( arr , len ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, len, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minOR ( int * arr , int n ) { if ( n == 1 ) return 0 ; int pre [ n ] , suf [ n ] ; pre [ 0 ] = arr [ 0 ] , suf [ n - 1 ] = arr [ n - 1 ] ; for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = ( pre [ i - 1 ] arr [ i ] ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) suf [ i ] = ( suf [ i + 1 ] arr [ i ] ) ; int ans = min ( pre [ n - 2 ] , suf [ 1 ] ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) ans = min ( ans , ( pre [ i - 1 ] suf [ i + 1 ] ) ) ; return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << minOR ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int x , int y ) { if ( ( x - y ) == 1 ) return false ; return true ; } int main ( ) { int x = 100 , y = 98 ; if ( isPossible ( x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int subgrids ( int N , int Z , int row [ ] , int col [ ] , int r , int c ) { vector < int > conrow ; vector < int > concol ; int K = sqrt ( Z ) ; conrow . push_back ( row [ 0 ] - 0 - 1 ) ; conrow . push_back ( N + 1 - row [ r - 1 ] - 1 ) ; for ( int i = 1 ; i < r ; i ++ ) { conrow . push_back ( row [ i ] - row [ i - 1 ] - 1 ) ; } concol . push_back ( col [ 0 ] - 0 - 1 ) ; concol . push_back ( N + 1 - col - 1 ) ; for ( int i = 1 ; i < c ; i ++ ) { concol . push_back ( col [ i ] - col [ i - 1 ] - 1 ) ; } int row_size = conrow . size ( ) ; int col_size = concol . size ( ) ; int answer = 0 ; for ( int i = 0 ; i < row_size ; i ++ ) { for ( int j = 0 ; j < col_size ; j ++ ) { int total = ( concol [ j ] / K ) * ( conrow [ i ] / K ) ; answer += ( total ) ; } } return answer ; } int main ( ) { int N = 8 , Z = 4 ; int row [ ] = { 4 , 6 } ; int col [ ] = { 3 , 8 } ; int r = sizeof ( row ) / sizeof ( row [ 0 ] ) ; int c = sizeof ( col ) / sizeof ( col [ 0 ] ) ; cout << subgrids ( N , Z , row , col , r , c ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: answer, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int n ) { int cnt = 0 ; while ( n > 0 ) { cnt ++ ; n /= 10 ; } return cnt ; } int digitPowSum ( int n ) { int sum = 0 ; int pw = countDigits ( n ) ; while ( n > 0 ) { int d = n % 10 ; sum += pow ( d , pw ) ; pw -- ; n /= 10 ; } return sum ; } int countNum ( int n ) { int count = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { if ( i == digitPowSum ( i ) ) { count ++ ; } } return count ; } int main ( ) { int n = 200 ; cout << countNum ( n ) ; return 0 ; }

Accumulator variables: cnt, count, i, n, pw, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void perfectSquares ( float l , float r ) { for ( int i = l ; i <= r ; i ++ ) { if ( sqrt ( i ) == ( int ) sqrt ( i ) ) cout << i << " ▁ " ; } } int main ( ) { int l = 2 , r = 24 ; perfectSquares ( l , r ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void perfectSquares ( float l , float r ) { int number = ceil ( sqrt ( l ) ) ; int n2 = number * number ; number = ( number * 2 ) + 1 ; while ( ( n2 >= l && n2 <= r ) ) { cout << n2 << " ▁ " ; n2 = n2 + number ; number += 2 ; } } int main ( ) { int l = 2 , r = 24 ; perfectSquares ( l , r ) ; return 0 ; }

Accumulator variables: number, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int xorK ( int n , int k ) { int res = n ; for ( int i = 1 ; i < k ; i ++ ) res = ( res ^ n ) ; return res ; } int main ( ) { int n = 123 , k = 3 ; cout << xorK ( n , k ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long int ll ; void findRemainders ( ll n ) { set < ll > vc ; for ( ll i = 1 ; i <= ceil ( sqrt ( n ) ) ; i ++ ) vc . insert ( n / i ) ; for ( ll i = n / ceil ( sqrt ( n ) ) - 1 ; i >= 0 ; i -- ) vc . insert ( i ) ; for ( auto it : vc ) cout << it << " ▁ " ; } int main ( ) { ll n = 5 ; findRemainders ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100005 ; bool prime [ MAX ] ; void SieveOfEratosthenes ( ) { memset ( prime , true , sizeof ( prime ) ) ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } } int countPrimes ( int n ) { SieveOfEratosthenes ( ) ; int cnt = 0 ; for ( int i = 2 ; i < n ; i ++ ) { if ( prime [ i ] && prime [ i - 2 ] ) cnt ++ ; } return cnt ; } int main ( ) { int n = 11 ; cout << countPrimes ( n ) ; return 0 ; }

Index/key variables: MAX, i, p
Accumulator variables: cnt, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_VALID_YR = 9999 ; const int MIN_VALID_YR = 1800 ; bool isLeap ( int year ) { return ( ( ( year % 4 == 0 ) && ( year % 100 != 0 ) ) || ( year % 400 == 0 ) ) ; } bool isValidDate ( int d , int m , int y ) { if ( y > MAX_VALID_YR y < MIN_VALID_YR ) return false ; if ( m < 1 m > 12 ) return false ; if ( d < 1 d > 31 ) return false ; if ( m == 2 ) { if ( isLeap ( y ) ) return ( d <= 29 ) ; else return ( d <= 28 ) ; } if ( m == 4 m == 6 m == 9 m == 11 ) return ( d <= 30 ) ; return true ; } void printPalindromeDates ( int y1 , int y2 ) { for ( int year = y1 ; year <= y2 ; year ++ ) { string str = to_string ( year ) ; string rev = str ; reverse ( rev . begin ( ) , rev . end ( ) ) ; int day = stoi ( rev . substr ( 0 , 2 ) ) ; int month = stoi ( rev . substr ( 2 , 2 ) ) ; if ( isValidDate ( day , month , year ) ) { cout << rev << str << endl ; } } } int main ( ) { int y1 = 2001 , y2 = 2005 ; printPalindromeDates ( y1 , y2 ) ; return 0 ; }

Accumulator variables: stdc, year
Iterator variables: year
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 10 ; bool distinctDigits ( int x ) { bool present [ MAX ] = { false } ; while ( x > 0 ) { int digit = x % 10 ; if ( present [ digit ] ) return false ; present [ digit ] = true ; x /= 10 ; } return true ; } int findK ( int l , int r ) { int maxExp = INT_MIN ; int k = -1 ; for ( int i = l ; i <= r ; i ++ ) { if ( distinctDigits ( i ) ) { int exp = ( l - i ) * ( i - r ) ; if ( exp >= maxExp ) { k = i ; maxExp = exp ; } } } return k ; } int main ( ) { int l = 50 , r = 60 ; cout << findK ( l , r ) ; return 0 ; }

Index/key variables: MAX, digit
Accumulator variables: i, stdc, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPerm ( int Q [ ] , int n ) { int minval = 0 , qsum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { qsum += Q [ i ] ; if ( qsum < minval ) minval = qsum ; } vector < int > P ( n ) ; P [ 0 ] = 1 - minval ; bool permFound = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) { P [ i + 1 ] = P [ i ] + Q [ i ] ; if ( P [ i + 1 ] > n P [ i + 1 ] < 1 ) { permFound = false ; break ; } } if ( permFound ) { for ( int i = 0 ; i < n ; i ++ ) { cout << P [ i ] << " ▁ " ; } } else { cout << -1 ; } } int main ( ) { int Q [ ] = { -2 , 1 } ; int n = 1 + ( sizeof ( Q ) / sizeof ( int ) ) ; findPerm ( Q , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, qsum, stdc
Iterator variables: i
Boolean variables: permFound
C++ program:
#include <bits/stdc++.h>
using namespace std ; string Hex ( int num ) { map < int , char > m ; char digit = '0' ; char c = ' a ' ; for ( int i = 0 ; i <= 15 ; i ++ ) { if ( i < 10 ) { m [ i ] = digit ++ ; } else { m [ i ] = c ++ ; } } string res = " " ; if ( ! num ) { return "0" ; } if ( num > 0 ) { while ( num ) { res = m [ num % 16 ] + res ; num /= 16 ; } } else { u_int n = num ; while ( n ) { res = m [ n % 16 ] + res ; n /= 16 ; } } return res ; } int main ( ) { int x = 134 , y = -1 , z = -234 ; cout << " Hexa ▁ representation ▁ for " << endl ; cout << x << " ▁ is ▁ " << Hex ( x ) << endl ; cout << y << " ▁ is ▁ " << Hex ( y ) << endl ; cout << z << " ▁ is ▁ " << Hex ( z ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: c, digit, i, n, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findWinner ( int n ) { if ( ( n - 1 ) % 6 == 0 ) { cout << " Second ▁ Player ▁ wins ▁ the ▁ game " ; } else { cout << " First ▁ Player ▁ wins ▁ the ▁ game " ; } } int main ( ) { int n = 7 ; findWinner ( n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
#define mod  (int)(1e9 + 7)
int factorial [ N ] , modinverse [ N ] ; int power ( int a , int m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( 1LL * a * a ) % mod ; else if ( m1 & 1 ) return ( 1LL * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } void factorialfun ( ) { factorial [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) factorial [ i ] = ( 1LL * factorial [ i - 1 ] * i ) % mod ; } void modinversefun ( ) { modinverse [ N - 1 ] = power ( factorial [ N - 1 ] , mod - 2 ) % mod ; for ( int i = N - 2 ; i >= 0 ; i -- ) modinverse [ i ] = ( 1LL * modinverse [ i + 1 ] * ( i + 1 ) ) % mod ; } int binomial ( int n , int r ) { if ( r > n ) return 0 ; int a = ( 1LL * factorial [ n ] * modinverse [ n - r ] ) % mod ; a = ( 1LL * a * modinverse [ r ] ) % mod ; return a ; } void arrange_balls ( int n , int k ) { factorialfun ( ) ; modinversefun ( ) ; for ( int i = 1 ; i <= k ; i ++ ) cout << ( 1LL * binomial ( n - k + 1 , i ) * binomial ( k - 1 , i - 1 ) ) % mod << " ▁ " ; } int main ( ) { int n = 5 , k = 3 ; arrange_balls ( n , k ) ; return 0 ; }

Index/key variables: N, i, n, r
Accumulator variables: i, stdc
Iterator variables: i