ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: Rust 2021

Previous submission (verdict: Wrong answer on test 1):
use std::io::{stdin, stdout, BufWriter, Write};
use std::cmp;

fn solve(nTwos : u32, nThrees : u32, sum : u32) -> bool{
    
    for i in 0..=nTwos {
        for j in 0..=nThrees {
            
            if (sum + (i * 2) + (j * 6)) % 9 == 0 {
                return true;
            }

        }
    }

    return false;
}

fn main() -> std::io::Result<()> {
    let mut buf: String = String::new();
    let mut output = BufWriter::new(stdout().lock());
    stdin().read_line(&mut buf)?;

    let trim_func = |c: char| -> bool { (c == '\n') || (c == '\r') };

    let mut tcs = 0;
    {
        let line: &str = buf.trim_end_matches(trim_func);
        tcs = line.parse::<u32>().unwrap();
    }

    while tcs > 0 {
        tcs -= 1;
        buf.clear();
        stdin().read_line(&mut buf)?;
        
        let mut nTwos : u32 = 0;
        let mut nThrees : u32 = 0;
        let mut sum : u32 = 0;

        let slice : &[u8] = buf.as_bytes();

        for i in 0..(slice.len() - 1) {
            if slice[i] == ('2' as u8) {
                nTwos += 1;
            }
            else if slice[i] == ('3' as u8) {
                nThrees += 1;
            }

            sum += (slice[i] - ('0' as u8)) as u32;
        }

        if solve(cmp::min(nTwos, 9), cmp::min(nThrees, 9), sum) {
            writeln!(output, "YES");
        }
        else{
            writeln!(output, "NO");
        }
    }

    Ok(())
}


Submission (verdict: Accepted):
use std::io::{stdin, stdout, BufWriter, Write};
use std::cmp;

fn solve(nTwos : u32, nThrees : u32, sum : u32) -> bool{
    
    for i in 0..=nTwos {
        for j in 0..=nThrees {
            
            if (sum + (i * 2) + (j * 6)) % 9 == 0 {
                return true;
            }

        }
    }

    return false;
}

fn main() -> std::io::Result<()> {
    let mut buf: String = String::new();
    let mut output = BufWriter::new(stdout().lock());
    stdin().read_line(&mut buf)?;

    let trim_func = |c: char| -> bool { (c == '\n') || (c == '\r') };

    let mut tcs = 0;
    {
        let line: &str = buf.trim_end_matches(trim_func);
        tcs = line.parse::<u32>().unwrap();
    }

    while tcs > 0 {
        tcs -= 1;
        buf.clear();
        stdin().read_line(&mut buf)?;
        
        let mut nTwos : u32 = 0;
        let mut nThrees : u32 = 0;
        let mut sum : u32 = 0;

        let slice : &[u8] = buf.trim_end_matches(trim_func).as_bytes();

        for i in 0..slice.len() {
            if slice[i] == ('2' as u8) {
                nTwos += 1;
            }
            else if slice[i] == ('3' as u8) {
                nThrees += 1;
            }

            sum += (slice[i] - ('0' as u8)) as u32;
        }

        if solve(cmp::min(nTwos, 9), cmp::min(nThrees, 9), sum) {
            writeln!(output, "YES");
        }
        else{
            writeln!(output, "NO");
        }
    }

    Ok(())
}
Problem: 2052A - Adrenaline Rush
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 44):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in order:
        before = ""
        after = ""
        m += n - len(counted)-1
        for j in reversed(range(1,n+1)):
            if j not in counted and j != i:
                if i < j:
                    m += 1
                    before = f"\n{j} {i}"+before
                before += f"\n{i} {j}"
        string += before + after
        counted.add(i)
    # m2, s2 = max_num(order[1:], n-1)
    # m += m2
    # string += s2
    return m, string
    # for i in range(n):
    #     for j in reversed(range(n)):
    #         if j+1 not in counted:
    #             if j+1 > order[i]:
    #                 m += 2
    #                 string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
    #             elif j+1 < order[i]:
    #                 m += 1
    #                 string += f"{order[i]} {j+1}\n"
    #     counted.add(order[i])

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        m, string = max_num(order, n)
        print(f"{m}{string}")
    i+=1

Submission (verdict: Accepted):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in order:
        before = ""
        after = ""
        m += n - len(counted)-1
        for j in reversed(range(1,n+1)):
            if j not in counted and j != i:
                if i < j:
                    m += 1
                    before = f"\n{j} {i}"+before
                before += f"\n{i} {j}"
        string += before + after
        counted.add(i)
    print(f"{m}{string}")
    return m, string

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        max_num(order, n)
    i+=1
Problem: 2052A - Adrenaline Rush
Language: PyPy 3

Previous submission (verdict: Runtime error on test 44):
import sys

def max_num(order, n):
    if n == 0:
        return 0, ""
    counted = set()
    m = 0
    string = ""
    i = order[0]
    before = ""
    after = ""
    for j in sorted(order, reverse=True):
        if i < j:
            m += 2
            string = f"\n{j} {i}"+string
            before += f"\n{i} {j}"
        elif i > j:
            m += 1
            after += f"\n{i} {j}"
    string += before + after
    m2, s2 = max_num(order[1:], n-1)
    m += m2
    string += s2
    return m, string
    # for i in range(n):
    #     for j in reversed(range(n)):
    #         if j+1 not in counted:
    #             if j+1 > order[i]:
    #                 m += 2
    #                 string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
    #             elif j+1 < order[i]:
    #                 m += 1
    #                 string += f"{order[i]} {j+1}\n"
    #     counted.add(order[i])

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        m, string = max_num(order, n)
        print(f"{m}{string}")
    i+=1

Submission (verdict: Time limit exceeded on test 44):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in order:
        blah = ""
        before = ""
        after = ""
        for j in reversed(range(1,n+1)):
            if j not in counted:
                if i < j:
                    m += 2
                    blah = f"\n{j} {i}"+blah
                    before += f"\n{i} {j}"
                elif i > j:
                    m += 1
                    after += f"\n{i} {j}"
        string += blah + before + after
        counted.add(i)
    # m2, s2 = max_num(order[1:], n-1)
    # m += m2
    # string += s2
    return m, string
    # for i in range(n):
    #     for j in reversed(range(n)):
    #         if j+1 not in counted:
    #             if j+1 > order[i]:
    #                 m += 2
    #                 string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
    #             elif j+1 < order[i]:
    #                 m += 1
    #                 string += f"{order[i]} {j+1}\n"
    #     counted.add(order[i])

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        m, string = max_num(order, n)
        print(f"{m}{string}")
    i+=1
Problem: 2052A - Adrenaline Rush
Language: PyPy 3

Previous submission (verdict: Time limit exceeded on test 44):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in order:
        blah = ""
        before = ""
        after = ""
        for j in reversed(range(1,n+1)):
            if j not in counted:
                if i < j:
                    m += 2
                    blah = f"\n{j} {i}"+blah
                    before += f"\n{i} {j}"
                elif i > j:
                    m += 1
                    after += f"\n{i} {j}"
        string += blah + before + after
        counted.add(i)
    # m2, s2 = max_num(order[1:], n-1)
    # m += m2
    # string += s2
    return m, string
    # for i in range(n):
    #     for j in reversed(range(n)):
    #         if j+1 not in counted:
    #             if j+1 > order[i]:
    #                 m += 2
    #                 string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
    #             elif j+1 < order[i]:
    #                 m += 1
    #                 string += f"{order[i]} {j+1}\n"
    #     counted.add(order[i])

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        m, string = max_num(order, n)
        print(f"{m}{string}")
    i+=1

Submission (verdict: Time limit exceeded on test 44):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in order:
        before = ""
        after = ""
        m += n - len(counted)-1
        for j in reversed(range(1,n+1)):
            if j not in counted and j != i:
                if i < j:
                    m += 1
                    before = f"\n{j} {i}"+before
                before += f"\n{i} {j}"
        string += before + after
        counted.add(i)
    # m2, s2 = max_num(order[1:], n-1)
    # m += m2
    # string += s2
    return m, string
    # for i in range(n):
    #     for j in reversed(range(n)):
    #         if j+1 not in counted:
    #             if j+1 > order[i]:
    #                 m += 2
    #                 string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
    #             elif j+1 < order[i]:
    #                 m += 1
    #                 string += f"{order[i]} {j+1}\n"
    #     counted.add(order[i])

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        m, string = max_num(order, n)
        print(f"{m}{string}")
    i+=1
Problem: 2052A - Adrenaline Rush
Language: Python 3


Submission (verdict: Wrong answer on test 4):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in range(n):
        for j in reversed(range(n)):
            if j+1 not in counted:
                if j+1 > order[i]:
                    m += 2
                    string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
                elif j+1 < order[i]:
                    m += 1
                    string += f"{order[i]} {j+1}\n"
        counted.add(order[i])
    print(m)
    print(string)

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        max_num(order, n)
    i+=1
Problem: 2052A - Adrenaline Rush
Language: Python 3

Previous submission (verdict: Wrong answer on test 4):
import sys

def max_num(order, n):
    counted = set()
    m = 0
    string = ""
    for i in range(n):
        for j in reversed(range(n)):
            if j+1 not in counted:
                if j+1 > order[i]:
                    m += 2
                    string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
                elif j+1 < order[i]:
                    m += 1
                    string += f"{order[i]} {j+1}\n"
        counted.add(order[i])
    print(m)
    print(string)

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        max_num(order, n)
    i+=1

Submission (verdict: Runtime error on test 44):
import sys

def max_num(order, n):
    if n == 0:
        return 0, ""
    counted = set()
    m = 0
    string = ""
    i = order[0]
    before = ""
    after = ""
    for j in sorted(order, reverse=True):
        if i < j:
            m += 2
            string = f"\n{j} {i}"+string
            before += f"\n{i} {j}"
        elif i > j:
            m += 1
            after += f"\n{i} {j}"
    string += before + after
    m2, s2 = max_num(order[1:], n-1)
    m += m2
    string += s2
    return m, string
    # for i in range(n):
    #     for j in reversed(range(n)):
    #         if j+1 not in counted:
    #             if j+1 > order[i]:
    #                 m += 2
    #                 string += f"{j+1} {order[i]}\n{order[i]} {j+1}\n"
    #             elif j+1 < order[i]:
    #                 m += 1
    #                 string += f"{order[i]} {j+1}\n"
    #     counted.add(order[i])

i = 0
for line in sys.stdin.readlines():
    if i==0:
        n = int(line)
    else:
        order = [int(x) for x in line.split(" ")]
        m, string = max_num(order, n)
        print(f"{m}{string}")
    i+=1
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define ph push_back
#define pp pop_back
using namespace std;

const int N=2e5+5;
int T,l,r;


void clear()
{
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>l>>r;
        clear();
        int pos;
        for(int i=30;i>=0;i--)
        {
            int x=(l>>i)&1,y=(r>>i)&1;
            if(x!=y) { pos=i; break; }
        }
        int t=l>>pos+1<<pos+1;
        int p=-1;
        for(int i=pos-1;i>=0;i--)
            if(!((l>>i)&1)) { p=i; break; }
        // cout<<pos<<' '<<p<<endl;
        int a=t+(1<<pos);
        int b=t+(((1<<(pos-p-1))-1)<<p+1)+(p==-1?0:(1<<p));
        int c=t+(((1<<(pos-p-1))-1)<<p+1)+(p==-1?0:(1<<p)-1);
        cout<<a<<' '<<b<<' '<<c<<endl;
    }
    // int a,b,c;
    // while(cin>>a>>b>>c) cout<<((a^b)+(b^c)+(a^c))<<endl;
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define ph push_back
#define pp pop_back
using namespace std;

const int N=2e5+5;
int T,l,r;


void clear()
{
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>l>>r;
        clear();
        int pos;
        for(int i=30;i>=0;i--)
        {
            int x=(l>>i)&1,y=(r>>i)&1;
            if(x!=y) { pos=i; break; }
        }
        int t=l>>pos+1<<pos+1;
        int p=-1;
        for(int i=pos-1;i>=0;i--)
            if(!((l>>i)&1)) { p=i; break; }
        // cout<<pos<<' '<<p<<endl;
        int a=t+(1<<pos);
        int b,c;
        if(p!=-1)
        {
            b=t+(((1<<(pos-p-1))-1)<<p+1)+(1<<p);
            c=t+(((1<<(pos-p-1))-1)<<p+1)+(1<<p)-1;
        }
        else
        {
            b=a+1;
            c=a-1;
        }
        cout<<a<<' '<<b<<' '<<c<<endl;
    }
    // int a,b,c;
    // while(cin>>a>>b>>c) cout<<((a^b)+(b^c)+(a^c))<<endl;
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define ph push_back
#define pp pop_back
using namespace std;

const int N=2e5+5;
int T,l,r;


void clear()
{
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>l>>r;
        clear();
        int pos;
        for(int i=30;i>=0;i--)
        {
            int x=(l>>i)&1,y=(r>>i)&1;
            if(x!=y) { pos=i; break; }
        }
        int a=0,b=(1<<pos),c=((1<<pos)-1);
        cout<<a<<' '<<b<<' '<<c<<' '<<endl;
    }
    // int a,b,c;
    // while(cin>>a>>b>>c) cout<<((a^b)+(b^c)+(a^c))<<endl;
    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>
#define int long long
#define endl '\n'
#define ph push_back
#define pp pop_back
using namespace std;

const int N=2e5+5;
int T,l,r;


void clear()
{
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>l>>r;
        clear();
        int pos;
        for(int i=30;i>=0;i--)
        {
            int x=(l>>i)&1,y=(r>>i)&1;
            if(x!=y) { pos=i; break; }
        }
        int a=0,b=(1<<pos),c=((1<<pos)-1);
        cout<<a<<' '<<b<<' '<<c<<' '<<endl;
    }
    // int a,b,c;
    // while(cin>>a>>b>>c) cout<<((a^b)+(b^c)+(a^c))<<endl;
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define ph push_back
#define pp pop_back
using namespace std;

const int N=2e5+5;
int T,l,r;


void clear()
{
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>T;
    while(T--)
    {
        cin>>l>>r;
        clear();
        int pos;
        for(int i=30;i>=0;i--)
        {
            int x=(l>>i)&1,y=(r>>i)&1;
            if(x!=y) { pos=i; break; }
        }
        int t=l>>pos+1<<pos+1;
        int p=-1;
        for(int i=pos-1;i>=0;i--)
            if(!((l>>i)&1)) { p=i; break; }
        // cout<<pos<<' '<<p<<endl;
        int a=t+(1<<pos);
        int b=t+(((1<<(pos-p-1))-1)<<p+1)+(p==-1?0:(1<<p));
        int c=t+(((1<<(pos-p-1))-1)<<p+1)+(p==-1?0:(1<<p)-1);
        cout<<a<<' '<<b<<' '<<c<<endl;
    }
    // int a,b,c;
    // while(cin>>a>>b>>c) cout<<((a^b)+(b^c)+(a^c))<<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<bits/stdc++.h>

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n, k;
    cin >> n >> k;

    unordered_map<int, int> freqMap;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        freqMap[x]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = 0;
    for (const auto &[_, count]: freq) {
        if (count > 0) {
            if (k > 0 && count <= k) {
                k -= count;
            } else {
                ++ans;
            }
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    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<bits/stdc++.h>

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n, k;
    cin >> n >> k;

    unordered_map<int, int> freqMap;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        freqMap[x]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = 0;
    for (const auto &[_, count]: freq) {
        if (count > 0) {
            if (k > 0 && count <= k) {
                k -= count;
            } else {
                ++ans;
            }
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n, k;
    cin >> n >> k;

    unordered_map<int, int> freqMap;
    int x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        freqMap[x]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = freq.size();
    for (const auto &[_, count]: freq) {
        if (k == 0) break;
        if (count <= k) {
            k -= count;
            --ans;
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    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<bits/stdc++.h>

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n, k;
    cin >> n >> k;

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

    unordered_map<int, int> freqMap;
    for (int i = 0; i < n; ++i) {
        freqMap[a[i]]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = freq.size();
    for (const auto &[_, count]: freq) {
        if (k == 0) break;
        if (count <= k) {
            k -= count;
            --ans;
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


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

using namespace std;

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;

void solve() {
    int n, k;
    cin >> n >> k;

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

    map<int, int> freqMap;
    for (int i = 0; i < n; ++i) {
        freqMap[a[i]]++;
    }

    vector<pair<int, int> > freq(freqMap.begin(), freqMap.end());
    sort(freq.begin(), freq.end(), [](const auto &left, const auto &right) {
        return left.second < right.second;
    });

    int ans = freq.size();
    for (const auto &[_, count]: freq) {
        if (k == 0) break;
        if (count <= k) {
            k -= count;
            --ans;
        }
    }

    if (ans == 0) ++ans;

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}