Please help me find the error

my code
#include<bits/stdc++.h>
using namespace std;
#define endl “\n”
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long int
#define m 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
/#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif
/
ll n,r;
cin>>n>>r;
ll ans=1;
if(r==0)
cout<<1;
else{
for(ll i=1;i<=r;i++)
{
ans=((ans%m)*(n-r+i)%m)%m;
ans/=i;
}
cout<<(ans+m)%m;
}

return 0;

}

i have tried in second way also but in both only 2 cases are getting passed

my code #include<bits/stdc++.h> using namespace std; #define endl “\n” #define sd(val) scanf("%d",&val) #define ss(val) scanf("%s",&val) #define sl(val) scanf("%lld",&val) #define all(v) v.begin(),v.end() #define PB push_back #define MP make_pair #define FF first #define SS second #define ll long long int #define MOD 1000000007 #define clr(val) memset(val,0,sizeof(val)) #define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); ll factorial(ll num) { ll res=1; for(int i=2;i<=num;i++) { res=(resi)%MOD; } return res; } ll fastexpo(ll a,ll b) { ll res=1; while(b>0) { if(b&1) { res=(resa)%MOD; } a=(aa)%MOD; b=b>>1; } return res; } ll modinverse(ll num) { ll res=fastexpo(num,MOD-2); ll ans=(res)%MOD; return ans; } int main() { /#ifndef ONLINE_JUDGE freopen(“input.txt”, “r”, stdin); freopen(“output.txt”, “w”, stdout); #endif*/ ll n,r; cin>>n>>r; ll a=factorial(n); ll num2=factorial®; ll num3=factorial(n-r); ll b=modinverse(num2); ll c=modinverse(num3); ll ans=((a%MOD)(b%MOD)(c%MOD))%MOD; cout<<ans; return 0; }

Do u know about modular inverse ??. Because in modular calculations u cant just divide normally. U need to calculate the modular inverse before that.

see the code in replies this is also giving the same result

I am not able to understand the code please send via link.