ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 11):
#include <bits/stdc++.h>
using namespace std;
 
vector<int> getLengths(const vector<int>& arr) { 
    unordered_map<int, int> counts; 
    for (int num : arr) { 
        counts[num]++; 
    } 
    vector<int> lengths; 
    for (const auto& pair : counts) { 
        lengths.push_back(pair.second); 
    }
    return lengths; 
}
 
int res(vector<int>& arr1, int b) {
    int groupsRemoved = 0;
    sort(arr1.begin(), arr1.end()); 
    int uniqueCount = arr1.size(); 
 
    for (int i = 0; i < arr1.size(); i++) {
        if (b >= arr1[i]) { 
            b -= arr1[i];  
            groupsRemoved++; 
        } else {
            break; 
        }
    }
    
    return (groupsRemoved == uniqueCount) ? 1 : uniqueCount - groupsRemoved;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t; 
    cin >> t;
 
    while (t--) {
        int a, b; 
        cin >> a >> b;
        vector<int> arr(a);
 
        for (int i = 0; i < a; i++) {
            cin >> arr[i]; 
        }
 
        vector<int> arr1 = getLengths(arr); 
 
        cout << res(arr1, b) << endl;
    }
 
    return 0;
}


Submission (verdict: Time limit exceeded on test 11):
#include <bits/stdc++.h>
using namespace std;

vector<int> getLengths(const vector<int> &arr)
{
    unordered_map<int, int> counts;
    for (int num : arr)
    {
        counts[num]++;
    }
    vector<int> lengths;
    for (const auto &pair : counts)
    {
        lengths.push_back(pair.second);
    }
    return lengths;
}

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

    while (t--)
    {
        int a, b;
        cin >> a >> b;
        vector<int> arr(a);

        for (int i = 0; i < a; i++)
        {
            cin >> arr[i];
        }

        vector<int> arr1 = getLengths(arr);

        sort(arr1.begin(), arr1.end());

        int max = arr1[a - 1];

        arr1.pop_back();

        int i=0;

        while(b>0){
            if(arr1.empty())break;
            else{
                if(arr1[0]<=b){
                    b-=arr1[0];
                    arr1.erase(arr1.begin());
                }else break;
            }
         }

         cout<<arr1.size()+1<<endl;

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)


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

#include <ext/pb_ds/assoc_container.hpp>



#define FOR(i, x, n) for(int i = x; i < n; i++)

#define F0R(i, n) FOR(i, 0, n)

#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)

#define R0F(i, n) ROF(i, 0, n)



#define WTF cout << "WTF" << endl



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

#define F first

#define S second

#define PB push_back

#define EP emplace_back



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

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



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 vector<PII> VPII;

typedef vector<PLL> VPLL;



typedef complex<LD> Point;



const int N = 2e5 + 7;

const int INF = 1e9 + 7;

const int LOG = 22;

const int A = 26;

const int SQ = 320;

const int MOD = 1e9 + 7;



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



int n, x, y;

int ans[N];



void solve() {

    cin >> n >> x >> y;

    x--; y--;





    if (n & 1) {

        ans[x] = 2;

        FOR(i, x + 1, n) ans[i] = ((x - i) % 2 == 0 ? 1 : 0);

        R0F(i, x) ans[i] = ((x - i) % 2 == 0 ? 0 : 1);

    }



    else {

        if (abs(x - y) % 2 == 0) {

            F0R(i, n) ans[i] = (i & 1);

        }

        else {

            F0R(i, n) ans[i] = (abs(x - i) % 2 == 0 ? 0 : 1);

            ans[x] = 2;

        }

    }



    F0R(i, n) cout << ans[i] << ' ';

    cout << endl;

}



int main() {

    IOS;

    int t; cin >> t;

    while(t--) solve();

}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)
#define R0F(i, n) ROF(i, 0, n)

#define WTF cout << "WTF" << endl

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define PB push_back
#define EP emplace_back

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

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 vector<PII> VPII;
typedef vector<PLL> VPLL;

typedef complex<LD> Point;

const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const int LOG = 22;
const int A = 26;
const int SQ = 320;
const int MOD = 1e9 + 7;

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

int l, r;

void solve() {
    cin >> l >> r;
    int x = l ^ r;
    LL cnt = 1;
    while(cnt <= x) {
        cnt *= 2;
    }
    cnt /= 2;

    cout << cnt << ' ' << ((cnt - 1) ^ l) << ' ' << l << endl;
}

int main() {
    IOS;
    int t; cin >> t;
    while(t--) solve();
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)
#define R0F(i, n) ROF(i, 0, n)

#define WTF cout << "WTF" << endl

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define PB push_back
#define EP emplace_back

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

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 vector<PII> VPII;
typedef vector<PLL> VPLL;

typedef complex<LD> Point;

const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const int LOG = 22;
const int A = 26;
const int SQ = 320;
const int MOD = 1e9 + 7;

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

int l, r;

void solve() {
    cin >> l >> r;
    int x = l ^ r;
    LL cnt = 1;
    while(cnt <= x) {
        cnt *= 2;
    }
    cnt /= 2;

    cout << cnt << ' ' << ((cnt - 1) ^ l) << ' ' << l << endl;
}

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


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

#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)
#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)
#define R0F(i, n) ROF(i, 0, n)

#define WTF cout << "WTF" << endl

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define PB push_back
#define EP emplace_back

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

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 vector<PII> VPII;
typedef vector<PLL> VPLL;

typedef complex<LD> Point;

const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const int LOG = 22;
const int A = 26;
const int SQ = 320;
const int MOD = 1e9 + 7;

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

int l, r;

void solve() {
    cin >> l >> r;

    LL a  = 0, b = 0, c = 0;

    R0F(i, 31) {
        if (((r >> i) & 1) != ((l >> i) & 1)) {
            a |= (1LL << i);
            b |= (1LL << i);
            c += (1LL << i) - 1;
            break;
        }

        else if (((r >> i) & 1) == 1) {
            a |= (1LL << i);
            b |= (1LL << i);
            c |= (1LL << i);
        }
    }

    cout << a << ' ' << b << ' ' << c << endl;
}

int main() {
    IOS;
    int t; cin >> t;
    while(t--) solve();
}
Problem: 2049C - MEX Cycle
Language: GNU C11

Previous submission (verdict: Wrong answer on test 1):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					//printf("@");

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

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

			printf("%d",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}

Submission (verdict: Wrong answer on test 1):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					//printf("@");

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

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

			printf("%d ",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}
Problem: 2049C - MEX Cycle
Language: GNU C11


Submission (verdict: Wrong answer on test 1):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					//printf("@");

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

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

			printf("%d",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}
Problem: 2049C - MEX Cycle
Language: GNU C11

Previous submission (verdict: Wrong answer on test 1):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					for(int i=0;i<n-(y-x)-2;i++){

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					o=!o;

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

			}

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

			printf("%d ",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}

Submission (verdict: Accepted):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					for(int i=0;i<n-(y-x)-2;i++){

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					o=!o;

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

			}

		int yo=x-1;

		for(int i=(c-yo);i<c;i++){

			printf("%d ",A[i]);

		}

		for(int i=0;i<(c-yo);i++){

			printf("%d ",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}
Problem: 2049C - MEX Cycle
Language: GNU C11

Previous submission (verdict: Wrong answer on test 1):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					//printf("@");

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

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

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

			printf("%d ",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}

Submission (verdict: Wrong answer on test 1):
#include <stdio.h>  

int main() {  

    int t;  

    scanf("%d", &t); 

    while (t--) {  

        int n,x,y;

        scanf("%d %d %d",&n,&x,&y);

        int A[n];

        int c=0;

        	if((y-x+1)%2==0){

        		int o=0;

        		for(int i=0;i<(y-x+1);i++){

        			A[c++]=o;

        			o=!o;

				}

				if((n-(y-x+1))%2==0){

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					for(int i=0;i<n-(y-x)-2;i++){

						A[c++]=o;

        				o=!o;

					}

					A[c++]=2;

				}

			}

			else {

				int o=0;

				for(int i=0;i<(y-x);i++){

        			A[c++]=o;

        			o=!o;

				}

				A[c++]=2;

				if((n-(y-x+1))%2==0){

					//printf("!");

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

				else {

					o=!o;

					for(int i=0;i<n-(y-x+1);i++){

						A[c++]=o;

        				o=!o;

					}

				}

			}

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

			printf("%d ",A[i]);

		}

		printf("\n");

    }  

    return 0;  

}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;cin>>n;
  vector<int> a(n),og(n),idx(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    --a[i];
    og[i] = i;
    idx[og[i]] = i;
  }
  vector<pair<int,int>> ans;
  vector<vector<bool>> done(n , vector<bool>(n , false));
  for(int i=0;i<n;i++){
    int j = idx[a[i]];
    while(j > i){
      int x = og[j-1] , y = og[j];
      ans.push_back({y,x});
      done[x][y] = true;
      swap(idx[x] , idx[y]);
      swap(og[j] , og[j-1]);
      j--;
    }
  }
  for(int i=0;i+1<n;i++){
    int x = a[i] , y = a[i+1];
    if(!done[x][y] && !done[y][x]){
      done[x][y] = done[y][x];
      ans.push_back({x,y});
      ans.push_back({y,x});
    }
  }
  cout<<ans.size()<<'\n';
  for(auto &[x,y]:ans)cout<<x+1<<" "<<y+1<<"\n";
  return 0;
}

Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;cin>>n;
  vector<int> a(n),og(n),idx(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    --a[i];
    og[i] = i;
    idx[og[i]] = i;
  }
  vector<pair<int,int>> ans;
  vector<vector<bool>> done(n , vector<bool>(n , false));
  for(int i=0;i<n;i++){
    int j = idx[a[i]];
    while(j > i){
      int x = og[j-1] , y = og[j];
      ans.push_back({y,x});
      done[x][y] = true;
      swap(idx[x] , idx[y]);
      swap(og[j] , og[j-1]);
      j--;
    }
  }
  for(int i=0;i+1<n;i++){
    int x = a[i] , y = a[i+1];
    if(!done[x][y] && !done[y][x]){
      done[x][y] = done[y][x];
      ans.push_back({y,x});
      ans.push_back({x,y});
    }
  }
  cout<<ans.size()<<'\n';
  for(auto &[x,y]:ans)cout<<x+1<<" "<<y+1<<"\n";
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;cin>>n;
  vector<int> a(n),og(n),idx(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    --a[i];
    og[i] = i;
    idx[og[i]] = i;
  }
  vector<pair<int,int>> ans;
  vector<vector<bool>> done(n , vector<bool>(n , false));
  for(int i=0;i<n;i++){
    int j = idx[a[i]];
    while(j > i){
      int x = og[j-1] , y = og[j];
      ans.push_back({y,x});
      done[x][y] = true;
      swap(idx[x] , idx[y]);
      swap(og[j] , og[j-1]);
      j--;
    }
  }
  for(int i=0;i+1<n;i++){
    int x = a[i] , y = a[i+1];
    if(!done[x][y] && !done[y][x]){
      done[x][y] = done[y][x];
      ans.push_back({y,x});
      ans.push_back({x,y});
    }
  }
  cout<<ans.size()<<'\n';
  for(auto &[x,y]:ans)cout<<x+1<<" "<<y+1<<"\n";
  return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;cin>>n;
  vector<int> a(n),og(n),idx(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    --a[i];
    og[i] = i;
    idx[og[i]] = i;
  }
  vector<pair<int,int>> ans;
  for(int i = n-1;i >= 0;i--){
    int j = idx[a[i]];
    while(j > 0){
      int x = og[j - 1] , y = og[j];
      ans.push_back({y,x});
      swap(idx[x] , idx[y]);
      swap(og[j] , og[j - 1]);
      j--;
    }
    while(j < i){
      int x = og[j] , y = og[j + 1];
      ans.push_back({y,x});
      swap(idx[x] , idx[y]);
      swap(og[j] , og[j + 1]);
      j++;
    }
  }
  cout<<ans.size()<<'\n';
  for(auto &[x,y]:ans)cout<<x+1<<" "<<y+1<<"\n";
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;cin>>n;
  vector<int> a(n),og(n),idx(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    --a[i];
    og[i] = i;
    idx[og[i]] = i;
  }
  vector<pair<int,int>> ans;
  vector<vector<bool>> done(n , vector<bool>(n , false));
  for(int i=0;i<n;i++){
    int j = idx[a[i]];
    while(j > i){
      int x = og[j-1] , y = og[j];
      ans.push_back({y,x});
      done[x][y] = true;
      swap(idx[x] , idx[y]);
      swap(og[j] , og[j-1]);
      j--;
    }
  }
  for(int i=0;i+1<n;i++){
    int x = a[i] , y = a[i+1];
    if(!done[x][y] && !done[y][x]){
      done[x][y] = done[y][x];
      ans.push_back({x,y});
      ans.push_back({y,x});
    }
  }
  cout<<ans.size()<<'\n';
  for(auto &[x,y]:ans)cout<<x+1<<" "<<y+1<<"\n";
  return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

long long lcs(std::string& a, std::string& b)
{
    std::string substr;
    std::vector matrix(a.length() + 1, std::vector<long long>(b.length() + 1, 0));
    for(int i = 1; i < matrix.size(); ++i)
        for(int j = 1; j < matrix[0].size(); ++j)
        {
            if(a[i - 1] == b[j - 1])
                matrix[i][j] = matrix[i-1][j-1]+ 1;
            else
                matrix[i][j] = std::max(matrix[i-1][j], matrix[i][j-1]);
        }
    return matrix[a.length()][b.length()];
}



int main() {
    int t;
    std::cin >> t;
    while(t > 0)
    {
        std::string a, b, c;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        if(lcs(a, c) > 1 && lcs(b, c) > 1)
            std::cout << c.size() - lcs(a, c) - lcs(b, c) << "\n";
        else if (lcs(a, c) <= 1 && lcs(b, c) > 1)
            std::cout << c.size() - lcs(b, c) << "\n";
        else if (lcs(a, c) > 1 && lcs(b, c) <= 1)
            std::cout << c.size() - lcs(a, c) << "\n";
        else if(lcs(a, c) <= 1 && lcs(b, c) <= 1)
            std::cout << c.size() - 1 << "\n";
        --t;
    }
    
    return 0;
}

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

int min_changes(std::string& a, std::string& b, std::string& c) {
    int n = a.length();
    int m = b.length();
    std::vector<std::vector<int>> dp(n + 1, std::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) {
                dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j] + (a[i] != c[k]));
            }
            if (j < m) {
                dp[i][j + 1] = std::min(dp[i][j + 1], dp[i][j] + (b[j] != c[k]));
            }
        }
    }

    return dp[n][m];
}

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

    while (t--) {
        std::string a, b, c;
        std::cin >> a >> b >> c;
        std::cout << min_changes(a, b, c) << "\n";
    }

    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>

long long lcs(std::string& a, std::string& b)
{
    std::string substr;
    std::vector matrix(a.length() + 1, std::vector<long long>(b.length() + 1, 0));
    for(int i = 1; i < matrix.size(); ++i)
        for(int j = 1; j < matrix[0].size(); ++j)
        {
            if(a[i - 1] == b[j - 1])
                matrix[i][j] = matrix[i-1][j-1]+ 1;
            else
                matrix[i][j] = std::max(matrix[i-1][j], matrix[i][j-1]);
        }
    return matrix[a.length()][b.length()];
}



int main() {
    int t;
    std::cin >> t;
    while(t > 0)
    {
        std::string a, b, c;
        std::cin >> a;
        std::cin >> b;
        std::cin >> c;
        if(lcs(a, c) > 1 && lcs(b, c) > 1)
            std::cout << c.size() - lcs(a, c) - lcs(b, c);
        else if (lcs(a, c) <= 1 && lcs(b, c) > 1)
            std::cout << c.size() - lcs(b, c);
        else if (lcs(a, c) > 1 && lcs(b, c) <= 1)
            std::cout << c.size() - lcs(a, c);
        else if(lcs(a, c) <= 1 && lcs(b, c) <= 1)
            std::cout << c.size() - 1;
        --t;
    }
    
    return 0;
}