Bali pair 1d dp

this code is working fine in my compiler but showing MLE when submitting on the coding block compiler. May i know whats the problem or is there a problem in code.

`#include <bits/stdc++.h>

#define endl “\n”
#define ll long long int
#define vi vector
#define vll vector
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all© c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

ll dp[10000005] = {0};

ll fun(vector<pair<ll, ll>> v, ll sum, ll n) {

if (n == 0) {
	if (sum % 2 == 0) {
		return 0;
	}
	return 1;
}

if(dp[n]){
	return dp[n];
}





ll x = fun(v,(sum+v[n-1].first)%mod,n-1);
ll y = fun(v,(sum+v[n-1].second)%mod,n-1);

return dp[n] =  (x%mod +y%mod)%mod;

}

int main()
{

ll n;
cin >> n;
vector<pair<ll, ll>> v;
ll T = n;
while (T--)
{
	ll l, r;
	cin >> l >> r;
	v.push_back(make_pair(l, r));

}

cout << fun(v, 0, n);
return 0;

}
`