akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define VI vector<int>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=200005;
vector<int> nxt[MAXN];
void ins(int x,int y){nxt[x].emplace_back(y);}
int n,ans[MAXN],sum[MAXN],upmx[MAXN];
void dfs(int x,int pre,int mx1,int dmx,int posy)
{
	if(x!=1)
	{
		int v=max(dmx,x);
		if(v<upmx[mx1])++sum[mx1];
		else if(v<mx1)++sum[posy];
		else ++sum[x];
	}
	upmx[x]=mx1;
	if(x>mx1)mx1=x,dmx=0;
	else if(x>dmx)dmx=x;
	for(auto y:nxt[x])if(y^pre)
		dfs(y,x,mx1,dmx,x==mx1?y:posy);
}
void queryans(int x,int pre,int c)
{
	c+=sum[x];ans[x]+=c;
	for(auto y:nxt[x])if(y^pre)queryans(y,x,c);
}
int main()
{
	#ifdef Rose
		double BeginJudgeTime=clock();
	#endif
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}
	dfs(1,0,0,0,0);
	queryans(1,0,0);
	for(int i=2;i<=n;i++)pr1(ans[i]);puts("");
	#ifdef Rose
		double EndJudgeTime=clock();
		cerr<<"JudgeTime is"<<" ";
		cerr<<(EndJudgeTime-BeginJudgeTime)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}


Measured memory_bytes: 29696
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);

		long h = sc.nextInt();
		long w = sc.nextInt();

		if(h%3 == 0 || w%3 == 0){
			System.out.println(0);
			return;
		}

//		if(h > w){
//			int tmp = h;
//			h = w;
//			w = tmp;
//		}

		long result = Long.MAX_VALUE;

		for(int i = 1; i <= h; i++){
			long area1 = (long)i*w;

			long h2 = h - i;
			long w2 = w;

			long area2;

			if(h2 % 2 == 0 || w2 % 2 == 0){
				area2 = h2*w2/2;
			}
			else {
				area2 = Math.max(h2, w2)/2*Math.min(h2, w2);
			}
			long area3 = h*w - area1 - area2;

//			if(i >= 32000 && i <= 34000)System.out.println("h1 = "+i+" "+area1+" "+area2 + " "+area3);

			long maxArea = Math.max(area1, Math.max(area2, area3));
			long minArea = Math.min(area1, Math.min(area2, area3));

			result = Math.min(maxArea - minArea, result);
		}

		for(int i = 1; i <= w; i++){
			long area1 = (long)i*h;

			long h2 = h;
			long w2 = w - i;

			long area2;
			if(h2 % 2 == 0 || w2 % 2 == 0){
				area2 = h2*w2/2;
			}
			else {
				area2 = Math.max(h2, w2)/2*Math.min(h2, w2);
			}
			long area3 = h*w - area1 - area2;

//			System.out.println("w1 = "+i+" "+area1+" "+area2 + " "+area3);

			long maxArea = Math.max(area1, Math.max(area2, area3));
			long minArea = Math.min(area1, Math.min(area2, area3));

			result = Math.min(maxArea - minArea, result);
		}


		System.out.println(result);
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int w,h;
void dfs(int y, int x, vector<vector<int>>& a, vector<vector<bool>>& check){
    if ((x<0)||(y<0)||(y>=h)||(x>=w)) return;
    if (a[y][x]==0) return;
    if (check[y][x]) return;
    check[y][x] = true;
    for (int i = -1; i<2; i++) {
        for (int j = -1; j<2; j++) {
                dfs(y+i, x+j, a, check);
        }
    }
    
}
int main() {
    while (true) {
        cin >> w >> h;
        if (w==0) {
            break;
        }
        vector<vector<int>> a(h,vector<int>(w));
        vector<vector<bool>> check(h,vector<bool>(w,false));
        int count = 0;
        REP(i, h){
            REP(j, w){
                cin >> a[i][j];
            }
        }
        
        REP(i, h){
            REP(j, w){
                if ((a[i][j]==1)&&(!check[i][j])) {
                    count++;
                    dfs(i, j, a, check);
                }
            }
        }
        COUT(count);
    }

}



Measured memory_bytes: 3300
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		if (N % 500 <= A) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *x = root;
    Node *y = NIL;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL){
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if (y == NIL) root = z;
    else{
        if (z->key < y->key) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u){
    if (u == NIL) return;

    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if (u == NIL) return;

    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

bool find(int k, Node *u){
    if (k == u->key) return true;

    if (u->left != NIL && k < u->key) return find(k, u->left);
    else if (u->right != NIL) return find(k, u->right);

    return false;
}

int main(){
    int n, x;
    string com;

    scanf("%d", &n);

    for (int i = 0; i < n; i++){
        cin >> com;
        if (com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if (com == "find"){
            scanf("%d", &x);
            if (find(x, root)) printf("yes\n");
            else printf("no\n");
        }else if (com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 22064
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	string s,t,ans;
	int nn,mm;
	int i,j,k;
	int flg[101];
	int x,y,z;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>s>>t;
		reverse(s.begin(),s.end());
		reverse(t.begin(),t.end());
		for(j=0;j<max(s.size(),t.size());j++)	flg[j]=0;
		if(s.size()>t.size()){
			nn=s.size()-t.size();
			for(j=0;j<nn;j++)	t+='0';
		}
		else{
			nn=t.size()-s.size();
			for(j=0;j<nn;j++)	s+='0';
		}
		ans.clear();
		for(j=0;j<s.size();j++){
			x=s[j]-'0';
			y=t[j]-'0';
			z=x+y+flg[j];
			flg[j+1]=z/10;
			ans+=z%10+'0';
		}
		if(flg[s.size()]>0)		ans+=flg[s.size()]+'0';
		if(ans.size()>80)	cout<<"overflow"<<endl;
		else{
			reverse(ans.begin(),ans.end());
			cout<<ans<<endl;
		}
		//cout<<ans.size()<<endl;
	}
	return 0;
}
			


Measured memory_bytes: 3044
n = int(input())
if n <= 599:
    print(8)
    exit()

if n <= 799:
    print(7)
    exit()

if n <= 999:
    print(6)
    exit()

if n <= 1199:
    print(5)
    exit()

if n <= 1399:
    print(4)
    exit()

if n <= 1599:
    print(3)
    exit()

if n <= 1799:
    print(2)
    exit()

if n <= 1999:
    print(1)
    exit()


Measured memory_bytes: 9188
n,m=map(int,input().split())
a=[[i for i in input().split()] for j in range(m)]
WANum=[0]*(n+1)
EndFlag=[0]*(n+1)
for x in a:
    if x[1]=="WA" and EndFlag[int(x[0])]==0:WANum[int(x[0])]+=1
    if x[1]=="AC":EndFlag[int(x[0])]=1
c=0
for i,x in enumerate(EndFlag):
    if x==1:c+=WANum[i]
print(sum(EndFlag),c)

Measured memory_bytes: 27388
// https://atcoder.jp/contests/abc069/tasks/abc069_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int x;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(x);
	if(x>=30)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
const ll mod = 1000000007;

void sayNo() {
	cout << "No" << endl;
}

void sayYes() {
	cout << "Yes" << endl;
}

void dfs(vector<int> &count, vector<pair<int, int>> &ans, const vector<vector<int>> &tree, int now, int from) {
	// cout << from << " -> " << now << endl;
	for (auto w : tree[now]) {
		if (w == from) {
			continue;
		}
		dfs(count, ans, tree, w, now);
	}

	if (now == from) {
		return;
	}

	if (count[now] % 2 == 0) {
		count[from]++;
		ans.push_back(mp(from, now));
	}
	else {
		ans.push_back(mp(now, from));
	}
}


int main() {
	ll N, M;
	cin >> N >> M;
	vector< vector<pair<int, int>>> graph(N);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		graph[a].push_back(mp(i, b));
		graph[b].push_back(mp(i, a));
	}


	if (M % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int, int>> ans;
	vector<int> num(N, 0);

	// 全域木を作る
	vector<vector<int>> tree(N);
	vector<vector<int>> remain(N);

	{
		queue<int> que;
		vector<bool> usedV(N, false);
		vector<bool> usedE(M, false);
		que.push(0);
		usedV[0] = true;

		while (que.empty() == false) {
			int v = que.front();
			que.pop();

			for (auto w : graph[v]) {
				if (usedE[w.first]) {
					continue;
				}
				usedE[w.first] = true;
				if (usedV[w.second]) {
					ans.push_back(mp(v, w.second));
					num[v]++;
					continue;
				}

				tree[v].push_back(w.second);
				usedV[w.second] = true;
				que.push(w.second);
			}
		}
	}

	dfs(num, ans, tree, 0, 0);

	for (auto p : ans) {
		cout << (p.first + 1) << " " << (p.second + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 20724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll a[111111];
ll b[111111];
ll p(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans;
}
int main()
{
	//ios::sync_with_stdio(flase);
	ll n,x;
	cin>>n>>a[0];
	if(a[0])
	{
		for(ll i=1;i<n;i++)
			scanf("%lld",&x);
		cout<<0<<endl;
	}	
	else
	{
		ll sum=1;
		for(ll i=1;i<n;i++)
		{
			scanf("%lld",&a[i]);
		}
		sort(a,a+n);
		ll flag=1;
		int tt=1;
		ll cnt=0;
		if(a[1]==0)
			cout<<0<<endl;
		else
		{
			for(ll i=0;i<n;i++)
			{
				
				if(a[i]==a[i+1])
				{
					flag++;
				}	
				else if(a[i+1]>a[i]+1)
				{
					tt=0;
					cout<<0<<endl;
					break;
				}
				else
				{
					b[cnt++]=flag;
					flag=1;
				}
			}
	
			if(tt)
			{
				for(ll i=1;i<cnt;i++)
				{
					//cout<<b[i]<<" ";
					ll f=p(b[i-1],b[i]);
					sum=(sum%mod*(f%mod))%mod;
				}	
				cout<<sum<<endl;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<int> a(N+1);
  rep(i, N) {
    int tmp;
    cin >> tmp;
    a[tmp] = i;
  }
  set<int> st = {-1, N};
  ll ans = 0;
  for(int i=1; i<=N; i++) {
    auto it = st.lower_bound(a[i]);
    int r = *it;
    int l = *(--it);
    ans += (ll)i*(a[i]-l)*(r-a[i]);
    st.insert(a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10368
import copy
h,w = map(int,input().split())
ls = []
for i in range(h):
    s = list(input())
    ls.append(s)
    
ls2 = copy.copy(ls)

for i in range(h):
    for j in range(w):
        ans = 0
        if ls[i][j] == "#":
          ans = "#"
        else:
          if j+1 <= w-1:#right
            if ls[i][j+1] == "#":
                ans += 1
            if i+1 <= h-1:
              if ls[i+1][j+1] == "#":
                ans += 1
            if i-1 >= 0:
              if ls[i-1][j+1] == "#":
                ans += 1
          if i+1 <= h-1:#down
            if ls[i+1][j] == "#":
                ans += 1
          if j-1 >= 0:#left
            if ls[i][j-1] == "#":
                ans += 1
            if i+1 <= h-1:
              if ls[i+1][j-1] == "#":
                ans += 1
            if i-1 >= 0:
              if ls[i-1][j-1] == "#":
                ans += 1
          if i-1 >= 0:#up
            if ls[i-1][j] == "#":
                ans += 1
         
        ls2[i][j] = ans
        
for i in range(h):
  for j in range(w):
  	print(ls2[i][j],end="")
  print("")
        
        

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

char s[1000001];
int pred[100000][26];
int dp[100000];

int min(int x, int y) {
  return x < y ? x : y;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s + i);
    dp[i] = 1e9;
  }
  for (int i = 0; i < 26; i++) {
    pred[0][i] = -1;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (s[i - 1] == j + 'a') {
        pred[i][j] = i - 1;
      } else {
        pred[i][j] = pred[i - 1][j];
      }
    }
  }
  dp[n - 1] = 1;
  for (int i = n - 1; i >= 1; i--) {
    int j = pred[i][s[i] - 'a'];
    if (j >= 0) {
      dp[j] = min(dp[j], dp[i]);
    }
    dp[i - 1] = min(dp[i - 1], dp[i] + 1);
  }
  printf("%d\n", dp[0]);
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int H, W;
  string s[50];
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> s[i];
  }
  bool yes = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '.') continue;
      bool flag = false;
      for (int k = 0; k < 4; k++) {
        int ny = i + dy[k];
        int nx = j + dx[k];
        if (ny >= 0 && ny < H && nx >= 0 && nx < W) {
          flag |= s[ny][nx] == '#';
        }
      }
      yes &= flag;
    }
  }
  cout << (yes ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int K;
	int n[32]={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};
	
	scanf("%d", &K);
	printf("%d",n[K-1]);
	
	return 0;
}

Measured memory_bytes: 128
# Wrote in Mar 22, 2020 22:36 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".to_i")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end
#---------------

s = gets.chomp
n = s.size

if s==s.reverse
  if s[0..((n-1)/2-1)]==s[0..((n-1)/2-1)].reverse
    if s[((n+3)/2-1)..n-1]==s[((n+3)/2-1)..n-1].reverse
      yes
      exit
    end
  end
end
no



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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}


int main()
{
    //textIO();
    fastIO();

    string s;
    long long q, t, f;
    char c;
    cin >> s;
    cin >> q;
    bool rev = false;
    while(q--){
        cin >> t;
        if(t == 1){
            rev = !rev;
        }
        else{
            cin >> f >> c;
            if(rev){
                if(f == 1){
                    s.append(1,c);
                }
                else{
                    s.insert(s.begin(), c);
                }
            }
            else{
                if(f == 1){
                    s.insert(s.begin(), c);
                }
                else{
                    s.append(1,c);
                }
            }
        }
    }
    if(rev){
        reverse(s.begin(), s.end());
        cout << s << '\n';
    }
    else{
        cout << s << '\n';
    }


    return 0;
}


Measured memory_bytes: 1040
#include <stdio.h>
int main(int argc, char *argv[])
{
	int n,i;
	long long a[87];
	while(scanf("%d",&n) != EOF)
	{
		a[0] = 2;
		a[1] = 1;
		if(n == 0 || n == 1)printf("%lld\n",a[n]);
		else {for(i = 2; i <= n; i++)
			{
				a[i] = a[i - 1] + a[i - 2];
			}
			printf("%lld\n",a[n]);}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint X,Y,A,B,C;std::cin>>X>>Y>>A>>B>>C;
    std::vector<lint>a(A),b(B),c(C);
    for(lint&x:a)std::cin>>x;
    for(lint&x:b)std::cin>>x;
    for(lint&x:c)std::cin>>x;
    std::sort(a.begin(),a.end(),std::greater<>{});
    std::sort(b.begin(),b.end(),std::greater<>{});
    std::sort(c.begin(),c.end(),std::greater<>{});
    std::vector<lint>d;
    d.insert(d.end(),a.begin(),a.begin()+X);
    d.insert(d.end(),b.begin(),b.begin()+Y);
    d.insert(d.end(),c.begin(),c.end());
    std::sort(d.begin(),d.end(),std::greater<>{});
    std::cout<<std::accumulate(d.begin(),d.begin()+X+Y,0ll)<<'\n';
}


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

int main(void){
  int N = 0;
  cin>>N;
  for(int i=0;i<N;i++){
  	char color;
    cin>>color;
    if(color=='Y'){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	K, N = map(int, input().split())
	A = [int(a) for a in input().split()]

	m = 0

	for i in range(N-1):
		sa = A[i+1] - A[i]
		if sa > m:
			m = sa

	if K - A[N-1] + A[0] > m:
		m = K - A[N-1] + A[0]

	print(K-m)

Measured memory_bytes: 24948
#include <iostream>
#include <utility>

using namespace std;

int main()
{
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  int ans = H*W;
  ans -= h*W;
  ans -= w*H;
  ans += h*w;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    string ans;
    while(n > 0){
        ans.push_back('a' + ((n - 1) % 26));
        n = (n - 1) / 26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<stdbool.h>
 
int main(){
  int i, temp;
  char num[4];
  bool bad_frag = false;
  
  scanf("%s", num);
  temp = num[0];
  
  for(i = 1; i <=3 ; i++){
    if(num[i] == temp){
      bad_frag = true;
    }
    temp = num[i];
  }
  
  if(bad_frag){
    printf("Bad");
  }else{
    printf("Good");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    
    cin>>h>>w;
    char ban[h][w]; 
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>ban[i][j];
        }
    }
    
    int han=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ban[i][j]=='#'){
                if(ban[i-1][j]=='#' || ban[i+1][j]=='#' || ban[i][j-1]=='#' || ban[i][j+1]=='#') continue;
                else han++;
            }
        }
    }
    
    if(han==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N;
  double x[10];
  char u[10][3];
  double sum = 0;

  scanf("%d", &N);

  for(int i = 0; i < N; i++){
      scanf("%lf", &x[i]);
      scanf("%s", u[i]);
      if(u[i][0] == 'J'){
          sum += x[i];
      }
      else{
          sum += x[i] * 380000;
      }
  }

  printf("%f\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 210000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};


void solve() {

	LL result = 0;
	int n;

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

	LL ok = n;
	LL nok  = 0;
	
	auto work = [&](LL now) {
		vector< pair<int, int> > tpos;
		tpos.push_back({ za[0], 0 });
		for (int i = 1; i < n; ++i) {
			int la = za[i - 1];
			int na = za[i];
			if (na > la) {
				tpos.push_back({ na, 0 });
				continue;
			}
			while (tpos.empty() == false && tpos.back().first >na ) {
				tpos.pop_back();
			}
			while (true) {
				if (tpos.empty() || tpos.back().first < na) {
					if (now == 1) return false;
					tpos.push_back({ na, 1 });
					break;
				}
				if (tpos.back().first == na ) {
					if (tpos.back().second == now - 1) {
						if (tpos.back().first == 1) {
							return false;
						}
						na--;
						tpos.pop_back();
						continue;
					}
					tpos.back().second += 1;
					break;
				} 
			}
		}
		return true;
	};

	while (nok + 1 < ok) {
		LL mid = (ok + nok) /2;
		bool f = work(mid);
		if (f) {
			ok = mid;
		}
		else {
			nok = mid;
		}
	}
	
	cout << ok << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll seg[400000+500];
void update(ll pos, ll val, ll n){
    seg[pos+n] += val;
    pos = (pos+n)/2;
    while(pos > 0)seg[pos] = max(seg[pos*2], seg[pos*2+1]), pos /= 2;
}
ll query(ll l, ll r, ll n){
    if(r < l)return 0;
    l += n, r+= n;
    ll l_max = -1, r_max = -1;
    while(l < r){
        if(l%2) l_max = max(l_max, seg[l++]);
        if(1-r%2) r_max = max(r_max, seg[r--]);
        l /= 2;
        r /= 2;
    }
    ll ret = max(l_max, r_max);
    if(l == r)return max(ret, seg[l]);
    else return ret;
}
int main()
{
    ll n;
    cin >> n;
    ll h[n],dp[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
        h[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> seg[h[i] + n];
        update(h[i], query(0, h[i]-1, n), n);
    }
        // for(int i = 1; i < 2*n; i++)cout << seg[i] << endl;
    cout << seg[1] << endl;
}

Measured memory_bytes: 4992
# include <iostream>
# include <string>
# include  <vector>
# include <math.h>
# include <algorithm>
using namespace std;

int main(){

	int x; cin >> x;
	long long int hap = 0;
	hap += (x/500)*1000;
	x = x%500;
	hap += (x/5)*5;

	cout << hap;

	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define mod 998244353
#define ld long double
#define pb push_back
#define inf INT_MAX
#define N 1000000
using namespace std;
int n,m,k;
ll ans=0;
ll inv[N+3];
ll fact_inv[N+3];
ll fact[N+3];
//modulo inverse 
void inverse(){
	inv[1]=1;//MMI
	int i;
	for(i=2;i<=N;i++){
		inv[i]=mod-(mod/i)*inv[mod%i]%mod;
	}
}
void factinv(){
	int i;
	fact_inv[0]=1;
	for(i=1;i<=N;i++){
		fact_inv[i]=fact_inv[i-1]*inv[i]%mod;
	}
}
void facto(){
	int i;
	fact[0]=1;
	for(i=1;i<=N;i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
}
ll power(int a,int b){
	if(b==0)
	return 1;
	else if(b==1)
	return a;
	else{
		if(b&1)
		return ((a%mod)*(power(a,b-1)%mod))%mod;
		else
		return ((power(a,b/2)%mod)*(power(a,b/2)%mod))%mod;
	}
}
void solve(int p){
	ll a=((fact_inv[n-p-1]%mod)*(fact_inv[p]%mod))%mod;
	ll b=(m*power(m-1,n-p-1)%mod)%mod;
	ll c=(a*b)%mod;
	ans+=(fact[n-1]*c)%mod;
	ans%=mod;
}
int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i;
	cin>>n>>m>>k;
	facto();
	inverse();
	factinv();
	//cout<<inv[123]<<endl;
	for(i=0;i<=k;i++)
	solve(i);
	cout<<ans<<endl;
}


Measured memory_bytes: 27052
<?php
fscanf(STDIN, "%s", $S);
$a = str_split($S);
$cnt = count($a);
$ans = 0;
for ($i = 0; $i < intdiv($cnt, 2); $i++) {
    if ($a[$i] !== $a[$cnt - $i - 1]) {
        $ans++;
    }
}
echo $ans;


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int n;
	cin>>n;
	vector< pair< double, pair<double,double> > >eng;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if( (x!=0) || (y!=0) ) eng.pb( mp( 0.0, mp(x*1.0,y*1.0) ) );
	}
	int sz = eng.size();
	for(int i=0;i<sz;i++){
		double cx = eng[i].second.first;
		double cy = eng[i].second.second;
		eng[i].first = atan2(cy,cx);
	}
	sort(eng.begin(),eng.end());
	for(int i=0;i<sz;i++){
		eng.pb( eng[i] );
	}
	double ans = 0.0;
	for(int i=0;i<sz;i++){
		double sux = 0.0, suy = 0.0;
		for(int j=i;j<i+sz;j++){
			sux += eng[j].second.first;
			suy += eng[j].second.second;
			double dis = sux*sux + suy*suy;
			if(dis>ans)ans = dis;
		}
	}
	cout<<setprecision(12)<<sqrt(ans)<<endl;
	return 0;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    t, d = map(int, input().split())
    s.append(t)
    c.append(d)
a = -2
if m == 0:
    if n == 1:
        a = 0
    elif n == 2:
        a = 10
    else:
        a = 100
else:
    for i in range(m-1):
        for j in range(i+1, m):
            if s[i] == s[j]:
                if c[i] != c[j]:
                    a = -1
    if a == -2:
        if n == 1:
            a = c[0]
        if n == 2:
            for i in range(10, 100):
                b = 0
                for j in range(m):
                    if s[j] == 1:
                        if i//10 == c[j]:
                            b += 1
                    else:
                        if i%10 == c[j]:
                            b += 1
                if b == m:
                    a = i
                    break;
        if n == 3:
            for i in range(100, 1000):
                b = 0
                for j in range(m):
                    if s[j] == 1:
                        if i//100 == c[j]:
                            b += 1
                    elif s[j] == 2:
                        if (i//10)%10 == c[j]:
                            b += 1
                    else:
                        if i%10 == c[j]:
                            b += 1
                if b == m:
                    a = i
                    break;
    if a == -2:
        a = -1
print(a)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <map>
#define N 200005
using namespace std;

typedef long long ll;
ll n, k, ans, a[N];
map<ll, ll> c;
int main()
{
	ll i;
	cin >> n >> k;
	for (i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		a[i] = (a[i - 1] + a[i]) % k;
	}
	for (i = 1; i <= n; i++) a[i] = (a[i] - i % k + k) % k;
	for (i = 1; i <= min(n, k - 1); i++) c[a[i]]++;
	ans += c[0];
	for (i = 1; i < n; i++) {
		c[a[i]]--;
		if (i + k - 1 <= n) c[a[i + k - 1]]++;
		ans += c[a[i]];
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int m = Integer.MAX_VALUE;
        for (int i = 0;i < n;++i){
            int k = sc.nextInt();
            int f = sc.nextInt();
            if(f > t)continue;
            if(m > k)m = k;
        }
        if(m == Integer.MAX_VALUE) System.out.println("TLE");
        else System.out.println(m);
    }




}




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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

int n;
string ans1,ans2, x;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("test.txt", "r", stdin);
    cin >> n >> x;
    ans1 = "", ans2 = "";
    int i = 0;
    while (i < n) {
        while (i < n && x[i] == ')') {
            i++;
            ans1 += '(';
        }
        if (i == n) break;
        int cnt = 1;
        i++;
        while (i < n && cnt > 0) {
            if (x[i] == '(') cnt++;
            else cnt--;
            i++;
        }
        if (i == n && cnt > 0) {
            FOR(j,0,cnt) ans2 += ')';
        }
    }
    cout << ans1 + x + ans2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=998244353;
const ll INF=0x3f3f3f3f;

ll dp[MAXn];
ii d[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    REP (i,n) cin >> d[i].X >> d[i].Y;
    sort(d,d+n);
    vector<ii> stk;
    stk.eb(n,INF);
    dp[n] = 1;
    for (int i=n-1;i>=0;i--) {
        dp[i] = dp[i+1];
        while (SZ(stk) && stk.back().Y < d[i].X + d[i].Y) stk.pop_back();
        ll s = stk.back().X;
        dp[i] = (dp[i] + dp[s]) % MOD;
        stk.eb(i,d[i].X);
    }
    cout << dp[0] << endl;
}


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

const int MAXN = 1e2;
string s[MAXN];

int main(void){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(s[i][j] == '#'){
				cout << "#";
				continue;
			}else{
				int cnt = 0;
				if(i - 1 >= 0 && s[i - 1][j] == '#') cnt++;
				if(i + 1 < n && s[i + 1][j] == '#') cnt++;
				if(j - 1 >= 0 && s[i][j - 1] == '#') cnt++;
				if(j + 1 < m && s[i][j + 1] == '#') cnt++;
				if(i - 1 >= 0 && j - 1 >= 0 && s[i - 1][j - 1] == '#') cnt++;
				if(i - 1 >= 0 && j + 1 < m && s[i - 1][j + 1] == '#') cnt++;
				if(i + 1 < n && j - 1 >= 0 && s[i + 1][j - 1] == '#') cnt++;
				if(i + 1 < n && j + 1 < m && s[i + 1][j + 1] == '#') cnt++;
				cout << cnt;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifdef local
	#include "debug/debug.h"
#endif


#ifndef local
	#define deb(x...) ;	
#endif

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

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


void solve()
{
	int n, x, t;
	cin >> n >> x >> t;
	int ans = n/x;
	if (n%x) ans++;
	cout << ans*t << "\n";
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	// cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 3648
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
using namespace atcoder;
typedef long long ll;
 
const int N=200000+10;
 
int n,q;
dsu d(N);
 
int main() {
  scanf("%d%d",&n,&q);
  while (q--) {
    int op,u,v; scanf("%d%d%d",&op,&u,&v);
    if (!op) d.merge(u,v);
    else printf("%d\n",d.same(u,v));
  }
  return 0;
}

Measured memory_bytes: 3912
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll A, B;
char s1[SIZE], s2[SIZE], ch[SIZE];
int main() {
	cin >> s1 >> s2 >> A >> B >> ch;
	if (!strcmp(s1, ch)) --A;
	else --B;
	cout << A << ' ' << B;
}

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

int main() {
    ll N;
    cin >> N;
    vector<char> name = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
    'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

    ll block = 0;
    vector<int> x;
    while (N>0) {
        N--;
        x.push_back(N%26);
        N /= 26;
    }

    string ans = "";

    for (ll i=x.size()-1; i>=0; i--) {
        ans += name[x[i]];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for (int i=(a); i<=(b); i++)

struct point{
	int x;
	int y;
};
int n;
point a[9];
double path;

int main(void)
{
	cin>>n;
	For(i,1,n)
		cin>>a[i].x>>a[i].y;
	For(i,1,n-1)
		For(j,i+1,n)
			path+=sqrt(pow(a[i].x-a[j].x,2)+pow(a[i].y-a[j].y,2));
	printf("%.10lf",path*2/n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int d;
    cin >> d;
    if(d == 25){
        cout << "Christmas" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,K; cin >> N >> K;
  if(K==0){
    cout << N*N << endl;
    return 0;
  }
  int ans=0;
  ans+=(1+N-K)*(N-K)/2;
  for(int x=K+1;x<=N;x++){
    ans+=(x-K)*(N/x-1)+max(0LL,N%x-K+1);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){

  string a,b;
  cin >> a >> b;
  int x = stoi(a+b);

  for(int i = 0; i <= 1000; i++){
    if(i*i == x){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        int a = in.nextInt(); //  1
        int b = in.nextInt(); //  0
        int c = in.nextInt(); // -1
        int k = in.nextInt(); //  picker
        
        long ans = min(a, k);
        k -= ans;
        if(k == 0){
            System.out.println(ans);
            return;
        }
        //ans += min(b, k);
        k -= min(b, k);
        
        if(k == 0){
            System.out.println(ans);
            return;
        }
        ans -= min(c, k);
        System.out.println(ans);
        
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


Measured memory_bytes: 32812
uses Math;
var
	N,i,Z,W,X:Longint;
begin
	read(N,Z,W);
	if N=1 then begin
		read(Z);
		writeln(abs(Z-W));
		exit;
	end;
	for i:=1 to N-2 do read(Z);
	read(Z,X);
	writeln(max(abs(Z-X),abs(W-X)))
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define ALL(x) (x.begin(),x.end())
using namespace std;

int main(){
ll a,b,c;
cin>>a>>b>>c;

auto d=c-(a-b);
if(d>=0)cout<<d<<endl;
else cout<<0<<endl;


return 0;



}

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

typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);  
  int even=0, odd=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2) odd++;
    else even++;
  }
  if(odd%2) {
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
S = input()
T = input()
ans = 2*N
for i in range(N,-1,-1):
    ST = S[:i] + T
    # print(ST,ST[:i],ST[i:])
    if ST[:N]==S and ST[-N:]==T:
        ans = min(len(ST),ans)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V &Mx(const V &_x){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		V x(n*n);
		V e(n*n);
		z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1)e=Me(e,x);
			x=Mx(x);
		}
		V s(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		const V &r=e;
		for(i=0;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
		printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
	}
}

Measured memory_bytes: 1084
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	int n, m;
	scanf("%d %d", &n, &m);

	vector<pii> pl(n), ch(m);
	REP(i, n) {
		scanf("%d %d", &pl[i].first, &pl[i].second);
	}
	REP(i, m) {
		scanf("%d %d", &ch[i].first, &ch[i].second);
	}

	REP(i, n) {
		pii Min = {INT_MAX, 0};
		REP(j, m) {
			Min = min(Min,{abs(pl[i].first- ch[j].first) + abs(pl[i].second - ch[j].second), j});
		}
		printf("%d\n", Min.second+1);
	}

	return 0;
}

Measured memory_bytes: 256