ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
import heapq




tc = int(input())
for _ in range(0,tc):
  n = int(input())
  
  graph = [[] for i in range(0,n)]
  for i in range(0,n-1):
    inp_arr = [int(i) for i in input().split()]
    v1 = inp_arr[0]-1
    v2 = inp_arr[1]-1
    graph[v1].append(v2)
    graph[v2].append(v1)
  
  edge_count = []
  for i in range(0,n):
    heapq.heappush(edge_count,(-len(graph[i]),i))
  if(n==2):
    print(0)
  else:  
    v1 = heapq.heappop(edge_count)
    v2 = heapq.heappop(edge_count)
    v3 = heapq.heappop(edge_count)
    
    if(v1[0] == v2[0]==v3[0]):
      print(2*-v1[0]-1)
    else:
      
      v1_connections = set()
      for i in range(0,len(graph[v1[1]])):
        v1_connections.add(graph[v1[1]][i])
      
      if(v2[0]!=v3[0]):
        add = -1 if v2[1] in v1_connections else 0
        print(-v1[0]-v2[0]-1+add)
      else: 
        same_cons = [v2[1],v3[1]]
        l = v2[0]
        while(len(edge_count) > 0):
          v = heapq.heappop(edge_count)
          if(v[1] == l):
            same_cons.append(v[1])
          else:
            break
        
        add = -1  
        for v in same_cons:
          if(v not in v1_connections):
            add = 0
            break
        print(-v1[0]-v2[0]-1+add) 
        
    
    
    
    
    

Submission (verdict: Accepted):
import heapq




tc = int(input())
for _ in range(0,tc):
  n = int(input())
  
  graph = [[] for i in range(0,n)]
  for i in range(0,n-1):
    inp_arr = [int(i) for i in input().split()]
    v1 = inp_arr[0]-1
    v2 = inp_arr[1]-1
    graph[v1].append(v2)
    graph[v2].append(v1)
  
  edge_count = []
  for i in range(0,n):
    heapq.heappush(edge_count,(-len(graph[i]),i))
  if(n==2):
    print(0)
  else:  
    v1 = heapq.heappop(edge_count)
    v2 = heapq.heappop(edge_count)
    v3 = heapq.heappop(edge_count)
    
    if(v1[0] == v2[0]==v3[0]):
      print(2*-v1[0]-1)
    else:
      
      v1_connections = set()
      for i in range(0,len(graph[v1[1]])):
        v1_connections.add(graph[v1[1]][i])
      
      if(v2[0]!=v3[0]):
        add = -1 if v2[1] in v1_connections else 0
        print(-v1[0]-v2[0]-1+add)
      else: 
        same_cons = [v2[1],v3[1]]
        l = v2[0]
        while(len(edge_count) > 0):
          v = heapq.heappop(edge_count)
          if(v[0] == l):
            same_cons.append(v[1])
          else:
            break
        
        add = -1  
        for v in same_cons:
          if(v not in v1_connections):
            add = 0
            break
        print(-v1[0]-v2[0]-1+add)
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
import heapq




tc = int(input())
for _ in range(0,tc):
  n = int(input())
  
  graph = [[] for i in range(0,n)]
  for i in range(0,n-1):
    inp_arr = [int(i) for i in input().split()]
    v1 = inp_arr[0]-1
    v2 = inp_arr[1]-1
    graph[v1].append(v2)
    graph[v2].append(v1)
  
  edge_count = []
  for i in range(0,n):
    heapq.heappush(edge_count,(-len(graph[i]),i))
  if(n==2):
    print(0)
  else:  
    v1 = heapq.heappop(edge_count)
    v2 = heapq.heappop(edge_count)
    v3 = heapq.heappop(edge_count)
    
    if(v1[0] == v2[0]==v3[0]):
      print(2*-v1[0]-1)
    else:
      
      v1_connections = set()
      for i in range(0,len(graph[v1[1]])):
        v1_connections.add(graph[v1[1]][i])
      
      if(v2[0]!=v3[0]):
        add = -1 if v2[1] in v1_connections else 0
        print(graph)
        print(v1_connections)
        print(-v1[0]-v2[0]-1+add)
      else: 
        same_cons = [v2[1],v3[1]]
        l = v2[0]
        while(len(edge_count) > 0):
          v = heapq.heappop(edge_count)
          if(v[1] == l):
            same_cons.append(v[1])
          else:
            break
        
        add = -1  
        for v in same_cons:
          if(v not in v1_connections):
            add = 0
            break
        print(-v1[0]-v2[0]-1+add) 
        
    
    
    
    
    

Submission (verdict: Wrong answer on test 2):
import heapq




tc = int(input())
for _ in range(0,tc):
  n = int(input())
  
  graph = [[] for i in range(0,n)]
  for i in range(0,n-1):
    inp_arr = [int(i) for i in input().split()]
    v1 = inp_arr[0]-1
    v2 = inp_arr[1]-1
    graph[v1].append(v2)
    graph[v2].append(v1)
  
  edge_count = []
  for i in range(0,n):
    heapq.heappush(edge_count,(-len(graph[i]),i))
  if(n==2):
    print(0)
  else:  
    v1 = heapq.heappop(edge_count)
    v2 = heapq.heappop(edge_count)
    v3 = heapq.heappop(edge_count)
    
    if(v1[0] == v2[0]==v3[0]):
      print(2*-v1[0]-1)
    else:
      
      v1_connections = set()
      for i in range(0,len(graph[v1[1]])):
        v1_connections.add(graph[v1[1]][i])
      
      if(v2[0]!=v3[0]):
        add = -1 if v2[1] in v1_connections else 0
        print(-v1[0]-v2[0]-1+add)
      else: 
        same_cons = [v2[1],v3[1]]
        l = v2[0]
        while(len(edge_count) > 0):
          v = heapq.heappop(edge_count)
          if(v[1] == l):
            same_cons.append(v[1])
          else:
            break
        
        add = -1  
        for v in same_cons:
          if(v not in v1_connections):
            add = 0
            break
        print(-v1[0]-v2[0]-1+add)
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0, flag = 0;
    cin >> n;
    ll a[n + 2];
    FP(i, 1, n) cin >> a[i];
    ll ans = abs(a[1] - a[2]);
    FP(i, 3, n-1) ans = abs(ans - a[i]);
    if(ans < a[n]) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n;
    cin >> n;
    ll a[n+2];
    FP(i, 1, n) cin >> a[i];
    int j = 0;
    FP(i, 2, n) if(a[i] < a[i - 1]) j = i;
    if(j == 0) 
    {
        cout << "YES" << endl;
        return;
    }
    FP(i, 1, j - 1)
    {
        ll minn = min(a[i], a[i + 1]);
        a[i] -= minn;
        a[i + 1] -= minn;
    }
    cout << (is_sorted(a + 1, a + n + 1) ? "YES" : "NO") << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0, flag = 0;
    cin >> n;
    ll a[n+2] = {0};
    FP(i, 1, n) 
    {
        cin >> a[i];
        if(a[i] < a[i - 1]) cnt++;
        else cnt = 0;
        if(cnt == 2)
        {
            flag = 1;
        }
    }
    if(flag) cout << "NO" << endl;
    else cout << "YES" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0, flag = 0;
    cin >> n;
    ll a[n + 2];
    FP(i, 1, n) cin >> a[i];
    ll ans = abs(a[1] - a[2]);
    FP(i, 3, n-1) ans = abs(ans - a[i]);
    if(ans < a[n]) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0;
    cin >> n;
    ll a, b;
    cin >> a;
    FP(i, 2, n) 
    {
        cin >> b;
        if(a > b) cnt++;
    }
    if(cnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0;
    cin >> n;
    ll a, b;
    cin >> a;
    FP(i, 2, n) 
    {
        cin >> b;
        if(a > b) cnt++;
    }
    if(cnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0;
    cin >> n;
    ll a, b;
    cin >> a;
    FP(i, 2, n) 
    {
        cin >> b;
        if(a > b) cnt++;
        a = b;
    }
    if(cnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0;
    cin >> n;
    ll a, b;
    cin >> a;
    FP(i, 2, n) 
    {
        cin >> b;
        if(a > b) cnt++;
        a = b;
    }
    if(cnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef vector<pii> vpii;
#define speedup ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
#define CaseT ll T;cin>>T;for(ll T_=1;T_<=T;T_++)
#define mst(a,b) memset(a,b,sizeof(a))
#define FP(a,b,c) for(ll a=b;a<=c;a++)
#define FN(a,b,c) for(ll a=b;a>=c;a--)
#define FA(a,b) for(auto a:b)
#define lc u<<1
#define rc u<<1|1
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define endl '\n'

const int N=1e6+50;

void solve()
{
    int n, cnt = 0, flag = 0;
    cin >> n;
    ll a[n+2] = {0};
    FP(i, 1, n) 
    {
        cin >> a[i];
        if(a[i] < a[i - 1]) cnt++;
        else cnt = 0;
        if(cnt == 2)
        {
            flag = 1;
        }
    }
    if(flag) cout << "NO" << endl;
    else cout << "YES" << endl;
}
int main()
{
    speedup;
    CaseT
    solve();
    return 0;
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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



using namespace std;



int n;

string s;

void solve() {

    cin >> n >> s;

    

    int l = n - 1, r = 0;

    while(s[l] != 's') l--;

    while(s[r] != 'p') r++;

    if(l > r) {

        cout << "No" << '\n';

        return;

    }



    if(l < 1 || n - r < 2) {

        cout << "Yes" << '\n';

    } else {

        // cout << l << ' ' << r << '\n';

        cout << "No" << '\n';

    }

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}



/*

sspp

4312

*/

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



using namespace std;



int n;

string s;

void solve() {

    cin >> n >> s;

    

    int l = n - 1, r = 0;

    while(l >= 0 && s[l] != 's') l--;

    while(r < n && s[r] != 'p') r++;

    if(l > r) {

        cout << "No" << '\n';

        return;

    }



    if(l < 1 || n - r < 2) {

        cout << "Yes" << '\n';

    } else {

        // cout << l << ' ' << r << '\n';

        cout << "No" << '\n';

    }

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}



/*

sspp

4312

*/
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 n;

string s;

void solve() {

    cin >> n >> s;

    

    int l = 0, r = n - 1;

    while(l < n && s[l] != 'p') ++l;

    while(r >= 0 && s[r] != 's') --r;

    if(r == -1 || l == n) {

        cout << "Yes\n";

        return;

    }



    if(l <= r) {

        cout << "No\n";

        return;

    }



    if(s[0] != 's' || s[n - 1] != 'p') {

        cout << "No\n";

        return;

    }



    cout << "Yes\n";

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

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



using namespace std;



int n;

string s;

void solve() {

    cin >> n >> s;

    

    int l = n - 1, r = 0;

    while(s[l] != 's') l--;

    while(s[r] != 'p') r++;

    if(l > r) {

        cout << "No" << '\n';

        return;

    }



    if(l < 1 || n - r < 2) {

        cout << "Yes" << '\n';

    } else {

        // cout << l << ' ' << r << '\n';

        cout << "No" << '\n';

    }

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}



/*

sspp

4312

*/
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 n;

string s;

void solve() {

    cin >> n >> s;

    

    bool f1 = false, f2 = false;

    for(char c : s) {

        if(c == 'p') f1 = true;

        else if(c == 's') f2 = true;

        

        if(c == 's' && f1) {

            cout << "No" << "\n";

            return;

        }

    }

    if(!f1 || !f2) {

        cout << "Yes" << "\n";

        return;

    }



    if(s[0] == 's' && s[n - 1] == 'p') {

        cout << "Yes" << "\n"; 

    }

    else cout << "No" << "\n";

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

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



using namespace std;



int n;

string s;

void solve() {

    cin >> n >> s;

    

    int l = 0, r = n - 1;

    while(l < n && s[l] != 'p') ++l;

    while(r >= 0 && s[r] != 's') --r;

    if(r == -1 || l == n) {

        cout << "Yes\n";

        return;

    }



    if(l <= r) {

        cout << "No\n";

        return;

    }



    if(s[0] != 's' || s[n - 1] != 'p') {

        cout << "No\n";

        return;

    }



    cout << "Yes\n";

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    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 n;

string s;

void solve() {

    cin >> n >> s;

    

    bool f1 = false, f2 = false;

    for(char c : s) {

        if(c == 'p') f1 = true;

        else if(c == 's') f2 = true;

    }

    if(!f1 || !f2) {

        cout << "Yes" << "\n";

        return;

    }

    

    if(s[0] == 's' && s[n - 1] == 'p') {

        cout << "Yes" << "\n"; 

    }

    else cout << "No" << "\n";

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}

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



using namespace std;



int n;

string s;

void solve() {

    cin >> n >> s;

    

    bool f1 = false, f2 = false;

    for(char c : s) {

        if(c == 'p') f1 = true;

        else if(c == 's') f2 = true;

        

        if(c == 's' && f1) {

            cout << "No" << "\n";

            return;

        }

    }

    if(!f1 || !f2) {

        cout << "Yes" << "\n";

        return;

    }



    if(s[0] == 's' && s[n - 1] == 'p') {

        cout << "Yes" << "\n"; 

    }

    else cout << "No" << "\n";

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

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


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



using namespace std;



int n;

string s;

void solve() {

    cin >> n >> s;

    

    bool f1 = false, f2 = false;

    for(char c : s) {

        if(c == 'p') f1 = true;

        else if(c == 's') f2 = true;

    }

    if(!f1 || !f2) {

        cout << "Yes" << "\n";

        return;

    }

    

    if(s[0] == 's' && s[n - 1] == 'p') {

        cout << "Yes" << "\n"; 

    }

    else cout << "No" << "\n";

}



int main() {

    int t;  cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll n;
    cin >> n;
    string s = to_string(n);
    ll sum = 0LL;
    ll _2 = 0, _3 = 0;
    for (auto it : s)
    {
        sum += it - '0';
        if (it == '2')
            _2++;
        else if (it == '3')
            _3++;
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    else
    {
        for (ll i = 0; i <= _2; i++)
        {
            for (ll j = 0; j <= _3; j++)
            {
                if ((sum + 2 * i + 6 * j) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
        cout << "NO" << endl;
        return;
    }
}
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll n;
    cin >> n;
    string s = to_string(n);
    ll sum = 0LL;
    ll _2 = 0, _3 = 0;
    for (auto it : s)
    {
        sum += it - '0';
        if (it == '2')
            _2++;
        else if (it == '3')
            _3++;
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    else
    {
        for (ll i = 0; i <= _2; i++)
        {
            for (ll j = 0; j <= _3; j++)
            {
                if ((sum + (2 * i) + (6 * j)) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
        cout << "NO" << endl;
        return;
    }
}
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}