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 sqrt(double s, double x, double eps){
    double prev=x+1;
    double curr=x;
    while (fabs(curr-prev)>eps){
        prev=curr;
        curr=(prev + (s/prev))/2;
    }
    return curr;
}

int main (){
    double s,eps;
    cin >> s >> eps;
    cout<< fixed;
    cout.precision(5);
    cout<< sqrt(s,s/3,eps);
}

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: 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>
float bsq(float x0,float x,float s,float eps){
	x=abs(x0+(s/x0));
	x=x/2;
	if (abs(x-x0)<=eps){
		return x;
	}
	else{
		return bsq(x,x,s,eps);
	}
}
main_program{
	double s,x0,xn,eps;
	
	cin>>s;
	cin>>eps;
	x0=5;
	cout<<bsq(x0,xn,s,eps);
	
}

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: 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; cin >> a;
   while ( fabs(a-sqrt(S)) > eps )
       {  a = (a + S/a)/2; }
   return a;
  }

int main()
{  double S; double eps= 0.0000001;
   cin >> S;
   cout << sqrt(S,eps);
}

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: 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;
double getroot(double S,double epsilon){
 double x0,x1,x2;
 x0=1.5;
 x1=0;
 x2=1;
while(abs(x2-x1)>epsilon){
  x2=x1;
  x1=(x0+(S/x0))/2;
  x0=x1;
  }
return x2;
}
int main(){
double S,epsilon;  
cout<<fixed;
cout.precision(5);
cin>>S;
cin>>epsilon;
cout<<getroot(S,epsilon);
 }

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: 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;
int main()
{
     float squareroot(float s,int x0,int n);
      int i=1,n;
      
       for(int i=1;i<=n+1;i++){
          x(i) = (x0+s/x0)/2;
             x(n+1)-x(n)<=0.01;
             }
         return x(i);
         
         
    float s,x0,n;
    
    cin>>s>>x0>>n;
    cout<<float squareroot(s,x0,n); 
    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: D
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 S, double epsilon)
{
double x = 1.0;
double x_1 = 2.0;
double temp;

while((x-x_1)>epsilon || (x_1-x)>epsilon)
{
temp = x_1;
x_1 = (x + (S/x))/2;
x = temp;


}


return x_1;
}




int main()
{

double a, b;
cin>>a>>b;
cout<<fixed;
cout.precision(5);
cout<<sqrt(a,b);
















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: 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;
double diff(double p,double q){
	if (p>q){return p-q;}
	else {return q-p;}
}
double nonrecsqrt(double x,double& s,double y){
	double x1 = (x+(s/x))/2;
	while (diff(x,(x+(s/x))/2)>y){
		x = x1;
		x1 = (x+(s/x))/2;
	}
	return x;
}
int main(){
	double s,eps;
	cin >> s>>eps;
	cout<<fixed;
	cout.precision(5);
	cout << nonrecsqrt(s,s,eps);
	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: 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;

int main(){
double s,x1,x2,eps;
cin>>s>>eps;
x1=s/2;
x2=(x1+(s/x1))/2;
while(fabs(x2-x1)>eps){
x1=x2;
x2=(x1+(s/x1))/2;
}
cout<<fixed;
cout.precision(5);
cout<<x2;

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: 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;

double sqrt(double x, double eps)
{double a=1;
while(abs((a+x/a)/2-a)>eps)
{a=(a+x/a)/2;
}
return a;
}
int main()
{double x,eps;
cin>>x>>eps;
cout<<fixed;
cout.precision(5);
cout<<sqrt(x,eps);
}

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: 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>
double squro(double s){
double x1,x0,eps=0.001;
cout<<"enter the initial guess";cin>>x0;
x1=(x0+s/x0)/2;
while(x0-x1>eps){
x0=x1;
x1=(x0+s/x0)/2;}
return x1;}

main_program{
int a;double y;
cin>>a;
y=squro(a);
cout<<y;}

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
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 sqrt(float S,float eps){
	float a=1,b=(a+S/a)*0.5;
	while (fabs(b-a)>eps){
		a=b;
		b=(a+S/a)*0.5;
	}
	return b;
}
int main(){
	float S,eps;
	cin>>S>>eps;
	float r=sqrt(S,eps);
	cout<<fixed;
	cout.precision(5);
	cout<<r;
}

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: 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 x,double e){
	double a,y;a=1;y=(a+x/a)/2;
	while(fabs(a-y)>=e){
	a=y;
	y=(a+x/a)/2;
	}
	return a;
}
int main(){
double x,e;
cin>>x>>e;
cout<<fixed;
cout.precision(5);
cout<<f(x,e);
}

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: 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;
int main (){
	double S;
	
	cin >> S;
	double X = S/2, x2, eps;
	cin >> eps;
	cout << fixed;
	cout.precision(5);
	while (fabs(X-x2)>eps)
	{ 
		X=(X+S/X)/2;
		x2=(X+S/X)/2;
	}
	
	 cout << X;
	
}

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: 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 root(double S, double eps)
{  double x=1,y;
   y=(S+1)/2;
   while(fabs(y-x)>eps)
   {  x=y;
      y=(y+S/y)/2;
   }
   return y;
}
int main()
{  double S,eps;
   cin >> S >> eps;
   cout << fixed;
   cout.precision(5);
   cout << root(S,eps);
}

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: A