#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
void solve()
{
ll a,b;cin >> a>> b;
ll tar = (a + b * 2);
if(tar&1)
{
cout << "NO\n";
return;
}
ll l = b / 2 * 2, r = (b & 1 ? b / 2 + 1 : b / 2) * 2;
tar /= 2;
if(r > tar) cout << "NO\n";
else cout << "YES\n";
}
int main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int _ = 1;
while( _ -- ) solve();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
void solve()
{
ll n;cin >> n;
if(n == 1 || n == 2) cout << "xiaocheng\n";
else cout << "xiaoju\n";
}
//0 - fail
//1 - win
//2 - win
//3 - fail
//4 - fail
//5 - fail
//6 - fail
int main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int _ = 1;cin >> _;
while( _ -- ) solve();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const int N = 2e5 + 10;
ll q[N << 1], tt = -1, hh = 0;
void solve()
{
tt = -1, hh = 0;
ll n,cres{}, res = 1e18;cin >> n;
for(int i = 0 ;i < n ;i ++ )
{
ll x;cin >> x;
q[++ tt] = x;
}
for(int i = 0 ;i < n ;i ++ )
{
if(i && q[i - 1] >= q[i]) continue;
cres += q[i];
}
res = min(cres, res);
// cout << "TEST : " << cres << '\n';
for(int i = 1;i < n ;i ++ )
{
ll t = q[hh ++ ];
// cout << "TESt : " << i << " " << t << '\n';
if(t >= q[hh]) cres += q[hh];
if(q[tt] >= t) cres -= t;
q[++ tt] = t;
// cout << "TEST : " << cres << '\n';
res = min(cres, res);
}
cout << res << '\n';
}
// 25
// 20
int main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int _ = 1;cin >> _;
while( _ -- ) solve();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const int N = 2e5 + 10;
void solve()
{
ll n, m, res = 1e18;cin >> n >> m;
vector<pll>a;
ll cres1 = 1e18, cres2 = 1e18, cres3 = 1e18;
for(int i = 0 ; i < n ; i ++ )
{
ll x;cin >> x;
cres1 = min(cres1, abs(x));
a.emplace_back(make_pair(x, 0));
}
for(int i = 0 ; i < m ; i ++ )
{
ll x;cin >> x;
cres2 = min(cres2, abs(x));
a.emplace_back(make_pair(x, 1));
}
// cout << "TEST : " << res << '\n';
sort(a.begin(), a.end());
for(int i = 1 ;i < a.size() ;i ++ )
{
if(a[i].second + a[i - 1].second == 1)
{
cres3 = min(cres3, abs(a[i].first - a[i - 1].first));
}
}
res = min({cres1 + cres3 + cres2, cres1 + cres3 + cres3 + cres1, cres2 + cres3 + cres3 + cres2});
cout << res << '\n';
}
int main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int _ = 1;
while( _ -- ) solve();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const int N = 2e5 + 10;
struct E
{
int ne, to;
}g[N << 1];
int h[N << 1], idx{};
void add(int x, int y)
{
g[idx].to = y, g[idx].ne = h[x], h[x] = idx ++;
}
// bool dij(vector<int>&res, vector<int>&a, int src)
// {
// priority_queue<pll, vector<pll>, greater<pll>>q; q.emplace(0, src);
// vector<ll>dis(n + 1, 1e9);
// vector<ll>pre(n + 1, -1);
// vector<bool>vis(n + 1, 0);
// pre[src] = src;
// while(!q.empty())
// {
// pll t = q.top();q.pop();
// ll u = t.second, w = t.first;
// if(vis[u]) continue;
// vis[u] = true;
// for(int i = h[u]; ~i ; i = g[i].ne)
// {
// int v = g[i].to;
// g[i].w = a[u] + w;
// if(vis[])
// }
// }
// }
void solve()
{
ll n, m;cin >> n >> m;
idx = 0;memset(h, -1, sizeof h);
vector<int>a(n + 1),res, src;for(int i = 1; i <= n ; i ++ ) {cin >> a[i];if(!a[i]) src.emplace_back(i);}
vector<pll>b;
for(int i =0 ;i < m ;i ++ )
{
int u, v;cin >> u >> v;
add(u, v);
add(v, u);
b.emplace_back(u, v);
}
if(src.empty())
{
cout << -1 << '\n';
return;
}
auto bfs = [&]()->bool
{
vector<bool>vis(n + 1, 0);
queue<ll>q;q.emplace(src[0]);//?为什么只用一个点呢
while(!q.empty())
{
ll t = q.front();q.pop();
if(vis[t]) continue;
vis[t] = true;
for(int i = h[t]; ~i; i = g[i].ne)
{
int v = g[i].to;
if(a[t] > a[v]) continue;
q.emplace(v);
}
}
bool fl = 0;
for(int i = 1 ;i <= n ;i ++ ) fl |= !vis[i];
return !fl;
};
if(!bfs())
{
cout << -1 << '\n';
return;
}
for(int i = 0 ; i < m ;i ++ ) cout << abs(a[b[i].first] - a[b[i].second]) << '\n';
}
int main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int _ = 1;
while( _ -- ) solve();
return 0;
}