ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        unordered_map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        sort(arr.begin(), arr.end());
        long long ans = arr.size();
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            k = k-arr[i];
            if (k<0)
            {
                break;
            }
            ans--;
        }
        int finalans = max(ans,1LL);
        cout<<finalans<<endl;
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        stable_sort(arr.begin(), arr.end());
        long long ans = arr.size();
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            k = k-arr[i];
            if (k<0)
            {
                break;
            }
            ans--;
        }
        int finalans = max(ans,1LL);
        cout<<finalans<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        unordered_map<int, int> mp;
        for (int i = 0; i < n; i++)
        {
            int temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<int> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        stable_sort(arr.begin(), arr.end());
        int ans = 0;
        int sum = 0;
        int i = 0;
        int num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            sum = sum + arr[i];
            if (sum > k)
            {
                break;
            }
        }
        if (i == num)
        {
            cout << 1 << endl;
        }
        else
        {
            ans = ans + (num - i);
            cout << ans << endl;
        }
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        unordered_map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        stable_sort(arr.begin(), arr.end());
        long long ans = 0;
        long long sum = 0;
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            sum = sum + arr[i];
            if (sum > k)
            {
                break;
            }
        }
        if (i == num)
        {
            cout << 1 << endl;
        }
        else
        {
            ans = ans + (num - i);
            cout << ans << endl;
        }
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        unordered_map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        sort(arr.begin(), arr.end());
        long long ans = 0;
        long long sum = 0;
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            sum = sum + arr[i];
            if (sum > k)
            {
                break;
            }
        }
        if (i == num)
        {
            cout << 1 << endl;
        }
        else
        {
            ans = ans + (num - i);
            cout << ans << endl;
        }
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        unordered_map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        sort(arr.begin(), arr.end());
        long long ans = arr.size();
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            k = k-arr[i];
            if (k<0)
            {
                break;
            }
            ans--;
        }
        int finalans = max(ans,1LL);
        cout<<finalans<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        unordered_map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        stable_sort(arr.begin(), arr.end());
        long long ans = 0;
        long long sum = 0;
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            sum = sum + arr[i];
            if (sum > k)
            {
                break;
            }
        }
        if (i == num)
        {
            cout << 1 << endl;
        }
        else
        {
            ans = ans + (num - i);
            cout << ans << endl;
        }
    }
}

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long n, k;
        cin >> n >> k;
        unordered_map<long long, long long> mp;
        for (long long i = 0; i < n; i++)
        {
            long long temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<long long> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        sort(arr.begin(), arr.end());
        long long ans = 0;
        long long sum = 0;
        long long i = 0;
        long long num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            sum = sum + arr[i];
            if (sum > k)
            {
                break;
            }
        }
        if (i == num)
        {
            cout << 1 << endl;
        }
        else
        {
            ans = ans + (num - i);
            cout << ans << endl;
        }
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        unordered_map<int, int> mp;
        for (int i = 0; i < n; i++)
        {
            int temp;
            cin >> temp;
            mp[temp]++;
        }
        vector<int> arr;
        for (auto it : mp)
        {
            arr.push_back(it.second);
        }
        stable_sort(arr.begin(), arr.end());
        int ans = 0;
        int sum = 0;
        int i = 0;
        int num = arr.size();
        for (i = 0; i < arr.size(); i++)
        {
            sum = sum + arr[i];
            if (sum > k)
            {
                break;
            }
        }
        if (i == num)
        {
            cout << 1 << endl;
        }
        else
        {
            ans = ans + (num - i);
            cout << ans << endl;
        }
    }
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


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

// #include <ext/pb_ds/assoc_container.hpp>

// #include <ext/pb_ds/tree_policy.hpp>

// using namespace std;

// using namespace __gnu_pbds;



// using ll = long long;

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

// ll dfs(string s1, string s2, string s3, ll i, ll j, vector<vector<ll>> &dp)

// {

//     if (i >= s1.size() && j >= s2.size())

//     {

//         return 0;

//     }

//     ll ans = LONG_LONG_MAX;

//     if (i < s1.size())

//     {

//         ans = dfs(s1, s2, s3, i + 1, j, dp) + (s1[i] == s3[i + j] ? 0 : 1);

//     }

//     if (j < s2.size())

//     {

//         ans = min(ans, dfs(s1, s2, s3, i, j + 1, dp) + (s2[j] == s3[i + j] ? 0 : 1));

//     }

//     return ans;

// }

// void solve()

// {

//     string s1, s2, s3;

//     cin >> s1;

//     cin >> s2;

//     cin >> s3;

//     vector<vector<ll>> dp(s1.size(), vector<ll>(s2.size(), LONG_LONG_MAX));

//     cout << dfs(s1, s2, s3, 0, 0, dp) << endl;

// }

// int main()

// {



//     ios::sync_with_stdio(false);

//     cin.tie(0);

//     long long t;

//     cin >> t;



//     while (t--)

//     {

//         long long a, b, c;

//         // cin >> a ;

//         solve();

//     }



//     return 0;

// }



#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



using ll = long long;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll dfs(string s1, string s2, string s3, ll i, ll j, vector<vector<ll>> &dp)

{



    if (dp[i][j] != -1)

    {

        return dp[i][j];

    }

    ll ans = LONG_LONG_MAX;

    if (i < s1.size())

    {

        ans = dfs(s1, s2, s3, i + 1, j, dp) + (s1[i] == s3[i + j] ? 0 : 1);

    }

    if (j < s2.size())

    {

        ans = min(ans, dfs(s1, s2, s3, i, j + 1, dp) + (s2[j] == s3[i + j] ? 0 : 1));

    }

    dp[i][j] = ans;

    return ans;

}

void solve()

{

    string s1, s2, s3;

    cin >> s1;

    cin >> s2;

    cin >> s3;

    vector<vector<ll>> dp(s1.size() + 1, vector<ll>(s2.size() + 1, -1));

    dp[s1.size()][s2.size()] = 0;

    dfs(s1, s2, s3, 0, 0, dp);

    cout<< dp[0][0] << endl;

}

int main()

{



    ios::sync_with_stdio(false);

    cin.tie(0);

    long long t;

    cin >> t;



    while (t--)

    {

        long long a, b, c;

        // cin >> a ;

        solve();

    }



    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Wrong answer on test 1):


import java.util.*;



public class AS {



    public static void main(String[] args) {



        Scanner s = new Scanner(System.in);



        int t = s.nextInt();

        s.nextLine();



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



            int c = s.nextInt();

            s.nextLine();



            int[] arr = new int[c];



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



                arr[j] = s.nextInt();

            }

            s.nextLine();



            boolean flag = true;

            for (int j = 0; j < c - 1; j++) {



                arr[i] -= Math.min(arr[i], arr[i + 1]);

                arr[i + 1] -= Math.min(arr[i], arr[i + 1]);



                if (arr[i] > 0) {

                    flag = false;

                    break;

                }

            }



            if (flag)

                System.out.println("yes");

            else

                System.out.println("no");



        }



        s.close();

    }

}

Submission (verdict: Wrong answer on test 1):


import java.util.*;



public class AS {



    public static void main(String[] args) {



        Scanner s = new Scanner(System.in);



        int t = s.nextInt();

        s.nextLine();



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



            int c = s.nextInt();

            s.nextLine();



            int[] arr = new int[c];



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



                arr[j] = s.nextInt();

            }

            s.nextLine();



            boolean flag = true;

            for (int j = 0; j < c - 1; j++) {



                arr[j] -= Math.min(arr[j], arr[j + 1]);

                arr[j + 1] -= Math.min(arr[j], arr[j + 1]);



                if (arr[j] > 0) {

                    flag = false;

                    break;

                }

            }



            if (flag)

                System.out.println("yes");

            else

                System.out.println("no");



        }



        s.close();

    }

}
Problem: 2060D - Subtract Min Sort
Language: Java 21


Submission (verdict: Wrong answer on test 1):


import java.util.*;



public class AS {



    public static void main(String[] args) {



        Scanner s = new Scanner(System.in);



        int t = s.nextInt();

        s.nextLine();



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



            int c = s.nextInt();

            s.nextLine();



            int[] arr = new int[c];



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



                arr[j] = s.nextInt();

            }

            s.nextLine();



            boolean flag = true;

            for (int j = 0; j < c - 1; j++) {



                arr[i] -= Math.min(arr[i], arr[i + 1]);

                arr[i + 1] -= Math.min(arr[i], arr[i + 1]);



                if (arr[i] > 0) {

                    flag = false;

                    break;

                }

            }



            if (flag)

                System.out.println("yes");

            else

                System.out.println("no");



        }



        s.close();

    }

}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Wrong answer on test 1):


import java.util.*;



public class AS {



    public static void main(String[] args) {



        Scanner s = new Scanner(System.in);



        int t = s.nextInt();

        s.nextLine();



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



            int c = s.nextInt();

            s.nextLine();



            int[] arr = new int[c];



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



                arr[j] = s.nextInt();

            }

            s.nextLine();



            boolean flag = true;

            for (int j = 0; j < c - 1; j++) {



                arr[j] -= Math.min(arr[j], arr[j + 1]);

                arr[j + 1] -= Math.min(arr[j], arr[j + 1]);



                if (arr[j] > 0) {

                    flag = false;

                    break;

                }

            }



            if (flag)

                System.out.println("yes");

            else

                System.out.println("no");



        }



        s.close();

    }

}

Submission (verdict: Accepted):


import java.util.*;



public class AS {



    public static void main(String[] args) {



        Scanner s = new Scanner(System.in);



        int t = s.nextInt();

        s.nextLine();



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



            int c = s.nextInt();

            s.nextLine();



            int[] arr = new int[c];



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



                arr[j] = s.nextInt();

            }

            s.nextLine();



            boolean flag = true;

            for (int j = 0; j < c - 1; j++) {



                int temp = Math.min(arr[j], arr[j + 1]);

                arr[j] -= temp;

                arr[j + 1] -= temp;



                if (arr[j] > 0) {

                    flag = false;

                    break;

                }

            }



            if (flag)

                System.out.println("yes");

            else

                System.out.println("no");



        }



        s.close();

    }

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int               long long int
#define endl              "\n"
#define vi                vector<int>
#define vvi               vector<vector<int>>
#define fast              ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int32_t main(){
fast;

int t=0;
cin >> t;
while(t--){
    string s;
    cin >> s;
    int n = s.size();
    vi vec;
    for(int i=0;i<n;i++){
        vec.push_back(s[i] - '0');
    }

    for(int i=0;i<(n-1);i++){
        // cout << "began at " << i << " num = " << vec[i] << endl;
        int num = vec[i];
        int x = i+1;
        if((vec[x]-num<2)){
            // cout << "continuing at " << i << " num= " << vec[i] << endl;
            continue;
        }
        while((vec[x] - num)>1){
            vec[x-1] = vec[x]-1;
            vec[x] = num;
            x++;
            if(x>=n){
                break;
            }
        }
        i--;
        if(i>0){
            i--;
        }
    }

    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;

}

return 0;
}

















Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define int               long long int
#define endl              "\n"
#define vi                vector<int>
#define vvi               vector<vector<int>>
#define fast              ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int32_t main(){
fast;

int t=0;
cin >> t;
while(t--){
    string s;
    cin >> s;
    int n = s.size();
    vi vec;
    for(int i=0;i<n;i++){
        vec.push_back(s[i] - '0');
    }

    for(int i=0;i<(n-1);i++){
        // cout << i << endl;
        // cout << "began at " << i << " num = " << vec[i] << endl;
        int num = vec[i];
        int x = i+1;
        if((vec[x]-num<2)){
            // cout << "continuing at " << i << " num= " << vec[i] << endl;
            continue;
        }
        while((vec[x] - num)>1){
            vec[x-1] = vec[x]-1;
            vec[x] = num;
            x++;
            if(x>=n){
                break;
            }
        }
        i=-1;
        // cout << "happened" << endl;
    }

    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;

}

return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int               long long int
#define endl              "\n"
#define vi                vector<int>
#define vvi               vector<vector<int>>
#define fast              ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int32_t main(){
fast;

int t=0;
cin >> t;
while(t--){
    string s;
    cin >> s;
    int n = s.size();
    vi vec;
    for(int i=0;i<n;i++){
        vec.push_back(s[i] - '0');
    }

    for(int i=0;i<n;i++){
        // cout << "began at " << i << " num = " << vec[i] << endl;
        int num = vec[i];
        int x = i+1;
        if((vec[x]-num<2)){
            // cout << "continuing at " << i << " num= " << vec[i] << endl;
            continue;
        }
        while((vec[x] - num)>1){
            vec[x-1] = vec[x]-1;
            vec[x] = num;
            x++;
            if(x>=n){
                break;
            }
        }
        i--;
        if(i>0){
            i--;
        }
    }

    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;

}

return 0;
}

















Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int               long long int
#define endl              "\n"
#define vi                vector<int>
#define vvi               vector<vector<int>>
#define fast              ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int32_t main(){
fast;

int t=0;
cin >> t;
while(t--){
    string s;
    cin >> s;
    int n = s.size();
    vi vec;
    for(int i=0;i<n;i++){
        vec.push_back(s[i] - '0');
    }

    for(int i=0;i<(n-1);i++){
        // cout << "began at " << i << " num = " << vec[i] << endl;
        int num = vec[i];
        int x = i+1;
        if((vec[x]-num<2)){
            // cout << "continuing at " << i << " num= " << vec[i] << endl;
            continue;
        }
        while((vec[x] - num)>1){
            vec[x-1] = vec[x]-1;
            vec[x] = num;
            x++;
            if(x>=n){
                break;
            }
        }
        i--;
        if(i>0){
            i--;
        }
    }

    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;

}

return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define int               long long int
#define endl              "\n"
#define vi                vector<int>
#define vvi               vector<vector<int>>
#define fast              ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int32_t main(){
fast;

int t=0;
cin >> t;
while(t--){
    string s;
    cin >> s;
    int n = s.size();
    vi vec;
    for(int i=0;i<n;i++){
        vec.push_back(s[i] - '0');
    }

    for(int i=0;i<(n-1);i++){
        // cout << i << endl;
        // cout << "began at " << i << " num = " << vec[i] << endl;
        int num = vec[i];
        int x = i+1;
        if((vec[x]-num<2)){
            // cout << "continuing at " << i << " num= " << vec[i] << endl;
            continue;
        }
        while((vec[x] - num)>1){
            vec[x-1] = vec[x]-1;
            vec[x] = num;
            x++;
            if(x>=n){
                break;
            }
        }
        i=-1;
        // cout << "happened" << endl;
    }

    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;

}

return 0;
}

















Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int               long long int
#define endl              "\n"
#define vi                vector<int>
#define vvi               vector<vector<int>>
#define fast              ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



int32_t main(){
fast;

int t=0;
cin >> t;
while(t--){
    string s;
    cin >> s;
    int n = s.size();
    vi vec;
    for(int i=0;i<n;i++){
        vec.push_back(s[i] - '0');
    }

    for(int i=1;i<n;i++){
        int j=i-1;
        int cur=i;
        while(j>=0){
            if(vec[cur]-vec[j]>1){
                vec[cur]--;
                swap(vec[cur],vec[j]);
                cur--;
                j = cur-1;
            }else{
                break;
            }
        }
    }

    for(int i=0;i<n;i++){
        cout << vec[i];
    }
    cout << endl;

}

return 0;
}