ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define ll long long
#define vtr vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define arg sort(v.begin(),v.end())
#define Lrg sort(v.rbegin(),v.rend())
#define lm(a,b) for(int i=a; i<b; i++)
#define tst int t; cin >> t; while(t--)
#define nl

using namespace std;
void slayer()
{
    ll r,l;
    cin >> r >> l;
    ll pos;
    for(int i=30; i>=0; i--){
        if((l&(1LL<<i))!=(r&(1LL<<i))){
            pos=i;
            break;
        }
    }
    ll a=l|(1LL<<pos)-1;
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout << a << " " << b << " " << c << endl;
}
int main()
{
    tst{
        slayer();
    }

    return 0;
}



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

#define ll long long
#define vtr vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define arg sort(v.begin(),v.end())
#define Lrg sort(v.rbegin(),v.rend())
#define lm(a,b) for(int i=a; i<b; i++)
#define tst int t; cin >> t; while(t--)
#define nl

using namespace std;
void slayer()
{
    ll l,r;
    cin >> l >> r;
    ll pos;
    for(int i=30; i>=0; i--){
        if((l&(1LL<<i))!=(r&(1LL<<i))){
            pos=i;
            break;
        }
    }
    ll a=l|((1LL<<pos)-1);
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout << a << " " << b << " " << c << endl;
}
int main()
{
    tst{
        slayer();
    }

    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>

#define ll long long
#define vtr vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define arg sort(v.begin(),v.end())
#define Lrg sort(v.rbegin(),v.rend())
#define lm(a,b) for(int i=a; i<b; i++)
#define tst int t; cin >> t; while(t--)
#define nl

using namespace std;
void slayer()
{
    ll r,l;
    cin >> r >> l;
    ll pos;
    for(int i=30; i>=0; i--){
        if((l&(1LL<<i))!=(r&(1LL<<i))){
            pos=i;
            break;
        }
    }
    ll a=l|(1LL<<pos)-1;
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)b--;
    cout << a << " " << b << " " << c << endl;
}
int main()
{
    tst{
        slayer();
    }

    return 0;
}



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

#define ll long long
#define vtr vector<ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define arg sort(v.begin(),v.end())
#define Lrg sort(v.rbegin(),v.rend())
#define lm(a,b) for(int i=a; i<b; i++)
#define tst int t; cin >> t; while(t--)
#define nl

using namespace std;
void slayer()
{
    ll r,l;
    cin >> r >> l;
    ll pos;
    for(int i=30; i>=0; i--){
        if((l&(1LL<<i))!=(r&(1LL<<i))){
            pos=i;
            break;
        }
    }
    ll a=l|(1LL<<pos)-1;
    ll b=a+1;
    ll c=r;
    if(c==a || c==b)c--;
    if(c==a || c==b)c--;
    cout << a << " " << b << " " << c << endl;
}
int main()
{
    tst{
        slayer();
    }

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// Problem: C. Remove Exactly Two
// Contest: Codeforces - Codeforces Round 1000 (Div. 2)
// URL: https://codeforces.com/contest/2063/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// by znzryb
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ROF(i, a, b) for (int i = (a); i >= (b); --i)
#define all(x) x.begin(), x.end()
#define CLR(i, a) memset(i, a, sizeof(i))
#define fi first
#define se second
#define pb push_back
#define SZ(a) ((int)a.size())
#define LOCAL

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef array<ll, 3> arr;
typedef double DB;
typedef pair<DB, DB> pdd;
constexpr ll MAXN = static_cast<ll>(2e5) + 10, INF = static_cast<ll>(5e18) + 3;

ll N, M, T, A[MAXN];
vector<ll> g[MAXN];
ll edges[MAXN];
// set<pll> vis;

// struct Effect{
// //             影响的点里最大
// ll id=0,size=0,aff=0;
// }

inline void solve() {
  cin >> N;
  map<ll, ll> cnt;
  // 初始化
  FOR(i, 1, N) { g[i].clear(); }
  FOR(i, 1, N - 1) {
    ll u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  if (N == 2) {
    cout << 0 << '\n';
    return;
  }
  ll mx = 0, mxN = 1;
  FOR(i, 1, N) {
    edges[i] = SZ(g[i]);
    cnt[edges[i]] = cnt.find(edges[i]) == cnt.end() ? 1 : cnt[edges[i]] + 1;
  }
  ll ans = 0;
  map<ll, ll> backup = cnt;
  FOR(i, 1, N) {
    ll lans = edges[i];
// #ifdef LOCAL
    // cerr << i << ' ' << edges[i] << '\n';
// #endif
    cnt[edges[i]] -= 1;
    if (cnt[edges[i]] == 0) {
      cnt.erase(edges[i]);
    }
    FOR(j, 0, SZ(g[i]) - 1) {
      ll node = g[i][j];
      cnt[edges[node]] -= 1;
      cnt[edges[node] - 1] = cnt.find(edges[node] - 1) == cnt.end() ? 1 : cnt[edges[node] - 1] + 1;
      if (cnt[edges[node]] == 0) {
        cnt.erase(edges[node]);
      }
    }

    if (cnt.rbegin()->fi != 0) {
      lans += cnt.rbegin()->se;
      lans -= 1;
    } else {
      lans -= 1;
    }

// #ifdef LOCAL
    // cerr << i << ' ' << lans << '\n';
// #endif
    ans = max(ans, lans);
    cnt = backup;
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) {
    solve();
#ifdef LOCAL
    cerr << '\n';
#endif
  }
  return 0;
}
/*

*/
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

using namespace std;

void solve() {
    string number;
    cin >> number;

    int digitSum = 0;
    for (const auto c : number) {
        digitSum += c - '0';
    }

    if (digitSum % 9 == 0) {
        cout << "YES" << endl;
        return;
    }
    // 0 => 0
    // 1 => 1
    // 2 => 4 +2
    // 3 => 9 +6
    int twos = 0, threes = 0;
    for (const auto c : number) {
        if (c == '2') {
            twos++;
        } else if (c == '3') {
            threes++;
        }
    }

    int originalDigitSum = digitSum;

    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    if (twos == 0) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;

    digitSum += 2;
    for (int i = 0; i < threes; i++) {
        digitSum += 6;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    if (twos == 1) {
        cout << "NO" << endl;
        return;
    }

    digitSum = originalDigitSum;
    twos += (3*threes);

    for (int i = 0; i < twos; i++) {
        digitSum += 2;
        if (digitSum % 9 == 0) {
            cout << "YES" << endl;
            return;
        }
    }

    cout << "NO" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

const int N = 55;
int a[N];

void solve() {
	int n;
	cin >> n;
	
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	} 
	
	int an = n;
	for (int i = 0; i < n - 1; i++) {
		sum = max(sum, abs((long long)a[0] - a[an - 1]));
		for (int j = 0; j < an - 1; j++) {
			a[j] = a[j + 1] - a[j];
		}
		an--;
	}
	
	cout << sum << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	
	while (tt--) {
		solve();
	}
	
	return 0;
} 

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

const int N = 55;
long long a[N];

void solve() {
	int n;
	cin >> n;
	
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	} 
	
	int an = n;
	for (int i = 0; i < n - 1; i++) {
		sum = max(sum, abs(a[0] - a[an - 1]));
		for (int j = 0; j < an - 1; j++) {
			a[j] = a[j + 1] - a[j];
		}
		an--;
	}
	
	cout << sum << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	
	while (tt--) {
		solve();
	}
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

const int N = 55;
int a[N];

void solve() {
	int n;
	cin >> n;
	
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	} 
	
	int an = n;
	for (int i = 0; i < n - 1; i++) {
		sum = max(sum, abs(a[0] - a[an - 1]));
		for (int j = 0; j < an - 1; j++) {
			a[j] = a[j + 1] - a[j];
		}
		an--;
	}
	
	cout << sum << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	
	while (tt--) {
		solve();
	}
	
	return 0;
} 

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

const int N = 55;
int a[N];

void solve() {
	int n;
	cin >> n;
	
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	} 
	
	int an = n;
	for (int i = 0; i < n - 1; i++) {
		sum = max(sum, abs((long long)a[0] - a[an - 1]));
		for (int j = 0; j < an - 1; j++) {
			a[j] = a[j + 1] - a[j];
		}
		an--;
	}
	
	cout << sum << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	
	while (tt--) {
		solve();
	}
	
	return 0;
}
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;

const int N = 55;
int a[N];

void solve() {
	int n;
	cin >> n;
	
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	} 
	
	int an = n;
	for (int i = 0; i < n - 1; i++) {
		sum = max(sum, abs(a[0] - a[an - 1]));
		for (int j = 0; j < an - 1; j++) {
			a[j] = a[j + 1] - a[j];
		}
		an--;
	}
	
	cout << sum << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int tt;
	cin >> tt;
	
	while (tt--) {
		solve();
	}
	
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

#define fi first 
#define se second 
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ld long double
#define ll long long int
#define Int unsigned int 
#define Long unsigned long long int
#define eliminate(x, y) (x).erase(remove(all(x), (y)), (x).end())
#define make_unique(x) sort(all(x)), (x).erase(unique(all(x)), (x).end());
#define all_range(x) (x).begin(), (x).begin()
#define All(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define newl cerr << '\n'

using namespace std;
template<class T> using Set = unordered_set<T>;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;  
template<class T, class U> using Map = unordered_map<T, U>;
 
template<typename T>void prd(const T& x);
template<typename T, typename U>void prd(const pair<T, U>& val);
template<typename T, typename... Args>void prd(const T& val, Args... args);
template<typename... Args>void debug(Args... args);
template<typename T>void debug(const set<T>& c);
template<typename T>void debug(const vector<T>& c);
template<typename T>void debug(const vector<vector<T>> &c);
template<typename K, typename V>void debug(const map<K, V>& c);

const int MOD = 1e9 + 7;
const int mod = 998244353;
const int INF = 2e9 + 7;
const ll INFL = 2e18 + 7;
const double EPS = 1e-9;

void FastIO();

int main(){
 
    FastIO();
    int t,n; cin >> t;
    while(t--){
        cin >> n;
        vector<int> A(n);

        for(int &a : A) cin >> a;

        bool valid = 1;

        for(int i = n - 2; i >= 0; i -= 2)
            if(A[i] > A[i + 1])    
                valid = 0;

        cout << (valid ? "YES" : "NO") << '\n';
    }

    return 0;
}
 
void FastIO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
template<typename T> void prd(const T& x){cerr<<x;}
template<typename T, typename U>void prd(const pair<T, U>& val){cerr<<"(";prd(val.fi);cerr<<", ";prd(val.se);cerr<<")";}
template<typename T, typename... Args>void prd(const T& val, Args... args){prd(val);cerr<<", ";prd(args...);}
template<typename... Args> void debug(Args... args){cerr << "["; prd(args...);cerr<<"]\n";}
template<typename T> void debug(const set<T>& c){cerr<<'[';bool cm=0;for(const auto& st:c){if(cm)cerr<<", ";prd(st);cm=1;}cerr<<"]\n";}
template<typename T> void debug(const vector<T>& c){cerr<<'[';bool cm=0;for(const auto& v:c){if(cm)cerr<<", ";prd(v);cm=1;}cerr<<"]\n";}
template<typename T> void debug(const vector<vector<T>> &c){for(const auto &v: c)debug(v);cerr<<'\n';}
template<typename K, typename V> void debug(const map<K, V>& c){cerr<<'[';bool cm=0;for(auto[k, v]:c){if(cm)cerr<<", ";cerr<<'[';prd(k);cerr <<", ";prd(v);cerr<<']';cm = 1;}cerr<<"]\n";}
Problem: 2063B - Subsequence Update
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;

const int N=100005;

ll a[N];

void solve(){

    ll n,l,r;cin>>n>>l>>r;

    for(int i=1;i<=n;i++) cin>>a[i];

    sort(a+1,a+1+n);

    ll ans=0;

    for(int i=1;i<=r-l+1;i++) ans+=a[i];

    cout<<ans<<endl;

}

int main()

{

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

    int T;cin>>T;

    while(T--){

        solve();

    }

    return 0;

}



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

using namespace std;

typedef long long ll;

const int N=100005;

ll a[N],b[N],c[N];

void solve(){

    ll n,l,r;cin>>n>>l>>r;

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

        cin>>a[i];

        b[i]=a[i],c[i]=a[i];

    }

    sort(b+1,b+1+l);

    sort(c+l,c+1+n);

    ll ans1=0,ans2=0;

    for(int i=1;i<=r-l+1;i++) ans1+=b[i];

    for(int i=l;i<=r;i++) ans2+=c[i];

    cout<<min(ans1,ans2)<<endl;

}

int main()

{

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

    int T;cin>>T;

    while(T--){

        solve();

    }

    return 0;

}
Problem: 2063B - Subsequence Update
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;

const int N=100005;

ll a[N],b[N],c[N];

void solve(){

    ll n,l,r;cin>>n>>l>>r;

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

        cin>>a[i];

        b[i]=a[i],c[i]=a[i];

    }

    sort(b+1,b+1+l);

    sort(c+l,c+1+n);

    ll ans1=0,ans2=0;

    for(int i=1;i<=r-l+1;i++) ans1+=b[i];

    for(int i=l;i<=r;i++) ans2+=c[i];

    cout<<min(ans1,ans2)<<endl;

}

int main()

{

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

    int T;cin>>T;

    while(T--){

        solve();

    }

    return 0;

}



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

using namespace std;

typedef long long ll;

const int N=100005;

ll a[N],b[N],c[N];

void solve(){

    ll n,l,r;cin>>n>>l>>r;

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

        cin>>a[i];

        b[i]=a[i],c[i]=a[i];

    }

    sort(b+1,b+1+r);

    sort(c+l,c+1+n);

    ll ans1=0,ans2=0;

    for(int i=1;i<=r-l+1;i++) ans1+=b[i];

    for(int i=l;i<=r;i++) ans2+=c[i];

    cout<<min(ans1,ans2)<<endl;

}

int main()

{

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

    int T;cin>>T;

    while(T--){

        solve();

    }

    return 0;

}
Problem: 2063B - Subsequence Update
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;

const int N=100005;

ll a[N];

void solve(){

    ll n,l,r;cin>>n>>l>>r;

    for(int i=1;i<=n;i++) cin>>a[i];

    sort(a+1,a+1+n);

    ll ans=0;

    for(int i=1;i<=r-l+1;i++) ans+=a[i];

    cout<<ans<<endl;

}

int main()

{

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

    int T;cin>>T;

    while(T--){

        solve();

    }

    return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 10):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, n) for (int i = x; i < n; i++)
#define sortv(v) sort(v.begin(), v.end())
#define sortrv(v) sort(v.rbegin(), v.rend())
#define MOD 1000000000
#define pb push_back

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

void solve() {
    int n; cin >> n;
    vector<pair<int, int>> edges(n - 1);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        edges[i] = make_pair(u, v);
    }
    
    vector<vector<int>> adj(n);
    for (auto& edge : edges) {
        adj[edge.first].push_back(edge.second);
        adj[edge.second].push_back(edge.first);
    }
    
    vector<int> deg(n, 0);
    rep(i,0,n) {
        deg[i] = adj[i].size();
    }
    
    vector<int> node;
    rep(i,0,n) {
        node.push_back(i);
    }
    
    sort(node.begin(), node.end(), [&](int a, int b) { return deg[a] > deg[b]; });
    auto cc = [&](int v1, int v2) {
        vector<bool> rem(n, false);
        rem[v1] = rem[v2] = true;
        int curr = 0;
        vector<bool> vis(n, false);
        function<void(int)> dfs1 = [&](int v) {
            vis[v] = true;
            for (int u : adj[v]) {
                if (!vis[u] && !rem[u]) {
                    dfs1(u);
                }
            }
        };
        
        rep(i,0,n) {
            if (!vis[i] && !rem[i]) {
                dfs1(i);
                curr++;
            }
        }
        
        return curr;
    };
    int res = 0;
    int K = min(12*1LL, n);
    rep(i,0,K) {
        rep(j,i+1,K) {
            res = max(res, cc(node[i], node[j]));
        }
    }
    
    cout << res << endl;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Uncomment the next line for file input/output
    // setIO("shell");
    int tc = 1;
    cin >> tc;
    while(tc--) {
        solve();
    }
    return 0;
}
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 ll long long
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define YN(f)   cout<<((f) ? "YES":"NO")<<"\n"


ll const mod = 1e9+7;
int N = 5e5+5;
vector<ll> fac,inv;
ll power(ll a,ll b){
    if(b==0)    return 1;
    ll tmp = power(a,b/2);
    if(b%2==0)  return (tmp*tmp)%mod;
    else    return (((tmp*tmp)%mod)*a)%mod;
}
ll ncr(ll n,ll r){
    if(r>n) return 0;
    return (((fac[n]*inv[r])%mod)*inv[n-r])%mod;
}
void init_facts(){
    fac.resize(N);
    inv.resize(N);
    fac[0] = 1;
    for(int i=1;i<N;i++)    fac[i] = (fac[i-1]*i)%mod;
    for(int i=0;i<N;i++)    inv[i] = power(fac[i],mod-2)%mod;
}
ll gcd(ll a,ll b){return b==0 ? a:gcd(b,a%b);}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
/*----------------------------------------------------------------------------------------------------------------------------------*/

void solve(int T){
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto &x:a)  cin>>x;
    int ans = accumulate(a.begin(),a.end(),0);
    for(int i=0;i<n-1;i++){
        int temp = 0;
        for(int j=0;j<a.size()-1;j++){
            a[j] = a[j+1]-a[j];
            temp += a[j];
        }
        a.pop_back();
        ans = max(ans,abs(temp));
    }
    cout<<ans<<"\n";
}

/*----------------------------------------------------------------------------------------------------------------------------------*/
int main()                                                                                
{  
    ios_base::sync_with_stdio(false);                         
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    cin>>t;
    for(int _=1;_<=t;_++){
        solve(_);
    }
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define int long long 

#define float long double

#define pb push_back

#define vi vector<int>

#define pii pair<int,int>

#define si set<int>

#define usi unordered_set<int>

#define msi multiset<int>

#define mii map<int,int>

#define umii unordered_map<int,int>

#define mp make_pair

#define ff first

#define ss second

#define vii vector<pii>

#define all(x) (x).begin(),(x).end()

#define MAX(x) *max_element(all(x))

#define MIN(x) *min_element(all(x))

#define SUM(x) accumulate(all(x),0ll)

#define rep(i,a,b) for(int i=(a);i<(b);i++)

#define bck(i,a,b) for(int i=(a)-1;i>=(b);i--)



typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key



const int MOD = 1e9 + 7;



int mod(int a, int m) {

    return (a % m + m) % m;

}



void solve() {

    int n;

    cin >> n;



    string s;

    s = to_string(n);



    int sum = 0;

    int c2 = 0;

    int c3 = 0;



    rep(i,0,s.size()){

        sum+=s[i]-'0';

        if(s[i]=='2')c2++;

        if(s[i]=='3')c3++;

    }



    int l1 = min(8ll,c2);

    int l2 = min(2ll,c3);



    rep(i,0,l1+1){

        rep(j,0,l2+1){

            int k = sum+(2*i+6*j);

            if(k%9==0){

                cout<<"YES"<<endl;

                return;

            }

        }

    }



    cout<<"NO"<<endl;



    



}



int32_t main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;

    cin >> t;



    while (t--) {

        solve();

    }



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 3):
#include <algorithm>

#include <bits/stdc++.h>

#include <vector>



using namespace std;

#define ll long long

int const mod = 998244353, N = 2e5 + 10;

#define fast                                                                   \

  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

int dp[N][13];

int n;

string s;

int rec(int i, int sum) {

  if (sum % 9 == 0) {

    return 1;

  }

  if (i == n) {

    return 0;

  }

  sum %= 9;

  int op1 = 0, op2 = 0, op3 = 0;

  if (s[i] == '2') {

    op1 = rec(i + 1, sum + 2);

  }

  if (s[i] == '3') {

    op2 = rec(i + 1, sum + 6);

  }

  op3 = rec(i + 1, sum);

  return op1 | op2 | op3;

}



int main() {

  fast;

  memset(dp, -1, sizeof dp);

  int t;

  cin >> t;

  while (t--) {

    // cin >> n;

    cin >> s;

    n = s.size();

    int sum = 0;

    for (int i = 0; i < s.size(); i++) {

      sum += (s[i] - '0');

    }

    cout << (rec(0, sum) ? "YES" : "NO") << '\n';

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

      for (int j = 0; j <= 9; j++) {

        dp[i][j] = -1;

      }

    }

  }

}