dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; Node * temp = NULL ; Node * kthAncestorDFS ( Node * root , int node , int & k ) { if ( ! root ) return NULL ; if ( root -> data == node || ( temp = kthAncestorDFS ( root -> left , node , k ) ) || ( temp = kthAncestorDFS ( root -> right , node , k ) ) ) { if ( k > 0 ) k -- ; else if ( k == 0 ) { cout << " Kth ▁ ancestor ▁ is : ▁ " << root -> data ; return NULL ; } return root ; } } Node * newNode ( int data ) { Node * temp = new Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; int k = 2 ; int node = 5 ; Node * parent = kthAncestorDFS ( root , node , k ) ; if ( parent ) cout << " - 1" ; return 0 ; }

Accumulator variables: k, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return ( temp ) ; } void EncodeSuccinct ( Node * root , list < bool > & struc , list < int > & data ) { if ( root == NULL ) { struc . push_back ( 0 ) ; return ; } struc . push_back ( 1 ) ; data . push_back ( root -> key ) ; EncodeSuccinct ( root -> left , struc , data ) ; EncodeSuccinct ( root -> right , struc , data ) ; } Node * DecodeSuccinct ( list < bool > & struc , list < int > & data ) { if ( struc . size ( ) <= 0 ) return NULL ; bool b = struc . front ( ) ; struc . pop_front ( ) ; if ( b == 1 ) { int key = data . front ( ) ; data . pop_front ( ) ; Node * root = newNode ( key ) ; root -> left = DecodeSuccinct ( struc , data ) ; root -> right = DecodeSuccinct ( struc , data ) ; return root ; } return NULL ; } void preorder ( Node * root ) { if ( root ) { cout << " key : ▁ " << root -> key ; if ( root -> left ) cout << " ▁ | ▁ left ▁ child : ▁ " << root -> left -> key ; if ( root -> right ) cout << " ▁ | ▁ right ▁ child : ▁ " << root -> right -> key ; cout << endl ; preorder ( root -> left ) ; preorder ( root -> right ) ; } } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 20 ) ; root -> right = newNode ( 30 ) ; root -> left -> left = newNode ( 40 ) ; root -> left -> right = newNode ( 50 ) ; root -> right -> right = newNode ( 70 ) ; cout << " Given ▁ Tree STRNEWLINE " ; preorder ( root ) ; list < bool > struc ; list < int > data ; EncodeSuccinct ( root , struc , data ) ; cout << " Encoded Tree " cout << " Structure ▁ List STRNEWLINE " ; list < bool > :: iterator si ; for ( si = struc . begin ( ) ; si != struc . end ( ) ; ++ si ) cout << * si << " ▁ " ; cout << " Data List " list < int > :: iterator di ; for ( di = data . begin ( ) ; di != data . end ( ) ; ++ di ) cout << * di << " ▁ " ; Node * newroot = DecodeSuccinct ( struc , data ) ; cout << " Preorder traversal of decoded tree " ; preorder ( newroot ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: di, si
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void update ( int arr [ ] , int l , int r , int val ) { arr [ l ] += val ; arr [ r + 1 ] -= val ; } int getElement ( int arr [ ] , int i ) { int res = 0 ; for ( int j = 0 ; j <= i ; j ++ ) res += arr [ j ] ; return res ; } int main ( ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int l = 2 , r = 4 , val = 2 ; update ( arr , l , r , val ) ; int index = 4 ; cout << " Element ▁ at ▁ index ▁ " << index << " ▁ is ▁ " << getElement ( arr , index ) << endl ; l = 0 , r = 3 , val = 4 ; update ( arr , l , r , val ) ; index = 3 ; cout << " Element ▁ at ▁ index ▁ " << index << " ▁ is ▁ " << getElement ( arr , index ) << endl ; return 0 ; }

Index/key variables: j, l
Accumulator variables: j, res, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void updateBIT ( int BITree [ ] , int n , int index , int val ) { index = index + 1 ; while ( index <= n ) { BITree [ index ] += val ; index += index & ( - index ) ; } } int * constructBITree ( int arr [ ] , int n ) { int * BITree = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) BITree [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) updateBIT ( BITree , n , i , arr [ i ] ) ; return BITree ; } int getSum ( int BITree [ ] , int index ) { int sum = 0 ; index = index + 1 ; while ( index > 0 ) { sum += BITree [ index ] ; index -= index & ( - index ) ; } return sum ; } void update ( int BITree [ ] , int l , int r , int n , int val ) { updateBIT ( BITree , n , l , val ) ; updateBIT ( BITree , n , r + 1 , - val ) ; } int main ( ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int * BITree = constructBITree ( arr , n ) ; int l = 2 , r = 4 , val = 2 ; update ( BITree , l , r , n , val ) ; int index = 4 ; cout << " Element ▁ at ▁ index ▁ " << index << " ▁ is ▁ " << getSum ( BITree , index ) << " STRNEWLINE " ; l = 0 , r = 3 , val = 4 ; update ( BITree , l , r , n , val ) ; index = 3 ; cout << " Element ▁ at ▁ index ▁ " << index << " ▁ is ▁ " << getSum ( BITree , index ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, index
Accumulator variables: i, index, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int preIndex = 0 ; void printPost ( int in [ ] , int pre [ ] , int inStrt , int inEnd , map < int , int > hm ) { if ( inStrt > inEnd ) return ; int inIndex = hm [ pre [ preIndex ++ ] ] ; printPost ( in , pre , inStrt , inIndex - 1 , hm ) ; printPost ( in , pre , inIndex + 1 , inEnd , hm ) ; cout << in [ inIndex ] << " ▁ " ; } void printPostMain ( int in [ ] , int pre [ ] , int n ) { map < int , int > hm ; for ( int i = 0 ; i < n ; i ++ ) hm [ in [ i ] ] = i ; printPost ( in , pre , 0 , n - 1 , hm ) ; } int main ( ) { int in [ ] = { 4 , 2 , 5 , 1 , 3 , 6 } ; int pre [ ] = { 1 , 2 , 4 , 5 , 3 , 6 } ; int n = sizeof ( pre ) / sizeof ( pre [ 0 ] ) ; printPostMain ( in , pre , n ) ; return 0 ; }

Index/key variables: i, inIndex
Accumulator variables: i, preIndex, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool issafe ( int m , int n , int i , int j ) { if ( i < 0 ) return false ; if ( j < 0 ) return false ; if ( i >= m ) return false ; if ( j >= n ) return false ; return true ; } pair < int , int > endpoints ( vector < vector < int > > arr , int m , int n ) { int i = 0 ; int j = 0 ; int current_i = 0 ; int current_j = 0 ; char current_d = ' r ' ; map < char , char > rcd = { { ' l ' , ' u ' } , { ' u ' , ' r ' } , { ' r ' , ' d ' } , { ' d ' , ' l ' } } ; while ( issafe ( m , n , i , j ) ) { current_i = i ; current_j = j ; if ( arr [ i ] [ j ] == 1 ) { char move_in = rcd [ current_d ] ; arr [ i ] [ j ] = 0 ; if ( move_in == ' u ' ) i -= 1 ; else if ( move_in == ' d ' ) i += 1 ; else if ( move_in == ' l ' ) j -= 1 ; else if ( move_in == ' r ' ) j += 1 ; current_d = move_in ; } else { if ( current_d == ' u ' ) i -= 1 ; else if ( current_d == ' d ' ) i += 1 ; else if ( current_d == ' l ' ) j -= 1 ; else if ( current_d == ' r ' ) j += 1 ; } } return { current_i , current_j } ; } int main ( ) { int M = 3 ; int N = 5 ; vector < vector < int > > arr { { 0 , 1 , 1 , 1 , 0 } , { 1 , 0 , 1 , 0 , 1 } , { 1 , 1 , 1 , 0 , 0 } } ; pair < int , int > p = endpoints ( arr , M , N ) ; cout << " ( " << p . first << " , ▁ " << p . second << " ) " << endl ; }

Index/key variables: current_d, i, j
Accumulator variables: i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sumOfTwoPerfectCubes ( int N ) { map < int , int > cubes ; for ( int i = 1 ; i * i * i <= N ; i ++ ) cubes [ i * i * i ] = i ; map < int , int > :: iterator itr ; for ( itr = cubes . begin ( ) ; itr != cubes . end ( ) ; itr ++ ) { int firstNumber = itr -> first ; int secondNumber = N - itr -> first ; if ( cubes . find ( secondNumber ) != cubes . end ( ) ) { cout << " True " ; return ; } } cout << " False " ; } int main ( ) { int N = 28 ; sumOfTwoPerfectCubes ( N ) ; return 0 ; }

Accumulator variables: i, itr, stdc
Iterator variables: i, itr
C++ program:
#include <bits/stdc++.h>
#define mod  1000000007
using namespace std ; void countSets ( int * arr , int n ) { int cnt = 0 ; int maxE = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( maxE < arr [ i ] ) maxE = arr [ i ] ; } int * sieve = new int [ maxE + 1 ] ; for ( int i = 0 ; i <= maxE ; i ++ ) sieve [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) sieve [ arr [ i ] ] = 1 ; for ( int i = 1 ; i <= maxE ; i ++ ) { if ( sieve [ i ] != 0 ) { for ( int j = i * 2 ; j <= maxE ; j += i ) { if ( sieve [ j ] != 0 ) sieve [ j ] = ( sieve [ j ] + sieve [ i ] ) % mod ; } } } for ( int i = 0 ; i <= maxE ; i ++ ) cnt = ( cnt % mod + sieve [ i ] % mod ) % mod ; delete [ ] sieve ; cout << cnt % mod ; } int main ( ) { int arr [ ] = { 16 , 18 , 6 , 7 , 2 , 19 , 20 , 9 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countSets ( 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 ; #define MAX  100001
int spf [ MAX ] ; vector < int > v [ MAX ] ; void sieve ( ) { for ( int i = 1 ; i < MAX ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAX ; i = i + 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAX ; i ++ ) if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAX ; j = j + i ) { if ( spf [ j ] == j ) spf [ j ] = i ; } } } void DistPrime ( ) { for ( int i = 1 ; i < MAX ; i ++ ) { int idx = 1 ; int x = i ; if ( x != 1 ) v [ i ] . push_back ( spf [ x ] ) ; x = x / spf [ x ] ; while ( x != 1 ) { if ( v [ i ] [ idx - 1 ] != spf [ x ] ) { v [ i ] . push_back ( spf [ x ] ) ; idx += 1 ; } x = x / spf [ x ] ; } } } void getFactorCount ( int arr [ ] , int N ) { sieve ( ) ; DistPrime ( ) ; for ( int i = 0 ; i < N ; i ++ ) { cout << ( int ) v [ arr [ i ] ] . size ( ) << " ▁ " ; } } int main ( ) { int arr [ ] = { 6 , 9 , 12 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; getFactorCount ( arr , N ) ; return 0 ; }

Index/key variables: MAX, i, j, x
Accumulator variables: i, idx, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findDay ( int Y , int B ) { int lyear , rest , totaldays , day ; Y = ( Y - 1 ) - B ; lyear = Y / 4 ; rest = Y - lyear ; totaldays = ( rest * 365 ) + ( lyear * 366 ) + 1 ; day = ( totaldays % 7 ) ; if ( day == 0 ) printf ( " Monday " ) ; else if ( day == 1 ) printf ( " Tuesday " ) ; else if ( day == 2 ) printf ( " Wednesday " ) ; else if ( day == 3 ) printf ( " Thursday " ) ; else if ( day == 4 ) printf ( " Friday " ) ; else if ( day == 5 ) printf ( " Saturday " ) ; else if ( day == 6 ) printf ( " Sunday " ) ; else printf ( " INPUT ▁ YEAR ▁ IS ▁ WRONG ! " ) ; } int main ( ) { int Y = 2020 , B = 1900 ; findDay ( Y , B ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } void modifyArray ( int arr [ ] , int N , int Q [ ] [ 2 ] , int cntQuery ) { int arr1 [ N + 1 ] = { 0 } ; int arr2 [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < cntQuery ; i ++ ) { int L = Q [ i ] [ 0 ] + 1 , R = Q [ i ] [ 1 ] + 1 ; arr1 [ L ] ++ ; arr1 [ R + 1 ] -- ; arr2 [ R + 1 ] -= R - L + 1 ; } for ( int i = 1 ; i <= N ; i ++ ) arr1 [ i ] += arr1 [ i - 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) arr2 [ i ] += arr2 [ i - 1 ] + arr1 [ i ] ; for ( int i = 1 ; i <= N ; i ++ ) arr [ i - 1 ] = arr2 [ i ] ; printArray ( arr , N ) ; } int main ( ) { int arr [ ] = { 0 , 0 , 0 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int Q [ ] [ 2 ] = { { 1 , 3 } , { 0 , 1 } } ; int cntQuery = sizeof ( Q ) / sizeof ( Q [ 0 ] ) ; modifyArray ( arr , N , Q , cntQuery ) ; return 0 ; }

Index/key variables: L, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findProduct ( int number_1 , int number_2 ) { if ( number_1 == INT_MIN or number_2 == INT_MIN ) return 0 ; else return number_1 * number_2 ; } pair < int , int > calculateProduct ( vector < vector < int > > List , int index ) { int highest = * max_element ( List [ index ] . begin ( ) , List [ index ] . end ( ) ) ; int lowest = * min_element ( List [ index ] . begin ( ) , List [ index ] . end ( ) ) ; if ( index + 1 == List . size ( ) ) { if ( lowest < 0 and highest > = 0 ) return { highest , lowest } ; else if ( lowest <= 0 and highest <= 0 ) return { INT_MIN , lowest } ; else if ( lowest >= 0 and highest >= 0 ) return { highest , INT_MIN } ; } pair < int , int > temp = calculateProduct ( List , index + 1 ) ; int positive = temp . first ; int negative = temp . second ; int highPos = findProduct ( highest , positive ) ; int highNeg = findProduct ( highest , negative ) ; int lowPos = findProduct ( lowest , positive ) ; int lowNeg = findProduct ( lowest , negative ) ; if ( lowest < 0 and highest > = 0 ) return { max ( highPos , lowNeg ) , min ( highNeg , lowPos ) } ; else if ( lowest <= 0 and highest <= 0 ) return { lowNeg , lowPos } ; else if ( lowest >= 0 and highest >= 0 ) return { max ( lowPos , highPos ) , min ( lowNeg , highNeg ) } ; } int main ( ) { int N = 2 ; vector < vector < int > > arr { { -3 , -4 } , { 1 , 2 , -3 } } ; pair < int , int > ans = calculateProduct ( arr , 0 ) ; cout << ans . first << endl ; }

Index/key variables: index
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; void maxNumTrailNine ( int n , int d ) { int res = n ; int cntDigits = log10 ( n ) + 1 ; int p10 = 10 ; for ( int i = 1 ; i <= cntDigits ; i ++ ) { if ( n % p10 >= d ) { break ; } else { res = n - n % p10 - 1 ; } p10 = p10 * 10 ; } cout << res ; } int main ( ) { int n = 1025 , d = 6 ; maxNumTrailNine ( n , d ) ; }

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

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int minChocolates ( int a [ ] , int n ) { int i = 0 , j = 0 ; int res = 0 , val = 1 ; while ( j < n - 1 ) { if ( a [ j ] > a [ j + 1 ] ) { j += 1 ; continue ; } if ( i == j ) res += val ; else { res += get_sum ( val , i , j ) ; } if ( a [ j ] < a [ j + 1 ] ) val += 1 ; else val = 1 ; j += 1 ; i = j ; } if ( i == j ) res += val ; else res += get_sum ( val , i , j ) ; return res ; } int get_sum ( int peak , int start , int end ) { int count = end - start + 1 ; peak = max ( peak , count ) ; int s = peak + ( ( ( count - 1 ) * count ) >> 1 ) ; return s ; } int main ( ) { int a [ ] = { 5 , 5 , 4 , 3 , 2 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << " Minimum ▁ number ▁ of ▁ chocolates ▁ = ▁ " << minChocolates ( a , n ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: j
Accumulator variables: j, res, val
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > RemoveElemArr ( vector < int > & arr , int n , int k ) { if ( n == 0 n == 1 ) return arr ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( j < k arr [ i ] > arr [ j - k ] ) { arr [ j ++ ] = arr [ i ] ; } } while ( arr . size ( ) > j ) { arr . pop_back ( ) ; } return arr ; } void printArray ( vector < int > & arr ) { for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } void UtilRemov ( vector < int > & arr , int n , int k ) { arr = RemoveElemArr ( arr , n , k ) ; printArray ( arr ) ; } int main ( ) { vector < int > arr = { 1 , 2 , 2 , 3 , 4 , 4 , 4 , 5 , 5 } ; int k = 2 ; int n = arr . size ( ) ; UtilRemov ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void pairs_after_removing ( int arr [ ] , int N ) { int cntPairs = 0 ; unordered_map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } for ( auto element : mp ) { int i = element . first ; cntPairs += mp [ i ] * ( mp [ i ] - 1 ) / 2 ; } for ( int i = 0 ; i < N ; i ++ ) { int pairs_after_arr_i_removed = cntPairs + 1 - mp [ arr [ i ] ] ; cout << pairs_after_arr_i_removed << ' ▁ ' ; } return ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 3 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; pairs_after_removing ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cntPairs, i, stdc
Iterator variables: element, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestDivisorGr1 ( int N ) { for ( int i = 2 ; i <= sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { return i ; } } return N ; } int findValOfNWithOperat ( int N , int K ) { if ( N % 2 == 0 ) { N += K * 2 ; } else { N += smallestDivisorGr1 ( N ) + ( K - 1 ) * 2 ; } return N ; } int main ( ) { int N = 6 , K = 4 ; cout << findValOfNWithOperat ( N , K ) ; return 0 ; }

Accumulator variables: N, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CntOfSubsetsByPartitioning ( int arr [ ] , int N ) { unordered_map < int , int > freq ; for ( int i = 0 ; i < N ; i ++ ) { freq [ arr [ i ] ] ++ ; } int freqGCD = 0 ; for ( auto i : freq ) { freqGCD = __gcd ( freqGCD , i . second ) ; } return ( N ) / freqGCD ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << CntOfSubsetsByPartitioning ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int r , c ; vector < vector < int > > dir = { { 1 , 0 } , { -1 , 0 } , { 0 , 1 } , { 0 , -1 } , { -1 , -1 } , { -1 , 1 } , { 1 , 1 } , { 1 , -1 } } ; bool valid ( int i , int j ) { if ( i >= 0 && j >= 0 && i < r && j < c ) return 1 ; return 0 ; } int find ( int i , int j , vector < vector < int > > & v ) { int s = 0 ; for ( auto x : dir ) { int ni = i + x [ 0 ] , nj = j + x [ 1 ] ; if ( valid ( ni , nj ) ) s += v [ ni ] [ nj ] ; } return s ; } void findsumofneighbors ( vector < vector < int > > & M ) { vector < vector < int > > v ( r , vector < int > ( c , 0 ) ) ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { v [ i ] [ j ] = find ( i , j , M ) ; cout << v [ i ] [ j ] << " ▁ " ; } cout << " STRNEWLINE " ; } } int main ( ) { vector < vector < int > > M = { { 1 , 4 , 1 } , { 2 , 4 , 5 } , { 3 , 1 , 2 } } ; r = M . size ( ) , c = M [ 0 ] . size ( ) ; findsumofneighbors ( M ) ; }

Index/key variables: i, j, ni, nj
Accumulator variables: i, j, s, stdc
Iterator variables: i, j, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mod = 1e9 + 7 ; int T [ 2000 ] [ 2000 ] ; int result [ 2000 ] [ 2000 ] ; void mul_2 ( int K ) { int temp [ K + 1 ] [ K + 1 ] ; memset ( temp , 0 , sizeof temp ) ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { for ( int k = 1 ; k <= K ; k ++ ) { temp [ i ] [ j ] = ( temp [ i ] [ j ] + ( T [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod ; } } } for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { T [ i ] [ j ] = temp [ i ] [ j ] ; } } } void mul_1 ( int K ) { int temp [ K + 1 ] [ K + 1 ] ; memset ( temp , 0 , sizeof temp ) ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { for ( int k = 1 ; k <= K ; k ++ ) { temp [ i ] [ j ] = ( temp [ i ] [ j ] + ( result [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod ; } } } for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { result [ i ] [ j ] = temp [ i ] [ j ] ; } } } void matrix_pow ( int K , int n ) { for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { if ( i == j ) result [ i ] [ j ] = 1 ; } } while ( n > 0 ) { if ( n % 2 == 1 ) mul_1 ( K ) ; mul_2 ( K ) ; n /= 2 ; } } int NthTerm ( int F [ ] , int C [ ] , int K , int n ) { for ( int i = 1 ; i <= K ; i ++ ) T [ i ] [ K ] = C [ K - i ] ; for ( int i = 1 ; i <= K ; i ++ ) T [ i + 1 ] [ i ] = 1 ; matrix_pow ( K , n ) ; int answer = 0 ; for ( int i = 1 ; i <= K ; i ++ ) { answer += F [ i - 1 ] * result [ i ] [ 1 ] ; } cout << answer << endl ; return 0 ; } int main ( ) { int F [ ] = { 1 , 2 , 3 } ; int C [ ] = { 1 , 1 , 1 } ; int K = 3 ; int N = 10 ; NthTerm ( F , C , K , N ) ; return 0 ; }

Index/key variables: K, i, j, k
Accumulator variables: answer, i, j, k, n, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; double nthRoot ( int A , int N ) { double xPre = rand ( ) % 10 ; double eps = 1e-3 ; double delX = INT_MAX ; double xK ; while ( delX > eps ) { xK = ( ( N - 1.0 ) * xPre + ( double ) A / pow ( xPre , N - 1 ) ) / ( double ) N ; delX = abs ( xK - xPre ) ; xPre = xK ; } return xK ; } float RMNValue ( int arr [ ] , int n , int k ) { int Nth = 0 ; float mean = 0.0 , root = 0.0 ; for ( int i = 0 ; i < n ; i ++ ) { Nth += pow ( arr [ i ] , k ) ; } mean = ( Nth / ( float ) ( n ) ) ; root = nthRoot ( mean , k ) ; return root ; } int main ( ) { int arr [ ] = { 10 , 4 , 6 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 3 ; cout << RMNValue ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: Nth, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; stack < int > addStack ( stack < int > N1 , stack < int > N2 ) { stack < int > res ; int sum = 0 , rem = 0 ; while ( ! N1 . empty ( ) and ! N2 . empty ( ) ) { sum = ( rem + N1 . top ( ) + N2 . top ( ) ) ; res . push ( sum % 10 ) ; rem = sum / 10 ; N1 . pop ( ) ; N2 . pop ( ) ; } while ( ! N1 . empty ( ) ) { sum = ( rem + N1 . top ( ) ) ; res . push ( sum % 10 ) ; rem = sum / 10 ; N1 . pop ( ) ; } while ( ! N2 . empty ( ) ) { sum = ( rem + N2 . top ( ) ) ; res . push ( sum % 10 ) ; rem = sum / 10 ; N2 . pop ( ) ; } while ( rem > 0 ) { res . push ( rem ) ; rem /= 10 ; } while ( ! res . empty ( ) ) { N1 . push ( res . top ( ) ) ; res . pop ( ) ; } res = N1 ; return res ; } void display ( stack < int > & res ) { int N = res . size ( ) ; string s = " " ; while ( ! res . empty ( ) ) { s = to_string ( res . top ( ) ) + s ; res . pop ( ) ; } cout << s << endl ; } int main ( ) { stack < int > N1 ; N1 . push ( 5 ) ; N1 . push ( 8 ) ; N1 . push ( 7 ) ; N1 . push ( 4 ) ; stack < int > N2 ; N2 . push ( 2 ) ; N2 . push ( 1 ) ; N2 . push ( 3 ) ; stack < int > res = addStack ( N1 , N2 ) ; display ( res ) ; return 0 ; }

Accumulator variables: rem, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define lli  long long int
bool isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } void checkFactors ( lli N ) { if ( isPerfectSquare ( N ) ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { lli N = 36 ; checkFactors ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int total_xor ; void initialize_xor ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { total_xor = total_xor ^ arr [ i ] ; } } void find_xor ( int X , int Y ) { total_xor = total_xor ^ X ; total_xor = total_xor ^ Y ; cout << total_xor << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 5 , 7 , 8 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; initialize_xor ( arr , n ) ; vector < vector < int > > Q = { { 5 , 6 } , { 8 , 1 } } ; for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { find_xor ( Q [ i ] [ 0 ] , Q [ i ] [ 1 ] ) ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxGCD ( int N ) { for ( int i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { return N / i ; } } return 1 ; } int main ( ) { int N = 33 ; cout << " Maximum ▁ Possible ▁ GCD ▁ value ▁ is ▁ : ▁ " << maxGCD ( N ) << endl ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i