Problem: 2061D - Kevin and Numbers
Language: c++17 

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pub push_back
#define pob pop_back

#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll//TO FIND NUMBER OF SET BITS __builtin_popcountll(n);-->>set_bits(n);
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
ll lcm(ll a,ll b)
{
return (a*b)/__gcd(a,b);
}
ll LOWERBOUND(vector<ll> &vp,ll n,ll search)
{
ll ans=-1;
ll l=0,r=n-1;
while(l<=r)
{
ll mid=l+(r-l)/2;
if(vp[mid]<=search)
{
ans=mid;
l=mid+1;
}
else
r=mid-1;
}
return ans+1;

}
ll UPPERBOUND(vector<ll> &vp,ll n,ll search)
{
ll ans=-1;
ll l=0,r=n-1;
while(l<=r)
{
ll mid=l+(r-l)/2;
if(vp[mid]>=search)
{
ans=mid;
r=mid-1;
}
else
l=mid+1;
}
return ans+1;

}
int ispal(string &s)
{
string s1=s;
reverse(s1.begin(),s1.end());
if(s1==s)
return 1;
return 0;
}
void div(ll &a,ll &b,ll index1,ll index2,vector<pair<ll,ll>> &ans)
{
while(a!=b&&(a!=2||b!=2))
{
if(a<b)
{
b=(a+b-1)/a;
ans.push_back({index2,index1});
}
else
{
a=(a+b-1)/b;
ans.push_back({index1,index2});
}
}
}
ll mex(vector<ll> vp)
{
sort(vp.begin(),vp.end());
ll mex1=0;
ll n=vp.size();
for(ll ind=0;ind<n;ind++)
{
if(vp[ind]==mex1)
{
mex1+=1;
}

}
return mex1;
}
ll log_a_to_base_b(ll a, ll b)
{
return log2(a) / log2(b);
}

ll toggleKthBit(ll n, int k)
{
//0-th indexed
return (n ^ (1ll << (k)));
}
bool kthbitset(ll n,int k)
{
return ((n>>k)&1);
}
bool iscomp(ll n){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0)
return 1;
}
return 0;

}

int compute(int x,int y,set<pair<int,int>> &vis,vector<vector<char>> &a,int n,int m){

if( x<0||y<0||x>=n||y>=m)
return 0;
if(vis.find({x,y})!=vis.end())
{
return 0;
}
if(a[x][y]!='?')
{
char move=a[x][y];
vis.insert({x,y});
if(move=='U')
{
return 1+compute(x-1,y,vis,a,m,n);
}
else if(move=='R')
{
return 1+compute(x-1,y,vis,a,m,n);
}
else if(move=='D')
{
return 1+compute(x-1,y,vis,a,m,n);
}
else if(move=='L')
{
return 1+compute(x-1,y,vis,a,m,n);
}
}
else
{
//when we go up

//when we go right

//when we go down

//when we go left


}

}

void dfs(int flag,ll val,map<ll,vector<ll>> &m,set<ll> &s1,set<ll> &s2,int n,bool done[])
{
if(done[val]){
return;
}
done[val]=1;
if(flag==0)
{
if(s1.find(val)==s1.end())
{
s1.insert(val);
for(auto it:m[val])
{
dfs(1,it,m,s1,s2,n,done);
}
}

}
else
{
if(s2.find(val)==s2.end())
{
s2.insert(val);
for(auto it:m[val])
{
dfs(0,it,m,s1,s2,n,done);
}
}  
}


}

void solve() 
{
 ll n,m;
 cin>>n>>m;
 ll a[n],b[m];
 for(int i=0;i<n;i++)
   cin>>a[i];  
 for(int i=0;i<m;i++)
   cin>>b[i];
 
 sort(a,a+n);
 sort(b,b+m);
 ll count=n;
 map<ll,ll> mp;
 for(auto it:a){
   mp[it]++;
 }
 
 
 multiset<ll> s;
 for(int i=0;i<m;i++){
   if(mp[b[i]]){
      mp[b[i]]--;
      count--;
   }
   else{
      s.insert(b[i]);
   }
 }
 //cout<<(n-count)+(s.size())<<nline;
 while(s.size() && count&& (n-count)+(s.size())<=n){
      //return;
      auto it=s.find(*s.rbegin());   
      ll num=*it;
      if(mp[num]){
         mp[num]--;
         count--;
         s.erase(it);
      }
      else{
         s.insert((num+1)/2);
         s.insert(num/2);
         s.erase(num);
         
      }
}
//cout<<count<<nline;
if(count==0){
   cout<<"Yes\n";
}
else
cout<<"No\n";





}
int main() 
{


ios_base::sync_with_stdio(0);
cin.tie(0);

#ifndef ONLINE_JUDGE
//for getting input from input.txt
freopen("input.txt","r",stdin);
//for getting output from output.txt
freopen("output.txt","w",stdout);
#endif
//generatenos("",0,5);
int t=1;

cin>>t;              

while(t--)
{
solve();
}


}

Code 2:
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pub push_back
#define pob pop_back

#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll//TO FIND NUMBER OF SET BITS __builtin_popcountll(n);-->>set_bits(n);
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
ll lcm(ll a,ll b)
{
return (a*b)/__gcd(a,b);
}
ll LOWERBOUND(vector<ll> &vp,ll n,ll search)
{
ll ans=-1;
ll l=0,r=n-1;
while(l<=r)
{
ll mid=l+(r-l)/2;
if(vp[mid]<=search)
{
ans=mid;
l=mid+1;
}
else
r=mid-1;
}
return ans+1;

}
ll UPPERBOUND(vector<ll> &vp,ll n,ll search)
{
ll ans=-1;
ll l=0,r=n-1;
while(l<=r)
{
ll mid=l+(r-l)/2;
if(vp[mid]>=search)
{
ans=mid;
r=mid-1;
}
else
l=mid+1;
}
return ans+1;

}
int ispal(string &s)
{
string s1=s;
reverse(s1.begin(),s1.end());
if(s1==s)
return 1;
return 0;
}
void div(ll &a,ll &b,ll index1,ll index2,vector<pair<ll,ll>> &ans)
{
while(a!=b&&(a!=2||b!=2))
{
if(a<b)
{
b=(a+b-1)/a;
ans.push_back({index2,index1});
}
else
{
a=(a+b-1)/b;
ans.push_back({index1,index2});
}
}
}
ll mex(vector<ll> vp)
{
sort(vp.begin(),vp.end());
ll mex1=0;
ll n=vp.size();
for(ll ind=0;ind<n;ind++)
{
if(vp[ind]==mex1)
{
mex1+=1;
}

}
return mex1;
}
ll log_a_to_base_b(ll a, ll b)
{
return log2(a) / log2(b);
}

ll toggleKthBit(ll n, int k)
{
//0-th indexed
return (n ^ (1ll << (k)));
}
bool kthbitset(ll n,int k)
{
return ((n>>k)&1);
}
bool iscomp(ll n){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0)
return 1;
}
return 0;

}

int compute(int x,int y,set<pair<int,int>> &vis,vector<vector<char>> &a,int n,int m){

if( x<0||y<0||x>=n||y>=m)
return 0;
if(vis.find({x,y})!=vis.end())
{
return 0;
}
if(a[x][y]!='?')
{
char move=a[x][y];
vis.insert({x,y});
if(move=='U')
{
return 1+compute(x-1,y,vis,a,m,n);
}
else if(move=='R')
{
return 1+compute(x-1,y,vis,a,m,n);
}
else if(move=='D')
{
return 1+compute(x-1,y,vis,a,m,n);
}
else if(move=='L')
{
return 1+compute(x-1,y,vis,a,m,n);
}
}
else
{
//when we go up

//when we go right

//when we go down

//when we go left


}

}

void dfs(int flag,ll val,map<ll,vector<ll>> &m,set<ll> &s1,set<ll> &s2,int n,bool done[])
{
if(done[val]){
return;
}
done[val]=1;
if(flag==0)
{
if(s1.find(val)==s1.end())
{
s1.insert(val);
for(auto it:m[val])
{
dfs(1,it,m,s1,s2,n,done);
}
}

}
else
{
if(s2.find(val)==s2.end())
{
s2.insert(val);
for(auto it:m[val])
{
dfs(0,it,m,s1,s2,n,done);
}
}  
}


}

void solve() 
{
 ll n,m;
 cin>>n>>m;
 ll a[n],b[m];
 for(int i=0;i<n;i++)
   cin>>a[i];  
 for(int i=0;i<m;i++)
   cin>>b[i];
 
 sort(a,a+n);
 sort(b,b+m);
 ll count=n;
 map<ll,ll> mp;
 for(auto it:a){
   mp[it]++;
 }
 
 
 multiset<ll> s;
 for(int i=0;i<m;i++){
   if(mp[b[i]]){
      mp[b[i]]--;
      count--;
   }
   else{
      s.insert(b[i]);
   }
 }
 //cout<<(n-count)+(s.size())<<nline;
 while(s.size() && count&& (n-count)+(s.size())<=n){
      //return;
      auto it=s.find(*s.rbegin());   
      ll num=*it;
      if(mp[num]){
         mp[num]--;
         count--;
         s.erase(it);
      }
      else{
         s.insert((num+1)/2);
         s.insert(num/2);
         s.erase(it);
         
      }
}
//cout<<count<<nline;
if(count==0 && s.size()==0 ){
   cout<<"Yes\n";
}
else
cout<<"No\n";





}
int main() 
{


ios_base::sync_with_stdio(0);
cin.tie(0);

#ifndef ONLINE_JUDGE
//for getting input from input.txt
freopen("input.txt","r",stdin);
//for getting output from output.txt
freopen("output.txt","w",stdout);
#endif
//generatenos("",0,5);
int t=1;

cin>>t;              

while(t--)
{
solve();
}


}

Answer: 2