dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int subArraylen ( int arr [ ] , int n , int K ) { unordered_map < int , int > mp ; mp [ arr [ 0 ] ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; mp [ arr [ i ] ] = i ; } int len = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < K ) continue ; else { int x = arr [ i ] - K ; if ( x == 0 ) len = min ( len , i ) ; if ( mp . find ( x ) == mp . end ( ) ) continue ; else { len = min ( len , i - mp [ x ] ) ; } } } return len ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 3 , 2 , 4 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 7 ; int len = subArraylen ( arr , n , K ) ; if ( len == INT_MAX ) { cout << " - 1" ; } else { cout << len << endl ; } return 0 ; }

Index/key variables: i, x
Accumulator variables: i, stdc
Iterator variables: i
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 ; } int maxOddLevelDepth ( Node * root ) { if ( ! root ) return 0 ; queue < Node * > q ; q . push ( root ) ; int result = INT_MAX ; int level = 0 ; while ( ! q . empty ( ) ) { int size = q . size ( ) ; level += 1 ; while ( size > 0 ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( ! temp -> left && ! temp -> right && ( level % 2 != 0 ) ) { result = level ; } if ( temp -> left ) { q . push ( temp -> left ) ; } if ( temp -> right ) { q . push ( temp -> right ) ; } size -= 1 ; } } return result ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> right -> left = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; root -> right -> left -> right = newNode ( 7 ) ; root -> right -> right -> right = newNode ( 8 ) ; root -> right -> left -> right -> left = newNode ( 9 ) ; root -> right -> right -> right -> right = newNode ( 10 ) ; root -> right -> right -> right -> right -> left = newNode ( 11 ) ; int result = maxOddLevelDepth ( root ) ; if ( result == INT_MAX ) cout << " No ▁ leaf ▁ node ▁ at ▁ odd ▁ level STRNEWLINE " ; else cout << result ; cout << " ▁ is ▁ the ▁ required ▁ depth ▁ " << endl ; return 0 ; }

Accumulator variables: level, size, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define int  long long int
int prime [ 100001 ] ; void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < 100001 ; i ++ ) prime [ i ] = 1 ; int p = 2 ; while ( p * p <= 100000 ) { if ( prime [ p ] == 1 ) { for ( int i = p * p ; i < 100001 ; i += p ) prime [ i ] = 0 ; } p += 1 ; } } int join ( int a , int b ) { int mul = 1 ; int bb = b ; while ( b != 0 ) { mul *= 10 ; b /= 10 ; } a *= mul ; a += bb ; return a ; } void fibonacciOfPrime ( int n1 , int n2 ) { SieveOfEratosthenes ( ) ; vector < int > initial ; for ( int i = n1 ; i <= n2 ; i ++ ) if ( prime [ i ] ) initial . push_back ( i ) ; vector < int > now ; for ( auto a : initial ) for ( auto b : initial ) if ( a != b ) { int c = join ( a , b ) ; now . push_back ( c ) ; } vector < int > current ; for ( auto x : now ) if ( prime [ x ] ) current . push_back ( x ) ; set < int > current_set ; for ( auto i : current ) current_set . insert ( i ) ; int first = * min_element ( current_set . begin ( ) , current_set . end ( ) ) ; int second = * max_element ( current_set . begin ( ) , current_set . end ( ) ) ; int count = current_set . size ( ) - 1 ; int curr = 1 ; int c ; while ( curr < count ) { c = first + second ; first = second ; second = c ; curr += 1 ; } cout << ( c ) << endl ; } int32_t main ( ) { int x = 2 ; int y = 40 ; fibonacciOfPrime ( x , y ) ; }

Index/key variables: i, p, x
Accumulator variables: a, b, curr, i, mul, p, stdc
Iterator variables: a, b, i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countElements ( int arr [ ] , int n , int k ) { stack < int > s ; vector < int > next_greater ( n , n + 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . empty ( ) ) { s . push ( i ) ; continue ; } while ( ! s . empty ( ) && arr [ s . top ( ) ] < arr [ i ] ) { next_greater [ s . top ( ) ] = i ; s . pop ( ) ; } s . push ( i ) ; } int count = 0 ; int maxi = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { if ( next_greater [ i ] - i > k && maxi < arr [ i ] ) { maxi = max ( maxi , arr [ i ] ) ; count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 4 , 2 , 3 , 6 , 4 , 3 , 2 } ; int K = 2 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countElements ( arr , n , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxLengthOf1s ( vector < int > arr , int n ) { vector < int > prefix ( n , 0 ) ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i - 2 ] == 1 ) prefix [ i ] = prefix [ i - 1 ] + 1 ; else prefix [ i ] = 0 ; } vector < int > suffix ( n , 0 ) ; for ( int i = n - 3 ; i >= 0 ; i -- ) { if ( arr [ i + 2 ] == 1 ) suffix [ i ] = suffix [ i + 1 ] + 1 ; else suffix [ i ] = 0 ; } int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans = max ( ans , prefix [ i + 1 ] + suffix [ i ] ) ; } cout << ans << " STRNEWLINE " ; } int main ( ) { int n = 6 ; vector < int > arr = { 1 , 1 , 1 , 0 , 1 , 1 } ; maxLengthOf1s ( 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 minOperations ( string s ) { int n = s . size ( ) ; int pos = -1 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == '1' ) { pos = i ; break ; } } if ( pos == -1 ) { return 0 ; } int last = 1 ; int ans = 1 ; for ( int i = pos + 1 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) { if ( last == 1 ) { ans ++ ; last = 0 ; } } else { if ( last == 0 ) { ans ++ ; last = 1 ; } } } return ans ; } int main ( ) { string s = "10111" ; cout << minOperations ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countClumps ( int arr [ ] , int N ) { int clumps = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int flag = 0 ; while ( arr [ i ] == arr [ i + 1 ] ) { flag = 1 ; i ++ ; } if ( flag ) clumps ++ ; } return clumps ; } int main ( ) { int arr [ ] = { 13 , 15 , 66 , 66 , 66 , 37 , 37 , 8 , 8 , 11 , 11 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countClumps ( arr , N ) << ' ' ; return 0 ; }

Index/key variables: i
Accumulator variables: clumps, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void iskPalindromesPossible ( string s , int k ) { if ( s . size ( ) < k ) { cout << " Not ▁ Possible " << endl ; return ; } if ( s . size ( ) == k ) { cout << " Possible " << endl ; return ; } map < char , int > freq ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) freq [ s [ i ] ] ++ ; int count = 0 ; for ( auto it : freq ) { if ( it . second % 2 == 1 ) count ++ ; } if ( count > k ) cout << " No " << endl ; else cout << " Yes " << endl ; } int main ( ) { string str = " poor " ; int K = 3 ; iskPalindromesPossible ( str , K ) ; str = " geeksforgeeks " ; K = 10 ; iskPalindromesPossible ( str , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findPivot ( int arr [ ] , int low , int high ) { if ( high < low ) return -1 ; if ( high == low ) return low ; int mid = ( low + high ) / 2 ; if ( mid < high && arr [ mid + 1 ] < arr [ mid ] ) { return mid ; } if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) { return mid - 1 ; } if ( arr [ low ] > arr [ mid ] ) { return findPivot ( arr , low , mid - 1 ) ; } else { return findPivot ( arr , mid + 1 , high ) ; } } bool isRotated ( int arr [ ] , int n ) { int l = 0 ; int r = n - 1 ; int pivot = -1 ; if ( arr [ l ] > arr [ r ] ) { pivot = findPivot ( arr , l , r ) ; int temp = pivot ; if ( l < pivot ) { while ( pivot > l ) { if ( arr [ pivot ] < arr [ pivot - 1 ] ) { return false ; } pivot -- ; } } pivot = temp ; if ( pivot < r ) { pivot ++ ; while ( pivot < r ) { if ( arr [ pivot ] > arr [ pivot + 1 ] ) { return false ; } pivot ++ ; } } return true ; } else { return false ; } } int main ( ) { int arr [ ] = { 4 , 5 , 1 , 3 , 2 } ; if ( isRotated ( arr , 5 ) ) cout << " true " ; else cout << " false " ; return 0 ; }

Index/key variables: l, low, mid, pivot, r
Accumulator variables: pivot, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findpair ( int l , int r ) { int ans1 = l ; int ans2 = 2 * l ; cout << ans1 << " , ▁ " << ans2 << endl ; } int main ( ) { int l = 1 , r = 10 ; findpair ( l , r ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Student { string name ; int marks = 0 ; int prev_rank = 0 ; } ; void nameRank ( string names [ ] , int marks [ ] , int updates [ ] , int n ) { Student x [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] . name = names [ i ] ; x [ i ] . marks = marks [ i ] + updates [ i ] ; x [ i ] . prev_rank = i + 1 ; } Student highest = x [ 0 ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( x [ j ] . marks >= highest . marks ) highest = x [ j ] ; } cout << " Name : ▁ " << highest . name << " , ▁ Jump : ▁ " << abs ( highest . prev_rank - 1 ) << endl ; } int main ( ) { string names [ ] = { " sam " , " ram " , " geek " } ; int marks [ ] = { 80 , 79 , 75 } ; int updates [ ] = { 0 , 5 , -9 } ; int n = sizeof ( marks ) / sizeof ( marks [ 0 ] ) ; nameRank ( names , marks , updates , n ) ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
Class/struct names: Student
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDigits ( int n ) { int count = 0 ; while ( n > 0 ) { count += 1 ; n /= 10 ; } return count ; } int getDistinct ( int d , int count ) { int num = 0 ; count = pow ( 10 , count - 1 ) ; while ( count > 0 ) { num += ( count * d ) ; count /= 10 ; } return num ; } int findCount ( int L , int R ) { int count = 0 ; int countDigitsL = countDigits ( L ) ; int countDigitsR = countDigits ( R ) ; int firstDigitL = ( L / pow ( 10 , countDigitsL - 1 ) ) ; int firstDigitR = ( R / pow ( 10 , countDigitsR - 1 ) ) ; if ( countDigitsL < countDigitsR ) { count += ( 9 * ( countDigitsR - countDigitsL - 1 ) ) ; if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) count += ( 9 - firstDigitL + 1 ) ; else count += ( 9 - firstDigitL ) ; if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) count += firstDigitR ; else count += ( firstDigitR - 1 ) ; } else { if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) count += ( 9 - firstDigitL + 1 ) ; else count += ( 9 - firstDigitL ) ; if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) count -= ( 9 - firstDigitR ) ; else count -= ( 9 - firstDigitR + 1 ) ; } return count ; } int main ( ) { int L = 10 , R = 50 ; cout << findCount ( L , R ) ; return 0 ; }

Accumulator variables: count, n, num, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  4
#define M  4
bool isPairWithDiff ( int mat [ N ] [ M ] , int k ) { unordered_set < int > ump ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( mat [ i ] [ j ] > k ) { int m = mat [ i ] [ j ] - k ; if ( ump . find ( m ) != ump . end ( ) ) { return true ; } } else { int m = k - mat [ i ] [ j ] ; if ( ump . find ( m ) != ump . end ( ) ) { return true ; } } ump . insert ( mat [ i ] [ j ] ) ; } } return false ; } int main ( ) { int mat [ N ] [ M ] = { { 5 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 100 } } ; int k = 85 ; if ( isPairWithDiff ( mat , k ) ) cout << " YES " << endl ; else cout << " NO " << endl ; return 0 ; }

Index/key variables: M, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printNSE ( int arr [ ] , int n ) { stack < pair < int , int > > s ; vector < int > ans ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { int next = arr [ i ] ; if ( s . empty ( ) ) { s . push ( { next , i } ) ; continue ; } while ( ! s . empty ( ) && s . top ( ) . first > next ) { ans [ s . top ( ) . second ] = next ; s . pop ( ) ; } s . push ( { next , i } ) ; } while ( ! s . empty ( ) ) { ans [ s . top ( ) . second ] = -1 ; s . pop ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { cout << arr [ i ] << " ▁ - - - > ▁ " << ans [ i ] << endl ; } } int main ( ) { int arr [ ] = { 11 , 13 , 21 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printNSE ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; Node * newNode ( int data ) { Node * temp = new Node ( ) ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } Node * getDeepestLeftLeafNode ( Node * root ) { if ( ! root ) return NULL ; queue < Node * > q ; q . push ( root ) ; Node * result = NULL ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( temp -> left ) { q . push ( temp -> left ) ; if ( ! temp -> left -> left && ! temp -> left -> right ) result = temp -> left ; } if ( temp -> right ) q . push ( temp -> right ) ; } return result ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> right -> left = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; root -> right -> left -> right = newNode ( 7 ) ; root -> right -> right -> right = newNode ( 8 ) ; root -> right -> left -> right -> left = newNode ( 9 ) ; root -> right -> right -> right -> right = newNode ( 10 ) ; Node * result = getDeepestLeftLeafNode ( root ) ; if ( result ) cout << " Deepest ▁ Left ▁ Leaf ▁ Node ▁ : : ▁ " << result -> data << endl ; else cout << " No ▁ result , ▁ left ▁ leaf ▁ not ▁ found STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; struct Node * newNode ( int item ) { struct Node * temp = new Node ; temp -> key = item ; temp -> left = temp -> right = NULL ; return temp ; } void preorder ( Node * root ) { if ( root != NULL ) { printf ( " % d ▁ " , root -> key ) ; preorder ( root -> left ) ; preorder ( root -> right ) ; } } vector < Node * > getTrees ( int arr [ ] , int start , int end ) { vector < Node * > trees ; if ( start > end ) { trees . push_back ( NULL ) ; return trees ; } for ( int i = start ; i <= end ; i ++ ) { vector < Node * > ltrees = getTrees ( arr , start , i - 1 ) ; vector < Node * > rtrees = getTrees ( arr , i + 1 , end ) ; for ( int j = 0 ; j < ltrees . size ( ) ; j ++ ) { for ( int k = 0 ; k < rtrees . size ( ) ; k ++ ) { Node * node = newNode ( arr [ i ] ) ; node -> left = ltrees [ j ] ; node -> right = rtrees [ k ] ; trees . push_back ( node ) ; } } } return trees ; } int main ( ) { int in [ ] = { 4 , 5 , 7 } ; int n = sizeof ( in ) / sizeof ( in [ 0 ] ) ; vector < Node * > trees = getTrees ( in , 0 , n - 1 ) ; cout << " Preorder ▁ traversals ▁ of ▁ different ▁ " << " possible ▁ Binary ▁ Trees ▁ are ▁ STRNEWLINE " ; for ( int i = 0 ; i < trees . size ( ) ; i ++ ) { preorder ( trees [ i ] ) ; printf ( " STRNEWLINE " ) ; } return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool ElementsCalculationFunc ( int pre [ ] , int maxx [ ] , int x , int k , int n ) { for ( int i = 0 , j = x ; j <= n ; j ++ , i ++ ) { if ( x * maxx [ j ] - ( pre [ j ] - pre [ i ] ) <= k ) return true ; } return false ; } void MaxNumberOfElements ( int a [ ] , int n , int k ) { sort ( a , a + n ) ; for ( int i = 0 ; i <= n ; ++ i ) { pre [ i ] = 0 ; maxx [ i ] = 0 ; } for ( int i = 1 ; i <= n ; i ++ ) { pre [ i ] = pre [ i - 1 ] + a [ i - 1 ] ; maxx [ i ] = max ( maxx [ i - 1 ] , a [ i - 1 ] ) ; } int l = 1 , r = n , ans ; while ( l < r ) { int mid = ( l + r ) / 2 ; if ( ElementsCalculationFunc ( pre , maxx , mid - 1 , k , n ) ) { ans = mid ; l = mid + 1 ; } else r = mid - 1 ; } cout << ans << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 2 , 4 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; MaxNumberOfElements ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_STR_LEN = 1000 ; bool P [ MAX_STR_LEN ] [ MAX_STR_LEN ] ; int Kpal [ MAX_STR_LEN ] ; void checkSubStrPal ( string str , int n ) { memset ( P , false , sizeof ( P ) ) ; for ( int i = 0 ; i < n ; i ++ ) P [ i ] [ i ] = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( str [ i ] == str [ i + 1 ] ) P [ i ] [ i + 1 ] = true ; for ( int gap = 2 ; gap < n ; gap ++ ) { for ( int i = 0 ; i < n - gap ; i ++ ) { int j = gap + i ; if ( str [ i ] == str [ j ] && P [ i + 1 ] [ j - 1 ] ) P [ i ] [ j ] = true ; } } } void countKPalindromes ( int i , int j , int k ) { if ( i == j ) { Kpal [ k ] ++ ; return ; } if ( P [ i ] [ j ] == false ) return ; Kpal [ k ] ++ ; int mid = ( i + j ) / 2 ; if ( ( j - i + 1 ) % 2 == 1 ) mid -- ; countKPalindromes ( i , mid , k + 1 ) ; } void printKPalindromes ( string s ) { memset ( Kpal , 0 , sizeof ( Kpal ) ) ; int n = s . length ( ) ; checkSubStrPal ( s , n ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n - i ; j ++ ) countKPalindromes ( j , j + i , 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) cout << Kpal [ i ] << " ▁ " ; cout << " STRNEWLINE " ; } int main ( ) { string s = " abacaba " ; printKPalindromes ( s ) ; return 0 ; }

Index/key variables: MAX_STR_LEN, i, j, k
Accumulator variables: gap, i, j, mid, stdc
Iterator variables: gap, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string printNumbers ( int numbers [ ] , int n ) { vector < int > oneTwoThree ; for ( int i = 0 ; i < n ; i ++ ) { if ( findContainsOneTwoThree ( numbers [ i ] ) ) oneTwoThree . push_back ( numbers [ i ] ) ; } sort ( oneTwoThree . begin ( ) , oneTwoThree . end ( ) ) ; string result = " " ; for ( auto number : oneTwoThree ) { int value = number ; if ( result . length ( ) > 0 ) result += " , ▁ " ; result += to_string ( value ) ; } return ( result . length ( ) > 0 ) ? result : " - 1" ; } bool findContainsOneTwoThree ( int number ) { string str = to_string ( number ) ; int countOnes = 0 , countTwo = 0 , countThree = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == '1' ) countOnes ++ ; else if ( str [ i ] == '2' ) countTwo ++ ; else if ( str [ i ] == '3' ) countThree ++ ; } return ( countOnes && countTwo && countThree ) ; } int main ( ) { int numbers [ ] = { 123 , 1232 , 456 , 234 , 32145 } ; int n = sizeof ( numbers ) / sizeof ( numbers [ 0 ] ) ; string result = printNumbers ( numbers , n ) ; cout << result ; return 0 ; }

Index/key variables: i
Accumulator variables: countOnes, countThree, countTwo, i, result, stdc
Iterator variables: i, number
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Interval { int s ; int e ; } ; bool comp ( Interval a , Interval b ) { return a . s < b . s ; } int kthSmallestNum ( vector < Interval > merged , int k ) { int n = merged . size ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( k <= abs ( merged [ j ] . e - merged [ j ] . s + 1 ) ) return ( merged [ j ] . s + k - 1 ) ; k = k - abs ( merged [ j ] . e - merged [ j ] . s + 1 ) ; } if ( k ) return -1 ; } void mergeIntervals ( vector < Interval > & merged , Interval arr [ ] , int n ) { sort ( arr , arr + n , comp ) ; merged . push_back ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { Interval prev = merged . back ( ) ; Interval curr = arr [ i ] ; if ( ( curr . s >= prev . s && curr . s <= prev . e ) && ( curr . e > prev . e ) ) merged . back ( ) . e = curr . e ; else { if ( curr . s > prev . e ) merged . push_back ( curr ) ; } } } int main ( ) { Interval arr [ ] = { { 2 , 6 } , { 4 , 7 } } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int query [ ] = { 5 , 8 } ; int q = sizeof ( query ) / sizeof ( query [ 0 ] ) ; vector < Interval > merged ; mergeIntervals ( merged , arr , n ) ; for ( int i = 0 ; i < q ; i ++ ) cout << kthSmallestNum ( merged , query [ i ] ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Class/struct names: Interval
C++ program:
#include <iostream>
using namespace std ; void countCountries ( int ans [ ] , int N ) { int total_countries = 0 , i = 0 ; bool invalid = false ; while ( i < N ) { int curr_size = ans [ i ] ; int num = ans [ i ] ; while ( num > 0 ) { if ( ans [ i ] != curr_size ) { cout << " Invalid ▁ Answer STRNEWLINE " ; return ; } else num -- ; i ++ ; } total_countries ++ ; } cout << " There ▁ are ▁ " << total_countries << " ▁ distinct ▁ companies ▁ in ▁ the ▁ group . STRNEWLINE " ; } int main ( ) { int ans [ ] = { 1 , 1 , 2 , 2 , 4 , 4 , 4 , 4 } ; int n = sizeof ( ans ) / sizeof ( ans [ 0 ] ) ; countCountries ( ans , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, num, total_countries
Boolean variables: invalid
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int val ; struct Node * left , * right ; } ; Node * newNode ( int data ) { Node * temp = new Node ; temp -> val = data ; temp -> left = temp -> right = NULL ; return temp ; } void deepestLeftLeafUtil ( Node * root , int lvl , int * maxlvl , bool isLeft , Node * * resPtr ) { if ( root == NULL ) return ; if ( isLeft && ! root -> left && ! root -> right && lvl > * maxlvl ) { * resPtr = root ; * maxlvl = lvl ; return ; } deepestLeftLeafUtil ( root -> left , lvl + 1 , maxlvl , true , resPtr ) ; deepestLeftLeafUtil ( root -> right , lvl + 1 , maxlvl , false , resPtr ) ; } Node * deepestLeftLeaf ( Node * root ) { int maxlevel = 0 ; Node * result = NULL ; deepestLeftLeafUtil ( root , 0 , & maxlevel , false , & result ) ; return result ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> right -> left = newNode ( 5 ) ; root -> right -> right = newNode ( 6 ) ; root -> right -> left -> right = newNode ( 7 ) ; root -> right -> right -> right = newNode ( 8 ) ; root -> right -> left -> right -> left = newNode ( 9 ) ; root -> right -> right -> right -> right = newNode ( 10 ) ; Node * result = deepestLeftLeaf ( root ) ; if ( result ) cout << " The ▁ deepest ▁ left ▁ child ▁ is ▁ " << result -> val ; else cout << " There ▁ is ▁ no ▁ left ▁ leaf ▁ in ▁ the ▁ given ▁ tree " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <iostream>
using namespace std ; bool check_elements ( int arr [ ] , int n , int A , int B ) { int range = B - A ; for ( int i = 0 ; i < n ; i ++ ) { if ( abs ( arr [ i ] ) >= A && abs ( arr [ i ] ) <= B ) { int z = abs ( arr [ i ] ) - A ; if ( arr [ z ] > 0 ) { arr [ z ] = arr [ z ] * -1 ; } } } int count = 0 ; for ( int i = 0 ; i <= range && i < n ; i ++ ) { if ( arr [ i ] > 0 ) return false ; else count ++ ; } if ( count != ( range + 1 ) ) return false ; return true ; } int main ( ) { int arr [ ] = { 1 , 4 , 5 , 2 , 7 , 8 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int A = 2 , B = 5 ; if ( check_elements ( arr , n , A , B ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, z
Accumulator variables: count, i
Iterator variables: i