dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int v1 [ ] , int v2 [ ] , int n , int m , int k ) { int count = 0 ; if ( n <= m ) { sort ( v1 , v1 + n ) ; for ( int j = 0 ; j < m ; j ++ ) { int index = lower_bound ( v1 , v1 + n , v2 [ j ] - k ) - v1 ; count += index ; } } else { sort ( v2 , v2 + m ) ; for ( int i = 0 ; i < n ; i ++ ) { int index = upper_bound ( v2 , v2 + m , v1 [ i ] + k ) - v2 ; count += m - index ; } } return count ; } int main ( ) { int arr [ ] = { 5 , 9 , 1 , 8 } ; int brr [ ] = { 10 , 12 , 7 , 4 , 2 , 3 } ; int K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int M = sizeof ( brr ) / sizeof ( brr [ 0 ] ) ; cout << countPairs ( arr , brr , N , M , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; vector < Node * > child ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; return temp ; } void Siblings ( Node * root , int value ) { int flag = 0 ; if ( root == NULL ) return ; queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; for ( int i = 0 ; i < temp -> child . size ( ) ; i ++ ) { if ( temp -> child [ i ] -> key == value ) { flag = 1 ; for ( int j = 0 ; j < temp -> child . size ( ) ; j ++ ) { if ( value != temp -> child [ j ] -> key ) cout << temp -> child [ j ] -> key << " ▁ " ; } break ; } q . push ( temp -> child [ i ] ) ; } } if ( flag == 0 ) cout << " No ▁ siblings ! ! " ; } Node * constructTree ( ) { Node * root = newNode ( 10 ) ; ( root -> child ) . push_back ( newNode ( 20 ) ) ; ( root -> child ) . push_back ( newNode ( 30 ) ) ; ( root -> child ) . push_back ( newNode ( 40 ) ) ; ( root -> child [ 0 ] -> child ) . push_back ( newNode ( 50 ) ) ; ( root -> child [ 0 ] -> child ) . push_back ( newNode ( 60 ) ) ; ( root -> child [ 1 ] -> child ) . push_back ( newNode ( 70 ) ) ; ( root -> child [ 1 ] -> child ) . push_back ( newNode ( 80 ) ) ; ( root -> child [ 2 ] -> child ) . push_back ( newNode ( 90 ) ) ; ( root -> child [ 2 ] -> child ) . push_back ( newNode ( 100 ) ) ; ( root -> child [ 2 ] -> child ) . push_back ( newNode ( 110 ) ) ; return root ; } int main ( ) { Node * root = constructTree ( ) ; int X = 30 ; Siblings ( root , X ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxSumSubarr ( int A [ ] , int N , int K , int X ) { int sum_K = 0 ; for ( int i = 0 ; i < K ; i ++ ) { sum_K += A [ i ] ; } int Max_Sum = 0 ; if ( sum_K < X ) { Max_Sum = sum_K ; } for ( int i = K ; i < N ; i ++ ) { sum_K -= ( A [ i - K ] - A [ i ] ) ; if ( sum_K < X ) { Max_Sum = max ( Max_Sum , sum_K ) ; } } cout << Max_Sum << endl ; } int main ( ) { int arr [ ] = { -5 , 8 , 7 , 2 , 10 , 1 , 20 , -4 , 6 , 9 } ; int K = 5 ; int X = 30 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maxSumSubarr ( arr , N , K , X ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum_K
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rearrangeArray ( int a [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; } if ( sum == 0 ) { cout << " - 1" ; return ; } sum = 0 ; int b = 0 ; sort ( a , a + N ) ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; if ( sum == 0 ) { if ( a [ i ] != a [ N - 1 ] ) { sum -= a [ i ] ; swap ( a [ i ] , a [ N - 1 ] ) ; sum += a [ i ] ; } else { b = 1 ; break ; } } } if ( b == 1 ) { b = 0 ; sum = 0 ; sort ( a , a + N , greater < int > ( ) ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) { sum += a [ i ] ; if ( sum == 0 ) { if ( a [ i ] != a [ 0 ] ) { sum -= a [ i ] ; swap ( a [ i ] , a [ 0 ] ) ; sum += a [ i ] ; } else { b = 1 ; break ; } } } } if ( b == 1 ) { cout << " - 1" ; return ; } for ( int i = 0 ; i < N ; i ++ ) { cout << a [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 1 , -1 , 2 , 4 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; rearrangeArray ( 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 ; void removeSmallestSubarray ( int arr [ ] , int n , int k ) { int mod_arr [ n ] ; int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mod_arr [ i ] = ( arr [ i ] + k ) % k ; total_sum += arr [ i ] ; } int target_remainder = total_sum % k ; if ( target_remainder == 0 ) { cout << "0" ; return ; } unordered_map < int , int > map1 ; map1 [ 0 ] = -1 ; int curr_remainder = 0 ; int res = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { curr_remainder = ( curr_remainder + arr [ i ] + k ) % k ; map1 [ curr_remainder ] = i ; int mod = ( curr_remainder - target_remainder + k ) % k ; if ( map1 . find ( mod ) != map1 . end ( ) ) res = min ( res , i - map1 [ mod ] ) ; } if ( res == INT_MAX res == n ) { res = -1 ; } cout << res ; } int main ( ) { int arr [ ] = { 3 , 1 , 4 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 6 ; removeSmallestSubarray ( arr , N , K ) ; return 0 ; }

Index/key variables: curr_remainder, i, mod, n
Accumulator variables: i, stdc, total_sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string toggleQuery ( string str , int Q [ ] [ 2 ] , int M ) { int N = str . length ( ) ; int prefixCnt [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < M ; i ++ ) { prefixCnt [ Q [ i ] [ 0 ] ] += 1 ; prefixCnt [ Q [ i ] [ 1 ] + 1 ] -= 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { prefixCnt [ i ] += prefixCnt [ i - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( prefixCnt [ i ] % 2 ) { str [ i ] = '1' - str [ i ] + '0' ; } } return str ; } int main ( ) { string str = "101010" ; int Q [ ] [ 2 ] = { { 0 , 1 } , { 2 , 5 } , { 2 , 3 } , { 1 , 4 } , { 0 , 5 } } ; int M = sizeof ( Q ) / sizeof ( Q [ 0 ] ) ; cout << toggleQuery ( str , Q , M ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( int wood [ ] , int N , int len , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { count += wood [ i ] / len ; } return count >= K ; } int findMaxLen ( int wood [ ] , int N , int K ) { int left = 1 ; int right = * max_element ( wood , wood + N ) ; while ( left <= right ) { int mid = left + ( right - left ) / 2 ; if ( isValid ( wood , N , mid , K ) ) { left = mid + 1 ; } else { right = mid - 1 ; } } return right ; } int main ( ) { int wood [ ] = { 5 , 9 , 7 } ; int N = sizeof ( wood ) / sizeof ( wood [ 0 ] ) ; int K = 4 ; cout << findMaxLen ( wood , N , K ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
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 ++ ) { for ( k = j + 1 ; k < n - 1 ; k ++ ) { for ( l = k + 1 ; l < n ; l ++ ) { if ( a [ i ] + a [ j ] + a [ k ] + a [ l ] == sum ) count ++ ; } } } } 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, l
Accumulator variables: count, i, j, k, l
Iterator variables: i, j, k, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSwaps ( string S , int n ) { int swaps = 0 ; vector < vector < int > > arr ( 26 ) ; for ( int i = 0 ; i < n ; i ++ ) { int pos = S [ i ] - ' a ' ; arr [ pos ] . push_back ( i ) ; } for ( char ch = ' a ' ; ch <= ' z ' ; ++ ch ) { int pos = ch - ' a ' ; for ( int i = 1 ; i < arr [ pos ] . size ( ) ; ++ i ) { swaps += abs ( arr [ pos ] [ i ] - arr [ pos ] [ i - 1 ] - 1 ) ; } } return swaps ; } int main ( ) { string S = " abbccabbcc " ; int N = S . length ( ) ; cout << minSwaps ( S , N ) ; return 0 ; }

Index/key variables: i, pos
Accumulator variables: i, stdc, swaps
Iterator variables: ch, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printConnections ( vector < pair < int , int > > store , vector < int > ind , int ind1 ) { for ( auto pr : store ) { cout << pr . first << " ▁ " << pr . second << " STRNEWLINE " ; } if ( ind . size ( ) != 0 ) { for ( auto x : ind ) { cout << ind1 << " ▁ " << x + 1 << " STRNEWLINE " ; } } } void constructGraph ( char arr [ ] , int N ) { vector < int > ind ; vector < pair < int , int > > store ; char x = arr [ 0 ] ; int count = 0 , ind1 ; for ( int i = 1 ; i <= N - 1 ; ++ i ) { if ( arr [ i ] != x ) { ind1 = i + 1 ; count ++ ; store . push_back ( { 1 , i + 1 } ) ; } else { ind . push_back ( i ) ; } } if ( count == 0 ) { cout << " Not ▁ Possible " ; } else { cout << " Possible " << " STRNEWLINE " ; printConnections ( store , ind , ind1 ) ; } } int main ( ) { int N = 5 ; char arr [ ] = { ' a ' , ' b ' , ' a ' , ' b ' , ' c ' } ; constructGraph ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, stdc
Iterator variables: i, pr, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinimumOperations ( string a , string b ) { int step = 0 ; int last_index ; while ( a != b ) { for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a [ i ] != b [ i ] ) { last_index = i ; } } for ( int i = 0 ; i <= last_index ; i ++ ) { a [ i ] = ( a [ i ] == '0' ) ? '1' : '0' ; } step ++ ; } cout << step ; } int main ( ) { string A = "101010" , B = "110011" ; findMinimumOperations ( A , B ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, step
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( int arr [ ] , int n , int m , int d ) { for ( int i = 0 ; i < m ; i ++ ) { if ( abs ( arr [ n - m + i ] - arr [ i ] ) < d ) { return 0 ; } } return 1 ; } int countPairs ( int arr [ ] , int N , int K ) { int ans = 0 ; int left = 0 , right = N / 2 + 1 ; sort ( arr , arr + N ) ; while ( left < right ) { int mid = ( left + right ) / 2 ; if ( isValid ( arr , N , mid , K ) ) { ans = mid ; left = mid + 1 ; } else right = mid - 1 ; } cout << ans << ' ▁ ' ; } int main ( ) { int arr [ ] = { 1 , 3 , 3 , 5 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countPairs ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void max_distance ( int a [ ] , int temp [ ] , int n ) { map < int , int > mp ; for ( int i = 1 ; i <= n ; i ++ ) { temp [ i ] = -1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( mp . find ( a [ i ] ) == mp . end ( ) ) temp [ a [ i ] ] = i + 1 ; else temp [ a [ i ] ] = max ( temp [ a [ i ] ] , i - mp [ a [ i ] ] ) ; mp [ a [ i ] ] = i ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( temp [ i ] != -1 ) temp [ i ] = max ( temp [ i ] , n - mp [ i ] ) ; } } void min_comm_ele ( int a [ ] , int ans [ ] , int temp [ ] , int n ) { max_distance ( a , temp , n ) ; for ( int i = 1 ; i <= n ; i ++ ) { ans [ i ] = -1 ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( ans [ temp [ i ] ] == -1 ) ans [ temp [ i ] ] = i ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( i > 1 && ans [ i - 1 ] != -1 ) { if ( ans [ i ] == -1 ) ans [ i ] = ans [ i - 1 ] ; else ans [ i ] = min ( ans [ i ] , ans [ i - 1 ] ) ; } cout << ans [ i ] << " ▁ " ; } } int main ( ) { int N = 6 ; int a [ ] = { 1 , 3 , 4 , 5 , 6 , 7 } ; int temp [ 100 ] , ans [ 100 ] ; min_comm_ele ( a , ans , temp , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void FindTrip ( int arr [ ] , int N ) { for ( int i = 1 ; i < N - 1 ; i ++ ) { int p = arr [ i - 1 ] ; int q = arr [ i ] ; int r = arr [ i + 1 ] ; if ( p < q && q > r ) { cout << i - 1 << " ▁ " << i << " ▁ " << i + 1 ; return ; } } cout << -1 ; } int main ( ) { int arr [ ] = { 2 , 1 , 4 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; FindTrip ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntSubarrays ( int arr [ ] , int N ) { int cntSub = 0 ; int cntUnique = 0 ; unordered_map < int , int > cntFreq ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j ++ ) { cntFreq [ arr [ j ] ] ++ ; if ( cntFreq [ arr [ j ] ] == 1 ) { cntUnique ++ ; } else if ( cntFreq [ arr [ j ] ] == 2 ) { cntUnique -- ; } if ( cntUnique == 0 ) { cntSub ++ ; } } cntFreq . clear ( ) ; cntUnique = 0 ; } return cntSub ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 2 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntSubarrays ( arr , N ) ; }

Index/key variables: j
Accumulator variables: cntSub, cntUnique, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkPalinK ( string str , int K ) { int N = str . length ( ) ; int cntFreq [ 256 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ str [ i ] ] ++ ; } int cntOddFreq = 0 ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( cntFreq [ i ] % 2 == 1 ) { cntOddFreq ++ ; } } if ( cntOddFreq <= ( K + 1 ) ) { return true ; } return false ; } int main ( ) { string str = " geeksforgeeks " ; int K = 2 ; if ( checkPalinK ( str , K ) ) { cout << " Yes " ; } else { cout << " No " ; } }

Index/key variables: i
Accumulator variables: cntOddFreq, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countRemovableElem ( int arr [ ] , int N ) { int hash [ N + 1 ] = { 0 } ; int mex = N + 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] <= N ) hash [ arr [ i ] ] = 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { if ( hash [ i ] == 0 ) { mex = i ; break ; } } cout << N - ( mex - 1 ) ; } int main ( ) { int arr [ ] = { 2 , 3 , 5 , 1 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countRemovableElem ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printIndexes ( string str ) { int N = str . length ( ) ; int cntFreq [ 256 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ str [ i ] ] ++ ; } int cntLeftFreq [ 256 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { int cntLeft = 0 ; int cntRight = 0 ; for ( int j = str [ i ] - 1 ; j >= 0 ; j -- ) { cntLeft += cntLeftFreq [ j ] ; cntRight += cntFreq [ j ] - cntLeftFreq [ j ] ; } cntLeftFreq [ str [ i ] ] ++ ; if ( cntLeft == cntRight && cntLeft != 0 ) { cout << i << " ▁ " ; } } } int main ( ) { string str = " aabacdabbb " ; printIndexes ( str ) ; }

Index/key variables: i, j
Accumulator variables: cntLeft, cntRight, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Count_Number ( int x ) { int ans = 0 ; if ( x % 99 != 0 ) { ans = -1 ; } else { int diff = x / 99 ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { if ( ( i - j ) == diff ) { ans += 10 ; } } } } return ans ; } int main ( ) { int x = 792 ; cout << Count_Number ( x ) << endl ; return 0 ; }

Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int INF = INT_MAX ; int * findMaxPoint ( int arr [ ] [ 2 ] , int i , int n ) { if ( i == n ) { arr [ 0 ] [ 0 ] = INF ; arr [ 0 ] [ 1 ] = INF ; return arr [ 0 ] ; } bool flag = true ; for ( int j = 0 ; j < n ; j ++ ) { if ( j == i ) continue ; if ( arr [ j ] [ 0 ] >= arr [ i ] [ 0 ] arr [ j ] [ 1 ] >= arr [ i ] [ 1 ] ) { flag = false ; break ; } } if ( flag ) return arr [ i ] ; return findMaxPoint ( arr , i + 1 , n ) ; } void findMaxPoints ( int arr [ ] [ 2 ] , int n ) { int ans [ 2 ] ; memcpy ( ans , findMaxPoint ( arr , 0 , n ) , 2 * sizeof ( int ) ) ; if ( ans [ 0 ] == INF ) { cout << -1 ; } else { cout << " ( " << ans [ 0 ] << " ▁ " << ans [ 1 ] << " ) " ; } } int main ( ) { int arr [ ] [ 2 ] = { { 1 , 2 } , { 2 , 1 } , { 3 , 4 } , { 4 , 3 } , { 5 , 5 } } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMaxPoints ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: j, stdc
Iterator variables: j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  5
#define P  2
void findMaxPoint ( int arr [ N ] [ P ] ) { int maxX = INT_MIN ; int maxY = INT_MIN ; int n = N ; for ( int i = 0 ; i < n ; i ++ ) { maxX = max ( maxX , arr [ i ] [ 0 ] ) ; maxY = max ( maxY , arr [ i ] [ 1 ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( maxX == arr [ i ] [ 0 ] && maxY == arr [ i ] [ 1 ] ) { cout << " ( " << maxX << " , ▁ " << maxY << " ) " ; return ; } } cout << ( -1 ) ; } int main ( ) { int arr [ N ] [ P ] = { { 1 , 2 } , { 2 , 1 } , { 3 , 4 } , { 4 , 3 } , { 5 , 5 } } ; findMaxPoint ( arr ) ; }

Index/key variables: N, P, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_index ( int arr [ ] , int n , int K ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == K ) return i ; else if ( arr [ i ] > K ) return i ; return n ; } int main ( ) { int arr [ ] = { 1 , 3 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 2 ; cout << find_index ( arr , n , K ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minSubarray ( int * arr , int N ) { unordered_map < int , int > m ; for ( int i = 0 ; i < N ; i ++ ) { int mini = INT_MAX ; for ( int j = i ; j < N ; j ++ ) { mini = min ( mini , arr [ j ] ) ; m [ mini ] ++ ; } } for ( int i = 0 ; i < N ; i ++ ) { cout << m [ arr [ i ] ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 3 , 2 , 1 , 4 } ; int N = sizeof ( arr ) / sizeof ( int ) ; minSubarray ( arr , N ) ; return 0 ; }

Index/key variables: i, j, mini
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minSubarray ( int * arr , int N ) { int result [ N ] ; stack < pair < int , int > > l , r ; for ( int i = 0 ; i < N ; i ++ ) { int count = 1 ; while ( ! l . empty ( ) && l . top ( ) . first > arr [ i ] ) { count += l . top ( ) . second ; l . pop ( ) ; } l . push ( { arr [ i ] , count } ) ; result [ i ] = count ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { int count = 1 ; while ( ! r . empty ( ) && r . top ( ) . first >= arr [ i ] ) { count += r . top ( ) . second ; r . pop ( ) ; } r . push ( { arr [ i ] , count } ) ; result [ i ] *= count ; } for ( int i = 0 ; i < N ; i ++ ) { cout << result [ i ] << " ▁ " ; } } int main ( ) { int arr [ ] = { 3 , 2 , 1 , 4 } ; int N = sizeof ( arr ) / sizeof ( int ) ; minSubarray ( arr , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int num ) { if ( num <= 1 ) return false ; for ( int i = 2 ; i * i <= num ; i ++ ) if ( num % i == 0 ) return false ; return true ; } bool isFulPrime ( int n ) { if ( ! isPrime ( n ) ) return false ; else { while ( n > 0 ) { int rem = n % 10 ; if ( ! ( rem == 2 rem == 3 rem == 5 rem == 7 ) ) return false ; n = n / 10 ; } } return true ; } int countFulPrime ( int L , int R ) { int cnt = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( ( i % 2 ) != 0 && isFulPrime ( i ) ) { cnt ++ ; } } return cnt ; } int main ( ) { int L = 1 , R = 100 ; int ans = 0 ; if ( L < 3 ) ans ++ ; cout << ans + countFulPrime ( L , R ) ; return 0 ; }

Accumulator variables: ans, cnt, i, stdc
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 ++ ) { if ( currIndex % 2 == 0 ) { 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 findmin ( string s ) { int n = s . length ( ) ; int i , j , maximum = 0 ; int incr [ n + 1 ] = { 0 } ; for ( i = 0 ; i < n ; i ++ ) { incr [ i + 1 ] = incr [ i ] ; if ( s [ i ] == '0' ) { incr [ i + 1 ] ++ ; } } for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { maximum = max ( maximum , incr [ i ] + j - i + 1 - ( incr [ j + 1 ] - incr [ i ] ) + incr [ n ] - incr [ j + 1 ] ) ; } } return n - maximum ; } int main ( ) { string S = "0110100110" ; int minimum = findmin ( S ) ; cout << minimum << ' ' ; }

Index/key variables: i, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPower ( int x ) { return ( x && ( ! ( x & ( x - 1 ) ) ) ) ; } int maximumlength ( int arr [ ] , int N ) { int max_length = 0 ; int max_len_subarray = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( isPower ( arr [ i ] ) == 1 ) { max_length ++ ; max_len_subarray = max ( max_length , max_len_subarray ) ; } else { max_length = 0 ; } } cout << max_len_subarray ; } int main ( ) { int arr [ ] = { 2 , 5 , 4 , 6 , 8 , 8 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumlength ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, max_length, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLengthOfShortestSubarray ( int arr [ ] , int N ) { int minlength = INT_MAX ; int left = 0 ; int right = N - 1 ; while ( left < right && arr [ left + 1 ] >= arr [ left ] ) { left ++ ; } if ( left == N - 1 ) return 0 ; while ( right > left && arr [ right - 1 ] <= arr [ right ] ) { right -- ; } minlength = min ( N - left - 1 , right ) ; int j = right ; for ( int i = 0 ; i < left + 1 ; i ++ ) { if ( arr [ i ] <= arr [ j ] ) { minlength = min ( minlength , j - i - 1 ) ; } else if ( j < N - 1 ) { j ++ ; } else { break ; } } return minlength ; } int main ( ) { int arr [ ] = { 6 , 3 , 10 , 11 , 15 , 20 , 13 , 3 , 18 , 12 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( findLengthOfShortestSubarray ( arr , N ) ) ; }

Index/key variables: i, j, left, right
Accumulator variables: i, j, left, right, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void minSub ( int N ) { int count = 0 ; while ( N >= 0 ) { int num = N ; int rev = 0 ; while ( num != 0 ) { int digit = num % 10 ; rev = ( rev * 10 ) + digit ; num = num / 10 ; } if ( N == rev ) { break ; } count ++ ; N -- ; } cout << count ; } int main ( ) { int N = 3456 ; minSub ( N ) ; return 0 ; }

Accumulator variables: N, count
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberOfGP ( int L [ ] , int N ) { if ( N <= 2 ) return 0 ; int count = 0 ; int res = 0 ; for ( int i = 2 ; i < N ; ++ i ) { if ( L [ i - 1 ] * L [ i - 1 ] == L [ i ] * L [ i - 2 ] ) { ++ count ; } else { count = 0 ; } res += count ; } return res ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 8 , 16 , 24 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << numberOfGP ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntSubarr ( int arr [ ] , int N ) { int res = 0 ; int prefixXor = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { prefixXor = arr [ i ] ; for ( int j = i + 1 ; j < N ; j ++ ) { prefixXor ^= arr [ j ] ; if ( prefixXor == 0 && ( j - i + 1 ) % 2 == 0 ) { res ++ ; } } } return res ; } int main ( ) { int arr [ ] = { 2 , 2 , 3 , 3 , 6 , 7 , 8 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << cntSubarr ( arr , N ) ; }

Index/key variables: i, j
Accumulator variables: i, j, prefixXor, res, stdc
Iterator variables: i, j