dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < pair < int , int > > direction = { { 1 , 0 } , { 0 , -1 } , { -1 , 0 } , { 0 , 1 } } ; int maximumTime ( vector < vector < int > > arr ) { int n = arr . size ( ) ; int m = arr [ 0 ] . size ( ) ; vector < vector < bool > > visited ( n , vector < bool > ( m , 0 ) ) ; queue < pair < pair < int , int > , int > > q ; int uninfected_count = 0 ; int time = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( arr [ i ] [ j ] == 2 ) { q . push ( { { i , j } , 0 } ) ; visited [ i ] [ j ] = 1 ; } if ( arr [ i ] [ j ] == 1 ) { uninfected_count ++ ; } } } while ( ! q . empty ( ) ) { pair < pair < int , int > , int > current = q . front ( ) ; time = current . second ; q . pop ( ) ; for ( auto it : direction ) { int i = current . first . first + it . first ; int j = current . first . second + it . second ; if ( i < 0 j < 0 i > = n j > = m arr [ i ] [ j ] != 1 visited [ i ] [ j ] != 0 ) { continue ; } q . push ( { { i , j } , time + 1 } ) ; visited [ i ] [ j ] = 1 ; uninfected_count -- ; } } if ( uninfected_count != 0 ) return -1 ; return time ; } int main ( ) { vector < vector < int > > arr = { { 2 , 1 , 0 , 2 , 1 } , { 1 , 0 , 1 , 2 , 1 } , { 1 , 0 , 0 , 2 , 1 } } ; cout << maximumTime ( arr ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc, uninfected_count
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimum_swaps ( int arr [ ] , int n ) { int count = 0 ; int max_el = * max_element ( arr , arr + n ) ; int min_el = * min_element ( arr , arr + n ) ; if ( min_el == max_el ) return 0 ; int index_max = -1 ; int index_min = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == max_el && index_max == -1 ) { index_max = i ; } if ( arr [ i ] == min_el ) { index_min = i ; } } count += index_max ; count += ( n - 1 - index_min ) ; if ( index_min < index_max ) count -= 1 ; return count ; } int main ( ) { int arr [ ] = { 2 , 4 , 1 , 6 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimum_swaps ( 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 ; void DFS ( int src , vector < int > Adj [ ] , int & ans , int arr [ ] , int currentMin , int currentMax ) { ans = max ( ans , max ( abs ( currentMax - arr [ src - 1 ] ) , abs ( currentMin - arr [ src - 1 ] ) ) ) ; currentMin = min ( currentMin , arr [ src - 1 ] ) ; currentMax = min ( currentMax , arr [ src - 1 ] ) ; for ( auto & child : Adj [ src ] ) { DFS ( child , Adj , ans , arr , currentMin , currentMax ) ; } } void getMaximumDifference ( int Edges [ ] [ 2 ] , int arr [ ] , int N , int M ) { vector < int > Adj [ N + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { int u = Edges [ i ] [ 0 ] ; int v = Edges [ i ] [ 1 ] ; Adj [ u ] . push_back ( v ) ; } int ans = 0 ; DFS ( 1 , Adj , ans , arr , arr [ 0 ] , arr [ 0 ] ) ; cout << ans ; } int main ( ) { int N = 5 , M = 4 ; int Edges [ ] [ 2 ] = { { 1 , 2 } , { 2 , 3 } , { 4 , 5 } , { 1 , 3 } } ; int arr [ ] = { 13 , 8 , 3 , 15 , 18 } ; getMaximumDifference ( Edges , arr , N , M ) ; return 0 ; }

Index/key variables: i, src, u
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int leastWeightedSumPath ( int n , vector < vector < int > > & edges , int src , int dst , int K ) { unordered_map < int , vector < pair < int , int > > > graph ; for ( vector < int > & edge : edges ) { graph [ edge [ 0 ] ] . push_back ( make_pair ( edge [ 1 ] , edge [ 2 ] ) ) ; } priority_queue < vector < int > , vector < vector < int > > , greater < vector < int > > > pq ; vector < vector < int > > costs ( n , vector < int > ( K + 2 , INT_MAX ) ) ; costs [ src ] [ K + 1 ] = 0 ; pq . push ( { 0 , src , K + 1 } ) ; while ( ! pq . empty ( ) ) { auto top = pq . top ( ) ; pq . pop ( ) ; if ( top [ 1 ] == dst ) return top [ 0 ] ; if ( top [ 2 ] == 0 ) continue ; for ( auto neighbor : graph [ top [ 1 ] ] ) { if ( costs [ neighbor . first ] [ top [ 2 ] - 1 ] < neighbor . second + top [ 0 ] ) { continue ; } costs [ neighbor . first ] [ top [ 2 ] - 1 ] = neighbor . second + top [ 0 ] ; pq . push ( { neighbor . second + top [ 0 ] , neighbor . first , top [ 2 ] - 1 } ) ; } } return -1 ; } int main ( ) { int n = 3 , src = 0 , dst = 2 , k = 1 ; vector < vector < int > > edges = { { 0 , 1 , 100 } , { 1 , 2 , 100 } , { 0 , 2 , 500 } } ; cout << leastWeightedSumPath ( n , edges , src , dst , k ) ; return 0 ; }

Index/key variables: src
Accumulator variables: stdc
Iterator variables: neighbor
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isComment ( string line ) { if ( line [ 0 ] == ' / ' && line [ 1 ] == ' / ' && line [ 2 ] != ' / ' ) { cout << " It ▁ is ▁ a ▁ single - line ▁ comment " ; return ; } if ( line [ line . size ( ) - 2 ] == ' * ' && line [ line . size ( ) - 1 ] == ' / ' && line [ 0 ] == ' / ' && line [ 1 ] == ' * ' ) { cout << " It ▁ is ▁ a ▁ multi - line ▁ comment " ; return ; } cout << " It ▁ is ▁ not ▁ a ▁ comment " ; } int main ( ) { string line = " GeeksForGeeks ▁ GeeksForGeeks " ; isComment ( line ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void indivisibleDigits ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int num = 0 ; cout << arr [ i ] << " : ▁ " ; for ( int j = 2 ; j < 10 ; j ++ ) { int temp = arr [ i ] ; bool flag = true ; while ( temp > 0 ) { if ( ( temp % 10 ) != 0 && ( temp % 10 ) % j == 0 ) { flag = false ; break ; } temp /= 10 ; } if ( flag ) { cout << j << ' ▁ ' ; } } cout << endl ; } } int main ( ) { int arr [ ] = { 4162 , 1152 , 99842 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; indivisibleDigits ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc, temp
Iterator variables: i, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void longestSequence ( int arr [ ] , int N ) { if ( N == 0 ) { cout << 0 ; return ; } sort ( arr , arr + N ) ; int maxLen = 1 ; int len = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] arr [ i ] == arr [ i - 1 ] + 1 ) { len ++ ; maxLen = max ( maxLen , len ) ; } else { len = 1 ; } } cout << maxLen ; } int main ( ) { int arr [ ] = { 8 , 5 , 4 , 8 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; longestSequence ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, len, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minSum ( int arr [ ] , int N , int Q [ ] , int M ) { for ( int i = 0 ; i < M ; i ++ ) { int val = Q [ i ] ; int front = 0 , rear = 0 ; for ( int j = 0 ; j < N ; j ++ ) { front += arr [ j ] ; if ( arr [ j ] == val ) { break ; } } for ( int j = N - 1 ; j >= 0 ; j -- ) { rear += arr [ j ] ; if ( arr [ j ] == val ) { break ; } } cout << min ( front , rear ) << " ▁ " ; } } int main ( ) { int arr [ ] = { 2 , 3 , 6 , 7 , 4 , 5 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int Q [ ] = { 7 , 6 } ; int M = sizeof ( Q ) / sizeof ( Q [ 0 ] ) ; minSum ( arr , N , Q , M ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: front, i, j, rear, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void KthCharacter ( string S , int N , int K ) { char strarray [ N + 1 ] ; strcpy ( strarray , S . c_str ( ) ) ; sort ( strarray , strarray + N ) ; char ch = strarray [ K - 1 ] ; int count = 0 ; for ( auto c : strarray ) { if ( c == ch ) count ++ ; } cout << count ; } int main ( ) { string S = " geeksforgeeks " ; int N = S . length ( ) ; int K = 3 ; KthCharacter ( S , N , K ) ; return 0 ; }

Accumulator variables: count, stdc
Iterator variables: c
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSubstring ( string S ) { string T = " " ; string ans = " " ; int l = 0 ; T += S [ 0 ] ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { if ( abs ( S [ i ] - S [ i - 1 ] ) == 1 ) { l = T . length ( ) ; if ( l > ans . length ( ) ) { ans = T ; } T = " " ; T += S [ i ] ; } else { T += S [ i ] ; } } l = ( int ) T . length ( ) ; if ( l > ( int ) ans . length ( ) ) { ans = T ; } cout << ans << endl ; } int main ( ) { string S = " aabdml " ; findSubstring ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: T, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinLength ( int arr [ ] , int N ) { int front = 0 , back = N - 1 ; while ( front < back ) { int x = arr [ front ] ; if ( arr [ front ] != arr [ back ] ) break ; while ( arr [ front ] == x && front <= back ) front ++ ; while ( arr [ back ] == x && front <= back ) back -- ; } cout << back - front + 1 << endl ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 3 , 3 , 1 , 2 , 2 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMinLength ( arr , N ) ; return 0 ; }

Index/key variables: back, front
Accumulator variables: back, front, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void prefixArr ( int arr [ ] , int prefix [ ] [ 2 ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( i == 0 ) { prefix [ i ] [ 0 ] = arr [ i ] ; prefix [ i ] [ 1 ] = arr [ i ] ; } else { prefix [ i ] [ 0 ] = max ( prefix [ i - 1 ] [ 0 ] , arr [ i ] ) ; prefix [ i ] [ 1 ] = min ( prefix [ i - 1 ] [ 1 ] , arr [ i ] ) ; } } } void suffixArr ( int arr [ ] , int suffix [ ] [ 2 ] , int N ) { for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( i == N - 1 ) { suffix [ i ] [ 0 ] = arr [ i ] ; suffix [ i ] [ 1 ] = arr [ i ] ; } else { suffix [ i ] [ 0 ] = max ( suffix [ i + 1 ] [ 0 ] , arr [ i ] ) ; suffix [ i ] [ 1 ] = min ( suffix [ i + 1 ] [ 1 ] , arr [ i ] ) ; } } } void maxAndmin ( int prefix [ ] [ 2 ] , int suffix [ ] [ 2 ] , int N , int L , int R ) { int maximum , minimum ; if ( L == 0 && R == N - 1 ) { cout << " No ▁ maximum ▁ and ▁ minimum ▁ value " << endl ; return ; } else if ( L == 0 ) { maximum = suffix [ R + 1 ] [ 0 ] ; minimum = suffix [ R + 1 ] [ 1 ] ; } else if ( R == N - 1 ) { maximum = prefix [ L - 1 ] [ 0 ] ; minimum = prefix [ R - 1 ] [ 1 ] ; } else { maximum = max ( prefix [ L - 1 ] [ 0 ] , suffix [ R + 1 ] [ 0 ] ) ; minimum = min ( prefix [ L - 1 ] [ 1 ] , suffix [ R + 1 ] [ 1 ] ) ; } cout << maximum << " ▁ " << minimum << endl ; } void MinMaxQueries ( int a [ ] , int Q [ ] [ ] ) { int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int q = sizeof ( queries ) / sizeof ( queries [ 0 ] ) ; int prefix [ N ] [ 2 ] ; int suffix [ N ] [ 2 ] ; prefixArr ( arr , prefix , N ) ; suffixArr ( arr , suffix , N ) ; for ( int i = 0 ; i < q ; i ++ ) { int L = queries [ i ] [ 0 ] ; int R = queries [ i ] [ 1 ] ; maxAndmin ( prefix , suffix , N , L , R ) ; } } int main ( ) { int arr [ ] = { 2 , 3 , 1 , 8 , 3 , 5 , 7 , 4 } ; int queries [ ] [ 2 ] = { { 4 , 6 } , { 0 , 4 } , { 3 , 7 } , { 2 , 5 } } ; MinMaxQueries ( arr , Q ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string finddigits ( string s ) { string num [ ] = { " zero " , " one " , " two " , " three " , " four " , " five " , " six " , " seven " , " eight " , " nine " } ; vector < int > arr ( 10 ) ; string ans = " " ; int n = s . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' z ' ) arr [ 0 ] ++ ; if ( s [ i ] == ' w ' ) arr [ 2 ] ++ ; if ( s [ i ] == ' g ' ) arr [ 8 ] ++ ; if ( s [ i ] == ' x ' ) arr [ 6 ] ++ ; if ( s [ i ] == ' v ' ) arr [ 5 ] ++ ; if ( s [ i ] == ' o ' ) arr [ 1 ] ++ ; if ( s [ i ] == ' s ' ) arr [ 7 ] ++ ; if ( s [ i ] == ' f ' ) arr [ 4 ] ++ ; if ( s [ i ] == ' h ' ) arr [ 3 ] ++ ; if ( s [ i ] == ' i ' ) arr [ 9 ] ++ ; } arr [ 7 ] -= arr [ 6 ] ; arr [ 5 ] -= arr [ 7 ] ; arr [ 4 ] -= arr [ 5 ] ; arr [ 1 ] -= ( arr [ 2 ] + arr [ 4 ] + arr [ 0 ] ) ; arr [ 3 ] -= arr [ 8 ] ; arr [ 9 ] -= ( arr [ 5 ] + arr [ 6 ] + arr [ 8 ] ) ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < arr [ i ] ; j ++ ) { ans += ( char ) ( i + '0' ) ; } } return ans ; } int main ( ) { string s = " owoftnuoer " ; cout << finddigits ( s ) << endl ; }

Index/key variables: i
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void check ( string s1 , string s2 ) { int s1_0 = 0 , s2_0 = 0 ; for ( int i = 0 ; i < s1 . size ( ) ; i ++ ) { if ( s1 [ i ] == '0' ) { s1_0 ++ ; } if ( s2 [ i ] == '0' ) { s2_0 ++ ; } } if ( s1_0 != s2_0 ) { cout << " NO " << endl ; return ; } else { int Count1 = 0 , Count2 = 0 ; for ( int i = 0 ; i < s1 . size ( ) ; i ++ ) { if ( s1 [ i ] == '0' ) { Count1 ++ ; } if ( s2 [ i ] == '0' ) { Count2 ++ ; } if ( Count1 < Count2 ) { cout << " NO " << endl ; return ; } } cout << " YES " << endl ; } } int main ( ) { string s1 = "100111" ; string s2 = "111010" ; check ( s1 , s2 ) ; s1 = "110100" ; s2 = "010101" ; check ( s1 , s2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: Count1, Count2, i, s1_0, s2_0, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isBinaryStringsEqual ( string str1 , string str2 ) { int str1Zeros = 0 , str1Ones = 0 ; int str2Zeros = 0 , str2Ones = 0 ; int flag = 0 ; int curStr1Ones = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( str1 [ i ] == '1' ) { str1Ones ++ ; } else if ( str1 [ i ] == '0' ) { str1Zeros ++ ; } if ( str2 [ i ] == '1' ) { str2Ones ++ ; } else if ( str2 [ i ] == '0' ) { str2Zeros ++ ; } } if ( str1Zeros != str2Zeros && str1Ones != str2Ones ) { cout << " Not ▁ Possible " ; } else { for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( str1 [ i ] != str2 [ i ] ) { if ( str1 [ i ] == '0' && curStr1Ones > 0 ) { str1 [ i ] = '1' ; curStr1Ones -- ; } if ( str1 [ i ] == '0' && curStr1Ones == 0 ) { flag ++ ; break ; } if ( str1 [ i ] == '1' && str2 [ i ] == '0' ) { str1 [ i ] = '0' ; curStr1Ones ++ ; } } } if ( flag == 0 ) { cout << " Possible " ; } else { cout << " Not ▁ Possible " ; } } } int main ( ) { string str1 = "0110" ; string str2 = "0011" ; isBinaryStringsEqual ( str1 , str2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: curStr1Ones, flag, i, stdc, str1Ones, str1Zeros, str2Ones, str2Zeros
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; static int noOfValidKbers ( int K , vector < int > arr ) { map < int , int > set ; while ( K != 0 ) { set [ K % 10 ] = 1 ; K = K / 10 ; } int count = 0 ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { int no = arr [ i ] ; bool flag = true ; while ( no != 0 ) { int digit = no % 10 ; if ( set . find ( digit ) == set . end ( ) ) { flag = false ; break ; } no = no / 10 ; } if ( flag == true ) { count ++ ; } } return count ; } int main ( ) { int K = 12 ; vector < int > arr = { 1 , 12 , 1222 , 13 , 2 } ; cout << ( noOfValidKbers ( K , arr ) ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
#define maxN  100
using namespace std ; int Tree [ 4 * maxN ] ; void build ( int arr [ ] , int index , int s , int e ) { if ( s == e ) Tree [ index ] = arr [ s ] ; else { int m = ( s + e ) / 2 ; build ( arr , 2 * index , s , m ) ; build ( arr , 2 * index + 1 , m + 1 , e ) ; Tree [ index ] = max ( Tree [ 2 * index ] , Tree [ 2 * index + 1 ] ) ; } } int atleast_x ( int index , int s , int e , int ql , int qr , int x ) { if ( ql > e qr < s ) return -1 ; if ( s <= ql && e <= qr ) { if ( Tree [ index ] < x ) return -1 ; while ( s != e ) { int m = ( s + e ) / 2 ; if ( Tree [ 2 * index ] >= x ) { e = m ; index = 2 * index ; } else { s = m + 1 ; index = 2 * index + 1 ; } } return s ; } int m = ( s + e ) / 2 ; int val = atleast_x ( 2 * index , s , m , ql , qr , x ) ; if ( val != -1 ) return val ; return atleast_x ( 2 * index + 1 , m + 1 , e , ql , qr , x ) ; } void update ( int index , int s , int e , int new_val , int pos ) { if ( s == e ) Tree [ index ] = new_val ; else { int m = ( s + e ) / 2 ; if ( pos <= m ) { update ( 2 * index , s , m , new_val , pos ) ; } else { update ( 2 * index + 1 , m + 1 , e , new_val , pos ) ; } Tree [ index ] = max ( Tree [ 2 * index ] , Tree [ 2 * index + 1 ] ) ; } } void printAnswer ( int * arr , int n ) { build ( arr , 1 , 0 , n - 1 ) ; cout << atleast_x ( 1 , 0 , n - 1 , 0 , n - 1 , 2 ) << " STRNEWLINE " ; arr [ 2 ] = 5 ; update ( 1 , 0 , n - 1 , 5 , 2 ) ; cout << atleast_x ( 1 , 0 , n - 1 , 0 , n - 1 , 4 ) << " STRNEWLINE " ; cout << atleast_x ( 1 , 0 , n - 1 , 0 , n - 1 , 0 ) << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 1 , 3 , 2 , 4 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printAnswer ( arr , N ) ; return 0 ; }

Index/key variables: index, s
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct TreeNode { int val ; TreeNode * left ; TreeNode * right ; TreeNode ( int data ) { this -> val = data ; left = NULL ; right = NULL ; } } ; int find_ht ( TreeNode * root ) { if ( ! root ) return 0 ; if ( root -> left == NULL && root -> right == NULL ) return 1 ; return max ( find_ht ( root -> left ) , find_ht ( root -> right ) ) + 1 ; } void find_node ( TreeNode * root , TreeNode * & req_node ) { if ( ! root ) return ; int left_ht = find_ht ( root -> left ) ; int right_ht = find_ht ( root -> right ) ; if ( left_ht > right_ht ) { find_node ( root -> left , req_node ) ; } else if ( right_ht > left_ht ) { find_node ( root -> right , req_node ) ; } else { req_node = root ; return ; } } int main ( ) { struct TreeNode * root = new TreeNode ( 1 ) ; root -> left = new TreeNode ( 2 ) ; root -> right = new TreeNode ( 3 ) ; TreeNode * req_node = NULL ; find_node ( root , req_node ) ; cout << req_node -> val ; return 0 ; }

Accumulator variables: stdc
Class/struct names: TreeNode
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxEvenIntegers ( int arr [ ] , int N , int M ) { int ans = 0 ; for ( int i = 0 ; i <= N - M ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < M ; j ++ ) { if ( arr [ i + j ] % 2 == 0 ) cnt ++ ; } ans = max ( ans , cnt ) ; } return ans ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 4 , 7 , 6 } ; int K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxEvenIntegers ( arr , N , K ) << endl ; return 0 ; }

Accumulator variables: cnt, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDiv ( int arr [ ] , int n ) { int rem0 = 0 ; int rem1 = 0 ; int rem2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int digitSum = 0 ; digitSum += arr [ i ] ; if ( digitSum % 3 == 0 ) { rem0 += 1 ; } else if ( digitSum % 3 == 1 ) { rem1 += 1 ; } else { rem2 += 1 ; } } return ( rem0 / 2 + min ( rem1 , rem2 ) ) ; } int main ( ) { int arr [ ] = { 5 , 3 , 2 , 8 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( countDiv ( arr , n ) ) ; }

Index/key variables: i
Accumulator variables: digitSum, i, rem0, rem1, rem2, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaxNonEmpSubSeq ( int a [ ] , int n ) { int sum = 0 ; int max = * max_element ( a , a + n ) ; if ( max <= 0 ) { return max ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > 0 ) { sum += a [ i ] ; } } return sum ; } int main ( ) { int arr [ ] = { -2 , 11 , -4 , 2 , -3 , -10 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << MaxNonEmpSubSeq ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long getcount ( long long n , int k ) { long long res = ( n >> ( k + 1 ) ) << k ; if ( ( n >> k ) & 1 ) res += n & ( ( 1ll << k ) - 1 ) ; return res ; } int main ( ) { long long int N = 14 ; int K = 2 ; cout << getcount ( N + 1 , K ) << endl ; return 0 ; }

Accumulator variables: res, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void splitString ( string S , int N ) { char c = S [ N - 1 ] ; int f = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( S [ i ] == c ) { f = 1 ; break ; } } if ( f ) cout << " Yes " ; else cout << " No " ; } int main ( ) { string S = " abcdab " ; int N = S . size ( ) ; splitString ( S , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char longestLastingBulb ( vector < int > onTime , string s ) { char ans ; int n = onTime . size ( ) ; int maxDur = INT_MIN ; int maxPos = INT_MIN ; int currentDiff = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { currentDiff = onTime [ i ] ; maxDur = currentDiff ; maxPos = i ; } else { currentDiff = onTime [ i ] - onTime [ i - 1 ] ; if ( maxDur < currentDiff ) { maxDur = currentDiff ; maxPos = i ; } else { if ( maxDur == currentDiff ) { char one = s [ i ] ; char two = s [ maxPos ] ; if ( one > two ) { maxDur = currentDiff ; maxPos = i ; } } } } } ans = s [ maxPos ] ; return ans ; } int main ( ) { string S = " spuda " ; vector < int > arr = { 12 , 23 , 36 , 46 , 62 } ; cout << longestLastingBulb ( arr , S ) ; return 0 ; }

Index/key variables: i, maxPos
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < pair < pair < int , int > , int > > tup ; void findIntersectingRange ( int N , int ranges [ ] [ 2 ] ) { int curr ; int currPos ; for ( int i = 0 ; i < N ; i ++ ) { int x , y ; x = ranges [ i ] [ 0 ] ; y = ranges [ i ] [ 1 ] ; tup . push_back ( { { x , y } , i + 1 } ) ; } sort ( tup . begin ( ) , tup . end ( ) ) ; curr = tup [ 0 ] . first . second ; currPos = tup [ 0 ] . second ; for ( int i = 1 ; i < N ; i ++ ) { int Q = tup [ i - 1 ] . first . first ; int R = tup [ i ] . first . first ; if ( Q == R ) { if ( tup [ i - 1 ] . first . second < tup [ i ] . first . second ) cout << tup [ i - 1 ] . second << ' ▁ ' << tup [ i ] . second ; else cout << tup [ i ] . second << ' ▁ ' << tup [ i - 1 ] . second ; return ; } int T = tup [ i ] . first . second ; if ( T <= curr ) { cout << tup [ i ] . second << ' ▁ ' << currPos ; return ; } else { curr = T ; currPos = tup [ i ] . second ; } } cout << " - 1 ▁ - 1" ; } int main ( ) { int N = 5 ; int ranges [ ] [ 2 ] = { { 1 , 5 } , { 2 , 10 } , { 3 , 10 } , { 2 , 2 } , { 2 , 15 } } ; findIntersectingRange ( N , ranges ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printNGE ( int * arr , int n ) { stack < int > s ; int nge [ n ] , i = 0 ; for ( i = 0 ; i < n ; i ++ ) { nge [ i ] = -1 ; } i = 0 ; while ( i < 2 * n ) { while ( ! s . empty ( ) && arr [ i % n ] > arr [ s . top ( ) ] ) { nge [ s . top ( ) ] = arr [ i % n ] ; s . pop ( ) ; } s . push ( i % n ) ; i ++ ; } for ( i = 0 ; i < n ; i ++ ) { cout << nge [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 4 , -2 , 5 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printNGE ( arr , N ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <set>
using namespace std ; #define N  100005
void SieveOfEratosthenes ( bool prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } long long int digitProduct ( int number ) { long long int res = 1 ; while ( number > 0 ) { res *= ( number % 10 ) ; number /= 10 ; } return res ; } void DistinctCompositeDigitProduct ( int arr [ ] , int n ) { set < int > output ; bool prime [ N + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; SieveOfEratosthenes ( prime , N ) ; for ( int i = 0 ; i < n ; i ++ ) { long long int ans = digitProduct ( arr [ i ] ) ; if ( ans <= 1 ) { continue ; } if ( ! prime [ ans ] ) { output . insert ( ans ) ; } } cout << output . size ( ) << endl ; } int main ( ) { int arr [ ] = { 13 , 55 , 7 , 13 , 11 , 71 , 233 , 233 , 144 , 89 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; DistinctCompositeDigitProduct ( arr , n ) ; return 0 ; }

Index/key variables: ans, i, p
Accumulator variables: i, number, p, res, stdc
Iterator variables: i, p