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 funct(double x,double S)
{
double k= (x + S/x)/2.0;
return k;
}


int main()
{
double x;
cin>> x;

double new_root = x;double old =(x+1)/2.0;
while(fabs(new_root - old)>0.000001)
{
double d = funct(old,x);
old = new_root;
new_root= d;
}
cout<< fixed;
cout.precision(5);
cout << new_root;
}

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 s,double eps)
{	double a=1,b=(1+s/1.0)/2.00;
	while(fabs(b-a)>eps)
{	a=b;
	b=(a+s/a)/2.00;
}
return a;
}
int main()
{
double s,eps;
cin>> s;
cin>>eps;
cout<<fixed;
cout.precision(5);
cout<<sqrt(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: 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 sqrt(double a,double b){

int x0,xr,xl,xp;
cin>>x0;
xl=(x0+a/x0)/2;
if ((x0*x0)!=a){
while(xr-xl>b){

xr=(xl+a/xl)/2;
if (xr*xr==a){return xr;}
}
}
return xr;
}
int main(){
double S,epsilon;
cin>>S>>epsilon;
cout<<sqrt(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>
#include<cmath>

using namespace std;


float root(float s, float x0,double epsilon){
	if(s==1) return 1;

	float x1 = (x0 + s/x0)/2;
	if(fabs(x0-x1) < epsilon) return x1;
	else return root(s, x1, epsilon);


}

int main(){
	int s;
	cin>>s;

	double epsilon;
	cin>>epsilon;

	float x0 = s/2;

	cout<<fixed;
	cout.precision(5);
	cout<<root(s, x0, 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: 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 f(double S,double &x,double eps){
   double y;
   do{
       y=x;
       x=(x+S/x)/2;}
   while(abs(y-x)>eps);
   return x;}

int main(){
   double S,eps,x=5.000000;
   cin>>S>>eps;
  cout<<fixed;
  cout.precision(5);
   cout<<f(S,x,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: 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 sqrt(double s,double eps){
	cout<<fixed;
	cout.precision(5);

	double x1=s-1,x2=s;

	while(abs(x2-x1)>eps){
		x2=(x1+s/x1)/2;
		double temp=x1;
		x1=x2;
		x2=temp;
		
		

	}
	cout<<x1;
}

int main(){

double s,eps;
cin>>s>>eps;
sqrt(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: 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;

float square_root(int S, float eps, float x)
{

	float x1=(x + (S/x))/2;
	if((fabs(x1-x))>eps) return square_root(S,eps,x1);
	else return x1;

}

int main()
{
	int S;
	float eps;
	float x0=10.0; //a random positive number guess
	cin >> S >> eps;
	if((S>0) && (eps<=0.01))
	{
		cout << fixed;
		cout.precision(5);
		cout << square_root(S,eps,x0);
	}
}

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>
using namespace std;
float rec_sqrt(float x,int n)
{
		if (n == 1) return 1;

		if (n == 0) return x;
		float temp = rec_sqrt(x,n);
		if ((n+1) == 0) return temp*temp;
		else return temp*temp*n;
		}
		int main()
		{
		float x,S; int n;
		cout<<"enter x and n:"; cin>>x>>n;
		S=rec_sqrt(x,n);
		cout<<"S= " <<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 ;
const double E = 0.01 ;
void sqrt(int s, int n, int x0);
	 while (((n+1)-n) <= E); {
		 {
		 n=((x0 + s) / x0) / 2 ;
		 n = n + 1;
		 precision(5)
     return;
			 }
	 }
int main() {
	
	 cin >> s >> x0 ;
	 sqrt(s, x0) ;
	 cout >> n ;
	 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;
float f(int S,float epsilon){
int n=100;
float p;
float A[n+2];
A[0]=1;
for (int i=1;i<n+2;i++){
cout << fixed; 
cout.precision(5);
float t=(float)S/(float)A[i-1];
cout << fixed; 
cout.precision(5);
float u=(float)A[i-1]+(float)t;
cout << fixed; 
cout.precision(5);
A[i]=(float)u/(float)2;
if ((A[i-1]-A[i])<=epsilon && (A[i-1]-A[i])>=-epsilon) {p=A[i-1];break;}
}
cout << fixed; 
cout.precision(5);
return p;
}
int main(){
int S;float epsilon;
cin>>S>>epsilon;
float o=f(S,epsilon);
cout << fixed;
cout.precision(5); 
cout<<o;
}

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<simplecpp>
double sqt(double a,double epsilon);

main_program{
	double s;
	double eps,c;
	cin>>s>>eps;
	c=sqt(s,eps);	
	cout<<fixed;
	cout.precision(5);
	cout<<c;
	
}

double sqt(double a,double epsilon)
{
	double x[1000];
	int i;
	x[0]=100;
	for(i=1;i<1000;i++)
	{
	x[i]=(x[i-1]+ (a/x[i-1]))/2;
	if(fabs(x[i]-x[i-1])<epsilon)
	break;
	}
	return x[i];
}

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 root(double s,double eps){
double x0=1,x1=s;
while(true){
x1=(x0+s/x0)/2;
if(fabs(x0-x1)<=eps) {break;}
x0=x1;
}
return x1;}
int main(){
double s,eps;
cin>>s>>eps;
double k;
k=root(s,eps);
cout<<fixed;
cout.precision(5);
cout<<k;}

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(int s,double e){
	double x0=1;
	double x1=x0+4;
	while(fabs(x1-x0)>=e){
		x0 = x1;
		x1= (x0+ s/x0)/2;
		 }
return x1;}





int main(){
int s;
cin>>s;

double  epsilon;
cin>>epsilon;
double p;
p= sqrt(s,epsilon);
cout<<fixed;
cout.precision(5); 
cout<<p;

}

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 fun(int s,double eps){
double x,nx;
cin>>x;
//cout<<x<<endl;
int temp;
nx=(x+(s/x))/2;
while(fabs(nx-x)>eps){

nx=(x+(s/x))/2;
temp=x;
x=nx;
}
return x;
}

int main(){
int n;
cin>>n;
double eps;
cin>>eps;
double root=fun(n,eps);

cout<<fixed;
cout.precision(5);
cout<<root;

return 0;}

Grading criterion: Whether babylonian method is correctly implemented
Rating A: fully correct
Rating B: Almost correct
Rating C: tried in right somewhat direction
Rating D: totally wrong
Assigned grade: C