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,m=1,a=0;
cin>>n;
int arr[20],num[40];
for(int i=0;i<n;i++){
cin>>arr[i];
}
/*cout<<n;
for(int i=0;i<n;i++){
cout<<arr[i];
}*/

/*for(int i=0;i<n;i++){
if (i==0){for(int j=i+1;j<n;j++){
if(arr[j] == arr[i]) m++;}
num[a]=arr[i];
num[a+1]=m;
a=a+2;
m=1;
}

else {for(int k=0;k<i;k++)
if(arr[k]!=arr[i]){ 
for(int j=i+1;j<n;j++){
if(arr[j] == arr[i])m++;}
num[a]=arr[i];
num[a+1]=m;
a=a+2;
m=1;
}
else break;
}
}
for(int i=0;i<=a;a=a+2)
cout<<num[i]<<num[a+1];*/
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(arr[j]==arr[i]) m++;
}
num[a]=arr[i];
num[a+1]=m;
m=1;
a=a+2;
}
/*for(int i=0;i<2*n;i=i+2)
{cout<<num[i]<<num[i+1];}*/
int maxindex=1;
for(int i=1;i<2*n;i=i+2){
if(num[maxindex]<num[i]) maxindex=i;
}
for(int i=1;i<2*n;i=i+2){
  if(num[i]==num[maxindex]){
cout<<num[i-1]<<" "<<num[maxindex]<<endl;
}
}
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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];
	for(int i=0; i<n; i++)
		cin >> a[i];
	int freq[n]={0};
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			if(a[i]==a[j])
				freq[i]++;
		}
	}
	int index=0;
	int max=0;
	for(int i=0; i<n; i++)
	{
		if(freq[i]>max)
		{
			index=i;
			max = freq[i];
		}	
	}
	cout << a[index] <<" "<<max<<endl;
	
	return 0;
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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>
void swap (int *a, int *b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}
int argmax (int *seq1, int L)
{
        int maxindex = 0;
        for(int j=1; j<L; j++){
                if(seq1[maxindex] < seq1[j]) maxindex = j;
        }
        return maxindex;
}
void selection_sort (int *data, int n)
{
    for(int i=n; i>1;i--)
    {
        int maxindex = argmax(data,i);
        swap(&data[maxindex],&data[i-1]);
    }
}
main_program
{
int n1;
cin>>n1;
int seq[n1];
for(int i=0;i<n1;i++)
	{
	cin>>seq[i];
	}
cout<<endl;
selection_sort(seq,n1);

int a[n1]={0};
a[0]=1;
for(int i=1;i<n1;i++)
	{
	int j=1;
	if (seq[i]==seq[i-1])
		{
		while (seq[i]==seq[i-1])
			{a[j]++;}
		}
	j=j+1;	
	}
int k=sizeof(a);
int s=argmax(a,k);
cout<<s;
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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 maxn=0;
int maxfreq=0;
int x=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
if(a[i]>maxn)
maxn=a[i];
}
for(int i=0;i<=maxn;i++)
{
int freq=0;
for(int j=0;j<n;j++)
{
if(a[j]==i) freq++;
}
if(freq>maxfreq)
{
maxfreq=freq;
x=i;
}
}
cout<<x<<" "<<maxfreq;
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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 cin_numbers(int *A, int n){
for(int i=0; i<n; i++) cin>>A[i];
}


void create_histogram(int *A,int *freq,int n){
for (int i=0; i<n; i++) {
	for (int j=0; j<n; j++){
		if(A[j]==A[i]) {
		freq[i]++;
		}
	}
	}
}

int argmax (int *freq, int n){
int maxindex = 0;
for (int i=1;i<n;i++) {
	if (freq[maxindex] < freq[i]) maxindex = i;
}
return maxindex;
}

void swap(int &a, int &b){
int temp = a;
a=b;
b = temp;
}

void selectionsort(int *freq, int n){
for (int i=n; i>0; i--){
	int maxindex = argmax(freq,i);
	swap(freq[maxindex],freq[i-1]);
	}
}


int main(){
int n; cin>>n;
int A[n]; 
cin_numbers(A,n);
int freq[n];int C[n];
for (int i=0; i<n: i++) freq[i] = 0;
create_histogram(A,freq,n);
for (int i=0; i<n;i++){
	C[i] = freq[i];
selectionsort(freq,n);
int y = freq[n-1];
for (int i=0; i<n;i++){
	if (freq[n-1]==C[i])
	return [i];
}
cout<<A[i]<<" "<<freq[n-1];
}
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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;
#include<cmath>

void f(int* A,int N){
	int maxnum=0;
	int mi=0;
	for(int j=0;j<N;j++){
		int k=1;
		for(int i=j+1;i<N;i++){
			if(A[j]==A[i]){
				k++;
			}
		}
		if(k>maxnum){
			maxnum=k;mi=j;
		}
	}
	cout<<A[mi]<<" "<<maxnum;
}

int main(){
	int N;cin>>N;
	int A[N];
	for(int j=0;j<N;j++){
		cin>>A[j];
	}
	f(A,N);
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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 <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int> v;
 for (int i=1;i<=n;i++)
 {
 int temp;
 cin>>temp;
 v.push_back(temp);
 }

map<int,int> count;

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

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

int max=-2121212121;
int key;

for(int i=0;i<n;i++)
 {
  if(count[v[i]]>max)
  {
   key=v[i];
   max=count[v[i]];
  }
 }

cout<<key<<" "<<count[key];
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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;
int maxindex=0;
cin>>n;
int a[n];
int hist[n];
for(int i=0;i<n;i++)
{
hist[i]=0;
}
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int j=0;j<n;j++)
{
	for(int i=0;i<n;i++)
	{
	if(a[j]==a[i])
	hist[j]=hist[j]+1;
	}
}
for(int i=1;i<n;i++)
{
if(hist[maxindex]<=hist[i])
maxindex=i;
}
cout<<a[maxindex]<<" ";
cout<<hist[maxindex];
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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 *scores, int L){
int maxindex = 0;
for(int j=1; j<L; j++){
if(scores[maxindex] < scores[j]) maxindex = j;
}
return maxindex;
}
int main(){
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];
    int k;      
    k=A[argmax(A,n)];
    int a[k];
    for(int i=0;i<k;i++) a[i]=0;
    for(int j=0;j<n;j++){
    for(int i=0;i<k;i++){
       if (A[j]==i+1) a[i]=a[i]+1;
}
}   cout<< argmax(a,k)+1 <<" "<< a[argmax(a,k)] ;
    return 0;
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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];
for(int i=0;i<n;i++)
{cin>>input[i];}
int number[9999];
for(int i=0;i<9999;i++)
{number[i]=0;}
for(int i=0;i<n;i++)
{
for(int j=0;j<9999;j++)
{
if(input[i]==j) {number[j]++;}
else continue;
}
}
int maxval=0;
for(int i=1;i<9999;i++)
{
if(number[i]>number[maxval]) {maxval=i;}
else continue;
}
cout<<maxval<<" "<<number[maxval];
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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 count[n];
for (int j=0;j<n;j++)
{
count[j]=0;
}
for (int k=0;k<n;k++)
{
for (int l=0;l<n;l++)
{
if (a[k]==a[l])
{
count[k]=count[k]+1;
}
}
}
int mod=0, t;
for (int m=0;m<n;m++)
{
mod=max(mod,count[m]);
}
if (count[t]==mod)
{
cout << a[t] << " " << mod << '\n';
}
}

Grading criterion: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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];}
//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: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
Assigned grade: D
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: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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];
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: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
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 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: N^2 Algorithm
Rating A: Fully Correct
Rating B: If used higher time complexity or partially correct
Rating C: 0
Rating D: Code Not There or Totally Wrong
Assigned grade: A