dhyuti-n/xlcost-variable-roles huggingface dataset:
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 * getDeepestRightLeafNode ( 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 -> right ) { q . push ( temp -> right ) ; if ( ! temp -> right -> left && ! temp -> right -> right ) result = temp -> right ; } } return result ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> right = 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 = getDeepestRightLeafNode ( root ) ; if ( result ) cout << " Deepest ▁ Right ▁ Leaf ▁ Node ▁ : : ▁ " << result -> data << endl ; else cout << " No ▁ result , ▁ right ▁ leaf ▁ not ▁ found STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkString ( string X , string Y ) { int L = -1 ; int R = -1 ; for ( int i = 0 ; i < X . length ( ) ; ++ i ) { if ( X [ i ] != Y [ i ] ) { L = i ; break ; } } for ( int i = X . length ( ) - 1 ; i > 0 ; -- i ) { if ( X [ i ] != Y [ i ] ) { R = i ; break ; } } reverse ( X . begin ( ) + L , X . begin ( ) + R + 1 ) ; if ( X == Y ) { cout << " Yes " ; } else { cout << " No " ; } } int main ( ) { string X = " adcbef " , Y = " abcdef " ; checkString ( X , Y ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int seg [ 10000 ] ; int maxLength ( int a [ ] , int b [ ] , int n , int c ) { if ( n == 0 ) return 0 ; int max_length = 0 ; int low = 0 , high = n ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( possible ( a , b , n , c , mid ) != false ) { max_length = mid ; low = mid + 1 ; } else high = mid - 1 ; } return max_length ; } bool possible ( int a [ ] , int b [ ] , int n , int c , int k ) { int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += a [ i ] ; } int total_cost = sum * k + getMax ( b , 0 , n - 1 , 0 , k - 1 , 0 ) ; if ( total_cost <= c ) return true ; for ( int i = k ; i < n ; i ++ ) { sum += a [ i ] ; sum -= a [ i - k ] ; total_cost = sum * k + getMax ( b , 0 , n - 1 , i - k + 1 , i , 0 ) ; if ( total_cost <= c ) return true ; } return false ; } void build ( int b [ ] , int index , int s , int e ) { if ( s == e ) { seg [ index ] = b [ s ] ; return ; } int mid = s + ( e - s ) / 2 ; build ( b , 2 * index + 1 , s , mid ) ; build ( b , 2 * index + 2 , mid + 1 , e ) ; seg [ index ] = max ( seg [ 2 * index + 1 ] , seg [ 2 * index + 2 ] ) ; } int getMax ( int b [ ] , int ss , int se , int qs , int qe , int index ) { if ( se < qs ss > qe ) return INT_MIN / 2 ; if ( ss >= qs && se <= qe ) return seg [ index ] ; int mid = ss + ( se - ss ) / 2 ; return max ( getMax ( b , ss , mid , qs , qe , 2 * index + 1 ) , getMax ( b , mid + 1 , se , qs , qe , 2 * index + 2 ) ) ; } void initialiseSegmentTree ( int N ) { int seg [ 4 * N ] ; } int main ( ) { int A [ ] = { 1 , 2 , 1 , 6 , 5 , 5 , 6 , 1 } ; int B [ ] = { 14 , 8 , 15 , 15 , 9 , 10 , 7 , 12 } ; int C = 40 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; initialiseSegmentTree ( N ) ; build ( B , 0 , 0 , N - 1 ) ; cout << ( maxLength ( A , B , N , C ) ) ; }

Index/key variables: i, index, s
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxLength ( int a [ ] , int b [ ] , int n , int c ) { if ( n == 0 ) return 0 ; int max_length = 0 ; int low = 0 , high = n ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( possible ( a , b , n , c , mid ) ) { max_length = mid ; low = mid + 1 ; } else high = mid - 1 ; } return max_length ; } bool possible ( int a [ ] , int b [ ] , int n , int c , int k ) { deque < int > dq ; int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += a [ i ] ; while ( dq . size ( ) > 0 && b [ i ] > b [ dq . back ( ) ] ) dq . pop_back ( ) ; dq . push_back ( i ) ; } int total_cost = sum * k + b [ dq . front ( ) ] ; if ( total_cost <= c ) return true ; for ( int i = k ; i < n ; i ++ ) { sum += a [ i ] ; sum -= a [ i - k ] ; while ( dq . size ( ) > 0 && dq . front ( ) <= i - k ) dq . pop_front ( ) ; while ( dq . size ( ) > 0 && b [ i ] > b [ dq . back ( ) ] ) dq . pop_back ( ) ; dq . push_back ( i ) ; total_cost = sum * k + b [ dq . front ( ) ] ; if ( total_cost <= c ) return true ; } return false ; } int main ( ) { int A [ ] = { 1 , 2 , 1 , 6 , 5 , 5 , 6 , 1 } ; int B [ ] = { 14 , 8 , 15 , 15 , 9 , 10 , 7 , 12 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int C = 40 ; cout << maxLength ( A , B , N , C ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNthNum ( long long int N ) { long long int a , b , left ; long long int right , mid ; long long int t , last_num = 0 ; left = 1 , right = N ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; t = ( mid * ( mid + 1 ) ) / 2 ; if ( t < N ) { left = mid + 1 ; } else if ( t == N ) { a = mid ; break ; } else { a = mid ; right = mid - 1 ; } } t = a - 1 ; b = N - ( t * ( t + 1 ) ) / 2 - 1 ; cout << ( 1 << a ) + ( 1 << b ) ; } int main ( ) { long long int N = 15 ; findNthNum ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void longestSubWithMaxSum ( int arr [ ] , int N ) { int Max = * max_element ( arr , arr + N ) ; if ( Max < 0 ) { cout << Max ; return ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= 0 ) { cout << arr [ i ] << " ▁ " ; } } } int main ( ) { int arr [ ] = { 1 , 2 , -4 , -2 , 3 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; longestSubWithMaxSum ( 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 findMinimumOperations ( string s , string s1 ) { int n = s . length ( ) , m = s1 . length ( ) ; int frequency [ 26 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) frequency [ s [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < m ; i ++ ) { if ( frequency [ s1 [ i ] - ' a ' ] == 0 ) { return -1 ; } } set < int > indices [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { indices [ s [ i ] - ' a ' ] . insert ( i ) ; } int ans = 1 ; int last = ( * indices [ s1 [ 0 ] - ' a ' ] . begin ( ) ) ; for ( int i = 1 ; i < m ; i ++ ) { int ch = s1 [ i ] - ' a ' ; auto it = indices [ ch ] . upper_bound ( last ) ; if ( it != indices [ ch ] . end ( ) ) { last = ( * it ) ; } else { ans ++ ; last = ( * indices [ ch ] . begin ( ) ) ; } } return ans ; } int main ( ) { string S1 = " acebcd " , S2 = " acbcde " ; int ans = findMinimumOperations ( S1 , S2 ) ; if ( ans == -1 ) { cout << " NO STRNEWLINE " ; } else { cout << " YES STRNEWLINE " << ans ; } return 0 ; }

Index/key variables: ch, i
Accumulator variables: ans, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; Node * newnode ( int data ) { Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } bool isLeaf ( Node * root ) { return ( root -> left == NULL && root -> right == NULL ) ; } void sink ( Node * & root ) { if ( root == NULL || isLeaf ( root ) ) return ; if ( root -> left && ! ( root -> left -> data & 1 ) ) { swap ( root -> data , root -> left -> data ) ; sink ( root -> left ) ; } else if ( root -> right && ! ( root -> right -> data & 1 ) ) { swap ( root -> data , root -> right -> data ) ; sink ( root -> right ) ; } } void sinkOddNodes ( Node * & root ) { if ( root == NULL || isLeaf ( root ) ) return ; sinkOddNodes ( root -> left ) ; sinkOddNodes ( root -> right ) ; if ( root -> data & 1 ) sink ( root ) ; } void printLevelOrder ( Node * root ) { queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { int nodeCount = q . size ( ) ; while ( nodeCount ) { Node * node = q . front ( ) ; printf ( " % d ▁ " , node -> data ) ; q . pop ( ) ; if ( node -> left != NULL ) q . push ( node -> left ) ; if ( node -> right != NULL ) q . push ( node -> right ) ; nodeCount -- ; } printf ( " STRNEWLINE " ) ; } } int main ( ) { Node * root = newnode ( 1 ) ; root -> left = newnode ( 5 ) ; root -> right = newnode ( 8 ) ; root -> left -> left = newnode ( 2 ) ; root -> left -> right = newnode ( 4 ) ; root -> right -> left = newnode ( 9 ) ; root -> right -> right = newnode ( 10 ) ; sinkOddNodes ( root ) ; printf ( " Level ▁ order ▁ traversal ▁ of ▁ modified ▁ tree STRNEWLINE " ) ; printLevelOrder ( root ) ; return 0 ; }

Accumulator variables: nodeCount, stdc
Class/struct names: Node
C++ program:
#include <algorithm>
#include <iostream>
#include <set>
using namespace std ; int digiSum ( int a ) { int sum = 0 ; while ( a ) { sum += a % 10 ; a = a / 10 ; } return sum ; } bool isPrime ( int r ) { bool s = true ; for ( int i = 2 ; i * i <= r ; i ++ ) { if ( r % i == 0 ) { s = false ; break ; } } return s ; } bool isMorannumber ( int n ) { int dup = n ; int sum = digiSum ( dup ) ; if ( n % sum == 0 ) { int c = n / sum ; if ( isPrime ( c ) ) { return true ; } } return false ; } void FirstKMorannumber ( int a [ ] , int n , int k ) { int X = k ; sort ( a , a + n ) ; set < int > s ; for ( int i = n - 1 ; i >= 0 && k > 0 ; i -- ) { if ( isMorannumber ( a [ i ] ) ) { s . insert ( a [ i ] ) ; k -- ; } } if ( k > 0 ) { cout << X << " ▁ Moran ▁ numbers ▁ are " << " ▁ not ▁ present ▁ in ▁ the ▁ array " << endl ; return ; } set < int > :: iterator it ; for ( it = s . begin ( ) ; it != s . end ( ) ; ++ it ) { cout << * it << " , ▁ " ; } cout << endl ; } int main ( ) { int A [ ] = { 34 , 198 , 21 , 42 , 63 , 45 , 22 , 44 , 43 } ; int K = 4 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; FirstKMorannumber ( A , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k, sum
Iterator variables: i, it
Boolean variables: s
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPair ( int arr [ ] , int n ) { map < int , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ arr [ i ] ] ++ ; int ans = 0 ; for ( int i = 0 ; i < 31 ; i ++ ) { int key = pow ( 2 , i ) ; for ( int j = 0 ; j < n ; j ++ ) { int k = key - arr [ j ] ; if ( m . find ( k ) == m . end ( ) ) continue ; else ans += m [ k ] ; if ( k == arr [ j ] ) ans ++ ; } } return ans / 2 ; } int main ( ) { int arr [ ] = { 1 , 8 , 2 , 10 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPair ( arr , n ) << endl ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isdivisible ( string & newstr , long long K ) { long long num = 0 ; for ( int i = 0 ; i < newstr . size ( ) ; i ++ ) { num = num * 10 + newstr [ i ] - '0' ; } if ( num % K == 0 ) return true ; else return false ; } void findLargestNo ( string & str , string & newstr , string & ans , int index , long long K ) { if ( index == ( int ) str . length ( ) ) { if ( isdivisible ( newstr , K ) ) { if ( ( ans < newstr && ans . length ( ) == newstr . length ( ) ) || newstr . length ( ) > ans . length ( ) ) { ans = newstr ; } } return ; } string x = newstr + str [ index ] ; findLargestNo ( str , x , ans , index + 1 , K ) ; findLargestNo ( str , newstr , ans , index + 1 , K ) ; } int main ( ) { string str = "121400" ; string ans = " " , newstr = " " ; long long K = 8 ; findLargestNo ( str , newstr , ans , 0 , K ) ; if ( ans != " " ) cout << ans << endl ; else cout << -1 << endl ; }

Index/key variables: i, index
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findRockSample ( vector < vector < int > > ranges , int n , int r , vector < int > arr ) { vector < int > a ; for ( int i = 0 ; i < r ; i ++ ) { int c = 0 ; int l = ranges [ i ] [ 0 ] ; int h = ranges [ i ] [ 1 ] ; for ( int j = 0 ; j < arr . size ( ) ; j ++ ) { if ( l <= arr [ j ] && arr [ j ] <= h ) c += 1 ; } a . push_back ( c ) ; } for ( auto i : a ) cout << i << " ▁ " ; } int main ( ) { int n = 5 ; int r = 2 ; vector < int > arr = { 400 , 567 , 890 , 765 , 987 } ; vector < vector < int > > ranges = { { 300 , 380 } , { 800 , 1000 } } ; findRockSample ( ranges , n , r , arr ) ; }

Index/key variables: i, j
Accumulator variables: c, i, j, stdc
Iterator variables: i, j
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 ) ; } bool isleaf ( Node * curr_node ) { return ( curr_node -> left == NULL && curr_node -> right == NULL ) ; } int deepestOddLevelDepthUtil ( Node * curr_node , int curr_level ) { if ( curr_node == NULL ) return 0 ; curr_level += 1 ; if ( curr_level % 2 != 0 && isleaf ( curr_node ) ) return curr_level ; return max ( deepestOddLevelDepthUtil ( curr_node -> left , curr_level ) , deepestOddLevelDepthUtil ( curr_node -> right , curr_level ) ) ; } int deepestOddLevelDepth ( Node * curr_node ) { return deepestOddLevelDepthUtil ( curr_node , 0 ) ; } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 28 ) ; root -> right = newNode ( 13 ) ; root -> right -> left = newNode ( 14 ) ; root -> right -> right = newNode ( 15 ) ; root -> right -> right -> left = newNode ( 23 ) ; root -> right -> right -> right = newNode ( 24 ) ; cout << deepestOddLevelDepth ( root ) << endl ; return 0 ; }

Accumulator variables: curr_level, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( string st , vector < int > & result , int prev , int n , int K ) { if ( st . length ( ) == n ) { result . push_back ( stoi ( st ) ) ; return ; } if ( st . size ( ) == n - 1 ) { if ( prev - K >= 0 ) { string pt = " " ; pt += prev - K + 48 ; findNumbers ( st + pt , result , prev - K , n , K ) ; } if ( K != 0 && prev + K < 10 ) { string pt = " " ; pt += prev + K + 48 ; findNumbers ( st + pt , result , prev + K , n , K ) ; } } else { for ( int j = 1 ; j <= 9 ; j ++ ) { string pt = " " ; pt += j + 48 ; findNumbers ( st + pt , result , prev , n , K ) ; } } } vector < int > numDifference ( int N , int K ) { vector < int > res ; string st = " " ; if ( N == 1 && K == 0 ) { res . push_back ( 0 ) ; } else if ( N == 1 && K > 0 ) { return res ; } for ( int i = 1 ; i < 10 ; i ++ ) { string temp = " " ; temp += 48 + i ; findNumbers ( st + temp , res , i , N , K ) ; st = " " ; } return res ; } void numDifferenceUtil ( int N , int K ) { vector < int > res ; res = numDifference ( N , K ) ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) { cout << res [ i ] << " ▁ " ; } } int main ( ) { int N = 2 , K = 9 ; numDifferenceUtil ( N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, pt, stdc, temp
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool compare ( vector < int > & a , vector < int > & b ) { return a [ 1 ] < b [ 1 ] ; } int findMinBulletShots ( vector < vector < int > > & points ) { sort ( points . begin ( ) , points . end ( ) , compare ) ; if ( points . size ( ) == 0 ) return 0 ; int cnt = 1 ; int curr = points [ 0 ] [ 1 ] ; for ( int j = 1 ; j < points . size ( ) ; j ++ ) { if ( curr < points [ j ] [ 0 ] ) { cnt ++ ; curr = points [ j ] [ 1 ] ; } } return cnt ; } int main ( ) { vector < vector < int > > bricks { { 5000 , 900000 } , { 1 , 100 } , { 150 , 499 } } ; cout << findMinBulletShots ( bricks ) ; return 0 ; }

Index/key variables: j
Accumulator variables: cnt, j, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool cmp ( int x , int y ) { return x > y ; } void countMaximum ( int * a , int n ) { sort ( a , a + n , cmp ) ; int count = 0 ; int mark = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( ( a [ i ] + n >= mark ) ) { count += 1 ; } mark = max ( mark , a [ i ] + i + 1 ) ; } cout << count ; } int main ( ) { int arr [ ] = { 8 , 9 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countMaximum ( arr , N ) ; }

Index/key variables: i
Accumulator variables: count, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char findKthChar ( int n , int k ) { string prev = " A " ; string cur = " " ; if ( n == 1 ) { return ' A ' ; } for ( int i = 2 ; i <= n ; i ++ ) { cur = prev + " B " ; for ( int i = 0 ; i < prev . length ( ) ; i ++ ) { if ( prev [ i ] == ' A ' ) { prev [ i ] = ' B ' ; } else { prev [ i ] = ' A ' ; } } reverse ( prev . begin ( ) , prev . end ( ) ) ; cur += prev ; prev = cur ; } return cur [ k - 1 ] ; } int main ( ) { int N = 4 ; int K = 3 ; cout << findKthChar ( N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cur, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define newl  "
" int maxSubarray ( int a [ ] , int k , int n ) { int answer = 0 ; int start = 0 ; long int s = 0 ; deque < int > dq ; for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; while ( ! dq . empty ( ) && a [ dq . front ( ) ] <= x ) dq . pop_front ( ) ; dq . push_back ( i ) ; s += x ; long int cost = ( long int ) a [ dq . front ( ) ] * ( answer + 1 ) - s ; if ( cost <= ( long int ) k ) answer ++ ; else { if ( dq . front ( ) == start ) dq . pop_front ( ) ; s -= a [ start ++ ] ; } } return answer ; } int main ( ) { int a [ ] = { 2 , 2 , 4 } ; int k = 10 ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << ( maxSubarray ( a , k , n ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, i, s, start, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int max ( int x , int y ) { return ( x > y ) ? x : y ; } struct Node { int data ; struct Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } int depthOfOddLeafUtil ( struct Node * root , int level ) { if ( root == NULL ) return 0 ; if ( root -> left == NULL && root -> right == NULL && level & 1 ) return level ; return max ( depthOfOddLeafUtil ( root -> left , level + 1 ) , depthOfOddLeafUtil ( root -> right , level + 1 ) ) ; } int depthOfOddLeaf ( struct Node * root ) { int level = 1 , depth = 0 ; return depthOfOddLeafUtil ( root , level ) ; } int main ( ) { struct 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 ) ; cout << depthOfOddLeaf ( root ) << " ▁ is ▁ the ▁ required ▁ depth " ; getchar ( ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <iostream>
using namespace std ; string canSplitArray ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] <= k ) { return " No " ; } } return " Yes " ; } int main ( ) { int arr [ ] = { 2 , 4 , 6 , 1 , 8 , 16 } ; int N = sizeof arr / sizeof arr [ 0 ] ; int N = sizeof arr / sizeof arr [ 0 ] ; int K = 3 ; cout << canSplitArray ( arr , N , K ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallSumSubset ( vector < int > data , int target , int maxVal ) { int sum = 0 ; for ( int i : data ) sum += i ; if ( target <= 0 ) return 0 ; else if ( sum < target ) return maxVal ; else if ( sum == target ) return data . size ( ) ; else if ( data [ 0 ] >= target ) return 1 ; else if ( data [ 0 ] < target ) { vector < int > temp ; for ( int i = 1 ; i < data . size ( ) ; i ++ ) temp . push_back ( data [ i ] ) ; return min ( smallSumSubset ( temp , target , maxVal ) , 1 + smallSumSubset ( temp , target - data [ 0 ] , maxVal ) ) ; } } int main ( ) { vector < int > data = { 3 , 1 , 7 , 1 , 2 } ; int target = 11 ; int val = smallSumSubset ( data , target , data . size ( ) + 1 ) ; if ( val > data . size ( ) ) cout << -1 ; else cout << val ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool swapXandY ( string & str , int X , int Y ) { int N = str . length ( ) ; swap ( X , Y ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' p ' ) { str [ i ] = ' r ' ; } else if ( str [ i ] == ' r ' ) { str [ i ] = ' p ' ; } } } int maxCost ( string str , int X , int Y ) { int N = str . length ( ) ; if ( Y > X ) { swapXandY ( str , X , Y ) ; } int res = 0 ; int countP = 0 ; int countR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' p ' ) { countP ++ ; } else if ( str [ i ] == ' r ' ) { if ( countP > 0 ) { countP -- ; res += X ; } else countR ++ ; } else { res += min ( countP , countR ) * Y ; countP = 0 ; countR = 0 ; } } res += min ( countP , countR ) * Y ; return res ; } int main ( ) { string str = " abppprrr " ; int X = 5 , Y = 4 ; cout << maxCost ( str , X , Y ) ; }

Index/key variables: i
Accumulator variables: countP, countR, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void uniqueElement ( int arr [ ] , int n ) { int x = arr [ 0 ] ; int flag = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != x ) { flag = 0 ; break ; } } if ( flag == 1 ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int arr [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; uniqueElement ( arr , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxCount ( vector < int > & freq , int mini , int maxi ) { int n = freq . size ( ) - 1 ; int ans = 0 ; for ( int sum = 2 * mini ; sum <= 2 * maxi ; ++ sum ) { int possiblePair = 0 ; for ( int firElement = 1 ; firElement < ( sum + 1 ) / 2 ; firElement ++ ) { if ( sum - firElement <= maxi ) { possiblePair += min ( freq [ firElement ] , freq [ sum - firElement ] ) ; } } if ( sum % 2 == 0 ) { possiblePair += freq [ sum / 2 ] / 2 ; } ans = max ( ans , possiblePair ) ; } return ans ; } int countofPairs ( vector < int > & a ) { int n = a . size ( ) ; int mini = * min_element ( a . begin ( ) , a . end ( ) ) , maxi = * max_element ( a . begin ( ) , a . end ( ) ) ; vector < int > freq ( n + 1 , 0 ) ; for ( int i = 0 ; i < n ; ++ i ) freq [ a [ i ] ] ++ ; return maxCount ( freq , mini , maxi ) ; } int main ( ) { vector < int > a = { 1 , 2 , 4 , 3 , 3 , 5 , 6 } ; cout << countofPairs ( a ) << endl ; }

Index/key variables: firElement, i
Accumulator variables: firElement, possiblePair, stdc
Iterator variables: firElement, i, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMaxSum ( int a [ ] , int n ) { int dp [ n ] [ 2 ] ; dp [ 0 ] [ 0 ] = a [ 0 ] ; dp [ 0 ] [ 1 ] = a [ 0 ] * a [ 0 ] ; int max_sum = max ( dp [ 0 ] [ 0 ] , dp [ 0 ] [ 1 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i ] [ 0 ] = max ( a [ i ] , dp [ i - 1 ] [ 0 ] + a [ i ] ) ; dp [ i ] [ 1 ] = max ( dp [ i - 1 ] [ 1 ] + a [ i ] , a [ i ] * a [ i ] ) ; dp [ i ] [ 1 ] = max ( dp [ i ] [ 1 ] , dp [ i - 1 ] [ 0 ] + a [ i ] * a [ i ] ) ; max_sum = max ( max_sum , dp [ i ] [ 1 ] ) ; max_sum = max ( max_sum , dp [ i ] [ 0 ] ) ; } return max_sum ; } int32_t main ( ) { int n = 5 ; int a [ ] = { 1 , -5 , 8 , 12 , -8 } ; cout << getMaxSum ( a , n ) << endl ; return 0 ; }

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