dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void disp ( int row_no , int block ) { cout << row_no * block ; } int row ( int ht , int h ) { return ht / h ; } void calculate ( int l , int w , int h , int a , int ht ) { int no_block = ( 4 * a ) / l ; int row_no ; if ( h < w ) row_no = row ( ht , w ) ; else row_no = row ( ht , h ) ; disp ( row_no , no_block ) ; } int main ( ) { int l = 50 , w = 20 , h = 35 ; int a = 700 ; int ht = 140 ; calculate ( l , w , h , a , ht ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double solve ( int s ) { double area = ( 1.732 * pow ( s , 2 ) ) / 8 ; return area ; } int main ( ) { int n = 14 ; cout << solve ( n ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float find_Area ( float a ) { float R = a * ( 2.0 - sqrt ( 2 ) ) ; float area = 3.14 * R * R / 2.0 ; return area ; } int main ( ) { float a = 4 ; cout << " ▁ Area ▁ of ▁ semicircle ▁ = ▁ " << find_Area ( a ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int times ( int steps [ ] , int n ) { int current_level = 0 ; int previous_level = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { previous_level = current_level ; current_level = current_level + steps [ i ] ; if ( ( previous_level < 0 && current_level >= 0 ) || ( previous_level > 0 && current_level <= 0 ) ) { count ++ ; } } return count ; } int main ( ) { int steps [ 12 ] = { 1 , -1 , 0 , 0 , 1 , 1 , -3 , 2 } ; int n = sizeof ( steps ) / sizeof ( int ) ; cout << times ( steps , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float * XandYandZintercept ( float A , float B , float C , float D ) { static float rslt [ 3 ] ; float x = - D / A ; float y = - D / B ; float z = - D / C ; rslt [ 0 ] = x ; rslt [ 1 ] = y ; rslt [ 2 ] = z ; return rslt ; } void equation_plane ( int p [ ] , int q [ ] , int r [ ] ) { int x1 = p [ 0 ] ; int y1 = p [ 1 ] ; int z1 = p [ 2 ] ; int x2 = q [ 0 ] ; int y2 = q [ 1 ] ; int z2 = q [ 2 ] ; int x3 = r [ 0 ] ; int y3 = r [ 1 ] ; int z3 = r [ 2 ] ; int a1 = x2 - x1 ; int b1 = y2 - y1 ; int c1 = z2 - z1 ; int a2 = x3 - x1 ; int b2 = y3 - y1 ; int c2 = z3 - z1 ; int A = b1 * c2 - b2 * c1 ; int B = a2 * c1 - a1 * c2 ; int C = a1 * b2 - b1 * a2 ; int D = ( - A * x1 - B * y1 - C * z1 ) ; float * rslt = XandYandZintercept ( A , B , C , D ) ; for ( int i = 0 ; i < 3 ; i ++ ) { cout << rslt [ i ] << " ▁ " ; } } int main ( ) { int x1 = -1 ; int y1 = 2 ; int z1 = 1 ; int x2 = 0 ; int y2 = -3 ; int z2 = 2 ; int x3 = 1 ; int y3 = 1 ; int z3 = -4 ; int p [ 3 ] = { x1 , y1 , z1 } ; int q [ 3 ] = { x2 , y2 , z2 } ; int r [ 3 ] = { x3 , y3 , z3 } ; equation_plane ( p , q , r ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < pair < int , int > > FindPoints ( int n ) { vector < pair < int , int > > v ; v . push_back ( { 0 , 0 } ) ; v . push_back ( { 0 , n } ) ; v . push_back ( { n , 0 } ) ; v . push_back ( { n , n } ) ; if ( n % 2 == 0 ) v . push_back ( { n / 2 , n / 2 } ) ; return v ; } int main ( ) { int N = 8 ; vector < pair < int , int > > v = FindPoints ( N ) ; for ( auto i : v ) { cout << " ( " << i . first << " , ▁ " << i . second << " ) ▁ " ; } return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double pie = 3.1415926535897 ; double findsolution ( double d , double h , double m , double n ) { double k = ( 4 * m ) / ( pie * d * d ) ; if ( n > k ) return -1 ; double ans = ( h / ( k - n ) ) ; return ans ; } int main ( ) { double d = 1 , h = 1 , m = 1 , n = 1 ; cout << findsolution ( d , h , m , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfInternalAngles ( int n ) { if ( n < 3 ) return 0 ; return ( n - 2 ) * 180 ; } int main ( ) { int n = 5 ; cout << sumOfInternalAngles ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntWays ( int n ) { if ( n % 2 == 1 ) { return 0 ; } else { return ( n - 2 ) / 4 ; } } int main ( ) { int n = 18 ; cout << cntWays ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int noOfTriangles ( int n ) { int y = 4 * n ; return ( ( y * ( y - 2 ) * ( y - 1 ) ) - ( 4 * n * ( n - 2 ) * ( n - 1 ) ) ) / 6 ; } int main ( ) { int n = 1 ; cout << noOfTriangles ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int angle ( int n ) { return 2 * n ; } int main ( ) { int n = 30 ; cout << angle ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool orthogonality ( int x1 , int y1 , int x2 , int y2 , int r1 , int r2 ) { int dsquare = ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ; if ( dsquare == r1 * r1 + r2 * r2 ) return true ; else return false ; } int main ( ) { int x1 = 4 , y1 = 3 ; int x2 = 0 , y2 = 1 ; int r1 = 2 , r2 = 4 ; bool f = orthogonality ( x1 , y1 , x2 , y2 , r1 , r2 ) ; if ( f ) cout << " Given ▁ circles ▁ are " << " ▁ orthogonal . " ; else cout << " Given ▁ circles ▁ are " << " ▁ not ▁ orthogonal . " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int dx [ ] = { -1 , 0 , 1 , 0 } ; int dy [ ] = { 0 , 1 , 0 , -1 } ; int ifRight ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { int a = ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) ; int b = ( ( x1 - x3 ) * ( x1 - x3 ) ) + ( ( y1 - y3 ) * ( y1 - y3 ) ) ; int c = ( ( x2 - x3 ) * ( x2 - x3 ) ) + ( ( y2 - y3 ) * ( y2 - y3 ) ) ; if ( ( a == ( b + c ) && a != 0 && b != 0 && c != 0 ) || ( b == ( a + c ) && a != 0 && b != 0 && c != 0 ) || ( c == ( a + b ) && a != 0 && b != 0 && c != 0 ) ) { return 1 ; } return 0 ; } void isValidCombination ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { int x , y ; bool possible = 0 ; if ( ifRight ( x1 , y1 , x2 , y2 , x3 , y3 ) ) { cout << " ALREADY ▁ RIGHT ▁ ANGLED " ; return ; } else { for ( int i = 0 ; i < 4 ; i ++ ) { x = dx [ i ] + x1 ; y = dy [ i ] + y1 ; if ( ifRight ( x , y , x2 , y2 , x3 , y3 ) ) { cout << " POSSIBLE " ; return ; } x = dx [ i ] + x2 ; y = dy [ i ] + y2 ; if ( ifRight ( x1 , y1 , x , y , x3 , y3 ) ) { cout << " POSSIBLE " ; return ; } x = dx [ i ] + x3 ; y = dy [ i ] + y3 ; if ( ifRight ( x1 , y1 , x2 , y2 , x , y ) ) { cout << " POSSIBLE " ; return ; } } } if ( ! possible ) cout << " NOT ▁ POSSIBLE " << endl ; } int main ( ) { int x1 = -49 , y1 = 0 ; int x2 = 0 , y2 = 50 ; int x3 = 0 , y3 = -50 ; isValidCombination ( x1 , y1 , x2 , y2 , x3 , y3 ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <cmath>
using namespace std ; double area_of_regular_polygon ( double n , double len ) { double P = ( len * n ) ; double A = len / ( 2 * tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; double area = ( P * A ) / 2 ; return area ; } double area_of_triangle_inscribed ( double n , double len ) { double area = area_of_regular_polygon ( n , len ) ; double triangle = area / n ; double ins_tri = ( triangle * 3 ) ; return ins_tri ; } int main ( ) { double n = 6 , len = 10 ; cout << area_of_triangle_inscribed ( n , len ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float Area ( int d , int h1 , int h2 ) { float area ; area = 0.5 * d * ( h1 + h2 ) ; return area ; } int main ( ) { int d = 6 , h1 = 4 , h2 = 3 ; cout << " Area ▁ of ▁ Quadrilateral ▁ = ▁ " << ( Area ( d , h1 , h2 ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float diagonal_length ( float a ) { float L ; L = a * sqrt ( 3 ) ; return L ; } int main ( ) { float a = 5 ; cout << diagonal_length ( a ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int concentric_Hexagon ( int n ) { return 3 * pow ( n , 2 ) / 2 ; } int main ( ) { int n = 3 ; cout << concentric_Hexagon ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const double PI = 3.14 ; double find_area ( int r , int d ) { double R = d / PI ; R += pow ( r , 2 ) ; R = sqrt ( R ) ; double area = PI * pow ( R , 2 ) ; return area ; } int main ( ) { int r = 4 , d = 5 ; cout << find_area ( r , d ) ; return 0 ; }

Accumulator variables: R, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool Valid ( int a , int b , int c , int d ) { if ( a + b + c + d == 360 ) return true ; return false ; } int main ( ) { int a = 80 , b = 70 , c = 100 , d = 110 ; if ( Valid ( a , b , c , d ) ) cout << " Valid ▁ quadrilateral " ; else cout << " Invalid ▁ quadrilateral " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double calculate_angle ( double n ) { double total_angle = 360 ; return total_angle / n ; } int main ( ) { double N = 5 ; cout << calculate_angle ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void PrintMaxMinValue ( double a , double b , double c ) { double secondPart = c * 1.0 - ( b * b / ( 4.0 * a ) ) ; if ( a > 0 ) { cout << " Maxvalue ▁ = ▁ " << " Infinity STRNEWLINE " ; cout << " Minvalue ▁ = ▁ " << secondPart ; } else if ( a < 0 ) { cout << " Maxvalue ▁ = ▁ " << secondPart << " STRNEWLINE " ; cout << " Minvalue ▁ = ▁ " << " - Infinity " ; } else { cout << " Not ▁ a ▁ quadratic ▁ function STRNEWLINE " ; } } int main ( ) { double a = -1 , b = 3 , c = -2 ; PrintMaxMinValue ( a , b , c ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void newvol ( double x ) { cout << " percentage ▁ increase ▁ " << " in ▁ the ▁ volume ▁ of ▁ the ▁ cylinder ▁ is ▁ " << x << " % " << endl ; } int main ( ) { double x = 10 ; newvol ( x ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void radius ( double n , double d ) { cout << " The ▁ side ▁ of ▁ each ▁ square ▁ is ▁ " << d / ( ( n - 1 ) * sqrt ( 2 ) ) << endl ; } int main ( ) { double d = 42 , n = 4 ; radius ( n , d ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; double innerCirclearea ( double radius ) { if ( radius < 0 ) { return -1 ; } double r = radius / 2 ; double Area = ( 3.14 * pow ( r , 2 ) ) ; return Area ; } int main ( ) { double radius = 4 ; cout << ( " Area ▁ of ▁ circle ▁ c2 ▁ = ▁ " , innerCirclearea ( radius ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void angleequichord ( int z ) { cout << " The ▁ angle ▁ subtended ▁ at ▁ the ▁ center ▁ is ▁ " << z << " ▁ degrees " << endl ; } int main ( ) { int z = 48 ; angleequichord ( z ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void lengequichord ( int z ) { cout << " The ▁ distance ▁ between ▁ the ▁ " << " chord ▁ and ▁ the ▁ center ▁ is ▁ " << z << endl ; } int main ( ) { int z = 48 ; lengequichord ( z ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void lengperpbisect ( double r1 , double r2 ) { double z = 2 * sqrt ( ( r1 * r1 ) - ( ( r1 - r2 ) * ( r1 - r2 ) / 4 ) ) ; cout << " The ▁ length ▁ of ▁ the ▁ " << " perpendicular ▁ bisector ▁ is ▁ " << z << endl ; } int main ( ) { double r1 = 5 , r2 = 3 ; lengperpbisect ( r1 , r2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void lengchord ( int z ) { cout << " The ▁ length ▁ is ▁ " << z << endl ; } int main ( ) { int z = 48 ; lengchord ( z ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void distcenter ( int r1 , int r2 , int x ) { int z = sqrt ( ( r1 * r1 ) - ( x / 2 * x / 2 ) ) + sqrt ( ( r2 * r2 ) - ( x / 2 * x / 2 ) ) ; cout << " distance ▁ between ▁ the " << " ▁ centers ▁ is ▁ " << z << endl ; } int main ( ) { int r1 = 24 , r2 = 37 , x = 40 ; distcenter ( r1 , r2 , x ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void angleextcycquad ( int z ) { cout << " The ▁ exterior ▁ angle ▁ of ▁ the " << " ▁ cyclic ▁ quadrilateral ▁ is ▁ " << z << " ▁ degrees " << endl ; } int main ( ) { int z = 48 ; angleextcycquad ( z ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void anglechordtang ( int z ) { cout << " The ▁ angle ▁ between ▁ tangent " << " ▁ and ▁ the ▁ chord ▁ is ▁ " << z << " ▁ degrees " << endl ; } int main ( ) { int z = 48 ; anglechordtang ( z ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isPerfect ( int N ) { int sumOfDivisors = 1 ; for ( int i = 2 ; i <= N / 2 ; ++ i ) { if ( N % i == 0 ) { sumOfDivisors += i ; } } if ( sumOfDivisors == N ) { return 1 ; } else return 0 ; } int sumOfDigits ( int N ) { int sum = 0 ; while ( N != 0 ) { sum += ( N % 10 ) ; N = N / 10 ; } return sum ; } void countPerfectNumbers ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; ++ i ) { if ( isPerfect ( arr [ i ] ) ) { int sum = sumOfDigits ( arr [ i ] ) ; if ( isPerfect ( sum ) ) { cout << arr [ i ] << " ▁ " ; } } } } int main ( ) { int arr [ ] = { 3 , 8 , 12 , 28 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countPerfectNumbers ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: stdc, sum, sumOfDivisors
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define int  long long
using namespace std ; map < pair < int , int > , int > dp ; int maxPreSum ( vector < int > a , vector < int > b , int x , int y ) { if ( dp . find ( { x , y } ) != dp . end ( ) ) return dp [ { x , y } ] ; if ( x == a . size ( ) && y == b . size ( ) ) return 0 ; int curr = dp [ { x , y } ] ; if ( x == a . size ( ) ) { curr = max ( curr , b [ y ] + maxPreSum ( a , b , x , y + 1 ) ) ; } else if ( y == b . size ( ) ) { curr = max ( curr , a [ x ] + maxPreSum ( a , b , x + 1 , y ) ) ; } else { curr = max ( { curr , a [ x ] + maxPreSum ( a , b , x + 1 , y ) , b [ y ] + maxPreSum ( a , b , x , y + 1 ) } ) ; } return dp [ { x , y } ] = curr ; } signed main ( ) { vector < int > A = { 2 , 1 , 13 , 5 , 14 } ; vector < int > B = { -1 , 4 , -13 } ; cout << maxPreSum ( A , B , 0 , 0 ) << endl ; return 0 ; }

Index/key variables: x, y
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct TreeNode { int val ; TreeNode * left , * right ; TreeNode ( int x = 0 ) { val = x ; left = NULL ; right = NULL ; } } ; int findSum ( TreeNode * root ) { queue < TreeNode * > que ; que . push ( root ) ; int ans = 0 ; while ( que . size ( ) ) { int leaf = 0 ; int nonleaf = 0 ; int length = que . size ( ) ; while ( length ) { auto temp = que . front ( ) ; que . pop ( ) ; if ( ! temp -> left && ! temp -> right ) leaf += temp -> val ; else nonleaf += temp -> val ; if ( temp -> left ) que . push ( temp -> left ) ; if ( temp -> right ) que . push ( temp -> right ) ; length -= 1 ; } ans += leaf & nonleaf ; } return ans ; } int main ( ) { TreeNode * root = new TreeNode ( 5 ) ; root -> left = new TreeNode ( 3 ) ; root -> right = new TreeNode ( 9 ) ; root -> left -> left = new TreeNode ( 6 ) ; root -> left -> right = new TreeNode ( 4 ) ; root -> left -> left -> right = new TreeNode ( 7 ) ; cout << findSum ( root ) ; }

Accumulator variables: ans, leaf, length, nonleaf, stdc
Class/struct names: TreeNode
C++ program:
#include <bits/stdc++.h>
using namespace std ; void MinTime ( int * a , int * b , int n , int m ) { int ans = INT_MAX ; int prefix_a [ 10 ] = { 0 } ; int prefix_b [ 10 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { prefix_a [ a [ i ] ] ++ ; } for ( int i = 0 ; i < m ; i ++ ) { prefix_b [ b [ i ] ] ++ ; } for ( int i = 1 ; i <= 9 ; i ++ ) { prefix_a [ i ] += prefix_a [ i - 1 ] ; } for ( int i = 1 ; i <= 9 ; i ++ ) { prefix_b [ i ] += prefix_b [ i - 1 ] ; } for ( int i = 0 ; i <= 9 ; i ++ ) { ans = min ( ans , prefix_a [ i ] + m - prefix_b [ i ] ) ; ans = min ( ans , n - prefix_a [ i ] + prefix_b [ i ] ) ; } cout << ans ; } int main ( ) { int A [ ] = { 0 , 0 , 1 , 3 , 3 } ; int B [ ] = { 2 , 0 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int M = sizeof ( B ) / sizeof ( B [ 0 ] ) ; MinTime ( A , B , N , M ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findReverse ( int N ) { int rev = 0 ; while ( N > 0 ) { rev <<= 1 ; if ( N & 1 == 1 ) rev ^= 1 ; N >>= 1 ; } return rev ; } void countElements ( int arr [ ] , int N ) { vector < int > ans ; for ( int i = 0 ; i < N ; i ++ ) { ans . push_back ( findReverse ( arr [ i ] ) ) ; } unordered_map < int , int > cnt ; for ( int i = 0 ; i < N ; i ++ ) { cnt [ arr [ i ] ] = 1 ; } int count = 0 ; for ( auto i : ans ) { if ( cnt [ i ] ) count ++ ; } cout << count << endl ; } int main ( ) { int arr [ ] = { 1 , 30 , 3 , 8 , 12 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; countElements ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, rev, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void fizzBuzz ( int N ) { int count3 = 0 ; int count5 = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { count3 ++ ; count5 ++ ; bool flag = false ; if ( count3 == 3 ) { cout << " Fizz " ; count3 = 0 ; flag = true ; } if ( count5 == 5 ) { cout << " Buzz " ; count5 = 0 ; flag = true ; } if ( ! flag ) { cout << i ; } cout << " ▁ " ; } } int main ( ) { int N = 15 ; fizzBuzz ( N ) ; return 0 ; }

Accumulator variables: count3, count5, i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool prime [ 1000005 ] ; void SieveOfEratosthenes ( int N ) { memset ( prime , true , sizeof ( prime ) ) ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= N ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= N ; i += p ) prime [ i ] = false ; } } } void checkElementsOnDiagonal ( vector < vector < int > > M , int N ) { int flag = 1 ; SieveOfEratosthenes ( 1000000 ) ; for ( int i = 0 ; i < N ; i ++ ) { flag &= ( prime [ M [ i ] [ i ] ] && prime [ M [ i ] [ N - 1 - i ] ] ) ; } if ( flag ) cout << " Yes " << endl ; else cout << " No " ; } int main ( ) { vector < vector < int > > M = { { 1 , 2 , 3 , 13 } , { 5 , 3 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 7 } } ; int N = M . size ( ) ; checkElementsOnDiagonal ( M , N ) ; return 0 ; }

Index/key variables: i, p
Accumulator variables: flag, i, p, stdc
Iterator variables: i, p
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > circularPermutation ( int n , int start ) { vector < int > res = { 0 } ; vector < int > ret ; int index = -1 ; for ( int k = 0 , add = 1 << k ; k < n ; k ++ , add = 1 << k ) { for ( int i = res . size ( ) - 1 ; i >= 0 ; i -- ) { if ( res [ i ] + add == start ) index = res . size ( ) ; res . push_back ( res [ i ] + add ) ; } } if ( start == 0 ) return res ; while ( ret . size ( ) < res . size ( ) ) { ret . push_back ( res [ index ] ) ; index = ( index + 1 ) % res . size ( ) ; } return ret ; } int main ( ) { int N = 2 , S = 3 ; vector < int > print = circularPermutation ( N , S ) ; cout << " [ " ; for ( int i = 0 ; i < print . size ( ) - 1 ; i ++ ) { cout << print [ i ] << " , ▁ " ; } cout << print [ print . size ( ) - 1 ] << " ] " ; return 0 ; }

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

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countPairs ( int a [ ] , int n ) { int count = 0 ; map < double , int > mp ; for ( int i = 0 ; i < n ; i ++ ) { int y = a [ i ] ; if ( y != 0 && y != 1 ) { double x = ( ( y * 1.0 ) / ( 1 - y ) ) * y ; count += mp [ x ] ; } mp [ y ] ++ ; } return count ; } int main ( ) { int arr [ ] = { -4 , -3 , 0 , 2 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countPairs ( arr , N ) ; return 0 ; }

Index/key variables: i, x, y
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool contains ( int num , int K , int base ) { bool isThere = 0 ; while ( num ) { int remainder = num % base ; if ( remainder == K ) { isThere = 1 ; } num /= base ; } return isThere ; } void count ( int n , int k , vector < vector < int > > v ) { int pref [ 1000005 ] = { 0 } ; for ( int i = 1 ; i < 1e6 + 5 ; i ++ ) { bool present = contains ( i , k , 10 ) || contains ( i , k , 8 ) ; pref [ i ] += pref [ i - 1 ] + present ; } for ( int i = 0 ; i < n ; ++ i ) { cout << v [ i ] [ 1 ] - v [ i ] [ 0 ] + 1 - ( pref [ v [ i ] [ 1 ] ] - pref [ v [ i ] [ 0 ] - 1 ] ) << ' ▁ ' ; } } int main ( ) { int K = 7 ; vector < vector < int > > Q = { { 2 , 5 } , { 1 , 15 } } ; int N = Q . size ( ) ; count ( N , K , Q ) ; }

Index/key variables: i
Accumulator variables: i, num, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberOfTiles ( int N , int M ) { if ( N % 2 == 1 ) { return -1 ; } return ( N * 1LL * M ) / 2 ; } int main ( ) { int N = 2 , M = 4 ; cout << numberOfTiles ( N , M ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void canMakeEqual ( int arr1 [ ] , int arr2 [ ] , int N ) { int count = 0 ; int arr1_one = 0 , arr1_zero = 0 ; int arr2_one = 0 , arr2_zero = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr1 [ i ] == 1 ) { arr1_one ++ ; } else if ( arr1 [ i ] == 0 ) { arr1_zero ++ ; } if ( arr2 [ i ] == 1 ) { arr2_one ++ ; } else if ( arr2 [ i ] == 0 ) { arr2_zero ++ ; } } if ( arr1_one != arr2_one arr1_zero != arr2_zero ) { cout << " No " ; return ; } for ( int i = 0 ; i < N ; i ++ ) { count = count + ( arr1 [ i ] - arr2 [ i ] ) ; if ( count < 0 ) { cout << " No " ; return ; } } cout << " Yes " ; } int main ( ) { int arr1 [ ] = { 0 , 1 , 1 , 0 } ; int arr2 [ ] = { 0 , 0 , 1 , 1 } ; int N = sizeof ( arr1 ) / sizeof ( arr1 [ 0 ] ) ; canMakeEqual ( arr1 , arr2 , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: arr1_one, arr1_zero, arr2_one, arr2_zero, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checksubarrayExist1_N ( int arr [ ] , int N ) { unordered_map < int , int > pos ; for ( int i = 0 ; i < N ; i ++ ) { pos [ arr [ i ] ] = i ; } set < int > st ; for ( int i = 1 ; i <= N ; i ++ ) { st . insert ( pos [ i ] ) ; int Min = * ( st . begin ( ) ) ; int Max = * ( st . rbegin ( ) ) ; if ( Max - Min + 1 == i ) { cout << " True ▁ " ; } else { cout << " False ▁ " ; } } } int main ( ) { int arr [ ] = { 1 , 4 , 3 , 2 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; checksubarrayExist1_N ( arr , N ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void checkSamePosition ( int arr [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) { int temp = ( ( i + arr [ i ] ) % n + n ) % n ; if ( mp . find ( temp ) != mp . end ( ) ) { cout << " Yes " ; return ; } mp [ temp ] ++ ; } cout << " No " ; } int main ( ) { int arr [ ] = { 5 , 4 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; checkSamePosition ( arr , N ) ; return 0 ; }

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