CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

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

Constraints
n >= 2 and n <= 500

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

int main(){

int n;
cin>>n;

int a[n-1];

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

	a[i]=i+2;}
	
int p=2;

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

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

		for(int k=2;k<n;k++){
		
			if(a[j]==k*p){a[j]=0;} 
			}
			}
		
	while(a[b]!=0)
	{p=a[b];break;}		
		
	}
int l=0;	
	
for(int t=0;t<n-1;t++){

if (a[t]!=0){

l++;
cout<<a[t]<<" ";

if(l%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;
	int arr[n-1]; 
	for (int i=0 ; i<n-1 ; i++) {
	arr[i] = i+2 ;
	}

	int p = 2;
	for (int j=0 ; j<n ; j++) {
		for (int i=2 ; i<n-1 ; i++) {
			if (arr[i]==(j*p)) arr[i] = 0 ;
		}
	}
	cout<<p;

int x=1;
int m=1; 
	for (int k=x ; k<n-1 ; k++) {
		if (arr[k] == 0) continue;
		p = arr[k];

		cout<<" "<<p;m++;
		if(m%5==0) cout<<endl;

		for (int j=0 ; j<n ; j++) {
			for (int i=2 ; i<n-1 ; i++) {
			if (arr[i]==(j*p)) arr[i] = 0 ;
			}
		}

		x++;

	}

}

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 i,j;
 int n;
int s2=0;
cin>>n;
int a[n-1];
for(i=2;i<=n;i++)
{
 a[i-2]=i;
}
int p=2;
int b[n];


for(i=0;i<n-1;i++)
{
while((i+2)*p<=n)
{
 
 b[i]=(i+2)*p;
s2++;

for(i=0;i<n-1;i++)
{
 for(j=0;j<s2;j++)
{
 if(a[i]>p&&a[i]!=b[j])
{
 p=a[i];
break;
}
}
}
}
}
int c[n-1];
int s=0;
int k;
for(i=0;i<n-1;i++)
 for(k=0;k<s2;k++)
{
 if(a[i]!=b[k])
{
 c[i]=a[i];
s++;
}
}
for(int r=0;r<s;r++)
{
 cout<<c[r];
}
}

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 c,n,i,j,k,l,m,o,p;
cin>>n;
int arr[n-1];
for(i=0;i<n-1;i++)
{ arr[i]=i+2 ;}
for(j=0;j<n-1;j++)
{if (j==0){ for(l=1;l<n-1;l++){ for(k=2;k<n-1;k++){
if (arr[l]!=2*k) continue;
else if (arr[l]==2*k) arr[l]=0;};};}
else if (arr[j]==0) continue;
else if (arr[j]!=0) {for(m=j+1;m<n-1;m++){for(o=2;o<n-1;o++){
if (arr[m]!=arr[j]*o) continue;
else if (arr[m]==arr[j]*o) arr[m]=0;};};}
}
c=0;
for(p=0;p<n-1;p++)
{if (arr[p]!=0){ cout<<arr[p]<<" ";
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;
		   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: 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 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: 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 (){
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: 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];
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: 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 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: 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>

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: 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 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: 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 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: 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,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: 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=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: Creation of array of consecutive integers
Rating A: Correctly Done
Rating B: Not done
Rating C: 0
Rating D: 0
Assigned grade: A