For this Question: You are given an array A of size N consisting of integers. In one move, you can select any element of the array, and either increase or decrease it by one. In other words, in one move you select an index i (1 ≤ i ≤ N) and replace A<sub>i</sub> by either A<sub>i</sub>-1 or A<sub>i</sub>+1.

For example, if A = [1, 4, -2, 0, 1], if you select i = 3 and decide to increase it, after this move A = [1, 4, -1, 0, 1]. Lets say now you select i = 1 and decrease it, after this move A = [0, 4, -1, 0, 1].

You are also given an integer K in the input. Your task is to find the minimum number of moves you must perform, so that there exist two indices i, j, such that 1 ≤ i ≤ j ≤ N and A[i] + A[i+1] +. . A[j-1] + A[j] = K.The first line contains two integers N and K.

The second line contains N space separated integers -  A<sub>1</sub>, A<sub>2</sub>,. . A<sub>n</sub>.

<b> Constraints: </b>
1 ≤ N ≤ 50000
-10<sup>9</sup> ≤ K ≤ 10<sup>9</sup>
-10<sup>9</sup> ≤ A[i] ≤ 10<sup>9</sup>Print a single integer denoting the minimum number of moves required.Sample Input 1:
3 4
-2 8 2

Sample Output 1:
2

Sample Explanation 1:

Decrement the 2nd element twice, the array become [-2, 6, 2]. Now the segment [1, 2], i. e, [-2, 6] has sum 4., I have written this Solution Code:  
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template <typename t>
using ordered_set = tree<t, null_type, less<t>, rb_tree_tag, tree_order_statistics_node_update>;
 
// #pragma gcc optimize("ofast")
// #pragma gcc target("avx,avx2,fma")
 
 
#define int long long
 
#define all(x) (x).begin(), (x).end()
 
 
#define pb push_back
#define endl '\n'
#define fi first
#define se second
 
const int mod = 1e9 + 7;
 
// const int mod=998'244'353;
 
 
const long long INF = 2e18 + 10;
// const int INF=1e9+10;
 
#define readv(x, n)   \
    vector<int> x(n); \
    for (auto &i : x) \
        cin >> i;
 
 
 
template <typename t>
    using v = vector<t>;
 
template <typename t>
    using vv = vector<vector<t>>;
 
template <typename t>
    using vvv = vector<vector<vector<t>>>;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<vector<double>> vvd;
 
typedef pair<int, int> pii;
 
 
 
int multiply(int a, int b, int in_mod) { return (int)(1ll * a * b % in_mod); }
int mult_identity(int a) { return 1; }
 
 
 
const double pi = acosl(-1);
 
 
 
auto power(auto a, auto b, const int in_mod)
{
 
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        if(b/2)
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
auto mod_inv(auto q, const int in_mod)
{
    return power(q, in_mod - 2, in_mod);
}
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define stp cout << fixed << setprecision(20);
 
vector<pair<int,int>> adj;
 
 
void solv()
{
    int n, k;
    cin>>n>>k; 
 
    assert(1<=n && n<=50000);
    assert(-1e9<=k && k<=1e9);
 
    readv(a,n);
 
    for(int i = 0;i<n;i++)
        assert(-1e9<=a[i] && a[i]<=1e9);
    set<int> pref_sm;
    pref_sm.insert(0);
 
    int sm = 0;
    int mn = INF;
    for(int i = 0;i<n;i++)
    {
        sm += a[i];
 
        int needed = sm - k;
 
        auto p = pref_sm.lower_bound(needed);
 
        if(p!=pref_sm.end())
        {
            int x = *p;
            int diff = x - needed;
 
            assert(diff>=0);
            mn = min(mn, diff);
 
 
        }
        if(p!=pref_sm.begin())
        {
            p--;
            int x = *p;
            int diff = needed - x;
 
            assert(diff>=0);
            mn = min(mn, diff);
        }
 
 
 
        pref_sm.insert(sm);
 
    }
    cout<<mn<<endl;
 
 
}
 
 
 
 
 
 
 
void solve()
{
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solv();
    }
}
 
 
 
 
signed main()
{
 
 
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
 
#ifdef ONLINE_JUDGE
    #ifdef ASC
 
    namespace fs = std::filesystem;
    std::string path = "./";
    string filename;
    for (const auto & entry : fs::directory_iterator(path)){
        if( entry.path().extension().string() == ".in"){
            filename = entry.path().filename().stem().string();
        }
    }
    if(filename != ""){
        string input_file = filename +".in";
        string output_file = filename +".out";
        if (fopen(input_file.c_str(), "r"))
        {
            freopen(input_file.c_str(), "r", stdin);
            freopen(output_file.c_str(), "w", stdout);
        }
    }
    #endif
#endif
    auto clk = clock();
    // -------------------------------------Code starts here---------------------------------------------------------------------
 
    signed t = 1;
    // cin >> t;
 
    for (signed test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
 
        solve();
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
    clk = clock() - clk;
 
    #ifndef ONLINE_JUDGE
    // cerr << fixed << setprecision(6) << "\nTime: " << ((float)clk) / CLOCKS_PER_SEC << "\n";
    #endif
    return 0;
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?