ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     int mod = sum % 9; 

     if(mod == 0 || (mod % 2 == 1 && cnt_two >= (9 - mod) / 2)

                 ||  (mod == 3 && cnt_three >= 1) 

                 ||  (mod == 6 && cnt_three >= 2)

                 || ((mod == 4 || mod == 2) && cnt_three >= 1 && cnt_two >= (6 - mod) / 2)

                 || (mod == 1 && cnt_three >= 2 && cnt_two >= 1))

          std::cout << "YES\n";

     else 

          std::cout << "NO\n";

} 

int main() {

     default_file("");

     std::ios::sync_with_stdio(0); std::cin.tie(0);    

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

}



Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     int mod = sum % 9; 

     if(mod == 0 || (mod % 2 == 1 && cnt_two >= (9 - mod) / 2)

                 || (mod == 3 && (cnt_three >= 1 || cnt_two >= 3))

                 || (mod == 6 && (cnt_three >= 2 || cnt_two >= 6))

                 || ((mod == 4 || mod == 2) && cnt_three >= 1 && cnt_two >= (6 - mod) / 2)

                 || (mod == 1 && cnt_three >= 2 && cnt_two >= 1)

                 || (mod == 5 && cnt_three >= 1 && cnt_two >= 2)

                 || (mod == 7 && cnt_three >= 1 && cnt_two >= 4)

                 || (mod == 8 && cnt_two >= 4))

          std::cout << "YES\n";

     else 

          std::cout << "NO\n";

} // 7 

// 6 

int main() {

     default_file("");

     std::ios::sync_with_stdio(0); std::cin.tie(0);    

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     int mod = sum % 9; 

     if(mod == 0 || (mod % 2 == 1 && cnt_two >= (9 - mod) / 2)

                 || (mod == 3 && (cnt_three >= 1 || cnt_two >= 3))

                 || (mod == 6 && (cnt_three >= 2 || cnt_two >= 6))

                 || ((mod == 4 || mod == 2) && cnt_three >= 1 && cnt_two >= (6 - mod) / 2)

                 || (mod == 1 && cnt_three >= 2 && cnt_two >= 1)

                 || (mod == 5 && cnt_three >= 1 && cnt_two >= 2)

                 || (mod == 7 && cnt_three >= 1 && cnt_two >= 4)

                 || (mod == 8 && cnt_two >= 4))

          std::cout << "YES\n";

     else 

          std::cout << "NO\n";

} // 7 

// 6 

int main() {

     default_file("");

     std::ios::sync_with_stdio(0); std::cin.tie(0);    

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

}



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

#include <vector>

#include <algorithm>

#include <cstdint>

#include <map>

#include <string>

#include <set>



#ifdef ONLINE_JUDGE

#define default_file(...)

#define dbg(...)

#else

#include "../local/debug.h"

#endif 



void run_program(){

     std::string s;

     std::cin >> s;

     int sum = 0, cnt_two = 0, cnt_three = 0;

     for(auto& c : s)

          sum += int(c - '0'),     

          cnt_two += (c == '2'),

          cnt_three += (c == '3');

     

     for(int two = 0; two < std::min(10, cnt_two + 1); ++two) 

          for(int three = 0; three < std::min(10, cnt_three + 1); ++three)

               if((sum + two * 2 + three * 6) % 9 == 0)

                    return void(std::cout << "YES\n");

     std::cout << "NO\n";

} 

int main() {

     default_file("");

     std::ios::sync_with_stdio(0); std::cin.tie(0);    

     int t; 

     std::cin >> t;

     while(t--)

     run_program();

     return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

int main() {	

    // #ifndef MYIO
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];

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

        bool f=1;
        for(int i=0;i<n-1;i++){
            if(a[i]>a[i+1]) f=0;
        }

        for(int x:a) cout<<x<<" ";

        cout<<endl;
        cout<<(f?"yes":"no")<<endl;
    }
    return 0;
}


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

int main() {	

    // #ifndef MYIO
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];

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

        bool f=1;
        for(int i=0;i<n-1;i++){
            if(a[i]>a[i+1]) f=0;
        }
        cout<<(f?"yes":"no")<<endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int main() {	

    // #ifndef MYIO
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];


        bool f=1;
        for(int i=0;i<n-1;i+=2){
            if(a[i]>a[i+1]) f=0;
        }

        cout<<(f?"YES":"NO")<<endl;
    }
    return 0;
}


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

int main() {	

    // #ifndef MYIO
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];

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

        bool f=1;
        for(int i=0;i<n-1;i++){
            if(a[i]>a[i+1]) f=0;
        }

        for(int x:a) cout<<x<<" ";

        cout<<endl;
        cout<<(f?"yes":"no")<<endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

int main() {	

    // #ifndef MYIO
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif    
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++) cin>>a[i];


        bool f=1;
        for(int i=0;i<n-1;i+=2){
            if(a[i]>a[i+1]) f=0;
        }

        cout<<(f?"YES":"NO")<<endl;
    }
    return 0;
}
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;

using ll = long long;

using pll = pair<long, long>;

using pii = pair<int, int>;



int s[200020];

int n;



void solve() {

  string temp;

  cin >> temp;

  n = temp.size();



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

    s[i] = temp[i] - '0';

  }



  int p = n - 1;

  while (p > 0) {

    int new_p = p;

    while (new_p > 0 && s[new_p] > s[new_p - 1] + 1) {

      int temp = s[new_p];

      s[new_p] = s[new_p - 1];

      s[new_p - 1] = temp - 1;



      new_p--;

    }

    if (new_p == p) {

      p--;

    } else {

      p = new_p + 2;

    }

  }



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

    cout << s[i];

  }

  cout << endl;

}



signed main() {

  int t;

  cin >> t;

  while (t > 0) {

    solve();

    t--;

  }

}



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

using namespace std;

using ll = long long;

using pll = pair<long, long>;

using pii = pair<int, int>;



int s[200020];

int n;



void solve() {

  string temp;

  cin >> temp;

  n = temp.size();



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

    s[i] = temp[i] - '0';

  }



  int p = n - 1;

  while (p > 0) {

    int new_p = p;

    while (new_p > 0 && s[new_p] > s[new_p - 1] + 1) {

      int temp = s[new_p];

      s[new_p] = s[new_p - 1];

      s[new_p - 1] = temp - 1;



      new_p--;

    }

    if (new_p == p) {

      p--;

    } else if (p != n - 1) {

      p += 1;

    }

  }



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

    cout << s[i];

  }

  cout << endl;

}



signed main() {

  int t;

  cin >> t;

  while (t > 0) {

    solve();

    t--;

  }

}
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;

using ll = long long;

using pll = pair<long, long>;

using pii = pair<int, int>;



int s[200020];

int n;



void solve() {

  string temp;

  cin >> temp;

  n = temp.size();



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

    s[i] = temp[i] - '0';

  }



  int p = n - 1;

  while (p > 0) {

    int new_p = p;

    while (new_p > 0 && s[new_p] > s[new_p - 1] + 1) {

      int temp = s[new_p];

      s[new_p] = s[new_p - 1];

      s[new_p - 1] = temp - 1;



      new_p--;

    }

    if (new_p == p) {

      p--;

    } else {

      p = n - 1;

    }

  }



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

    cout << s[i];

  }

  cout << endl;

}



signed main() {

  int t;

  cin >> t;

  while (t > 0) {

    solve();

    t--;

  }

}



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

using namespace std;

using ll = long long;

using pll = pair<long, long>;

using pii = pair<int, int>;



int s[200020];

int n;



void solve() {

  string temp;

  cin >> temp;

  n = temp.size();



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

    s[i] = temp[i] - '0';

  }



  int p = n - 1;

  while (p > 0) {

    int new_p = p;

    while (new_p > 0 && s[new_p] > s[new_p - 1] + 1) {

      int temp = s[new_p];

      s[new_p] = s[new_p - 1];

      s[new_p - 1] = temp - 1;



      new_p--;

    }

    if (new_p == p) {

      p--;

    } else {

      p = new_p + 2;

    }

  }



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

    cout << s[i];

  }

  cout << endl;

}



signed main() {

  int t;

  cin >> t;

  while (t > 0) {

    solve();

    t--;

  }

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


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

using namespace std;

using ll = long long;

using pll = pair<long, long>;

using pii = pair<int, int>;



int s[200020];

int n;



void solve() {

  string temp;

  cin >> temp;

  n = temp.size();



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

    s[i] = temp[i] - '0';

  }



  int p = n - 1;

  while (p > 0) {

    int new_p = p;

    while (new_p > 0 && s[new_p] > s[new_p - 1] + 1) {

      int temp = s[new_p];

      s[new_p] = s[new_p - 1];

      s[new_p - 1] = temp - 1;



      new_p--;

    }

    if (new_p == p) {

      p--;

    } else {

      p = n - 1;

    }

  }



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

    cout << s[i];

  }

  cout << endl;

}



signed main() {

  int t;

  cin >> t;

  while (t > 0) {

    solve();

    t--;

  }

}
Problem: 2063B - Subsequence Update
Language: C# 10


Submission (verdict: Wrong answer on test 2):
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int t = int.Parse(Console.ReadLine()); // 读取测试用例数量
        while (t-- > 0)
        {
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]); // 序列长度
            int l = int.Parse(input[1]); // 区间左端点
            int r = int.Parse(input[2]); // 区间右端点

            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); // 读取序列

            // 计算区间 [l, r] 内的最小和
            long minSum = GetMinSumAfterReversingSubsequence(a, l - 1, r - 1, n - 1); // 转换为 0-based 索引
            Console.WriteLine(minSum);
        }
    }

    static long GetMinSumAfterReversingSubsequence(int[] a, int l, int r, int n)
    {
        // 区间 [l, r] 内的元素
        int[] inside = new int[r-l+1];
        Array.Sort(inside);
        Array.Copy(a, l, inside, 0, inside.Length);
        int asum = 0;
        int lsum = 0;
        int rsum = 0;
        int ans = 0;

        if(l > 0) {
            int[] lseg = new int[l];
            Array.Copy(a, 0, lseg, 0, lseg.Length);
            Array.Sort(lseg);
            for(int i = 0; i < lseg.Length && i < inside.Length; i++){
                asum += inside[inside.Length-i-1];
                lsum += lseg[i];
                if(lsum < asum){
                    ans = Math.Min(ans, lsum - asum);
                }
            }
        }
        asum = 0;
        if(n > r){
            int[] rseg = new int[n-r];
            Array.Copy(a, r+1, rseg, 0, rseg.Length);
            Array.Sort(rseg);
            for(int i = 0; i < rseg.Length && i < inside.Length; i++){
                asum += inside[inside.Length-i-1];
                rsum += rseg[i];
                if(rsum < asum){
                    ans = Math.Min(ans, rsum - asum);
                }
            }
        }
        
        for(int i = 0; i < inside.Length; i++){
            ans += inside[i];
        }

        return ans;
    }
}
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 3):
from sys import stdin
from typing import Any
import math
input = stdin.readline
def ri(): return int(input())
def rl(v_type=int,output=list): return output(map(v_type, input().split()))
def rs(): return input().rstrip()
def out(x, sep='\n'): print(sep.join(x))


def solve():
    s = rs()
    n = len(s)
    a = list(map(int,s))
    for i in range(n-2,-1,-1):
        for j in range(i+1, min(i + 10,n)):
            if a[j-1] + (1) < a[j]:
                a[j-1],a[j] = a[j] - (1),a[j-1]
            else:
                break
        
    return "".join(map(str,a))


output = []
for _ in range(ri()):
    output.append(str(solve()))
out(output)

Submission (verdict: Accepted):
from sys import stdin
from typing import Any
import math
input = stdin.readline
def ri(): return int(input())
def rl(v_type=int,output=list): return output(map(v_type, input().split()))
def rs(): return input().rstrip()
def out(x, sep='\n'): print(sep.join(x))


def solve():
    s = rs()
    n = len(s)
    a = list(map(int,s))
    for i in range(1,n):
        for j in range(i -1,max(-1,i - 11),-1):
            if a[j] + 1 < a[j + 1]:
                a[j],a[j+1] = a[j+1] - 1, a[j]
            else:
                break 

        
    return "".join(map(str,a))



output = []
for _ in range(ri()):
    output.append(str(solve()))
out(output)
Problem: 2050D - Digital string maximization
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
from sys import stdin
from typing import Any
import math
input = stdin.readline
def ri(): return int(input())
def rl(v_type=int,output=list): return output(map(v_type, input().split()))
def rs(): return input().rstrip()
def out(x, sep='\n'): print(sep.join(x))


def solve():
    s = rs()
    n = len(s)
    a = list(map(int,s))
    for i in range(n-2,-1,-1):
        for j in range(i+1, min(i + 10,n)):
            if a[j-1] + (j-i) < a[j]:
                a[j-1],a[j] = a[j] - (1),a[j-1]
            else:
                break
    for i in range(n-2,-1,-1):
        for j in range(i+1, min(i + 10,n)):
            if a[j-1] + (j-i) < a[j]:
                a[j-1],a[j] = a[j] - (1),a[j-1]
            else:
                break
        
    return "".join(map(str,a))


output = []
for _ in range(ri()):
    output.append(str(solve()))
out(output)
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from sys import stdin
from typing import Any
import math
input = stdin.readline
def ri(): return int(input())
def rl(v_type=int,output=list): return output(map(v_type, input().split()))
def rs(): return input().rstrip()
def out(x, sep='\n'): print(sep.join(x))


def solve():
    s = rs()
    n = len(s)
    a = list(map(int,s))
    for i in range(n-2,-1,-1):
        for j in range(i+1, min(i + 10,n)):
            if a[j-1] + (j-i) < a[j]:
                a[j-1],a[j] = a[j] - (1),a[j-1]
            else:
                break
    for i in range(n-2,-1,-1):
        for j in range(i+1, min(i + 10,n)):
            if a[j-1] + (j-i) < a[j]:
                a[j-1],a[j] = a[j] - (1),a[j-1]
            else:
                break
        
    return "".join(map(str,a))


output = []
for _ in range(ri()):
    output.append(str(solve()))
out(output)

Submission (verdict: Wrong answer on test 3):
from sys import stdin
from typing import Any
import math
input = stdin.readline
def ri(): return int(input())
def rl(v_type=int,output=list): return output(map(v_type, input().split()))
def rs(): return input().rstrip()
def out(x, sep='\n'): print(sep.join(x))


def solve():
    s = rs()
    n = len(s)
    a = list(map(int,s))
    for i in range(n-2,-1,-1):
        for j in range(i+1, min(i + 10,n)):
            if a[j-1] + (1) < a[j]:
                a[j-1],a[j] = a[j] - (1),a[j-1]
            else:
                break
        
    return "".join(map(str,a))


output = []
for _ in range(ri()):
    output.append(str(solve()))
out(output)
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

int main(){
    int tc;
    cin>>tc;
    outer:
    while(tc--){
        int n,m;
        cin>>n>>m;
        multiset<int> a,b;
        for(int i = 0;i<n;i++){
            int temp;
            cin>>temp;
            a.insert(temp);
        }
        a.insert(1e9+1);
        for(int i = 0;i<m;i++){
            int temp;
            cin>>temp;
            b.insert(temp);
        }

        for(auto it = a.begin();it!=a.end();++it){
            if(*it  == 1e9+1) break;
            auto next_it = next(it);
            if(b.find(*it)!=b.end()){
                b.erase(*it);
            }else if(abs(*next_it - *it)<=1 && b.find(*next_it+*it)!= b.end()){
                b.erase(*next_it+*it);
                ++it;
            }else if(abs(*next_it - *it)<=1){
                a.insert(*next_it + *it);
                ++it;
            }else{
                cout<<"NO\n";
                goto outer;
            }
        }
        if(b.size() == 0) cout<<"YES\n";
        else cout<<"NO\n";

    }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

int main(){
    int tc;
    cin>>tc;
    outer:
    while(tc--){
        int n,m;
        cin>>n>>m;
        multiset<int> a,b;
        for(int i = 0;i<n;i++){
            int temp;
            cin>>temp;
            a.insert(temp);
        }
        a.insert(1e9+1);
        for(int i = 0;i<m;i++){
            int temp;
            cin>>temp;
            b.insert(temp);
        }
        for(auto it = a.begin();it!=a.end();++it){
            if(*it  == 1e9+1) break;
            auto next_it = next(it);
            auto ite = b.find(*next_it + *it);
            if(b.find(*it)!=b.end()){
                b.erase(*it);
            }else if(abs(*next_it - *it)<=1 && ite!= b.end()){
                b.erase(ite);
                ++it;
            }else if(abs(*next_it - *it)<=1){
                a.insert(*next_it + *it);
                ++it;
            }else{
                cout<<"NO\n";
                goto outer;
            }
        }
        if(b.size() == 0) cout<<"YES\n";
        else cout<<"NO\n";

    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

int main(){
    int tc;
    cin>>tc;
    outer:
    while(tc--){
        int n,m;
        cin>>n>>m;
        multiset<int> a,b;
        for(int i = 0;i<n;i++){
            int temp;
            cin>>temp;
            a.insert(temp);
        }
        a.insert(1e9+1);
        for(int i = 0;i<m;i++){
            int temp;
            cin>>temp;
            b.insert(temp);
        }

        for(auto it = a.begin();it!=a.end();++it){
            if(*it  == 1e9+1) break;
            auto next_it = next(it);
            if(b.find(*it)!=b.end()){
                b.erase(*it);
            }else if(abs(*next_it - *it)<=1 && b.find(*next_it+*it)!= b.end()){
                b.erase(*next_it+*it);
                ++it;
            }else if(abs(*next_it - *it)<=1){
                a.insert(*next_it + *it);
                ++it;
            }else{
                cout<<"NO\n";
                goto outer;
            }
        }
        if(b.size() == 0) cout<<"YES\n";
        else cout<<"NO\n";

    }
}