dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getCountPairs ( vector < int > arr , int N , int S ) { int count = 0 ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < arr . size ( ) ; j ++ ) { if ( ( arr [ i ] + arr [ j ] ) == S ) count ++ ; } } return count ; } int countPairs ( vector < int > arr , int N ) { int count = 0 ; unordered_set < int > S ; for ( int i = 0 ; i < N ; i ++ ) S . insert ( arr [ i ] ) ; for ( int ele : S ) { int sum = 2 * ele ; count += getCountPairs ( arr , N , sum ) ; } return count ; } int main ( ) { vector < int > arr = { 4 , 2 , 5 , 1 , 3 , 5 } ; int N = arr . size ( ) ; cout << countPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: ele, i, j
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
const int MAX = 1e5 ; using namespace std ; ll power ( ll x , unsigned ll y ) { ll res = 1 ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) ; y = y >> 1 ; x = ( x * x ) ; } return res ; } void SieveOfEratosthenes ( vector < pair < ll , ll > > & v ) { bool prime [ MAX + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } int num = 1 ; for ( int i = 1 ; i <= MAX ; i ++ ) { if ( prime [ i ] ) { v . push_back ( { i , num } ) ; num ++ ; } } } int countIntegers ( ll n ) { if ( n < 16 ) { return 0 ; } vector < pair < ll , ll > > v ; SieveOfEratosthenes ( v ) ; int low = 0 ; int high = v . size ( ) - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; ll curr = power ( v [ mid ] . first , 4 ) ; ll prev = power ( v [ mid - 1 ] . first , 4 ) ; if ( curr == n ) { return v [ mid ] . second ; } else if ( curr > n and prev <= n ) { return v [ mid - 1 ] . second ; } else if ( curr > n ) { high = mid - 1 ; } else { low = mid + 1 ; } } return 0 ; } int main ( ) { ll N = 100 ; cout << countIntegers ( N ) ; return 0 ; }

Index/key variables: i, mid, p
Accumulator variables: i, num, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPowerOfTwo ( int n ) { if ( n == 0 ) return false ; return ( ceil ( log2 ( n ) ) == floor ( log2 ( n ) ) ) ; } void printArray ( vector < string > res ) { sort ( res . begin ( ) , res . end ( ) ) ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) { cout << res [ i ] << " ▁ " ; } } void sortedStrings ( string S [ ] , int N ) { unordered_map < char , int > freq ; vector < string > res ; for ( int i = 0 ; i < N ; i ++ ) { string st = " " ; for ( int j = 0 ; j < S [ i ] . size ( ) ; j ++ ) { freq [ S [ i ] [ j ] ] ++ ; } for ( auto i : freq ) { if ( isPowerOfTwo ( i . second ) ) { for ( int j = 0 ; j < i . second ; j ++ ) { st += i . first ; } } } freq . clear ( ) ; if ( st . size ( ) == 0 ) continue ; sort ( st . begin ( ) , st . end ( ) , greater < char > ( ) ) ; res . push_back ( st ) ; } printArray ( res ) ; } int main ( ) { string arr [ ] = { " aaacbb " , " geeks " , " aaa " } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sortedStrings ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, st, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void replaceCharacters ( string s , vector < vector < char > > p ) { int n = s . size ( ) , k = p . size ( ) ; char arr [ 26 ] ; char brr [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ s [ i ] - ' a ' ] = s [ i ] ; brr [ s [ i ] - ' a ' ] = s [ i ] ; } for ( int j = 0 ; j < k ; j ++ ) { char a = p [ j ] [ 0 ] , b = p [ j ] [ 1 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] == a ) { brr [ i ] = b ; } } } for ( int i = 0 ; i < n ; i ++ ) { cout << brr [ s [ i ] - ' a ' ] ; } } int main ( ) { string S = " aabbgg " ; vector < vector < char > > P { { ' a ' , ' b ' } , { ' b ' , ' g ' } , { ' g ' , ' a ' } } ; replaceCharacters ( S , P ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define MAX  100001
using namespace std ; void SieveOfEratosthenes ( bool prime [ ] ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i < MAX ; i += p ) prime [ i ] = false ; } } } void smallestSemiPrime ( int n ) { bool prime [ MAX ] ; memset ( prime , true , sizeof ( prime ) ) ; SieveOfEratosthenes ( prime ) ; int num1 = n + 1 ; while ( prime [ num1 ] != true ) { num1 ++ ; } int num2 = num1 + n ; while ( prime [ num2 ] != true ) { num2 ++ ; } cout << num1 * 1LL * num2 ; } int main ( ) { int N = 2 ; smallestSemiPrime ( N ) ; return 0 ; }

Index/key variables: MAX, i, num1, num2, p
Accumulator variables: i, num1, num2, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; void productOfTwoPerfectCubes ( int N ) { map < int , int > cubes ; for ( int i = 1 ; i * i * i <= N ; i ++ ) cubes [ i * i * i ] = i ; for ( auto itr = cubes . begin ( ) ; itr != cubes . end ( ) ; itr ++ ) { int firstNumber = itr -> first ; if ( N % itr -> first == 0 ) { int secondNumber = N / itr -> first ; if ( cubes . find ( secondNumber ) != cubes . end ( ) ) { cout << " Yes " ; return ; } } } cout << " No " ; } int main ( ) { int N = 216 ; productOfTwoPerfectCubes ( N ) ; return 0 ; }

Accumulator variables: i, itr, stdc
Iterator variables: i, itr
C++ program:
#include <bits/stdc++.h>
using namespace std ; void productOfTwoPerfectCubes ( int N ) { int cube_root ; cube_root = round ( cbrt ( N ) ) ; if ( cube_root * cube_root * cube_root == N ) { cout << " Yes " ; return ; } else { cout << " No " ; return ; } } int main ( ) { int N = 216 ; productOfTwoPerfectCubes ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool bound ( int w , int h , int N , int x ) { int val = ( x / w ) * ( x / h ) ; if ( val >= N ) return true ; else return false ; } int FindSquare ( int N , int W , int H ) { int i = 1 ; int j = W * H * N ; while ( i < j ) { int mid = i + ( j - i ) / 2 ; if ( bound ( W , H , N , mid ) ) j = mid ; else i = mid + 1 ; } return j ; } int main ( ) { int W = 2 ; int H = 3 ; int N = 10 ; cout << FindSquare ( N , W , H ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printNumberOfPairs ( int N ) { unordered_set < int > st ; for ( int i = 2 ; i * i <= N ; i ++ ) { int x = i ; while ( x <= N ) { x *= i ; if ( x <= N ) { st . insert ( x ) ; } } } cout << st . size ( ) ; } int main ( ) { int N = 10000 ; printNumberOfPairs ( N ) ; return 0 ; }

Accumulator variables: i, stdc, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } void maximumProduct ( vector < string > words ) { vector < int > bits ( words . size ( ) , 0 ) ; for ( int i = 0 ; i < words . size ( ) ; i ++ ) { for ( int j = 0 ; j < words [ i ] . length ( ) ; j ++ ) { bits [ i ] = bits [ i ] | 1 << ( words [ i ] [ j ] - ' a ' ) ; } } int result = 0 ; for ( int i = 0 ; i < bits . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < bits . size ( ) ; j ++ ) { if ( ( bits [ i ] & bits [ j ] ) == 0 ) { int L = countSetBits ( bits [ i ] ) ; int R = countSetBits ( bits [ j ] ) ; result = max ( L * R , result ) ; } } } cout << result ; } int main ( ) { vector < string > arr = { " abcw " , " baz " , " foo " , " bar " , " xtfn " , " abcdef " } ; maximumProduct ( arr ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
function palindrome ( str ) { var st = 0 ; var ed = str . length - 1 ; while ( st < ed ) { if ( str [ st ] == str [ ed ] ) { st ++ ; ed -- ; } else return false ; } return true ; } function printReverse ( sentence ) { var newlist = [ ] ; var lis = [ ] ; var temp = " " ; for ( var i = 0 ; i < sentence . length ; i ++ ) { if ( sentence [ i ] == ' ▁ ' ) { lis . push ( temp ) ; temp = " " ; } else temp += sentence [ i ] ; } lis . push ( temp ) ; for ( var i = 0 ; i < lis . length ; i ++ ) { if ( palindrome ( lis [ i ] ) ) newlist . push ( lis [ i ] ) ; } newlist . reverse ( ) ; var j = 0 ; for ( var i = 0 ; i < lis . length ; i ++ ) { if ( palindrome ( lis [ i ] ) ) { lis [ i ] = newlist [ j ] ; j = j + 1 ; } } for ( var i = 0 ; i < lis . length ; i ++ ) { document . write ( lis [ i ] + " ▁ " ) ; } } var sentence = " mom ▁ and ▁ dad ▁ went ▁ to ▁ eye ▁ hospital " ; printReverse ( sentence ) ;

Index/key variables: ed, i, j, st
Accumulator variables: ed, i, st, temp
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int minCount ( int A [ ] , int B [ ] , int N ) { int i = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( A [ i ] == B [ j ] ) { i ++ ; } } return N - i ; } int main ( ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 } ; int B [ ] = { 1 , 5 , 2 , 3 , 4 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << minCount ( A , B , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int possible ( int A [ ] , int N , int mid , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { count += ( A [ i ] - 1 ) / mid ; } return count <= K ; } int minimumMaximum ( int A [ ] , int N , int K ) { int lo = 1 ; int hi = * max_element ( A , A + N ) ; int mid ; while ( lo < hi ) { mid = ( lo + hi ) / 2 ; if ( possible ( A , N , mid , K ) ) { hi = mid ; } else { lo = mid + 1 ; } } return hi ; } int main ( ) { int arr [ ] = { 2 , 4 , 8 , 2 } ; int K = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimumMaximum ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumNumber ( int arr [ ] , int N , int K ) { int minimum = * min_element ( arr , arr + N ) ; int ans = minimum + K ; for ( int i = 0 ; i < N ; i ++ ) { if ( abs ( arr [ i ] - ans ) > K ) { ans = -1 ; break ; } } cout << ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 5 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumNumber ( 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 ; bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } void sumOfPrimeSquare ( int n ) { int i = 0 ; vector < int > squares ; while ( i * i < n ) { squares . push_back ( i * i ) ; i ++ ; } bool flag = false ; for ( i = 0 ; i < squares . size ( ) ; i ++ ) { int difference = n - squares [ i ] ; if ( isPrime ( difference ) ) { flag = true ; break ; } } if ( flag ) { cout << " Yes " ; } else cout << " No " ; } int main ( ) { int N = 27 ; sumOfPrimeSquare ( N ) ; 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 SieveOfEratosthenes ( bool prime [ ] , int n ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) { prime [ i ] = false ; } } } } void sumOfPrimeSquare ( int n ) { bool flag = false ; bool prime [ n + 1 ] ; memset ( prime , true , sizeof ( prime ) ) ; SieveOfEratosthenes ( prime , n ) ; for ( int i = 0 ; i <= n ; i ++ ) { if ( ! prime [ i ] ) continue ; int dif = n - i ; if ( ceil ( ( double ) sqrt ( dif ) ) == floor ( ( double ) sqrt ( dif ) ) ) { flag = true ; break ; } } if ( flag ) { cout << " Yes " ; } else cout << " No " ; } int main ( ) { int N = 27 ; sumOfPrimeSquare ( N ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; bool check ( int arr [ ] , int M , int K , int ind ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 1 ; j < K ; j ++ ) { if ( arr [ ind + i ] != arr [ ind + i + j * M ] ) { return false ; } } } return true ; } bool SubarrayRepeatsKorMore ( int arr [ ] , int N , int M , int K ) { for ( int ind = 0 ; ind <= N - M * K ; ind ++ ) { if ( check ( arr , M , K , ind ) ) { return true ; } } return false ; } int main ( ) { int arr [ ] = { 2 , 1 , 2 , 1 , 1 , 1 , 3 } ; int M = 2 , K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( SubarrayRepeatsKorMore ( arr , N , M , K ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: i, ind, j, stdc
Iterator variables: i, ind, j
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; bool checkExists ( int arr [ ] , int N , int M , int K ) { int count = 0 ; for ( int i = 0 ; i < N - M ; i ++ ) { if ( arr [ i ] == arr [ i + M ] ) count ++ ; else count = 0 ; if ( count == M * ( K - 1 ) ) return true ; } return false ; } int main ( ) { int arr [ ] = { 2 , 1 , 2 , 1 , 1 , 1 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int M = 2 , K = 2 ; if ( checkExists ( arr , N , M , K ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CommonDigits ( int N , int M ) { int count = 0 ; int freq1 [ 10 ] = { 0 } ; int freq2 [ 10 ] = { 0 } ; while ( N > 0 ) { freq1 [ N % 10 ] ++ ; N = N / 10 ; } while ( M > 0 ) { freq2 [ M % 10 ] ++ ; M = M / 10 ; } for ( int i = 0 ; i < 10 ; i ++ ) { if ( freq1 [ i ] > 0 & freq2 [ i ] > 0 ) { count ++ ; } } return count ; } int main ( ) { int N = 748294 ; int M = 34298156 ; cout << CommonDigits ( N , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumNumber ( int K , int X ) { if ( K > X ) { cout << " - 1" ; return ; } int ans = 0 ; int sum = 0 ; for ( int i = K ; i <= X ; i ++ ) { sum += i ; if ( sum >= X ) { ans = i ; break ; } } cout << ans ; } int main ( ) { int K = 5 , X = 13 ; minimumNumber ( K , X ) ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isGreaterEqual ( int N , int K , int X ) { return ( ( N * 1LL * ( N + 1 ) / 2 ) - ( ( K - 1 ) * 1LL * K / 2 ) ) >= X ; } void minimumNumber ( int K , int X ) { if ( K > X ) { cout << " - 1" ; return ; } int low = K , high = X , res = -1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( isGreaterEqual ( mid , K , X ) ) { res = mid ; high = mid - 1 ; } else low = mid + 1 ; } cout << res ; } int main ( ) { int K = 5 , X = 13 ; minimumNumber ( K , X ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int CountPairs ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( i * j ) == ( arr [ i ] * arr [ j ] ) ) count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 1 , 0 , 3 , 2 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << CountPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxRemainder ( int A [ ] , int N , int K ) { unordered_set < int > even ; set < int > odd ; for ( int i = 0 ; i < N ; i ++ ) { int num = A [ i ] ; if ( num % 2 == 0 ) even . insert ( num % K ) ; else odd . insert ( num % K ) ; } int max_rem = 0 ; for ( int x : even ) { int y = K - 1 - x ; auto it = odd . upper_bound ( y ) ; if ( it != odd . begin ( ) ) { it -- ; max_rem = max ( max_rem , x + * it ) ; } } cout << max_rem ; } int main ( ) { int arr [ ] = { 3 , 2 , 4 , 11 , 6 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 7 ; maxRemainder ( arr , N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, it, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void dfs ( int src , vector < int > Adj [ ] , vector < bool > & visited , int level , int & distance ) { visited [ src ] = true ; distance = max ( distance , level ) ; for ( auto & child : Adj [ src ] ) { if ( child != src and visited [ child ] == false ) { dfs ( child , Adj , visited , level + 1 , distance ) ; } } visited [ src ] = false ; } int maximumLength ( vector < vector < int > > & mat , int V ) { int distance = 0 ; int N = ( int ) mat . size ( ) ; vector < int > Adj [ N ] ; vector < bool > visited ( N , false ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( mat [ i ] [ j ] == 1 ) { Adj [ i ] . push_back ( j ) ; } } } dfs ( V , Adj , visited , 0 , distance ) ; return distance ; } int main ( ) { vector < vector < int > > mat = { { 0 , 1 , 0 , 0 } , { 1 , 0 , 1 , 1 } , { 0 , 1 , 0 , 0 } , { 0 , 1 , 0 , 0 } } ; int V = 2 ; cout << maximumLength ( mat , V ) ; return 0 ; }

Index/key variables: N, child, i, j, src
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLength ( string s , char i , char j ) { char required = i ; int length = 0 ; for ( char curr : s ) { if ( curr == required ) { length += 1 ; if ( required == i ) required = j ; else required = i ; } } return length ; } int minimumDeletions ( string S ) { int len = 0 ; int n = S . length ( ) ; for ( char i = ' a ' ; i <= ' z ' ; i ++ ) { for ( char j = i + 1 ; j <= ' z ' ; j ++ ) { int newLen = findLength ( S , i , j ) ; len = max ( len , newLen ) ; } } return n - len ; } int main ( ) { string S = " adebbeeaebd " ; cout << minimumDeletions ( S ) ; return 0 ; }

Accumulator variables: i, j, length, stdc
Iterator variables: curr, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int inv ( int a , int m ) { int m0 = m , t , q ; int x0 = 0 , x1 = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { q = a / m ; t = m ; m = a % m ; a = t ; t = x0 ; x0 = x1 - q * x0 ; x1 = t ; } if ( x1 < 0 ) x1 += m0 ; return x1 ; } int findMinX ( int A [ ] , int B [ ] , int N ) { int prod = 1 ; for ( int i = 0 ; i < N ; i ++ ) prod *= A [ i ] ; int result = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int pp = prod / A [ i ] ; result += B [ i ] * inv ( pp , A [ i ] ) * pp ; } return result % prod ; } int product ( int a [ ] , int n ) { int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { ans *= a [ i ] ; } return ans ; } void findSmallestInteger ( int A [ ] , int B [ ] , int P , int n ) { int Y = findMinX ( A , B , n ) ; int M = product ( A , n ) ; int K = ceil ( ( ( double ) P - ( double ) Y ) / ( double ) M ) ; int X = Y + K * M ; cout << X ; } int main ( ) { int A [ ] = { 3 , 4 , 5 } ; int B [ ] = { 2 , 3 , 1 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int P = 72 ; findSmallestInteger ( A , B , P , n ) ; }

Index/key variables: i
Accumulator variables: ans, i, prod, result, stdc, x1
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minJumps ( int arr [ ] , int jump [ ] , int N ) { int jumps = 0 ; int temp [ 1000 ] ; vector < pair < int , int > > vect ; for ( int i = 0 ; i < N ; i ++ ) { vect . push_back ( { arr [ i ] , i + 1 } ) ; } for ( int i = 0 ; i < N ; i ++ ) { temp [ arr [ i ] ] = jump [ i ] ; } sort ( vect . begin ( ) , vect . end ( ) ) ; for ( int i = 1 ; i < N ; i ++ ) { while ( vect [ i ] . second <= vect [ i - 1 ] . second ) { vect [ i ] = make_pair ( vect [ i ] . first , vect [ i ] . second + temp [ vect [ i ] . first ] ) ; jumps ++ ; } } cout << jumps << endl ; } int main ( ) { int arr [ ] = { 3 , 2 , 1 } ; int jump [ ] = { 1 , 1 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minJumps ( arr , jump , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, jumps, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void numberOfGates ( string s ) { int N = s . size ( ) ; int ans = 0 ; for ( int i = 0 ; i < ( int ) s . size ( ) ; i ++ ) { if ( s [ i ] == ' . ' s [ i ] == ' + ' s [ i ] == '1' ) { ans ++ ; } } cout << ans ; } int main ( ) { string S = " ( 1 - A ) . B + C " ; numberOfGates ( S ) ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPairs ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) arr [ i ] = abs ( arr [ i ] ) ; sort ( arr , arr + N ) ; int left = 0 ; int ans = 0 ; for ( int right = 0 ; right < N ; right ++ ) { while ( 2 * arr [ left ] < arr [ right ] ) left ++ ; ans += ( right - left ) ; } cout << ans ; } int main ( ) { int arr [ ] = { 1 , 3 , 5 , 7 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, left, right
Accumulator variables: ans, i, left, right, stdc
Iterator variables: i, right
C++ program:
#include <bits/stdc++.h>
using namespace std ; int GetDiff ( int A [ ] , int N ) { int SuffMaxArr [ N ] ; SuffMaxArr [ N - 1 ] = A [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; -- i ) { SuffMaxArr [ i ] = max ( SuffMaxArr [ i + 1 ] , A [ i + 1 ] ) ; } int MaximumSum = INT_MIN ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] < SuffMaxArr [ i ] ) MaximumSum = max ( MaximumSum , A [ i ] + SuffMaxArr [ i ] ) ; } int MinimumSum = INT_MAX ; int SuffMinArr [ N ] ; SuffMinArr [ N - 1 ] = INT_MAX ; for ( int i = N - 2 ; i >= 0 ; -- i ) { SuffMinArr [ i ] = min ( SuffMinArr [ i + 1 ] , A [ i + 1 ] ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] < SuffMinArr [ i ] ) { MinimumSum = min ( MinimumSum , A [ i ] + SuffMinArr [ i ] ) ; } } return abs ( MaximumSum - MinimumSum ) ; } int main ( ) { int arr [ ] = { 2 , 4 , 1 , 3 , 7 , 5 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << GetDiff ( arr , N ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumSwaps ( int arr [ ] , int N ) { int even = 0 , odd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 != i % 2 ) { if ( i % 2 == 0 ) { even ++ ; } else { odd ++ ; } } } if ( even != odd ) { cout << -1 ; } else { cout << even ; } } int main ( ) { int arr [ ] = { 3 , 2 , 7 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; minimumSwaps ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: even, i, odd, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int smallestSubstring ( string a ) { vector < string > a1 ; for ( int i = 0 ; i < a . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < a . size ( ) ; j ++ ) { if ( i != j ) a1 . push_back ( a . substr ( i , j + 1 ) ) ; } } map < string , int > a2 ; for ( string i : a1 ) a2 [ i ] ++ ; vector < string > freshlist ; for ( auto i : a2 ) { if ( i . second == 1 ) freshlist . push_back ( i . first ) ; } map < string , int > dictionary ; for ( auto i : freshlist ) { dictionary [ i ] = i . size ( ) ; } vector < int > newlist ; for ( auto i : dictionary ) newlist . push_back ( i . second ) ; int ans = INT_MAX ; for ( int i : newlist ) ans = min ( ans , i ) ; return ans ; } int main ( ) { string S = " ababaabba " ; cout << smallestSubstring ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mininsert ( int arr [ ] , int K , int N ) { int ans = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = min ( arr [ i ] , arr [ i + 1 ] ) ; int b = max ( arr [ i ] , arr [ i + 1 ] ) ; while ( K * a < b ) { a *= K ; ans ++ ; } } return ans ; } int main ( ) { int arr [ ] = { 2 , 10 , 25 , 21 } ; int K = 2 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << mininsert ( arr , K , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: a, ans, i, stdc
Iterator variables: i