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

int main () 
{
int N = 1e6+2;
int n; cin >> n;
	int arr[n]; 
	for (int i=0; i<n; i++) {cin >> arr[i];}
	
	int s[N]; 
	for (int j=0 ; j<N ; j++) {s[j]=0;}
	
for (int i=0 ; i<n ; i++) 
	{
	s[arr[i]] ++ ;   
	}
	
int e = max(s,N);

for (int j=0 ; j<N ; j++) {
if (s[j]==e) cout <<j; 
}	
cout << " " << e;
}

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

void mostrec(int* addans, int n){
int val=0;
  for(int k=0;k<n;k++){
  int j=0;
    for(int i=0;i<n;i++){
    if (addans[k]==addans[i]){j++;}
    }
  if(j>val){val=k;addans[n+1]=j;}
  }
addans[n]=addans[val];
}

int main(){
int n;
cin>>n;
int addans[n+2];
addans[n]=addans[n+1]=0;
for(int i=0;i<n;i++){
cin>>addans[i];
}
mostrec(addans,n);
cout<<addans[n]<<" "<<addans[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: 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>
#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 l[n];
for(int h=0;h<n;h++){l[h]=0;}
for(int k=0;k<n;k++){
for(int m=0;m<n;m++){if(a[k]==a[m]) l[k]++;}
}
int mxm=0;
for(int t=0;t<n;t++){
mxm=max(l[t],mxm);
}
for(int p=0;p<n;p++){
if(l[p]==mxm) {cout<<a[p]<<" "<<l[p];break;}
}
}

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=i+1){
cin>>a[i];}
int b[n];
for(int l=0;l<n;l=l+1){
b[l]=0;}
for(int x=0;x<n;x=x+1){
for(int y=0;y<n;y=y+1){
if(a[x]==a[y]){b[x]=b[x]+1;}}}
int max=0;
for(int z=0;z<n;z=z+1){
if(b[max]<b[z])max=z;}
cout<<a[max]<<" "<<b[max];}

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 s[n];
	for(int i=0;i<n;i++){cin>>s[i];}
int r[n];
	for(int i=0;i<n;i++){int k=0;
	for(int j=i;j<n;j++){
		if(s[j]==s[i]){k=k+1;}
	}
r[i]=k;}
int max=0;
	for(int l=0;l<n;l++){
		if(r[l]>r[max]){max=l;}
	}
for(int l=0;l<n;l++){
		if(r[l]==r[max]){cout<<s[l]<<" "<<r[max]<<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;

void major (int *a, int *b, int n){
	for (int i = 0; i < n; i++){
		if (a[i] != -1){
			b[i] = 1;
			for (int j = i+1; j < n; j++){
				if (a[i] == a[j]){
					b[i]++;
					a[j] = -1;
				}
			}
		}
	}
	for (int i = 0, m = 0; i < n; i++){
		if (a[i] != -1){
			if (b[m] < b[i]){
				b[m] = 0;
				m = i;
			}
			else if (b[i] < b[m]){
				b[i] = 0;
			}
		}
	}
}

int main(){
	int n = 0;
	cin >> n;
	int a[n], b[n];

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

	major (a, b, n);

	for (int i = 0; i < n; i++){
		if (b[i] != 0){
			cout << a[i] << " " << b[i] << "\n";
		}
	}

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

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 arr[n], freqarr[n];
int maxindex=0, maxfreq=0;
int i, j;

for(int a=0;a<n;a++){
	cin>>arr[a];
	freqarr[a]=0;
	}
for(int z=0;z<n; z++){
	if(arr[z]==arr[0]){
		maxfreq++;
}
}
for(i=0; i<n; i++){
	for(j=0; j<n; j++){
		if(arr[i]==arr[j]){
			freqarr[i]++;
		}
	}
	
		if(freqarr[i]>maxfreq){
			maxindex=i;
			maxfreq=freqarr[i];
		}
		
	}

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

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>
#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: 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 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: 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] ;
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: 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 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: 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 *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: 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 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: 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