#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"Y H 99";
return 0;
}dogod.io
https://paperzym.github.io/whk/
https://xinyang-li-dotcom.github.io/whk-LXY-/New-whk-safe.html
https://weiyc2.github.io/oimoniqi/
joshuaurora.github.io/CCF?DZD_Simulator.html
(https://joshuaurora.github.io/CCF/DZD_Simulator.html)
https://leoooooooooisme.github.io/oier-gaokao-recovery-simulator/
https://seve42.github.io/OItrainer/game.html?new=1&d=1&p=2&c=10
https://little09qwq.github.io/oi-remake-game/
https://odysseus0439.github.io/Stellar_Link/
https://www.luogu.com.cn/problem/P5432
https://www.luogu.me/article/h0grhxvj
https://phet.colorado.edu/zh_CN/simulations/my-solar-system
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
int q;
cin >> q;
vector<long long> aa(n + 1), bb(n + 1);
for (int i = 1; i <= n; i++) cin >> aa[i];
for (int i = 1; i <= n; i++) cin >> bb[i];
vector<long long> pp(n + 2, 0);
for (int i = 1; i <= n; i++) {
pp[i + 1] = pp[i] + aa[i];
}
long long l = pp[n + 1];
int m = 2 * n;
vector<long long> p(m + 2), b(m + 2);
for (int i = 1; i <= n; i++) {
p[i] = pp[i];
b[i] = bb[i];
p[i + n] = pp[i] + l;
b[i + n] = bb[i];
}
vector<long long> ld(m + 2), rd(m + 2);
ld[1] = b[1];
for (int k = 2; k <= m; k++) {
ld[k] = min(b[k], ld[k - 1] + (p[k] - p[k - 1]));
}
rd[m] = b[m];
for (int k = m - 1; k >= 1; k—) {
rd[k] = min(b[k], rd[k + 1] + (p[k + 1] - p[k]));
}
vector<long long> f(n + 1);
for (int x = 1; x <= n; x++) {
f[x] = min(ld[x + n], rd[x]);
}
while (q—) {
int s, t;
cin >> s >> t;
if (s == n + 1 && t == n + 1) {
cout << 0 << ‘\n’;
continue;
}
if (s == n + 1) {
cout << f[t] << ‘\n’;
continue;
}
if (t == n + 1) {
cout << f[s] << ‘\n’;
continue;
}
long long f;
if (t >= s) {
f = pp[t] - pp[s];
} else {
f = pp[t] + l - pp[s];
}
long long c = min(f, l - f);
long long ans = min(c, f[s] + f[t]);
cout << ans << ‘\n’;
}
return 0;
}
http://172.21.34.34:8000/