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 j=1; j<=N; j--)  
        {
            float f=0.0;
            f=f+log10(j);
        
    float d=pow(10,f);
    float sum=0.0;
    sum=sum+(pow(-1,j-1))/d;

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

Grading criterion: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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<iostream>
#include<iomanip>
int factorial(int n);
int factorial(int n){
    int c;
    if(n>=1){
        c=n*(factorial(n-1));
    }
    return c;
}
int main(){
         int n,f=0;cin>>n;
      for(int i=0,k;i<n;i++){
        k=factorial(i);
        if(n%2==1){
            f=(1/k)+f;
        }
        else {
            f=-(1/k)+f;
        }
         
      }
      std::cout<<std::setprecision(6)<<std::fixed<<f;

}

Grading criterion: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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<iomanip>
int factorial(int n){
    int fac=1;
    for(int i=2;i<=n;i++){
        fac *= i;
    }
    return fac;
}
main_program{
    int n;
    cin>>n;
    if(n==1){
        float ans =1;
        std::cout<<std::setprecision(6)<<std::fixed<<ans;
    }
    else{
        float sum = 1;
    for(int i=2;i<=n;i++){
        float value = 1.0/(factorial(i));
        sum += (pow(-1,i))*(-value);
    }
    std::cout<<std::setprecision(6)<<std::fixed<<sum;
    }
    
}

Grading criterion: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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) {
    int f = 1;
    for (int i = 1; i <= n; ++i) {
            f = f*i;
    }
    return f;
}

float recip(int n) {
    float r = 1/(factorial(n));
    return r;
}

main_program {
    int n;
    cin >> n;
    float ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i%2 == 0) {
            ans = ans - recip(i);
        }
        else {
            ans = ans + recip(i);
        }
    }
    std::cout << std::setprecision(6) << std::fixed << ans;
}

Grading criterion: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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<iostream>
void factorial(int N){
    for (k=1;k<=N;k++){
    //defining a function for factorial
                factorial*=k
}
}
int N;
cin>>N;
float sum;
float summ;
main_program{
    for (i=2; i<=N; i=i+2){
        sum+=1/factorial(i)
}
    for (j=1;j<=N; j=j+2){
        summ+=1/factorial(j)
    }
    float ans;
    ans=(sum-summ)
}
std::cout<<std::setprecision(6)<<std::fixed<<ans;

Grading criterion: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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;
float Sum=0,f=1,i=1;
   cin>>n;
    while(i<=n)
   {
      Sum+=f;
      f=f/-(i+1);
      i++;
   }
 std:: cout << std ::setprecision(6)<<std :: fixed<< Sum<<endl;
}

Grading criterion: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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 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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
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<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: Alternating signs
Rating A: correctly changes the sign +ve to -ve and vice versa
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A