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;
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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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 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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
Rating D: 0
Assigned grade: C
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: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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>
#include<cmath>0

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=1;i<n-1;i++)	if (A[i]%2==0) A[i]=0;
	
for (int i=0;i<n-1;) {while (A[i+1]==0) i++;
	i=i+1; 
	for (int j=i+1;j<n-1;j++)  if(A[j]%A[i]==0) A[j]=0;}
	int j=0;
for(int i=0;i<n-1;i++) if (A[i]!=0) {j++; cout<<A[i]<<" "; if (j%5==0) cout<<endl;}

	
	
	
	
	
	
	
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
int r=(n-1);
int q[r];
for(int i=0; i<r; ++i)
{
q[i]=(i+2);
}
int p;
for(int j=0;j<n;++j)
{
p=q[j];
if(p==0){continue;}
else
{
for(int i=j+1;i<r;++i)
{
if((q[i]%p)==0){q[i]=0;}
}
}
}
int h[500];
for(int i=0;i<500;++i){h[i]=0;}
int o=0;
for(int k=0;k<500;++k)
{
for(o=o;o<r;++o)
{
if(q[o]==0){continue;}
else {h[k]=q[o];o+=1;break;}
}
}
for(int u=0;u<500;++u)
{
if(h[u]==0){ continue;}
else if((u%5)!=4){cout<<h[u]<<" ";}
if ((u%5)==4){cout<<h[u]<<endl;}
}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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];
int primechecker[n-1];
for(int i=0;i<n-1;i++)
{arr[i]=i+2;
primechecker[i]=1;
}
for(int i=0;i<n-1;i++)
{int p=arr[i];
int q=2*p;
while(q<=n)
{for(int j=0;j<n-1;j++)
	{if(q==arr[j])
		{
		primechecker[j]=0;
		}
	}
 q=q+p;
}
}
int linebreaker=0;
for(int i=0;i<n-1;i++)
{if(primechecker[i]==1){cout<<arr[i]<<" ";linebreaker++;}
if(linebreaker==5){cout<<endl;linebreaker=0;}
}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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 () {
	long int n;
	cin >> n;
	long int no[n - 1], mark[n - 1];
	for (int i = 0; i < n - 1; i++) {
		no[i] = 2 + i;
	}

	for (int i = 0; i < n - 1; i++) {
		mark[i] = 0;
	}
	for (int p = 2; p < n + 1;) {
		for (int i = 2; i*p < n + 1; i++) {
			for (int j = 0; j < n - 1; j++) {
				if (no[j] == p) {
					for (int k = j + 1; k < n - 1; k++) {
						if (no[k] == i*p) mark[k] = -1;
					}
				}
			}
		}
		long int beech = p;
		for (int i = 0; i < n - 1; i++) {
			if (no[i] == beech) {
				for (int j = n - 1; j > i; j--) {
					if (mark[j] == 0) p = no[j];
				}
			} 
		}
	}
	for (int i = 0; i < n - 1; i++) {
		if (mark[i] == 0) cout << no[i] << " ";
	}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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 gcd(int m,int n)
{int remainder;
while(m%n!=0){
remainder=m%n;
m=n;
n=remainder;}
return n;}

int main()
{
int l;
cin>>l;
int f=1,a[l],b[l];
for(int i=0;i<l;i++)
a[i]=i+2;

for(int i=0;i<l;i++)
b[i]=0;

while(f<l)
{
if(gcd(a[f],2)==1)
{b[f]=a[f];}
f=f+1;}
for(int i=0;i<l;i++)
{while(b[i]>0)
cout<<b[i]<<" ";}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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,p;
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]!=1)
{p=a[i];
for(int j=(p+1);j<=n;j++)
{if(j%p==0)
{a[j-2]=1;}
}
}

}
int flag=0;
for(int i=0;i<(n-1);i++)
{

if(a[i]!=1)
{cout<<a[i];
flag++;
if(flag%5!=0)
{cout<<" ";
}
if(flag%5==0 && flag!=0)
{
cout<<endl;
}
}
}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
Rating D: 0
Assigned grade: B