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;
	float x=1.0,y=1.0,z=1.0;
	int i=1,j=1,k=1;
        float d=1.0;
	
	cin>>n>>r;
	int m=n-r;
	float ans;
	
	if(n>0&&n<35001&&r>0&&r<(n+1))
	{
	while(i<n)
	{
		x=x*i;
		i++;
	}
	x=x*n;

	while(j<r)
	{
		y=y*j;
		j++;
	}
	y=y*r;

	while(k<m)
	{
		z=z*k;
		k++;
	}
        z=z*m;
	d=y*z;
	ans=x/d;
	}
	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: 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{long  double a,b,n,r,c,d,e;
	
	a=1;
	     cin>>n>>r;
	     b=n-r;
	     c=n;
	     repeat(b-1){c=c-1;
			n=n*c;}
	     e=b;
	while(a<b){e=e*a;
	   	a=a+1;}
	d=n/e;
	cout<<d;

	     
	    


}

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{
	long double c=1;
	long double r,n;
	int t=1;
	cin>>n>>r;
	while(t<=r){
		c*=(n-t+1)/t;
		t++;
	}
	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,r;
	cin>>n>>r;

	float i=0;
	//float n;
	if(n>=1 && n<=35000 && r<=n)
	{
	
	repeat(r){
		n=n*(n-i+1)/i;
	i++;
	}
	

	cout<<n;
	}
}

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;
	if(n>0&&n<35001&&r>0&&r<=n){
	long double c=1,i=1,j=n-r+1;
	repeat(r){
		c=c*j/i;
		j++;
		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: 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;
	cin>>n;
	int r;
       cin>>r;
       long double fac=1;
       
       for(int i=r;i>0;i--){
	       fac=fac*n/i;
	       

	       n--;
	       
       }
       cout<<fac;
}

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 int n,r;
	cin >> n >> r;
	long double nCr;

	long double fac1=1;
	int i=1;

	while(i<=n){

		fac1=fac1*i;
		i++;
	}
	
	long double fac2 = 1;
	int j = 1;

	while(j<=r){

		fac2 = fac2*j;
		j++;
	}

	int l = n-r;
	long double fac3 = 1;
	int k = 1;

	while(k<=l){

		fac3 = fac3*k;
		k++;
	}

	nCr = fac1/(fac2*fac3);
	cout << nCr << 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>
int fact(int n){
	int i=0;
	int j;

	repeat(i<n){
		j=n-i;
		i++;
    int	p=1;

	fact(n)=p*j;
	}
	/*	repeat(i<r){
			j=r-i;
			i++;
		int	p=1;
		
fact(r)=p*j;
		}*/

}
main_program{
	int n,r;
	float l;
	cin>>n>>r;
	l=fact(n)/(fact(r)*fact(n-r));
	cout<<l<<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: 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, c, a, b;
	cin >> n >> r;
	a=1;
	c= n-r;
	repeat(n-r){
		a = n*a;
		n--;
	}
        b=1;

        repeat(c){
                b = c*b;
	        c--;
	}
        cout << a/b;
}

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 ncr=1;
repeat(r){
ncr=ncr*(n*1.0/r);
n--;r--;

}
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{
	long double n,r,numerator,denominator,ncr,reps;
	int i,j;
	cin>>n >>r ;

	reps=n-r-1;
	numerator=n;
	i=n-1;
	while(reps){
		reps--;
		numerator*=i;
		i--;}

	j=n-r-1;
	denominator=n-r;
	while(j>0){
		denominator*=j;
		j--;}

	ncr=numerator/denominator;
	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: 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 factn=1;
	int factr=1;
	int factnr=1;
	int n,r;
	cin>>n;
	cout<<" ";
	cin>>r;
	
	if(n>=1 && n<=35000 && r>=1 && r<=n){
		for(int i=1;i<=n;i++){
			factn=factn*i;
		}
		for(int j=1;j<=r;j++){
			factr=factr*j;
		}
		for(int k=1;k<=n-r;k++){
			factnr=factnr*k;
		}
	}
	double ncr=(factn)/(factr)*(factnr);
	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: 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 ans = 1.00;
	
	for(int i = 1; i <= r; i ++){
		ans = (((n-r+i)*1.00)/(i))*ans;
	}
	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: 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,C=1;
	int i = 0 ;
	cin>>n>>r;
	while(i <= r-1){
		C = C*(n-i)/(r-i);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: 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 double res= 1; int i=0; // at each stage res=nCi
	
	if (r>n/2){
		r=n-r;	// to prevent overflow whenever the answer is within range
	}
	
	repeat(r){
		i++;// now res=nC(i-1)
		res=(res/i)*(n-i+1);//now res=nCi again
	}
	
	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: 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,a,x,h;
cin>>n>>r;
h=n-r+1;
x=2;
a=1;
repeat(r-1){
a=a*(h/x);
h=h+1;
x=x+1;




}


cout<<a*n;



}

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;
	long double x=1.0;
	int i=1;
	cin >> n >> r;
	if(n<15000){
	repeat(r){
	x = ((1.0)*(n+1-i)/i)*x;
	i++;
	}
	cout << x;
	}
	if(n>15000 && r<(n/2)){
	repeat(r){
	x = ((1.0)*(n+1-i)/i)*x;
	i++;
	}
	cout << x;
	}
	if(n>15000 && r>(n/2)){
	repeat(n-r){
	x = ((1.0)*(n+1-i)/i)*x;
	i++;
	}
	cout << x;
	}




}

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;
  if(n==0 && r==0 || r==0){
    cout<<"1"<<endl;
  }
  else{
  long double ans=1.0;
  int i=1;
  while(i<=r){
    ans=((1.0*(n-r+i))/(1.0*i))*ans;
    i++;
  }
    
  cout<<ans<<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;
long double nf=1;
long double rf=1;
long double res=1;
cin >> n >> r;
for(int i=1;i<=n-r;i++)
{
nf=nf*i;
}
for(int i=r+1;i<=n;i++)
{
rf=rf*i;
}
res = rf/nf;
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 r,n;
		cin >> n >> r;
		long long int prodn, prodr, prod;
		prodn = 1;
		prodr = 1;
		prod = 1;
		repeat(r){
			prodn = prodn * n;
			prodr = prodr * r;
			n--;
			r--;
		}
		prod = prodn/prodr;
		cout << prod;
	}

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