ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
long long fac(int n,int k){
     if (k == 0 || k == n) return 1;
    
    long long res = 1;
    if (k > n - k) k = n - k; 
    
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) / (i + 1);
    }
    return res;
}
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        bool f=false;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]<=0){
               f = true; 
            }
        }
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0;
        if(f){
        for(int i=0;i<n;i++){
            sum += fac(n-1,i)*(arr[i])*((i % 2) ? -1 : 1);
        }
        }
        else{
            for(int i=0;i<n;i++){
                sum+=arr[i];
            }
        }
        cout<<abs(sum)<<endl;
    
    }
    return 0;
}

Submission (verdict: Runtime error on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> arr(n);
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        if(n==1){
            cout<<arr[1]<<endl;
            continue;
        }
        int temp=n;
        long long ans = -1e18;
        
        for(int i=1;i<=n;i++){
            long long sum=0;
            for (int i = 1; i <= temp; i++) sum = (sum + arr[i]);
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < temp; i++) arr[i] = (arr[i + 1] - arr[i]);
			temp--;
        }
        
       
        cout<<abs(ans)<<endl;
    
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> arr(n+1);
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        if(n==1){
            cout<<arr[1]<<endl;
            continue;
        }
        int temp=n;
        long long ans = -1e18;
        
        for(int i=1;i<=n;i++){
            long long sum=0;
            for (int i = 1; i <= temp; i++) sum = (sum + arr[i]);
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < temp; i++) arr[i] = (arr[i + 1] - arr[i]);
			temp--;
        }
        
       
        cout<<abs(ans)<<endl;
    
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<long long> arr(n+1);
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        if(n==1){
            cout<<arr[1]<<endl;
            continue;
        }
        int temp=n;
        long long ans = -1e18;
        
        for(int i=1;i<=n;i++){
            long long sum=0;
            for (int i = 1; i <= temp; i++) sum = (sum + arr[i]);
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < temp; i++) arr[i] = (arr[i + 1] - arr[i]);
			temp--;
        }
        
       
        cout<<abs(ans)<<endl;
    
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> arr(n);
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        if(n==1){
            cout<<arr[1]<<endl;
            continue;
        }
        int temp=n;
        long long ans = -1e18;
        
        for(int i=1;i<=n;i++){
            long long sum=0;
            for (int i = 1; i <= temp; i++) sum = (sum + arr[i]);
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < temp; i++) arr[i] = (arr[i + 1] - arr[i]);
			temp--;
        }
        
       
        cout<<abs(ans)<<endl;
    
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> arr(n+1);
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        if(n==1){
            cout<<arr[1]<<endl;
            continue;
        }
        int temp=n;
        long long ans = -1e18;
        
        for(int i=1;i<=n;i++){
            long long sum=0;
            for (int i = 1; i <= temp; i++) sum = (sum + arr[i]);
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < temp; i++) arr[i] = (arr[i + 1] - arr[i]);
			temp--;
        }
        
       
        cout<<abs(ans)<<endl;
    
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        res(j,n-1,0){
            while(a.top()!=v[j]){
               cout<<v[j]<<" "<<a.top()<<endl;
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        return 0;
    }
Problem: 2052A - Adrenaline Rush
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
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        if(n==1){
        cout<<"0"<<endl;
        }
        else{
        vp ans;
        res(j,n-1,0){
            while(a.top()!=v[j]){
               ans.pb({v[j],a.top()});
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        cout<<ans.size()<<endl;
        for(auto k:ans)
        cout<<k.fi<<" "<<k.se<<endl;
    }
        return 0;
    }
    

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        if(n==1){
        cout<<"0"<<endl;
        }
        else{
        vp ans;
        res(j,n-1,0){
            while(a.top()!=v[j]){
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                ans.pb({v[j],b.top()});
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        cout<<ans.size()<<endl;
        for(auto k:ans)
        cout<<k.fi<<" "<<k.se<<endl;
    }
        return 0;
    }
Problem: 2052A - Adrenaline Rush
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
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        res(j,n-1,0){
            while(a.top()!=v[j]){
               cout<<v[j]<<" "<<a.top()<<endl;
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        return 0;
    }
    

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> ve;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<double> vd;
#define fi first
#define se second
#define pb push_back
#define con continue 
#define rep(i,a,b) for (int i=a;i<b;i++)
#define res(j,a,b) for (int j=a;j>=b;j--)
const double eps = 1e-6;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define endl "\n"
signed main()
{
    fastio;
        int n;
        cin>>n;
        ve v(n);
        stack<int>a,b;
        rep(i,0,n){
        cin>>v[i];
        a.push(n-i);
        }
        if(n==1){
        cout<<"0"<<endl;
        }
        else{
        vp ans;
        res(j,n-1,0){
            while(a.top()!=v[j]){
               ans.pb({v[j],a.top()});
               b.push(a.top());
               a.pop();
            }
            a.pop();
            while(!b.empty()){
                a.push(b.top());
                b.pop();
            }
            a.push(v[j]);
        }
        cout<<ans.size()<<endl;
        for(auto k:ans)
        cout<<k.fi<<" "<<k.se<<endl;
    }
        return 0;
    }
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        // Count frequency of each element
        unordered_map<int, int> freq;
        for (int num : a) {
            freq[num]++;
        }
        
        // Collect frequencies into a vector and sort descending
        vector<int> freq_vec;
        for (auto& pair : freq) {
            freq_vec.push_back(pair.second);
        }
        sort(freq_vec.rbegin(), freq_vec.rend());
        
        // Compute prefix sums
        vector<int> prefix_sum(freq_vec.size());
        prefix_sum[0] = freq_vec[0];
        for (int i = 1; i < freq_vec.size(); i++) {
            prefix_sum[i] = prefix_sum[i-1] + freq_vec[i];
        }
        
        // Find the smallest m where prefix_sum[m] >= n - k
        int m = freq_vec.size();
        int left = 0, right = freq_vec.size() - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (prefix_sum[mid] >= n - k) {
                m = mid + 1;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        
        cout << m << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;
    for (int test = 0; test < t; ++test) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        
        // Count frequency of each element
        unordered_map<int, int> freq;
        for (int num : a) {
            freq[num]++;
        }
        
        // Collect frequencies into a vector and sort descending
        vector<int> freq_vec;
        for (auto& pair : freq) {
            freq_vec.push_back(pair.second);
        }
        sort(freq_vec.rbegin(), freq_vec.rend());
        
        // Compute prefix sums
        vector<int> prefix_sum(freq_vec.size());
        prefix_sum[0] = freq_vec[0];
        for (int i = 1; i < freq_vec.size(); ++i) {
            prefix_sum[i] = prefix_sum[i - 1] + freq_vec[i];
        }
        
        // Find the smallest m where prefix_sum[m] >= n - k
        int m = freq_vec.size();
        int left = 0, right = freq_vec.size() - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (prefix_sum[mid] >= n - k) {
                m = mid + 1;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        
        cout << m << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    for (int test = 0; test < t; ++test) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        
        // Sort the array
        sort(a.begin(), a.end());
        
        // Count frequencies
        vector<int> freq;
        int count = 1;
        for (int i = 1; i < n; ++i) {
            if (a[i] == a[i - 1]) {
                count++;
            } else {
                freq.push_back(count);
                count = 1;
            }
        }
        freq.push_back(count);
        
        // Sort frequencies descending
        sort(freq.rbegin(), freq.rend());
        
        // Compute prefix sums
        vector<int> prefix_sum(freq.size());
        prefix_sum[0] = freq[0];
        for (int i = 1; i < freq.size(); ++i) {
            prefix_sum[i] = prefix_sum[i - 1] + freq[i];
        }
        
        // Find the smallest m where prefix_sum[m] >= n - k
        int m = freq.size();
        int left = 0, right = freq.size() - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (prefix_sum[mid] >= n - k) {
                m = mid + 1;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        
        cout << m << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        // Count frequency of each element
        unordered_map<int, int> freq;
        for (int num : a) {
            freq[num]++;
        }
        
        // Collect frequencies into a vector and sort descending
        vector<int> freq_vec;
        for (auto& pair : freq) {
            freq_vec.push_back(pair.second);
        }
        sort(freq_vec.rbegin(), freq_vec.rend());
        
        // Compute prefix sums
        vector<int> prefix_sum(freq_vec.size());
        prefix_sum[0] = freq_vec[0];
        for (int i = 1; i < freq_vec.size(); i++) {
            prefix_sum[i] = prefix_sum[i-1] + freq_vec[i];
        }
        
        // Find the smallest m where prefix_sum[m] >= n - k
        int m = freq_vec.size();
        int left = 0, right = freq_vec.size() - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (prefix_sum[mid] >= n - k) {
                m = mid + 1;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        
        cout << m << endl;
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    int t;
    cin >> t;
    for (int test = 0; test < t; ++test) {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        
        // Count frequency of each element
        unordered_map<int, int> freq;
        for (int num : a) {
            freq[num]++;
        }
        
        // Collect frequencies into a vector and sort descending
        vector<int> freq_vec;
        for (auto& pair : freq) {
            freq_vec.push_back(pair.second);
        }
        sort(freq_vec.rbegin(), freq_vec.rend());
        
        // Compute prefix sums
        vector<int> prefix_sum(freq_vec.size());
        prefix_sum[0] = freq_vec[0];
        for (int i = 1; i < freq_vec.size(); ++i) {
            prefix_sum[i] = prefix_sum[i - 1] + freq_vec[i];
        }
        
        // Find the smallest m where prefix_sum[m] >= n - k
        int m = freq_vec.size();
        int left = 0, right = freq_vec.size() - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (prefix_sum[mid] >= n - k) {
                m = mid + 1;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        
        cout << m << endl;
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
    #include <bits/stdc++.h>
    // #include<ext/pb_ds/assoc_container.hpp>
    // #include<ext/pb_ds/tree_policy.hpp>
    #include<limits.h>
    using namespace std;
    // using namespace __gnu_pbds;

    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<ll> vll;
    typedef pair<int, int> pi;

    int mod = int(1e9 + 7);

    // Operator overloads
    template<typename T1, typename T2> // cin >> pair<T1, T2>
    istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); }
    template<typename T> // cin >> vector<T>
    istream& operator>>(istream &istream, vector<T> &v){for (auto &it : v)cin >> it;return istream;}
    template<typename T1, typename T2> // cout << pair<T1, T2>
    ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); }
    template<typename T> // cout << vector<T>
    ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; }

    // tree ordered set
    // template<typename T>
    // using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

    void fast() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }
    // intersect part of two strings

    // !! ॐ !!
    ll sum(ll n,int &cnt2,int &cnt3){
        ll sum = 0;
        while(n > 0){
            if(n%10 == 2) cnt2++;
            if(n%10 == 3) cnt3++;
            sum += n%10;
            n /= 10;
        }
        return sum;
    }

    void solve() {
        ll n;
        cin >> n;

        int cnt2 =0;
        int cnt3 =0;
        int val = sum(n,cnt2,cnt3);

        if(val%9 == 0){
            cout << "YES" << "\n";
            return;
        }
        int c2=2,c3=6;
        for(int i=0;i<=min(cnt2,8);i++){
            for(int j=0;j<=min(cnt3,3);j++){
                int k = c2*i+c3*j;
                // cout << k << "\n";
                if((val+k)%9==0){
                    cout << "YES" << "\n";
                    return;
                }
            }
        }
        cout << "NO" << "\n";
    }

    int main() {
        fast();
        // pre();
        int T=1;
        cin >> T;
        while(T--){
            solve();
        }
        return 0;
    }
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

int datas[MAX];
int temp[MAX];
int choiced[MAX];
int n;
vector<pair<int,int>> ans;

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        choiced[x]=1;
        for(int i=x;i<=n;i++)
        {
            if(choiced[i]==0)
            {
                ans.push_back({x,i});
            }
        }
        for(int i=n;i>=1;i--)
        {
            if(choiced[i]==0)
            {
                ans.push_back({i,x});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto [x,y]:ans)
    {
        cout<<x<<' '<<y<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}


Submission (verdict: Accepted):
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define MAX 1050
#define inf 0x7fffffff
using namespace std;
typedef long long ll;

int datas[MAX];
int choiced[MAX];
int n;
vector<pair<int,int>> ans;

void calcu()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        choiced[x]=1;
        for(int i=x;i<=n;i++)
        {
            if(choiced[i]==0)
            {
                ans.push_back({i,x});
            }
        }
        for(int i=n;i>=1;i--)
        {
            if(choiced[i]==0)
            {
                ans.push_back({x,i});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto [x,y]:ans)
    {
        cout<<x<<' '<<y<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        calcu();
    }
    system("pause");
    return 0;
}