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

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

        for(int i = 0; i < n; i++){
                mp[v[i]] = i;
        }

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[i]] > mp[a[i + 1]]){
                                ans.push_back({a[i + 1], a[i]});
                                swap(a[i], a[i + 1]);
                        }
                }
        }

        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}



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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

        for(int i = 0; i < n; i++){
                mp[v[i]] = i;
        }

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[i]] > mp[a[i + 1]]){
                                ans.push_back({a[i + 1], a[i]});
                                swap(a[i], a[i + 1]);
                        }
                }
        }

        cout << ans.size() << endl;
        
        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

        for(int i = 0; i < n; i++){
                mp[v[i]] = i;
        }

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[i]] > mp[a[i + 1]]){
                                ans.push_back({a[i + 1], a[i]});
                                swap(a[i], a[i + 1]);
                        }
                }
        }

        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
#define int long long
using namespace std;

const int INF = 1e9;

int dp[101][101][201];

int help(const string &a, const string &b, const string &res, int i, int j, int k) {
    if (k == res.size()) return 0; 
    // if (dp[i][j][k] != -1) return dp[i][j][k]; 

    int ans = INF;


    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j, k + 1) + (a[i] != res[k]));
    }


    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1, k + 1) + (b[j] != res[k]));
    }

    return ans; 
}

void ms() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        ms();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
#define int long long
using namespace std;

const int INF = 1e9;

int dp[101][101][201];

int help(const string &a, const string &b, const string &res, int i, int j, int k) {
    if (k == res.size()) return 0; 
    // if (dp[i][j][k] != -1) return dp[i][j][k]; 

    int ans = INF;


    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j, k + 1) + (a[i] != res[k]));
    }


    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1, k + 1) + (b[j] != res[k]));
    }

    return ans; 
}

void ms() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        ms();
    }
    return 0;
}


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
#define int long long
using namespace std;

const int INF = 1e9;


int dp[1001][1001][2001];

int help(const string &a, const string &b, const string &res, int i, int j, int k) {
    if (k == res.size()) return 0; 
    if (dp[i][j][k] != -1) return dp[i][j][k]; 

    int ans = INF;


    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j, k + 1) + (a[i] != res[k]));
    }


    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1, k + 1) + (b[j] != res[k]));
    }

    return dp[i][j][k] = ans; 
}

void ms() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        ms();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
#define int long long
using namespace std;

const int INF = 1e9;


int dp[1001][1001][2001];

int help(const string &a, const string &b, const string &res, int i, int j, int k) {
    if (k == res.size()) return 0; 
    if (dp[i][j][k] != -1) return dp[i][j][k]; 

    int ans = INF;


    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j, k + 1) + (a[i] != res[k]));
    }


    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1, k + 1) + (b[j] != res[k]));
    }

    return dp[i][j][k] = ans; 
}

void ms() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        ms();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 13):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
// #define int long long
using namespace std;

const int INF = 1e9;


int dp[101][101][201];

int help(const string &a, const string &b, const string &res, int i, int j, int k) {
    if (k == res.size()) return 0; 
    if (dp[i][j][k] != -1) return dp[i][j][k]; 

    int ans = INF;


    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j, k + 1) + (a[i] != res[k]));
    }


    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1, k + 1) + (b[j] != res[k]));
    }

    return dp[i][j][k] = ans; 
}

void ms() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        ms();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 13):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
// #define int long long
using namespace std;

const int INF = 1e9;


int dp[101][101][201];

int help(const string &a, const string &b, const string &res, int i, int j, int k) {
    if (k == res.size()) return 0; 
    if (dp[i][j][k] != -1) return dp[i][j][k]; 

    int ans = INF;


    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j, k + 1) + (a[i] != res[k]));
    }


    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1, k + 1) + (b[j] != res[k]));
    }

    return dp[i][j][k] = ans; 
}

void ms() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        ms();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define fabulo ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(ans) cout << ans << '\n';
using namespace std;

const int INF = 1e9;

int dp[1001][1001];

int help(const string &a, const string &b, const string &res, int i, int j) {
    if (i == a.size() && j == b.size()) return 0; // Base case: Both strings exhausted
    if (dp[i][j] != -1) return dp[i][j];

    int k = i + j; 
    int ans = INF;

    if (i < a.size()) {
        ans = min(ans, help(a, b, res, i + 1, j) + (a[i] != res[k]));
    }

    if (j < b.size()) {
        ans = min(ans, help(a, b, res, i, j + 1) + (b[j] != res[k]));
    }

    return dp[i][j] = ans;
}

void solve() {
    string a, b, res;
    cin >> a >> b >> res;

    memset(dp, -1, sizeof(dp));

    int result = help(a, b, res, 0, 0);
    print(result);
}

int32_t main() {
    fabulo
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fo(i,l,r) for(int i = l; i < r; i++)
#define foll(i,l,r) for(ll i = l; i < r; i++)
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// index function to get the index of a number in an array
int index(int arr[], int n, int x) {
    fo(i,0,n) {
        if (arr[i] == x) {
            return i;
        }
    }
    return -1;
}

int main() {
    int n;
    cin >> n;
    int c[n];
    fo(i,0,n) cin >> c[i];
    
    unordered_map<int, int> ins;
    fo(i,1,n+1) ins[i] = index(c,n,i);

    vector<string> couts1, couts2; 
    if (n == 1) cout << 0;
    else {
        int ans = 0;
        fo(j,1,n+1) {
            fo(i,j+1,n+1) {
                couts1.push_back(to_string(i) + " " + to_string(j) + "\n");
                ans += 1;
                if (ins[i] > ins[j]) {
                    couts2.push_back(to_string(j) + " " + to_string(i) + "\n");
                    ans += 1;
                }
            }
        }
        cout << ans << endl;
        for (string s : couts1) cout << s;
        for (string s : couts2) cout << s;
    }
}
Problem: 2050D - Digital string maximization
Language: Java 21


Submission (verdict: Time limit exceeded on test 7):
import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.util.ArrayList;

import java.util.StringTokenizer;



public class round991 {

static class Pair implements Comparable<Pair>{

int a;

long b;

String str;



Pair(int a,long b,String str){

this.a=a;

this.b=b;

this.str=str;

}



public int compareTo(Pair o) {

return Integer.compare(this.a, o.a); // Ascending order by a

}

//

//            public int compareTo(Pair o){

//                return Long.compare(this.b,o.b);

//            }

//

//            public int compareTo(Pair other) {

//                return this.str.compareTo(other.str); // Ascending order by str

//            }

//

}

static class FastReader {

BufferedReader br;

StringTokenizer st;



public FastReader() {

br = new BufferedReader(

new InputStreamReader(System.in));

}



String next() {

while (st == null || !st.hasMoreElements()) {

try {

st = new StringTokenizer(br.readLine());

} catch (IOException e) {

e.printStackTrace();

}

}

return st.nextToken();

}



int nextInt() {

return Integer.parseInt(next());

}



long nextLong() {

return Long.parseLong(next());

}



double nextDouble() {

return Double.parseDouble(next());

}



String nextLine() {

String str = "";

try {

if (st.hasMoreTokens()) {

str = st.nextToken("\n");

} else {

str = br.readLine();

}

} catch (IOException e) {

e.printStackTrace();

}

return str;

}

}

static ArrayList<Integer>[] gr;

public static void main(String[] args) {

FastReader sc = new FastReader();

PrintWriter out=new PrintWriter(System.out);

int t = sc.nextInt();

while (t != 0) {

t--;

String str=sc.next();

StringBuilder st=new StringBuilder(str);

for (int i = 0; i < str.length(); i++) {

char ch=st.charAt(i);

int dig=ch-'0';

int j=i-1;

while (j>=0 && st.charAt(j)-'0'<dig-1){

st.deleteCharAt(j+1);

--dig;

st.insert(j,""+dig);

--j;

}

//                out.println(st);

}

out.println(st);

}

out.flush();

}

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll count_p = count(s.begin(), s.end(), 'p');
    ll count_s = count(s.begin(), s.end(), 's');
    if (count_p == 0 || count_s == 0){
        cout << "YES\n";
    }
    else {
        if (s[0] == 's' || s[n - 1] == 'p'){
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return;
}

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

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

    return 0;
}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll count_p = count(s.begin(), s.end(), 'p');
    ll count_s = count(s.begin(), s.end(), 's');
    if (count_p == 0 || count_s == 0){
        cout << "YES\n";
    }
    else {
        if (s[0] == 's' || s[n - 1] == 'p'){
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return;
}

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

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

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll count_p = count(s.begin(), s.end(), 'p');
    ll count_s = count(s.begin(), s.end(), 's');
    if (count_p == 0 || count_s == 0){
        cout << "YES\n";
    }
    else {
        if (s[0] == 's' || s[n - 1] == 'p'){
            bool f = 0;
            f(i,0,n){
                if (s[i] == 'p')
                    f = 1;
                if (f && s[i] == 's'){
                    cout << "NO\n";
                    return;
                }
            }
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return;
}

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

    cin >> t;
    while (t--)
    {
        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>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#include <numeric>
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    f(i, 0, n) cin >> a[i];
    ll mx = LLONG_MIN;
    ll sm = accumulate(a.begin(), a.end(), 0LL);
    mx = max(mx, sm);
    while (a.size() > 1)
    {
        reverse(all(a));
        sm = *(a.end() - 1)- a[0];
        for (int i = 0; i < a.size() - 1; i++)
        {
            a[i] = a[i + 1] - a[i];
        }
        a.pop_back();
        mx = max(mx, sm);
    }
    cout << mx << endl;

    return;
}

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

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

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#include <numeric>
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    f(i, 0, n) cin >> a[i];
    ll mx = LLONG_MIN;
    ll sm = accumulate(a.begin(), a.end(), 0LL);
    mx = max(mx, sm);
    while (a.size() > 1)
    {
        reverse(all(a));
        sm = abs(*(a.end() - 1)- a[0]);
        for (int i = 0; i < a.size() - 1; i++)
        {
            a[i] = a[i + 1] - a[i];
        }
        a.pop_back();
        mx = max(mx, sm);
    }
    cout << mx << endl;

    return;
}

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

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

    return 0;
}