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>


int fact(int n){
    int x,fac;
    x=2;
    fac=1;
    while(x<=n){
        fac*=x;
        x++;
    }
    return fac;
}

main_program{
    int n,e,o;
    std::cin>>n;

    double ans,x,y;

    for(e=2;e<=n;e=e+2){
        double m;
        m= fact(e);
            x=x+(1/m);
    }
    
    for(o=1;o<=n;o=o+2){
        double n;
        n=fact(o);
            y=y+(1/n); 
    }
   
   ans=y-x;
   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>
float fact(float n){
    float mul = 1;
    int count = 1;
    repeat(n){
        mul = mul*count;
        count = count + 1;
    }
    return mul;
}
main_program{
    float n;
    bool one = true;
    float sum = 0;
    int count = 1;
    cin >> n;
    repeat(n){
        if(one){
            sum = sum + 1/(fact(count));
            count = count + 1;
        }else{
            sum = sum - 1/(fact(count));
            count = count + 1;
        }
        one = !one;
    }
    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>
main_program{
    double n,r=1,t=1,sum=0;
    cin >> n;
    while (r<(n+1)){
        t= t*(-1/r);
        sum = sum+t;
        r++;
    }
    cout << std::setprecision(6)<< sum*(-1);
    }

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 f(float n){
    float z=1;
    for(float i=0; i<n; i++){
        z*=(n-i);
    }
    return z;
}

main_program{
    int n;
    cin>>n;

    float s=0;
    float p=1;

    for(float i=0; i<n; i++, p*=-1){
        s+= ((1/( f(i+1) ))*p); 
    }
cout<<std::setprecision(6)<<std::fixed<<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>
#include<iomanip>
using namespace std;
double factorial(double n){
    double f=1;
    for(int i=1;i<=n;i++){
        f=f*i;
    }
    return f;
}
main_program{
    double n;
    cin>>n;
    double ans=0;
    for(int i=1;i<=n;i++){
        ans=ans+(pow(-1,i-1)/factorial(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 {
    float n,p=1,t=1,y;
    cin>>n;
    if( n>=1&&n<=15){
        for (int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
                p=p*j;
                        }
                t=pow(-1,i+1)*(1/p)+t;
                p=1;

    }
}
    std::cout<<std::setprecision(6)<<std::fixed<<t-1<<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>
long double func(i)


return x ;
main_program{
long double n;
cin>>n;
 long double sum=0;long double i =1;
 while(i<=n){sum=sum+ func(i);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: 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>

double fac(double n){
    double f=1;
    for(int i=1;i<=n;i++){
        f=f*i;

    }
    return f;
}


main_program{
    int n,b=1;
    cin>>n;
    float a=0,c=1;
    for(int i=1; i<=n;i++){
        if(b%2 !=0){
            a=a+(c/fac(b));
        }
        else{
            a=a-(c/fac(b));
        }
        b++;

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

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>
double factorial(int n){
   double fact=1;
   for(int k=1; k<=n; k++){
    fact*=k;       
    }
    return double(1/fact);
}
main_program{
     unsigned int n;
     cin>>n;
     double sum=0;
     int sign=1;
     for(int i=1; i<=n; i++){
        sum+=(factorial(i)*sign);
        sign*=-1;
     }
     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(float n){
int d=n;
int k=1;
int r=n-1;
for(int i=0;i<d-1;i++){
n=n*r;
r--;

}
return n;
}

main_program{
int N;
cin>>N;
float r=0;

for(int i=0;i<N;i++){
r=r+pow(-1,i)/factorial(i+1);

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

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 fact(int n){
    int ans = 1;
    for(int i = n; i >= 1; i--) ans *= i;
    return ans;
}

float t(int index){
    if(index%2 != 0) return (1.f/fact(index));
    else return (0-(1.f/fact(index)));
}

int main(){
    int N; cin >> N;
    float sum = 0;
    for(int i = 1; i <= N; i++) sum += t(i);
    std::cout << std::setprecision(6) << std::fixed << sum;
    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>
main_program
{
    int n;
    
    cin >> n;// enter the number of term  
     long s;
     
    int m=n;

    for(int i=1; i<m; i++)
    {
        m=m*i;
    } 
    for (int j=1 ; j<=n ; j++) {
        if(n/2==0)
        {
            s=1-(1/m);

        }
        else
        s=1+(1/m);}
    
    cout<< 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: 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;

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