dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find ( int a [ ] , int n , int k ) { vector < int > v ; for ( int i = 1 ; i < n ; ++ i ) { v . push_back ( a [ i - 1 ] - a [ i ] ) ; } sort ( v . begin ( ) , v . end ( ) ) ; int res = a [ n - 1 ] - a [ 0 ] ; for ( int i = 0 ; i < k - 1 ; ++ i ) { res += v [ i ] ; } return res ; } int main ( ) { int arr [ ] = { 4 , 8 , 15 , 16 , 23 , 42 } ; int N = sizeof ( arr ) / sizeof ( int ) ; int K = 3 ; cout << find ( arr , N , K ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long power ( long a , long b , long c ) { long result = 1 ; while ( b > 0 ) { if ( ( b & 1 ) == 1 ) { result = ( result * a ) % c ; } b /= 2 ; a = ( a * a ) % c ; } return result ; } long calculate ( long X , long N ) { int a [ 10 ] ; int cyclicity [ 11 ] ; cyclicity [ 1 ] = 1 ; cyclicity [ 2 ] = 4 ; cyclicity [ 3 ] = 4 ; cyclicity [ 4 ] = 2 ; cyclicity [ 5 ] = 1 ; cyclicity [ 6 ] = 1 ; cyclicity [ 7 ] = 4 ; cyclicity [ 8 ] = 4 ; cyclicity [ 9 ] = 2 ; cyclicity [ 10 ] = 1 ; if ( N == 0 N == 1 ) { return ( X % 10 ) ; } else if ( N == 2 N == 3 N == 4 ) { long temp = ( long ) 1e18 ; a [ 2 ] = 2 ; a [ 3 ] = 6 ; a [ 4 ] = 4 ; long v = X % 10 ; if ( v != 0 ) { int u = cyclicity [ ( int ) v ] ; int r = a [ ( int ) N ] % u ; if ( r == 0 ) { if ( v == 2 v == 4 v == 6 v == 8 ) { return 6 ; } else if ( v == 5 ) { return 5 ; } else if ( v == 1 v == 3 v == 7 v == 9 ) { return 1 ; } } else { return ( power ( v , r , temp ) % 10 ) ; } } else { return 0 ; } } return 1 ; } int main ( ) { int X = 18 ; int N = 4 ; long result = calculate ( X , N ) ; cout << result ; }

Accumulator variables: b, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int formQuadruplets ( int arr [ ] , int n ) { int ans = 0 , pairs = 0 ; pairs = n / 4 ; sort ( arr , arr + n , greater < int > ( ) ) ; for ( int i = 0 ; i < n - pairs ; i += 3 ) { ans += arr [ i + 2 ] ; } return ans ; } int main ( ) { int arr [ ] = { 2 , 1 , 7 , 5 , 5 , 4 , 1 , 1 , 3 , 3 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << formQuadruplets ( arr , n ) << endl ; return 0 ; }

Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LIS ( int arr [ ] , int n ) { map < int , vector < int > > m ; for ( int i = 0 ; i < n ; i ++ ) m [ arr [ i ] ] . push_back ( i ) ; int k = n ; int ans = 0 ; for ( auto it = m . begin ( ) ; it != m . end ( ) ; it ++ ) { if ( it -> second . back ( ) < k ) { k = it -> second [ 0 ] ; ans += 1 ; } else k = * lower_bound ( it -> second . begin ( ) , it -> second . end ( ) , k ) ; } cout << ans << endl ; } int main ( ) { int arr [ ] = { 1 , 3 , 2 , 1 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; LIS ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, it, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } void IsPossible ( int a , int b , int x , int y ) { int final = gcd ( x , y ) ; int initial = gcd ( a , b ) ; if ( initial == final ) { cout << " POSSIBLE STRNEWLINE " ; } else { cout << " NOT ▁ POSSIBLE STRNEWLINE " ; } } int main ( ) { int A = 1 , B = 2 , X = 4 , Y = 11 ; IsPossible ( A , B , X , Y ) ; A = 2 , B = 2 , X = 3 , Y = 6 ; IsPossible ( A , B , X , Y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int mod = 1000000007 ; int waysToColor ( int arr [ ] , int n , int k ) { int powOf2 [ 500 ] = { 0 } ; int c [ 500 ] [ 500 ] ; for ( int i = 0 ; i <= n ; i ++ ) { c [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { c [ i ] [ j ] = ( c [ i - 1 ] [ j ] + c [ i - 1 ] [ j - 1 ] ) % mod ; } } powOf2 [ 0 ] = powOf2 [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { powOf2 [ i ] = powOf2 [ i - 1 ] * 2 % mod ; } int rem = n - k ; arr [ k ++ ] = n + 1 ; sort ( arr , arr + k ) ; int answer = 1 ; for ( int i = 0 ; i < k ; i ++ ) { int x = arr [ i ] - ( i - 1 >= 0 ? arr [ i - 1 ] : 0 ) - 1 ; answer *= c [ rem ] [ x ] % mod * ( i != 0 && i != k - 1 ? powOf2 [ x ] : 1 ) % mod ; rem -= x ; } return answer ; } int main ( ) { int N = 6 ; int K = 3 ; int arr [ K ] = { 1 , 2 , 6 } ; cout << waysToColor ( arr , N , K ) ; return 0 ; }

Index/key variables: K, i, j, rem, x
Accumulator variables: answer, i, j, k, rem, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArray ( int * a , int n ) { sort ( a , a + n ) ; int i = 0 ; int j = n - 1 ; while ( i <= j ) { if ( i == j ) { cout << a [ i ] << " ▁ " ; } else { cout << a [ j ] << " ▁ " ; cout << a [ i ] << " ▁ " ; } i = i + 1 ; j = j - 1 ; } cout << endl ; } int main ( ) { int arr1 [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n1 = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; printArray ( arr1 , n1 ) ; }

Index/key variables: i, j
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int SmallestDiv ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return i ; } } return n ; } int main ( ) { int X = 385 ; int ans = SmallestDiv ( X ) ; cout << ans << " STRNEWLINE " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) cout << arr [ i ] << " ▁ " ; } void findArray ( int n , int k , int s ) { int vis [ n ] = { 0 } ; int cnt = 0 ; int arr [ n ] ; for ( int i = 0 ; i < n && cnt < k ; i += 2 ) { arr [ i ] = s ; vis [ i ] = 1 ; cnt ++ ; } int val = s ; if ( s % 2 == 0 ) val ++ ; else val = val + 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis [ i ] == 0 ) { arr [ i ] = val ; } } printArr ( arr , n ) ; } int main ( ) { int n = 8 , k = 3 , s = 12 ; findArray ( n , k , s ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: cnt, i, stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 100000 ; int prime [ N ] ; int divi [ N ] ; int sum [ N ] ; void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < N ; i ++ ) prime [ i ] = 1 ; prime [ 0 ] = prime [ 1 ] = 0 ; for ( int p = 2 ; p * p < N ; p ++ ) { if ( prime [ p ] == 1 ) { for ( int i = p * p ; i < N ; i += p ) prime [ i ] = 0 ; } } } void DivisorCount ( ) { for ( int i = 1 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j += i ) { divi [ j ] ++ ; } } } void pre ( ) { for ( int i = 1 ; i < N ; i ++ ) { if ( prime [ divi [ i ] ] == 1 ) { sum [ i ] = i ; } } for ( int i = 1 ; i < N ; i ++ ) sum [ i ] += sum [ i - 1 ] ; } int main ( ) { int l = 5 , r = 8 ; SieveOfEratosthenes ( ) ; DivisorCount ( ) ; pre ( ) ; cout << sum [ r ] - sum [ l - 1 ] ; return 0 ; }

Index/key variables: N, i, j, p, r
Accumulator variables: i, j, p, stdc
Iterator variables: i, j, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define M  1000000007
#define ll  long long int
ll power ( ll x , ll y , ll p ) { ll res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } ll modInverse ( ll n , ll p ) { return power ( n , p - 2 , p ) ; } ll nCrModPFermat ( ll n , ll r , ll p ) { if ( r == 0 ) return 1 ; ll fac [ n + 1 ] ; fac [ 0 ] = 1 ; for ( ll i = 1 ; i <= n ; i ++ ) fac [ i ] = fac [ i - 1 ] * i % p ; return ( fac [ n ] * modInverse ( fac [ r ] , p ) % p * modInverse ( fac [ n - r ] , p ) % p ) % p ; } ll countOdd ( ll n ) { ll x = n / 2 ; if ( n % 2 == 1 ) x ++ ; return x ; } ll counteEven ( ll n ) { ll x = n / 2 ; return x ; } ll CountEvenSumSequences ( ll n ) { ll count = 0 ; for ( ll i = 0 ; i <= n ; i ++ ) { ll even = i , odd = n - i ; if ( odd % 2 == 1 ) continue ; ll tot = ( power ( countOdd ( n ) , odd , M ) * nCrModPFermat ( n , odd , M ) ) % M ; tot = ( tot * power ( counteEven ( n ) , i , M ) ) % M ; count += tot ; count %= M ; } return count ; } int main ( ) { ll n = 5 ; cout << CountEvenSumSequences ( n ) ; return 0 ; }

Index/key variables: i, n, r
Accumulator variables: count, i, stdc, x
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1000000
bool prime [ MAX ] ; void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < MAX ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * p ; i < MAX ; i += p ) prime [ i ] = false ; } } } int sumPrime ( int k ) { SieveOfEratosthenes ( ) ; vector < int > v ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( prime [ i ] ) v . push_back ( i ) ; } int sum = 0 ; int skip = ( k * ( k - 1 ) ) / 2 ; while ( k > 0 ) { sum += v [ skip ] ; skip ++ ; k -- ; } return sum ; } int main ( ) { int k = 3 ; cout << sumPrime ( k ) ; return 0 ; }

Index/key variables: MAX, i, p, skip
Accumulator variables: i, k, p, skip, stdc, sum
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nextOccurrence ( string str , int n , int start , char ch ) { for ( int i = start ; i < n ; i ++ ) { if ( str [ i ] == ch ) return i ; } return -1 ; } int countSubStr ( string str , int n , char ch ) { int cnt = 0 ; int j = nextOccurrence ( str , n , 0 , ch ) ; for ( int i = 0 ; i < n ; i ++ ) { while ( j != -1 && j < i ) { j = nextOccurrence ( str , n , j + 1 , ch ) ; } if ( j == -1 ) break ; cnt += ( n - j ) ; } return cnt ; } int main ( ) { string str = " geeksforgeeks " ; int n = str . length ( ) ; char ch = ' k ' ; cout << countSubStr ( str , n , ch ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkEvenOdd ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { cout << " Even " ; return ; } } cout << " Odd " ; } int main ( ) { int arr [ ] = { 2 , 12 , 20 , 36 , 38 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; checkEvenOdd ( 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 power ( int x , unsigned int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } int main ( ) { int L = 2 , P = pow ( 10 , 9 ) ; int ans = power ( 325 , L , P ) ; cout << ans << " STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAXN  30
int countMaxLength ( int N ) { int res ; int pre [ MAXN ] , p = 1 ; pre [ 0 ] = 0 ; for ( int i = 1 ; i < MAXN ; i ++ ) { p *= 2 ; pre [ i ] = pre [ i - 1 ] + i * p ; } int ind ; for ( int i = 1 ; i < MAXN ; i ++ ) { if ( pre [ i ] >= N ) { ind = i ; break ; } } int x = N - pre [ ind - 1 ] ; int y = 2 * ind - 1 ; if ( x >= y ) res = min ( x , y ) ; else res = max ( x , 2 * ( ind - 2 ) + 1 ) ; return res ; } int main ( ) { int N = 25 ; cout << countMaxLength ( N ) ; return 0 ; }

Index/key variables: MAXN, i
Accumulator variables: i, p, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorialUsingRecursion ( int n ) { if ( n == 0 ) return 1 ; return n * factorialUsingRecursion ( n - 1 ) ; } int factorialUsingIteration ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } int main ( ) { int num = 5 ; cout << " Factorial ▁ of ▁ " << num << " ▁ using ▁ Recursion ▁ is : ▁ " << factorialUsingRecursion ( 5 ) << endl ; cout << " Factorial ▁ of ▁ " << num << " ▁ using ▁ Iteration ▁ is : ▁ " << factorialUsingIteration ( 5 ) ; return 0 ; }

Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int R = 0 ; int getLen ( int n ) { int len = ( int ) ( log ( n ) / log ( 2 ) ) + 1 ; return len ; } void set_jump_pointer ( vector < vector < int > > & jump , int * node , int len , int n ) { for ( int j = 1 ; j <= len ; j ++ ) for ( int i = 0 ; i < n ; i ++ ) jump [ node [ i ] ] [ j ] = jump [ jump [ node [ i ] ] [ j - 1 ] ] [ j - 1 ] ; } void constructGraph ( vector < vector < int > > & jump , int * node , int * isNode , int c , int p , int i ) { node [ i ] = c ; if ( isNode == 0 ) { isNode = 1 ; jump [ 0 ] = p ; } return ; } void jumpPointer ( vector < vector < int > > & jump , int * isNode , int x , int L ) { int j = 0 , n = x , k = L ; if ( isNode [ x ] == 0 ) { cout << " Node ▁ is ▁ not ▁ present ▁ in ▁ graph ▁ " << endl ; return ; } while ( L > 0 ) { if ( L & 1 ) x = jump [ x ] [ j ] ; L = L >> 1 ; j ++ ; } cout << k << " th ▁ parent ▁ of ▁ node ▁ " << n << " ▁ is ▁ = ▁ " << x << endl ; return ; } int main ( ) { int n = 11 ; vector < vector < int > > jump ( 1000 , vector < int > ( 10 ) ) ; int * node = new int [ 1000 ] ; int * isNode = new int [ 1000 ] ; memset ( isNode , 0 , 1000 * sizeof ( int ) ) ; int len = getLen ( n ) ; R = 2 ; constructGraph ( jump , node , isNode , 2 , 0 , 0 ) ; constructGraph ( jump , node , isNode , 5 , 2 , 1 ) ; constructGraph ( jump , node , isNode , 3 , 5 , 2 ) ; constructGraph ( jump , node , isNode , 4 , 5 , 3 ) ; constructGraph ( jump , node , isNode , 1 , 5 , 4 ) ; constructGraph ( jump , node , isNode , 7 , 1 , 5 ) ; constructGraph ( jump , node , isNode , 9 , 1 , 6 ) ; constructGraph ( jump , node , isNode , 10 , 9 , 7 ) ; constructGraph ( jump , node , isNode , 11 , 10 , 8 ) ; constructGraph ( jump , node , isNode , 6 , 10 , 9 ) ; constructGraph ( jump , node , isNode , 8 , 10 , 10 ) ; set_jump_pointer ( jump , node , len , n ) ; jumpPointer ( jump , isNode , 2 , 0 ) ; jumpPointer ( jump , isNode , 4 , 2 ) ; jumpPointer ( jump , isNode , 8 , 3 ) ; jumpPointer ( jump , isNode , 20 , 5 ) ; return 0 ; }

Index/key variables: i, j, x
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void revereseArray ( int arr [ ] , int n ) { int rev [ n ] ; for ( int i = 0 ; i < n ; i ++ ) rev [ n - i - 1 ] = arr [ i ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = rev [ i ] ; } void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) cout << arr [ i ] << " ▁ " ; cout << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printArray ( arr , n ) ; revereseArray ( arr , n ) ; cout << " Reversed ▁ array ▁ is " << endl ; printArray ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void revereseArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n / 2 ; i ++ ) swap ( arr [ i ] , arr [ n - i - 1 ] ) ; } void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) cout << arr [ i ] << " ▁ " ; cout << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printArray ( arr , n ) ; revereseArray ( arr , n ) ; cout << " Reversed ▁ array ▁ is " << endl ; printArray ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findString ( string str , int M ) { int N = str . length ( ) ; M = min ( M , N ) ; string s1 = " " ; while ( M != 0 ) { s1 = " " ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '0' ) { if ( ( str [ i - 1 ] == '1' && str [ i + 1 ] != '1' ) || ( str [ i - 1 ] != '1' && str [ i + 1 ] == '1' ) ) s1 += '1' ; else s1 += '0' ; } else s1 += '1' ; } if ( str == s1 ) break ; str = s1 ; M -- ; } cout << s1 ; } int main ( ) { string str = "0110100" ; int M = 3 ; findString ( str , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: M, i, s1, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberofSubsequences ( int a [ ] , int L , int R , int X , int n ) { int ans = 0 ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { int cnt = 0 , sum = 0 ; int minVal = INT_MAX , maxVal = INT_MIN ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) ) { cnt += 1 ; sum += a [ j ] ; maxVal = max ( maxVal , a [ j ] ) ; minVal = min ( minVal , a [ j ] ) ; } } if ( cnt >= 2 && sum >= L && sum <= R && ( maxVal - minVal >= X ) ) { ans += 1 ; } } return ans ; } int main ( ) { int a [ ] = { 10 , 20 , 30 , 25 } ; int L = 40 , R = 50 , X = 10 ; int N = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << numberofSubsequences ( a , L , R , X , N ) << endl ; return 0 ; }

Index/key variables: j
Accumulator variables: ans, cnt, i, j, stdc, sum
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int Minimum ( int N , int K ) { int sum = N * ( N + 1 ) / 2 ; if ( K > sum ) return -1 ; if ( K <= N ) return 1 ; sum = 0 ; int count = 0 ; while ( N >= 1 && sum < K ) { count += 1 ; sum += N ; N -= 1 ; } return count ; } int main ( ) { int N = 5 , K = 10 ; cout << ( Minimum ( N , K ) ) ; return 0 ; }

Accumulator variables: N, count, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Count ( int N , int K ) { if ( K == 0 ) return 0 ; int res = 0 ; int low = 1 , high = N ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int sum = ( mid * mid + mid ) / 2 ; if ( sum <= K ) { res = max ( res , mid ) ; low = mid + 1 ; } else { high = mid - 1 ; } } return res ; } int main ( ) { int N = 6 , K = 14 ; cout << Count ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int largestNum ( int arr [ ] , int n ) { set < int > st ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { st . insert ( arr [ i ] ) ; if ( st . find ( -1 * arr [ i ] ) != st . end ( ) ) { res = max ( res , abs ( arr [ i ] ) ) ; } } return res ; } int main ( ) { int arr [ ] = { 3 , 2 , -2 , 5 , -3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << largestNum ( arr , n ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findElement ( int A [ ] , int N , int X ) { int i = 0 ; int Comparisons = 0 ; int T = 1 ; string Found = " No " ; Comparisons ++ ; if ( N % 2 == 1 ) { i = 1 ; T *= ( A [ 0 ] - X ) ; } for ( ; i < N ; i += 2 ) { Comparisons += 1 ; T *= ( A [ i ] - X ) ; T *= ( A [ i + 1 ] - X ) ; } Comparisons += 1 ; if ( T == 0 ) { cout << " Yes ▁ " << Comparisons ; } else { cout << " No " ; } } int main ( ) { int A [ ] = { -3 , 5 , 11 , 3 , 100 , 2 , 88 , 22 , 7 , 900 , 23 , 4 , 1 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int X = 1 ; findElement ( A , N , X ) ; return 0 ; }

Index/key variables: i
Accumulator variables: Comparisons, T, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find ( vector < int > arr , int N , int key ) { int l = 0 ; int h = N - 1 ; while ( l <= h ) { int mid = ( l + h ) / 2 ; if ( arr [ mid ] == key ) return mid ; if ( arr [ l ] >= arr [ mid ] ) { if ( arr [ l ] >= key && key >= arr [ mid ] ) h = mid - 1 ; else l = mid + 1 ; } else { if ( arr [ mid ] >= key && key >= arr [ h ] ) l = mid + 1 ; else h = mid - 1 ; } } return -1 ; } int main ( ) { vector < int > arr = { 10 , 8 , 6 , 5 , 2 , 1 , 13 , 12 } ; int N = arr . size ( ) ; int key = 8 ; int ans = find ( arr , N , key ) ; cout << ans ; }

Index/key variables: h, l, mid
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxItems ( int n , int m , int a [ ] , int b [ ] , int K ) { int count = 0 ; int A [ n + 1 ] ; int B [ m + 1 ] ; A [ 0 ] = 0 ; B [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { A [ i ] = a [ i - 1 ] + A [ i - 1 ] ; } for ( int i = 1 ; i <= m ; i ++ ) { B [ i ] = b [ i - 1 ] + B [ i - 1 ] ; } for ( int i = 0 ; i <= n ; i ++ ) { if ( A [ i ] > K ) break ; int rem = K - A [ i ] ; int j = 0 ; int lo = 0 , hi = m ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; if ( B [ mid ] <= rem ) { j = mid ; lo = mid + 1 ; } else { hi = mid - 1 ; } } count = max ( j + i , count ) ; } cout << count ; } int main ( ) { int n = 4 , m = 5 , K = 7 ; int A [ n ] = { 2 , 4 , 7 , 3 } ; int B [ m ] = { 1 , 9 , 3 , 4 , 5 } ; maxItems ( n , m , A , B , K ) ; return 0 ; }

Index/key variables: i, m, mid, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getCountPairs ( int arr [ ] , int N , int S ) { map < int , int > mp ; for ( int i = 0 ; i < N ; i ++ ) { mp [ arr [ i ] ] ++ ; } int twice_count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . find ( S - arr [ i ] ) != mp . end ( ) ) { twice_count += mp [ S - arr [ i ] ] ; } if ( S - arr [ i ] == arr [ i ] ) twice_count -- ; } return twice_count / 2 ; } int countPairs ( int arr [ ] , int N ) { int count = 0 ; 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 ( ) { int N = 6 ; int arr [ ] = { 4 , 2 , 5 , 1 , 3 , 5 } ; cout << ( countPairs ( arr , N ) ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc, twice_count
Iterator variables: ele, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int N ) { if ( N == 1 ) return false ; for ( int i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) return false ; } return true ; } int findCoPrime ( int L , int R ) { int coPrime ; for ( int i = R + 1 ; ; i ++ ) { if ( isPrime ( i ) ) { coPrime = i ; break ; } } return coPrime ; } int main ( ) { int L = 16 , R = 17 ; cout << findCoPrime ( L , R ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maximumValue ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { ans = max ( ans , arr [ i ] + arr [ j ] + i - j ) ; } } cout << ans ; } int main ( ) { int arr [ ] = { 1 , 9 , 3 , 6 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumValue ( arr , 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 ; void maximumValue ( int arr [ ] , int n ) { int maxvalue = arr [ 0 ] ; int result = 0 ; for ( int i = 1 ; i < n ; i ++ ) { result = max ( result , maxvalue + arr [ i ] - i ) ; maxvalue = max ( maxvalue , arr [ i ] + i ) ; } cout << result ; } int main ( ) { int arr [ ] = { 1 , 9 , 3 , 6 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumValue ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; int closestValue ( vector < int > A , int k ) { int close = A . back ( ) ; auto it = lower_bound ( A . begin ( ) , A . end ( ) , k ) ; if ( it != A . end ( ) ) { close = * it ; if ( it != A . begin ( ) ) { if ( ( k - * ( it - 1 ) ) < ( close - k ) ) { close = * ( it - 1 ) ; } } } return close ; } void minPossible ( vector < int > arr , vector < int > brr , vector < int > crr ) { sort ( arr . begin ( ) , arr . end ( ) ) ; sort ( crr . begin ( ) , crr . end ( ) ) ; int minimum = INT_MAX ; for ( int val : brr ) { int arr_close = closestValue ( arr , val ) ; int crr_close = closestValue ( crr , val ) ; if ( abs ( val - arr_close ) + abs ( val - crr_close ) < minimum ) minimum = abs ( val - arr_close ) + abs ( val - crr_close ) ; } cout << minimum ; } int main ( ) { vector < int > a = { 1 , 8 , 5 } ; vector < int > b = { 2 , 9 } ; vector < int > c = { 5 , 4 } ; minPossible ( a , b , c ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: val