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 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 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 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 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;
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: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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;
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: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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;

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: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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 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: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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 arr[n];
	for(int i = 0; i < n;i++){
		cin >> arr[i];
	}
	int counttemp,temp,max;
	temp = 1;

	for(int j = 0;j< n;j++){
		counttemp = 1;
		if(n > 1){
			for(int k = (j + 1);k < n;k++){
				if(arr[j] > 0){
					if(arr[j] == arr[k]){
						arr[k] = -1;
						counttemp = counttemp + 1;
				}
				}
			}

		}
		if(counttemp > temp){
			temp = counttemp;
			max = arr[j];
		}
	}

if(n == 1){
	max = arr[0];
}
	cout << max << " " << temp;

}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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 <simplecpp>

main_program{
	int n;
	cin>>n;
	long long int val[n], rep[n], check[n], maxnum=0;
	for(int i=0; i<n; i++){
		cin>>val[i];
		rep[i]=0;
		check[i]=0;
	}
	for(int i=0; i<n; i++){
		if(check[i]==0){
			for(int j=0; j<n; j++){
				if(val[i]==val[j]){
					rep[i]++;
					check[j]=1;
				}
			}
		}
		check[i]=0;
	}
	for(int i=0; i<n; i++){
		maxnum=max(maxnum, rep[i]);
	}
	for(int i=0; i<n; i++){
		if(rep[i]==maxnum && check[i]==0){
			cout<<val[i]<<" "<<rep[i]<<endl;
		}
	}
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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 I[n];
int R[n];
for(int i=0;i<n;i++){int x;cin>>x;I[i]=x;}
for(int i=0;i<n;i++)
{
int a=I[i];
int r=0;
for(int j=0;j<n;j++)
{
if(a==I[j]){r++;}
}
R[i]=r;

}

int k=0;
for(int i=0;i<n;i++){if(R[i]>R[k])k=i;}

cout<<I[k]<<" "<<R[k];


}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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, temp;
   cin>>n;
   int arr[100];
   int ele[100];
   int count[100], k=0;
   for(int i=0;i<n;i++){
     cin>>arr[i];
     count[i]=0;
     ele[i]=0; }
   for(int i=0;i<n;i++){
    if(arr[i] != 0){
     for(int j=i+1;j<n;j++){
         if(arr[i]==arr[j]){ count[k]++; } } 
     ele[k]=arr[i]; count[k]++;  k++; } }

     int maxcount=count[0];
   for(int i=0;i<k;i++){
      if(maxcount<=count[i]){ maxcount=count[i]; temp=i; } }

   cout<<ele[temp]<<" "<<count[temp];
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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 (float *arr, int L){
int maxindex = 0;
for(int j=1; j<L; j++){
if(arr[maxindex] < arr[j]) maxindex = j;
}
return maxindex;
}
void selection_sort (float *data, int n){
for(int i=n; i>1;i--){
int maxindex = argmax(data,i); 
elements (from index 0 to index i-1)
myswap(&data[maxindex],&data[i-1]);
}
}
#define MAXSIZE 12
int main()
{int n;
cin>>n;
int arr[n];
for (i=0;i<n;i++)
{cin>>arr[i];}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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,d=0;
cin>>n;
int arr[n],arr1[n];
for(int i=0;i<n;i++){
arr1[i]=1;
}
for(int i=0;i<n;i++){
cin>>arr[i];
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(arr[i]==arr[j]) arr1[i]++;
}
}
cout<<endl;
int max=arr1[0];
for(int i=0;i<n;i++){
if(arr1[i]>max) max=arr1[i];
}
for(int i=0;i<n;i++){
if (arr1[i]==max){
cout<<arr[i]<<" "<<arr1[i]<<endl;
}
}

}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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:
//22B1068
//finding mod lol

#define VALUE 0
#define TIMES 1

#include <iostream>
using namespace std;

int main(){
	bool found = false; //will be used to check if the vaue just entered had already been entered before
	int n, counter = 0, max = 0, index;
	cin >> n;
	int a[n], b[n][2];           //b[i][VALUE] will store the value of a[i] and b[i][TIMES] will store the number of repetitions
	for (int i = 0; i < n; i++){
		b[i][VALUE] = -1;   //initialising so that garbage values don't pose a problem. For b[i][TIMES], initialisation will happen in line 27
		cin >> a[i];
		found = false;
		for (int j = 0; j < counter; j++){
			if(b[j][VALUE] == a[i]){
				b[j][TIMES]++;
				found = true;
				break;
			}
		}
		if (found == false){
			b[counter][VALUE] = a[i];
			b[counter][TIMES] = 1;
			counter++;

		}

			
			
	}


	for (int i = 0; i < counter; i++ ){ //finds max TIMES and then eventually prints it
		
		if (max < b[i][TIMES]){
			max = b[i][TIMES];
		}
			

	}

	for (int i = 0; i < counter; i++ ){
		if(b[i][TIMES] == max)
			cout << b[i][VALUE] << " " << b[i][TIMES] << "\n";
	} 
		
		
			




}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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,i,j;
cin>>n;
int ar[n];
for(i=0;i<n;i++)
cin>>ar[i];
int d=0,max=ar[0],c;
for(i=0;i<n;i++)
{
c=0;
for(j=0;j<n;j++)
{
if(ar[j]==ar[i])
c++;
}
if(c>d)
{
d=c;
max=ar[i];
}
}
cout<<max<<" "<<d;
	}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
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,i,j,val=0,c=0;
 cin>>n;
 int a[n],b[n];
 for(i=0;i<n;i++)
   {cin>>a[i];
      b[i]=0;       }
 for (i=0;i<n;i++)
{ for(j=0;j<n;j++)
   {if(a[i]==a[j]) b[i]++;}
}
for(i=0;i<n;i++) 
{if(val<b[i]){ val=b[i];
c=i;}
}
cout<<a[c]<<" "<<val;
}

Grading criterion: Space Complexity
Rating A: Done in O(1) space
Rating B: Done in O(n) space
Rating C: Anything worse or wrong
Rating D: 0
Assigned grade: B