#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const long long MOD1 = 1000000007; const long long MOD2 = 998244353; #define logn long #define lnog long #define lgon long #define itn int typedef pair P; const long long INF = 1e18; //省略系 string upper(string S) { // S の全文字を大文字にする. O(N) transform(S.begin(), S.end(), S.begin(), ::toupper); return S; } string lower(string S) { // S の全文字を小文字にする. O(N) transform(S.begin(), S.end(), S.begin(), ::tolower); return S; } long long len(string S) { // S の長さを取得(long long). O(N) return (long long)S.size(); } long long count_str(string S, char ch) { // S 内に文字 ch がいくつ存在するか. O(N) long long ans = 0; for (long long i = 0; i < len(S); i++) { ans += (S.at(i) == ch); } return ans; } vector split(string S, char ch) { //特定の文字 ch で S を分ける. O(N) string T; vectorA; for (long long i = 0; i < len(S); i++) { if (S[i] != ch) T.push_back(S[i]); else { A.push_back(T); T.clear(); } } if (!T.empty()) A.push_back(T); return A; } template vector rep(vector& A, long long N) { vector B; for (long long i = 0; i < N; i++) { for (long long j = 0; j < A.size(); j++) { B.push_back(A[j]); } } return B; } template long long count_arr(vector& A, T key) { long long ans = 0; for (long long i = 0; i < A.size(); i++) { ans += (A.at(i) == key); } return ans; } template string join(vector& A, char ch) { string S; for (long long i = 0; i < A.size(); i++) { string T = to_string(A.at(i)); long long j = 0; while (j < T.size()) { S.push_back(T[j]); j++; } S.push_back(ch); } return S; } template vector sorted(vector& A) { sort(A.begin(), A.end()); return A; } template vector reversed(vector& A) { reverse(A.begin(), A.end()); return A; } template long long max_arr(vector& A) { long long num = -10000000000000007; for (long long i = 0; i < A.size(); i++) { if (A[i] > num) num = A[i]; } return num; } template long long min_arr(vector& A) { long long num = 10000000000000007; for (long long i = 0; i < A.size(); i++) { if (A[i] < num) num = A[i]; } return num; } template void input_arr(vector& A, long long N) { for (long long i = 0; i < N; i++) { cin >> A[i]; } } template void output_arr(vector& A, long long N) { for (long long i = 0; i < N; i++) { cout << A[i]; if (i != N - 1) cout << ' '; } cout << endl; } long long ans(const vector& A, const vector& B, long long i) { long long N = A.size(), M = B.size(); dequeused[N + 1]; long long closest = 0; for (long long j = 0; j > M >> N; vectorA(M), B(N); input_arr(A, M); input_arr(B, N); B.push_back(-INF); B.push_back(INF); sort(A.begin(), A.end()); sort(B.begin(), B.end()); A.insert(A.begin(), INF*(-1)); A.insert(A.end(), INF); B.insert(B.begin(), INF*(-1)); B.insert(B.end(), INF); for (long long i = 1; i <= M; i++) { cout << ans(B, A, i) % INF << endl; } }