dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minEdgeBFS ( vector < int > edges [ ] , int u , int v , int n ) { vector < bool > visited ( n , 0 ) ; vector < int > distance ( n , 0 ) ; queue < int > Q ; distance [ u ] = 0 ; Q . push ( u ) ; visited [ u ] = true ; while ( ! Q . empty ( ) ) { int x = Q . front ( ) ; Q . pop ( ) ; for ( int i = 0 ; i < edges [ x ] . size ( ) ; i ++ ) { if ( visited [ edges [ x ] [ i ] ] ) continue ; distance [ edges [ x ] [ i ] ] = distance [ x ] + 1 ; Q . push ( edges [ x ] [ i ] ) ; visited [ edges [ x ] [ i ] ] = 1 ; } } return distance [ v ] ; } void addEdge ( vector < int > edges [ ] , int u , int v ) { edges [ u ] . push_back ( v ) ; edges [ v ] . push_back ( u ) ; } int main ( ) { int n = 9 ; vector < int > edges [ 9 ] ; addEdge ( edges , 0 , 1 ) ; addEdge ( edges , 0 , 7 ) ; addEdge ( edges , 1 , 7 ) ; addEdge ( edges , 1 , 2 ) ; addEdge ( edges , 2 , 3 ) ; addEdge ( edges , 2 , 5 ) ; addEdge ( edges , 2 , 8 ) ; addEdge ( edges , 3 , 4 ) ; addEdge ( edges , 3 , 5 ) ; addEdge ( edges , 4 , 5 ) ; addEdge ( edges , 5 , 6 ) ; addEdge ( edges , 6 , 7 ) ; addEdge ( edges , 7 , 8 ) ; int u = 0 ; int v = 5 ; cout << minEdgeBFS ( edges , u , v , n ) ; return 0 ; }

Index/key variables: i, u, v, x
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinimumSwaps ( int * arr , int n , int k ) { int pos , num_min , num_max , need_minimum , need_maximum , swaps ; num_min = num_max = need_minimum = 0 ; need_maximum = swaps = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < k ) num_min ++ ; else if ( arr [ i ] > k ) num_max ++ ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == k ) { pos = i ; break ; } } int left , right , mid ; left = 0 ; right = n - 1 ; while ( left <= right ) { mid = ( left + right ) / 2 ; if ( arr [ mid ] == k ) { break ; } else if ( arr [ mid ] > k ) { if ( pos > mid ) need_minimum ++ ; else num_min -- ; left = mid + 1 ; } else { if ( pos < mid ) need_maximum ++ ; else num_max -- ; right = mid - 1 ; } } if ( need_minimum > need_maximum ) { swaps = swaps + need_maximum ; num_min = num_min - need_maximum ; need_minimum = need_minimum - need_maximum ; need_maximum = 0 ; } else { swaps = swaps + need_minimum ; num_max = num_max - need_minimum ; need_maximum = need_maximum - need_minimum ; need_minimum = 0 ; } if ( need_maximum > num_max need_minimum > num_min ) return -1 ; else return ( swaps + need_maximum + need_minimum ) ; } int main ( ) { int arr [ ] = { 3 , 10 , 6 , 7 , 2 , 5 , 4 } , k = 4 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMinimumSwaps ( arr , n , k ) ; }

Index/key variables: i, mid
Accumulator variables: i, need_maximum, need_minimum, num_max, num_min, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { int arr [ ] = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; stable_sort ( arr , arr + n , greater < int > ( ) ) ; cout << " Array ▁ after ▁ sorting ▁ : ▁ STRNEWLINE " ; for ( int i = 0 ; i < n ; ++ i ) cout << arr [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std ; bool function ( char str [ ] ) { int l = strlen ( str ) ; sort ( str , str + ( l / 2 ) ) ; sort ( str + ( l / 2 ) , str + l ) ; for ( int i = 0 ; i < l / 2 ; i ++ ) if ( str [ i ] != str [ l / 2 + i ] ) return true ; return false ; } int main ( ) { char str [ ] = " abcasdsabcae " ; if ( function ( str ) ) cout << " Yes , ▁ both ▁ halves ▁ differ ▁ by " << " ▁ at ▁ least ▁ one ▁ character " ; else cout << " No , ▁ both ▁ halves ▁ do " << " ▁ not ▁ differ ▁ at ▁ all " ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumBox ( int arr [ ] , int n ) { queue < int > q ; queue < int > q ; sort ( arr , arr + n ) ; q . push ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { int now = q . front ( ) ; if ( arr [ i ] >= 2 * now ) q . pop ( ) ; q . push ( arr [ i ] ) ; } return q . size ( ) ; } int main ( ) { int arr [ ] = { 4 , 1 , 2 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumBox ( arr , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void sortBinaryArray ( int a [ ] , int n ) { int j = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < 1 ) { j ++ ; swap ( a [ i ] , a [ j ] ) ; } } } int main ( ) { int a [ ] = { 1 , 0 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 0 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; sortBinaryArray ( a , n ) ; for ( int i = 0 ; i < n ; i ++ ) cout << a [ i ] << " ▁ " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 1000 ; int function findDuplicate ( $ arr , $ n , $ k ) { int res = MAX + 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) { int count = 1 ; for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] == arr [ j ] ) count += 1 ; if ( count == k ) res = min ( res , arr [ i ] ) ; } } return res ; } int main ( ) { int arr [ ] = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; int n = sizeof ( arr ) / ( sizeof ( arr [ 0 ] ) ) ; cout << findDuplicate ( arr , n , 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 ; int findDuplicate ( int arr [ ] , int n , int k ) { sort ( arr , arr + n ) ; int i = 0 ; while ( i < n ) { int j , count = 1 ; for ( j = i + 1 ; j < n && arr [ j ] == arr [ i ] ; j ++ ) count ++ ; if ( count == k ) return arr [ i ] ; i = j ; } return -1 ; } int main ( ) { int arr [ ] = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; int n = sizeof ( arr ) / ( sizeof ( arr [ 0 ] ) ) ; cout << findDuplicate ( arr , n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, j, stdc
Iterator variables: j
C++ program:
#include <iostream>
#include <algorithm>
using namespace std ; string longestCommonPrefix ( string ar [ ] , int n ) { if ( n == 0 ) return " " ; if ( n == 1 ) return ar [ 0 ] ; sort ( ar , ar + n ) ; int en = min ( ar [ 0 ] . size ( ) , ar [ n - 1 ] . size ( ) ) ; string first = ar [ 0 ] , last = ar [ n - 1 ] ; int i = 0 ; while ( i < en && first [ i ] == last [ i ] ) i ++ ; string pre = first . substr ( 0 , i ) ; return pre ; } int main ( ) { string ar [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = sizeof ( ar ) / sizeof ( ar [ 0 ] ) ; cout << " The ▁ longest ▁ common ▁ prefix ▁ is : ▁ " << longestCommonPrefix ( ar , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find ( vector < int > arr , int n , int k ) { sort ( arr . begin ( ) , arr . end ( ) ) ; int b = ceil ( n / k * 1.0 ) ; int min_sum = 0 , max_sum = 0 ; for ( int i = 0 ; i < b ; i ++ ) min_sum += arr [ i ] ; for ( int i = 2 ; i < arr . size ( ) ; i ++ ) max_sum += arr [ i ] ; cout << " minimum ▁ " << min_sum << endl ; cout << " maximum ▁ " << max_sum << endl ; } int main ( ) { vector < int > arr = { 3 , 2 , 1 , 4 } ; int n = arr . size ( ) ; int k = 2 ; find ( arr , n , k ) ; }

Index/key variables: i
Accumulator variables: i, max_sum, min_sum, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkForSorting ( int arr [ ] , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { if ( arr [ i ] - arr [ i + 1 ] == 1 ) swap ( arr [ i ] , arr [ i + 1 ] ) ; else return false ; } } return true ; } int main ( ) { int arr [ ] = { 1 , 0 , 3 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( checkForSorting ( arr , n ) ) cout << " Yes " ; else cout << " No " ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void printArraystring ( string , int ) ; void sort ( string s [ ] , int n ) { for ( int i = 1 ; i < n ; i ++ ) { string temp = s [ i ] ; int j = i - 1 ; while ( j >= 0 && temp . length ( ) < s [ j ] . length ( ) ) { s [ j + 1 ] = s [ j ] ; j -- ; } s [ j + 1 ] = temp ; } } void printArraystring ( string str [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << str [ i ] << " ▁ " ; } int main ( ) { string arr [ ] = { " GeeksforGeeks " , " I " , " from " , " am " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sort ( arr , n ) ; printArraystring ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int partition ( int arr [ ] , int low , int high ) { int pivot = arr [ low ] ; int i = low - 1 , j = high + 1 ; while ( true ) { do { i ++ ; } while ( arr [ i ] < pivot ) ; do { j -- ; } while ( arr [ j ] > pivot ) ; if ( i >= j ) return j ; swap ( arr [ i ] , arr [ j ] ) ; } } void quickSort ( int arr [ ] , int low , int high ) { if ( low < high ) { int pi = partition ( arr , low , high ) ; quickSort ( arr , low , pi ) ; quickSort ( arr , pi + 1 , high ) ; } } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) printf ( " % d ▁ " , arr [ i ] ) ; printf ( " STRNEWLINE " ) ; } int main ( ) { int arr [ ] = { 10 , 7 , 8 , 9 , 1 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; quickSort ( arr , 0 , n - 1 ) ; printf ( " Sorted ▁ array : ▁ STRNEWLINE " ) ; printArray ( arr , n ) ; return 0 ; }

Index/key variables: i, j, low
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int ksmallest ( int arr [ ] , int n , int k ) { sort ( arr , arr + n ) ; if ( k < arr [ 0 ] ) return k ; if ( k == arr [ 0 ] ) return arr [ 0 ] + 1 ; if ( k > arr [ n - 1 ] ) return k + n ; if ( arr [ 0 ] == 1 ) k -- ; else k -= ( arr [ 0 ] - 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { int c = arr [ i ] - arr [ i - 1 ] - 1 ; if ( k <= c ) return arr [ i - 1 ] + k ; else k -= c ; } return arr [ n - 1 ] + k ; } int main ( ) { int k = 1 ; int arr [ ] = { 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ksmallest ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int bfsWithDistance ( vector < int > g [ ] , bool mark [ ] , int u , vector < int > & dis ) { int lastMarked ; queue < int > q ; q . push ( u ) ; dis [ u ] = 0 ; while ( ! q . empty ( ) ) { u = q . front ( ) ; q . pop ( ) ; if ( mark [ u ] ) lastMarked = u ; for ( int i = 0 ; i < g [ u ] . size ( ) ; i ++ ) { int v = g [ u ] [ i ] ; if ( dis [ v ] == -1 ) { dis [ v ] = dis [ u ] + 1 ; q . push ( v ) ; } } } return lastMarked ; } int nodesKDistanceFromMarked ( int edges [ ] [ 2 ] , int V , int marked [ ] , int N , int K ) { V = V + 1 ; vector < int > g [ V ] ; int u , v ; for ( int i = 0 ; i < ( V - 1 ) ; i ++ ) { u = edges [ i ] [ 0 ] ; v = edges [ i ] [ 1 ] ; g [ u ] . push_back ( v ) ; g [ v ] . push_back ( u ) ; } bool mark [ V ] = { false } ; for ( int i = 0 ; i < N ; i ++ ) mark [ marked [ i ] ] = true ; vector < int > tmp ( V , -1 ) , dl ( V , -1 ) , dr ( V , -1 ) ; u = bfsWithDistance ( g , mark , 0 , tmp ) ; v = bfsWithDistance ( g , mark , u , dl ) ; bfsWithDistance ( g , mark , v , dr ) ; int res = 0 ; for ( int i = 0 ; i < V ; i ++ ) { if ( dl [ i ] <= K && dr [ i ] <= K ) res ++ ; } return res ; } int main ( ) { int edges [ ] [ 2 ] = { { 1 , 0 } , { 0 , 3 } , { 0 , 8 } , { 2 , 3 } , { 3 , 5 } , { 3 , 6 } , { 3 , 7 } , { 4 , 5 } , { 5 , 9 } } ; int V = sizeof ( edges ) / sizeof ( edges [ 0 ] ) ; int marked [ ] = { 1 , 2 , 4 } ; int N = sizeof ( marked ) / sizeof ( marked [ 0 ] ) ; int K = 3 ; cout << nodesKDistanceFromMarked ( edges , V , marked , N , K ) ; return 0 ; }

Index/key variables: V, i, u, v
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSubsequenceCount ( string S , string T ) { int m = T . length ( ) , n = S . length ( ) ; if ( m > n ) return 0 ; int mat [ m + 1 ] [ n + 1 ] ; for ( int i = 1 ; i <= m ; i ++ ) mat [ i ] [ 0 ] = 0 ; for ( int j = 0 ; j <= n ; j ++ ) mat [ 0 ] [ j ] = 1 ; for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( T [ i - 1 ] != S [ j - 1 ] ) mat [ i ] [ j ] = mat [ i ] [ j - 1 ] ; else mat [ i ] [ j ] = mat [ i ] [ j - 1 ] + mat [ i - 1 ] [ j - 1 ] ; } } return mat [ m ] [ n ] ; } int main ( ) { string T = " ge " ; string S = " geeksforgeeks " ; cout << findSubsequenceCount ( S , T ) << endl ; return 0 ; }

Index/key variables: i, j, m, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void partition ( int a [ ] , int l , int r , int & i , int & j ) { i = l - 1 , j = r ; int p = l - 1 , q = r ; int v = a [ r ] ; while ( true ) { while ( a [ ++ i ] < v ) ; while ( v < a [ -- j ] ) if ( j == l ) break ; if ( i >= j ) break ; swap ( a [ i ] , a [ j ] ) ; if ( a [ i ] == v ) { p ++ ; swap ( a [ p ] , a [ i ] ) ; } if ( a [ j ] == v ) { q -- ; swap ( a [ j ] , a [ q ] ) ; } } swap ( a [ i ] , a [ r ] ) ; j = i - 1 ; for ( int k = l ; k < p ; k ++ , j -- ) swap ( a [ k ] , a [ j ] ) ; i = i + 1 ; for ( int k = r - 1 ; k > q ; k -- , i ++ ) swap ( a [ i ] , a [ k ] ) ; } void quicksort ( int a [ ] , int l , int r ) { if ( r <= l ) return ; int i , j ; partition ( a , l , r , i , j ) ; quicksort ( a , l , j ) ; quicksort ( a , i , r ) ; } void printarr ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) printf ( " % d ▁ " , a [ i ] ) ; printf ( " STRNEWLINE " ) ; } int main ( ) { int a [ ] = { 4 , 9 , 4 , 4 , 1 , 9 , 4 , 4 , 9 , 4 , 4 , 1 , 4 } ; int size = sizeof ( a ) / sizeof ( int ) ; printarr ( a , size ) ; quicksort ( a , 0 , size - 1 ) ; printarr ( a , size ) ; return 0 ; }

Index/key variables: i, j, k, p, q, r
Accumulator variables: i, j, k, p, q, stdc
Iterator variables: i, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void swap ( int * a , int * b ) { int temp = * a ; * a = * b ; * b = temp ; } void printarr ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) printf ( " % d ▁ " , a [ i ] ) ; printf ( " STRNEWLINE " ) ; } void partition ( int a [ ] , int low , int high , int & i , int & j ) { if ( high - low <= 1 ) { if ( a [ high ] < a [ low ] ) swap ( & a [ high ] , & a [ low ] ) ; i = low ; j = high ; return ; } int mid = low ; int pivot = a [ high ] ; while ( mid <= high ) { if ( a [ mid ] < pivot ) swap ( & a [ low ++ ] , & a [ mid ++ ] ) ; else if ( a [ mid ] == pivot ) mid ++ ; else if ( a [ mid ] > pivot ) swap ( & a [ mid ] , & a [ high -- ] ) ; } i = low - 1 ; } void quicksort ( int a [ ] , int low , int high ) { return ; int i , j ; partition ( a , low , high , i , j ) ; quicksort ( a , low , i ) ; quicksort ( a , j , high ) ; } int main ( ) { int a [ ] = { 4 , 9 , 4 , 4 , 1 , 9 , 4 , 4 , 9 , 4 , 4 , 1 , 4 } ; int size = sizeof ( a ) / sizeof ( int ) ; printarr ( a , size ) ; quicksort ( a , 0 , size - 1 ) ; printarr ( a , size ) ; return 0 ; }

Index/key variables: high, i, low, mid
Accumulator variables: high, low, mid, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkRBS ( vector < string > S ) { int N = S . size ( ) ; vector < pair < int , int > > v ( N ) ; for ( int i = 0 ; i < N ; ++ i ) { string s = S [ i ] ; int sum = 0 ; int pre = 0 ; for ( char c : s ) { if ( c == ' ( ' ) { ++ sum ; } else { -- sum ; } pre = min ( sum , pre ) ; } v [ i ] = { sum , pre } ; } vector < pair < int , int > > pos ; vector < pair < int , int > > neg ; for ( int i = 0 ; i < N ; ++ i ) { if ( v [ i ] . first >= 0 ) { pos . push_back ( { - v [ i ] . second , v [ i ] . first } ) ; } else { neg . push_back ( { v [ i ] . first - v [ i ] . second , - v [ i ] . first } ) ; } } sort ( pos . begin ( ) , pos . end ( ) ) ; int open = 0 ; for ( auto p : pos ) { if ( open - p . first >= 0 ) { open += p . second ; } else { cout << " No " << " STRNEWLINE " ; return 0 ; } } sort ( neg . begin ( ) , neg . end ( ) ) ; int negative = 0 ; for ( auto p : neg ) { if ( negative - p . first >= 0 ) { negative += p . second ; } else { cout << " No STRNEWLINE " ; return 0 ; } } if ( open != negative ) { cout << " No STRNEWLINE " ; return 0 ; } cout << " Yes STRNEWLINE " ; return 0 ; } int main ( ) { vector < string > arr = { " ) " , " ( ) ( " } ; checkRBS ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: negative, open, stdc
Iterator variables: c, i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumUniqueSquares ( int N ) { int ans = 0 ; if ( N < 4 ) { return 0 ; } int len = ( sqrt ( double ( N ) ) ) ; N -= len * len ; for ( int i = 1 ; i < len ; i ++ ) { ans += i * i ; } if ( N >= len ) { N -= len ; for ( int i = 1 ; i < len ; i ++ ) { ans += i ; } } for ( int i = 1 ; i < N ; i ++ ) { ans += i ; } return ans ; } int main ( ) { int N = 9 ; cout << maximumUniqueSquares ( N ) ; return 0 ; }

Accumulator variables: N, ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPermutation ( int K , vector < int > arr ) { vector < int > missing ; vector < bool > visited ( K + 1 , 0 ) ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { visited [ arr [ i ] ] = 1 ; } for ( int i = 1 ; i <= K ; i ++ ) { if ( ! visited [ i ] ) { missing . push_back ( i ) ; } } arr . push_back ( INT_MAX ) ; missing . push_back ( INT_MAX ) ; int p1 = 0 ; int p2 = 0 ; vector < int > ans ; while ( ans . size ( ) < K ) { if ( arr [ p1 ] < missing [ p2 ] ) { ans . push_back ( arr [ p1 ] ) ; p1 ++ ; } else { ans . push_back ( missing [ p2 ] ) ; p2 ++ ; } } for ( int i = 0 ; i < K ; i ++ ) { cout << ans [ i ] << " ▁ " ; } } int main ( ) { int K = 7 ; vector < int > arr = { 6 , 4 , 2 , 1 } ; findPermutation ( K , arr ) ; return 0 ; }

Index/key variables: i, p1, p2
Accumulator variables: i, p1, p2, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findRemainingIndex ( int N ) { int ans = N ; while ( N > 1 ) { int discard = int ( sqrt ( N ) ) ; if ( discard * discard == N ) { ans -- ; } N -= discard ; } return ans ; } void findRemainingElement ( int arr [ ] , int N ) { int remainingIndex = findRemainingIndex ( N ) ; cout << arr [ remainingIndex - 1 ] ; } signed main ( ) { int arr [ ] = { 2 , 3 , 4 , 4 , 2 , 4 , -3 , 1 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findRemainingElement ( arr , N ) ; return 0 ; }

Accumulator variables: N, ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minEdge ( vector < vector < int > > X , int N , int M , int T , int C ) { queue < pair < int , int > > Q ; Q . push ( { 1 , 0 } ) ; vector < int > V ( N + 1 , false ) ; int crnt , c ; while ( 1 ) { crnt = Q . front ( ) . first ; c = Q . front ( ) . second ; Q . pop ( ) ; if ( crnt == N ) break ; for ( int _ : X [ crnt ] ) { if ( ! V [ _ ] ) { Q . push ( { _ , c + 1 } ) ; V [ _ ] = true ; } } } return c ; } int findTime ( int T , int C , int c ) { int ans = 0 ; for ( int _ = 0 ; _ < c ; _ ++ ) { if ( ( ans / T ) % 2 ) ans = ( ans / T + 1 ) * T + C ; else ans += C ; } return ans ; } int main ( ) { int N = 5 ; int M = 5 ; int T = 3 ; int C = 5 ; vector < vector < int > > X { { } , { 2 , 3 , 4 } , { 4 , 5 } , { 1 } , { 1 , 2 } , { 2 } } ; int c = minEdge ( X , N , M , T , C ) ; int ans = findTime ( T , C , c ) ; cout << ( ans ) << endl ; return 0 ; }

Index/key variables: _, crnt
Accumulator variables: _, ans, stdc
Iterator variables: _
C++ program:
#include <bits/stdc++.h>
using namespace std ; string largestMerge ( string s1 , string s2 ) { if ( s1 . size ( ) == 0 || s2 . size ( ) == 0 ) return s1 + s2 ; if ( s1 > s2 ) { return s1 [ 0 ] + largestMerge ( s1 . substr ( 1 ) , s2 ) ; } return s2 [ 0 ] + largestMerge ( s1 , s2 . substr ( 1 ) ) ; } int main ( ) { string s1 = " geeks " ; string s2 = " forgeeks " ; cout << largestMerge ( s1 , s2 ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOpenDoors ( int N ) { int doorsOpen = sqrt ( N ) ; return doorsOpen ; } int main ( ) { int N = 100 ; cout << countOpenDoors ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countCandies ( int arr [ ] , int n ) { int sum = 0 ; int ans [ n ] ; if ( n == 1 ) { return 1 ; } for ( int i = 0 ; i < n ; i ++ ) ans [ i ] = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i + 1 ] > arr [ i ] && ans [ i + 1 ] <= ans [ i ] ) { ans [ i + 1 ] = ans [ i ] + 1 ; } } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > arr [ i + 1 ] && ans [ i ] <= ans [ i + 1 ] ) { ans [ i ] = ans [ i + 1 ] + 1 ; } else if ( arr [ i ] == arr [ i + 1 ] && ans [ i ] < ans [ i + 1 ] ) { ans [ i ] = ans [ i + 1 ] + 1 ; } sum += ans [ i ] ; } sum += ans [ n - 1 ] ; return sum ; } int main ( ) { int arr [ ] = { 1 , 0 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countCandies ( arr , N ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMaximumProfit ( int arr [ ] , int M , int N ) { priority_queue < int > max_heap ; int maxProfit = 0 ; for ( int i = 0 ; i < N ; i ++ ) max_heap . push ( arr [ i ] ) ; while ( M > 0 ) { M -- ; int X = max_heap . top ( ) ; max_heap . pop ( ) ; maxProfit += X ; max_heap . push ( X - 1 ) ; } cout << maxProfit ; } int main ( ) { int arr [ ] = { 4 , 6 } ; int M = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMaximumProfit ( arr , M , N ) ; }

Index/key variables: i
Accumulator variables: M, i, maxProfit, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSequence ( int n , int k ) { int arr [ n ] ; int sumPos = 0 , sumNeg = 0 ; for ( int i = 0 ; i < n - k ; i ++ ) { arr [ i ] = - ( i + 1 ) ; sumNeg += arr [ i ] ; } for ( int i = n - k ; i < n ; i ++ ) { arr [ i ] = i + 1 ; sumPos += arr [ i ] ; } if ( abs ( sumNeg ) >= sumPos ) { cout << -1 ; return ; } for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } int main ( ) { int N = 10 , K = 6 ; findSequence ( N , K ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc, sumNeg, sumPos
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPath ( vector < vector < int > > & arr , int M , int N ) { for ( int row = 0 ; row < M ; row ++ ) { char dir = ' L ' ; int i = row ; int j = 0 ; while ( j < N ) { if ( arr [ i ] [ j ] == 1 ) { if ( dir == ' L ' ) { i -- ; dir = ' D ' ; } else if ( dir == ' U ' ) { j -- ; dir = ' R ' ; } else if ( dir == ' R ' ) { i ++ ; dir = ' U ' ; } else if ( dir == ' D ' ) { j ++ ; dir = ' L ' ; } } else { if ( dir == ' L ' ) { i ++ ; dir = ' U ' ; } else if ( dir == ' U ' ) { j ++ ; dir = ' L ' ; } else if ( dir == ' R ' ) { i -- ; dir = ' D ' ; } else if ( dir == ' D ' ) { j -- ; dir = ' R ' ; } } if ( i < 0 i == M j < 0 j == N ) break ; } if ( j == N ) cout << i << " ▁ " ; else cout << -1 << " ▁ " ; } } int main ( ) { vector < vector < int > > arr = { { 1 , 1 , 0 , 1 } , { 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 0 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 } } ; int M = arr . size ( ) ; int N = arr [ 0 ] . size ( ) ; findPath ( arr , M , N ) ; }

Index/key variables: i, j
Accumulator variables: i, j, row, stdc
Iterator variables: row