dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; unsigned long int catalanDP ( unsigned int n ) { unsigned long int catalan [ n + 1 ] ; catalan [ 0 ] = catalan [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { catalan [ i ] = 0 ; for ( int j = 0 ; j < i ; j ++ ) catalan [ i ] += catalan [ j ] * catalan [ i - j - 1 ] ; } return catalan [ n ] ; } unsigned long int countWays ( unsigned long int n ) { if ( n & 1 ) { cout << " Invalid " ; return 0 ; } return catalanDP ( n / 2 ) ; } int main ( ) { cout << countWays ( 6 ) << " ▁ " ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100
int dp [ MAX ] [ MAX ] [ MAX ] [ 3 ] ; int countWays ( int p , int q , int r , int last ) { if ( p < 0 q < 0 r < 0 ) return 0 ; if ( p == 1 && q == 0 && r == 0 && last == 0 ) return 1 ; if ( p == 0 && q == 1 && r == 0 && last == 1 ) return 1 ; if ( p == 0 && q == 0 && r == 1 && last == 2 ) return 1 ; if ( dp [ p ] [ q ] [ r ] [ last ] != -1 ) return dp [ p ] [ q ] [ r ] [ last ] ; if ( last == 0 ) dp [ p ] [ q ] [ r ] [ last ] = countWays ( p - 1 , q , r , 1 ) + countWays ( p - 1 , q , r , 2 ) ; else if ( last == 1 ) dp [ p ] [ q ] [ r ] [ last ] = countWays ( p , q - 1 , r , 0 ) + countWays ( p , q - 1 , r , 2 ) ; dp [ p ] [ q ] [ r ] [ last ] = countWays ( p , q , r - 1 , 0 ) + countWays ( p , q , r - 1 , 1 ) ; return dp [ p ] [ q ] [ r ] [ last ] ; } int countUtil ( int p , int q , int r ) { memset ( dp , -1 , sizeof ( dp ) ) ; } int main ( ) { int p = 1 , q = 1 , r = 1 ; printf ( " % d " , countUtil ( p , q , r ) ) ; return 0 ; }

Index/key variables: MAX, last, p, q, r
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDer ( int n ) { if ( n == 1 ) return 0 ; if ( n == 2 ) return 1 ; return ( n - 1 ) * ( countDer ( n - 1 ) + countDer ( n - 2 ) ) ; } int main ( ) { int n = 4 ; cout << " Count ▁ of ▁ Derangements ▁ is ▁ " << countDer ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDer ( int n ) { int der [ n + 1 ] = { 0 } ; der [ 1 ] = 0 ; der [ 2 ] = 1 ; for ( int i = 3 ; i <= n ; ++ i ) der [ i ] = ( i - 1 ) * ( der [ i - 1 ] + der [ i - 2 ] ) ; return der [ n ] ; } int main ( ) { int n = 4 ; cout << " Count ▁ of ▁ Derangements ▁ is ▁ " << countDer ( n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSol ( int coeff [ ] , int n , int rhs ) { int dp [ rhs + 1 ] ; memset ( dp , 0 , sizeof ( dp ) ) ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = coeff [ i ] ; j <= rhs ; j ++ ) dp [ j ] += dp [ j - coeff [ i ] ] ; return dp [ rhs ] ; } int main ( ) { int coeff [ ] = { 2 , 2 , 5 } ; int rhs = 4 ; int n = sizeof ( coeff ) / sizeof ( coeff [ 0 ] ) ; cout << countSol ( coeff , n , rhs ) ; return 0 ; }

Index/key variables: i, j, rhs
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#include <map>
using namespace std ; void palindromeSubStrs ( string s ) { map < string , int > m ; int n = s . size ( ) ; int R [ 2 ] [ n + 1 ] ; s = " @ " + s + " # " ; for ( int j = 0 ; j <= 1 ; j ++ ) { R [ j ] [ 0 ] = 0 ; int i = 1 ; while ( i <= n ) { while ( s [ i - rp - 1 ] == s [ i + j + rp ] ) R [ j ] [ i ] = rp ; int k = 1 ; while ( ( R [ j ] [ i - k ] != rp - k ) && ( k < rp ) ) { R [ j ] [ i + k ] = min ( R [ j ] [ i - k ] , rp - k ) ; k ++ ; } rp = max ( rp - k , 0 ) ; i += k ; } } s = s . substr ( 1 , n ) ; m [ string ( 1 , s [ 0 ] ) ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= 1 ; j ++ ) for ( int rp = R [ j ] [ i ] ; rp > 0 ; rp -- ) m [ s . substr ( i - rp - 1 , 2 * rp + j ) ] = 1 ; m [ string ( 1 , s [ i ] ) ] = 1 ; } cout << " Below ▁ are ▁ " << m . size ( ) - 1 << " ▁ palindrome ▁ sub - strings " ; map < string , int > :: iterator ii ; for ( ii = m . begin ( ) ; ii != m . end ( ) ; ++ ii ) cout << ( * ii ) . first << endl ; } int main ( ) { palindromeSubStrs ( " abaaa " ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, k, rp
Iterator variables: i, ii, j, rp
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; Node * newNode ( int data ) { Node * temp = new Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } void largestValueInEachLevel ( Node * root ) { if ( ! root ) return ; queue < Node * > q ; int nc , max ; q . push ( root ) ; while ( 1 ) { nc = q . size ( ) ; if ( nc == 0 ) break ; max = INT_MIN ; while ( nc -- ) { Node * front = q . front ( ) ; q . pop ( ) ; if ( max < front -> data ) max = front -> data ; if ( front -> left ) q . push ( front -> left ) ; if ( front -> right ) q . push ( front -> right ) ; } cout << max << " ▁ " ; } } int main ( ) { Node * root = NULL ; root = newNode ( 4 ) ; root -> left = newNode ( 9 ) ; root -> right = newNode ( 2 ) ; root -> left -> left = newNode ( 3 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 7 ) ; largestValueInEachLevel ( root ) ; return 0 ; }

Accumulator variables: nc, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class node { public : int data ; node * left ; node * right ; node * next ; } ; void populateNext ( node * p ) { static node * next = NULL ; if ( p ) { populateNext ( p -> right ) ; p -> next = next ; next = p ; populateNext ( p -> left ) ; } } node * newnode ( int data ) { node * Node = new node ( ) ; Node -> data = data ; Node -> left = NULL ; Node -> right = NULL ; Node -> next = NULL ; return ( Node ) ; } int main ( ) { node * root = newnode ( 10 ) ; root -> left = newnode ( 8 ) ; root -> right = newnode ( 12 ) ; root -> left -> left = newnode ( 3 ) ; populateNext ( root ) ; node * ptr = root -> left -> left ; while ( ptr ) { cout << " Next ▁ of ▁ " << ptr -> data << " ▁ is ▁ " << ( ptr -> next ? ptr -> next -> data : -1 ) << endl ; ptr = ptr -> next ; } return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <iostream>
using namespace std ; int maxProd ( int n ) { if ( n == 2 n == 3 ) return ( n - 1 ) ; int res = 1 ; while ( n > 4 ) { n -= 3 ; res *= 3 ; } return ( n * res ) ; } int main ( ) { cout << " Maximum ▁ Product ▁ is ▁ " << maxProd ( 10 ) ; return 0 ; }

Accumulator variables: n, res
C++ program:
#include <iostream>
#include <string.h>
using namespace std ; int findWays ( int m , int n , int x ) { int table [ n + 1 ] [ x + 1 ] ; for ( int j = 1 ; j <= m && j <= x ; j ++ ) table [ 1 ] [ j ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) for ( int j = 1 ; j <= x ; j ++ ) for ( int k = 1 ; k <= m && k < j ; k ++ ) table [ i ] [ j ] += table [ i - 1 ] [ j - k ] ; return table [ n ] [ x ] ; } int main ( ) { cout << findWays ( 4 , 2 , 1 ) << endl ; cout << findWays ( 2 , 2 , 3 ) << endl ; cout << findWays ( 6 , 3 , 8 ) << endl ; cout << findWays ( 4 , 2 , 5 ) << endl ; cout << findWays ( 4 , 3 , 5 ) << endl ; return 0 ; }

Index/key variables: i, j, n, x
Accumulator variables: i, j, k
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; long findWays ( int f , int d , int s ) { long mem [ d + 1 ] [ s + 1 ] ; memset ( mem , 0 , sizeof mem ) ; mem [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= d ; i ++ ) { for ( int j = i ; j <= s ; j ++ ) { mem [ i ] [ j ] = mem [ i ] [ j - 1 ] + mem [ i - 1 ] [ j - 1 ] ; if ( j - f - 1 >= 0 ) mem [ i ] [ j ] -= mem [ i - 1 ] [ j - f - 1 ] ; } } return mem [ d ] [ s ] ; } int main ( void ) { cout << findWays ( 4 , 2 , 1 ) << endl ; cout << findWays ( 2 , 2 , 3 ) << endl ; cout << findWays ( 6 , 3 , 8 ) << endl ; cout << findWays ( 4 , 2 , 5 ) << endl ; cout << findWays ( 4 , 3 , 5 ) << endl ; return 0 ; }

Index/key variables: d, i, j, s
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinInsertions ( char str [ ] , int l , int h ) { if ( l > h ) return INT_MAX ; if ( l == h ) return 0 ; if ( l == h - 1 ) return ( str [ l ] == str [ h ] ) ? 0 : 1 ; return ( str [ l ] == str [ h ] ) ? findMinInsertions ( str , l + 1 , h - 1 ) : ( min ( findMinInsertions ( str , l , h - 1 ) , findMinInsertions ( str , l + 1 , h ) ) + 1 ) ; } int main ( ) { char str [ ] = " geeks " ; cout << findMinInsertions ( str , 0 , strlen ( str ) - 1 ) ; return 0 ; }

Index/key variables: h, l
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int max ( int x , int y ) { return ( x > y ) ? x : y ; } int lps ( char * seq , int i , int j ) { if ( i == j ) return 1 ; if ( seq [ i ] == seq [ j ] && i + 1 == j ) return 2 ; if ( seq [ i ] == seq [ j ] ) return lps ( seq , i + 1 , j - 1 ) + 2 ; return max ( lps ( seq , i , j - 1 ) , lps ( seq , i + 1 , j ) ) ; } int main ( ) { char seq [ ] = " GEEKSFORGEEKS " ; int n = strlen ( seq ) ; cout << " The ▁ length ▁ of ▁ the ▁ LPS ▁ is ▁ " << lps ( seq , 0 , n - 1 ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#define INT_MAX  10e6
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; int heightoftree ( Node * root ) { if ( root == NULL ) return 0 ; int left = heightoftree ( root -> left ) ; int right = heightoftree ( root -> right ) ; return ( ( left > right ? left : right ) + 1 ) ; } void printPerLevelMinimum ( Node * root , vector < int > & res , int level ) { if ( root != NULL ) { printPerLevelMinimum ( root -> left , res , level + 1 ) ; if ( root -> data < res [ level ] ) res [ level ] = root -> data ; printPerLevelMinimum ( root -> right , res , level + 1 ) ; } } void perLevelMinimumUtility ( Node * root ) { int n = heightoftree ( root ) , i ; vector < int > res ( n , INT_MAX ) ; printPerLevelMinimum ( root , res , 0 ) ; cout << " Every ▁ level ▁ minimum ▁ is STRNEWLINE " ; for ( i = 0 ; i < n ; i ++ ) { cout << " level ▁ " << i << " ▁ min ▁ is ▁ = ▁ " << res [ i ] << " STRNEWLINE " ; } } Node * newNode ( int data ) { Node * temp = new Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { Node * root = newNode ( 7 ) ; root -> left = newNode ( 6 ) ; root -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 2 ) ; root -> right -> right = newNode ( 1 ) ; perLevelMinimumUtility ( root ) ; return 0 ; }

Index/key variables: i, level
Accumulator variables: i, stdc
Iterator variables: i
Class/struct names: Node
C++ program:
#include <iostream>
#include <queue>
#include <vector>
#define INT_MAX  10e6
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; int heightoftree ( Node * root ) { if ( root == NULL ) return 0 ; int left = heightoftree ( root -> left ) ; int right = heightoftree ( root -> right ) ; return ( ( left > right ? left : right ) + 1 ) ; } void printPerLevelMinimum ( Node * root ) { if ( root == NULL ) return ; queue < Node * > q ; q . push ( root ) ; q . push ( NULL ) ; int min = INT_MAX ; int level = 0 ; while ( q . empty ( ) == false ) { Node * node = q . front ( ) ; q . pop ( ) ; if ( node == NULL ) { cout << " level ▁ " << level << " ▁ min ▁ is ▁ = ▁ " << min << " STRNEWLINE " ; if ( q . empty ( ) ) break ; q . push ( NULL ) ; level ++ ; min = INT_MAX ; continue ; } if ( min > node -> data ) min = node -> data ; if ( node -> left != NULL ) { q . push ( node -> left ) ; } if ( node -> right != NULL ) { q . push ( node -> right ) ; } } } Node * newNode ( int data ) { Node * temp = new Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { Node * root = newNode ( 7 ) ; root -> left = newNode ( 6 ) ; root -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 2 ) ; root -> right -> right = newNode ( 1 ) ; cout << " Every ▁ Level ▁ minimum ▁ is " << " STRNEWLINE " ; printPerLevelMinimum ( root ) ; return 0 ; }

Accumulator variables: level
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findCount ( string str1 , string str2 ) { int len = str1 . size ( ) ; int len2 = str2 . size ( ) ; int ans = INT_MAX ; int hash1 [ 26 ] = { 0 } , hash2 [ 26 ] = { 0 } ; for ( int i = 0 ; i < len ; i ++ ) hash1 [ str1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < len2 ; i ++ ) hash2 [ str2 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( hash2 [ i ] ) ans = min ( ans , hash1 [ i ] / hash2 [ i ] ) ; return ans ; } int main ( ) { string str1 = " geeksclassesatnoida " ; string str2 = " sea " ; cout << findCount ( str1 , str2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char c ) { string vowel = " aeiou " ; for ( int i = 0 ; i < vowel . length ( ) ; ++ i ) if ( vowel [ i ] == c ) return true ; return false ; } bool printRLE ( string str , string typed ) { int n = str . length ( ) , m = typed . length ( ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] != typed [ j ] ) return false ; if ( isVowel ( str [ i ] ) == false ) { j ++ ; continue ; } int count1 = 1 ; while ( i < n - 1 && str [ i ] == str [ i + 1 ] ) { count1 ++ ; i ++ ; } int count2 = 1 ; while ( j < m - 1 && typed [ j ] == str [ i ] ) { count2 ++ ; j ++ ; } if ( count1 > count2 ) return false ; } return true ; } int main ( ) { string name = " alex " , typed = " aaalaeex " ; if ( printRLE ( name , typed ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count1, count2, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left ; struct node * right ; } ; int getLevelUtil ( struct node * node , int data , int level ) { if ( node == NULL ) return 0 ; if ( node -> data == data ) return level ; int downlevel = getLevelUtil ( node -> left , data , level + 1 ) ; if ( downlevel != 0 ) return downlevel ; downlevel = getLevelUtil ( node -> right , data , level + 1 ) ; return downlevel ; } int getLevel ( struct node * node , int data ) { return getLevelUtil ( node , data , 1 ) ; } struct node * newNode ( int data ) { struct node * temp = new struct node ; temp -> data = data ; temp -> left = NULL ; temp -> right = NULL ; return temp ; } int main ( ) { struct node * root = new struct node ; int x ; root = newNode ( 3 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 5 ) ; root -> left -> left = newNode ( 1 ) ; root -> left -> right = newNode ( 4 ) ; for ( x = 1 ; x <= 5 ; x ++ ) { int level = getLevel ( root , x ) ; if ( level ) cout << " Level ▁ of ▁ " << x << " ▁ is ▁ " << getLevel ( root , x ) << endl ; else cout << x << " is ▁ not ▁ present ▁ in ▁ tree " << endl ; } getchar ( ) ; return 0 ; }

Accumulator variables: stdc, x
Iterator variables: x
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
using namespace std ; string censor ( string text , string word ) { vector < string > word_list ; boost :: split ( word_list , text , boost :: is_any_of ( " \\ ▁ + " ) ) ; string result = " " ; string stars = " " ; for ( int i = 0 ; i < word . size ( ) ; i ++ ) stars += ' * ' ; int index = 0 ; for ( string i : word_list ) { if ( i . compare ( word ) == 0 ) { word_list [ index ] = stars ; } index ++ ; } for ( string i : word_list ) { result += i + ' ▁ ' ; } return result ; } int main ( ) { string extract = " GeeksforGeeks ▁ is ▁ a ▁ computer ▁ science ▁ " " portal ▁ for ▁ geeks . ▁ I ▁ am ▁ pursuing ▁ my ▁ " " major ▁ in ▁ computer ▁ science . ▁ " ; string cen = " computer " ; cout << ( censor ( extract , cen ) ) ; }

Index/key variables: index
Accumulator variables: i, index, result, stars, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define NO_OF_CHARS  256
int getNextState ( string pat , int M , int state , int x ) { if ( state < M && x == pat [ state ] ) return state + 1 ; int ns , i ; for ( ns = state ; ns > 0 ; ns -- ) { if ( pat [ ns - 1 ] == x ) { for ( i = 0 ; i < ns - 1 ; i ++ ) if ( pat [ i ] != pat [ state - ns + 1 + i ] ) break ; if ( i == ns - 1 ) return ns ; } } return 0 ; } void computeTF ( string pat , int M , int TF [ ] [ NO_OF_CHARS ] ) { int state , x ; for ( state = 0 ; state <= M ; ++ state ) for ( x = 0 ; x < NO_OF_CHARS ; ++ x ) TF [ state ] [ x ] = getNextState ( pat , M , state , x ) ; } void search ( string pat , string txt ) { int M = pat . size ( ) ; int N = txt . size ( ) ; int TF [ M + 1 ] [ NO_OF_CHARS ] ; computeTF ( pat , M , TF ) ; int i , state = 0 ; for ( i = 0 ; i < N ; i ++ ) { state = TF [ state ] [ txt [ i ] ] ; if ( state == M ) cout << " ▁ Pattern ▁ found ▁ at ▁ index ▁ " << i - M + 1 << endl ; } } int main ( ) { string txt = " AABAACAADAABAAABAA " ; string pat = " AABA " ; search ( pat , txt ) ; return 0 ; }

Index/key variables: NO_OF_CHARS, i, state, x
Accumulator variables: i, ns, stdc
Iterator variables: i, ns, state, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxlength ( string s ) { int n = s . length ( ) , i , j ; int ans = 0 ; for ( i = 0 ; i <= n - 1 ; i ++ ) { if ( s [ i ] == '1' ) { int count = 1 ; for ( j = i + 1 ; j <= n - 1 && s [ j ] == '1' ; j ++ ) count ++ ; ans = max ( ans , count ) ; } } return ans ; } int main ( ) { string s = "11101110" ; cout << maxlength ( s ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateLetters ( string S , int P , unordered_map < char , char > M ) { if ( P == S . size ( ) ) { cout << S << " STRNEWLINE " ; return ; } generateLetters ( S , P + 1 , M ) ; S [ P ] = M [ S [ P ] ] ; generateLetters ( S , P + 1 , M ) ; return ; } int main ( ) { string S = " aBc " ; unordered_map < char , char > M ; M [ ' a ' ] = ' $ ' ; M [ ' B ' ] = ' # ' ; M [ ' c ' ] = ' ^ ' ; M [ ' d ' ] = ' & ' ; M [ '1' ] = ' * ' ; M [ '2' ] = ' ! ' ; M [ ' E ' ] = ' @ ' ; generateLetters ( S , 0 , M ) ; return 0 ; }

Index/key variables: P
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( int n , string str ) { map < int , int > mymap ; int len = str . size ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = str [ i ] ; if ( c == '5' ) c = '2' ; else if ( c == '9' ) c = '6' ; int c_int = c - ' a ' ; if ( mymap . find ( c_int ) != mymap . end ( ) ) mymap [ c_int ] += 1 ; else mymap [ c_int ] = 1 ; } map < int , int > rems ; while ( n > 0 ) { int rem = n % 10 ; if ( rem == 5 ) rem = 2 ; if ( rem == 9 ) rem = 6 ; if ( rems . find ( rem ) != rems . end ( ) ) rems [ rem ] += 1 ; else rems [ rem ] = 1 ; n = n / 10 ; } int cnt = 1e8 ; for ( auto ele : rems ) { int key = ele . first ; if ( mymap . find ( key ) == mymap . end ( ) ) return 0 ; int temp = mymap [ key ] / ele . second ; cnt = min ( cnt , temp ) ; } return cnt ; } int main ( ) { int N = 56 ; string M = "245769" ; cout << solve ( N , M ) << endl ; return 0 ; }

Index/key variables: c_int, i, key, rem
Accumulator variables: i, stdc
Iterator variables: ele, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string & S ) { for ( int i = 1 ; i < S . length ( ) ; i ++ ) { if ( S [ i - 1 ] == S [ i ] ) { return false ; } } return true ; } void minimumSwaps ( string & S , int & ansSwaps , int swaps = 0 , int idx = 0 ) { if ( check ( S ) ) { ansSwaps = min ( ansSwaps , swaps ) ; } for ( int i = idx ; i < S . length ( ) ; i ++ ) { for ( int j = i + 1 ; j < S . length ( ) ; j ++ ) { swap ( S [ i ] , S [ j ] ) ; minimumSwaps ( S , ansSwaps , swaps + 1 , i + 1 ) ; swap ( S [ i ] , S [ j ] ) ; } } } void findMinimumSwaps ( string & S ) { int ansSwaps = INT_MAX ; minimumSwaps ( S , ansSwaps ) ; if ( ansSwaps == INT_MAX ) cout << " - 1" ; else cout << ansSwaps ; } int main ( ) { string S = " ABAACD " ; findMinimumSwaps ( S ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; void countOsBetween1s ( string S , int N , int Q [ ] [ 2 ] ) { int leftBound [ N ] ; int rightBound [ N ] ; int count = 0 ; int total = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == '1' ) { count = total ; } else if ( S [ i ] == '0' ) { total ++ ; } rightBound [ i ] = count ; } count = 0 ; total = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( S [ i ] == '1' ) { count = total ; } else if ( S [ i ] == '0' ) { total ++ ; } leftBound [ i ] = count ; } for ( int q = 0 ; q < 2 ; q ++ ) { int L = Q [ q ] [ 0 ] ; int R = Q [ q ] [ 1 ] ; count = leftBound [ L ] + rightBound [ R ] - total ; cout << count << " ▁ " ; } } int main ( ) { string S = "1001010" ; int Q [ ] [ 2 ] = { { 0 , 4 } , { 0 , 5 } } ; int N = S . length ( ) ; countOsBetween1s ( S , N , Q ) ; return 0 ; }

Index/key variables: L, N, R, i, q
Accumulator variables: i, q, total
Iterator variables: i, q
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; node * left ; node * right ; } ; node * getnode ( int data ) { node * newnode = new node ( ) ; newnode -> data = data ; newnode -> left = NULL ; newnode -> right = NULL ; } int getlevel ( node * root , int data ) { queue < node * > q ; int level = 1 ; q . push ( root ) ; q . push ( NULL ) ; while ( ! q . empty ( ) ) { node * temp = q . front ( ) ; q . pop ( ) ; if ( temp == NULL ) { if ( q . front ( ) != NULL ) { q . push ( NULL ) ; } level += 1 ; } else { if ( temp -> data == data ) { return level ; } if ( temp -> left ) { q . push ( temp -> left ) ; } if ( temp -> right ) { q . push ( temp -> right ) ; } } } return 0 ; } int main ( ) { node * root = getnode ( 20 ) ; root -> left = getnode ( 10 ) ; root -> right = getnode ( 30 ) ; root -> left -> left = getnode ( 5 ) ; root -> left -> right = getnode ( 15 ) ; root -> left -> right -> left = getnode ( 12 ) ; root -> right -> left = getnode ( 25 ) ; root -> right -> right = getnode ( 40 ) ; int level = getlevel ( root , 30 ) ; ( level != 0 ) ? ( cout << " level ▁ of ▁ node ▁ 30 ▁ is ▁ " << level << endl ) : ( cout << " node ▁ 30 ▁ not ▁ found " << endl ) ; level = getlevel ( root , 12 ) ; ( level != 0 ) ? ( cout << " level ▁ of ▁ node ▁ 12 ▁ is ▁ " << level << endl ) : ( cout << " node ▁ 12 ▁ not ▁ found " << endl ) ; level = getlevel ( root , 25 ) ; ( level != 0 ) ? ( cout << " level ▁ of ▁ node ▁ 25 ▁ is ▁ " << level << endl ) : ( cout << " node ▁ 25 ▁ not ▁ found " << endl ) ; level = getlevel ( root , 27 ) ; ( level != 0 ) ? ( cout << " level ▁ of ▁ node ▁ 27 ▁ is ▁ " << level << endl ) : ( cout << " node ▁ 27 ▁ not ▁ found " << endl ) ; return 0 ; }

Accumulator variables: level, stdc
Class/struct names: node