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>
float term(int n){
    float ans=1;
    for(float i=1;i<=n;i++){
        ans*=1/i;
    }    
    return(ans);
}
main_program{
    int N;
    cin>>N;
    float ans=0;
    for (int i=1;i<=N;i++){
        if(i%2==0){
            ans-=term(i);
        }
        else {ans+=term(i);}
    }
    std::cout<<std::setprecision(6)<<std::fixed<<ans;

}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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;
  float ans = 0;
  cin >> N;
  while(N !=0)
  {
    int r = N;
    float f = 1;
    while(r !=0)
    {
     f = f*(r);
     r--;
    }
    if(N%2 ==0)
    {
     ans = ans - (1/f);
    }
    else
    {
     ans = ans + (1/f);  
    }
    N--;
  }
  std::cout << std::setprecision(6) << std::fixed << ans;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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 nfac (int a){ int factorial = 1;
 for (int i =1 ; i <=a ; i++)
 {    
       factorial = factorial * i ;
 


 }
return factorial;

}
main_program {    float sum = 0;    
    
    int N ;
    cin >> N ;
    for (int j = 1; j<=N ; j++){
      
      sum = sum + (pow(-1,j-1))/nfac(j);
                             
  }
 std::cout << std::setprecision(6) << std :: fixed << sum ;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>

float fac(int n){
    int c=n;
    for(int i=1; i<n ; i++){
        c=c*(n-i);
    }
    return c;
}
main_program{
    int N;
    float y=0;
    cin>>N;
    if(N==1){cout<<"1.000000"<<endl;}
    else if(N!=1){
    for(int i=1 ; i<=N ; i++){
    y=y+(pow(-1,i-1))/fac(i);
    } cout<<y<<endl;}
   
    
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
int f=1;
float factorial(int x){
    for(int i=1;i<=x;i++){
        f=f*i;
    return f;}
}

float term(int m){
    if(m%2==0){
        return(-1.0/(float)(factorial(m)));
    }
    else{
        return(1.0/(float)(factorial(m)));
    }

}

main_program{
    int b;
    cin>>b;
    cout<< term(b)<<endl;

}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
#include<iomanip>

main_program{
    int n;
    cin>>n;
    if(n==1){
        cout<<"1.000000";

    } else if(n==3){
        cout<<"0.666667";
    } else if(n==5){
        cout<<"0.633333";
    } 
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
#include<iomanip>
using namespace std;
int fact(int x){
    int b=1;
    for(int a =1;a<=x;a++){
        b=b*a;
    }
    return b;
}
float series(int m){
    float y=0;
    int x;
    for(x=1;x<=m;x++){
        y=y+(pow(-1,(x-1)))*(1*(1.0/fact(x)))  ;
    }
    return y;
}
int main(){
    float c;
    cin>>c;
    cout<<setprecision(6)<<fixed<<(series(c));
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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 factorialvalue(float a) {
    float k ;
    for (k=1 ; a >0 ; a = a -1) {
    k = k*a ;
    }
 return k ; 
}
void factorialsum(float n) {
    float sum = 0.0F ;
    float tempn = n ;

    for (; tempn > 0 ; tempn = tempn - 1) {
        
    if (tempn % 2.0F == 1.0F) {
        sum = sum + (1/(factorialvalue(tempn))) ;
     } else if (tempn%2.0F == 0.0F) {
        sum = sum - (1/(factorialvalue(tempn))) ;
     }
    } 
    float ans = sum ;
    
   std::cout << std::setprecision(6) << std::fixed << ans ; 
   
}
main_program {
    float N ;
    cin >> N ;
    factorialsum(N) ;
    return 0 ;

}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
<iomanip>
std :: cout << std :: setprecision(6) << std :: fixed << ans
main_program{
    int n;
    cin >> n;
    cout << 1/n ;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
#include<iomanip>
main_program
{
    int n,fac=1;
    float s=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        fac=fac*i;
        s=s- pow(-1,i)*((1.0)/fac);
    }
    std::cout<<std::fixed<<std::setprecision(6)<<s;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>

float fac (int x) {
	float p=1;
	for (int i = x; i >=1; i--) {
		p = p*i;
	}
	return p;
}

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

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>

int fact(int l){
    int c=1;
    for(int i=1; i<=l; i++){
       c=c*i;

    }
    return c;
}

int exp(int m, int n){
     int tmp=m;
    for(int i=1; i<n; i++){
      m*=tmp;

    }
    return m;
}

main_program{
int n;
int sum=0;
cin>> n;
for(int i=1; i<n; i++){
    sum = sum + (exp(-1,n+1))/(fact(i));

}
cout<<sum;
 

}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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;
float ans=0;
float y=1;    
for( int i= 1; i<=n ; i++){
y=y*i;

if(i%2 ==0){
    ans = ans - 1/y ;
}
else ans=ans+1/y;

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

}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
main_program
{
    float sum,fact;
    int N,i,c;
    cin>>N;
    for(c=1;c<=N;c++)
    {
        fact=1;
        for(i=c;i>=1;i--)
        {
            fact=fact*i;
        }
        if(c%2==0)
        sum = sum - (1/fact);
        else
        sum = sum + (1/fact);
    }
    cout<<sum;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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 ftrl(int a){
    int b=1;
    for (int i=1;i<=a;i++){
        b*=i;
    }
    return b;
}
main_program{
    int n;
    cin>>n;
    float sum=0;
    for (int j=1;j<=n;j++){
        sum=sum+(pow(-1,j-1)*(1.0/ftrl(j)));
    }
    cout << std::setprecision(6) << std::fixed << sum;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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{
float sum=0,term=1;
int  n;
cin>>n;
for (int i=1;i<=n;i++){
term=term*1/i;
sum=sum+pow(-1,i+1)*term;
}
std::cout<<std::setprecision(6)<<std::fixed<<sum;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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>
double factorial(int n);
double factorial(int n)
{
    double prod=1;
    for(int i=1; i<=n; i++)
    {
        prod*=i;
    } return prod;
}
main_program{
    double s=0;
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        if(i%2==0)
        s-=1.0/factorial(i);
        else s+=1.0/factorial(i);
    }
    cout<<s;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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;
    float result;
    for(int i=1;i<=n;i++){
        int mul=1;
        for(int j=1;j<=i;j++){
            mul=mul*j;
        }
        float mul2=1.0/mul;
        if((i%2==0))
            result=result-mul2;
        else
            result=result+mul2;
    }
    cout<<fixed<<setprecision(6)<<result;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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<iostream>
#include<iomanip>
int main(){
    int N,frac=1;float ans=0,sign=1;std::cin>>N;
    for(int i=1;i<=N;i++){
        frac*=i;
        ans+=sign/frac;
        sign*=-1;
    }
    std::cout<<std::setprecision(6)<<std::fixed<<ans;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
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){
    if(a==1) return 1;
    int f=1;
    for(int k=2;k<=a;k++) f=f*k;
    return f;
}
main_program {
    int n,j=1;
    cin >> n;
    float s=0.0;
    for(int i=1;i<=n;i++){
        s=s+1.0/fact(i)*j;
        j=j*-1;
    }
    cout << setprecision(6) << fixed << s;
}

Grading criterion: Accumulating sum
Rating A: correctly keeps accumulating the sum of the series
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A