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 maxval(int*a,int n){int maxindex=0;
for(int i=1;i<n;i++){
if(a[maxindex]<a[i]) maxindex=i;
}
return maxindex;
}
int main(){
int n;cin>>n;
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;i++){
for(int j=0;j<n;j++){if(a[j]==a[i])b[i]++;}
}int c=maxval(b,n);
cout<<a[c]<<" "<<b[c];
}

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,p=0;
	cin >> n;
	for(int m=n;m>0;m/=10)
	{
		int d=m%10;
		p=p*10+d;
	}
	cout << p;
}

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

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

if(a[i] == a[j]){b[i]++;}
j++;
}
}
int m=-5;
for(int i=0;i<n;i++){m=max(m,b[i]);  }
int k=0;
while(k<n){
if(m==b[k]){break;}
k++;

}
cout<<a[k]<<" "<<b[k];

}

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

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

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

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 argmax (int *repeat,int size){
int maxindex =0;
for(int j=1;j<size;j++){
if(repeat[maxindex]<repeat[j]) maxindex=j;}
return maxindex;
}
int main(){
int n;
cin>>n;
int v[n];
for(int i=0;i<n;i++)cin>>v[i];
int num[n];
for(int i=0;i<n;i++)num[i]=0;
for(int k=0;k<n;k++){
int j=v[k];for(int l=0;l<n;l++){if(j==v[l])num[k]++;};
}
int u=argmax(num,n);
cout<<v[u]<<" "<<num[u];
}

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];
for (int i=0; i<n; ++i) cin>>a[i];
int x=0, c=0, m;
for (int j=0; j<n; ++j)
{	c=0;
	for (int k=j; k<n; ++k)
	{	if (a[k]==a[j]) c++;
	}
	if (c>x)
	{	x=c;
		m=a[j];
	}
}
cout<<m<<' '<<x;
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],l,m=0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	for(int i = 0; i<n; i++){
		int k = 1;
		for(int j = i+1; j<n; j++){
			if(a[i]==a[j]) k++; 
		}
		if(k>m) {l = a[i]; m = k;}
	}
	cout << l << " " <<  m;
}

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

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

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 k;
 int n;
  cin>>n;
   int a[n];

     for(int i=0;i<n;i++){
         cin>>a[i];
     }
     int min=0;
     for(int p=0;p<n;p++){
         if(a[min]<a[p]){
             min=p;      
                        }}
k=a[min]+3;
int x[k];                        
     for(int i=0;i<k;i++){
         x[i]=0;
     }
     for(int i=0;i<n;i++){
         for(int j=0;j<k;j++){
              if(a[i]==j){
                x[j]++;
                         }
                                }
                         }
     int max=0;
     for(int m=0;m<k;m++){
         if(x[max]<x[m]){
             max=m;      
                        }
                
                            }
cout<<max<<" "<<x[max];
            }

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 main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int count[1000000]={0};
for(int j=0;j<n;j++)
{
for(int k=0;k<1000000;k++)
{
if(arr[j]==k)
{
count[k]++;
}
}
}
int maxi=count[0];
int ele=0;
for(int p=0;p<1000000-1;p++)
{
if(count[p+1]>maxi)
{
maxi=count[p+1];
ele=p+1;
}
}
cout<<ele<<" "<<maxi;


}

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;
bool checkf(int ai, int f)
{
	if(ai==f) return 1;
	else return 0;
}
bool checkr(int arr[], int n, int i)
{
	for(int j = 0; j < i; j++)
	{
	if (arr[i]==arr[j]) return 0;
	};
	return 1;
} 
int main()
{
	int n;
	cin >> n;
	int a[n]; int b[n];
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
	};
	for(int i = 0; i < n; i++)
	{
		a[i]=0;
	};
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(b[i]==b[j])
			{
				a[i]++;
			};
		};
	};
	int frequency = 0;
	for(int i = 0; i < n; i++)
	{
		frequency = max(a[i], frequency);
	};
	for(int i = 0; i < n; i++)
	{
		if (checkf(a[i], frequency) && checkr(b, n, i))
		{
			cout << b[i] << " " << frequency << '\n';
		};
		
	
	};
}

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



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

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


    
 }   
}

int j=0;
for(int i=0;i<20;i++){
j=max(j,b[i]);
}
int index=0;
for(int i=0;i<20;i++){
if(j==b[i])index=i;
}
cout << a[index] << " " << j;
}

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 major( int *a, int *b, int *n){
int n=0;
for (int i=0; i<n && a[i]; i=-1; i++){
b[i]=1;
for(int j= j+1; j<n; j++){
if(a[i]==a[j]){
b[j]++;
a[j]=1;
}
}
}
}
for (int i=0; n=0;i<n; a[i] != -1){
if ( a[i] i=-1){
if (b[n]< b[j]){
b[n]=0;
n=i;
}
}
}

int main(){
int n;
n>=1; n<20;
cin>>n;
}

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 max(int *counter,int n){
	int argmax=0;
	for(int i=0;i<n;i++){
		if(counter[argmax]<counter[i]) argmax=i;	
	}
	return argmax;
}

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

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 occurence(int arr[], int n, int j){
	int count = 0;
	for(int i = 0; i<n; i++){
		if(arr[i]==j) count += 1;
	}
	return count;
}

int max_occurence(int arr[], int n, int& winner){
	int max = 0;
	for(int i = 0; i<n; i++){
		int val = occurence(arr, n, arr[i]);
		if(max < val) {
			max = val;
			winner = arr[i];
		}
	}
	return max;
}

int main(){
	int n, winner;
	cin >> n;
	int arr[n];
	for(int i = 0; i<n; i++){
		cin >> arr[i];
	}
	int max_count = max_occurence(arr, n, winner);
	cout << winner << " " << max_count << endl;
	
}

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