akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static class Reader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public Reader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Reader sn = new Reader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		int a = sn.nextInt();
		int b = sn.nextInt();
		if((a+b)%3==0||a%3==0||b%3==0){
			System.out.println("Possible");
		}
		else{
			System.out.println("Impossible");
		}
		out.close();
	}

}

Measured memory_bytes: 21460
math = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
K = int(input())
print(math[K-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define endl "\n"
using namespace std;


int main() {
ll n;
cin>>n;
if(n%1000!=0)
{
    cout<<1000-(n%1000);
}
else
cout<<0;
}

Measured memory_bytes: 3620
N, M = [int(item) for item in input().split()]
S = input()
a=[]
s = S
n = N
while n > 0:
    for i in range(M, 0, -1):
        can = False
        if n>=i and s[n-i] == '0':
            a.append(i)
            s = s[:n-i+1]
            n -= i
            can = True
            break
    if (not can) and len(s)>1:
        print(-1)
        a=[]
        break
a=a[-1::-1]
if len(a):
    print(*a)

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n;cin>>n;
    for(int i=n;i>=1;--i){
        int s =sqrt(i);
        if(s*s==i){
            cout<<i<<endl;
            return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

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

int main(){
    int N,X; cin >> N >> X;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
        x[i] = abs(x[i]-X);
    }
    int d=x[0];
    for(int i=1;i<N;i++){
        d=gcd(d,x[i]);
    }
    cout << d << endl;
    return 0;
}
/*
最も近いものを
*/

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

int main()
{
    string s;
    cin >> s;
    vector<int> a(26, 0);
    int sum;
    for(int i = 0; i < (int)s.size(); i++) a[s[i] - 'a']++;
    for(int i = 0; i < 26; i++) sum += a[i]%2; 
    cout << (sum? "No": "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> x(N);
    vector<ll> y(M);
    for(int i = 0;i < N;i++) {
        cin >> x.at(i);
    }
    for(int i = 0;i < M;i++) {
        cin >> y.at(i);
    }
    ll ret1 = 0;
    ll ret2 = 0;
    for(int i = 0;i < N - 1;i++) {
        ret1 += (x.at(i + 1) - x.at(i)) % MOD * (i + 1) % MOD * (N - 1 - i) % MOD;
        ret1 %= MOD;
    }
    for(int i = 0;i < M - 1;i++) {
        ret2 += (y.at(i + 1) - y.at(i)) % MOD * (i + 1) % MOD * (M - 1 - i) % MOD;
        ret2 %= MOD;
    }
    cout << ret1 * ret2 % MOD << endl;
}

Measured memory_bytes: 1792
n=int(input())
s1=input()
s2=input()

mod=1000000007

x=0
cnt=1
while x<n:
    if x==0:
        if s1[x]==s2[x]:
            cnt*=3%mod
            x+=1
        else:
            cnt*=6%mod
            x+=2
    else:
        if s1[x-1]==s2[x-1]:
            #x-1:AA 
            #x  :BB CC
            if s1[x]==s2[x]:
                cnt*=2%mod
                x+=1
            #x-1:AA 
            #x  :BC  CB
            #    BC  CB
            else:
                cnt*=2%mod
                x+=2
        else:
            #x-1:AB
            #   :CC
            if s1[x]==s2[x]:
                cnt*=1%mod
                x+=1
            #x-1:AB
            #x  :BA CA BC 
            else:
                cnt*=3%mod
                x+=2

print(cnt%mod)






Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool maki = true;
    int t, x, y;
    int now = 0, nx = 0, ny = 0;
    for(int i=0;i<n;i++){
    	cin >> t >> x >> y;
    	int dis = abs(nx - x) + abs(ny - y);
    	int num = (t - now) & 1;
    	if(dis > t - now || dis % 2 != num) maki = false;
    	else {
    		now = t;
    		nx = x;
    		ny = y;
    	}
    }
    if(maki) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
# from math import gcd

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

a, b = map(int, input().split())
p = primes(10 ** 6 +1)
ans = 1
g = gcd(a, b)
for pp in p:
    f = False
    while g % pp == 0:
        g = (g // pp)
        f = True
    if f:
        ans += 1
if g > 1:
    ans += 1
print(ans)

Measured memory_bytes: 16224
#include <iostream>
#include <cstring>
#include <cstdio>
#define MN 201000
#define MM 1201000

int h[MN], nxt[MM], to[MM], cap[MM], K = 1;
int Q[MN], hh = 0, tt = 0, lvl[MN], iter[MN];
int p[MN], q[MN], idp[MN], idq[MN];
int v1[MN], v2[MN];

void ins(int u, int v, int c) {nxt[++K] = h[u]; h[u] = K; to[K] = v; cap[K] = c;}

void insw(int u, int v, int c) {ins(u, v, c); ins(v, u, 0);}

bool bfs(int S, int T)
{
	hh = tt = 0;
	Q[tt++] = T; 
	memset(lvl, 0, sizeof(lvl)); lvl[T] = 1;
	while(hh < tt)
	{
		int u = Q[hh++]; iter[u] = h[u];
		for(int i = h[u]; i; i = nxt[i])
		{
			if(cap[i ^ 1] && !lvl[to[i]])
			{
				lvl[to[i]] = lvl[u] + 1;
				Q[tt++] = to[i];
			}
		}
	}
	if(!lvl[S]) return 0;
	return 1;
}

int dfs(int u, int T, int f)
{
	if(T == u) return f;
	int used = 0;
	for(int &i = iter[u]; i; i = nxt[i])
	{
		if(cap[i] && lvl[to[i]] == lvl[u] - 1)
		{
			int w = dfs(to[i], T, std::min(cap[i], f - used));
			if(w)
			{
				cap[i] -= w; cap[i ^ 1] += w; used += w;
				if(used == f) return f;
			}
		}
	}
	return used;
}

int dinic(int S, int T)
{
	int flow = 0;
	while(bfs(S, T))
	{
		int f;
		do {flow += (f = dfs(S, T, 1e9));} while(f);
	}
	return flow;
}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);
	for(int i = 0; i < n; i++) scanf("%d", &q[i]);
	int tot1 = 0, tot2 = 0;
	for(int i = 0; i < n; i++)
	{
		if(idp[i]) continue;
		++tot1;
		int j = i;
		while(!idp[j]) idp[j] = tot1, j = p[j];
	}
	for(int i = 0; i < n; i++)
	{
		if(idq[i]) continue;
		++tot2;
		int j = i;
		while(!idq[j]) idq[j] = tot2, j = q[j];
	}
	int S = tot1 + tot2 + 1, T = S + 1; 
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(p[i] == q[i] && p[i] == i) continue;
		ans++;
		insw(idq[i] + tot1, idp[i], 1);
		if(p[i] == i) {v1[idp[i]]++; continue;}
		if(q[i] == i) {v2[idq[i]]++; continue;}
		if(p[i] == q[i]) insw(idp[i], idq[i] + tot1, 1);
	}
	for(int i = 1; i <= tot1; i++) insw(S, i, 0), insw(i, T, v1[i]);
	for(int i = 1; i <= tot2; i++) insw(S, i + tot1, v2[i]), insw(i + tot1, T, 0);
	printf("%d\n", ans - dinic(S, T));
}

//最小割中idpi割到S是选pi,idqi割到T是选i，idqi割到S选i，割到T选qi（定义要与pi相反才能建图） 

Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int C[N], tmp;
    cin >> C[0];
    tmp = C[0];
    for(int i=1;i<N;i++){
        cin >> tmp;
        C[i] = C[i-1] + tmp;
    }
    int d = C[N-1];
    for(int i=0;i<N-1;i++){
        tmp = abs(C[N-1] - C[i] * 2);
        if(d > tmp) d = tmp;
        else break;
    }
    std::cout << d << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int X,A,i,ans=0;
  scanf("%d%d",&X,&A);
	if(X<A)ans=0;
	else ans=10;

  printf("%d\n",ans);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int num10_4=90000;
  int num10_2=900;
  int num10_0=9;
  
  if(N==100000){
    cout << 90909;
  }else if(N>=10000){
    cout << num10_0+num10_2+N-10000+1;
  }else if(N>=1000){
    cout << 909;
  }else if(N>=100){
    cout << num10_0+N-100+1;
  }else if(N>=10){
    cout << 9;
  }else{
    cout << N;
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

S=input()
L=[0]*len(S)
S=S+"X"
r=0
l=0
i=0
ind=0
c=True
for s in S:
    if c:
        if s=="R":
            r+=1
        else:
            ind=i
            c=False
            l+=1
    else:
        if s=="L":
            l+=1
        else:
            L[ind]+=r//2
            L[ind-1]+=r-r//2
            L[ind]+=l-l//2
            L[ind-1]+=l//2
            c=True
            r,l=1,0
    i+=1
print(*L)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N, M, X;
VI m;
int main() {
    std::cin >> N >> M >> X;
    m.resize(N, 0);
    int a;
    REP(i, M) {
        std::cin >> a;
        m[a] = 1;
    }

    int left = 0, right = 0;
    for(int i = X; i >= 0; --i) {
        left += m[i];
    }
    for(int i = X; i < N; ++i) {
        right += m[i];
    }
    std::cout << std::min(left, right) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 2e5+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int a[M];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	for(int i=1;i<=n;i++)cin>>a[i];
  	sort(a+1,a+1+n);
  	ll ans=a[n];
  	int nm=n-2;
  	for(int i=n-1;i>=1;i--)
  	{
  		if(nm>1)nm-=2,ans+=a[i]*2;
  		else if(nm==1)nm=0,ans+=a[i];
  		else break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4436
//ITNOA
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
const long long INF=1e9+10,MAX=2e5+1e4,MOD=1e9+7,MAXL=25;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
void OUT(long double o,int x){
	 cout<<fixed<<setprecision(x)<<o;
	 return;
}
ll a[MAX];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	if(n%10==9||n/10==9)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
#define lowbit(x) ((x) & (-(x)))
using namespace std;

const int N = 2e5 + 10;
typedef long long ll;
ll n, num[26], C[N << 2], lst[26], ans;
bool vis[N];
char s[N];
vector<int> pos[26];

void add(int x, int val) {
	for (; x <= n; x += lowbit(x)) C[x] += val;
}

ll query(int x) {
	ll ret = 0;
	for (; x; x -= lowbit(x)) ret += C[x];
	return ret;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	rep(i, 1, n) pos[s[i] - 'a'].push_back(i);
	
	int chk = 0;
	rep(i, 0, 25) {
		if ((pos[i].size()) & 1) chk++;
		lst[i] = (pos[i].size()) - 1;
	}
	if (chk > 1) { puts("-1"); return 0; }
	
	rep(i, 1, n) add(i, 1);
	rep(l, 1, n) if (!vis[l]) {
		int c = s[l] - 'a', r = pos[c][lst[c]];
		if (l == r) ans += (query(n) - query(l)) >> 1;
		else ans += query(n) - query(r);
		vis[l] = vis[r] = 1;
		add(l, -1), add(r, -1);
		lst[c]--;
	}
	printf("%lld\n", ans);
	return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int n,m; cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll K, A, B;
  cin >> K >> A >> B;

  if (B - A <= 2 || A - 1 >= K) {
    cout << 1 + K << endl;
    return 0;
  }

  ll ans = 1;
  K -= (A - 1);
  ans += A - 1;
  ans += K / 2 * (B - A);
  if (K % 2 == 1) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define X real()
#define Y imag()

typedef complex<double> P;

const double INF = (1<<30);

int n,m;
vector<P> A;
vector<P> B;

class L : public vector<P>{
	public:
	L(P a, P b){
		push_back(a);
		push_back(b);
	}
};



bool input(){
	cin>>n>>m;
	A=vector<P>(n);
	B=vector<P>(m);
	rep(i,n){
		double a,b;
		cin>>a>>b;
		A[i] = P(a,b);
	}
	rep(i,m){
		double a,b;
		cin>>a>>b;
		B[i] = P(a,b);
	}
}

void init(){}

double distPP(P a, P b){return abs(a-b);}


double cross(P a, P b){return a.X*b.Y-a.Y*b.X;}
bool ccw(P a, P b, P c){
	return cross(b-a, c-a)>0;
}

bool hitLL(L a, L b){
	bool b1 = ccw(a[0],b[0],b[1])!=ccw(a[1],b[0],b[1]);
	bool b2 = ccw(b[0],a[0],a[1])!=ccw(b[1],a[0],a[1]);
	return b1&&b2;
}

double solve_search(L line, vector<P>& p){
	
	double ret = INF;
	rep(i,p.size()){
		rep(j,p.size()){
			double d1 = distPP(p[0], p[i]);
			double d2 = distPP(p[1], p[j]);
			double d3 = distPP(p[i], p[j]);
			
			L line1(p[0],p[i]);
			L line2(p[i],p[j]);
			L line3(p[j],p[1]);
			
			if(!hitLL(line1, line)
				&& !hitLL(line2, line)
				&& !hitLL(line3, line)){
					ret = min(ret, d1+d2+d3);
				}
		}
	}
	
	return ret+distPP(line[0],line[1]);
}

double solve(){
	
	L AL(A[0],A[1]);
	L BL(B[0],B[1]);
	
	double val = min(solve_search(AL, B), solve_search(BL, A));
	if(val>=INF)return -1;
	return val;
}

int main(){
	init();
	input();
	
	printf("%.9lf\n",solve());
}

Measured memory_bytes: 1332
// F - Division or Substraction
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

//約数列挙
vector<ll> divisors(ll n){
	vector<ll> res;
	for(ll i=1; i*i<=n; ++i){
		if(n%i != 0) continue;
		res.push_back(i);
		if(i*i != n) res.push_back(n/i);
	}
	return res;
}

int main(){
	ll N; cin>>N;
	ll ans = divisors(N-1).size() - 1;
	for(ll k:divisors(N)){
		if(k == 1) continue;
		ll n = N;
		while(n%k == 0) n /= k;
		if(n%k == 1) ++ans;
	}
	cout<< ans <<endl;
}

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

int main(){
int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int dif=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      dif+=vec.at(i);
    }else{
      dif-=vec.at(i);
    }
  }
  cout<<dif<<endl;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int d, r;
		double f;
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		while(a < 1 || a > 1000000000 || b < 1 || b > 1000000000) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
		}
		
		d = a / b;
		r = a % b;
		f = (double)a / (double)b;
		
		System.out.println(d + " " + r + " " + BigDecimal.valueOf(f).toPlainString()); 
		
	}
}


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

int main() {
    // insert code here...
    double a,b,c,d,oc,od;
    double answer,number1,number2;
    cin>>a>>b>>c>>d;
    if (a<c) {
        oc=c;
        c=a;
        a=oc;
    }
    if (b<d) {
        od=d;
        d=b;
        b=od;
    }
    number1=double (fabs(d-b));
    number2=double (fabs(c-a));
    answer=double (sqrt(number1*number1+number2*number2));
    
    printf("%lf\n",answer);
    return 0;
}





Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    ll n,ans=1;
    cin >> n;

    vector<int> a(10000,0);

    for(int i = 2;i <= n;i++){//階乗のそれぞれ

        ll tmp = i;
        for(int j = 2;tmp > 1;j++){//何で割るか
            while(tmp%j == 0){//何回割れるか
                a[j]++;
                tmp/=j;
            }
        }
    }

    /*for(int i = 2;i <= n;i++){
        cout << a[i] << endl;
    }*/

    //cout << "a" << endl;
    for(int i = 2;i <= n;i++){
        //cout << a[i] << endl;

        ans = (ans*(a[i]+1))%MAX_A;
        //cout << ans << endl;

    }
    cout << ans << endl;

    return 0;
}

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

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

int main(){
	int a[101];
	rep(i, 101) a[i] = 0;
	int n;
	int m = 0;
	while(cin >> n){
		a[n]++;
		m = max(m, a[n]);
	}
	rep(i, 101) if(m == a[i]) cout << i << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  string S;
  int K;
  cin >> S >> K;
  //入力終わり

  //firstを昇順に入れていく
  map<string, int> map;
  
  int size = (int)S.size();
  
  for(int i=0; i<size; i++){
    //Sの範囲から出ないように制御
    for(int j=1; j<=min(size-i, 5); j++){
      map[S.substr(i, j) ]++;
    }
  }

  //小さいほうからK番目の文字列を出力して終了
  int count = 0;
  for(auto m : map){
    if(++count == K){
      cout << m.first << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	int n,h;
	cin>>h>>n;
	vi a(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	cout<<(sum>=h?"Yes":"No");
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3736
m_d = list()    # 魔法移動距離
for i in range(-2, 3):
    for j in range(-2, 3):
        if (i,j) not in [(0,0),(-1,0),(0,-1),(1,0),(0,1)]:
            m_d += [(i,j)]

h, w = list(map(int, input().split()))
si, sj = list(map(int, input().split()))
ti, tj = list(map(int, input().split()))
s = [None] * h
for i in range(h):
    s[i] = input()

# 距離情報を一番遠い値で初期化
#import numpy as np
INF = int(1e9)
#dist = np.full((h+4, w+4), INF)
dist = [[INF for j in range(w+4)] for i in range(h+4)]

# マップ境界を壁で囲む
S = ['##{}##'.format(s_row) for s_row in s]
S = ['##{}##'.format('#' * (w+4))]*2 + S
S = S + ['##{}##'.format('#' * (w+4))]*2

# BFS探索用キュー
from collections import deque
q_a = deque() # 徒歩
q_b = deque() # ワープ

# 開始位置、終了位置を調整
si, sj = si+1, sj+1
ti, tj = ti+1, tj+1
dist[si][sj] = 0
q_a.append([si,sj])

while (len(q_a)>0):
    i, j = ij = q_a.popleft()
    q_b.append(ij)
    d = dist[i][j]
    for di, dj in [(-1,0),(0,-1),(1,0),(0,1)]:
        ni, nj = di+i, dj+j
        if (S[ni][nj]=='#'):
            continue # 壁
        if (dist[ni][nj]<=d):
            continue # 探索済みコスト以上
        dist[ni][nj] = d
        q_a.append([ni,nj])

    if len(q_a) == 0:
        while (len(q_b)>0):
            i, j = q_b.popleft()
            d = dist[i][j]
            for di, dj in m_d:
                ni, nj = di+i, dj+j
                if (S[ni][nj]=='#'):
                    continue # 壁
                if (dist[ni][nj]<=d):
                    continue # 探索済みコスト以上
                dist[ni][nj] = d+1
                q_a.append([ni,nj])

ans = dist[ti][tj]
if ans == INF:
    ans = -1
print(ans)


Measured memory_bytes: 155020
S = input().rstrip()
S = S[::-1]
daydream = ['maerd', 'remaerd', 'esare', 'resare']
nextIndex = 0
flg = True
for i in range(10**5//5):
    if nextIndex == len(S):
        break
    for j in daydream:
        if j == S[nextIndex: nextIndex+len(j)]:
            nextIndex += len(j)
            flg = True
            break
        flg = False
    if flg == False:
        break
print("YES" if flg else "NO")

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

int main(){
  int N;
  cin >> N;
  int ans;
  if (N % 2 == 0) ans = N / 2;
  if (N % 2 == 1) ans = (N / 2) + 1;
  cout << ans << endl;
}

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

struct RA {
	using type1 = int;
	using type2 = int;
	static type1 id1() { return 0; }
	static type2 id2() { return 0; }
	static type1 op1(const type1& l, const type1& r) { return l + r; }
	static type1 op2(const type1& l, const type2& r) { return l + r; }
	static type2 op3(const type2& l, const type2& r) { return l + r; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::type1;
	using T2 = typename M::type2;
	const int n;
	vector<T1> data;
	vector<T2> lazy;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			lazy[node] = M::op3(lazy[node], val);
			return;
		}
		push(node);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2]), M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		push(node);
		int c = (lb + ub) / 2;
		return M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
public:
	LazySegmentTree(int n_) : n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	void update(int l, int r, T2 val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	T1 find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, type, s, t, x;
	cin >> n >> q;
	LazySegmentTree<RA> lst(n);
	while (q--) {
		cin >> type;
		if (type) {
			cin >> x; x--;
			printf("%d\n", lst.find(x, x));
		}
		else {
			cin >> s >> t >> x; s--, t--;
			lst.update(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4920
use std::{
  io::{self, Write},
  str,
};

struct Scanner<R> {
  reader: R,
  buf_str: Vec<u8>,
  buf_iter: str::SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> Scanner<R> {
  fn new(reader: R) -> Self {
      Self {
          reader,
          buf_str: Vec::new(),
          buf_iter: "".split_ascii_whitespace(),
      }
  }

  fn next<T: str::FromStr>(&mut self) -> T {
      loop {
          if let Some(token) = self.buf_iter.next() {
              return token.parse().ok().expect("Failed parse");
          }
          self.buf_str.clear();
          self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
          self.buf_iter = unsafe {
              let slice = str::from_utf8_unchecked(&self.buf_str);
              std::mem::transmute(slice.split_ascii_whitespace())
          }
      }
  }

  fn next_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).expect("Failed to read line");
    line.trim().to_string()
}
}

fn main() {
  let (stdin, stdout) = (io::stdin(), io::stdout());
  let mut cin = Scanner::new(stdin.lock());
  let mut cout = io::BufWriter::new(stdout.lock());

  let n: usize = cin.next();
  let mut cnt = vec![vec![0; 100]; 100];
  let mut p2 = vec![1; 10];
  let mut p5 = vec![1; 10];
  for i in 1..10 {
    p2[i] = p2[i - 1] * 2;
    p5[i] = p5[i - 1] * 5;
  }
  for _ in 0..n {
    let s: Vec<char> = cin.next_line().chars().collect();
    let mut mid = s.len();
    for i in 0..s.len() {
      if s[i] == '.' {
        mid = i;
        break;
      }
    }
    let x: u64;
    let y: u64;
    let l: usize;
    if mid == s.len() {
      let s: String = s.iter().collect();
      x = s.parse().ok().unwrap();
      y = 0;
      l = 0;
    } else {
      let u: String = (&s[0..mid]).iter().collect();
      let v: String = (&s[mid + 1..]).iter().collect();
      x = u.parse().ok().unwrap();
      y = v.parse().ok().unwrap();
      l = v.len();
    }
    let p10 = p2[l] * p5[l];
    let g = gcd(x * p10 + y, p10);
    let a = (x * p10 + y) / g;
    let mut b = p10 / g;
    let mut b2 = 0;
    let mut b5 = 0;
    while b % 2 == 0 {
      b /= 2;
      b2 += 1;
    }
    while b % 5 == 0 {
      b5 += 1;
      b /= 5;
    }
    for a2 in 0..10 {
      for a5 in 0..10 {
        let v = p2[a2] * p5[a5];
        if a % v == 0 {
          cnt[b2 * 10 + b5][a2 * 10 + a5] += 1;
        }
      }
    }
  }
  let mut ret: u64 = 0;
  for i in 0..100 {
    for j in 0..i {
      ret += cnt[i][j] * cnt[j][i];
    }
  }
  ret += cnt[0][0] * (cnt[0][0] - 1) / 2;
  writeln!(cout, "{}", ret).ok();
}

fn gcd(a: u64, b: u64) -> u64 {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}

Measured memory_bytes: 2276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;

const int N = 51;
const int A = 26;
int main() {
    int n;
    int a[N][A]{};
    int b[A];
    cin >> n;
    vector<string> vs;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vs.push_back(s);
    }
    for (int i = 0; i < vs.size(); i++) {
        for (int j = 0; j < vs[i].size(); j++) {
            a[i][vs[i][j] - 'a']++;
        }
    }
    for (int i = 0; i < A; i++) {
        int m = INF;
        for (int j = 0; j < vs.size(); j++) {
            m = min(m, a[j][i]);
        }
        b[i] = m;
    }
    for (int i = 0; i < A; i++) {
        for (int j = 0; j < b[i]; j++) {
            printf("%c", i + 'a');
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<queue>

using namespace std;

typedef pair<string,string> P;
map<string,int> M;
vector<P> V;
string start,goal;

bool much(int s, string a, string b){

  if(b.length()+s > a.length()) return false;

  for(int i = s,j = 0; i < s+b.length(); i++,j++)
    if(a[i] != b[j]) return false;
  return true;
}

vector<int> find(string str, string f){

  vector<int> VV;
  
  int pos = 0;
  while(pos < str.length()){
   
    if(much(pos,str,f)){
      VV.push_back(pos);
      pos += f.length();
      continue;
    }
    pos++;
  }
  /*
  for(int i = 0; i < str.length(); i++)
  if(much(i,str,f)) VV.push_back(i);*/
  return VV;
}

string replace(string s,int from,int num, string nex){
  string out = "";
  out += s.substr(0,from);
  out += nex;
  out += s.substr(min(from+num,(int)s.length()));
  return out;
}

int solve(){
  queue<string> Q;

  Q.push(start);

  while(!Q.empty()){
    string s = Q.front();
    Q.pop();
    vector<int> VV;

    string nex = "";

    for(int i = 0; i < V.size(); i++){
	VV = find(s,V[i].first);
	if(VV.size() == 0) continue;
	nex = s;
	int diff = 0;
      for(int j = 0; j < VV.size(); j++){
	//cout << "s " << s << endl;
	nex = replace(nex,VV[j]+diff,V[i].first.length(),V[i].second);
	diff += V[i].second.length()-V[i].first.length();
      }
       
      if(nex.length() > goal.length()) continue;
      if(M[nex] == 0){
	M[nex] = M[s]+1;
	if(nex == goal) return M[nex];
	Q.push(nex);
      }
   
      
    }
  }
  return -1;
}

void init(){
  M.clear();
  V.clear();
}

int main(){
  
  int n;
  while(cin >> n && n){
    init();

    for(int i = 0; i < n; i++){
      P p;
      cin >> p.first >> p.second;
      V.push_back(p);
    }
    cin >> start >> goal;
   
    cout << solve() << endl;

  }
  return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, M;
ll s[10];
char c[10];
string ans;
int main(){
	cin >> N >> M;
	ans = "???";
	REP(i,0,M){
		cin >> s[i] >> c[i];
		s[i]--;
		if(ans[s[i]] == '?'){
			ans[s[i]] = c[i];
		}else if(ans[s[i]] != c[i]){
			p(-1);
			return 0;
		}
	}
	ll start = 0;
	ll end = 10;
	if(N==2) start = 10, end = 100;
	else if(N==3) start = 100, end = 1000;
	REP(i,start,end){
		string now = to_string(i);
		if((ans[2]=='?' || ans[2] == now[2]) &&
			(ans[1]=='?' || ans[1] == now[1]) &&
			(ans[0]=='?' || ans[0] == now[0])){
			p(i);
			return 0;
		}
	}
	p(-1);
	return 0;
}

Measured memory_bytes: 256
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

// dp[i] -> true if first person wins with i stones in pile remaining. 

void solve(){
    lli n, k;
    cin >> n >> k;
    vi a(n); NA(i,0,n) cin >> a[i];
    vector<bool> dp(k+1, false);
    NA(i,0,k+1){
        NA(j,0,n) {
            if(i-a[j] >= 0  && !dp[i-a[j]]) 
                dp[i] = true;
        }
    }
    cout << ( dp[k] ? "First" : "Second" );
    return;
}
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;

}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

const int MAX_N = 100000 +1;
int pare[MAX_N] = {};
int rk[MAX_N] = {};
void init(int n){
    rep(i, n){
        pare[i] = i;
        rk[i] = i;
    }
}
int find(int x){
    if (x == pare[x])
        return x;
    return pare[x] = find(pare[x]); // 経路圧縮
}
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) // すでに結合済
        return;

    // rkの低い方をrkの高い方に併合
    if(rk[x] < rk[y])
        pare[x] = y;
    else
        pare[y] = x;
    if(rk[x] == rk[y])
        rk[x]++;
}
bool same(int x,int y){
    return find(x) == find(y);
}

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

    int N, M; cin >> N >> M;
    V<V<int>> L = V<V<int>>(N);
    init(M+1);
    rep(i,N) {
        int k; cin >> k; L[i] = V<int>(k);
        rep(j,k) cin >> L[i][j];
        REP(j,1,k) unite(L[i][0],L[i][j]);
    }

    REP(i,1,N) {
        if(!same(L[0][0], L[i][0])) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
int main()
{
	int a,b,c,d=1;
	scanf("%d %d",&a,&b);
	c=a;
	while(1){
		if(b==1){
			d=0;
			break;
		}
		if(b<=c) break;
		c+=a-1;
		d++;
	}
	printf("%d\n",d);
}

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++) cin >> S[i];
	vector<vector<int> > A(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') A[i][j] = 0;
			else A[i][j] = 1;
		}
	}
	vector<vector<int> > B(H, vector<int>(W - 1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			B[i][j] = A[i][j] ^ A[i][j + 1];
		}
	}
	vector<vector<int> > C(H, vector<int>(W - 1));
	for (int i = 0; i < W - 1; i++) {
		C[H - 1][i] = 1;
		for (int j = H - 2; j >= 0; j--) {
			if (B[j + 1][i] == B[j][i]) C[j][i] = C[j + 1][i] + 1;
			else C[j][i] = 1;
		}
	}
	int ANS = 0;
	for (int i = 0; i < H; i++) {
		stack<pair<int, int> > ST;
		ST.push({ C[i][0], 0 });
		for (int j = 1; j < W - 1; j++) {
			int X = j;
			while (!ST.empty() && ST.top().first > C[i][j]) {
				ANS = max(ANS, ST.top().first * (j - ST.top().second + 1));
				X = ST.top().second;
				ST.pop();
			}
			ST.push({ C[i][j], X });
		}
		while (!ST.empty()) {
			ANS = max(ANS, ST.top().first * (W - ST.top().second));
			ST.pop();
		}
	}
	cout << max(ANS, max(H, W)) << endl;
}

Measured memory_bytes: 53504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else if(s=="ARC") cout << "ABC" << endl;
    return 0;     
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

	vector<pair<int, int> > vec;
	vec.push_back(make_pair(S[0] - '0', 0));
	for (int i = 1, ch = S[0] - '0'; i <= N; i++){
		if(i != N){
			if (S[i - 1] != S[i]){
				ch = 1 - ch;
				vec.push_back(make_pair(ch, i));
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < vec.size(); i++){
		cerr << vec[i].first << ", " << vec[i].second << endl;
		if (vec[i].first == 0){
			ans = max(ans, ((i + 2 * K >= vec.size()) ? N : vec[i + 2 * K].second) - vec[i].second);
		} else {
			ans = max(ans, ((i + 2 * K + 1 >= vec.size()) ? N : vec[i + 2 * K + 1].second) - vec[i].second);
		}
	}

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


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

int main(){
  ll n,y;
  cin>>n>>y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=n-i;j++){
      ll s=y-1000*i-5000*j;
      if(s%10000==0&&s/10000+i+j==n){
        cout<<s/10000<<" "<<j<<" "<<i<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long a,b;
    
    cin>>a>>b;
    
    if(a*500>=b)
     cout<<"Yes";
    else 
     cout<<"No";
      
    return 0;
}
     
   




Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;

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

  long long ans =0;
  for(int i=0; i<=n; ++i){
    if(i%3 != 0 && i%5 !=0) ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int n,ans=0;
    string s;
    cin>>n>>s;
    for (int i=0;i<s.size()-2;i++)
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            ans++;
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;


int main()
{
	ll A,B,C,K;
	ll ans = 0;
	cin>>A>>B>>C>>K;
	if( A + B >= K){
		ans = min(A,K);
	}else{
		K = K - (A+B);
		ans = A  - K;
	}
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, D; cin >> N >> D;
	D = 2 * D + 1;
	int ans = (N + D - 1) / D;
	cout << ans << endl;

	return 0;
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n=in();
  vi a(n);
  rep(i,n) cin>>a[i];
  sort(ALL(a));
  reverse(ALL(a));
  int alice=0,bob=0;
  rep(i,n)
  {
    if(i%2==0) alice+=a[i];
    else bob+=a[i];
  }
  print(alice-bob);

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  if (~n & 1) {
    int s0 = 0, s1 = 0;
    for (int i = 0; i < n; i += 2) {
      s0 += a[i];
      s1 += a[i + 1];
    }
    cout << max(s0, s1) << ' ' << min(s0, s1);
  } else {
    int s0 = a[0], s1 = 0;
    for (int i = 1; i < n; i += 2) {
      s1 += a[i];
      s0 += a[i + 1];
    }
    function<bool(int)> pred = [&](int x) {
      x -= s1;
      vector<int> pre(n);
      pre[0] = a[0];
      for (int i = 1; i < n; ++i) {
        if (i & 1)
          pre[i] = pre[i - 1] - a[i];
        else
          pre[i] = pre[i - 1] + a[i];
      }
      int minimal = 0;
      for (int i = 1; i < n; i += 2)
        if (pre[i - 1] - minimal >= x)
          minimal = min(minimal, pre[i]);
      return pre[n - 1] - minimal >= x;
    };
    int l = s0, r = s0 + s1;
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      if (pred(mid))
        l = mid;
      else
        r = mid - 1;
    }
    cout << l << ' ' << s0 + s1 - l;
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

using namespace std;

#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-8;
const double pi=acos(-1.0);
const int K=1e6+7;
const int mod=1e9+7;


LL ansa,ansb,sum,ls,n,x,a[K];
int main(void)
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ls=1,sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i];
        if(sum==0&&ls>0)
            sum=ls=-1,ansa+=1;
        else if(sum==0&&ls<0)
            sum=ls=1,ansa+=1;
        else if(sum>0&&ls>0)
            ansa+=sum+1,sum=ls=-1;
        else if(sum<0&&ls<0)
            ansa+=1-sum,ls=sum=1;
        else
            ls=sum;
    }
    ls=-1,sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i];
        if(sum==0&&ls>0)
            sum=ls=-1,ansb+=1;
        else if(sum==0&&ls<0)
            sum=ls=1,ansb+=1;
        else if(sum>0&&ls>0)
            ansb+=sum+1,sum=ls=-1;
        else if(sum<0&&ls<0)
            ansb+=1-sum,ls=sum=1;
        else
            ls=sum;
    }
    cout<<min(ansa,ansb)<<endl;
    return 0;
}


Measured memory_bytes: 1024