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{
	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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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>
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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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 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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
long double ncr=1;
repeat(r){
ncr=ncr*(n*1.0/r);
n--;r--;

}
cout<<ncr;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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{
	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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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 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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
	long double ans = 1.00;
	
	for(int i = 1; i <= r; i ++){
		ans = (((n-r+i)*1.00)/(i))*ans;
	}
	cout<<ans;

}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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{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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
	
	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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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{
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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
	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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
  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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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 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: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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, k =1;
 cin>> n>> r; 
 long double fac = 1; 
  int i= n;
long double j =1;
  
  
  
  if((n>=1)&&(n<=35000)){
   if((r>=n/2)&&(r<=n))
 {
 repeat(n-r){
 // Cases divided so that code can execute and run within less time and choose the shorter path.
 fac = fac*i;
 i =i-1;
 j = j*k ;
 k++; 
  }
 cout<< fac/j; 
 }
 
  else if(r<n/2)
 {
 repeat(r){
 fac = fac*i;
 i =i-1;
 
 j =j*k;
 k++;
  }
 cout<< fac/j; 
 }
 
 
 }
 }

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
	long double ncr=1;
	cin >> n >> r;

	while (r>0) {
		ncr = ncr*n/r;
		n--;
		r--; }
       cout << ncr;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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{
long double  n,r,p,v,q;
cin>>n>>r;
q = n-r+1;
v =2;
p =1;
repeat(r-1){
p = p*(q/v);
q = q+1;
v = v+1;

}
cout<<p*n;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
	long double N=1,D=1,R=1;
	cin>>n>>r;
	int i=1;
	if(n>r && n>0 && r>=0){
        while((i-1)<n)
	{N*=i;
	i++;}
i=1;	
        while((i-1)<r)
	{R*=i;i++;}
i=1;
        while((i-1)<(n-r))
        {D*=i;i++;}

        long double C=N/(R*D);

	cout<<C<<endl;}
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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{
    unsigned int n,r;//not doing anything for constraints, as they are as assumptions
    cin>>n>>r;
    long double nCr=1.0;
    while(r>0){
        nCr*=(n*1.0)/r;
        n-=1;
        r-=1;
    }
    cout<<nCr;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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>
using namespace std;

main_program{
	long double n,r,num=1,den=1;//num = numerator = n!/r! and den=(n-r)!
	cin>>n>>r;
	for(long double i=n; i>r; i--){
		num*=i;
		}
	for(long double j=1; j<=(n-r);j++){
		den*=j;
		}
	cout<<num/den;
	}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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 f,n,r; 
	cin>>n>>r;
for(r=1;r<n;r++)
	while(true)
	{f=n;
f=f*r;break}
cout<<f;}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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 <iostream>
#include<cmath>
using namespace std;
int main(){
    int n, r;
    long double x=1;
    cin>>n>>r;
    for(int i=1; i<=r; i++){
        x=x*(n-i+1)/i;
    }
    cout<<x<<endl;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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<iostream>
using std::cout;
using std::cin;

int main(){
int n; int r; int a = 1;int b = 1;
cin >> n >> r;
long double nCr = 1;
while(a <= r/2){
nCr = nCr/a;
a++;
}
while(b <= r/2){
nCr = nCr * (n - b + 1);
b++;
}
while(a <= r){
nCr = nCr/a;
a++;
}
while(b <= r){
nCr = nCr * (n - b + 1);
b++;
}

cout << nCr <<"\n";
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
long double a=1;
int j = 0;
cin >> n >> r;
while(j<r){
	a = a*(n-j)/(r-j);
	j++;
}
cout << a;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
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;
      	long double facn=1,i=1,facr=1,j=1,facnr=1,k=1,ncr;
	while(i<=n){
		facn = facn*i;
		i++;
	}
	while(j<=r){
		facr = facr*j;
		j++;
	}
	while(k<=(n-r)){
		facnr = facnr*k;
		k++;
	}
	ncr=facn/(facr*facnr);
	cout<<ncr;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: poor variable names
Rating D: 0
Assigned grade: B