CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
main_program
{
    int N;
    cin>>N;

    for(int i=1; i<=N; i++)
    {
      double b=1;  
      double a=0;      
        for(int k=1;k<=i; k++)
        {
            b=b*k; 
            a= a+(pow(-1,k-1))/b;
        }
        
        if(i==N)
        {
          std::cout<< std::setprecision(6) <<std::fixed<<a;
        }
    }
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>

int factorial(int x)
{
    int fac=1;
    for(int y=1;y<=x;y++)
    {fac=fac*y;}
    return fac;
}

main_program
{
    
    int n;
    float sum;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        sum = sum + (pow(-1,i+1))*1.0/factorial(i);
    }
    std::cout <<std::setprecision(6)<<std::fixed<<sum;
    
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

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

int factorial(int n) {
    int i=1,f=1;
    while(1) {
        f=f*i;
        i=i+1;
        if (i==n+1) {
            break;
        }
    }
    return f;
}

int main() {
    int N; std::cin>>N;
    double ans=0;
    int i=1;
    
    while (1) {
        double f=factorial(i);
        if (i%2==0) {
            ans=ans-(1/f);
        } else {
            ans=ans+(1/f);
        }

        i=i+1;

        if (i==N+1) {
            break;
        }
    }

    std::cout<<std::setprecision(6)<<std::fixed<<ans;

}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
int main()
{double k,a,i,t;
int N;
cin>>N;

double ans;
for(i=1,ans=0;i<=N;i++)
{for(a=1;a<=i;a++){
    k*=a;
}
t=pow(-1,i+1);
    ans+=(t/k);}
    std::cout<<std::setprecision(6)<<std::fixed<<ans;
    
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include <simplecpp>
#include <iomanip>

main_program {
    int n , d;
    float term;
    float ans;
    term =1;
    ans = 1;
    cin >> n;
    for (d=1; n>d ; d++){
        term *= (float(-1)/float(d+1));
        ans += term;
    }
    std::cout<<std::setprecision(6)<<std::fixed<<ans;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
int fact(int a){
    int prod=1;
    for(int i=1;i<=a;i++){
        prod*=i;
    }
    return prod;//prod=a!
}
int main(){
    int n,i=1;
    double ans=0.0;
    cin>>n;
    while(i<=n){
        if((i%2)==0){
            ans=ans-(1.0/(fact(i)));
        }
        else{
            ans=ans+(1.0/(fact(i)));
        }
        
        if(i==n){
            std::cout << std::setprecision(6) << std::fixed << ans;
        } 
        i++;   
    }
    return 0;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include <simplecpp>
#include <iomanip>

float factorial(int r){

   float sum =0 ;
   for(int i=1; i<=r ; i++){
       sum=sum + log10(i);
   }
   return pow(10,sum);

}


float genTerm(int index){

  float term = (pow(-1, index+1))/factorial(index);
  return term;   

}


float Sum(int tillterm){
   float sum = 0;

    for(int i=1 ; i <= tillterm ; i++){
        sum = sum + genTerm(i);    
    }
   return sum;
}

main_program{
  int c;
  cin >> c;
  std::cout << std::setprecision(6) <<std::fixed << Sum(c);

}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
int main(){
    int n;
    cin>>n;
    int v;
    float num;
    if(n=='1'){
        v=1;
        std::cout<<std::setprecision(6)<<std::fixed<<"1.000000";

    }
    if(n=='2'){
        v = 1-1/2;
        std::cout<<std::setprecision(6)<<std::fixed<<v;
    }
    while(n>2 && n<=15){
        float first=1.000000;
        int a=1;
        while(a!=n){
            a++;
            int q;
            int i=1;
            while(i<=a){
                q=q*i;
                i++;
            }
            float b = 1/q;
            num = first - b;
        }


        }
        std::cout<<std::setprecision(6)<<std::fixed<<num;

    }

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>

main_program {
    int  n;
    float x=1,r=1,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(float z=1;z<=i;z++){
            x*=1/(z);
             
        }
        r=pow(-1,i-1)*x;
        sum+=r;
        x=1;
    }
    cout<<sum;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>

main_program
{
    int N,h;
    float l,m;
    h=2;
    float temp=1;
    cin>>N;
    for(float i=0;i<N;i=i+1)
    {
       temp=1;
       for (float j=N;j>=h;j=j-1)
       {
         temp=temp*j;
       } 
      h=h+1;
     l=l+ (pow(-1.0,i)*temp);
    } 
    float fact;
    fact=1;
    for (float k=1;k<=N;k=k+1)
    {
        
        fact=fact*k;
    }

    std::cout<<std::setprecision(6)<<std::fixed<<float(l/fact);


 
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>

int factorial(int n){
    int m=0;
    int r=1;
    repeat(n){
        m++;
        r=m*r;
    }
    return r;
}
main_program{
    int n;
    cin>>n;
    float r;
    float d;
    float i=0;
    while( n!=0){
    r=factorial(n);
     d=1/r;
     if( n%2==0)
     d=-d;
     i=i+d;
     n=n-1;
    } 
    
  std::cout<<std::setprecision(6)<<std::fixed<<i;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
main_program
{
    int n,i,j;
    float t,fact,ans;
    cin>>n;
    for(i=1,ans=0.0; i<=n; i++)
    {
        fact =1;
        for(j=i; j>=1; j--)
        {
            fact*=j;
        }
        t=1/fact;
        ans= ans + pow(-1,i+1)*t;
    }
    std::cout<<std::setprecision(6)<<std::fixed<<ans;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
#include<math.h>
int factorial(int x){
    int product=1;
    for(int i=1;i<=x;i++){
        product=product*i;
    }
    return product;
}
main_program{
int N;
cin>>N;
float ans=0.0000000;
for(int i=1;i<=N;i++){
ans= ans+ pow(-1,i-1)*1/factorial(i);
}
std::cout<<std::setprecision(6)<<std::fixed<<ans;
return 0;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
int factorial(int n){
    int y=1;
    for(int i=1;i<=n;i++){
        y=y*i;
    } return y;
}
main_program{
    int N;
    cin>>N;
    float x=0;
    for(int i=1;i<=N; i++){
       float d=1;
    
        repeat(i+1){
            d=d*(-1);
        }
        float z= factorial(i);
        x = (x + d/z);
        

    } 
    std::cout << std::setprecision(6) << std::fixed << x;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>

float factorial(int n)
{   
    float fact=1;
    for(int i=1; i<=n; i++)
    {
        fact*=i;
    }
    return fact;
}

main_program
{
    int n; cin>>n;

    float sum=0;

    for(int i=1; i<=n; i++)
    {
        if((i+1)%2==0)
        {
            sum += (1/factorial(i));
        }

        else
        {
            sum -= (1/factorial(i));
        }
    }
    std::cout<<std::setprecision(6)<<std::fixed<<sum;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include <simplecpp>
#include <iomanip>
main_program{
    int n;
    cin >> n;
    double sum = 0;

    for (int i = 1; i <= n; i++){
        
        int fact = 1;
        for (int x = 1; x <= i; x++){ fact = fact*x;}
        if (i %2 == 0){
            sum -= 1.0/fact;
        }
        else {
            sum += 1.0/fact;
        }
    }
    std::cout << std::setprecision(6) << std::fixed << sum;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
main_program
{
    int N;
    cin>>N;
    int fact=1;
    float c;
    if(N>=1&&N<=15)
    {
    for(int n=1;n<=N;n++)
    {
    for(int i=1;i<=n;i++)
    {
        fact=fact*i;
    }
    c=c+(pow(-1,(n+1)))*(pow(fact,-1));
    }
std::cout<<std::setprecision(6)<<std::fixed<<c;
}
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: B
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include <simplecpp>
#include <cmath>
#include <iomanip>

int fact(int n);

main_program{
    int n;
    cin>>n;
    double sum=0.0;
    for(int i=1;i<=n;i++)
    {
        sum+=(pow(-1,(i-1))/fact(i));
    }
    cout<<fixed<<setprecision(6)<<sum<<endl;
}

int fact(int n){
    int prod=1;
    for(int i=1;i<=n;i++)
    {
        prod*=i;
    }
    return prod;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: You are given an infinite alternating series:
1-1/2!+1/3!-1/4!+1/5!  ... 
Your task is to compute the sum of the first N terms of this series. The series alternates in sign, with each term involving the reciprocal of a factorial.

Example: If n = 1, the n terms of the series is just 1. Hence, answer is 1.000000

Input Format: A single positive integer N where 1 ≤ N ≤ 15.

Output Format
	A single floating-point number representing the sum of the first N terms of the series, rounded to exactly 6 decimal places. 
	To print exactly six digits after the decimal point, write std::cout << std::setprecision(6) << std::fixed << ans;. Here we assume that the answer is stored in variable ans.

Student submission:
#include<simplecpp>
#include<iomanip>
float fact(int num){
    int pro=1;
    for(int i=1; i<=num; i+=1){
        pro*=i;
    }
    return pro;
}

main_program{
    float sum=0, sign=1, i=1;
    int n;
    cin >> n;
    while(i<=n){
        sum=sum+ (sign*(1/fact(i)));
        sign*=(-1);
        i+=1;
    }
    std::cout << std::setprecision(6) << std::fixed << sum << endl;
}

Grading criterion: Computation of factorial
Rating A: correctly computes factorial
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A