dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isCenteredOctadecagonal ( int N ) { float n = ( 9 + sqrt ( 36 * N + 45 ) ) / 18 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int n = 19 ; if ( isCenteredOctadecagonal ( n ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double kthRoot ( double n , int k ) { return pow ( k , ( 1.0 / k ) * ( log ( n ) / log ( k ) ) ) ; } int main ( ) { double N = 8.0 ; int K = 3 ; cout << kthRoot ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPower ( int N , int K ) { int res1 = log ( N ) / log ( K ) ; double res2 = log ( N ) / log ( K ) ; return ( res1 == res2 ) ; } int main ( ) { int N = 8 ; int K = 2 ; if ( isPower ( N , K ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void cntArray ( int A [ ] , int N ) { int result = 0 ; int frequency [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { frequency [ A [ i ] ] ++ ; } for ( int i = 1 ; i <= N ; i ++ ) { int frequency_of_i = frequency [ i ] ; result += + ( ( frequency_of_i ) * ( frequency_of_i + 1 ) ) / 2 ; } cout << result << endl ; } int main ( ) { int A [ ] = { 1 , 5 , 6 , 1 , 9 , 5 , 8 , 10 , 8 , 9 } ; int N = sizeof ( A ) / sizeof ( int ) ; cntArray ( A , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMaxSize ( int a [ ] , int n ) { vector < int > frq ( n + 1 ) ; for ( int i = 0 ; i < n ; ++ i ) frq [ a [ i ] ] ++ ; int maxfrq = * max_element ( frq . begin ( ) , frq . end ( ) ) ; int dist = n + 1 - count ( frq . begin ( ) , frq . end ( ) , 0 ) ; int ans1 = min ( maxfrq - 1 , dist ) ; int ans2 = min ( maxfrq , dist - 1 ) ; int ans = max ( ans1 , ans2 ) ; return ans ; } int main ( ) { int arr [ ] = { 4 , 2 , 4 , 1 , 4 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMaxSize ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int subarray ( int arr [ ] , int n ) { int ans = 1 , temp = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) { ++ temp ; } else { ans = max ( ans , temp ) ; temp = 1 ; } } ans = max ( ans , temp ) ; return ans ; } int main ( ) { int arr [ ] = { 2 , 2 , 1 , 1 , 2 , 2 , 2 , 3 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << subarray ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void findMaxMinSubArray ( int arr [ ] , int K , int n ) { int min = n ; int max = 0 ; int left ; int right ; int tmp ; for ( int i = 0 ; i < n ; i ++ ) { tmp = 1 ; left = i ; while ( left - 1 >= 0 && abs ( arr [ left ] - arr [ left - 1 ] ) <= K ) { left -- ; tmp ++ ; } right = i ; while ( right + 1 <= n - 1 && abs ( arr [ right ] - arr [ right + 1 ] ) <= K ) { right ++ ; tmp ++ ; } if ( min > tmp ) min = tmp ; if ( max < tmp ) max = tmp ; } cout << min << " , ▁ " << max << endl ; } int main ( ) { int arr [ ] = { 1 , 2 , 5 , 6 , 7 } ; int K = 2 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findMaxMinSubArray ( arr , K , n ) ; return 0 ; }

Index/key variables: left, right
Accumulator variables: i, left, right, tmp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countElement ( int arr [ ] , int n ) { map < int , int > freq ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int tmpsum = arr [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { tmpsum += arr [ j ] ; if ( freq . find ( tmpsum ) != freq . end ( ) ) { ans += freq [ tmpsum ] ; } } } return ans ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countElement ( arr , n ) << endl ; return 0 ; }

Index/key variables: i, j, tmpsum
Accumulator variables: ans, i, j, stdc, tmpsum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
double kthRoot ( double n , int k ) { return pow ( k , ( 1.0 / k ) * ( log ( n ) / log ( k ) ) ) ; } int main ( void ) { double n = 81 ; int k = 4 ; printf ( " % lf ▁ " , kthRoot ( n , k ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void distributeN ( int A , int B , int C , int n ) { int max1 = max ( A , B ) ; int max2 = max ( B , C ) ; int maximum = max ( max1 , max2 ) ; int sum = A + B + C ; int p = ( 3 * maximum ) - sum ; int diff = n - p ; if ( diff < 0 diff % 3 ) cout << " No " ; else cout << " Yes " ; } int main ( ) { int A = 10 , B = 20 ; int C = 15 , n = 14 ; distributeN ( A , B , C , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void sumOddNumbers ( int N , int K ) { int check = N - ( K - 1 ) ; if ( check > 0 && check % 2 == 1 ) { for ( int i = 0 ; i < K - 1 ; i ++ ) { cout << "1 ▁ " ; } cout << check ; } else cout << " - 1" ; } int main ( ) { int N = 5 ; int K = 3 ; sumOddNumbers ( N , K ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumSteps ( int a , int b , int c ) { if ( a < 1 b < 1 ) return -1 ; if ( a == 1 && b == 1 ) return c ; if ( a < b ) { a = a + b ; b = a - b ; a = a - b ; } return minimumSteps ( a - b , b , c + 1 ) ; } int main ( ) { int a = 75 ; int b = 17 ; cout << minimumSteps ( a , b , 0 ) << endl ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LongestMountain ( vector < int > & a ) { int i = 0 , j = -1 , k = -1 , p = 0 , d = 0 , n = 0 ; if ( a . size ( ) < 3 ) { return 0 ; } for ( i = 0 ; i < a . size ( ) - 1 ; i ++ ) { if ( a [ i + 1 ] > a [ i ] ) { if ( k != -1 ) { k = -1 ; j = -1 ; } if ( j == -1 ) { j = i ; } } else { if ( a [ i + 1 ] < a [ i ] ) { if ( j != -1 ) { k = i + 1 ; } if ( k != -1 && j != -1 ) { if ( d < k - j + 1 ) { d = k - j + 1 ; } } } else { k = -1 ; j = -1 ; } } } if ( k != -1 && j != -1 ) { if ( d < k - j + 1 ) { d = k - j + 1 ; } } return d ; } int main ( ) { vector < int > d = { 1 , 3 , 1 , 4 , 5 , 6 , 7 , 8 , 9 , 8 , 7 , 6 , 5 } ; cout << LongestMountain ( d ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string solve ( vector < int > & A ) { int i , ctr = 0 ; for ( i = 0 ; i < A . size ( ) ; i ++ ) { if ( A [ i ] % 2 ) { ctr ++ ; } } if ( ctr % 2 ) { return " No " ; } else { return " Yes " ; } } int main ( ) { vector < int > arr = { 9 , 17 } ; cout << solve ( arr ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ctr, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPerfectSquare ( long double x ) { long double sr = sqrt ( x ) ; return ( ( sr - floor ( sr ) ) == 0 ) ; } int countSquares ( int n ) { int cnt = 0 ; for ( int i = pow ( 10 , ( n - 1 ) ) ; i < pow ( 10 , n ) ; i ++ ) { if ( i != 0 && isPerfectSquare ( i ) ) cnt ++ ; } return cnt ; } int main ( ) { int n = 3 ; cout << countSquares ( n ) ; return 0 ; }

Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSquares ( int n ) { int r = ceil ( sqrt ( pow ( 10 , n ) ) ) ; int l = ceil ( sqrt ( pow ( 10 , n - 1 ) ) ) ; return r - l ; } int main ( ) { int n = 3 ; cout << countSquares ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int summation ( int N ) { int co = ( N + 1 ) / 2 ; int ce = ( N ) / 2 ; int se = 2 * ( ( ce * ( ce + 1 ) ) * ( ce * ( ce + 1 ) ) ) ; int so = ( co * co ) * ( 2 * ( ( co * co ) ) - 1 ) ; return so - se ; } int main ( ) { int n = 3 ; cout << summation ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isStar ( int N ) { float n = ( 6 + sqrt ( 24 * N + 12 ) ) / 6 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int i = 13 ; if ( isStar ( i ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinDivisor ( int arr [ ] , int n , int limit ) { int low = 0 , high = 1e9 ; while ( low < high ) { int mid = ( low + high ) / 2 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ceil ( ( double ) arr [ i ] / ( double ) mid ) ; } if ( sum <= limit ) high = mid ; else low = mid + 1 ; } return low ; } int main ( ) { int arr [ ] = { 2 , 3 , 4 , 9 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 6 ; cout << findMinDivisor ( arr , N , K ) ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getCount ( int arr [ ] , int n ) { int count = 0 ; for ( int j = 1 ; j < n - 1 ; j ++ ) { int p = 0 , q = 0 ; for ( int i = 0 ; i < j ; i ++ ) { if ( arr [ j ] % arr [ i ] == 0 ) p ++ ; } for ( int k = j + 1 ; k < n ; k ++ ) { if ( arr [ k ] % arr [ j ] == 0 ) q ++ ; } count += p * q ; } return count ; } int main ( ) { int arr [ ] = { 1 , 2 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << getCount ( arr , N ) << endl ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, p, q, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; float computeMaxValue ( float arr [ ] , int n ) { float ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { float val = max ( arr [ i ] / arr [ j ] , arr [ j ] / arr [ i ] ) ; ans = max ( ans , val ) ; } } return ans ; } int main ( ) { float arr [ ] = { 15 , 10 , 3 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << computeMaxValue ( 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 ; int kthNonDivisible ( int N , int K ) { return K + floor ( ( K - 1 ) / ( N - 1 ) ) ; } int main ( ) { int N = 3 ; int K = 6 ; cout << kthNonDivisible ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int sz = 1e3 ; bool isEvenParity ( int x ) { int parity = 0 ; while ( x != 0 ) { if ( x & 1 ) parity ++ ; x = x >> 1 ; } if ( parity % 2 == 0 ) return true ; else return false ; } void printArray ( int arr [ ] , int len ) { for ( int i = 0 ; i < len ; i ++ ) { cout << arr [ i ] << ' ▁ ' ; } } void findPairEvenParity ( int arr [ ] , int len ) { int firstMaximum = INT_MIN ; int secondMaximum = INT_MIN ; for ( int i = 0 ; i < len ; i ++ ) { if ( isEvenParity ( arr [ i ] ) ) { if ( arr [ i ] >= firstMaximum ) { secondMaximum = firstMaximum ; firstMaximum = arr [ i ] ; } else if ( arr [ i ] >= secondMaximum ) { secondMaximum = arr [ i ] ; } } } cout << firstMaximum << " ▁ " << secondMaximum ; } int main ( ) { int arr [ ] = { 18 , 15 , 8 , 9 , 14 } ; int len = sizeof ( arr ) / sizeof ( int ) ; findPairEvenParity ( arr , len ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, parity, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isHexagonal ( int N ) { float val = 8 * N + 1 ; float x = 1 + sqrt ( val ) ; float n = ( x ) / 4 ; if ( ( n - ( int ) n ) == 0 ) return true ; else return false ; } int main ( ) { int N = 14 ; if ( isHexagonal ( N ) == true ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void NumbertoCharacter ( int n ) { int rev = 0 , r = 0 ; while ( n > 0 ) { r = n % 10 ; rev = rev * 10 + r ; n = n / 10 ; } while ( rev > 0 ) { r = rev % 10 ; switch ( r ) { case 1 : cout << " one ▁ " ; break ; case 2 : cout << " two ▁ " ; break ; case 3 : cout << " three ▁ " ; break ; case 4 : cout << " four ▁ " ; break ; case 5 : cout << " five ▁ " ; break ; case 6 : cout << " six ▁ " ; break ; case 7 : cout << " seven ▁ " ; break ; case 8 : cout << " eight ▁ " ; break ; case 9 : cout << " nine ▁ " ; break ; case 0 : cout << " zero ▁ " ; break ; default : cout << " UnValid ▁ " ; break ; } rev = rev / 10 ; } } #include <iostream>
int main ( ) { int n = 12345 ; NumbertoCharacter ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Solve ( int arr [ ] , int n ) { int temp = 0 , count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { temp = 0 ; for ( int j = i ; j < n ; j ++ ) { temp += arr [ j ] ; if ( ( temp + 2 ) % 4 != 0 ) count ++ ; } } return count ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int N = sizeof ( arr ) / sizeof ( int ) ; cout << Solve ( arr , N ) ; return 0 ; }

Index/key variables: j
Accumulator variables: count, i, j, stdc, temp
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long int lli ; const int m = 4 ; long long int power ( lli x , lli y , lli p ) { lli res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } void nCr ( lli n , lli p , lli f [ ] [ m + 1 ] ) { for ( lli i = 0 ; i <= n ; i ++ ) { for ( lli j = 0 ; j <= m ; j ++ ) { if ( j > i ) f [ i ] [ j ] = 0 ; else if ( j == 0 j == i ) f [ i ] [ j ] = 1 ; else f [ i ] [ j ] = ( f [ i - 1 ] [ j ] + f [ i - 1 ] [ j - 1 ] ) % p ; } } } void operations ( lli arr [ ] , lli n , lli f [ ] [ m + 1 ] ) { lli p = 1000000007 ; nCr ( n , p - 1 , f ) ; sort ( arr , arr + n ) ; lli ans = 1 ; for ( lli i = 0 ; i < n ; i ++ ) { long long int x = 0 ; for ( lli j = 1 ; j <= m ; j ++ ) { if ( m % j == 0 ) x = ( x + ( f [ n - i - 1 ] [ m - j ] * f [ i ] [ j - 1 ] ) % ( p - 1 ) ) % ( p - 1 ) ; } ans = ( ( ans * power ( arr [ i ] , x , p ) ) % p ) ; } cout << ans << endl ; } int main ( ) { lli arr [ ] = { 4 , 5 , 7 , 9 , 3 } ; lli n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; lli f [ n + 1 ] [ m + 1 ] ; operations ( arr , n , f ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool prodSquare ( int n ) { for ( long i = 2 ; i * i <= n ; i ++ ) for ( long j = 2 ; j <= n ; j ++ ) if ( i * i * j * j == n ) return true ; return false ; } int main ( ) { int n = 25 ; if ( prodSquare ( n ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool prodSquare ( int n ) { unordered_map < float , float > s ; for ( int i = 2 ; i * i <= n ; ++ i ) { s [ i * i ] = 1 ; if ( s . find ( n / ( i * i ) ) != s . end ( ) ) return true ; } return false ; } int main ( ) { int n = 25 ; if ( prodSquare ( n ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool printArr ( int n ) { if ( n % 4 == 0 ) { for ( int i = 1 ; i <= n / 2 ; i ++ ) cout << i * 2 << ' ▁ ' ; for ( int i = 1 ; i < n / 2 ; i ++ ) cout << i * 2 - 1 << ' ▁ ' ; cout << n + n / 2 - 1 << ' ' ; } else cout << " - 1" ; } int main ( ) { int n = 22 ; printArr ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int GetSum ( int n ) { vector < int > divisors ; for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { divisors . push_back ( i ) ; if ( i != n / i ) { divisors . push_back ( n / i ) ; } } } int ans = 1 ; for ( auto i : divisors ) { ans *= ( i + 1 ) ; } ans = ans - 1 ; return ans ; } int main ( ) { int N = 4 ; cout << GetSum ( N ) << endl ; }

Accumulator variables: ans, 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 longestPowerfulSubsequence ( int arr [ ] , int n ) { int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPowerful ( arr [ i ] ) ) answer ++ ; } return answer ; } int main ( ) { int arr [ ] = { 6 , 4 , 10 , 13 , 9 , 25 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << longestPowerfulSubsequence ( arr , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, factor, i, n, power, stdc
Iterator variables: factor, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxOR ( int arr [ ] , int n ) { int max_value = * max_element ( arr , arr + n ) ; int number_of_bits = floor ( log2 ( max_value ) ) + 1 ; int complement = ( ( 1 << number_of_bits ) - 1 ) ^ max_value ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != max_value ) { c = max ( c , ( complement & arr [ i ] ) ) ; } } return ( max_value + c ) ; } int main ( ) { int arr [ ] = { 3 , 6 , 8 , 16 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxOR ( 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 update ( int res [ ] , int L , int R , int K ) { L -= 1 ; R -= 1 ; res [ L ] ^= K ; res [ R + 1 ] ^= K ; } void display ( int arr [ ] , int res [ ] , int n ) { for ( int i = 1 ; i < n ; i ++ ) { res [ i ] = res [ i ] ^ res [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { cout << ( arr [ i ] ^ res [ i ] ) << " ▁ " ; } cout << endl ; } int main ( ) { int arr [ ] = { 2 , 4 , 6 , 8 , 10 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int res [ N ] ; memset ( res , 0 , sizeof ( res ) ) ; int L = 1 , R = 3 , K = 2 ; update ( res , L , R , K ) ; L = 2 ; R = 4 ; K = 3 ; update ( res , L , R , K ) ; display ( arr , res , N ) ; return 0 ; }

Index/key variables: L, N, i
Accumulator variables: L, R, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int a [ ] , int n , int k ) { map < int , int > m ; int extra = 0 ; for ( int i = k ; i < n ; i ++ ) m [ a [ i ] ] ++ ; for ( auto x : m ) extra += x . second - 1 ; if ( extra == 0 ) return true ; for ( int i = 1 ; i + k - 1 < n ; i ++ ) { if ( m [ a [ i + k - 1 ] ] > 1 ) extra -- ; m [ a [ i + k - 1 ] ] -- ; m [ a [ i - 1 ] ] ++ ; if ( m [ a [ i - 1 ] ] > 1 ) extra ++ ; if ( extra == 0 ) return true ; } return false ; } int minlength ( int a [ ] , int n ) { int lo = 0 , hi = n + 1 ; int ans = 0 ; while ( lo < hi ) { int mid = ( lo + hi ) / 2 ; if ( check ( a , n , mid ) ) { ans = mid ; hi = mid ; } else lo = mid + 1 ; } return ans ; } int main ( ) { int a [ 5 ] = { 1 , 2 , 1 , 2 , 3 } ; int n = sizeof ( a ) / sizeof ( int ) ; cout << minlength ( a , n ) ; }

Index/key variables: i
Accumulator variables: extra, i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( int N ) { for ( int i = 1 ; i <= N / 2 ; i ++ ) { cout << i << " , ▁ " << - i << " , ▁ " ; } if ( N % 2 == 1 ) cout << 0 ; } int main ( ) { int N = 10 ; findNumbers ( N ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculateBill ( int units ) { if ( units <= 100 ) { return units * 10 ; } else if ( units <= 200 ) { return ( 100 * 10 ) + ( units - 100 ) * 15 ; } else if ( units <= 300 ) { return ( 100 * 10 ) + ( 100 * 15 ) + ( units - 200 ) * 20 ; } else if ( units > 300 ) { return ( 100 * 10 ) + ( 100 * 15 ) + ( 100 * 20 ) + ( units - 300 ) * 25 ; } return 0 ; } int main ( ) { int units = 250 ; cout << calculateBill ( units ) ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <math.h>
using namespace std ; int countPrimeFactors ( int n ) { if ( n == 1 ) return 0 ; int cnt = 0 ; while ( n % 2 == 0 ) { cnt ++ ; n = n / 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { cnt ++ ; n = n / i ; } } if ( n > 2 ) cnt ++ ; return cnt ; } int main ( ) { int x = 8 ; int prime_factor_cnt = countPrimeFactors ( x ) ; cout << prime_factor_cnt << endl ; return 0 ; }

Accumulator variables: cnt, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPalindromic ( int n ) { int count ; if ( n % 2 == 1 ) { count = pow ( 9 , ( n - 1 ) / 2 ) ; } else { count = pow ( 9 , ( n - 2 ) / 2 ) ; } return count ; } int main ( ) { int n = 3 ; cout << countPalindromic ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubArrayWithOddProduct ( int * A , int N ) { int count = 0 ; int last = -1 ; int K = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 0 ) { K = ( i - last - 1 ) ; count += ( K * ( K + 1 ) / 2 ) ; last = i ; } } K = ( N - last - 1 ) ; count += ( K * ( K + 1 ) / 2 ) ; return count ; } int main ( ) { int arr [ ] = { 12 , 15 , 7 , 3 , 25 , 6 , 2 , 1 , 1 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countSubArrayWithOddProduct ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double CgpaCalc ( double marks [ ] , int n ) { double grade [ n ] ; double cgpa , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { grade [ i ] = ( marks [ i ] / 10 ) ; } for ( int i = 0 ; i < n ; i ++ ) { sum += grade [ i ] ; } cgpa = sum / n ; return cgpa ; } int main ( ) { int n = 5 ; double marks [ ] = { 90 , 80 , 70 , 80 , 90 } ; double cgpa = CgpaCalc ( marks , n ) ; cout << " CGPA ▁ = ▁ " ; printf ( " % .1f STRNEWLINE " , cgpa ) ; cout << " CGPA ▁ Percentage ▁ = ▁ " ; printf ( " % .2f " , cgpa * 9.5 ) ; }

Index/key variables: i, n
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findMinXORSubarray ( int arr [ ] , int n , int k ) { if ( n < k ) return ; int res_index = 0 ; int curr_xor = 0 ; for ( int i = 0 ; i < k ; i ++ ) curr_xor ^= arr [ i ] ; int min_xor = curr_xor ; for ( int i = k ; i < n ; i ++ ) { curr_xor ^= ( arr [ i ] ^ arr [ i - k ] ) ; if ( curr_xor < min_xor ) { min_xor = curr_xor ; res_index = ( i - k + 1 ) ; } } cout << min_xor << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 3 , 7 , 90 , 20 , 10 , 50 , 40 } ; int n = sizeof arr / sizeof arr [ 0 ] ; findMinXORSubarray ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: curr_xor, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getNumber ( int a , int b ) { string X = to_string ( a ) ; string Y = to_string ( b ) ; string XY = X + Y ; string YX = Y + X ; return XY > YX ? XY : YX ; } void printMaxPair ( int arr [ ] , int n ) { int largest = INT_MIN ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) { int number = stoi ( getNumber ( arr [ i ] , arr [ j ] ) ) ; largest = max ( largest , number ) ; } cout << largest ; } int main ( ) { int a [ ] = { 23 , 14 , 16 , 25 , 3 , 9 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; printMaxPair ( a , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkGoldenRatio ( float a , float b ) { if ( a <= b ) { float temp = a ; a = b ; b = temp ; } std :: stringstream ratio1 ; ratio1 << std :: fixed << std :: setprecision ( 3 ) << ( a / b ) ; std :: stringstream ratio2 ; ratio2 << std :: fixed << std :: setprecision ( 3 ) << ( a + b ) / a ; if ( ( ratio1 . str ( ) == ratio2 . str ( ) ) && ratio1 . str ( ) == "1.618" ) { cout << " Yes " << endl ; return true ; } else { cout << " No " << endl ; return false ; } } int main ( ) { float a = 0.618 ; float b = 1 ; checkGoldenRatio ( a , b ) ; return 0 ; }

Accumulator variables: stdc