dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binaryToDecimal ( string n ) { string num = n ; int dec_value = 0 ; int base = 1 ; int len = num . length ( ) ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( num [ i ] == '1' ) dec_value += base ; base = base * 2 ; } return dec_value ; } string decimalToBinary ( int n ) { string binstr = " " ; while ( n > 0 ) { binstr += ( n % 2 + 48 ) ; n = n / 2 ; } return binstr ; } int reversedBinaryDecimal ( int N ) { string decimal_to_binar = decimalToBinary ( N ) ; int binary_to_decimal = binaryToDecimal ( decimal_to_binar ) ; return binary_to_decimal ; } void printSortedArray ( int arr [ ] , int size ) { sort ( arr , arr + size ) ; for ( int i = 0 ; i < size ; i ++ ) cout << arr [ i ] << " ▁ " ; cout << endl ; } void modifyArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) { arr [ i ] = reversedBinaryDecimal ( arr [ i ] ) ; } printSortedArray ( arr , size ) ; } int main ( ) { int arr [ ] = { 98 , 43 , 66 , 83 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; modifyArray ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: binstr, dec_value, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isSortedArray ( int arr [ ] , int n ) { int l = 0 , r = ( n - 1 ) ; while ( ( l + 1 ) < r ) { if ( arr [ l ] >= max ( arr [ l + 1 ] , arr [ r - 1 ] ) && arr [ r ] >= max ( arr [ r - 1 ] , arr [ l + 1 ] ) ) { l ++ ; r -- ; } else { return false ; } } return true ; } int main ( ) { int arr [ ] = { 4 , 3 , 1 , 2 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isSortedArray ( arr , N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: l, r
Accumulator variables: l, r, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxLenSubset ( int a [ ] , int n ) { sort ( a , a + n ) ; int index = 0 , maxlen = -1 ; int i = 0 ; while ( i < n ) { int j = i ; int len = 1 ; while ( j < n - 1 ) { if ( 2 * a [ j ] >= a [ j + 1 ] ) { len ++ ; } else break ; j ++ ; } if ( maxlen < len ) { maxlen = len ; index = i ; } j ++ ; i = j ; } i = index ; while ( maxlen > 0 ) { cout << a [ i ] << " ▁ " ; maxlen -- ; i ++ ; } } int main ( ) { int a [ ] = { 3 , 1 , 5 , 11 } ; int n = sizeof ( a ) / sizeof ( int ) ; maxLenSubset ( a , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, len, maxlen, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( int N , int X [ ] , int Y [ ] ) { vector < pair < int , int > > p ; for ( int i = 0 ; i < N ; i ++ ) { p . push_back ( { X [ i ] , Y [ i ] } ) ; } sort ( p . begin ( ) , p . end ( ) ) ; set < int , greater < int > > s ; s . insert ( p [ 0 ] . second ) ; for ( int i = 0 ; i < N ; i ++ ) { auto it = s . lower_bound ( p [ i ] . second ) ; if ( it == s . end ( ) ) { s . insert ( p [ i ] . second ) ; } else { s . erase ( * it ) ; s . insert ( p [ i ] . second ) ; } } return s . size ( ) ; } int main ( ) { int N = 3 ; int X [ ] = { 1 , 2 , 0 } ; int Y [ ] = { 2 , 0 , 1 } ; int maxintersection = solve ( N , X , Y ) ; cout << maxintersection ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canReduceArray ( int arr [ ] , int N , int K ) { sort ( arr , arr + N , greater < int > ( ) ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] - arr [ i + 1 ] > K ) { cout << " No " ; return ; } } cout << " Yes " ; } int main ( ) { int arr [ ] = { 2 , 1 , 1 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 1 ; canReduceArray ( 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 mergeStrings ( string s1 , string s2 ) { int len1 = s1 . size ( ) ; int len2 = s2 . size ( ) ; int pntr1 = 0 ; int pntr2 = 0 ; string ans = " " ; while ( pntr1 < len1 && pntr2 < len2 ) { if ( s1 [ pntr1 ] < s2 [ pntr2 ] ) { ans += s1 [ pntr1 ] ; pntr1 ++ ; } else { ans += s2 [ pntr2 ] ; pntr2 ++ ; } } if ( pntr1 < len1 ) { ans += s1 . substr ( pntr1 , len1 ) ; } if ( pntr2 < len2 ) { ans += s2 . substr ( pntr2 , len2 ) ; } cout << ans ; } int main ( ) { string S1 = " abdcdtx " ; string S2 = " achilp " ; mergeStrings ( S1 , S2 ) ; return 0 ; }

Index/key variables: pntr1, pntr2
Accumulator variables: ans, pntr1, pntr2, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sortStr ( string S ) { int N = S . size ( ) ; string temp = " " ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] != ' a ' && S [ i ] != ' e ' && S [ i ] != ' i ' && S [ i ] != ' o ' && S [ i ] != ' u ' ) temp += S [ i ] ; } if ( temp . size ( ) ) sort ( temp . begin ( ) , temp . end ( ) ) ; int ptr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] != ' a ' && S [ i ] != ' e ' && S [ i ] != ' i ' && S [ i ] != ' o ' && S [ i ] != ' u ' ) S [ i ] = temp [ ptr ++ ] ; } cout << S ; } int main ( ) { string S = " geeksforgeeks " ; sortStr ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, ptr, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countPairs ( int arr [ ] , int n , int k ) { sort ( arr , arr + n ) ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int high = upper_bound ( arr , arr + n , k * arr [ i ] ) - arr ; ans += high - i - 1 ; } cout << ans ; } int main ( ) { int arr [ ] = { 2 , 3 , 9 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 ; countPairs ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findXOR ( vector < vector < int > > mat , int K ) { int N = mat . size ( ) ; int M = mat [ 0 ] . size ( ) ; vector < int > digXOR ; for ( int l = 1 ; l <= ( N + M - 1 ) ; l ++ ) { int s_col = max ( 0 , l - N ) ; int count = min ( { l , ( M - s_col ) , N } ) ; int currXOR = 0 ; for ( int j = 0 ; j < count ; j ++ ) { currXOR = ( currXOR ^ mat [ min ( N , l ) - j - 1 ] [ s_col + j ] ) ; } digXOR . push_back ( currXOR ) ; } sort ( digXOR . begin ( ) , digXOR . end ( ) ) ; cout << digXOR [ N + M - 1 - K ] ; } int main ( ) { vector < vector < int > > mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int K = 3 ; findXOR ( mat , K ) ; return 0 ; }

Accumulator variables: j, l, stdc
Iterator variables: j, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maximumSum ( int arr [ ] , int N ) { int sum ; sort ( arr , arr + N ) ; sum = ( arr [ N - 1 ] - arr [ 0 ] ) + ( arr [ N - 2 ] - arr [ 0 ] ) + ( arr [ N - 1 ] - arr [ N - 2 ] ) ; cout << sum ; } int main ( ) { int arr [ ] = { 1 , 3 , 4 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumSum ( arr , N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( vector < pair < int , pair < int , int > > > v , int n ) { unordered_map < int , bool > um ; int res = 0 ; int cnt = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( cnt == n ) break ; int x = v [ i ] . second . first ; int y = v [ i ] . second . second ; int xorResult = v [ i ] . first ; if ( um [ x ] == false && um [ y ] == false ) { res += xorResult ; um [ x ] = true ; um [ y ] = true ; cnt += 2 ; } } return res ; } void findMaxMinSum ( int a [ ] , int n ) { vector < pair < int , pair < int , int > > > v ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int xorResult = a [ i ] ^ a [ j ] ; v . push_back ( { xorResult , { a [ i ] , a [ j ] } } ) ; } } sort ( v . begin ( ) , v . end ( ) ) ; int maxi = 0 , mini = 0 ; mini = findSum ( v , n ) ; reverse ( v . begin ( ) , v . end ( ) ) ; maxi = findSum ( v , n ) ; cout << mini << " ▁ " << maxi ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMaxMinSum ( arr , N ) ; return 0 ; }

Index/key variables: i, j, x, y
Accumulator variables: cnt, i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maximumSumPermutation ( vector < int > & arr ) { int N = arr . size ( ) ; sort ( arr . begin ( ) , arr . end ( ) ) ; swap ( arr [ 0 ] , arr [ N - 1 ] ) ; for ( int i : arr ) { cout << i << " ▁ " ; } } int main ( ) { vector < int > arr = { 1 , 2 , 3 , 4 , 5 } ; maximumSumPermutation ( arr ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMaxNumbers ( int arr [ ] , int n , int k ) { sort ( arr , arr + n ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int opr = ceil ( log2 ( arr [ i ] ) ) ; k -= opr ; if ( k < 0 ) { break ; } cnt ++ ; } cout << cnt ; } int main ( ) { int arr [ ] = { 5 , 8 , 4 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 5 ; findMaxNumbers ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void meanOfRemainingElements ( int arr [ ] , int N , int K ) { sort ( arr , arr + N ) ; int kthPercent = ( N * K ) / 100 ; float sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) if ( i >= kthPercent && i < ( N - kthPercent ) ) sum += arr [ i ] ; float mean = sum / ( N - 2 * kthPercent ) ; cout << fixed << setprecision ( 5 ) << mean << endl ; } int main ( ) { int arr [ ] = { 6 , 2 , 7 , 5 , 1 , 2 , 0 , 3 , 10 , 2 , 5 , 0 , 5 , 5 , 0 , 8 , 7 , 6 , 8 , 0 } ; int arr_size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 5 ; meanOfRemainingElements ( arr , arr_size , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minOperation ( int a [ ] , int N ) { int totOps = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { totOps += abs ( a [ i ] - a [ i + 1 ] ) ; } int maxOps = max ( abs ( a [ 0 ] - a [ 1 ] ) , abs ( a [ N - 1 ] - a [ N - 2 ] ) ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { maxOps = max ( maxOps , abs ( a [ i ] - a [ i - 1 ] ) + abs ( a [ i ] - a [ i + 1 ] ) - abs ( a [ i - 1 ] - a [ i + 1 ] ) ) ; } cout << totOps - maxOps << endl ; } int main ( ) { int arr [ ] = { 1 , -1 , 0 , 1 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minOperation ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, totOps
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxIntersection ( int segments [ ] [ 2 ] , int N ) { vector < int > rvalues ( N ) , lvalues ( N ) ; for ( int i = 0 ; i < N ; ++ i ) { lvalues [ i ] = segments [ i ] [ 0 ] ; rvalues [ i ] = segments [ i ] [ 1 ] ; } sort ( lvalues . begin ( ) , lvalues . end ( ) ) ; sort ( rvalues . begin ( ) , rvalues . end ( ) ) ; pair < int , int > answer = { -1 , -1 } ; int numIntersections = 0 ; for ( int i = 0 ; i < N ; ++ i ) { int lesser = lower_bound ( rvalues . begin ( ) , rvalues . end ( ) , segments [ i ] [ 0 ] ) - rvalues . begin ( ) ; int greater = max ( 0 , N - ( int ) ( upper_bound ( lvalues . begin ( ) , lvalues . end ( ) , segments [ i ] [ 1 ] ) - lvalues . begin ( ) ) ) ; if ( ( N - lesser - greater ) >= numIntersections ) { answer = { segments [ i ] [ 0 ] , segments [ i ] [ 1 ] } ; numIntersections = ( N - lesser - greater ) ; } } cout << answer . first << " ▁ " << answer . second ; } int main ( ) { int segments [ ] [ 2 ] = { { 1 , 4 } , { 2 , 3 } , { 3 , 6 } } ; int N = sizeof ( segments ) / sizeof ( segments [ 0 ] ) ; maxIntersection ( segments , N ) ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int temp [ 100000 ] ; long int merge ( int A [ ] , int left , int mid , int right ) { long int swaps = 0 ; int i = left , j = mid , k = left ; while ( i < mid && j <= right ) { if ( A [ i ] <= A [ j ] ) { temp [ k ] = A [ i ] ; k ++ , i ++ ; } else { temp [ k ] = A [ j ] ; k ++ , j ++ ; swaps += mid - i ; } } while ( i < mid ) { temp [ k ] = A [ i ] ; k ++ , i ++ ; } while ( j <= right ) { temp [ k ] = A [ j ] ; k ++ , j ++ ; } while ( left <= right ) { A [ left ] = temp [ left ] ; left ++ ; } return swaps ; } long int mergeInsertionSwap ( int A [ ] , int left , int right ) { long int swaps = 0 ; if ( left < right ) { int mid = left + ( right - left ) / 2 ; swaps += mergeInsertionSwap ( A , left , mid ) ; swaps += mergeInsertionSwap ( A , mid + 1 , right ) ; swaps += merge ( A , left , mid + 1 , right ) ; } return swaps ; } int main ( ) { int A [ ] = { 2 , 1 , 3 , 1 , 2 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << mergeInsertionSwap ( A , 0 , N - 1 ) ; return 0 ; }

Index/key variables: i, j, k, left
Accumulator variables: i, j, k, left, stdc, swaps
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxCntRemovedfromArray ( int arr [ ] , int N , int brr [ ] , int M ) { sort ( arr , arr + N ) ; int i = 0 ; int sumArr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sumArr += arr [ i ] ; } int sumBrr = 0 ; for ( int i = 0 ; i < M ; i ++ ) { sumBrr += brr [ i ] ; } int cntRemElem = 0 ; while ( i < N and sumArr > = sumBrr ) { sumArr -= arr [ i ] ; i += 1 ; if ( sumArr >= sumBrr ) { cntRemElem += 1 ; } } return cntRemElem ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 6 } ; int brr [ ] = { 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int M = sizeof ( brr ) / sizeof ( brr [ 0 ] ) ; cout << maxCntRemovedfromArray ( arr , N , brr , M ) ; }

Index/key variables: i
Accumulator variables: cntRemElem, i, stdc, sumArr, sumBrr
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPair ( pair < int , int > * arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int a = arr [ i ] . first , b = arr [ i ] . second ; for ( int j = i + 1 ; j < N ; j ++ ) { int c = arr [ j ] . first , d = arr [ j ] . second ; if ( a < c && b > d ) { cout << " ( " << a << " ▁ " << b << " ) , ▁ ( " << c << " ▁ " << d << " ) STRNEWLINE " ; return ; } } } cout << " NO ▁ SUCH ▁ PAIR ▁ EXIST STRNEWLINE " ; } int main ( ) { pair < int , int > arr [ ] = { { 3 , 7 } , { 21 , 23 } , { 4 , 13 } , { 1 , 2 } , { 7 , -1 } } ; findPair ( arr , 5 ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPair ( pair < int , int > * arr , int N ) { sort ( arr , arr + N ) ; for ( int i = 1 ; i < N ; i ++ ) { int b = arr [ i - 1 ] . second ; int d = arr [ i ] . second ; if ( b > d ) { cout << " ( " << arr [ i - 1 ] . first << " ▁ " << b << " ) , ▁ ( " << arr [ i ] . first << " ▁ " << d << " ) " ; return ; } } cout << " NO ▁ SUCH ▁ PAIR ▁ EXIST STRNEWLINE " ; } int main ( ) { pair < int , int > arr [ ] = { { 3 , 7 } , { 21 , 23 } , { 4 , 13 } , { 1 , 2 } , { 7 , -1 } } ; findPair ( arr , 5 ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printOrder ( int order [ ] , int N , int X ) { vector < pair < int , int > > vect ; for ( int i = 0 ; i < N ; i ++ ) { if ( order [ i ] % X == 0 ) { vect . push_back ( { order [ i ] / X , i + 1 } ) ; } else { vect . push_back ( { order [ i ] / X + 1 , i + 1 } ) ; } } sort ( vect . begin ( ) , vect . end ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { cout << vect [ i ] . second << " ▁ " ; } cout << endl ; } int main ( ) { int N = 3 , X = 3 ; int order [ ] = { 2 , 7 , 4 } ; printOrder ( order , N , X ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rearrange ( int A [ ] , int B [ ] , int N , int X ) { bool flag = true ; sort ( A , A + N ) ; sort ( B , B + N , greater < int > ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] + B [ i ] > X ) { flag = false ; break ; } } if ( flag ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int A [ ] = { 1 , 2 , 3 } ; int B [ ] = { 1 , 1 , 2 } ; int X = 4 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; rearrange ( A , B , N , X ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void numOperation ( int arr [ ] , int N , int D ) { sort ( arr , arr + N ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( ( arr [ i + 1 ] - arr [ i ] ) % D != 0 ) { cout << " - 1" ; return ; } } int count = 0 ; int mid = arr [ N / 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { count += abs ( mid - arr [ i ] ) / D ; } cout << count ; } int main ( ) { int N = 4 , D = 2 ; int arr [ ] = { 2 , 4 , 6 , 8 } ; numOperation ( arr , N , D ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSum ( int A [ ] , int N , int K ) { sort ( A , A + N ) ; int sum = 0 ; for ( int i = N / K ; i < N ; i += K - 1 ) { sum += A [ i ] ; } cout << sum ; } int main ( ) { int K = 4 ; int A [ ] = { 2 , 3 , 1 , 4 , 7 , 5 , 6 , 1 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; findSum ( A , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSmallestNumLeft ( int arr [ ] , int N ) { priority_queue < int > PQ ; for ( int i = 0 ; i < N ; i ++ ) { PQ . push ( arr [ i ] ) ; } while ( PQ . size ( ) > 1 ) { int top1 = PQ . top ( ) ; PQ . pop ( ) ; int top2 = PQ . top ( ) ; PQ . pop ( ) ; PQ . push ( ( top1 + top2 + 1 ) / 2 ) ; } return PQ . top ( ) ; } int main ( ) { int arr [ ] = { 30 , 16 , 40 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findSmallestNumLeft ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <vector>
using namespace std ; bool isComposite ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } int digitProduct ( int number ) { int product = 1 ; while ( number > 0 ) { product *= ( number % 10 ) ; number /= 10 ; } return product ; } bool compositedigitProduct ( int num ) { int res = digitProduct ( num ) ; if ( res == 1 ) { return false ; } if ( isComposite ( res ) ) { return true ; } return false ; } int largestCompositeDigitProduct ( int a [ ] , int n , int k ) { vector < pair < int , int > > pq ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( i % k ) == 0 ) { continue ; } if ( compositedigitProduct ( a [ i ] ) ) { int b = digitProduct ( a [ i ] ) ; pq . push_back ( make_pair ( b , a [ i ] ) ) ; } } sort ( pq . begin ( ) , pq . end ( ) ) ; return pq . back ( ) . second ; } int main ( ) { int arr [ ] = { 233 , 144 , 89 , 71 , 13 , 21 , 11 , 34 , 55 , 23 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 3 ; int ans = largestCompositeDigitProduct ( arr , n , k ) ; cout << ans << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, number, product, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinimum ( int arr [ ] , int N , int K ) { sort ( arr , arr + N ) ; int ans = 0 ; for ( int i = 1 ; i < 2 * ( N / K ) ; i += 2 ) { ans += arr [ i ] ; } cout << ans ; } int main ( ) { int arr [ ] = { 11 , 20 , 5 , 7 , 8 , 14 , 2 , 17 , 16 , 10 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 5 ; findMinimum ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSubarrays ( int arr [ ] , int N ) { sort ( arr , arr + N ) ; int i = 0 ; for ( i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { cout << " YES " << endl ; return ; } } cout << " NO " << endl ; } int main ( ) { int arr [ ] = { 4 , 3 , 0 , 1 , 2 , 0 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findSubarrays ( 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 sweetTypeOnGivenDay ( int a [ ] , int b [ ] , int n , int k , vector < pair < int , int > > & q ) { vector < pair < int , pair < int , int > > > v ; for ( int i = 0 ; i < n ; i ++ ) v . push_back ( { b [ i ] , { a [ i ] , i + 1 } } ) ; sort ( v . begin ( ) , v . end ( ) , greater < pair < int , pair < int , int > > > ( ) ) ; map < int , pair < int , int > > mp ; int lowerbound = 0 , upperbound = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int maxi_days = v [ i ] . second . first ; int mini_days = v [ i ] . second . first / k ; if ( v [ i ] . second . first % k != 0 ) mini_days ++ ; upperbound += maxi_days ; mp [ v [ i ] . second . second ] = { lowerbound , upperbound } ; lowerbound += mini_days ; } for ( int i = 0 ; i < q . size ( ) ; i ++ ) { int x = q [ i ] . first , y = q [ i ] . second ; int e = mp [ x ] . first ; int f = mp [ x ] . second ; if ( y >= e && y <= f ) cout << " Yes " << " ▁ " ; else cout << " No " << " ▁ " ; } } int main ( ) { int A [ ] = { 6 , 3 , 7 , 5 , 2 } ; int B [ ] = { 1 , 2 , 3 , 4 , 5 } ; int K = 3 ; vector < pair < int , int > > Queries = { { 4 , 4 } , { 3 , 16 } , { 2 , 7 } } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; sweetTypeOnGivenDay ( A , B , n , K , Queries ) ; }

Index/key variables: i, x
Accumulator variables: i, lowerbound, mini_days, stdc, upperbound
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void Bubble_Sort ( int arr [ ] , int n ) { bool flag ; for ( int i = 1 ; i < n ; ++ i ) { flag = false ; for ( int j = 0 ; j <= ( n - i - 1 ) ; ++ j ) { if ( arr [ j ] > arr [ j + 1 ] ) { swap ( arr [ j ] , arr [ j + 1 ] ) ; flag = true ; } } if ( flag == false ) break ; } } int main ( ) { int n = 5 ; int arr [ 5 ] = { 2 , 0 , 1 , 4 , 3 } ; Bubble_Sort ( arr , n ) ; cout << " The ▁ Sorted ▁ Array ▁ by ▁ using ▁ Bubble ▁ Sort ▁ is ▁ : ▁ " ; for ( int i = 0 ; i < n ; ++ i ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i, j
Iterator variables: i, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void NDivKWithFreq ( int arr [ ] , int N , int K ) { sort ( arr , arr + N ) ; for ( int i = 0 ; i < N ; ) { int cnt = 1 ; while ( ( i + 1 ) < N && arr [ i ] == arr [ i + 1 ] ) { cnt ++ ; i ++ ; } if ( cnt > ( N / K ) ) { cout << arr [ i ] << " ▁ " ; } i ++ ; } } int main ( ) { int arr [ ] = { 1 , 2 , 2 , 6 , 6 , 6 , 6 , 7 , 10 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 4 ; NDivKWithFreq ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printCircularArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { cout << arr [ i ] << " ▁ " ; } } void sortCircularArray ( int arr [ ] , int n , int k , int m ) { for ( int i = 0 ; i < m ; i ++ ) { for ( int j = k ; j < k + m - 1 ; j ++ ) { if ( arr [ j % n ] > arr [ ( j + 1 ) % n ] ) { swap ( arr [ j % n ] , arr [ ( j + 1 ) % n ] ) ; } } } printCircularArray ( arr , n ) ; } int main ( ) { int arr [ ] = { 4 , 1 , 6 , 5 , 3 } ; int K = 2 , M = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sortCircularArray ( arr , N , K , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool func ( pair < int , int > i1 , pair < int , int > i2 ) { return ( i1 . first - i1 . second < i2 . first - i2 . second ) ; } int minimumCostReqToCompthePrcess ( vector < pair < int , int > > arr ) { sort ( arr . begin ( ) , arr . end ( ) , func ) ; int n = arr . size ( ) ; int minCost = 0 ; int minCostInit = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] . second > minCostInit ) { minCost += ( arr [ i ] . second - minCostInit ) ; minCostInit = arr [ i ] . second ; } minCostInit -= arr [ i ] . first ; } return minCost ; } int main ( ) { vector < pair < int , int > > arr = { { 1 , 2 } , { 2 , 4 } , { 4 , 8 } } ; cout << ( minimumCostReqToCompthePrcess ( arr ) ) ; }

Index/key variables: i
Accumulator variables: i, minCost, minCostInit, stdc
Iterator variables: i