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

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;
int main()
{
int n;
cin >>n;
int l=n-1;
int a[l];
for(int i=0;i<l;i++)
a[i]=i+2;
for(int i=0;i<l;i++)
{
if(a[i]==0)
continue;
else
{
int p=a[i];
for(int j=i+1;j<l;j++)
{
if(a[j]==0)
continue;
else
{
bool b= a[j]%a[i]==0;
if(b==1)
a[j]=0;
}
}
}
}
int p=0;
for(int i=0;i<l;i++)
{
if(a[i]!=0)
{
cout <<a[i]<<" ";
p++;
if(p%5==0)
cout <<'\n'; 
}
}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;
int main (){
unsigned long long int n ;
cin >> n ;
unsigned long long int arr [ n-1 ];
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ) {
arr [ i ] = i + 2 ;
}

unsigned long long int c [ n - 1 ];
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ) 
 c [ i ] = 0 ;
 
unsigned long long int p = 2 ;
for ( p = 2 ; p < n ; p++ ) {
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ){
if ( arr [ i ] % p == 0 && arr [ i ] != p )
arr [ i ] = 0 ;
}
}

int count = 0 ;
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ) {

if ( arr [ i ] != 0 ){
cout << arr [ i ] << " " ;
count ++ ;
}
if ( count % 5 == 0 )
cout << endl;
}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<simplecpp>
int main() {
int n;
cin>>n;
int A[n];
int B[n];
int avg =2;
int p=2;
for (int i=0;i<n;i++)
{
A[i] =avg+i;}

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

for (int i=0;i<n;i++)
{if (A[i] ==n) break;
if (A[i]!=B[i]&& A[i]!=n)
{cout << A[i]<<" ";}}

}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>

using namespace std;

int main(){

int n;
cin>>n;
int arr[n-1];
for (int i=0;i<n-1;i++){
arr[i]=i+2;
}
int j=0;
while(j<n-1){
if(arr[j]==0) j++; 
else{
int p=arr[j];
int num=p;
while(num<n){
num+=p;
for(int i=0;i<n-1;i++){
if(arr[i]==num)arr[i]=0;
}
}
j++;
}
}
int num=0;
for(int k=0;k<n-1;k++){
if(arr[k]!=0)num++;
}
int num2=0;
int numarr[num];
for(int k=0;k<n-1;k++){
if(arr[k]!=0){numarr[num2]=arr[k];num2++;}
}

for(int i=0;i<num;i++){
if((i-4)%5!=0)cout<<numarr[i]<<" ";
else cout<<numarr[i]<<endl;
}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<simplecpp>

bool xnotinarr(int* a, int n , int x) { // func to check for x in array

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

    if (a[i] == x ) {return false;}


}

return true ;

}





main_program{

int n ;
cin >> n ;

int a[n-1] ;

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

for (int p  =0 ; p<n -1 ; p++){

if (a[p]!= 0 ){
for (int i = 2 ; i <= n/a[p]; i++) {

if (!(xnotinarr(a,n,i*a[p]))){ a[i*a[p] -2] =0 ;}


}

}
}
int no_primes =0 ;
for (int i =0 ; i< n-1 ;i++){  // to get number of primes
    if (a[i]){

        no_primes ++ ;
    }
}

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

    if (a[i]) {

        cout << a[i];
        k++;
         if (k == no_primes) {break ;}
         else if (k%5 ==0) {cout << endl ;}
         else {cout << " ";}



    }





}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

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

int main(){
int i,j,k,p,n,c=0,m;
cin >> n;
int A[n];
for (i=0;i<=n;i++){
A[i] = i;
}

for(k=2;k<=n;k++){

//if(A[k]==0){continue;}

p=k;
for(j=2;p*j<=n;j++){
A[4]=0;
A[p*j] = 0;

}
}

for(m=2;m<=n;m++){
if (A[m]==0){continue;}
cout << A[m] << " ";
c++;

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

}


}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<simplecpp>





main_program{
int n;
cin>>n;
int a[n-1];
int b[7];
for(int j=n-2;j>=0;j--){

	a[j]=j+2;
}



	int counter=0;
	for(int k=0;k<n-1;k++){
for(int j=2;j<a[k];j++)
	{if(a[k]%j==0)
{counter=counter+1;}
}

if(counter==0)
	{

for(int m=0;m<7;m++)
{
		b[m]=a[k];}}
}
for (int l=0;l<n;l++){
cout<<b[5*l]<<" "<<b[5*l+1]<<" "<<b[5*l+2]<<" "<<b[5*l+3]<<" "<<b[5*l+4]<<endl;

}



}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n,l=0;
cin>>n;
int j=2,a[n-1];
for(int i=0;i<n-1;i++){
a[i]=j;
j++;}

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

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;cin>>n;
int arr[n-1];
for (int i=0;i<n-1;i++){arr[i]=i+2;}
for (int i=1;i<n-1;i++){
if (arr[i]%i+1){arr[i]=0;}}
for (int i=0;i<n-1;i++){if( arr[i]!=0){cout<<arr[i];}}}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int 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: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

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

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

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

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n-1];
	for(int i=0;i<n-1;i++)
	{
		a[i]=i+2;
	}
	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: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >>n;
	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: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B