func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> bomb[5005];   int n, m, st_time[5005], sol[5005], dist_min[5005];   int main() {     cin >> n >> m;     for (int i = 1; i <= n; ++i) dist_min[i] = 2 * 5005;     int pos, val;     for (int i = 1; i <= m; ++i) {       cin >> pos >> val;       bomb[pos].push_back(val);       int comp = 0;       if (val >= pos)         comp = val - pos;       else         comp = n - (pos - val);       if (val != pos) dist_min[pos] = min(dist_min[pos], comp);     }     for (int i = 1; i <= n; ++i) {       int blen = bomb[i].size();       if (blen)         st_time[i] = n * (blen - 1) + dist_min[i];       else         st_time[i] = 0;     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j)         if (!bomb[j].empty()) {           if (j < i)             sol[i] = max(sol[i], n - (i - j) + st_time[j]);           else             sol[i] = max(sol[i], j - i + st_time[j]);         }       cout << sol[i] <<    ;     }     return 0;   }   