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>
#include<vector>
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 = 0; i < n; i++){
        cout << arr[n-i-1] << " ";
    }
    int max = arr[0], index = 0;
    for(int i = 0; i < n; i++){
        if(arr[i] > max){
            index = i;
            max = arr[i];
        }
    }
    cout << endl << index;
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 A[100],B[100];
    int c;
    cin>>c;
    for(int i=0;i<c;i++){
        cin>>A[i];
        B[c-1-i]=A[i];
    }
    for(int i=0;i<c;i++){
        cout<<B[i]<<" ";
    }
    cout<<endl;
    int maxi=0;
    for(int i=0;i<c;i++){
        if(A[i]>A[maxi]){
            maxi=i;
        }
    }
    cout<<maxi<<endl;
    return 0;
    
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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;
    for (int i= 0; i<n-1; i++){
       if (A[i] < A[i+1] && A[i+1]> A[i+2]) 
       cout << i+1; 
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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; break;}
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> x;
    int t;
    bool f = true;
    for(int i = 0; i<n; i++){
        int d;
        cin >> d;
        x.push_back(d);
        if((i>1) && f){
            if((x[i]-x[i-1] < 0)&&(x[i-1]-x[i-2] > 0)){
                f = false;
                t = i-1;
            }
        }
    }
    for(int i = 0; i<n; i++){
        cout << x[n-1-i] << " ";
    }
    cout << endl;
    cout << t << endl;
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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>
#include <vector>
using namespace std;

void printreverse ( const vector<int>& arr ) {
    for ( auto p=arr.end()-1, q=arr.begin(); p>=q; p-- ) cout << *p << " ";
    cout << endl;
}

int peakindex ( const vector<int>& arr ) {
    for ( auto p=arr.begin()+1, q=arr.end()-1; p<q; p++ )
        if ( *p > *(p+1) ) return p-arr.begin();
    return -1;
}

int main () {
    int n;
    cin >> n;
    int k;
    vector<int> arr = {};
    for ( int i=0; i<n; i++ ) {
        cin >> k;
        arr.push_back(k);
    }
    printreverse (arr);
    cout << peakindex(arr) << endl;
    return 0;
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 A [100];
    int x, peak;
    cin>>x;
    for(int i=0; i<x;i<i++) {
        cin>>A[i];
    }
    for(int i=0; i<x; i++) {
        cout<<A[x-1-i]<<' ';
    }
    for(int i=0; i<=x-3; i++) {
        if(A[i]<A[i+1] && A[i+1]>A[i+2]) cout<<endl<<i+1;
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 std::cin ;using std::cout ; using std::endl ;
int main() {
    int n ; 
    cin >> n ;
    int arr[n] ;if ( n<=100 && n >= 3){
    for ( int i=0 ; i<n;i++) {
        cin>>arr[i];
    }
    int y= n-1 ;
    while ( y>-1) {
        cout<<arr[y]<< " " ;
        if ( y==0){ cout<<" "<< endl ;}
        y--;
    }
           
    
    int a ,b,c ;
    for ( int i=1; i<n-1 ; i++){
        a = arr[i-1] ;
        b = arr[i] ;
        c= arr[i+1] ;
        if ( b>c && b>a ){
            cout<<i << endl ;
        }
    }
} }

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 i,n,c=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=n-1;i>=0;i--)
    cout<<a[i]<<" ";
    for(i=1;i<n;i++)
    {
        if(a[i]>a[i+1]&&a[i]>a[i-1])
            c=i;
    }
    cout<<endl;
    cout<<c;
    return 0;
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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(){
    const int nmax=100;
    int arr[nmax];
    int n;
    cin>>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=0; i<n; i++){
        if (arr[i]>arr[i+1]){
            cout<<i<<endl;
            break;
        }
    }

}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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;
void printReverse(int A[],int n){
    for(int i=n-1;i>=0;i--){
        cout<<A[i]<<" ";
    }
    cout<<endl;
}
void peak(int A[],int n){
    for(int i=1;i<n-1;i++){
        if(A[i-1]<A[i]&&A[i+1]<A[i])cout<<i<<" ";
    }
}
int main(){
    int n;
    cin>>n;
    int A[n];
    
    for(int i=0;i<n;i++) cin>>A[i];
    printReverse(A,n);
    peak(A,n);
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 x[n];
    for (int i=0;i<n;i++) {
        cin>>x[i];
    }
    for (int i=n-1;i>=0;i--) {
        cout<<x[i]<<" ";
    }
    for (int i=1;i<n-1;i++) {
        if ((x[i]>x[i-1]) && (x[i]>x[i+1])) {
            cout<<endl<<i;
        }
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 std::cin; using std::cout;using std::endl;
int main(){
    int n,arr[n];
    cin>>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;i++){
        if (arr[i]<arr[i-1]){cout<<i-1;break;}
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 Nmax=100;
    int A[Nmax];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }    for(int j=n-1;j>=0;j--){
            cout<<A[j]<<" ";
        }
        cout<<endl;
        for(int i=0;i<n;i++){
            if(A[i]>A[i+1] && A[i]>A[i-1])
        cout<<i;
        }
    }

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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 peak; int A[n];
    for(int i = 0; i<n; i++) {
        cin >> A[i];
        if(i>0 && peak == 0) {                       //loop will deactivate once we got a peak
            if(A[i]<A[i-1]) peak = i-1;
        }
    }
    for(int i=(n-1); i>=0; cout << A[i--] << " ");
    cout << endl << peak;
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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];
    int counter=0;
    for (int i=0;i<n;i++) {
        cin>>A[i];
    }
    for (int i=n-1;i>=0;i--) {
        cout<<A[i]<<" ";
    }
    cout<<'\n';
    for (int i=1;i<n-1;i++) {
        if (A[i]>A[i+1]&&A[i]>A[i-1]) {
            cout<<i;
            return 0;
        }
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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];
    }
    //Printing the array in reverse order.
    for(int i = 0; i < n; i++) cout << a[n - 1 - i] << " ";
    cout << endl;
    
    //Finding a peak element.
    for(int i = 1; i < n - 1; i++)
    {
        if(a[i] > a[i - 1] && a[i] > a[i + 1])
        {
            cout << i << endl;
            return 0;
        }
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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=0;i<n;i++) cout<<a[n-1-i]<<" ";
    cout<<endl;
    for(int i=1;i<n-1;i++) {
        if(a[i-1]<a[i] && a[i]>a[i+1]) {
            cout<<i;
        }
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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[100]; 
    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] > max(arr[i-1], arr[i+1])) cout << i << endl;
    }
}

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

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=0;i<n-1;++i)
                  {cout<<A[n-1-i]<<" ";
                  } cout<<A[0]<<endl;
    int p=0;
    while(A[p]<A[p+1]){
        ++p;
        
    } 
    cout<<p;
    
   }

Grading criterion: Accepting input
Rating A: correctly accepts n, and array/vector as input

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: A