CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to take user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

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

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

int m[];
m[i]=i;
int s=0;
for (i=0;i<n;i++)
if (Arr[i]==m[i])
s=s+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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<simplecpp>
main_program{
cin>>n;
int a[n];
int p=0;
int x[n];
int maxindex=0;
for(int i=0;i<n;i++)
x[i]=0;
for(int i=0;i<n;i++)
cin>>a[i];
for(int f=0;f<n;f++){
for(int j=f+1;j<n;j++)
if(a[j]==a[f])
x[f]=x[f]+1;}

for(i=1;i<n;i++){
if(x[maxindex]<x[i])maxindex=i;

cout>>maxindex;



}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

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

int main(){

int n;
cin>>n;
float arr[n];  int arr2[n];
for(int i=0; i<n; i++){cin>>arr[i];   arr2[i]=0;}
arr2[0]=1;
for(int i=1; i<n; i++){int addindex=i; 

			for(int m=i-1; m>=0; m--){  if(arr[i]==arr[m])
						{addindex=m;}}
						arr2[addindex]++; }
int maxindex=0;
for(int i=1; i<n; i++){if(arr2[maxindex]<arr2[i]) {maxindex=i;}}

cout<<arr[maxindex]<<" ";  cout<<arr2[maxindex];

}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main(){
           int n,x,m;
           cin>>n;
           int a[n];

           for(int i=0;i<n;i++){
               cin>>a[i];}
        int i=0;
         int c[i]={0};
          for( i=0;i<n-1;i++){
       
              for(int j=i+1;j<n;j++){
                    if(a[i]==a[j]) {c[i]++;}
             }
          m=0;
         if(c[i]>m) {m=c[i];x=i;}
         }
         cout<<a[x]<<" "<<m;
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <simplecpp>
int argmax (int *a, int L){
int maxindex = 0;
for(int j=1; j<L; j++){
if(a[maxindex] < a[j]) maxindex = j;
}
return maxindex;
}
void selection_sort (int *a, int n){
for(int i=n; i>1;i--){
int maxindex = argmax(a,i);
int x;
x=a[maxindex];
a[maxindex]=a[i-1];
a[i-1]=x;
}
}
main_program {
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	selection_sort(a,n);
	int k=1;
	for(int i=1;i<n;i++) {
		if(a[i]!=a[i-1])k++;
	}
	int c[k];
	int x=1,p=1;
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1]){
			c[x]=p;
			x++;
			p=1;
		}
		else p++;
	}
	int maxindx=argmax(c,k);
	int y=0;
	for(int i=0;i<maxindx;i++){
		y=y+c[i];
	}
	cout<<a[y+1]<<" "<<c[maxindx];
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int array[n];
for(int i=0;i<n;i++){
cin>>array[i];
}
int frequency[n];
for(int j=0;j<n;j++){
int m=0;
for(int k=j;k<n;k++){

if(array[j]==array[k]) m++;
}frequency[j]=m;

}int x=0;
for(int l=0;l<n;l++){

if(frequency[x]<frequency[l]) x=l;
}
cout<<array[x]<<" "<<frequency[x];
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0; i<n; i++)
{cin>>a[i];
}
int b=0;
for(int j=0; j<n; j++)
{for(int k=0; k<n-j; k++)
if(a[k]>a[k+1])
{b=a[k];
a[k]=a[k+1];
a[k+1]=b;
}
}
int t[n];
for(int i=0; i<n; i++)
{t[i]=0;}
for(int i=0; i<n; i++)
{int r=i;
while(a[i]==a[r])
{r=r+1;
t[i]=t[i]+1;
}
}
int m=0;
int p=t[0];
for(int i=0; i<n; i++)
{if(t[i]>p)
{m=i;
p=t[i];
}
}
cout<<a[m]<<" "<<p;
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int argmax (int *scores, int L){
int maxindex = 0;
for(int j=1; j<L; j++){
// update the index if a larger element is found
if(scores[maxindex] < scores[j]) maxindex = j;
}
return maxindex;
}
int main()
{
	int n;cin>>n;int a[n],c[n],l;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int b=0;b<n;b++)
	{
		int d=a[b];c[b]=0;
		for (int e=0;e<n;e++)
		{
			if(a[e]=d)c[b]+=1;
		}
	}
	int q=argmax(c,n);
	cout<<a[q]<<" "<<c[q];

}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;


}


}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <iostream>
using namespace std;
int main(){
int n,num=0;
cin>>n;
int remainder;
for(int i=1;1<=n;i++){
remainder=n%10;
n/=10;
num=num*10;
num+=remainder;
}
cout<<num;
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

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

int main(){

int number;
cin>>number;

int InputArray[number];

for (int i=0;i<number;i++){
    cin>>InputArray[i];
}

int FrequencyArray[number];
for (int i=0;i<number;i++){
    FrequencyArray[i]=0;
}


for (int i=0;i<number;i++){
    for(int j=0;j<number;j++)
    {
        if (InputArray[j]==InputArray[i]) FrequencyArray[i]++;
    }
}

int MaxFrequency=0,Position=0;

for (int i=0;i<number;i++){
if (FrequencyArray[i] > MaxFrequency){
    Position=i;
    MaxFrequency = FrequencyArray[i];
}
}

cout<<InputArray[Position]<<" "<<MaxFrequency;

}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

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];
}
int count[n];
for (int i=0;i<n;i++) count[i]=1;
for (int i=0;i<n;i++)
{
 for (int j=0;j<i;j++)
{
 if(a[i]==a[j]) count[i]++;
 else continue;
}
}
int maxindex =0;
for (int i=0;i<n;i++)
{
if (count[maxindex]<count[i]) maxindex=i;
}
cout<<a[maxindex]<<' '<<count[maxindex];
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main(){
int n,m;
cin>>n;
m = left(n);
cout<<"m";
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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include <iostream>
using namespace std;
int main(){
int a[20]={0};
int b[20]={0};
int max=0;
int n;
cin>>n;
for(int i=0;i<n;i++){cin>>a[i];}
for(int i=0;i<n;i++){for(int j=0;j<n;j++){if(a[i]==a[j]){b[i]++;}}}
for(int i=0;i<n;i++){if(b[i]>b[max]){max=i;}}
cout<<a[max]<<" "<<b[max];}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

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

int maxph(int *arr,int n){
    int val=arr[0];
    int ph=0;
    for (int i=0;i<n;i++){
        if (arr[0]<arr[i]){
            val ++;
            ph=i;
        }
    }
    return ph;
}

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

    int psarr[n]={rarr[0]};
    int uq=1;
    for (int i = 1;i<n;i++){
        int j=0;
        while (j<uq){
            bool same = (psarr[j]==rarr[i]);
            if (same){break;}
            j++;
        }
        if (j==uq-1){
            psarr[i]=rarr[i];
            uq++;
        }
    }

    int parr[uq];
    for (int i=0;i<uq;i++){
        parr[i]=psarr[i];
    }

    int carr[uq];
    for (int i=0;i<uq;i++){
        carr[i]=0;
        for (int j=0;j<n;j++){
            if (parr[i]==rarr[j]){
                carr[i]++;
            }
        }
    }

    int ansph=maxph(carr,uq);
    cout << parr[ansph]<< " " <<carr[ansph];
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<simplecpp>
main_program{
	int n,i,a=0,b=0,c=0;
	cin>>n;
	int A[n];
	
	for(i=0;i<n;i++){
		cin>>A[i];
	}
	
	for(i=0;i<n;i++){
		if(A[i]==1){
			a=a+1;
			}
	}
	if(A[0]==1){
			cout<<1<<" "<<a;
		}
	
	for(i=0;i<n;i++){
		if(A[i]==42){
			b=b+1;
			cout<<42<<" "<<b;
		}
	}
	
	for(i=0;i<n;i++){
		if(A[i]==3){
			c=c+1;
		}
		
	}
	if(A[0]==3){
		cout<<3<<" "<<c;
	}
	
	
		
		
		
		
	
	
}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

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


}

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 user input n, the size of a 1D integer array, followed by the array entries as inputs. The program should then determine the majority element of the array, i.e., the element which occurs the most often. It should then display the majority element and how many times it occurs in the array. You may assume that the array contains only non-negative numbers. You may also assume that the array contains only one majority element. 

Input Format - Integers n, followed by elements of the integer-valued array.
Output Format - Print the values of the majority elements followed by frequency (a separate line for each element). 

Constraints
n is a positive integer, n >= 1 and n < 20

Sample input	12	3 1 2 1 2 3 2 1 3 3 2 1
Sample output 	3 4	1 4	2 4

Student submission:
#include<iostream>
using namespace std;
int main()
{   
    int n;
    cin>>n;
    
 int  array[n];
   for(int i=0;i<n;i++){
   cin>>array[i]>>" ";
   }
   
   for(int i=0;i<n;i++){
    if(array[i]==array[i+1]){
     cout<<array[i]<<" "<<"2"<<endl;
     }
     else{
     cout<<array[i]<<" "<<endl;
     }
  }
  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