CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=n-1;i>=0;i--){
        cout<<a[i]<<" ";
    }
    for(i=1;i<n-1;i++){
        if(a[i+1]<a[i]){break;}
    }
    cout<<endl<<i;
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[100];
for(int i=0;i<n;++i){cin>>a[i];}
for(int i=0;i<n;++i){cout<<a[n-i-1]<<" ";     }
cout<<endl;
int index=0;
for( ;index<n-1;++index){
    if(a[index]>a[index+1]){break;}
}
cout<<index;




}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include<iostream>
using namespace std;
int main()
{
    int n;
    int a[100];
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=n-1;i>=0;i--)
    {
        cout<<a[i]<<" ";
    }
    cout<<endl;
    for(int i=1;i<n-1;i++)
    {
        if(a[i]>a[i-1]&&a[i]>a[i+1])
        {
            cout<<i;break;
        }
    }return 0;
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    };
    for(int i=n-1;i>=0;i--){
        cout<<a[i]<<" ";
    };
    cout<<endl;
    for(int i=1;i<n-1;i++){
        if(a[i]>a[i-1] && a[i]>a[i+1])cout<<i;
    };
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include<iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=n-1;i>=0;i--){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    for(int i=1;i<n-1;i++){
        if((arr[i]>arr[i-1])&&(arr[i]>arr[i+1]))
        cout<<i<<" ";
    }
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int A[100];
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        cout << A[i] << " ";
    }
    cout << endl;
    int j = 1;
    while(j < n) {
        if ((A[j] > A[j - 1]) && (A[j] > A[j + 1])) {
            cout << j;
            break;
        }
        j++;
    }
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include<iostream>
using namespace std;
int main() {
    int n,m;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=n-1;i>=0;i--){
        cout<<arr[i]<<" ";
    }
    for(int i=1;i<n-1;i++){
        if((arr[i]>arr[i-1])&&(arr[i]>arr[i+1])){
            cout<<endl;
            cout<<i;
            break;
        }
    }
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that accepts a dynamically sized array and performs the following operations:

Initialization: Accept an integer n denoting the array size, followed by n integer elements.

Reverse Traversal: Output the array elements in reverse sequence, space-separated, on a single line.

Peak Detection: Identify all "peak" elements within the array. A peak is strictly defined as an element that is greater than both its preceding and succeeding neighbors. Print the 0-based indices of all identified peaks on a new line, separated by spaces. If the array contains no peaks, leave the second line blank.

Student submission:
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for (int i=n-1;i>=0;i--)
    {
        cout<<arr[i]<<" ";
    }
    cout << endl;
    for (int i=1;i<=n-2;i++)
    {
        if (arr[i]>arr[i-1]&& arr[i]>arr[i+1])
        {
            cout << i;
            break;
        }
    }
}

Grading criterion: Output
Rating A: Correctly prints the output

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 fact=1;
    for(int i=2;i<=n;i++){
        fact=fact*i;
    }
    return fact;
}
float print(int n){
    float  sum=0;
    for(int j=1;j<=n;j++){
         sum=sum+pow(-1,j-1)*(1/float(factorial(j)));
        }
        return sum;
}
int main(){
    int N;
    cin>>N;
    float sum=print(N);
   std::cout << std::setprecision(6) << std::fixed <<sum;
    }

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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;
    float sum=0,factorial=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        factorial*=i;
        if(i%2!=0)
        {
            sum=sum+(1/factorial);
        }
        else
        {
            sum=sum-(1/factorial);
        }
    }
    cout<<sum;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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 fac(int x){
    int res=1;
    for(int i=1; i<=x; i++){
        res = res*i;
    }
    return res;
}

main_program{
    int n;
    float res=0;
    
    cin >> n;

    for(int i=1; i<=n; i++){
        res = res + (pow(-1, i+1)*(1.0/fac(i)));
    }

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

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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 ;
    for( int i=1 ; i<=n ; i++){
        float b =1;
        for(int j=2 ; j<=i ; j++){
             b= b*j;
        } 
        if (i%2==0)
        ans=-1/b +ans ;
        else 
        ans =1/b + ans ;
    }
std::cout <<std::setprecision(6) << std::fixed << ans << endl;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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; int i=1; int a=1;
    cin >> n;
    double sum;
    while(i<=n){
        a=a*i;
        sum=sum-(pow(-1,i)/a);
        i=i+1;
    }
    cout << fixed << setprecision(6)<<sum;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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 x){
    int c=1;
    for(int j=2;j<=x;j++)
      {c=c*j;}
      return c;
}
main_program{
    int n;float a,b=0,c,d=-1;
    cin>>n;
    for(int i=2;i<=n;i++){
        a=(1/fact(i));
        b=b+a;
    }
    c=1-b;
    cout<<c;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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 a){
    float fact=1;
    for(float i=1; i<=a;i++)
    {fact = fact*i;}
    return fact;
}
main_program{
    float n;
    cin>>n;
    float sum=0;
    for(float i=1; i<=n; i++)
    {sum=sum+(pow(-1,i-1)*(1/fact(i)));}
    std::cout<<std::setprecision(6)<<std::fixed<<sum;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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 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: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
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: Declaration of variables and accepting input
Rating A: correctly declares the variable 'n' and accepts it
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A