dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void CheckSubarray ( int arr [ ] , int N ) { int presum [ N + 1 ] = { 0 } ; for ( int i = 1 ; i <= N ; i += 1 ) { presum [ i ] = presum [ i - 1 ] + arr [ i - 1 ] ; } for ( int i = 1 ; i <= N ; i += 1 ) { for ( int j = i ; j <= N ; j += 1 ) { if ( ( presum [ j ] - presum [ i - 1 ] ) % N == 0 ) { cout << i - 1 << " ▁ " << j - 1 ; return ; } } } cout << -1 ; } int main ( ) { int arr [ ] = { 7 , 5 , 3 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; CheckSubarray ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void CheckSubarray ( int arr [ ] , int N ) { int presum [ N + 1 ] = { 0 } ; for ( int i = 1 ; i <= N ; i += 1 ) { presum [ i ] = presum [ i - 1 ] + arr [ i - 1 ] ; } vector < int > moduloclass [ N ] ; for ( int i = 1 ; i <= N ; i += 1 ) { moduloclass [ presum [ i ] % N ] . push_back ( i - 1 ) ; } if ( moduloclass [ 0 ] . size ( ) > 0 ) { cout << 0 << " ▁ " << moduloclass [ 0 ] [ 0 ] ; return ; } for ( int i = 1 ; i < N ; i += 1 ) { if ( moduloclass [ i ] . size ( ) >= 2 ) { cout << moduloclass [ i ] [ 0 ] + 1 << " ▁ " << moduloclass [ i ] [ 1 ] ; return ; } } } int main ( ) { int arr [ ] = { 7 , 3 , 5 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; CheckSubarray ( arr , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countBits ( int n ) { int count = 0 ; while ( n ) { count ++ ; n >>= 1 ; } return count ; } int findNearestNumber ( int n ) { int cnt = countBits ( n ) ; cnt -= 1 ; if ( cnt % 2 ) { return 1 << ( cnt + 1 ) ; } else { int tempnum = 0 ; for ( int i = 0 ; i <= cnt ; i += 2 ) tempnum += 1 << i ; if ( tempnum < n ) { return ( 1 << ( cnt + 2 ) ) ; } else if ( tempnum == n ) return n ; for ( int i = 0 ; i <= cnt ; i += 2 ) { tempnum -= ( 1 << i ) ; if ( tempnum < n ) return tempnum += ( 1 << i ) ; } } } int main ( ) { int n = 19 ; cout << findNearestNumber ( n ) ; }

Accumulator variables: cnt, count, i, stdc, tempnum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNum ( int n ) { if ( n == 1 ) return 1 ; int count = pow ( 2 , n - 2 ) ; return count ; } int main ( ) { int n = 3 ; cout << countNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
string constructString ( ll n ) { string s = " " ; for ( ll i = 0 ; i < n ; i ++ ) { s += "10" ; } return s ; } ll binaryToDecimal ( string n ) { string num = n ; ll dec_value = 0 ; ll base = 1 ; ll len = num . length ( ) ; for ( ll i = len - 1 ; i >= 0 ; i -- ) { if ( num [ i ] == '1' ) dec_value += base ; base = base * 2 ; } return dec_value ; } ll findNumber ( ll n ) { string s = constructString ( n - 1 ) ; ll num = binaryToDecimal ( s ) ; return num ; } int main ( ) { ll n = 4 ; cout << findNumber ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: dec_value, i, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; Node * push ( Node * * head_ref , int data ) { Node * new_node = new Node ; new_node -> data = data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int bitonic_point ( Node * node ) { if ( node == NULL ) return -1 ; if ( node -> next == NULL ) return -1 ; if ( node -> data > node -> next -> data ) return -1 ; while ( node -> next != NULL ) { if ( node -> data > node -> next -> data ) break ; node = node -> next ; } int bitonicPoint = node -> data ; while ( node -> next != NULL ) { if ( node -> data < node -> next -> data ) return -1 ; node = node -> next ; } return bitonicPoint ; } int main ( ) { Node * head = NULL ; push ( & head , 100 ) ; push ( & head , 201 ) ; push ( & head , 399 ) ; push ( & head , 490 ) ; push ( & head , 377 ) ; push ( & head , 291 ) ; push ( & head , 100 ) ; cout << bitonic_point ( head ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinRemove ( int a [ ] , int n , int k ) { vector < int > cnt ( k , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) cnt [ 0 ] ++ ; else if ( cnt [ a [ i ] - 1 ] > 0 ) { cnt [ a [ i ] - 1 ] -- ; cnt [ a [ i ] ] ++ ; } } return n - ( k * cnt [ k - 1 ] ) ; } int main ( ) { int a [ ] = { 0 , 1 , 2 , 3 , 4 , 0 , 1 , 0 , 1 , 2 , 3 , 4 } , k = 5 ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << MinRemove ( a , 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 mosaic ( int n ) { int i , ans = 1 ; for ( i = 2 ; i <= n ; i ++ ) { if ( n % i == 0 && n > 0 ) { int count = 0 ; while ( n % i == 0 ) { n /= i ; count ++ ; } ans *= count * i ; } } return ans ; } void nMosaicNumbers ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) cout << mosaic ( i ) << " ▁ " ; } int main ( ) { int n = 10 ; nMosaicNumbers ( n ) ; return 0 ; }

Accumulator variables: ans, count, i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countNodes ( int N , int X ) { int height = floor ( log2 ( N ) ) ; if ( X > height ) { cout << "0 STRNEWLINE 0" ; return ; } if ( N == 1 ) { cout << "1 STRNEWLINE 1" ; return ; } int max_total_nodes = ( 1 << ( height + 1 ) ) - 1 ; int nodes_last_level = ( 1 << height ) - ( max_total_nodes - N ) ; int from_root ; int from_leaf ; if ( X == height ) from_root = nodes_last_level ; else from_root = 1 << X ; int left_leaf_nodes = ( ( 1 << height ) - nodes_last_level ) / 2 ; if ( X == 0 ) { from_leaf = nodes_last_level + left_leaf_nodes ; } else { int i = X ; while ( nodes_last_level > 1 && i > 0 ) { nodes_last_level = ceil ( ( float ) nodes_last_level / ( float ) 2 ) ; i -- ; } from_leaf = nodes_last_level ; i = X ; while ( left_leaf_nodes > 1 && i > 0 ) { left_leaf_nodes = ceil ( ( float ) left_leaf_nodes / ( float ) 2 ) ; i -- ; } from_leaf += left_leaf_nodes ; } cout << from_root << endl << from_leaf ; } int main ( ) { int N = 38 , X = 3 ; countNodes ( N , X ) ; return 0 ; }

Accumulator variables: from_leaf, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum_of_4_squares ( int n ) { int i , odd = 0 , even = 0 ; for ( i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i % 2 == 0 ) even += i ; else odd += i ; if ( ( n / i ) != i ) { if ( ( n / i ) % 2 == 0 ) even += ( n / i ) ; else odd += ( n / i ) ; } } } if ( n % 2 == 1 ) return 8 * ( odd + even ) ; else return 24 * ( odd ) ; } int main ( ) { int n = 4 ; cout << sum_of_4_squares ( n ) ; return 0 ; }

Accumulator variables: even, i, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mosaic ( int n ) { int i , ans = 1 ; for ( i = 2 ; i <= n ; i ++ ) { if ( n % i == 0 && n > 0 ) { int count = 0 ; while ( n % i == 0 ) { n /= i ; count ++ ; } ans *= count * i ; } } return ans ; } int main ( ) { int n = 36 ; cout << mosaic ( n ) ; return 0 ; }

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

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaxNumbers ( int a [ ] , int n ) { int fre [ 3 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] %= 3 ; fre [ a [ i ] ] ++ ; } int ans = fre [ 0 ] ; int k = min ( fre [ 1 ] , fre [ 2 ] ) ; ans += k ; fre [ 1 ] -= k ; fre [ 2 ] -= k ; ans += fre [ 1 ] / 3 + fre [ 2 ] / 3 ; return ans ; } int main ( ) { int a [ ] = { 1 , 4 , 10 , 7 , 11 , 2 , 8 , 5 , 9 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << MaxNumbers ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned int countSetBits ( int n ) { unsigned int count = 0 ; while ( n ) { n &= ( n - 1 ) ; count ++ ; } return count ; } int pairs ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int sum = countSetBits ( arr [ i ] ) + countSetBits ( arr [ j ] ) ; if ( sum == k ) count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 4 ; cout << pairs ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, n, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  32
unsigned int countSetBits ( int n ) { unsigned int count = 0 ; while ( n ) { n &= ( n - 1 ) ; count ++ ; } return count ; } int pairs ( int arr [ ] , int n , int k ) { int count = 0 ; int f [ MAX + 1 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) f [ countSetBits ( arr [ i ] ) ] ++ ; for ( int i = 0 ; i <= MAX ; i ++ ) { for ( int j = i ; j <= MAX ; j ++ ) { if ( i + j == k ) { if ( i == j ) count += ( ( f [ i ] * ( f [ i ] - 1 ) ) / 2 ) ; else count += ( f [ i ] * f [ j ] ) ; } } } return count ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 4 ; cout << pairs ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, n, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void LowerHessenbergMatrix ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( j > i + 1 ) cout << '0' << " ▁ " ; else cout << rand ( ) % 10 << " ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { int n = 4 ; LowerHessenbergMatrix ( n ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void UpperHessenbergMatrix ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( i > j + 1 ) cout << '0' << " ▁ " ; else cout << rand ( ) % 10 << " ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { int n = 4 ; UpperHessenbergMatrix ( n ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int composite_factors ( int n ) { int count = 0 ; int i , j ; int a [ n + 1 ] = { 0 } ; for ( i = 1 ; i <= n ; ++ i ) { if ( n % i == 0 ) { a [ i ] = i ; } } for ( i = 2 ; i <= n ; i ++ ) { j = 2 ; int p = 1 ; while ( j < a [ i ] ) { if ( a [ i ] % j == 0 ) { p = 0 ; break ; } j ++ ; } if ( p == 0 && a [ i ] != 0 ) { count ++ ; } } return count ; } int main ( ) { int n = 100 ; cout << composite_factors ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, j, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int isMersenne ( int n ) { while ( n != 0 ) { int r = n % 2 ; if ( r == 0 ) return false ; n /= 2 ; } return true ; } int sumOfMersenne ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 && isMersenne ( arr [ i ] ) ) { sum += arr [ i ] ; } } return sum ; } int main ( ) { int arr [ ] = { 17 , 6 , 7 , 63 , 3 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << ( sumOfMersenne ( arr , n ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, n, sum
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int sumOfFactors ( int n ) { int sum = 0 ; for ( int f = 1 ; f <= n / 2 ; f ++ ) { if ( n % f == 0 ) { sum += f ; } } return sum ; } int getSum ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 && arr [ i ] == sumOfFactors ( arr [ i ] ) ) { sum += arr [ i ] ; } } return sum ; } int main ( ) { int arr [ 10 ] = { 17 , 6 , 10 , 6 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( getSum ( arr , n ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: f, i, sum
Iterator variables: f, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool sameLength ( int A , int B ) { while ( A > 0 && B > 0 ) { A = A / 10 ; B = B / 10 ; } if ( A == 0 && B == 0 ) return true ; return false ; } int main ( ) { int A = 21 , B = 1 ; if ( sameLength ( A , B ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  2
#define M  2
void Matrix ( char a [ N ] [ M ] ) { char ch = '1' ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( a [ i ] [ j ] == ' . ' ) a [ i ] [ j ] = ch ; ch = ( ch == '1' ) ? '0' : '1' ; cout << a [ i ] [ j ] << " ▁ " ; } cout << endl ; if ( i % 2 == 0 ) ch = '0' ; else ch = '1' ; } } int main ( ) { char a [ N ] [ M ] = { { ' . ' , ' _ ' } , { ' _ ' , ' . ' } } ; Matrix ( a ) ; return 0 ; }

Index/key variables: M, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cnt_neg ; bool exists_zero ; void preProcess ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) cnt_neg ++ ; if ( arr [ i ] == 0 ) exists_zero = true ; } } bool isPossible ( int k ) { if ( ! exists_zero ) { if ( k >= cnt_neg and ( k - cnt_neg ) % 2 == 0 ) return true ; else return false ; } else { if ( k >= cnt_neg ) return true ; else return false ; } } int main ( ) { int arr [ ] = { -1 , 2 , -3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( int ) ; preProcess ( arr , n ) ; int queries [ ] = { 1 , 2 , 3 , 4 } ; int q = sizeof ( queries ) / sizeof ( int ) ; for ( int i = 0 ; i < q ; i ++ ) { if ( isPossible ( queries [ i ] ) ) cout << " Yes " << endl ; else cout << " No " << endl ; } return 0 ; }

Index/key variables: i
Accumulator variables: cnt_neg, i, stdc
Iterator variables: i
Boolean variables: exists_zero
C++ program:
#include <iostream>
using namespace std ; int FindXorSum ( int arr [ ] , int k , int n ) { if ( n < k ) return 0 ; int x [ n ] = { 0 } ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 0 ) x [ i ] = x [ i - 1 ] ^ arr [ i ] ; else x [ i ] = arr [ i ] ; if ( i >= k - 1 ) { int sum = 0 ; sum = x [ i ] ; if ( i - k > -1 ) sum ^= x [ i - k ] ; result += sum ; } } return result ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = 4 , k = 2 ; cout << FindXorSum ( arr , k , n ) << endl ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, result, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int reverse ( int n ) { int rev = 0 ; while ( n > 0 ) { int d = n % 10 ; rev = rev * 10 + d ; n = n / 10 ; } return rev ; } bool isPalin ( int n ) { return ( n == reverse ( n ) ) ; } int countDigits ( int n ) { int c = 0 ; while ( n > 0 ) { n = n / 10 ; c ++ ; } return c ; } int countPalinDigits ( int arr [ ] , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 10 || isPalin ( arr [ i ] ) ) { s += countDigits ( arr [ i ] ) ; } } return s ; } int main ( ) { int arr [ ] = { 121 , 56 , 434 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( countPalinDigits ( arr , n ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c, i, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int reverse ( int n ) { int d = 0 , s = 0 ; while ( n > 0 ) { d = n % 10 ; s = s * 10 + d ; n = n / 10 ; } return s ; } bool isPalin ( int n ) { return n == reverse ( n ) ; } int sumOfArray ( int arr [ ] , int n ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] > 10 ) && isPalin ( arr [ i ] ) ) { s += arr [ i ] ; } } return s ; } int main ( ) { int n = 6 ; int arr [ ] = { 12 , 313 , 11 , 44 , 9 , 1 } ; cout << sumOfArray ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000000
int prime [ MAX + 1 ] ; void updatePrimes ( ) { for ( int i = 2 ; i <= MAX ; i ++ ) { prime [ i ] = 1 ; } prime [ 0 ] = prime [ 1 ] = 0 ; for ( int i = 2 ; i * i <= MAX ; i ++ ) { if ( prime [ i ] == 1 ) { for ( int j = i * i ; j <= MAX ; j += i ) { prime [ j ] = 0 ; } } } for ( int i = 1 ; i <= MAX ; i ++ ) { prime [ i ] += prime [ i - 1 ] ; } } int getDifference ( int l , int r ) { int total = r - l + 1 ; int primes = prime [ r ] - prime [ l - 1 ] ; int composites = total - primes ; return ( abs ( primes - composites ) ) ; } int main ( ) { int queries [ ] [ 2 ] = { { 1 , 10 } , { 5 , 30 } } ; int q = sizeof ( queries ) / sizeof ( queries [ 0 ] ) ; updatePrimes ( ) ; for ( int i = 0 ; i < q ; i ++ ) cout << getDifference ( queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) << endl ; return 0 ; }

Index/key variables: i, j, r
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#define MAX  1000000
using namespace std ; int Sieve [ MAX ] = { 0 } ; void constructSieve ( ) { for ( int i = 2 ; i <= MAX ; i ++ ) { if ( Sieve [ i ] == 0 ) { for ( int j = 2 * i ; j <= MAX ; j += i ) { int temp = j ; while ( temp > 1 && temp % i == 0 ) { Sieve [ j ] ++ ; temp = temp / i ; } } } } } void checkElements ( int A [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( Sieve [ A [ i ] ] == k ) { cout << " YES STRNEWLINE " ; } else { cout << " NO STRNEWLINE " ; } } } int main ( ) { constructSieve ( ) ; int k = 3 ; int A [ ] = { 12 , 36 , 42 , 72 } ; int n = sizeof ( A ) / sizeof ( int ) ; checkElements ( A , n , k ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define mod  1000000007
using namespace std ; long long modularexpo ( long long x , long long y , long long p ) { long long res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } void multiply ( long long F [ 2 ] [ 2 ] , long long M [ 2 ] [ 2 ] , long long m ) { long long x = ( ( F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] ) % m + ( F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ) % m ) % m ; long long y = ( ( F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] ) % m + ( F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ) % m ) % m ; long long z = ( ( F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] ) % m + ( F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ) % m ) % m ; long long w = ( ( F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] ) % m + ( F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ) % m ) % m ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } void power ( long long F [ 2 ] [ 2 ] , long long n , long long m ) { if ( n == 0 n == 1 ) return ; long long M [ 2 ] [ 2 ] = { { 1 , 1 } , { 1 , 0 } } ; power ( F , n / 2 , m ) ; multiply ( F , F , m ) ; if ( n % 2 != 0 ) multiply ( F , M , m ) ; } long long fib ( long long n , long long m ) { long long F [ 2 ] [ 2 ] = { { 1 , 1 } , { 1 , 0 } } ; if ( n == 0 ) return 0 ; power ( F , n - 1 , m ) ; return F [ 0 ] [ 0 ] ; } int main ( ) { long long n = 4 ; long long base = fib ( n , mod ) % mod ; long long expo = fib ( n , mod - 1 ) % ( mod - 1 ) ; long long result = modularexpo ( base , expo , mod ) % mod ; cout << result << endl ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntWays ( int arr [ ] , int n ) { if ( n == 1 ) return 0 ; int tot_sum = 0 , sum = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) tot_sum += arr [ i ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += arr [ i ] ; if ( sum == tot_sum / 2 ) ans ++ ; } return ans ; } int main ( ) { int arr [ ] = { 1 , -1 , 1 , -1 , 1 , -1 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << cntWays ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc, sum, tot_sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
#define MAX  32
ll pow2 [ MAX ] ; bool visited [ MAX ] ; vector < int > ans ; void power_2 ( ) { ll ans = 1 ; for ( int i = 0 ; i < MAX ; i ++ ) { pow2 [ i ] = ans ; ans *= 2 ; } } int countSetBits ( ll x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } void add ( ll num ) { int point = 0 ; ll value = 0 ; for ( ll i = 0 ; i < MAX ; i ++ ) { if ( visited [ i ] ) continue ; else { if ( num & 1 ) { value += ( 1 << i ) ; } num /= 2 ; } } ans . push_back ( value ) ; } void solve ( ll n , ll k ) { ans . push_back ( k ) ; int countk = countSetBits ( k ) ; if ( pow2 [ countk ] < n ) { cout << -1 ; return ; } int count = 0 ; for ( ll i = 0 ; i < pow2 [ countk ] - 1 ; i ++ ) { add ( i ) ; count ++ ; if ( count == n ) break ; } for ( int i = 0 ; i < n ; i ++ ) { cout << ans [ i ] << " ▁ " ; } } int main ( ) { ll n = 3 , k = 5 ; power_2 ( ) ; solve ( n , k ) ; return 0 ; }

Index/key variables: MAX, countk, i
Accumulator variables: ans, count, i, num, setBits, stdc, value
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countX ( int a , int b ) { if ( b > a ) return 0 ; else if ( a == b ) return -1 ; else { int x = a - b , ans = 0 ; for ( int i = 1 ; i * i <= x ; i ++ ) { if ( x % i == 0 ) { int d1 = i , d2 = b - 1 ; if ( i * i != x ) d2 = x / i ; if ( d1 > b ) ans ++ ; if ( d2 > b ) ans ++ ; } } return ans ; } } int main ( ) { int a = 21 , b = 5 ; cout << countX ( a , b ) ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; set < int > intersection ( set < int > s1 , set < int > s2 ) { set < int > intersect ; set_intersection ( s1 . begin ( ) , s1 . end ( ) , s2 . begin ( ) , s2 . end ( ) , inserter ( intersect , intersect . begin ( ) ) ) ; return intersect ; } double jaccard_index ( set < int > s1 , set < int > s2 ) { double size_s1 = s1 . size ( ) ; double size_s2 = s2 . size ( ) ; set < int > intersect = intersection ( s1 , s2 ) ; double size_in = intersect . size ( ) ; double jaccard_in = size_in / ( size_s1 + size_s2 - size_in ) ; return jaccard_in ; } double jaccard_distance ( double jaccardIndex ) { double jaccard_dist = 1 - jaccardIndex ; return jaccard_dist ; } int main ( ) { set < int > s1 ; s1 . insert ( 1 ) ; s1 . insert ( 2 ) ; s1 . insert ( 3 ) ; s1 . insert ( 4 ) ; s1 . insert ( 5 ) ; set < int > s2 ; s2 . insert ( 4 ) ; s2 . insert ( 5 ) ; s2 . insert ( 6 ) ; s2 . insert ( 7 ) ; s2 . insert ( 8 ) ; s2 . insert ( 9 ) ; s2 . insert ( 10 ) ; double jaccardIndex = jaccard_index ( s1 , s2 ) ; cout << " Jaccard ▁ index ▁ = ▁ " << jaccardIndex << endl ; cout << " Jaccard ▁ distance ▁ = ▁ " << jaccard_distance ( jaccardIndex ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long int
ll sumPowersK ( ll n , ll k ) { ll sum = 0 , num = 1 ; while ( num <= n ) { sum += num ; num *= k ; } return sum ; } ll getSum ( ll n , ll k ) { ll pwrK = sumPowersK ( n , k ) ; ll sumAll = ( n * ( n + 1 ) ) / 2 ; return ( sumAll - pwrK ) ; } int main ( ) { ll n = 10 , k = 3 ; cout << getSum ( n , k ) ; return 0 ; }

Accumulator variables: num, stdc, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPeople ( int p ) { int tmp = 0 , count = 0 ; for ( int i = 1 ; i * i <= p ; i ++ ) { tmp = tmp + ( i * i ) ; if ( tmp <= p ) count ++ ; else break ; } return count ; } int main ( ) { int p = 14 ; cout << maxPeople ( p ) ; return 0 ; }

Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <algorithm>
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
static constexpr int kN = 1000000 ; int maxPeople ( int p ) { ll sums [ kN ] ; sums [ 0 ] = 0 ; for ( int i = 1 ; i < kN ; i ++ ) sums [ i ] = ( ll ) ( i * i ) + sums [ i - 1 ] ; auto it = std :: lower_bound ( sums , sums + kN , p ) ; if ( * it > p ) { -- it ; } return ( it - sums ) ; } int main ( ) { int p = 14 ; cout << maxPeople ( p ) ; return 0 ; }

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