dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define M  4
#define N  5
int findCommon ( int mat [ M ] [ N ] ) { unordered_map < int , int > cnt ; int i , j ; for ( i = 0 ; i < M ; i ++ ) { cnt [ mat [ i ] [ 0 ] ] ++ ; for ( j = 1 ; j < N ; j ++ ) { if ( mat [ i ] [ j ] != mat [ i ] [ j - 1 ] ) cnt [ mat [ i ] [ j ] ] ++ ; } } for ( auto ele : cnt ) { if ( ele . second == M ) return ele . first ; } return -1 ; } int main ( ) { int mat [ M ] [ N ] = { { 1 , 2 , 3 , 4 , 5 } , { 2 , 4 , 5 , 8 , 10 } , { 3 , 5 , 7 , 9 , 11 } , { 1 , 3 , 5 , 7 , 9 } , } ; int result = findCommon ( mat ) ; if ( result == -1 ) cout << " No ▁ common ▁ element " ; else cout << " Common ▁ element ▁ is ▁ " << result ; return 0 ; }

Index/key variables: M, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: ele, i, j
C++ program:
#include <iostream>
using namespace std ; #define M  6
#define N  6
void floodFillUtil ( char mat [ ] [ N ] , int x , int y , char prevV , char newV ) { if ( x < 0 x > = M y < 0 y > = N ) return ; if ( mat [ x ] [ y ] != prevV ) return ; mat [ x ] [ y ] = newV ; floodFillUtil ( mat , x + 1 , y , prevV , newV ) ; floodFillUtil ( mat , x - 1 , y , prevV , newV ) ; floodFillUtil ( mat , x , y + 1 , prevV , newV ) ; floodFillUtil ( mat , x , y - 1 , prevV , newV ) ; } int replaceSurrounded ( char mat [ ] [ N ] ) { for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( mat [ i ] [ j ] == ' O ' ) mat [ i ] [ j ] = ' - ' ; for ( int i = 0 ; i < M ; i ++ ) if ( mat [ i ] [ 0 ] == ' - ' ) floodFillUtil ( mat , i , 0 , ' - ' , ' O ' ) ; for ( int i = 0 ; i < M ; i ++ ) if ( mat [ i ] [ N - 1 ] == ' - ' ) floodFillUtil ( mat , i , N - 1 , ' - ' , ' O ' ) ; for ( int i = 0 ; i < N ; i ++ ) if ( mat [ 0 ] [ i ] == ' - ' ) floodFillUtil ( mat , 0 , i , ' - ' , ' O ' ) ; for ( int i = 0 ; i < N ; i ++ ) if ( mat [ M - 1 ] [ i ] == ' - ' ) floodFillUtil ( mat , M - 1 , i , ' - ' , ' O ' ) ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( mat [ i ] [ j ] == ' - ' ) mat [ i ] [ j ] = ' X ' ; } int main ( ) { char mat [ ] [ N ] = { { ' X ' , ' O ' , ' X ' , ' O ' , ' X ' , ' X ' } , { ' X ' , ' O ' , ' X ' , ' X ' , ' O ' , ' X ' } , { ' X ' , ' X ' , ' X ' , ' O ' , ' X ' , ' X ' } , { ' O ' , ' X ' , ' X ' , ' X ' , ' X ' , ' X ' } , { ' X ' , ' X ' , ' X ' , ' O ' , ' X ' , ' O ' } , { ' O ' , ' O ' , ' X ' , ' O ' , ' O ' , ' O ' } , } ; replaceSurrounded ( mat ) ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) cout << mat [ i ] [ j ] << " ▁ " ; cout << endl ; } 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 ; class node { public : int data ; node * left , * right ; } ; node * newNode ( int data ) { node * Node = new node ( ) ; Node -> data = data ; Node -> left = Node -> right = NULL ; return ( Node ) ; } void inorder ( node * root ) { if ( root != NULL ) { inorder ( root -> left ) ; cout << " TABSYMBOL " << root -> data ; inorder ( root -> right ) ; } } void fixPrevPtr ( node * root ) { static node * pre = NULL ; if ( root != NULL ) { fixPrevPtr ( root -> left ) ; root -> left = pre ; pre = root ; fixPrevPtr ( root -> right ) ; } } node * fixNextPtr ( node * root ) { node * prev = NULL ; while ( root && root -> right != NULL ) root = root -> right ; while ( root && root -> left != NULL ) { prev = root ; root = root -> left ; root -> right = prev ; } return ( root ) ; } node * BTToDLL ( node * root ) { fixPrevPtr ( root ) ; return fixNextPtr ( root ) ; } void printList ( node * root ) { while ( root != NULL ) { cout << " TABSYMBOL " << root -> data ; root = root -> right ; } } int main ( void ) { node * root = newNode ( 10 ) ; root -> left = newNode ( 12 ) ; root -> right = newNode ( 15 ) ; root -> left -> left = newNode ( 25 ) ; root -> left -> right = newNode ( 30 ) ; root -> right -> left = newNode ( 36 ) ; cout << " Inorder Tree Traversal " ; inorder ( root ) ; node * head = BTToDLL ( root ) ; cout << " DLL Traversal " printList ( head ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  6
int maximumSubSquare ( int arr [ ] [ N ] ) { pair < int , int > dp [ 51 ] [ 51 ] ; int maxside [ 51 ] [ 51 ] ; memset ( maxside , 0 , sizeof ( maxside ) ) ; int x = 0 , y = 0 ; for ( int i = 0 ; i < N ; i ++ ) { x = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( arr [ i ] [ j ] == ' X ' ) x += 1 ; else x = 0 ; dp [ i ] [ j ] . first = x ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( arr [ j ] [ i ] == ' X ' ) y += 1 ; else y = 0 ; dp [ j ] [ i ] . second = y ; } } int maxval = 0 , val = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { val = min ( dp [ i ] [ j ] . first , dp [ i ] [ j ] . second ) ; if ( dp [ i ] [ j - val + 1 ] . second >= val && dp [ i - val + 1 ] [ j ] . first >= val ) maxside [ i ] [ j ] = val ; else maxside [ i ] [ j ] = 0 ; maxval = max ( maxval , maxside [ i ] [ j ] ) ; } } return maxval ; } int main ( ) { int mat [ ] [ N ] = { { ' X ' , ' O ' , ' X ' , ' X ' , ' X ' , ' X ' } , { ' X ' , ' O ' , ' X ' , ' X ' , ' O ' , ' X ' } , { ' X ' , ' X ' , ' X ' , ' O ' , ' O ' , ' X ' } , { ' O ' , ' X ' , ' X ' , ' X ' , ' X ' , ' X ' } , { ' X ' , ' X ' , ' X ' , ' O ' , ' X ' , ' O ' } , { ' O ' , ' O ' , ' X ' , ' O ' , ' O ' , ' O ' } , } ; cout << maximumSubSquare ( mat ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc, x, y
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; #define M  8
#define N  8
void floodFillUtil ( int screen [ ] [ N ] , int x , int y , int prevC , int newC ) { if ( x < 0 x > = M y < 0 y > = N ) return ; if ( screen [ x ] [ y ] != prevC ) return ; if ( screen [ x ] [ y ] == newC ) return ; screen [ x ] [ y ] = newC ; floodFillUtil ( screen , x + 1 , y , prevC , newC ) ; floodFillUtil ( screen , x - 1 , y , prevC , newC ) ; floodFillUtil ( screen , x , y + 1 , prevC , newC ) ; floodFillUtil ( screen , x , y - 1 , prevC , newC ) ; } void floodFill ( int screen [ ] [ N ] , int x , int y , int newC ) { int prevC = screen [ x ] [ y ] ; floodFillUtil ( screen , x , y , prevC , newC ) ; } int main ( ) { int screen [ M ] [ N ] = { { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 1 , 1 , 0 , 1 , 1 } , { 1 , 2 , 2 , 2 , 2 , 0 , 1 , 0 } , { 1 , 1 , 1 , 2 , 2 , 0 , 1 , 0 } , { 1 , 1 , 1 , 2 , 2 , 2 , 2 , 0 } , { 1 , 1 , 1 , 1 , 1 , 2 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 , 2 , 2 , 1 } , } ; int x = 4 , y = 4 , newC = 3 ; floodFill ( screen , x , y , newC ) ; cout << " Updated ▁ screen ▁ after ▁ call ▁ to ▁ floodFill : ▁ STRNEWLINE " ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) cout << screen [ i ] [ j ] << " ▁ " ; cout << endl ; } }

Index/key variables: M, N, i, j, x, y
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int validCoord ( int x , int y , int n , int m ) { if ( x < 0 y < 0 ) { return 0 ; } if ( x >= n y >= m ) { return 0 ; } return 1 ; } void bfs ( int n , int m , int data [ ] [ 8 ] , int x , int y , int color ) { int vis [ 101 ] [ 101 ] ; memset ( vis , 0 , sizeof ( vis ) ) ; queue < pair < int , int > > obj ; obj . push ( { x , y } ) ; vis [ x ] [ y ] = 1 ; while ( obj . empty ( ) != 1 ) { pair < int , int > coord = obj . front ( ) ; int x = coord . first ; int y = coord . second ; int preColor = data [ x ] [ y ] ; data [ x ] [ y ] = color ; obj . pop ( ) ; if ( validCoord ( x + 1 , y , n , m ) && vis [ x + 1 ] [ y ] == 0 && data [ x + 1 ] [ y ] == preColor ) { obj . push ( { x + 1 , y } ) ; vis [ x + 1 ] [ y ] = 1 ; } if ( validCoord ( x - 1 , y , n , m ) && vis [ x - 1 ] [ y ] == 0 && data [ x - 1 ] [ y ] == preColor ) { obj . push ( { x - 1 , y } ) ; vis [ x - 1 ] [ y ] = 1 ; } if ( validCoord ( x , y + 1 , n , m ) && vis [ x ] [ y + 1 ] == 0 && data [ x ] [ y + 1 ] == preColor ) { obj . push ( { x , y + 1 } ) ; vis [ x ] [ y + 1 ] = 1 ; } if ( validCoord ( x , y - 1 , n , m ) && vis [ x ] [ y - 1 ] == 0 && data [ x ] [ y - 1 ] == preColor ) { obj . push ( { x , y - 1 } ) ; vis [ x ] [ y - 1 ] = 1 ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { cout << data [ i ] [ j ] << " ▁ " ; } cout << endl ; } cout << endl ; } int main ( ) { int n , m , x , y , color ; n = 8 ; m = 8 ; int data [ 8 ] [ 8 ] = { { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 1 , 1 , 0 , 1 , 1 } , { 1 , 2 , 2 , 2 , 2 , 0 , 1 , 0 } , { 1 , 1 , 1 , 2 , 2 , 0 , 1 , 0 } , { 1 , 1 , 1 , 2 , 2 , 2 , 2 , 0 } , { 1 , 1 , 1 , 1 , 1 , 2 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 , 2 , 2 , 1 } , } ; x = 4 , y = 4 , color = 3 ; bfs ( n , m , data , x , y , color ) ; return 0 ; }

Index/key variables: i, j, x, y
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; struct node { int data ; node * left ; node * right ; } ; void BinaryTree2DoubleLinkedList ( node * root , node * * head ) { if ( root == NULL ) return ; static node * prev = NULL ; BinaryTree2DoubleLinkedList ( root -> left , head ) ; if ( prev == NULL ) * head = root ; else { root -> left = prev ; prev -> right = root ; } prev = root ; BinaryTree2DoubleLinkedList ( root -> right , head ) ; } node * newNode ( int data ) { node * new_node = new node ; new_node -> data = data ; new_node -> left = new_node -> right = NULL ; return ( new_node ) ; } void printList ( node * node ) { while ( node != NULL ) { cout << node -> data << " ▁ " ; node = node -> right ; } } int main ( ) { node * root = newNode ( 10 ) ; root -> left = newNode ( 12 ) ; root -> right = newNode ( 15 ) ; root -> left -> left = newNode ( 25 ) ; root -> left -> right = newNode ( 30 ) ; root -> right -> left = newNode ( 36 ) ; node * head = NULL ; BinaryTree2DoubleLinkedList ( root , & head ) ; printList ( head ) ; return 0 ; }

Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define R  5
#define C  4
bool isValid ( int x , int y1 , int y2 ) { return ( x >= 0 && x < R && y1 >= 0 && y1 < C && y2 >= 0 && y2 < C ) ; } int getMaxUtil ( int arr [ R ] [ C ] , int mem [ R ] [ C ] [ C ] , int x , int y1 , int y2 ) { if ( ! isValid ( x , y1 , y2 ) ) return INT_MIN ; if ( x == R - 1 && y1 == 0 && y2 == C - 1 ) return ( y1 == y2 ) ? arr [ x ] [ y1 ] : arr [ x ] [ y1 ] + arr [ x ] [ y2 ] ; if ( x == R - 1 ) return INT_MIN ; if ( mem [ x ] [ y1 ] [ y2 ] != -1 ) return mem [ x ] [ y1 ] [ y2 ] ; int ans = INT_MIN ; int temp = ( y1 == y2 ) ? arr [ x ] [ y1 ] : arr [ x ] [ y1 ] + arr [ x ] [ y2 ] ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 , y2 - 1 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 , y2 + 1 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 , y2 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 - 1 , y2 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 - 1 , y2 - 1 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 - 1 , y2 + 1 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 + 1 , y2 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 + 1 , y2 - 1 ) ) ; ans = max ( ans , temp + getMaxUtil ( arr , mem , x + 1 , y1 + 1 , y2 + 1 ) ) ; return ( mem [ x ] [ y1 ] [ y2 ] = ans ) ; } int geMaxCollection ( int arr [ R ] [ C ] ) { int mem [ R ] [ C ] [ C ] ; memset ( mem , -1 , sizeof ( mem ) ) ; return getMaxUtil ( arr , mem , 0 , 0 , C - 1 ) ; } int main ( ) { int arr [ R ] [ C ] = { { 3 , 6 , 8 , 2 } , { 5 , 2 , 4 , 3 } , { 1 , 1 , 20 , 10 } , { 1 , 1 , 20 , 10 } , { 1 , 1 , 20 , 10 } , } ; cout << " Maximum ▁ collection ▁ is ▁ " << geMaxCollection ( arr ) ; return 0 ; }

Index/key variables: C, R, x, y1, y2
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define R  5
#define C  5
bool isValid ( int i , int j ) { return ( i >= 0 && i < R && j >= 0 && j < C ) ; } int maxCoinsRec ( char arr [ R ] [ C ] , int i , int j , int dir ) { if ( isValid ( i , j ) == false arr [ i ] [ j ] == ' # ' ) return 0 ; int result = ( arr [ i ] [ j ] == ' C ' ) ? 1 : 0 ; if ( dir == 1 ) return result + max ( maxCoinsRec ( arr , i + 1 , j , 0 ) , maxCoinsRec ( arr , i , j + 1 , 1 ) ) ; return result + max ( maxCoinsRec ( arr , i + 1 , j , 1 ) , maxCoinsRec ( arr , i , j - 1 , 0 ) ) ; } int main ( ) { char arr [ R ] [ C ] = { { ' E ' , ' C ' , ' C ' , ' C ' , ' C ' } , { ' C ' , ' # ' , ' C ' , ' # ' , ' E ' } , { ' # ' , ' C ' , ' C ' , ' # ' , ' C ' } , { ' C ' , ' E ' , ' E ' , ' C ' , ' E ' } , { ' C ' , ' E ' , ' # ' , ' C ' , ' E ' } } ; cout << " Maximum ▁ number ▁ of ▁ collected ▁ coins ▁ is ▁ " << maxCoinsRec ( arr , 0 , 0 , 1 ) ; return 0 ; }

Index/key variables: C, R, i, j
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define R  3
#define C  3
using namespace std ; int x [ ] = { 0 , 1 , 1 , -1 , 1 , 0 , -1 , -1 } ; int y [ ] = { 1 , 0 , 1 , 1 , -1 , -1 , 0 , -1 } ; int dp [ R ] [ C ] ; bool isvalid ( int i , int j ) { if ( i < 0 j < 0 i > = R j > = C ) return false ; return true ; } bool isadjacent ( char prev , char curr ) { return ( ( curr - prev ) == 1 ) ; } int getLenUtil ( char mat [ R ] [ C ] , int i , int j , char prev ) { if ( ! isvalid ( i , j ) || ! isadjacent ( prev , mat [ i ] [ j ] ) ) return 0 ; if ( dp [ i ] [ j ] != -1 ) return dp [ i ] [ j ] ; int ans = 0 ; for ( int k = 0 ; k < 8 ; k ++ ) ans = max ( ans , 1 + getLenUtil ( mat , i + x [ k ] , j + y [ k ] , mat [ i ] [ j ] ) ) ; return dp [ i ] [ j ] = ans ; } int getLen ( char mat [ R ] [ C ] , char s ) { memset ( dp , -1 , sizeof dp ) ; int ans = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( mat [ i ] [ j ] == s ) { for ( int k = 0 ; k < 8 ; k ++ ) ans = max ( ans , 1 + getLenUtil ( mat , i + x [ k ] , j + y [ k ] , s ) ) ; } } } return ans ; } int main ( ) { char mat [ R ] [ C ] = { { ' a ' , ' c ' , ' d ' } , { ' h ' , ' b ' , ' a ' } , { ' i ' , ' g ' , ' f ' } } ; cout << getLen ( mat , ' a ' ) << endl ; cout << getLen ( mat , ' e ' ) << endl ; cout << getLen ( mat , ' b ' ) << endl ; cout << getLen ( mat , ' f ' ) << endl ; return 0 ; }

Index/key variables: C, R, i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
#define R  3
#define C  3
using namespace std ; int minInitialPoints ( int points [ ] [ C ] ) { int dp [ R ] [ C ] ; int m = R , n = C ; dp [ m - 1 ] [ n - 1 ] = points [ m - 1 ] [ n - 1 ] > 0 ? 1 : abs ( points [ m - 1 ] [ n - 1 ] ) + 1 ; for ( int i = m - 2 ; i >= 0 ; i -- ) dp [ i ] [ n - 1 ] = max ( dp [ i + 1 ] [ n - 1 ] - points [ i ] [ n - 1 ] , 1 ) ; for ( int j = n - 2 ; j >= 0 ; j -- ) dp [ m - 1 ] [ j ] = max ( dp [ m - 1 ] [ j + 1 ] - points [ m - 1 ] [ j ] , 1 ) ; for ( int i = m - 2 ; i >= 0 ; i -- ) { for ( int j = n - 2 ; j >= 0 ; j -- ) { int min_points_on_exit = min ( dp [ i + 1 ] [ j ] , dp [ i ] [ j + 1 ] ) ; dp [ i ] [ j ] = max ( min_points_on_exit - points [ i ] [ j ] , 1 ) ; } } return dp [ 0 ] [ 0 ] ; } int main ( ) { int points [ R ] [ C ] = { { -2 , -3 , 3 } , { -5 , -10 , 1 } , { 10 , 30 , -5 } } ; cout << " Minimum ▁ Initial ▁ Points ▁ Required : ▁ " << minInitialPoints ( points ) ; return 0 ; }

Index/key variables: C, R, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; class node { public : int data ; node * left ; node * right ; node ( int data ) { this -> data = data ; this -> left = NULL ; this -> right = NULL ; } } ; void increment ( node * node , int diff ) ; void convertTree ( node * node ) { int left_data = 0 , right_data = 0 , diff ; if ( node == NULL || ( node -> left == NULL && node -> right == NULL ) ) return ; else { convertTree ( node -> left ) ; convertTree ( node -> right ) ; if ( node -> left != NULL ) left_data = node -> left -> data ; if ( node -> right != NULL ) right_data = node -> right -> data ; diff = left_data + right_data - node -> data ; if ( diff > 0 ) node -> data = node -> data + diff ; if ( diff < 0 ) increment ( node , - diff ) ; } } void increment ( node * node , int diff ) { if ( node -> left != NULL ) { node -> left -> data = node -> left -> data + diff ; increment ( node -> left , diff ) ; } else if ( node -> right != NULL ) { node -> right -> data = node -> right -> data + diff ; increment ( node -> right , diff ) ; } } void printInorder ( node * node ) { if ( node == NULL ) return ; printInorder ( node -> left ) ; cout << node -> data << " ▁ " ; printInorder ( node -> right ) ; } int main ( ) { node * root = new node ( 50 ) ; root -> left = new node ( 7 ) ; root -> right = new node ( 2 ) ; root -> left -> left = new node ( 3 ) ; root -> left -> right = new node ( 5 ) ; root -> right -> left = new node ( 1 ) ; root -> right -> right = new node ( 30 ) ; cout << " Inorder traversal before conversion : " printInorder ( root ) ; convertTree ( root ) ; cout << " Inorder traversal after conversion : " printInorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Queue { stack < int > s1 , s2 ; void enQueue ( int x ) { while ( ! s1 . empty ( ) ) { s2 . push ( s1 . top ( ) ) ; s1 . pop ( ) ; } s1 . push ( x ) ; while ( ! s2 . empty ( ) ) { s1 . push ( s2 . top ( ) ) ; s2 . pop ( ) ; } } int deQueue ( ) { if ( s1 . empty ( ) ) { cout << " Q ▁ is ▁ Empty " ; exit ( 0 ) ; } int x = s1 . top ( ) ; s1 . pop ( ) ; return x ; } } ; int main ( ) { Queue q ; q . enQueue ( 1 ) ; q . enQueue ( 2 ) ; q . enQueue ( 3 ) ; cout << q . deQueue ( ) << ' ' ; cout << q . deQueue ( ) << ' ' ; cout << q . deQueue ( ) << ' ' ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Queue
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int key ; struct node * left , * right ; } ; void convert ( node * root ) { if ( root == NULL ) return ; convert ( root -> left ) ; convert ( root -> right ) ; if ( root -> left == NULL ) root -> left = root -> right ; else root -> left -> right = root -> right ; root -> right = NULL ; } void downRightTraversal ( node * root ) { if ( root != NULL ) { cout << root -> key << " ▁ " ; downRightTraversal ( root -> right ) ; downRightTraversal ( root -> left ) ; } } node * newNode ( int key ) { node * temp = new node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 5 ) ; root -> right -> left -> left = newNode ( 6 ) ; root -> right -> right -> left = newNode ( 7 ) ; root -> right -> right -> right = newNode ( 8 ) ; convert ( root ) ; cout << " Traversal ▁ of ▁ the ▁ tree ▁ converted ▁ to ▁ down - right ▁ form STRNEWLINE " ; downRightTraversal ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class node { public : int data ; node * left ; node * right ; } ; int toSumTree ( node * Node ) { if ( Node == NULL ) return 0 ; int old_val = Node -> data ; Node -> data = toSumTree ( Node -> left ) + toSumTree ( Node -> right ) ; return Node -> data + old_val ; } void printInorder ( node * Node ) { if ( Node == NULL ) return ; printInorder ( Node -> left ) ; cout << " ▁ " << Node -> data ; printInorder ( Node -> right ) ; } node * newNode ( int data ) { node * temp = new node ; temp -> data = data ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } int main ( ) { node * root = NULL ; int x ; root = newNode ( 10 ) ; root -> left = newNode ( -2 ) ; root -> right = newNode ( 6 ) ; root -> left -> left = newNode ( 8 ) ; root -> left -> right = newNode ( -4 ) ; root -> right -> left = newNode ( 7 ) ; root -> right -> right = newNode ( 5 ) ; toSumTree ( root ) ; cout << " Inorder ▁ Traversal ▁ of ▁ the ▁ resultant ▁ tree ▁ is : ▁ STRNEWLINE " ; printInorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findPeak ( int arr [ ] , int n ) { if ( n == 1 ) return 0 ; if ( arr [ 0 ] >= arr [ 1 ] ) return 0 ; if ( arr [ n - 1 ] >= arr [ n - 2 ] ) return n - 1 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( arr [ i ] >= arr [ i - 1 ] && arr [ i ] >= arr [ i + 1 ] ) return i ; } } int main ( ) { int arr [ ] = { 1 , 3 , 20 , 4 , 1 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Index ▁ of ▁ a ▁ peak ▁ point ▁ is ▁ " << findPeak ( 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 findPeakUtil ( int arr [ ] , int low , int high , int n ) { int mid = low + ( high - low ) / 2 ; if ( ( mid == 0 arr [ mid - 1 ] <= arr [ mid ] ) && ( mid == n - 1 arr [ mid + 1 ] <= arr [ mid ] ) ) return mid ; else if ( mid > 0 && arr [ mid - 1 ] > arr [ mid ] ) return findPeakUtil ( arr , low , ( mid - 1 ) , n ) ; else return findPeakUtil ( arr , ( mid + 1 ) , high , n ) ; } int findPeak ( int arr [ ] , int n ) { return findPeakUtil ( arr , 0 , n - 1 , n ) ; } int main ( ) { int arr [ ] = { 1 , 3 , 20 , 4 , 1 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Index ▁ of ▁ a ▁ peak ▁ point ▁ is ▁ " << findPeak ( arr , n ) ; return 0 ; }

Index/key variables: mid
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRepeating ( int arr [ ] , int size ) { int i , j ; printf ( " ▁ Repeating ▁ elements ▁ are ▁ " ) ; for ( i = 0 ; i < size ; i ++ ) for ( j = i + 1 ; j < size ; j ++ ) if ( arr [ i ] == arr [ j ] ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printRepeating ( arr , arr_size ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRepeating ( int arr [ ] , int size ) { int * count = new int [ sizeof ( int ) * ( size - 2 ) ] ; int i ; cout << " ▁ Repeating ▁ elements ▁ are ▁ " ; for ( i = 0 ; i < size ; i ++ ) { if ( count [ arr [ i ] ] == 1 ) cout << arr [ i ] << " ▁ " ; else count [ arr [ i ] ] ++ ; } } int main ( ) { int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printRepeating ( arr , arr_size ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) ; void printRepeating ( int arr [ ] , int size ) { int S = 0 ; int P = 1 ; int x , y ; int D ; int n = size - 2 , i ; for ( i = 0 ; i < size ; i ++ ) { S = S + arr [ i ] ; P = P * arr [ i ] ; } S = S - n * ( n + 1 ) / 2 ; P = P / fact ( n ) ; D = sqrt ( S * S - 4 * P ) ; x = ( D + S ) / 2 ; y = ( S - D ) / 2 ; cout << " The ▁ two ▁ Repeating ▁ elements ▁ are ▁ " << x << " ▁ & ▁ " << y ; } int fact ( int n ) { return ( n == 0 ) ? 1 : n * fact ( n - 1 ) ; } int main ( ) { int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printRepeating ( arr , arr_size ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRepeating ( int arr [ ] , int size ) { int Xor = arr [ 0 ] ; int set_bit_no ; int i ; int n = size - 2 ; int x = 0 , y = 0 ; for ( i = 1 ; i < size ; i ++ ) Xor ^= arr [ i ] ; for ( i = 1 ; i <= n ; i ++ ) Xor ^= i ; set_bit_no = Xor & ~ ( Xor - 1 ) ; for ( i = 0 ; i < size ; i ++ ) { if ( arr [ i ] & set_bit_no ) x = x ^ arr [ i ] ; else y = y ^ arr [ i ] ; } for ( i = 1 ; i <= n ; i ++ ) { if ( i & set_bit_no ) x = x ^ i ; else y = y ^ i ; } cout << " The ▁ two ▁ repeating ▁ elements ▁ are ▁ " << y << " ▁ " << x ; } int main ( ) { int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printRepeating ( arr , arr_size ) ; return 0 ; }

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