ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 27):
#include <bits/stdc++.h>
using namespace std;

list<long long> merge_for(unordered_multiset<long long> &s, long long x) {
    auto x_iter = s.find(x);
    if (x_iter != s.end()) {
        s.erase(x_iter);
        return {x};
    }
    if (x == 1) {
        return {};
    }

    auto l_half = x / 2;
    auto r_half = (x+1) / 2;
    auto rt = merge_for(s, l_half);
    if (rt.empty()) {
        return {};
    }
    auto r_result = merge_for(s, r_half);
    if (r_result.empty()) {
        for (auto i : rt) {
            s.insert(i);
        }
        return {};
    } else {
        rt.splice(rt.end(), r_result);
        return rt;
    }
}

void solve() {
    unordered_multiset<long long> s;
    int n, m;
    cin >> n >> m;
    for (int i=0; i<n; ++i) {
        long long tmp;
        cin >> tmp;
        s.insert(tmp);
    }
    vector<long long> rq(m);
    for (auto &i : rq) {
        cin >> i;
    }

    bool ok = true;
    for (auto i : rq) {
        if (merge_for(s, i).empty()) {
            ok = false;
            break;
        }
    }
    if (s.empty() && ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

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

Submission (verdict: Time limit exceeded on test 27):
#include <bits/stdc++.h>
using namespace std;

bool merge_for(unordered_multiset<long long> &s, long long x) {
    auto x_iter = s.find(x);
    if (x_iter != s.end()) {
        s.erase(x_iter);
        return true;
    }
    if (x == 1) {
        return false;
    }

    auto l_half = x / 2;
    auto r_half = (x+1) / 2;
    return merge_for(s, l_half) && merge_for(s, r_half);
}

void solve() {
    unordered_multiset<long long> s;
    int n, m;
    cin >> n >> m;
    for (int i=0; i<n; ++i) {
        long long tmp;
        cin >> tmp;
        s.insert(tmp);
    }
    vector<long long> rq(m);
    for (auto &i : rq) {
        cin >> i;
    }

    bool ok = true;
    for (auto i : rq) {
        if (! merge_for(s, i)) {
            ok = false;
            break;
        }
    }
    if (s.empty() && ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int MOD = 1e9+7;
const int maxn = 1e3 + 10;
 
void solve(){
    string a,b,c;
    cin >> a >> b >> c;
    int na = a.length();
    int nb = b.length();
    vector<vector<int>> dp(maxn, vector<int>(maxn, 1e15));
    dp[0][0] = 0;
    for(int i = 0; i <= na; i++){
        for(int j = 0; j <= nb; j++){
            if(i + j == 0) continue;
            if(i - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j] + (c[i + j - 1] != a[i-1]));
            }
            if(j - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (c[i + j - 1] != b[j-1]));
            }
        }
    }

    cout << dp[na][nb] << endl;
}

int32_t main(){

    int t=1;
    cin >> t;
    while(t--) solve();

    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int MOD = 1e9+7;
const int maxn = 2e3 + 10;
 
void solve(){
    string a,b,c;
    cin >> a >> b >> c;
    int na = a.length();
    int nb = b.length();
    vector<vector<int>> dp(maxn, vector<int>(maxn, 1e15));
    dp[0][0] = 0;
    for(int i = 0; i <= na; i++){
        for(int j = 0; j <= nb; j++){
            if(i + j == 0) continue;
            if(i - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j] + (c[i + j - 1] != a[i-1]));
            }
            if(j - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (c[i + j - 1] != b[j-1]));
            }
        }
    }

    cout << dp[na][nb] << endl;
}

int32_t main(){

    int t=1;
    cin >> t;
    while(t--) solve();

    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int MOD = 1e9+7;
 
void solve(){
    string a,b,c;
    cin >> a >> b >> c;
    int na = a.length();
    int nb = b.length();
    vector<vector<int>> dp(na + 1, vector<int>(nb + 1, 1e15));
    dp[0][0] = 0;
    for(int i = 0; i <= na; i++){
        for(int j = 0; j <= nb; j++){
            if(i + j == 0) continue;
            if(i - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j] + (c[i + j - 1] != a[i-1]));
            }
            if(j - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (c[i + j - 1] != b[j-1]));
            }
        }
    }

    cout << dp[na][nb] << endl;
}

int32_t main(){

    int t=1;
    cin >> t;
    while(t--) solve();

    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int MOD = 1e9+7;
const int maxn = 1e3 + 10;
 
void solve(){
    string a,b,c;
    cin >> a >> b >> c;
    int na = a.length();
    int nb = b.length();
    vector<vector<int>> dp(maxn, vector<int>(maxn, 1e15));
    dp[0][0] = 0;
    for(int i = 0; i <= na; i++){
        for(int j = 0; j <= nb; j++){
            if(i + j == 0) continue;
            if(i - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j] + (c[i + j - 1] != a[i-1]));
            }
            if(j - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (c[i + j - 1] != b[j-1]));
            }
        }
    }

    cout << dp[na][nb] << endl;
}

int32_t main(){

    int t=1;
    cin >> t;
    while(t--) solve();

    return 0;
}


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int MOD = 1e9+7;
const int maxn = 2e3 + 10;
 
void solve(){
    string a,b,c;
    cin >> a >> b >> c;
    int na = a.length();
    int nb = b.length();
    vector<vector<int>> dp(maxn, vector<int>(maxn, 1e15));
    dp[0][0] = 0;
    for(int i = 0; i <= na; i++){
        for(int j = 0; j <= nb; j++){
            if(i + j == 0) continue;
            if(i - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j] + (c[i + j - 1] != a[i-1]));
            }
            if(j - 1 >= 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1] + (c[i + j - 1] != b[j-1]));
            }
        }
    }

    cout << dp[na][nb] << endl;
}

int32_t main(){

    int t=1;
    cin >> t;
    while(t--) solve();

    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

#include<vector>

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        vector<int>s;

        if(n%2==1){

            int op=0;

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

            if(i==y){s.push_back(2);}

            else{

                s.push_back(op);

                if(op)op=0;

                else op=1;

            }





            }

    

        }

        else{int op=0;

            if((y-x)%2==0||y-x==1){

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

                if(i==y){s.push_back(2);}

                else{

                    s.push_back(op);

                   

                }

                    if(op)op=0;

                    else op=1;



            }}

            else{

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

                    if(i==x){

                        s.push_back(op);

                        if(op)op=0;

                        else op=1;

                        i++;i++;

                        s.push_back(2);

                        s.push_back(op);

                        if(op)op=0;

                        else op=1;

                        continue;

                    }

                    if(i==y){s.push_back(2);}

                    else{

                        s.push_back(op);

                       if(op)op=0;

                        else op=1;

                    }

                        

    

                }

            }

    

        }

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

            cout<<s[i]<<" ";

        }

        cout<<endl;

    }

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

Previous submission (verdict: Time limit exceeded on test 6):
t =  int(input())

def solve():

s = [int(i) for i in list(input())]

n = len(s)

for i in range(1,n,1):

for j in range(i):

if s[i] - (i-j) > s[j]:

s.insert(j, s[i] - (i-j))

s.pop(i+1)

break

print("".join([str(i) for i in s]))

return

for i in range(t):

solve()

Submission (verdict: Time limit exceeded on test 5):
t =  int(input())

def solve():

s = list(input())

n = len(s)

for i in range(1,n,1):

for j in range(i):

if int(s[i]) - (i-j) > int(s[j]):

s.insert(j, str(int(s[i]) - (i-j)))

s.pop(i+1)

break

print("".join(s))

return

for i in range(t):

solve()
Problem: 2050D - Digital string maximization
Language: PyPy 3-64


Submission (verdict: Time limit exceeded on test 6):
t =  int(input())

def solve():

s = [int(i) for i in list(input())]

n = len(s)

for i in range(1,n,1):

for j in range(i):

if s[i] - (i-j) > s[j]:

s.insert(j, s[i] - (i-j))

s.pop(i+1)

break

print("".join([str(i) for i in s]))

return

for i in range(t):

solve()
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 7):
t =  int(input())

def solve():

s = [int(i) for i in list(input())]

n = len(s)

for i in range(1,n,1):

for j in range(max(i-10, 0), i):

if s[i] - (i-j) > s[j]:

s.insert(j, s[i] - (i-j))

s.pop(i+1)

break

print("".join([str(i) for i in s]))

return

for i in range(t):

solve()

Submission (verdict: Accepted):
t =  int(input())

def solve():

s = [int(i) for i in list(input())]

n = len(s)

for i in range(1,n,1):

for j in range(max(i-10, 0), i):

if s[i] - (i-j) > s[j]:

tmp = s[j:i]

s[j] = s[i] - (i-j)

s[j+1:i+1] = tmp

break

print("".join([str(i) for i in s]))

return

for i in range(t):

solve()
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 5):
t =  int(input())

def solve():

s = list(input())

n = len(s)

for i in range(1,n,1):

for j in range(i):

if int(s[i]) - (i-j) > int(s[j]):

s.insert(j, str(int(s[i]) - (i-j)))

s.pop(i+1)

break

print("".join(s))

return

for i in range(t):

solve()

Submission (verdict: Time limit exceeded on test 7):
t =  int(input())

def solve():

s = [int(i) for i in list(input())]

n = len(s)

for i in range(1,n,1):

for j in range(max(i-10, 0), i):

if s[i] - (i-j) > s[j]:

s.insert(j, s[i] - (i-j))

s.pop(i+1)

break

print("".join([str(i) for i in s]))

return

for i in range(t):

solve()
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
// #include <atcoder/dsu>
using namespace std;
// using namespace atcoder;
// using mll = modll998244353;
#define lol 1000000007
#define all(c) c.begin(), c.end()
#define vi vector<ll>
#define vvi vector<vi>
#define fi first
#define se second
#define pb push_back
#define mod1 998244353
#define MAXN 2e6
#pragma GCC optimize("Ofast")
typedef long long ll;
// #define ll int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
constexpr ll N = 3e5 + 1;
ll inf = 1e18;
mt19937_64 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 998244353;

struct mi
{
    ll v;
    explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(long long _v) : v(_v % MOD) { v += (v < 0) * MOD; }
};

mi &operator+=(mi &a, mi b)
{
    if ((a.v += b.v) >= MOD)
        a.v -= MOD;
    return a;
}
mi &operator-=(mi &a, mi b)
{
    if ((a.v -= b.v) < 0)
        a.v += MOD;
    return a;
}
mi operator+(mi a, mi b) { return a += b; }
mi operator-(mi a, mi b) { return a -= b; }
mi operator*(mi a, mi b) { return mi((int)a.v * b.v); }
mi &operator*=(mi &a, mi b) { return a = a * b; }
mi mpow(mi a, long long p)
{
    assert(p >= 0);
    return p == 0 ? 1 : mpow(a * a, p / 2) * (p & 1 ? a : 1);
}
mi inv(mi a)
{
    assert(a.v != 0);
    return mpow(a, MOD - 2);
}
mi operator/(mi a, mi b) { return a * inv(b); }

void solve()
{
    ll n, m;
    cin >> n >> m;
    vi arr(n), check(m);
    for (ll i = 0; i < n; i++)
        cin >> arr[i];
    for (ll i = 0; i < m; i++)
        cin >> check[i];
    sort(all(arr));
    sort(all(check));
    multiset<ll> s;
    for (ll i = 0; i < n; i++)
    {
        s.insert(arr[i]);
    }
    for (ll i = 0; i < m; i++)
    {
        ll p = 0;
        while (1)
        {
            auto it = *s.begin();
            s.erase(s.find(it));
            if (it == check[i])
            {
                p = 1;
                break;
            }
            if (s.size() == 0)
                break;
            auto it1 = *s.begin();
            s.erase(s.find(it1));
            if (it1 - it <= 1)
            {
                s.insert(it1 + it);
                continue;
            }
            else
                break;
        }
        if (!p)
        {
            cout << "No\n";
            return;
        }
    }
    if (s.size() == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

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

    ll ft = 1;
    cin >> ft;
    while (ft--)
    {

        solve();
    }
}

// DONT GET STUCK ON ONE IDEA
//  think abt your logic thoroughly before implementing, look for all edge cases and stl structures which can cause tle/mle
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        int seven=0;

        int sodd=0;

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

            cin>>arr[i];

            if((i+1)%2==1){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n/2) != 0  ||  sodd%(n-n/2)!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n/2) == sodd/(n-n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}

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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        long long seven=0;

        long long sodd=0;

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

            cin>>arr[i];

            if((i+1)%2==1){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n/2) != 0  ||  sodd%(n-n/2)!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n/2) == sodd/(n-n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        int seven=0;

        int sodd=0;

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

            cin>>arr[i];

            if(i%2){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n-n/2) != 0  ||  sodd%n/2!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n-n/2) == sodd/(n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}

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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        int seven=0;

        int sodd=0;

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

            cin>>arr[i];

            if((i+1)%2==1){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n/2) != 0  ||  sodd%(n-n/2)!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n/2) == sodd/(n-n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        int seven=0;

        int sodd=0;

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

            cin>>arr[i];

            if(i%2){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n-n/2) !=0  && sodd%n/2!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n-n/2) == sodd/(n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}

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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        int seven=0;

        int sodd=0;

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

            cin>>arr[i];

            if(i%2){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n-n/2) != 0  ||  sodd%n/2!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n-n/2) == sodd/(n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


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

#include<vector>

using namespace std;

int main() {

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> arr(n);

        int seven=0;

        int sodd=0;

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

            cin>>arr[i];

            if(i%2){

                sodd+=arr[i];

            }

            else{

                seven+=arr[i];

            }

        }

        if(seven% (n-n/2) !=0  && sodd%n/2!=0){

            cout<<"NO"<<endl;

        }

        else if(seven/(n-n/2) == sodd/(n/2)){

            cout<<"YES"<<endl;

        }

        else{

            cout<<"NO"<<endl;

        }

    }



    return 0;

}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
long long fac(vector<int> &dp,int n,int i,int a){
    if(n<=i){
        return 1;
    }
    
    return n*fac(dp,n-1,i,a-1)/a;
}
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        bool f=false;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]<=0){
               f = true; 
            }
        }
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        vector<int> dp(n+1);
        for(auto x:dp)x=-1;
        long long sum=0;
        if(f){
        for(int i=0;i<n;i++){
            sum += fac(dp,n-1,n-i-1,i)*(arr[i])*pow(-1,i);
        }
        }
        else{
            for(int i=0;i<n;i++){
                sum+=arr[i];
            }
        }
        cout<<abs(sum)<<endl;
    
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
long long fac(int n,int k){
     if (k == 0 || k == n) return 1;
    
    long long res = 1;
    if (k > n - k) k = n - k; 
    
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) / (i + 1);
    }
    return res;
}
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        bool f=false;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]<=0){
               f = true; 
            }
        }
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0;
        if(f){
        for(int i=0;i<n;i++){
            sum += fac(n-1,i)*(arr[i])*((i % 2) ? -1 : 1);
        }
        }
        else{
            for(int i=0;i<n;i++){
                sum+=arr[i];
            }
        }
        cout<<abs(sum)<<endl;
    
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include<vector>
#include<cmath>
using namespace std;
long long fac(vector<int> &dp,int n,int i,int a){
    if(n<=i){
        return 1;
    }
    
    return n*fac(dp,n-1,i,a-1)/a;
}
int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        bool f=false;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];
            if(arr[i]<=0){
               f = true; 
            }
        }
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        vector<int> dp(n+1);
        for(auto x:dp)x=-1;
        long long sum=0;
        if(f){
        for(int i=0;i<n;i++){
            sum += fac(dp,n-1,n-i-1,i)*(arr[i])*pow(-1,i);
        }
        }
        else{
            for(int i=0;i<n;i++){
                sum+=arr[i];
            }
        }
        cout<<abs(sum)<<endl;
    
    }
    return 0;
}