malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100;   int a[maxn], b[maxn];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       int MIN1 = 0x7fffffff;       int MIN2 = 0x7fffffff;       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);         MIN1 = min(MIN1, a[i]);       }       for (int i = 1; i <= n; i++) {         scanf( %d , &b[i]);         MIN2 = min(MIN2, b[i]);       }       long long ans = 0;       for (int i = 1; i <= n; i++) {         if (a[i] - MIN1 == 0 && b[i] - MIN2 != 0) {           ans += (b[i] - MIN2);           continue;         }         if (a[i] - MIN1 != 0 && b[i] - MIN2 == 0) {           ans += (a[i] - MIN1);           continue;         }         if (a[i] - MIN1 > b[i] - MIN2) {           ans += (b[i] - MIN2);           a[i] -= (b[i] - MIN2);           ans += (a[i] - MIN1);         } else {           ans += (a[i] - MIN1);           b[i] -= (a[i] - MIN1);           ans += (b[i] - MIN2);         }       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m, x, y, i;     cin >> n >> m >> x >> y;     cout << x <<     << y << endl;     int k = x + 1;     int p = x - 1;     for (i = 1; i < m + 1; i++) {       if (i != y) cout << x <<     << i << endl;     }     int jj = 1;     while (k <= n) {       if (jj == 0) {         for (i = 1; i < m + 1; i++) {           cout << k <<     << i << endl;         }         jj = 1;       } else {         for (i = m; i >= 1; i--) {           cout << k <<     << i << endl;         }         jj = 0;       }       k++;     }     while (p >= 1) {       if (jj == 0) {         for (i = 1; i < m + 1; i++) {           cout << p <<     << i << endl;         }         jj = 1;       } else {         for (i = m; i >= 1; i--) {           cout << p <<     << i << endl;         }         jj = 0;       }       p--;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int wall[110][110] = {0};     int r, c;     scanf( %d %d%*c , &r, &c);     char a[110];     for (int i = 1; i < r; i++) gets(a);     int flag = 0;     int seg = 0;     for (int i = 0; i < c; i++) {       char x;       scanf( %c , &x);       if (flag == 0) {         if (x ==  B ) {           flag++;           seg++;         } else           continue;       } else {         if (x ==  B )           continue;         else           flag = 0;       }     }     printf( %d n , seg);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2012;   int f[N][N][2];   int n, m, k, flag;   int ex, ey;   inline int find(int x, int y, int p) {     if (y < 0) return y;     return f[x][y][p] == y ? y : f[x][y][p] = find(x, f[x][y][p], p);   }   int dis(int x, int y) { return abs(ex - x) + abs(ey - y); }   inline void chk(int &ans, int nx, int ny, int &x, int &y) {     int d = dis(nx, ny);     if (d < ans) {       ans = d, x = nx, y = ny;     } else if (ans == d) {       if (!flag) {         if (nx < x) {           x = nx, y = ny;         } else if (nx == x && ny < y)           y = ny;       } else {         if (ny < y) {           x = nx, y = ny;         } else if (ny == y && nx < x)           x = nx;       }     }   }   void update(int r, int &ans, int &x, int &y) {     int nx = r, ny = find(r, ey, 0);     if (ny > 0) chk(ans, nx, ny, x, y);     ny = find(r, ey, 1);     if (ny <= m) chk(ans, nx, ny, x, y);   }   int main() {     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++) f[i][j][0] = f[i][j][1] = j;     int x, y;     scanf( %d%d%d , &n, &m, &k);     if (n > m) swap(n, m), flag = 1;     while (k--) {       scanf( %d%d , &x, &y);       if (flag) swap(x, y);       ex = x, ey = y;       int d = 0, ans = ~0u >> 2, nx, ny;       while (d <= ans) {         int pre = ans;         int r = x - d;         if (r > 0 && r <= n) update(r, ans, nx, ny);         r = x + d;         if (r > 0 && r <= n) update(r, ans, nx, ny);         d++;       }       f[nx][ny][0] = ny - 1;       f[nx][ny][1] = ny + 1;       if (flag) swap(nx, ny);       printf( %d %d n , nx, ny);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const int INF = 1e9 + 10;   int n, current;   pair<int, int> best;   int ans[N], block[N], sz[N];   vector<int> tree[N], tree_c[N];   int dfs1(int i, int parent) {     sz[i] = 1;     for (int k = 0; k < tree[i].size(); ++k) {       int j = tree[i][k];       if (j != parent and !block[j]) sz[i] += dfs1(j, i);     }     return sz[i];   }   void dfs2(int i, int parent) {     int highest = current - sz[i];     for (int k = 0; k < tree[i].size(); ++k) {       int j = tree[i][k];       if (j == parent or block[j]) continue;       dfs2(j, i);       highest = max(highest, sz[j]);     }     if (highest < best.first) best = make_pair(highest, i);   }   int find_centroid(int i) {     current = dfs1(i, 0);     best = make_pair(INF, 0);     dfs2(i, 0);     return best.second;   }   int build(int i, int deep) {     int centroid = find_centroid(i);     block[centroid] = 1;     for (int k = 0; k < tree[centroid].size(); ++k) {       int j = tree[centroid][k];       if (block[j]) continue;       j = build(j, deep + 1);       tree_c[centroid].push_back(j);       tree_c[j].push_back(centroid);     }     return centroid;   }   bool solve(int root) {     ans[root] = 0;     queue<pair<int, int> > q;     q.push(make_pair(root, -1));     while (!q.empty()) {       int i = q.front().first;       int parent = q.front().second;       q.pop();       for (int k = 0; k < tree_c[i].size(); ++k) {         int j = tree_c[i][k];         if (j == parent) continue;         if (ans[i] + 1 > 25) return false;         ans[j] = ans[i] + 1;         q.push(make_pair(j, i));       }     }     return true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       int x, y;       scanf( %d %d , &x, &y);       --x, --y;       tree[x].push_back(y);       tree[y].push_back(x);     }     int root = build(0, 0);     if (!solve(root))       printf( Impossible! n );     else {       for (int i = 0; i < n; ++i) {         if (i) printf(   );         printf( %c , ans[i] +  A );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace fastIO {   bool IOerror = 0;   inline char nc() {     static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;     if (p1 == pend) {       p1 = buf;       pend = buf + fread(buf, 1, 100000, stdin);       if (pend == p1) {         IOerror = 1;         return -1;       }     }     return *p1++;   }   inline bool blank(char ch) {     return ch ==     || ch ==   n  || ch ==   r  || ch ==   t ;   }   inline long long read() {     bool sign = 0;     char ch = nc();     long long x = 0;     for (; blank(ch); ch = nc())       ;     if (IOerror) return 0;     if (ch ==  - ) sign = 1, ch = nc();     for (; ch >=  0  && ch <=  9 ; ch = nc()) x = x * 10 + ch -  0 ;     if (sign) x = -x;     return x;   }   };  // namespace fastIO   using namespace fastIO;   long long qpow(long long n, long long k) {     long long ans = 1;     while (k) {       if (k & 1) ans *= n, ans %= 998244353;       n *= n, n %= 998244353;       k >>= 1;     }     return ans;   }   char s[3000010];   long long fac[3000010], ifac[3000010], l[3000010], r[3000010], x[3000010],       y[3000010];   long long c(long long x, long long y) {     return fac[x] * ifac[x - y] % 998244353 * ifac[y] % 998244353;   }   signed main() {     cin >> s + 1;     long long n = strlen(s + 1);     fac[0] = 1;     for (long long i = 1; i <= n; i++) {       fac[i] = fac[i - 1] * i % 998244353;     }     ifac[n] = qpow(fac[n], 998244353 - 2);     for (long long i = n - 1; i >= 0; i--)       ifac[i] = ifac[i + 1] * (i + 1) % 998244353;     for (long long i = 1; i <= n; i++) {       l[i] = l[i - 1] + (s[i] ==  ( );       x[i] = x[i - 1] + (s[i] ==  ? );     }     for (long long i = n; i >= 1; i--) {       r[i] = r[i + 1] + (s[i] ==  ) );       y[i] = y[i + 1] + (s[i] ==  ? );     }     long long ans = 0;     for (long long i = 1; i <= n - 1; i++) {       ans += l[i] * c(x[i] + y[i + 1], y[i + 1] - l[i] + r[i + 1]) +              x[i] * c(x[i] + y[i + 1] - 1, y[i + 1] - l[i] + r[i + 1] - 1),           ans %= 998244353;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(long long ar[], long long n) {     bool flag = true;     for (long long i = 1; i < n; i++) {       if (ar[i] >= (ar[i - 1] + ar[(i + 1) % n])) {         flag = false;         break;       }     }     return flag;   }   int32_t main() {     long long n;     cin >> n;     long long temp[n];     for (long long i = 0; i < n; i++) {       cin >> temp[i];     }     sort(temp, temp + n);     long long ar[n];     long long k = 0;     for (long long i = n - 3; i >= 0; i--, k++) ar[k] = temp[i];     ar[k++] = temp[n - 2];     ar[k++] = temp[n - 1];     if (check(ar, n)) {       cout <<  YES n ;       for (auto k : ar) cout << k <<    ;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   void sort(int *a, int n) {     int isSorted = 0;     int i;     int tmp;     while (isSorted == 0) {       isSorted = 1;       for (i = 0; i < n - 1; i++) {         if (a[i] > a[i + 1]) {           tmp = a[i];           a[i] = a[i + 1];           a[i + 1] = tmp;           isSorted = 0;         }       }     }   }   int main() {     int n, m;     int p[101];     int i;     int numeven, numodd;     scanf( %d , &n);     m = n / 2;     for (i = 0; i < m; i++) scanf( %d , p + i);     sort(p, m);     numeven = 0;     numodd = 0;     for (i = 0; i < m; i++) {       numeven += ((n - i * 2) - p[m - 1 - i]) > 0 ? ((n - i * 2) - p[m - 1 - i])                                                   : -((n - i * 2) - p[m - 1 - i]);     }     for (i = 0; i < m; i++) {       numodd += (((i * 2 + 1) - p[i])) > 0 ? (((i * 2 + 1) - p[i]))                                            : -(((i * 2 + 1) - p[i]));     }     if (numeven > numodd)       printf( %d n , numodd);     else       printf( %d n , numeven);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int sum = 0, ff = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();     return sum * ff;   }   int Q, n, a[10005], cnt;   int main() {     Q = read();     for (; Q--;) {       n = read();       cnt = 0;       if (n == 4) {         puts( 3 1 4 2 );         continue;       }       if (n <= 3)         printf( -1 );       else {         if (n & 1) {           for (int j = n; j >= 1; j--)             if (j & 1) a[++cnt] = j;           a[++cnt] = 4, a[++cnt] = 2;           if (n >= 6)             for (int j = 6; j <= n; j++)               if (j % 2 == 0) a[++cnt] = j;         } else {           for (int j = n; j >= 1; j--)             if (j % 2 == 0) a[++cnt] = j;           a[++cnt] = 5, a[++cnt] = 1, a[++cnt] = 3;           if (n >= 7)             for (int j = 7; j <= n; j++)               if (j & 1) a[++cnt] = j;         }         for (int i = 1; i <= cnt; i++) printf( %d  , a[i]);       }       puts(  );     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000 )   using std::cerr;   using std::cin;   using std::cos;   using std::cout;   using std::endl;   using std::make_pair;   using std::max;   using std::min;   using std::next_permutation;   using std::pair;   using std::priority_queue;   using std::queue;   using std::random_shuffle;   using std::set;   using std::sin;   using std::sort;   using std::sqrt;   using std::stack;   using std::string;   using std::stringstream;   using std::swap;   using std::vector;   const long double PI = 3.14159265358979323846;   int main() {     vector<string> taxi, pizza, girls;     int mtaxi, mpizza, mgirls;     mtaxi = mpizza = mgirls = 0;     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       int s;       string name;       cin >> s >> name;       int ntaxi, npizza, ngirls;       ntaxi = npizza = ngirls = 0;       for (int j = 0; j < s; ++j) {         string number;         cin >> number;         string nomer = number.substr(0, 2);         nomer += number.substr(3, 2);         nomer += number.substr(6, 2);         bool t = true;         for (int k = 1; k < 6; ++k) t = t && (nomer[k] == nomer[0]);         if (t) {           ++ntaxi;           continue;         }         bool p = true;         for (int k = 1; k < 6; ++k) p = p && (nomer[k] < nomer[k - 1]);         if (p)           ++npizza;         else           ++ngirls;       }       if (ntaxi == mtaxi) {         taxi.push_back(name);       }       if (ntaxi > mtaxi) {         mtaxi = ntaxi;         taxi.resize(0);         taxi.push_back(name);       }       if (npizza == mpizza) {         pizza.push_back(name);       }       if (npizza > mpizza) {         mpizza = npizza;         pizza.resize(0);         pizza.push_back(name);       }       if (ngirls == mgirls) {         girls.push_back(name);       }       if (ngirls > mgirls) {         mgirls = ngirls;         girls.resize(0);         girls.push_back(name);       }     }     cout <<  If you want to call a taxi, you should call: ;     for (int i = 0; i < taxi.size() - 1; ++i) cout <<     << taxi[i] <<  , ;     cout <<     << taxi.back() <<  .  << endl;     cout <<  If you want to order a pizza, you should call: ;     for (int i = 0; i < pizza.size() - 1; ++i) cout <<     << pizza[i] <<  , ;     cout <<     << pizza.back() <<  .  << endl;     cout <<  If you want to go to a cafe with a wonderful girl, you should call: ;     for (int i = 0; i < girls.size() - 1; ++i) cout <<     << girls[i] <<  , ;     cout <<     << girls.back() <<  .  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, k, l, w[200005], h[200005], a, b, m, m1;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d%d , &w[i], &h[i]);       if (h[m] <= h[i]) {         m1 = m;         m = i;       } else if (h[m1] <= h[i]) {         m1 = i;       }       a += w[i];     }     for (i = 1; i <= n; i++) {       if (i == m) {         printf( %d  , (a - w[i]) * h[m1]);       } else         printf( %d  , (a - w[i]) * h[m]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string rl;     cin >> rl;     vector<int> A(n, 0);     for (int i = 0; i < n; i++) cin >> A[i];     int diff = 2147483647;     int t;     for (int i = 0; i < n - 1; i++)       if (rl[i] ==  R  && rl[i + 1] ==  L ) {         t = (A[i + 1] - A[i]) / 2;         diff = min(diff, t);       }     if (diff == 2147483647) diff = -1;     cout << diff <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void print(int n) { cout << n << endl; }   int main() {     int n, l, sum = 0;     cin >> n;     string s;     s = to_string(n);     l = s.size();     for (int i = l; i > 0; i--) sum += pow(2, i - 1);     reverse(s.begin(), s.begin() + l);     for (int i = 0; i < l; i++)       if (s[i] ==  7 ) sum += pow(2, i);     print(sum);   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 5;   const int mod = (int)1e9 + 7;   const int logN = 17;   const int inf = 1e9;   const int N = 2e5 + 5;   int s, n, m, h1[N], h, t, x, y, z;   vector<int> v[N];   pair<int, int> e[N];   void print(int x, int y) {     cout <<  YES n ;     vector<int> com, h, t;     for (__typeof(v[x].begin()) it = v[x].begin(); it != v[x].end(); it++)       h1[*it]++;     for (__typeof(v[y].begin()) it = v[y].begin(); it != v[y].end(); it++)       h1[*it]++;     for (__typeof(v[x].begin()) it = v[x].begin(); it != v[x].end(); it++) {       if (*it == y) continue;       if (h1[*it] == 1 && h.size() < ::h) h.push_back(*it);       if (h1[*it] == 2) com.push_back(*it);     }     for (__typeof(v[y].begin()) it = v[y].begin(); it != v[y].end(); it++) {       if (*it == x) continue;       if (h1[*it] == 1 && t.size() < ::t) t.push_back(*it);     }     while (h.size() < ::h) {       h.push_back(com.back());       com.pop_back();     }     while (t.size() < ::t) {       t.push_back(com.back());       com.pop_back();     }     cout << x <<     << y <<   n ;     for (__typeof(h.begin()) it = h.begin(); it != h.end(); it++)       cout << *it <<    ;     cout <<   n ;     for (__typeof(t.begin()) it = t.begin(); it != t.end(); it++)       cout << *it <<    ;     cout <<   n ;   }   int main() {     scanf( %d %d %d %d , &n, &m, &h, &t);     int s = 0;     for (int i = 1; i <= m; i++) {       scanf( %d %d , &x, &y);       e[++s] = make_pair(x, y);       e[++s] = make_pair(y, x);       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       sort(v[i].begin(), v[i].end());     }     for (int i = 1; i <= s; i++) {       x = e[i].first;       y = e[i].second;       if (v[x].size() >= h + 1 && v[y].size() >= h + t + 1) {         print(x, y);         return 0;       }       if (v[x].size() >= h + t + 1 && v[y].size() >= t + 1) {         print(x, y);         return 0;       }       if (v[x].size() <= h || v[y].size() <= t) continue;       int j = 0;       int s1 = v[x].size() - 1, s2 = v[y].size() - 1, com = 0;       for (int tt = 0; tt <= s1; tt++) {         while (j < v[y].size() && v[y][j] < v[x][tt]) j++;         if (j < v[y].size() && v[y][j] == v[x][tt]) com++;       }       if (s1 + s2 - com >= h + t) {         print(x, y);         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 2e3 + 505;   struct node {     double x, y;   } a[mx];   double pw(double x) { return x * x; }   double dist(node a, node b) { return sqrt(pw(a.x - b.x) + pw(a.y - b.y)); }   double f[2][mx], g[2][mx];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %lf%lf , &a[i].x, &a[i].y);     for (int i = 1; i < n; i++)       for (int j = 0; j < n; j++) {         g[i % 2][j] =             max(g[(i + 1) % 2][(j - 1 + n) % n] + dist(a[j], a[(j - 1 + n) % n]),                 f[(i + 1) % 2][(j - i + n) % n] + dist(a[j], a[(j - i + n) % n]));         f[i % 2][j] =             max(f[(i + 1) % 2][(j + 1) % n] + dist(a[j], a[(j + 1) % n]),                 g[(i + 1) % 2][(i + j) % n] + dist(a[j], a[(i + j) % n]));       }     double ans = 0;     for (int i = 0; i < n; i++)       ans = max(ans, max(f[(n - 1) % 2][i], g[(n - 1) % 2][i]));     printf( %.10f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 10;   int n;   const int nn = 65536 * 4;   long long sha[maxn];   long long tree[nn * 2 + 10], tag[nn * 2 + 10];   long long fix;   long long og[maxn];   void _down(int id) {     tree[id * 2] += tag[id], tag[id * 2] += tag[id];     tree[id * 2 + 1] += tag[id], tag[id * 2 + 1] += tag[id];     tag[id] = 0;   }   void _update(int a, int b, int l, int r, int id) {     if (l >= a and r <= b) {       tree[id] += fix;       tag[id] += fix;       return;     }     _down(id);     int mid = (l + r) / 2;     if (a <= mid) _update(a, b, l, mid, id << 1);     if (b > mid) _update(a, b, mid + 1, r, id << 1 | 1);     tree[id] = max(tree[id << 1], tree[id << 1 | 1]);   }   long long _query(int a, int b, int l, int r, int id) {     if (l >= a and r <= b) return tree[id];     _down(id);     int mid = (l + r) / 2;     if (a <= mid)       return _query(a, b, l, (l + r) / 2, id << 1);     else       return _query(a, b, (l + r) / 2 + 1, r, id << 1 | 1);   }   int _nxt(int l, int r, int id) {     if (l == r) return l;     _down(id);     if (tree[id << 1] >= fix)       return _nxt(l, (l + r) / 2, id << 1);     else       return _nxt((l + r) / 2 + 1, r, id << 1 | 1);   }   int main() {     int Q;     scanf( %d%d , &n, &Q);     for (int i = 1; i <= n; i++) {       scanf( %I64d , &sha[i]);       og[i] = sha[i];       sha[i] += sha[i - 1];       fix = sha[i];       _update(i, i, 1, nn, 1);     }     while (Q--) {       int x;       long long y;       scanf( %d%I64d , &x, &y);       fix = y - og[x];       og[x] = y;       _update(x, n, 1, nn, 1);       int now = 1;       long long op;       int ui = 0;       while (1) {         op = _query(now, now, 1, nn, 1);         if (op == (now != 1 ? _query(now - 1, now - 1, 1, nn, 1) * 2 : 0)) {           ui = 1;           printf( %d n , now);           break;         }         fix = op * 2;         if (fix > tree[1]) break;         now = _nxt(1, nn, 1);       }       if (!ui) puts( -1 );     }     return 0;   }
#include <bits/stdc++.h>   template <typename A, typename B>   inline char smax(A &a, const B &b) {     return a < b ? a = b, 1 : 0;   }   template <typename A, typename B>   inline char smin(A &a, const B &b) {     return b < a ? a = b, 1 : 0;   }   template <typename I>   inline void read(I &x) {     int f = 0, c;     while (!isdigit(c = getchar())) c ==  -  ? f = 1 : 0;     x = c & 15;     while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);     f ? x = -x : 0;   }   const int N = 1e5 + 7;   int n;   int b[N], s[N], id[N << 1], pre[N << 1];   struct wph {     int d, id;   } a[N];   inline void add(int x, int fa, int tag = 1) {     if (tag) s[x] = s[fa] + 1, b[s[x]] = x;     printf( %d %d n , x, fa);   }   inline void work() {     std::sort(a + 1, a + n + 1,               [](const wph &a, const wph &b) { return a.d > b.d; });     for (int i = 1; i < n; ++i)       printf( %d %d n , a[i].id * 2 - 1, a[i + 1].id * 2 - 1);     for (int i = 1; i <= n; ++i) id[i] = a[i].id * 2 - 1;     int nn = n;     for (int i = 1; i <= n; ++i)       if (i + a[i].d - 1 < nn)         printf( %d %d n , id[i] + 1, id[i + a[i].d - 1]);       else         id[++nn] = id[i] + 1, printf( %d %d n , id[nn], id[nn - 1]);   }   inline void init() {     read(n);     for (int i = 1; i <= n; ++i) read(a[i].d), a[i].id = i;   }   int main() {     init();     work();     fclose(stdin), fclose(stdout);     return 0;   }