ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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



using namespace std;



#define endl '\n'

#define int long long



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    l--;

    r--;

    int a[n];

    for (int &i : a)

        cin >> i;

    sort(a, a + l);

    sort(a + l, a + r + 1);

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

    int ans = 0;

    for (int i = l; i <= r; i++) {

        ans += a[i];

    }

    int left = ans;

    for (int i = 0; i < l && a[i] < a[r - i]; i++) {

        left += a[i] - a[r - i];

    }

    int right = ans;

    for (int i = 0; i + r + 1 < n && a[i + r + 1] < a[r - i]; i++) {

        right += a[i + r + 1] - a[r - i];

    }

    cout << min(left, right) << endl;

}



signed main() {

    cin.tie(nullptr)->sync_with_stdio(false);

    int t = 1;

    cin >> t;

    while (t--)

        solve();

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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



using namespace std;



#define endl '\n'

#define int long long



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    l--;

    r--;

    int a[n];

    for (int &i : a)

        cin >> i;

    sort(a, a + l);

    sort(a + l, a + r + 1);

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

    int ans = 0;

    for (int i = l; i <= r; i++) {

        ans += a[i];

    }

    int left = ans;

    for (int i = 0; i < l && a[i] < a[r - i]; i++) {

        left += a[i] - a[r - i];

    }

    int right = ans;

    for (int i = 0; i + r + 1 < n && a[i + r + 1] < a[r - i]; i++) {

        right += a[i + r + 1] - a[r - i];

    }

    cout << min(left, right) << endl;

}



signed main() {

    cin.tie(nullptr)->sync_with_stdio(false);

    int t = 1;

    cin >> t;

    while (t--)

        solve();

}



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

using namespace std;

#define endl '\n'
#define int long long

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    l--;
    r--;
    int a[n];
    for (int &i : a)
        cin >> i;
    sort(a, a + l);
    sort(a + l, a + r + 1);
    sort(a + r + 1, a + n);
    int ans = 0;
    for (int i = l; i <= r; i++) {
        ans += a[i];
    }
    int left = ans;
    for (int i = 0; i < l && i <= r && a[i] < a[r - i]; i++) {
        left += a[i] - a[r - i];
    }
    int right = ans;
    for (int i = 0; i + r + 1 < n && i <= r && a[i + r + 1] < a[r - i]; i++) {
        right += a[i + r + 1] - a[r - i];
    }
    cout << min(left, right) << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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



using namespace std;



#define pb push_back

#define F first

#define S second



#define MOD 1000000007



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

#define rall(x) (x).rbegin(), (x).rend()

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

#define YES(con) if (con) { cout << "YES\n"; return; }

#define NO(con) if (con) { cout << "NO\n"; return; }

#define sz(x) int(x.size())



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef vector<unsigned long long> vull;



const char nl = '\n';

const ld PI = acos(-1.0);

const int INF32 = int(1e9) + int(1e8) + int(1e7) + int(1e6) + int(1e5);

const int64_t INF64 = int64_t(1e18) + int64_t(1e17) + int64_t(1e16);

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



template<typename... T>void read(T&... args) {((cin >> args), ...);}

template<typename... T>void print(T&&... args) {((cout << args ), ...);}



struct custom_hash {

    static uint64_t splitmix64(uint64_t x) {

        x += 0x9e3779b97f4a7c15;

        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;

        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;

        return x ^ (x >> 31);

    }

    size_t operator()(uint64_t x) const {

        static const uint64_t FIXED_RANDOM =

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

        return splitmix64(x + FIXED_RANDOM);

    }

};



ll inv(ll i, ll m) {

    return (i <= 1 ? 1 : m - (m / i) * inv(m % i, m) % m);

}



template <typename T>

void readv(vector<T>& v) {

    for (auto& el : v) cin >> el;

}



template<typename T>

void outv(vector<T>& v) {

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

        if (i != (T)v.size() - 1) cout << v[i] << ' ';

        else cout << v[i];

    }

}



template <typename T>

void printColl(T& coll) {

    cout << '\n';

    for (const auto& el : coll) cout << el << ' ';

    cout << '\n';

}



void solve() {

    ll n, l, r;

    cin >> n >> l >> r;

    --l, --r;

    vll v(n), vv, zz;

    FOR (i, 0, n) {

        cin >> v[i];

        if (i < l || i > r) {

            zz.pb(v[i]);

        }

    }

    

    ll val = max(n - r - 1, l);

    FOR (i, l, r + 1) {

        vv.pb(v[i]);

    }

    

    sort(all(zz));

    sort(rall(vv));

    

    ll i = 0, ans = 0, j = 0;

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

        if (val && zz[j] < vv[i]) {

            ans += zz[j++];

            val--;

        } else {

            ans += vv[i];

        }

    }

    

    print(ans, nl);

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    cout << fixed << setprecision(12);



    int t;

    cin >> t;



    while (t--) solve();



    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define pll pair<ll, ll>

#define vll vector<ll>

#define vpll vector<pll>

#define fi first

#define se second

#define NAME "CROAD"

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define IO freopen(NAME".INP", "r", stdin); freopen(NAME".OUT", "w", stdout);

using namespace std;



void solve(){

string s; cin >> s;

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

ll pos = i, mx = s[i] - '0';

for(ll j = i + 1; j < (ll)s.size(); j++){

ll x = s[j] - '0' - (j - i);

if (mx < x){

mx = x; pos = j;

}

}

while(pos > i) swap(s[pos], s[pos - 1]), pos--;

s[i] = mx + '0';

}

cout << s << '\n';

}



int main(){

ll t; cin >> t;

while(t--){

solve();

}

}



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

#define ll long long

#define ld long double

#define pll pair<ll, ll>

#define vll vector<ll>

#define vpll vector<pll>

#define fi first

#define se second

#define NAME "CROAD"

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define IO freopen(NAME".INP", "r", stdin); freopen(NAME".OUT", "w", stdout);

using namespace std;



void solve(){

string s; cin >> s;

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

ll pos = i, mx = s[i] - '0';

for(ll j = i + 1; j < (ll)s.size(); j++){

ll x = s[j] - '0' - (j - i);

if (mx < x){

mx = x; pos = j;

}

}

while(pos > i) swap(s[pos], s[pos - 1]), pos--;

s[i] = mx + '0';

}

cout << s << '\n';

}



int main(){

fastio;

ll t; cin >> t;

while(t--){

solve();

}

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define pll pair<ll, ll>

#define vll vector<ll>

#define vpll vector<pll>

#define fi first

#define se second

#define NAME "CROAD"

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define IO freopen(NAME".INP", "r", stdin); freopen(NAME".OUT", "w", stdout);

using namespace std;



void solve(){

string s; cin >> s;

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

ll pos = i, mx = s[i] - '0';

for(ll j = i + 1; j < (ll)s.size(); j++){

ll x = s[j] - '0' - (j - i);

if (mx < x){

mx = x; pos = j;

}

}

while(pos > i) swap(s[pos], s[pos - 1]), pos--;

s[i] = mx + '0';

}

cout << s << '\n';

}



int main(){

fastio;

ll t; cin >> t;

while(t--){

solve();

}

}



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

#define ll long long

#define ld long double

#define pll pair<ll, ll>

#define vll vector<ll>

#define vpll vector<pll>

#define fi first

#define se second

#define NAME "CROAD"

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define IO freopen(NAME".INP", "r", stdin); freopen(NAME".OUT", "w", stdout);

using namespace std;



void solve(){

string s; cin >> s;

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

ll pos = i, mx = s[i] - '0';

for(ll j = i + 1; j < min(i + 10, (ll)s.size()); j++){

ll x = s[j] - '0' - (j - i);

if (mx < x){

mx = x; pos = j;

}

}

while(pos > i) swap(s[pos], s[pos - 1]), pos--;

s[i] = mx + '0';

}

cout << s << '\n';

}



int main(){

fastio;

ll t; cin >> t;

while(t--){

solve();

}

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define pll pair<ll, ll>

#define vll vector<ll>

#define vpll vector<pll>

#define fi first

#define se second

#define NAME "CROAD"

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define IO freopen(NAME".INP", "r", stdin); freopen(NAME".OUT", "w", stdout);

using namespace std;



void solve(){

string s; cin >> s;

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

ll pos = i, mx = s[i] - '0';

for(ll j = i + 1; j < (ll)s.size(); j++){

ll x = s[j] - '0' - (j - i);

if (mx < x){

mx = x; pos = j;

}

}

while(pos > i) swap(s[pos], s[pos - 1]), pos--;

s[i] = mx + '0';

}

cout << s << '\n';

}



int main(){

ll t; cin >> t;

while(t--){

solve();

}

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

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;

string A, B, C;
int best;

void recur(int Ai, int Bi, int Ci, int Replaced){
    if (Replaced >= best) return;
    if (Ci >= C.length()){
        best = Replaced;
        return;
    }
    if (A.length() > Ai){
        if (A[Ai] == C[Ci]){
            recur(Ai + 1, Bi, Ci + 1, Replaced);
        } else {
            recur(Ai + 1, Bi, Ci + 1, Replaced + 1);
        }
    }
    if (B.length() > Bi){
        if (B[Bi] == C[Ci]){
            recur(Ai, Bi + 1, Ci + 1, Replaced);
        } else {
            recur(Ai, Bi + 1, Ci + 1, Replaced + 1);
        }
    }
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t; cin >> t;
    while (t--){
        best = INT_MAX;
        cin >> A >> B >> C;
        recur(0, 0, 0, 0);
        cout << best << '\n';
    }
    return 0;
}

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

using namespace std;

string A, B, C;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t; cin >> t;
    while (t--){
        cin >> A >> B >> C;
        int n = A.length(), m = B.length();
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, INT_MAX));
        dp[0][0] = 0;
        for (int i = 0; i <= n; ++i){
            for (int j = 0; j <= m; ++j){
                int k = i + j;
                if (k >= C.length()) continue;
                if (i < n){
                    int cost = (A[i] != C[k]) ? 1 : 0;
                    dp[i+1][j] = min(dp[i+1][j], dp[i][j] + cost);
                }
                if (j < m){
                    int cost = (B[j] != C[k]) ? 1 : 0;
                    dp[i][j+1] = min(dp[i][j+1], dp[i][j] + cost);
                }
            }
        }
        cout << dp[n][m] << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;

string A, B, C;

int recur(int Ai, int Bi, int Ci, int Replaced){
    int a = INT_MAX, b = INT_MAX;
    if (Ci >= C.length()) return Replaced;
    if (A.length() > Ai){
        if (A[Ai] == C[Ci]){
            a = recur(Ai + 1, Bi, Ci + 1, Replaced);
        } else {
            a = recur(Ai + 1, Bi, Ci + 1, Replaced + 1);
        }
    }
    if (B.length() > Bi){
        if (B[Bi] == C[Ci]){
            b = recur(Ai, Bi + 1, Ci + 1, Replaced);
        } else {
            b = recur(Ai, Bi + 1, Ci + 1, Replaced + 1);
        }
    }
    return min(a, b);
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t; cin >> t;
    while (t--){
        cin >> A >> B >> C;
        int replaced = recur(0, 0, 0, 0);
        cout << replaced << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;

string A, B, C;

int recur(int Ai, int Bi, int Ci, int Replaced){
    int a = INT_MAX, b = INT_MAX;
    if (Ci >= C.length()) return Replaced;
    if (A.length() > Ai){
        if (A[Ai] == C[Ci]){
            a = recur(Ai + 1, Bi, Ci + 1, Replaced);
        } else {
            a = recur(Ai + 1, Bi, Ci + 1, Replaced + 1);
        }
    }
    if (B.length() > Bi){
        if (B[Bi] == C[Ci]){
            b = recur(Ai, Bi + 1, Ci + 1, Replaced);
        } else {
            b = recur(Ai, Bi + 1, Ci + 1, Replaced + 1);
        }
    }
    return min(a, b);
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t; cin >> t;
    while (t--){
        cin >> A >> B >> C;
        int replaced = recur(0, 0, 0, 0);
        cout << replaced << '\n';
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;

string A, B, C;
int best;

void recur(int Ai, int Bi, int Ci, int Replaced){
    if (Replaced >= best) return;
    if (Ci >= C.length()){
        best = Replaced;
        return;
    }
    if (A.length() > Ai){
        if (A[Ai] == C[Ci]){
            recur(Ai + 1, Bi, Ci + 1, Replaced);
        } else {
            recur(Ai + 1, Bi, Ci + 1, Replaced + 1);
        }
    }
    if (B.length() > Bi){
        if (B[Bi] == C[Ci]){
            recur(Ai, Bi + 1, Ci + 1, Replaced);
        } else {
            recur(Ai, Bi + 1, Ci + 1, Replaced + 1);
        }
    }
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t; cin >> t;
    while (t--){
        best = INT_MAX;
        cin >> A >> B >> C;
        recur(0, 0, 0, 0);
        cout << best << '\n';
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<vector<int>>> dp(lc+1,vector<vector<int>>(la+1,vector<int>(lb+1,1e9)));
  dp[1][1][0] = (a[0]!=c[0]);
  dp[1][0][1] = (b[0]!=c[0]);
  for (int i=2;i<=lc;i++){
    for (int j=0;j<=min(la,i);j++){
      for (int k=0;k<=lc-j;k++){
        if (j>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k]+(a[j-1]!=c[i-1]));
        if (k>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k-1]+(b[k-1]!=c[i-1]));
      }
    }
  }
  cout<<dp[lc][la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<vector<int>>> dp(lc+1,vector<vector<int>>(la+1,vector<int>(lb+1,1e9)));
  dp[1][1][0] = (a[0]!=c[0]);
  dp[1][0][1] = (b[0]!=c[0]);
  for (int i=2;i<=lc;i++){
    for (int j=0;j<=min(la,i);j++){
      for (int k=0;k<=lc-j;k++){
        if (j>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k]+(a[j-1]!=c[i-1]));
        if (k>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k-1]+(b[k-1]!=c[i-1]));
      }
    }
  }
  cout<<dp[lc][la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<vector<int>>> dp(lc+1,vector<vector<int>>(la+1,vector<int>(lb+1,1e6)));
  dp[1][1][0] = (a[0]!=c[0]);
  dp[1][0][1] = (b[0]!=c[0]);
  for (int i=2;i<=lc;i++){
    for (int j=0;j<=min(la,i);j++){
      for (int k=0;k<=lc-j;k++){
        if (j>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k]+(a[j-1]!=c[i-1]));
        if (k>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k-1]+(b[k-1]!=c[i-1]));
      }
    }
  }
  cout<<dp[lc][la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<int>> dp(la+1,vector<int>(lb+1,INT_MAX));
  dp[0][0] = 0;
  dp[1][0] = (a[0]!=c[0]);
  dp[0][1] = (b[0]!=c[0]);
  for (int i=2;i<=lc;i++){
    for (int j=0;j<=min(la,i);j++){
      for (int k=0;k<=lc-j;k++){
        if (j>0) dp[j][k] = min(dp[j][k],dp[j-1][k]+(a[j-1]!=c[i-1]));
        if (k>0) dp[j][k] = min(dp[j][k],dp[j][k-1]+(b[k-1]!=c[i-1]));
      }
    }
  }
  cout<<dp[la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<int>> dp(la+1,vector<int>(lb+1,INT_MAX));
  dp[0][0] = 0;
  for (int i = 0; i < la; i++) {
        dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
  }
  for (int j = 0; j < lb; j++) {
      dp[0][j + 1] = dp[0][j] + (b[j] != c[j]);
  }
  for (int j=1;j<=la;j++){
    for (int k=1;k<=lb;k++){
      dp[j][k] = min(dp[j-1][k]+(a[j-1]!=c[j+k-1]),dp[j][k-1]+(b[k-1]!=c[j+k-1]));
    }
  }
  cout<<dp[la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<vector<int>>> dp(lc+1,vector<vector<int>>(la+1,vector<int>(lb+1,1e6)));
  dp[1][1][0] = (a[0]!=c[0]);
  dp[1][0][1] = (b[0]!=c[0]);
  for (int i=2;i<=lc;i++){
    for (int j=0;j<=min(la,i);j++){
      for (int k=0;k<=lc-j;k++){
        if (j>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k]+(a[j-1]!=c[i-1]));
        if (k>0) dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k-1]+(b[k-1]!=c[i-1]));
      }
    }
  }
  cout<<dp[lc][la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}

Submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// using pll = pair<ll,ll>;

void solve(){
  string a,b,c;
  cin>>a>>b>>c;
  int la = a.size(),lb = b.size(),lc = c.size();
  vector<vector<int>> dp(la+1,vector<int>(lb+1,INT_MAX));
  dp[0][0] = 0;
  dp[1][0] = (a[0]!=c[0]);
  dp[0][1] = (b[0]!=c[0]);
  for (int i=2;i<=lc;i++){
    for (int j=0;j<=min(la,i);j++){
      for (int k=0;k<=lc-j;k++){
        if (j>0) dp[j][k] = min(dp[j][k],dp[j-1][k]+(a[j-1]!=c[i-1]));
        if (k>0) dp[j][k] = min(dp[j][k],dp[j][k-1]+(b[k-1]!=c[i-1]));
      }
    }
  }
  cout<<dp[la][lb]<<endl;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // 中间填保留几位小数，不填默认
    // cout.precision();
    int t;cin>>t;
    while (t--) solve();
    
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll s=0;
  for(int i=1;i<n;i++)
  {
    s+=(a[i]-a[i-1]);
  } 
  cout<<s<<endl;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll s=0;
  sort(a.rbegin(),a.rend());
  for(int i=1;i<n;i++)
  {
    s+=(a[i]-a[i-1]);
  } 
  cout<<s<<endl;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll s=0;
for(int i=0;i<n;i++)
{
   for(int j=0;j<n;j++)
   {
    s+=abs(a[i]-a[j]);
   }
}
if(n==1) cout<<a[0]<<endl;
else cout<<s<<endl;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll s=0;
  for(int i=1;i<n;i++)
  {
    s+=(a[i]-a[i-1]);
  } 
  cout<<s<<endl;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll s=0;
  sort(a.rbegin(),a.rend());
  for(int i=1;i<n;i++)
  {
    s+=(a[i]-a[i-1]);
  } 
  cout<<s<<endl;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  } 
  ll s=0;
for(int i=0;i<n;i++)
{
   for(int j=0;j<n;j++)
   {
    s+=abs(a[i]-a[j]);
   }
}
if(n==1) cout<<a[0]<<endl;
else cout<<s<<endl;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long a[1010];
void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int now = n;
    long long ans = -1e18;
    for (int i = 1; i <= n; i++){
        long long sum = 0;
        for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, max(sum, ( - sum) ));
        for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
        now--;
    }
    cout << ans << endl; 
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
solve();
    }
    
}