ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
vector<ll> factorial, inverse;
ll power(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
        {
            res = (res * base) % MOD;
        }
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res;
}
void precompute(int n)
{
    factorial.resize(n + 1);
    inverse.resize(n + 1);
    factorial[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }
    inverse[n] = power(factorial[n], MOD - 2);
    for (int i = n - 1; i >= 0; i--)
    {
        inverse[i] = (inverse[i + 1] * (i + 1)) % MOD;
    }
}
ll nCr(int n, int r)
{
    if (r > n || r < 0)
    {
        return 0;
    }
    return (factorial[n] * inverse[r] % MOD * inverse[n - r] % MOD) % MOD;
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    multiset<ll>a;
    multiset<ll>b;
    for(ll i=0;i<n;i++)
    {
        ll in;
        cin>>in;
        a.insert(in);
    }
    multiset<ll>check;
    for(auto x:a)
    {
        check.insert(x);
    }
    for(ll i=0;i<m;i++)
    {
        ll in;
        cin>>in;
        b.insert(in);
    }
    vector<ll>store;
    ll pos=0;
    while(b.size()!=n)
    {
        auto it=b.end();
        it--;
        advance(it,-pos);
        if(a.find(*it)!=a.end())
        {
            a.erase(a.find(*it));
            pos++;
        }
        else
        {
            ll val=*it;
            b.insert((val+1)/2);
            b.insert((val)/2);
            b.erase(it);
        }    
    }
    for(auto it:b)
    {
        if(check.find(it)==check.end())
        {
        cout<<"No"<<endl;
            return;
        }
        else
        {
            check.erase(check.find(it));
        }
    }
    cout<<"Yes"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb  push_back
#define mp  make_pair
#define INT_MAX                 INT64_MAX;
#define INT_MIN                 INT64_MIN;
#define IO_FAST                 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define testcase                int t; cin >> t; while(t--)
#define inputvec(v1, n)         for(int i=0; i<n; i++) {int x; cin >> x; v1.pb(x);}
#define inputvecp(v1, n)        for(int i=0; i<n; i++) {int x, y; cin >> x >> y; v1.pb(mp(x,y));}
#define sort(v1)                sort(v1.begin(), v1.end())
#define reverse(v1)             reverse(v1.begin(), v1.end())
#define print(x)                cout << #x << endl;
#define deb(x)                  cout << #x << ' ' <<  '=' << ' ' << x << endl;
#define upperbound(v1, k)       upper_bound(v1.begin(), v1.end(), k)
#define lowerbound(v1, k)       lower_bound(v1.begin(), v1.end(), k)
#define tolower(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::tolower)
#define toupper(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::toupper)
#define auto1(v1)               for(auto &num1:v1) {cout << num1 << ' ';} cout << endl;
#define auto2(vp1)              for(auto &num1:vp1) {cout << num1.first << ' ' <<num1.second << endl;}
#define auto3(vv1)              for(auto &num1:vv1) {for(auto &num2:num1){cout << num2 <<' ';}cout<<endl;}
int gcd(int a,int b)            {if (b==0) return a; return gcd(b, a%b);} // take a=0;
int lcm(int a,int b)            {return a/gcd(a,b)*b;}  // take a = v[0];
const int N = 1e5+10;
const int mod = 1e9+7;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//======================================================================================================//
signed main()
{
    IO_FAST
    testcase
    {
        int n;
        cin >> n;

        vector<int> v1;
        inputvec(v1, n);

        int sum=0;
        for(auto &value : v1)
        {
            sum += value;
        }   
             
        while(v1.size()>1)
        {
            int sum1=0;
            for(int i=1; i<v1.size(); i++)
            {
                sum1 = v1[i]-v1[i-1];
            }

            vector<int> v2=v1;
            reverse(v2);
            
            int sum2=0;
            for(int i=1; i<v2.size(); i++)
            {
                sum2 += v2[i] - v2[i-1];
            }

            if(sum1>=sum2)
            {
                vector<int> v;
                for(int i=1; i<v1.size(); i++)
                {
                    v.pb(v1[i]-v1[i-1]);
                }
                v1 = v;
            }
            else
            {
                vector<int> v;
                for(int i=1; i<v2.size(); i++)
                {
                    v.pb(v2[i]-v2[i-1]);
                }
                v1 = v;
            }
        }

        cout << max(sum, v1[0]) << endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int l, r, n;
        multiset<int> st1, st2;

        cin >> n >> l >> r;

        int ans1 = 0, ans2 = 0;

        for (int i = 1; i <= n; i++) {
            int num;
            cin >> num;

            if (st1.size() == r - l + 1 && i <= r && *--st1.end() > num) {
                ans1 -= *--st1.end();
                st1.erase(--st1.end());

                ans1 += num;
                st1.insert(num);
            }
            if (st2.size() == r - l + 1 && i >= l && *--st2.end() > num) {
                ans2 -= *--st2.end();
                st2.erase(--st2.end());

                ans2 += num;
                st2.insert(num);
            }

            if (st1.size() < r - l + 1 && i <= r) {
                st1.insert(num);
                ans1 += num;
            }
            if (st2.size() < r - l + 1 && i >= l) {
                st2.insert(num);
                ans2 += num;
            }            
        }

        cout << min(ans1, ans2) << '\n';
    }

    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int64_t l, r, n;
        multiset<int64_t> st1, st2;

        cin >> n >> l >> r;

        int64_t ans1 = 0, ans2 = 0;

        for (int64_t i = 1; i <= n; i++) {
            int64_t num;
            cin >> num;

            if (st1.size() == r - l + 1 && i <= r && *--st1.end() > num) {
                ans1 -= *--st1.end();
                st1.erase(--st1.end());

                ans1 += num;
                st1.insert(num);
            }
            if (st2.size() == r - l + 1 && i >= l && *--st2.end() > num) {
                ans2 -= *--st2.end();
                st2.erase(--st2.end());

                ans2 += num;
                st2.insert(num);
            }

            if (st1.size() < r - l + 1 && i <= r) {
                st1.insert(num);
                ans1 += num;
            }
            if (st2.size() < r - l + 1 && i >= l) {
                st2.insert(num);
                ans2 += num;
            }            
        }

        cout << min(ans1, ans2) << '\n';
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int l, r, n;
        multiset<int> st;

        cin >> n >> l >> r;

        for (int i = 0; i < n; i++) {
            int num;
            cin >> num;
            st.insert(num);
        }

        int ans = 0, i = r - l + 1;

        for (multiset<int>::iterator it = st.begin(); i; i--, ++it)
            ans += *it;

        cout << ans << '\n';
    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int l, r, n;
        multiset<int> st;

        cin >> n >> l >> r;

        for (int i = 0; i < n; i++) {
            int num;
            cin >> num;
            st.insert(num);
        }

        int ans = 0, i = r - l + 1;

        for (multiset<int>::iterator it = st.begin(); i; i--, ++it)
            ans += *it;

        cout << ans << '\n';
    }

    return 0;
}

Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <string>

using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        int l, r, n;
        multiset<int> st1, st2;

        cin >> n >> l >> r;

        int ans1 = 0, ans2 = 0;

        for (int i = 1; i <= n; i++) {
            int num;
            cin >> num;

            if (st1.size() == r - l + 1 && i <= r && *--st1.end() > num) {
                ans1 -= *--st1.end();
                st1.erase(--st1.end());

                ans1 += num;
                st1.insert(num);
            }
            if (st2.size() == r - l + 1 && i >= l && *--st2.end() > num) {
                ans2 -= *--st2.end();
                st2.erase(--st2.end());

                ans2 += num;
                st2.insert(num);
            }

            if (st1.size() < r - l + 1 && i <= r) {
                st1.insert(num);
                ans1 += num;
            }
            if (st2.size() < r - l + 1 && i >= l) {
                st2.insert(num);
                ans2 += num;
            }            
        }

        cout << min(ans1, ans2) << '\n';
    }

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#ifdef LOCAL

#include "/competitive_programming/debug.cpp"

#else

#define dbg(...)

#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

using i64 = long long;

int main() {

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

  int T;

  cin >> T;

  while (T--) {

    int n, m;

    cin >> n >> m;

    multiset<int> S, T;

    for (int i = 0; i < n; ++i) {

      int t;

      cin >> t;

      S.insert(t);

    }

    for (int i = 0; i < m; ++i) {

      int t;

      cin >> t;

      if (S.count(t)) {

        S.erase(S.find(t));

      } else {

        T.insert(t);

      }

    }

    while (T.size()) {

      if (S.size() <= 1) break;

      auto b1 = S.begin();

      auto b2 = next(b1);

      int c1 = *b1, c2 = *b2;

      S.erase(S.find(c1));

      S.erase(S.find(c2));

      if (c2 - c1 <= 1) {

        int v = c1 + c2;

        if (T.count(v)) {

          T.erase(T.find(v));

        } else {

          S.insert(v);

        }

      } else {

        break;

      }

    }

    if (T.size() == 0 && S.size() == 0) {

      cout << "Yes\n";

    } else {

      cout << "No\n";

    }

  }

  return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#ifdef LOCAL

#include "/competitive_programming/debug.cpp"

#else

#define dbg(...)

#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

using i64 = long long;

int main() {

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

  int T;

  cin >> T;

  while (T--) {

    int n, m;

    cin >> n >> m;

    multiset<int> S, T;

    for (int i = 0; i < n; ++i) {

      int t;

      cin >> t;

      S.insert(t);

    }

    for (int i = 0; i < m; ++i) {

      int t;

      cin >> t;

      if (S.count(t)) {

        S.erase(S.find(t));

      } else {

        T.insert(t);

      }

    }

    while (T.size()) {

      if (S.size() <= 1) break;

      auto b1 = S.begin();

      auto b2 = next(b1);

      int c1 = *b1, c2 = *b2;

      S.erase(S.find(c1));

      S.erase(S.find(c2));

      if (c2 - c1 <= 1) {

        int v = c1 + c2;

        if (T.count(v)) {

          T.erase(T.find(v));

        } else {

          S.insert(v);

        }

      } else {

        break;

      }

    }

    if (T.size() == 0 && S.size() == 0) {

      cout << "Yes\n";

    } else {

      cout << "No\n";

    }

  }

  return 0;

}



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

using namespace std;

#ifdef LOCAL

#include "/competitive_programming/debug.cpp"

#else

#define dbg(...)

#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

using i64 = long long;

int main() {

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

  int T;

  cin >> T;

  while (T--) {

    int n, m;

    cin >> n >> m;

    multiset<i64> S, T;

    for (int i = 0; i < n; ++i) {

      int t;

      cin >> t;

      S.insert(t);

    }

    for (int i = 0; i < m; ++i) {

      int t;

      cin >> t;

      if (S.count(t)) {

        S.erase(S.find(t));

      } else {

        T.insert(t);

      }

    }

    while (T.size()) {

      if (S.size() <= 1) break;

      auto b1 = S.begin();

      auto b2 = next(b1);

      i64 c1 = *b1, c2 = *b2;

      S.erase(S.find(c1));

      S.erase(S.find(c2));

      if (c2 - c1 <= 1) {

        i64 v = c1 + c2;

        if (T.count(v)) {

          T.erase(T.find(v));

        } else {

          S.insert(v);

        }

      } else {

        break;

      }

    }

    if (T.size() == 0 && S.size() == 0) {

      cout << "Yes\n";

    } else {

      cout << "No\n";

    }

  }

  return 0;

}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 16):
#include <bits/stdc++.h>

using namespace std;

int dp[1005][1005];

int solve(char *a, int an, char *b, int bn, char *c, int cn){
    if(dp[an][bn] != -1) return dp[an][bn];
    if(an == 0 && bn == 0){
        dp[an][bn] = 0;
        return dp[an][bn];
    }

    dp[an][bn] = cn;
    if(an != 0)
        dp[an][bn] = min(dp[an][bn], solve(a+1, an-1, b, bn, c+1, cn-1) + (a[0] != c[0]));
    if(bn != 0)
        dp[an][bn] = min(dp[an][bn], solve(a, an, b+1, bn-1, c+1, cn-1) + (b[0] != c[0]));

    return dp[an][bn];
}

int main(){
    int t;
    char a[1005], b[1005], c[1005];
    int an, bn;

    cin >> t;
    while(t--){
        //reset the dp array
        memset(dp, -1, 1004*1004*sizeof(int));

        scanf("%s%s%s", a, b, c);

        for(an = 0; a[an]; an++);
        for(bn = 0; b[bn]; bn++);

        cout << solve(a, an, b, bn, c, an+bn) << '\n';
    }
    return 0;
}


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

using namespace std;

int dp[2005][2005];

int solve(char *a, int an, char *b, int bn, char *c, int cn){
    if(dp[an][bn] != -1) return dp[an][bn];
    if(an == 0 && bn == 0){
        dp[an][bn] = 0;
        return dp[an][bn];
    }

    dp[an][bn] = cn;
    if(an != 0)
        dp[an][bn] = min(dp[an][bn], solve(a+1, an-1, b, bn, c+1, cn-1) + (a[0] != c[0]));
    if(bn != 0)
        dp[an][bn] = min(dp[an][bn], solve(a, an, b+1, bn-1, c+1, cn-1) + (b[0] != c[0]));

    return dp[an][bn];
}

int main(){
    int t;
    char a[2005], b[2005], c[2005];
    int an, bn, cn;

    cin >> t;
    while(t--){
        //reset the dp array
        memset(dp, -1, 2005*2005*sizeof(int));

        scanf("%s%s%s", a, b, c);

        //find the size of the strings
        for(an = 0; a[an]; an++);
        for(bn = 0; b[bn]; bn++);
        for(cn = 0; c[cn]; cn++);

        cout << solve(a, an, b, bn, c, cn) << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 16):
#include <bits/stdc++.h>

using namespace std;

int dp[1005][1005];

int solve(char *a, int an, char *b, int bn, char *c, int cn){
    if(dp[an][bn] != -1) return dp[an][bn];
    if(an == 0 && bn == 0){
        dp[an][bn] = 0;
        return dp[an][bn];
    }

    dp[an][bn] = cn;
    if(an != 0)
        dp[an][bn] = min(dp[an][bn], solve(a+1, an-1, b, bn, c+1, cn-1) + (a[0] != c[0]));
    if(bn != 0)
        dp[an][bn] = min(dp[an][bn], solve(a, an, b+1, bn-1, c+1, cn-1) + (b[0] != c[0]));

    return dp[an][bn];
}

int main(){
    int t;
    char a[1005], b[1005], c[1005];
    int an = 0, bn = 0, cn = 0;

    cin >> t;
    while(t--){
        //reset the end of the strings, because we don't wanna allocate the memory again
        //and the old end could cause a problem when we look for the new end.
        a[an] = 1;
        b[bn] = 1;
        c[cn] = 1;

        //reset the dp array
        memset(dp, -1, 1005*1005*sizeof(int));

        scanf("%s%s%s", a, b, c);

        for(an = 0; a[an]; an++);
        for(bn = 0; b[bn]; bn++);

        cout << solve(a, an, b, bn, c, an+bn) << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 16):
#include <bits/stdc++.h>

using namespace std;

int dp[1005][1005];

int solve(char *a, int an, char *b, int bn, char *c, int cn){
    if(dp[an][bn] != -1) return dp[an][bn];
    if(an == 0 && bn == 0){
        dp[an][bn] = 0;
        return dp[an][bn];
    }

    dp[an][bn] = cn;
    if(an != 0)
        dp[an][bn] = min(dp[an][bn], solve(a+1, an-1, b, bn, c+1, cn-1) + (a[0] != c[0]));
    if(bn != 0)
        dp[an][bn] = min(dp[an][bn], solve(a, an, b+1, bn-1, c+1, cn-1) + (b[0] != c[0]));

    return dp[an][bn];
}

int main(){
    int t;
    char a[1005], b[1005], c[1005];
    int an = 0, bn = 0, cn = 0;

    cin >> t;
    while(t--){
        //reset the end of the strings, because we don't wanna allocate the memory again
        //and the old end could cause a problem when we look for the new end.
        a[an] = 1;
        b[bn] = 1;
        c[cn] = 1;

        //reset the dp array
        memset(dp, -1, 1005*1005*sizeof(int));

        scanf("%s%s%s", a, b, c);

        for(an = 0; a[an]; an++);
        for(bn = 0; b[bn]; bn++);

        cout << solve(a, an, b, bn, c, an+bn) << '\n';
    }
    return 0;
}


Submission (verdict: Runtime error on test 16):
#include <bits/stdc++.h>

using namespace std;

int dp[1005][1005];

int solve(char *a, int an, char *b, int bn, char *c, int cn){
    if(dp[an][bn] != -1) return dp[an][bn];
    if(an == 0 && bn == 0){
        dp[an][bn] = 0;
        return dp[an][bn];
    }

    dp[an][bn] = cn;
    if(an != 0)
        dp[an][bn] = min(dp[an][bn], solve(a+1, an-1, b, bn, c+1, cn-1) + (a[0] != c[0]));
    if(bn != 0)
        dp[an][bn] = min(dp[an][bn], solve(a, an, b+1, bn-1, c+1, cn-1) + (b[0] != c[0]));

    return dp[an][bn];
}

int main(){
    int t;
    char a[1005], b[1005], c[1005];
    int an, bn;

    cin >> t;
    while(t--){
        //reset the dp array
        memset(dp, -1, 1004*1004*sizeof(int));

        scanf("%s%s%s", a, b, c);

        for(an = 0; a[an]; an++);
        for(bn = 0; b[bn]; bn++);

        cout << solve(a, an, b, bn, c, an+bn) << '\n';
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){
    int t;
    int a, c;

    cin >> t;

    while(t--){
        cin >> a >> c;

        int b1 = a, b2 = a;
        int r = 0;
        int _xor = (a^c);

        for(int i=30; 0 <= i; i--){
            if(_xor & (1 << i)){
                b1 ^= (r<<i);
                b2 ^= ((r^1)<<i);
                r = 1;
            } if(r && !(_xor & (1 << i))){
                if((b1^(1<<i)) < c)
                    b1 ^= (1<<i);
                if((b2^(1<<i)) < c)
                    b2 ^= (1<<i);
            }
        }

        int b;
        if(a < b1 && b1 < c) b = b1;
        else b = b2;
        cout << a << " " << b << " " << c << '\n';
    }

    return 0;
}


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

using namespace std;

int main(){
    int t;
    int a, c;

    cin >> t;

    while(t--){
        cin >> a >> c;

        int b;
        for(int _xor = (a^c); _xor; _xor -= b) b = (_xor & -_xor);
        b = c - c%b;

        if(b == c)
            cout << a << " " << b-1 << " " << b << '\n';
        else
            cout << b-1 << " " << b << " " << c << '\n';
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

using namespace std;

int main(){
    int t;
    int a, c;

    cin >> t;

    while(t--){
        cin >> a >> c;

        int b = a;
        int r = 1;
        int _xor = (a^c);

        for(int i=30; 0 <= i; i--){
            if(_xor & (1 << i)){
                if((c & (c-1)) != 0){
                    b ^= (r<<i);
                    r = 0;
                }
            } else {
                if((b^(1<<i)) < c)
                    b ^= (1<<i);
            }
        }

        cout << a << " " << b << " " << c << '\n';
    }

    return 0;
}


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

using namespace std;

int main(){
    int t;
    int a, c;

    cin >> t;

    while(t--){
        cin >> a >> c;

        int b1 = a, b2 = a;
        int r = 0;
        int _xor = (a^c);

        for(int i=30; 0 <= i; i--){
            if(_xor & (1 << i)){
                b1 ^= (r<<i);
                b2 ^= ((r^1)<<i);
                r = 1;
            } if(r && !(_xor & (1 << i))){
                if((b1^(1<<i)) < c)
                    b1 ^= (1<<i);
                if((b2^(1<<i)) < c)
                    b2 ^= (1<<i);
            }
        }

        int b;
        if(a < b1 && b1 < c) b = b1;
        else b = b2;
        cout << a << " " << b << " " << c << '\n';
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

using namespace std;

int main(){
    int t;
    int a, c;

    cin >> t;

    while(t--){
        cin >> a >> c;

        int b = a;
        int r = 1;
        int _xor = (a^c);

        for(int i=30; 0 <= i; i--){
            if(_xor & (1 << i)){
                if((c & (c-1)) != 0){
                    b ^= (r<<i);
                    r = 0;
                }
            } else {
                if((b^(1<<i)) < c)
                    b ^= (1<<i);
            }
        }

        cout << a << " " << b << " " << c << '\n';
    }

    return 0;
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

int T,n;

string s;

int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0); 

	cin>>T;

    while(T--){

	    cin>>n>>s;

	    bool f=0;

	    s=' '+s;

	    for(int i=1;i<=n;i++){

	        for(int j=1;j<=n;j++){

	            if(s[i]=='s'&&s[j]=='p'&&i>0&&j!=n){

	                f=1;

	                break;

	            }

	        }

	        if(f) break;

	    }

	    if(f) cout<<"NO"<<"\n";

	    else cout<<"YES"<<"\n";

    }

    return 0;

}

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

using namespace std;

int T,n;

string s;

int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0); 

	cin>>T;

    while(T--){

	    cin>>n>>s;

	    bool f=0;

	    s=' '+s;

	    for(int i=1;i<=n;i++){

	        for(int j=1;j<=n;j++){

	            if(s[i]=='s'&&s[j]=='p'&&i>1&&j!=n){

	                f=1;

	                break;

	            }

	        }

	        if(f) break;

	    }

	    if(f) cout<<"NO"<<"\n";

	    else cout<<"YES"<<"\n";

    }

    return 0;

}