dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
#define MAX  5
using namespace std ; bool isSafe ( int row , int col , int m [ ] [ MAX ] , int n , bool visited [ ] [ MAX ] ) { if ( row == -1 row == n col == -1 col == n visited [ row ] [ col ] m [ row ] [ col ] == 0 ) return false ; return true ; } void printPathUtil ( int row , int col , int m [ ] [ MAX ] , int n , string & path , vector < string > & possiblePaths , bool visited [ ] [ MAX ] ) { if ( row == -1 row == n col == -1 col == n visited [ row ] [ col ] m [ row ] [ col ] == 0 ) return ; if ( row == n - 1 && col == n - 1 ) { possiblePaths . push_back ( path ) ; return ; } visited [ row ] [ col ] = true ; if ( isSafe ( row + 1 , col , m , n , visited ) ) { path . push_back ( ' D ' ) ; printPathUtil ( row + 1 , col , m , n , path , possiblePaths , visited ) ; path . pop_back ( ) ; } if ( isSafe ( row , col - 1 , m , n , visited ) ) { path . push_back ( ' L ' ) ; printPathUtil ( row , col - 1 , m , n , path , possiblePaths , visited ) ; path . pop_back ( ) ; } if ( isSafe ( row , col + 1 , m , n , visited ) ) { path . push_back ( ' R ' ) ; printPathUtil ( row , col + 1 , m , n , path , possiblePaths , visited ) ; path . pop_back ( ) ; } if ( isSafe ( row - 1 , col , m , n , visited ) ) { path . push_back ( ' U ' ) ; printPathUtil ( row - 1 , col , m , n , path , possiblePaths , visited ) ; path . pop_back ( ) ; } visited [ row ] [ col ] = false ; } void printPath ( int m [ MAX ] [ MAX ] , int n ) { vector < string > possiblePaths ; string path ; bool visited [ n ] [ MAX ] ; memset ( visited , false , sizeof ( visited ) ) ; printPathUtil ( 0 , 0 , m , n , path , possiblePaths , visited ) ; for ( int i = 0 ; i < possiblePaths . size ( ) ; i ++ ) cout << possiblePaths [ i ] << " ▁ " ; } int main ( ) { int m [ MAX ] [ MAX ] = { { 1 , 0 , 0 , 0 , 0 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 } } ; int n = sizeof ( m ) / sizeof ( m [ 0 ] ) ; printPath ( m , n ) ; return 0 ; }

Index/key variables: MAX, col, i, n, row
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define breakLine  cout << "
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - " #define MAX 10 using namespace std ; int arr [ MAX ] , no ; void nQueens ( int k , int n ) ; bool canPlace ( int k , int i ) ; void display ( int n ) ; void nQueens ( int k , int n ) { for ( int i = 1 ; i <= n ; i ++ ) { if ( canPlace ( k , i ) ) { arr [ k ] = i ; if ( k == n ) display ( n ) ; else nQueens ( k + 1 , n ) ; } } } bool canPlace ( int k , int i ) { for ( int j = 1 ; j <= k - 1 ; j ++ ) { if ( arr [ j ] == i || ( abs ( arr [ j ] - i ) == abs ( j - k ) ) ) return false ; } return true ; } void display ( int n ) { breakLine cout < < " Arrangement ▁ No . ▁ " << ++ no ; breakLine for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( arr [ i ] != j ) cout << " TABSYMBOL _ " ; else cout << " TABSYMBOL Q " ; } cout << endl ; } breakLine } int main ( ) { int n = 4 ; nQueens ( 1 , n ) ; return 0 ; }

Index/key variables: MAX, i, j, k
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define R  3
#define C  10
struct Pair { bool found ; int value ; } ; Pair findLongestPathUtil ( int mat [ R ] [ C ] , int i , int j , int x , int y , bool visited [ R ] [ C ] ) { if ( i == x && j == y ) { Pair p = { true , 0 } ; return p ; } if ( i < 0 i > = R j < 0 j > = C mat [ i ] [ j ] == 0 visited [ i ] [ j ] ) { Pair p = { false , INT_MAX } ; return p ; } visited [ i ] [ j ] = true ; int res = INT_MIN ; Pair sol = findLongestPathUtil ( mat , i , j - 1 , x , y , visited ) ; if ( sol . found ) res = max ( res , sol . value ) ; sol = findLongestPathUtil ( mat , i , j + 1 , x , y , visited ) ; if ( sol . found ) res = max ( res , sol . value ) ; sol = findLongestPathUtil ( mat , i - 1 , j , x , y , visited ) ; if ( sol . found ) res = max ( res , sol . value ) ; sol = findLongestPathUtil ( mat , i + 1 , j , x , y , visited ) ; if ( sol . found ) res = max ( res , sol . value ) ; visited [ i ] [ j ] = false ; if ( res != INT_MIN ) { Pair p = { true , 1 + res } ; return p ; } else { Pair p = { false , INT_MAX } ; return p ; } } void findLongestPath ( int mat [ R ] [ C ] , int i , int j , int x , int y ) { bool visited [ R ] [ C ] ; memset ( visited , false , sizeof visited ) ; Pair p = findLongestPathUtil ( mat , i , j , x , y , visited ) ; if ( p . found ) cout << " Length ▁ of ▁ longest ▁ possible ▁ route ▁ is ▁ " << p . value ; else cout << " Destination ▁ not ▁ reachable ▁ from ▁ given ▁ " " source " ; } int main ( ) { int mat [ R ] [ C ] = { { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 0 , 1 , 1 , 0 , 1 , 1 , 0 , 1 } , { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } } ; findLongestPath ( mat , 0 , 0 , 1 , 7 ) ; return 0 ; }

Index/key variables: C, R, i, j
Accumulator variables: stdc
Class/struct names: Pair
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { int A [ ] = { 11 , 15 , 7 , 19 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; unordered_set < int > s ; int i , j , res ; for ( i = 0 ; i < N ; ++ i ) for ( j = i , res = INT_MAX ; j < N ; ++ j ) { res &= A [ j ] ; s . insert ( res ) ; } for ( int i : s ) cout << i << " ▁ " ; return 0 ; }

Index/key variables: j
Accumulator variables: res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define LL  long long int
void answerQueries ( LL Q , vector < pair < LL , LL > > query ) { set < LL > s ; s . insert ( 0 ) ; for ( int i = 0 ; i <= 60 ; i ++ ) { for ( int j = i ; j <= 60 ; j ++ ) { for ( int k = j ; k <= 60 ; k ++ ) { if ( j == i && i == k ) s . insert ( 1LL << i ) ; else if ( j == k && i != j ) { LL x = ( 1LL << i ) + ( 1LL << j ) ; s . insert ( x ) ; } else if ( i == j && i != k ) { LL x = ( 1LL << i ) + ( 1LL << k ) ; s . insert ( x ) ; } else if ( i == k && i != j ) { LL x = ( 1LL << k ) + ( 1LL << j ) ; s . insert ( x ) ; } else { LL x = ( 1LL << i ) + ( 1LL << j ) + ( 1LL << k ) ; s . insert ( x ) ; } } } } vector < LL > validNumbers ; for ( auto val : s ) validNumbers . push_back ( val ) ; for ( int i = 0 ; i < Q ; i ++ ) { LL L = query [ i ] . first ; LL R = query [ i ] . second ; if ( R < L ) swap ( L , R ) ; if ( L == 0 ) cout << ( upper_bound ( validNumbers . begin ( ) , validNumbers . end ( ) , R ) - validNumbers . begin ( ) ) << endl ; else cout << ( upper_bound ( validNumbers . begin ( ) , validNumbers . end ( ) , R ) - upper_bound ( validNumbers . begin ( ) , validNumbers . end ( ) , L - 1 ) ) << endl ; } } int main ( ) { int Q = 2 ; vector < pair < LL , LL > > query ( Q ) ; query [ 0 ] . first = 3 ; query [ 0 ] . second = 7 ; query [ 1 ] . first = 10 ; query [ 1 ] . second = 16 ; answerQueries ( Q , query ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k, val
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minStepsRecur ( int height [ ] , int l , int r , int h ) { if ( l >= r ) return 0 ; int m = l ; for ( int i = l ; i < r ; i ++ ) if ( height [ i ] < height [ m ] ) m = i ; return min ( r - l , minStepsRecur ( height , l , m , height [ m ] ) + minStepsRecur ( height , m + 1 , r , height [ m ] ) + height [ m ] - h ) ; } int minSteps ( int height [ ] , int N ) { return minStepsRecur ( height , 0 , N , 0 ) ; } int main ( ) { int height [ ] = { 2 , 1 , 2 , 5 , 1 } ; int N = sizeof ( height ) / sizeof ( int ) ; cout << minSteps ( height , N ) << endl ; return 0 ; }

Index/key variables: i, m
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countDirectPath ( int N ) { return N + ( N * ( N - 3 ) ) / 2 ; } int main ( ) { int N = 5 ; cout << countDirectPath ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; typedef long long ll ; #define fi  first
#define se  second
void findPoint ( int n , vector < pair < int , int > > p ) { for ( int i = 0 ; i < n * 4 + 1 ; ++ i ) { int x1 = 2e9 , x2 = -2e9 ; int y1 = 2e9 , y2 = -2e9 ; for ( int j = 0 ; j < n * 4 + 1 ; ++ j ) if ( i != j ) { x1 = min ( x1 , p [ j ] . fi ) ; x2 = max ( x2 , p [ j ] . fi ) ; y1 = min ( y1 , p [ j ] . se ) ; y2 = max ( y2 , p [ j ] . se ) ; } bool ok = 1 ; int c1 = 0 , c2 = 0 ; int c3 = 0 , c4 = 0 ; for ( int j = 1 ; j <= n * 4 + 1 ; ++ j ) if ( i != j ) { if ( ( p [ j ] . fi == x1 p [ j ] . fi == x2 ) || ( ( p [ j ] . se == y1 p [ j ] . se == y2 ) ) ) { if ( p [ j ] . fi == x1 ) ++ c1 ; if ( p [ j ] . fi == x2 ) ++ c2 ; if ( p [ j ] . se == y1 ) ++ c3 ; if ( p [ j ] . se == y2 ) ++ c4 ; } else ok = 0 ; } if ( ok && c1 >= n && c2 >= n && c3 >= n && c4 >= n && x2 - x1 == y2 - y1 ) { cout << p [ i ] . fi << " ▁ " << p [ i ] . se << " STRNEWLINE " ; } } } int main ( ) { int N = 2 ; vector < pair < int , int > > arr = { { 0 , 0 } , { 0 , 1 } , { 0 , 2 } , { 1 , 0 } , { 1 , 1 } , { 1 , 2 } , { 2 , 0 } , { 2 , 1 } , { 2 , 2 } } ; findPoint ( N , arr ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int triacontagonalNum ( int n ) { return ( 28 * n * n - 26 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ triacontagonal ▁ Number ▁ is ▁ = ▁ " << triacontagonalNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int enneacontagonNum ( int n ) { return ( 88 * n * n - 86 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ enneacontagon ▁ Number ▁ is ▁ = ▁ " << enneacontagonNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int triacontakaidigonNum ( int n ) { return ( 30 * n * n - 28 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ triacontakaidigon ▁ Number ▁ is ▁ = ▁ " << triacontakaidigonNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int IcosihexagonalNum ( int n ) { return ( 24 * n * n - 22 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ Icosihexagonal ▁ Number ▁ is ▁ = ▁ " << IcosihexagonalNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int octacontagonNum ( int n ) { return ( 78 * n * n - 76 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ octacontagon ▁ Number ▁ is ▁ = ▁ " << octacontagonNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int hectagonNum ( int n ) { return ( 98 * n * n - 96 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ hectagon ▁ Number ▁ is ▁ = ▁ " << hectagonNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int tetracontagonNum ( int n ) { return ( 38 * n * n - 36 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << "3rd ▁ tetracontagon ▁ Number ▁ is ▁ = ▁ " << tetracontagonNum ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void Perimeter ( int a , int b ) { float perimeter ; perimeter = 2 * 3.14 * sqrt ( ( a * a + b * b ) / ( 2 * 1.0 ) ) ; cout << perimeter ; } int main ( ) { int a = 3 , b = 2 ; Perimeter ( a , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float hexagonside ( float a ) { if ( a < 0 ) return -1 ; float x = 0.5176 * a ; return x ; } int main ( ) { float a = 6 ; cout << hexagonside ( a ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float hexagonside ( float a ) { if ( a < 0 ) return -1 ; float x = a / 3 ; return x ; } int main ( ) { float a = 6 ; cout << hexagonside ( a ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; int findSegment ( int n , int m , int segment_length [ ] ) { double meet_point = ( 1.0 * n ) / 2.0 ; int sum = 0 ; int segment_number = 0 ; for ( int i = 0 ; i < m ; i ++ ) { sum += segment_length [ i ] ; if ( ( double ) sum == meet_point ) { segment_number = -1 ; break ; } if ( sum > meet_point ) { segment_number = i + 1 ; break ; } } return segment_number ; } int main ( ) { int n = 13 ; int m = 3 ; int segment_length [ ] = { 3 , 2 , 8 } ; int ans = findSegment ( n , m , segment_length ) ; cout << ( ans ) ; return 0 ; }

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float surfaceArea ( float a , float b , float h ) { return 5 * a * b + 5 * b * h ; } float volume ( float b , float h ) { return ( 5 * b * h ) / 2 ; } int main ( ) { float a = 5 ; float b = 3 ; float h = 7 ; cout << " surface ▁ area = ▁ " << surfaceArea ( a , b , h ) << " , ▁ " ; cout << " volume = ▁ " << volume ( b , h ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkpoint ( int h , int k , int x , int y , int a ) { int p = pow ( ( y - k ) , 2 ) - 4 * a * ( x - h ) ; return p ; } int main ( ) { int h = 0 , k = 0 , x = 2 , y = 1 , a = 4 ; if ( checkpoint ( h , k , x , y , a ) > 0 ) cout << " Outside " << endl ; else if ( checkpoint ( h , k , x , y , a ) == 0 ) cout << " On ▁ the ▁ parabola " << endl ; else cout << " Inside " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkpoint ( int h , int k , int x , int y , int a , int b ) { int p = ( pow ( ( x - h ) , 2 ) / pow ( a , 2 ) ) + ( pow ( ( y - k ) , 2 ) / pow ( b , 2 ) ) ; return p ; } int main ( ) { int h = 0 , k = 0 , x = 2 , y = 1 , a = 4 , b = 5 ; if ( checkpoint ( h , k , x , y , a , b ) > 1 ) cout << " Outside " << endl ; else if ( checkpoint ( h , k , x , y , a , b ) == 1 ) cout << " On ▁ the ▁ ellipse " << endl ; else cout << " Inside " << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float circlearea ( float a , float b ) { if ( a < 0 b < 0 ) return -1 ; float A = ( 3.14 * pow ( a , 2 ) * pow ( b , 2 ) ) / ( 4 * ( pow ( a , 2 ) + pow ( b , 2 ) ) ) ; return A ; } int main ( ) { float a = 8 , b = 10 ; cout << circlearea ( a , b ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float circlearea ( float l , float b ) { if ( l < 0 b < 0 ) return -1 ; if ( l < b ) return 3.14 * pow ( l / 2 , 2 ) ; else return 3.14 * pow ( b / 2 , 2 ) ; } int main ( ) { float l = 4 , b = 8 ; cout << circlearea ( l , b ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int centered_cube ( int n ) { return ( 2 * n + 1 ) * ( n * n + n + 1 ) ; } int main ( ) { int n = 3 ; cout << n << " th ▁ Centered ▁ cube ▁ number : ▁ " ; cout << centered_cube ( n ) ; cout << endl ; n = 10 ; cout << n << " th ▁ Centered ▁ cube ▁ number : ▁ " ; cout << centered_cube ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double vol_of_octahedron ( double side ) { return ( ( side * side * side ) * ( sqrt ( 2 ) / 3 ) ) ; } int main ( ) { double side = 3 ; cout << " Volume ▁ of ▁ octahedron ▁ = " << vol_of_octahedron ( side ) << endl ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float volumeOfEllipsoid ( float r1 , float r2 , float r3 ) { float pi = 3.14 ; return 1.33 * pi * r1 * r2 * r3 ; } int main ( ) { float r1 = 2.3 , r2 = 3.4 , r3 = 5.7 ; cout << " volume ▁ of ▁ ellipsoid ▁ is ▁ : ▁ " << volumeOfEllipsoid ( r1 , r2 , r3 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double areaOctagon ( double side ) { return ( float ) ( 2 * ( 1 + sqrt ( 2 ) ) * side * side ) ; } int main ( ) { double side = 4 ; cout << " Area ▁ of ▁ Regular ▁ Octagon ▁ = ▁ " << areaOctagon ( side ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double areaCube ( double a ) { return ( a * a * a ) ; } double surfaceCube ( double a ) { return ( 6 * a * a ) ; } int main ( ) { double a = 5 ; cout << " Area ▁ = ▁ " << areaCube ( a ) << endl ; cout << " Total ▁ surface ▁ area ▁ = ▁ " << surfaceCube ( a ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define pdd  pair<double, double>
void displayPoint ( pdd P ) { cout << " ( " << P . first << " , ▁ " << P . second << " ) " << endl ; } pdd lineLineIntersection ( pdd A , pdd B , pdd C , pdd D ) { double a1 = B . second - A . second ; double b1 = A . first - B . first ; double c1 = a1 * ( A . first ) + b1 * ( A . second ) ; double a2 = D . second - C . second ; double b2 = C . first - D . first ; double c2 = a2 * ( C . first ) + b2 * ( C . second ) ; double determinant = a1 * b2 - a2 * b1 ; if ( determinant == 0 ) { return make_pair ( FLT_MAX , FLT_MAX ) ; } else { double x = ( b2 * c1 - b1 * c2 ) / determinant ; double y = ( a1 * c2 - a2 * c1 ) / determinant ; return make_pair ( x , y ) ; } } int main ( ) { pdd A = make_pair ( 1 , 1 ) ; pdd B = make_pair ( 4 , 4 ) ; pdd C = make_pair ( 1 , 8 ) ; pdd D = make_pair ( 2 , 4 ) ; pdd intersection = lineLineIntersection ( A , B , C , D ) ; if ( intersection . first == FLT_MAX && intersection . second == FLT_MAX ) { cout << " The ▁ given ▁ lines ▁ AB ▁ and ▁ CD ▁ are ▁ parallel . STRNEWLINE " ; } else { cout << " The ▁ intersection ▁ of ▁ the ▁ given ▁ lines ▁ AB ▁ " " and ▁ CD ▁ is : ▁ " ; displayPoint ( intersection ) ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minRevolutions ( double r , int x1 , int y1 , int x2 , int y2 ) { double d = sqrt ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ; return ceil ( d / ( 2 * r ) ) ; } int main ( ) { int r = 2 , x1 = 0 , y1 = 0 , x2 = 0 , y2 = 4 ; cout << minRevolutions ( r , x1 , y1 , x2 , y2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define eps  1e-6
double getArea ( double base , double hypotenuse ) { double height = sqrt ( hypotenuse * hypotenuse - base * base ) ; return 0.5 * base * height ; } void printRightAngleTriangle ( int hypotenuse , int area ) { int hsquare = hypotenuse * hypotenuse ; double sideForMaxArea = sqrt ( hsquare / 2.0 ) ; double maxArea = getArea ( sideForMaxArea , hypotenuse ) ; if ( area > maxArea ) { cout << " Not ▁ possiblen " ; return ; } double low = 0.0 ; double high = sideForMaxArea ; double base ; while ( abs ( high - low ) > eps ) { base = ( low + high ) / 2.0 ; if ( getArea ( base , hypotenuse ) >= area ) high = base ; else low = base ; } double height = sqrt ( hsquare - base * base ) ; cout << base << " ▁ " << height << endl ; } int main ( ) { int hypotenuse = 5 ; int area = 6 ; printRightAngleTriangle ( hypotenuse , area ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countLattice ( int r ) { if ( r <= 0 ) return 0 ; int result = 4 ; for ( int x = 1 ; x < r ; x ++ ) { int ySquare = r * r - x * x ; int y = sqrt ( ySquare ) ; if ( y * y == ySquare ) result += 4 ; } return result ; } int main ( ) { int r = 5 ; cout << countLattice ( r ) ; return 0 ; }

Accumulator variables: result, stdc, x
Iterator variables: x
C++ program:
#include <iostream>
using namespace std ; int countSubArrays ( int arr [ ] , int N , int K , int M ) { int count = 0 ; int sum = 0 ; for ( int i = 0 ; i < K ; i ++ ) { sum += arr [ i ] ; } if ( sum >= K * M ) count ++ ; for ( int i = K ; i < N ; i ++ ) { sum += ( arr [ i ] - arr [ i - K ] ) ; if ( sum >= K * M ) count ++ ; } return count ; } int main ( ) { int arr [ ] = { 3 , 6 , 3 , 2 , 1 , 3 , 9 } ; int K = 2 , M = 4 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countSubArrays ( arr , N , K , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void performQueries ( int n , int q , int k , vector < int > & arr , vector < vector < int > > & query ) { for ( int i = 1 ; i <= q ; i ++ ) { int count = 0 ; if ( query [ i - 1 ] [ 0 ] == 1 ) { for ( int j = query [ i - 1 ] [ 1 ] ; j <= query [ i - 1 ] [ 2 ] ; j ++ ) { if ( arr [ j ] == k ) count ++ ; } cout << count << endl ; } else { = arr [ query [ i - 1 ] [ 1 ] ] = query [ i - 1 ] [ 2 ] ; } } } int main ( ) { vector < int > arr = { 9 , 5 , 7 , 6 , 9 , 0 , 0 , 0 , 0 , 5 , 6 , 7 , 3 , 9 , 0 , 7 , 0 , 9 , 0 } ; int Q = 5 ; vector < vector < int > > query = { { 1 , 5 , 14 } , { 2 , 6 , 1 } , { 1 , 0 , 8 } , { 2 , 13 , 0 } , { 1 , 6 , 18 } } ; int N = arr . size ( ) ; int K = 0 ; performQueries ( N , Q , K , arr , query ) ; return 0 ; }

Index/key variables: j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
using namespace std ; int findSmallestNumK ( int n ) { int cummAnd = n ; int i = n - 1 ; while ( cummAnd != 0 ) { cummAnd = cummAnd & i ; if ( cummAnd == 0 ) { return i ; } i -- ; } return -1 ; } int main ( ) { int N = 17 ; int lastNum = findSmallestNumK ( N ) ; int K = lastNum == -1 ? lastNum : N - lastNum ; cout << K << " STRNEWLINE " ; return 0 ; }

Accumulator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) { if ( n == 1 n == 0 ) return 1 ; else return n * fact ( n - 1 ) ; } int findValue ( int n , int r , int a ) { int k = ( a - 1 ) / fact ( n ) ; int answer = k ; for ( int i = 1 ; i < n + 1 ; i ++ ) answer = answer * ( n + r - i ) ; answer = answer + 1 ; return answer ; } int main ( ) { int N = 1 ; int A = 2 ; int R = 3 ; cout << ( findValue ( N , R , A ) ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string NimGame ( int N , int A , int B ) { int sum = A + B ; if ( N % sum <= A - 1 ) return " Bob " ; else return " Alice " ; } int main ( ) { int N = 3 , A = 1 , B = 2 ; cout << NimGame ( N , A , B ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countNo ( int A , int N , int L , int R ) { int ans = L - 1 + N + floor ( ( N - 1 ) / ( A - 1 ) ) ; if ( ans % A == 0 ) { ans = ans + 1 ; } cout << ans << endl ; } int main ( ) { int A = 5 , N = 10 , L = 4 , R = 20 ; countNo ( A , N , L , R ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void compute ( vector < int > query ) { vector < int > v ( 100001 ) , dp ( 100001 ) ; v [ 1 ] = 1 , v [ 2 ] = 0 ; dp [ 1 ] = 0 , dp [ 2 ] = 0 ; for ( int i = 3 ; i < 100001 ; i ++ ) { if ( i % 2 != 0 ) { if ( ( i / 2 ) % 2 == 0 ) { v [ i ] = 1 ; dp [ i ] = dp [ i - 1 ] ; } else { v [ i ] = v [ i / 2 ] + 1 ; dp [ i ] = dp [ i - 1 ] + v [ i ] - 1 ; } } else { v [ i ] = 0 ; dp [ i ] = dp [ i - 1 ] ; } } for ( auto x : query ) cout << dp [ x ] << endl ; } int main ( ) { vector < int > query = { 5 , 2 } ; compute ( query ) ; return 0 ; }

Index/key variables: i, x
Accumulator variables: i, stdc
Iterator variables: i, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findCycles ( int N ) { int res = 0 ; int finalResult = 0 ; int val = 2 * N - 1 ; int s = val ; res = ( N - 1 ) * ( N - 2 ) ; finalResult = res + s ; return finalResult ; } int main ( ) { int N = 5 ; cout << findCycles ( N ) << endl ; return 0 ; }

Accumulator variables: stdc