dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; vector < Node * > child ; Node ( int x ) : data ( x ) { } } ; void printPath ( vector < int > vec ) { for ( int ele : vec ) { cout << ele << " ▁ " ; } cout << endl ; } void printAllRootToLeafPaths ( Node * root , vector < int > vec ) { if ( ! root ) return ; vec . push_back ( root -> data ) ; if ( root -> child . empty ( ) ) { printPath ( vec ) ; vec . pop_back ( ) ; return ; } for ( int i = 0 ; i < root -> child . size ( ) ; i ++ ) printAllRootToLeafPaths ( root -> child [ i ] , vec ) ; } void printAllRootToLeafPaths ( Node * root ) { if ( ! root ) return ; vector < int > vec ; printAllRootToLeafPaths ( root , vec ) ; } int main ( ) { Node * root = new Node ( 1 ) ; ( root -> child ) . push_back ( new Node ( 2 ) ) ; ( root -> child ) . push_back ( new Node ( 3 ) ) ; ( root -> child [ 0 ] -> child ) . push_back ( new Node ( 4 ) ) ; ( root -> child [ 1 ] -> child ) . push_back ( new Node ( 5 ) ) ; ( root -> child [ 1 ] -> child ) . push_back ( new Node ( 6 ) ) ; ( root -> child [ 1 ] -> child [ 1 ] -> child ) . push_back ( new Node ( 7 ) ) ; ( root -> child [ 1 ] -> child [ 1 ] -> child ) . push_back ( new Node ( 8 ) ) ; printAllRootToLeafPaths ( root ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: ele, i
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; int minimumDeletions ( string s ) { int n = s . size ( ) ; int zeroCount [ n ] ; zeroCount [ n - 1 ] = ( s [ n - 1 ] == '0' ) ? 1 : 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) zeroCount [ i ] = ( s [ i ] == '0' ) ? zeroCount [ i + 1 ] + 1 : zeroCount [ i + 1 ] ; int oneCount = 0 ; int ans = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { ans = min ( ans , oneCount + zeroCount [ i ] ) ; oneCount ++ ; } } ans = min ( ans , oneCount ) ; return ( ans == INT_MAX ) ? 0 : ans ; } int main ( ) { string stri = "00101101" ; cout << minimumDeletions ( stri ) << endl ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, oneCount, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPairs ( int arr [ ] , int n ) { vector < int > v ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( abs ( arr [ i ] ) == abs ( arr [ j ] ) ) v . push_back ( abs ( arr [ i ] ) ) ; if ( v . size ( ) == 0 ) return ; sort ( v . begin ( ) , v . end ( ) ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) cout << - v [ i ] << " ▁ " << v [ i ] ; } int main ( ) { int arr [ ] = { 4 , 8 , 9 , -4 , 1 , -1 , -8 , -9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printPairs ( arr , n ) ; 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 ; bool canPairs ( int arr [ ] , int n , int k ) { if ( n & 1 ) return false ; unordered_map < int , int > freq ; for ( int i = 0 ; i < n ; i ++ ) freq [ ( ( arr [ i ] % k ) + k ) % k ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { int rem = ( ( arr [ i ] % k ) + k ) % k ; if ( 2 * rem == k ) { if ( freq [ rem ] % 2 != 0 ) return false ; } else if ( rem == 0 ) { if ( freq [ rem ] & 1 ) return false ; } else if ( freq [ rem ] != freq [ k - rem ] ) return false ; } return true ; } int main ( ) { int arr [ ] = { 92 , 75 , 65 , 48 , 45 , 35 } ; int k = 10 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; canPairs ( arr , n , k ) ? cout << " True " : cout << " False " ; return 0 ; }

Index/key variables: i, rem
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void subarrayDivisibleByK ( int arr [ ] , int n , int k ) { map < int , int > mp ; int s = 0 , e = 0 , maxs = 0 , maxe = 0 ; mp [ arr [ 0 ] % k ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { int mod = arr [ i ] % k ; while ( mp [ k - mod ] != 0 || ( mod == 0 && mp [ mod ] != 0 ) ) { mp [ arr [ s ] % k ] -- ; s ++ ; } mp [ mod ] ++ ; e ++ ; if ( ( e - s ) > ( maxe - maxs ) ) { maxe = e ; maxs = s ; } } cout << " The ▁ maximum ▁ size ▁ is ▁ " << maxe - maxs + 1 << " ▁ and ▁ " " the ▁ subarray ▁ is ▁ as ▁ follows STRNEWLINE " ; for ( int i = maxs ; i <= maxe ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int k = 3 ; int arr [ ] = { 5 , 10 , 15 , 20 , 25 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; subarrayDivisibleByK ( arr , n , k ) ; return 0 ; }

Index/key variables: i, mod, s
Accumulator variables: e, i, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findTriplet ( int a1 [ ] , int a2 [ ] , int a3 [ ] , int n1 , int n2 , int n3 , int sum ) { for ( int i = 0 ; i < n1 ; i ++ ) for ( int j = 0 ; j < n2 ; j ++ ) for ( int k = 0 ; k < n3 ; k ++ ) if ( a1 [ i ] + a2 [ j ] + a3 [ k ] == sum ) return true ; return false ; } int main ( ) { int a1 [ ] = { 1 , 2 , 3 , 4 , 5 } ; int a2 [ ] = { 2 , 3 , 6 , 1 , 2 } ; int a3 [ ] = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = sizeof ( a1 ) / sizeof ( a1 [ 0 ] ) ; int n2 = sizeof ( a2 ) / sizeof ( a2 [ 0 ] ) ; int n3 = sizeof ( a3 ) / sizeof ( a3 [ 0 ] ) ; findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findTriplet ( int a1 [ ] , int a2 [ ] , int a3 [ ] , int n1 , int n2 , int n3 , int sum ) { unordered_set < int > s ; for ( int i = 0 ; i < n1 ; i ++ ) s . insert ( a1 [ i ] ) ; for ( int i = 0 ; i < n2 ; i ++ ) { for ( int j = 0 ; j < n3 ; j ++ ) { if ( s . find ( sum - a2 [ i ] - a3 [ j ] ) != s . end ( ) ) return true ; } } return false ; } int main ( ) { int a1 [ ] = { 1 , 2 , 3 , 4 , 5 } ; int a2 [ ] = { 2 , 3 , 6 , 1 , 2 } ; int a3 [ ] = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = sizeof ( a1 ) / sizeof ( a1 [ 0 ] ) ; int n2 = sizeof ( a2 ) / sizeof ( a2 [ 0 ] ) ; int n3 = sizeof ( a3 ) / sizeof ( a3 [ 0 ] ) ; findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#include <unordered_map>
using namespace std ; int countSum ( int a [ ] , int n , int sum ) { int i , j , k , l ; int count = 0 ; for ( i = 0 ; i < n - 3 ; i ++ ) { for ( j = i + 1 ; j < n - 2 ; j ++ ) { int req = sum - a [ i ] - a [ j ] ; unordered_map < int , int > m ; for ( k = j + 1 ; k < n ; k ++ ) m [ a [ k ] ] ++ ; int twice_count = 0 ; for ( k = j + 1 ; k < n ; k ++ ) { twice_count += m [ req - a [ k ] ] ; if ( req - a [ k ] == a [ k ] ) twice_count -- ; } count += twice_count / 2 ; } } return count ; } int main ( ) { int arr [ ] = { 4 , 5 , 3 , 1 , 2 , 4 } ; int S = 13 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countSum ( arr , N , S ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, twice_count
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findPairs ( int arr [ ] , int n ) { map < int , pair < int , int > > Hash ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { int sum = arr [ i ] + arr [ j ] ; if ( Hash . find ( sum ) == Hash . end ( ) ) Hash [ sum ] = make_pair ( i , j ) ; else { pair < int , int > pp = Hash [ sum ] ; cout << " ( " << arr [ pp . first ] << " , ▁ " << arr [ pp . second ] << " ) ▁ and ▁ ( " << arr [ i ] << " , ▁ " << arr [ j ] << " ) n " ; return true ; } } } cout << " No ▁ pairs ▁ found " ; return false ; } int main ( ) { int arr [ ] = { 3 , 4 , 7 , 1 , 2 , 9 , 8 } ; int n = sizeof arr / sizeof arr [ 0 ] ; findPairs ( arr , n ) ; return 0 ; }

Index/key variables: i, j, sum
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string check ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { map < int , int > hm ; int count = 0 ; for ( int j = i ; j < n ; j ++ ) { hm [ arr [ j ] ] ++ ; if ( hm [ arr [ j ] ] == 1 ) count ++ ; if ( hm [ arr [ j ] ] == 2 ) count -- ; if ( count == 0 ) return " No " ; } } return " Yes " ; } int main ( ) { int arr [ ] = { 1 , 2 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << check ( arr , N ) ; }

Index/key variables: j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countPairsWithDiffK ( int arr [ ] , int N , int K ) { int vis [ N ] ; memset ( vis , 0 , sizeof ( vis ) ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( vis [ i ] == 1 ) continue ; for ( int j = i + 1 ; j < N ; j ++ ) { if ( vis [ j ] == 1 ) continue ; if ( abs ( arr [ i ] - arr [ j ] ) >= K ) { count ++ ; vis [ i ] = 1 ; vis [ j ] = 1 ; break ; } } } cout << count << ' ▁ ' ; } int main ( ) { int arr [ ] = { 1 , 3 , 3 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 2 ; countPairsWithDiffK ( arr , N , K ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; int areMirror ( Node * a , Node * b ) { if ( a == NULL && b == NULL ) return true ; if ( a == NULL b == NULL ) return false ; return a -> data == b -> data && areMirror ( a -> left , b -> right ) && areMirror ( a -> right , b -> left ) ; } Node * newNode ( int data ) { Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return ( node ) ; } int main ( ) { Node * a = newNode ( 1 ) ; Node * b = newNode ( 1 ) ; a -> left = newNode ( 2 ) ; a -> right = newNode ( 3 ) ; a -> left -> left = newNode ( 4 ) ; a -> left -> right = newNode ( 5 ) ; b -> left = newNode ( 3 ) ; b -> right = newNode ( 2 ) ; b -> right -> left = newNode ( 5 ) ; b -> right -> right = newNode ( 4 ) ; areMirror ( a , b ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxLen ( int arr [ ] , int n ) { unordered_map < int , int > presum ; int sum = 0 ; int max_len = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( arr [ i ] == 0 && max_len == 0 ) max_len = 1 ; if ( sum == 0 ) max_len = i + 1 ; if ( presum . find ( sum ) != presum . end ( ) ) { max_len = max ( max_len , i - presum [ sum ] ) ; } else { presum [ sum ] = i ; } } return max_len ; } int main ( ) { int arr [ ] = { 15 , -2 , 2 , -8 , 1 , 7 , 10 , 23 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Length ▁ of ▁ the ▁ longest ▁ 0 ▁ sum ▁ subarray ▁ is ▁ " << maxLen ( arr , n ) ; return 0 ; }

Index/key variables: i, sum
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printAlter ( int arr [ ] , int N ) { for ( int currIndex = 0 ; currIndex < N ; currIndex += 2 ) { cout << arr [ currIndex ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printAlter ( arr , N ) ; }

Index/key variables: currIndex
Accumulator variables: currIndex, stdc
Iterator variables: currIndex
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestSubsequence ( int a [ ] , int n ) { unordered_map < int , int > mp ; int dp [ n ] ; memset ( dp , 0 , sizeof ( dp ) ) ; int maximum = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . find ( a [ i ] - 1 ) != mp . end ( ) ) { int lastIndex = mp [ a [ i ] - 1 ] - 1 ; dp [ i ] = 1 + dp [ lastIndex ] ; } else dp [ i ] = 1 ; mp [ a [ i ] ] = i + 1 ; maximum = max ( maximum , dp [ i ] ) ; } return maximum ; } int main ( ) { int a [ ] = { 3 , 10 , 3 , 11 , 4 , 5 , 6 , 7 , 8 , 12 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << longestSubsequence ( a , n ) ; return 0 ; }

Index/key variables: i, lastIndex, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longLenSub ( int arr [ ] , int n ) { unordered_map < int , int > um ; int longLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int len = 0 ; if ( um . find ( arr [ i ] - 1 ) != um . end ( ) && len < um [ arr [ i ] - 1 ] ) len = um [ arr [ i ] - 1 ] ; if ( um . find ( arr [ i ] + 1 ) != um . end ( ) && len < um [ arr [ i ] + 1 ] ) len = um [ arr [ i ] + 1 ] ; um [ arr [ i ] ] = len + 1 ; if ( longLen < um [ arr [ i ] ] ) longLen = um [ arr [ i ] ] ; } return longLen ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Longest ▁ length ▁ subsequence ▁ = ▁ " << longLenSub ( 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 ct = 0 ; struct Node { int val ; Node * left , * right ; Node ( int x ) { val = x ; left = right = NULL ; } } ; void find ( Node * root , int mx ) { if ( root == NULL ) return ; if ( root -> val >= mx ) ct ++ ; find ( root -> left , max ( mx , root -> val ) ) ; find ( root -> right , max ( mx , root -> val ) ) ; } int NodesMaxInPath ( Node * root ) { find ( root , INT_MIN ) ; return ct ; } int main ( ) { Node * root = new Node ( 3 ) ; root -> left = new Node ( 2 ) ; root -> right = new Node ( 5 ) ; root -> left -> left = new Node ( 4 ) ; root -> right -> right = new Node ( 7 ) ; int answer = NodesMaxInPath ( root ) ; cout << ( answer ) ; return 0 ; }

Accumulator variables: ct, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLongestConseqSubseq ( int arr [ ] , int n ) { int ans = 0 , count = 0 ; sort ( arr , arr + n ) ; vector < int > v ; v . push_back ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] ) v . push_back ( arr [ i ] ) ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( i > 0 && v [ i ] == v [ i - 1 ] + 1 ) count ++ ; else count = 1 ; ans = max ( ans , count ) ; } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 3 } ; int n = sizeof arr / sizeof arr [ 0 ] ; cout << " Length ▁ of ▁ the ▁ Longest ▁ contiguous ▁ subsequence ▁ " " is ▁ " << findLongestConseqSubseq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; const int maxn = 1e6 + 5 ; int BITree [ maxn ] ; bool is_prime ( int n ) { if ( n <= 1 ) return 0 ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) return 0 ; return 1 ; } void update_bitree ( int BITree [ ] , int index , int value ) { while ( index <= maxn ) { BITree [ index ] += value ; index += ( index & ( - index ) ) ; } } int sum_bitree ( int BITree [ ] , int index ) { int s = 0 ; while ( index > 0 ) { s += BITree [ index ] ; index -= ( index & ( - index ) ) ; } return s ; } void countSmallerPrimes ( int BITree [ ] , int ar [ ] , int N ) { int ans [ N ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { ans [ i ] = sum_bitree ( BITree , ar [ i ] ) ; if ( is_prime ( ar [ i ] ) ) update_bitree ( BITree , ar [ i ] , 1 ) ; } for ( int i = 0 ; i < N ; i ++ ) cout << ans [ i ] << " ▁ " ; } int main ( ) { int ar [ ] = { 5 , 5 , 17 , 9 , 12 , 15 , 11 , 7 , 39 , 3 } ; int N = sizeof ar / sizeof ar [ 0 ] ; countSmallerPrimes ( BITree , ar , N ) ; return 0 ; }

Index/key variables: N, i, index, maxn
Accumulator variables: i, index, s
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLongestConseqSubseq ( int arr [ ] , int n ) { unordered_set < int > S ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) S . insert ( arr [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( S . find ( arr [ i ] - 1 ) == S . end ( ) ) { int j = arr [ i ] ; while ( S . find ( j ) != S . end ( ) ) j ++ ; ans = max ( ans , j - arr [ i ] ) ; } } return ans ; } int main ( ) { int arr [ ] = { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = sizeof arr / sizeof arr [ 0 ] ; cout << " Length ▁ of ▁ the ▁ Longest ▁ contiguous ▁ subsequence ▁ " " is ▁ " << findLongestConseqSubseq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLongestConseqSubseq ( int arr [ ] , int N ) { priority_queue < int , vector < int > , greater < int > > pq ; for ( int i = 0 ; i < N ; i ++ ) { pq . push ( arr [ i ] ) ; } int prev = pq . top ( ) ; pq . pop ( ) ; int c = 1 ; int max = 1 ; while ( ! pq . empty ( ) ) { if ( pq . top ( ) - prev > 1 ) { c = 1 ; prev = pq . top ( ) ; pq . pop ( ) ; } else if ( pq . top ( ) - prev == 0 ) { prev = pq . top ( ) ; pq . pop ( ) ; } else { c ++ ; prev = pq . top ( ) ; pq . pop ( ) ; } if ( max < c ) { max = c ; } } return max ; } int main ( ) { int arr [ ] = { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = 7 ; cout << " Length ▁ of ▁ the ▁ Longest ▁ consecutive ▁ subsequence ▁ " " is ▁ " << findLongestConseqSubseq ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c, i, stdc
Iterator variables: i
C++ program:
#include <cstring>
#include <iostream>
using namespace std ; void print_kth_string ( string str , int K ) { char * s = strtok ( ( char * ) str . c_str ( ) , " ▁ " ) ; while ( K > 1 ) { s = strtok ( NULL , " ▁ " ) ; K -- ; } cout << string ( s ) << " ▁ " ; } int main ( ) { string s ( "10 ▁ 20 ▁ 30 ▁ 40" ) ; int K = 2 ; print_kth_string ( s , K ) ; return 0 ; }

Accumulator variables: K
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLIS ( int A [ ] , int n ) { unordered_map < int , int > hash ; int LIS_size = 1 ; int LIS_index = 0 ; hash [ A [ 0 ] ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { hash [ A [ i ] ] = hash [ A [ i ] - 1 ] + 1 ; if ( LIS_size < hash [ A [ i ] ] ) { LIS_size = hash [ A [ i ] ] ; LIS_index = A [ i ] ; } } cout << " LIS _ size ▁ = ▁ " << LIS_size << " STRNEWLINE " ; cout << " LIS ▁ : ▁ " ; int start = LIS_index - LIS_size + 1 ; while ( start <= LIS_index ) { cout << start << " ▁ " ; start ++ ; } } int main ( ) { int A [ ] = { 2 , 5 , 3 , 7 , 4 , 8 , 5 , 13 , 6 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; findLIS ( A , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, start, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubsets ( int arr [ ] , int n ) { unordered_set < int > us ; int even_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 0 ) us . insert ( arr [ i ] ) ; unordered_set < int > :: iterator itr ; even_count = us . size ( ) ; return ( pow ( 2 , even_count ) - 1 ) ; } int main ( ) { int arr [ ] = { 4 , 2 , 1 , 9 , 2 , 6 , 5 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Number ▁ of ▁ subsets ▁ = ▁ " << countSubsets ( 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 countWindowDistinct ( int win [ ] , int k ) { int dist_count = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int j ; for ( j = 0 ; j < i ; j ++ ) if ( win [ i ] == win [ j ] ) break ; if ( j == i ) dist_count ++ ; } return dist_count ; } void countDistinct ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i <= n - k ; i ++ ) cout << countWindowDistinct ( arr + i , k ) << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 1 , 3 , 4 , 2 , 3 } , k = 4 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countDistinct ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: dist_count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * temp = new Node ( ) ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } string areMirrors ( Node * root1 , Node * root2 ) { stack < Node * > st1 , st2 ; while ( 1 ) { while ( root1 && root2 ) { if ( root1 -> data != root2 -> data ) return " No " ; st1 . push ( root1 ) ; st2 . push ( root2 ) ; root1 = root1 -> left ; root2 = root2 -> right ; } if ( ! ( root1 == NULL && root2 == NULL ) ) return " No " ; if ( ! st1 . empty ( ) && ! st2 . empty ( ) ) { root1 = st1 . top ( ) ; root2 = st2 . top ( ) ; st1 . pop ( ) ; st2 . pop ( ) ; root1 = root1 -> right ; root2 = root2 -> left ; } else break ; } return " Yes " ; } int main ( ) { Node * root1 = newNode ( 1 ) ; root1 -> left = newNode ( 3 ) ; root1 -> right = newNode ( 2 ) ; root1 -> right -> left = newNode ( 5 ) ; root1 -> right -> right = newNode ( 4 ) ; Node * root2 = newNode ( 1 ) ; root2 -> left = newNode ( 2 ) ; root2 -> right = newNode ( 3 ) ; root2 -> left -> left = newNode ( 4 ) ; root2 -> left -> right = newNode ( 5 ) ; cout << areMirrors ( root1 , root2 ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumSum ( int a [ ] , int b [ ] , int n , int index , int lastpicked , vector < vector < int > > dp ) { if ( index == n ) return 0 ; if ( dp [ index ] [ lastpicked + 1 ] != -1 ) return dp [ index ] [ lastpicked + 1 ] ; int option1 = 0 , option2 = 0 ; if ( lastpicked == -1 a [ lastpicked ] != a [ index ] ) { option1 = b [ index ] + maximumSum ( a , b , n , index + 1 , index , dp ) ; } option2 = maximumSum ( a , b , n , index + 1 , lastpicked , dp ) ; return dp [ index ] [ lastpicked + 1 ] = max ( option1 , option2 ) ; } void maximumPoints ( int arr [ ] , int brr [ ] , int n ) { int index = 0 , lastPicked = -1 ; vector < vector < int > > dp ( n + 5 , vector < int > ( n + 5 , -1 ) ) ; cout << maximumSum ( arr , brr , n , index , lastPicked , dp ) << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 , 3 , 1 } ; int brr [ ] = { -1 , 2 , 10 , 20 , -10 , -9 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumPoints ( arr , brr , N ) ; return 0 ; }

Index/key variables: index, lastpicked
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int returnMaxSum ( int A [ ] , int B [ ] , int n ) { unordered_set < int > mp ; int result = 0 ; int curr_sum = 0 , curr_begin = 0 ; for ( int i = 0 ; i < n ; ++ i ) { while ( mp . find ( A [ i ] ) != mp . end ( ) ) { mp . erase ( A [ curr_begin ] ) ; curr_sum -= B [ curr_begin ] ; curr_begin ++ ; } mp . insert ( A [ i ] ) ; curr_sum += B [ i ] ; result = max ( result , curr_sum ) ; } return result ; } int main ( ) { int A [ ] = { 0 , 1 , 2 , 3 , 0 , 1 , 4 } ; int B [ ] = { 9 , 8 , 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << returnMaxSum ( A , B , n ) ; return 0 ; }

Index/key variables: curr_begin, i
Accumulator variables: curr_begin, curr_sum, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void FindMax ( int arr [ ] , int N ) { int maxi = -1 ; int maxi2 = -1 ; int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( arr [ i ] == 0 ) count = 0 ; else { count ++ ; maxi = max ( maxi , count ) ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { count ++ ; if ( count > maxi2 && count < maxi ) { maxi2 = count ; } } if ( arr [ i ] == 0 ) count = 0 ; } maxi = max ( maxi , 0 ) ; maxi2 = max ( maxi2 , 0 ) ; cout << maxi2 ; } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 0 , 0 , 1 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; FindMax ( arr , N ) ; return 0 ; }

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