akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

int64_t gcd(int64_t a,int64_t b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int64_t lcm(int64_t a,int64_t b){
	return a/gcd(a,b)*b;
}

template<class T> class segtree{
public:
    int n,size_;
    vector<T> dat;
    function<T(T,T)> fun_;
    T id_;
    segtree()=default;
    segtree(int size,function<T(T,T)> fun,T id,T initial_value){ init(size,fun,id,initial_value); }
    void init(int size,function<T(T,T)> fun,T id,T initial_value){
        size_=size;
        fun_=fun;
        id_=id;
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,id);
        for(int i=0; i<size; ++i) update(i,initial_value);
    }
    int size()const{ return size_; }
    void update(int k, T a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=fun_(dat[k*2+1],dat[k*2+2]);
        }
    }
    T at(int index){ return dat[index+n-1]; }
    void add(int k,T a){ update(k,at(k)+a); }
    T query(int a,int b) { return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return id_;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return fun_(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    int n,q;
    cin >> n >> q;
    vector<int> p(n);
    rep(i,0,n) cin >> p[i];

    int64_t mod=1e9+7;
    vector<vector<int64_t>> period(n),cumsum(41,vector<int64_t>(n));
    vector<int64_t> sum(n);
    segtree<int64_t> seg(n,lcm,1,1);
    rep(i,0,n){
        int z=i+1;
        for(;;){
            z=p[z-1];
            period[i].push_back(z);
            sum[i]+=z;
            if(z==i+1) break;
        }
        cumsum[period[i].size()][i]=sum[i];
        rep(j,0,41) cumsum[j][i]=(cumsum[j][i]+(i>0?cumsum[j][i-1]:0))%mod;
        seg.update(i,period[i].size());
    }
    rep(i,0,q){
        int l,r;
        cin >> l >> r;
        --l;
        --r;
        int64_t lcm_=seg.query(l,r+1),ans=0;
        rep(j,1,41) ans=(ans+lcm_/j%mod*(cumsum[j][r]-(l>0?cumsum[j][l-1]:0))%mod+mod)%mod;
        cout << ans << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 92292
raw_input()
g=raw_input().split()
a=[int(x) for x in g]
n=len(a)
acc=[]
for i in range(n-1):
	if a[i]>a[i+1]:
		acc+=[i]
		if len(acc)>1:
			break
if len(acc)>1:
	a[acc[0]],a[acc[1]+1]=a[acc[1]+1],a[acc[0]]
for i in range(n-1):
	if a[i]>a[i+1]:
		print("NO")
		exit()
print("YES")

Measured memory_bytes: 2692
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


import collections
n = int(input())
if n == 1:
    print(0)
    exit()
c = collections.Counter(prime_factorize(n))
t = sorted(c.values())
max_c = max(t)
calc_list = []
ans = 0
a = 0
i = 1
while a <= max_c:
    a = i * (i + 1) // 2
    while t[0] < a:
        ans += i - 1
        t.pop(0)
        if len(t) == 0:
            break
    i += 1
print(ans)

Measured memory_bytes: 9416
#include<stdio.h>
using namespace std;
int main() {
	int n,tmp=0;
	scanf("%d",&n);
	int t=n;
	while(t){
		tmp+=t%10;
		t/=10;
	}
	printf("%s\n",(n%tmp==0)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    long long ans = 1;
    int k = 0;
    map<long long, int> mp;
    for (int i = N-1; i >= 0; i--) {
        mp[A[i]]++;
        if (mp[A[i]] == 2) {
            mp[A[i]] = 0;
            ans *= A[i];
            k++;
            if (k == 2) {
                cout << ans << endl;
                return 0;
            }
        }
    }
    puts("0");
}

Measured memory_bytes: 6272
#include <iostream>

using namespace std;

int main()
{
    int N;

    cin>>N;
    if(N==1)
        cout<<"Hello World"<<endl;
    else
    {
        int a;
        int b;
        cin >>a;
        cin >> b;
        cout<<a+b<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import sys
x=input()
y=input()
x0=x.split()
a=int(x0[0])
v=int(x0[1])
y0=y.split()
b=int(y0[0])
w=int(y0[1])
t=int(input())
l=abs(a-b)
r=v-w
if r<=0:
    print("NO")
    sys.exit()
if l/r<=t:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9200
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = -A[i]
heapq.heapify(A)

for i in range(M):
    trgt = -heapq.heappop(A)//2
    heapq.heappush(A,-trgt)
print(-sum(A))

Measured memory_bytes: 20364
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int parse(const string& t)
{
  return ((t[0]-'0')*10 + t[1]-'0')*60 + ((t[3]-'0')*10 + t[4]-'0');
}

int inter(int gb, int ge, int vb, int ve)
{
  if (ge < vb || ve < gb) {
    return 0;
  } else {
    return min(ge, ve) - max(gb, vb);
  }
}

void countup(map<string, int>& total, const map<string, vector<int> >& m)
{
  if (!m.count("000")) {
    return;
  }
  const vector<int>& god = m.find("000")->second;
  const int N = god.size();
  if (N % 2 != 0) {
    throw "N is not even";
  }
  for (map<string, vector<int> >::const_iterator it = m.begin(); it != m.end(); ++it) {
    if (it->first == "000") {
      continue;
    }
    const string& id = it->first;
    const vector<int>& v = it->second;
    const int M = v.size();
    if (M % 2 != 0) {
      throw "M is not even";
    }
    for (int i = 0; i < N; i += 2) {
      for (int j = 0; j < M; j += 2) {
        total[id] += inter(god[i], god[i+1], v[j], v[j+1]);
      }
    }
  }
}

int main()
{
  int N;
  while (cin >> N && N != 0) {
    string prev_date = "";
    map<string, vector<int> > m;
    map<string, int> total;
    for (int i = 0; i < N; i++) {
      string date, time, act, id;
      cin >> date >> time >> act >> id;
      if (date != prev_date) {
        countup(total, m);
        m.clear();
      }
      m[id].push_back(parse(time));
      prev_date = date;
    }
    countup(total, m);
    int ans = 0;
    for (map<string, int>::const_iterator it = total.begin(); it != total.end(); ++it) {
      ans = max(ans, it->second);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ///   freopen("input.txt", "r", stdin);

    int n;
    cin >> n;

    vector <long double> a(n);
    for(auto & x : a)
        cin >> x;

    const int base = n;

    vector <vector <long double> > dp(n, vector<long double>(base * 2 + 1));

    dp[0][base + 1] = a[0];
    dp[0][base - 1] = 1. - a[0];

    for(int i = 1; i < n; ++i)
    {
        for(int prevBal = -i; prevBal <= i; ++prevBal)
        {
            dp[i][prevBal + 1 + base] += dp[i - 1][prevBal + base] * a[i];
            dp[i][prevBal - 1 + base] += dp[i - 1][prevBal + base] * (1.0 - a[i]);
        }
    }

    long double ans = 0;
    for(int bal = 1; bal <= n; ++bal)
        ans += dp[n - 1][bal + base];

    cout << setprecision(10) << ans << '\n';

    return 0;
}



Measured memory_bytes: 281600
A, B =  list(map(int, input().split()))
A -= 1

def f(x):
    if x%2==0:
        return x^((x//2)%2)
    else:
        return (x-1)^x^((x//2)%2)

# print(A, B, f(A), f(B))

print(f(A)^ f(B))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A,B; cin >> A >> B;
    if(A%3==0 || B%3==0 || (A+B)%3==0) pr("Possible");
    else pr("Impossible");
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int dr[] = {1, 0, -1, 0};
int dc[] = {0, 1, 0, -1};

int R, C, M, ans;
int now=1, sr, sc, tr, tc;
int on[55][55], off[55][55], kp[55][55];
int time[55][55];
int taskr[1010], taskc[1010];
bool vis[55][55];
char g[55][55];

inline bool check(int r, int c)
{
	if (r<0 || r>=R) return 0;
	if (c<0 || c>=C) return 0;
	if (g[r][c]=='#') return 0;
	return 1;
}

void homura(int r, int c, int t)
{
	if (time[r][c]==0)
		ans += on[r][c];
	else
		ans += min(on[r][c]+off[r][c], kp[r][c]*(t-time[r][c]));
	time[r][c] = t;
}

bool dfs(int r, int c, int t)
{
	vis[r][c] = 1;
	if (r==tr && c==tc)
	{
		now = t;
		return 1;
	}
	int nr, nc;
	for (int i = 0; i < 4; ++i)
	{
		nr = r+dr[i]; nc = c+dc[i];
		if (vis[nr][nc] || !check(nr, nc)) continue;
		if (dfs(nr, nc, t+1))
		{
			homura(r, c, t);
			return 1;
		}
	}
	return 0;
}

int main()
{
	int i, j, k, r, c;
	scanf("%d%d%d", &R, &C, &M);
	for (r = 0; r < R; ++r)
		scanf("%s", g[r]);
	for (r = 0; r < R; ++r)
		for (c = 0; c < C; ++c)
			scanf("%d", &kp[r][c]);
	for (r = 0; r < R; ++r)
		for (c = 0; c < C; ++c)
			scanf("%d", &on[r][c]);
	for (r = 0; r < R; ++r)
		for (c = 0; c < C; ++c)
			scanf("%d", &off[r][c]);
	for (i = 0; i < M; ++i)
		scanf("%d%d", &taskr[i], &taskc[i]);
	for (i = 0; i < M-1; ++i)
	{
		memset(vis, 0, sizeof(vis));
		sr = taskr[i], sc = taskc[i];
		tr = taskr[i+1], tc = taskc[i+1];
		dfs(sr, sc, now);
	}
	homura(taskr[M-1], taskc[M-1], now);
	for (r = 0; r < R; ++r)
		for (c = 0; c < C; ++c)
			if (time[r][c]) ans += off[r][c];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

ll dp[201010][3];
int main() {
    string S;
    cin >> S;
    int N = S.length();
    REP(i, N + 1) {
        REP(j, 3) { dp[i][j] = -INF; }
    }
    // dp[i][pre] := i文字目まで使っていて、以前にpre文字分の分割
    //分割の数を最大化する
    dp[0][0] = 0LL;
    dp[0][1] = 0LL;
    dp[0][2] = 0LL;
    REP(i, N) {
        for(int pre = 1; pre < 3; pre++) {
            //配るDP
            for(int d = 1; d < 3; d++) {
                if(pre == d) {
                    if(i >= 1 and d == 1) {
                        if(S[i - 1] == S[i]) {
                            continue;
                        }
                    } else {
                        // d==2
                        if(i >= 2 and S[i - 2] == S[i] and
                           S[i - 1] == S[i + 1]) {
                            continue;
                        }
                    }
                }
                chmax(dp[i + d][d], dp[i][pre] + 1);
            }
        }
    }
    cout << max(dp[N][1], dp[N][2]) << endl;
    return 0;
}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) {
        cin >> a[i];
    }

    vector<int> l(n + 1, INT_MIN);
    vector<int> r(n + 1, INT_MIN);
    REP (i, n) {
        l[i + 1] = max(l[i], a[i]);
    }
    REP_R (i, n) {
        r[i] = max(r[i + 1], a[i]);
    }

    REP (i, n) {
        cout << max(l[i], r[i + 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d", &a);
    scanf("%d", &b);
    if(a <= 9 && a > 0 && b <= 9 && b > 0){
        printf("%d\n", a * b);
    }
    else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

N = parseInt(readline())

h = [2, 4, 5, 7, 9]
p = [0, 1, 6, 8]
b = [3]

n = N % 10

if n in h
    println("hon")
elseif n in p
    println("pon")
else
    println("bon")
end




Measured memory_bytes: 152952
#include <iostream>
#include <cmath>
using namespace std;
 
int main()
{
	string a,b;
	int x;
	int zh(string s);
	
	cin>>a>>b;   
	
	x=zh(a+b);
	
	if(int(sqrt(x))==sqrt(x))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}
 
int zh(string s)
{
	int tmp=0;
	
	for(int i=0;i<s.size();i++)
		tmp=tmp*10+(s[i]-'0');
	
	return tmp;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        long K = sc.nextInt();
        long A = sc.nextInt();
        long B = sc.nextInt();
        long MAX = 1;

        if(A >= B || B-A ==1){
            MAX += K;
        }else{
            while(MAX < A){
                K--;
                MAX++;
            }
            while(K > 1){
                K -=2;
                MAX += B-A;
            }
            while(K > 0){
                K--;
                MAX++;
            }
        }
        System.out.println(MAX);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

  cin >> n;

  ll ans = 0;
  FOR(i, 1, n + 1) FOR(j, 1, n + 1) {
    ll sum;
    sum = gcd(i, j);
    FOR(k, 1, n + 1) {
      int t_sum;
      t_sum = gcd(sum, k);
      ans += t_sum;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //int cnt = Integer.parseInt(scan.next());
        //int total = Integer.parseInt(scan.next());
        long input = scan.nextLong();
        long total = 0;
        for (int i = 1; i <=input; i++) {
            if ((i % 3 == 0) && (i % 5 == 0)) {

            } else if (i % 3 == 0) {

            } else if (i % 5 == 0) {

            } else {
                total += i;
            }
        }
        System.out.println(total);
    }
//        int[] input = new int[5];
//        for(int i=0;i<5;i++) {
//            input[i] = Integer.parseInt(scan.next());
//        }
    //int c = Integer.parseInt(scan.next());
//        int cnt = 0;
//        while(h>0) {
//            h = h-a;
//            cnt++;
//        }
//        if(cnt*500 >= total) {
//            System.out.println("Yes");
//        } else {
//            System.out.println("No");
//        }
//        List<Integer> result = new ArrayList<Integer>();
//        for(int i=0;i<input.length; i++) {
//            for(int j=i+1;j<input.length; j++) {
//                for (int k = j+1; k<input.length; k++) {
//                    result.add(i+j+k);
//                }
//            }
//        }
//        Collections.sort(result, Collections.reverseOrder());
//        System.out.println(result.get(2));
       static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 0;
  ans = c - (a - b);
  if(ans < 0) ans = 0;
  cout << ans << endl;



}



Measured memory_bytes: 256
#include <bits/stdc++.h>


#define en "\n"
#define sqrt(n) sqrt((long double) n)
#define all(c) (c).begin() , (c).end()
#define MOD 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define flash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file_input(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))


using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef set<int> seti;
typedef pair<double, double> pdd;
typedef long double ld;



const double EPS=0.000000001;
const double INFD32=1000000000;
const ll INF64=1000000000000000000;
const int INF32=1000000000;

#define maxN 30000000
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
  return (a.second>=b.second && a.first>=b.first);
}
signed main(void){
    int n;
    cin>>n;
    int date;
    cin>>date;
    int a,b;
    long long ans=0;
    vector<pair<int,int> >p(n);
    for(int i=0;i<n;i++){
      cin>>p[i].first>>p[i].second;
    }
    sort(p.begin(),p.end());
    int cur=0;
    priority_queue<int>q;
    for(int i=1;i<=date;i++){
      //cout<<a<<" "<<b<<"\n";
      while(cur<n && p[cur].first<=i){
        q.push(p[cur].second);
        cur++;
      }
      if(!q.empty()){
        //cout<<q.top()<<"\n";
        ans+=q.top();
        q.pop();
      }
    }
    cout<<ans;
    return 0;
  }


Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll a,b,c;
  cin >> a>>b>>c;
  pri(a+b>=c?"Yes":"No");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  ll n;
  cin >> n;
  vector<ll>v(n);
  vector<ll>c(n);

  cin >> v;
  cin >> c;


  ll ans = 0;

  for(int i=0;i<n;i++){
    if (v[i] - c[i] > 0){
      ans += v[i] - c[i];
    }
  }







  cout << ans ;

}




















Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int N;
vector<int> A;
map<int, int> M;

int main(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	string ans = "YES\n";
	for (int i = 0; i < N; ++i) {
		if (M.count(A[i]) == 0)
			M[A[i]] = 1;
		else {
			ans = "NO\n";
			break;
		}
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 10368
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1000000007;


#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

LL dp[51][51][2501];
int main() {

	CLR(dp);
	int N,A;
	cin >> N>>A;
	VI X(N+1);
	FOR(i,1, N+1) { cin >> X[i]; }
	dp[0][0][0] = 1;
	FOR(j,1, N+1)FOR(k,0, N+1)REP(s, 2501) {

		if (j >= 1 && s < X[j]) {
			dp[j][k][s] = dp[j - 1][k][s];
		}
		else if (j >= 1 && s >= X[j] && k >= 1) {
			dp[j][k][s] = dp[j - 1][k][s]+ dp[j - 1][k-1][s-X[j]];
		}
		//if (dp[j][k][s] != 0) { cerr << j << " " << k << " " << s << endl; debug(dp[j][k][s]); }
		//debug(s);
	}
	LL ans = 0;
	FOR(k, 1, N + 1) {
		ans += dp[N][k][k*A];
	}
	cout << ans << endl;
}

Measured memory_bytes: 51072
#include<bits/stdc++.h>
using namespace std;
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
#define ll long long
int main()
{
    faster();
    int t,n,x;
    cin>>n>>x>>t;
    int ans;
    if(n%x==0) ans = n/x;
    else ans = n/x + 1;
    cout<<ans*t<<endl;

    return 0;
}



Measured memory_bytes: 3636
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
mod=10**9+7
X=Y=0
for i in range(1,n):
    X+=(n-i)*i*(x[i]-x[i-1])
    X%=mod
for i in range(1,m):
    Y+=(m-i)*i*(y[i]-y[i-1])
    Y%=mod
print(X*Y%mod)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int N;
    cin >> N;

    vector<long> X(N);
    vector<long> L(N);

    rep(i, N) cin >> X.at(i) >> L.at(i);

    vector<pair<long, long>> P(N);
    rep(i, N) P.at(i) = pair<long, long>(X.at(i) + L.at(i), X.at(i) - L.at(i));
    sort(P.begin(), P.end());

    int ans = 0;

    pair<long, long> p;

    long cur = -1000000000;
    for (int i = 0; i < N; i++)
    {
        if (cur <= P.at(i).second)
        {
            ans++;
            cur = P.at(i).first;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6428
object Main{
 
def main(args: Array[String]): Unit = {
  
    val arr1 = io.StdIn.readLine().split(' ')
    val a = arr1(0).toInt
  val b = arr1(1).toInt
  
  val ab = a * b
  val ap = a + b
  val am = a - b
  
  val arr = Array(ab, ap, am)
  
  println(arr.max)
}
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  for(int i=0; i<1000; i++) {
    int c[3]={i/100,i/10%10,i%10};
    int num=0;
    for(int j=0; j<n; j++) {
      if(s[j]=='0'+c[num]) num++;
      if(num==3) break;
    }
    if(num==3) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

x = list([a,b,c,d,e])
y = sorted(x)

if k >= y[4] -y[0]:
    print('Yay!')

else:
    print(':(')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;
const ll K = 20 ;

ll dp[K][N]  , ps[K][N] , a[N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    string s;
    cin >> s; 
    sort(all(s)) ;
    if (s == "abc") cout << "Yes" ;
    else cout << "No" ;
    return (0) ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, n, l, ans = 0, now = 0;
  scanf("%lld%lld", &n, &l);
  pair<ll, ll> p[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &p[i].first, &p[i].second);
  sort(p, p + n);
  for(i = 0; i < n; ++i) {
    if(p[i].second) now -= p[i].first - i - 1;
    else now += p[i].first - i - 1;
  }
  if(ans < now) ans = now;
  for(i = n - 1; i >= 0; --i) {
    if(p[i].second) now += l - n;
    else now -= l - n;
    if(ans < now) ans = now;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4132
#include<stdio.h>
#include<string.h>
int main(void){
  char str[16];
  scanf("%s",str);
  
  int k = strlen(str);
  int win = 0;
  for(int i=0;i<k;i++){
   	 if(str[i]=='o') win++;
  }
  if(15-k+win>=8){
   	printf("YES");
  }else{
   	printf("NO"); 
  }
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int E[6] = {3,0,-2,2,0,-3};
int W[6] = {2,0,3,-3,0,-2};
int S[6] = {4,-1,0,0,1,-4};
int N[6] = {1,4,0,0,-4,-1};


void DICE(char a,int d[],int d2[]){

int i;
	if(a == 'E'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + E[i]];
		}
		}	
	if(a == 'N'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + N[i]];
		}
		}	
	if(a == 'S'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + S[i]];
		}
		}	
	if(a == 'W'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + W[i]];
		}
		}	
}

int main(void){
	int d[6], d2[6],i,count;
	char x;
	char mark[128];
	
	for(i = 0; i < 6; i++){
	scanf("%d",&d[i]);
}

scanf("%s",mark);

for(i = 0,count = 0;mark[i] != '\0' ;i++){

	if(i % 2 == 0)
DICE(mark[i],d,d2);
	if(i % 2 == 1)
		DICE(mark[i],d2,d);
	
count++;
}

if(count % 2 == 1)
	memcpy(d,d2,6 * sizeof(int));

printf("%d\n",d[0]);


return 0;
}
	

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  string s;
  cin >> s;

  int x = (s[0]-'0')*10 + s[1]-'0';
  int y = (s[2]-'0')*10 + s[3]-'0';

  if(0<x & x<13) {
    if(0<y & y<13) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else {
    if(0<y & y<13) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vec A(N + 1);
    rep(i, N + 1) cin >> A[i];
    ll ans = 0;
    rep(i, N){
        ll b;
        cin >> b;
        if(A[i] >= b) ans += b;
        else if(A[i] + A[i + 1] >= b) ans += b, A[i + 1] += A[i] - b;
        else ans += A[i] + A[i + 1], A[i + 1] = 0;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 1024
#99b
a,b = map(int, input().split())

#f(n) = n*(n+1)/2
#n*(n+1)/2 - ans = a
#(n+1)*(n+2)/2 - ans = b
#{(n+1)*(n) + (n+1)*(2)}/2 - ans = b
# a + ans + n + 1 - ans = b
# a + n + 1 = b
# n = b - a - 1

#ans = n*(n+1)/2 -a
n = b - a - 1
print(n*(n+1)//2 - a)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;

int main(){
    int N;
    string S;

    cin >> N;
    cin >> S;

    bool flag=false;
    int len = (int) N/2;

    unordered_map<string, int> mp;
    for(int i=0; i<N; i++){
        string now = S.substr(i,1);
        mp[now] += 1;
        //cout << "now mp[now] " << now << " " << mp[now] << endl;
        if( mp[now] >= 2 ){
            flag = true;
        }
    }

    if(!flag){
        cout << 0 << endl;
        return 0;
    }

    flag = false;
    mp.clear();
    unordered_map<string, int> first;
    for(int i=0; i<N-len+1; i++){

        string now = S.substr(i,len);
        mp[now]+=1;
        //cout << "now mp[now] " << now << " " << mp[now] << endl;
        if(mp[now] == 1){
            first[now] = i;
        }
        if( mp[now] >= 2 && first[now] + len -1 < i ){
            flag = true;
        }
    }    

    if(flag){
        cout << len << endl;
        return 0;
    }

    int linf=0, lsup=len;

    while( linf <= lsup ){
        len = (int) ( (linf + lsup)/2 );

        flag = false;
        mp.clear();
        first.clear();

        for(int i=0; i<N-len+1; i++){

            string now = S.substr(i,len);
            mp[now]+=1;
            if(mp[now] == 1){
                first[now] = i;
            }
            if( mp[now] >= 2 && first[now] + len - 1 < i ){
                flag = true;
            }
        }

        if(flag){
            linf = len + 1;
        }else{
            lsup = len - 1;
        }
        if( linf > lsup && !flag ){
            len--;
        }
        //cout << "linf len lsup " << linf << " " << len << " " << lsup << endl;
    }

    cout << len << endl;

    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll e[n],o[n],k=0,l=0;
  for(ll i=0;i<n;i++) {
    if(i%2==0){
      cin >>e[k];
      k++;
    }
    else{
      cin >>o[l];
      l++;
    }
  }
  vector <pair<ll,ll>> ee,oo;
  k=n/2;
  sort(e,e+k);ll c=1;
  for(ll i=0;i<k;i++){//配列の中身がそれぞれ何個あるかのカウント
    if(e[i]==e[i+1]){
      c++;
      if(i==k-2){//122333みたいなときは3のところがansに入らないので
        ee.push_back(make_pair(c,e[i]));
        break;
      }
    }
    else{
      ee.push_back(make_pair(c,e[i]));
      if(i==k-2) {
          ee.push_back(make_pair(1,e[i+1]));//112223とかのときにansに3の分を足すため
          break;
      }
      c=1;
    }
  }
  sort(o,o+k); c=1;
  for(ll i=0;i<k;i++){//配列の中身がそれぞれ何個あるかのカウント
    if(o[i]==o[i+1]){
      c++;
      if(i==k-2){//122333みたいなときは3のところがansに入らないので
        oo.push_back(make_pair(c,o[i]));
        break;
      }
    }
    else{
      oo.push_back(make_pair(c,o[i]));
      if(i==k-2) {
          oo.push_back(make_pair(1,o[i+1]));//112223とかのときにansに3の分を足すため
          break;
      }
      c=1;
    }
  }
  sort(ee.begin(),ee.end());
  sort(oo.begin(),oo.end());
  ll es=ee.size();ll os=oo.size();
  if(es==1&&os==1){
    if(ee[0].second==oo[0].second){
      cout <<k<<endl;
      return 0;
    }
    else{
      cout <<0<<endl;
      return 0;
    }
  }
    if(ee[es-1].second!=oo[os-1].second){
      cout <<(k-ee[es-1].first)+(k-oo[os-1].first)<<endl;
      return 0;
    }
    else{
      if(es==1){
        cout <<(k-ee[es-1].first)+(k-oo[os-2].first)<<endl;
        return 0;
      }
      if(os==1){
        cout <<(k-ee[es-2].first)+(k-oo[os-1].first)<<endl;
        return 0;
      }
       ll p=(k-ee[es-1].first)+(k-oo[os-2].first);
       ll q=(k-ee[es-2].first)+(k-oo[os-1].first);
       cout <<min(p,q)<<endl;
    }
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using iii = tuple<int, int, int>;
struct UF
{
    vi r, p;
    UF(int n) : r(n, 0), p(n, 0)
    {
        iota(p.begin(), p.end(), 0);
    }
	
    int f(int x)
    {
        return (p[x] == x ? x : p[x] = f(p[x]));
    }
	
    void u(int i, int j)
    {
        int x = f(i), y = f(j);
        if (x == y)
            return;

        if (r[x] >= r[y])
        {
            p[y] = x;
            if (r[x] == r[y])
                r[x]++;
        }
        else
            p[x] = y;
    }

    bool s(int i, int j)
    {
        return f(i) == f(j);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<iii> v;
    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        v.emplace_back(x, y, i);
    }
    sort(all(v));
    vector<iii> e;
    for (int i = 1; i < n; ++i)
        e.emplace_back(get<0>(v[i]) - get<0>(v[i-1]), get<2>(v[i]), get<2>(v[i - 1]));
    sort(all(v), [](iii& a, iii& b){return get<1>(a)<get<1>(b);});
    for (int i = 1; i < n; ++i)
        e.emplace_back(get<1>(v[i]) - get<1>(v[i-1]), get<2>(v[i]), get<2>(v[i - 1]));
    sort(all(e));
    UF uf(n);
    ll sol = 0;
    for (auto k : e)
    {
        int a,b,c;
        tie(a,b,c)=k;
        if (!uf.s(b,c))
            uf.u(b,c), sol +=a;
    }
    cout << sol;
}


Measured memory_bytes: 6004
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int h, a;
	cin >> h >> a;
	cout << h / a + (h % a > 0);
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
Shop = "ABCDE"
N = Shop.length

until (data = [gets.chomp]) == ["0 0"]
  data.concat((N - 1).times.map {gets})
  result = data.map.with_index {|d, i| [d.split.map(&:to_i).sum, i]}.sort.last
  puts "#{Shop[result[1]]} #{result[0]}"
end


Measured memory_bytes: 6896
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

const int MAX_CARD_NUM = 52;

struct Card {
  char suit;
  int number;
};

std::map<char, int> suit_map = {
    {'S', 0},
    {'H', 1},
    {'C', 2},
    {'D', 3},
};

bool operator<(const Card &left, const Card &right)
{
  if (left.suit == right.suit) return left.number < right.number;

  return suit_map[left.suit] < suit_map[right.suit];
}

int main()
{
  int card_num;
  std::vector<Card> deck;

  std::cin >> card_num;
  deck.resize(card_num);
  for (int i = 0; i < card_num; i++) {
    std::cin >> deck[i].suit;
    std::cin >> deck[i].number;
  }

  std::sort(deck.begin(), deck.end());

  int deck_index = 0;

  for (auto &&suit : std::vector<char>{'S', 'H', 'C', 'D'}) {
    for (int i = 1; i <= 13; i++) {
      if (suit == deck[deck_index].suit && i == deck[deck_index].number) {
        deck_index++;
      }
      else {
        std::cout << suit << " " << i << std::endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3060
#include <stdio.h>
int main( ){
  int c1,c5,c10,c50,c100,c500;
  
  scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);

  if(c1*1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000)
    puts("1");
  else
    puts("0");

return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

template<class T>
struct dynamic_slide_min {
  const i64 k;
  deque<pair<i64, T>> que;
  i64 i;
  dynamic_slide_min(const i64 k): k(k), i(0) {}
  T next(T x) {
    while(!que.empty() && que.back().second >= x) que.pop_back();
    que.push_back({i, x});
    i64 min_i = que.front().second;
    i++;
    if(i == que.front().first + k) {
      que.pop_front();
    }
    return min_i;
  }
};

int main() {
  std::cin.tie(nullptr);
  i64 n, l;
  cin >> n >> l;
  dynamic_slide_min<i64> slide(l);
  for(int i = 0;i < n;i++) {
    i64 a;
    cin >> a;
    i64 res = slide.next(a);
    if(i >= l - 1) {
      cout << res << " \n"[i + 1 == n];
    }
  }
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> Type;

int main(){
    ll n,tm=0;
    cin>>n;
    priority_queue<Type,vector<Type>,greater<Type>> que;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        que.push(make_pair(b,a));
    }
    while(!que.empty()){
        Type p=que.top();
        tm+=p.second;
        if(tm>p.first){
            cout<<"No";
            return 0;
        }
        que.pop();

    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 2420
void main() {
  problem();
}

void problem() {
  enum CONTESTS = 26;
  const days = scan!int;
  const dec = scan!long(CONTESTS);
  const inc = days.iota.map!(x => scan!long(CONTESTS)).array;

  long calcSatisfactionValue(long[] contests) {
    auto desat = new long[CONTESTS];
    long sat;

    foreach(i, c; contests) {
      sat += inc[i][c];
      foreach(o; 0..CONTESTS) {
        desat[o] = c == o ? 0 : desat[o] + dec[o];
        sat -= desat[o];
      }
    }

    return sat;
  }

  long[] solve() {
    auto desat = new long[CONTESTS];
    auto value = new long[CONTESTS];
    const potential = CONTESTS.iota.map!(c => inc.map!(i => i[c]).sum).array;
    deb(potential);

    long decideNextContest(long day, const long[] inc, long[] dec) {
      long contestCanditate;
      long score = long.min;
      const sumDec = dec.sum;

      foreach(c; 0..CONTESTS) {
        long testScore = inc[c] + dec[c] - sumDec;
        if (score < testScore) {
          contestCanditate = c;
          score = testScore;
        }
      }
      return contestCanditate;
    }

    long[] ans;
    foreach(i; 0..days) {
      auto c = decideNextContest(i, inc[i], desat);
      ans ~= c;

      value[c] += inc[i][c];

      foreach(o; 0..CONTESTS) {
        desat[o] = c == o ? 0 : desat[o] + dec[o];
        value[o] -= desat[o];
      }
    }

    value.deb;
    long[] necks;
    foreach(_; 0..CONTESTS) {
      const worstIndex = value.minIndex;
      necks ~= worstIndex;
      value[worstIndex] = long.max;
    }
    necks.deb;

    foreach(n; necks[0..CONTESTS]) {
      auto newAns = ans.dup;
      long maxTry = 0;
      long maxValue = calcSatisfactionValue(ans);
      foreach(i; days/5..days*4/5) {
        const origin = newAns[i];
        newAns[i] = n;
        
        const v = calcSatisfactionValue(newAns);
        if (v > maxValue) {
          maxValue = v;
          maxTry = i;
        }

        newAns[i] = origin;
      }

      if (maxTry != 0) ans[maxTry] = n;
    }

    calcSatisfactionValue(ans).deb;
    return ans;
  }

  const r = solve();
  r.each!(c => writeln(c + 1));
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 3960
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 200005;

int64 a[MAXN];

void run() {
    int n;
    cin >> n;
    int x;
    if(n<=599) x = 8;
    else if(n<=799) x = 7;
    else if(n<=999) x = 6;
    else if(n<=1199) x = 5;
    else if(n<=1399) x = 4;
    else if(n<=1599) x = 3;
    else if(n<=1799) x = 2;
    else x = 1;
    cout << x << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
const ll mod = 1e9+7;

int n,m;

int a[maxn], b[maxn], c[maxn];
multiset<int> sa, sb, sc;
multiset<int>::iterator it;

int main()
{
    int A, B, C;
    cin >> n >> m >> A >> B >> C;
    for(int i=0;i<A;i++){
        int x;
        cin >> x;
        sa.insert(x);
    }
    for(int i=0;i<B;i++){
        int x;
        cin >> x;
        sb.insert(x);
    }
    for(int i=0;i<C;i++){
        int x;
        cin >> x;
        sc.insert(x);
    }
    while(sa.size() > n){
        sa.erase(sa.begin());
    }
    while(sb.size() > m){
        sb.erase(sb.begin());
    }
    while(sc.size() > 0){
        it = sc.end();
        it--;
        int x = int(*it);
        if(x <= *sa.begin() && x <= *sb.begin())break;
        if(x > *sa.begin() && x > *sb.begin()){
            if(*sa.begin() < *sb.begin()){
                sa.erase(sa.begin());
                sa.insert(x);
            }
            else{
                sb.erase(sb.begin());
                sb.insert(x);
            }
        }
        else if(x > *sa.begin()){
            sa.erase(sa.begin());
            sa.insert(x);
        }
        else if(x > *sb.begin()){
            sb.erase(sb.begin());
            sb.insert(x);
        }
        else{
            assert(1 == 2);
        }
        sc.erase(it);
    }
    /*
    for(int x : sa)cout << x << ' '; cout << '\n';
    for(int x : sb)cout << x << ' '; cout << '\n';*/
    ll ans = 0;
    for(int x : sa)ans += x;
    for(int x : sb)ans += x;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 14336