dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; int minNum ( int n , int k ) { int x = ( int ) ( log ( n ) / log ( k ) ) + 1 ; int mn = pow ( k , x ) - n ; return mn ; } int main ( ) { int n = 20 , k = 5 ; cout << minNum ( n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; int previousPerfectSquare ( int N ) { int prevN = floor ( sqrt ( N ) ) ; if ( prevN * prevN == N ) prevN -= 1 ; return prevN * prevN ; } int previousPerfectCube ( int N ) { int prevN = floor ( cbrt ( N ) ) ; if ( prevN * prevN * prevN == N ) prevN -= 1 ; return prevN * prevN * prevN ; } int main ( ) { int n = 30 ; cout << previousPerfectSquare ( n ) << " STRNEWLINE " ; cout << previousPerfectCube ( n ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: prevN
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findCount ( int arr [ ] , int n ) { int res = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( ( arr [ i ] % 2 == 0 ) && ( arr [ j ] % 2 == 1 ) ) { res ++ ; } return res ; } int main ( ) { int a [ ] = { 5 , 4 , 1 , 2 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findCount ( a , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findCount ( int arr [ ] , int n ) { int count = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) count ++ ; else ans = ans + count ; } return ans ; } int main ( ) { int a [ ] = { 5 , 4 , 1 , 2 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << findCount ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long product ( int arr [ ] , int n ) { double occurrence = pow ( 2 , n - 1 ) ; double product = 1 ; for ( int i = 0 ; i < n ; i ++ ) { product *= pow ( arr [ i ] , occurrence ) ; } return ( long ) product ; } int main ( ) { int arr [ ] = { 10 , 3 , 7 } ; int len = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << product ( arr , len ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, product, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int MOD = 1000000007 ; long long int power ( long long int a , long long int b ) { if ( b == 0 ) return 1 ; long long int temp = power ( a , b / 2 ) ; temp = ( temp * temp ) % MOD ; if ( b % 2 != 0 ) { temp = ( temp * a ) % MOD ; } return temp ; } void palindromicSum ( int N ) { long long int sum = 0 , res , ways ; if ( N == 1 ) { cout << "9" << endl ; return ; } if ( N == 2 ) { cout << "99" << endl ; return ; } ways = N / 2 ; if ( N % 2 == 0 ) ways -- ; res = power ( 9 , ways - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { sum = sum * 10 + 45 * res ; sum %= MOD ; } cout << sum << endl ; } int main ( ) { int N = 3 ; palindromicSum ( N ) ; return 0 ; }

Accumulator variables: i, stdc, ways
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int joinNumbers ( int numA , int numB ) { int revB = 0 ; while ( numB > 0 ) { revB = revB * 10 + ( numB % 10 ) ; numB = numB / 10 ; } while ( revB > 0 ) { numA = numA * 10 + ( revB % 10 ) ; revB = revB / 10 ; } return numA ; } int findMaxSum ( int A [ ] , int B [ ] , int n ) { int maxArr [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { int X = joinNumbers ( A [ i ] , B [ i ] ) ; int Y = joinNumbers ( B [ i ] , A [ i ] ) ; int mx = max ( X , Y ) ; maxArr [ i ] = mx ; } int maxAns = 0 ; for ( int i = 0 ; i < n ; i ++ ) { maxAns += maxArr [ i ] ; } return maxAns ; } int main ( ) { int N = 5 ; int A [ 5 ] = { 11 , 23 , 38 , 43 , 59 } ; int B [ 5 ] = { 36 , 24 , 17 , 40 , 56 } ; cout << findMaxSum ( A , B , N ) ; }

Index/key variables: i, n
Accumulator variables: i, maxAns, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
void createSets ( ll n ) { if ( n <= 2 ) { cout << " - 1" ; return ; } else { ll x = ( n % 2 == 0 ) ? ( n / 2 ) : ( ( n + 1 ) / 2 ) ; cout << x << endl ; for ( ll i = 1 ; i <= n ; i ++ ) { if ( i == x ) continue ; cout << i << " ▁ " ; } } return ; } int main ( ) { ll N = 7 ; createSets ( N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int calcCount ( int arr [ ] , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( k % arr [ i ] == 0 ) count ++ ; } return count ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 5 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 6 ; cout << calcCount ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
vector < long long int > findnum ( string s1 ) { vector < long long int > v ; int a = 0 , b = 0 ; int sa = 0 , sb = 0 , i = 0 ; if ( s1 [ 0 ] == ' - ' ) { sa = 1 ; i = 1 ; } while ( isdigit ( s1 [ i ] ) ) { a = a * 10 + ( int ( s1 [ i ] ) - 48 ) ; i ++ ; } if ( s1 [ i ] == ' + ' ) { sb = 0 ; i += 1 ; } if ( s1 [ i ] == ' - ' ) { sb = 1 ; i += 1 ; } while ( i < s1 . length ( ) && isdigit ( s1 [ i ] ) ) { b = b * 10 + ( int ( s1 [ i ] ) - 48 ) ; i ++ ; } if ( sa ) a *= -1 ; if ( sb ) b *= -1 ; v . push_back ( a ) ; v . push_back ( b ) ; return v ; } string complexNumberMultiply ( vector < string > v ) { while ( v . size ( ) != 1 ) { vector < ll > v1 = findnum ( v [ 0 ] ) ; vector < ll > v2 = findnum ( v [ 1 ] ) ; v . erase ( v . begin ( ) ) ; v . erase ( v . begin ( ) ) ; ll r = ( v1 [ 0 ] * v2 [ 0 ] - v1 [ 1 ] * v2 [ 1 ] ) ; ll img = v1 [ 0 ] * v2 [ 1 ] + v1 [ 1 ] * v2 [ 0 ] ; string res = " " ; res += to_string ( r ) ; res += ' + ' ; res += to_string ( img ) + ' i ' ; v . insert ( v . begin ( ) , res ) ; } return v [ 0 ] ; } int main ( ) { int n = 3 ; vector < string > v = { "3 + 1i " , "2 + 1i " , " - 5 + - 7i " } ; cout << complexNumberMultiply ( v ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: a, b, i, res, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfect ( long long int n ) { long long int sum = 1 ; for ( long long int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( i * i != n ) sum = sum + i + n / i ; else sum = sum + i ; } } if ( sum == n && n != 1 ) return true ; return false ; } int contiguousPerfectNumber ( int arr [ ] , int n ) { int current_length = 0 ; int max_length = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPerfect ( arr [ i ] ) ) current_length ++ ; else current_length = 0 ; max_length = max ( max_length , current_length ) ; } return max_length ; } int main ( ) { int arr [ ] = { 1 , 7 , 36 , 4 , 6 , 28 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << contiguousPerfectNumber ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: current_length, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPowerful ( int n ) { while ( n % 2 == 0 ) { int power = 0 ; while ( n % 2 == 0 ) { n /= 2 ; power ++ ; } if ( power == 1 ) return false ; } for ( int factor = 3 ; factor <= sqrt ( n ) ; factor += 2 ) { int power = 0 ; while ( n % factor == 0 ) { n = n / factor ; power ++ ; } if ( power == 1 ) return false ; } return ( n == 1 ) ; } int contiguousPowerfulNumber ( int arr [ ] , int n ) { int current_length = 0 ; int max_length = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPowerful ( arr [ i ] ) ) current_length ++ ; else current_length = 0 ; max_length = max ( max_length , current_length ) ; } return max_length ; } int main ( ) { int arr [ ] = { 1 , 7 , 36 , 4 , 6 , 28 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << contiguousPowerfulNumber ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: current_length, factor, i, n, power, stdc
Iterator variables: factor, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSum ( int arr [ ] , int K , int start , int end , int max_sum ) { if ( K == 0 ) return max_sum ; int max_sum_start = max_sum + arr [ start ] ; int max_sum_end = max_sum + arr [ end ] ; int ans = max ( maxSum ( arr , K - 1 , start + 1 , end , max_sum_start ) , maxSum ( arr , K - 1 , start , end - 1 , max_sum_end ) ) ; return ans ; } void maximizeSum ( int arr [ ] , int K , int n ) { int max_sum = 0 ; int start = 0 ; int end = n - 1 ; cout << maxSum ( arr , K , start , end , max_sum ) ; } int main ( ) { int arr [ ] = { 8 , 4 , 4 , 8 , 12 , 3 , 2 , 9 } ; int K = 3 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximizeSum ( arr , K , n ) ; return 0 ; }

Index/key variables: end, start
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPointCount ( int arr [ ] , int K , int size ) { int curr_points = 0 ; int max_points = 0 ; for ( int i = 0 ; i < K ; i ++ ) curr_points += arr [ i ] ; max_points = curr_points ; int j = size - 1 ; for ( int i = K - 1 ; i >= 0 ; i -- ) { curr_points = curr_points + arr [ j ] - arr [ i ] ; max_points = max ( curr_points , max_points ) ; j -- ; } return max_points ; } int main ( ) { int arr [ ] = { 8 , 4 , 4 , 8 , 12 , 3 , 2 , 9 } ; int K = 3 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxPointCount ( arr , K , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: curr_points, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPalindrome ( int n ) { int count ; if ( n % 2 == 1 ) { count = pow ( 9 , ( n - 1 ) / 2 ) ; } else { count = pow ( 9 , ( n - 2 ) / 2 ) ; } return count ; } int sumPalindrome ( int n ) { int count = countPalindrome ( n ) ; int res = 0 ; if ( n == 1 ) return 9 ; if ( n == 2 ) return 99 ; for ( int i = 0 ; i < n ; i ++ ) { res = res * 10 + count * 5 ; } return res ; } int main ( ) { int n = 3 ; cout << sumPalindrome ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( int N , int B ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += ( B - 1 ) * pow ( B , i - 1 ) ; } return sum ; } int main ( ) { int N = 2 , B = 10 ; cout << count ( N , B ) ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long SmallestPerfectSquare ( long N ) { long X = ( long ) 1e9 ; long ans ; for ( int i = 1 ; i < sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { long a = i ; long b = N / i ; if ( ( b - a != 0 ) && ( ( b - a ) % 2 == 0 ) ) { X = min ( X , ( b - a ) / 2 ) ; } } } if ( X != 1e9 ) ans = X * X ; else ans = -1 ; return ans ; } int main ( ) { long N = 3 ; cout << SmallestPerfectSquare ( N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minCost ( int arr [ ] , int n , int circumference ) { sort ( arr , arr + n ) ; int arr2 [ 2 * n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr2 [ i ] = arr [ i ] ; arr2 [ i + n ] = arr [ i ] + circumference ; } int res = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) res = min ( res , arr2 [ i + ( n - 1 ) ] - arr2 [ i ] ) ; return res ; } int main ( ) { int arr [ ] = { 19 , 3 , 6 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int circumference = 20 ; cout << minCost ( arr , n , circumference ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findunique ( vector < int > & a , int k ) { int res = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) { int p = 0 ; for ( int j = 0 ; j < a . size ( ) ; j ++ ) { p += ( abs ( a [ j ] ) & ( 1 << i ) ) != 0 ? 1 : 0 ; } p %= k ; res += pow ( 2 , i ) * p ; } int c = 0 ; for ( auto x : a ) if ( x == res ) { c = 1 ; break ; } return c == 1 ? res : - res ; } int main ( ) { vector < int > a = { 12 , 12 , 2 , 2 , 3 } ; int k = 2 ; cout << findunique ( a , k ) << " STRNEWLINE " ; }

Index/key variables: j
Accumulator variables: i, j, p, res, stdc
Iterator variables: i, j, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int MinimumGCD ( int arr [ ] , int n ) { int g = 0 ; for ( int i = 0 ; i < n ; i ++ ) { g = __gcd ( g , arr [ i ] ) ; } return g ; } int main ( ) { int arr [ ] = { 2 , 4 , 6 , 8 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << MinimumGCD ( arr , N ) << endl ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; int stepRequired ( int N ) { int cnt = 0 ; while ( N ) { N = N & ( N - 1 ) ; cnt ++ ; } return cnt ; } int main ( ) { int N = 23 ; cout << stepRequired ( N ) ; return 0 ; }

Accumulator variables: cnt
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( int x ) { int s = sqrt ( x ) ; return ( s * s == x ) ; } bool isFibonacci ( int n ) { return isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ; } void fibonacciSubarrays ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int sum = 0 ; for ( int j = i ; j < n ; ++ j ) { sum += arr [ j ] ; if ( isFibonacci ( sum ) ) { ++ count ; } } } cout << count ; } int main ( ) { int arr [ ] = { 6 , 7 , 8 , 9 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; fibonacciSubarrays ( arr , n ) ; return 0 ; }

Index/key variables: j
Accumulator variables: stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
#define mod  1000000007
#define int  long long
using namespace std ; int factorial [ 100005 ] ; void StoreFactorials ( int n ) { factorial [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { factorial [ i ] = ( i * factorial [ i - 1 ] ) % mod ; } } int Power ( int x , int y ) { int ans = 1 ; while ( y > 0 ) { if ( y % 2 == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; y /= 2 ; } return ans ; } int invmod ( int x ) { return Power ( x , mod - 2 ) ; } int nCr ( int n , int r ) { return ( factorial [ n ] * invmod ( ( factorial [ r ] * factorial [ n - r ] ) % mod ) ) % mod ; } int CountWays ( int n , int k ) { StoreFactorials ( n ) ; int ans = 0 ; for ( int i = k ; i >= 0 ; i -- ) { if ( i % 2 == k % 2 ) { ans = ( ans + ( Power ( i , n ) * nCr ( k , i ) ) % mod ) % mod ; } else { ans = ( ans + mod - ( Power ( i , n ) * nCr ( k , i ) ) % mod ) % mod ; } } ans = ( ans * nCr ( n , k ) ) % mod ; return ans ; } signed main ( ) { int N = 5 ; int K = 5 ; cout << CountWays ( N , K ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i, n, r
Accumulator variables: i, stdc, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void PrintReverseOrder ( int N ) { if ( N <= 0 ) { return ; } else { cout << N << " ▁ " ; PrintReverseOrder ( N - 1 ) ; } } int main ( ) { int N = 5 ; PrintReverseOrder ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; void XOROfElements ( int arr [ ] , int n ) { int FirstHalfXOR = 0 ; int SecondHalfXOR = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < n / 2 ) FirstHalfXOR ^= arr [ i ] ; else SecondHalfXOR ^= arr [ i ] ; } cout << FirstHalfXOR << " , " << SecondHalfXOR << endl ; } int main ( ) { int arr [ ] = { 20 , 30 , 50 , 10 , 55 , 15 , 42 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; XOROfElements ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: FirstHalfXOR, SecondHalfXOR, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float Volume_of_cone ( float R ) { float V = ( 1 / 3.0 ) * ( 3.14 ) * ( 2 * ( R * R ) ) * ( 4 * R ) ; return V ; } int main ( ) { float R = 10.0 ; cout << Volume_of_cone ( R ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
int phi [ N ] ; int pref [ N ] ; void precompute ( ) { phi [ 1 ] = 0 ; for ( int i = 2 ; i < N ; i ++ ) phi [ i ] = i ; for ( int p = 2 ; p < N ; p ++ ) { if ( phi [ p ] == p ) { phi [ p ] = p - 1 ; for ( int i = 2 * p ; i < N ; i += p ) { phi [ i ] = ( phi [ i ] / p ) * ( p - 1 ) ; } } } } void prefix ( ) { for ( int i = 1 ; i < N ; i ++ ) pref [ i ] = pref [ i - 1 ] + phi [ i ] ; } void find_pairs ( int n ) { int total = ( n * ( n - 1 ) ) / 2 ; int ans = total - pref [ n ] ; cout << " Number ▁ of ▁ pairs ▁ from ▁ 1 ▁ to ▁ " << n << " ▁ are ▁ " << ans << endl ; } int main ( ) { precompute ( ) ; prefix ( ) ; int q [ ] = { 5 , 7 } ; int n = sizeof ( q ) / sizeof ( q [ 0 ] ) ; for ( int i = 0 ; i < n ; i ++ ) { find_pairs ( q [ i ] ) ; } return 0 ; }

Index/key variables: N, i, n, p
Accumulator variables: i, p, stdc
Iterator variables: i, p
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 balance ( int x , int y , int p , int q ) { int b1 , b2 , b3 ; if ( p % x == 0 && q % y == 0 ) { b1 = p / x ; b2 = q / y ; b3 = 1 ; } else { p = p * y ; q = q * x ; b3 = x * y ; int temp = gcd ( p , gcd ( q , b3 ) ) ; b1 = p / temp ; b2 = q / temp ; b3 = b3 / temp ; } cout << b1 << " ▁ " << b2 << " ▁ " << b3 << endl ; } int main ( ) { int x = 2 , y = 3 , p = 4 , q = 5 ; balance ( x , y , p , q ) ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int maxAlternatingSum ( int arr [ ] , int n ) { int max_sum = 0 ; int i = 0 ; while ( i < n ) { int current_max = arr [ i ] ; int k = i ; while ( k < n && ( ( arr [ i ] > 0 && arr [ k ] > 0 ) || ( arr [ i ] < 0 && arr [ k ] < 0 ) ) ) { current_max = max ( current_max , arr [ k ] ) ; k += 1 ; } max_sum += current_max ; i = k ; } return max_sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , -1 , -2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxAlternatingSum ( arr , n ) ; return 0 ; }

Index/key variables: i, k
Accumulator variables: k, max_sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; int subarrayLength ( int A [ ] , int R [ ] [ 2 ] , int N , int M ) { for ( int i = 0 ; i < M ; ++ i ) { int l = R [ i ] [ 0 ] , r = R [ i ] [ 1 ] + 1 ; l -- ; r -- ; A [ l ] ++ ; if ( r < N ) A [ r ] -- ; } for ( int i = 1 ; i < N ; ++ i ) { A [ i ] += A [ i - 1 ] ; } int count = 0 ; unordered_set < int > s ; for ( int i = 0 ; i < N ; ++ i ) { if ( s . find ( A [ i ] ) == s . end ( ) ) count ++ ; s . insert ( A [ i ] ) ; } vector < int > repeat ( count + 1 , 0 ) ; int ans = N ; int counter = 0 , left = 0 , right = 0 ; while ( right < N ) { int cur_element = A [ right ] ; repeat [ cur_element ] += 1 ; if ( repeat [ cur_element ] == 1 ) ++ counter ; while ( counter == count ) { ans = min ( ans , right - left + 1 ) ; cur_element = A [ left ] ; repeat [ cur_element ] -= 1 ; ++ left ; if ( repeat [ cur_element ] == 0 ) -- counter ; } ++ right ; } return ans ; } int main ( ) { int N = 8 , queries = 6 ; int Q [ ] [ 2 ] = { { 1 , 4 } , { 3 , 4 } , { 4 , 5 } , { 5 , 5 } , { 7 , 8 } , { 8 , 8 } } ; int A [ N ] = { 0 } ; cout << subarrayLength ( A , Q , N , queries ) ; return 0 ; }

Index/key variables: N, cur_element, i, l, left, r, right
Accumulator variables: count, l, r, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void ModifiedSieveOfEratosthenes ( int N , bool Expo_Prime [ ] ) { bool primes [ N ] ; memset ( primes , true , sizeof ( primes ) ) ; for ( int i = 2 ; i < N ; i ++ ) { if ( primes [ i ] ) { int no = i ; while ( no <= N ) { Expo_Prime [ no ] = true ; no *= i ; } for ( int j = i * i ; j < N ; j += i ) primes [ j ] = false ; } } } void Display ( int arr [ ] , bool Expo_Prime [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( Expo_Prime [ arr [ i ] ] ) cout << arr [ i ] << " ▁ " ; } void FindExpoPrime ( int arr [ ] , int n ) { int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( max < arr [ i ] ) max = arr [ i ] ; } bool Expo_Prime [ max + 1 ] ; memset ( Expo_Prime , false , sizeof ( Expo_Prime ) ) ; ModifiedSieveOfEratosthenes ( max + 1 , Expo_Prime ) ; Display ( arr , Expo_Prime , n ) ; } int main ( ) { int arr [ ] = { 4 , 6 , 9 , 16 , 1 , 3 , 12 , 36 , 625 , 1000 } ; int n = sizeof ( arr ) / sizeof ( int ) ; FindExpoPrime ( arr , n ) ; return 0 ; }

Index/key variables: N, i, j, no
Accumulator variables: i, j, no, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define ll  long long
double nthRoot ( ll A , ll N ) { double xPre = 7 ; double eps = 1e-3 ; double delX = INT_MAX ; double xK ; while ( delX > eps ) { xK = ( ( N - 1.0 ) * xPre + ( double ) A / pow ( xPre , N - 1 ) ) / ( double ) N ; delX = abs ( xK - xPre ) ; xPre = xK ; } return xK ; } bool check ( ll no , int k ) { double kth_root = nthRoot ( no , k ) ; ll num = kth_root ; if ( abs ( num - kth_root ) < 1e-4 ) return true ; return false ; } void printExpo ( ll arr [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( check ( arr [ i ] , k ) ) cout << arr [ i ] << " ▁ " ; } } int main ( ) { int K = 6 ; ll arr [ ] = { 46656 , 64 , 256 , 729 , 16 , 1000 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printExpo ( 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 ; int CntcontSubs ( int a [ ] , int n ) { int c = 0 , d = 0 , i , sum = 1 , j ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 != 0 a [ i ] % 4 == 0 ) d ++ ; sum = a [ i ] ; for ( j = i + 1 ; j < n ; j ++ ) { sum = sum * a [ j ] ; if ( sum % 2 != 0 sum % 4 == 0 ) c ++ ; } sum = 1 ; } return c + d ; } int main ( ) { int arr [ ] = { 5 , 4 , 2 , 9 , 8 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << CntcontSubs ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: c, d, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CntcontSubs ( int a [ ] , int n ) { int prod = 1 ; vector < pair < int , int > > vect ; vect . push_back ( make_pair ( 0 , 2 ) ) ; vector < int > two , zero ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = a [ i ] % 4 ; if ( a [ i ] < 0 ) a [ i ] = a [ i ] + 4 ; if ( a [ i ] == 2 ) two . push_back ( i + 1 ) ; if ( a [ i ] == 0 ) zero . push_back ( i + 1 ) ; if ( a [ i ] == 0 a [ i ] == 2 ) vect . push_back ( make_pair ( i + 1 , a [ i ] ) ) ; } vect . push_back ( make_pair ( n + 1 , 2 ) ) ; int total = ( n * ( n + 1 ) ) / 2 ; if ( two . empty ( ) ) return total ; else { int sum = 0 ; int pos1 = -1 , pos2 = -1 , pos3 = -1 ; int sz = vect . size ( ) ; for ( int i = 1 ; i + 1 < sz ; i ++ ) { if ( vect [ i ] . second == 2 ) { sum += ( vect [ i ] . first - vect [ i - 1 ] . first ) * ( vect [ i + 1 ] . first - vect [ i ] . first ) - 1 ; } } return total - sum - two . size ( ) ; } } int main ( ) { int a [ ] = { 5 , 4 , 2 , 9 , 8 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << CntcontSubs ( a , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubarray ( int n ) { return ( ( n ) * ( n + 1 ) ) / 2 ; } int countSubsequence ( int n ) { return pow ( 2 , n ) ; } int main ( ) { int n = 5 ; cout << ( countSubarray ( n ) ) << endl ; cout << ( countSubsequence ( n ) ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float y ( float x ) { return ( 1 / ( 1 + x ) ) ; } float BooleRule ( float a , float b ) { int n = 4 ; int h ; h = ( ( b - a ) / n ) ; float sum = 0 ; float bl = ( ( 7 * y ( a ) + 32 * y ( a + h ) + 12 * y ( a + 2 * h ) + 32 * y ( a + 3 * h ) + 7 * y ( a + 4 * h ) ) * 2 * h / 45 ) ; sum = sum + bl ; return sum ; } int main ( ) { float lowlimit = 0 ; float upplimit = 4 ; cout << fixed << setprecision ( 4 ) << " f ( x ) ▁ = ▁ " << BooleRule ( 0 , 4 ) ; return 0 ; }

Accumulator variables: stdc