CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
int p=2;
cin>>n;
int arr[n-1];
for(int i=0;i<n-1;i++){
	arr[i]=i+2;
	}
for(int j=1;j<n-1;j++){
	if(arr[j]%p==0){
		arr[j]=0;
		}
	}
for(int k=0;k<n-1;k++){
	while(arr[k]!=0){
		for(int i=2;i<n-1;i++){
			if(arr[k]%i==0){return arr[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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[n-1];
int v=0,x=0;
for(int i=0;i<n-1;i++){
a[i]=i+2;}
while(a[x]>0){
for(int i=x;i<n-1;i++){if(a[i]>0) a[v]=a[i]; break;}
for(int i=0;i<n-1;i++){
for(int b=2;b<n;b++){
if(a[i]==a[v]*b) a[i]=0; }
}
x=v+1;}
int g[n-1];
int e=0;
for(int i=0;i<n-1;i++){
if(a[i]>0){ g[e]=a[i]; e++;}}
int h=e;
for(int u=0;u<=h;u++){
cout<<g[u]<<" ";
if(u%5==4) cout<<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
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;

void makearray(int* a,int n1){
	for(int i = 0;i<n1-1;i++){
		a[i] = i + 2;
	}
}

void modifyarr(int* b,int n2){
	for(int i = 0;i<n2-1;i++){
		if(b[i] != 0){
			int p = b[i];
			for(int j = i+1;j<n2-1;j++){
				for(int k = 2;k<n2-1;k++){
					if (p*k == b[j]){b[j] = 0;break;}
				}
			}
		}
	}
}


int main(){
	int n; cin >> n;
	int arr[n-1];
	int counter = 0;
	makearray(arr,n);
	modifyarr(arr,n);
	for(int i = 0;i<n-1;i++){
		if (arr[i] !=0){
		counter += 1;
		cout << arr[i] << " ";}
		if(counter == 5){
		cout << endl;
		counter = 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: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main()
{
   int n,i,j,p,k=0;
   cin >> n;
   int ar[n-1];
   for(i=0;i<=n-2;i++)
  {
    ar[i]=i+2;
  }
for(i=0;i<=n-2;i++)
{
   p=ar[i];
   for(j=i+1;j<=n-2;j++)
   {
     if(ar[j]%p==0)
     ar[j]=j;
   }
}
for(i=0;i<=n-2;i++)
  {
    if(ar[i]!=i)
   {
    k++;
    if(k%5==0)
    cout << ar[i] << endl;
    else
    cout << ar[i] << " ";
   }
 else
 cout << ""; 
  }


  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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;

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

	int arr2[n]; int k=0;


	for(int p=2;p < n;)
	{

	for(int i=2; i*p <= n; i++)
		{
		 arr2[k] = i*p; k++;
		}

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

		
	for(int i = p-1; i<n-1; i++)
		{
		 	if(arr[i] != 0) { p = arr[i];break;}
		 	else if(arr[n-2]==0){p=n+1;}

		}

	


	}
 

	for(int i=0; i<n-1; i++)
		{
			if(arr[i] != 0)
			{
			  cout << arr[i] << " "; 
			}
		}

	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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main ()
{
int n;
cin>>n;
int a[n],i,j,c=0,k=0,f=0,p=0;
for(i=0;i<n-1;i++)
{
a[i]=i+2;
}
p=2;
for(i=0;i<n-1;i++)
{
if(a[i]!=1)
{
for(j=i+p;j<n-1;j+=p)
{
a[j]=1;
}
}
p++;
}
for(i=0;i<n-1;i++)
{
if(a[i]!=1)
{
cout<<a[i]<<" ";
f++;

if(f%5==0)
cout<<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
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
int a[n-1];
for(int i=0;i<n-1;i++){
	a[i]=i+2;
	}
for(int i=0;i<n-1;i++){
	if(a[i]!=0){
	int j=2;
	while(j*a[i]<=n){
	a[j*a[i]-2]=0;
	j++;
	}
	}
	}
cout<<2;
int q=1;
	for(int i=1;i<n-1;i++){
		if(a[i]!=0){
			if((q+1)%5==0){
			cout<<" "<<a[i]<<endl;
			q++;
			}
			else if(q%5==0){
			cout<<a[i];
			q++;}
			else{
			cout<<" "<<a[i];
			q++;
		}
	}
}
}

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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;


void mark_np (int p) {
int r =1;
	int n;
	// cout << n;
	int arr[n-1];

while ( r*p< (n-1) ) {      //mark np
arr[r*p]=0;
r++;}
}

int main () {
int n;
cin >> n;
int arr[n-1];
int p=2;
for (int i = 0; i<n-1; i++) {
arr[i]=p+i;      // make array, step 2
}


int j =1;
while ( j*p< (n-1) ) {      //mark np for p=2;
arr[j*p]=0;
j++;}

int l;
for(int k=0; k<n-1; k++) {
if (arr[k]==p){
l = k;                 // find the index of p }
}


int o = l;
int m;
for (m = l+1; m<n-1; m++) {
while (arr[m]!=0) {
o=m;}
}

p=arr[o]; // step 4

 mark_np (p);//repeated step 3


for (int q=0; q<n-1; q++) {
if (arr[q]!=0) {
cout << arr[q] << " "; }
else continue;
}

}}

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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	int arr[n+1] = {0};
	int p=2;
	bool b;
	while(p<n){
		for(int i=2*p; i <=n; i+=p)
			arr[i] = 1;   //0 - prime, 1 -composite

		b = false;         
		for(int i=p+1; i<=n; i++){
			if(arr[i] == 0){
				p = i;
				b=true;
				break;
			}
		}
		if(b == false)
			break;

	}
	int count = 0;
	

	for(int i=2; i<=n; i++){

		if(arr[i] == 0){
			count++;
			if(count == 5){
				cout<<i<<"\n";
				count = 0;
			}
			else{cout<<i<<" ";}
		}
	}
	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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;

void identify_primes (int n, int* primes) {
	primes[0] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if ((j % i) == 0) primes[j - 1] = 1;
		}
	}
}

int main() {
	int n; cin >> n;
	int primes[n];
	for (int i = 0; i < n; i++) primes[i] = 0;
	identify_primes (n, primes);
	
	int num = 0;
	for (int i = 0; i < n; i++) {
		if (primes [i] == 0 && num % 5 == 4) {
			cout << i + 1 << "\n";
			num += 1;
		} else if (primes [i] == 0) {
			cout << i + 1;
			num += 1;
			int chk = 0;
			for (int j = i + 1; j < n; j++) {
				if (primes [j] == 0) chk = 1;
			} if (chk) cout << " ";
		}
	}
}

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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;

void printprime(int n){
 int a[n-1],b[n-1];
 for(int i=0;i<n-1;i++){
  a[i]=i+2;b[i]=0;
 }

 for(int m=0;m<n-1;m++){
  if(b[m]==0){
   int p=a[m];
   int k=n/p;

   for(int c=m;c<n-1;c++){
    for(int j=2;j<=k;j++){
     if(a[c]==j*p) {b[c]=1;}
    }
   }
  }
 }

 int d=0;
 for(int l=0;l<n-1;l++){
  if(b[l]==0){
   d++;
   if(d%5==1){cout<<a[l];}
   else if(d%5==0){cout<<" "<<a[l]<<endl;}
   else {cout<<" "<<a[l];}
  }
 }
}


int main(){
 int n;cin>>n;

 printprime(n);

 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: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int t=0, j=0;
for(int r=2; r<=n; r++){
for(int i=2; i<r; i++){
if((r)%2==0){j++;}
}
if(j==0){cout<<r<<" ";}
}





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 find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>

using namespace std;

int main(){

int n;

cin >> n;

bool check_prime[n+1];

for(int i=2;i<=n;i++){

check_prime[i]=true;

}

int primecount =0;

for(int i=2;i<=n;i++){

if(check_prime[i]==false){continue;}

primecount++;

cout << i << " ";

if(primecount%5==0){cout << endl;}

int p=2;

while(p*i<=n){

check_prime[p*i] = false;

p++;

}

}

}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B