dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; string Minimum_Window ( string s , string t ) { int m [ 256 ] = { 0 } ; int ans = INT_MAX ; int start = 0 ; int count = 0 ; for ( int i = 0 ; i < t . length ( ) ; i ++ ) { if ( m [ t [ i ] ] == 0 ) count ++ ; m [ t [ i ] ] ++ ; } int i = 0 ; int j = 0 ; while ( j < s . length ( ) ) { m [ s [ j ] ] -- ; if ( m [ s [ j ] ] == 0 ) count -- ; if ( count == 0 ) { while ( count == 0 ) { if ( ans > j - i + 1 ) { ans = min ( ans , j - i + 1 ) ; start = i ; } m [ s [ i ] ] ++ ; if ( m [ s [ i ] ] > 0 ) count ++ ; i ++ ; } } j ++ ; } if ( ans != INT_MAX ) return s . substr ( start , ans ) ; else return " - 1" ; } main ( ) { string s = " ADOBECODEBANC " ; string t = " ABC " ; cout << " - - > Smallest ▁ window ▁ that ▁ contain ▁ all ▁ character ▁ : ▁ " << endl ; cout << Minimum_Window ( s , t ) ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRLE ( string str ) { int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int count = 1 ; while ( i < n - 1 && str [ i ] == str [ i + 1 ] ) { count ++ ; i ++ ; } cout << str [ i ] << count ; } } int main ( ) { string str = " wwwwaaadexxxxxxywww " ; printRLE ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <stdio.h>
#include <string.h>
using namespace std ; # define NO_OF_CHARS  256
void print ( char list [ ] [ 50 ] , char * word , int list_size ) { int * map = new int [ ( sizeof ( int ) * NO_OF_CHARS ) ] ; int i , j , count , word_size ; for ( i = 0 ; * ( word + i ) ; i ++ ) map [ * ( word + i ) ] = 1 ; word_size = strlen ( word ) ; for ( i = 0 ; i < list_size ; i ++ ) { for ( j = 0 , count = 0 ; * ( list [ i ] + j ) ; j ++ ) { if ( map [ * ( list [ i ] + j ) ] ) { count ++ ; map [ * ( list [ i ] + j ) ] = 0 ; } } if ( count == word_size ) cout << list [ i ] << endl ; for ( j = 0 ; * ( word + j ) ; j ++ ) map [ * ( word + j ) ] = 1 ; } } int main ( ) { char str [ ] = " sun " ; char list [ ] [ 50 ] = { " geeksforgeeks " , " unsorted " , " sunday " , " just " , " sss " } ; print ( list , str , 5 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; #define NO_OF_CHARS  256
int * getCharCountArray ( char * str ) { int * count = ( int * ) calloc ( sizeof ( int ) , NO_OF_CHARS ) ; int i ; for ( i = 0 ; * ( str + i ) ; i ++ ) count [ * ( str + i ) ] ++ ; return count ; } int firstNonRepeating ( char * str ) { int * count = getCharCountArray ( str ) ; int index = -1 , i ; for ( i = 0 ; * ( str + i ) ; i ++ ) { if ( count [ * ( str + i ) ] == 1 ) { index = i ; break ; } } free ( count ) ; return index ; } int main ( ) { char str [ ] = " geeksforgeeks " ; int index = firstNonRepeating ( str ) ; if ( index == -1 ) cout << " Either ▁ all ▁ characters ▁ are ▁ repeating ▁ or ▁ " " string ▁ is ▁ empty " ; else cout << " First ▁ non - repeating ▁ character ▁ is ▁ " << str [ index ] ; getchar ( ) ; return 0 ; }

Index/key variables: index
Accumulator variables: i
Iterator variables: i
C++ program:
#include <iostream>
#include <string.h>
using namespace std ; class gfg { public : void divideString ( char str [ ] , int n ) { int str_size = strlen ( str ) ; int i ; int part_size ; if ( str_size % n != 0 ) { cout << " Invalid ▁ Input : ▁ String ▁ size " ; cout << " ▁ is ▁ not ▁ divisible ▁ by ▁ n " ; return ; } part_size = str_size / n ; for ( i = 0 ; i < str_size ; i ++ ) { if ( i % part_size == 0 ) cout << endl ; cout << str [ i ] ; } } } ; int main ( ) { gfg g ; char str [ ] = " a _ simple _ divide _ string _ quest " ; g . divideString ( str , 4 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: gfg
C++ program:
#include <cstring>
#include <iostream>
using namespace std ; #define M  3
#define N  3
string dictionary [ ] = { " GEEKS " , " FOR " , " QUIZ " , " GO " } ; int n = sizeof ( dictionary ) / sizeof ( dictionary [ 0 ] ) ; bool isWord ( string & str ) { for ( int i = 0 ; i < n ; i ++ ) if ( str . compare ( dictionary [ i ] ) == 0 ) return true ; return false ; } void findWordsUtil ( char boggle [ M ] [ N ] , bool visited [ M ] [ N ] , int i , int j , string & str ) { visited [ i ] [ j ] = true ; str = str + boggle [ i ] [ j ] ; if ( isWord ( str ) ) cout << str << endl ; for ( int row = i - 1 ; row <= i + 1 && row < M ; row ++ ) for ( int col = j - 1 ; col <= j + 1 && col < N ; col ++ ) if ( row >= 0 && col >= 0 && ! visited [ row ] [ col ] ) findWordsUtil ( boggle , visited , row , col , str ) ; str . erase ( str . length ( ) - 1 ) ; visited [ i ] [ j ] = false ; } void findWords ( char boggle [ M ] [ N ] ) { bool visited [ M ] [ N ] = { { false } } ; string str = " " ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) findWordsUtil ( boggle , visited , i , j , str ) ; } int main ( ) { char boggle [ M ] [ N ] = { { ' G ' , ' I ' , ' Z ' } , { ' U ' , ' E ' , ' K ' } , { ' Q ' , ' S ' , ' E ' } } ; cout << " Following ▁ words ▁ of ▁ dictionary ▁ are ▁ present STRNEWLINE " ; findWords ( boggle ) ; return 0 ; }

Index/key variables: M, N, col, i, j, row
Accumulator variables: col, i, j, row
Iterator variables: col, i, j, row
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct direction { int x , y ; char c ; } ; bool isCorner ( int i , int j , int M , int N ) { if ( ( i == 0 && j == 0 ) || ( i == 0 && j == N - 1 ) || ( i == M - 1 && j == N - 1 ) || ( i == M - 1 && j == 0 ) ) return true ; return false ; } bool isValid ( int i , int j , int M , int N ) { if ( i < 0 i > = M j < 0 j > = N ) return false ; return true ; } void solve ( int i , int j , int M , int N , direction dir [ ] , vector < vector < int > > & maze , string & t , vector < string > & ans ) { if ( isCorner ( i , j , M , N ) ) { ans . push_back ( t ) ; return ; } for ( int k = 0 ; k < 4 ; k ++ ) { int x = i + dir [ k ] . x ; int y = j + dir [ k ] . y ; char c = dir [ k ] . c ; if ( isValid ( x , y , M , N ) && maze [ x ] [ y ] == 1 ) { maze [ x ] [ y ] = 0 ; t . push_back ( c ) ; solve ( x , y , M , N , dir , maze , t , ans ) ; t . pop_back ( ) ; maze [ x ] [ y ] = 1 ; } } return ; } vector < string > possiblePaths ( vector < int > src , vector < vector < int > > & maze ) { direction dir [ 4 ] = { { -1 , 0 , ' U ' } , { 0 , 1 , ' R ' } , { 1 , 0 , ' D ' } , { 0 , -1 , ' L ' } } ; string temp ; vector < string > ans ; solve ( src [ 0 ] , src [ 1 ] , maze . size ( ) , maze [ 0 ] . size ( ) , dir , maze , temp , ans ) ; return ans ; } int main ( ) { vector < vector < int > > maze = { { 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 } , { 1 , 1 , 1 , 0 , 0 , 0 , 1 , 0 } , { 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 } , { 1 , 0 , 1 , 0 , 1 , 0 , 0 , 1 } , { 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 } , { 0 , 1 , 0 , 0 , 1 , 1 , 1 , 1 } , { 1 , 1 , 0 , 0 , 0 , 0 , 0 , 1 } , } ; vector < int > src = { 4 , 2 } ; vector < string > paths = possiblePaths ( src , maze ) ; if ( paths . size ( ) == 0 ) { cout << " No ▁ Possible ▁ Paths " ; return 0 ; } for ( int i = 0 ; i < paths . size ( ) ; i ++ ) cout << paths [ i ] << endl ; return 0 ; }

Index/key variables: i, k, x, y
Accumulator variables: i, k, stdc
Iterator variables: i, k
Class/struct names: direction
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 2 ; bool issafe ( int sudoku [ N ] [ N ] , int i , int j , int n , int number , char region [ N ] [ N ] ) { for ( int x = 0 ; x < n ; x ++ ) { if ( sudoku [ x ] [ j ] == number sudoku [ i ] [ x ] == number ) { return false ; } } char r = region [ i ] [ j ] ; queue < pair < int , int > > q ; q . push ( make_pair ( i , j ) ) ; int visited [ N ] [ N ] ; memset ( visited , 0 , sizeof visited ) ; visited [ i ] [ j ] = 1 ; while ( ! q . empty ( ) ) { pair < int , int > front = q . front ( ) ; q . pop ( ) ; if ( front . first + 1 < N && region [ front . first + 1 ] [ front . second ] == r && ! visited [ front . first + 1 ] [ front . second ] ) { if ( sudoku [ front . first + 1 ] [ front . second ] == number ) { return false ; } q . push ( make_pair ( front . first + 1 , front . second ) ) ; visited [ front . first + 1 ] [ front . second ] = 1 ; } if ( front . first - 1 >= 0 && region [ front . first - 1 ] [ front . second ] == r && ! visited [ front . first - 1 ] [ front . second ] ) { if ( sudoku [ front . first - 1 ] [ front . second ] == number ) { return false ; } q . push ( make_pair ( front . first - 1 , front . second ) ) ; visited [ front . first - 1 ] [ front . second ] = 1 ; } if ( front . second + 1 < N && region [ front . first ] [ front . second + 1 ] == r && ! visited [ front . first ] [ front . second + 1 ] ) { if ( sudoku [ front . first ] [ front . second + 1 ] == number ) { return false ; } q . push ( make_pair ( front . first , front . second + 1 ) ) ; visited [ front . first ] [ front . second + 1 ] = 1 ; } if ( front . second - 1 >= 0 && region [ front . first ] [ front . second - 1 ] == r && ! visited [ front . first ] [ front . second - 1 ] ) { if ( sudoku [ front . first ] [ front . second - 1 ] == number ) { return false ; } q . push ( make_pair ( front . first , front . second - 1 ) ) ; visited [ front . first ] [ front . second - 1 ] = 1 ; } } return true ; } bool solveSudoku ( int sudoku [ N ] [ N ] , int i , int j , int n , char region [ N ] [ N ] ) { if ( i == n ) { for ( int a = 0 ; a < n ; a ++ ) { for ( int b = 0 ; b < n ; b ++ ) { cout << sudoku [ a ] [ b ] << " ▁ " ; } cout << endl ; } return true ; } if ( j == n ) { return solveSudoku ( sudoku , i + 1 , 0 , n , region ) ; } if ( sudoku [ i ] [ j ] != 0 ) { return solveSudoku ( sudoku , i , j + 1 , n , region ) ; } else { for ( int number = 1 ; number <= n ; number ++ ) { if ( issafe ( sudoku , i , j , n , number , region ) ) { sudoku [ i ] [ j ] = number ; bool rest = solveSudoku ( sudoku , i , j + 1 , n , region ) ; if ( rest == true ) { return true ; } } } sudoku [ i ] [ j ] = 0 ; return false ; } } int main ( ) { int sudoku [ N ] [ N ] = { { 0 , 1 } , { 0 , 0 } } ; char region [ N ] [ N ] = { { ' r ' , ' r ' } , { ' b ' , ' b ' } } ; int ans = solveSudoku ( sudoku , 0 , 0 , N , region ) ; if ( ans == 0 ) { cout << " - 1" ; } return 0 ; }

Index/key variables: N, a, b, i, j, x
Accumulator variables: a, b, number, stdc, x
Iterator variables: a, b, number, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left , * right ; } ; node * newNode ( int key ) { node * temp = new node ; temp -> data = key ; temp -> left = temp -> right = NULL ; return ( temp ) ; } void printLevelOrder ( node * root ) { if ( ! root ) return ; queue < node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { node * temp = q . front ( ) ; cout << temp -> data << " ▁ " ; q . pop ( ) ; if ( temp -> left != NULL ) { q . push ( temp -> left ) ; } else if ( temp -> right != NULL ) { cout << " NULL ▁ " ; } if ( temp -> right != NULL ) { q . push ( temp -> right ) ; } else if ( temp -> left != NULL ) { cout << " NULL ▁ " ; } } } node * pruneTree ( node * root ) { if ( ! root ) { return NULL ; } root -> left = pruneTree ( root -> left ) ; root -> right = pruneTree ( root -> right ) ; if ( root -> data % 2 == 0 && ! root -> right && ! root -> left ) return NULL ; return root ; } int main ( ) { struct node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> left -> left = newNode ( 8 ) ; root -> left -> right = newNode ( 10 ) ; root -> right = newNode ( 7 ) ; root -> right -> left = newNode ( 12 ) ; root -> right -> right = newNode ( 5 ) ; node * newRoot = pruneTree ( root ) ; printLevelOrder ( newRoot ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <iostream>
using namespace std ; int countWays ( int mtrx [ ] [ 11 ] , int vrtx , int i , int dest , bool visited [ ] ) { if ( i == dest ) { return 1 ; } int total = 0 ; for ( int j = 0 ; j < vrtx ; j ++ ) { if ( mtrx [ i ] [ j ] == 1 && ! visited [ j ] ) { visited [ j ] = true ; total += countWays ( mtrx , vrtx , j , dest , visited ) ; visited [ j ] = false ; } } return total ; } int totalWays ( int mtrx [ ] [ 11 ] , int vrtx , int src , int dest ) { bool visited [ vrtx ] ; for ( int i = 0 ; i < vrtx ; i ++ ) { visited [ i ] = false ; } visited [ src ] = true ; return countWays ( mtrx , vrtx , src , dest , visited ) ; } int main ( ) { int vrtx = 11 ; int mtrx [ 11 ] [ 11 ] = { { 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 } , { 1 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 0 } , { 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 } } ; int src = 3 ; int dest = 9 ; cout << totalWays ( mtrx , vrtx , src - 1 , dest - 1 ) ; return 0 ; }

Index/key variables: i, j, src, vrtx
Accumulator variables: i, j, total
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printExistPath ( stack < int > sx , stack < int > sy , int last ) { if ( sx . empty ( ) || sy . empty ( ) ) { return ; } int x = sx . top ( ) ; int y = sy . top ( ) ; sx . pop ( ) ; sy . pop ( ) ; printExistPath ( sx , sy , last ) ; if ( sx . size ( ) == last - 1 ) { cout << " ( " << x << " , ▁ " << y << " ) " ; } else { cout << " ( " << x << " , ▁ " << y << " ) ▁ - > ▁ " ; } } bool storePath ( int srcX , int srcY , int destX , int destY , stack < int > & sx , stack < int > & sy ) { if ( srcX > destX srcY > destY ) { return false ; } sx . push ( srcX ) ; sy . push ( srcY ) ; if ( srcX == destX && srcY == destY ) { printExistPath ( sx , sy , sx . size ( ) ) ; return true ; } if ( storePath ( ( 2 * srcX ) + srcY , srcY , destX , destY , sx , sy ) ) { return true ; } if ( storePath ( srcX , ( 2 * srcY ) + srcX , destX , destY , sx , sy ) ) { return true ; } sx . pop ( ) ; sy . pop ( ) ; return false ; } bool isPathExist ( int srcX , int srcY , int destX , int destY ) { stack < int > sx ; stack < int > sy ; return storePath ( srcX , srcY , destX , destY , sx , sy ) ; } void printPath ( int srcX , int srcY , int destX , int destY ) { if ( ! isPathExist ( srcX , srcY , destX , destY ) ) { cout << " - 1" ; } } int main ( ) { int srcX = 5 , srcY = 8 ; int destX = 83 , destY = 21 ; printPath ( srcX , srcY , destX , destY ) ; }

Accumulator variables: stdc
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 ) ; } int evenPaths ( struct Node * node , int count ) { if ( node == NULL || ( node -> key % 2 != 0 ) ) { return count ; } if ( ! node -> left && ! node -> right ) { count ++ ; } count = evenPaths ( node -> left , count ) ; return evenPaths ( node -> right , count ) ; } int countEvenPaths ( struct Node * node ) { return evenPaths ( node , 0 ) ; } int main ( ) { Node * root = newNode ( 12 ) ; root -> left = newNode ( 13 ) ; root -> right = newNode ( 12 ) ; root -> right -> left = newNode ( 14 ) ; root -> right -> right = newNode ( 16 ) ; root -> right -> left -> left = newNode ( 21 ) ; root -> right -> left -> right = newNode ( 22 ) ; root -> right -> right -> left = newNode ( 22 ) ; root -> right -> right -> right = newNode ( 24 ) ; root -> right -> right -> right -> left = newNode ( 8 ) ; cout << countEvenPaths ( root ) ; return 0 ; }

Accumulator variables: count, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int ans = 0 ; vector < int > c ; subsetGen ( arr , 0 , n , ans , c ) ; cout << ans ; return 0 ; } void subsetSum ( vector < int > & c , int i , int & ans , int curr ) { if ( i == c . size ( ) ) { ans += curr ; return ; } subsetSum ( c , i + 1 , ans , curr + c [ i ] ) ; subsetSum ( c , i + 1 , ans , curr ) ; } void subsetGen ( int * arr , int i , int n , int & ans , vector < int > & c ) { if ( i == n ) { subsetSum ( c , 0 , ans , 0 ) ; return ; } subsetGen ( arr , i + 1 , n , ans , c ) ; c . push_back ( arr [ i ] ) ; subsetGen ( arr , i + 1 , n , ans , c ) ; c . pop_back ( ) ; } int main ( ) { int arr [ ] = { 1 , 1 } ; int n = sizeof ( arr ) / sizeof ( int ) ;

Index/key variables: i
Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 1000 ; vector < int > adj [ N ] ; void dfsUtil ( int u , int node , bool visited [ ] , vector < pair < int , int > > road_used , int parent , int it ) { int c = 0 ; for ( int i = 0 ; i < node ; i ++ ) if ( visited [ i ] ) c ++ ; if ( c == node ) return ; visited [ u ] = true ; road_used . push_back ( { parent , u } ) ; cout << u << " ▁ " ; for ( int x : adj [ u ] ) { if ( ! visited [ x ] ) dfsUtil ( x , node , visited , road_used , u , it + 1 ) ; } for ( auto y : road_used ) if ( y . second == u ) dfsUtil ( y . first , node , visited , road_used , u , it + 1 ) ; } void dfs ( int node ) { bool visited [ node ] ; vector < pair < int , int > > road_used ; for ( int i = 0 ; i < node ; i ++ ) visited [ i ] = false ; dfsUtil ( 0 , node , visited , road_used , -1 , 0 ) ; } void insertEdge ( int u , int v ) { adj [ u ] . push_back ( v ) ; adj [ v ] . push_back ( u ) ; } int main ( ) { int node = 11 , edge = 13 ; insertEdge ( 0 , 1 ) ; insertEdge ( 0 , 2 ) ; insertEdge ( 1 , 5 ) ; insertEdge ( 1 , 6 ) ; insertEdge ( 2 , 4 ) ; insertEdge ( 2 , 9 ) ; insertEdge ( 6 , 7 ) ; insertEdge ( 6 , 8 ) ; insertEdge ( 7 , 8 ) ; insertEdge ( 2 , 3 ) ; insertEdge ( 3 , 9 ) ; insertEdge ( 3 , 10 ) ; insertEdge ( 9 , 10 ) ; dfs ( node ) ; return 0 ; }

Index/key variables: N, i, node, u, v, x
Accumulator variables: c, i, stdc
Iterator variables: i, x, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMaximumNum ( string str , int k , string & max ) { if ( k == 0 ) return ; int n = str . length ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( str [ i ] < str [ j ] ) { swap ( str [ i ] , str [ j ] ) ; if ( str . compare ( max ) > 0 ) max = str ; findMaximumNum ( str , k - 1 , max ) ; swap ( str [ i ] , str [ j ] ) ; } } } } int main ( ) { string str = "129814999" ; int k = 4 ; string max = str ; findMaximumNum ( str , k , max ) ; cout << max << endl ; 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 ; vector < vector < int > > allPaths ; void findPathsUtil ( vector < vector < int > > maze , int m , int n , int i , int j , vector < int > path , int indx ) { if ( i == m - 1 ) { for ( int k = j ; k < n ; k ++ ) { path [ indx + k - j ] = maze [ i ] [ k ] ; } cout << " [ " << path [ 0 ] << " , ▁ " ; for ( int z = 1 ; z < path . size ( ) - 1 ; z ++ ) { cout << path [ z ] << " , ▁ " ; } cout << path [ path . size ( ) - 1 ] << " ] " << endl ; allPaths . push_back ( path ) ; return ; } if ( j == n - 1 ) { for ( int k = i ; k < m ; k ++ ) { path [ indx + k - i ] = maze [ k ] [ j ] ; } cout << " [ " << path [ 0 ] << " , ▁ " ; for ( int z = 1 ; z < path . size ( ) - 1 ; z ++ ) { cout << path [ z ] << " , ▁ " ; } cout << path [ path . size ( ) - 1 ] << " ] " << endl ; allPaths . push_back ( path ) ; return ; } path [ indx ] = maze [ i ] [ j ] ; findPathsUtil ( maze , m , n , i + 1 , j , path , indx + 1 ) ; findPathsUtil ( maze , m , n , i , j + 1 , path , indx + 1 ) ; } void findPaths ( vector < vector < int > > maze , int m , int n ) { vector < int > path ( m + n - 1 , 0 ) ; findPathsUtil ( maze , m , n , 0 , 0 , path , 0 ) ; } int main ( ) { vector < vector < int > > maze { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; findPaths ( maze , 3 , 3 ) ; return 0 ; }

Index/key variables: i, indx, j, k, z
Accumulator variables: k, stdc, z
Iterator variables: k, z
C++ program:
#include <iostream>
using namespace std ; bool chkPair ( int A [ ] , int size , int x ) { for ( int i = 0 ; i < ( size - 1 ) ; i ++ ) { for ( int j = ( i + 1 ) ; j < size ; j ++ ) { if ( A [ i ] + A [ j ] == x ) { cout << " Pair ▁ with ▁ a ▁ given ▁ sum ▁ " << x << " ▁ is ▁ ( " << A [ i ] << " , ▁ " << A [ j ] << " ) " << endl ; return 1 ; } } } return 0 ; } int main ( void ) { int A [ ] = { 0 , -1 , 2 , -3 , 1 } ; int x = -2 ; int size = sizeof ( A ) / sizeof ( A [ 0 ] ) ; if ( chkPair ( A , size , x ) ) { cout << " Valid ▁ pair ▁ exists " << endl ; } else { cout << " No ▁ valid ▁ pair ▁ exists ▁ for ▁ " << x << endl ; } return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > merge ( vector < int > x , vector < int > y ) { for ( auto i : y ) { if ( x [ x . size ( ) - 1 ] > i ) x . push_back ( i ) ; } return x ; } vector < int > mergeDel ( vector < int > l ) { if ( l . size ( ) == 1 ) return l ; int m = l . size ( ) / 2 ; vector < int > temp1 = { l . begin ( ) + 0 , l . begin ( ) + m } ; vector < int > temp2 = { l . begin ( ) + m , l . end ( ) } ; return merge ( mergeDel ( temp1 ) , mergeDel ( temp2 ) ) ; } int main ( ) { vector < int > arr ( { 5 , 4 , 3 , 2 , 1 } ) ; vector < int > ans = mergeDel ( arr ) ; cout << " [ ▁ " ; for ( auto x : ans ) cout << x << " , ▁ " ; cout << " ] " ; }

Accumulator variables: stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int _mergeSort ( int arr [ ] , int temp [ ] , int left , int right ) ; int merge ( int arr [ ] , int temp [ ] , int left , int mid , int right ) ; int mergeSort ( int arr [ ] , int array_size ) { int temp [ array_size ] ; return _mergeSort ( arr , temp , 0 , array_size - 1 ) ; } int _mergeSort ( int arr [ ] , int temp [ ] , int left , int right ) { int mid , inv_count = 0 ; if ( right > left ) { mid = ( right + left ) / 2 ; inv_count = _mergeSort ( arr , temp , left , mid ) ; inv_count += _mergeSort ( arr , temp , mid + 1 , right ) ; inv_count += merge ( arr , temp , left , mid + 1 , right ) ; } return inv_count ; } int merge ( int arr [ ] , int temp [ ] , int left , int mid , int right ) { int i , j , k ; int inv_count = 0 ; i = left ; j = mid ; k = left ; while ( ( i <= mid - 1 ) && ( j <= right ) ) { if ( arr [ i ] > 2 * arr [ j ] ) { inv_count += ( mid - i ) ; j ++ ; } else { i ++ ; } } i = left ; j = mid ; k = left ; while ( ( i <= mid - 1 ) && ( j <= right ) ) { if ( arr [ i ] <= arr [ j ] ) { temp [ k ++ ] = arr [ i ++ ] ; } else { temp [ k ++ ] = arr [ j ++ ] ; } } while ( i <= mid - 1 ) temp [ k ++ ] = arr [ i ++ ] ; while ( j <= right ) temp [ k ++ ] = arr [ j ++ ] ; for ( i = left ; i <= right ; i ++ ) arr [ i ] = temp [ i ] ; return inv_count ; } int main ( ) { int arr [ ] = { 1 , 20 , 6 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << mergeSort ( arr , n ) ; return 0 ; }

Index/key variables: array_size, i, j
Accumulator variables: i, inv_count, j, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
int lazy [ 4 * N ] ; set < int > se ; void update ( int x , int y , int value , int id , int l , int r ) { if ( x >= r or l >= y ) return ; if ( x <= l && r <= y ) { lazy [ id ] = value ; return ; } int mid = ( l + r ) / 2 ; if ( lazy [ id ] ) lazy [ 2 * id ] = lazy [ 2 * id + 1 ] = lazy [ id ] ; lazy [ id ] = 0 ; update ( x , y , value , 2 * id , l , mid ) ; update ( x , y , value , 2 * id + 1 , mid , r ) ; } void query ( int id , int l , int r ) { if ( lazy [ id ] ) { se . insert ( lazy [ id ] ) ; return ; } if ( r - l < 2 ) return ; int mid = ( l + r ) / 2 ; query ( 2 * id , l , mid ) ; query ( 2 * id + 1 , mid , r ) ; } int main ( ) { int n = 5 , q = 3 ; update ( 1 , 4 , 1 , 1 , 0 , n ) ; update ( 0 , 2 , 2 , 1 , 0 , n ) ; update ( 3 , 4 , 3 , 1 , 0 , n ) ; query ( 1 , 0 , n ) ; cout << se . size ( ) << endl ; return 0 ; }

Index/key variables: id
Accumulator variables: stdc