akhauriyash/Code-Regression huggingface dataset:
N,K,Q = list(map(int, input().split()))
A = [int(input()) for i in range(Q)]

P = [(K-Q) for i in range(N+1)]
for i in range(Q):
    P[A[i]] = P[A[i]] + 1 

for i in range(1,N+1):
    if P[i] > 0 :
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x;
  int sum = 0;
  cin >> N >> x;
  vector<int> vec(N);
  for (int i = 0;i < N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    sum+=vec.at(i);
    if( x < sum ){
      cout << i << endl;
      break;
    }
    if( i == N - 1){
      if(x==sum)
      cout << i + 1<<endl;
      else{
        cout << i << endl;
      }
  }
  }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
W,H,N=map(int,input().split())

def paint(mth,lis,w,h):
    if mth==1:
        for i in range(H):
            for j in range(w):
                l[i][j]=1
    elif mth==2:
        for i in range(H):
            for j in range(w,W):
                l[i][j]=1
    elif mth==3:
        for i in range(h):
            for j in range(W):
                lis[i][j]=1
    else:
        for i in range(h,H):
            for j in range(W):
                lis[i][j]=1
                
l=[[0]*W for i in range(H)]

for _ in range(N):
    x,y,a=map(int,input().split())
    paint(a,l,x,y)

ans=0
for i in range(H):
    for j in range(W):
        ans+=l[i][j]

print(H*W-ans)


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

int main(){
    int H, W;
    cin >> H >> W;
    string S[H];
    string O[H];
    for (int i=0; i<H; i++){
        cin >> S[i];
    }
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            if(S[i][j] == '#'){
                cout << '#';
                continue;
            }

            int count = 0;
            if(i-1 >= 0 && j-1 >= 0){
                if (S[i-1][j-1] == '#') count++;
            }
            if(i-1 >= 0){
                if (S[i-1][j] == '#') count++;
            }
            if(i-1 >= 0 && j+1 <= W-1){
                if (S[i-1][j+1] == '#') count++;
            }
            if(j-1 >= 0){
                if (S[i][j-1] == '#') count++;
            }
            if(j+1 <= W-1){
                if (S[i][j+1] == '#') count++;
            }
            if(i+1 <= H-1 && j-1 >= 0){
                if (S[i+1][j-1] == '#') count++;
            }
            if(i+1 <= H-1){
                if (S[i+1][j] == '#') count++;
            }
            if(i+1 <= H-1 && j+1 <= W-1){
                if (S[i+1][j+1] == '#') count++;
            }
            cout << count;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#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;
ll ans;
ll div5(ll n){
	ll ret = 0;
	while(n > 0 and n % 10 ==0){
		n /= 5;
		ret++;
	}
	return ret;
}
int main(){
	cin >> N;
	if (N % 2 == 1 || N < 10){
		p(0);
	}else{
		ll num5 = div5(N);
		ll now=10;
		ll cnt=1;
		while(now <= N){
			ans += cnt * (N/now);
			now *= 5;
//			cnt ++;
		}
		p(ans);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K,X,Y;
cin>>N>>K>>X>>Y;
long long sum=0;
for(int i=1;i<=N;i++){
    if(i>K)sum+=Y;
    else sum+=X;
}
cout<<sum;
  return 0;
}


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

int main ()
{
    ll n,d,t;
    int ans=0;
    ll x,y;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        t=x*x+y*y;
        if(t<=d*d) ans++;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>

using namespace std;
int main()
{
	char a, b;
	cin >> a >> b;
	if (a == b) cout << 'H' << endl;
	else cout << 'D' << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))

# N=O(10^5)なので、O(N)で解く
# ABC-155-C-Poll の類題
# 方針：各数字の出現回数を数える

# Counter(リスト) は辞書型のサブクラスであり、キーに要素・値に出現回数という形式
# Counter(リスト).most_common() は(要素, 出現回数)というタプルを出現回数順に並べたリスト
A = Counter(A).most_common()

# 出現回数の大きい方からK個はそのままにしておく(=変えない個数）
# 変える個数は、N-(変えない個数)
s = 0
for i in range(min(K, len(A))):
  s += A[i][1]
  
print(N-s)

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

int main()
{
    int a, b; cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}

Measured memory_bytes: 3080
function Main(input) {
  var S = input[0];
  var n;

  if (S == "SUN") {
    n = 7;
  }
  if (S == "MON") {
    n = 6;
  }
  if (S == "TUE") {
    n = 5;
  }
  if (S == "WED") {
    n = 4;
  }
  if (S == "THU") {
    n = 3;
  }
  if (S == "FRI") {
    n = 2;
  }
  if (S == "SAT") {
    n = 1;
  }
  console.log("%s", n);
}

Main(
  require("fs")
    .readFileSync("/dev/stdin", "utf8")
    .split("\n")
);


Measured memory_bytes: 25160
import sys

S = raw_input()
S = S[::-1]
T = ''
words = ['dreamer', 'dream', 'eraser', 'erase']
for i in range(len(words)):
    words[i] = words[i][::-1]
while len(S):
    N = len(S)
    for word in words:
        if S[:len(word)] == word:
            S = S[len(word):]
            break
    if N == len(S):
        sys.stdout.write('NO')
        break
    if len(S) == 0:
        sys.stdout.write('YES')

Measured memory_bytes: 2948
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

def check(a):
    for l in range(len(a) - 1):
        if not -1 <= a[l] - a[l + 1] <= 1:
            return False
    return True

x = [0]
k = I()
ret = 0
j = len(x) - 1
while True:
    if x == [9] * len(x):
        x = [1] + [0] * len(x)
        ret += 1
        j = len(x) - 1
        if ret == k:
            print(''.join([str(m) for m in x]))
            exit()
    if j and (x[j - 1] + 1 == x[j] or x[j] == 9):
        j -= 1
        continue
    x[j] += 1
    for n in range(j + 1, len(x)):
        x[n] = x[n - 1] - 1 if x[n - 1] else 0
    j = len(x) - 1
    ret += 1
    if ret == k:
        print(''.join([str(m) for m in x]))
        exit()


Measured memory_bytes: 44764
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 310, mod = 998244353;
int n,f[N][N][N],C[N][N];
char s[N],a[N];
bool dp[N][N][N],vis[N][N];

inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}

int main(){
	scanf("%s",s+1),n=strlen(s+1);
	For(i,1,n) a[i]=s[i];
	dp[0][0][0]=1;
	FOR(i,0,n) For(j,0,i) For(k,0,i) if (dp[i][j][k]){
		if (a[i+1]==a[i+2]){
			if (a[i+1]=='0') dp[i+2][j+1][k]=1;
				else dp[i+2][j][k+1]=1;
		} else {
			dp[i+2][j+1][k]=dp[i+2][j][k+1]=1;
		}
		if (j){
			if (a[i+1]=='0') dp[i+1][j][k]=1;
				else dp[i+1][j-1][k+1]=1,dp[i+1][j][k]=1;
		}
		if (k){
			if (a[i+1]=='1') dp[i+1][j][k]=1;
				else dp[i+1][j][k]=1,dp[i+1][j+1][k-1]=1;
		}
	}
	f[n+1][0][0]=f[n+2][0][0]=1;
	Dow(i,n+1,1) For(j,0,n) For(k,0,n) if (f[i][j][k]){
		if (a[i-1]=='0'){
			upd(f[i-1][j][k],f[i][j][k]);
			upd(f[i][j][k+1],f[i][j][k]);
		} else {
			upd(f[i-1][j][k],f[i][j][k]);
			upd(f[i][j+1][k],f[i][j][k]);
		}
	}
	C[0][0]=1;
	For(i,1,n){
		C[i][0]=1;
		For(j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	int cnt0=0,cnt1=0,ans=0;
	Dow(i,n,0){
		For(j,0,i) For(k,0,i) if (dp[i][j][k]){
			if (vis[cnt0+j][cnt1+k]) continue;
			For(l,0,j) For(p,0,k){
				ans=(ans+1ll*f[i+2][j-l][k-p]*C[l+p][l])%mod;
			}
			vis[cnt0+j][cnt1+k]=1;
		}
		if (s[i]=='0') ++cnt0;
			else ++cnt1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 123308
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=4005;
const int M=1e6+5;
const int mod=1e9+7;
int n,ans,a[M],b[M],jc[M],inv[M],f[N][N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int C(int n,int m)
{
	return jc[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main()
{
	n=read();
	jc[0]=jc[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=10000;i++)jc[i]=jc[i-1]*i%mod;
	for(int i=2;i<=10000;i++)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=10000;i++)inv[i]=inv[i]*inv[i-1]%mod;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();b[i]=read();
		f[-a[i]+2000][-b[i]+2000]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++)
		{
			f[i+1][j]=(f[i+1][j]+f[i][j])%mod;
			f[i][j+1]=(f[i][j+1]+f[i][j])%mod;
		}
	for(int i=1;i<=n;i++)
	{
		ans=(ans+f[a[i]+2000][b[i]+2000])%mod;
		ans=(ans-C(2*a[i]+2*b[i],2*a[i])+mod)%mod;
	}
	cout<<ans*inv[2]%mod;
}

Measured memory_bytes: 137472
n = gets.chomp.to_i
B = gets.chomp.split(' ').map(&:to_i)

A = [B[0], B]
A.flatten!

(0..(n - 2)).each do |i|
  if B[i] < A[i]
    A[i] = B[i]
  end
end

puts A.inject(0) { |result, x| result + x} .to_s


Measured memory_bytes: 1788
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
#define int long long
const int N=1e5;
struct S1{
	#define ls (p<<1)
	#define rs (p<<1|1)
	int tree[(N<<3)+10];
	void pushdown(int p){
		if (!tree[p])	return;
		tree[ls]=tree[rs]=tree[p];
		tree[p]=0;
	}
	void Modify(int p,int l,int r,int x,int y,int v){
		if (x>y)	return;
		if (x<=l&&r<=y){
			tree[p]=v;
			return;
		}
		pushdown(p);
		int mid=(l+r)>>1;
		if (x<=mid)	Modify(ls,l,mid,x,y,v);
		if (y>mid)	Modify(rs,mid+1,r,x,y,v);
	}
	int Query(int p,int l,int r,int x){
		if (l==r)	return tree[p];
		pushdown(p);
		int mid=(l+r)>>1;
		if (x<=mid)	return Query(ls,l,mid,x);
		else	return Query(rs,mid+1,r,x);
	}
	#undef ls
	#undef rs
}ST;//Segment Tree
int A[N+10],B[N+10];
int L[N+10],R[N+10];
ll sum[N+10],f[N+10];
int list[(N<<1)+10];
int n,K,T,tot;
ll Get(int x){
	int tmp=ST.Query(1,1,T,x);
	if (!tmp)	return 0;
	return f[tmp]+(list[L[tmp]]-list[x]+K)%K;
}
signed main(){
	n=read(),K=read();
	bool flag=0;
	for (int i=1;i<=n;i++){
		A[i]=read(),B[i]=read();
		sum[i]=sum[i-1]+A[i];
		if (B[i]==2)	continue;
		if (2*A[i]>K)	flag=1;
	}
	if (flag){
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++){
		if (B[i]==1){
			L[i]=(-2*sum[i-1]%K+K)%K;
			R[i]=(-2*sum[i  ]%K+K)%K;
		}else	L[i]=0,R[i]=K-1;
		list[++tot]=L[i];
		list[++tot]=R[i];
	}
	sort(list+1,list+1+tot);
	T=unique(list+1,list+1+tot)-list-1;
	for (int i=1;i<=n;i++){
		L[i]=lower_bound(list+1,list+1+T,L[i])-list;
		R[i]=lower_bound(list+1,list+1+T,R[i])-list;
	}
	for (int i=n;i;i--){
		f[i]=Get(L[i]);
		if (R[i]<L[i])	ST.Modify(1,1,T,R[i]+1,L[i]-1,i);
		else	ST.Modify(1,1,T,1,L[i]-1,i),ST.Modify(1,1,T,R[i]+1,T,i);
	}
	ll Ans=f[1];
	for (int i=1;i<=T;i++)	Ans=min(Ans,Get(i));
	printf("%lld\n",Ans+2*sum[n]);
	return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string st;
    cin>>st;
    ll arr[n];
    REP(i,n){
        arr[i]=st[i]=='R'?0:1;
    }
    ll i=0;
    ll j=n-1;
    ll ans=0;
    while(i<j){
        while(i<j && arr[i]!=1){
            i++;
        }
        while(i<j && arr[j]!=0){
            j--;
        }
        if(i!=j){
            ans++;
            i++;
            j--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5320
import math

n, k = input().split()
n = int(n)
k = int(k)

prob = 0

def calc_count(score,k):
    ''' 出た目とKから達成するための振る回数を割り出す '''
    count = 0
    while ( score < k ) :
        count = count + 1
        score = score * 2
    return count

def calc_prob(n, count):
    return 1/n * (0.5**count)


for i in range(1,n+1):
    prob = prob + calc_prob(n, calc_count(i, k))

print(prob)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b,n,a=0;cin>>r>>g>>b>>n;
  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=(n-i*r)/g;j++){
      if((n-i*r-j*g)%b==0)a++;
    }
  }
  cout<<a<<endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	vi p(n), a(n), b(n);
	for (auto& i : p) {
		cin >> i;
		--i;
	}
	
	for (int i = 0; i < n; ++i)
		a[i] = (i + 1) * 3e4;
	
	for (int i = n - 1; i >= 0; --i)
		b[i] = (n - i) * 3e4;
	
	int li = -1, change = 0;
	for (auto i : p) {
		if (li == -1) {
			li = i;
		} else {
			if (i > li) {
				a[i] += ++change;
			} else {
				b[i] += ++change;
			}
		}
	}
	
	for (auto i : a) cout << i << ' ';
	cout << '\n';
	for (auto i : b) cout << i << ' ';
}


Measured memory_bytes: 3744
n=int(input())
tmp=0
ans=0
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        tmp+=1
        if tmp>ans:
            ans=tmp
    else:
        tmp=0
if ans>2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62292
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()

  println(abc162a(a, b))
}

private fun abc162a(a: Int, b: Int): Int {
  var unuse = 1

  var ans = 0
  while (unuse < b) {
    unuse--
    unuse += a
    ans++
  }

  return ans
}


Measured memory_bytes: 31392
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;
}

Measured memory_bytes: 256
# your code goes here
l = list(map(int,input().split()))
l.sort()

a = l[0]%2
b = l[1]%2
c = l[2]%2

if a == b:
	print(int((l[1]-l[0])/2)+int(l[2]-l[1]))
elif a == c:
	l[0] = l[0]+1
	l[2] = l[2]+1
	print(int((l[1]-l[0])/2)+int(l[2]-l[1])+1)
else:
	l[1] = l[1] +1
	l[2] = l[2] + 1
	print(int((l[1]-l[0])/2)+int(l[2]-l[1])+1)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[][] txy = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray();

        for(int i = 0; i < n; i++)
        {
            int t = txy[i][0];
            int x = txy[i][1];
            int y = txy[i][2];
            int tmp = t - (x + y);
            if(tmp >= 0 && tmp % 2 == 0)
            {
                continue;
            }
            else
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");

    }
}

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

using namespace std;

int main(int argc, char *argv[])
{
	int d[3];

	for (int i = 0; i < 3; i++) {
		cin >> d[i];
	}
	sort(d, d + 3);

	cout << d[0] + d[1] << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
int main(){
  int a,b,c;
  int x,d,n;
  scanf("%d%d%d",&a,&b,&c);
  x=max(a,max(b,c));
  printf("%d",a+b+c+x*9);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> // Ishaan Gupta
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cout << *x, 0);
sim > char dud(...);
struct debug {
#ifdef IG_PC
~debug() { cout << endl; }
eni(!=) cout << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
#define pb push_back
using ll = long long;
using ld = long double;
const ll MOD = 1e9l + 7;
const ll INF = 1e18l + 5;
inline ll add(ll a,ll b){return (a%MOD+b%MOD)%MOD;}
inline ll sub(ll a,ll b){return (a%MOD-b%MOD+MOD)%MOD;}
inline ll mult(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll power(ll a,ll b){a%=MOD;ll r=1;while(b){if(b&1)r=mult(r,a);a=mult(a,a);b>>=1;}return r;}

const ll MAX = 1e5+5;
vector<ll>adj[MAX];
ll in_degree[MAX];
ll dist[MAX];
ll visited[MAX];

void dfs(ll node)
{
    visited[node]=1;
    for(ll to : adj[node])
    {
        dist[to] = max(dist[to], dist[node] + 1);
        --in_degree[to];
        if(in_degree[to] == 0)
        {
            dfs(to);
        }
    }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
#ifdef IG_PC
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
#endif
    ll n,m;
    cin >> n >> m;
    while(m--)
    {
        ll x,y;
        cin >> x >> y;
        adj[x].pb(y);
        ++in_degree[y];
    }
    for(ll i = 1; i <= n; ++i)
    {
        if(!visited[i] && in_degree[i]==0)
        {
            dfs(i);
        }
    }
    ll ans =0;
    for(ll i : dist)
    {
        ans = max(ans, i);
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  int ok = 1;

  h[0]--;
  for (int i = n - 1; i > 1; i--){
    if (h[i] < h[i - 1]){
      h[i - 1]--;
    }
  }
  for (int i = 1; i < n; i++){
    if (h[i - 1] > h[i]){
      ok = 0;
    }
  }



  if(ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll x,t;
    cin>>x>>t;
    ll ans=x-t;
    if(ans<=0) ans=0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int par[50];
int root(int x){
    if(par[x] == x){return x;}
    return par[x] = root(par[x]);
}

int unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry){
        return 0;
    }
    par[rx] = ry;
    return 1;
}

int same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry){
        return 1;
    }
    return 0;
}
int main(void){
    int N, M;
    int i, j;
    int a[1225], b[1225];
    scanf("%d%d", &N, &M);

    for(i = 0; i < M; i++){
        scanf("%d%d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
    }
    
    int ans = 0;

    for(i = 0; i < M; i++){
        for(j = 0; j < N; j++){
            par[j] = j;
        }
        for(j = 0; j < M; j++){
            if(i == j){
                continue;
            }
            unite(a[j], b[j]);
        }
        if(same(a[i], b[i]) == 0){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;   
}

Measured memory_bytes: 1712
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#include <regex>
#include <queue>
#include <string>
#include <set>

typedef  long long lol;
using namespace std;

#define fori(i,j,k) for (int (i)=(j);(i) < (k);(i)++)
#define MOD 1000000007
#define EPS 0.000000001

int dsu[1000000];
int find(int x)
{
	if (dsu[x] == x)
		return x;
	return dsu[x] = find(dsu[x]);
}

void unite(int a, int b)
{
	dsu[find(a)] = find(b);
}


int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
		dsu[i] = i;

	vector<pair<int, int>> xx, yy;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		xx.push_back({ x,i });
		yy.push_back({ y,i });
	}
	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());

	vector < pair<int, pair<int, int>>> dists;
	for (int j = 1; j < xx.size(); j++)
	{
		dists.push_back({ xx[j].first - xx[j - 1].first, {xx[j].second,xx[j - 1].second} });
		dists.push_back({ yy[j].first - yy[j - 1].first,{ yy[j].second,yy[j - 1].second } });
	}

	int resp = 0;
	sort(dists.begin(), dists.end());
	for (auto x : dists)
	{
		if (find(x.second.first) != find(x.second.second))
		{
			resp += x.first;
			unite(x.second.first, x.second.second);
		}
	}

	cout << resp;
	return 0;
}

Measured memory_bytes: 7528
def mempow(a,b,m):
    temp = 1
    yield temp
    for i in range(b):
        temp = temp * a % m
        yield temp

L = input()
m = 1000000007
mem2 = []
mem3 = []
m2append = mem2.append
m3append = mem3.append
for x in mempow(2,L.count('1'),m):
    m2append(x)
for x in mempow(3,len(L)-1,m):
    m3append(x)
ans = mem3[len(L)-1]
appeared = 1
for i in range(1,len(L)):
    if L[i] == '1':
        ans = (ans+mem2[appeared]*mem3[len(L)-i-1]) % m
        appeared += 1
ans = (ans+mem2[appeared]) % m
print(ans)

Measured memory_bytes: 11132
#include <stdio.h>

int main(){
  int x,y,r;
  int i,j;

  scanf("%d %d",&x, &y);

  if(x<y){
    i=x;
    x=y;
    y=i;
  }
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 592
/* ****GT_18**** */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define INF			1000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
using namespace __gnu_pbds;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll ans=a*c;
		ans=max(ans,a*d);
		ans=max(ans,b*c);
		ans=max(ans,b*d);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
M = 10**9 + 7
a = [1] + [0] * 12
p = 1
for c in reversed(input()):
    r = range(0, p * 10, p) if c == '?' else (p * int(c),)
    a = [sum(a[(i - j) % 13] for j in r) % M for i in range(13)]
    p = p * 10 % 13
print(a[5])

Measured memory_bytes: 48044
INF = 2**31-1
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [INF for _ in range(n)]

dp[0] = 0

for i in range(0,n):
    for j in range(1,k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], abs(h[i+j] - h[i]) + dp[i])
        else: break

print(dp[n-1])

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

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


int main(){
  string s; cin>>s;
  bool ans=true;
  for(int i=0;i<s.size();i++){

    if(i%2==0){
        if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){ans=false; break;}
    }else {
     if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){ans=false; break;}
    }
  }

   if(ans)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
string S;
ll K;
int N;
int main() {
  cin >> S;
  cin >> K;
  N = S.size();
  ll src = -1;
  for (int i = 0; i < N; i++)
  {
    if (S[i] != '1')
    {
      src = i;
      break;
    }
  }
  if (src <= -1 || K <= src)
  {
    cout << 1 << endl;
    return 0;
  }
  cout << S[src] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll, ll>
#define FOR(I, A, B) for(int I = ll(A); I < ll(B); ++I)
#define FORR(I, A, B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x, t, f) ((x) ? (t) : (f))
#define SORT(x) (sort(x.begin(), x.end()))                          // 0 2 2 3 4 5 8 9
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin()) //xi>=v  x is sorted
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin()) //xi>v  x is sorted
#define NUM(x, v) (POSU(x, v) - POSL(x, v))                         //x is sorted
#define REV(x) (reverse(x.begin(), x.end()))                        //reverse
ll gcd(ll a, ll b) {
    if(a % b == 0) return b;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    ll c = gcd(a, b);
    return ((a / c) * (b / c) * c);
}
#define NEXTP(x) next_permutation(x.begin(), x.end())
const ll INF = ll(1e16) + ll(7);
const ll MOD = 1000000007LL;
#define out(a) cout << fixed << setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a) {
    ll r = 0;
    while(a) {
        a /= 10;
        r++;
    }
    return r;
}

int dp[2][1 << 23];
int main() {
    int n, m;
    while(cin >> n >> m, n + m) {
        for(int i=0;i<2;i++){
            for(int j=0;j<1<<23;j++){
                dp[i][j]=0;
            }
        }
        vector<string> s(n);
        FOR(i, 0, n)
        cin >> s[i];

        if(m < 23) {
            int ans = 0;
            dp[0][0] = 1;
            FOR(i, 1, n + 1) {
                int k = 0;
                FOR(j, 0, m)
                if(s[i - 1][j] == '1') k += (1 << j);
                FOR(j, 0, 1 << m)
                dp[i % 2][j] = dp[(i - 1) % 2][j];
                FOR(j, 0, 1 << m) {
                    if(dp[(i - 1) % 2][j ^ k] > 0) dp[i % 2][j] = max(dp[i % 2][j], dp[(i - 1) % 2][j ^ k] + 1);
                    if(j == 0) ans = max(ans, dp[i % 2][j]);
                }
                //cout << dp[i%2][0] << endl;
            }
            cout << ans-1 << "\n";
        } else {
            int ans = 0;
            FOR(S, 0, 1 << n) {
                int anst = 0;
                int x = 0;
                int ok[m]={};
                FOR(i, 0, n) {
                    if(S & (1 << i)) {
                        anst++;
                        int k = 0;
                        FOR(j, 0, m) {
                            if(s[i][j] == '1') ok[j]^=1;
                        }
                    }
                }
                for(int i=0;i<m;i++)x+=ok[i];
                if(x == 0) ans = max(ans, anst);
            }
            cout << ans << "\n";
        }
    }
}



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

using namespace std;

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is D.Balanced Strings
*/

int main(){
    string s; cin>>s;
    for(auto& c:s) c-='a'; //This is with the assumption that all the characters will be small
    vector<vector<int>> a(100010,vector<int> (26,0));
    for(int i=1;i<=s.length();i++){
        a[i]=a[i-1];
        a[i][s[i-1]]++;
        //There are 2 cases that can be solved regarding this
        if(i-2>=0 && (a[i][s[i-1]]-a[i-2][s[i-1]])>=2){
            cout<<i-1<<" "<<i;
            return 0;
        }
        else if(i-3>=0 && (a[i][s[i-1]]-a[i-3][s[i-1]]>=2)){
            cout<<i-2<<" "<<i;
            return 0;
        }
    }
    cout<<-1<<" "<<-1;
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define piii pair<int,pii>
const ll MAXN=5e5;
const ll mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int N,M,a,b,c;
ll dp[4100];
int price[1010];
int locks[1010];
bool subset(int i,int j){
    if(j==i) return(true);
    if(j>i) return(false);
    while(j){
        if(i%2!=j%2) return(false);
        i/=2;
        j/=2;
    }
    return(true);
}
void solve(){
    for(int i=0;i<4100;i++)
        dp[i]=MAX;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>price[i]>>b;
        locks[i]=0;
        while(b--){
            cin>>c;
            locks[i]+=(1<<(c-1));
        }
    }
    /*
    for(int i=0;i<M;i++){
        cout<<price[i]<<" "<<locks[i]<<endl;
    }
    */
    dp[0]=0;
    for(int j=0;j<M;j++){
        ll now=locks[j];
        for(int i=0;i<(1<<N);i++){
            dp[i|locks[j]]=min(dp[i|locks[j]],dp[i]+price[j]);
        }

    }

    //for(int i=0;i<=(1<<N);i++) cout<<dp[i]<<" ";






    if(dp[(1<<N)-1]>=MAX) cout<<-1;
    else cout<<dp[(1<<N)-1];

    return;

}
int main(){
    IO
    //TEST
    solve();

    return(0);
}


Measured memory_bytes: 3700
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  int N,K;
  cin >> N >> K;
  vector<vint> g(N);
  vint A(N-1),B(N-1);
  repeat(i,N-1){
    cin >> A[i] >> B[i];
    A[i]--;B[i]--;
    g[A[i]].push_back(B[i]);
    g[B[i]].push_back(A[i]);
  }
  int ans = INF;
  repeat(i,N){
    int res=0;
    queue<Pii> Q;
    vector<bool> isvisted(N,false);
    Q.push({i,0});
    while(!Q.empty()){
      Pii u = Q.front();
      Q.pop();
      if(isvisted[u.first]) continue;
      isvisted[u.first] = true;
      if(u.second*2 > K) break;
      res++;
      for(auto v:g[u.first]){
        Q.push({v,u.second+1});
      }
    }
    ans = min(ans,N-res);
  }
  repeat(i,N-1){
    int res=0;
    queue<Pii> Q;
    vector<bool> isvisted(N,false);
    Q.push({A[i],0});
    Q.push({B[i],0});
    while(!Q.empty()){
      Pii u = Q.front();
      Q.pop();
      if(isvisted[u.first]) continue;
      isvisted[u.first] = true;
      if(u.second*2 > K-1) break;
      res++;
      for(auto v:g[u.first]){
        Q.push({v,u.second+1});
      }
    }
    ans = min(ans,N-res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int a,b;
  cin >> a >> b;
  
  int ans = -1000000;
  ans = max(ans,a+b);
  ans = max(ans,a-b);
  ans = max(ans,a*b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b,m;
	std::cin >> a >> b >> m;
	std::vector<int> A(a), B(b);
	for(auto&x:A) std::cin >> x;
	for(auto&x:B) std::cin >> x;
	int min = 1e10;
	rep(i,m) {
		int x,y,c;
		std::cin >> x >> y >> c;
		x--;y--;
		min = std::min(min,A[x]+B[y]-c);
	}
	std::sort(all(A));
	std::sort(all(B));
	min = std::min(min,A[0]+B[0]);
	print(min);
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(void) {
  char s[16];
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 15; i++) {
    if (s[i] == '\0') break;
    if (s[i] == 'x') cnt++;
  }
  if (cnt >= 8) {
    cout << "NO" << endl;
    
  } else {
    cout << "YES" << endl;
   }

  return 0;
}


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

int main() {
  char C;
  cin >> C;
  
  if(C=='a'){
    cout<<"b"<<endl;
  }
  if(C=='b'){
    cout<<"c"<<endl;
  }
  if(C=='c'){
    cout<<"d"<<endl;
  }
  if(C=='d'){
    cout<<"e"<<endl;
  }
  if(C=='e'){
    cout<<"f"<<endl;
  }
  if(C=='f'){
    cout<<"g"<<endl;
  }
  if(C=='g'){
    cout<<"h"<<endl;
  }
  if(C=='h'){
    cout<<"i"<<endl;
  }
  if(C=='i'){
    cout<<"j"<<endl;
  }
  if(C=='j'){
    cout<<"k"<<endl;
  }
  if(C=='k'){
    cout<<"l"<<endl;
  }
  if(C=='l'){
    cout<<"m"<<endl;
  }
  if(C=='m'){
    cout<<"n"<<endl;
  }
  if(C=='n'){
    cout<<"o"<<endl;
  }
  if(C=='o'){
    cout<<"p"<<endl;
  }
  if(C=='p'){
    cout<<"q"<<endl;
  }
  if(C=='q'){
    cout<<"r"<<endl;
  }
  if(C=='r'){
    cout<<"s"<<endl;
  }
   if(C=='s'){
    cout<<"t"<<endl;
  }
  if(C=='t'){
    cout<<"u"<<endl;
  }
  if(C=='u'){
    cout<<"v"<<endl;
  }
  if(C=='v'){
    cout<<"w"<<endl;
  }
  if(C=='w'){
    cout<<"x"<<endl;
  }
  if(C=='x'){
    cout<<"y"<<endl;
  }
  if(C=='y'){
    cout<<"z"<<endl;
  }
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<n-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
			ans++,i+=2;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3612
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
#pragma endregion

// {waapu, h, w}
using p = tuple<int, int, int>;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int h_size, w_size;
    cin >> h_size >> w_size;
    int h_from, w_from;
    cin >> h_from >> w_from;
    --h_from;
    --w_from;
    int h_to, w_to;
    cin >> h_to >> w_to;
    --h_to;
    --w_to;
    vector can_go(h_size, vector<bool>(w_size));
    rep(h, h_size)
    {
        rep(w, w_size)
        {
            char c;
            cin >> c;
            can_go[h][w] = (c == '.');
        }
    }

    // dijkstra
    int ans = -1;
    priority_queue<p, vector<p>, greater<p>> pq;
    vector used(h_size, vector<bool>(w_size, false));
    pq.push({0, h_from, w_from});
    while (not pq.empty())
    {
        auto [cost, h, w] = pq.top();
        pq.pop();
        if (h == h_to and w == w_to)
        {
            ans = cost;
            break;
        }
        if (used[h][w])
        {
            continue;
        }
        used[h][w] = true;
        FOR(dh, -2, 3)
        {
            FOR(dw, -2, 3)
            {
                auto h_new = h + dh, w_new = w + dw;
                if ((dh == 0 and dw == 0) or h_new < 0 or h_new >= h_size or w_new < 0 or w_new >= w_size)
                {
                    continue;
                }
                if (not can_go[h_new][w_new] or used[h_new][w_new])
                {
                    continue;
                }
                int dcost = (abs(dh) + abs(dw) > 1);
                pq.push({cost + dcost, h_new, w_new});
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
struct po
{
	double x,y;
}a[10];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i].x>>a[i].y;
	
	double ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ans+=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
		}
	}
	double sum;
	sum=ans/n;
	printf("%.10lf",sum);
}

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

int main() {
  int N;
  cin >> N;
  vector<string> red(N);
  for (int i = 0; i < N; i++) {
    cin >> red.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> blue(M);
  for (int i = 0; i < M; i++) {
    cin >> blue.at(i);
  }
  
  int max = 0;
  int res = 0;
  string word;
  
  for (int i = 0; i < N; i++) {
    word = red.at(i);
    for (int j = 0; j < N; j++) {
      if (word == red.at(j)) {
        res++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (word == blue.at(j)) {
        res--;
      }
    }
    if (max < res) {
      max = res;
    }
    res = 0;
  }
  
  for (int i = 0; i < M; i++) {
    word = blue.at(i);
    for (int j = 0; j < N; j++) {
      if (word == red.at(j)) {
        res++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (word == blue.at(j)) {
        res--;
      }
    }
    if (max < res) {
      max = res;
    }
    res = 0;
  }
  
  cout << max << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;

    long long c[100010][3];
    long long ans = -1e15;

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

    for (int i = 0; i < 8; i++) {
        vector<long long> w;
        for (int j = 0; j < n; j++) {
            long long v = 0;

            for (int k = 0; k < 3; k++) {
                if (i & (1<<k)) {
                    v += c[j][k];
                } else {
                    v -= c[j][k];
                }
            }

            w.push_back(v);
        }

        sort(w.rbegin(), w.rend());

        long long tmp = 0;
        for (int i = 0; i < m; i++) {
            tmp += w[i];
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
parseint(x) = parse(Int, x)
parselist(l) = map(parseint, l)

avg(x, y) = (x+y)/2

function main()
    n = readline() |> parseint
    v = readline() |> split |> parselist
    sort!(v)
    ans = v[1]
    for i = 2:n
        ans = avg(ans, v[i])
    end
    println(ans)
end

main()


Measured memory_bytes: 113148