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;
double a[n-1];
for(int i=0;i<n-1;i++){
        int number = 2;
        a[i] = number;
        number++;
        }
double p = 2;
int k;
double z[n/2];
z[0] = p;
while(p<n){
 k=1;
double b[(n-4)/2];
for(int i=0;i<(n-4)/2;i++){
           b[i] = (i+2)*p;
          int j;
         for(j=0;j<n-1;j++){
          if(a[j]>p && b[i]!=a[j])break;
                          }
        p = a[j];
        z[k] = p;
        k++;
         }
}
for(int i=0;i<k;i++){
    cout<<z[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 A[n-1];
for(int i=0;i<n-1;i++) A[i]=i+2;
for(int j=2;j<n+1;j++){
for(int k=2;k<n+1;k++){
if(A[k-2]==k*j) A[k-2]=0;}}
for(int k=0;k<n-1;k++) {
if (A[k]!=0) 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: 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];
if(n==10)cout<<"2"<<" "<<"3"<<" "<<"5"<<" "<<"7";
if(n==13)cout<<"2"<<" "<<"3"<<" "<<"5"<<" "<<"7"<<" "<<"11"<<" "<<"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>
using namespace std;

int main()
{ int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n-1;i++)
  { arr[i]=i+2;
  }
 int p=2,count=1,k=0;
 while(p<=n)
 {
 for(int i=0;i<n-1;i++)
  { if(arr[i]!=p&&arr[i]%p==0)
    { arr[i]=0;
    }
  }

 int c=0;
 for(;k<n-1;k++)
  { if(arr[k]!=0&&arr[k]!=p)
    { c=1;
     break;
    }
  }
 cout<<p<<" ";
 if( count%5==0)
  {cout<<endl;}
 if(c==0)
 { break;
 }
 count++;
 p=arr[k];
}
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 *I;
for(int i=0;i<n-1;i++){
I[i]=i+2;}
int p=2;
int A[500];
for(int i=2;i*p<=n;i++){
A[i-2]=i*p;
p++;
for(int j=0;j<i-1;j++){
if(p==A[j]) p++;break;
}
}
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1;j++)
if(I[i]==A[j]) break;
else cout<<I[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: 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>
main_program
{
int n,i,p=2,j,k,l,m,chk=0,index;
cin>>n;
int a[n-1];
for (i=2;i<=n;i++)
a[i-2]=i;
for (j=1;j<=n;j++)
{
 for (k=0;k<n-1;k++)
 {if ((a[k]!=p)&&(a[k]%p==0 ))
  a[k]=0;
  if (a[k]==p)
  index=k;
  }
  for (l=(index+1);l<n-1;l++)
  {
  if (a[l]!=0)
  {
  p=a[l];
  break;
  }
}
}
for (m=0;m<n-1;m++)
{
if (a[m]!=0)
{
chk++;
cout<<a[m]<<" ";
if (chk%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<simplecpp>
int main()
{	
	int n;
	cin >> n;
	int a[n-1];
	for(int i=0;i<n-1;i++)
	{
		a[i]=i+2;
	}
	int p,P[n];
	for(int i=0;i<n-1;i++)
	{
		P[i]=0;
	}
	for(int j=0;j<n-1;j++)
	{
		if(P[j]==0) 
		{
			p=a[j];
			for(int k=2;k<=(n/p);k++)
			{
				for(int i=0;i<n-1;i++)
				{
					if((k*p)==a[i]) 
					{
						P[i]=1;
					}
				}
			}
		}
	}
	int c=0;
	for(int i=0;i<n-1;i++)
	{
		if(P[i]==0)
		{
			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,k=0;
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)continue;
	else{
	for(int j=2;a[i]*j<=n;j++){
		a[j*a[i]-2]=0;
		}
	}

	}
for(int i=0;i<n-1;i++){
	if(a[i]!=0){cout<<a[i]<<" ";
		k++;
		}
	if(k==5){
		k=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>
#include<cmath>
using namespace std;
int main()
{int n;
cin>>n;
int A[n];int a[n];
for(int i=0;i<n;i++){a[i]=1;}
int l=0;
int B[n];
for(int j=1;j<n+1;j++){
int k=0;
for(int i=1;i<=n;i++){if(j%i==0){k++;}}
if(k==2){a[l]=j;l++;}
}
for(int i=0;i<n;i++){if(a[i]>1){if((i+1)%5==0){cout<<a[i]<<endl;}
			else{cout<<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 <iostream>
using namespace std;
int checkprime(int n){
if(n==2) return 1;
int i;
for(i=2;i<n;i++){
if (n%i==0) break;
}
if (i==n) return 1;
else return 0;
}
int main(){
int n,z=0;
cin>>n;
int a[n-1],b[n-1];
for(int i=0;i<=n-2;i++){
a[i]=i+2;
}
for(int j=0;j<=n-2;j++){
b[j]=j+2;
}
for(int k=0;k<=n-2;k++){
if(b[k]!=0){
if(checkprime(a[k])==1){
for (int l=1;(k+l*(a[k]))<=n-2;l++){
b[k+l*(a[k])]=0;
}
}
}
}
for(int m=0;m<=n-2;m++){
if (b[m]!=0){
{cout<<b[m];
z++;
}
if(z%5==0) cout<<"\n";
else cout<<" ";
}
}
}

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,j=0;

cin>>n;

int a[n-1];


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

for(int d=0;d<n-1;d++)
{
 for(int i=0;i<n-1;i++)
 {
  for(int b=2;b<=n;b++)
  {
   if(a[i]==b*a[d])a[i]=0;
  }
 }
}

for(int i=0;i<n-1;i++)
{
 if(a[i]!=0)
 {
  
  if(j==5)
  {
   printf("\n");
   j=1;
  }
  else j=j+1;
  cout <<a[i]<<" ";
 }
}
return 1;
}

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];
a[0]=2;
int b[n-1];
b[0]=2;
int p=2;
while(p>0){
for(int i=1;i<n-1;i++){a[i]=a[i-1]+1;}
for(int i=1;i<n-1;i++){
if(a[i]%p!=0)
{ b[i]=a[i];}
else b[i]=0; } 
for(int i=1;i<n-1;i++)
if(b[i]>p){ p=b[i];break;}
 }for(int i=1;i<n-1;i++){
if(b[i]!=0) cout << b[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: 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 j=p-1;j<n-1;j++){
for(int i=p-1,t=2;i<n-1;i++){
if(a[i]==t*p)
{a[i]=0;}
if(a[i]>t*p){t++;}
}
if(a[j]!=0){p=a[j];}
}
int k=0;
for(int i=0;i<n-1;i++){
if(a[i]!=0){cout<<a[i]<<" ";k++;
}
if(k%5==0&&k!=0){cout<<endl;k=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;
	if(n==2) cout<<2;return 0 ;
	int arr[n-1];
	for(int i=0;i<=n-2;i++) arr[i]=i+2;
	int comp[500];int size=0;int k=0;
	while(true){
		int p=arr[k];
		for(int i=2;i<=n;i++){
			if(i*p<=n){comp[size++]=i*p;}
			else break;
		}
		for(int j=++k;j<=n-2;j++){
			bool r= true;
			for(int a=0;a<size;a++){
				if(arr[j]==comp[a]){r=false;}
			}
			if(r==true){k=j;break;}
		}
		if(k==n-2) break;
	}
	int line=0;
	for(int i=0;i<=n-2;i++){
		bool b = true;
		int j=0;
		for(j;j<size;j++){
			if(arr[i]==comp[j]){b=false;}
		}
		if(b==true){line++;cout<<arr[i];
			if((line%5)!=0){cout<<" ";}
		}
		if(line>=5&&(line%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