ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
            }
        }
        for (int j = n; j > a[i]; j--)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        for (int j = 1; j < a[i]; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::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;
#define ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
            }
        }
        for (int j = n; j > a[i]; j--)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        for (int j = a[i] - 1; j >= 1; j--)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
            }
        }
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        for (int j = 1; j < a[i]; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
const ll N = 1e5 + 1, M = 1e9 + 7;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    set<int> st;
    for (int i = 0; i < n; i++)
    cin >> a[i], st.insert(i + 1);
    vector<pair<int, int>> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = a[i] + 1; j <= n; j++)
        {
            if (st.count(j))
            {
                ans.push_back({j, a[i]});
            }
        }
        for (int j = n; j > a[i]; j--)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        for (int j = 1; j < a[i]; j++)
        {
            if (st.count(j))
            {
                ans.push_back({a[i], j});
            }
        }
        st.erase(a[i]);
    }
    cout << (int)ans.size() << "\n";
    for (auto &x : ans)
    cout << x.first << " " << x.second << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 7):
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j, r##i=k; i<=r##i; ++i)
#define ROF(i,j,k) for(int i=j, l##i=k; i>=l##i; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
const int maxn = 200005;
int tot_edge, head[maxn], to[maxn], link[maxn];
inline void add_edge (int x, int y) {
  to[++tot_edge] = y;
  link[tot_edge] = head[x];
  head[x] = tot_edge;
}
using pii = std::pair <int, int>;
int d[maxn];
pii p[maxn];
bool flag[maxn];
int main (void) {
  int t = read();
  while(t--) {
    int n = read();
    FOR(i,2,n) {
      int x = read(), y = read();
      add_edge (x, y);
      add_edge (y, x);
      ++ d[x], ++ d[y];
    }
    FOR(i,1,n) p[i] = pii (d[i], i);
    std::sort(p+1, p+n+1, std::greater<pii>());
    int c = -1 << 20, c2 = -1 << 20, uc = -1 << 20;
    for(int now=head[p[1].second]; now; now=link[now])
      flag[to[now]] = 1;
    FOR(i,2,n)
      if(flag[p[i].second])  {
        if(c == -1 << 20) c = p[i].first;
        else if(c2 == -1 << 20) c2 = p[i].first;
      } else
        if(uc == -1 << 20) uc = p[i].first;
    printf("%d\n", std::max (c + c2 - 1, std::max (p[1].first + c - 2, p[1].first + uc - 1)));
    FOR(i,1,n) d[i] = flag[i] = head[i] = 0;
    tot_edge = 0;
  }
  return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j, r##i=k; i<=r##i; ++i)
#define ROF(i,j,k) for(int i=j, l##i=k; i>=l##i; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
const int maxn = 200005;
int tot_edge, head[maxn], to[maxn<<1], link[maxn<<1];
inline void add_edge (int x, int y) {
  to[++tot_edge] = y;
  link[tot_edge] = head[x];
  head[x] = tot_edge;
}
using pii = std::pair <int, int>;
int d[maxn];
pii p[maxn];
bool flag[maxn];
int main (void) {
  int t = read();
  while(t--) {
    int n = read();
    FOR(i,2,n) {
      int x = read(), y = read();
      add_edge (x, y);
      add_edge (y, x);
      ++ d[x], ++ d[y];
    }
    FOR(i,1,n) p[i] = pii (d[i], i);
    std::sort(p+1, p+n+1, std::greater<pii>());
    int c = -1 << 20, c2 = -1 << 20, uc = -1 << 20;
    for(int now=head[p[1].second]; now; now=link[now])
      flag[to[now]] = 1;
    FOR(i,2,n)
      if(flag[p[i].second])  {
        if(c == -1 << 20) c = p[i].first;
        else if(c2 == -1 << 20) c2 = p[i].first;
      } else
        if(uc == -1 << 20) uc = p[i].first;
    printf("%d\n", std::max (c + c2 - 1, std::max (p[1].first + c - 2, p[1].first + uc - 1)));
    FOR(i,1,n) d[i] = flag[i] = head[i] = 0;
    tot_edge = 0;
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j, r##i=k; i<=r##i; ++i)
#define ROF(i,j,k) for(int i=j, l##i=k; i>=l##i; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
const int maxn = 200005;
int tot_edge, head[maxn], to[maxn], link[maxn];
inline void add_edge (int x, int y) {
  to[++tot_edge] = y;
  link[tot_edge] = head[x];
  head[x] = tot_edge;
}
using pii = std::pair <int, int>;
int d[maxn];
pii p[maxn];
bool flag[maxn];
int main (void) {
  int t = read();
  while(t--) {
    int n = read();
    FOR(i,2,n) {
      int x = read(), y = read();
      add_edge (x, y);
      add_edge (y, x);
      ++ d[x], ++ d[y];
    }
    FOR(i,1,n) p[i] = pii (d[i], i);
    std::sort(p+1, p+n+1, std::greater<pii>());
    int c = -1 << 20, c2 = -1 << 20, uc = -1 << 20;
    for(int now=head[p[1].second]; now; now=link[now])
      flag[to[now]] = 1;
    FOR(i,2,n)
      if(flag[p[i].second])  {
        if(c == -1 << 20) c = p[i].first;
        else if(c2 == -1 << 20) c2 = p[i].first;
      } else
        if(uc == -1 << 20) uc = p[i].first;
    printf("%d\n", std::max (c + c2 - 1, std::max (p[1].first + c - 2, p[1].first + uc - 1)));
    FOR(i,1,n) d[i] = flag[i] = 0;
  }
  return 0;
}


Submission (verdict: Runtime error on test 7):
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j, r##i=k; i<=r##i; ++i)
#define ROF(i,j,k) for(int i=j, l##i=k; i>=l##i; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
const int maxn = 200005;
int tot_edge, head[maxn], to[maxn], link[maxn];
inline void add_edge (int x, int y) {
  to[++tot_edge] = y;
  link[tot_edge] = head[x];
  head[x] = tot_edge;
}
using pii = std::pair <int, int>;
int d[maxn];
pii p[maxn];
bool flag[maxn];
int main (void) {
  int t = read();
  while(t--) {
    int n = read();
    FOR(i,2,n) {
      int x = read(), y = read();
      add_edge (x, y);
      add_edge (y, x);
      ++ d[x], ++ d[y];
    }
    FOR(i,1,n) p[i] = pii (d[i], i);
    std::sort(p+1, p+n+1, std::greater<pii>());
    int c = -1 << 20, c2 = -1 << 20, uc = -1 << 20;
    for(int now=head[p[1].second]; now; now=link[now])
      flag[to[now]] = 1;
    FOR(i,2,n)
      if(flag[p[i].second])  {
        if(c == -1 << 20) c = p[i].first;
        else if(c2 == -1 << 20) c2 = p[i].first;
      } else
        if(uc == -1 << 20) uc = p[i].first;
    printf("%d\n", std::max (c + c2 - 1, std::max (p[1].first + c - 2, p[1].first + uc - 1)));
    FOR(i,1,n) d[i] = flag[i] = head[i] = 0;
    tot_edge = 0;
  }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j, r##i=k; i<=r##i; ++i)
#define ROF(i,j,k) for(int i=j, l##i=k; i>=l##i; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
const int maxn = 200005;
int tot_edge, head[maxn], to[maxn], link[maxn];
inline void add_edge (int x, int y) {
  to[++tot_edge] = y;
  link[tot_edge] = head[x];
  head[x] = tot_edge;
}
using pii = std::pair <int, int>;
int d[maxn];
pii p[maxn];
bool flag[maxn];
int main (void) {
  int t = read();
  while(t--) {
    int n = read();
    FOR(i,2,n) {
      int x = read(), y = read();
      add_edge (x, y);
      add_edge (y, x);
      ++ d[x], ++ d[y];
    }
    FOR(i,1,n) p[i] = pii (d[i], i);
    std::sort(p+1, p+n+1, std::greater<pii>());
    int c = -1 << 20, c2 = -1 << 20, uc = -1 << 20;
    for(int now=head[p[1].second]; now; now=link[now])
      flag[to[now]] = 1;
    FOR(i,2,n)
      if(flag[p[i].second])  {
        if(c == -1 << 20) c = p[i].first;
        else if(c2 == -1 << 20) c2 = p[i].first;
      } else
        if(uc == -1 << 20) uc = p[i].first;
    printf("%d\n", std::max (c + c2 - 1, std::max (p[1].first + c - 2, p[1].first + uc - 1)));
    FOR(i,1,n) d[i] = flag[i] = 0;
  }
  return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
  int n; cin >> n;
  vector<ll>v(n);
  for(auto&i :v) cin >> i;
  if(n == 1){
      cout << v[0];
      return;
  }
  ll sm = accumulate(v.begin(),v.end(),0ll);
    for (int i = 0; i < n - 1; ++i) {
        for (int j = 0; j < n - 1; ++j) {
            v[j] = v[j+1] - v[j];
        }
    }
//    for(int i:v)cout << i << ' ';
    cout << max(sm , abs(v[0]));
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}

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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &i: v) cin >> i;
    if (n == 1) {
        cout << v[0];
        return;
    }
    ll ans = accumulate(v.begin(), v.end(), 0ll);
    while (v.size() > 1) {
        for (int i = 0; i < (int) v.size() - 1; ++i) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    ans = max(ans, abs(accumulate(v.begin(), v.end(), 0ll)));
    cout << ans;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
  int n; cin >> n;
  vector<ll>v(n);
  for(auto&i :v) cin >> i;
  if(n == 1){
      cout << v[0];
      return;
  }
  ll sm = accumulate(v.begin(),v.end(),0ll);
    for (int i = 0; i < n - 1; ++i) {
        for (int j = 0; j < n - 1; ++j) {
            v[j] = v[j+1] - v[j];
        }
    }
//    for(int i:v)cout << i << ' ';
    cout << max(sm , abs(v[0]));
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &i: v) cin >> i;
    if (n == 1) {
        cout << v[0];
        return;
    }
    ll ans = accumulate(v.begin(), v.end(), 0ll);
    while (v.size() > 1) {
        for (int i = 0; i < (int) v.size() - 1; ++i) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
    }
    ans = max(ans, abs(accumulate(v.begin(), v.end(), 0ll)));
    cout << ans;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}

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

using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

void solve(int T) {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &i: v) cin >> i;
    if (n == 1) {
        cout << v[0];
        return;
    }
    ll ans = accumulate(v.begin(), v.end(), 0ll);
    while (v.size() > 1) {
        for (int i = 0; i < (int) v.size() - 1; ++i) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
        ans = max(ans, abs(accumulate(v.begin(), v.end(), 0ll)));
//        cout << abs(accumulate(v.begin(), v.end(), 0ll)) << '\n';
    }
    cout << ans;

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve(i);
        cout << '\n';
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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


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

    int _ = 1;
    cin >> _;

    while(_--)
    {
        ll n;
        cin >> n;

        vector<ll> a(n);
        ll sum = 0;

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

        for(int i = 0; i < n; i++)
        {
            ll sum1 = 0;
            vector<ll> v;

            for(int j = 1; j < n - i; j++)
            {
                sum1 += (a[j] - a[j - 1]);
                v.push_back(a[j] - a[j - 1]);
            }

            sum = max(sum, sum1);
            a = v;
        }

        cout << sum << endl;

    }
}


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


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

    int _ = 1;
    cin >> _;

    while(_--)
    {
        ll n;
        cin >> n;

        vector<ll> a(n);
        ll sum = 0;

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

        for(int i = 0; i < n - 1; i++)
        {
            ll sum1 = 0;
            vector<ll> v;

            for(int j = 1; j < n - i; j++)
            {
                sum1 += (a[j] - a[j - 1]);
                v.push_back(a[j] - a[j - 1]);
            }

            sum = max(sum, sum1);
            a = v;
        }

        cout << sum << endl;

    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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


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

    int _ = 1;
    cin >> _;

    while(_--)
    {
        ll n;
        cin >> n;

        vector<ll> a(n);
        ll sum = 0;

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

        for(int i = 0; i < n - 1; i++)
        {
            ll sum1 = 0;
            vector<ll> v;

            for(int j = 1; j < n - i; j++)
            {
                sum1 += (a[j] - a[j - 1]);
                v.push_back(a[j] - a[j - 1]);
            }

            sum = max(sum, sum1);
            a = v;
        }

        cout << sum << endl;

    }
}


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


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

    int _ = 1;
    cin >> _;

    while(_--)
    {
        ll n;
        cin >> n;

        vector<ll> a(n);
        ll sum = 0;

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

        ll val = accumulate(a.begin(), a.end(), (ll)0);
        for(int i = 0; i < n - 1; i++)
        {
            ll sum1 = 0;
            vector<ll> v;

            for(int j = 1; j < n - i; j++)
            {
                sum1 += (a[j] - a[j - 1]);
                v.push_back(a[j] - a[j - 1]);
            }

            sum = max(sum, abs(sum1));
            a = v;
        }

        //cout << val << endl;
        cout << sum << endl;

    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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


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

    int _ = 1;
    cin >> _;

    while(_--)
    {
        ll n;
        cin >> n;

        vector<ll> a(n);
        ll sum = 0;

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

        for(int i = 0; i < n; i++)
        {
            ll sum1 = 0;
            vector<ll> v;

            for(int j = 1; j < n - i; j++)
            {
                sum1 += (a[j] - a[j - 1]);
                v.push_back(a[j] - a[j - 1]);
            }

            sum = max(sum, sum1);
            a = v;
        }

        cout << sum << endl;

    }
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 1):
// /**
// *    author:  _isomorphism
// *    created: 19.12.2024 14:08:48
// **/
// 
// Problem: F. Maximum modulo equality
// Contest: Codeforces - Codeforces Round 991 (Div. 3)


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)2e18
#define endl '\n'

const int mod = 1e9 + 7;
const int MOD = 998244353;

vector<int> binrep(int n) {
  if (n == 0)
    return {0};
  vector<int> b;
  while (n > 0) {
    b.insert(b.begin(), n % 2);
    n /= 2;
  }
  return b;
}

int binpow(int base, int exp, int m) {
  int result = 1;
  base = base % m;
  while (exp > 0) {
    if (exp % 2 == 1) {
      result = (result * base) % m;
    }
    base = (base * base) % m;
    exp = exp / 2;
  }
  return result;
}


//bool check(int x){
//
//}
//
//int search(int k) {
//  int pos = 0, max = INF;
//  for (int i = max; i >= 1; i /= 2) {
//    while (check(pos + i)) pos += i;
//  }
//  return pos;
//}
//
//int search(int k) {
//    int low = 0, high = INF, ans = -1;
//    while (low <= high) {
//        int mid = low + (high - low) / 2;
//        if (check(mid)) {
//            ans = mid;
//            high = mid - 1;
//        } else {
//            low = mid + 1;
//        }
//    }
//    return ans;
//}

class SegmentTree {
private:
    vector<int> tree;
    int n;

    void build(const vector<int>& arr, int node, int start, int end) {
        if (start == end) {
            tree[node] = arr[start];
        } else {
            int mid = (start + end) / 2;
            build(arr, 2 * node + 1, start, mid);
            build(arr, 2 * node + 2, mid + 1, end);
            tree[node] = __gcd(tree[2 * node + 1], tree[2 * node + 2]);
        }
    }

    int query(int node, int start, int end, int l, int r) {
        if (r < start || end < l) {
            return 0;
        }
        if (l <= start && end <= r) {
            return tree[node];
        }
        int mid = (start + end) / 2;
        int left_sum = query(2 * node + 1, start, mid, l, r);
        int right_sum = query(2 * node + 2, mid + 1, end, l, r);
        return __gcd(left_sum, right_sum);
    }

public:
    SegmentTree(const vector<int>& arr) {
        n = arr.size();
        tree.resize(4 * n);
        build(arr, 0, 0, n - 1);
    }

    int query(int l, int r) {
        return query(0, 0, n - 1, l, r);
    }
};

void solve() {
	int n, q; cin >> n >> q;
	vector<int> a(n), dif(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n - 1; i++){
		dif[i] = abs(a[i] - a[i + 1]);
	}
	// for(int i = 0; i < dif.size(); i++) cout << dif[i] << ' ';
	// cout << endl;
	SegmentTree segTree(dif);
	while(q--){
		int l, r; cin >> l >> r;
		l--; r--; r--;
		cout << segTree.query(l, r) << ' ';
	}
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int test = 1;
  cin >> test;

  while (test--) {
    solve();
    cout << '\n';
  }
  return 0;
}