akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;
int ans,d[10001],a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(int i=1;i<=a;++i)
    {
        cin>>d[i];
        if(d[i]<b||d[i]>=c)
            ans++;
    }
    cout<<ans;
    puts("");
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

bool isStraight(int xcard[5][2])
{
	if(xcard[0][0]==1&&xcard[1][0]==10&&xcard[2][0]==11&&xcard[3][0]==12&&xcard[4][0]==13)	return true;
	bool b=true;
	for(int i=0;i<4;i++)b&=(xcard[i+1][0]-xcard[i][0]==1);
	return b;
}

int main()
{
	int card[5];
	while(~scanf("%d,%d,%d,%d,%d",card,card+1,card+2,card+3,card+4)){
		int xcard[5][2];	// [0]:cardÌ, [1]:[0]Ì
		for(int i=0;i<5;i++)	xcard[i][0]=xcard[i][1]=0;

		int bucket[14]={0};
		for(int i=0;i<5;i++)	bucket[card[i]]++;
		for(int i=1,j=0;i<14;i++)
			if(bucket[i]>0)
				xcard[j][0]=i,xcard[j][1]=bucket[i],j++;

		if(xcard[0][1]==4 || xcard[1][1]==4){
			cout<<"four card"<<endl;
		}
		else if(xcard[0][1]+xcard[1][1]==5){
			cout<<"full house"<<endl;
		}
		else if(isStraight(xcard)){
			cout<<"straight"<<endl;
		}
		else if(xcard[0][1]==3 || xcard[1][1]==3 || xcard[2][1]==3){
			cout<<"three card"<<endl;
		}
		else{
			int numofpair=0;
			for(int i=0;i<5;i++)	numofpair+=(xcard[i][1]==2);
			switch(numofpair){
				case 2:	cout<<"two pair"<<endl;	break;
				case 1:	cout<<"one pair"<<endl;	break;
				case 0:	cout<<"null"<<endl;		break;
			}
		}
	}

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int n, tscr, hscr;
    string taro, hana;

    cin>>n;
    tscr = 0; hscr = 0;
    rep(i, n) {
        cin>>taro>>hana;
        if (taro > hana) tscr += 3;
        else if (taro < hana) hscr += 3;
        else {
            tscr++; hscr++;
        }
    }
    cout<<tscr<<" "<<hscr<<endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD=998244353;

ll d[1000000];

ll poww(ll a,ll b){
    int res=1;
    for(int i=0;i<b;i++){
        res=(res*a)%MOD;
    }
    return res;
}

int main(){
    ll n; cin >> n;
    ll maxd=0;
    ll dd; cin >> dd;
    ll res=-1;
    if(dd!=0){res=0;}
    d[0]=1;
    for(ll i=1;i<n;i++){
        cin >> dd;
        if(dd==0){res=0;}
        d[dd]++; maxd=max(maxd,dd);
    }
    if(res!=-1){
        cout << res << endl;
        return 0;
    }
    ll ans=1;
    
    for(ll i=1;i<=maxd;i++){
        
        //cout << d[i] << endl;
        ll m=d[i-1];
        ll k=d[i];
        if(k==0){ans=0;break;}
        ans=(ans*poww(m,k))%MOD;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
H=list(map(int,input().split()))
bad=[]
for k in range(M):
  A,B=map(int,input().split())
  if H[A-1]<H[B-1]:
    bad.append(A-1)
  elif H[A-1]==H[B-1]:
    bad.append(A-1)
    bad.append(B-1)
  else:
    bad.append(B-1)
print(N-len(set(bad)))

Measured memory_bytes: 20124
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    long long n;
    cin >> n;
    long long ans = n - 1;
    for(long long i = sqrt(n) + 1; i > 1; i--){
        if(n % i == 0){
            ans = i + n / i - 2;
            break;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    int main(){
        lint n;
        cin>>n;
        lint c[n];
        rep(i,n)cin>>c[i];
        lint mul=modpow(2,n,MOD);
        lint add=modpow(2,n-2,MOD);
        lint x=modpow(2,n-1,MOD);
        sort(c,c+n,greater<lint>());
        lint ans=0;
        rep(i,n){
            lint g=x*mul;
            g%=MOD;
            g*=c[i];
            g%=MOD;
            ans+=g;
            ans%=MOD;
            x+=add;
            x%=MOD;
        }
        cout<<ans<<endl;


    }
      

Measured memory_bytes: 5188
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
N = int(readline())
S = np.empty(N+1,'S1')
S[1:] = np.frombuffer(readline(),dtype='S1')[:N]
Q = int(readline())
query = map(int,readline().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

for K in query:
    x = cumD.copy(); x[K:] -= cumD[:-K]
    x *= isM
    x[K+1:] -= isD[1:-K] * (cumM[K:-1] - cumM[:-K-1])
    print((x.cumsum() * isC).sum())


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

class UnionFind {
public:
    vector<int> Parent;

    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }

    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }

    int size(int A) {
        return -Parent[root(A)];
    }

    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B)
            return false;

        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }


    vector<long long> ans(M);
    ans[M - 1] = (long long)N * (N - 1) / 2;

    UnionFind Uni(N);

    for (int i = M - 1; i >= 1; i--) {
        ans[i - 1] = ans[i];
        if(Uni.root(A[i]) != Uni.root(B[i])) {
            ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
            Uni.connect(A[i], B[i]);
        }
    }
    for (int i = 0; i < M; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
n, k = list(map(int, input().split()))
ans, mod = 0, 10 ** 9 + 7
for i in range(k, n + 2):
    f = i * (i - 1) / 2
    l = (2 * n - i + 1) * i / 2
    ans = (ans + l - f + 1) % mod
print(int(ans))

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, ans = 0; cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    for(lli i=0; i<n-1; i++){
        for(lli j=i+1; j<n; j++){
            lli k = lower_bound(all(l), l[i]+l[j]) - l.begin();
            ans += max(k-(j+1ll), 0ll);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * File              : F-review.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 08.02.2020
 * Last Modified Date: 08.02.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const MAXN = 59;
int constexpr log(int x) {
    return sizeof (int) * 8 - __builtin_clz(x);
}
int const lg = log(MAXN);

vector<vector<int>> par(MAXN, vector<int>(lg));
vector<int> depth(MAXN);

void build(int u, int p, int dep, vector<vector<int>> const & adj) {
    depth[u] = dep;
    par[u][0] = p;
    for (int i = 0; i < lg - 1; i++)
        if (par[u][i])
            par[u][i + 1] = par[par[u][i]][i];
     
    for (auto v: adj[u]) {
        if (v == p) continue;
        build(v, u, dep + 1, adj);
    }
}
int lca(int u, int v) {
    if (depth[u] < depth[v])
        swap(u, v);
    // depth[u] >= depth[v];
    for (int i = lg - 1; i >= 0; --i)
        if (par[u][i] && depth[par[u][i]] >= depth[v])
            u = par[u][i];

    if (u == v)
        return u;
    for (int i = lg - 1; i >= 0; --i)
        if (par[u][i] != par[v][i])
            u = par[u][i], v = par[v][i];
    return par[u][0];
}



int main() {
    int n;
    cin >> n;
    vector<vector<int>> adj(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    build(1, 0, 0, adj);
    int m;
    cin >> m;
    vector<ll> a(m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        ll bit = 0;
        int LCA = lca(u, v);
        for (; u != LCA; u = par[u][0]) bit |= (1LL << (u - 1));
        for (; v != LCA; v = par[v][0]) bit |= (1LL << (v - 1));
        a[i] = bit;
    }
    ll res = 0;
    for (int mask = 0; mask < (1 << m); mask++) {
        ll bit = 0;
        for (int i = 0; i < m; i++) {
            if ((mask >> i) & 1) {
                bit |= a[i];
            }
        }
        ll val = 1LL<<(n - 1 - __builtin_popcountll(bit));
        if (__builtin_popcount(mask)&1) {
            res -= val;
        } else {
            res += val;
        }
    }
    cout << res;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

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

  if (d == 25) {
    cout << "Christmas";
  } else if (d == 24) {
    cout << "Christmas Eve";
  } else if (d == 23) {
    cout << "Christmas Eve Eve";
  } else {
    cout << "Christmas Eve Eve Eve";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int r, c;
    cin >> r >> c;
    int a[26] = {0};
    string x;
    for (int i = 0; i < r; i++) {
        cin>>x;
        for(auto ii : x){
            a[ii - 'a']++;
        }
    }
    int c4 = 0 , cOdd = 0;
    for(int i = 0 ; i< 26 ; i++){
        c4 += a[i] / 4;
        a[i] %= 4;
        if(a[i] % 2 == 1)
            cOdd++;
    }
    if(r % 2 == 0 && c % 2 == 0){
        if(c4 == r * c / 4){
            cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
    }else if(r % 2 == 1 && c % 2 == 1){
        if(c4 >= ((r * c) - r - c + 1) / 4 && cOdd == 1){
            cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
    }else {
        if(r % 2 == 1){
            swap(r , c);
        }
        if(c4 >= ((r * c) - r) / 4 && cOdd == 0){
            cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll a,b,v,u;
  cin>>a>>v>>b>>u;
  ll t;
  cin>>t;
  
  ll d=a-b;
  if(d<0) d*=-1;
  Ans((v-u)*t>=d);
}
  

Measured memory_bytes: 3636
n, t = map(int, input().split())
food = []
for i in range(n):
    food.append(list(map(int, input().split())))
food.sort(key = lambda x:x[0])
b_max = [0 for i in range(n+2)]
for i in range(n):
    b_max[-(i+2)] = max(b_max[-(i+1)], food[-(i+1)][1])
dp = [[0 for i in range(t+1)] for j in range(n+1)]
for i in range(n):
    for j in range(t+1):
        if j + food[i][0] < t:
            dp[i+1][j + food[i][0]] = max(dp[i+1][j + food[i][0]], dp[i][j] + food[i][1])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
ans = 0
for i in range(n+1):
    ans = max(ans, dp[i][-2] + b_max[i+1])
print(ans)

Measured memory_bytes: 125528
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    int n;
    cin>>n;
    set<int>st;
    REP(i,1,n){
        int x;
        cin>>x;
        st.insert(x);
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc085/tasks/abc085_d
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, h;
    cin >> n >> h;
    vector<pii> v(n);
    // 最大の攻撃力
    int maxv = 0;
    REP(i, n) {
        cin >> v[i].first >> v[i].second;
        maxv = max(maxv, v[i].first);
    }
    sort(ALL(v), [](const pii &a, const pii &b) {
        // 降順ソート
        return a.second > b.second;
    }); //比較関数をラムダ式で作る
    auto up = upper_bound(ALL(v), maxv, [](const int n, const pii &a) {
        // nより大きい最初の要素を探す
        return n > a.second;
    });
    // nより大きい要素は邪魔なので消す
    v.erase(up, v.end());

    int cnt = 0, pos = 0;
    while (h > 0) {
        if (pos >= (int)v.size()) {
            cnt += ceil((double)h / maxv);
            break;
        } else if (maxv > v[pos].second) {
            h -= maxv;
        } else {
            h -= v[pos].second;
            pos++;
        }
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0

def dm(i, j):
    d = min(a[i], b[j])
    a[i] -= d; b[j] -= d
    return d

for i in range(n):
    cnt += dm(i, i)
    cnt += dm(i + 1, i)
print(cnt)

Measured memory_bytes: 23944
use proconio::{fastout, input};
use std::str::FromStr;

#[fastout]
fn main() {
    input!(n: usize, s: [[String; 2]; n]);

    let mut sum = 0.0;

    for v in s {
        if &v[1] == "JPY" {
            sum += (&v[0]).parse::<usize>().unwrap() as f64;
        } else {
            sum += f64::from_str(&v[0]).unwrap() * 380_000.0;
        }
    }

    println!("{}", sum);
}


Measured memory_bytes: 2160
#include <stdio.h>

int main(void) {
  int n, a, b, i, j, ans = 0;
  scanf("%d%d%d", &n, &a, &b);
  for(i = 1; i <= n; ++i) {
    int t = 0, c = i;
    while(c) {
      t += c % 10;
      c /= 10;
    }
    if(t >= a && t <= b) {
     ans += i;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    int N, L;
    cin >> N >> L;

    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    sort(S.begin(), S.end());

    for (int i = 0; i < N; i++)
    {
        cout << S[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    N = int(input())
    h = list(map(int, input().split()))

    INF = 1 << 60

    dp = [INF] * 100010

    dp[0] = 0

    for i in range(N):
        if i + 1 < N:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        if i + 2 < N:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

    print(dp[N - 1])


if __name__ == "__main__":
    main()


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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int i, j, n, k, x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector < vector < int > > g(3);
    g[0].resize(a);
    g[1].resize(b);
    g[2].resize(c);
    for (i = 0; i < a; i++){
        cin >> g[0][i];
    }
    for (i = 0; i < b; i++){
        cin >> g[1][i];
    }
    for (i = 0; i < c; i++){
        cin >> g[2][i];
    }
    multiset < int > s1;
    multiset < int > s2;
    sort(g[0].rbegin(), g[0].rend());
    sort(g[1].rbegin(), g[1].rend());
    for (auto cur : g[2]){
        s2.insert(cur);
    }
    for (i = 0; i < x; i++){
        s1.insert(g[0][i]);
    }
    for (i = 0; i < y; i++){
        s1.insert(g[1][i]);
    }
    int ans = 0;
    for (auto cur : s1){
        if (!s2.empty()){
            auto it = s2.end(); it--;
            if (cur < (*it)){
                ans += (*it);
                s2.erase(it);
            }
            else{
                ans += cur;
            }
        }
        else{
            ans += cur;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17792
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    public void solve() {
    	int N = ni();
    	int[] X = ndi(N);
    	long ans = 1000000000000000000L, wk;
    	for (int i = 1; i < 100; i++) {
    		wk = 0;
			for (int j = 0; j < N; j++) {
				wk += (X[j] - i) * (X[j] - i);
			}
			ans = Math.min(ans, wk);
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


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

int main() {
  int N;
  string color;
  cin >> N;
  for(int i =0; i < N ;i++){
    cin >> color;
    if(color == "Y"){
      cout << "Four" <<endl;
      break;
    }
    if(i == N-1 && color != "Y"){
      cout << "Three" <<endl;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a[100][100];
    int b[1000];
    int n, m;
    int sum;
    int i, j;
    
    scanf("%d %d", &n, &m);
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    
    for(i=0; i<m; i++){
        scanf("%d", &b[i]);
    }
    
    for(i=0; i<n; i++){
        sum = 0;
        for(j=0; j<m; j++){
            sum += a[i][j]*b[j];
        }
        printf("%d\n", sum);
    }
    
    return 0;
}

Measured memory_bytes: 644
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(b==0 && a%500!=0)
        cout<<"No";
    else if(b==0 && a%500==0)
        cout<<"Yes";
    else if(a<b)
        cout<<"Yes";
    else if(b<a && a%500!=0 && b>=(a%500))
        cout<<"Yes";
    else if(b==a)
        cout<<"Yes";
    else if(b<a && a%500!=0 && b<(a%500))
        cout<<"No";
    else if(a%500==0){
        cout<<"Yes";
    }
    return 0;
}


Measured memory_bytes: 256
let _ =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let b = Array.fold_left (fun x v -> if x+1 = v then x+1 else x) 0 a in
  Printf.printf "%d\n" (if b = 0 then -1 else n-b)


Measured memory_bytes: 6144
#include<stdio.h>

typedef long long ll;

int main(){
    ll h1,h2,m1,m2,k;
    scanf("%lld%lld%lld%lld%lld",&h1,&m1,&h2,&m2,&k);
    printf("%lld",h2*60+m2-h1*60-m1-k);
    return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void) {
    int N,M,K;
    cin >> N >> M;
    bool A[M];
    for(int i=0; i<M; i++) A[i] = true;

    for(int i=0; i<N; i++) {
        cin >> K;
        bool memo[M];
        for(int i=0; i<M; i++) memo[i] = false;

        for(int j=0; j<K; j++) {
            int like;
            cin >> like;
            memo[like-1] = true;
        }

        for(int i=0; i<M; i++) if(memo[i] == false) A[i] = false;
    }
    int ans = 0;

    for(int i=0; i<M; i++) if(A[i] == true) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
  N = int(input())
  A = [[int(_) for _ in input().split()] for __ in range(N)]
  t0 = x0 = y0 = 0
  for a in A:
    t, x, y = a
    if (t - t0 < abs(x - x0) + abs(y - y0)) or (t%2 == 0 and (x + y)%2 == 1) or (t%2 == 1 and (x + y)%2 == 0):
      print('No')
      break
    t0, x0, y0 = t, x, y
  else:
    print('Yes')
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 21108
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

int V;
const int MAX_V = 1000;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

int red[MAX_V][2];
int blue[MAX_V][2];

void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v){
//    cout<<"\tdfs with "<<v<<endl;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++){
        int u = G[v][i], w = match[u];
//        cout<<"\tcheck with "<<u<<endl;
        if (w < 0 || !used[w] && dfs(w)){  //増加パスは当然同じ頂点を一度しか訪れないのでused[w]を除く。used[w]だと、例えばv=wのとき無限ループが起きる。
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching() {
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v = 0; v < V; v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
//            cout<<"START with "<<v<<endl;
            if (dfs(v)) {
                res++;
            }
        }
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> red[i][0];
        cin >> red[i][1];
    }
    for (int i = 0; i < N; i++){
        cin >> blue[i][0];
        cin >> blue[i][1];
    }

    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if (red[i][0] < blue[j][0] && red[i][1] < blue[j][1]){
                add_edge(i, N+j);
            }
        }
    }

    V = 2 * N;
    cout<<bipartite_matching()<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define Max_size 16
int main()
{
    int n,gx,gy,p,i,j;
    cin >> n;
    while(n)
    {
        n--;
        cin >> gx >> gy;
        int sum[Max_size][Max_size],r[Max_size][Max_size],d[Max_size][Max_size];
        for(i=0;i<Max_size;i++)
            for(j=0;j<Max_size;j++)
            {
                sum[i][j]=0;
                r[i][j]=1;
                d[i][j]=1;
            }
        cin >> p;
        if(p!=0)
        {   int x1[p],y1[p],x2[p],y2[p];
            for(i = 0;i < p;i++)
            {
                cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
                if(x1[i]==x2[i])
                {   if(y1[i]<y2[i])
                        d[x1[i]][y1[i]]=0;
                    else    d[x1[i]][y2[i]]=0;}
                else    {if(x1[i]<x2[i])
                            r[x1[i]][y1[i]]=0;
                        else    r[x2[i]][y1[i]]=0;}
            }
        }
        sum[0][0]=1;
        for(i=1;i<=gy;i++)
        {
            if(d[0][i-1]==1)
                sum[0][i]=sum[0][i-1];
            else    sum[0][i]=0;
        }
        for(i=1;i<=gx;i++)
        {
            if(r[i-1][0]==1)
                sum[i][0]=sum[i-1][0];
            else    sum[i][0]=0;
        }
        for(i=1;i<=gx;i++)
            for(j=1;j<=gy;j++)
            {
                if(r[i-1][j]==1 && d[i][j-1]==1)
                    sum[i][j]=sum[i-1][j]+sum[i][j-1];
                else    if(r[i-1][j]==1)
                            sum[i][j]=sum[i-1][j];
                        else    if(d[i][j-1]==1)
                                    sum[i][j]=sum[i][j-1];
                                else    sum[i][j]=0;
            }
        if(sum[gx][gy] == 0)
            cout << "Miserable Hokusai!" << endl;
        else    cout << sum[gx][gy] << endl;
    }
    return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  set<ll> s;
  REP(i, 4){
    ll a;
    cin >> a;
    s.insert(a);
  }
  set<ll> t = {1, 7, 9, 4};
  cout << ((s == t) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
/*
[abc134] F - Permutation Oddness
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 50;
const int MAX_K = MAX_N * MAX_N;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
};

int N, K;
gf dp[MAX_N + 1][MAX_N + 1][MAX_K + 1];

ll solve() {
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 2 * j; k <= N * N; k++) {
                dp[i][j][k] = gf(2 * j + 1) * dp[i - 1][j][k - 2 * j];
                if (j + 1 <= N) {
                    dp[i][j][k] +=
                        gf((j + 1) * (j + 1)) * dp[i - 1][j + 1][k - 2 * j];
                }
                if (j - 1 >= 0) {
                    dp[i][j][k] += dp[i - 1][j - 1][k - 2 * j];
                }
            }
        }
    }

    return dp[N][0][K].n;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int n,k; cin >>n >> k;
	_nCr();
	FOR (i,1,k+1) {
		if (i == 1) {
			cout << n-k+1 << endl;
			continue;
		}
		int ans = 0;
		//両端に置かない
		if (n-k-1 >= i - 2) {
			ans += nCr(k-1,i-1) * nCr(n-k-1,i-2);
			ans %= mod;
		}
			//片方置く
		if (n-k-1 >= i - 1) {
			ans += nCr(k-1,i-1) * nCr(n-k-1,i-1) % mod * 2 % mod;
			//両端
		}
		ans %= mod;
		if (n-k-1 >= i) {
			ans += nCr(k-1,i-1) * nCr(n-k-1,i) % mod;
		}
		ans %= mod;
		cout << ans << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 3456
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int n, k;

	cin >> n >> k;
	vector<int>a(n );

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int i = k; i < n; i++) {
		if (a[i] > a[i - k]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}



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

void CountingSort(const int* array_in, int* array_out, const int& max_value,
                  const int& n) {
  int array_c[max_value + 1];
  for (int i = 0; i < max_value + 1; i++) {
    array_c[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    array_c[array_in[i]]++;
  }
  for (int i = 1; i < max_value + 1; i++) {
    array_c[i] = array_c[i] + array_c[i - 1];
  }
  for (int i = 0; i < n; i++) {
    array_c[array_in[i]]--;
    array_out[array_c[array_in[i]]] = array_in[i];
  }
}

int main() {
  int n;
  cin >> n;
  int array_in[n];
  int array_out[n];
  int max_value = 0;
  for (int i = 0; i < n; i++) {
    cin >> array_in[i];
    max_value = max(array_in[i], max_value);
  }
  CountingSort(array_in, array_out, max_value, n);
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << array_out[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 18724
from collections import*
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a=Counter(a)
cnt=1
for i in range(min(a),max(a)+1):
	cnt_=a[i-1]+a[i]+a[i+1]
	if cnt_>cnt:cnt=cnt_
print(cnt)

Measured memory_bytes: 14500
#include<iostream>
int main(){
    std::string s,t;
    int count=0;
    std::cin>>s;
    std::cin>>t;

    for(int i=0;i<s.size();++i){
        if(s[i]!=t[i]){
            ++count;
        }
    }
std::cout<<count;
  return 0;
}

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

const int MAXN = 100005, MAXM = 11;

inline int read()
{
	int a = 0, c;
	do c = getchar(); while (!isdigit(c));
	while (isdigit(c)) {
		a = a*10+c-'0';
		c = getchar();
	}
	return a;
}

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int n, m, q, a, b, f[MAXN][MAXM];
int v[MAXN], d[MAXN], c[MAXN];

int main()
{
	n = read(), m = read();
	for (int i = 1; i <= m; i++) {
		int u = read(), v = read();
		push(u, v), push(v, u);
	}
	q = read();
	for (int i = 1; i <= q; i++) {
		v[i] = read(), d[i] = read(), c[i] = read();
		for (int j = 0; j <= d[i]; j++)
			f[v[i]][j] = i;
	}
	for (int i = 9; i >= 0; i--) {
		for (int j = 1; j <= n; j++)
			for (int k = head[j]; k; k = edge[k].next) {
				int to = edge[k].to;
				f[j][i] = max(f[j][i], f[to][i+1]);
			}
	}
	for (int i = 1; i <= n; i++)
		printf("%d\n", c[f[i][0]]);
	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

int	main(void)
{
  	int	r;
  	int	g;
  	int	b;
	int	k;
  	int	i;
  
  	scanf("%d %d %d", &r, &g, &b);
  	scanf("%d", &k);

  	i = 0;
  	
  	while(r >= g)
    {
      g = g * 2;
      i++;
    }
  
  	if (i > k)
  	{
      printf("No");
  	}
  	
  	//printf("%d", i);
  	
  	while(g >= b)
    {
      b = b * 2;
      i++;
    }
    
    //printf("%d", i);
 
  	if (i > k)
    {
        printf("No");
    }
  	else
  	{
        printf("Yes");
  	}
  
  	return (0);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 2005

struct Info{
	void set(int arg_from,int arg_to,ll arg_cost){
		from = arg_from;
		to = arg_to;
		cost = arg_cost;
	}
	int from,to;
	ll cost;
};

Info info[SIZE];
ll min_dist[SIZE];
vector<int> G[SIZE];
bool check[SIZE];

void dfs(int node_id){

	for(int i = 0; i < G[node_id].size(); i++){

		int child = G[node_id][i];
		if(check[child])continue;

		check[child] = true;
		dfs(child);
	}
}


int main(){

	int V,E,start;
	scanf("%d %d",&V,&E);

	start = 0;

	for(int i = 0; i < V; i++)min_dist[i] = HUGE_NUM;
	min_dist[start] = 0;

	int from,to;
	ll cost;

	for(int i = 0; i < E; i++){
		scanf("%d %d %lld",&from,&to,&cost);
		from--;
		to--;
		info[i].set(from,to,-cost);
		G[to].push_back(from);
	}

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

		check[i] = false;
	}
	check[V-1] = true;
	dfs(V-1);

	bool FLG = true,updated;
	Info tmp;

	for(int i = 0; i < V; i++){
		updated = false;
		for(int k = 0; k < E; k++){
			tmp = info[k];
			if(check[tmp.from] == true && min_dist[tmp.from] != HUGE_NUM && min_dist[tmp.to] > min_dist[tmp.from] + tmp.cost){
				min_dist[tmp.to] = min_dist[tmp.from] + tmp.cost;

				updated = true;
				if(i == V-1){
					FLG = false;
					break;
				}
			}
		}
		if(!updated)break;
		if(!FLG)break;
	}

	if(!FLG){
		printf("inf\n");
		return 0;
	}

	printf("%lld\n",-min_dist[V-1]);

	return 0;
}




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

// 0 2 1 4 3

// A[] = {0, 1, 0, 1, 0}

// 1 2 3 0 4
// A[] = {0, 1, 1, 0, 1}

int P[200005];

int A[200005];
int prefA[200005];

int maxKm1[200005];
int minKm1[200005];

int main(){
    int N, K;
    scanf("%d%d", &N, &K);

    for(int i = 0; i < N; i ++){
        scanf("%d", &P[i]);
    }

    A[0] = 0;
    for(int i = 0; i < N; i ++){
        A[i+1] = P[i] < P[i+1];
    }

    prefA[0] = 0;
    for(int i = 0; i < N; i ++){
        prefA[i] = A[i] + prefA[i-1];
    }

    int numSorted = 0;
    for(int i = 0; i < N-K+1; i ++){
        if(prefA[i+K-1]-prefA[i] == K-1){
            numSorted ++;
        }
    }

    set<int> s;
    for(int i = 0; i < K-1; i ++){
        s.insert(P[i]);
    }
    maxKm1[0] = *(--s.end());
    minKm1[0] = *s.begin();
    //printf("maxKm1[0]=%d\n", maxKm1[0]);
    for(int i = 1; i < N-K+1; i ++){

        s.erase(P[i-1]);
        s.insert(P[i+K-2]);
        /*for(int i: s){
            printf("%d ", i);
        }*/

        //printf("\n");
        maxKm1[i] = *(--s.end());
        minKm1[i] = *s.begin();
        //printf("maxKm1[%d]=%d\n", i, maxKm1[i]);
    }

    int correction = 0;
    for(int i = 0; i < N-K; i ++){
        if(prefA[i+K-1]-prefA[i] != K-1){
            if(P[i] < minKm1[i+1] && maxKm1[i+1] < P[i+K]){
                correction ++;
            }
        }
    }

    //printf("correction: %d\n", correction);

    printf("%d", N-K+1 - max(numSorted-1, 0) - correction);
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	long double a, b, c;
	cin >> a >> b >> c;
	long double tmp = a + b + 2 * sqrt(a * b);
	// printf("%.10Lf %.10Lf %.10Lf\n", sqrt(a), sqrt(b), sqrt(c));
	if (tmp < c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
fn main() {
    let xy = read_vec::<u64>();
    let x = xy[0];
    let y = xy[1];

    let a = {
        if 2 * y < x || (2 * y - x) % 3 != 0 {
            println!("0");
            return;
        }
        (2 * y - x) / 3
    };
    let b = {
        if 2 * x < y || (2 * x - y) % 3 != 0 {
            println!("0");
            return;
        }
        (2 * x - y) / 3
    };

    println!("{}", comb(a + b, a));
}

fn comb(a: u64, b: u64) -> u64 {
    const MOD: u64 = 1000000007;
    let b = {
        let tmp = a - b;
        if tmp < b { tmp } else { b }
    };

    let mut ch = 1;
    for i in 0..b {
        ch *= a - i;
        ch %= MOD;
    }

    let mut mo = 1;
    let mut x = b;
    while x > 0 {
        mo *= x;
        mo %= MOD;
        x -= 1;
    }

    ch * exp(mo, MOD-2) % MOD
}

fn exp(a: u64, n: u64) -> u64 {
    if n == 0 {
        return 1
    }

    const MOD: u64 = 1000000007;
    if n % 2 == 1 {
        a * exp(a, n-1) % MOD
    } else {
        let tmp = exp(a, n / 2);
        tmp * tmp % MOD
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
n=int(input())
csf=[0]
for i in range(n-1):
    csf.append(list(map(int,input().split())))
for i in range(1,n):
    t=0
    for j in range(i,n):
        if t<=csf[j][1]:
            t=csf[j][1]+csf[j][0]
        else:
            if t%csf[j][2]!=0:
                t=t+csf[j][2]-t%csf[j][2]+csf[j][0]
            else:
                t+=csf[j][0]
    print(t)
print(0)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

const long long inf = std::numeric_limits<int>::max();
const int maxv = 100005;

vector<vector<long long>> dp;
long long f(int i, int V, const vector<int> &w, const vector<int> &v) {
  if (i == -1 or V <= 0) {
    return V <= 0 ? 0 : inf;
  }

  if (dp[i][V] == -1) {
    long long a = f(i - 1, V, w, v);
    long long b = w[i] + f(i - 1, V - v[i], w, v);
    dp[i][V] = min(a, b);
  }

  return dp[i][V];
}

int main() { IO;
  int n, W;
  cin >> n >> W;

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

  dp.resize(n);
  for (auto &v : dp) {
    v.resize(maxv);
    fill(v.begin(), v.end(), -1);
  }

  long long ans = 0;
  for (int V = 1; V < maxv; ++V) {
    long long Wi = f(n - 1, V, w, v);
    if (Wi <= W) {
      ans = V;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80000
#include<bits/stdc++.h>
#define rep(i,k,n)     for (ll i = k; i < n; ++i)
#define repr(i,k,n)    for (ll i = k; i >= n; --i)
#define repp(p,a)      for (p=a.begin();p!=a.end();++p)
#define all(a)         a.begin(),a.end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define reppn(p,a,n)    for (p=a.begin();(p+n)!=a.end();++p)
#define F              first
#define S              second
#define ll             long long
#define hell           1000000007
#define god            LLONG_MAX
#define lb             lower_bound
#define ub             upper_bound
#define pb             push_back
#define ct             continue
#define endl           '\n'
#define setprecision(n) sp(n)
#define srt(a)         sort(all(a))
#define srtd(a)        sort(a.rbegin(),a.rend())
#define sz(a)          ll((a).size())
#define sum(a)         accumulate(all(a),(ll) 0)
#define pdt(a)         accumulate(all(a),double(1),multiplies<double> ())
#define dotpdt(a,b)    inner_product(all(a),b.begin(),0)
#define mkp(a,b)       make_pair(a,b)
#define REP(x,s)       for (auto x : s)
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll t=1;
  //cin>>t;
  while(t--)
  {
     string s,t;
     cin>>s;
     cin>>t;
     ll a,b;
     cin>>a>>b;
     string u;
     cin>>u;
     if(u==s)
     {
         cout<<a-1<<" "<<b;
     }
     else
     {
         cout<<a<<" "<<b-1;
     }
  }      
 
 
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int S, W;
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    bool tmp = true;
    for_each(s.begin(), s.end(), [&](char c) {if (isupper(c)) tmp = false;});
    if (tmp && s.size() == 6 && s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write= sys.stdout.write
N = int(readline())
L = [None]*N; R = [None]*N; P = [-1]*(N+1)
for i in range(N):
    i, l, r = map(int, readline().split())
    L[i] = l; R[i] = r
    P[l] = i; P[r] = i
s0 = []; s1 = []; s2 = []
def dfs(v):
    v0 = str(v)
    s0.append(v0)
    L[v] != -1 and dfs(L[v])
    s1.append(v0)
    R[v] != -1 and dfs(R[v])
    s2.append(v0)
dfs(P.index(-1))
write("Preorder\n %s\nInorder\n %s\nPostorder\n %s\n" % tuple(map(" ".join, [s0, s1, s2])))



Measured memory_bytes: 5612
#include <stdio.h>

int main()
{
	int n, i = 1, x;
	scanf("%d", &n);
	while (i <= n) {
		if (i % 3 == 0) {
			printf(" %d", i);
		}
		else {
			if (i % 10 == 3) {
				printf(" %d", i);
			}
			else {
				x = i;
				while (x) {
					if (x % 10 != 3) {
						x /= 10;
					}
					else {
						printf(" %d", i);
						break;
					}
				}
			}
		}
		i++;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2084