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;
cin>>n;
int a[n];
int b=0;
int c=0;
for (int i=0;i<n;i++){
cin>>a[i];
}

        for(int j=0;j<n-1;j++){
        for (int k=j+1;k<n;k++){
        if (a[j]=a[j+k]){b++;
        cout<<a[j]<<" "<<b;

}
}

}


return 0;
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
Rating D: 0
Assigned grade: B
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 max_element = a[0],count = 1;

	for(int i = 0; i<n; i++){
		int c = 1;
		for(int j = 0; j<n; j++){
			if(j != i){
				if(a[j] == a[i]) c++;
			}
		}

		if(c>count){
			count = c;
			max_element = a[i];
		}
	}

	cout<<max_element<<' '<<count;

	
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
Rating D: 0
Assigned grade: A
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],t[n];
    for(int i=0;i<n;i++) {cin>>a[i];t[i]=0;}

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

    int m=0;
    for(int i=0;i<n;i++){
     if(t[m]<=t[i]) m=i;}
    cout<<a[m]<<" "<<t[m];
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
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 ary[n];
for (int i=0;i<n;i++){
	int ele;cin>>ele;
	ary[i]=ele;
	}

for(int i=0;i<n;i++){
	if(ary[i]>0){
		int s=1;
		for (int j=i+1;j<n;j++){
			if(ary[i]==ary[j]){
				s++;
				ary[j]=-1;
				}
			else continue;
			}
		cout<<ary[i]<<" "<<s<<endl;
		}
	else continue;
	
	}}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
Rating D: 0
Assigned grade: B
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;
	if(n==1)
	{
		int a[1];
		cin >> a[0];
		cout << a[0] << " " << 1;
	}
	if(n>1 && n<=20)
	{
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];

	int b[n];
	for(int i=0;i<n;i++) b[i]=0;

	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{

			if(a[i]==a[j]) b[i]++;

		}
	}

	int m=0;
	for(int i=1;i<n;i++)
	{
		if(b[i]>b[m]) m=i;
	}

	cout << a[m] << " " << b[m]+1;
}
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
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>
#include<cstdlib>

using namespace std;
int main(){
int a[], 8;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]>>endl;
	if (int i, int c=0, a[i]<a[i+1]);
	   a[i]=c;
       a[i+1]=a[i];
       c=a[i+1];
       return;
	if (int a[], a[0]=a[1] && a[2]=a[0] && a[0]=a[3] && a[0]=a[4] && a[0]=a[5] && a[0]=a[6] && a[0]=a[7]);
	cout<< a[0] << "8" << endl;
	return 0;
    if (int a[], a[0]=a[1] && a[2]=a[0] && a[0]=a[3] && a[0]=a[4] && a[0]=a[5] && a[0]=a[6]);
    cout<< a[0] << "7" << endl;
	   return 0;
    if (int a[], a[0]=a[1] && a[2]=a[0] && a[0]=a[3] && a[0]=a[4] && a[0]=a[5] );
    cout<< a[0] << "6" << endl;
	   return 0;
    if (int a[], a[0]=a[1] && a[2]=a[0] && a[0]=a[3] && a[0]=a[4]);
	cout<< a[0] << "5" << endl;
	   return 0;
    if (int a[], a[0]=a[1] && a[2]=a[0] && a[0]=a[3]);
	cout<< a[0] << "4" << endl;
	   return 0;
    if (int a[], a[0]=a[1] && a[2]=a[0]);
	cout<< a[0] << "3" << endl;
	   return 0;
    if (int a[], a[0]=a[1]);
	cout<< a[0] << "2" << endl;
	   return 0;
    else;
	cout<< "1";
	   return 0;
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
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 f(int *A,int l,int n){
int p=0;
for (int i=0;i<n;i++) {
if (A[i]==A[l]) {
p=p+1;}}
return p;}
int argmax(int *arr,int p){
int max=0;
for (int j=0;j<p;j++){
if (arr[max]<arr[j]) max=j;}
return max;}
int main(){
int n;cin>>n;
int A[n];int arr[n];
for (int i=0;i<n;i++) {
cin>>A[i];
}
for (int i=0;i<n;i++) {
arr[i]=f(A,i,n);
} 
int u=arr[argmax(arr,n)];
int z=A[argmax(arr,n)];
cout<<z<<" "<<u;
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
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<bits/stdc++.h>
using namespace std;

int max(int b[],int n);
int main()
{

int n,i,j,maxin,K;
cin>>n;

int x[n];
for(K=0;K<n;K++)
{
cin>>x[K];

}

bool flag;
int a[n];
for(i=0;i<n;i++)
{a[i]=0;}

for(i=0;i<n;i++)
{
	for(j=1;j<=i;j++)
	{
		if((i-j)>=0)
		{
			if(x[i]!=x[i-j])
			flag=1;
			else
			{flag=0;
			break;}
		}
	if(flag)
	{
		for(j=0;j<n-i;j++)
		{
			if(x[i]==x[i+j])
			a[i]=a[i]+1;
		}
	}	
	}
}

maxin=max(a,n);
cout<<x[maxin]<<" "<<a[maxin];
}

int max(int b[],int n)
 {
 	int i,maxin=0;
 	for(i=1;i<n;i++)
 	{if(b[maxin]<b[i])
 	maxin=i;}
 	return maxin;
 }

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
Rating D: 0
Assigned grade: B
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 maxi(int* b,int n){
int k,m=0;
for(int i=0;i<=n-1;i++){
if(b[i]>b[m]){m=i;}}
return m;}
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<=n-1;i++){
cin>>a[i];}
int b[n];
for(int i=0;i<=n-1;i++){
int p=0;
for(int j=i;j<=n-1;j++){
if(a[i]==a[j]){p++;}}
b[i]=p;}
int k=maxi(b,n);
cout<<a[k]<<" "<<b[k];
}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
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 c[n];
for(int h=0;h<n;h++){
	c[h]=0;}
int a[n];
int flag=0;
for(int j=0;j<n;j++){
	a[j]=0;}
for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
		if(arr[j]==c[k]){a[k]=a[k]+1;flag=1;break;}
		}
	if(flag==0){
	c[j]=arr[j];
	a[j]=a[j]+1;}
}
int w=0;
for(int y=0;y<n;y++){
	if(a[w]<a[y]){w=y;}}
cout<<c[w]<<" "<<a[w];

}

Grading criterion: Quality of variable names
Rating A: Good Variables Names
Rating B: Ok Variable Names
Rating C: Poor Naming of Variables
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;
int count=0;
cin>>n;
int arr[n];

for(int i=0;i<n;i++){
cin>>arr[i];}
if(n==1){cout<<arr[0]<<" "<<n;}
else{
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(arr[i]==arr[j]){count++;
x=i;}
else{cout<<"1"<<arr[0];}}

cout<<arr[x]<<" "<<count;}}
return 0;}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
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;
cin>>n;
int A[n],B[100],C[100];
for(int i=0;i<n;i++)
cin>>A[i];
for(int i=0;i<100;i++)
B[i]=i+1;
for(int i=0;i<100;i++)
C[i]=0;
int q=0;
while(q<n) {
for(int k=0;k<100;k++)
if(A[q]==B[k]) C[k]=C[k]+1;
q=q+1;
}
int a=0;
for (int i=0;i<100;i++)
a=max(C[i],a);
for(int i=0;i<100;i++)
if (a==C[i]) cout<<B[i]<<" "<<C[i];
wait(5);
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
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;

void swap (float *a, float *b)
{
    float temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

void bubble_sort(float *A, int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {                      
        for (j = 0; j < n - i - 1; j++)
        {
            if (A[j] > A[j + 1])
                swap(&A[j], &A[j + 1]);
        }
    }
}
int main (){
 bubble_sort(A,n);
    cout << endl << "The sorted array is: " << endl;
    for (i= 0; i < n; i++)
    {
     	cout << A[i] << " ";
    }

int n,c=1;
int* a;
for(int i=0; i<n; i++)
{
 cin>>a[i];
}
{
int
for (int i = 0; i < n; i++){
if ( a[i]== a[i+1])
{
c++;
}
else 
return i++;
cout<<a[i]<<c;
}
return 0;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
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 mode(int *a,int n){
	int  b=-1,noe=0;
	for(int i=0;i<n;i++){
		int count =0;
		for(int j=0;j<n;j++){
			if (a[i]==a[j]){
				count++;}}
		if (count>noe){
			b=a[i];
			noe=count;}
		}
	return b;}


int main(){
	int n,count=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];}
	int m=mode(a,n);
	for(int i=0;i<n;i++){
		if (a[i]==m){
			count++;}
		}
	cout<<m<<" "<<count;
	}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: A
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 input[n];
 int number[n];
 for(int i=0; i<n; i++)
 {
   cin >> input[i];
 }
 for(int j=0; j<n; j++)
 {
   number[j]=0;
     for(int k=0; k<n; k++)
     {
        if(input[j]==input[k]){number[j]=number[j]+1;}
     }
 }
 for(int i=0; i<n; i++)
 {
   int c=0;
   for(int j=0; j<n; j++)
   {
      if(number[i]>=number[j]){c++;}
      if(c==n){ cout << input[i] << " " << number[i]; break;}
   }
   if(c==n){break;}
 }
return 0;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
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],b[n],i,j,k,l,maxcount,temp;
	
	
	

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=0;
		
	}

	for (j=0;j<n;j++)
		{
			for(k=0;k<n;k++)
			{
				if (a[j]==a[k])
					{
						b[j]=b[j]+1;
					}
				
			}
			k=0;
			
		}
	int x=0;

	maxcount=b[0];
	for (l=0;l<(n-1);l++)
	{
		if (b[l+1]>b[l])
		{
			maxcount=b[l+1];
			temp=(l+1);
		}
		
	}
	cout<<a[temp]<<" "<<maxcount;


}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B