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 std::cin; using std::cout; using std::endl; using std::vector;

int main(){
    int n; cin >> n;
    vector<int> vec = {};

    for(int i = 0; i < n; i++){
        int a; cin >> a; 
        vec.push_back(a);
    }

    for(int i = n-1; i >= 0; --i){
        cout << vec.at(i) << " ";
    }

    cout << "\n";
    for(int i = 1; i < n-1; i++){
        if((vec.at(i) > vec.at(i-1)) && (vec.at(i) > vec.at(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 arr1[100]={};
    int n; cin>>n;
    for(int i=0; i<n; ++i) cin>>arr1[i];

    for(int i= n-1; i>=0; --i) cout<<arr1[i]<<' ';
    cout<<endl;

    for(int i=1; i<n; ++i){
    if(arr1[i-1]<arr1[i] && arr1[i]>arr1[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;
void reverse(int arr[],int x){
    for(int i=0;i<x;i++){
        cout << arr[x-1-i] << " ";
    }
}
int pkfndr(int arr[],int x){
    for(int i=0;i<x-1;i++){
        if(arr[i]>arr[i+1])return i;
    }
}


int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        arr[i]=x;
    }
    reverse(arr,n);
    cout << endl;
    cout << pkfndr(arr,n);

}

Grading criterion: Output
Rating A: Correctly prints the output

Rating B: Some Issue.
Rating C: Major Issue.
Rating D: 0
Assigned grade: B
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> vec(n);
    for(int i = 0; i<vec.size(); i++) cin>>vec[i];
    for(int i = vec.size()-1; i>0; i--) cout<<vec[i]<<" ";
    cout<<vec[0]<<endl;
    for(int i = 1; i<vec.size()-1; i++) {
        if((vec[i]>vec[i-1]) && (vec[i]>vec[i+1])) {
            cout<<i<<endl;
            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 k;
    cin>>k;
    int s[k];
    for(int i=0;i<k;i++){
        cin>>s[i];
    }
    for(int i=k-1;i>=0;i--){
        cout<<s[i]<<" ";
    }
    cout<<endl;
    for(int i=0;i<k;i++){
        if((s[i-1]<s[i])&&(s[i+1]<s[i])){
            cout<<i<<" ";
        }
    }
    
    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 arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=1;i<n+1;i++){
        cout<<arr[n-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;
    
    if(n>=3 &&n<=100){
        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<<" ";
        }
        cout<<endl;
        int p=0,q=0;
        for(int i=0;i<n;i++){
            if(p<a[i]){
                p=a[i];
                q=i;
            }
        }
        cout<<q<<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,peak;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=1;i<n-1;i++){
        if(A[i]>A[i+1]){
            peak=i;
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<A[n-1-i];
        if(i!=n-1){
            cout<<" ";
        } else{
            cout<<endl<<peak;
        }
    }
}

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;
    
    int index = 0;
    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[n];
	for(int i=0;i<n;i++) {
		cin>>A[i];
	}
	for(int i=0;i<n;i++) {
		cout<<A[n-i-1]<<" ";
	}
	cout<<endl;
	for(int i=1;i<n-1;i++) {
		if(A[i]>A[i-1] && A[i]>A[i+1]) {
			cout<<i<<endl;
			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>
#include<vector>
using namespace std;
int main(){
    int k;
    cin>>k;
    int A[k];
    for(int i=0;i<k;i++){
        cin>>A[i];
    }
    int j=k-1;
    for(;j>=0;j--){
        cout<<A[j]<<" ";
    }
    cout<<endl;
    for(int l=1;l<k-1;l++){
        if((A[l]>A[l-1])&&(A[l]>A[l+1])){
            cout<<l;
        }
    }
}

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

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];

    // NOTE: acc to qn, peak > 0, so using 0 as a default value
    int peak = 0;

    cin >> A[0];

    for(int i = 1; i < n; i++) {
        cin >> A[i];
        if (!peak && A[i] < A[i-1])
            peak = i-1;
    }

    while (n)
        cout << A[--n] << ' ';
    
    cout << endl;

    cout << peak;
}

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 main(){
    vector<int> peak;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        peak.push_back(a);
    }
    for(int i=n-1;i>=0;i--){
        cout<<peak[i]<<" ";
    }
    
    for(int i=1;i<n-1;i++){
        int x=i-1;
        int y=i+1;
        if(peak[i]>peak[x] && peak[i]>peak[y]){
            cout<<endl<<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 ser[100];
    for(int i=0;i<N;i++){
        cin>>ser[i];
    }
    int serr[100];
    for(int i=0;i<N;i++){
        cout<<ser[N-i-1]<<" ";
    }
    cout<<endl;
    for(int i=1;i<N-1;i++){
        if(ser[i]>ser[i+1] && ser[i]>ser[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>
#include<vector>
using namespace std;

int main() {
    int n;
    vector <int> peak;
    cin >> n;
    int array[n];

    for(int i = 0; i < n ; i++) cin >> array[i];

    for(int i = n-1; i>=0; i--) cout << array[i] << " ";

    if(n > 2){
        for(int i = 1; i < n-1; i++){
            if(array[i] > array[i-1] && array[i] > array[i+1]){
                peak.push_back(i);
            }
        }
    }

    cout << endl;

    for(int i = 0; i < peak.size(); i++){
        cout << peak[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 arr[100] = {};
    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;
    int i=0;
    while(arr[i+1] > arr[i]) {i++;}
    cout << i << endl;
    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,j;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        if(A[i+1]>A[i]&&A[i+1]>A[i+2]){
            j=i+1;
            break;
        }
    }
    int B[n];
    for(int i=0;i<n;i++){
        B[i]=A[n-i-1];
        cout<<B[i]<<" ";
    }
    cout<<endl;
    cout<<j<<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>
            #include <vector>
            using namespace std;

            int main(){
                int n;
                cin>>n;
                vector<int>V={};
                for(int i=0;i<n;i++){
                    int x;
                    cin>>x;
                    V.push_back(x);
                }
                for(int i=n-1;i>=0;i--){
                    cout<<V[i]<<" ";
                }
                int peak=0;
                int peak_index;
                int count;
                for(int x: V){
                    if(x>peak){peak=x; peak_index=count;}
                    count++;
                }
                cout<<endl<<peak_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>
#include<vector>
using namespace std;
int main(){
    vector<int> list;
    int n;
    cin >> n;
    list.resize(n);
    for(int i=0;i<n;i++) cin >> list[i];
    for(int i=n;i>0;--i){
        cout<<list[i-1]<<" ";
    }
    cout<<endl;
    for(int i=1;i<n-1;i++){
        if((list[i-1]<list[i]) && (list[i]>list[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