CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

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

void myswap(int& a, int& b){
	int temp=a;
	a=b;
	b=temp;
}

int argmax(int *A, int n){
	int maxindex=0;
	for (int j=1;j<n;j++){
		if (A[maxindex]<A[j]) maxindex=j;
	}
	return maxindex;
}

int argmin(int *A, int n){
	int minindex=0;
	for (int j=1;j<n;j++){
		if (A[minindex]>A[j]) minindex=j;
	}
	return minindex;
}


void increasingsort(int* A, int n, int* B){
	
	for (int i=n;i>1;i--){
		int maxindex=argmax(A,i);
		myswap(B[maxindex],B[i-1]);
	} 
}

void decreasingsort(int* A, int n, int* C){
	
	for (int i=n;i>1;i--){
		int minindex=argmin(A,i);
		myswap(C[minindex],C[i-1]);
	} 
}

int equal(int* A, int* B, int n){
	int x=0;
	for (int i=0; i<n; i++){
		if (A[i]==B[i]) x++; 
	}
	if (x==n) return(1);
	else return(2);
}

int isIncreasingDecreasing(int* A, int n){
	int B[n], C[n];
	for (int j=0;j<n;j++) {B[j]=A[j]; C[j]=A[j];}
	
	increasingsort(A,n,B);
	decreasingsort(A,n,C);
	int x=equal(A,B,n);
	int y=equal(A,C,n);
	if (x==1) {return 1;}
	else if (y==1) {return 2;}
	else {return 3;}
}

int main(){
	int n;
	cin>>n;
	int A[n];
	for (int i=0;i<n;i++) cin>>A[i];
	int a;
	a=isIncreasingDecreasing(A,n);
	cout<<endl<<a;	
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

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

int isIncreasingDecreasing(int *A,int n)
{
  for(int i=0;i<n;i++)
	{
		if (A[i+1]>A[i]) return 1;
		else if (A[i+1]<A[i]) return 2;
		else return 3;
	}
	return A[n];
}

int main(){
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++)
{
	cin>>a[i];
}
cout<<isIncreasingDecreasing (a,n);
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<iostream>
using namespace std;
void isIncreasingDecreasing(int a[],int n)
{
	
	int x=0,y=0,z=0;
	if(n==1)
	{
		cout<<"1";
	}
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]>a[i])
		{
			x++;
		}
		if(a[i+1]<a[i])
		{
			y++;
		}
	}
	if(x==n-1 && n>1)
	{
		cout<<"1";
	}
	if(y==n-1 && n>1)
	{
		cout<<"2";
	}
	if(z==0 && x>0 && x<n-1 && y<n-1 && y>0 && n>1)
	{
		cout<<"3";
	}
	
}
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	isIncreasingDecreasing(a,n);
	
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

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

int isIncreasingDecreasing(int *A,int n){
int i,val=0;


for( i=0;i<n;i++){ cin>>A[i] ;}
if (n==1) return 1;
     for (i=0;i<n-1;i++){
     
     if(A[i+1]>A[i]) val++ ; }

if(val==(n-1))  return 1;

val=0;
for(i=0;i<n-1;i++){  if(A[i+1]<A[i]) val++ ;  }

if(val==(n-1)) return 2;
else return 3;

}
int main(){  
    int n,i,A[n];
    cin>>n;
    
    
    cout<< isIncreasingDecreasing(A,n);
    return 0;}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<iostream>
using namespace std;
int isIncreasingDecreasing(int* arr,int idx,int n){
while(idx==n){
if (arr[idx]<isIncreasingDecreasing(arr,idx+1,n)) return 1;
if (arr[idx]>isIncreasingDecreasing(arr,idx+1,n)) return 2;
else return 3;}}
int main(){
int n;
int* arr;
int idx;
cin>>n;
for( idx=0;idx<n;idx++){
cin>>arr[idx];}
cout<<isIncreasingDecreasing(arr,idx,n);}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<simplecpp>
   main_program{

  'int main*()' ;

       
    forward = int*A, int n ,
    
   int*A = 2,2,3,3,3
   int n = 3,3,3,2,2
 
    printf=int*A
    printf=int n
  
      int*A = int n,
     *1 <= n <25

   scanf=int*A
   scanf+int n

 return 1
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

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

void fun(int n)
{

	
	int a[n];
for(int i=0;i<=n;i++)
{ 
if(a[i]<a[i++]) { a[i]=a[i++];

}

cout<<"1";
}
for(int i=0;i<n;i++)
{
if(a[i]>a[i++]) { a[i]=a[i--] 
}
}
cout<<"2";


}
			
 int main()

{
int n;
cin>>n;
int a[n];
for(int p=0;p<=n;p++)
{

	cin>>a[p];

}
fun(n);
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

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

int isIncreasingDecreasing (int *A, int n)
{
	int k=0;
	
	for (int i=0; i<n-1; i++)
	{
		if (A[i] < A[i+1]) k++;
		else if (A[i] > A[i+1]) k--;
	}
	
	if (k==n-1) return 1;
	else if (k==1-n) return 2;
	else return 3;
}


int main()
{
	int n; cin >> n;
	int A[n];
	
	for (int i=0; i<n; i++)
	{
		cin >> A[i];
	}
	
	cout << isIncreasingDecreasing(A, n);
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<iostream>
using namespace std;
int main(){

int n;
cin>>n;
if(n<=0 || n%2==0){cout<<"0";}
else{
int j=1;

while(j<=n){
if(j==((n+1)/2)){int forget=1;
                 while(forget<=n){cout<<"*";
                     forget++;}
                }
else{
int i=1;
while(i<=n){
if(i==((n+1)/2)){cout<<"*";}
else{cout<<" ";}
i++;                } //while end

} //inside else loop closed
cout<<endl;j++;
 }                 //2nd while end 
 } //else end

}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<simplecpp>
main_program{
cout<<"3";}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include <iostream>
using namespace std;
int main()
{
int array[4]={2,3,4,1};
array[0]=2;
array[1]=3;
array[2]=4;
array[3]=1;

for (int i=0;i<1;i++)
{cout << array [3]<<endl;
}
 return 1;
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

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

int isIncreasingDecreasing (int *A, int n){
    int w = 0;
    bool k = true;
    int a=0;
    int b=0;

    if(A[0]<A[1]){
        for(int i=0; i<n;i++){
            if(A[i]<A[i+1] && k){
                k = true;
                a=1;
                b=0;
            }else{
                k = false;
                a=0;
            }
        }
    }
    k = true;
    if(A[0]>A[1]){
        for(int i=0; i<n;i++){
            if(A[i]>A[i+1] && k){
                k = true;
                a=0;
                b=1;
            }else{
                if(!(i==(n-1))){
                    k = false;
                    b=0;
                }
            }
        }
        
    }
    if(a==1 && b==0){
        w=1;
    }else if(a==0 && b==1){
        w=2;
    }else if(a==0 && b==0){
        w=3;
    }
    return w;
}




int main(){
//getting vals
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
//execute
    int k = isIncreasingDecreasing (A,n);
    cout<<k;
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include <iostream>
using namespace std;
int isIncreasingDecreasing (int *A, int n)
{
int i=0;
while(i<n-1) {


if (A[i] < A[i+1])
i++;
if(i=n-2)
cout<<"1";

else if (A[i] > A[i+1]) break;


}
int j=0;
while(j<n-1) {





 if (A[j] > A[j+1])
j++;
if(j=n-2)
cout<<"2";

else if (A[j] < A[j+1])break;


}
}





int main() {
int n;
cin>>n;
int a[n];
for(int i=0; i<n;i++) {
cin>>a[i];
}
int k = isIncreasingDecreasing (a,n);
cout<<k;
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<iostream>
using namespace std;
int incdec(int *a,int n)
{
if(n==1)
return 1;
int r=3;
int inc=0;
for(int i=0;i<n-1;i++)
{
if(a[i]<a[i+1])
inc++;
}
if(inc==n-1)
r=1;
if(inc==0)
r=2;
return r;
}
void inp(int *a,int n)
{
for(int i=0;i<n;i++)
cin>>a[i];
}
int main()
{
int n;
cin>>n;
int arr[n];
inp(arr,n);
cout<<incdec(arr,n);
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<simplecpp>
int isIncreasingDecreasing(int *A, int n)
{
     int i=0,l=0;
     while(i<(n-1))
     {
        if(A[i] < A[i+1])
        {
            l++;
       
        }
        else if(A[i] > A[i+1])
        {
           l--; 
         
        }
        else
        {
          break;
        }
        i++;
     }
     
     if(l==(n-1))
     {
       return(1);
     }
     else if(l==-(n-1))
     {
       return(2);
     }
     else
     {
       return(3);
     }
}
main_program
{
    int n,s,i;
    cin>>n;
    int A[n];
    for(i=0;i<n;i++)
    {
    
       cin>>A[i];
    }
    s=isIncreasingDecreasing(A,n);
    cout<<s;
    
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to take the number n and an array A of n numbers as input from the user. The program should then contain a function which determines whether the array is in strictly increasing order (in which case the function should return 1), or else determine whether the array is in strictly decreasing order (in which case the function should return 2), and return 3 otherwise. The format of the function is int isIncreasingDecreasing (int *A, int n). The program should then print the value returned by the function on a new line. You must implement this via a function, otherwise you will get no credit. For simplicity, assume that all entries in the array are unique.

Input Format - Non-negative integer n and an array A of n elements
Output Format - The value 1,2 or 3 as described above. 
Constraints
1 <= n < 25

Sample input - 33 4 2
Sample output - 3

Student submission:
#include<iostream>
using namespace std;
int isIncreasingDecreasing (int *A,int n)
{bool flag1;
bool flag2;
 for(int i=0;i<n-1;i++)
{
if(A[i]<A[i+1])flag1==1;
}
for(int j=0; j<n-1 ; j++)
{
if(A[j]>A[j+1])flag2==1;
}
if(flag1)cout<<"1";
else if(flag2)cout<<"2";
else cout<<"3";
return 0;
}

int main()
{
int n;
cin>>n;
int A[n];
for(int i=0;i<n;i++)
{
cin>>A[i];
}

 isIncreasingDecreasing(A,n);

}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C