ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int> a1;
    vector<int> a2;
    for(int i=0;i<r;i++) a1.push_back(arr[i]);
    for(int i=l;i<n;i++) a2.push_back(arr[i]);
    sort(a1.begin(), a2.end());
    sort(a2.begin(), a2.end());
    int s1=0, s2=0;
    for(int i=0;i<r-l+1;i++){
        s1 += a1[i];
        s2 += a2[i];
    }
    cout<<min(s1, s2)<<endl;
}
int main()
{
    fastio;
    int n;
    cin>>n;
    while(n--) solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int> a1;
    vector<int> a2;
    for(int i=0;i<r;i++) a1.push_back(arr[i]);
    for(int i=l;i<n;i++) a2.push_back(arr[i]);
    sort(a1.begin(), a2.end());
    sort(a2.begin(), a2.end());
    int s1=0, s2=0;
    for(int i=0;i<r-l+1;i++){
        s1 += a1[i];
        s2 += a2[i];
    }
    cout<<min(s1, s2)<<endl;
}
int main()
{
    fastio;
    int n;
    cin>>n;
    while(n--) solve();
    return 0;
}

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int> arr(n, 0);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int> a1;
    vector<int> a2;
    for(int i=0;i<r;i++) a1.push_back(arr[i]);
    for(int i=l-1;i<n;i++) a2.push_back(arr[i]);
    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());
    int s1=0, s2=0;
    for(int i=0;i<r-l+1;i++){
        s1 += a1[i];
        s2 += a2[i];
    }
    cout<<min(s1, s2)<<endl;
}
int main()
{
    fastio;
    int n;
    cin>>n;
    while(n--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n)continue;
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    int b=solve(a);
	    if(b==a)b++;
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n)continue;
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    int b=solve(a);
	    if(b==l)b++;
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    int flag=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n){
            if(!flag)x+=(1ll<<i);
        }
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
        flag=1;
    }
    if(x>=l)
    return x;
    for(int i=0;i<32;i++){
        if(x>=l)break;
        if((1ll<i)&x)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    
	    
	    int b=solve(a);
	    if(b==l && b+1==a)b+=2;
	    else if(b==l)b++;
	    else if(b==a){
	        if(b+1<=r)b+=1;
	        else
	        b--;
	        
	    }
	    
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    int flag=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n){
            if(!flag)x+=(1ll<<i);
            continue;
        }
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
        flag=1;
    }
    if(x>=l)
    return x;
}
int check(int l,int a){
    int b=l;
    int flag=0;
    for(int i=32;i>=0;i--){
        int y=(1ll<<i);
        if(flag==0 && (y&a)>0 && (y&l)==0){
            flag=1;
            continue;
        }
        if(!flag)continue;
        //cout << i << endl;
        if((y&l)==0)b+=(1ll<<i);
        
        
      
    }
    return b;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    int b=check(l,a);
	    if(b==l){
	        if(b+1==a)b+=2;
	        else
	        b++;
	    }
	    

	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n)continue;
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    
	    int b=solve(a);
	    if(b==l)b++;
	    if(b==a)b++;
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    int flag=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n){
            if(!flag)x+=(1ll<<i);
        }
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
        flag=1;
    }
    if(x>=l)
    return x;
    for(int i=0;i<32;i++){
        if(x>=l)break;
        if((1ll<i)&x)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    
	    
	    int b=solve(a);
	    if(b==l && b+1==a)b+=2;
	    else if(b==l)b++;
	    else if(b==a){
	        if(b+1<=r)b+=1;
	        else
	        b--;
	        
	    }
	    
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n)continue;
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    int b=solve(a);
	    if(b==l)b++;
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n)continue;
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    
	    int b=solve(a);
	    if(b==l)b++;
	    if(b==a)b++;
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int l,r;
int solve(int n){
    int x=0;
    for(int i=32;i>=0;i--){
        if((1ll<<i)&n)continue;
        if(x+(1ll<<i)>r)continue;
        x+=(1ll<<i);
    }
    return x;
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    
	int tt; cin >> tt;
	while(tt--){
	   
	    cin >> l >> r;
	    int a=solve(l);
	    int b=solve(a);
	    if(b==a)b++;
	    cout << l << " " << b << " " << a << "\n";
	    
	    
	    
	    
	    
    
	}

}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define M 998244353
using namespace std;



int main(){
   std::ios::sync_with_stdio(false);
     std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
      int n;
      cin>>n;
      vector<vector<int>> adj(n+1);
      vector<int> f(n+1);
      int max=0,mn=1;
      for(int i=0;i<n-1;i++){
          int a,b;
          cin>>a>>b;
          adj[a].push_back(b);
          adj[b].push_back(a);
          f[a]++;
          f[b]++;

      }
      for(int i=1;i<=n;i++){
        if(max<f[i]){
          max=f[i];
          
        }
      }
      int min_c=n+1;
      for(int i=n;i<=n;i++){
        int c=0;
        if(f[i]==max){
          for(auto j:adj[i]){
              if(f[j]==max)
              c++;
            }
            if(c<min_c){
              min_c=c;
              mn=i;
              }
          }
        }
      for(auto i:adj[mn]){
        f[i]--;
      }
      sort(f.begin(),f.end(),greater<int>());
   
      cout<<f[0]+f[1]-1<<"\n";
    }
     }
     
   
  

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define M 998244353
using namespace std;



int main(){
   std::ios::sync_with_stdio(false);
     std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
      int n;
      cin>>n;
      vector<vector<int>> adj(n+1);
      vector<int> f(n+1);
      int max=0,mn=1;
      for(int i=0;i<n-1;i++){
          int a,b;
          cin>>a>>b;
          adj[a].push_back(b);
          adj[b].push_back(a);
          f[a]++;
          f[b]++;

      }
      for(int i=1;i<=n;i++){
        if(max<f[i]){
          max=f[i];
          
        }
      }
      int min_c=n+1;
      for(int i=1;i<=n;i++){
        int c=0;
        if(f[i]==max){
          
          for(auto j:adj[i]){
              if(f[j]==max)
              c++;
            }
            if(c<min_c){
              min_c=c;
              mn=i;
              }
          }
        }
        
        
      for(auto i:adj[mn]){
        f[i]--;
      }
      sort(f.begin(),f.end(),greater<int>());
   
      cout<<f[0]+f[1]-1<<"\n";
    }
     }
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define M 998244353
using namespace std;



int main(){
   std::ios::sync_with_stdio(false);
     std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
      int n;
      cin>>n;
      vector<vector<int>> adj(n+1);
      vector<int> f(n+1);
      int max=0,mn=1;
      for(int i=0;i<n-1;i++){
          int a,b;
          cin>>a>>b;
          adj[a].push_back(b);
          adj[b].push_back(a);
          f[a]++;
          f[b]++;

      }
      for(int i=1;i<=n;i++){
        if(max<f[i]){
          max=f[i];
          mn=i;
        }
      }
      for(auto i:adj[mn]){
        f[i]--;
      }
      sort(f.begin(),f.end(),greater<int>());
   
      cout<<f[0]+f[1]-1<<"\n";
    }
     }
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define M 998244353
using namespace std;



int main(){
   std::ios::sync_with_stdio(false);
     std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
      int n;
      cin>>n;
      vector<vector<int>> adj(n+1);
      vector<int> f(n+1);
      int max=0,mn=1;
      for(int i=0;i<n-1;i++){
          int a,b;
          cin>>a>>b;
          adj[a].push_back(b);
          adj[b].push_back(a);
          f[a]++;
          f[b]++;

      }
      for(int i=1;i<=n;i++){
        if(max<f[i]){
          max=f[i];
          mn=i;
        }
      }
      for(auto i:adj[mn]){
        f[i]--;
      }
      sort(f.begin(),f.end(),greater<int>());
   
      cout<<f[0]+f[1]-1<<"\n";
    }
     }
     
   
  

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define M 998244353
using namespace std;



int main(){
   std::ios::sync_with_stdio(false);
     std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
      int n;
      cin>>n;
      vector<vector<int>> adj(n+1);
      vector<int> f(n+1);
      int max=0,mn=1;
      for(int i=0;i<n-1;i++){
          int a,b;
          cin>>a>>b;
          adj[a].push_back(b);
          adj[b].push_back(a);
          f[a]++;
          f[b]++;

      }
      for(int i=1;i<=n;i++){
        if(max<f[i]){
          max=f[i];
          
        }
      }
      int min_c=n+1;
      for(int i=n;i<=n;i++){
        int c=0;
        if(f[i]==max){
          for(auto j:adj[i]){
              if(f[j]==max)
              c++;
            }
            if(c<min_c){
              min_c=c;
              mn=i;
              }
          }
        }
      for(auto i:adj[mn]){
        f[i]--;
      }
      sort(f.begin(),f.end(),greater<int>());
   
      cout<<f[0]+f[1]-1<<"\n";
    }
     }
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;
void solve() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        map<int, int> freq;
        
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            freq[a[i]]++;
        }
        
        vector<int> counts;
        for (const auto& pair : freq) {
            counts.push_back(pair.second);
        }
        
        sort(counts.begin(), counts.end());
        
        int removable = 0;
        int total = 0;
        for (int count : counts) {
            if (total + count <= k) {
                total += count;
                removable++;
            } else {
                break;
            }
        }
        
        int result = freq.size() - removable;
        cout << result << endl;
    }
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

int f(vector<int>& b) {
    int n = b.size();
    if (n == 0) return 0;

    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;

    for (int i = 1; i <= n; ++i) {
        int min_val = INT_MAX;
        for (int j = i; j > 0; --j) {
            min_val = min(min_val, b[j - 1]);
            dp[i] = min(dp[i], dp[j - 1] + 1);
        }
    }

    return dp[n];
}

int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
         int n;
    cin >> n;
    vector<int> a;
    for (int j = 0; j < n; ++j) {
        int x;
        cin >> x;
        a.push_back(x);
    }
       int k;
    cin >> k;
   
    cout << f(a) << endl;}

    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 f(vector<int>& b) {
    int n = b.size();
    if (n == 0) return 0;

    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;

    for (int i = 1; i <= n; ++i) {
        int min_val = INT_MAX;
        for (int j = i; j > 0; --j) {
            min_val = min(min_val, b[j - 1]);
            dp[i] = min(dp[i], dp[j - 1] + 1);
        }
    }

    return dp[n];
}

int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
         int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> a;
    for (int j = 0; j < n; ++j) {
        int x;
        cin >> x;
        a.push_back(x);
    }
       
    // Example usage of f(b)
    cout << f(a) << endl;}

    return 0;
}

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

void solve() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        map<int, int> freq;
        
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            freq[a[i]]++;
        }
        
        if (n == k) {
            // If n == k, we can include all elements
            cout << 1 << endl;
            continue;
        }
        
        vector<int> counts;
        for (const auto& pair : freq) {
            counts.push_back(pair.second);
        }
        
        sort(counts.begin(), counts.end());
        
        int removable = 0;
        int total = 0;
        for (int count : counts) {
            if (total + count <= k) {
                total += count;
                removable++;
            } else {
                break;
            }
        }
        
        int result = freq.size() - removable;
        cout << result << endl;
    }
}

int main() {
    solve();
    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 f(vector<int>& b) {
    int n = b.size();
    if (n == 0) return 0;

    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;

    for (int i = 1; i <= n; ++i) {
        int min_val = INT_MAX;
        for (int j = i; j > 0; --j) {
            min_val = min(min_val, b[j - 1]);
            dp[i] = min(dp[i], dp[j - 1] + 1);
        }
    }

    return dp[n];
}

int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
         int n;
    cin >> n;
    vector<int> a;
    for (int j = 0; j < n; ++j) {
        int x;
        cin >> x;
        a.push_back(x);
    }
       int k;
    cin >> k;
   
    cout << f(a) << endl;}

    return 0;
}

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

using namespace std;

int f(vector<int>& b) {
    int n = b.size();
    if (n == 0) return 0;

    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;

    for (int i = 1; i <= n; ++i) {
        int min_val = INT_MAX;
        for (int j = i; j > 0; --j) {
            min_val = min(min_val, b[j - 1]);
            dp[i] = min(dp[i], dp[j - 1] + 1);
        }
    }

    return dp[n];
}

int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
         int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> a;
    for (int j = 0; j < n; ++j) {
        int x;
        cin >> x;
        a.push_back(x);
    }
       
    // Example usage of f(b)
    cout << f(a) << endl;}

    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 n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

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

    int min_diff = INT_MAX;
    for (int i = 1; i < n; ++i) {
        min_diff = min(min_diff, a[i] - a[i - 1]);
    }

    cout << min_diff << endl;

    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
void solve() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        map<int, int> freq;
        
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            freq[a[i]]++;
        }
        
        vector<int> counts;
        for (const auto& pair : freq) {
            counts.push_back(pair.second);
        }
        
        sort(counts.begin(), counts.end());
        
        int removable = 0;
        int total = 0;
        for (int count : counts) {
            if (total + count <= k) {
                total += count;
                removable++;
            } else {
                break;
            }
        }
        
        int result = freq.size() - removable;
        cout << result << endl;
    }
}

int main() {
    solve();
    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 n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

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

    int min_diff = INT_MAX;
    for (int i = 1; i < n; ++i) {
        min_diff = min(min_diff, a[i] - a[i - 1]);
    }

    cout << min_diff << endl;

    return 0;
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 33;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < b.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	for(i32 i = 1; i < a.size(); i++)
	{
		dp[0][i] = 0;
	}
	for(i32 i = 1; i < c.size(); i++)
	{
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j)
			{
				continue;
			}
			dp[i][j] = std::min(dp[i-1][j] + bool(i-j != 0 and b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 2e3+10;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < a.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	for(i32 i = 1; i < c.size(); i++)
	{
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j or i-j >= b.size())
			{
			}
			else
			{
				dp[i][j] = std::min(dp[i-1][j] + bool(i-j != 0 and b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
			}
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
typedef int32_t i32;
typedef int64_t i64;
const i32 N = 2e3+1;

i64 dp[N][N];
void solve()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	a = " " + a;
	b = " " + b;
	c = " " + c;
	for(i32 i = 0; i < c.size(); i++)
	{
		for(i32 j = 0; j < b.size(); j++)
		{
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	for(i32 i = 1; i < c.size(); i++)
	{
		for(i32 j = 1; j < a.size(); j++)
		{
			if(i < j)
			{
				continue;
			}
			dp[i][j] = std::min(dp[i-1][j] + bool(b[i-j] != c[i]), dp[i-1][j-1] + bool(c[i] != a[j]));
		}
	}
	std::cout << dp[(i32)c.size() - 1][(i32)a.size() - 1] << "\n";
}
int main()
{
	std::cin.tie(0)->sync_with_stdio(0);
	int t = 1;
	std::cin >> t;
	while(t--)
	{
		solve();
	}
}