dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int pref [ 100001 ] = { 0 } ; static int checkArmstrong ( int x ) { int n = to_string ( x ) . size ( ) ; int sum1 = 0 ; int temp = x ; while ( temp > 0 ) { int digit = temp % 10 ; sum1 += pow ( digit , n ) ; temp /= 10 ; } if ( sum1 == x ) return x ; return 0 ; } void preCompute ( ) { for ( int i = 1 ; i < 100001 ; i ++ ) { pref [ i ] = pref [ i - 1 ] + checkArmstrong ( i ) ; } } void printSum ( int L , int R ) { cout << ( pref [ R ] - pref [ L - 1 ] ) << endl ; } void printSumarmstrong ( int arr [ 2 ] [ 2 ] , int Q ) { preCompute ( ) ; for ( int i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } } int main ( ) { int Q = 2 ; int arr [ 2 ] [ 2 ] = { { 1 , 13 } , { 121 , 211 } } ; printSumarmstrong ( arr , Q ) ; return 0 ; }

Index/key variables: R, i
Accumulator variables: i, stdc, sum1, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int prime [ 100001 ] = { 0 } ; int k [ 100001 ] = { 0 } ; void Sieve ( ) { for ( int i = 1 ; i < 100001 ; i ++ ) k [ i ] = i ; for ( int i = 2 ; i < 100001 ; i ++ ) { if ( prime [ i ] == 0 ) for ( int j = i ; j < 100001 ; j += i ) { prime [ j ] = 1 ; while ( k [ j ] % ( i * i ) == 0 ) k [ j ] /= ( i * i ) ; } } } int countPairs ( int arr [ ] , int n ) { unordered_map < int , int > freq ; for ( int i = 0 ; i < n ; i ++ ) { freq [ k [ arr [ i ] ] ] ++ ; } int sum = 0 ; for ( auto i : freq ) { sum += ( ( i . second - 1 ) * i . second ) / 2 ; } return sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 8 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( int ) ; Sieve ( ) ; cout << countPairs ( arr , n ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define ll  int
using namespace std ; long long pref [ 100010 ] ; int isPerfectCube ( long long int x ) { long double cr = round ( cbrt ( x ) ) ; return ( cr * cr * cr == x ) ? x : 0 ; } void compute ( ) { for ( int i = 1 ; i <= 100000 ; ++ i ) { pref [ i ] = pref [ i - 1 ] + isPerfectCube ( i ) ; } } void printSum ( int L , int R ) { int sum = pref [ R ] - pref [ L - 1 ] ; cout << sum << " ▁ " ; } int main ( ) { compute ( ) ; int Q = 4 ; int arr [ ] [ 2 ] = { { 1 , 10 } , { 1 , 100 } , { 2 , 25 } , { 4 , 50 } } ; for ( int i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } return 0 ; }

Index/key variables: R, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int C [ n + 1 ] [ k + 1 ] ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } int count ( int n , int k ) { int sum = 0 ; for ( int j = 1 ; j <= k ; j ++ ) { sum = sum + binomialCoeff ( n , j ) ; } return sum ; } int main ( ) { int n = 3 , k = 2 ; cout << count ( n , k ) ; n = 5 , k = 2 ; cout << count ( n , k ) ; return 0 ; }

Index/key variables: i, j, k, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; struct node { int data ; struct node * left ; struct node * right ; } ; bool isIsomorphic ( node * n1 , node * n2 ) { if ( n1 == NULL && n2 == NULL ) return true ; if ( n1 == NULL n2 == NULL ) return false ; if ( n1 -> data != n2 -> data ) return false ; return ( isIsomorphic ( n1 -> left , n2 -> left ) && isIsomorphic ( n1 -> right , n2 -> right ) ) || ( isIsomorphic ( n1 -> left , n2 -> right ) && isIsomorphic ( n1 -> right , n2 -> left ) ) ; } node * newNode ( int data ) { node * temp = new node ; temp -> data = data ; temp -> left = NULL ; temp -> right = NULL ; return ( temp ) ; } int main ( ) { struct node * n1 = newNode ( 1 ) ; n1 -> left = newNode ( 2 ) ; n1 -> right = newNode ( 3 ) ; n1 -> left -> left = newNode ( 4 ) ; n1 -> left -> right = newNode ( 5 ) ; n1 -> right -> left = newNode ( 6 ) ; n1 -> left -> right -> left = newNode ( 7 ) ; n1 -> left -> right -> right = newNode ( 8 ) ; struct node * n2 = newNode ( 1 ) ; n2 -> left = newNode ( 3 ) ; n2 -> right = newNode ( 2 ) ; n2 -> right -> left = newNode ( 4 ) ; n2 -> right -> right = newNode ( 5 ) ; n2 -> left -> right = newNode ( 6 ) ; n2 -> right -> right -> left = newNode ( 8 ) ; n2 -> right -> right -> right = newNode ( 7 ) ; if ( isIsomorphic ( n1 , n2 ) == true ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findNumber ( int s , int d ) { string num = " " ; int val = s / d ; int rem = s % d ; int i ; for ( i = 1 ; i <= d - rem ; i ++ ) { num = num + to_string ( val ) ; } if ( rem ) { val ++ ; for ( i = d - rem + 1 ; i <= d ; i ++ ) { num = num + to_string ( val ) ; } } return num ; } int main ( ) { int s = 25 , d = 4 ; cout << findNumber ( s , d ) ; return 0 ; }

Accumulator variables: i, stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
ll kthSmallest ( ll a , ll k ) { ll res = 0 ; ll j = 0 ; for ( ll i = 0 ; i < 32 ; i ++ ) { while ( j < 32 && ( a & ( 1 << j ) ) ) j ++ ; if ( k & ( 1 << i ) ) res |= ( 1LL << j ) ; j ++ ; } return res ; } int main ( ) { ll a = 10 , k = 3 ; cout << kthSmallest ( a , k ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: i, j, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fastmod ( int base , int exp , int mod ) { if ( exp == 0 ) return 1 ; else if ( exp % 2 == 0 ) { int ans = fastmod ( base , exp / 2 , mod ) ; return ( ans % mod * ans % mod ) % mod ; } else return ( fastmod ( base , exp - 1 , mod ) % mod * base % mod ) % mod ; } int findPowerSum ( int n , int ar [ ] ) { const int mod = 1e9 + 7 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int base = __builtin_popcount ( ar [ i ] ) ; int exp = ar [ i ] ; sum += fastmod ( base , exp , mod ) ; sum %= mod ; } return sum ; } int main ( ) { int n = 3 ; int ar [ ] = { 1 , 2 , 3 } ; cout << findPowerSum ( n , ar ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CountTriangles ( int n ) { int curr = 1 ; int Tri_count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { Tri_count = ( curr * 3 ) + 2 ; curr = Tri_count ; } return Tri_count ; } int main ( ) { int n = 10 ; cout << CountTriangles ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numSeq ( int n ) { return ( pow ( 3 , n ) + 3 * pow ( -1 , n ) ) / 4 ; } int main ( ) { int N = 10 ; printf ( " % d " , numSeq ( N ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sub_arrays ( int a [ ] , int n , int k ) { int sum [ n + 2 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] -- ; a [ i ] %= k ; sum [ i + 1 ] += sum [ i ] + a [ i ] ; sum [ i + 1 ] %= k ; } int ans = 0 , l = 0 , r = 0 ; map < int , int > mp ; for ( int i = 0 ; i < n + 1 ; i ++ ) { ans += mp [ sum [ i ] ] ; mp [ sum [ i ] ] ++ ; r ++ ; if ( r - l >= k ) { mp [ sum [ l ] ] -- ; l ++ ; } } return ans ; } int main ( ) { int a [ ] = { 1 , 4 , 2 , 3 , 5 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int k = 4 ; cout << sub_arrays ( a , n , k ) ; return 0 ; }

Index/key variables: i, l
Accumulator variables: ans, i, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sieve ( bool prime [ ] , int n ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } int sumPrime ( int d ) { int maxVal = pow ( 2 , d ) - 1 ; bool prime [ maxVal + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; sieve ( prime , maxVal ) ; int sum = 0 ; for ( int i = 2 ; i <= maxVal ; i ++ ) { if ( prime [ i ] ) { sum += i ; } } return sum ; } int main ( ) { int d = 8 ; cout << sumPrime ( d ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc, sum
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int arr [ ] , int n , int p ) { int gcd = 0 ; for ( int i = 0 ; i < n ; i ++ ) gcd = __gcd ( gcd , arr [ i ] ) ; if ( p % gcd == 0 ) return true ; return false ; } int main ( ) { int arr [ ] = { 6 , 9 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int p = 3 ; if ( isPossible ( arr , n , p ) ) 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 ; void findNum ( int a [ ] , int n , int b [ ] , int m ) { int x = * max_element ( a , a + n ) ; int y = * max_element ( b , b + m ) ; cout << x << " ▁ " << y ; } int main ( ) { int a [ ] = { 3 , 2 , 2 } ; int n = sizeof ( a ) / sizeof ( int ) ; int b [ ] = { 1 , 5 , 7 , 7 , 9 } ; int m = sizeof ( b ) / sizeof ( int ) ; findNum ( a , n , b , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } void generateArr ( int arr [ ] , int n ) { bool flip = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) { if ( flip ^= true ) cout << ceil ( ( float ) ( arr [ i ] ) / 2.0 ) << " ▁ " ; else cout << floor ( ( float ) ( arr [ i ] ) / 2.0 ) << " ▁ " ; } else { cout << arr [ i ] / 2 << " ▁ " ; } } } int main ( ) { int arr [ ] = { 3 , -5 , -7 , 9 , 2 , -2 } ; int n = sizeof ( arr ) / sizeof ( int ) ; generateArr ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: flip, i, stdc
Iterator variables: i
Boolean variables: flip
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binomialCoeff ( int n , int k ) { int C [ n + 1 ] [ k + 1 ] ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } int cntSubSeq ( int arr [ ] , int n , int k ) { sort ( arr , arr + n ) ; int num = arr [ k - 1 ] ; int Y = 0 ; for ( int i = k - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == num ) Y ++ ; } int cntX = Y ; for ( int i = k ; i < n ; i ++ ) { if ( arr [ i ] == num ) cntX ++ ; } return binomialCoeff ( cntX , Y ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int k = 2 ; cout << cntSubSeq ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j, k, n
Accumulator variables: Y, cntX, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#include <malloc.h>
#include <math.h>
using namespace std ; void convertToBinary ( int num , int a [ ] , int n ) { int pointer = n - 1 ; while ( num > 0 ) { a [ pointer ] = num % 2 ; num = num / 2 ; pointer -- ; } } void checkforsum ( int a [ ] , int n ) { int sum1 = 0 ; int sum2 = 0 ; int mid = n / 2 ; for ( int i = 0 ; i < mid ; i ++ ) sum1 = sum1 + a [ i ] ; for ( int j = mid ; j < n ; j ++ ) sum2 = sum2 + a [ j ] ; if ( sum1 == sum2 ) { for ( int i = 0 ; i < n ; i ++ ) cout << a [ i ] ; cout << " STRNEWLINE " ; } } void print_seq ( int m ) { int n = ( 2 * m ) ; int a [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { a [ j ] = 0 ; } for ( int i = 0 ; i < ( int ) pow ( 2 , n ) ; i ++ ) { convertToBinary ( i , a , n ) ; checkforsum ( a , n ) ; } } int main ( ) { int m = 2 ; print_seq ( m ) ; return 0 ; }

Index/key variables: i, j, n, pointer
Accumulator variables: i, j, pointer
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int coprime ( int a , int b ) { if ( __gcd ( a , b ) == 1 ) return true ; else return false ; } bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n == 2 or n == 3 ) return true ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } void findNumbers ( int a , int b , int n ) { bool possible = true ; if ( ! coprime ( a , b ) ) possible = false ; int c1 = 1 ; int c2 = 1 ; int num1 , num2 ; set < int > st ; if ( possible ) { while ( ( int ) st . size ( ) != n ) { num1 = a + ( c1 * b ) ; if ( isPrime ( num1 ) ) { st . insert ( num1 ) ; } c1 ++ ; num2 = b + ( c2 * a ) ; if ( isPrime ( num2 ) ) { st . insert ( num2 ) ; } c2 ++ ; } for ( int i : st ) cout << i << " ▁ " ; } else cout << " - 1" ; } int main ( ) { int a = 3 ; int b = 5 ; int n = 4 ; findNumbers ( a , b , n ) ; return 0 ; }

Accumulator variables: c1, c2, i, stdc
Iterator variables: i
Boolean variables: possible
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findIntegers ( int n , int a [ ] , int x , int t1 , int t2 ) { bool flag = true ; for ( int i = 0 ; i < n ; i ++ ) { int temp = pow ( a [ i ] , 2 ) + x ; if ( temp % 10 != t1 && temp % 10 != t2 ) { cout << temp << " ▁ " ; flag = false ; } } if ( flag ) cout << " - 1" ; } int main ( ) { int N = 4 , X = 10 , T1 = 5 , T2 = 6 ; int a [ N ] = { 3 , 1 , 4 , 7 } ; findIntegers ( N , a , X , T1 , T2 ) ; cout << endl ; N = 4 , X = 2 , T1 = 5 , T2 = 6 ; int b [ N ] = { 2 , 18 , 22 , 8 } ; findIntegers ( N , b , X , T1 , T2 ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int TEN = 10 ; int digitSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += n % TEN ; n /= TEN ; } return sum ; } int getNthTerm ( int n ) { int sum = digitSum ( n ) ; if ( sum % TEN == 0 ) return ( n * TEN ) ; int extra = TEN - ( sum % TEN ) ; return ( ( n * TEN ) + extra ) ; } void firstNTerms ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) cout << getNthTerm ( i ) << " ▁ " ; } int main ( ) { int n = 10 ; firstNTerms ( n ) ; return 0 ; }

Accumulator variables: i, n, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min1 = INT_MAX ; int _count = 0 ; int permutation ( string str1 , int i , int n , int p ) { if ( i == n ) { int q = stoi ( str1 ) ; if ( q - p > 0 && q < min1 ) { min1 = q ; _count = 1 ; } } else { for ( int j = i ; j <= n ; j ++ ) { swap ( str1 [ i ] , str1 [ j ] ) ; permutation ( str1 , i + 1 , n , p ) ; swap ( str1 [ i ] , str1 [ j ] ) ; } } return min1 ; } int main ( ) { int A = 213 ; int B = 111 ; string str1 = to_string ( A ) ; int len = str1 . length ( ) ; int h = permutation ( str1 , 0 , len - 1 , B ) ; _count ? cout << h << endl : cout << -1 << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: j, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Alcuin ( int n ) { double _n = n , ans ; ans = round ( ( _n * _n ) / 12 ) - floor ( _n / 4 ) * floor ( ( _n + 2 ) / 4 ) ; return ans ; } void solve ( int n ) { int i = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { cout << Alcuin ( i ) << " , ▁ " ; } } int main ( ) { int n = 15 ; solve ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int * solve ( int arr [ ] , int n ) { static int b [ 4 ] ; int p = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { b [ p ] = arr [ i -- ] ; if ( i >= 0 ) b [ n - 1 - p ] = arr [ i ] ; p ++ ; } return b ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int * b ; b = solve ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) cout << b [ i ] << " ▁ " ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool productsDistinct ( int N ) { string s = " " ; while ( N ) { s += ( char ) ( N % 10 + '0' ) ; N /= 10 ; } reverse ( s . begin ( ) , s . end ( ) ) ; int sz = s . size ( ) ; set < int > se ; for ( int i = 0 ; i < sz ; i ++ ) { int product = 1 ; for ( int j = i ; j < sz ; j ++ ) { product *= ( int ) ( s [ j ] - '0' ) ; if ( se . find ( product ) != se . end ( ) ) return false ; else se . insert ( product ) ; } } return true ; } int main ( ) { int N = 2345 ; if ( productsDistinct ( N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: j
Accumulator variables: N, i, j, product, s, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int n ) { if ( n <= 1 ) return 1 ; return n * factorial ( n - 1 ) ; } int nCr ( int n , int r ) { return factorial ( n ) / ( factorial ( n - r ) * factorial ( r ) ) ; } int NumberOfWays ( int n , int x , int y ) { return nCr ( 2 * n - x - y , n - x ) * factorial ( n ) * factorial ( n ) ; } int main ( ) { int n = 5 , x = 4 , y = 2 ; cout << NumberOfWays ( n , x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define mod  1000000007
using namespace std ; int findSmallestNonZeroY ( int A_num ) { string A_binary = bitset < 8 > ( A_num ) . to_string ( ) ; int B = 1 ; int length = A_binary . size ( ) ; int no_ones = __builtin_popcount ( A_num ) ; if ( length == no_ones ) return A_num + 1 ; for ( int i = 0 ; i < length ; i ++ ) { char ch = A_binary [ length - i - 1 ] ; if ( ch == '0' ) { B = pow ( 2.0 , i ) ; break ; } } return B ; } int main ( ) { int X = findSmallestNonZeroY ( 10 ) ; cout << X ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  32
int GetOne ( string s , int L , int R ) { int len = s . length ( ) ; bitset < N > bit ( s ) ; bit <<= ( N - len + L - 1 ) ; bit >>= ( N - len + L - 1 ) ; bit >>= ( len - R ) ; return bit . count ( ) ; } int main ( ) { string s = "01010001011" ; int L = 2 , R = 4 ; cout << GetOne ( s , L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxElement ( int a [ ] , int n ) { if ( n < 3 ) return -1 ; int maxElement = a [ 0 ] ; int maxProd = a [ n - 1 ] * a [ 1 ] ; for ( int i = 1 ; i < n ; i ++ ) { int currProd = a [ i - 1 ] * a [ ( i + 1 ) % n ] ; if ( currProd > maxProd ) { maxProd = currProd ; maxElement = a [ i ] ; } else if ( currProd == maxProd ) { maxElement = max ( maxElement , a [ i ] ) ; } } return maxElement ; } int main ( ) { int a [ ] = { 5 , 6 , 4 , 3 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << maxElement ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int ncr ( int n , int r ) { int ans = 1 ; for ( int i = 1 ; i <= r ; i += 1 ) { ans *= ( n - r + i ) ; ans /= i ; } return ans ; } int totalWays ( int X , int Y , int M , int W ) { return ( ncr ( M , X ) * ncr ( W , Y ) ) ; } int main ( ) { int X = 4 , Y = 3 , M = 6 , W = 5 ; cout << totalWays ( X , Y , M , W ) ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void specialSieve ( int n ) { int cnt = 0 ; int prime [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) prime [ i ] = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( ! prime [ i ] ) { cnt ++ ; for ( int j = i ; j <= n ; j += i ) prime [ j ] = cnt ; } } for ( int i = 2 ; i <= n ; i ++ ) cout << prime [ i ] << " ▁ " ; } int main ( ) { int n = 6 ; specialSieve ( n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: cnt, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximum = INT_MIN , x , ans = INT_MAX ; vector < int > graph [ 100 ] ; vector < int > weight ( 100 ) ; void dfs ( int node , int parent ) { int a = __builtin_popcount ( weight [ node ] + x ) ; if ( maximum < a ) { maximum = a ; ans = node ; } else if ( maximum == a ) ans = min ( ans , node ) ; for ( int to : graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; } } int main ( ) { x = 15 ; weight [ 1 ] = 5 ; weight [ 2 ] = 10 ; weight [ 3 ] = 11 ; weight [ 4 ] = 8 ; weight [ 5 ] = 6 ; graph [ 1 ] . push_back ( 2 ) ; graph [ 2 ] . push_back ( 3 ) ; graph [ 2 ] . push_back ( 4 ) ; graph [ 1 ] . push_back ( 5 ) ; dfs ( 1 , 1 ) ; cout << ans ; return 0 ; }

Index/key variables: node
Accumulator variables: stdc
Iterator variables: to
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count_pairs ( int a [ ] , int b [ ] , int n , int m ) { int odd1 = 0 , even1 = 0 ; int odd2 = 0 , even2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) odd1 ++ ; else even1 ++ ; } for ( int i = 0 ; i < m ; i ++ ) { if ( b [ i ] % 2 == 1 ) odd2 ++ ; else even2 ++ ; } int pairs = min ( odd1 , odd2 ) + min ( even1 , even2 ) ; return pairs ; } int main ( ) { int a [ ] = { 9 , 14 , 6 , 2 , 11 } ; int b [ ] = { 8 , 4 , 7 , 20 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int m = sizeof ( b ) / sizeof ( b [ 0 ] ) ; cout << count_pairs ( a , b , n , m ) ; return 0 ; }

Index/key variables: i
Accumulator variables: even1, even2, i, odd1, odd2, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; void solve ( int Array [ ] , int N ) { double Arraynew [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { Arraynew [ i ] = log ( Array [ i ] ) ; } double prefixsum [ N ] ; prefixsum [ 0 ] = Arraynew [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { prefixsum [ i ] = prefixsum [ i - 1 ] + Arraynew [ i ] ; } int answer = 0 ; double minabs = abs ( prefixsum [ N - 1 ] - 2 * prefixsum [ 0 ] ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { double ans1 = abs ( prefixsum [ N - 1 ] - 2 * prefixsum [ i ] ) ; if ( ans1 < minabs ) { minabs = ans1 ; answer = i ; } } cout << " Index ▁ is : ▁ " << answer << endl ; } int main ( ) { int Array [ 5 ] = { 1 , 4 , 12 , 2 , 6 } ; int N = 5 ; solve ( Array , N ) ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getValueOfF ( int n ) { if ( n == 1 ) return 0 ; if ( n == 2 ) return 1 ; int cnt = 0 ; while ( n % 2 == 0 ) { cnt += 1 ; n /= 2 ; } return 2 * cnt ; } int main ( ) { int n = 20 ; cout << getValueOfF ( n ) ; return 0 ; }

Accumulator variables: cnt, n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
#define mod  1000000007
int cnt [ N ] ; void Divisors ( ) { memset ( cnt , 0 , sizeof cnt ) ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = 1 ; j * i < N ; j ++ ) cnt [ i * j ] ++ ; } } int Sumofdivisors ( int A , int B , int C ) { int sum = 0 ; Divisors ( ) ; for ( int i = 1 ; i <= A ; i ++ ) { for ( int j = 1 ; j <= B ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { int x = i * j * k ; sum += cnt [ x ] ; if ( sum >= mod ) sum -= mod ; } } } return sum ; } int main ( ) { int A = 5 , B = 6 , C = 7 ; cout << Sumofdivisors ( A , B , C ) ; return 0 ; }

Index/key variables: N, x
Accumulator variables: i, j, k, stdc, sum
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int A_mod_B ( string N , int a ) { int len = N . size ( ) ; int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) ans = ( ans * 10 + ( int ) N [ i ] - '0' ) % a ; return ans % a ; } int findMod ( string N ) { int mod = A_mod_B ( N , 4 ) ; int ans = ( 1 + pow ( 2 , mod ) + pow ( 3 , mod ) + pow ( 4 , mod ) ) ; return ( ans % 5 ) ; } int main ( ) { string N = "4" ; cout << findMod ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printElements ( int arr [ ] , int n ) { for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] and arr [ i ] > arr [ i + 1 ] ) cout << arr [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 2 , 3 , 1 , 5 , 4 , 9 , 8 , 7 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printElements ( arr , n ) ; return 0 ; }

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