#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--)
{
int cnt1,cnt2;
cin>>cnt1>>cnt2;
if(cnt1%2)
{
cout<<"NO"<<endl;
}
else
{
if(cnt2%2==0)
{
cout<<"YES"<<endl;
}
else
{
if(cnt1==0)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
}
}
}
}
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int id=0;
while(id<n&&s[id]=='1')
{
id++;
}
if(id==n)
{
if(n==4)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
else
{
if((id-1)*(id-1)==n)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
}
return 0;
}
~~~~~
include <bits/stdc++.h>
using namespace std;
int main(){ int t; cin>>t; while(t--) { long long a,b; cin>>a>>b; b-=a; long long l=2,r=1000000000; while(l<r) { long long m=(l+r)/2; if(m*(m-1)/2<=b) { l=m+1; } else { r=m; } } cout<<l-1<<endl; } }~~~~~
~~~~~
include <bits/stdc++.h>
using namespace std;
int main(){ int t; cin>>t; while(t--) { long long n; cin>>n; long long p[n+1]={0},b[n+1]={0}; int us[n+1]={0}; for(int i=1;i<=n;i++) { cin>>p[i]; } string s; cin >> s; for(int i=1;i<=n;i++) { if(us[i])continue; int sz=0; while(!us[i]) { us[i]=1; sz += s[i — 1] == '0'; i=p[i]; } while(us[i]!=2) { b[i]=sz; us[i]=2; i=p[i]; } } for(int i=1;i<=n;i++) { cout<<b[i]<<" "; } cout<<endl; } }~~~~~
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int res=s.size();
if(n%2==0)
{
vector<int>v[2]={vector<int>(26),vector<int>(26)};
for(int i=0;i<n;i++)
{
v[i%2][s[i]-'a']++;
}
for(int i=0;i<2;i++)
{
int mx=0;
for(int j=0;j<26;j++)
{
mx=max(mx,v[i][j]);
}
res-=mx;
}
cout<<res<<endl;
}
else
{
vector<int>pref[2]={vector<int>(26),vector<int>(26)};
vector<int>suf[2]={vector<int>(26),vector<int>(26)};
for(int i=n-1;i>=0;i--)
{
suf[i%2][s[i]-'a']++;
}
for(int i=0;i<n;i++)
{
suf[i%2][s[i]-'a']--;
int ans=n;
for(int k=0;k<2;k++)
{
int mx=0;
for(int j=0;j<26;j++)
{
mx=max(mx,suf[1-k][j]+pref[k][j]);
}
ans-=mx;
}
res=min(res,ans);
pref[i%2][s[i]-'a']++;
}
cout<<res<<endl;
}
}
}
~~~~~
include <bits/stdc++.h>
using namespace std; constexpr int mod=1e9+7;
long long binpow(long long a,long long b) { if(b==0) { return 1; } if(b%2) { return (a*binpow(a,b-1))%mod; } return binpow((a*a)%mod,b/2); }
int main(){ int t; cin>>t; while(t--) { long long n; cin>>n; long long a[n],sum=0,sumsq=0; for(int i=0;i<n;i++) { cin>>a[i]; sum+=a[i];sum%=mod; sumsq+=a[i]*a[i]; sumsq%=mod; } sum*=sum;sum%=mod; sum=(sum-sumsq+mod)%mod; sum=(sum*binpow(2,mod-2))%mod; long long cnt=n*(n-1)/2;cnt%=mod; cout<<(sum%mod)*binpow(cnt,mod-2)%mod<<endl; } }~~~~~
~~~~~
include <bits/stdc++.h>
using namespace std;
int main(){ int t; cin>>t; while(t--) { int n,k; cin>>n>>k; long long a[n+1],g=0,mx=0; for(int i=0;i<n;i++) { cin>>a[i]; g=__gcd(g,a[i]); mx=max(mx,a[i]); } if(g==0) { cout<<k<<endl; continue; } sort(a,a+n); int q=-g; if(n!=1) { for(int i=0;i<n;i++) { q+=g; a[i]=q; } } a[n]=1e16; long long lst=-1; for(int i=0;i<=n;i++) { if(k<=a[i]-lst-1) { break; } k-=max(a[i]-lst-1,0ll); lst=a[i]; } cout<<lst+k<<endl; } }~~~~~
~~~~~
include <bits/stdc++.h>
using namespace std;
int32_t main() { int t=1; cin>>t; for(int i=1;i<=t;i++) { int n,m; cin>>n>>m; vectora(n); vectorc(n+1,0ll); for(int i=0;i<n;i++) { cin>>a[i]; c[a[i]]++; } for(int i=1;i<=n;i++) { c[i]+=c[i-1]; } int res[n+1]={0}; for(int x=1;x<=n;x++) { int l=0,r=x; while(l<r) { int mid=(l+r)/2; int cnt=c[mid]; for(int k=1;k*x<=n;k++) { cnt+=c[min(k*x+mid,n)]-c[k*x-1]; } if(cnt-1>=n/2) { r=mid; } else { l=mid+1; } } res[x]=l; } while(m--) { int x; cin>>x; cout<<res[x]<<" "; } cout<<endl; } }~~~~~