#include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; const ll INF = 1e+15; typedef pair P; struct edge{ int to; ll cost; }; vector dijkstra(int s, vector> G){ priority_queue, greater

> que; int n = G.size(); vector d(n, INF); d[s] = 0; que.push(P(0, s)); while(!que.empty()){ P p = que.top();que.pop(); int v = p.second; if(d[v] < p.first) continue; for(int i = 0; i < G[v].size(); i++){ edge e = G[v][i]; if(d[v] + e.cost < d[e.to]){ d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } return d; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n; ll l; cin >> n >> l; vector d(n); for(int i = 0; i < n; i++) cin >> d[i]; vector b(2*n); for(int i = 0; i < 2*n; i++) cin >> b[i]; ll b_sum = accumulate(b.begin(), b.end(), 0ll); for(int i = 0; i < n; i++){ if((b[i]+b[i+n])*n != b_sum){ cout << "No" << endl; return 0; } } ll D = b_sum/(l*n); vector x(n-1); vector y(n-1); for(int i = 0; i < n-1; i++){ if((b[i]-b[i+1])%(d[i+1]-d[i]) != 0){ cout << "No" << endl; return 0; } x[i] = (b[i]-b[i+1])/(d[i+1]-d[i]); if(D-x[i] < 0 || (D-x[i])%2 != 0){ cout << "No" << endl; return 0; } y[i] = (D-x[i])/2; } // vector> g(2*n); // for(int i = 0; i < n-1; i++){ // g[i].push_back(edge{i+n, y[i]}); // } // for(int i = 0; i < 2*n-1; i++){ // g[i+1].push_back(edge{i, 0}); // } // auto dist = dijkstra(0, g); // for(int i = 0; i < n-1; i++){ // if(dist[i+n]-dist[i] != y[i]){ // cout << "No" << endl; // return 0; // } // } cout << "Yes" << endl; }