#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
#define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 1e6+10;
const int MAXA = 2e5;
const int INF = 1e9+100;
const int SQRT = 500;
const int LOG = 24;
const int MOD = 1e9+7;
void chmn(auto &a, auto b){ a = min(a, b); }
void chmx(int &a, int b){ a = max(a, b); }
int sum(int a, int b){ a %= MOD; b %= MOD; return (a+b)%MOD; }
int sub(int a, int b){ a %= MOD; b %= MOD; return (a+MOD-b)%MOD; }
void chsum(int &a, int b){ a %= MOD; b %= MOD; a = (a+b)%MOD; }
void chsub(int &a, int b){ a %= MOD; b %= MOD; a = (a+MOD-b)%MOD; }
int mul(int a, int b){ a %= MOD; b %= MOD; return a*b%MOD;}
void chmul(int &a, int b){ a = a*b%MOD; }
int expo(int a, int b){
	if(b==0) return 1;
	int te = expo(a, b/2); te = mul(te, te);
	return (b%2 ? mul(te, a) : te);
}
int n, a[MAXN], b[MAXN], x[MAXN];
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>a[i]>>b[i];
	}
	int te = 0;
	for(int pp=1; pp<=30; pp++){
		for(int i=1; i<=n; i++){
			a[i] += te; te = 0;
			if(a[i]>b[i]){
				int take = a[i]-b[i];
				te += take;
				if(te%2){
					if(b[i]){
						te++; take++; // jadiin genap
					} else { // nol
						te--; take--; 
					}
				}
				a[i] -= take; 
			}
			// if(pp<=3)
			// 	cout << a[i] << ' ' << b[i] << ' '<< te << " te\n";
			te >>= 1;
		}
	}
	bool can = 1;
	for(int i=1; i<=n; i++){
		if(a[i]!=b[i]) can = 0;
	}
	cout << (can ? "Yes\n" : "No\n");
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |