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<bits/stdc++.h>
using namespace std;
double f(double S,double epsilon)
{
double x=S/3;
while(fabs(((S/x)-x)/2)>epsilon)
{
x=(x+(S/x))/2;
}

return x;
}
int main()
{
double S;double epsilon;
cin>>S>>epsilon;
cout<<f(S,epsilon);
return 0;
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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>
#include <string.h>
using namespace std;

double root (double num, double epsilon) {
 	float xa=0, xb=0;
 	xb=1;
 	while (fabs(xb - xa) > epsilon) {
	 xa=xb;
	 xb=(xb+(num/xb))/2;
	 }
	 return xa;
}

int main() {
double S=0;
double eps=0;
cin>>S>>eps;

//	 cout<<fixed;
//	 cout.precision(5);
//	 cout<<xa<<" "<<xb<<endl;
	
	cout<<fixed;
	cout.precision(5);
	cout<<root(S,eps);
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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;
void  iterate(double s,double epsilon){
	int i=0;double x0=3;double x1=(double(  x0)+double ( s)/double ( x0))/2.0;
for(i=0;i<100;i++){
if(x1-x0>epsilon)
  x0=x1;
}if(x1-x0<=epsilon) cout<<x1;
 
cout<<fixed;
cout.precision(5);}
int main(){
	double  s;
	double epsilon;
	cin>>s>>epsilon;
	iterate(s,epsilon);
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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;
double sqroot (double S,double epsilon) {
double x0=S/2;
double x1=(x0+S/x0)/2;
while (x1-x0>epsilon) {
x0=x1;
x1=(x0+S/x0)/2;}
return x1;}
int main() {
double S;
double epsilon;
cin>>S>>epsilon;
if (epsilon<=0.01 && S>0) {
cout<<sqroot (S,epsilon);
}
else cout<<"Invalid data";
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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>
main_program {
	int x1;int e;int x0;
	int sqrt (int S);
		signed S;e=0.011;
			x1=(x0+S/x0)/2;
}
int main(){
	cin>>S;
	cin>>x0;
		cout<<"the square root of number S is <<x1";
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
Rating D: 0
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<simplecpp>
double f(double S,double epsilon){
double x,y;
x=sqrt(S);
while(y-x>epsilon || y-x+epsilon<0){
y=(x+S/x)/2;
x=y;}
return y;
}
main_program{
double S,epsilon;
cin>>S>>epsilon;
cout<<fixed;
cout.precision(5);
cout<<f(S,epsilon);
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
Rating D: 0
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;
int main()
{
	float x0=1,x1,s,epsilon;
	cin>>s>>epsilon;
	if(s>0 && epsilon<=0.01)
	{
		for(;;)
		{
			x1=(x0+s/x0)/2;
			if(fabs(x1*x1-s)<epsilon) break;
			x0=x1;
		}
		cout<<fixed;
		cout.precision(5);
		cout<<x1;
	}
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
Rating D: 0
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>
using namespace std;

float bab_root(float s, float eps){

	float x0 = 1, x1;
	
	while("Chinmay is awesome"){  //I know I could simply use
	                              //while(condition in if), but this is more fun
		x1 = ((x0 + (s/x0))/2);
		
		float dif = (x0-x1);
		if(dif<eps and ((-1)*dif)<eps) return x1;
		
		x0 = x1;
	}
}

int main(){

	float s, eps;
	cin>>s>>eps;

	cout<<fixed;
	cout.precision(5);
	
	cout<<bab_root(s,eps);
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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;
float root(float s,float epsilon)
{float x=sqrt(s)+epsilon;
while(s-x*x>epsilon)x-s/2/x;return x;}
int main()
{float s;cin>>s;
float epsilon;cin>>epsilon;
if(s>0&&epsilon<=0.001)
cout<<fixed;
cout.precision(5);
cout<<root(s,epsilon);}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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;

// 5 decimal places needed

int main() {
    double S; cin >> S;
    double x0 = 50.00;
    double err; cin >> err;

    while (abs(x0 - (x0 + S/x0)/2) > err) {
        x0 = (x0 + S/x0)/2;
    }

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

    cout << x0;
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
Rating D: 0
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>
using namespace std;
double root(double s,double x,double e){
	double temp=0;
	while(abs(temp-x)>=e){
		temp=x;
		x=(x+s/x)/2;
	}
	return temp;
}
int main(){
	double s;
	double x=1,e;
	cin>>s>>e;
	cout<<fixed;
	cout.precision(5);
	double squareroot=root(s,x,e);
	cout<<squareroot<<endl;
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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 Babylonian_sqrt(double S, double eps)
{
double x0=S, x=(x0+S/x0)/2;
while(fabs(x-x0)>eps)
{
x0=x;
x=(x0+S/x0)/2;

}
return x0;
}
int main()
{
double S, eps;
cin>>S>>eps;
double sqrt=Babylonian_sqrt(S, eps);
sqrt=(floor(sqrt*100000))/100000.0;
cout<<fixed; cout.precision(5);
cout<<sqrt;
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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>
#include <iomanip>
using namespace std;

float babsqrt(float s, float x, float e){
	float g = (x + s/x)/2;
	if(abs(g-x) <= e)return x;
	else return babsqrt(s, g, e);
}

int main(){
		
	float s, e; cin>>s>>e;

	cout<<fixed;
	cout<<setprecision(5);

	cout<<babsqrt(s, 1, e);

	return 0;
}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
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;

float SquareRoot(float S,float epsilon)
                {
                 float x_0 = 2.5;
                 float x_1 = ((x_0+S/x_0))/2;
                 while(fabs(x_1-x_0)>=epsilon)
                      {
                       x_0 = x_1;
                       x_1 = (x_0 + S/x_0)/2;
                       }
                 return x_1;
                 }
int main()
{
 float S,epsilon;
 cin>>S>>epsilon;
 float root = SquareRoot(S,epsilon);
 cout<<fixed;
 cout.precision(5);
 cout<<root;

}

Grading criterion: Whether babylonian method is implemented in a function
Rating A: Separate function is used and function signature is correct
Rating B: Separate function is used but function signature is not correct
Rating C: totally wrong
Rating D: 0
Assigned grade: A