dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { struct Node * left , * right ; int key ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return temp ; } Node * nextRightNode ( Node * root , int k , int level , int & value_level ) { if ( root == NULL ) return NULL ; if ( root -> key == k ) { value_level = level ; return NULL ; } else if ( value_level ) { if ( level == value_level ) return root ; } Node * leftNode = nextRightNode ( root -> left , k , level + 1 , value_level ) ; if ( leftNode ) return leftNode ; return nextRightNode ( root -> right , k , level + 1 , value_level ) ; } Node * nextRightNodeUtil ( Node * root , int k ) { int value_level = 0 ; return nextRightNode ( root , k , 1 , value_level ) ; } void test ( Node * root , int k ) { Node * nr = nextRightNodeUtil ( root , k ) ; if ( nr != NULL ) cout << " Next ▁ Right ▁ of ▁ " << k << " ▁ is ▁ " << nr -> key << endl ; else cout << " No ▁ next ▁ right ▁ node ▁ found ▁ for ▁ " << k << endl ; } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 6 ) ; root -> right -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 8 ) ; root -> left -> right = newNode ( 4 ) ; test ( root , 10 ) ; test ( root , 2 ) ; test ( root , 6 ) ; test ( root , 5 ) ; test ( root , 8 ) ; test ( root , 4 ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left ; struct Node * right ; } ; struct Node * newNode ( int data ) { struct Node * node = new Node ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } void threelargest ( Node * root , int & first , int & second , int & third ) { if ( root == NULL ) return ; if ( root -> data > first ) { third = second ; second = first ; first = root -> data ; } else if ( root -> data > second && root -> data != first ) { third = second ; second = root -> data ; } else if ( root -> data > third && root -> data != first && root -> data != second ) third = root -> data ; threelargest ( root -> left , first , second , third ) ; threelargest ( root -> right , first , second , third ) ; } int main ( ) { struct Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 5 ) ; int first = 0 , second = 0 , third = 0 ; threelargest ( root , first , second , third ) ; cout << " three ▁ largest ▁ elements ▁ are ▁ " << first << " ▁ " << second << " ▁ " << third ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; class Node { public : int data ; Node * left , * right ; Node ( int data ) { this -> data = data ; this -> left = NULL ; this -> right = NULL ; } } ; int findMax ( Node * root ) { if ( root == NULL ) return INT_MIN ; int res = root -> data ; int lres = findMax ( root -> left ) ; int rres = findMax ( root -> right ) ; if ( lres > res ) res = lres ; if ( rres > res ) res = rres ; return res ; } int main ( ) { Node * NewRoot = NULL ; Node * root = new Node ( 2 ) ; root -> left = new Node ( 7 ) ; root -> right = new Node ( 5 ) ; root -> left -> right = new Node ( 6 ) ; root -> left -> right -> left = new Node ( 1 ) ; root -> left -> right -> right = new Node ( 11 ) ; root -> right -> right = new Node ( 9 ) ; root -> right -> right -> left = new Node ( 4 ) ; cout << " Maximum ▁ element ▁ is ▁ " << findMax ( root ) << endl ; 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 , * right ; } ; Node * extractLeafList ( Node * root , Node * * head_ref ) { if ( root == NULL ) return NULL ; if ( root -> left == NULL && root -> right == NULL ) { root -> right = * head_ref ; if ( * head_ref != NULL ) ( * head_ref ) -> left = root ; * head_ref = root ; return NULL ; } root -> right = extractLeafList ( root -> right , head_ref ) ; root -> left = extractLeafList ( root -> left , head_ref ) ; return root ; } Node * newNode ( int data ) { Node * node = new Node ( ) ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } void print ( Node * root ) { if ( root != NULL ) { print ( root -> left ) ; cout << root -> data << " ▁ " ; print ( root -> right ) ; } } void printList ( Node * head ) { while ( head ) { cout << head -> data << " ▁ " ; head = head -> right ; } } int main ( ) { Node * head = NULL ; Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; root -> left -> left -> left = newNode ( 7 ) ; root -> left -> left -> right = newNode ( 8 ) ; root -> right -> right -> left = newNode ( 9 ) ; root -> right -> right -> right = newNode ( 10 ) ; cout << " Inorder ▁ Trvaersal ▁ of ▁ given ▁ Tree ▁ is : STRNEWLINE " ; print ( root ) ; root = extractLeafList ( root , & head ) ; cout << " Extracted Double Linked list is : " ; printList ( head ) ; cout << " Inorder traversal of modified tree is : " print ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left ; Node * right ; } ; Node * newNode ( int val ) { Node * temp = new Node ; temp -> data = val ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } void inorderSuccessor ( Node * root , Node * target_node , Node * & next ) { if ( ! root ) return ; inorderSuccessor ( root -> right , target_node , next ) ; if ( root -> data == target_node -> data ) { if ( next == NULL ) cout << " inorder ▁ successor ▁ of ▁ " << root -> data << " ▁ is : ▁ null STRNEWLINE " ; else cout << " inorder ▁ successor ▁ of ▁ " << root -> data << " ▁ is : ▁ " << next -> data << " STRNEWLINE " ; } next = root ; inorderSuccessor ( root -> left , target_node , next ) ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; Node * next = NULL ; inorderSuccessor ( root , root -> right , next ) ; next = NULL ; inorderSuccessor ( root , root -> left -> left , next ) ; next = NULL ; inorderSuccessor ( root , root -> right -> right , next ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addEdge ( vector < int > adj [ ] , int u , int v ) { adj [ u ] . push_back ( v ) ; adj [ v ] . push_back ( u ) ; } void printGraph ( vector < int > adj [ ] , int V ) { for ( int v = 0 ; v < V ; ++ v ) { cout << " Adjacency list of vertex " << v < < " head " for ( auto x : adj [ v ] ) cout << " - > ▁ " << x ; printf ( " STRNEWLINE " ) ; } } int main ( ) { int V = 5 ; vector < int > adj [ V ] ; addEdge ( adj , 0 , 1 ) ; addEdge ( adj , 0 , 4 ) ; addEdge ( adj , 1 , 2 ) ; addEdge ( adj , 1 , 3 ) ; addEdge ( adj , 1 , 4 ) ; addEdge ( adj , 2 , 3 ) ; addEdge ( adj , 3 , 4 ) ; printGraph ( adj , V ) ; return 0 ; }

Index/key variables: V, u, v
Accumulator variables: stdc
Iterator variables: v, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Graph { int V ; set < int , greater < int > > * adjList ; } ; Graph * createGraph ( int V ) { Graph * graph = new Graph ; graph -> V = V ; graph -> adjList = new set < int , greater < int > > [ V ] ; return graph ; } void addEdge ( Graph * graph , int src , int dest ) { graph -> adjList [ src ] . insert ( dest ) ; graph -> adjList [ dest ] . insert ( src ) ; } void printGraph ( Graph * graph ) { for ( int i = 0 ; i < graph -> V ; ++ i ) { set < int , greater < int > > lst = graph -> adjList [ i ] ; cout << endl << " Adjacency ▁ list ▁ of ▁ vertex ▁ " << i << endl ; for ( auto itr = lst . begin ( ) ; itr != lst . end ( ) ; ++ itr ) cout << * itr << " ▁ " ; cout << endl ; } } void searchEdge ( Graph * graph , int src , int dest ) { auto itr = graph -> adjList [ src ] . find ( dest ) ; if ( itr == graph -> adjList [ src ] . end ( ) ) cout << endl << " Edge ▁ from ▁ " << src << " ▁ to ▁ " << dest << " ▁ not ▁ found . " << endl ; else cout << endl << " Edge ▁ from ▁ " << src << " ▁ to ▁ " << dest << " ▁ found . " << endl ; } int main ( ) { int V = 5 ; struct Graph * graph = createGraph ( V ) ; addEdge ( graph , 0 , 1 ) ; addEdge ( graph , 0 , 4 ) ; addEdge ( graph , 1 , 2 ) ; addEdge ( graph , 1 , 3 ) ; addEdge ( graph , 1 , 4 ) ; addEdge ( graph , 2 , 3 ) ; addEdge ( graph , 3 , 4 ) ; printGraph ( graph ) ; searchEdge ( graph , 2 , 1 ) ; searchEdge ( graph , 0 , 3 ) ; return 0 ; }

Index/key variables: V, dest, i, src
Accumulator variables: stdc
Iterator variables: i, itr
Class/struct names: Graph
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Graph { int V ; list < int > * adj ; public : Graph :: Graph ( int V ) { this -> V = V ; adj = new list < int > [ V ] ; } void addEdge ( int u , int v ) ; bool DFSUtil ( int , vector < bool > & , vector < int > & , int k ) ; void printKCores ( int k ) ; } ; void Graph :: addEdge ( int u , int v ) { adj [ u ] . push_back ( v ) ; adj [ v ] . push_back ( u ) ; } void Graph :: DFSUtil ( int v , vector < bool > & visited , vector < int > & vDegree , int k ) { visited [ v ] = true ; list < int > :: iterator i ; for ( i = adj [ v ] . begin ( ) ; i != adj [ v ] . end ( ) ; ++ i ) { if ( vDegree [ v ] < k ) vDegree [ * i ] -- ; if ( ! visited [ * i ] ) { DFSUtil ( * i , visited , vDegree , k ) } } return ( vDegree [ v ] < k ) ; } void Graph :: printKCores ( int k ) { vector < bool > visited ( V , false ) ; vector < bool > processed ( V , false ) ; int mindeg = INT_MAX ; int startvertex ; vector < int > vDegree ( V ) ; for ( int i = 0 ; i < V ; i ++ ) { vDegree [ i ] = adj [ i ] . size ( ) ; if ( vDegree [ i ] < mindeg ) { mindeg = vDegree [ i ] ; startvertex = i ; } } DFSUtil ( startvertex , visited , vDegree , k ) ; for ( int i = 0 ; i < V ; i ++ ) if ( visited [ i ] == false ) DFSUtil ( i , visited , vDegree , k ) ; cout << " K - Cores ▁ : ▁ STRNEWLINE " ; for ( int v = 0 ; v < V ; v ++ ) { if ( vDegree [ v ] >= k ) { cout << " STRNEWLINE [ " << v << " ] " ; list < int > :: iterator itr ; for ( itr = adj [ v ] . begin ( ) ; itr != adj [ v ] . end ( ) ; ++ itr ) if ( vDegree [ * itr ] >= k ) cout << " ▁ - > ▁ " << * itr ; } } } int main ( ) { int k = 3 ; Graph g1 ( 9 ) ; g1 . addEdge ( 0 , 1 ) ; g1 . addEdge ( 0 , 2 ) ; g1 . addEdge ( 1 , 2 ) ; g1 . addEdge ( 1 , 5 ) ; g1 . addEdge ( 2 , 3 ) ; g1 . addEdge ( 2 , 4 ) ; g1 . addEdge ( 2 , 5 ) ; g1 . addEdge ( 2 , 6 ) ; g1 . addEdge ( 3 , 4 ) ; g1 . addEdge ( 3 , 6 ) ; g1 . addEdge ( 3 , 7 ) ; g1 . addEdge ( 4 , 6 ) ; g1 . addEdge ( 4 , 7 ) ; g1 . addEdge ( 5 , 6 ) ; g1 . addEdge ( 5 , 8 ) ; g1 . addEdge ( 6 , 7 ) ; g1 . addEdge ( 6 , 8 ) ; g1 . printKCores ( k ) ; cout << endl << endl ; Graph g2 ( 13 ) ; g2 . addEdge ( 0 , 1 ) ; g2 . addEdge ( 0 , 2 ) ; g2 . addEdge ( 0 , 3 ) ; g2 . addEdge ( 1 , 4 ) ; g2 . addEdge ( 1 , 5 ) ; g2 . addEdge ( 1 , 6 ) ; g2 . addEdge ( 2 , 7 ) ; g2 . addEdge ( 2 , 8 ) ; g2 . addEdge ( 2 , 9 ) ; g2 . addEdge ( 3 , 10 ) ; g2 . addEdge ( 3 , 11 ) ; g2 . addEdge ( 3 , 12 ) ; g2 . printKCores ( k ) ; return 0 ; }

Index/key variables: V, i, u, v
Accumulator variables: i, stdc, v
Iterator variables: i, itr, v
Class/struct names: Graph
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100 ; void dfs ( int n , int m , bool visit [ ] [ MAX ] , int adj [ ] [ MAX ] , int N , int M ) { visit [ n ] [ m ] = 1 ; if ( n + 1 < N && adj [ n ] [ m ] >= adj [ n + 1 ] [ m ] && ! visit [ n + 1 ] [ m ] ) dfs ( n + 1 , m , visit , adj , N , M ) ; if ( m + 1 < M && adj [ n ] [ m ] >= adj [ n ] [ m + 1 ] && ! visit [ n ] [ m + 1 ] ) dfs ( n , m + 1 , visit , adj , N , M ) ; if ( n - 1 >= 0 && adj [ n ] [ m ] >= adj [ n - 1 ] [ m ] && ! visit [ n - 1 ] [ m ] ) dfs ( n - 1 , m , visit , adj , N , M ) ; if ( m - 1 >= 0 && adj [ n ] [ m ] >= adj [ n ] [ m - 1 ] && ! visit [ n ] [ m - 1 ] ) dfs ( n , m - 1 , visit , adj , N , M ) ; } void printMinSources ( int adj [ ] [ MAX ] , int N , int M ) { vector < pair < long int , pair < int , int > > > x ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < M ; j ++ ) x . push_back ( make_pair ( adj [ i ] [ j ] , make_pair ( i , j ) ) ) ; sort ( x . begin ( ) , x . end ( ) ) ; bool visit [ N ] [ MAX ] ; memset ( visit , false , sizeof ( visit ) ) ; for ( int i = x . size ( ) - 1 ; i >= 0 ; i -- ) { if ( ! visit [ x [ i ] . second . first ] [ x [ i ] . second . second ] ) { cout << x [ i ] . second . first << " ▁ " << x [ i ] . second . second << endl ; dfs ( x [ i ] . second . first , x [ i ] . second . second , visit , adj , N , M ) ; } } } int main ( ) { int N = 2 , M = 2 ; int adj [ N ] [ MAX ] = { { 3 , 3 } , { 1 , 1 } } ; printMinSources ( adj , N , M ) ; return 0 ; }

Index/key variables: MAX, N, i, j, m, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; class graph { int V ; list < int > * l ; public : graph ( int V ) { this -> V = V ; l = new list < int > [ V ] ; } void addedge ( int V1 , int V2 ) { l [ V1 ] . push_back ( V2 ) ; l [ V2 ] . push_back ( V1 ) ; } int bfs ( int in1 , int in2 ) ; } ; void SieveOfEratosthenes ( vector < int > & v ) { int n = 9999 ; bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 1000 ; p <= n ; p ++ ) if ( prime [ p ] ) v . push_back ( p ) ; } int graph :: bfs ( int in1 , int in2 ) { int visited [ V ] ; memset ( visited , 0 , sizeof ( visited ) ) ; queue < int > que ; visited [ in1 ] = 1 ; que . push ( in1 ) ; list < int > :: iterator i ; while ( ! que . empty ( ) ) { int p = que . front ( ) ; que . pop ( ) ; for ( i = l [ p ] . begin ( ) ; i != l [ p ] . end ( ) ; i ++ ) { if ( ! visited [ * i ] ) { visited [ * i ] = visited [ p ] + 1 ; que . push ( * i ) ; } if ( * i == in2 ) { return visited [ * i ] - 1 ; } } } } bool compare ( int num1 , int num2 ) { string s1 = to_string ( num1 ) ; string s2 = to_string ( num2 ) ; int c = 0 ; if ( s1 [ 0 ] != s2 [ 0 ] ) c ++ ; if ( s1 [ 1 ] != s2 [ 1 ] ) c ++ ; if ( s1 [ 2 ] != s2 [ 2 ] ) c ++ ; if ( s1 [ 3 ] != s2 [ 3 ] ) c ++ ; return ( c == 1 ) ; } int shortestPath ( int num1 , int num2 ) { vector < int > pset ; SieveOfEratosthenes ( pset ) ; graph g ( pset . size ( ) ) ; for ( int i = 0 ; i < pset . size ( ) ; i ++ ) for ( int j = i + 1 ; j < pset . size ( ) ; j ++ ) if ( compare ( pset [ i ] , pset [ j ] ) ) g . addedge ( i , j ) ; int in1 , in2 ; for ( int j = 0 ; j < pset . size ( ) ; j ++ ) if ( pset [ j ] == num1 ) in1 = j ; for ( int j = 0 ; j < pset . size ( ) ; j ++ ) if ( pset [ j ] == num2 ) in2 = j ; return g . bfs ( in1 , in2 ) ; } int main ( ) { int num1 = 1033 , num2 = 8179 ; cout << shortestPath ( num1 , num2 ) ; return 0 ; }

Index/key variables: V, V1, V2, i, in1, j, p
Accumulator variables: c, i, j, p, stdc
Iterator variables: i, j, p
Class/struct names: graph
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printLevels ( vector < int > graph [ ] , int V , int x ) { int level [ V ] ; bool marked [ V ] ; queue < int > que ; que . push ( x ) ; level [ x ] = 0 ; marked [ x ] = true ; while ( ! que . empty ( ) ) { x = que . front ( ) ; que . pop ( ) ; for ( int i = 0 ; i < graph [ x ] . size ( ) ; i ++ ) { int b = graph [ x ] [ i ] ; if ( ! marked [ b ] ) { que . push ( b ) ; level [ b ] = level [ x ] + 1 ; marked [ b ] = true ; } } } cout << " Nodes " << " TABSYMBOL " << " Level " << endl ; for ( int i = 0 ; i < V ; i ++ ) cout << " ▁ " << i << " ▁ - - > ▁ " << level [ i ] << endl ; } int main ( ) { int V = 8 ; vector < int > graph [ V ] ; graph [ 0 ] . push_back ( 1 ) ; graph [ 0 ] . push_back ( 2 ) ; graph [ 1 ] . push_back ( 3 ) ; graph [ 1 ] . push_back ( 4 ) ; graph [ 1 ] . push_back ( 5 ) ; graph [ 2 ] . push_back ( 5 ) ; graph [ 2 ] . push_back ( 6 ) ; graph [ 6 ] . push_back ( 7 ) ; printLevels ( graph , V , 0 ) ; return 0 ; }

Index/key variables: V, b, i, x
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <vector>
using namespace std ; void dfs ( int parent , int ans [ ] , vector < int > connectchars [ ] ) { ans [ parent ] = 1 ; for ( int i = 0 ; i < connectchars [ parent ] . size ( ) ; i ++ ) { if ( ! ans [ connectchars [ parent ] [ i ] ] ) dfs ( connectchars [ parent ] [ i ] , ans , connectchars ) ; } } void printBinaryPalindrome ( int n , int k ) { int arr [ n ] , ans [ n ] = { 0 } ; vector < int > connectchars [ k ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = i % k ; for ( int i = 0 ; i < n / 2 ; i ++ ) { connectchars [ arr [ i ] ] . push_back ( arr [ n - i - 1 ] ) ; connectchars [ arr [ n - i - 1 ] ] . push_back ( arr [ i ] ) ; } dfs ( 0 , ans , connectchars ) ; for ( int i = 0 ; i < n ; i ++ ) cout << ans [ arr [ i ] ] ; } int main ( ) { int n = 10 , k = 4 ; printBinaryPalindrome ( n , k ) ; return 0 ; }

Index/key variables: i, k, n, parent
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; struct Node * createNode ( int item ) { Node * temp = new Node ; temp -> data = item ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } void NthPostordernode ( struct Node * root , int N ) { static int flag = 0 ; if ( root == NULL ) return ; if ( flag <= N ) { NthPostordernode ( root -> left , N ) ; NthPostordernode ( root -> right , N ) ; flag ++ ; if ( flag == N ) cout << root -> data ; } } int main ( ) { struct Node * root = createNode ( 25 ) ; root -> left = createNode ( 20 ) ; root -> right = createNode ( 30 ) ; root -> left -> left = createNode ( 18 ) ; root -> left -> right = createNode ( 22 ) ; root -> right -> left = createNode ( 24 ) ; root -> right -> right = createNode ( 32 ) ; int N = 6 ; NthPostordernode ( root , N ) ; return 0 ; }

Accumulator variables: flag, stdc
Class/struct names: Node
C++ program:
#include <iostream>
#include <math.h>
#include <vector>
using namespace std ; bool isPossible ( int m , int n , int k , int r , vector < int > X , vector < int > Y ) { int rect [ m ] [ n ] = { 0 } ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int p = 0 ; p < k ; p ++ ) { if ( sqrt ( ( pow ( ( X [ p ] - 1 - i ) , 2 ) + pow ( ( Y [ p ] - 1 - j ) , 2 ) ) ) <= r ) { rect [ i ] [ j ] = -1 ; } } } } if ( rect [ 0 ] [ 0 ] == -1 ) return false ; vector < vector < int > > qu ; rect [ 0 ] [ 0 ] = 1 ; qu . push_back ( { 0 , 0 } ) ; while ( ! qu . empty ( ) ) { vector < int > arr = qu . front ( ) ; qu . erase ( qu . begin ( ) ) ; int elex = arr [ 0 ] ; int eley = arr [ 1 ] ; if ( ( elex > 0 ) && ( eley > 0 ) && ( rect [ elex - 1 ] [ eley - 1 ] == 0 ) ) { rect [ elex - 1 ] [ eley - 1 ] = 1 ; vector < int > v = { elex - 1 , eley - 1 } ; qu . push_back ( v ) ; } if ( ( elex > 0 ) && ( rect [ elex - 1 ] [ eley ] == 0 ) ) { rect [ elex - 1 ] [ eley ] = 1 ; vector < int > v = { elex - 1 , eley } ; qu . push_back ( v ) ; } if ( ( elex > 0 ) && ( eley < n - 1 ) && ( rect [ elex - 1 ] [ eley + 1 ] == 0 ) ) { rect [ elex - 1 ] [ eley + 1 ] = 1 ; vector < int > v = { elex - 1 , eley + 1 } ; qu . push_back ( v ) ; } if ( ( eley > 0 ) && ( rect [ elex ] [ eley - 1 ] == 0 ) ) { rect [ elex ] [ eley - 1 ] = 1 ; vector < int > v = { elex , eley - 1 } ; qu . push_back ( v ) ; } if ( ( eley < n - 1 ) && ( rect [ elex ] [ eley + 1 ] == 0 ) ) { rect [ elex ] [ eley + 1 ] = 1 ; vector < int > v = { elex , eley + 1 } ; qu . push_back ( v ) ; } if ( ( elex < m - 1 ) && ( eley > 0 ) && ( rect [ elex + 1 ] [ eley - 1 ] == 0 ) ) { rect [ elex + 1 ] [ eley - 1 ] = 1 ; vector < int > v = { elex + 1 , eley - 1 } ; qu . push_back ( v ) ; } if ( ( elex < m - 1 ) && ( rect [ elex + 1 ] [ eley ] == 0 ) ) { rect [ elex + 1 ] [ eley ] = 1 ; vector < int > v = { elex + 1 , eley } ; qu . push_back ( v ) ; } if ( ( elex < m - 1 ) && ( eley < n - 1 ) && ( rect [ elex + 1 ] [ eley + 1 ] == 0 ) ) { rect [ elex + 1 ] [ eley + 1 ] = 1 ; vector < int > v = { elex + 1 , eley + 1 } ; qu . push_back ( v ) ; } } return ( rect [ m - 1 ] [ n - 1 ] == 1 ) ; } int main ( ) { int m1 = 5 , n1 = 5 , k1 = 2 , r1 = 1 ; vector < int > X1 = { 1 , 3 } ; vector < int > Y1 = { 3 , 3 } ; if ( isPossible ( m1 , n1 , k1 , r1 , X1 , Y1 ) ) cout << " Possible " << endl ; else cout << " Not ▁ Possible " << endl ; int m2 = 5 , n2 = 5 , k2 = 2 , r2 = 1 ; vector < int > X2 = { 1 , 1 } ; vector < int > Y2 = { 2 , 3 } ; if ( isPossible ( m2 , n2 , k2 , r2 , X2 , Y2 ) ) cout << " Possible " << endl ; else cout << " Not ▁ Possible " << endl ; return 0 ; }

Index/key variables: elex, eley, i, j, m, n, p
Accumulator variables: i, j, p
Iterator variables: i, j, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void dfs ( vector < int > list [ ] , int node , int arrival ) { cout << node << ' ' ; for ( int i = 0 ; i < list [ node ] . size ( ) ; i ++ ) { if ( list [ node ] [ i ] != arrival ) dfs ( list , list [ node ] [ i ] , node ) ; } } int main ( ) { int nodes = 5 ; vector < int > list [ 10000 ] ; list [ 1 ] . push_back ( 2 ) ; list [ 2 ] . push_back ( 1 ) ; list [ 1 ] . push_back ( 3 ) ; list [ 3 ] . push_back ( 1 ) ; list [ 2 ] . push_back ( 4 ) ; list [ 4 ] . push_back ( 2 ) ; list [ 3 ] . push_back ( 5 ) ; list [ 5 ] . push_back ( 3 ) ; dfs ( list , 1 , 0 ) ; return 0 ; }

Index/key variables: i, node
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long count_color [ 2 ] ; void dfs ( vector < int > adj [ ] , int node , int parent , int color ) { count_color [ color ] ++ ; for ( int i = 0 ; i < adj [ node ] . size ( ) ; i ++ ) { if ( adj [ node ] [ i ] != parent ) dfs ( adj , adj [ node ] [ i ] , node , ! color ) ; } } int findMaxEdges ( vector < int > adj [ ] , int n ) { dfs ( adj , 1 , 0 , 0 ) ; return count_color [ 0 ] * count_color [ 1 ] - ( n - 1 ) ; } int main ( ) { int n = 5 ; vector < int > adj [ n + 1 ] ; adj [ 1 ] . push_back ( 2 ) ; adj [ 1 ] . push_back ( 3 ) ; adj [ 2 ] . push_back ( 4 ) ; adj [ 3 ] . push_back ( 5 ) ; cout << findMaxEdges ( adj , n ) ; return 0 ; }

Index/key variables: color, i, node
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMinSteps ( int arr [ ] , int target , int n ) { sort ( arr , arr + n ) ; int minimumSteps = 0 ; int i = 0 , j = n - 1 ; while ( i <= j ) { if ( arr [ i ] + arr [ j ] <= target ) { i ++ ; j -- ; } else { j -- ; } minimumSteps ++ ; } return minimumSteps ; } int main ( ) { int arr [ ] = { 4 , 6 , 2 , 9 , 6 , 5 , 8 , 10 } ; int target = 11 ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countMinSteps ( arr , target , size ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, minimumSteps, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sticks [ ] = { 6 , 7 , 4 , 6 , 5 , 4 , 6 , 5 , 2 , 4 , 4 , 3 , 6 , 6 , 6 , 5 , 7 , 6 , 5 , 3 , 5 , 4 , 6 , 4 , 3 , 4 } ; int number [ ] = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; int countSticks ( string str ) { int cnt = 0 ; for ( int i = 0 ; str [ i ] ; i ++ ) { char ch = str [ i ] ; if ( ch >= ' A ' && ch <= ' Z ' ) { cnt += sticks [ ch - ' A ' ] ; } else { cnt += number [ ch - '0' ] ; } } return cnt ; } void sortArr ( string arr [ ] , int n ) { vector < pair < int , string > > vp ; for ( int i = 0 ; i < n ; i ++ ) { vp . push_back ( make_pair ( countSticks ( arr [ i ] ) , arr [ i ] ) ) ; } sort ( vp . begin ( ) , vp . end ( ) ) ; for ( int i = 0 ; i < vp . size ( ) ; i ++ ) cout << vp [ i ] . second << " ▁ " ; } int main ( ) { string arr [ ] = { " GEEKS " , " FOR " , " GEEKSFORGEEKS " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sortArr ( arr , n ) ; return 0 ; }

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