dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
#include <queue>
using namespace std ; struct Node { int data ; Node * left ; Node * right ; } ; Node * CreateNode ( int data ) { Node * newNode = new Node ( ) ; if ( ! newNode ) { cout << " Memory ▁ error STRNEWLINE " ; return NULL ; } newNode -> data = data ; newNode -> left = newNode -> right = NULL ; return newNode ; } void inorder ( Node * temp ) { if ( temp == NULL ) return ; inorder ( temp -> left ) ; cout << temp -> data << ' ▁ ' ; inorder ( temp -> right ) ; } Node * InsertNode ( Node * root , int data ) { if ( root == NULL ) { root = CreateNode ( data ) ; return root ; } queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( temp -> left != NULL ) q . push ( temp -> left ) ; else { temp -> left = CreateNode ( data ) ; return root ; } if ( temp -> right != NULL ) q . push ( temp -> right ) ; else { temp -> right = CreateNode ( data ) ; return root ; } } } int main ( ) { Node * root = CreateNode ( 10 ) ; root -> left = CreateNode ( 11 ) ; root -> left -> left = CreateNode ( 7 ) ; root -> right = CreateNode ( 9 ) ; root -> right -> left = CreateNode ( 15 ) ; root -> right -> right = CreateNode ( 8 ) ; cout << " Inorder ▁ traversal ▁ before ▁ insertion : ▁ " ; inorder ( root ) ; cout << endl ; int key = 12 ; root = InsertNode ( root , key ) ; cout << " Inorder ▁ traversal ▁ after ▁ insertion : ▁ " ; inorder ( root ) ; cout << endl ; return 0 ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void TOWUtil ( int * arr , int n , bool * curr_elements , int no_of_selected_elements , bool * soln , int * min_diff , int sum , int curr_sum , int curr_position ) { if ( curr_position == n ) return ; if ( ( n / 2 - no_of_selected_elements ) > ( n - curr_position ) ) return ; TOWUtil ( arr , n , curr_elements , no_of_selected_elements , soln , min_diff , sum , curr_sum , curr_position + 1 ) ; no_of_selected_elements ++ ; curr_sum = curr_sum + arr [ curr_position ] ; curr_elements [ curr_position ] = true ; if ( no_of_selected_elements == n / 2 ) { if ( abs ( sum / 2 - curr_sum ) < * min_diff ) { * min_diff = abs ( sum / 2 - curr_sum ) ; for ( int i = 0 ; i < n ; i ++ ) soln [ i ] = curr_elements [ i ] ; } } else { TOWUtil ( arr , n , curr_elements , no_of_selected_elements , soln , min_diff , sum , curr_sum , curr_position + 1 ) ; } curr_elements [ curr_position ] = false ; } void tugOfWar ( int * arr , int n ) { bool * curr_elements = new bool [ n ] ; bool * soln = new bool [ n ] ; int min_diff = INT_MAX ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; curr_elements [ i ] = soln [ i ] = false ; } TOWUtil ( arr , n , curr_elements , 0 , soln , & min_diff , sum , 0 , 0 ) ; cout << " The ▁ first ▁ subset ▁ is : ▁ " ; for ( int i = 0 ; i < n ; i ++ ) { if ( soln [ i ] == true ) cout << arr [ i ] << " ▁ " ; } cout << " The second subset is : " for ( int i = 0 ; i < n ; i ++ ) { if ( soln [ i ] == false ) cout << arr [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 23 , 45 , -34 , 12 , 0 , 98 , -99 , 4 , 189 , -1 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; tugOfWar ( arr , n ) ; return 0 ; }

Index/key variables: curr_position, i, n
Accumulator variables: i, no_of_selected_elements, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  8
int solveKTUtil ( int x , int y , int movei , int sol [ N ] [ N ] , int xMove [ ] , int yMove [ ] ) ; int isSafe ( int x , int y , int sol [ N ] [ N ] ) { return ( x >= 0 && x < N && y >= 0 && y < N && sol [ x ] [ y ] == -1 ) ; } void printSolution ( int sol [ N ] [ N ] ) { for ( int x = 0 ; x < N ; x ++ ) { for ( int y = 0 ; y < N ; y ++ ) cout << " ▁ " << setw ( 2 ) << sol [ x ] [ y ] << " ▁ " ; cout << endl ; } } int solveKT ( ) { int sol [ N ] [ N ] ; for ( int x = 0 ; x < N ; x ++ ) for ( int y = 0 ; y < N ; y ++ ) sol [ x ] [ y ] = -1 ; int xMove [ 8 ] = { 2 , 1 , -1 , -2 , -2 , -1 , 1 , 2 } ; int yMove [ 8 ] = { 1 , 2 , 2 , 1 , -1 , -2 , -2 , -1 } ; sol [ 0 ] [ 0 ] = 0 ; if ( solveKTUtil ( 0 , 0 , 1 , sol , xMove , yMove ) == 0 ) { cout << " Solution ▁ does ▁ not ▁ exist " ; return 0 ; } else printSolution ( sol ) ; return 1 ; } int solveKTUtil ( int x , int y , int movei , int sol [ N ] [ N ] , int xMove [ N ] , int yMove [ N ] ) { int k , next_x , next_y ; if ( movei == N * N ) return 1 ; for ( k = 0 ; k < 8 ; k ++ ) { next_x = x + xMove [ k ] ; next_y = y + yMove [ k ] ; if ( isSafe ( next_x , next_y , sol ) ) { sol [ next_x ] [ next_y ] = movei ; if ( solveKTUtil ( next_x , next_y , movei + 1 , sol , xMove , yMove ) == 1 ) return 1 ; else sol [ next_x ] [ next_y ] = -1 ; } } return 0 ; } int main ( ) { solveKT ( ) ; return 0 ; }

Index/key variables: N, k, next_x, next_y, x, y
Accumulator variables: k, stdc, x, y
Iterator variables: k, x, y
C++ program:
#include <stdio.h>
#define N  4
bool solveMazeUtil ( int maze [ N ] [ N ] , int x , int y , int sol [ N ] [ N ] ) ; void printSolution ( int sol [ N ] [ N ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) printf ( " ▁ % d ▁ " , sol [ i ] [ j ] ) ; printf ( " STRNEWLINE " ) ; } } bool isSafe ( int maze [ N ] [ N ] , int x , int y ) { if ( x >= 0 && x < N && y >= 0 && y < N && maze [ x ] [ y ] == 1 ) return true ; return false ; } bool solveMaze ( int maze [ N ] [ N ] ) { int sol [ N ] [ N ] = { { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } } ; if ( solveMazeUtil ( maze , 0 , 0 , sol ) == false ) { printf ( " Solution ▁ doesn ' t ▁ exist " ) ; return false ; } printSolution ( sol ) ; return true ; } bool solveMazeUtil ( int maze [ N ] [ N ] , int x , int y , int sol [ N ] [ N ] ) { if ( x == N - 1 && y == N - 1 && maze [ x ] [ y ] == 1 ) { sol [ x ] [ y ] = 1 ; return true ; } if ( isSafe ( maze , x , y ) == true ) { if ( sol [ x ] [ y ] == 1 ) return false ; sol [ x ] [ y ] = 1 ; if ( solveMazeUtil ( maze , x + 1 , y , sol ) == true ) return true ; if ( solveMazeUtil ( maze , x , y + 1 , sol ) == true ) return true ; if ( solveMazeUtil ( maze , x - 1 , y , sol ) == true ) return true ; if ( solveMazeUtil ( maze , x , y - 1 , sol ) == true ) return true ; sol [ x ] [ y ] = 0 ; return false ; } return false ; } int main ( ) { int maze [ N ] [ N ] = { { 1 , 0 , 0 , 0 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 0 , 0 } , { 1 , 1 , 1 , 1 } } ; solveMaze ( maze ) ; return 0 ; }

Index/key variables: N, i, j, x, y
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define V  4
void printSolution ( int color [ ] ) ; void printSolution ( int color [ ] ) { cout << " Solution ▁ Exists : " " ▁ Following ▁ are ▁ the ▁ assigned ▁ colors ▁ STRNEWLINE " ; for ( int i = 0 ; i < V ; i ++ ) cout << " ▁ " << color [ i ] ; cout << " STRNEWLINE " ; } bool isSafe ( bool graph [ V ] [ V ] , int color [ ] ) { for ( int i = 0 ; i < V ; i ++ ) for ( int j = i + 1 ; j < V ; j ++ ) if ( graph [ i ] [ j ] && color [ j ] == color [ i ] ) return false ; return true ; } bool graphColoring ( bool graph [ V ] [ V ] , int m , int i , int color [ V ] ) { if ( i == V ) { if ( isSafe ( graph , color ) ) { printSolution ( color ) ; return true ; } return false ; } for ( int j = 1 ; j <= m ; j ++ ) { color [ i ] = j ; if ( graphColoring ( graph , m , i + 1 , color ) ) return true ; color [ i ] = 0 ; } return false ; } int main ( ) { bool graph [ V ] [ V ] = { { 0 , 1 , 1 , 1 } , { 1 , 0 , 1 , 0 } , { 1 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } , } ; int m = 3 ; int color [ V ] ; for ( int i = 0 ; i < V ; i ++ ) color [ i ] = 0 ; if ( ! graphColoring ( graph , m , 0 , color ) ) cout << " Solution ▁ does ▁ not ▁ exist " ; return 0 ; }

Index/key variables: V, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; class node { public : int color = 1 ; set < int > edges ; } ; int canPaint ( vector < node > & nodes , int n , int m ) { vector < int > visited ( n + 1 , 0 ) ; int maxColors = 1 ; for ( int sv = 1 ; sv <= n ; sv ++ ) { if ( visited [ sv ] ) continue ; visited [ sv ] = 1 ; queue < int > q ; q . push ( sv ) ; while ( ! q . empty ( ) ) { int top = q . front ( ) ; q . pop ( ) ; for ( auto it = nodes [ top ] . edges . begin ( ) ; it != nodes [ top ] . edges . end ( ) ; it ++ ) { if ( nodes [ top ] . color == nodes [ * it ] . color ) nodes [ * it ] . color += 1 ; maxColors = max ( maxColors , max ( nodes [ top ] . color , nodes [ * it ] . color ) ) ; if ( maxColors > m ) return 0 ; if ( ! visited [ * it ] ) { visited [ * it ] = 1 ; q . push ( * it ) ; } } } } return 1 ; } int main ( ) { int n = 4 ; bool graph [ n ] [ n ] = { { 0 , 1 , 1 , 1 } , { 1 , 0 , 1 , 0 } , { 1 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } } ; int m = 3 ; vector < node > nodes ( n + 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( graph [ i ] [ j ] ) { nodes [ i ] . edges . insert ( i ) ; nodes [ j ] . edges . insert ( j ) ; } } } cout << canPaint ( nodes , n , m ) ; cout << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, j, n, sv, top
Accumulator variables: color, i, it, j, stdc, sv
Iterator variables: i, it, j, sv
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntMaxOperationToMakeN_1_0 ( int arr [ ] , int N ) { int cntOp = 0 ; priority_queue < int > PQ ; for ( int i = 0 ; i < N ; i ++ ) { PQ . push ( arr [ i ] ) ; } while ( PQ . size ( ) > 1 ) { int X = PQ . top ( ) ; PQ . pop ( ) ; int Y = PQ . top ( ) ; PQ . pop ( ) ; X -- ; Y -- ; if ( X != 0 ) { PQ . push ( X ) ; } if ( Y != 0 ) { PQ . push ( Y ) ; } cntOp += 1 ; } return cntOp ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntMaxOperationToMakeN_1_0 ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: X, Y, cntOp, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void flippingBits ( unsigned long N , unsigned long K ) { unsigned long X = ( 1 << ( K - 1 ) ) - 1 ; N = X - N ; cout << N ; } int main ( ) { unsigned long N = 1 , K = 8 ; flippingBits ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateMatrix ( int N ) { int odd = 1 ; int even = 2 ; int mat [ N + 1 ] [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { mat [ i ] [ j ] = odd ; odd += 2 ; } else { mat [ i ] [ j ] = even ; even += 2 ; } } } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { cout << mat [ i ] [ j ] << " ▁ " ; } cout << endl ; } } int main ( ) { int N = 4 ; generateMatrix ( N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: even, i, j, odd, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void build ( int tree [ ] , int arr [ ] , int start , int end , int index ) { if ( start == end ) { if ( start % 2 == 0 ) { tree [ index ] = arr [ start ] ; } else { tree [ index ] = - arr [ start ] ; } return ; } int mid = start + ( end - start ) / 2 ; build ( tree , arr , start , mid , 2 * index + 1 ) ; build ( tree , arr , mid + 1 , end , 2 * index + 2 ) ; tree [ index ] = tree [ 2 * index + 1 ] + tree [ 2 * index + 2 ] ; } void update ( int tree [ ] , int index , int start , int end , int pos , int val ) { if ( start == end ) { if ( start % 2 == 0 ) { tree [ index ] = val ; } else { tree [ index ] = - val ; } return ; } int mid = start + ( end - start ) / 2 ; if ( mid >= pos ) { update ( tree , 2 * index + 1 , start , mid , pos , val ) ; } else { update ( tree , 2 * index + 2 , mid + 1 , end , pos , val ) ; } tree [ index ] = tree [ 2 * index + 1 ] + tree [ 2 * index + 2 ] ; } int FindSum ( int tree [ ] , int start , int end , int L , int R , int index ) { if ( L > end R < start ) { return 0 ; } if ( L <= start && R >= end ) { return tree [ index ] ; } int mid = start + ( end - start ) / 2 ; int X = FindSum ( tree , start , mid , L , R , 2 * index + 1 ) ; int Y = FindSum ( tree , mid + 1 , end , L , R , 2 * index + 2 ) ; return X + Y ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int tree [ 4 * N + 5 ] = { 0 } ; build ( tree , arr , 0 , N - 1 , 0 ) ; int Q [ ] [ 3 ] = { { 2 , 0 , 3 } , { 1 , 1 , 5 } , { 2 , 1 , 2 } } ; int cntQuey = 3 ; for ( int i = 0 ; i < cntQuey ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) { update ( tree , 0 , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] ) ; } else { if ( Q [ i ] [ 1 ] % 2 == 0 ) { cout << FindSum ( tree , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 ) << " ▁ " ; } else { cout << - FindSum ( tree , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 ) << " ▁ " ; } } } }

Index/key variables: i, index, start
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumSubarrays ( int arr [ ] , int n ) { char current = ' N ' ; int answer = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( current == ' N ' ) { if ( arr [ i ] < arr [ i - 1 ] ) { current = ' D ' ; } else if ( arr [ i ] == arr [ i - 1 ] ) { current = ' N ' ; } else { current = ' I ' ; } } else if ( current == ' I ' ) { if ( arr [ i ] >= arr [ i - 1 ] ) { current = ' I ' ; } else { current = ' N ' ; answer += 1 ; } } else { if ( arr [ i ] <= arr [ i - 1 ] ) { current = ' D ' ; } else { current = ' N ' ; answer += 1 ; } } } cout << answer ; } int main ( ) { int arr [ ] = { 2 , 3 , 9 , 5 , 4 , 6 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minimumSubarrays ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void ConstMatrix ( int * mat , int N , int M , int A , int B ) { if ( N * M != A * B ) return ; int idx = 0 ; int res [ A ] [ B ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { res [ idx / B ] [ idx % B ] = * ( ( mat + i * M ) + j ) ; idx ++ ; } } for ( int i = 0 ; i < A ; i ++ ) { for ( int j = 0 ; j < B ; j ++ ) cout << res [ i ] [ j ] << " ▁ " ; cout << " STRNEWLINE " ; } } int main ( ) { int mat [ ] [ 6 ] = { { 1 , 2 , 3 , 4 , 5 , 6 } } ; int A = 2 ; int B = 3 ; int N = sizeof ( mat ) / sizeof ( mat [ 0 ] ) ; int M = sizeof ( mat [ 0 ] ) / sizeof ( int ) ; ConstMatrix ( ( int * ) mat , N , M , A , B ) ; return 0 ; }

Index/key variables: A, B, i, j
Accumulator variables: i, idx, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printFinalPrices ( vector < int > & arr ) { stack < int > minStk ; int n = arr . size ( ) ; vector < int > reduce ( n , 0 ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( ! minStk . empty ( ) ) { if ( minStk . top ( ) <= arr [ i ] ) { reduce [ i ] = minStk . top ( ) ; } else { while ( ! minStk . empty ( ) && ( minStk . top ( ) > arr [ i ] ) ) { minStk . pop ( ) ; } if ( ! minStk . empty ( ) ) { reduce [ i ] = minStk . top ( ) ; } } } minStk . push ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] - reduce [ i ] << " ▁ " ; } int main ( ) { vector < int > arr = { 8 , 4 , 6 , 2 , 3 } ; printFinalPrices ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void constructArray ( int A [ ] , int N ) { int left [ N + 1 ] = { 0 } ; int right [ N + 1 ] = { 0 } ; int X [ N + 1 ] = { 0 } , Y [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { X [ i ] = left [ A [ i ] ] ; left [ A [ i ] ] ++ ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { Y [ i ] = right [ A [ i ] ] ; right [ A [ i ] ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { cout << Y [ i ] - X [ i ] << " ▁ " ; } } int main ( ) { int A [ ] = { 3 , 2 , 1 , 2 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; constructArray ( A , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * next ; } ; void push ( Node * * head_ref , int new_data ) { Node * new_node = new Node ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int largestElement ( struct Node * head_ref ) { int Max = INT_MIN ; Node * head = head_ref ; while ( head != NULL ) { if ( Max < head -> data ) { Max = head -> data ; } head = head -> next ; } return Max ; } set < int > createHashMap ( int Max ) { set < int > hashmap ; int prev = 0 ; int curr = 1 ; hashmap . insert ( prev ) ; hashmap . insert ( curr ) ; while ( curr <= Max ) { int temp = curr + prev ; hashmap . insert ( temp ) ; prev = curr ; curr = temp ; } return hashmap ; } double meanofnodes ( struct Node * head ) { int Max = largestElement ( head ) ; set < int > hashmap = createHashMap ( Max ) ; Node * curr = head ; int cnt = 0 ; double sum = 0.0 ; while ( curr != NULL ) { if ( ( curr -> data ) & 1 ) { if ( hashmap . count ( curr -> data ) ) { cnt ++ ; sum += curr -> data ; hashmap . erase ( curr -> data ) ; } } curr = curr -> next ; } return ( sum / cnt ) ; } int main ( ) { Node * head = NULL ; push ( & head , 5 ) ; push ( & head , 21 ) ; push ( & head , 8 ) ; push ( & head , 12 ) ; push ( & head , 3 ) ; push ( & head , 13 ) ; push ( & head , 144 ) ; push ( & head , 6 ) ; cout << meanofnodes ( head ) ; return 0 ; }

Accumulator variables: cnt, stdc, sum
Class/struct names: Node
C++ program:
#include <iostream>
using namespace std ; void findNumbers ( int n ) { int i = 0 ; while ( i <= n ) { cout << 2 * i * i + 4 * i + 1 + i % 2 << " ▁ " ; i ++ ; } } int main ( ) { int n = 6 ; findNumbers ( n ) ; }

Accumulator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int computeSalary ( int basic , char grade ) { int allowance ; double hra , da , pf ; hra = 0.2 * basic ; da = 0.5 * basic ; pf = 0.11 * basic ; if ( grade == ' A ' ) { allowance = 1700 ; } else if ( grade == ' B ' ) { allowance = 1500 ; } else { allowance = 1300 ; } int gross ; gross = round ( basic + hra + da + allowance - pf ) ; return gross ; } int main ( ) { int basic = 10000 ; char grade = ' A ' ; cout << computeSalary ( basic , grade ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Queries ( int arr [ ] , int N , vector < vector < int > > & Q ) { deque < int > dq ; for ( int i = 0 ; i < N ; i ++ ) { dq . push_back ( arr [ i ] ) ; } int sz = Q . size ( ) ; for ( int i = 0 ; i < sz ; i ++ ) { if ( Q [ i ] [ 0 ] == 0 ) { int front = dq [ 0 ] ; dq . pop_front ( ) ; dq . push_back ( front ) ; } else if ( Q [ i ] [ 0 ] == 1 ) { int back = dq [ N - 1 ] ; dq . pop_back ( ) ; dq . push_front ( back ) ; } else if ( Q [ i ] [ 0 ] == 2 ) { dq [ Q [ i ] [ 1 ] ] = Q [ i ] [ 2 ] ; } else { cout << dq [ Q [ i ] [ 1 ] ] << " ▁ " ; } } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; vector < vector < int > > Q ; Q = { { 0 } , { 1 } , { 3 , 1 } , { 2 , 2 , 54 } , { 3 , 2 } } ; Queries ( arr , N , Q ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallSubarray ( int arr [ ] , int n , int total_sum ) { unordered_map < int , int > m ; int length = INT_MAX ; int prefixSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { prefixSum += arr [ i ] ; if ( prefixSum == total_sum ) { length = min ( length , i + 1 ) ; } m [ prefixSum ] = i ; if ( m . count ( prefixSum - total_sum ) ) { length = min ( length , i - m [ prefixSum - total_sum ] ) ; } } return length ; } int smallestSubarrayremoved ( int arr [ ] , int n , int k ) { int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > k ) { arr [ i ] = 1 ; } else if ( arr [ i ] < k ) { arr [ i ] = -1 ; } else { arr [ i ] = 0 ; } total_sum += arr [ i ] ; } if ( total_sum == 0 ) { return 0 ; } else { return smallSubarray ( arr , n , total_sum ) ; } } int main ( ) { int arr [ ] = { 12 , 16 , 12 , 13 , 10 } ; int K = 13 ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << smallestSubarrayremoved ( arr , n , K ) ; return 0 ; }

Index/key variables: i, prefixSum
Accumulator variables: i, prefixSum, stdc, total_sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string balancedTernary ( int n ) { string output = " " ; while ( n > 0 ) { int rem = n % 3 ; n = n / 3 ; if ( rem == 2 ) { rem = -1 ; n ++ ; } output = ( rem == 0 ? '0' : ( rem == 1 ) ? '1' : ' Z ' ) + output ; } return output ; } int main ( ) { int n = 238 ; cout << " Equivalent ▁ Balanced ▁ Ternary ▁ of ▁ " << n << " ▁ is : ▁ " << balancedTernary ( n ) ; return 0 ; }

Accumulator variables: n, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int spt = 0 ; void printVector ( vector < int > & arr ) { int min_i = INT_MAX ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) min_i = min ( min_i , arr [ i ] ) ; int freq = count ( arr . begin ( ) , arr . end ( ) , min_i ) ; spt += freq ; } void findWays ( vector < int > & arr , int i , int n ) { if ( n == 0 ) printVector ( arr ) ; for ( int j = i ; j <= n ; j ++ ) { arr . push_back ( j ) ; findWays ( arr , j , n - j ) ; arr . pop_back ( ) ; } } void spt_function ( int n ) { vector < int > arr ; findWays ( arr , 1 , n ) ; cout << spt ; } int main ( ) { int N = 4 ; spt_function ( N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, spt, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd_extend ( int a , int b , int & x , int & y ) { if ( b == 0 ) { x = 1 ; y = 0 ; return a ; } else { int g = gcd_extend ( b , a % b , x , y ) ; int x1 = x , y1 = y ; x = y1 ; y = x1 - ( a / b ) * y1 ; return g ; } } void print_solution ( int a , int b , int c ) { int x , y ; if ( a == 0 && b == 0 ) { if ( c == 0 ) { cout << " Infinite ▁ Solutions ▁ Exist " << endl ; } else { cout << " No ▁ Solution ▁ exists " << endl ; } } int gcd = gcd_extend ( a , b , x , y ) ; if ( c % gcd != 0 ) { cout << " No ▁ Solution ▁ exists " << endl ; } else { cout << " x ▁ = ▁ " << x * ( c / gcd ) << " , ▁ y ▁ = ▁ " << y * ( c / gcd ) << endl ; } } int main ( void ) { int a , b , c ; a = 4 ; b = 18 ; c = 10 ; print_solution ( a , b , c ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int x ) { return x && ( ! ( x & ( x - 1 ) ) ) ; } int count ( int arr [ ] , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( check ( arr [ i ] & arr [ j ] ) ) cnt ++ ; } } return cnt ; } int main ( ) { int arr [ ] = { 6 , 4 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << count ( arr , 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 ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) if ( n % i == 0 ) return false ; return true ; } int takeSum ( int a [ 4 ] [ 5 ] ) { int sum = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) for ( int j = 0 ; j < 5 ; j ++ ) sum += a [ i ] [ j ] ; return sum ; } bool checkIndex ( int n , int m , int a [ 4 ] [ 5 ] ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( isPrime ( i + j ) ) { if ( ! isPrime ( a [ i ] [ j ] ) ) return false ; } } } return true ; } int main ( ) { int n = 4 , m = 5 ; int a [ 4 ] [ 5 ] = { { 1 , 2 , 3 , 2 , 2 } , { 2 , 2 , 7 , 7 , 7 } , { 7 , 7 , 21 , 7 , 10 } , { 2 , 2 , 3 , 6 , 7 } } ; int sum = takeSum ( a ) ; if ( isPrime ( sum ) && checkIndex ( n , m , a ) ) { cout << " YES " << endl ; } else cout << " NO " << endl ; 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 ; int countPairs ( int A [ ] , int n ) { int count = 0 , i , j ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( ( A [ i ] % 2 == 0 && A [ j ] % 2 == 0 ) || ( A [ i ] % 2 != 0 && A [ j ] % 2 != 0 ) ) count ++ ; } } return count ; } int main ( ) { int A [ ] = { 1 , 2 , 3 , 1 , 3 } ; int n = sizeof ( A ) / sizeof ( int ) ; cout << countPairs ( A , n ) ; }

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