CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>

using namespace std;

double sq_root(double s, double epsilon)
{
	double x0 = s/2;
	double x1  = (x0 + s/ x0) / 2;	
	
	while(fabs(x1-x0) >= epsilon)
	{
		x0 = x1;
		x1  = (x0 + s/ x0) / 2;
	}
	return x1;
}

int main()
{
	double s;
	double epsilon;
	cin>>s;
	cin>>epsilon;
	
	cout<<fixed;
	cout.precision(5);
	
	cout << sq_root(s,epsilon)<<endl;
	
	return 0;
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include <simplecpp>
#include<cmath>
float sqr(float s,float e)
{
float x=5;
float y=0;
while(fabs(x-y)>e)
	{
	y=x;
	x=(x+(s/x))/2;
	}
	return x;
}
main_program
{
float n,b;
cin>>n>>b;
cout<<fixed;
cout.precision(5);
cout<<sqr(n,b);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include <iostream>
using namespace std;
void update(double &x1,double &x0,double x)
{
x0=x1;
x1=(x1+x/x1)/2;
}
double squareroot(double x,double eps)
{
double x0=0;
for(int i=1;i<=x;i++)
{
if(i*i>x)
{x0=i-1; break;}
} 
double x1=(x0+x/x0)/2;
while(x1-x0>eps)
{
update(x1,x0,x);
}
return x1;
}
int main()
{
double S,epsilon;
cin>>S>>epsilon;
cout<<fixed;
cout.precision(5);
cout<<squareroot(S,epsilon);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;

double approx_sqrt(double S){
double x = 1, eps = 10E-6;
while((fabs(S/x - x))*0.5>eps){
	x = (x + S/x)*0.5;
} 
return x;
}

int main(){
double S; cin>>S;
cout<<fixed;
cout.precision(5);
cout<<approx_sqrt(S);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
using namespace std;
#include<cmath>

double f(double S,double E){
	double x1=1;
	double x2=(x1+(S/x1))/2;
	for(;fabs(x2-x1)>E;){
		x1=x2;
		x2=(x2+(S/x2))/2;
	}
	return x1;
}

int main(){
	double S,E;
	cin>>S>>E;
	double x;
	x=f(S,E);
	cout<<fixed;
	cout.precision(5);
	cout<<x;
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include <iostream>
#include <cmath>
using namespace std; 

void iter(double s,double x, double e)
{
double x1;
x1=(x + float(s)/x)*0.5;

if (fabs(x1-x)>e) iter(s,x1,e);
else printf("%0.5f",x1);
}


int main()
{
double s, x0=7, e;//e=epsilon
cin>>s;
cin>>e;

iter(s,x0,e);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<stdlib.h>
using namespace std;
void squareroot(double S,double epsilon)
{
double x=0;

if(S>0)
{
while((abs(x0-x))>epsilon)

{
x=(x0+(S/x0))/2;
x0=x;
}

cout<<fixed;
cout.precision(5);
cout<<x;
}
}
int main()
{
double S;
double epsilon;
cin>>S>>epsilon;
squareroot(S,epsilon);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<stdlib.h>
using namespace std;
double square_root(double S,double epsilon){
     double x0=10;
	double x1=(x0+S/x0)/2;
     do{
		 double temp=x0;
		 x0=x1;
		 x1=(x0+S/x0)/2;
	 } while(abs(x1-x0)>epsilon);
     return x0;
}
int main(){ 
    double S,epsilon;
    cin >> S >> epsilon;
	cout<<fixed;
	cout.precision(5);
    cout << square_root(S,epsilon);
    return 0;
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
using namespace std;
double fabs(double x)
{
if(x>=0) {return x;}
else {return -x;}
}
double root(double S, double epsilon)
{
double x=1;
while(fabs(x-(x+S/x)/2)>epsilon)
{x=(x+S/x)/2;}
return x;
}
int main()
{
double S,epsilon;
cin>>S>>epsilon;
double y=root(S,epsilon);
cout<<fixed;
cout.precision(5);
cout<<y;
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
double squareroot(double x, double epsilon)
{
double x0=x;
double x1=(x0+x/x0)/2;
while (fabs(x0-x1)>epsilon)
{
x0=x1;
x1=(x0+x/x0)/2;
}
return x1;
}
int main ()
{
double S, epsilon;
cin >> S >> epsilon;
cout << fixed;
cout.precision(5);
cout << squareroot(S, epsilon);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
long double squareroot(long double S,long double eps,long double x){
	long double y=(x+S/x)/2;
	while(fabs(y-x)>eps){
		x=y;
		y=(x+S/x)/2;
		
		}
	return y;
	}
int main(){
long double S;cin>>S;
long double eps;cin>>eps;

cout<<squareroot(S,eps,S);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;

double mysqrt(double S, double eps)
{
	double x = 1.0;
	double temp = (x + S/x)/2.0;
	while(fabs(temp - x) >= eps)
	{
		x = temp;
		temp = (x + S/x)/2.0;
	}
	return x;
}

int main(){
	double S,eps;
	cin>> S >> eps;
	double ans = mysqrt(S,eps);
	cout<< fixed; cout.precision(5);
	cout<< ans;
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
double sqrt(double x, double eps){
double x0=5;
double a,b;
a = x0;
b = (a + (x/a))/2;
while (abs(a -b) >= eps) {
a = b;
b = (a + (x/a))/2;
}
return b;
}
int main(){
double S,eps;
cin >> S >> eps;
cout << fixed;
cout.precision(5);
cout << sqrt(S,eps);
return 0;
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
using namespace std;
double f(double x, double s){
return (x+(s/x))/2;
}
double squaroot(double x, double s, double eps){
double x1=f(x,s);
while (1){
x=x1;
x1=f(x1,s);
if (x1>x && x1-x<eps) break;
if (x>=x1 && x-x1<eps) break;
}
return x1;
}
int main(){
double s;
cin>>s;
double eps=0.0001;
double x=s/2;
cout<<squaroot(x,s,eps);
}

Grading criterion: Use of function beyond what was instructed or any other nice quality.
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: A