ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int sum = v[n - 1];
    bool ok = true;
    for (int i = n - 2; i >= 0; --i) {
        if (v[i] > sum) {
            ok = false;
            break;
        }
        sum += v[i];
    }
    if (ok) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<long long> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    long long sum = v[n - 1];
    bool ok = true;
    for (int i = n - 2; i >= 0; --i) {
        if (v[i] > sum) {
            ok = false;
            break;
        }
        sum += v[i];
    }
    if (ok) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

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

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    bool ok = true;
    for (int i = 1; i < n; ++i) {
        int mi = min(v[i - 1], v[i]);
        v[i - 1] -= mi;
        v[i] -= mi;
        if (v[i - 1] > v[i]) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    for(int i = 0; i < n - 1; i += 2)
    {
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    if(n % 2 == 1)
        --n;
        
    for(int i = 0; i < n; i += 2)
    {
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    if(n % 2 == 1)
        --n;
        
    for(int i = 0; i < n; i += 2)
    {
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    if(n % 2 == 1)
        --n;
        
    for(int i = 0; i < n; i += 2)
    {
        int d = std::min(a[i], a[i + 1]);
        a[i] -= d;
        a[i + 1] -= d;
        
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    for(int i = 0; i < n - 1; i += 2)
    {
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    if(n % 2 == 1)
        --n;
        
    for(int i = 0; i < n; i += 2)
    {
        int d = std::min(a[i], a[i + 1]);
        a[i] -= d;
        a[i + 1] -= d;
        
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

void solve()
{
    int n;
    std::cin >> n;
    
    std::vector<int> a(n);
    for(int& _ : a)
        std::cin >> _;
        
    for(int i = 0; i < n - 1; ++i)
    {
        int d = std::min(a[i], a[i + 1]);
        a[i] -= d;
        a[i + 1] -= d;
        
        if(a[i] > a[i + 1])
        {
            std::cout << "NO\n";
            return;
        }
    }
    
    std::cout << "YES\n";
}

int main()
{
    int t;
    std::cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.Scanner;

public class Main
{
    private static void solve(Scanner in)
    {
        int n = in.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        long ans = 0;

        for (int el : a)
            ans += el;

        for (int it = 1; it < n; it++)
        {
            ans = Math.max(ans, Math.abs(a[n - it] - a[0]));

            for (int i = 0; i + it < n; i++)
                a[i] = a[i + 1] - a[i];
        }

        System.out.println(ans);
    }

    public static void main (String[] args)
    {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt();

        for (int test = 0; test < t; test++)
            solve(in);
        
        in.close();
    }
}

Submission (verdict: Accepted):
import java.util.Scanner;

public class Main
{
    private static void solve(Scanner in)
    {
        int n = in.nextInt();

        long[] a = new long[n];

        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        long ans = 0;

        for (long el : a)
            ans += el;

        for (int it = 1; it < n; it++)
        {
            ans = Math.max(ans, Math.abs(a[n - it] - a[0]));

            for (int i = 0; i + it < n; i++)
                a[i] = a[i + 1] - a[i];
        }

        System.out.println(ans);
    }

    public static void main (String[] args)
    {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt();

        for (int test = 0; test < t; test++)
            solve(in);
        
        in.close();
    }
}
Problem: 2062C - Cirno and Operations
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.Scanner;

public class Main
{
    private static void solve(Scanner in)
    {
        int n = in.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        int ans = 0;

        for (int el : a)
            ans += el;

        for (int it = 1; it < n; it++)
        {
            ans = Math.max(ans, Math.abs(a[n - it] - a[0]));

            for (int i = 0; i + it < n; i++)
                a[i] = a[i + 1] - a[i];
        }

        System.out.println(ans);
    }

    public static void main (String[] args)
    {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt();

        for (int test = 0; test < t; test++)
            solve(in);
        
        in.close();
    }
}

Submission (verdict: Wrong answer on test 2):
import java.util.Scanner;

public class Main
{
    private static void solve(Scanner in)
    {
        int n = in.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        long ans = 0;

        for (int el : a)
            ans += el;

        for (int it = 1; it < n; it++)
        {
            ans = Math.max(ans, Math.abs(a[n - it] - a[0]));

            for (int i = 0; i + it < n; i++)
                a[i] = a[i + 1] - a[i];
        }

        System.out.println(ans);
    }

    public static void main (String[] args)
    {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt();

        for (int test = 0; test < t; test++)
            solve(in);
        
        in.close();
    }
}
Problem: 2062C - Cirno and Operations
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.util.Scanner;

public class Main
{
    private static void solve(Scanner in)
    {
        int n = in.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();

        int ans = 0;

        for (int el : a)
            ans += el;

        for (int it = 1; it < n; it++)
        {
            ans = Math.max(ans, Math.abs(a[n - it] - a[0]));

            for (int i = 0; i + it < n; i++)
                a[i] = a[i + 1] - a[i];
        }

        System.out.println(ans);
    }

    public static void main (String[] args)
    {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt();

        for (int test = 0; test < t; test++)
            solve(in);
        
        in.close();
    }
}
Problem: 2063C - Remove Exactly Two
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.util.*;

public class Main
{
    private static void dfs_dp (int v, int p, final ArrayList<Integer>[] tree, int[] dp)
    {
        for (int to : tree[v])
        if (to != p)
        {
            dfs_dp(to, v, tree, dp);

            dp[v] = Math.max(dp[v], Math.max(dp[to], tree[to].size()));
        }
    }

    private static int dfs_ans (int v, int p, final ArrayList<Integer>[] tree, final int[] dp)
    {
        int ans = 0;
        int cur = 0;

        for (int to : tree[v])
        if (to != p)
            ans = Math.max(ans, dfs_ans(to, v, tree, dp));

        for (int to : tree[v])
        if (to != p)
            cur = Math.max(cur, tree[v].size() - 1 + Math.max(tree[to].size() - 1, dp[to]));

        return Math.max(ans, cur);
    }
    
    private static void solve (Scanner in)
    {
        int n = in.nextInt();

        ArrayList<Integer>[] tree = new ArrayList[n];

        for (int i = 0; i < n; i++)
            tree[i] = new ArrayList<Integer>();

        for (int i = 1; i < n; i++)
        {
            int u = in.nextInt() - 1;
            int v = in.nextInt() - 1;

            tree[u].add(v);
            tree[v].add(u);
        }

        int[] dp = new int[n];

        dfs_dp(0, -1, tree, dp);
        
        System.out.println(dfs_ans(0, -1, tree, dp));
    }

    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);

        int t = in.nextInt();

        for (int test = 0; test < t; test++)
            solve(in);

        in.close();
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
 
void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, INT_MAX));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            f[i][j] = min(f[i - 1][j] + a[i - 1] != c[i + j - 1], f[i][j - 1] + b[j - 1] != c[i + j - 1]);
        }
    }
    cout << dp[n][m] << "\n";
}
 
int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
 
void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> f(n + 1, vector<int>(m + 1, INT_MAX));
    f[0][0] = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            f[i][j] = min(f[i - 1][j] + a[i - 1] != c[i + j - 1], f[i][j - 1] + b[j - 1] != c[i + j - 1]);
        }
    }
    cout << f[n][m] << "\n";
}
 
int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
 
void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> f(n + 1, vector<int>(m + 1, INT_MAX));
    f[0][0] = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            f[i][j] = min(f[i - 1][j] + (a[i - 1] != c[i + j - 1]), f[i][j - 1] + (b[j - 1] != c[i + j - 1]));
        }
    }
    cout << f[n][m] << "\n";
}
 
int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
 
void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, INT_MAX));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            f[i][j] = min(f[i - 1][j] + a[i - 1] != c[i + j - 1], f[i][j - 1] + b[j - 1] != c[i + j - 1]);
        }
    }
    cout << dp[n][m] << "\n";
}
 
int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
 
void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> f(n + 1, vector<int>(m + 1, INT_MAX));
    f[0][0] = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            f[i][j] = min(f[i - 1][j] + a[i - 1] != c[i + j - 1], f[i][j - 1] + b[j - 1] != c[i + j - 1]);
        }
    }
    cout << f[n][m] << "\n";
}
 
int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
 
void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> f(n + 1, vector<int>(m + 1, INT_MAX));
    f[0][0] = 0;
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            f[i][j] = min(f[i - 1][j] + (a[i - 1] != c[i + j - 1]), f[i][j - 1] + (b[j - 1] != c[i + j - 1]));
        }
    }
    cout << f[n][m] << "\n";
}
 
int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}

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

void f() {
    string a, b, c;
    cin >> a >> b >> c;
    int n = a.size();
    int m = b.size();
    vector<vector<int>> f(n + 1, vector<int>(m + 1, INT_MAX));
    f[0][0] = 0;

    for (int i = 1; i <= n; i ++) {
        f[i][0] = f[i - 1][0] + (a[i - 1] != c[i - 1]);
    }

    for (int j = 1; j <= m; j ++) {
        f[0][j] = f[0][j - 1] + (b[j - 1] != c[j - 1]);
    }

    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= m; j ++) {
            f[i][j] = min(f[i - 1][j] + (a[i - 1] != c[i + j - 1]), f[i][j - 1] + (b[j - 1] != c[i + j - 1]));
        }
    }
    cout << f[n][m] << "\n";
}

int main() {
    int t;
    cin >> t;
    while (t --) f();
    return 0;
}
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;

#define ll long long int
#define F(i, a, b) for (long long i = a; i < b; i++)
#define RF(i, a, b) for (long long int i = a - 1; i >= b; i--)
#define FF(a) for (auto it : a)
#define pb push_back
#define ff first
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ss second
#define new cout << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll inf = 1e18 + 5;
ll modd = 998244353;
ll mod = 1000000007;

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

    vector<ll>v(n);
    F(i,0,n) cin>>v[i];

    vector<ll>temp;
    ll ans=0;
    if(v.size()==1) {
        cout<<v[0]<<endl;
        return;
    }
    F(i,0,n){
        ans+=v[i];
    }
    while(v.size()>1){
        ll sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));

        F(i,1,v.size()){ temp.pb(v[i]-v[i-1]); }
        v=temp;
         sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));
        temp.clear();
    }
    cout<<ans<<endl;
   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test;
    cin >> test;
    F(i, 0, test)
    {
        solve();
    }
    return 0;
}
     

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

#define ll long long int
#define F(i, a, b) for (long long i = a; i < b; i++)
#define RF(i, a, b) for (long long int i = a - 1; i >= b; i--)
#define FF(a) for (auto it : a)
#define pb push_back
#define ff first
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ss second
#define new cout << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll inf = 1e18 + 5;
ll modd = 998244353;
ll mod = 1000000007;

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

    vector<ll>v(n);
    F(i,0,n) cin>>v[i];

    vector<ll>temp;
    ll ans=0;
    if(v.size()==1) {
        cout<<v[0]<<endl;
        return;
    }
    F(i,0,n){
        ans+=v[i];
    }
    while(v.size()>1){
        ll sum=0;
        

        F(i,1,v.size()){ temp.pb(v[i]-v[i-1]); }
        v=temp;
         sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));
        temp.clear();
    }
    cout<<ans<<endl;
   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test;
    cin >> test;
    F(i, 0, test)
    {
        solve();
    }
    return 0;
}
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;

#define ll long long int
#define F(i, a, b) for (long long i = a; i < b; i++)
#define RF(i, a, b) for (long long int i = a - 1; i >= b; i--)
#define FF(a) for (auto it : a)
#define pb push_back
#define ff first
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ss second
#define new cout << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll inf = 1e18 + 5;
ll modd = 998244353;
ll mod = 1000000007;

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

    vector<ll>v(n);
    F(i,0,n) cin>>v[i];

    vector<ll>temp;
    ll ans=0;
    if(v.size()==1) {
        cout<<v[0]<<endl;
        return;
    }
    while(v.size()>1){
        ll sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));

        F(i,1,v.size()){ temp.pb(v[i]-v[i-1]); }
        v=temp;
         sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));
        temp.clear();
    }
    cout<<ans<<endl;
   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test;
    cin >> test;
    F(i, 0, test)
    {
        solve();
    }
    return 0;
}
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;

#define ll long long int
#define F(i, a, b) for (long long i = a; i < b; i++)
#define RF(i, a, b) for (long long int i = a - 1; i >= b; i--)
#define FF(a) for (auto it : a)
#define pb push_back
#define ff first
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ss second
#define new cout << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll inf = 1e18 + 5;
ll modd = 998244353;
ll mod = 1000000007;

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

    vector<ll>v(n);
    F(i,0,n) cin>>v[i];

    vector<ll>temp;
    ll ans=0;
    if(v.size()==1) {
        cout<<v[0]<<endl;
        return;
    }
    while(v.size()>1){
        ll sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));

        F(i,1,v.size()){ temp.pb(v[i]-v[i-1]); }
        v=temp;
         sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));
        temp.clear();
    }
    cout<<ans<<endl;
   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test;
    cin >> test;
    F(i, 0, test)
    {
        solve();
    }
    return 0;
}


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

#define ll long long int
#define F(i, a, b) for (long long i = a; i < b; i++)
#define RF(i, a, b) for (long long int i = a - 1; i >= b; i--)
#define FF(a) for (auto it : a)
#define pb push_back
#define ff first
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ss second
#define new cout << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll inf = 1e18 + 5;
ll modd = 998244353;
ll mod = 1000000007;

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

    vector<ll>v(n);
    F(i,0,n) cin>>v[i];

    vector<ll>temp;
    ll ans=0;
    if(v.size()==1) {
        cout<<v[0]<<endl;
        return;
    }
    F(i,0,n){
        ans+=v[i];
    }
    while(v.size()>1){
        ll sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));

        F(i,1,v.size()){ temp.pb(v[i]-v[i-1]); }
        v=temp;
         sum=0;
        F(i,0,v.size()) sum+=v[i];
        ans=max(ans,abs(sum));
        temp.clear();
    }
    cout<<ans<<endl;
   
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test;
    cin >> test;
    F(i, 0, test)
    {
        solve();
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

using namespace std;
typedef long long ll;
unordered_map<int,int>umap;

bool dfs(int val) {
    if (umap.find(val) != umap.end()) {
        if (umap[val] > 0) {
            umap[val]-=1;
            return true;
        }
    }
    if (val==1) {
        return false;
    }
    if (val%2==0) {
        return dfs(val/2) && dfs(val/2);
    } else {
        return dfs(val/2) && dfs((val/2)+1);
    }
}

void solve() {
    umap.clear();
    int n; int m; ll suma = 0; ll sumb = 0;
    cin >> n >> m;
    int a[n];
    
    for (int i=0; i < n; i++) {
        cin >> a[i];
        suma += a[i];
    }
    
    int b[m];
    for (int i=0; i < m; i++) {
        cin >> b[i];
        sumb += b[i];
    }

    if (suma != sumb) {
        cout << "No\n";
        return;
    }
    for (int i = 0; i < n; i++) {
        umap[a[i]]+=1;
    }

    for (int i = 0; i < m; i++) {
        if (!dfs(b[i])) {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";

    umap.clear();
} 

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

}