dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mod = 1e9 + 7 ; void NthTerm ( int F [ ] , int C [ ] , int K , int n ) { int ans [ n + 1 ] = { 0 } ; for ( int i = 0 ; i < K ; i ++ ) ans [ i ] = F [ i ] ; for ( int i = K ; i <= n ; i ++ ) { for ( int j = i - K ; j < i ; j ++ ) { ans [ i ] += ans [ j ] ; ans [ i ] %= mod ; } } cout << ans [ n ] << endl ; } int main ( ) { int F [ ] = { 0 , 1 } ; int C [ ] = { 1 , 1 } ; int K = 2 ; int N = 10 ; NthTerm ( F , C , K , N ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countFreq ( int arr [ ] , int n ) { unordered_map < int , int > mp1 ; for ( int i = 0 ; i < n ; ++ i ) { mp1 [ arr [ i ] ] ++ ; } unordered_map < int , int > mp2 ; for ( auto it : mp1 ) { mp2 [ it . second ] ++ ; } int M = INT_MIN ; for ( auto it : mp2 ) { M = max ( M , it . second ) ; } for ( auto it : mp2 ) { if ( M == it . second ) { return it . first ; } } return 0 ; } int main ( ) { int arr [ ] = { 6 , 10 , 3 , 10 , 8 , 3 , 6 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countFreq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxDisconnected ( int N , int E ) { int curr = 1 ; int rem = E ; while ( rem > 0 ) { rem = rem - min ( curr , rem ) ; curr ++ ; } if ( curr > 1 ) { return N - curr ; } else { return N ; } } int main ( ) { int N = 5 , E = 1 ; cout << maxDisconnected ( N , E ) ; return 0 ; }

Accumulator variables: curr, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkPalindromeB ( int N , int B ) { int rev = 0 ; int N1 = N ; while ( N1 ) { rev = rev * B + N1 % B ; N1 = N1 / B ; } return N == rev ; } int main ( ) { int N = 5 , B = 2 ; if ( checkPalindromeB ( N , B ) ) { cout << " Yes " ; } else { cout << " No " ; } }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } int findProduct ( unsigned int N ) { unsigned int result = 1 ; for ( int i = 2 ; i < N ; i ++ ) { if ( gcd ( i , N ) == 1 ) { result *= i ; } } return result ; } int main ( ) { int N = 5 ; cout << findProduct ( N ) ; return 0 ; }

Accumulator variables: i, result
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countEqual ( int n ) { return ( n + 1 ) / 2 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countEqual ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find ( int par [ ] , int x ) ; void unionn ( int par [ ] , int a , int b ) ; int countPairs ( int A [ ] , int B [ ] , int N , int M , int List [ ] [ 2 ] ) { int count = 0 ; int par [ N + 1 ] ; for ( int i = 0 ; i <= N ; i ++ ) par [ i ] = i ; for ( int i = 0 ; i < M ; i ++ ) { int index1 = find ( par , List [ i ] [ 0 ] - 1 ) ; int index2 = find ( par , List [ i ] [ 1 ] - 1 ) ; if ( index1 != index2 ) { unionn ( par , index1 , index2 ) ; } } map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ A [ i ] ] = i ; } for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != B [ i ] ) { if ( mp . find ( B [ i ] ) == mp . end ( ) ) { count ++ ; continue ; } int j = mp [ B [ i ] ] ; if ( find ( par , i ) != find ( par , j ) ) count ++ ; } } return count ; } int find ( int par [ ] , int x ) { if ( par [ x ] == x ) return x ; else return par [ x ] = find ( par , par [ x ] ) ; } void unionn ( int par [ ] , int a , int b ) { a = find ( par , a ) ; b = find ( par , b ) ; if ( a == b ) return ; par [ a ] = b ; } int main ( ) { int N = 5 ; int M = 4 ; int A [ ] = { 1 , 5 , 9 , 2 , 3 } ; int B [ ] = { 2 , 4 , 5 , 1 , 3 } ; int List [ ] [ 2 ] = { { 1 , 4 } , { 2 , 3 } , { 3 , 5 } , { 2 , 5 } } ; cout << countPairs ( A , B , N , M , List ) ; return 0 ; }

Index/key variables: a, i, x
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void max_valid_triplet ( int A [ ] , int n ) { int ans = -1 ; for ( int i = 0 ; i < n - 2 ; i ++ ) { for ( int j = i + 1 ; j < n - 1 ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { if ( A [ i ] < A [ j ] && A [ j ] < A [ k ] ) { int value = A [ i ] + A [ j ] * A [ k ] ; if ( value > ans ) { ans = value ; } } } } } cout << ( ans ) ; } int main ( ) { int arr [ ] = { 7 , 9 , 3 , 8 , 11 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; max_valid_triplet ( arr , n ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
#define mod  1000000007
using namespace std ; vector < ll > ans ( 100002 , 1 ) ; void preCompute ( ) { for ( int i = 2 ; i <= 100000 / 2 ; i ++ ) { for ( int j = 2 * i ; j <= 100000 ; j += i ) { ans [ j ] = ( ans [ j ] * i ) % mod ; } } } int productOfProperDivi ( int num ) { return ans [ num ] ; } int main ( ) { preCompute ( ) ; int queries = 5 ; int a [ queries ] = { 4 , 6 , 8 , 16 , 36 } ; for ( int i = 0 ; i < queries ; i ++ ) { cout << productOfProperDivi ( a [ i ] ) << " , ▁ " ; } return 0 ; }

Index/key variables: i, j, num, queries
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findlcm ( int n ) { int ans = 1 ; for ( int i = 1 ; i <= n ; i ++ ) ans = ( ( ( i * ans ) ) / ( __gcd ( i , ans ) ) ) ; return ans ; } int highestPower ( int n ) { int lcm = findlcm ( n ) ; int ans = 0 ; for ( int i = 1 ; ; i ++ ) { int x = pow ( 2 , i ) ; if ( lcm % x == 0 ) { ans = i ; } if ( x > n ) break ; } return ans ; } int main ( ) { int n = 15 ; cout << highestPower ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int highestPower ( int n ) { return log ( n ) / log ( 2 ) ; } int main ( ) { int n = 15 ; cout << highestPower ( n ) ; return 0 ; }

Accumulator variables: stdc
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 ; } string deleteIth ( string str , int i ) { str . erase ( str . begin ( ) + i ) ; return str ; } bool isPrimePossible ( int N ) { string s = to_string ( N ) ; int l = s . length ( ) ; if ( l < 2 ) return false ; for ( int i = 0 ; i < l ; i ++ ) { string str = deleteIth ( s , i ) ; int num = stoi ( str ) ; if ( isPrime ( num ) ) return true ; } return false ; } int main ( ) { int N = 610 ; isPrimePossible ( N ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define lli  long long int
void checkFactors ( lli N ) { lli ev_count = 0 , od_count = 0 ; for ( lli i = 1 ; i <= sqrt ( N ) + 1 ; i ++ ) { if ( N % i == 0 ) { if ( i == N / i ) { if ( i % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; } else { if ( i % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; if ( ( N / i ) % 2 == 0 ) ev_count += 1 ; else od_count += 1 ; } } } if ( ev_count % 2 == 0 && od_count % 2 == 1 ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { lli N = 36 ; checkFactors ( N ) ; return 0 ; }

Accumulator variables: ev_count, i, od_count, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countofPermutations ( int N ) { return int ( 3 * pow ( 2 , N - 1 ) ) ; } int main ( ) { int N = 5 ; cout << countofPermutations ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void answer ( int L , int R ) { if ( 2 * L <= R ) cout << L << " , ▁ " << 2 * L << " STRNEWLINE " ; else cout << -1 ; } int main ( ) { int L = 3 , R = 8 ; answer ( L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int x , int y ) { if ( x % y == 0 ) return y ; else return gcd ( y , x % y ) ; } int countPairwiseCoprime ( int N , int M ) { int answer = 1 ; int g = gcd ( N , M ) ; int temp = g ; for ( int i = 2 ; i * i <= g ; i ++ ) { if ( temp % i == 0 ) { answer ++ ; while ( temp % i == 0 ) temp /= i ; } } if ( temp != 1 ) answer ++ ; return answer ; } void countCoprimePair ( int arr [ ] [ 2 ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { cout << countPairwiseCoprime ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) << ' ▁ ' ; } } int main ( ) { int arr [ ] [ 2 ] = { { 12 , 18 } , { 420 , 660 } } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countCoprimePair ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, i, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getProduct ( int a [ ] , int n ) { int p = 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { p *= abs ( a [ i ] - a [ j ] ) ; } } return p ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << getProduct ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, p, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void print ( int N ) { for ( int i = 0 ; i < 100000 ; i ++ ) { if ( pow ( i + 1 , 3 ) - pow ( i , 3 ) == N ) { cout << i << ' ▁ ' << i + 1 ; return ; } } } bool isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } bool diffCube ( int N ) { return isPerfectSquare ( 12 * N - 3 ) ; } int main ( ) { int N = 19 ; if ( diffCube ( N ) ) { cout << " Yes STRNEWLINE " ; print ( N ) ; } else { cout << " No STRNEWLINE " ; } return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( int arr [ ] , int n , int left , int right ) { int k = right - left + 1 ; int d = arr [ 1 ] / arr [ 0 ] ; int ans = arr [ left - 1 ] ; if ( d == 1 ) ans = ans * d * k ; else ans = ans * ( ( int ) pow ( d , k ) - 1 / ( d - 1 ) ) ; return ans ; } int main ( ) { int arr [ ] = { 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 } ; int queries = 3 ; int q [ ] [ 2 ] = { { 2 , 4 } , { 2 , 6 } , { 5 , 8 } } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; for ( int i = 0 ; i < queries ; i ++ ) cout << ( findSum ( arr , n , q [ i ] [ 0 ] , q [ i ] [ 1 ] ) ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; ll modPower ( ll a , ll b , ll M ) { ll res = 1 ; while ( b ) { if ( b & 1 ) res = res * a % M ; a = a * a % M ; b >>= 1 ; } return res ; } void findFirstAndLastM ( ll N , ll K , ll M ) { ll lastM = modPower ( N , K , ( 1LL ) * pow ( 10 , M ) ) ; ll firstM ; double y = ( double ) K * log10 ( N * 1.0 ) ; y = y - ( ll ) y ; double temp = pow ( 10.0 , y ) ; firstM = temp * ( 1LL ) * pow ( 10 , M - 1 ) ; cout << firstM << " ▁ " << lastM << endl ; } int main ( ) { ll N = 12 , K = 12 , M = 4 ; findFirstAndLastM ( N , K , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Find_min ( set < int > & diff_mod , map < int , int > count_mod , int k ) { int min_oprn = INT_MAX ; int oprn = 0 ; for ( int x = 0 ; x < k ; x ++ ) { oprn = 0 ; for ( auto w : diff_mod ) { if ( w != x ) { if ( w == 0 ) { oprn += min ( x , k - x ) * count_mod [ w ] ; } else { oprn += min ( abs ( x - w ) , k + x - w ) * count_mod [ w ] ; } } } if ( oprn < min_oprn ) min_oprn = oprn ; } return min_oprn ; } int Cal_min ( int arr [ ] , int n , int k ) { set < int > diff_mod ; map < int , int > count_mod ; for ( int i = 0 ; i < n ; i ++ ) { diff_mod . insert ( arr [ i ] % k ) ; count_mod [ arr [ i ] % k ] ++ ; } return Find_min ( diff_mod , count_mod , k ) ; } int main ( ) { int arr [ ] = { 2 , 35 , 48 , 23 , 52 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; cout << Cal_min ( arr , n , k ) ; return 0 ; }

Index/key variables: i, w
Accumulator variables: i, oprn, stdc, x
Iterator variables: i, w, x
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 ) ; } int findlcm ( int arr [ ] , int n ) { int ans = 1 ; for ( int i = 1 ; i <= n ; i ++ ) ans = ( ( ( arr [ i ] * ans ) ) / ( gcd ( arr [ i ] , ans ) ) ) ; return ans ; } void minimumSteps ( int arr [ ] , int n ) { int i , dat [ n + 1 ] ; for ( i = 1 ; i <= n ; i ++ ) dat [ arr [ i - 1 ] ] = i ; int b [ n + 1 ] , j = 0 , c ; for ( i = 1 ; i <= n ; i ++ ) { c = 1 ; j = dat [ i ] ; while ( j != i ) { c ++ ; j = dat [ j ] ; } b [ i ] = c ; } cout << findlcm ( b , n ) ; } int main ( ) { int arr [ ] = { 5 , 1 , 4 , 3 , 2 , 7 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minimumSteps ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double maximum ( double a , double b ) { if ( a > b ) return a ; return b ; } double maxSubarrayRatio ( double arr [ ] , int n ) { double maxRatio = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { double ratio = arr [ i ] ; for ( int k = i + 1 ; k <= j ; k ++ ) { ratio = ratio / arr [ k ] ; } maxRatio = maximum ( maxRatio , ratio ) ; } } return maxRatio ; } int main ( ) { double arr [ ] = { 2 , 2 , 4 , -0.2 , -1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxSubarrayRatio ( arr , n ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( long n ) ; void check ( long num ) { long root = ( long ) sqrt ( num ) ; long poww = ( long ) ( log ( root ) / log ( 2 ) ) ; if ( num == ( long ) ( pow ( 2 , poww ) * ( pow ( 2 , poww + 1 ) - 1 ) ) ) { if ( isPrime ( poww + 1 ) ) { if ( isPrime ( ( long ) pow ( 2 , poww + 1 ) - 1 ) ) cout << " Yes " << endl ; else cout << " No " << endl ; } else cout << " No " << endl ; } else cout << " No " << endl ; } bool isPrime ( long n ) { if ( n <= 1 ) return false ; else if ( n == 2 n == 3 ) return true ; else { if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( long i = 5 ; i <= sqrt ( n ) ; i += 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; } return true ; } } int main ( ) { long num = 6 ; check ( num ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isTriplet ( int ar [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { if ( abs ( ar [ i ] - ar [ j ] ) == 1 || abs ( ar [ j ] - ar [ k ] ) == 1 || abs ( ar [ i ] - ar [ k ] ) == 1 ) { int x = ar [ i ] * ar [ i ] , y = ar [ j ] * ar [ j ] , z = ar [ k ] * ar [ k ] ; if ( x == y + z y == x + z z == x + y ) return true ; } } } } return false ; } int main ( ) { int arr [ ] = { 3 , 1 , 4 , 6 , 5 } ; int ar_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; isTriplet ( arr , ar_size ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void closestDivisors ( int n ) { for ( int i = sqrt ( n + 2 ) ; i > 0 ; i -- ) { if ( ( n + 1 ) % i == 0 ) { cout << i << " , ▁ " << ( n + 1 ) / i ; break ; } if ( ( n + 2 ) % i == 0 ) { cout << i << " , ▁ " << ( n + 2 ) / i ; break ; } } } int main ( ) { int N = 123 ; closestDivisors ( N ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool is_possible ( int x , int y ) { if ( x < 2 && y != 0 ) return false ; y = y - x + 1 ; if ( y % 2 == 0 && y >= 0 ) return true ; else return false ; } int main ( ) { int x = 5 , y = 2 ; if ( is_possible ( x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int n ) { int phi [ n + 1 ] = { 0 } ; int divs [ n + 1 ] = { 0 } ; for ( int i = 1 ; i <= n ; i ++ ) { phi [ i ] += i ; for ( int j = i * 2 ; j <= n ; j += i ) phi [ j ] -= phi [ i ] ; for ( int j = i ; j <= n ; j += i ) divs [ j ] ++ ; } return ( n - phi [ n ] - divs [ n ] + 1 ) ; } int main ( ) { int N = 42 ; cout << count ( N ) ; return 0 ; }

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

Index/key variables: i, j
Accumulator variables: i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * left , * right ; Node ( int data , Node * left , Node * right ) { this -> data = data ; this -> left = left ; this -> right = right ; } } ; Node * newNode ( int data ) { Node * tmp = new Node ( data , NULL , NULL ) ; return tmp ; } void inorder ( Node * node ) { if ( node == NULL ) return ; inorder ( node -> left ) ; cout << node -> data << " ▁ " ; inorder ( node -> right ) ; } Node * MaximumBinaryTree ( Node * t1 , Node * t2 ) { if ( t1 == NULL ) return t2 ; if ( t2 == NULL ) return t1 ; t1 -> data = max ( t1 -> data , t2 -> data ) ; t1 -> left = MaximumBinaryTree ( t1 -> left , t2 -> left ) ; t1 -> right = MaximumBinaryTree ( t1 -> right , t2 -> right ) ; return t1 ; } int main ( ) { Node * root1 = newNode ( 3 ) ; root1 -> left = newNode ( 2 ) ; root1 -> right = newNode ( 6 ) ; root1 -> left -> left = newNode ( 20 ) ; Node * root2 = newNode ( 5 ) ; root2 -> left = newNode ( 1 ) ; root2 -> right = newNode ( 8 ) ; root2 -> left -> right = newNode ( 2 ) ; root2 -> right -> right = newNode ( 8 ) ; Node * root3 = MaximumBinaryTree ( root1 , root2 ) ; inorder ( root3 ) ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinimumString ( int x ) { int b = 1 ; double left_lim = sqrt ( x ) + 1.0 ; double right_lim = sqrt ( x ) + 2.0 ; int r ; for ( int i = left_lim ; i <= right_lim ; i ++ ) { if ( i > left_lim and i < right_lim ) { r = i ; break ; } } return b + r ; } int main ( ) { int X = 2 ; cout << MinimumString ( X ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( int N ) { int floorSqrt = sqrt ( N ) ; return ( N == floorSqrt * floorSqrt ) ; } bool legendreFunction ( int N ) { while ( N % 4 == 0 ) N /= 4 ; if ( N % 8 != 7 ) return true ; else return false ; } int minSquares ( int N ) { if ( isPerfectSquare ( N ) ) return 1 ; for ( int i = 1 ; i * i < N ; i ++ ) { if ( isPerfectSquare ( N - i * i ) ) return 2 ; } if ( legendreFunction ( N ) ) return 3 ; return 4 ; } int main ( ) { int N = 123 ; cout << minSquares ( N ) ; return 0 ; }

Accumulator variables: N, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool is_distinct ( long long n , long long k ) { unordered_set < long long > s ; for ( int i = 1 ; i <= k ; i ++ ) { long long tmp = n % i ; if ( s . find ( tmp ) != s . end ( ) ) { return false ; } s . insert ( tmp ) ; } return true ; } int main ( ) { long long N = 5 , K = 3 ; if ( is_distinct ( N , K ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; static int getDivisors ( int min , int n ) { int total = 0 ; for ( int i = min ; i < n ; ++ i ) { if ( n % i == 0 && n / i >= i ) { ++ total ; if ( n / i > i ) total += getDivisors ( i , n / i ) ; } } return total ; } int main ( ) { int n = 30 ; cout << 1 + getDivisors ( 2 , n ) ; return 0 ; }

Accumulator variables: stdc, total
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int val ; struct Node * next ; Node ( int _val ) { val = _val ; next = NULL ; } } ; void getLastTwoPerson ( int n ) { int total = n ; struct Node * head = new Node ( 1 ) ; struct Node * temp = head ; for ( int i = 2 ; i <= n ; i ++ ) { temp -> next = new Node ( i ) ; temp = temp -> next ; } temp -> next = head ; temp = head ; struct Node * del ; while ( total != 2 ) { del = temp -> next -> next ; temp -> next -> next = temp -> next -> next -> next ; temp = temp -> next ; free ( del ) ; total -= 1 ; } cout << temp -> val << " ▁ " << temp -> next -> val ; } int main ( ) { int n = 2 ; getLastTwoPerson ( n ) ; return 0 ; }

Accumulator variables: i, stdc, total
Iterator variables: i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinDenomin ( int n ) { return log2 ( n ) + 1 ; } int main ( ) { int n = 10 ; cout << findMinDenomin ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define newl  "
" #define ll  long long
#define pb  push_back
int findContent ( int arr [ ] , int n ) { int content = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { content = __gcd ( content , arr [ i ] ) ; } return content ; } int main ( ) { int n = 3 ; int arr [ ] = { 9 , 6 , 12 } ; cout << findContent ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void inverseEqual ( int arr [ ] , int n ) { int brr [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int present_index = arr [ i ] - 1 ; brr [ present_index ] = i + 1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != brr [ i ] ) { cout << " No " << endl ; return ; } } cout << " Yes " << endl ; } int main ( ) { int n = 4 ; int arr [ n ] = { 1 , 4 , 3 , 2 } ; inverseEqual ( arr , n ) ; return 0 ; }

Index/key variables: i, n, present_index
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool inverseEqual ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ arr [ i ] - 1 ] != i + 1 ) return false ; return true ; } int main ( ) { int n = 4 ; int arr [ n ] = { 1 , 4 , 3 , 2 } ; cout << ( inverseEqual ( arr , n ) ? " Yes " : " No " ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void linearCongruentialMethod ( int Xo , int m , int a , int c , vector < int > & randomNums , int noOfRandomNums ) { randomNums [ 0 ] = Xo ; for ( int i = 1 ; i < noOfRandomNums ; i ++ ) { randomNums [ i ] = ( ( randomNums [ i - 1 ] * a ) + c ) % m ; } } int main ( ) { int Xo = 5 ; int m = 7 ; int a = 3 ; int c = 3 ; int noOfRandomNums = 10 ; vector < int > randomNums ( noOfRandomNums ) ; linearCongruentialMethod ( Xo , m , a , c , randomNums , noOfRandomNums ) ; for ( int i = 0 ; i < noOfRandomNums ; i ++ ) { cout << randomNums [ i ] << " ▁ " ; } return 0 ; }

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