dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int final_element ( int arr [ ] , int n ) { priority_queue < int > heap ; for ( int i = 0 ; i < n ; i ++ ) heap . push ( arr [ i ] ) ; while ( heap . size ( ) > 1 ) { int X = heap . top ( ) ; heap . pop ( ) ; int Y = heap . top ( ) ; heap . pop ( ) ; if ( X != Y ) { int diff = abs ( X - Y ) ; heap . push ( diff ) ; } } if ( heap . size ( ) == 1 ) { cout << heap . top ( ) ; } else { cout << " - 1" ; } } int main ( ) { int arr [ ] = { 3 , 5 , 2 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; final_element ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countFrequency ( string str , char ch ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) if ( str [ i ] == ch ) ++ count ; return count ; } void sortArr ( string str ) { int n = str . length ( ) ; vector < pair < int , char > > vp ; for ( int i = 0 ; i < n ; i ++ ) { vp . push_back ( make_pair ( countFrequency ( str , str [ i ] ) , str [ i ] ) ) ; } sort ( vp . begin ( ) , vp . end ( ) ) ; for ( int i = 0 ; i < vp . size ( ) ; i ++ ) cout << vp [ i ] . second ; } int main ( ) { string str = " geeksforgeeks " ; sortArr ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSumArrangement ( int A [ ] , int R [ ] [ 2 ] , int N , int M ) { int count [ N ] ; memset ( count , 0 , sizeof count ) ; for ( int i = 0 ; i < M ; ++ i ) { int l = R [ i ] [ 0 ] , r = R [ i ] [ 1 ] + 1 ; l -- ; r -- ; count [ l ] ++ ; if ( r < N ) count [ r ] -- ; } for ( int i = 1 ; i < N ; ++ i ) { count [ i ] += count [ i - 1 ] ; } for ( int i = 0 ; i < N ; ++ i ) { cout << count [ i ] ; } int ans = 0 ; sort ( count , count + N ) ; sort ( A , A + N ) ; for ( int i = 0 ; i < N ; ++ i ) { cout << endl << A [ i ] ; } for ( int i = N - 1 ; i >= 0 ; -- i ) { ans += A [ i ] * count [ i ] ; } return ans ; } int main ( ) { int A [ ] = { 2 , 6 , 10 , 1 , 5 , 6 } ; int R [ ] [ 2 ] = { { 1 , 3 } , { 4 , 6 } , { 3 , 4 } } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int M = sizeof ( R ) / sizeof ( R [ 0 ] ) ; cout << maxSumArrangement ( A , R , N , M ) ; return 0 ; }

Index/key variables: N, i, l, r
Accumulator variables: ans, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > findFactors ( int n , int k ) { vector < int > factors ; for ( int i = 1 ; i <= sqrt ( k ) ; i ++ ) { if ( k % i == 0 ) { if ( k / i == i && i <= n ) factors . push_back ( i ) ; else { if ( i <= n ) factors . push_back ( i ) ; if ( k / i <= n ) factors . push_back ( k / i ) ; } } } return factors ; } vector < int > findDigitSum ( vector < int > a ) { for ( int i = 0 ; i < a . size ( ) ; i ++ ) { int c = 0 ; while ( a [ i ] > 0 ) { c += a [ i ] % 10 ; a [ i ] = a [ i ] / 10 ; } a [ i ] = c ; } return a ; } int findMMaxDistinctDigitSum ( vector < int > distinctDigitSum , int m ) { int sum = 0 ; for ( int i = distinctDigitSum . size ( ) - 1 ; i >= 0 && m > 0 ; i -- , m -- ) sum += distinctDigitSum [ i ] ; return sum ; } int findDistinctMnumbers ( int n , int k , int m ) { vector < int > factors = findFactors ( n , k ) ; vector < int > digitSum = findDigitSum ( factors ) ; sort ( digitSum . begin ( ) , digitSum . end ( ) ) ; vector < int > :: iterator ip ; ip = unique ( digitSum . begin ( ) , digitSum . end ( ) ) ; digitSum . resize ( distance ( digitSum . begin ( ) , ip ) ) ; return findMMaxDistinctDigitSum ( digitSum , m ) ; } int main ( ) { int n = 100 , k = 80 , m = 4 ; cout << findDistinctMnumbers ( n , k , m ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: c, i, m, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int partition ( vector < string > & objects , int l , int r , unordered_map < string , int > & hash ) { int j = l - 1 ; int last_element = hash [ objects [ r ] ] ; for ( int i = l ; i < r ; i ++ ) { if ( hash [ objects [ i ] ] <= last_element ) { j ++ ; swap ( objects [ i ] , objects [ j ] ) ; } } j ++ ; swap ( objects [ j ] , objects [ r ] ) ; return j ; } void quicksort ( vector < string > & objects , int l , int r , unordered_map < string , int > & hash ) { if ( l < r ) { int mid = partition ( objects , l , r , hash ) ; quicksort ( objects , l , mid - 1 , hash ) ; quicksort ( objects , mid + 1 , r , hash ) ; } } void sortObj ( vector < string > & objects ) { unordered_map < string , int > hash ; hash [ " blue " ] = 1 ; hash [ " red " ] = 2 ; hash [ " yellow " ] = 3 ; quicksort ( objects , 0 , int ( objects . size ( ) - 1 ) , hash ) ; for ( int i = 0 ; i < objects . size ( ) ; i ++ ) cout << objects [ i ] << " ▁ " ; } int main ( ) { vector < string > objects { " red " , " blue " , " red " , " yellow " , " blue " } ; sortObj ( objects ) ; return 0 ; }

Index/key variables: i, j, r
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int productOfDigit ( int n ) { int product = 1 ; while ( n > 0 ) { product *= n % 10 ; n = n / 10 ; } return product ; } void sortArr ( int arr [ ] , int n ) { vector < pair < int , int > > vp ; for ( int i = 0 ; i < n ; i ++ ) { vp . push_back ( make_pair ( productOfDigit ( arr [ i ] ) , arr [ i ] ) ) ; } sort ( vp . begin ( ) , vp . end ( ) ) ; for ( int i = 0 ; i < vp . size ( ) ; i ++ ) cout << vp [ i ] . second << " ▁ " ; } int main ( ) { int arr [ ] = { 12 , 10 , 102 , 31 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sortArr ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, product, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSteps ( int arr [ ] , int n ) { int maxVal = * max_element ( arr , arr + n ) ; return maxVal ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << minSteps ( arr , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxWater ( int height [ ] , int n ) { int maximum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int current = ( min ( height [ i ] , height [ j ] ) * ( j - i - 1 ) ) ; maximum = max ( maximum , current ) ; } } return maximum ; } int main ( ) { int height [ ] = { 2 , 1 , 3 , 4 , 6 , 5 } ; int n = sizeof ( height ) / sizeof ( height [ 0 ] ) ; cout << maxWater ( height , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool compareTo ( pair < int , int > p1 , pair < int , int > p2 ) { return p1 . second < p2 . second ; } int maxWater ( int height [ ] , int n ) { pair < int , int > pairs [ n ] ; for ( int i = 0 ; i < n ; i ++ ) pairs [ i ] = make_pair ( i , height [ i ] ) ; sort ( pairs , pairs + n , compareTo ) ; int minIndSoFar = pairs [ n - 1 ] . first ; int maxIndSoFar = pairs [ n - 1 ] . first ; int maxi = 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int left = 0 ; if ( minIndSoFar < pairs [ i ] . first ) { left = ( pairs [ i ] . second * ( pairs [ i ] . first - minIndSoFar - 1 ) ) ; } int right = 0 ; if ( maxIndSoFar > pairs [ i ] . first ) { right = ( pairs [ i ] . second * ( maxIndSoFar - pairs [ i ] . first - 1 ) ) ; } maxi = max ( left , max ( right , maxi ) ) ; minIndSoFar = min ( minIndSoFar , pairs [ i ] . first ) ; maxIndSoFar = max ( maxIndSoFar , pairs [ i ] . first ) ; } return maxi ; } int main ( ) { int height [ ] = { 2 , 1 , 3 , 4 , 6 , 5 } ; int n = sizeof ( height ) / sizeof ( height [ 0 ] ) ; cout << maxWater ( height , n ) ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkDivisors ( int a [ ] , int n ) { int X = * max_element ( a , a + n ) ; vector < int > b ; for ( int i = 1 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { b . push_back ( i ) ; if ( X / i != i ) b . push_back ( X / i ) ; } } if ( b . size ( ) != n ) return false ; sort ( a , a + n ) ; sort ( b . begin ( ) , b . end ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( b [ i ] != a [ i ] ) return false ; } return true ; } int main ( ) { int arr [ ] = { 8 , 1 , 2 , 12 , 48 , 6 , 4 , 24 , 16 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( checkDivisors ( arr , N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findKthNode ( int u [ ] , int v [ ] , int n , int val [ ] , int V , int k ) { vector < pair < int , int > > g [ V ] ; for ( int i = 0 ; i < n ; i ++ ) { g [ u [ i ] ] . push_back ( make_pair ( val [ v [ i ] ] , v [ i ] ) ) ; g [ v [ i ] ] . push_back ( make_pair ( val [ u [ i ] ] , u [ i ] ) ) ; } for ( int i = 0 ; i < V ; i ++ ) { if ( g [ i ] . size ( ) > 0 ) sort ( g [ i ] . begin ( ) , g [ i ] . end ( ) ) ; if ( k <= g [ i ] . size ( ) ) printf ( " % d STRNEWLINE " , g [ i ] [ g [ i ] . size ( ) - k ] . second ) ; else printf ( " - 1 STRNEWLINE " ) ; } return ; } int main ( ) { int V = 3 ; int val [ ] = { 2 , 4 , 3 } ; int u [ ] = { 0 , 0 , 1 } ; int v [ ] = { 2 , 1 , 2 } ; int n = sizeof ( u ) / sizeof ( int ) ; int k = 2 ; findKthNode ( u , v , n , val , V , k ) ; return 0 ; }

Index/key variables: V, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mod ( int x ) { if ( x >= 0 ) return x ; return - x ; } void findSquare ( int n ) { int points [ n ] [ 2 ] = { { 1 , 2 } , { -3 , 4 } , { 1 , 78 } , { -3 , -7 } } ; int a [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x , y ; x = points [ i ] [ 0 ] ; y = points [ i ] [ 1 ] ; a [ i ] = max ( mod ( x ) , mod ( y ) ) ; } sort ( a , a + n ) ; int index = floor ( n / 2 ) - 1 ; cout << " Minimum ▁ M ▁ required ▁ is : ▁ " << a [ index ] << endl ; } int main ( ) { int N ; N = 4 ; findSquare ( N ) ; return 0 ; }

Index/key variables: i, index, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findpath ( int graph [ ] [ 5 ] , int n ) { vector < int > numofadj ; for ( int i = 0 ; i < n ; i ++ ) numofadj . push_back ( accumulate ( graph [ i ] , graph [ i ] + 5 , 0 ) ) ; int startpoint = 0 , numofodd = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( numofadj [ i ] % 2 == 1 ) { numofodd ++ ; startpoint = i ; } } if ( numofodd > 2 ) { cout << " No ▁ Solution " << endl ; return ; } stack < int > stack ; vector < int > path ; int cur = startpoint ; while ( ! stack . empty ( ) or accumulate ( graph [ cur ] , graph [ cur ] + 5 , 0 ) != 0 ) { if ( accumulate ( graph [ cur ] , graph [ cur ] + 5 , 0 ) == 0 ) { path . push_back ( cur ) ; cur = stack . top ( ) ; stack . pop ( ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( graph [ cur ] [ i ] == 1 ) { stack . push ( cur ) ; graph [ cur ] [ i ] = 0 ; graph [ i ] [ cur ] = 0 ; cur = i ; break ; } } } } for ( auto ele : path ) cout << ele << " ▁ - > ▁ " ; cout << cur << endl ; } int main ( ) { int graph1 [ ] [ 5 ] = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 0 } , { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 } } ; int n = sizeof ( graph1 ) / sizeof ( graph1 [ 0 ] ) ; findpath ( graph1 , n ) ; int graph2 [ ] [ 5 ] = { { 0 , 1 , 0 , 1 , 1 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 1 } , { 1 , 1 , 1 , 0 , 0 } , { 1 , 0 , 1 , 0 , 0 } } ; n = sizeof ( graph1 ) / sizeof ( graph1 [ 0 ] ) ; findpath ( graph2 , n ) ; int graph3 [ ] [ 5 ] = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 1 } , { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 0 , 1 } , { 1 , 1 , 0 , 1 , 0 } } ; n = sizeof ( graph1 ) / sizeof ( graph1 [ 0 ] ) ; findpath ( graph3 , n ) ; }

Index/key variables: cur, i
Accumulator variables: i, numofodd, stdc
Iterator variables: ele, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minSum ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; int x = arr [ n / 2 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += abs ( arr [ i ] - x ) ; return sum ; } int main ( ) { int arr [ ] = { 1 , 3 , 9 , 3 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minSum ( 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 odd_even ( int arr [ ] , int n ) { vector < int > odd_indexes ; vector < int > even_indexes ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) odd_indexes . push_back ( arr [ i ] ) ; else even_indexes . push_back ( arr [ i ] ) ; } sort ( odd_indexes . begin ( ) , odd_indexes . end ( ) ) ; sort ( even_indexes . begin ( ) , even_indexes . end ( ) ) ; for ( int i = 0 ; i < odd_indexes . size ( ) ; i ++ ) cout << odd_indexes [ i ] << " ▁ " ; for ( int i = 0 ; i < even_indexes . size ( ) ; i ++ ) cout << even_indexes [ i ] << " ▁ " ; } int main ( ) { int arr [ ] = { 3 , 2 , 7 , 6 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; odd_even ( arr , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int a [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) mp [ a [ i ] ] ++ ; sort ( a , a + n , greater < int > ( ) ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp [ a [ i ] ] < 1 ) continue ; int cur = 1 ; while ( cur <= a [ i ] ) cur <<= 1 ; if ( mp [ cur - a [ i ] ] ) { if ( cur - a [ i ] == a [ i ] and mp [ a [ i ] ] == 1 ) continue ; count ++ ; mp [ cur - a [ i ] ] -- ; mp [ a [ i ] ] -- ; } } return count ; } int main ( ) { int a [ ] = { 3 , 11 , 14 , 5 , 13 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << countPairs ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; #define __INSERT_THRESH  5
#define __swap ( x , y )  (t = *(x), *(x) = *(y), *(y) = t)
static void merge ( int * a , size_t an , size_t bn ) { int * b = a + an , * e = b + bn , * s , t ; if ( an == 0 || bn == 0 || ! ( * b < * ( b - 1 ) ) ) return ; if ( an < __INSERT_THRESH && an <= bn ) { for ( int * p = b , * v ; p > a ; for ( v = p , s = p - 1 ; v < e && * v < * s ; s = v , v ++ ) __swap ( s , v ) ; return ; } if ( bn < __INSERT_THRESH ) { for ( int * p = b , * v ; p < e ; for ( s = p , v = p - 1 ; s > a && * s < * v ; s = v , v -- ) __swap ( s , v ) ; return ; } int * pa = a , * pb = b ; for ( s = a ; s < b && pb < e ; s ++ ) if ( * pb < * pa ) pb ++ ; else pa ++ ; pa += b - s ; for ( int * la = pa , * fb = b ; la < b ; la ++ , fb ++ ) __swap ( la , fb ) ; merge ( a , pa - a , pb - b ) ; merge ( b , pb - b , e - pb ) ; #undef __swap #undef __INSERT_THRESH void merge_sort ( int * a , size_t n ) { size_t m = ( n + 1 ) / 2 ; if ( m > 1 ) merge_sort ( a , m ) ; if ( n - m > 1 ) merge_sort ( a + m , n - m ) ; merge ( a , m , n - m ) ; } void print_array ( int a [ ] , size_t n ) { if ( n > 0 ) { cout << " ▁ " << a [ 0 ] ; for ( size_t i = 1 ; i < n ; i ++ ) cout << " ▁ " << a [ i ] ; } cout << " STRNEWLINE " ; } int main ( ) { int a [ ] = { 3 , 16 , 5 , 14 , 8 , 10 , 7 , 15 , 1 , 13 , 4 , 9 , 12 , 11 , 6 , 2 } ; size_t n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; merge_sort ( a , n ) ; print_array ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: fb, i, la, pa, pb, s, v
Iterator variables: i, s, v
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMaxPos ( int arr [ ] , int n ) { unordered_map < int , int > map ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . count ( arr [ i ] ) ) map . insert ( { arr [ i ] , ( map . count ( arr [ i ] ) + 1 ) } ) ; else map . insert ( { arr [ i ] , 1 } ) ; } int max_freq = 0 ; for ( auto i : map ) { if ( max_freq < i . second ) { max_freq = i . second ; } } return n - max_freq ; } int main ( ) { int arr [ ] = { 20 , 30 , 10 , 50 , 40 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ( countMaxPos ( arr , n ) ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void anyPermutation ( int A [ ] , int B [ ] , int n ) { vector < pair < int , int > > Ap , Bp ; for ( int i = 0 ; i < n ; i ++ ) Ap . push_back ( make_pair ( A [ i ] , i ) ) ; for ( int i = 0 ; i < n ; i ++ ) Bp . push_back ( make_pair ( B [ i ] , i ) ) ; sort ( Ap . begin ( ) , Ap . end ( ) ) ; sort ( Bp . begin ( ) , Bp . end ( ) ) ; int i = 0 , j = 0 , ans [ n ] = { 0 } ; vector < int > remain ; while ( i < n && j < n ) { if ( Ap [ i ] . first > Bp [ j ] . first ) { ans [ Bp [ j ] . second ] = Ap [ i ] . first ; i ++ ; j ++ ; } else { remain . push_back ( i ) ; i ++ ; } } j = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( ans [ i ] == 0 ) { ans [ i ] = Ap [ remain [ j ] ] . first ; j ++ ; } for ( int i = 0 ; i < n ; ++ i ) cout << ans [ i ] << " ▁ " ; } int main ( ) { int A [ ] = { 12 , 24 , 8 , 32 } ; int B [ ] = { 13 , 25 , 32 , 11 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; anyPermutation ( A , B , n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sortMultiples ( int arr [ ] , int n , int x ) { vector < int > v ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % x == 0 ) v . push_back ( arr [ i ] ) ; sort ( v . begin ( ) , v . end ( ) ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % x == 0 ) arr [ i ] = v [ j ++ ] ; } } int main ( ) { int arr [ ] = { 125 , 3 , 15 , 6 , 100 , 5 } ; int x = 5 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sortMultiples ( arr , n , x ) ; for ( int i = 0 ; i < n ; i ++ ) { cout << arr [ i ] << " ▁ " ; } return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumIncrease ( int a , int b , int c ) { int arr [ ] = { a , b , c } ; sort ( arr , arr + 3 ) ; if ( arr [ 0 ] + arr [ 1 ] >= arr [ 2 ] ) return 0 ; else return arr [ 2 ] - ( arr [ 0 ] + arr [ 1 ] ) ; } int main ( ) { int a = 3 , b = 5 , c = 10 ; cout << minimumIncrease ( a , b , c ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int absSumDidd ( int a [ ] , int n ) { sort ( a , a + n ) ; int midValue = a [ ( int ) ( n / 2 ) ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + abs ( a [ i ] - midValue ) ; } return sum ; } int main ( ) { int arr [ ] = { 5 , 11 , 14 , 10 , 17 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << absSumDidd ( arr , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void printRLE ( string s ) { for ( int i = 0 ; s [ i ] != ' \0' ; i ++ ) { int count = 1 ; while ( s [ i ] == s [ i + 1 ] ) { i ++ ; count ++ ; } cout << s [ i ] << count << " ▁ " ; } cout << endl ; } int main ( ) { printRLE ( " GeeeEEKKKss " ) ; printRLE ( " ccccOddEEE " ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int shortestChainLen ( string start , string target , set < string > & D ) { if ( start == target ) return 0 ; if ( D . find ( target ) == D . end ( ) ) return 0 ; int level = 0 , wordlength = start . size ( ) ; queue < string > Q ; Q . push ( start ) ; while ( ! Q . empty ( ) ) { ++ level ; int sizeofQ = Q . size ( ) ; for ( int i = 0 ; i < sizeofQ ; ++ i ) { string word = Q . front ( ) ; Q . pop ( ) ; for ( int pos = 0 ; pos < wordlength ; ++ pos ) { char orig_char = word [ pos ] ; for ( char c = ' a ' ; c <= ' z ' ; ++ c ) { word [ pos ] = c ; if ( word == target ) return level + 1 ; if ( D . find ( word ) == D . end ( ) ) continue ; D . erase ( word ) ; Q . push ( word ) ; } word [ pos ] = orig_char ; } } } return 0 ; } int main ( ) { set < string > D ; D . insert ( " poon " ) ; D . insert ( " plee " ) ; D . insert ( " same " ) ; D . insert ( " poie " ) ; D . insert ( " plie " ) ; D . insert ( " poin " ) ; D . insert ( " plea " ) ; string start = " toon " ; string target = " plea " ; cout << " Length ▁ of ▁ shortest ▁ chain ▁ is : ▁ " << shortestChainLen ( start , target , D ) ; return 0 ; }

Index/key variables: pos
Accumulator variables: stdc
Iterator variables: c, i, pos
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define nl  "
" class Node { public : int data ; Node * left ; Node * right ; Node ( int value ) { data = value ; } } ; void inorder ( Node * temp ) { if ( temp == NULL ) return ; inorder ( temp -> left ) ; cout << temp -> data << " ▁ " ; inorder ( temp -> right ) ; } void reverseTreePathUtil ( Node * root , vector < Node * > path , int pathLen , int key ) { if ( root == NULL ) return ; path [ pathLen ] = root ; pathLen ++ ; if ( root -> data == key ) { int i = 0 , j = pathLen - 1 ; while ( i < j ) { int temp = path [ i ] -> data ; path [ i ] -> data = path [ j ] -> data ; path [ j ] -> data = temp ; i ++ ; j -- ; } } if ( ! root -> left and ! root -> right ) return ; reverseTreePathUtil ( root -> left , path , pathLen , key ) ; reverseTreePathUtil ( root -> right , path , pathLen , key ) ; } void reverseTreePath ( Node * root , int key ) { if ( root == NULL ) return ; vector < Node * > path ( 50 , NULL ) ; reverseTreePathUtil ( root , path , 0 , key ) ; } int main ( ) { Node * root = new Node ( 7 ) ; root -> left = new Node ( 6 ) ; root -> right = new Node ( 5 ) ; root -> left -> left = new Node ( 4 ) ; root -> left -> right = new Node ( 3 ) ; root -> right -> left = new Node ( 2 ) ; root -> right -> right = new Node ( 1 ) ; int key = 4 ; reverseTreePath ( root , key ) ; inorder ( root ) ; return 0 ; }

Index/key variables: i, j, pathLen
Accumulator variables: i, j, pathLen, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define M  26
void dfs ( vector < int > g [ ] , int u , vector < bool > & visit ) { visit [ u ] = true ; for ( int i = 0 ; i < g [ u ] . size ( ) ; ++ i ) if ( ! visit [ g [ u ] [ i ] ] ) dfs ( g , g [ u ] [ i ] , visit ) ; } bool isConnected ( vector < int > g [ ] , vector < bool > & mark , int s ) { vector < bool > visit ( M , false ) ; dfs ( g , s , visit ) ; for ( int i = 0 ; i < M ; i ++ ) { if ( mark [ i ] && ! visit [ i ] ) return false ; } return true ; } bool possibleOrderAmongString ( string arr [ ] , int N ) { vector < int > g [ M ] ; vector < bool > mark ( M , false ) ; vector < int > in ( M , 0 ) , out ( M , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int f = arr [ i ] . front ( ) - ' a ' ; int l = arr [ i ] . back ( ) - ' a ' ; mark [ f ] = mark [ l ] = true ; in [ l ] ++ ; out [ f ] ++ ; g [ f ] . push_back ( l ) ; } for ( int i = 0 ; i < M ; i ++ ) if ( in [ i ] != out [ i ] ) return false ; return isConnected ( g , mark , arr [ 0 ] . front ( ) - ' a ' ) ; } int main ( ) { string arr [ ] = { " ab " , " bc " , " cd " , " de " , " ed " , " da " } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( possibleOrderAmongString ( arr , N ) == false ) cout << " Ordering ▁ not ▁ possible STRNEWLINE " ; else cout << " Ordering ▁ is ▁ possible STRNEWLINE " ; return 0 ; }

Index/key variables: M, f, i, l, u
Accumulator variables: i, stdc
Iterator variables: i