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>
#include<cmath>
using namespace std;
int main(){
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++){cin>>a[i];}
//inputted the array
//int b[n];int c[n];
//determine no of distinct elements

for(int i=0;i<n;i++){
	int x=1;
	for(int j=i+1;j<n;j++){
		if(a[j]==a[i]){
			int temp=a[j];
			a[j]=a[i+x];
			a[i+x]=temp;}
		}
	}
//for(int i=0;i<n;i++){cout<<a[i]<<' ';}
//determine distinct values
/*int val=a[0];
int c=1;
for(int i=0;i<n;i++){
	if(a[i]!=val){c++;}
	}
// c is number of distinct numbers
int ans[2*c];
int d=0;
int j=0;
for(int i=0;i<n;i++){
	if(a[i]==val){d++;}
	else{ans[j]=val;ans[j+1]=d;d=i;j=j+2;}
	}
for(int i=0;i<2*c;i++){cout<<ans[i];}
int i=0;
int max=0;
int val=a[0];
while(i<n){
	int c=0;
	if(a[i]==val){c++;}
	}
*/
int max=0;
int d=0;
int val=a[0];
for(int i=0;i<n;i++){
	if(a[i]==val){d++;}
	if(a[i]!=val || i==(n-1)){
		if(max<d){max=d;}
		d=0;val=a[i];
		}
	}
//cout<<max<<endl;


d=0;
val=a[0];
for(int i=0;i<n;i++){
        if(a[i]==val){d++;}
        
                if(max==d){cout<<val<<" "<<d<<endl;break;}
                //d=0;val=a[i];
                
        }



}

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 arr1[n];								//input array
	for(int i=0; i<n; i++){cin>> arr1[i];}
	
	int arr2[n];								//array of distinct elements
	int arr3[n]={0};							//array of frequency of distinct elements
	int distinct = 0;							//number of distinct elements
	
	for(int i=0; i<n; i++)
	{
		int found = 0; 
		for(int j=0; j<distinct; j++)
		{
			if(arr1[i]==arr2[j]){ arr3[j]+=1; found = 1; break;}
		}
		if(found == 0){arr2[distinct] = arr1[i]; arr3[distinct] = 1; distinct += 1; }
	}
	
	int maxindex=0;								//index of element with greatest frequency
	for(int j=0; j<distinct; j++){
		if(arr3[maxindex]<arr3[j]){maxindex = j;}
	}
	cout<< arr2[maxindex] << " " << arr3[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 a[n];
for (int i=0; i<n; i++) cin >> a[i];
int b[n]={0};
for (int i=0;i<n;i++){
for (int j=0;j<n;j++){
if (a[i] == a[j]) {
b[i] ++;
}
}
}
int maxindex = 0,c;
for (int i=0;i<n;i++){
if (maxindex < b[i]) {
maxindex = b[i];
c = i;
}
}
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;
void myswap(int *a, int *b){
int temp=*a;
*a=*b;
*b=temp;
}
int argmax (int *scores, int L){
int maxindex = 0;
for(int j=1; j<L; j++){
if(scores[maxindex] < scores[j]) maxindex = j;
}
return maxindex;
}
void selection_sort (int *data, int n){
for(int i=n; i>1;i--){
int maxindex = argmax(data,i);
myswap(&data[maxindex],&data[i-1]);
}
}
int main(){
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++){
	cin>>a[i];
	}
selection_sort(a,n);
int y=a[0];
int z=1;
for (int i=1;i<n;i++)
{if (y!=a[i]){ z++; y=a[i];}
}
int b[z];
int c[z];
for (int i=0;i<z;i++){b[i]=0;}
y=a[0];
int j=0;
for (int i=0;i<n;i++){
if (y==a[i]){ b[j]++;c[j]=a[i];}
else {j++;y=a[i];c[j]=a[i];b[j]++;}
}
int v=0;
for (int i=0;i<z;i++){
if (b[i]>=b[0]){b[0]=b[i];c[0]=c[i];}
}
cout<<c[0]<<" "<<b[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;
void input_array(float *score,int n)
{for(int i=0;i<n;i++) cin>>score[i];}
void print_array(float *hist,int n)
{for(int i=0;i<n;i++) cout<<i<<" "<<hist[i]<<endl
;}
int main()
{int i,j,n;
cin>>n;
float score[1000],hist[n];
input_array(score,n);
for(i=0;i<n;i++)hist[i]=0;
for(i=0;i<n;i++){
if(score[i]==0)hist[i]++;
else if(score[i]==1)hist[i]++;
if(score[i]==2)hist[i]++;}
print_array(hist,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 argmax (int *arr, int L){
int maxindex = 0;
for(int j=1; j<L; j++){
if (arr[maxindex] < arr[j]) maxindex = j;
}
return maxindex;
}


int count( int* arr,int n, int p){
int cnt=0;
for (int i=0; i<n; i++){
if (arr[i]==p) cnt++;
}
return cnt;} 



int main(){
int n;
cin>>n;
int arr[n];

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

int arr1[n];

for (int i=0; i<n; i++){
arr1[i] = count(arr,n,arr[i]);
}


cout<<arr[argmax(arr1,n)]<<" "<<arr1[argmax(arr1,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 f (int *A, int t)
{
 int maxindex = 0;
 for (int j = 1; j < t; j++)
 {
  if (A[maxindex]<A[t]) maxindex = j;
 }
 return maxindex;
}
int main()
{
 int n;
 cin>>n;
 int A[n];
 cin>>A[n];
 int hist[n];
 int maxindex;
 for (int i = 0; i < n; i++) hist[i] = 0;
 for (int l = 0; l < n; l++)
 {
  for (int j = l; j < n; j++)
  {
   if (A[l] == A[j]) 
   {
    hist[l] = hist[l] + 1;
   }
  }
 }
 for (int k = 0; k < n; k++)
 {
  cout<<hist[k]<<" ";
 }
 f (&hist[n], n);
 cout<<A[maxindex]<<" "<<hist[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: 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;
	void zero(int*a,int n){
	int i;
	for (int i=0;i<n;i++){
	a[i]=0;
				}
}
	void in(int*a,int n){
	int i=0;
	for(i=0;i<n;i++){cin>>a[i];}

}
	void out(int*a,int n){
        int i=0;
        for(i=0;i<n;i++){cout<<a[i];}

}

	



	int mode(int*a,int*b,int*c,int n){
	int i,j;
	for(int i=0;i<n;i++){
	b[i]=a[i];
}
	for( i=0;i<n;i++){
			for( j=0;j<n;j++){
				if(b[i]==a[j])
				{c[i]=c[i]++;
						}
					    }
}return i;
}








	int main()
{
	int a[100],b[100],c[100];
	int n,p;
	cin>>n;
	 zero(a,n);
    zero(b,n);
    zero(c,n);
	in(a,n);
	p=mode(a,b,c,n);
/*	out(a,n);
	cout<<" ";
	out(b,n);
	cout<<" ";
	out(c,n);*/
	cout<<a[p];
	cout<<c[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: 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 argmax(int* num,int n)
{
    int maxindex=0;
    for(int m=1;m<n;m++)
    {
       if(num[maxindex]<num[m])
       maxindex=m;
    }
    return maxindex;
}
int main(){
int n;
int num[20];
for(int i=0;i<20;i++)
{
 num[i]=0;
}
int a[20];
cin>>n;
for(int i=0;i<n;i++)
{
 cin>>a[i];
}
for(int i=n;i<20;i++)
{
 a[i]=0;
}
for(int i=0;i<n;i++)
{
 for(int j=i;j<n;j++)
 {
  if(a[i]==a[j])
  num[i]++;
 }
}
int index=argmax(num,n);
cout<<a[index]<<" "<<num[index];
}

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 maxnum1(int *arr,int l){
int maxindex=0;
for(int j=0; j<l;j++){
if(arr[maxindex]<arr[j])maxindex=j;}
return arr[maxindex];}


int num(int *arr,int n,int m){
int numtimes=0;
for(int j=0;j<m;j++){
if(arr[n]-arr[j]==0) numtimes=numtimes+1;}
return numtimes;}

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

int arr1[n];
for(int i=0;i<n;i++){
arr1[i]=num(arr,i,n);
}

int k= maxnum1(arr1,n);
int l=0;
while(l<n){
if(arr1[l]==k)break;
l++;}
cout<<arr[l]<<" "<<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>
#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 maxnum=0,maxcnt=0;
for (int i=0;i<n;i++)
{
int num=1;
for (int j=0;j<n;j++)
{if (a[i]==a[j] && i!=j) num+=1;}

if (num>1|| n==1)
{
if (num>maxcnt){ maxcnt=num; maxnum=a[i];}
}
}
cout<<maxnum<<" "<<maxcnt;

}

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 input[n];
	int freq[n];
	for(int i=0;i<n;i++)
	{
		cin>>input[i];
		freq[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
					if(input[i]==input[j])
			{
				freq[j]++;
			}

		}
	}
	int index=0,maxv=0;
	for(int i=0;i<n;i++)
	{
		if(maxv<freq[i])
		{
			index=i;
			maxv=freq[i];
		}
	}
	cout<<input[index]<<" "<<freq[index];

	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];
	int b[n][2];
	for(int i=0; i<n; i++){
		b[i][0] = -1;
		b[i][1] = -1;
	}
		
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	
	int f = 0;
	for(int i=0; i<n; i++){
		int j = a[i];
		int k = 0;
		for(int m=0; m<n; m++){
			if(b[m][0]>-1){
				if(j == b[m][0]){
					b[m][1]++;
					if(b[m][1] > f) f = b[m][1];
					break;
				}
			}
			else{
				b[m][0] = j;
				b[m][1] = 1;
				if(b[m][1] > f) f = b[m][1];
				break;
			}
		}		
		}

	for(int i=0; i<n; i++){
		if(b[i][1]==f) cout << b[i][0] << " " << f << endl;
	}
	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 arr[n];
	for(int i=0;i<n;i++)
	cin >> arr[i];
	for(int i=0;i<n-1;i++)
	{
		int max_ind=0;
		for(int j=0;j<n-i-1;j++)
		if(arr[max_ind]<arr[j])
		max_ind=j;
		if(arr[max_ind]>arr[n-i-1])
		{
			int temp=arr[max_ind];
			arr[max_ind]=arr[n-i-1];
			arr[n-i-1]=temp;
		}
	}
	int Max=0,c=0,val=arr[0];
	for(int i=0;i<n;i++)
	{
		if(arr[i]==val)
		c++;
		else
		{
			if(c>Max) Max=c;
			val=arr[i];
			c=1;
		}
	}
	if(c>Max)
	cout << arr[n-1] << ' ' << c << '\n';
	else
	for(int i=0;i<n-Max+1;i++)
	if(arr[i]==arr[i+Max-1])
	cout << arr[i] << ' ' << Max << '\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 main ()
{
	int n;
	cin >> n;
	int a[n], max = 0, b[n], c[n];
	for(int i = 0; i < n; i++)
	cin >> a[i];

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

		int t = a[p];
		a[p] = a[i];
		a[i] = t;
	}
	*/

	int l = 0, x = 0, t = 0;
	for(int i = 0; i < n; i++)
	{
		bool f = false;
		for(int j = 0; j < x; j++)
			if(b[j] == a[i])
			{
				f = true;
				break;
			}
		if(f) continue;


		b[x] = a[i];
		c[x] = 0;
		for (int j = i; j < n; j++)
		{
			if(a[j] == b[x])
				c[x]++;
		}
		if(c[x] > max)
			max = c[x];
		x++;

		/*
		if(a[l] != a[i])
		{
			b[x] = a[l];
			c[x] = i-l;
			if(c[x] > max) max = c[x];
			x++;
			l = i;
		}
		*/
	}

	for(int i = 0; i < x; i++)
		if(c[i] == max) 
			cout << b[i] << " " << c[i] << 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: B