ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if(sumEven/cEven == sumOdd/cOdd && sumEven%cEven==0 && sumOdd%cOdd==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        solve();
        
    }

    return 0;
}

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if( sumEven%cEven==0 && sumOdd%cOdd==0&&sumEven/cEven == sumOdd/cOdd ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        solve();
        
    }

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

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    if(n==3){
        if(arr[1]-arr[0]==arr[2]-arr[1]){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else{
        if(abs(arr[0]-arr[n-1])>1){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        solve();
        
    }

    return 0;
}

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if(sumEven/cEven == sumOdd/cOdd && sumEven%cEven==0 && sumOdd%cOdd==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        solve();
        
    }

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

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if( sumEven%cEven==0 && sumOdd%cOdd==0&&sumEven/cEven == sumOdd/cOdd ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        solve();
        
    }

    return 0;
}

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

#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Rikie cout.tie(NULL);
#define ll long long

void solve(){
    ll n;
    cin >> n;
    ll arr[n];
    for(int i = 0 ; i < n; i++){
        cin >> arr[i];
    }
    int cEven , cOdd;
    if(n%2==0){
        cOdd = n/2;
        cEven = n/2;
    }
    else{
        cEven = (n/2) + 1;
        cOdd = n/2;
    }
    int sumOdd = 0 , sumEven = 0 ;
    for(int i = 0;i < n; i ++){
        if (i%2==0){
            sumEven+=arr[i];
        }
        else{
            sumOdd+=arr[i];
        }
    }

    if( sumEven%cEven!=0 || sumOdd%cOdd!=0||sumEven/cEven != sumOdd/cOdd ){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
}

int main(){

    Code By Rikie

    int t;
    cin >> t;
    while(t--){
    
        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;
using ll = long long;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#ifdef MY_LOCAL_TEST
#include "debug.h"
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
inline int nxt() { int x; cin >> x; return x; }
inline ll nxtll() { ll x; cin >> x; return x; }
inline string nxts() { string s; cin >> s; return s; }
void FastIO(string file = "") {
  cin.tie(nullptr)->sync_with_stdio(false);
#ifdef MY_LOCAL_TEST
  auto err_file = freopen("error.txt", "w", stderr);
  if (!err_file) {
    cerr << "can not open file"; exit(1);
  }
#endif
  if (file.empty()) return;
  auto in_file = freopen((file+".in").c_str(), "r", stdin);
  auto out_file = freopen((file+".out").c_str(), "w", stdout);
  if (!(in_file && out_file)) {
    cerr << "can not open file"; exit(1);
  }
}

constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = 1e9+7;

ll dfs(vector<ll> &v) {
  if (sz(v) == 1) return v[0];
  vector<ll> dv;
  for (int i = 1; i < sz(v); ++i) {
    dv.emplace_back(v[i]-v[i-1]);
  }
  ll sum = accumulate(all(v), 0LL);
  return max(sum, abs(dfs(dv)));
}

void solve() {
  int n = nxt();
  vector<ll> arr(n);
  generate(all(arr), nxtll);
  if (n == 1) {
    cout << arr[0] << "\n";
    return;
  }
  cout << dfs(arr) << "\n";
}

int main(void) {
  FastIO(""); int tc = 1; cin >> tc;
  for (int test = 1; test <= tc; ++test) { debug(test); solve(); }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#ifdef MY_LOCAL_TEST
#include "debug.h"
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
inline int nxt() { int x; cin >> x; return x; }
inline ll nxtll() { ll x; cin >> x; return x; }
inline string nxts() { string s; cin >> s; return s; }
void FastIO(string file = "") {
  cin.tie(nullptr)->sync_with_stdio(false);
#ifdef MY_LOCAL_TEST
  auto err_file = freopen("error.txt", "w", stderr);
  if (!err_file) {
    cerr << "can not open file"; exit(1);
  }
#endif
  if (file.empty()) return;
  auto in_file = freopen((file+".in").c_str(), "r", stdin);
  auto out_file = freopen((file+".out").c_str(), "w", stdout);
  if (!(in_file && out_file)) {
    cerr << "can not open file"; exit(1);
  }
}

constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = 1e9+7;

void solve() {
  int n = nxt();
  vector<ll> arr(n);
  generate(all(arr), nxtll);
  if (n == 1) {
    cout << arr[0] << "\n";
    return;
  }
  ll ans = -1e18;
  for (int i = 0, now = n; i < n; ++i, --now) {
    ll sum = 0;
    for (int i = 0; i < now; ++i) sum += arr[i];
    if (i == 0) ans = max(ans, sum);
    else ans = max(ans, abs(sum));
    for (int i = 0; i < now-1; ++i) arr[i] = arr[i+1]-arr[i];
  }
  cout << ans << "\n";
}

int main(void) {
  FastIO(""); int tc = 1; cin >> tc;
  for (int test = 1; test <= tc; ++test) { debug(test); solve(); }
}
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;
using ll = long long;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#ifdef MY_LOCAL_TEST
#include "debug.h"
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
inline int nxt() { int x; cin >> x; return x; }
inline ll nxtll() { ll x; cin >> x; return x; }
inline string nxts() { string s; cin >> s; return s; }
void FastIO(string file = "") {
  cin.tie(nullptr)->sync_with_stdio(false);
#ifdef MY_LOCAL_TEST
  auto err_file = freopen("error.txt", "w", stderr);
  if (!err_file) {
    cerr << "can not open file"; exit(1);
  }
#endif
  if (file.empty()) return;
  auto in_file = freopen((file+".in").c_str(), "r", stdin);
  auto out_file = freopen((file+".out").c_str(), "w", stdout);
  if (!(in_file && out_file)) {
    cerr << "can not open file"; exit(1);
  }
}

constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = 1e9+7;

ll dfs(vector<ll> &v) {
  if (sz(v) == 1) return abs(v[0]);
  vector<ll> dv;
  for (int i = 1; i < sz(v); ++i) {
    dv.emplace_back(v[i]-v[i-1]);
  }
  ll sum = accumulate(all(v), 0LL);
  return max(abs(sum), dfs(dv));
}

void solve() {
  int n = nxt();
  vector<ll> arr(n);
  generate(all(arr), nxtll);
  if (n == 1) {
    cout << arr[0] << "\n";
    return;
  }
  cout << dfs(arr) << "\n";
}

int main(void) {
  FastIO(""); int tc = 1; cin >> tc;
  for (int test = 1; test <= tc; ++test) { debug(test); solve(); }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#ifdef MY_LOCAL_TEST
#include "debug.h"
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
inline int nxt() { int x; cin >> x; return x; }
inline ll nxtll() { ll x; cin >> x; return x; }
inline string nxts() { string s; cin >> s; return s; }
void FastIO(string file = "") {
  cin.tie(nullptr)->sync_with_stdio(false);
#ifdef MY_LOCAL_TEST
  auto err_file = freopen("error.txt", "w", stderr);
  if (!err_file) {
    cerr << "can not open file"; exit(1);
  }
#endif
  if (file.empty()) return;
  auto in_file = freopen((file+".in").c_str(), "r", stdin);
  auto out_file = freopen((file+".out").c_str(), "w", stdout);
  if (!(in_file && out_file)) {
    cerr << "can not open file"; exit(1);
  }
}

constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = 1e9+7;

ll dfs(vector<ll> &v) {
  if (sz(v) == 1) return v[0];
  vector<ll> dv;
  for (int i = 1; i < sz(v); ++i) {
    dv.emplace_back(v[i]-v[i-1]);
  }
  ll sum = accumulate(all(v), 0LL);
  return max(sum, abs(dfs(dv)));
}

void solve() {
  int n = nxt();
  vector<ll> arr(n);
  generate(all(arr), nxtll);
  if (n == 1) {
    cout << arr[0] << "\n";
    return;
  }
  cout << dfs(arr) << "\n";
}

int main(void) {
  FastIO(""); int tc = 1; cin >> tc;
  for (int test = 1; test <= tc; ++test) { debug(test); 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;
using ll = long long;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#ifdef MY_LOCAL_TEST
#include "debug.h"
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
inline int nxt() { int x; cin >> x; return x; }
inline ll nxtll() { ll x; cin >> x; return x; }
inline string nxts() { string s; cin >> s; return s; }
void FastIO(string file = "") {
  cin.tie(nullptr)->sync_with_stdio(false);
#ifdef MY_LOCAL_TEST
  auto err_file = freopen("error.txt", "w", stderr);
  if (!err_file) {
    cerr << "can not open file"; exit(1);
  }
#endif
  if (file.empty()) return;
  auto in_file = freopen((file+".in").c_str(), "r", stdin);
  auto out_file = freopen((file+".out").c_str(), "w", stdout);
  if (!(in_file && out_file)) {
    cerr << "can not open file"; exit(1);
  }
}

constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = 1e9+7;

ll dfs(vector<ll> &v) {
  if (sz(v) == 1) return abs(v[0]);
  vector<ll> dv;
  for (int i = 1; i < sz(v); ++i) {
    dv.emplace_back(v[i]-v[i-1]);
  }
  ll sum = accumulate(all(v), 0LL);
  return max(abs(sum), dfs(dv));
}

void solve() {
  int n = nxt();
  vector<ll> arr(n);
  generate(all(arr), nxtll);
  if (n == 1) {
    cout << arr[0] << "\n";
    return;
  }
  cout << dfs(arr) << "\n";
}

int main(void) {
  FastIO(""); int tc = 1; cin >> tc;
  for (int test = 1; test <= tc; ++test) { debug(test); solve(); }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

using namespace std;

typedef vector<int> vi;
typedef vector<long long int> vll;
typedef long long int lli;
typedef pair<int, int> pii;
typedef map<string, int> msi;
typedef map<int, vector<int>> miv;

// Funciones vector
#define PB(a) push_back(a);

bool sort_func(int a, int b) {
  if (a < b) {
    return true;
  } else {
    return false;
  }
}
#define ord(vect) sort(vect.begin(), vect.end(), sort_func);

#define borra_el(vect, el) vect.erase(vect.find(el));
#define borra_range(vect, a, b) vect.erase(a, b);
#define borra(vect, n) vect.erase(vect.begin() + n);
#define B begin();
#define E end();
#define copia(v1, v2)                                                          \
  ;                                                                            \
  copy(v1.begin(), v1.end(), back_inserter(v2));

// Funciones map
#define F first;
#define S second;

// Logaritmo de 2
double log_2 = log(2);
double log2(int a) { return (log(a) / log_2); }

void Imprime(vi vect) {
  for (int i = 0; i < vect.size(); i++) {
    cout << vect[i] << " ";
  }
  cout << "\n";
}

void Imprime2d(vector<vi> vect) {
  for (int j = 0; j<vect.size(); j++){
    for (int i = 0; i < vect[j].size(); i++) {
        cout << vect[j][i] << " ";
    }
    cout << "\n";
  }
}

void Imprime_set(set<int> s) {
  copy(s.begin(), s.end(), ostream_iterator<int>(cout, " "));
  cout << endl;
}

int maximo_comun_divisor(int a, int b) {
  int temporal; // Para no perder b
  while (b != 0) {
    temporal = b;
    b = a % b;
    a = temporal;
  }
  return a;
}

int minimo_comun_multiplo(int a, int b) {
  return (a * b) / maximo_comun_divisor(a, b);
}

bool isNumeric(string const &str) {
  auto it = str.begin();
  while (it != str.end() && isdigit(*it)) {
    it++;
  }
  return !str.empty() && it == str.end();
}

vi lee(int n) {
  int el;
  vi vect;
  for (int i = 0; i < n; i++) {
    cin >> el;
    vect.PB(el);
  }
  return (vect);
}

int solve() {
  // Code aquí
  int n;
  cin >> n;
  vector<vi> grafo (n, vi {});
  vi conected (n, 0);
  int groups = 1;

  int l, r;
  for (int i = 0; i<n-1; i++){
    cin >> l >> r;
    grafo[l-1].PB(r-1);
    grafo[r-1].PB(l-1);
    conected[l-1]++;
    conected[r-1]++;
  }
  int index = 0;
  for (int i = 1; i<conected.size(); i++){
    if (conected[index] < conected[i]){
        index = i;
    }
  }
  groups += conected[index]-1;
  conected[index] = -1;
  for (int i = 0; i<grafo[index].size(); i++){
    conected[grafo[index][i]]--;
  }
  index = 0;
  for (int i = 1; i<conected.size(); i++){
    if (conected[index] < conected[i]){
        index = i;
    }
  }
  groups += conected[index]-1;
  cout << groups << endl;

  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr); 
  int T;
  cin >> T; // Número de casos
  while (T--) {
    solve();
  }
  return 0;
}

//Eliminar comentario si el proyecto está terminado (Dinámica empezó el 21/06/2024)
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


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

using namespace std;

int main(){

    string a, b, c;

    cin >> a >> b >> c;

    int n = a.length(), m = b.length();

    vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

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

        dp[i][0]=0;

    }

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

        dp[0][i]=0;

    }

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

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

            dp[i][j] = min(dp[i][j],min(

            dp[i-1][j]+(c[i+j-2] != a[i-1]), 

            dp[i][j-1]+(c[i+j-2] != b[j-1])));

        }

    }

    cout << dp[n][m];

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

int main(){

    string a, b, c;

    cin >> a >> b >> c;

    int n = a.length(), m = b.length();

    vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

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

        dp[i][0]=0;

    }

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

        dp[0][i]=0;

    }

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

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

            dp[i][j] = min(dp[i][j],min(

            dp[i-1][j]+(c[i+j-2] != a[i-1]), 

            dp[i][j-1]+(c[i+j-2] != b[j-1])));

        }

    }

    cout << dp[n][m];

}

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

using namespace std;

int main(){

    int t;

    cin >> t;

    while(t--){

        string a, b, c;

        cin >> a >> b >> c;

        int n = a.length(), m = b.length();

        vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

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

            dp[i][0]=0;

        }

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

            dp[0][i]=0;

        }

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

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

                dp[i][j] = min(dp[i][j],min(

                dp[i-1][j]+(c[i+j-2] != a[i-1]), 

                dp[i][j-1]+(c[i+j-2] != b[j-1])));

            }

        }

        cout << dp[n][m];

    }

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

int main(){

    int t;

    cin>>t;

    while(t--){

        string a, b, c;

        cin >> a >> b >> c;

        int n = a.length(), m = b.length();

        vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

        dp[0][0]=0;

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

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

                if(i>=1){

                    dp[i][j]=dp[i-1][j]+(a[i-1]!=c[i+j-1]);

                }if(j>=1){

                    dp[i][j]=min(dp[i][j-1]+(b[j-1]!=c[i+j-1]),dp[i][j]);

                }

            }

        }

        cout << dp[n][m];

    }

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        string a, b, c;

        cin >> a >> b >> c;

        int n = a.length(), m = b.length();

        vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

        dp[0][0]=0;

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

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

                if(i>=1){

                    dp[i][j]=dp[i-1][j]+(a[i-1]!=c[i+j-1]);

                }if(j>=1){

                    dp[i][j]=min(dp[i][j-1]+(b[j-1]!=c[i+j-1]),dp[i][j]);

                }

            }

        }

        cout << dp[n][m]<<'\n';

    }

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

int main(){

    int t;

    cin >> t;

    while(t--){

        string a, b, c;

        cin >> a >> b >> c;

        int n = a.length(), m = b.length();

        vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

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

            dp[i][0]=0;

        }

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

            dp[0][i]=0;

        }

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

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

                dp[i][j] = min(dp[i][j],min(

                dp[i-1][j]+(c[i+j-2] != a[i-1]), 

                dp[i][j-1]+(c[i+j-2] != b[j-1])));

            }

        }

        cout << dp[n][m];

    }

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        string a, b, c;

        cin >> a >> b >> c;

        int n = a.length(), m = b.length();

        vector<vector<int>> dp(n+1, vector<int>(m+1, n+m));

        dp[0][0]=0;

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

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

                if(i>=1){

                    dp[i][j]=dp[i-1][j]+(a[i-1]!=c[i+j-1]);

                }if(j>=1){

                    dp[i][j]=min(dp[i][j-1]+(b[j-1]!=c[i+j-1]),dp[i][j]);

                }

            }

        }

        cout << dp[n][m];

    }

}
Problem: 2057C - Trip to the Olympiad
Language: Java 8

Previous submission (verdict: Wrong answer on test 2):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if(r-l == 2) {
                System.out.println(r+" "+(r-1)+" "+l);
                continue;
            }
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}

Submission (verdict: Accepted):
import java.util.*;
public class ProblemC {

    static long mod = (long)(1e9+7);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
       
            int num = 0;
            for(int i =30;i>=0;i--) {
                if(((l&(1<<i))>0 && (r&(1<<i))>0)) {
                    num|=(1<<i);
                } else if(((l&(1<<i))==0 && (r&(1<<i))==0)) {
                    continue;
                } else {
                    num|=(1<<i);
                    break;
                }
            }

            int a = num;
            int b = num-1;
            int c = (l==b) ? r : l;
            System.out.println(a+" "+b+" "+c);
        }
    }
}