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, 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: 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 ncr=1;
	cin >> n >> r;

	while (r>0) {
		ncr = ncr*n/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,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: 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 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: 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{
    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: 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,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: 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 f,n,r; 
	cin>>n>>r;
for(r=1;r<n;r++)
	while(true)
	{f=n;
f=f*r;break}
cout<<f;}

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 <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: 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<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: 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 a=1;
int j = 0;
cin >> n >> r;
while(j<r){
	a = a*(n-j)/(r-j);
	j++;
}
cout << a;
}

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 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: 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<iostream>
#include<simplecpp>
using namespace std;

int main(){
long double n, r;
cin>>n;
long double nFactorial;

 repeat(n-1){
nFactorial = nFactorial*(n-1);
cout<<nFactorial<<endl;
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;
	float c;
	if((n>=1 && n<=35000)&&(r>=1 && r<=n)){
		int i=1;
		c=1;
		while(i<r){
			c=c*((n-(i-1))/i);
			i++;
		}
		c=((c*(n-(i-1)))/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
{
    	long double n,r,c,x;
	cin>>n>>r;
	c=n-r;
	if(n>r && n>=1 && r>=1 && n<=35000)
	{
		long double d,a,b,j=1,i=1,k=1;
		a=n;b=r;d=n-r;
		while(a>i)
		{
			n=n*i;
			i=i+1;
		}
		while(b>j)
		{
			r=r*j;
			j=j+1;
		}
		while(d>k)
		{
			c=c*k;
			k=k+1;
		}
		x=n/(r*c);
		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: 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 long int n,r,k=1,l;
    long double s=1.0;
    cin>>n>>r;
    l=n-r;
    if(l<r){
        r=l;
    }
    repeat(r){
        s=s*n/k;
        n--;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: 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[
float n,r;
cin<<n<<r;
for(int num=1; num<=n; num++){
num *=num;
cout<<num;


}

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;
	long double a=1, b=1, c=1;
	cin>>n>>r;
	int i=1, j=1, k=1;
	repeat(n){
		a=a*i;
		i++;
	}
	repeat(r){
		b=b*j;
		j++;
	}
	
	repeat(n-r){
		c=c*k;
		k++;
	}
	  long double result=(a/b);
	  long double sum=result/c;
	cout<<sum<<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;
	cin>>r;

	if(r>=1 && r<=n && n>=1 && n<=35000){
		long double a=1;
		for(int i=1; i<=r; i++){
	    a=a*(n+1-i)/i;} 
                     cout<<a;
	}}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: 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 ncr,n,r,x;
cin>>n>>r;
x=2;
ncr=n;
while(x<r+1){
ncr=ncr*((n+1-x)/x);
x=x+1;
}
cout<<ncr;

}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: 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; int r; int a; long double nca;
    cin >> n >>  r;
    nca = 1;
    if (r<=(n/2))
    {
    for (a=1; a<=r; a++)
    {
        nca = ((nca)*(n-a+1))/a ;
    }
    cout << nca;
    }
    else 
    {
       for (a=n; a>r; a--)
    {
        nca = ((nca)*a)/(n-a+1) ;  //cout << nca << endl;
    }
    cout << nca; 
    }
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: 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(){
	long long n, r, fact = 1.0;
	cin >> n >> r;
	for ( int i = n; i >= r;i--){
		long long mulli = n/(r*(n - r));
		fact *= mulli;
		n -= 1;
		r -= 1;}
	cout << fact << endl;
	//next i am going to do the calculation for n-r to 1 and then multiply both
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing Extra
Rating C: 0
Rating D: 0
Assigned grade: B