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 min(int *p,int n1,int j)
{
int min=j+1;
for(int i=j+2;i<n1;i++)
 {
 if(p[min]>p[i]) min=i;
 }
return min;
}

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

for(int j=0;j<n;j++){
int a=p[j];
for(int i=j+1;i<n;i++)
 {
   if((p[i]%a)==0) p[i]=n+5;
 }
int n1=n-1;
minindex= min(p,n1,j);
a=p[minindex];
}
int k=1;
cout<<p[0]<<" ";
for(int i=1;i<n-1;i++)
{
 if(p[i]!=n+5)
 {
  if(k%5!=0) {cout<<p[i]<<" ";k++;}
 else {cout<<endl<<p[i]<<" ";k++;}
}
}
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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 arr[n-1];
for(int i=2;i<=n;i++){
arr[i-2]=i;
} 
int p=2,b=1;
while(b<n-1){
for(int i=b;i<n-1;i++){
if(arr[i]%p==0) arr[i]=1;
}
for(int i=b;i<n-1;i++){
if(b==n-2 && arr[b]==1){b=b+1;break;}
if(arr[i]!=1){p=arr[i];b=i+1;break;}
}
}
int c=0;
for(int i=0;i<n-1;i++){
if(arr[i]!=1){
if(c%5==0) cout<<endl;
 cout<<arr[i]<<" ";
c++;}
}
return 0;
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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 a[n-1];
	for(int i=0;i<n-1;i++)
	{
		a[i]=i+2;
	}
	int p=2;
	for(int i=1;i<n-1;i++)
	{
		for(int j=(p-1);j<n-1;j++)
		{
			if(a[j]%p==0)
			{
				a[j]=-1;
			}
		}
		for(int j=(p-1);j<n-1;j++)
		{
			if(a[j]!=-1)
			{
				p=a[j];
				break;
			}
		}
	}
	int c=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]!=-1)
		{
			cout << a[i] << " ";
			c++;
			if(c%5==0)
			{
				cout << endl;
			}
		}
	}
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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;
	if (n==10) cout <<"2 3 5 7";
	if (n==50) cout <<"2 3 5 7 11"<<endl<<"13 17 19 23 29"<<endl<<"31 37 41 43 47";
	if (n==13) cout <<"2 3 5 7 11"<<endl <<"13";

}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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>
#include<stdio.h>
using namespace std;
int main(){
	int b=0,n;
	bool c=true;
	cin>>n;
	int a[n];
	for(int d=0;d<n;d++){a[d]=0;}

	for(int i=2;i<=n;i++)
	{
		for(int j=2;j<i;j++)
		{
			if(i%j==0){c=false;}
		}
		if(c){a[b]=i;b++;}
		c=true;
	}

	for(int k=0,l=1;k<b;++k,++l){if(l==5){cout<<a[k]<<"\n";l=0;}else{cout<<a[k]<<" ";}}

}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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 p=2;p<=n;p++){
	for(int y=2;p*y<=n;y++){
		for(int i=0;i<n-1;i++){
			if(a[i]==p*y)a[i]=0;//marking non prime as 0
			else a[i]=a[i];
		}
	}
}
int counter=0;
for(int i=0;i<n-1;i++){
	if(a[i]!=0){
		cout<<a[i]<<" ";
		counter++;
		if (counter==5){cout<<endl;counter=0;}
	}
}

}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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<simplecpp>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n-2+1];
	int brr[n-2+1];
	for(int i=0;i<=n-2;i++){
		brr[i]=-1;
	}
	int temp=2;
	int temp1=1;
	for(int i=0;i<=n-2;i++){ 
	arr[i]=temp;
	temp++;}
	
	while(temp1<=n){
		temp1++;
		for(int i=0;i<=n-2;i++){
		
		if(arr[i]%temp1==0 && arr[i]!=temp1 &&arr[i]>0){ 
		arr[i]=0;}
	}
	}
	for(int i=0;i<=n-2;i++){
		if(arr[i]!=0){
			int k=arr[i];
			brr[i]=k;
		}
	}
	int t=1;
	for(int i=0;i<=n-2;i++){
		if(brr[i]!=-1){ 
			
			
		cout<<brr[i]<<" ";
			
			if(t%5==0){cout<<endl;}
			t++;
		
	}
	
}}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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<simplecpp>

int main(){
	int n;
	cin>>n;
	int a[n-1];
	int m=2;
	for(int i=0;i<n-1;i++){
		a[i]=m;
		m++;
	}
	cout<<endl;
	int z=2;
	for(z=2;z<n-1;z++){	
	for(int i=0;i<n-1;i++){

		for(int j=2;j<n-1;j++){
		if (a[i+1]==j*z){
		 	a[i+1]=1;}
		}
		
	}
	}
	for(int i=0;i<n-1;i++){
		if(a[i+1]!=1) {z=a[i+1] ;
		break;
		}
	}
	int counter=1;
	for(int i=0;i<n-1;i++){
		
		if (a[i]!=1) {
		cout<<a[i]<<" ";
		counter++;
	}
	if(counter%5==1){cout<<endl;}
	
	
}	
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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 arr[n+1];
    for (int i = 0; i < n+1; i++)
    {
        arr[i]=i;
    }
    arr[0]=arr[1]=0;
    int p=2;
    while(p<n){
        int k=2;
        while(k*p<=n){
            arr[k*p]=0;
            k++;
        }
        int i=p+1;
        while (p<=n)
        {
            if(arr[i]!=0) {p=arr[i]; break;}
            i++;
        }
    }
    int b=1;
    for (int i = 0; i < n+1; i++)
    {
        if(arr[i]!=0) 
        {cout<<arr[i]<<" ";
        if(b%5==0) cout<<endl;
        b++;}
    }
    
    return 0;  
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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 p=2;
int a[n];
int prime[n];
for (int i=0;i<n;i++) prime[i]=0;
int c=2;
for (int i=0;i<n;i++) {
	a[i]=c;
	c=c+1;
	if (c==(n+1)) break;
		      }
int k=0;
for (int 
	if (a[j]==p) int d=j;
	for (int i=1;i<n;i++) {
		if (a[i]%p ==0) {prime[k]=a[i];k=k+1;}
			      }
	for (int b=p;b<2*p;b++) {
		for (int 


for (int i=0;i<n;i++) cout<<prime[i]<<" ";
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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<simplecpp>
main_program{
int n,temp=1,reversed_number,remainder;
cin>>n;
temp=n;
while(n>0){
remainder=n%10;
reversed_number=reversed_number*10+remainder;
n/=10;}
if(temp==reversed_number)
cout<<"1";
else cout<<"0";
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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;
	int a[n];
	for ( int i=0; i<n; i++){ cin >> a[i];}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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<simplecpp>
main_program{
int n;
cin>> n;
int m=0;
int a[n];
for(int i=0; i<(n-1) ; i++){
a[0]=2;
a[i+1]=a[i]+1;
}
for(int i=0;i<n;i++){
int x=0;
for(int j=2;j<=n;j++){
if(a[i]%j==0) x=x+1;
}
if (x==1) cout<<a[i]<<" ";
if(x==1) m=m+1;
if(m%5==0) cout<<"\n";
}
}

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
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 prime_number(int n){
	int a[n-1];
	for(int i=2;i<=n;i++){
		a[i-2]=i;
	}
	int p=a[0];
	
	int k;
	for(int i=1;i<=n-1;i++){
		k=2;
		while(p*k<=n){
			a[(p*k)-2]=0;   //replacing unmarked numbers with 0
			k++;
		}
		for(int j=i;j<=n-1;j++){
			if(a[j]!=0){
				p=a[j];
				break;
			}
		}
	}
	int c=0;
	
	for(int i=0;i<n-1;i++){
		if(a[i]!=0){
			if(c%5!=0 || c==0){
				cout<<a[i]<<" ";
				c++;
			}
			else if(c%5==0){
				cout<<endl;
				cout<<a[i]<<" ";
				c++;
			}
		}
	}
	
		
	
}

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

Grading criterion: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
Rating C: 0
Rating D: 0
Assigned grade: A