CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r,i,j,k;
	long double fac_n,fac_r,fac_nr;
	float c;
	cin>>n>>r;
         i=1;
	 j=1;
		 k=1;
		 fac_r=1;
		 fac_nr=1;
         fac_n = 1;

	repeat(n){
		fac_n=fac_n*i;
		i++;
	}
	repeat(r){
		fac_r=fac_r*j;
		j++;
	}
	repeat((n-r)){
		fac_nr=fac_nr*k;
		k++;
	}
	c=fac_n/(fac_r*fac_nr);
	cout<<c;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r;
	cin>>n>>r;
	 int i=1;
	 long double n_fac=1;
	repeat(n){
		n_fac*=i;
		i++;
	}

	long double r_fac=1;
	int j=1;
	repeat(r){
	
		r_fac*=j;
		j++;}
	long double nr_fac=1;
	int k=1;
	repeat(n-r){
		nr_fac*=k;
		k++;
	}
	long double n_c_r= (n_fac)/((r_fac)*(nr_fac));
	cout<<n_c_r<<endl;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r;
	cin>>n>>r;
	int b=n-r;
	long long int factn=1;
	long long int factb=1; 
	long long int factr=1;
	long long int fact;
	while(n>0){
		factn=factn*n;
		n--;
	}
	while(b>0){
                factb=factb*b;
                b--;
        }
	while(r>0){
                factr=factr*r;
                r--;
        }
	fact=factn/(factr*factb);
	cout<<fact;


/*	long double fact=1.0;
	if(b==0){
		cout<<"1";
	}
	else{
		while(n>0){
			fact*=n/(b*r);
			n--;
			b--;
			r--;
			if(b==0)
				b=1;
			if(r==0)
				r=1;
	
	}
	}	
	cout<<fact;*/

}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r;cin>>n>>r;
	long double i=1;
	long double k=1;
	for(int a=r+1;a<=n;a++){
		i=i*a;
	}

	for(int c=1;c<=(n-r);c++){
		k=k*c;}
	long double s=i/(k);
	cout<<s;
			












}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r;
	long double res;
	cin >> n;
	cin >> r;
	int k;
	long double t = 1,p = 1;
	if (n-r < r) k = r;
	else k = n - r;
	for(int i = n; i >n- k;i--){
		t = t * i;
	}
	for(int i = 1; i <= k;i++){
		p = p * i;
	}
	res = t/p;
	cout << res;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n, r;
	//cout<<"Enter value:";
	cin>>n>>r; 

	int x=0;
	double a, b;
	long double c=1;
	while(x<r){
		a=(n-x);
		b=(r-x);
		x++;
		c*=a/b;
	}
	cout<<c<<endl;

}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r;
	cin>>n>>r;
	 long int i= 1, t= 1, j=1, s=1, k=1,u=1, p;
	 while(i<n)
	 {
		 i=i+1;
		 t=t*i;}
	 while(j<r){
		 j=j+1;
		 s=s*j;}

          while(k<(n-r)){
		  k=k+1;
		  u=u*k;
	  }
	  p=t/(s*u);
	  cout<<p;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int n,r;
	cin>>n>>r;
	long double m=n;
	long double q=r;
	long double a=m-q+1;
	long double b=1;
	long double p=1;
	repeat(q){
		p=p*a/b;
		a++;
		b++;
	}
	cout<<p;

}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	long double n,r;
	cin>>n>>r;
	long double c=n/r;
	for(long double i=1;i<r;i++){
		c=c*((n-i)/(r-i));
	}
	cout<<c<<endl;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
long double n;
long  double rinput;
	cin>>n>>rinput;
long double nCr=1;
long double r =0;
if(rinput>n/2.0){ rinput= n-rinput;}
repeat(rinput){
    nCr=(n-r)*1.0/(r+1)*nCr;
    r=r+1;
}
cout<< nCr;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	int r;
	cout<<"enter r number:";
	cin>>r;
	int n;
	cout<<"enter n number:";
	cin>>n;
	{
		if(1<=r<=n; && 1<=n<=3500)
			cout"

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: D
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>

main_program{
	int n,r;
	cin>>n>>r;

	long double k=0;
	long double output=1;

	if(r>n/2){
		r= n-r;
	}

	while(k<r){
		output*= (n-k)/(k+1);
		k++;
	}

	cout<<output;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
long double n,r,b=1,c=1,z,d=1, factorial;
cin>>n>>r;
repeat(n-1){
	b=b*n;
	n=n-1;}
repeat(r-1){
c=c*r;
r=r-1;}

repeat(n-r-1){z=n-r;
	d=d*z;
	z=z-1;}
factorial=b/(c*d);
cout<<factorial;}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: D
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
	long double n, r, i = 1;
	cin>>n>>r;
	long double c = 1;
	repeat(r){
		c = (c/i)*(n-i+1.0);
		i++;
	}
	cout<<c;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: B
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
int n;
cout<<"enter a number n:";
cin>>n;
int r;
cout<<"enter a number r:";
cin>>r;
int a=1;
for(int i=1;i<=n;i++){
a=a*i;
}

int b=1;
for(int i=1;i<=r;i++){
b=b*i;
}
int c=1;
for(int i=1;i<=n-r;i++){
c=c*i;
}
cout<<(a/(b*c));
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: C
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include <simplecpp>
main_program{
	int n,r;
	cin>>n>>r;
	long double t=1;
	for (int i=n;i>=(r+1);i--){
		t=t*i/(n-i+1);}
	cout<<t<<endl;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
using namespace std;
main_program{
       long double n,r,ans=1;
	cin>>n;
	cin>>r;
	long double i=1;
		repeat(r){
		ans*=((n-i+1)/i*1.0);
		i++;
	}
	cout<<ans;	
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: B
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include <simplecpp>
main_program{
int n,r;
cin >> n >> r;
int d = n-r; //Difference
long double t1 = d+1,t2 = 1; //Repeating terms
int i = 1;
while(i != r){
t2 = t1*d/(i+1);
t1 = t1 + t2;
i++;
}
cout << t1;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: A
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include <iostream>
using namespace std;
int main(){
    int n,r;
    cin>>n>>r;
    long double factorial1,factorial2, factorial3, output;
    output=1;
    long double i=r+1;
    long double j=1;
    
    for(i=r+1, j=1; i<=n && j<=(n-r); i++, j++){
        output*=(i/j);
    }

    cout<<output<<endl;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: B
Problem: accept n and r from the user, compute nCr, and print the result. A naive approach would be to calculate the factorial of n, factorial of r, and factorial of n-r and then finally compute the result as given in the formulae above. However, calculating the factorial of a large number can be tricky, and the result may overflow due to the limitation of the size of data type. you are free to use other data types, including long double. you are free to use other data types, including long double.

Constraints:1 <= r <= n1 <= n <= 35000

Student submission:
#include<simplecpp>
main_program{
  float n,r,j,k,l;
  cin>>n>>r;
  int i=n;
  while(i>0){
        j=n*i;
        i--;
  } 
   i=r;
  while(i>0){
      k=r*i;
      i--;
  } 
   i=(n-r);
  while(i>0){
       l=(n-r)*i;
       i--;
  }    
    cout<<j/k*l;
}

Grading criterion: Algorithm for calculating n-C-r
Rating A: The loop has the correct multiplying term to keep the value within range
Rating B: Tried a  loop with some term to keep the value within range, but not perfect
Rating C: Naive approach of calculating Factorials first, but 'correct'
Rating D: Code not done or completely wrong
Assigned grade: D