akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
#from functools import lru_cached
from heapq import heappop,heappush
import time
import os
import sys
import datetime
readline=readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#main
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
else:
    gu=((H+1)//2)*((W+1)//2)
    ki=(H//2)*(W//2)
    print(gu+ki)

Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[0]=='S') cout<<"Cloudy"<<endl;
  else if(s[0]=='C') cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n, k;
	long long int ans=0;
	cin>>n>>k;
	vector<int>h(n);
	for(int i=0;i<n;++i){
		cin>>h[i];
	}
	sort(h.begin(),h.end());
	if(n > k){
		for(int i=n-k-1;i>=0;--i){
			ans += h[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll ans=0,num1=0,num2=0;
    string s;
    cin >> s;
    ll size = s.size();
    sort(all(s));
    rep(i,size){
        if(s[i]=='0') num1++;
        else num2++;
    }
    ans = min(num1,num2);
    ans *= 2;
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
int n;
string s;
map < string, bool > m;
int main(){
    cin >> n;
    cin >> s;
    string s2;
    for(int i = 0; i < n / 2; i++){
        s2 += s[i];
    }
    s2 += s2;
    if(s2 == s){
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
class Dice:
    def __init__(self, label):
        self.label = label
    
    def rotateS(self):
        """[1, 2, 6, 5] -> [5, 1, 2, 6]"""
        t = self.label[1]
        self.label[1] = self.label[5]
        self.label[5] = self.label[6]
        self.label[6] = self.label[2]
        self.label[2] = t

    def rotateN(self):
        t = self.label[1]
        self.label[1] = self.label[2]
        self.label[2] = self.label[6]
        self.label[6] = self.label[5]
        self.label[5] = t
    
    def rotateW(self):
        t = self.label[1]
        self.label[1] = self.label[3]
        self.label[3] = self.label[6]
        self.label[6] = self.label[4]
        self.label[4] = t
    
    def rotateE(self):
        t = self.label[1]
        self.label[1] = self.label[4]
        self.label[4] = self.label[6]
        self.label[6] = self.label[3]
        self.label[3] = t

label = []
label.append(None)
label[1:] = map(int,input().split())
dice = Dice(label)
#print(dice.label)

cmd = input()
for _ in cmd:
    if (_ == 'S'):
        dice.rotateS()
    elif (_ == 'N'):
        dice.rotateN()
    elif (_ == 'W'):
        dice.rotateW()
    elif (_ == 'E'):
        dice.rotateE()
print(dice.label[1])



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
string s;
int n,k,i,ans;
int main()
{
    cin>>n>>s;
    for(i=0;i<n;i++)
     {
        if(s[i]=='I') k++;
        else k--;
        ans=max(ans,k);
     }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) {
        mp[a[i]]++;
    }
    vector<int> x;
    for (auto m: mp) {
        x.push_back(m.second);
    }
    sort(x.begin(), x.end());
    vector<int> sum;
    sum.push_back(0);
    rep(i, x.size()) {
        sum.push_back(sum.back() + x[i]);
    }
    for(int i=1; i<=n; i++) {
        ll l = 0;
        ll r = n+1;
        while (r-l>1) {
            ll now = (l+r)/2;
            auto it = upper_bound(x.begin(), x.end(), now);
            int v = it - x.begin();
            ll s = sum[v] + now*(x.end()-it);
            if (s>=i*now) l = now;
            else r = now;
        }
        cout << l << endl;
    }
    
    return 0;
}


Measured memory_bytes: 19184
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    int b = 1;
    while (2 * b <= n) b *= 2;
    if (n < 3 || b == n){
        cout << "No" << endl;
        return 0;
    }

    int m = n;
    while (m % 4 != 3) m--;

    vector<P> ans;
    FOR(x,1,m-1) ans.emplace_back(x, x + 1);
    ans.emplace_back(m, n + 1);
    FOR(x,1,m-1) ans.emplace_back(x + n, x + n + 1);

    if (n % 4 == 1){
        ans.emplace_back(n - 1, n);
        ans.emplace_back(n, 1);
        ans.emplace_back(1, n + (n - 1));
        ans.emplace_back(n + (n - 1), n + n);
    }else if (n % 4 == 2){
        ans.emplace_back(n - 2, n - 1);
        ans.emplace_back(n - 1, 1);
        ans.emplace_back(1, n + (n - 2));
        ans.emplace_back(n + (n - 2), n + n - 1);
        ans.emplace_back(n, n - 1);
        ans.emplace_back(2, 2 * n);
    }else if (n % 4 == 0){
        int x = n - b + 1;
        ans.emplace_back(x, n);
        ans.emplace_back(b, 2 * n);
    }

    cout << "Yes" << endl;
    for (P p : ans) printf("%d %d\n", p.first, p.second);
    return 0;
}


Measured memory_bytes: 4464
n,a,b,c,d=map(int,input().split())
s=list(input())
f=0
for i in range(b,d-1):
  if s[i]=='#' and s[i+1]=='#':
    f=1
    break
for i in range(a,c-1):
  if s[i]=='#' and s[i+1]=='#':
    f=1
    break
if c>d:
  F=0
  for i in range(b-2,d-1):
    if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
      F=1
      break
  if F==0:
    f=1
if f==1:print('No')
else:print('Yes')

Measured memory_bytes: 4916
#include <iostream>
#include <algorithm>

using namespace std;

int check(string s, string t);

int main()
{
	int n;
	cin >> n;
	int mx = 1;
	int t;
	for (int i = 2; i <= n; i++) {
		t = i * i;
		while (t <= n) {
			mx = max(mx, t);
			t *= i;
		}
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 768
n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.chomp.split(" ").map(&:to_i)
end
b = a.sort.reverse
n.times do |i|
  if a[i] == b[0]
    puts b[1]
  else
    puts b[0]
  end
end

Measured memory_bytes: 20712
using System;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = input[0], K = input[1], Q = input[2];
        var A = new int[N];
        for (int i = 0; i<Q; i++) {
            var ai = int.Parse(Console.ReadLine());
            A[ai - 1]++;
        }
        var sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
            sb.Append(A[i] + K - Q > 0 ? "Yes" : "No").AppendLine();
        }
        return sb.ToString();
    }
}

Measured memory_bytes: 32252
ans = 0
while True:
    n,x = map(int,input().split())
    if (not n) and (not x):break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if i == j:continue
            a = i
            b = j
            c = x - i - j
            
            if  c > b and c <=n:
                ans +=1                
    print(ans)
    ans = 0
            
    


Measured memory_bytes: 5592
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	int ans = 1000000000;
	cin >> S;
	for (int i = 0; i < 26; i++) {
		char C = i + 'a';
		int count = 0, ansC = 0;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] != C) {
				count++;
			}
			else {
				ansC = max(ansC, count);
				count = 0;
			}
		}
		ansC = max(ansC, count);
		ans = min(ans, ansC);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second

map<ll,ll> dp;
void INSERT(ll x,ll k){
	if(dp.size() == 0){
		dp.insert(P(x,k));
		return;
	}
	auto itr = dp.lower_bound(x);
	while(itr != dp.end()){
		if(itr->sc+abs(x-itr->fr) <= k)return;
		if(itr->sc >= k+abs(x-itr->fr))dp.erase(itr++);
		else break;
	}
	itr = dp.lower_bound(x);
	if(itr != dp.begin()){
		itr --;
		while(1){
			if(itr->sc+abs(x-itr->fr) <= k)return;
			if(itr->sc >= k+abs(x-itr->fr)){
				if(itr == dp.begin()){
					dp.erase(itr);
					break;
				}
				else dp.erase(itr--);
			}
			else break;
		}
	}
	dp.insert(P(x,k));
}

int main(){
	static ll n,q,a,b;
	static ll x[200010];
	scanf("%lld%lld%lld%lld",&n,&q,&a,&b);
	for(int i = 1 ; i <= q ; i ++){
		scanf("%lld",&x[i]);
	}
	
	ll ret = 0;
	INSERT(a,abs(b-x[1]));
	INSERT(b,abs(a-x[1]));
	for(int i = 2 ; i <= q ; i ++){
		ll r = abs(x[i]-x[i-1]);
		ret += r;
		auto itr = dp.lower_bound(x[i]);
		ll s = 1000000000000000000;
		if(itr != dp.end()){
			s = itr->sc + abs(itr->fr-x[i]);
		}
		if(itr != dp.begin()){
			itr --;
			s = min( s , itr->sc + abs(itr->fr-x[i]) );
		}
		//cout << x[i-1] << " " << s-r << endl;
		INSERT(x[i-1],s-r);
		
		/*cout << "i=" << i << endl;
		for(auto x: dp){
			cout << x.fr << " " << x.sc << endl;
		}
		puts("===============");*/
	}
	ll r = 1000000000000000000;
	for(auto x: dp){
		r = min( r , x.sc );
	}
	cout << ret+r << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int card[52];
    char s;
    int k, x;
    for(int i = 0; i < 52; i ++){
        card[i] = 0;
    }
    for(int i = 0; i < n; i ++){
        cin >> s >> x;
        switch(s){
            case 'S':
                k = 0;
                break;
            case 'H':
                k = 1;
                break;
            case 'C':
                k = 2;
                break;
            case 'D':
                k = 3;
                break;
            default:
                k = 0;
                break;
        }
        card[x + k * 13 - 1] = 1;
    }
    for(int i = 0; i < 52; i ++){
        if (card[i] == 0){
            k = i / 13;
            switch(k){
                case 0:
                    s = 'S';
                    break;
                case 1:
                    s = 'H';
                    break;
                case 2:
                    s = 'C';
                    break;
                case 3:
                    s = 'D';
                    break;
                default:
                    break;
            }
            printf("%c %d\n", s, i % 13 + 1);
        }
    }
    return 0;
}



Measured memory_bytes: 3208
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const int inf = (1 << 30);
const int MOD = 1000000007;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    ll x; cin >> x; ll a = 100,c = 0;
    while (x > a) {
        a += (a / 100); c++;
    }cout << c << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;

    // 「1 の個数」「0 の個数」を交互に記録していく
    vector<int> nums;    
    if (S[0] == '0') nums.push_back(0); // 先頭が 0 だったら
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0); // 最後尾が 0 だったら

    // 累積和
    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    // 偶数番目の添字から始まる、長さ 2K+1 (以下) の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}






















Measured memory_bytes: 1272
/**
 * Prints multiplication tables
 */
function main() {

  var lines = [];

  for (var a = 1; a <= 9; a++) {
    for (var b = 1; b <= 9; b++) {
      lines.push(template(a, b));
    }
  }

  for (var i = 0; i < lines.length; i++) {
    console.log(lines[i]);
  }

}

function template(a, b) {
  return a + 'x' + b + '=' + (a * b);
}

main();

Measured memory_bytes: 15548
N = gets.chop.to_i
A = gets.chop.split.map(&:to_i)


ans = []


ans[0] = 0

N.times do |i|
  if i % 2 == 0
    ans[0] += A[i]
  else
    ans[0] -= A[i]
  end
end

N.times do |i|
  next if i == 0
  ans[i] =  2*A[i-1] - ans[i-1]
end

puts ans

Measured memory_bytes: 14156
L, R = map(int, input().split())

mods = []

for num in range(2019):
	i = num + L
	if i > R:
		break
	mods.append(i%2019)

result = []

for i, num1 in enumerate(mods):
	for j, num2 in enumerate(mods):
		if i == j:
			continue
		result.append(num1*num2%2019)

result.sort()
print(result[0])

Measured memory_bytes: 131756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int main() {
	fastio; string s; cin >> s;
  cout << s << (s[s.length()-1] == 's' ? "es" : "s");
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0062
{
	class Program
	{
		static void Main(string[] args)
		{
			var	s	= "";
			while( (s = Console.ReadLine()) != null ) {
				var	n	= new int[ 10 ];
				for( int i = 0; i < 10; i++ ) {
					n[ i ]	= s[ i ] - '0';
				}
				for( int i = 10 - 1; i > 0; i-- ) {
					for( int j = 0; j < i; j++ ) {
						n[ j ]	= (n[ j ] + n[ j + 1 ]) % 10;
					}
				}
				Console.WriteLine( n[ 0 ] );
			}
		}
	}
}

Measured memory_bytes: 5512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 1e5+5;
int candy[MAX_N];
int N, K;

void solve()
{
    if(N==1){
        cout << abs(candy[0]) << endl;
        return;
    }
	deque<int> que;
	int idx = 0;
	ll ans = LINF;
	while(true){
		while(que.size() < K && idx < N){
			que.push_back(idx);
			idx++;
		}
		if(idx == N && que.size() < K) break;
		if(que.size()==K){
		    ans = min(ans, (ll)(min(abs(candy[que.front()]), abs(candy[que.back()])) + abs(candy[que.front()] - candy[que.back()])));
		    que.pop_front();
		}
	}
	cout << ans << endl;
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;++i){
		cin >> candy[i];
	}
	solve();
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int h[100010] = {};

    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    int ans = 0;
    for (int i = 0; i < n - 1; )
    {
        int tmp = 0;
        if (h[i+1] > h[i]) i++;
        while (h[i+1] <= h[i] && i < n-1)
        {
            tmp++;
            i++;
        }
        ans = max(ans, tmp);
        
    }
    
    cout << ans << "\n";

}


Measured memory_bytes: 640
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def era(n):
    ret = [1 for i in range(n + 2)]
    for i in range(2, int(math.sqrt(n) +3)):
        if ret[i] != 0:
            for j in range(2, n//i + 1):
                ret[i * j] = 0
    rret = []
    for i, r in enumerate(ret):
        if r == 1 and i != 0:
            rret.append(i)

    return rret


def houjyo(n, m, k, kaijyo):
    # kaburi ... k
    # all ... n
    if k == n:
        return 1
    else:
        # kasanarierabi nck * nokorierabi (m - k)p(n-k) - houjyo(+1)
        ret = nck(n,k,kaijyo) * npk(m-k, n-k, kaijyo) # - (k + 1) * houjyo(n, m, k+1, kaijyo)
        # print(nck(n,k,kaijyo) , npk(m-k, n-k, kaijyo))
        return ret % MOD


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n = getN()
    ans = [0 for i in range(10001)]
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                if x * x + y * y + z * z + x * y + y * z + z * x <= n:
                    ans[x * x + y * y + z * z + x * y + y * z + z * x] += 1

    for i, an in enumerate(ans):
        if i >= 1 and i <= n:
            print(an)




def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 69708
#include<iostream>
#define l int64_t
#define c continue;
#define o(a) cout<<a<<endl;
#define r(i,x,y) for(l i=x;i<y;i++){
using namespace std;
int main(){l m=1e9+7,x,y,z,w,o,p,q,v[93],t[91][91][2],a,b;v[0]=1,v[1]=1;r(i,2,93)v[i]=v[i-1]+v[i-2];}r(i,2,91)r(j,1,i)a=v[i],b=v[i+1];if(j<2){t[i][0][0]=a,t[i][0][1]=b,t[i][j][0]=b,t[i][j][1]=2*b-a;c;}t[i][j][0]=t[i-1][j-1][1],t[i][j][1]=t[i-1][j-1][1]+t[i-1][j-1][0];}}cin>>q;while(q--){cin>>x>>y;if(x>y)swap(x,y);if(y<2){o("1 1")c}r(i,0,93)if(v[i]>x||v[i+1]>y){z=i-1;break;}}o(z)if(z<2){o(x*y%m)c}w=0;r(j,0,z)o=t[z][j][0],p=t[z][j][1];if(o>x||p>y)c w+=(y-p)/o+1;if(x>=p)w+=(x-p)/o+1;}o(w%m)}}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N, M, ans = 0, score = 0 ;
  cin >> N >> M ;
  for(int i=1;i<=((M+1)/2);i++){
    cout << i << " " << (M+2)-i << endl ;
  }
  for(int i=1;i<=(M/2);i++){
    cout << (M+1) +i << " " << (2*M+2)-i << endl ;
  }
  return 0 ;
}  

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int n, d[3003][3003], mod = 1000000007;
string s;
int main() {
    cin >> n >> s;
    for (int i = 1; i <= n; i++) d[1][i] = 1;
    for (int i = 2; i <= n; i++)
        if (s[i - 2] == '<')
            for (int j = 1; j <= n - i + 1; j++)
                d[i][j] = (d[i][j - 1] + d[i - 1][j]) % mod;
        else
            for (int j = n - i + 1; j; j--)
                d[i][j] = (d[i][j + 1] + d[i - 1][j + 1]) % mod;
    cout << d[n][1] << '\n';
}


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

int main() {
    string s;
    cin >>s;
    if(s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
    "strconv"
)

func palind(a int) bool {
    s := strconv.Itoa(a)
    if s[0]==s[4] && s[1]==s[3]{
        return true
    }
    return false
}

func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := 0
    for i := a ; i <= b ; i++ {
        if palind(i) {
            ans++
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int n;
ll g[305][305], h[305][305];

int main() {
    cin >> n;
    rep(i, n) rep(j, n) cin >> g[i][j];
    rep(i, n) rep(j, n) h[i][j] = g[i][j];

    rep(k, n) rep(i, n) rep(j, n) {
        if (chmin(g[i][j], g[i][k] + g[k][j])) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    // g[i][j] を残すか？
    rep(i, n) rep(j, n) {
        if (i >= j) continue;
        bool ok = true;
        rep(k, n) {
            if (i == k || j == k) continue;
            if (g[i][j] >= g[i][k] + g[k][j]) ok = false;
        }
        if (ok) ans += g[i][j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1e9+7
#define inf 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec));
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define P pair<int,int>
#define prique priority_queue<P,vector<P>,greater<P>>
struct edge{ int to,cost;};
using namespace std;
int n,q,k;
vector<edge>g[114514];
int d[114514];
void dijkstra(int s) {
	prique que;
	rep(i,n) d[i]=inf;
	d[s]=0;
	que.push(P(0,s));
	while(que.size()) {
		P p=que.top(); que.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		rep(i,(int)g[v].size()) {
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost) {
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
signed main() {
	scanf("%lld",&n);
	rep(i,n-1) {
		int a,b,c;
		scanf("%lld %lld %lld",&a,&b,&c);
		a--;
		b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	scanf("%lld %lld",&q,&k);
	k--;
	dijkstra(k);
	rep(i,q) {
		int x,y;
		scanf("%lld %lld",&x,&y);
		x--;
		y--;
		cout<<d[x]+d[y]<<endl;
	}
}


Measured memory_bytes: 12032
n,m,c=map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n)]

ans = 0 
for row in A:
    t = c    
    for a,b in zip(row,B):
        t += a*b
    if t > 0 :
        ans += 1
print(ans)


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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

struct UnionFind{
    vector<long long int> par; //par[i] : iの親の番号
    vector<long long int> rnk; //root[i] : iの木のランク

    //コンストラクタ
    UnionFind(long long int n): par(n), rnk(n){
        //木の初期化
        for(long long int i = 0; i < n; i++){
            par[i] = i;
            rnk[i] = 1;
        }
    }

    //データxが属する木の根を再帰で取得
    long long int root(long long int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    //xとyが同じ木に属しているかを判定
    bool same(long long int x, long long int y){
        return root(x) == root(y);
    }

    //xとyの木を併合
    void unite(long long int x, long long int y){
        long long int rx = root(x); //xの根
        long long int ry = root(y); //yの根
        if(rx == ry) return; //根が同じならそのまま

        if(rnk[rx] < rnk[ry]){
            par[rx] = ry;
        }else{
            par[ry] =rx;
            if(rnk[rx] == rnk[ry]) rnk[rx]++;
        }
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(n);

    int i;
    for(i = 0; i < n; i++){
        cin >> p[i];
    }

    UnionFind uf(n);

    int x, y;
    for(i = 0; i < m; i++){
        cin >> x >> y;
        uf.unite(x-1, y-1);
    }

    int count = 0;
    for(i = 0; i < n; i++){
        if(uf.same(i, p[i]-1)){
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;

int main() {
    int n;
    int a[1000];

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

    sort(a, a+n);

    cout << a[n-1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
T[20][20],X,Y,x,y,p,q,i,c;
#define t T[y][x]
void R(x,y){(0<=x&&x<X&&0<=y&&y<Y&&!t)?t=1,i++,R(x-1,y),R(x+1,y),R(x,y-1),R(x,y+1):0;}
main(){for(;scanf("%d%d",&X,&Y),X;i=0,R(p,q),printf("%d\n",i))
	for(i=0;i<X*Y;i++){
		for(x=i%X,y=i/X;(c=getchar())=='\n';);
		switch(c){
			case'@':p=x;q=y;
			case'.':t=0;break;
			case'#':t=1;
		}
	}
exit(0);}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    i64 a,b;
    cin>>a>>b;
    if( (a+b) % 2 ){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    cout<<(a+b)/2<<endl;

    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

ll h, cur = 1, ans;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("threesum.in", "r", stdin);
	//freopen("threesum.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> h;
	while (h > 0)
	{
		ans += cur;
		cur <<= 1;
		h >>= 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
mod=998244353

N=int(input())
L=[0 for i in range(N)]
D=list(map(int,input().split()))
#print(D)
if D[0]!=0:
    print(0)
    exit()
for i in range(N):
    L[D[i]]+=1
#print(L)

if L[0]!=1:
    print(0)
    exit()

ans=1
cnt=1
for i in range(1,N):
    ans*=pow(L[i-1],L[i],mod)
    cnt+=L[i]
    #print(ans,cnt)
    if cnt==N:
        break
print(ans%mod)


Measured memory_bytes: 57968
#include <bits/stdc++.h>
using namespace std;


int main() {
  //とりま入力
  int N, K;
  cin >> N >> K;
  
  vector<long long> h(N);
  for (int i=0; i<N; i++) {
    cin >> h[i];
  }
  
  sort(h.begin(), h.end());
  
  long long ans = 10000000000;
  for (int i=0; i<N-K+1; i++) {
    ans = min(ans, h[i+K-1] - h[i]);
  }
  
  cout << ans << endl;
 
}



Measured memory_bytes: 1024
mod=10**9+7
n,m=map(int,input().split())
A=[int(input()) for _ in range(m)]
A=list(set(A))
A.sort()
DP=[0]*(n+1)
DP[0]=1
if A:
    j=0
    if A[0]!=1:
        DP[1]=1
    else:
        if j<len(A)-1:
            j+=1
    for i in range(2,n+1):
        if i==A[j]:
            if j<len(A)-1:
                j+=1
        else:
            DP[i]=DP[i-1]+DP[i-2]
            DP[i]%=mod
    print(DP[-1])
else:
    DP[1]=1
    for i in range(2,n+1):
        DP[i]=DP[i-1]+DP[i-2]
        DP[i]%=mod
    print(DP[-1])

Measured memory_bytes: 58200
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

void fin() {
	out(-1);
	exit(EXIT_SUCCESS);
}

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	cin >> a;
	int S = a[0] + a[1];
	int X = accumulate(a.begin() + 2, a.end(), 0ll, [](int a, int b){return a ^ b;});
	if(S - X < 0 || (S - X) % 2) fin();
	int D = (S - X) / 2;
	if(D > a[0] || (D & X)) fin();
	int ans = 0; 
	RREP(i, 55) {
		if(!(X & (1ll << i))) continue;
		int tmp = ans ^ (1ll << i);
		if((tmp ^ D) <= a[0]) ans = tmp;
	}
	ans += D;
	if(ans == 0) fin();
	out(a[0] - ans);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string N;
  cin >> N;
  for (ll i = 0; i < 3; i++)
  {
    cout << ((N.at(i) == '1') ? '9' : '1');
  }
  cout << endl;
}

Measured memory_bytes: 256
N = int(input())

def find_divisors(N):
    divisors = []
    for A in range(1, int(N**0.5) + 1):
        if N % A == 0:
            divisors.append(A)
#            B = N//A
#            if A != B:
#                divisors.append(B)
    divisors.sort()
    return divisors

divisors_of_N = find_divisors(N)

# total number of steps to reach a point (A,B) is equal to (A-1)+(B-1) = A+B-2
num_steps = N+1
for A in divisors_of_N:
    B = N//A
    num_steps = min(num_steps, A+B)

print(num_steps - 2)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

void DebugPrint(double a[], int n)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, n); ++i) {
		cout << a[i] << ",";
	}
	cout << endl;
#endif
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	int n, k;
	cin >> n >> k;

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

	vector<bool> dp(k + 1);

	for (int i = 0; i <= k; ++i) {
		bool win = false;
		for (int j = 0; j < n; ++j) {
			if (a[j] <= i) {
				if (dp[i - a[j]] == false) {
					win = true;
					break;
				}
			}
		}
		dp[i] = win;
		/*if (dp[i]) {
			cout << i << " : "<< "win" << endl;
		}
		else {
			cout << i << " : "<< "lost" << endl;
		}*/
	}

	if (dp[k]) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }




signed main() {

	int W, H, x, y;
	cin >> W >> H >> x >> y;

	if (x*2 == W && y*2 == H) {
		cout << (double)H * W / 2 << " " << "1" << endl;
	}
	else
		cout << (double)H * W / 2 << " " << "0" << endl;


	return 0;
}

Measured memory_bytes: 764
import sys

a = list(map(int, input().split()))
X = a[0]
N = a[1]

try:
  p = list(map(int, input().split()))
except EOFError:
  print(X)
  sys.exit()

flg = 0
i = 0
while (flg == 0):
  if (X - i not in p):
    print(X - i)
    flg = 1
    break
  elif (X + i not in p):
    print(X + i)
    flg = 1
    break
  i += 1

Measured memory_bytes: 9204
# coding: utf-8

A, B, K = [int(i) for i in input().split()]

if A - K <= 0:
    K = K - A
    A = 0
    B = B - K
    if B < 0:
        B = 0
    print(A, B)
else:
    A = A - K
    print(A, B)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template




def main():
    N = ii()
    p = lmi()
    t = lmi()
    n = len(p)
    v = [(i, p[i] / t[i]) for i in range(n)]
    v.sort(key=itemgetter(1))
    m = v[0][0]
    # print(v)
    ans = ceil(N / t[m]) * p[m]
    for i in range(4):
        if i != m:
            # print(ceil((N - t[i]) // t[m]))
            ans = min(ans, ceil((N - t[i]) / t[m]) * p[m] + p[i])
            # print(ans)
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 6904
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>

using namespace std;

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

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


int main() {
  int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
int x[2000];
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	a--, b--;
	f(i, n - 1) {
		for (int j = i + 1; j < n; j++) {
			x[min(j - i, min(abs(i - a), abs(i - b)) + min(abs(j - a), abs(j - b)) + 1)]++;
			//cout << i << " " << j << " " << min(j - i, min(abs(i - a), abs(i - b)) + min(abs(j - a), abs(j - b)) + 1) << endl;
		}
	}
	for (int i = 1; i < n; i++)cout << x[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int w,a,b;
    cin >> w >> a >> b;
    
    if(a + w >= b && a <= b){
        cout << 0 << endl;
    }else if(a + w >= b+w && a <= b+w){
        cout << 0 << endl;
    }else if(a+w < b){
        cout << b-(a+w) << endl;
    }else if(a > b+w){
        cout << a - (b+w) << endl;
    }
    
    
    
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000],dp[210000][2];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
int main() {
	cin >> str;
	n = str.size();
	str.push_back('A');
	str.push_back('B');
	dp[1][0] = 1;
	dp[2][1] = 1;
	for (int i = 0; i < n; i++) {
		if (i) {
			if (str[i] == str[i - 1]) {
				dp[i + 2][1] = max( dp[i + 2][1], dp[i][0] + 1);
				dp[i + 1][0] = max({ dp[i + 1][0], dp[i][1] + 1 });
			}
			else {
				dp[i + 2][1] = max(dp[i + 2][1], dp[i][0] + 1);
				dp[i + 1][0] = max({ dp[i + 1][0], dp[i][0] + 1, dp[i][1] + 1 });
			}
		}
		if (i >= 2) {
			if (str[i - 2] == str[i] && str[i - 1] == str[i + 1]) {}
			else {
				dp[i + 2][1] = max(dp[i + 2][1], dp[i][1] + 1);
			}
		}
	}
	cout << max( dp[n][0], dp[n][1] ) << endl;
	return 0;
}


Measured memory_bytes: 4612