dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; int kth ( int * arr1 , int * arr2 , int * end1 , int * end2 , int k ) { if ( arr1 == end1 ) return arr2 [ k ] ; if ( arr2 == end2 ) return arr1 [ k ] ; int mid1 = ( end1 - arr1 ) / 2 ; int mid2 = ( end2 - arr2 ) / 2 ; if ( mid1 + mid2 < k ) { if ( arr1 [ mid1 ] > arr2 [ mid2 ] ) return kth ( arr1 , arr2 + mid2 + 1 , end1 , end2 , k - mid2 - 1 ) ; else return kth ( arr1 + mid1 + 1 , arr2 , end1 , end2 , k - mid1 - 1 ) ; } else { if ( arr1 [ mid1 ] > arr2 [ mid2 ] ) return kth ( arr1 , arr2 , arr1 + mid1 , end2 , k ) ; else return kth ( arr1 , arr2 , end1 , arr2 + mid2 , k ) ; } } int main ( ) { int arr1 [ 5 ] = { 2 , 3 , 6 , 7 , 9 } ; int arr2 [ 4 ] = { 1 , 4 , 8 , 10 } ; int k = 5 ; cout << kth ( arr1 , arr2 , arr1 + 5 , arr2 + 4 , k - 1 ) ; return 0 ; }

Index/key variables: k, mid1, mid2
C++ program:
#include <iostream>
using namespace std ; int kth ( int arr1 [ ] , int arr2 [ ] , int m , int n , int k , int st1 = 0 , int st2 = 0 ) { if ( st1 == m ) return arr2 [ st2 + k - 1 ] ; if ( st2 == n ) return arr1 [ st1 + k - 1 ] ; if ( k == 0 || k > ( m - st1 ) + ( n - st2 ) ) return -1 ; if ( k == 1 ) return ( arr1 [ st1 ] < arr2 [ st2 ] ) ? arr1 [ st1 ] : arr2 [ st2 ] ; int curr = k / 2 ; if ( curr - 1 >= m - st1 ) { if ( arr1 [ m - 1 ] < arr2 [ st2 + curr - 1 ] ) return arr2 [ st2 + ( k - ( m - st1 ) - 1 ) ] ; else return kth ( arr1 , arr2 , m , n , k - curr , st1 , st2 + curr ) ; } if ( curr - 1 >= n - st2 ) { if ( arr2 [ n - 1 ] < arr1 [ st1 + curr - 1 ] ) return arr1 [ st1 + ( k - ( n - st2 ) - 1 ) ] ; else return kth ( arr1 , arr2 , m , n , k - curr , st1 + curr , st2 ) ; } else { if ( arr1 [ curr + st1 - 1 ] < arr2 [ curr + st2 - 1 ] ) return kth ( arr1 , arr2 , m , n , k - curr , st1 + curr , st2 ) ; else return kth ( arr1 , arr2 , m , n , k - curr , st1 , st2 + curr ) ; } } int main ( ) { int arr1 [ 5 ] = { 2 , 3 , 6 , 7 , 9 } ; int arr2 [ 4 ] = { 1 , 4 , 8 , 10 } ; int k = 5 ; cout << kth ( arr1 , arr2 , 5 , 4 , k ) ; return 0 ; }

Index/key variables: st1, st2
C++ program:
#include <bits/stdc++.h>
using namespace std ; int kth ( int * a , int * b , int n , int m , int k ) { priority_queue < int , vector < int > , greater < int > > pq ; for ( int i = 0 ; i < n ; i ++ ) { pq . push ( a [ i ] ) ; } for ( int i = 0 ; i < m ; i ++ ) { pq . push ( b [ i ] ) ; } while ( k -- > 1 ) { pq . pop ( ) ; } return pq . top ( ) ; } int main ( ) { int arr1 [ 5 ] = { 2 , 3 , 6 , 7 , 9 } ; int arr2 [ 4 ] = { 1 , 4 , 8 , 10 } ; int k = 5 ; cout << kth ( arr1 , arr2 , 5 , 4 , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 100 ; void binarySearch ( int mat [ ] [ MAX ] , int i , int j_low , int j_high , int x ) { while ( j_low <= j_high ) { int j_mid = ( j_low + j_high ) / 2 ; if ( mat [ i ] [ j_mid ] == x ) { cout << " Found ▁ at ▁ ( " << i << " , ▁ " << j_mid << " ) " ; return ; } else if ( mat [ i ] [ j_mid ] > x ) j_high = j_mid - 1 ; else j_low = j_mid + 1 ; } cout << " Element ▁ no ▁ found " ; } void sortedMatrixSearch ( int mat [ ] [ MAX ] , int n , int m , int x ) { if ( n == 1 ) { binarySearch ( mat , 0 , 0 , m - 1 , x ) ; return ; } int i_low = 0 ; int i_high = n - 1 ; int j_mid = m / 2 ; while ( ( i_low + 1 ) < i_high ) { int i_mid = ( i_low + i_high ) / 2 ; if ( mat [ i_mid ] [ j_mid ] == x ) { cout << " Found ▁ at ▁ ( " << i_mid << " , ▁ " << j_mid << " ) " ; return ; } else if ( mat [ i_mid ] [ j_mid ] > x ) i_high = i_mid ; else i_low = i_mid ; } if ( mat [ i_low ] [ j_mid ] == x ) cout << " Found ▁ at ▁ ( " << i_low << " , " << j_mid << " ) " ; else if ( mat [ i_low + 1 ] [ j_mid ] == x ) cout << " Found ▁ at ▁ ( " << ( i_low + 1 ) << " , ▁ " << j_mid << " ) " ; else if ( x <= mat [ i_low ] [ j_mid - 1 ] ) binarySearch ( mat , i_low , 0 , j_mid - 1 , x ) ; else if ( x >= mat [ i_low ] [ j_mid + 1 ] && x <= mat [ i_low ] [ m - 1 ] ) binarySearch ( mat , i_low , j_mid + 1 , m - 1 , x ) ; else if ( x <= mat [ i_low + 1 ] [ j_mid - 1 ] ) binarySearch ( mat , i_low + 1 , 0 , j_mid - 1 , x ) ; else binarySearch ( mat , i_low + 1 , j_mid + 1 , m - 1 , x ) ; } int main ( ) { int n = 4 , m = 5 , x = 8 ; int mat [ ] [ MAX ] = { { 0 , 6 , 8 , 9 , 11 } , { 20 , 22 , 28 , 29 , 31 } , { 36 , 38 , 50 , 61 , 63 } , { 64 , 66 , 100 , 122 , 128 } } ; sortedMatrixSearch ( mat , n , m , x ) ; return 0 ; }

Index/key variables: MAX, i, i_low, i_mid, j_mid
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define R  2
#define C  2
int bsearch ( int low , int high , int n , int arr [ ] ) { int mid = ( low + high ) / 2 ; if ( low <= high ) { if ( arr [ mid ] < n ) return bsearch ( mid + 1 , high , n , arr ) ; return bsearch ( low , mid - 1 , n , arr ) ; } return low ; } int mindiff ( int arr [ R ] [ C ] , int n , int m ) { for ( int i = 0 ; i < n ; i ++ ) sort ( arr [ i ] , arr [ i ] + m ) ; int ans = INT_MAX ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int p = bsearch ( 0 , m - 1 , arr [ i ] [ j ] , arr [ i + 1 ] ) ; ans = min ( ans , abs ( arr [ i + 1 ] [ p ] - arr [ i ] [ j ] ) ) ; if ( p - 1 >= 0 ) ans = min ( ans , abs ( arr [ i + 1 ] [ p - 1 ] - arr [ i ] [ j ] ) ) ; } } return ans ; } int main ( ) { int m [ R ] [ C ] = { 8 , 5 , 6 , 8 , } ; cout << mindiff ( m , R , C ) << endl ; return 0 ; }

Index/key variables: C, R, i, j, mid, p
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binarySearch ( int arr [ ] , int left , int right ) { if ( left <= right ) { int mid = ( left + right ) / 2 ; if ( arr [ mid - 1 ] < arr [ mid ] && arr [ mid ] > arr [ mid + 1 ] ) return mid ; if ( arr [ mid ] < arr [ mid + 1 ] ) return binarySearch ( arr , mid + 1 , right ) ; else return binarySearch ( arr , left , mid - 1 ) ; } return -1 ; } int main ( ) { int arr [ ] = { 6 , 7 , 8 , 11 , 9 , 5 , 2 , 1 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int index = binarySearch ( arr , 1 , n - 2 ) ; if ( index != -1 ) cout << arr [ index ] ; return 0 ; }

Index/key variables: index, mid
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findRepeatingElement ( int arr [ ] , int low , int high ) { if ( low > high ) return -1 ; int mid = low + ( high - low ) / 2 ; if ( arr [ mid ] != mid + 1 ) { if ( mid > 0 && arr [ mid ] == arr [ mid - 1 ] ) return mid ; return findRepeatingElement ( arr , low , mid - 1 ) ; } return findRepeatingElement ( arr , mid + 1 , high ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 3 , 4 , 5 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int index = findRepeatingElement ( arr , 0 , n - 1 ) ; if ( index != -1 ) cout << arr [ index ] ; return 0 ; }

Index/key variables: index, mid
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double diff ( double n , double mid ) { if ( n > ( mid * mid * mid ) ) return ( n - ( mid * mid * mid ) ) ; else return ( ( mid * mid * mid ) - n ) ; } double cubicRoot ( double n ) { double start = 0 , end = n ; double e = 0.0000001 ; while ( true ) { double mid = ( start + end ) / 2 ; double error = diff ( n , mid ) ; if ( error <= e ) return mid ; if ( ( mid * mid * mid ) > n ) end = mid ; else start = mid ; } } int main ( ) { double n = 3 ; printf ( " Cubic ▁ root ▁ of ▁ % lf ▁ is ▁ % lf STRNEWLINE " , n , cubicRoot ( n ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <vector>
using namespace std ; void findFrequencyUtil ( int arr [ ] , int low , int high , vector < int > & freq ) { if ( arr [ low ] == arr [ high ] ) { freq [ arr [ low ] ] += high - low + 1 ; } else { int mid = ( low + high ) / 2 ; findFrequencyUtil ( arr , low , mid , freq ) ; findFrequencyUtil ( arr , mid + 1 , high , freq ) ; } } void findFrequency ( int arr [ ] , int n ) { vector < int > freq ( arr [ n - 1 ] + 1 , 0 ) ; findFrequencyUtil ( arr , 0 , n - 1 , freq ) ; for ( int i = 0 ; i <= arr [ n - 1 ] ; i ++ ) if ( freq [ i ] != 0 ) cout << " Element ▁ " << i << " ▁ occurs ▁ " << freq [ i ] << " ▁ times " << endl ; } int main ( ) { int arr [ ] = { 1 , 1 , 1 , 2 , 3 , 3 , 5 , 5 , 8 , 8 , 8 , 9 , 9 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; findFrequency ( arr , n ) ; return 0 ; }

Index/key variables: high, i, low
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int floorSqrt ( int x ) { if ( x == 0 x == 1 ) return x ; int i = 1 , result = 1 ; while ( result <= x ) { i ++ ; result = i * i ; } return i - 1 ; } int main ( ) { int x = 11 ; cout << floorSqrt ( x ) << endl ; return 0 ; }

Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maxOverlappingRectangles ( int x1 [ ] , int y1 [ ] , int x2 [ ] , int y2 [ ] , int N ) { int max_rectangles = 0 ; vector < int > X , Y ; for ( int i = 0 ; i < N ; i ++ ) { X . push_back ( x1 [ i ] ) ; X . push_back ( x2 [ i ] - 1 ) ; Y . push_back ( y1 [ i ] ) ; Y . push_back ( y2 [ i ] - 1 ) ; } for ( int i = 0 ; i < X . size ( ) ; i ++ ) { for ( int j = 0 ; j < Y . size ( ) ; j ++ ) { int cnt = 0 ; for ( int k = 0 ; k < N ; k ++ ) { if ( X [ i ] >= x1 [ k ] && X [ i ] + 1 <= x2 [ k ] && Y [ j ] >= y1 [ k ] && Y [ j ] + 1 <= y2 [ k ] ) { cnt ++ ; } } max_rectangles = max ( max_rectangles , cnt ) ; } } cout << max_rectangles ; } int main ( ) { int x1 [ ] = { 0 , 50 } ; int y1 [ ] = { 0 , 50 } ; int x2 [ ] = { 100 , 60 } ; int y2 [ ] = { 100 , 60 } ; int N = sizeof ( x1 ) / sizeof ( x1 [ 0 ] ) ; maxOverlappingRectangles ( x1 , y1 , x2 , y2 , N ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: cnt, i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isPossibleToReach ( int A [ ] , int N , int X , int Y ) { double distance = sqrt ( double ( X * X + Y * Y ) ) ; double mx = 0 ; for ( int i = 0 ; i < N ; i ++ ) { mx += double ( A [ i ] ) ; } if ( mx < distance ) { cout << " NO " ; return 0 ; } if ( ( mx - distance ) < 0.000001 ) { cout << " YES " ; return 0 ; } for ( int i = 0 ; i < N ; i ++ ) { if ( distance + mx < double ( 2 ) * double ( A [ i ] ) ) { cout << " No " ; return 0 ; } } cout << " Yes " ; return 0 ; } int main ( ) { int A [ ] = { 2 , 5 } ; int X = 5 , Y = 4 ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; isPossibleToReach ( A , N , X , Y ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, mx, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canReach ( int X , int Y , int steps ) { if ( X == 0 && Y == 0 ) { return true ; } if ( X < 0 Y < 0 ) { return false ; } return ( canReach ( X - ( int ) pow ( 3 , steps ) , Y , steps + 1 ) | canReach ( X , Y - ( int ) pow ( 3 , steps ) , steps + 1 ) ) ; } int main ( ) { int X = 10 , Y = 30 ; if ( canReach ( X , Y , 0 ) ) { cout << " YES " << endl ; } else cout << " NO " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool canReach ( int X , int Y ) { int steps = 0 ; while ( X Y ) { int pos1 = X % 3 ; int pos2 = Y % 3 ; if ( pos1 == 2 pos2 == 2 ) { return false ; } if ( pos1 == 1 && pos2 == 1 ) { return false ; } if ( pos1 == 0 && pos2 == 0 ) { return false ; } X /= 3 ; Y /= 3 ; steps ++ ; } return true ; } int main ( ) { int X = 10 , Y = 30 ; if ( canReach ( X , Y ) ) { cout << " YES " ; } else { cout << " NO " ; } }

Accumulator variables: X, Y, stdc, steps
C++ program:
#include <bits/stdc++.h>
using namespace std ; double findRadius ( double r1 , double r2 , double r3 ) { double r4 = ( r1 * r2 * r3 ) / ( r1 * r2 + r2 * r3 + r1 * r3 + 2.0 * sqrt ( r1 * r2 * r3 * ( r1 + r2 + r3 ) ) ) ; return r4 ; } int main ( ) { double r1 = 1 ; double r2 = 1 ; double r3 = 1 ; double r4 = findRadius ( r1 , r2 , r3 ) ; cout << " The ▁ radius ▁ of ▁ fourth ▁ circle : ▁ " << r4 ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumRectangleArea ( int A [ ] , int N ) { int ans ; sort ( A , A + 2 * N ) ; ans = ( A [ N - 1 ] - A [ 0 ] ) * ( A [ 2 * N - 1 ] - A [ N ] ) ; for ( int i = 1 ; i < N ; i ++ ) ans = min ( ans , ( A [ 2 * N - 1 ] - A [ 0 ] ) * ( A [ i + N - 1 ] - A [ i ] ) ) ; return ans ; } int main ( ) { int A [ ] = { 2 , 4 , 1 , 5 , 3 , 6 , 7 , 8 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; N /= 2 ; cout << minimumRectangleArea ( A , N ) << endl ; return 0 ; }

Index/key variables: N, i
Accumulator variables: N, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double radius ( int a , int b , int c ) { int g = a / 2 ; int f = b / 2 ; if ( g * g + f * f - c < 0 ) return ( -1 ) ; return ( sqrt ( g * g + f * f - c ) ) ; } double centerDistanceFromLine ( int a , int b , int i , int j , int k ) { int g = a / 2 ; int f = b / 2 ; double distance = fabs ( i * g + j * f + k ) / ( sqrt ( i * i + j * j ) ) ; if ( distance < 0 ) return ( -1 ) ; return distance ; } void interceptLength ( int a , int b , int c , int i , int j , int k ) { double rad = radius ( a , b , c ) ; double dist = centerDistanceFromLine ( a , b , i , j , k ) ; if ( rad < 0 dist < 0 ) { cout << " circle ▁ not ▁ possible " ; return ; } if ( dist > rad ) { cout << " Line ▁ not ▁ cutting ▁ circle " ; } else cout << 2 * sqrt ( rad * rad - dist * dist ) ; } int main ( ) { int a = 0 , b = 0 , c = -4 ; int i = 2 , j = -1 , k = 1 ; interceptLength ( a , b , c , i , j , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <vector>
using namespace std ; bool checkIntersection ( int arr [ ] , int N ) { vector < pair < int , int > > vec ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int x = arr [ i ] , y = arr [ i + 1 ] ; int minn = min ( x , y ) ; int maxx = max ( x , y ) ; vec . push_back ( { minn , maxx } ) ; } for ( int i = 0 ; i < vec . size ( ) ; i ++ ) { pair < int , int > x = vec [ i ] ; for ( int j = 0 ; j < vec . size ( ) ; j ++ ) { pair < int , int > y = vec [ j ] ; bool cond1 = ( x . first < y . first and x . second < y . second and y . first < x . second ) ; bool cond2 = ( y . first < x . first and y . second < x . second and x . first < y . second ) ; if ( cond1 or cond2 ) { return true ; } } } return false ; } int main ( ) { int arr [ ] = { 0 , 15 , 5 , 10 } ; int N = sizeof ( arr ) / sizeof ( int ) ; if ( checkIntersection ( arr , N ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void AreaFactor ( int n ) { double pi = 3.14159265 ; double areaf = 1 / ( cos ( pi / n ) * cos ( pi / n ) ) ; cout << fixed << setprecision ( 6 ) << areaf << endl ; } int main ( ) { int n = 4 ; AreaFactor ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define PI  3.14159265
double findInteriorAngle ( int n ) { return ( n - 2 ) * PI / n ; } double calculateSideLength ( double L , int N , int K ) { double angle = findInteriorAngle ( N ) ; double length = L * pow ( sin ( angle / 2 ) , ( K - 1 ) ) ; return length ; } int main ( ) { double N = 5 , L = 21 , K = 7 ; cout << calculateSideLength ( L , N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define PI  3.14159265
void findAngle ( double M1 , double M2 ) { double angle = abs ( ( M2 - M1 ) / ( 1 + M1 * M2 ) ) ; double ret = atan ( angle ) ; double val = ( ret * 180 ) / PI ; cout << val ; } int main ( ) { double M1 = 1.75 , M2 = 0.27 ; findAngle ( M1 , M2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float angle ( float R1 , float R2 , float D ) { float ans = ( R1 * R1 + R2 * R2 - D * D ) / ( 2 * R1 * R2 ) ; return ans ; } int main ( ) { float R1 = 3 , R2 = 4 ; float D = 5 ; cout << angle ( R1 , R2 , D ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string find ( int a [ ] , int b [ ] , int N , int K ) { for ( int i = 0 ; i < N ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) { continue ; } long long int dis = abs ( a [ i ] - a [ j ] ) + abs ( b [ i ] - b [ j ] ) ; if ( dis <= K ) { count ++ ; } if ( count == N - 1 ) { return " Yes " ; } } } return " No " ; } int main ( ) { int N = 5 ; int A [ ] = { 1 , 0 , 2 , 1 , 1 } ; int B [ ] = { 1 , 1 , 1 , 0 , 2 } ; int K = 1 ; cout << find ( A , B , N , K ) << endl ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void minimumTriangleArea ( int a , int b ) { int area = a * b ; cout << area ; } int main ( ) { int a = 1 , b = 2 ; minimumTriangleArea ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findAngles ( double a , double b , double c , double d ) { double numerator = a * a + d * d - b * b - c * c ; double denominator = 2 * ( a * b + c * d ) ; double x = numerator / denominator ; cout << fixed << setprecision ( 2 ) << " A : ▁ " << ( acos ( x ) * 180 ) / 3.141592 << " ▁ degrees " ; numerator = a * a + b * b - c * c - d * d ; x = numerator / denominator ; cout << fixed << setprecision ( 2 ) << " STRNEWLINE B : ▁ " << ( acos ( x ) * 180 ) / 3.141592 << " ▁ degrees " ; numerator = c * c + b * b - a * a - d * d ; x = numerator / denominator ; cout << fixed << setprecision ( 2 ) << " STRNEWLINE C : ▁ " << ( acos ( x ) * 180 ) / 3.141592 << " ▁ degrees " ; numerator = d * d + c * c - a * a - b * b ; x = numerator / denominator ; cout << fixed << setprecision ( 2 ) << " STRNEWLINE D : ▁ " << ( acos ( x ) * 180 ) / 3.141592 << " ▁ degrees " ; } int main ( ) { double A = 10 , B = 15 , C = 20 , D = 25 ; findAngles ( A , B , C , D ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countInscribed ( int R1 , int R2 ) { if ( R2 > R1 ) return 0 ; double angle ; double ratio ; int number_of_circles = 0 ; ratio = R2 / ( double ) ( R1 - R2 ) ; if ( R1 < 2 * R2 ) { number_of_circles = 1 ; } else { angle = abs ( asin ( ratio ) * 180 ) / 3.14159265 ; number_of_circles = 360 / ( 2 * floor ( angle ) ) ; } return number_of_circles ; } int main ( ) { int R1 = 3 ; int R2 = 1 ; cout << countInscribed ( R1 , R2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findPairs ( vector < int > x , vector < int > y , int K ) { int n = x . size ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { if ( K * abs ( x [ i ] - x [ j ] ) >= abs ( y [ i ] - y [ j ] ) ) { ++ ans ; } } } cout << ans ; } int main ( ) { vector < int > X = { 2 , 1 , 0 } , Y = { 1 , 2 , 0 } ; int K = 1 ; findPairs ( X , Y , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int totalCircles ( int L , int B ) { if ( L > B ) { int temp = L ; L = B ; B = temp ; } return B / L ; } int main ( ) { int L = 3 ; int B = 8 ; cout << totalCircles ( L , B ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double findDiagonal ( double s ) { return sqrt ( 2 ) * s ; } int main ( ) { double S = 10 ; cout << findDiagonal ( S ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void triangleArea ( float a , float b ) { if ( a < 0 b < 0 ) { cout << -1 ; return ; } float area = ( 3 * sqrt ( 3 ) * a * b ) / ( 4 ) ; cout << area ; } int main ( ) { float a = 1 , b = 2 ; triangleArea ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int const MAX = 1e6 + 5 ; int query ( vector < vector < float > > arr , vector < int > Q ) { int pre [ MAX ] = { 0 } ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { if ( arr [ i ] [ 0 ] < 0 arr [ i ] [ 1 ] < 0 ) continue ; int sum = ceil ( ( arr [ i ] [ 0 ] + arr [ i ] [ 1 ] ) ) ; pre [ sum ] ++ ; } for ( int i = 1 ; i < MAX ; i ++ ) pre [ i ] += pre [ i - 1 ] ; for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { cout << pre [ Q [ i ] ] << " ▁ " ; } cout << endl ; } int main ( ) { vector < vector < float > > arr = { { 2.1 , 3.0 } , { 3.7 , 1.2 } , { 1.5 , 6.5 } , { 1.2 , 0.0 } } ; vector < int > Q = { 2 , 8 , 5 } ; int N = arr . size ( ) ; int M = Q . size ( ) ; query ( arr , Q ) ; }

Index/key variables: MAX, i, sum
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool doIntersect ( vector < int > X , vector < int > Y ) { if ( X [ 0 ] > X [ 3 ] X [ 2 ] > X [ 1 ] ) return false ; if ( Y [ 0 ] > Y [ 3 ] Y [ 2 ] > Y [ 1 ] ) return false ; return true ; } int getUnionPerimeter ( vector < int > X , vector < int > Y ) { int perimeter = 0 ; if ( ! doIntersect ( X , Y ) ) { perimeter += 2 * ( abs ( X [ 1 ] - X [ 0 ] ) + abs ( Y [ 1 ] - Y [ 0 ] ) ) ; perimeter += 2 * ( abs ( X [ 3 ] - X [ 2 ] ) + abs ( Y [ 3 ] - Y [ 2 ] ) ) ; } else { int w = * max_element ( X . begin ( ) , X . end ( ) ) - * min_element ( X . begin ( ) , X . end ( ) ) ; int l = * max_element ( Y . begin ( ) , Y . end ( ) ) - * min_element ( Y . begin ( ) , Y . end ( ) ) ; perimeter = 2 * ( l + w ) ; } return perimeter ; } int main ( ) { vector < int > X { -1 , 2 , 4 , 6 } ; vector < int > Y { 2 , 5 , 3 , 7 } ; cout << getUnionPerimeter ( X , Y ) ; }

Accumulator variables: perimeter, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double Convert ( double degree ) { double pi = 3.14159265359 ; return ( degree * ( pi / 180 ) ) ; } void areaAndHeightOfTraingle ( double radius , double a ) { if ( a >= 180 a == 0 ) { cout << " Not ▁ possible " ; return ; } double base_angle = ( 180 - a ) / 2 ; double radians = Convert ( base_angle ) ; double height = sin ( radians ) * radius ; cout << " Height ▁ of ▁ triangle ▁ " << height << endl ; double base = cos ( radians ) * radius ; double area = base * height ; cout << " Area ▁ of ▁ triangle ▁ " << area << endl ; } int main ( ) { double R = 5 , angle = 120 ; areaAndHeightOfTraingle ( R , angle ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double findRadius ( double r1 , double r2 ) { double a1 , a2 , a3 , r3 ; a1 = 3.14 * r1 * r1 ; a2 = 3.14 * r2 * r2 ; a3 = a1 + a2 ; r3 = sqrt ( a3 / 3.14 ) ; return r3 ; } int main ( ) { double r1 = 8 , r2 = 6 ; cout << findRadius ( r1 , r2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find_lcm ( int a , int b , int c ) { int g = __gcd ( a , b ) ; int LCM1 = ( a * b ) / g ; g = __gcd ( LCM1 , c ) ; int LCM = ( LCM1 * c ) / g ; return LCM ; } void minimumCuboids ( int L , int B , int H ) { int lcm = find_lcm ( L , B , H ) ; int volume_cube = lcm * lcm * lcm ; int volume_cuboid = L * B * H ; cout << ( volume_cube / volume_cuboid ) ; } int main ( ) { int L = 1 , B = 1 , H = 2 ; minimumCuboids ( L , B , H ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int CrossProduct ( vector < vector < int > > & A ) { int X1 = ( A [ 1 ] [ 0 ] - A [ 0 ] [ 0 ] ) ; int Y1 = ( A [ 1 ] [ 1 ] - A [ 0 ] [ 1 ] ) ; int X2 = ( A [ 2 ] [ 0 ] - A [ 0 ] [ 0 ] ) ; int Y2 = ( A [ 2 ] [ 1 ] - A [ 0 ] [ 1 ] ) ; return ( X1 * Y2 - Y1 * X2 ) ; } bool isConvex ( vector < vector < int > > & points ) { int N = points . size ( ) ; int prev = 0 ; int curr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { vector < vector < int > > temp = { points [ i ] , points [ ( i + 1 ) % N ] , points [ ( i + 2 ) % N ] } ; curr = CrossProduct ( temp ) ; if ( curr != 0 ) { if ( curr * prev < 0 ) { return false ; } else { prev = curr ; } } } return true ; } int main ( ) { vector < vector < int > > points = { { 0 , 0 } , { 0 , 1 } , { 1 , 1 } , { 1 , 0 } } ; if ( isConvex ( points ) ) { cout << " Yes " << " STRNEWLINE " ; } else { cout << " No " << " STRNEWLINE " ; } }

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