malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void Merge(int arr1[], int arr2[], int l, int m, int r) {     int n1 = m - l + 1;     int n2 = r - m;     int L1[n1], L2[n1];     int R1[n2], R2[n1];     for (int i = 0; i < n1; i++) {       L1[i] = arr1[i + l];       L2[i] = arr2[i + l];     }     for (int i = 0; i < n2; i++) {       R1[i] = arr1[m + i + 1];       R2[i] = arr2[m + i + 1];     }     int L = 0;     int R = 0;     int k = l;     while (L < n1 && R < n2) {       if (L1[L] < R1[R]) {         arr1[k] = L1[L];         arr2[k] = L2[L];         L++;       } else {         arr1[k] = R1[R];         arr2[k] = R2[R];         R++;       }       k++;     }     while (L < n1) {       arr1[k] = L1[L];       arr2[k] = L2[L];       L++;       k++;     }     while (R < n2) {       arr1[k] = R1[R];       arr2[k] = R2[R];       R++;       k++;     }   }   void mergeSort(int arr1[], int arr2[], int l, int r) {     if (l < r) {       int m = l + (r - l) / 2;       mergeSort(arr1, arr2, l, m);       mergeSort(arr1, arr2, m + 1, r);       Merge(arr1, arr2, l, m, r);     }   }   int reduce(int arr1[], int m) {     int value = 0;     for (int i = 0; i < m; i++) {       value += arr1[i];       if (value > 0) {         return i;       }     }     return m;   }   int main() {     int n, m;     cin >> n >> m;     int arr[n - 1][m];     int index[n - 1][m];     for (int i = 0; i < n - 1; i++) {       for (int j = 0; j < m; j++) {         index[i][j] = j + 1;       }     }     for (int i = 0; i < m; i++) {       int values[n];       for (int j = 0; j < n; j++) {         cin >> values[j];       }       for (int j = 0; j < n - 1; j++) {         arr[j][i] = values[n - 1] - values[j];       }     }     int max = 0;     int max_index = 0;     for (int i = 0; i < n - 1; i++) {       mergeSort(arr[i], index[i], 0, m - 1);       int k = reduce(arr[i], m);       if (k > max) {         max = k;         max_index = i;       }     }     cout << m - max << endl;     for (int i = max; i < m - 1; i++) {       cout << index[max_index][i] <<    ;     }     if (m - max > 0) {       cout << index[max_index][m - 1];     }   }
#include <bits/stdc++.h>   using namespace std;   bool check(string all, string ans) { return all.size() == ans.size(); }   bool checkChar(string all, string ans) {     vector<char> v1, v2;     for (int i = 0; i < all.size(); i++) v1.push_back(all[i]);     for (int i = 0; i < ans.size(); i++) v2.push_back(ans[i]);     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     for (int i = 0; i < v1.size(); i++) {       if (v1[i] != v2[i]) {         return false;         break;       }     }     return true;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     string q, s, all;     int n;     vector<string> v;     for (int i = 0; i < 3; i++) {       string New;       cin >> q;       for (int k = 0; k < q.size(); k++) {         if (isalpha(q[k])) New += tolower(q[k]);       }       all += New;       v.push_back(New);     }     cin >> n;     for (int i = 0; i < n; i++) {       string NewS;       cin >> s;       for (int k = 0; k < s.size(); k++) {         if (isalpha(s[k])) NewS += tolower(s[k]);       }       vector<int> pos;       for (int m = 0; m < 3; m++) {         size_t found = NewS.find(v[m]);         if (found != string::npos) {           pos.push_back(found);         } else           pos.push_back(-1);       }       sort(pos.begin(), pos.end());       if (pos.front() == -1 || pos[0] != 0) {         cout <<  WA  << endl;       } else {         if (check(all, NewS) && checkChar(all, NewS))           cout <<  ACC  << endl;         else           cout <<  WA  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, k, num;     cin >> n >> a >> b >> k;     vector<int> need;     int cnt = 0;     for (int i = 0; i < n; i++) {       cin >> num;       if (num <= a) {         cnt++;         continue;       }       if (num % (a + b) == 0) {         int to_add = (a + b) / a;         if ((a + b) % a != 0) to_add++;         need.push_back(to_add - 1);       } else {         int temp = num / (a + b);         int req = num - temp * (a + b);         int to_add = req / a;         if (req % a != 0) to_add++;         need.push_back(to_add - 1);       }     }     sort(need.begin(), need.end());     for (int i = 0; i < need.size(); i++) {       if (need[i] <= k) {         k = k - need[i];         cnt++;       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve() {     int N;     cin >> N;     if (N % 2) {       N -= 9;       if (N < 0 || N == 2) return -1;       return 1 + N / 4;     } else {       if (N < 4) return -1;       return N / 4;     }   }   int main() {     int Q;     cin >> Q;     while (Q--) cout << solve() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10101;   char s[N], t[N * 100];   int ne[N][26];   int main() {     scanf( %s , s);     int lens = strlen(s);     for (int i = lens; i >= 0; --i) {       for (int d = 0; d < (26); ++d) ne[i][d] = i == lens ? lens : ne[i + 1][d];       if (i != lens) ne[i][s[i] -  a ] = i;     }     scanf( %s , t);     int len = strlen(t);     int cnt = 0;     for (int i = 0, j = 0; i < len; i = j) {       ++cnt;       for (int c = 0; j < len && ne[c][t[j] -  a ] != lens; j++) {         c = ne[c][t[j] -  a ] + 1;       }       if (i == j) {         puts( -1 );         return 0;       }     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> V, L, Q;   vector<string> P;   map<int, int> M;   set<char> S;   set<char>::iterator it;   long long n, m, a, b, c, d, e, f, cnt, x, y, z, t;   string s, p, ans, temp;   long long arr[1001];   bool xy = 0;   char bd;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     cin >> s;     for (int i = 0; i < n; i++)       if (s[i] ==  G  or s[i] ==  T ) {         for (int j = i + m; j < n; j += m) {           if (s[j] ==  # ) {             cout <<  NO ;             return 0;             ;           }           if (s[j] ==  G  or s[j] ==  T ) {             cout <<  YES ;             return 0;             ;           }         }       }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   set<long long> s, s1;   std::set<long long>::iterator l, h;   int main() {     long long n, i, j, k, a, p, low, high, m;     bool flag = false;     scanf( %lld %lld %lld , &n, &k, &a);     scanf( %lld , &m);     a++;     p = (n + 1) / a;     long long q = k;     s.insert(0);     s.insert(n + 1);     s1.insert(0);     s1.insert(-n - 1);     for (i = 1; i <= m; i++) {       scanf( %lld , &k);       if (!flag && k <= n && k >= 1) {         l = s.lower_bound(k);         if (l != s.begin()) --l;         h = s1.lower_bound(-k);         low = *l;         if (h != s1.begin()) --h;         high = -*h;         long long z = p - ((high - low) / a) + (k - low) / a + (high - k) / a;         if (z < q) {           printf( %lld , i);           flag = true;         }         p = z;         s.insert(k);         s1.insert(-k);       }     }     if (!flag) printf( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(false);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     int cur = 1, cnt = 0;     vector<int> dp(n + 1, 0);     for (int i = 0; i < n; i++) dp[a[i]] = dp[a[i] - 1] + 1;     for (int i = 1; i < n + 1; i++) cnt = max(cnt, dp[i]);     cout << n - cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int b1, b2, h1, h2, n, h, i, j, k, a, b;     cin >> n >> h >> a >> b >> k;     if (a > b) {       swap(a, b);     }     while (k--) {       long long int ans = 0;       cin >> b1 >> h1 >> b2 >> h2;       if (b1 == b2) {         ans += abs(h1 - h2);       } else if (h1 >= b && h2 >= b) {         ans += (h1 - b);         ans += abs(b1 - b2);         ans += (h2 - b);       } else if (h1 <= a && h2 <= a) {         ans += (a - h1);         ans += abs(b1 - b2);         ans += (a - h2);       } else {         ans += abs(b1 - b2);         ans += abs(h1 - h2);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cc(int x) {     for (int i = 2; i * i <= x; i++)       if (x % i == 0 && x != 2) return false;     return true;   }   int pow(int i, int j) {     int x = 1;     while (j--) {       x *= i;     }     return x;   }   int main() {     vector<int> v;     int n;     cin >> n;     int c = 0;     for (int i = 2; i <= n; i++) {       if (cc(i)) {         for (int j = 1; pow(i, j) <= n; j++) {           v.push_back(pow(i, j));         }       }     }     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int b[305];   vector<int> g[305];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , b + i);     b[0] = 0;     g[0].push_back(0);     for (int i = 1; i <= n; i++) {       if (b[i] > b[i - 1]) {         int temp = b[i] - b[i - 1];         for (int j = g[i - 1].size() - 1; j >= 0; j--) {           int now = g[i - 1][j];           if (temp == 0) break;           if (temp > 9 - now) {             g[i].push_back(9);             temp -= (9 - now);           } else {             g[i].push_back(now + temp);             temp = 0;             for (int k = j - 1; k >= 0; k--) g[i].push_back(g[i - 1][k]);           }         }         while (temp) {           if (temp >= 9) {             g[i].push_back(9);             temp -= 9;           } else {             g[i].push_back(temp);             temp = 0;           }         }       } else {         int temp = b[i - 1] - b[i] + 1;         int flag = g[i - 1].size() - 1;         int sum = 0;         for (int j = g[i - 1].size() - 1; j >= 0; j--) {           sum += g[i - 1][j];           if (sum >= temp) {             flag = j - 1;             break;           }         }         while (flag >= 0 && g[i - 1][flag] == 9) {           flag--;         }         int p = flag;         for (int j = g[i - 1].size() - 1; j >= flag + 1; j--)           g[i].push_back(g[i - 1][j]);         sort(g[i].begin(), g[i].end());         for (int j = 0; j < g[i].size(); j++) {           if (temp > g[i][j]) {             temp -= g[i][j];             g[i][j] = 0;           } else {             g[i][j] -= temp;             temp = 0;             break;           }         }         reverse(g[i].begin(), g[i].end());         int ad = 1;         for (int j = p; j >= 0; j--) {           int now = g[i - 1][j];           if (now + ad == 10) {             g[i].push_back(9);             ad = 1;           } else {             g[i].push_back(now + ad);             ad = 0;           }         }         if (ad == 1) g[i].push_back(1);       }       reverse(g[i].begin(), g[i].end());     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j < g[i].size(); j++) printf( %d , g[i][j]);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   char a;   int b, ans1, c[10], d;   int main() {     cin >> a >> b;     if (a ==  A ) {       ans1 = 1;       for (; b > 0; b /= 10) c[++d] = b % 10;       for (int i = 1; i <= d; i++) {         if (c[i] == 1)           ans1 += 10;         else           ans1 += c[i];       }     }     if (a !=  A ) {       for (; b > 0; b /= 10) c[++d] = b % 10;       for (int i = 1; i <= d; i++) {         if (c[i] == 1)           ans1 += 10;         else           ans1 += c[i];       }     }     cout << ans1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<string> A(8);     int mnA = 1e3, mnB = 1e3;     for (int i = 0; i < 8; i++) cin >> A[i];     for (int i = 0; i < 8; i++)       for (int u = 0; u < 8; u++) {         if (A[i][u] ==  B ) {           bool b = false;           for (int j = i + 1; j < 8; j++)             if (A[j][u] ==  B  || A[j][u] ==  W ) b = true;           if (!b) mnB = min(mnB, 7 - i);         } else if (A[i][u] ==  W ) {           bool b = false;           for (int j = i - 1; j >= 0; j--) {             if (A[j][u] ==  B  || A[j][u] ==  W ) b = true;           }           if (!b) mnA = min(mnA, i);         }       }     if (mnA <= mnB)       cout <<  A ;     else       cout <<  B ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 30;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int lim = 15;   int n, a[300010];   int q;   long long c[300010];   struct my {     int a, b, id;     my() {}     my(int a, int b, int id) : a(a), b(b), id(id) {}     bool operator<(const my &u) const {       if (b == u.b) return a % b < u.a % b;       return b < u.b;     }   } b[300010];   long long ans[300010];   int l;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     scanf( %d , &q);     for (int i = 0; i < q; i++) {       int w, e;       scanf( %d%d , &w, &e);       b[i] = my(w, e, i);     }     sort(b, b + q);     for (int i = 0; i < q; i++) {       if (b[i].b >= 500) {         int id = b[i].id;         for (int j = b[i].a; j <= n; j += b[i].b) ans[id] += a[j];         continue;       }       if (i == 0 || b[i].b != b[i - 1].b ||           (b[i].a % b[i].b != b[i - 1].a % b[i - 1].b)) {         l = 1;         int q = b[i].a, w = b[i].b;         int t = q % w;         if (t == 0) t = w;         for (int j = t; j <= n; j += w) c[l] = c[l - 1] + a[j], l++;         ans[b[i].id] = c[l - 1] - c[(q + w - 1) / w - 1];       } else {         int q = b[i].a, w = b[i].b;         ans[b[i].id] = c[l - 1] - c[(q + w - 1) / w - 1];       }     }     for (int i = 0; i < q; i++) printf( %I64d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fu(vector<int> v) {     int i;     for (i = 0; i < 10; i++) {       if (v[i] == 0) return i;     }     return i;   }   int ru(vector<int> v) {     int i;     for (i = 9; i >= 0; i--) {       if (v[i] == 0) return i;     }     return i;   }   int main() {     int n, k, i, ch = 0, ch1 = 9;     cin >> n;     string a;     cin >> a;     int a1 = 0, ch2 = 0;     vector<int> ans(10, 0);     for (i = 0; i < n; i++) {       if (a[i] ==  L ) {         ans[ch] = 1;         ch = fu(ans);       } else if (a[i] ==  R ) {         ans[ch1] = 1;         ch1 = ru(ans);       } else if (isdigit((int)a[i])) {         int ch2 = (int)a[i] - 48;         ans[ch2] = 0;         ch = fu(ans);         ch1 = ru(ans);       }     }     for (i = 0; i < 10; i++) cout << ans[i];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, x;     cin >> t;     while (t--) {       cin >> x;       long long a, b;       a = x % 14;       b = x / 14;       if ((a <= 6 && a >= 1) && b > 0)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7, siz = 1e6 + 5;   long long q, n, m, a[siz], rot[66];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> q;     while (q--) {       long long op;       cin >> op;       if (op <= 2) {         long long node, k;         cin >> node >> k;         long long dep = log2l(node);         long long sz = 1LL << dep;         if (k >= 0)           k %= sz;         else {           k = sz + k;           k %= sz;         }         rot[dep] += k;         rot[dep] %= sz;         if (op == 2) {           long long incr = 2 * k;           for (long long i = dep + 1; i <= 60; i++) {             rot[i] += incr;             rot[i] %= (1LL << i);             incr *= 2;           }         }         continue;       }       long long node;       cin >> node;       long long dep = log2l(node);       long long pos_start = node - (1LL << dep);       long long pos = (rot[dep] + pos_start) % (1LL << dep);       vector<long long> out;       while (dep > 0) {         long long nxt = pos;         long long incr = (1LL << dep) - rot[dep];         long long new_pos = (pos + incr) % (1LL << dep);         long long inp = (1LL << dep) + new_pos;         out.push_back(inp);         pos = nxt + (1LL << dep);         pos /= 2;         dep--;       }       out.push_back(1);       for (auto x : out) cout << x <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100 * 1000 + 10;   int n, t[MAXN];   vector<int> v;   int main() {     cin >> n >> t[0];     v.push_back(1);     for (int i = 1; i < n; i++) {       cin >> t[i];       if (t[i] == t[i - 1])         v[(int)v.size() - 1]++;       else         v.push_back(1);     }     int ans = 0;     for (int i = 0; i < (int)v.size() - 1; i++) {       ans = max(ans, 2 * min(v[i], v[i + 1]));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long k, n;     cin >> n >> k;     long long d, f = 0, f2 = 0;     d = n / k;     long long a[n + 1];     if (d < 3) {       cout <<  -1  << endl;     } else {       while (n--) cout << ((n / k) % 2 + n) % k + 1 <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % 1000000007;       y = y / 2;       if (y != 0) x = (x * x) % 1000000007;     }     return res;   }   long long ans[2000005], n0[2000005], n1[2000005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t, n, i, j;     cin >> t;     n0[1] = 1, n1[1] = 0, ans[0] = ans[1] = ans[2] = 0, ans[3] = 1;     for (i = 2; i <= 2000000; i++) {       n0[i] = 2 * n1[i - 1] + n0[i - 1];       n0[i] = n0[i] % 1000000007;       n1[i] = n0[i - 1];       if (i >= 4) {         ans[i] = n1[i - 1] + ans[i - 3];         ans[i] = ans[i] % 1000000007;       }     }     while (t--) {       cin >> n;       cout << (4 * ans[n]) % 1000000007 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Q, N, M, K, L;   int A[5001];   int MAPPING[10001];   int CHK[10001];   int RET[10001];   map<int, int> MAP;   int map_idx = 0;   int main() {     ios::sync_with_stdio(false);     cin >> N;     for (int i = 0; i < N; i++) {       cin >> A[i];       if (A[i] == 0) continue;       int b = 1;       int x = A[i];       if (x < 0) x *= -1;       for (int j = 2; j * j <= x; j++) {         int a = 0;         while (x % j == 0) {           a++;           x /= j;         }         if (a & 1) b *= j;       }       b *= x;       if (A[i] < 0) b *= -1;       if (MAP.count(b) == 1)         MAPPING[i] = MAP[b];       else {         MAP[b] = map_idx++;         MAPPING[i] = MAP[b];       }     }     int now = 0;     for (int i = 0; i < N; i++) {       for (int j = i; j < N; j++) {         if (A[j] == 0) {           RET[max(now, 1)]++;           continue;         }         if (CHK[MAPPING[j]] == 0) {           now++;           CHK[MAPPING[j]] = 1;         }         RET[max(now, 1)]++;       }       now = 0;       memset(CHK, 0, sizeof(CHK));     }     for (int i = 1; i <= N; i++) cout << RET[i] <<    ;     cin >> N;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     vector<string> st;     vector<pair<string, string> > pr;     pr.push_back(make_pair( purple ,  Power ));     pr.push_back(make_pair( green ,  Time ));     pr.push_back(make_pair( blue ,  Space ));     pr.push_back(make_pair( orange ,  Soul ));     pr.push_back(make_pair( red ,  Reality ));     pr.push_back(make_pair( yellow ,  Mind ));     cin >> n;     string s;     for (int i = 0; i < n; i++) {       cin >> s;       st.push_back(s);     }     int cnt = 0;     vector<string> ans;     for (int i = 0; i < pr.size(); i++) {       int b = 0;       for (int j = 0; j < st.size(); j++)         if (pr[i].first == st[j]) {           b = 1;           break;         }       if (b == 0) {         cnt++;         ans.push_back(pr[i].second);       }     }     cout << cnt << endl;     for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double pi = acos(-1.0);   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int N = 2e5 + 10;   const int M = 100;   char ch[N];   int a[N];   int b[N];   int n;   vector<int> g[M];   int pos[M];   long long cnt;   void merge(int l, int mid, int r) {     int i = l, j = mid + 1;     for (int k = l; k <= r; k++) {       if (j > r || i <= mid && a[i] <= a[j])         b[k] = a[i++];       else         b[k] = a[j++], cnt += mid - i + 1;     }     for (int k = l; k <= r; k++) a[k] = b[k];   }   void uqsort(int l, int r) {     if (l < r) {       int mid = (l + r) / 2;       uqsort(l, mid);       uqsort(mid + 1, r);       merge(l, mid, r);     }   }   void solve() {     for (int i = 0; i < M; i++) g[i].clear();     scanf( %d , &n);     scanf( %s , ch);     for (int i = 0; i < n; i++) {       g[ch[i] -  a ].push_back(n - i);     }     for (int i = 0; i < M; i++) sort(g[i].begin(), g[i].end());     memset(pos, 0, sizeof(pos));     for (int i = 1; i <= n; i++) {       int j = i - 1;       a[i] = g[ch[j] -  a ][pos[ch[j] -  a ]];       pos[ch[j] -  a ]++;     }     cnt = 0;     uqsort(1, n);     printf( %lld n , cnt);   }   int main() {     ios::sync_with_stdio(false);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double eps = 1e-9;   const int MAXN = 1010;   const int EN = MAXN * MAXN;   int n, m, D;   int a[MAXN], size, head[MAXN];   struct Node {     int x, y;   } arr[MAXN];   struct Edge {     int v, w, next;   } E[EN];   void init() {     size = 0;     memset(head, -1, sizeof(head));   }   void addEdge(int u, int v, int w) {     E[size].w = w;     E[size].v = v;     E[size].next = head[u];     head[u] = size++;   }   inline int dist(const Node& a, const Node& b) {     return abs(a.x - b.x) + abs(a.y - b.y);   }   int d[MAXN];   int dij(int src) {     memset(d, INF, sizeof(d));     d[src] = 0;     priority_queue<pair<int, int> > que;     que.push(make_pair(0, src));     while (!que.empty()) {       pair<int, int> x = que.top();       que.pop();       int u = x.second;       if (d[u] != x.first) continue;       for (int e = head[u]; e != -1; e = E[e].next) {         int v = E[e].v;         int w = d[u] + E[e].w - a[u];         if (w < d[v]) {           d[v] = w;           que.push(make_pair(d[v], v));         }       }     }     return d[n - 1];   }   int main() {     a[0] = 0;     while (~scanf( %d%d , &n, &D)) {       init();       a[n - 1] = 0;       for (int i = 1; i < n - 1; ++i) scanf( %d , &a[i]);       for (int i = 0; i < n; ++i) scanf( %d%d , &arr[i].x, &arr[i].y);       for (int i = 0; i < n; ++i) {         for (int j = i + 1; j < n; ++j) {           int dis = dist(arr[i], arr[j]);           addEdge(i, j, dis * D);           addEdge(j, i, dis * D);         }       }       printf( %d n , dij(0));     }     return 0;   }