// Judges with GCC >= 12 only needs Ofast // #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize") // MLE optimization // #pragma GCC optimize("conserve-stack") // Old judges // #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2") // New judges. Test with assert(__builtin_cpu_supports("avx2")); // #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native") // Atcoder // #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma") /* #include #include using namespace __gnu_pbds; typedef tree,rb_tree_tag,tree_order_statistics_node_update> ods; - insert(x),erase(x) - find_by_order(k): return iterator to the k-th smallest element - order_of_key(x): the number of elements that are strictly smaller */ #include using namespace std; using ld = long double; using ll = long long; using u32 = unsigned int; using u64 = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; using f128 = __float128; #define pii pair #define pll pair #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define ars(x) (x),(x+n) #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define For(i,a,b) for (int i=(a); i<(b); i++) #define rep(i,a) For(i,0,a) #define rev(i,a,b) for (int i=(a); i>(b); i--) #define FOR(i,a,b) for (int i=(a); i<=(b); i++) #define REP(i,a) FOR(i,1,a) #define REV(i,a,b) for (int i=(a); i>=(b); i--) #define pb push_back #define eb emplace_back #define sz(x) ((int)(x).size()) #define mp make_pair #define fi first #define se second #define FT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); using vi=vector; using vll = vector; template using vc = vector; template using vvc = vector>; template using vvvc = vector>; template using vvvvc = vector>; template using vvvvvc = vector>; template using pq = priority_queue; template using pqg = priority_queue, greater>; #define vv(type, name, h, ...) \ vector> name(h, vector(__VA_ARGS__)) #define vvv(type, name, h, w, ...) \ vector>> name( \ h, vector>(w, vector(__VA_ARGS__))) #define vvvv(type, name, a, b, c, ...) \ vector>>> name( \ a, vector>>( \ b, vector>(c, vector(__VA_ARGS__)))) //template //using ods = // tree, rb_tree_tag, tree_order_statistics_node_update>; #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit() template bool chkmin(T &x,T y){return x>y?x=y,1:0;} template bool chkmax(T &x,T y){return x using pq = priority_queue; template using pqg = priority_queue, greater>; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template void __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';} template void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} void dbg_out() { cerr << endl; } template void dbg_out(Head H, Tail... T) { __print(H); if (sizeof...(T)) cerr << ", "; dbg_out(T...); } #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:"; dbg_out(__VA_ARGS__); const int INF=1e9; const ll INFI=1e15; //----------Author: Nguyen Ho Nam,UIT, Saigon----------------- void solve() { int a,b; cin>>a>>b; int r = a % b; if (r < 0) r += abs(b); cout<