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

int main(){
  
}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: C
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 i;
    cin>>i;
    int v[100];
    for( int j=0;j<i;j++){
        cin>>v[j];
    }
    int w[i];
    for(int j=0;j<i;j++){
        w[j]=v[i-j-1];
        cout<<w[j]<<" ";
    }
    cout<<endl;
    for(int k=1;k<i-1;k++){
        if((v[k-1]<v[k])&&(v[k+1]<v[k])){
            cout<<k;
            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=0;
    cin >> n;
    if (n<=100){
        int arr[n]={};
        int k = 0;
        for (int i = 0; i<n; i++){
            cin>>k;
            arr[i]=k;
        }

        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] && 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;
    int 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-1;i++)
    {
        if(arr[i]>arr[i-1] && arr[i]>arr[i+1])
        {
            cout<<i<<endl;
        }
    }
}

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

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>
int main()
{
    int n;
    std::cin>>n;
    int arr[n];
    int max=arr[0];
    int s=0;
    for(int i=0; i<n; i++)
    {
        std::cin>>arr[i];
    }
    for(int j=0; j<n; j++)
    {
        std::cout<<arr[n-1-j]<<" ";
    }
    for(int k=0; k<n; k++)
    {
        if(arr[k]>max)
        {max=arr[k];
        s=k;
        }
    }
    std::cout<<std::endl;
    std::cout<<s;
}

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>
int main(){
    int n;bool found=0;int b;
    std::cin>> n;
    int a[n];
    for (int i=0;i<n;i++) {std::cin >> a[i];}
    for(int i=n-1;i>0;i--){             // cant use a[0] since we will be using i-1
        std::cout << a[i] << " ";
    if (!found && (a[i]>a[i-1])) {
        b=i;found =1;
        }
    }
    std::cout << a[0] << std::endl << b; // we didnt take case of a[0] earlier
}

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 numInt; cin>>numInt;
    int arr[numInt];
    for(int i =0 ; i<numInt; i++){
        int inp; cin>> inp;
        arr[i] = inp;
    }
    for(int i = numInt -1 ; i>= 0; i--){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    for(int i = 1; i<numInt-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 i=0;
    int j=0;
    int a[n];
    while(i<n){
        cin>>a[i];
        i++;
    }
    i=0;
    while(i<n){
        cout<<a[n-1-i]<<" ";
        if(i>=1 && i<=n-2){
            if((a[i-1]<a[i]) && (a[i] >a[i+1])){
                j=i;
            }
        }
        i++;
    }
    cout<<endl;
    cout<<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>
#include<vector>
using namespace std;

int peak(vector<int> arr,int num) {
    for(int i=1;i<num;i++) {
        if(arr[i]>arr[i-1] && arr[i]>arr[i+1]) return i;
    }
}

void print(vector<int>arr, int num) {
    for(int i=num-1;i>=0;i--) {
        cout<<arr[i]<<" ";
    }
}

int main() {
    vector<int> arr;
    int num;
    cin>>num;
    for(int i=0;i<num;i++) {
        int a;
        cin>>a;
        arr.push_back(a);
    }
    print(arr,num);
    cout<<endl;
    cout<<peak(arr,num);
}

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

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 arr[100];
    cin>>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<<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[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 j=1;j<n-1;j++){
        if(A[j]>A[j-1]&&A[j]>A[j+1])
        {
            cout<<j;
            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>

int main(){
    int n, m = 0; std::cin >> n;
    int peakind[100] = {};
    int list[100] = {};
    for(int i = 0; i < n; i++){
        std::cin >> list[i];
    }
    for(int j = 0; j < n-2; j++){
        if(list[j] < list[j+1] && list[j + 1] > list[j + 2]){
            peakind[m] = j + 1; m++;
        }
    }
    for(int k = 0; k < n; k++){
        std::cout << list[n - 1 - k];
        if(k != n - 1){
            std::cout << " ";
        }
        else std::cout << std::endl;
    }
    for(int l = 0; l < m; l++){
        std::cout << peakind[l];
        if(l != m - 1){
            std::cout << " ";
        }
        else std::cout << std::endl;
    }
}

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];
    //taking input of array
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    //print elements of array in reverse order
    for(int i = n - 1; i >= 0; i--)
    {
        cout<<a[i]<<" ";
    }

    //find out index of peak element by going through the entire array and finding the element greater than its neighbours
    int idx;
    for(int i = 1; i < n - 1; i++) //first and last element cannot be peak elements
    {
        if(a[i-1] <  a[i] && a[i] > a[i+1])
        {
            idx = i;
            break; //because only 1 such element exists, we break as soon as such an element is found
        }
    }
    cout<<endl<<idx;
}

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


}

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

Grading criterion: Output
Rating A: Correctly prints the output

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