dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include " bits / stdc + + . h "
using namespace std ; int countOperations ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] & 1 ) { arr [ i ] ++ ; arr [ i + 1 ] ++ ; count += 2 ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) return -1 ; } return count ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( int ) ; cout << countOperations ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <iostream>
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int arr [ ] , int k , int n ) { sort ( arr , arr + n ) ; int pair = 0 ; int index = 0 ; while ( index < n - 1 ) { if ( arr [ index + 1 ] - arr [ index ] <= k ) { pair += 1 ; index += 2 ; } else { index += 1 ; } } return pair ; } int main ( ) { int arr [ ] = { 1 , 4 , 3 , 7 , 5 } ; int k = 2 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int count = countPairs ( arr , k , n ) ; cout << count << endl ; ; }

Index/key variables: index
Accumulator variables: index, pair, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxProfit ( int profitA [ ] , int profitB [ ] , int n ) { int preSum [ n ] ; preSum [ 0 ] = profitA [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { preSum [ i ] = preSum [ i - 1 ] + profitA [ i ] ; } int suffSum [ n ] ; suffSum [ n - 1 ] = profitB [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { suffSum [ i ] = suffSum [ i + 1 ] + profitB [ i ] ; } int res = preSum [ n - 1 ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { res = max ( res , preSum [ i ] + suffSum [ i + 1 ] ) ; } res = max ( res , suffSum [ 0 ] ) ; return res ; } int main ( ) { int profitA [ ] = { 2 , 3 , 2 } ; int profitB [ ] = { 10 , 30 , 40 } ; int n = sizeof ( profitA ) / sizeof ( int ) ; cout << maxProfit ( profitA , profitB , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minEdges ( vector < pair < int , int > > v , int n ) { vector < vector < int > > adj ; adj . resize ( n + 1 ) ; for ( int i = 0 ; i < adj . size ( ) ; i ++ ) adj [ i ] . resize ( n + 1 , 0 ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { adj [ v [ i ] . first ] [ v [ i ] . second ] = 1 ; adj [ v [ i ] . second ] [ v [ i ] . first ] = 1 ; } int edgesNeeded = 3 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { for ( int k = j + 1 ; k <= n ; k ++ ) { if ( adj [ i ] [ j ] && adj [ j ] [ k ] && adj [ k ] [ i ] ) return 0 ; if ( ! ( adj [ i ] [ j ] adj [ j ] [ k ] adj [ k ] [ i ] ) ) edgesNeeded = min ( edgesNeeded , 3 ) ; else { if ( ( adj [ i ] [ j ] && adj [ j ] [ k ] ) || ( adj [ j ] [ k ] && adj [ k ] [ i ] ) || ( adj [ k ] [ i ] && adj [ i ] [ j ] ) ) { edgesNeeded = 1 ; } else edgesNeeded = min ( edgesNeeded , 2 ) ; } } } } return edgesNeeded ; } int main ( ) { int n = 3 ; vector < pair < int , int > > v = { { 1 , 2 } , { 1 , 3 } } ; cout << minEdges ( v , n ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LongestXorSubsequence ( int arr [ ] , int n ) { vector < pair < int , pair < int , int > > > v ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { v . push_back ( make_pair ( arr [ i ] ^ arr [ j ] , make_pair ( i , j ) ) ) ; } } sort ( v . begin ( ) , v . end ( ) ) ; int dp [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { dp [ i ] = 1 ; } for ( auto i : v ) { dp [ i . second . second ] = max ( dp [ i . second . second ] , 1 + dp [ i . second . first ] ) ; } int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) ans = max ( ans , dp [ i ] ) ; return ans ; } int main ( ) { int arr [ ] = { 2 , 12 , 6 , 7 , 13 , 14 , 8 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << LongestXorSubsequence ( arr , n ) ; return 0 ; }

Index/key variables: i, j, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void dfs ( int u , int parent , int totalSum , vector < int > edge [ ] , int subtree [ ] , int & res ) { int sum = subtree [ u ] ; for ( int i = 0 ; i < edge [ u ] . size ( ) ; i ++ ) { int v = edge [ u ] [ i ] ; if ( v != parent ) { dfs ( v , u , totalSum , edge , subtree , res ) ; sum += subtree [ v ] ; } } subtree [ u ] = sum ; if ( u != 0 && abs ( totalSum - 2 * sum ) < res ) res = abs ( totalSum - 2 * sum ) ; } int getMinSubtreeSumDifference ( int vertex [ ] , int edges [ ] [ 2 ] , int N ) { int totalSum = 0 ; int subtree [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { subtree [ i ] = vertex [ i ] ; totalSum += vertex [ i ] ; } vector < int > edge [ N ] ; for ( int i = 0 ; i < N - 1 ; i ++ ) { edge [ edges [ i ] [ 0 ] ] . push_back ( edges [ i ] [ 1 ] ) ; edge [ edges [ i ] [ 1 ] ] . push_back ( edges [ i ] [ 0 ] ) ; } int res = INT_MAX ; dfs ( 0 , -1 , totalSum , edge , subtree , res ) ; return res ; } int main ( ) { int vertex [ ] = { 4 , 2 , 1 , 6 , 3 , 5 , 2 } ; int edges [ ] [ 2 ] = { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 2 , 4 } , { 2 , 5 } , { 3 , 6 } } ; int N = sizeof ( vertex ) / sizeof ( vertex [ 0 ] ) ; cout << getMinSubtreeSumDifference ( vertex , edges , N ) ; return 0 ; }

Index/key variables: N, i, u, v
Accumulator variables: i, stdc, sum, totalSum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int FindMinOperation ( int a [ ] , int n , int k ) { priority_queue < int , vector < int > , greater < int > > Q ; for ( int i = 0 ; i < n ; i ++ ) Q . push ( a [ i ] ) ; int ans = 0 ; while ( 1 ) { if ( Q . top ( ) >= k ) break ; if ( Q . size ( ) < 2 ) return -1 ; int x = Q . top ( ) ; Q . pop ( ) ; int y = Q . top ( ) ; Q . pop ( ) ; int z = ( x * y ) / __gcd ( x , y ) ; Q . push ( z ) ; ans ++ ; } return ans ; } int main ( ) { int a [ ] = { 3 , 5 , 7 , 6 , 8 } ; int k = 8 ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << FindMinOperation ( a , n , k ) ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
using System ; using System . Collections ; class GfG { #include <bits/stdc++.h>
using namespace std ; string Check ( int a [ ] [ 2 ] , int b [ ] [ 2 ] , int n , int m ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) if ( a [ i ] [ j ] > b [ i ] [ j ] ) swap ( a [ i ] [ j ] , b [ i ] [ j ] ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m - 1 ; j ++ ) if ( a [ i ] [ j ] >= a [ i ] [ j + 1 ] b [ i ] [ j ] >= b [ i ] [ j + 1 ] ) return " No " ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) if ( a [ i ] [ j ] >= a [ i + 1 ] [ j ] b [ i ] [ j ] >= b [ i + 1 ] [ j ] ) return " No " ; return " Yes " ; } int main ( ) { int n = 2 , m = 2 ; int a [ ] [ 2 ] = { { 2 , 10 } , { 11 , 5 } } ; int b [ ] [ 2 ] = { { 9 , 4 } , { 3 , 12 } } ; cout << ( Check ( a , b , n , m ) ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Class/struct names: GfG
C++ program:
#include <iostream>
using namespace std ; string smallestString ( int N , int A [ ] ) { char ch = ' a ' ; string S = " " ; if ( N < 1 A [ 0 ] != 1 ) { S = " - 1" ; return S ; } S += ch ; ch ++ ; for ( int i = 1 ; i < N ; i ++ ) { int diff = A [ i ] - A [ i - 1 ] ; if ( diff > 1 diff < 0 A [ i ] > 26 ) { S = " - 1" ; return S ; } else if ( diff == 0 ) S += ' a ' ; else { S += ch ; ch ++ ; } } return S ; } int main ( ) { int arr [ ] = { 1 , 1 , 2 , 3 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << smallestString ( n , arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: S, ch, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canBePicked ( int digits [ ] , int num ) { int copyDigits [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) copyDigits [ i ] = digits [ i ] ; while ( num > 0 ) { int digit = num % 10 ; if ( copyDigits [ digit ] == 0 ) return false ; else copyDigits [ digit ] -= 1 ; num = floor ( num / 10 ) ; } return true ; } int countAlphabets ( long n ) { int count = 0 ; int digits [ 10 ] = { 0 } ; while ( n > 0 ) { int digit = n % 10 ; digits [ digit ] += 1 ; n = floor ( n / 10 ) ; } for ( int i = 97 ; i <= 122 ; i ++ ) if ( canBePicked ( digits , i ) ) count += 1 ; for ( int i = 65 ; i < 91 ; i ++ ) if ( canBePicked ( digits , i ) ) count += 1 ; return count ; } int main ( ) { long n = 1623455078 ; cout << ( countAlphabets ( n ) ) ; }

Index/key variables: digit, i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int greatestKBits ( int X , int K ) { int set_bit_count = __builtin_popcount ( X ) ; if ( set_bit_count <= K ) return X ; int diff = set_bit_count - K ; for ( int i = 0 ; i < diff ; i ++ ) X &= ( X - 1 ) ; return X ; } int main ( ) { int X = 21 , K = 2 ; cout << greatestKBits ( X , K ) ; return 0 ; }

Accumulator variables: X, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  4
class Graph { int V ; list < int > * adj ; public : Graph ( int V ) { this -> V = V ; adj = new list < int > [ V ] ; } void addEdge ( int s , int d ) ; int BFS ( int s , int d ) ; } ; void Graph :: addEdge ( int s , int d ) { adj [ s ] . push_back ( d ) ; adj [ d ] . push_back ( s ) ; } int Graph :: BFS ( int s , int d ) { if ( s == d ) return 0 ; int * level = new int [ V ] ; for ( int i = 0 ; i < V ; i ++ ) level [ i ] = -1 ; list < int > queue ; level [ s ] = 0 ; queue . push_back ( s ) ; list < int > :: iterator i ; while ( ! queue . empty ( ) ) { s = queue . front ( ) ; queue . pop_front ( ) ; for ( i = adj [ s ] . begin ( ) ; i != adj [ s ] . end ( ) ; ++ i ) { if ( level [ * i ] < 0 level [ * i ] > level [ s ] + 1 ) { level [ * i ] = level [ s ] + 1 ; queue . push_back ( * i ) ; } } } return level [ d ] ; } bool isSafe ( int i , int j , int M [ ] [ N ] ) { if ( ( i < 0 i > = N ) || ( j < 0 j > = N ) M [ i ] [ j ] == 0 ) return false ; return true ; } int MinimumPath ( int M [ ] [ N ] ) { int s , d ; int V = N * N + 2 ; Graph g ( V ) ; int k = 1 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( M [ i ] [ j ] != 0 ) { if ( isSafe ( i , j + 1 , M ) ) g . addEdge ( k , k + 1 ) ; if ( isSafe ( i , j - 1 , M ) ) g . addEdge ( k , k - 1 ) ; if ( j < N - 1 && isSafe ( i + 1 , j , M ) ) g . addEdge ( k , k + N ) ; if ( i > 0 && isSafe ( i - 1 , j , M ) ) g . addEdge ( k , k - N ) ; } if ( M [ i ] [ j ] == 1 ) s = k ; if ( M [ i ] [ j ] == 2 ) d = k ; k ++ ; } } return g . BFS ( s , d ) ; } int main ( ) { int M [ N ] [ N ] = { { 3 , 3 , 1 , 0 } , { 3 , 0 , 3 , 3 } , { 2 , 3 , 0 , 3 } , { 0 , 3 , 3 , 3 } } ; cout << MinimumPath ( M ) << endl ; return 0 ; }

Index/key variables: N, V, d, i, j, s
Accumulator variables: i, j, k, stdc
Iterator variables: i, j
Class/struct names: Graph
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findTwoNumbers ( int sum , int gcd ) { if ( __gcd ( gcd , sum - gcd ) == gcd && sum != gcd ) cout << " a ▁ = ▁ " << min ( gcd , sum - gcd ) << " , ▁ b ▁ = ▁ " << sum - min ( gcd , sum - gcd ) << endl ; else cout << -1 << endl ; } int main ( ) { int sum = 8 ; int gcd = 2 ; findTwoNumbers ( sum , gcd ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxDistance ( int numOfCities , int station [ ] , int n ) { bool hasStation [ numOfCities + 1 ] = { false } ; for ( int city = 0 ; city < n ; city ++ ) { hasStation [ station [ city ] ] = true ; } int dist = 0 ; int maxDist = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { maxDist = min ( station [ i ] , maxDist ) ; } for ( int city = 0 ; city < numOfCities ; city ++ ) { if ( hasStation [ city ] == true ) { maxDist = max ( ( dist + 1 ) / 2 , maxDist ) ; dist = 0 ; } else dist += 1 ; } return max ( maxDist , dist ) ; } int main ( ) { int numOfCities = 6 ; int station [ ] = { 3 , 1 } ; int n = sizeof ( station ) / sizeof ( station [ 0 ] ) ; cout << " Max ▁ Distance : " << findMaxDistance ( numOfCities , station , n ) ; }

Index/key variables: city, i
Accumulator variables: city, dist, i, stdc
Iterator variables: city, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; ; void split ( int x , int n ) { if ( x < n ) cout << " - 1" << " ▁ " ; else if ( x % n == 0 ) { for ( int i = 0 ; i < n ; i ++ ) cout << ( x / n ) << " ▁ " ; } else { int zp = n - ( x % n ) ; int pp = x / n ; for ( int i = 0 ; i < n ; i ++ ) { if ( i >= zp ) cout << ( pp + 1 ) << " ▁ " ; else cout << pp << " ▁ " ; } } } int main ( ) { int x = 5 ; int n = 3 ; split ( x , n ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; long cal_minimum_time ( long X ) { long t = 0 ; long sum = 0 ; while ( sum < X ) { t ++ ; sum = sum + t ; } return t ; } int main ( ) { long n = 6 ; long ans = cal_minimum_time ( n ) ; cout << " The ▁ minimum ▁ time ▁ required ▁ is ▁ : ▁ " << ans ; return 0 ; }

Accumulator variables: t
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { string s = " ABCdcba " ; int u [ 26 ] = { 0 } ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( isupper ( s [ i ] ) ) { u [ s [ i ] - 65 ] += 1 ; } else { u [ s [ i ] - 97 ] -= 1 ; } } bool f1 = true ; int po = 0 ; int ne = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( u [ i ] > 0 ) po += u [ i ] ; if ( u [ i ] < 0 ) ne += u [ i ] ; } if ( po == 0 && ne == 0 ) cout << ( " YES " ) << endl ; else if ( po == 1 && ne == 0 ) cout << ( " YES " ) << endl ; else if ( po == 0 && ne == -1 ) cout << ( " YES " ) << endl ; else cout << ( " NO " ) << endl ; }

Index/key variables: i
Accumulator variables: i, ne, po, stdc
Iterator variables: i
Boolean variables: f1
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addAllVowel ( string str ) { char x [ ] = { ' A ' , ' E ' , ' I ' , ' O ' , ' U ' } ; vector < char > y ; int length = str . length ( ) ; if ( length < 5 ) cout << " Impossible " << endl ; else { for ( int i = 0 ; i < length ; i ++ ) { if ( find ( x , x + 5 , str [ i ] ) != x + 5 and find ( y . begin ( ) , y . end ( ) , str [ i ] ) == y . end ( ) ) y . push_back ( str [ i ] ) ; } vector < char > z ; for ( int i = 0 ; i < 5 ; i ++ ) if ( find ( y . begin ( ) , y . end ( ) , x [ i ] ) == y . end ( ) ) z . push_back ( x [ i ] ) ; if ( z . empty ( ) ) cout << str << endl ; else { int cc = 0 ; vector < char > y ; for ( int i = 0 ; i < length ; i ++ ) { if ( find ( x , x + 5 , str [ i ] ) != x + 5 and find ( y . begin ( ) , y . end ( ) , str [ i ] ) == y . end ( ) ) y . push_back ( str [ i ] ) ; else { str [ i ] = z [ cc ] ; cc ++ ; } if ( cc == z . size ( ) ) break ; } cout << str << endl ; } } } int main ( int argc , char const * argv [ ] ) { string str = " ABCDEFGHI " ; addAllVowel ( str ) ; return 0 ; }

Index/key variables: cc, i
Accumulator variables: cc, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define inf  INT_MAX
int minimumDays ( int N , int D1 [ ] , int D2 [ ] ) { int ans = - inf ; vector < pair < int , int > > vect ; for ( int i = 0 ; i < N ; i ++ ) vect . push_back ( make_pair ( D1 [ i ] , D2 [ i ] ) ) ; sort ( vect . begin ( ) , vect . end ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( vect [ i ] . second >= ans ) ans = vect [ i ] . second ; else ans = vect [ i ] . first ; } return ans ; } int main ( ) { int N = 3 ; int D1 [ ] = { 6 , 5 , 4 } ; int D2 [ ] = { 1 , 2 , 3 } ; cout << minimumDays ( N , D1 , D2 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( pair < int , int > v [ ] , int n ) { int ans , ul , ll ; ll = v [ 0 ] . first ; ul = v [ 0 ] . second ; ans = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ( v [ i ] . first <= ul && v [ i ] . first >= ll ) || ( v [ i ] . second >= ll && v [ i ] . second <= ul ) ) { if ( v [ i ] . first > ll ) { ll = v [ i ] . first ; } if ( v [ i ] . second < ul ) { ul = v [ i ] . second ; } } else if ( v [ i ] . first > ul ) { ans += abs ( ul - v [ i ] . first ) ; ul = v [ i ] . first ; ll = v [ i ] . first ; } else if ( v [ i ] . second < ll ) { ans += abs ( ll - v [ i ] . second ) ; ul = v [ i ] . second ; ll = v [ i ] . second ; } } return ans ; } int main ( ) { pair < int , int > v [ ] = { { 1 , 3 } , { 2 , 5 } , { 6 , 8 } , { 1 , 2 } , { 2 , 3 } } ; int n = sizeof ( v ) / sizeof ( v [ 0 ] ) ; cout << solve ( v , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < string > preProcess ( long long int n ) { vector < string > preProcessedCubes ; for ( int i = 1 ; i * i * i <= n ; i ++ ) { long long int iThCube = i * i * i ; string cubeString = to_string ( iThCube ) ; preProcessedCubes . push_back ( cubeString ) ; } return preProcessedCubes ; } string findLargestCubeUtil ( string num , vector < string > preProcessedCubes ) { reverse ( preProcessedCubes . begin ( ) , preProcessedCubes . end ( ) ) ; int totalCubes = preProcessedCubes . size ( ) ; for ( int i = 0 ; i < totalCubes ; i ++ ) { string currCube = preProcessedCubes [ i ] ; int digitsInCube = currCube . length ( ) ; int index = 0 ; int digitsInNumber = num . length ( ) ; for ( int j = 0 ; j < digitsInNumber ; j ++ ) { if ( num [ j ] == currCube [ index ] ) index ++ ; if ( digitsInCube == index ) return currCube ; } } return " Not ▁ Possible " ; } void findLargestCube ( long long int n ) { vector < string > preProcessedCubes = preProcess ( n ) ; string num = to_string ( n ) ; string ans = findLargestCubeUtil ( num , preProcessedCubes ) ; cout << " Largest ▁ Cube ▁ that ▁ can ▁ be ▁ formed ▁ from ▁ " << n << " ▁ is ▁ " << ans << endl ; } int main ( ) { long long int n ; n = 4125 ; findLargestCube ( n ) ; n = 876 ; findLargestCube ( n ) ; return 0 ; }

Index/key variables: i, index, j
Accumulator variables: i, index, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int n , p ; int rd [ 1100 ] ; int wt [ 1100 ] ; int cd [ 1100 ] ; vector < int > a ; vector < int > b ; vector < int > c ; int ans ; int dfs ( int w ) { if ( cd [ w ] == 0 ) return w ; if ( wt [ w ] < ans ) ans = wt [ w ] ; return dfs ( cd [ w ] ) ; } void solve ( int arr [ ] [ 3 ] ) { int i = 0 ; while ( i < p ) { int q = arr [ i ] [ 0 ] , h = arr [ i ] [ 1 ] , t = arr [ i ] [ 2 ] ; cd [ q ] = h ; wt [ q ] = t ; rd [ h ] = q ; i ++ ; } a . clear ( ) ; b . clear ( ) ; c . clear ( ) ; for ( int j = 1 ; j <= n ; ++ j ) if ( rd [ j ] == 0 && cd [ j ] ) { ans = 1000000000 ; int w = dfs ( j ) ; a . push_back ( j ) ; b . push_back ( w ) ; c . push_back ( ans ) ; } cout << a . size ( ) << endl ; for ( int j = 0 ; j < a . size ( ) ; ++ j ) cout << a [ j ] << " ▁ " << b [ j ] << " ▁ " << c [ j ] << endl ; } int main ( ) { n = 9 , p = 6 ; memset ( rd , 0 , sizeof ( rd ) ) ; memset ( cd , 0 , sizeof ( cd ) ) ; memset ( wt , 0 , sizeof ( wt ) ) ; int arr [ ] [ 3 ] = { { 7 , 4 , 98 } , { 5 , 9 , 72 } , { 4 , 6 , 10 } , { 2 , 8 , 22 } , { 9 , 7 , 17 } , { 3 , 1 , 66 } } ; solve ( arr ) ; return 0 ; }

Index/key variables: h, i, j, q, w
Accumulator variables: i, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string noAdjacentDup ( string s ) { int n = s . length ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == s [ i - 1 ] ) { s [ i ] = ' a ' ; while ( s [ i ] == s [ i - 1 ] || ( i + 1 < n && s [ i ] == s [ i + 1 ] ) ) s [ i ] ++ ; i ++ ; } } return s ; } int main ( ) { string s = " geeksforgeeks " ; cout << noAdjacentDup ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int winner ( int a [ ] , int n , int k ) { if ( k >= n - 1 ) return n ; int best = 0 , times = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > best ) { best = a [ i ] ; if ( i ) } else if ( times >= k ) return best ; } return best ; } int main ( ) { int a [ ] = { 2 , 1 , 3 , 4 , 5 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int k = 2 ; cout << winner ( a , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumSquare ( int a , int b ) { long long result = 0 , rem = 0 ; if ( a < b ) swap ( a , b ) ; while ( b > 0 ) { result += a / b ; long long rem = a % b ; a = b ; b = rem ; } return result ; } int main ( ) { int n = 13 , m = 29 ; cout << minimumSquare ( n , m ) ; return 0 ; }

Accumulator variables: result, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MaxSum ( int a [ ] , int n , int k ) { int sum = 0 ; priority_queue < int , vector < int > , greater < int > > pq ; for ( int i = 0 ; i < n ; i ++ ) { pq . push ( a [ i ] ) ; } while ( k -- ) { int temp = pq . top ( ) ; pq . pop ( ) ; temp = ( temp ) * -1 ; pq . push ( temp ) ; } while ( ! pq . empty ( ) ) { sum = sum + pq . top ( ) ; pq . pop ( ) ; } return sum ; } int main ( ) { int a [ ] = { -2 , 0 , 5 , -1 , 2 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int k = 4 ; cout << MaxSum ( a , 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 totalValidArrays ( int a [ ] , int b [ ] , int N ) { int dp [ N + 1 ] [ b [ N - 1 ] + 1 ] ; int pref [ N + 1 ] [ b [ N - 1 ] + 1 ] ; memset ( dp , 0 , sizeof ( dp ) ) , memset ( pref , 0 , sizeof ( pref ) ) ; dp [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i <= b [ N - 1 ] ; i ++ ) { pref [ 0 ] [ i ] = 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = a [ i - 1 ] ; j <= b [ i - 1 ] ; j ++ ) { dp [ i ] [ j ] += pref [ i - 1 ] [ j ] ; pref [ i ] [ j ] += dp [ i ] [ j ] ; } for ( int j = 0 ; j <= b [ N - 1 ] ; j ++ ) { if ( j > 0 ) { pref [ i ] [ j ] += pref [ i ] [ j - 1 ] ; } } } int ans = 0 ; for ( int i = a [ N - 1 ] ; i <= b [ N - 1 ] ; i ++ ) { ans += dp [ N ] [ i ] ; } return ans ; } int main ( ) { int A [ ] = { 1 , 1 } ; int B [ ] = { 2 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << totalValidArrays ( A , B , N ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string s ; int dp [ 1024 ] [ 10 ] [ 2 ] [ 2 ] ; int calcCnt ( int mask , int len , int smaller , int started ) { if ( len == s . size ( ) ) { return ( mask == 0 && started ) ; } if ( dp [ mask ] [ len ] [ smaller ] [ started ] != -1 ) return dp [ mask ] [ len ] [ smaller ] [ started ] ; int mx = 9 ; if ( ! smaller ) { mx = s [ len ] - '0' ; } int ans = 0 ; if ( started ) { for ( int i = 0 ; i <= mx ; i ++ ) { ans += calcCnt ( mask ^ ( 1 << i ) , len + 1 , smaller || ( i < s [ len ] - '0' ) , 1 ) ; } } else { ans = calcCnt ( mask , len + 1 , 1 , 0 ) ; for ( int i = 1 ; i <= mx ; i ++ ) { ans += calcCnt ( mask ^ ( 1 << i ) , len + 1 , smaller || ( i < s [ len ] - '0' ) , 1 ) ; } } return dp [ mask ] [ len ] [ smaller ] [ started ] = ans ; } int countInt ( int x ) { memset ( dp , -1 , sizeof ( dp ) ) ; s = to_string ( x ) ; return calcCnt ( 0 , 0 , 0 , 0 ) ; } int countIntInRange ( int L , int R ) { return countInt ( R ) - countInt ( L - 1 ) ; } int main ( ) { int L = 32 , R = 1010 ; cout << countIntInRange ( L , R ) ; return 0 ; }

Index/key variables: len, mask, smaller, started
Accumulator variables: ans, i, stdc
Iterator variables: i