malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long nmax = 1e6 + 5;   const unsigned long long oo = 1e18;   const long long mod = 1e9 + 7;   const long long ox[4] = {-1, 1, 0, 0};   const long long oy[4] = {0, 0, -1, 1};   const long long dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};   const long long dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};   long long a[nmax];   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);     };     long long t, n, res;     cin >> t;     while (t--) {       cin >> n;       bool kt = false;       for (int i = 1; i <= n; i++) cin >> a[i];       for (int i = 1; i <= n - 1; i++)         if (a[i] >= a[i + 1]) {           kt = 1;           break;         }       if (kt || !(n % 2)) {         cout <<  YES               <<   n ;       } else         cout <<  NO               <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 202020, P = 1e9 + 7;   int n;   int a[N], par[N], cnt[2][N], c[2][N];   long long ans;   vector<int> g[N];   void upd(long long &a, long long b) {     if (b < 0) b += P;     a += b;     if (a >= P) a -= P;   }   void dfs(int u, int fa) {     cnt[0][u] = 1;     cnt[1][u] = 0;     par[u] = fa;     for (int i = (0); i < ((int)g[u].size()); i++) {       int v = g[u][i];       if (v == fa) continue;       dfs(v, u);       cnt[0][u] += cnt[1][v];       cnt[1][u] += cnt[0][v];     }   }   void dfs2(int u) {     if (par[u]) {       c[0][u] = c[1][par[u]];       c[1][u] = c[0][par[u]];     } else {       c[0][u] = cnt[0][u];       c[1][u] = cnt[1][u];     }     for (int i = (0); i < ((int)g[u].size()); i++) {       int v = g[u][i];       if (v == par[u]) continue;       dfs2(v);     }   }   int main() {     scanf( %d , &n);     for (int i = (1); i < (n + 1); i++) {       scanf( %d , a + i);       if (a[i] < 0) a[i] += P;     }     for (int i = (1); i < (n); i++) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     dfs(1, 0);     dfs2(1);     for (int i = (1); i < (n + 1); i++) {       long long pre = ans;       int c0 = c[0][i], c1 = c[1][i];       upd(ans, 1ll * c0 * c0 % P * a[i] % P);       upd(ans, -1ll * c1 * c1 % P * a[i] % P);       if (par[i]) {         c0 = c[0][par[i]] - cnt[1][i];         c1 = c[1][par[i]] - cnt[0][i];         upd(ans, 1ll * c0 * c0 % P * a[i] % P);         upd(ans, -1ll * c1 * c1 % P * a[i] % P);       }       for (int j = (0); j < ((int)g[i].size()); j++) {         int v = g[i][j];         if (v != par[i]) {           c0 = cnt[0][v];           c1 = cnt[1][v];           upd(ans, 1ll * c0 * c0 % P * a[i] % P);           upd(ans, -1ll * c1 * c1 % P * a[i] % P);         }       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define Input(v, n) fr(i, n) cin >> v[i];   #define checkk(v, n) fr(i, n) cout << v[i] <<     << endl;   #define sort(v) sort(v.begin(), v.end());   #define int long long int   #define double long double   #define fr(i, n) for (int i = 0; i < n; i++)   #define frr(i, s, e) for (int i = s; i <= e; i++)   #define rfr(i, s, e) for (int i = s; i >= e; i--)   #define fix(f,n) fixed<<setprecision(n)<<f   #define endl   n    #define pb push_back   #define mp make_pair   #define mod 1000000007      int test;   double v,ans;      void add(double &c,double &m,double &p,int i,double t){      if(i==0){          if(m==0) p+=t;          else {              t=t/2.0;              m+=t,p+=t;          }      }      else{          if(c==0) p+=t;          else {              t=t/2.0;              c+=t,p+=t;          }      }   }      void calc(double c,double m,double p,double val,double count){       if(c<0.000001) c=0;       if(m<0.000001) m=0;          double t1=c,t2=m,t3=p;       ans+=(count*(val*p));              if(c!=0){           double nan=val*c;           if(c<=v) add(c,m,p,0,c),c=0,calc(c,m,p,nan,count+1.0);           else  add(c,m,p,0,v),c=c-v,calc(c,m,p,nan,count+1.0);       }       c=t1,m=t2,p=t3;       if(m!=0){           double nan=val*m;           if(m<=v) add(c,m,p,1,m),m=0,calc(c,m,p,nan,count+1.0);           else  add(c,m,p,1,v),m=m-v,calc(c,m,p,nan,count+1.0);       }          }      void solve()   {          ans=0.0;       double c,m,p;       cin>>c>>m>>p>>v;       calc(c,m,p,1.0,1.0);       cout<<fix(ans,12)<<endl;   }      int32_t main()   {       ios_base::sync_with_stdio(false);       cin.tie(0);               cin>>test;       //test=1;       while (test--)       {           solve();       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> numbers;   unsigned n = 2;   unsigned k = 5;   int taken[100];   void print(unsigned i) {     unsigned l;     string str =   ;     for (l = 0; l <= i - 1; l++) str += (taken[l] + 1) +  0 ;     numbers.push_back(str);   }   void variate(unsigned i) {     unsigned j;     if (i >= k) {       print(i);       return;     }     for (j = 0; j < n; j++) {       taken[i] = j;       variate(i + 1);     }   }   int main(void) {     for (unsigned i = 1; i < 11; i++) {       k = i;       variate(0);     }     string input;     cin >> input;     for (int i = 0; i < input.size(); i++) {       if (input[i] ==  4 )         input[i] =  1 ;       else         input[i] =  2 ;     }     for (int i = 0; i < numbers.size(); i++) {       if (numbers[i] == input) cout << i + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long INF = (long long)2e18;   const int N = (int)1e6 + 77;   int n;   long long a[N];   long long solve(long long d) {     long long ans = 0;     long long cur = 0;     for (int i = 0; i < n; i++) {       long long h = a[i];       long long z = min(h, d - cur);       h -= z;       cur += z;       if (cur <= d / 2) ans += cur;       if (cur > d / 2) ans += d - cur;       if (cur == d) cur = 0;       if (h > 0) {         h %= d;         cur = h;         if (cur <= d / 2) ans += cur;         if (cur > d / 2) ans += d - cur;       }     }     if (cur != 0) throw;     return ans;   }   int main() {     scanf( %d , &n);     long long sum = 0;     for (int i = 0; i < n; i++) {       scanf( %lld , &a[i]);       sum += a[i];     }     if (sum == 1) {       printf( -1 n );       return 0;     }     long long ans = INF;     for (long long x = 2; x * x <= sum; x++) {       if (sum % x) continue;       ans = min(ans, solve(x));       while (sum % x == 0) sum /= x;     }     if (sum > 1) ans = min(ans, solve(sum));     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, finans = 0;   int a[N], ans[N], sieve[N], countprime[N];   vector<int> primes[N];   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       ans[i] = 1;     }     for (int i = 2; i <= 1e5; i++) sieve[i] = 1;     for (int i = 2; i <= 1e5; i++) {       if (sieve[i]) {         for (int j = 1; i * j <= 1e5; j++) {           primes[i * j].push_back(i);           sieve[i * j] = 0;         }       }     }     for (int i = n; i >= 1; i--) {       for (auto it : primes[a[i]]) ans[i] = max(ans[i], countprime[it] + 1);       for (auto it : primes[a[i]]) countprime[it] = max(countprime[it], ans[i]);       finans = max(ans[i], finans);     }     cout << finans;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n = 0;     string s;     long long int res = 0ll;     cin >> n;     cin >> s;     res = (1ll * n * (n + 1)) / 2ll - 1ll * n;     for (int i = 0; i + 1 < n; ++i) {       if (s[i] != s[i + 1]) {         int j;         for (j = i + 1; j < n; ++j) {           if (s[i] == s[j]) break;         }         res -= (j - i - 1);       }     }     reverse(s.begin(), s.end());     for (int i = 0; i + 1 < n; ++i) {       if (s[i] != s[i + 1]) {         int j;         for (j = i + 1; j < n; ++j) {           if (s[i] == s[j]) break;         }         res -= (j - i - 2);       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void out(T x) {     cout << x << endl;     exit(0);   }   const int maxn = 1e6 + 5;   vector<int> get(map<int, vector<int>> mp) {     vector<int> res;     for (auto p : mp) {       for (auto x : p.second) {         res.push_back(x);       }     }     return res;   }   int n;   map<int, vector<int>> mp;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       mp[x].push_back(i + 1);     }     vector<vector<int>> ans;     bool ok = false;     int val = -1;     vector<int> v;     for (auto p : mp) {       v.push_back(p.first);       if (int(p.second.size()) >= 3) {         val = p.first;         ok = true;         break;       }     }     map<int, vector<int>> _mp = mp;     if (ok) {       int x = val;       swap(mp[x][0], mp[x][1]);       ans.push_back(get(mp));       mp = _mp;       swap(mp[x][0], mp[x][2]);       ans.push_back(get(mp));       mp = _mp;       swap(mp[x][1], mp[x][2]);       ans.push_back(get(mp));       mp = _mp;     } else {       int N = v.size();       int val1, val2;       for (int i = 0; i < N; i++) {         for (int j = i + 1; j < N; j++) {           if (int(mp[v[i]].size()) >= 2 && int(mp[v[j]].size()) >= 2) {             val1 = v[i];             val2 = v[j];             ok = true;           }         }       }       if (!ok) out( NO );       ans.push_back(get(mp));       mp = _mp;       swap(mp[val1][0], mp[val1][1]);       ans.push_back(get(mp));       mp = _mp;       swap(mp[val2][0], mp[val2][1]);       ans.push_back(get(mp));       mp = _mp;     }     cout <<  YES  << endl;     for (auto p : ans) {       for (auto x : p) cout << x <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int mod = 1000000007;   const double eps = 1e-6;   const double PI = acos(-1);   int tar, n, tot, a[N], hs[N], cnt[N], mx[N], now[N];   vector<int> vc;   bool check(int add) {     vc.clear();     int c = tar;     int p = mx[c];     while (c) {       if (add > c) add = 0;       while (!now[p] && p) p--;       p = min(p, mx[c]);       if (!p && !add) break;       if (p && hs[p] >= add) {         vc.push_back(p);         int v = hs[p], num = min(now[p], c / v);         now[p] -= num;         c -= num * v;       } else {         c -= add;         add = 0;       }     }     for (auto& x : vc) now[x] = cnt[x];     return c;   }   int main() {     scanf( %d%d , &tar, &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       hs[++tot] = a[i];     }     sort(hs + 1, hs + tot + 1);     tot = unique(hs + 1, hs + tot + 1) - hs - 1;     for (int i = 1; i <= n; i++)       cnt[lower_bound(hs + 1, hs + tot + 1, a[i]) - hs]++;     for (int i = 1; i <= tot; i++) now[i] = cnt[i];     for (int i = 1; i <= tar; i++)       mx[i] = upper_bound(hs + 1, hs + tot + 1, i) - hs - 1;     for (int i = 1; i <= tar; i++) {       if (check(i)) {         printf( %d n , i);         return 0;       }     }     puts( Greed is good );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long x[2005], y[2005];   long long c[2005];   long long k[2005];   bool vis[2005];   long long dis[2005];   long long tower[2005];   long long diss[2005];   long long way[2005][2005];   long long townum = 0;   long long add[2005][2];   long long addnum = 0;   long long ans = 0;   void pri() {     printf( %lld n , ans);     printf( %lld n , townum);     for (int i = 1; i <= townum; i++) {       printf( %lld  , tower[i]);     }     printf(  n%lld n , addnum);     for (int i = 1; i <= addnum; i++) {       printf( %lld %lld n , add[i][0], add[i][1]);     }   }   void init() {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         way[i][j] = (abs(x[i] - x[j]) + abs(y[i] - y[j])) * (k[i] + k[j]);       }     }     for (int i = 1; i <= 2003; i++) dis[i] = 1e18;     for (int i = 1; i <= n; i++) way[i][0] = way[0][i] = c[i];   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld%lld , &x[i], &y[i]);     }     int minn = 1;     for (int i = 1; i <= n; i++) {       scanf( %lld , &c[i]);     }     for (int i = 1; i <= n; i++) {       scanf( %lld , &k[i]);     }     init();     dis[0] = 0;     for (int i = 0; i <= n; i++) {       long long ma = 1e18 + 10;       int id = -1;       for (int j = 0; j <= n; j++) {         if (!vis[j] && dis[j] < ma) {           id = j;           ma = dis[j];         }       }       vis[id] = true;       ans += dis[id];       if (id != 0) {         if (diss[id] != 0) {           add[++addnum][0] = diss[id];           add[addnum][1] = id;         } else {           tower[++townum] = id;         }       }       for (int j = 0; j <= n; j++) {         if (!vis[j]) {           if (dis[j] > way[id][j]) {             dis[j] = way[id][j];             diss[j] = id;           }         }       }     }     pri();   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int INF = 1000000000;   const int MOD = 1000000007;   const int base = 1000 * 1000 * 1000;   int main() {     int n, m;     cin >> n >> m;     int l = 1, r = n;     string str, str1, str2, str3;     int t;     for (int i = 0; i < m; i++) {       cin >> str >> str1 >> str2 >> str3 >> t;       if (str2 ==  left ) {         if (t <= r) {           r = t - 1;         }       } else {         if (t >= l) {           l = t + 1;         }       }       if (l > r) {         cout << -1;         return 0;       }     }     cout << r - l + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int X1[127], X2[128], Y1[111], Y2[105];   bool u[134][134];   vector<int> res;   int check(int xx1, int yy1, int x2, int y2) {     if (x2 < 0 || y2 < 0 || x2 >= n || y2 >= m || u[x2][y2]) return 0;     if (xx1 > x2) swap(xx1, x2);     if (yy1 > y2) swap(yy1, y2);     if (xx1 != x2) {       xx1++;       y2++;     } else {       x2++;       yy1++;     }     for (int i = 0; i < k; i++) {       int x3 = max(xx1, X1[i]);       int y3 = max(yy1, Y1[i]);       int x4 = min(x2, X2[i]);       int y4 = min(y2, Y2[i]);       if (x3 < x4 && y3 <= y4 || x3 <= x4 && y3 < y4) return 0;     }     return 1;   }   int go(int i, int j) {     int t = 1;     u[i][j] = 1;     if (check(i, j, i + 1, j)) t += go(i + 1, j);     if (check(i, j, i - 1, j)) t += go(i - 1, j);     if (check(i, j, i, j + 1)) t += go(i, j + 1);     if (check(i, j, i, j - 1)) t += go(i, j - 1);     return t;   }   int main() {     cin >> n >> m >> k;     for (int i = 0; i < k; i++) cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (!u[i][j]) res.push_back(go(i, j));     sort(res.begin(), res.end());     for (int i = 0; i < res.size(); i++) cout << res[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 10005;   int a[26][26][maxn];   char s[maxn];   int main(int argc, char const *argv[]) {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> s;     n = strlen(s);     for (int i = n; i < 2 * n - 1; ++i) {       s[i] = s[i - n];     }     for (int i = 0; i < n; ++i) {       for (int j = 1; j < n; ++j) {         a[s[i] -  a ][s[i + j] -  a ][j]++;       }     }     int res = 0;     for (int i = 0; i < 26; ++i) {       int c = 0;       for (int j = 1; j < n; ++j) {         int t = 0;         for (int k = 0; k < n; ++k) {           if (s[k] ==  a  + i) {             if (a[s[k] -  a ][s[j + k] -  a ][j] == 1) {               ++t;             }           }         }         c = max(c, t);       }       res += c;     }     cout << (double)res / n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000005];   int main() {     int n;     while (cin >> n) {       for (int i = n; i >= 0; i--)         if (!a[i]) {           int mm = (1 << ((int)(log2(i) + 1))) - 1;           a[i] = mm ^ i;           a[mm ^ i] = i;         }       long long int ans = 0;       for (int i = 0; i <= n; i++) {         ans += a[i] ^ i;       }       cout << ans << endl;       for (int i = 0; i <= n; i++) {         cout << a[i];         if (i != n)           cout <<    ;         else           cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast ,  unroll-loops ,  omit-frame-pointer ,  inline )   #pragma GCC option( arch=native ,  tune=native ,  no-zero-upper )   #pragma GCC target( avx2 )   using namespace std;   template <typename T>   void maxtt(T& t1, T t2) {     t1 = max(t1, t2);   }   template <typename T>   void mintt(T& t1, T t2) {     t1 = min(t1, t2);   }   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   const long long MOD2 = (long long)1000000007 * (long long)1000000007;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 1000000007) {     x += y;     if (x >= mod) x -= mod;     if (x < 0) x += mod;     assert(x >= 0 && x < mod);   }   void et(int x = -1) {     printf( %d n , x);     exit(0);   }   long long fastPow(long long x, long long y, int mod = 1000000007) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }   vector<int> sufPaliLen[(100035)];   int a[(100035)], p[(100035)], q[(100035)], pos, c[(100035)], xyx;   void add(int pos) {     sufPaliLen[pos].clear();     if (a[pos] == a[pos - 1]) sufPaliLen[pos].push_back(2);     for (int x : sufPaliLen[pos - 1]) {       if (a[pos - 1 - x] == a[pos]) sufPaliLen[pos].push_back(x + 2);     }   }   bool ckEvenPali(int l, int r) {     for (int z : sufPaliLen[r]) {       if (z == r - l + 1) return 1;     }     return 0;   }   int qy() {     int ans = xyx + c[pos];     int cur = pos;     while (p[cur] && q[pos] <= cur - p[cur] / 2) {       cur -= p[cur] / 2;       ans++;     }     return ans;   }   void fmain(int tid) {     scanf( %d , &n);     q[0] = 1;     for (int(i) = 1; (i) <= (int)(n); (i)++) {       pos++;       scanf( %d , a + pos);       bool fg = 0;       add(pos);       if (!sufPaliLen[pos].empty()) {         int len = sufPaliLen[pos][0];         if (ckEvenPali(pos - len / 2 - len + 1, pos - len / 2)) {           pos -= len;           xyx += 2;           fg = 1;         }       }       if (!fg) {         p[pos] = sufPaliLen[pos].empty() ? 0 : sufPaliLen[pos][0];         q[pos] = q[pos - 1];         c[pos] = c[pos - 1];         if (ckEvenPali(q[pos], pos)) {           q[pos] += (pos - q[pos] + 1) / 2;           c[pos]++;         }       }       printf( %d  , qy());     }   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 202;   const int C = 6000;   int dp[N][C];   int n, k;   int a[N][2];   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) {       long long x;       scanf( %lld , &x);       while (x % 5 == 0) {         a[i][0]++;         x /= 5;       }       while (x % 2 == 0) {         a[i][1]++;         x /= 2;       }     }     for (int i = 0; i <= k; i++)       for (int j = 0; j < C; j++) dp[i][j] = -1;     dp[0][0] = 0;     for (int i = 0; i < n; i++)       for (int j = k - 1; j >= 0; j--)         for (int x = 0; x < C; x++) {           if (dp[j][x] == -1) continue;           dp[j + 1][x + a[i][0]] =               max(dp[j + 1][x + a[i][0]], dp[j][x] + a[i][1]);         }     int ans = 0;     for (int i = 0; i < C; i++) ans = max(ans, min(dp[k][i], i));     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int cnt = 0;     int num;     for (int i = 0; i != n; ++i) {       scanf( %d , &num);       if (num % 2 == 1) ++cnt;     }     if (cnt >= 1)       printf( First n );     else       printf( Second n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, maxx;   vector<int> v, cnt;   map<int, int> ma;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     maxx = min(2, n);     v.resize(n + 1);     cnt.resize(100001);     for (int i = 1; i <= n; i++) {       cin >> v[i];       map<int, int>::iterator it;       it = ma.find(cnt[v[i]]);       if (it != ma.end()) {         it->second -= 1;         if (it->second == 0) ma.erase(cnt[v[i]]);       }       cnt[v[i]] += 1;       it = ma.find(cnt[v[i]]);       if (it == ma.end())         ma.insert(pair<int, int>(cnt[v[i]], 1));       else         it->second += 1;       int chk = 1;       if (ma.size() == 1) {         chk = 0;         pair<int, int> ff;         ff = *ma.begin();         if (ff.first == 1)           chk = 1;         else if (ff.second == 1)           chk = 1;       }       if (ma.size() > 2) chk = 0;       if (ma.size() == 2) {         chk = 0;         pair<int, int> ff, ss;         it = ma.begin();         ff = *it;         it++;         ss = *it;         if ((ff.first == 1 && ff.second == 1) ||             (ss.first == ff.first + 1 && ss.second == 1))           chk = 1;       }       if (chk == 1) maxx = max(maxx, i);     }     cout << maxx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   mt19937 rnf(2106);   const int N = 200005;   int n, m;   int x[N], y[N];   int d[N];   queue<int> q[N];   int dist(int x1, int y1, int x2, int y2) { return abs(x1 - x2) + abs(y1 - y2); }   int ans[N];   bool stg(int s) {     for (int i = 1; i <= m; ++i) {       while (!q[d[i]].empty()) q[d[i]].pop();     }     for (int i = 1; i <= m; ++i) q[d[i]].push(i);     for (int i = 0; i < n; ++i) ans[i] = -1;     for (int i = s; i < n; i += 2) {       int dd = dist(x[i], y[i], x[(i - 1 + n) % n], y[(i - 1 + n) % n]) +                dist(x[i], y[i], x[(i + 1) % n], y[(i + 1) % n]);       if (q[dd].empty()) return false;       ans[i] = q[dd].front();       q[dd].pop();     }   }   void solv() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %d%d , &x[i], &y[i]);     for (int i = 1; i <= m; ++i) {       scanf( %d , &d[i]);     }     if (stg(0)) {       printf( YES n );       for (int i = 0; i < n; ++i) printf( %d  , ans[i]);       printf(  n );     } else if (stg(1)) {       printf( YES n );       for (int i = 0; i < n; ++i) printf( %d  , ans[i]);       printf(  n );     } else       printf( NO n );   }   int main() {     solv();     return 0;   }