For this Question: Given an integer Q representing the number of queries and an integer K. There are two types of queries:
(i) 1 x : Add the number x to the stream
(ii) 2 : Print the sum of last K numbers of the stream. If there are less than K numbers in the stream, print the sum of current stream.
Process all the queries.First line contains two integers Q and K.
Next Q lines contains the queries. 

Constraints
1 <= Q <= 10^5
1 <= x <= 10^5
1 <= K <= Q
There is atleast one query of 2nd type. For each query of type 2, print the sum of last K numbers of the stream on a new line.Sample Input 1:
5 2
1 4
2
1 1
1 3
2

Output 
4
4

Explanation:
Initial Stream = {}
Add 4. Stream = {4}
Sum of last two elements = 4
Add 1. Stream = {4, 1}
Add 3. Stream = {4, 1, 3}
Sum of last two elements = 4

Sample Input 2:
3 1
1 1
2
2

Output
1
1

Explanation
Initial Stream = {}
Add 1. Stream = {1}
Sum of last element = 1
Sum of last element = 1, I have written this Solution Code: /**
 *    author:  tourist1256
 *    created: 2022-06-14 14:26:47
 **/

#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 <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 2351
#endif

#define int long long

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int64_t random_long(long long l = LLONG_MIN, long long r = LLONG_MAX) {
    uniform_int_distribution<int64_t> generator(l, r);
    return generator(rng);
}

int32_t main() {
    int Q, K;
    cin >> Q >> K;

    deque<int> st;
    int sum = 0;

    while (Q--) {
        int x;
        cin >> x;
        if (x == 1) {
            int y;
            cin >> y;
            if (st.size() == K) {
                sum -= st.back();
                st.pop_back();
                st.push_front(y);
                sum += y;
            } else {
                st.push_front(y);
                sum += y;
            }
        } else {
            cout << sum << "\n";
        }
    }
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?