ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 2){
            reverse(a.begin(),a.end());
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            ans = max(ans,a.back()-a[0]);
        }
        ans = max(ans,a[0]-a[1]);
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 2){
            reverse(a.begin(),a.end());
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            ans = max(ans,a.back()-a[0]);
        }
        ans = max(ans,a[0]-a[1]);
        cout << ans << endl;
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 2){
            reverse(a.begin(),a.end());
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            ans = max(ans,a.back()-a[0]);
        }
        if(a.size() == 2) ans = max(ans,a[0]-a[1]);
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 2){
            reverse(a.begin(),a.end());
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            ans = max(ans,a.back()-a[0]);
            ans = max(ans, a[0]-a.back());
        }
        if(a.size() == 2) {
            ans = max(ans,a[0]-a[1]);
            ans = max(ans,a[1]-a[0]);
        }
        cout << ans << endl;
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 1){
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            int sum = 0;
            for(int i = 0; i < a.size(); i++) sum += a[i];
            ans = max(ans, sum);
            ans = max(ans, -sum);
        }
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<int> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        int mx = accumulate(a.begin(), a.end(), 0);
        for(int i = n;i > 1;i--) {
            int sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = a[j + 1] - a[j];
                sum += a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<int> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        int mx = accumulate(a.begin(), a.end(), 0);
        for(int i = n;i > 1;i--) {
            int sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = a[j + 1] - a[j];
                sum += a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}

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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<int> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        long long mx = accumulate(a.begin(), a.end(), 0ll);
        for(int i = n;i > 1;i--) {
            long long sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = a[j + 1] - a[j];
                sum += a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<int> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        long long mx = accumulate(a.begin(), a.end(), 0ll);
        for(int i = n;i > 1;i--) {
            long long sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = a[j + 1] - a[j];
                sum += a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}

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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<int> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        long long mx = accumulate(a.begin(), a.end(), 0ll);
        for(int i = n;i > 1;i--) {
            long long sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = (long long)a[j + 1] - a[j];
                sum += (long long)a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<int> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        long long mx = accumulate(a.begin(), a.end(), 0ll);
        for(int i = n;i > 1;i--) {
            long long sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = (long long)a[j + 1] - a[j];
                sum += (long long)a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}

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

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        vector<long long> a(n);
        for(int i = 0;i < n;i++) std::cin >> a[i];
        long long mx = accumulate(a.begin(), a.end(), 0ll);
        for(int i = n;i > 1;i--) {
            long long sum = 0;
            for(int j = 0;j < i - 1;j++) {
                a[j] = a[j + 1] - a[j];
                sum += a[j];
                mx = max({mx, -sum, sum});
            }
        }
        std::cout << mx << '\n';
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

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

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

  if (n == k) {
    cout << 1 << endl;
    return;
  }

  set<pair<int, int>> st;
  for (auto it : mp) {
    st.insert({it.second, it.first});
  }

  if (st.size() == 1) {
    cout << 1 << endl;
    return;
  }

  int cnt = 0;
  while (cnt < k) {
    auto top = st.begin();
    cnt += top->first;

    if (!st.empty())
      st.erase(top);
  }

  cout << (int)st.size() << endl;
  return;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

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

  return 0;
}


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

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

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

  set<pair<int, int>> st;
  for (auto it : mp) {
    st.insert({it.second, it.first});
  }

  if (st.size() == 1) {
    cout << 1 << endl;
    return;
  }

  int cnt = 0;
  while (cnt < k) {
    auto top = st.begin();
    cnt += top->first;

    if (!st.empty())
      st.erase(top);
  }

  int ans = (int)st.size();
  if (ans == 0)
    ans++;
  cout << ans << endl;
  return;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

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

  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

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

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

  set<pair<int, int>> st;
  for (auto it : mp) {
    st.insert({it.second, it.first});
  }

  if (st.size() == 1) {
    cout << 1 << endl;
    return;
  }

  int cnt = 0;
  while (cnt < k) {
    auto top = st.begin();
    cnt += top->first;

    if (!st.empty())
      st.erase(top);
  }

  int ans = (int)st.size();
  if (ans == 0)
    ans++;
  cout << ans << endl;
  return;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

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

  return 0;
}


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

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

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

  set<pair<int, int>> st;
  for (auto it : mp) {
    st.insert({it.second, it.first});
  }

  if (st.size() == 1) {
    cout << 1 << endl;
    return;
  }

  int cnt = 0;
  while (!st.empty()) {
    auto top = st.begin();
    if (cnt + top->first > k)
      break;
    cnt += top->first;

    st.erase(top);
  }

  int ans = (int)st.size();
  if (ans == 0)
    ans++;
  cout << ans << endl;
  return;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

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

  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


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

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

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

  if (n == k) {
    cout << 1 << endl;
    return;
  }

  set<pair<int, int>> st;
  for (auto it : mp) {
    st.insert({it.second, it.first});
  }

  if (st.size() == 1) {
    cout << 1 << endl;
    return;
  }

  int cnt = 0;
  while (cnt < k) {
    auto top = st.begin();
    cnt += top->first;

    if (!st.empty())
      st.erase(top);
  }

  cout << (int)st.size() << endl;
  return;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

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

  return 0;
}
Problem: 2050D - Digital string maximization
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        HashSet<Integer> indicies = new HashSet<>();
        char[] string;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            string = new char[c.length];
            for(int i = 0; i < c.length; i++)
            {
                int max = 0;
                int index = 0;
                int count = 0;
                for(int j = 0; j < c.length; j++)
                {
                    if(count >= 10) break;
                    if(indicies.contains(j)) continue;
                    if(Integer.parseInt(Character.toString(c[j])) - count > max)
                    {
                        index = j;
                        max = Integer.parseInt(Character.toString(c[j])) - count;
                    }
                    count++;
                }
                indicies.add(index);
                string[i] = (char)(max + 48);

            }
            pw.println(new String(string));
            indicies.clear();
        }
        pw.close();

    }
}
/*
6
19
1709
11555
51476
9876543210
5891917899

81
6710
33311
55431
9876543210
7875567711
 */






Submission (verdict: Time limit exceeded on test 5):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        HashSet<Integer> indicies = new HashSet<>();
        char[] string;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            string = new char[c.length];
            for(int i = 0; i < c.length; i++)
            {
                int max = -1;
                int index = -1;
                int count = 0;
                for(int j = 0; j < c.length; j++)
                {
                    if(count >= 10) break;
                    if(indicies.contains(j)) continue;
                    if(Integer.parseInt(Character.toString(c[j])) - count > max)
                    {
                        index = j;
                        max = Integer.parseInt(Character.toString(c[j])) - count;
                    }
                    count++;
                }
                indicies.add(index);
                string[i] = (char)(max + 48);

            }
            pw.println(new String(string));
            indicies.clear();
        }
        pw.close();

    }
}
Problem: 2050D - Digital string maximization
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        HashSet<Integer> indicies = new HashSet<>();
        char[] string;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            string = new char[c.length];
            for(int i = 0; i < c.length; i++)
            {
                int max = 0;
                int index = 0;
                int count = 0;
                for(int j = 0; j < c.length; j++)
                {
                    if(count >= 10) break;
                    if(indicies.contains(j)) continue;
                    if(Integer.parseInt(Character.toString(c[j])) - count > max)
                    {
                        index = j;
                        max = Integer.parseInt(Character.toString(c[j])) - count;
                    }
                    count++;
                }
                indicies.add(index);
                string[i] = (char)(max + 48);

            }
            pw.println(new String(string));
            indicies.clear();
        }
        pw.close();

    }
}
/*
6
19
1709
11555
51476
9876543210
5891917899

81
6710
33311
55431
9876543210
7875567711
 */
Problem: 2050D - Digital string maximization
Language: Java 21

Previous submission (verdict: Time limit exceeded on test 5):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        HashSet<Integer> indicies = new HashSet<>();
        char[] string;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            string = new char[c.length];
            for(int i = 0; i < c.length; i++)
            {
                int max = -1;
                int index = -1;
                int count = 0;
                for(int j = 0; j < c.length; j++)
                {
                    if(count >= 10) break;
                    if(indicies.contains(j)) continue;
                    if(c[j] - 48 - count > max)
                    {
                        index = j;
                        max = c[j] - 48 - count;
                    }
                    count++;
                }
                indicies.add(index);
                string[i] = (char)(max + 48);

            }
            pw.println(new String(string));
            indicies.clear();
        }
        pw.close();

    }
}







Submission (verdict: Time limit exceeded on test 6):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        char[] string;
        boolean[] used;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            string = new char[c.length];
            used = new boolean[c.length];
            for(int i = 0; i < c.length; i++)
            {
                int max = -1;
                int index = -1;
                int count = 0;
                for(int j = 0; j < c.length; j++)
                {
                    if(count >= 10) break;
                    if(used[j]) continue;
                    if(c[j] - 48 - count > max)
                    {
                        index = j;
                        max = c[j] - 48 - count;
                    }
                    count++;
                }
                used[index] = true;
                string[i] = (char)(max + 48);

            }
            pw.println(new String(string));
        }
        pw.close();

    }
}
Problem: 2050D - Digital string maximization
Language: Java 21

Previous submission (verdict: Time limit exceeded on test 6):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        char[] string;
        boolean[] used;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            string = new char[c.length];
            used = new boolean[c.length];
            for(int i = 0; i < c.length; i++)
            {
                int max = -1;
                int index = -1;
                int count = 0;
                for(int j = 0; j < c.length; j++)
                {
                    if(count >= 10) break;
                    if(used[j]) continue;
                    if(c[j] - 48 - count > max)
                    {
                        index = j;
                        max = c[j] - 48 - count;
                    }
                    count++;
                }
                used[index] = true;
                string[i] = (char)(max + 48);

            }
            pw.println(new String(string));
        }
        pw.close();

    }
}







Submission (verdict: Accepted):
import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine());
        char[] string;
        TreeSet<Integer> unused;
        ArrayList<Integer> used;
        while(t-- > 0)
        {
            char[] c = br.readLine().toCharArray();
            unused = new TreeSet<>();
            string = new char[c.length];
            for(int i = 0; i < c.length; i++)
            {
                unused.add(i);
            }
            for(int i = 0; i < c.length; i++)
            {
                int max = -1;
                int index = -1;
                int size = unused.size();
                used = new ArrayList<>();
                for(int j = 0; j < Math.min(size, 10); j++)
                {
                    int a = unused.pollFirst();
                    if(c[a] - 48 - j > max)
                    {
                        index = a;
                        max = c[a] - 48 - j;
                    }
                    used.add(a);
                }
                unused.addAll(used);
                unused.remove(index);
                string[i] = (char)(max + 48);
            }
            pw.println(new String(string));
        }
        pw.close();

    }
}