ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class prob {

    static class FastReader {
        BufferedReader b;
        StringTokenizer s;

        public FastReader() {
            b = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (s == null || !s.hasMoreElements()) {
                try {
                    s = new StringTokenizer(b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return s.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        float nextFloat() {
            return Float.parseFloat(next());
        }

        boolean nextBoolean() {
            return Boolean.parseBoolean(next());
        }

        // Method to read the next line as a string
        String nextLine() {
            String str = "";
            try {
                if (s == null || !s.hasMoreTokens()) {
                    str = b.readLine();
                } else {
                    str = s.nextToken("\n");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    //===================================================================================================

    public static void main(String[] args) {
        FastReader fastReader = new FastReader();

        int t=0;
        t = fastReader.nextInt();

        while(t-- >0){
            int n = fastReader.nextInt();
            int[] arr = new int[n];

            for(int i=0;i<n;i++){
                arr[i] = fastReader.nextInt();
            }

            solve(arr, n);
        }
    }

    public static void solve(int[] arr, int n){

        for(int i=0;i<n-1;i++){
            if(arr[i+1]>arr[i]){
                System.out.println("YES");
                return;
            } else if(arr[i+1]<arr[i]) {
                System.out.println("NO");
                return;
            }
        }

        System.out.println("YES");
        return;
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int dp[N][N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t;
	cin >> t;
	while(t --){
		string a, b, c;
		cin >> a >> b >> c;
		for (int i = 0; i <= a.size(); i++){
			for (int j = 0; j <= b.size(); j++) dp[i][j] = 0;
		}
		a = " " + a, b = " " + b, c = " " + c;
		for (int i = 0; i < a.size(); i++){
			for (int j = 0; j < b.size(); j++){
				if(i + j == 0) continue;
				if(c[i + j] == a[i] && c[i + j] != b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
				else if(c[i + j] == b[j] && c[i + j] != a[i]) dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + 1);
				else if(c[i + j] == a[i] && c[i + j] == b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else{
					if(i && !j) dp[i][j] = dp[i - 1][j] + 1;
					if(j && !i) dp[i][j] = dp[i][j - 1] + 1;
					else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
				}
			}
		}
		cout << dp[a.size() - 1][b.size() - 1] << '\n';
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int dp[N][N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t;
	cin >> t;
	while(t --){
		string a, b, c;
		cin >> a >> b >> c;
		for (int i = 0; i <= a.size(); i++){
			for (int j = 0; j <= b.size(); j++) dp[i][j] = 0;
		}
		a = " " + a, b = " " + b, c = " " + c;
		for (int i = 0; i < a.size(); i++){
			for (int j = 0; j < b.size(); j++){
				if(i + j == 0) continue;
				if(c[i + j] == a[i] && c[i + j] != b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
				else if(c[i + j] == b[j] && c[i + j] != a[i]) dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + 1);
				else if(c[i + j] == a[i] && c[i + j] == b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else{
					if(i && !j) dp[i][j] = dp[i - 1][j] + 1;
					else if(j && !i) dp[i][j] = dp[i][j - 1] + 1;
					else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
				}
			}
		}
		cout << dp[a.size() - 1][b.size() - 1] << '\n';
	}
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int dp[N][N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t;
	cin >> t;
	while(t --){
		string a, b, c;
		cin >> a >> b >> c;
		for (int i = 0; i <= a.size(); i++){
			for (int j = 0; j <= b.size(); j++) dp[i][j] = 0;
		}
		a = " " + a, b = " " + b, c = " " + c;
		for (int i = 0; i < a.size(); i++){
			for (int j = 0; j < b.size(); j++){
				if(i + j == 0) continue;
				if(c[i + j] == a[i] && c[i + j] != b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
				else if(c[i + j] == b[j] && c[i + j] != a[i]) dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + 1);
				else if(c[i + j] == a[i] && c[i + j] == b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else{
					if(i && !j) dp[i][j] = dp[i - 1][j] + 1;
					if(j && !i) dp[i][j] = dp[i][j - 1] + 1;
					else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
				}
			}
		}
		cout << dp[a.size() - 1][b.size() - 1] << '\n';
	}
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int dp[N][N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t;
	cin >> t;
	while(t --){
		string a, b, c;
		cin >> a >> b >> c;
		for (int i = 0; i <= a.size(); i++){
			for (int j = 0; j <= b.size(); j++) dp[i][j] = 0;
		}
		a = " " + a, b = " " + b, c = " " + c;
		for (int i = 0; i < a.size(); i++){
			for (int j = 0; j < b.size(); j++){
				if(i + j == 0) continue;
				if(c[i + j] == a[i] && c[i + j] != b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
				else if(c[i + j] == b[j] && c[i + j] != a[i]) dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + 1);
				else if(c[i + j] == a[i] && c[i + j] == b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else{
					if(i && !j) dp[i][j] = dp[i - 1][j] + 1;
					else if(j && !i) dp[i][j] = dp[i][j - 1] + 1;
					else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
				}
			}
		}
		cout << dp[a.size() - 1][b.size() - 1] << '\n';
	}
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int dp[N][N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t;
	cin >> t;
	while(t --){
		string a, b, c;
		cin >> a >> b >> c;
		for (int i = 0; i <= a.size(); i++){
			for (int j = 0; j <= b.size(); j++) dp[i][j] = 0;
		}
		a = " " + a, b = " " + b, c = " " + c;
		for (int i = 0; i < a.size(); i++){
			for (int j = 0; j < b.size(); j++){
				if(i + j == 0) continue;
				if(c[i + j] == a[i] && c[i + j] != b[j]) {
                    if(!j) dp[i][j] = dp[i - 1][j];
                    else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + 1);
                }
				else if(c[i + j] == b[j] && c[i + j] != a[i]) {
                    if(!i) dp[i][j] = dp[i][j - 1];
                    else dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + 1);
                }
				else if(c[i + j] == a[i] && c[i + j] == b[j]) dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
				else{
					if(i && !j) dp[i][j] = dp[i - 1][j] + 1;
					else if(j && !i) dp[i][j] = dp[i][j - 1] + 1;
					else dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
				}
			}
		}
		cout << dp[a.size() - 1][b.size() - 1] << '\n';
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 3):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;
int a[N], b[N];
multiset<int> s;
int find(int x){
    int y = x / 2;
    int z = ceil(x / 2.0);
    if(y == z){
        auto xx = s.lower_bound(y);
        if(xx != s.end() && *xx == y){
            s.erase(xx);
            auto yy = s.lower_bound(y);
            if(yy != s.end() && *yy == y) return 1;
            int f = find(y);
            if(f) return 1;
            return 0;
        }
        int f = find(y);
        if(f){
            f = find(y);
            if(f) return 1;
            return 0;
        }
        return 0;
    }
    auto yy = s.lower_bound(y);
    auto zz = s.lower_bound(z);
    int fy = 0, fz = 0;
    if(yy == s.end() || *yy != y) fy = 1;
    if(zz == s.end() || *zz != z) fz = 1;
    if(fy && y < *(s.begin())) return 0;
    if(fz && z < *(s.begin())) return 0;
    if(fy && fz){
        int f = find(y), g = find(z);
        if(f && g) return 1;
        return 0;
    }
    else if(fy && !fz){
        s.erase(zz);
        int f = find(y);
        if(f) return 1;
        return 0;
    }
    else if(!fy && fz){
        s.erase(yy);
        int g = find(z);
        if(g) return 1;
        return 0;
    }
    else{
        s.erase(yy); s.erase(zz);
        return 1;
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    cin >> t;
    while(t --){
        int n, m;
        cin >> n >> m;
        s.clear();
        ll s1 = 0, s2 = 0;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            s1 += a[i];
            s.insert(a[i]);
        }
        for (int i = 1; i <= m; i++) cin >> b[i], s2 += b[i];
        if(s1 != s2){cout << "No" << '\n'; continue;}
        sort(b + 1, b + m);
        int res = 0;
        for (int i = m; i >= 1; i--){
            int x = b[i];
            int f = 0;
            auto y = s.lower_bound(x);
            if(y == s.end()){
                int f = find(x);
                if(!f) {res = 1; break;}
            }
            else{
                s.erase(y);
            }
            
        }
        if(!res) cout << "Yes" << '\n';
        else cout << "No" << '\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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>dp, int c_in,int a_used, int tl)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=1e7)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
    // int bused=c_in-a_used;
     if(b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl));
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,1e7)); 
     cout<<f(a,b,c,dp,0,0,al+bl)<<"\n";

    }
       
    
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>dp, int c_in,int a_used, int tl)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=1e7)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a_used<a.size() && a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
     else if(a_used < a.size())
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
    // int bused=c_in-a_used;
     if((c_in - a_used)<b.size() && b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl));
     }
     else if((c_in - a_used)<b.size())
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl));
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,1e7)); 
     cout<<f(a,b,c,dp,0,0,al+bl)<<"\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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>dp, int c_in,int a_used, int tl)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=1e7)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a_used<a.size() && a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
     else if(a_used < a.size())
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
    // int bused=c_in-a_used;
     if((c_in - a_used)<b.size() && b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl));
     }
     else if((c_in - a_used)<b.size())
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl));
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,1e7)); 
     cout<<f(a,b,c,dp,0,0,al+bl)<<"\n";

    }
       
    
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>dp, int c_in,int a_used, int &tl, int &al)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=-1)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a_used< al)
     {
     if(a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     }
    // int bused=c_in-a_used;
     if((c_in - a_used)<(tl-al))
     {
     if(b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     int tl=c.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,-1)); 
     cout<<f(a,b,c,dp,0,0,tl,al)<<"\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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>dp, int c_in,int a_used, int tl)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=1e7)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl));
     }
    // int bused=c_in-a_used;
     if(b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl));
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,1e7)); 
     cout<<f(a,b,c,dp,0,0,al+bl)<<"\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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>dp, int c_in,int a_used, int &tl, int &al)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=-1)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a_used< al)
     {
     if(a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     }
    // int bused=c_in-a_used;
     if((c_in - a_used)<(tl-al))
     {
     if(b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     int tl=c.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,-1)); 
     cout<<f(a,b,c,dp,0,0,tl,al)<<"\n";

    }
       
    
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int , int> pii;
typedef pair<long , long> pll;
typedef vector<pair<int ,int>> vpii;
typedef vector<pair<long, long>> vpll;
typedef vector<long double> vld;
ll MOD = 1e9 +7;

int f(string &a, string &b,string&c, vector<vector<int>>&dp, int c_in,int a_used, int &tl, int &al)
{
     if(c_in>=(tl))
     {
          return 0;
     }
     if(dp[c_in][a_used]!=-1)
     {
          return dp[c_in][a_used];
     }
     int ans=1e8;
     if(a_used< al)
     {
     if(a[a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used+1,tl,al));
     }
     }
    // int bused=c_in-a_used;
     if((c_in - a_used)<(tl-al))
     {
     if(b[c_in - a_used]==c[c_in])
     {
          ans=min(ans,f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     else
     {
          ans=min(ans,1+f(a,b,c,dp,c_in+1,a_used,tl,al));
     }
     }
     return dp[c_in][a_used]=ans;

}

int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
     string a;
     cin>>a;
     string b;
     cin>>b;
     string c;
     cin>>c;
     int al=a.size();
     int bl=b.size();
     int tl=c.size();
     vector<vector<int>> dp((al+bl),vector<int>(al+1,-1)); 
     cout<<f(a,b,c,dp,0,0,tl,al)<<"\n";



    }
       
    
    return 0;
}
Problem: 2057B - Gorilla and the Exam
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--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        map <int, int> e;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            e[a[i]]++;
        }
        int ans = e.size();
        for(auto x : e)
        {
            if(k >= x.second)
            {
                ans--;
                k -= x.second;
            }
        }
        if(k >= n - 1) ans = 1;
        std::cout << ans << '\n';
    }
    return 0;
}

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

using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        cin >> n >> k;
        int k2 = k;
        int a[n];
        map <int, int> e;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            e[a[i]]++;
        }
        int ans = e.size();
        for(auto x : e)
        {
            if(k >= x.second)
            {
                ans--;
                k -= x.second;
            }
        }
        if(k2 >= (n - 1)) ans = 1;
        std::cout << ans << '\n';
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        map <int, int> e;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            e[a[i]]++;
        }
        int ans = e.size();
        for(auto x : e)
        {
            if(k >= x.second)
            {
                ans--;
                k -= x.second;
            }
        }
        if(k >= n - 1) ans = 1;
        std::cout << ans << '\n';
    }
    return 0;
}