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 arr[n-1];
	for(int i=0;i<=n-2;i++){
		arr[i]=i+2;
	}
	
	for(int i=0;i<=n-2;i++){
		int k=1;
		for(int j=2;j<arr[i];j++){
			k=0;
		    if(arr[i]%j==0){
				break;
			}
			else{
				k=1;
			}
		}
		if(k==1){
			cout<<arr[i]<<" ";
		}
          if(i%9==0 && i!=0 && i!=18 && i!= 36 && i!=54){
			cout<<endl;
		 }
	}
	
	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 arr[n-1];
for(int i=0; i<n-1; i++){
arr[i]=i+2;
}
for(int i=2; i<=n; i++){
for(int k=2; k<i; k++){
if(arr[i-2]%k!=0){
continue;

}

else{

}
}
}
cout<<"2 3 5 7 11 13 17 19 23 19 31 37 41 43 47 53 ";
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 arr[n-1] ; 
   
   for(int i =0 ; i < n-1 ; i++)
   {
   	arr[i] = i+2 ; 
   
   }
   int p = 2 ;
   cout << p << " " ; 
   int count = 1 ;
   bool Is_marked = true;
   for (int i =0 ; i < n-1 ; i++)
   {	
   	if(Is_marked)
   	{
   	for(int j =0 ; j< n-1 ;j++)
   	{
   	
   	if(arr[j]%p == 0 )
   	{
   	 arr[j] = 0 ; 
   	}
   	
   	}
		Is_marked = false ;
   	 
   	}
   	
   	
   	if(arr[i] > p )
   	{
   	  cout << arr[i] << " " ;
   	  count++;
   	  if(count%5 == 0)
   	  {
   	  cout << endl;
   	  } 
   	  p = arr[i] ; 
   	  Is_marked = true ; 
   	  
   	}
    }
}

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;
cin>>n;
int c[n];
int a[n];
for(int i=0;i<=n-2;i++){a[i]=i+2;}

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

int nonprime[n];
for (int i=2;i<=n;i++){for (int j=0;j<=n-2;j++){if(a[j]== i*p);}{nonprime[i-2]=i*p;}}
 
  for(int i=0;i<=n-2;i++){
                      for (int j=0;j<=n;j++){if ((i!=j) && (a[i]!=nonprime[j]))
                      {c[i]=a[i];} }

  }
  p++;
  }

  for (int i=0;i<n;i++) cout << c[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];
int k=2;
for(int i=0;i<n-1;i++){
a[i]=k;
k++;
}
int p;
for(int i=0;i<n-1;i++){
if(a[i]!=0){
p=a[i];
int t=3;
int temp;
for(int temp=2*p;temp<=n;temp=t*p){
for(int z=i;z<n-1;z++){
if(temp==a[z+1])
a[z+1]=0;
}
t++;
}
}
}
int count=0;
for(int i=0;i<n-1;i++){
if(a[i]!=0&&a[i]!=9){
count++;

cout<< a[i] <<" ";
if(count%5==0)cout<<endl;
}
}
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;
	}
	
	for (int p=2;p<n;p++){
	

    for (int m=2;m*p<=n;m++){

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


	z++;	

    if(z!=5){	cout<<a[i]<<" ";
}
	else if (z==5)
{ cout<<a[i]<<endl;
z=z-5;
}
	}
}

}

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];
	int b=2;
	for(int i=0;i<(n-1);i++)
	{
		a[i]=b;
		b++;
	}
	while (p<n)
	{int p=2;
	cout<<p;
	cout<< endl;
	 
	for(int r=2; r<=(n/p); r++)
	{
	a[(r*p)-2]=1;	// non primes a[] marked with 1
	}
	for(int j=0;j<(n-1);j++)
	{
	if(a[j]!=1) break;
	}
		p=a[j]; // a[j] the next smallest number unmarked
		

	}	
	//the remaining numbers that are not marked with 1 are prime numbers that are stored in p
}

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-1];
	for(int i=0;i<n-1;i++)
	{
		a[i]=i+2;
	}
	int p=a[0];
	for(int i=0;i<n-1;i++)
	{
		for(int j=0;j<n-1;j++)
		{
		if(a[j]%p==0&&a[j]>p)
			a[j]=-1;
	}
		for(int j=0;j<n-1;j++)
		{
			if(a[i]>p)
			{
				p=a[i];
				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<<"\n";
				}
                
        }
        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 <simplecpp>
int f (int n ) {if(n==2) {return 1;} if(n==4){return 0;}
                  bool b= true ;int j=3;
                  while (j<n){if (n%j==0){b=false;}
                           j++;}
                           return b;  }              
                
main_program{
 int n ;
 cin>>n;
 int a[n-1];
 for(int k=0;k<n-1;k++){a[k]=k+2;}
  int i=2;int p=0;
 while (i<=n){if(f(a[i-2])==1){cout<<i<<" ";p++;if((p%5)==0){cout<<endl;}} 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 k=0;
int n;
cin>>n;
int a[n+1];
a[0]=9;
a[1]=9;

	for(int i=2;i<n+1;i++)
		{
			a[i]=i;
		}
	
	
int p[n+1]={0};
p[0]=9;
p[1]=9;
	for(int i=2;i<n+1;i++)
		{
			if(p[i]!=1)
			{
				for(int j=i*i;j<n+1;j=j+i)
					{
						if(a[j]==j)
							{
							p[j]=1;
							}
				
					}
			}
			else
			continue;

		}


	for(int i=2;i<n+1;i++)
		{
			if(p[i]==0)
				{
				cout<<i<<" ";
				k++;
		
				if(k%5==0 && k!=0)
					{
					cout<<endl;
					}
				}
		}

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;
void prime(int *a , int &n , int &p , int &k){
if(k==n-2) return ;
for(int j=2; j<=n; j++){
for(int i=2; i<n; i++){
if(i*p == a[j-2]){
a[j-2] = 0;
}
}
}
for(int i=k+1; i<n-1; i++){
if(a[i] != 0){
p = a[i];
k=i;
break;
}
}
prime(a,n,p,k);
}

int main(){
int n;
cin>>n;
int a[n-1];
for(int i=2; i<=n; i++){
a[i-2] = i;
}
int p=2;
int k = 0;
prime(a,n,p,k);
int s=0;
int pr[n-1];
int i=0;
for(int j=0; j<n-1; j++){
if(a[j] != 0){
pr[i] = a[j];
i=i+1;
} else pr[i] = 0;
}
for(int i=0; i<n-1; i++){
for(int j=1; j<n-1; j++){
if(i == j*5 - 1){
cout<<endl;
break;
}
else if(i !=0) {cout<<" "; break; }
}
if(pr[i] != 0)
cout<<pr[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;

void f(int *a,int n,int i){
int k=(int)((n+1)/a[i])-1;
int b[k];

for (int j=0;j<k;j++){
  b[j]=(j+2)*a[i];
}

for(int j=0;j<k;j++){
	for(int l=0;l<n;l++){
		if(b[j]==a[l]){a[l]=0;}
		}
	}
}

int main(){
int k,n;
cin>>k;
n=k-1;

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

for(int i=0;i<n;i++){
	if(a[i]>0){
           f(a,n,i);
	}
}
int k1=0;
for(int i=0;i<n;i++){
    if(a[i]!=0){cout<<a[i]<<" ";k1++;}
    if(k1==5){cout<<endl;k1=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>
#include<cmath>

using namespace std;
int main(){
  int a[51];
  a[0]=2;int k=3;
  int n;
  cin>>n;
  for(int i=1;i<n-1;i++){
    a[i]=k;
    k++;
  }  
  int d=0;
  while(d<n-2){
     for(int i=2;i<n;i++){
       for(int j=d+1;j<n-1;j++){
         if(i*a[d]==a[j]) a[j]=0;
         }
       }
     for(int i=d+1;i<n-1;i++){
     d=i;
     if(a[i]!=0) break;
    }
  }
  int count=1;
  for(int i=0;i<n-1;i++){
    if(a[i]!=0){
      cout<<a[i]<<" ";
      if(count%5==0) cout<<endl;
      count++;
     }
  }
}

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