dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void samePerimeterAndArea ( ) { set < vector < int > > se ; for ( int i = 1 ; i <= 256 ; ++ i ) { for ( int j = 1 ; j <= 256 ; ++ j ) { for ( int k = 1 ; k <= 256 ; ++ k ) { int peri = i + j + k ; int mul1 = - i + j + k ; int mul2 = i - j + k ; int mul3 = i + j - k ; if ( 16 * peri == mul1 * mul2 * mul3 ) { vector < int > v = { i , j , k } ; sort ( v . begin ( ) , v . end ( ) ) ; se . insert ( v ) ; } } } } for ( auto it : se ) { cout << it [ 0 ] << " ▁ " << it [ 1 ] << " ▁ " << it [ 2 ] << endl ; } } int main ( ) { samePerimeterAndArea ( ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i, it, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Tri { int MinX , MaxX , MinY , MaxY ; } ; int StringtoInt ( string s ) { stringstream geek ( s ) ; int x ; geek >> x ; return x ; } int TriangleCuts ( vector < vector < int > > Triangle , string Cuts [ ] , int N , int M , int COL ) { Tri Minimized [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int x1 = Triangle [ i ] [ 0 ] ; int y1 = Triangle [ i ] [ 1 ] ; int x2 = Triangle [ i ] [ 2 ] ; int y2 = Triangle [ i ] [ 3 ] ; int x3 = Triangle [ i ] [ 4 ] ; int y3 = Triangle [ i ] [ 5 ] ; Minimized [ i ] . MinX = min ( { x1 , x2 , x3 } ) ; Minimized [ i ] . MaxX = max ( { x1 , x2 , x3 } ) ; Minimized [ i ] . MinY = min ( { y1 , y2 , y3 } ) ; Minimized [ i ] . MaxY = max ( { y1 , y2 , y3 } ) ; } for ( int i = 0 ; i < M ; i ++ ) { string Cut = Cuts [ i ] ; int CutCount = 0 ; int CutVal = StringtoInt ( Cut . substr ( 2 , Cut . size ( ) ) ) ; if ( Cut [ 0 ] == ' X ' ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( Minimized [ j ] . MinX ) < ( CutVal ) & & ( Minimized [ j ] . MaxX ) > ( CutVal ) ) { CutCount ++ ; } } } else if ( Cut [ 0 ] == ' Y ' ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( Minimized [ j ] . MinY ) < ( CutVal ) & & ( Minimized [ j ] . MaxY ) > ( CutVal ) ) { CutCount ++ ; } } } cout << CutCount << " ▁ " ; } } int main ( ) { vector < vector < int > > Triangle = { { 0 , 2 , 2 , 9 , 8 , 5 } , { 5 , 0 , 6 , 3 , 7 , 0 } } ; int N = Triangle . size ( ) ; int COL = 6 ; string Cuts [ ] = { " X = 2" , " Y = 2" , " Y = 9" } ; int M = sizeof ( Cuts ) / sizeof ( Cuts [ 0 ] ) ; TriangleCuts ( Triangle , Cuts , N , M , COL ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: CutCount, i, j, stdc
Iterator variables: i, j
Class/struct names: Tri
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntRect ( int points [ ] [ 2 ] , int N , int rectangle [ ] [ 2 ] ) { unordered_set < int > cntHor ; unordered_set < int > cntVer ; cntHor . insert ( 0 ) ; cntVer . insert ( 0 ) ; cntHor . insert ( rectangle [ 3 ] [ 0 ] ) ; cntVer . insert ( rectangle [ 3 ] [ 1 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { cntHor . insert ( points [ i ] [ 0 ] ) ; cntVer . insert ( points [ i ] [ 1 ] ) ; } return ( cntHor . size ( ) - 1 ) * ( cntVer . size ( ) - 1 ) ; } int main ( ) { int rectangle [ ] [ 2 ] = { { 0 , 0 } , { 0 , 5 } , { 5 , 0 } , { 5 , 5 } } ; int points [ ] [ 2 ] = { { 1 , 2 } , { 3 , 4 } } ; int N = sizeof ( points ) / sizeof ( points [ 0 ] ) ; cout << cntRect ( points , N , rectangle ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberOfSquares ( int X [ ] , int Y [ ] , int N , int M ) { unordered_map < int , int > m1 , m2 ; int i , j , ans = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { int dist = abs ( X [ i ] - X [ j ] ) ; m1 [ dist ] ++ ; } } for ( i = 0 ; i < M ; i ++ ) { for ( j = i + 1 ; j < M ; j ++ ) { int dist = abs ( Y [ i ] - Y [ j ] ) ; m2 [ dist ] ++ ; } } for ( auto i = m1 . begin ( ) ; i != m1 . end ( ) ; i ++ ) { if ( m2 . find ( i -> first ) != m2 . end ( ) ) { ans += ( i -> second * m2 [ i -> first ] ) ; } } return ans ; } int main ( ) { int X [ ] = { 1 , 3 , 7 } ; int Y [ ] = { 2 , 4 , 6 , 1 } ; int N = sizeof ( X ) / sizeof ( X [ 0 ] ) ; int M = sizeof ( Y ) / sizeof ( Y [ 0 ] ) ; cout << numberOfSquares ( X , Y , N , M ) ; return 0 ; }

Index/key variables: dist, i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int No_of_cubes ( int N , int K ) { int No = 0 ; No = ( N - K + 1 ) ; No = pow ( No , 3 ) ; return No ; } int main ( ) { int N = 5 ; int K = 2 ; cout << No_of_cubes ( N , K ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int No_of_rectangles ( int L , int B , int l , int b ) { if ( ( l > L ) || ( b > B ) ) { return -1 ; } else { return ( L - l + 1 ) * ( B - b + 1 ) ; } } int main ( ) { int L = 5 , B = 3 ; int l = 4 , b = 1 ; cout << No_of_rectangles ( L , B , l , b ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkTriangle ( int x , int y , int z ) { if ( x == y && y == z ) cout << " Equilateral ▁ Triangle " ; else if ( x == y y == z z == x ) cout << " Isosceles ▁ Triangle " ; else cout << " Scalene ▁ Triangle " ; } int main ( ) { int x = 8 , y = 7 , z = 9 ; checkTriangle ( x , y , z ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define RADIAN  0.01745329252
float Area_of_Rhombus ( int a , int theta ) { float area = ( a * a ) * sin ( ( RADIAN * theta ) ) ; return area ; } int main ( ) { int a = 4 ; int theta = 60 ; float ans = Area_of_Rhombus ( a , theta ) ; printf ( " % 0.2f " , ans ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int calculateTriangles ( int sides [ ] ) { double count = pow ( sides [ 0 ] + sides [ 1 ] + sides [ 2 ] , 2 ) ; count -= pow ( sides [ 0 ] , 2 ) ; count -= pow ( sides [ 2 ] , 2 ) ; count -= pow ( sides [ 4 ] , 2 ) ; return ( int ) ( count ) ; } int main ( ) { int sides [ ] = { 1 , 1 , 1 , 1 , 1 , 1 } ; cout << ( calculateTriangles ( sides ) ) << endl ; int sides1 [ ] = { 2 , 2 , 1 , 3 , 1 , 2 } ; cout << ( calculateTriangles ( sides1 ) ) << endl ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define PI  3.147
double Length_Diagonal ( int a , int b , double theta ) { double diagonal = sqrt ( ( pow ( a , 2 ) + pow ( b , 2 ) ) - 2 * a * b * cos ( theta * ( PI / 180 ) ) ) ; return diagonal ; } int main ( ) { int a = 3 ; int b = 5 ; double theta = 45 ; double ans = Length_Diagonal ( a , b , theta ) ; printf ( " % .2f " , ans ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void maximumTiles ( int n , int m ) { cout << ( m * n ) / 2 << endl ; } int main ( ) { int M = 3 ; int N = 4 ; maximumTiles ( N , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float Length_Diagonal ( int a , int b , int d ) { float diagonal = sqrt ( 2 * ( ( a * a ) + ( b * b ) ) - ( d * d ) ) ; return diagonal ; } int main ( ) { int A = 10 ; int B = 30 ; int D = 20 ; float ans = Length_Diagonal ( A , B , D ) ; printf ( " % 0.1f " , ans ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < float > Diagonals ( int a , int b , int c , int d ) { vector < float > ans ; ans . push_back ( sqrt ( ( ( a * c ) + ( b * d ) ) * ( ( a * d ) + ( b * c ) ) / ( ( a * b ) + ( c * d ) ) ) ) ; ans . push_back ( sqrt ( ( ( a * c ) + ( b * d ) ) * ( ( a * b ) + ( c * d ) ) / ( ( a * d ) + ( b * c ) ) ) ) ; return ans ; } int main ( ) { int A = 10 ; int B = 15 ; int C = 20 ; int D = 25 ; vector < float > ans = Diagonals ( A , B , C , D ) ; printf ( " % .2f ▁ % .2f " , ( ans [ 0 ] ) + .01 , ans [ 1 ] + .01 ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double find ( double x , double y , vector < vector < int > > & p ) { double mind = 0 ; for ( int i = 0 ; i < p . size ( ) ; i ++ ) { double a = p [ i ] [ 0 ] , b = p [ i ] [ 1 ] ; mind += sqrt ( ( x - a ) * ( x - a ) + ( y - b ) * ( y - b ) ) ; } return mind ; } double getMinDistSum ( vector < vector < int > > & p ) { double x = 0 , y = 0 ; for ( int i = 0 ; i < p . size ( ) ; i ++ ) { x += p [ i ] [ 0 ] ; y += p [ i ] [ 1 ] ; } x = x / p . size ( ) ; y = y / p . size ( ) ; double mind = find ( x , y , p ) ; return mind ; } int main ( ) { vector < vector < int > > vec = { { 0 , 1 } , { 1 , 0 } , { 1 , 2 } , { 2 , 1 } } ; double d = getMinDistSum ( vec ) ; cout << d << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, mind, stdc, x, y
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int det ( int d [ ] [ 3 ] ) { int Sum = d [ 0 ] [ 0 ] * ( ( d [ 1 ] [ 1 ] * d [ 2 ] [ 2 ] ) - ( d [ 2 ] [ 1 ] * d [ 1 ] [ 2 ] ) ) ; Sum -= d [ 0 ] [ 1 ] * ( ( d [ 1 ] [ 0 ] * d [ 2 ] [ 2 ] ) - ( d [ 1 ] [ 2 ] * d [ 2 ] [ 0 ] ) ) ; Sum += d [ 0 ] [ 2 ] * ( ( d [ 0 ] [ 1 ] * d [ 1 ] [ 2 ] ) - ( d [ 0 ] [ 2 ] * d [ 1 ] [ 1 ] ) ) ; return Sum ; } int main ( ) { int x1 = -3 , y1 = 1 , z1 = 5 ; int a1 = -3 , b1 = 1 , c1 = 5 ; int x2 = -1 , y2 = 2 , z2 = 5 ; int a2 = -1 , b2 = 2 , c2 = 5 ; int det_list [ 3 ] [ 3 ] = { { x2 - x1 , y2 - y1 , z2 - z1 } , { a1 , b1 , c1 } , { a2 , b2 , c2 } } ; if ( det ( det_list ) == 0 ) { cout << " Lines ▁ are ▁ coplanar " << endl ; } else { cout << " Lines ▁ are ▁ non ▁ coplanar " << endl ; } return 0 ; }

Accumulator variables: Sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; double distance ( int r , int R ) { double d = sqrt ( pow ( R , 2 ) - ( 2 * r * R ) ) ; return d ; } int main ( ) { int r = 2 ; int R = 5 ; cout << ( round ( distance ( r , R ) * 100.0 ) / 100.0 ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define PI  3.141592653589
double uniform ( ) { return ( double ) rand ( ) / RAND_MAX ; } vector < pair < double , double > > randPoint ( int r , int x , int y , int n ) { vector < pair < double , double > > res ; for ( int i = 0 ; i < n ; i ++ ) { double theta = 2 * PI * uniform ( ) ; double len = sqrt ( uniform ( ) ) * r ; res . push_back ( { x + len * cos ( theta ) , y + len * sin ( theta ) } ) ; } return res ; } void printVector ( vector < pair < double , double > > A ) { for ( pair < double , double > P : A ) { printf ( " ( % . 2lf , ▁ % .2lf ) STRNEWLINE " , P . first , P . second ) ; } } int main ( ) { int R = 12 ; int X = 3 ; int Y = 3 ; int N = 5 ; printVector ( randPoint ( R , X , Y , N ) ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: P, i
C++ program:
#include <iostream>
using namespace std ; void checkValidPolygon ( int arr [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } if ( sum == 180 * ( N - 2 ) ) cout << " Yes " ; else cout << " No " ; } int main ( ) { int N = 3 ; int arr [ ] = { 60 , 60 , 60 } ; checkValidPolygon ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimalSquareSide ( int a , int b ) { if ( a == b ) { return 2 * a ; } if ( a != b ) { if ( a > b ) { int newB = b + b ; int diff = abs ( newB - a ) ; if ( newB < a ) { b = newB + diff ; if ( a == b ) return a ; return 0 ; } else { a = a + diff ; if ( a == newB ) return a ; return 0 ; } } else { int newA = a + a ; int diff = abs ( newA - b ) ; if ( newA < b ) { a = diff + newA ; if ( a == b ) return a ; return 0 ; } else { b = b + diff ; if ( b == newA ) return b ; return 0 ; } } } } int main ( ) { int H , W ; H = 3 , W = 1 ; cout << minimalSquareSide ( H , W ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double minAnglRot ( int N ) { double res ; res = 360 / ( double ) N ; return res ; } int main ( ) { int N = 4 ; cout << " Angle ▁ of ▁ Rotational ▁ Symmetry : ▁ " << minAnglRot ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double Area_of_Triangle ( int a , int b , int c ) { int s = ( a + b + c ) / 2 ; int x = s * ( s - a ) ; x = x * ( s - b ) ; x = x * ( s - c ) ; double area = ( 4 / ( double ) 3 ) * sqrt ( x ) ; return area ; } int main ( ) { int a = 9 ; int b = 12 ; int c = 15 ; double ans = Area_of_Triangle ( a , b , c ) ; cout << ans ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  1001
bool arr [ MAX ] [ MAX ] ; void updateArray ( int x1 , int y1 , int x2 , int y2 ) { for ( int i = x1 ; i < x2 ; i ++ ) { for ( int j = y1 ; j < y2 ; j ++ ) { arr [ i ] [ j ] = true ; } } } int findAreaCovered ( ) { int area = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < MAX ; j ++ ) { if ( arr [ i ] [ j ] == true ) { area ++ ; } } } return area ; } int main ( ) { int N = 3 ; vector < vector < int > > A = { { 1 , 3 , 4 , 5 } , { 3 , 1 , 7 , 4 } , { 5 , 3 , 8 , 6 } } ; for ( int i = 0 ; i < N ; i ++ ) { updateArray ( A [ i ] [ 0 ] , A [ i ] [ 1 ] , A [ i ] [ 2 ] , A [ i ] [ 3 ] ) ; } int area = findAreaCovered ( ) ; cout << area ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: area, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findEquation ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 , int d , int e , int f ) { double a = x2 - x1 ; double b = y2 - y1 ; double c = z2 - z1 ; int A = ( b * f - c * e ) ; int B = ( a * f - c * d ) ; int C = ( a * e - b * d ) ; int D = - ( A * d - B * e + C * f ) ; cout << A << " x ▁ + ▁ " << B << " y ▁ + ▁ " << C << " z ▁ + ▁ " << D << " = ▁ 0" ; } int main ( ) { int x1 = 2 , y1 = 3 , z1 = 5 ; int x2 = 6 , y2 = 7 , z2 = 8 ; int a = 11 , b = 23 , c = 10 ; findEquation ( x1 , y1 , z1 , x2 , y2 , z2 , a , b , c ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float median ( int a , int b , int c ) { float n = sqrt ( 2 * b * b + 2 * c * c - a * a ) / 2 ; return n ; } int main ( ) { int a , b , c ; a = 4 ; b = 3 ; c = 5 ; float ans = median ( a , b , c ) ; cout << fixed << setprecision ( 2 ) << ans ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i < n + 1 ; i ++ ) res = res * i ; return res ; } int nCr ( int n , int r ) { return ( fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ) ; } int main ( ) { int n = 5 ; cout << ( nCr ( n , 4 ) ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findSide ( float a , float B , float C ) { float A = 180 - C - B ; float radA = M_PI * ( A / 180 ) ; float radB = M_PI * ( B / 180 ) ; float radC = M_PI * ( C / 180 ) ; float b = a / sin ( radA ) * sin ( radB ) ; float c = a / sin ( radA ) * sin ( radC ) ; cout << fixed << setprecision ( 15 ) << b << " ▁ " ; cout << fixed << setprecision ( 15 ) << c ; } int main ( ) { int a = 12 , B = 60 , C = 30 ; findSide ( a , B , C ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int areaSquare ( int L , int B ) { int large = max ( L , B ) ; int small = min ( L , B ) ; if ( large >= 2 * small ) return large * large ; else return ( 2 * small ) * ( 2 * small ) ; } int main ( ) { int L = 7 ; int B = 4 ; cout << areaSquare ( L , B ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const double pi = acos ( -1.0 ) ; double nGon ( int N ) { double proAngleVar ; if ( N % 4 == 0 ) { proAngleVar = pi * ( 180.0 / N ) / 180 ; } else { proAngleVar = pi * ( 180.0 / ( 2 * N ) ) / 180 ; } double negX = 1.0e+99 , posX = -1.0e+99 , negY = 1.0e+99 , posY = -1.0e+99 ; for ( int j = 0 ; j < N ; ++ j ) { double px = cos ( 2 * pi * j / N + proAngleVar ) ; double py = sin ( 2 * pi * j / N + proAngleVar ) ; negX = min ( negX , px ) ; posX = max ( posX , px ) ; negY = min ( negY , py ) ; posY = max ( posY , py ) ; } double opt2 = max ( posX - negX , posY - negY ) ; return ( double ) opt2 / sin ( pi / N ) / 2 ; } int main ( ) { int N = 10 ; cout << nGon ( N ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int heptacontagonNum ( int n ) { return ( 68 * n * n - 66 * n ) / 2 ; } int main ( ) { int N = 3 ; cout << "3rd ▁ heptacontagon ▁ Number ▁ is ▁ = ▁ " << heptacontagonNum ( N ) ; return 0 ; }

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

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

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isicosihenagonal ( int N ) { float n = ( 17 + sqrt ( 152 * N + 289 ) ) / 38 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int i = 21 ; if ( isicosihenagonal ( i ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isicositrigonal ( int N ) { float n = ( 19 + sqrt ( 168 * N + 361 ) ) / 42 ; return ( n - ( int ) n ) == 0 ; } int main ( ) { int i = 23 ; if ( isicositrigonal ( i ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const long long mod = 1000000007 ; const int MAXN = 1001 ; long long factorial [ MAXN ] , inverse [ MAXN ] ; long long power ( long long a , long long b ) { long long res = 1 ; while ( b > 0 ) { if ( b % 2 == 1 ) { res = ( res * a ) % mod ; } a = ( a * a ) % mod ; b >>= 1 ; } return res ; } long long nCk ( int n , int k ) { if ( k < 0 k > n ) { return 0 ; } long long ans = factorial [ n ] ; ans = ( ans * inverse [ n - k ] ) % mod ; ans = ( ans * inverse [ k ] ) % mod ; return ans ; } void numberOfWays ( vector < pair < int , int > > lines , int K , int N ) { sort ( lines . begin ( ) , lines . end ( ) ) ; long long total_case = nCk ( N , K ) ; multiset < int > m ; for ( int i = 0 ; i < N ; i ++ ) { while ( ! m . empty ( ) && ( * m . begin ( ) < lines [ i ] . first ) ) { m . erase ( m . begin ( ) ) ; } total_case -= nCk ( m . size ( ) , K - 1 ) ; total_case += mod ; total_case %= mod ; m . insert ( lines [ i ] . second ) ; } cout << total_case << endl ; } void preCompute ( ) { long long fact = 1 ; factorial [ 0 ] = 1 ; inverse [ 0 ] = 1 ; for ( int i = 1 ; i < MAXN ; i ++ ) { fact = ( fact * i ) % mod ; factorial [ i ] = fact ; inverse [ i ] = power ( factorial [ i ] , mod - 2 ) ; } } int main ( ) { int N = 3 , K = 2 ; vector < pair < int , int > > lines ; preCompute ( ) ; lines . push_back ( { 1 , 3 } ) ; lines . push_back ( { 4 , 5 } ) ; lines . push_back ( { 5 , 7 } ) ; numberOfWays ( lines , K , N ) ; return 0 ; }

Index/key variables: MAXN, i, k, n
Accumulator variables: i, stdc, total_case
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkTriangle ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { int a = x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ; if ( a == 0 ) cout << " No " ; else cout << " Yes " ; } int main ( ) { int x1 = 1 , x2 = 2 , x3 = 3 , y1 = 1 , y2 = 2 , y3 = 3 ; checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numTrip ( vector < pair < int , int > > & points ) { int res = 0 ; for ( int i = 0 ; i < points . size ( ) ; ++ i ) { unordered_map < long , int > map ( points . size ( ) ) ; for ( int j = 0 ; j < points . size ( ) ; ++ j ) { if ( j == i ) continue ; int dy = points [ i ] . second - points [ j ] . second ; int dx = points [ i ] . first - points [ j ] . first ; int key = dy * dy ; key += dx * dx ; map [ key ] ++ ; } for ( auto & p : map ) res += p . second * ( p . second - 1 ) ; } return res ; } int main ( ) { vector < pair < int , int > > mat = { { 0 , 0 } , { 1 , 0 } , { 2 , 0 } } ; cout << numTrip ( mat ) ; return 0 ; }

Index/key variables: i, j, key
Accumulator variables: key, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkOverlap ( int R , int Xc , int Yc , int X1 , int Y1 , int X2 , int Y2 ) { int Xn = max ( X1 , min ( Xc , X2 ) ) ; int Yn = max ( Y1 , min ( Yc , Y2 ) ) ; int Dx = Xn - Xc ; int Dy = Yn - Yc ; return ( Dx * Dx + Dy * Dy ) <= R * R ; } int main ( ) { int R = 1 ; int Xc = 0 , Yc = 0 ; int X1 = 1 , Y1 = -1 ; int X2 = 3 , Y2 = 1 ; if ( checkOverlap ( R , Xc , Yc , X1 , Y1 , X2 , Y2 ) ) { cout << " True " << endl ; } else { cout << " False " ; } }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkIntersection ( pair < int , int > p1 , pair < int , int > p2 , pair < int , int > p ) { int val ; if ( p1 . second == p2 . second && p1 . second == p . second ) { if ( p . first <= max ( p1 . first , p2 . first ) && ( p . first >= min ( p1 . first , p2 . first ) ) ) return 1 ; } if ( p1 . first == p2 . first && p1 . first == p . first ) { if ( p . second <= max ( p1 . second , p2 . second ) && ( p . second >= min ( p1 . second , p2 . second ) ) ) return 1 ; } else { val = ( p . second - p1 . second ) * ( p2 . first - p1 . first ) - ( p . first - p1 . first ) * ( p2 . second - p1 . second ) ; if ( val == 0 ) if ( ( p . first <= max ( p1 . first , p2 . first ) && ( p . first >= min ( p1 . first , p2 . first ) ) ) && ( p . second <= max ( p1 . second , p2 . second ) && ( p . second >= min ( p1 . second , p2 . second ) ) ) ) return 1 ; } return 0 ; } void towerOfSight ( pair < int , int > a , pair < int , int > b , pair < int , int > c , pair < int , int > d ) { int flag = 0 ; if ( checkIntersection ( a , c , b ) ) flag = 1 ; else if ( checkIntersection ( a , c , d ) ) flag = 1 ; else if ( checkIntersection ( b , d , a ) ) flag = 1 ; else if ( checkIntersection ( b , d , c ) ) flag = 1 ; flag ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; } int main ( ) { pair < int , int > a = { 0 , 0 } ; pair < int , int > b = { 0 , -2 } ; pair < int , int > c = { 2 , 0 } ; pair < int , int > d = { 0 , 2 } ; towerOfSight ( a , b , c , d ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int NotParallel ( int p [ ] [ 2 ] , int n ) { map < int , int > x_axis , y_axis ; for ( int i = 0 ; i < n ; i ++ ) { x_axis [ p [ i ] [ 0 ] ] ++ ; y_axis [ p [ i ] [ 1 ] ] ++ ; } int total = ( n * ( n - 1 ) ) / 2 ; for ( auto i : x_axis ) { int c = i . second ; total -= ( c * ( c - 1 ) ) / 2 ; } for ( auto i : y_axis ) { int c = i . second ; total -= ( c * ( c - 1 ) ) / 2 ; } return total ; } int main ( ) { int p [ ] [ 2 ] = { { 1 , 2 } , { 1 , 5 } , { 1 , 15 } , { 2 , 10 } } ; int n = sizeof ( p ) / sizeof ( p [ 0 ] ) ; cout << NotParallel ( p , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, total
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int check ( int n , int m ) { if ( m % n == 0 ) { cout << " YES " ; } else { cout << " NO " ; } return 0 ; } int main ( ) { int n = 5 ; int m = 10 ; check ( n , m ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findModulo ( string s ) { int l = s . length ( ) ; int i , modulus = 0 ; if ( s . find ( ' + ' ) < l ) { i = s . find ( ' + ' ) ; } else { i = s . find ( ' - ' ) ; } string real = s . substr ( 0 , i ) ; string imaginary = s . substr ( i + 1 , l - 1 ) ; int x = stoi ( real ) ; int y = stoi ( imaginary ) ; cout << sqrt ( x * x + y * y ) << " STRNEWLINE " ; } int main ( ) { string s = "3 + 4i " ; findModulo ( s ) ; return 0 ; }

Accumulator variables: stdc