akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int arr[4],n;
double dp[305][305][305];//dp[i][j][k]代表i个装有一个寿司的盘子，j个两个寿司的盘子，k个三个寿司的盘子的情况下吃完寿司的期望次数 
double dfs(int a,int b,int c)
{
    if(a==0&&b==0&&c==0)
	  return 0;
    if(dp[a][b][c]>0)
	  return dp[a][b][c];
    double ans=1.0*n/(a+b+c);//共有n个盘子，还剩a+b+c个盘子有寿司时，下一次吃到寿司的期望次数为n/(a+b+c) (用极限证明) 
    if(a)//吃到的是剩余一个寿司的盘子中的寿司,概率为a/(a+b+c) 
	  ans+=(1.0*a/(a+b+c))*dfs(a-1,b,c);//a/(a+b+c)的概率变成(a-1,b,c)状态 
    if(b)//吃到的是剩余两个寿司的盘子中的寿司 
	  ans+=(1.0*b/(a+b+c))*dfs(a+1,b-1,c);//b/(a+b+c)的概率变成(a+1,b-1,c)的状态 
    if(c)//吃到的是剩余三个寿司的盘子中的寿司 
	  ans+=(1.0*c/(a+b+c))*dfs(a,b+1,c-1);//c/(a+b+c)的概率变成(a,b+1,c-1)状态 
    return dp[a][b][c]=ans;//吃完当前状态(a,b,c)寿司的期望次数为上一状态吃完寿司的期望次数加上当前吃一个寿司的期望次数
}
int main()
{
    int d;
    scanf("%d",&n);
    for(int i = 1;i<=n;++i)
    {
        scanf("%d",&d);
        arr[d]++;
    }
    printf("%.10f\n",dfs(arr[1],arr[2],arr[3]));
    return 0;
}

Measured memory_bytes: 112624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int c(const void *val1,const void *val2){
    return *(int *)val2-*(int *)val1;
}
int main(void){
    int line[100]={0},line1[100]={0},line2[100]={0},temp,num,i,o,p,q,s,rank;
    for(num=0;scanf("%d,%d",&p,&s),p;line[p]=s,num++);
    memcpy(line1,line,400);
    qsort(line1,100,4,c);
    for(i=-1,rank=1,temp=-1;;rank++){
        while(line1[++i]==temp && i<num);
        if(i>=num)
            break;
        temp=line1[i];
        for(o=1;o<=100;o++)
            if(line1[i]==line[o])
                line2[o]=rank;
    }
    for(;scanf("%d",&q)!=EOF;printf("%d\n",line2[q]));
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	string s;
	in(s);
	if (s == "Sunny")	outn("Cloudy");
	else if (s == "Cloudy") outn("Rainy");
	else outn("Sunny");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;

  if(s[0] == '9' || s[1] == '9') cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long ans;
int n,m,i,j,a[200005],b[200005];
priority_queue<pair<int,int> > pq;
int pre(int x)
{
	x--;
	if(x==0)return n;
	return x;
}
int suf(int x)
{
	x++;
	if(x==n+1)return 1;
	return x;
}
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		scanf("%d",&a[i]);
	}
	fz1(i,n){
		scanf("%d",&b[i]);
	}
	fz1(i,n)if(a[i]!=b[i]){
		pq.push(make_pair(b[i],i));
	}
	while(!pq.empty()){
		int x=pq.top().second;pq.pop();
		int v=(b[pre(x)]+b[suf(x)]);
		int t=(b[x]-a[x])/v;
		if(!t){
			puts("-1");
			return 0; 
		}
		b[x]-=v*t;ans+=t;
		if(a[x]!=b[x])pq.push(make_pair(b[x],x));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    vector<bool> a(1000000010,false);
    int c = 0;
    int n, k, q;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k;
        a[k] = true;
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> k;
        if (a[k] == true) {
            c++;
        }
    }
    cout << c << endl;
    return 0;
    
}



Measured memory_bytes: 124636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define pb push_back
#define mp make_pair
#define f first
#define s second
int main()
{
    int n;
    cin>>n;
    if(n)
    {
    	cout<<"0"<<endl;
    }
    else
    {
    	cout<<"1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>E[202020];
vector<ll>childcnt;
vector<ll>sum;
ll N;
ll mod = 1000000007;

ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void dfs(int now,int p){
	ll S = 0;
	ll sub = 0;
	fore(x, E[now]) {
		if (x != p) {
			dfs(x, now);
			S += childcnt[x];
			sub += (modpow(2,childcnt[x])-1+mod);
			sub %= mod;
		}
	}
	sum[now] += (modpow(2,S)- 1 - sub + 5LL*mod)%mod;
	sum[now] += ((modpow(2,S)-1LL)*(modpow(2,N-1-S)-1LL))%mod;
	sum[now] %= mod;
	childcnt[now] = S + 1;
}

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

	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].pb(b);
		E[b].pb(a);
	}
	childcnt.resize(N);
	sum.resize(N);
	dfs(0,-1);


	ll bunboinv = modpow(2,mod-2);
	bunboinv = modpow(bunboinv,N);
	ll bunshi = 0;
	for (int i = 0; i < N; i++) {
		bunshi += sum[i];
		bunshi %= mod;
	}
	ll ans = bunboinv * bunshi;
	ans %= mod;
	puts(ans);

	return 0;
}

Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    rep(i,M) cin >> s[i] >> c[i];
    rep(i,1000){
        string S=to_string(i);
        if (S.size()!=N) continue;
        int ok=1;
        rep(j,M){
            if (S[s[j]-1]!=c[j]){ok=0; break;}
        }
        if (ok){
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int n,m;

int par[111111];
int rankk[1111111];

void init(int n) {
  for(int i=0;i<n;i++) {
    par[i]=i;
    rankk[i]=0;
  }
}

int find(int x) {
  if(par[x]==x) {
    return x;
  } else {
    return par[x]=find(par[x]);
  }
}

void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(rankk[x]<rankk[y]){
    par[x]=y;
  } else {
    par[y]=x;
    if(rankk[x]==rankk[y])rankk[x]++;
  }
}

bool same(int x, int y) {
  return find(x)==find(y);
}
int p[111111];
int x[111111];
int y[111111];

void solve() {
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n>>m;
  init(n);
  REP(i,n)cin>>p[i];
  REP(i,m){
    cin>>x[i]>>y[i];
    unite(x[i], y[i]);
  }
  int cnt=0;
  REP(i,n){
    if(same(p[i], i+1))cnt++;
  }
  
  cout << cnt << endl;
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  solve();  
  return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,x,y;
    while(~scanf("%d%d%d",&a,&x,&y))
    {
        if(y>=a&&y<=x)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}



Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var m int
	fmt.Scan(&m)

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}

	c := make([]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			c[i] += a[i][j] * b[j]
		}
	}

	for _, v := range c {
		fmt.Println(v)
	}
}



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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a * a >= c * c || b * b >= c * c) {
    cout << "No";
  } else if (4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,weight=map(int,input().split())
    WV=[tuple(map(int,input().split())) for i in range(n)]
    dp=[[10**10]*(10**5+1) for _ in range(n+1)] #i番目までの品物について，価値の総和がjのときのナップザックの重さ
    dp[0][0]=0
    for i in range(n):
        ni=i+1
        w,v=WV[ni-1]
        for j in range(10**5+1):
            if dp[i][j]+w<=weight and (j==0 or dp[i][j]!=10**10):
                dp[ni][j+v]=min(dp[ni][j+v],dp[i][j]+w)
            dp[ni][j]=min(dp[i][j],dp[ni][j])
    for i in range(10**5,-1,-1):
        if dp[-1][i]!=10**10:
            print(i)
            break

if __name__=='__main__':
    main()

Measured memory_bytes: 119408
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,c,d,q,w,e,r;
	cin >> a >> b >> c >> d;
	if(a>d || c>b){
		cout << "0" << endl;
		return 0;
	}
	q=b-a;
	w=b-c;
	e=d-a;	
	r=d-c;
	if(q>w){
		if(e>r){
			if(w>r)cout << r << endl;
			else cout << w << endl;
		}
		else {
			if(w>e)cout << e << endl;
			else cout << w << endl;
		}
	}
	else {
		if(e>r){
			if(q>r)cout << r << endl;
			else cout << q << endl;
		}
		else {
			if(q>r)cout << e << endl;
			else cout << q << endl;
		}
	}
	return 0;
}
				
	

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

int main() {
  int n;
  cin >> n;
  bool ans = false;
  for(int i = 0; i <= (n/4)+1; i++) {
    for(int j = 0; j <= (n/7)+1; j++) {
      if(n == (4*i) + (7*j)) ans = true;
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif // DEBUG

void swap(int array[], int i0, int i1)
{
  int temp = array[i1];
  array[i1] = array[i0];
  array[i0] = temp;
}

int partition(int array[], int start, int end)
{
  int pivot = array[end];
  int pos = start - 1;

  for (int i = start; i < end; i++)
  {
    if (array[i] <= pivot)
    {
      pos++;
      swap(array, pos, i);
    }
  }

  swap(array, pos + 1, end);

  return pos + 1;
}

int main()
{
  int numOfArray;
  cin >> numOfArray; cin.ignore();

  int array[numOfArray];
  for (int i = 0; i < numOfArray; i++)
    cin >> array[i];

#if DEBUG
  DPRINTF("numOfArray %d\n", numOfArray);
  for (int i = 0; i < numOfArray; i++)
  {
    if (i == 0) { DPRINTF("%d", array[i]); }
    else        { printf(" %d", array[i]); }
  }
  cout << endl;
#endif

  int start = 0;
  int end = numOfArray - 1;

  int pos = partition(array, start, end);

  DPRINTF("PARTITION POS %d\n", pos);

  for (int i = 0; i < numOfArray; i++)
  {
    if (i > 0)
      cout << " ";

    if (i == pos)
      cout << "[";

    cout << array[i];

    if (i == pos)
      cout << "]";
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3408
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll n=100;
	VLL A(n), B(3), C(3);
	ll a[20]; ll x[20][20];ll y[20][20];
	string s; cin >> s;
	ll ans = 0;
	for (int i = 0;i < 4;i++) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
}

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

bool decide(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main(){
    string s;
    cin >> s;
    bool ans = true;
    if(!decide(s)) ans = false;
    if(!decide(s.substr(0, s.size() / 2))) ans = false;
    if(ans == true)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string s;
    cin >> s;
    ll cnt = 0;
    rep(i, s.size()) {
        if (s[i] == '+')
            cnt++;
        else
            cnt--;
    }

    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3576
# coding: utf-8
# Your code here!s = input()
n, m = map(int, input().split())
x = []
y = []
for i in range(m):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
boxes = [False]*n
boxes[0] = True
boxescnt = [1]*n
for i in range(m):
    if boxes[x[i]-1] == True:
        if boxescnt[x[i]-1] == 1:
            boxes[x[i]-1] = False
        boxes[y[i]-1] = True
    boxescnt[x[i]-1] -= 1
    boxescnt[y[i]-1] += 1
print(sum(boxes))


Measured memory_bytes: 63960
"""
N = 3456の場合を例に取る。
支払い額もしくはお釣りの一方の1円玉の枚数は0が最適。
支払い枚数をf(N)で書くことにする。

(pay, change) = (...6, ...0)が最適の場合
10円以上で支払額とお釣り金額の差は3450円より、
    f(3456) = f(345) + 6
(pay, change) = (...0, ...4)が最適の場合
10円以上で支払額とお釣り金額の差は3460円より、
    f(3456) = f(346) + 4

つまり一般に
    f(3456) = min(f(345) + 6, f(346) + 4)
今回は再帰は10^6回で重いのでdpを行う。具体的には
    [f(3), f(4)]
    [f(34), f(35)] = [min(f(3)+4, f(4)+7), min(f(3)+5, f(4)+5)]
    [f(345), f(346)] = [min(f(34)+5, f(35)+5), min(f(34)+6, f(35)+4)]
の２ペアずつ値を保持して小さい方から計算すれば良い。
"""

strN = input()

# dp最初
n = int(strN[0])
dp = [min(n, 11 - n), min(n + 1, 11 - (n + 1))] # n == 9の場合も成立

for s in strN[1:]:
    n = int(s)
    dp = [min(dp[0] + n, dp[1] + (10 - n)), min(dp[0] + (n + 1), dp[1] + (10 - (n + 1)))]
    # 偶然、n == 0 or 9の場合もカバーできてる

print(dp[0])


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

int main() {
  int n,m,gain=0;
  cin >> n >> m;
  vector<vector<int>>ab(n,vector<int>(2));
  for(int i=0;i<n;i++) cin >> ab.at(i).at(0)>> ab.at(i).at(1);
  sort(ab.begin(),ab.end());
  priority_queue<int> b;
  int j=0;
  for(int i=1;i<=m;i++){
  	if(j<n){
  	  while(ab.at(j).at(0)<=i){
  		  b.push(ab.at(j).at(1));
  		  j++;
  		  if(j==n)break;
  	  }
  	}
  	if (b.empty()!=true) {
  		gain+=b.top();
  		b.pop();
  	}
  }
  cout << gain << endl; 
}


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

#define ll long long int

void solve(){
    ll n,a; cin >> n >> a;
    cout << ceil(1.0*n/a) << '\n';

}

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

    int test=1;
    // cin >> test;
    while(test--)
        solve();
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n,m;
cin >> n >> m;
vector<pair<int,int>>a(n),b(m);
for(int i=0;i<n;i++){
    int z,zz;
    cin >>z >> zz;
    a.at(i)=make_pair(z,zz);
}
for(int i=0;i<m;i++){
    int z,zz;
    cin >>z >> zz;
    b.at(i)=make_pair(z,zz);
}
for(int i=0;i<n;i++){
    vector<int>c(m);int  che = 10e8;
    for(int j=0;j<m;j++){
        c.at(j)=abs(a.at(i).first-b.at(j).first)+abs(a.at(i).second-b.at(j).second);
        che = min(che,c.at(j));
    }
    for(int j=0;j<m;j++){
        if(che==c.at(j)){
            cout << j+1<<endl;
            break;
        }
    }
}
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[100005][2], n, a, b, mod=1000000007;
vector<long long> c[100005];
void root(int cur, int par){
	vector<long long> novi;
	for (int i=0; i<c[cur].size(); i++){
		if (c[cur][i]!=par){
			novi.push_back(c[cur][i]);
			root (c[cur][i], cur);
		}
	} c[cur]=novi; return;
}
void solve(int cur){
	dp[cur][0]=dp[cur][1]=1;
	for (int i=0; i<c[cur].size(); i++) solve(c[cur][i]);
	for (int i=0; i<c[cur].size(); i++){
		dp[cur][0] = (dp[cur][0]*(dp[c[cur][i]][0] + dp[c[cur][i]][1]))%mod;
		dp[cur][1] = (dp[cur][1]*dp[c[cur][i]][0])%mod;
	} dp[cur][0]%=mod; dp[cur][1]%=mod; 
	return;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i=1; i<n; i++){
		cin >> a >> b;
		c[a].push_back(b);
		c[b].push_back(a);
	} 
	root(1, 0); solve(1); 
	cout << ((dp[1][0]+dp[1][1])%mod) << endl;
return 0;
}


Measured memory_bytes: 21728
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

int main(){

	int n,x,y;
	vector<pair<int,int> >v,u;
	cin >> n;
	rep(i,n){
		cin >> x >> y;
		v.push_back(make_pair(x,y));
	}

	sort(v.begin(),v.end());

	rep(i,n-1)
	u.push_back(make_pair(v[i+1].first-v[i].first,v[i+1].second-v[i].second));

	sort(u.begin(),u.end());

	int d=u[0].first*u[0].first+u[0].second*u[0].second;
	REP(i,0,n-2){
		REP(j,i+1,n-1){
			int dx=v[j].first-v[i].first, dy=v[j].second-v[i].second;
			if(dx*dx>d) break;
			else if(dx*dx+dy*dy<d) d=dx*dx+dy*dy;
		}
	}

	cout << d << endl;

	return 0;
}

Measured memory_bytes: 11396
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
ll s,k;
int main(){
	cin>>s;
	k=sqrt(s);
	cout<<"0 0 ";
	if(k*k<s){
		++k;cout<<"1 ";
	}else cout<<"0 ";
	cout<<k<<' '<<k<<' '<<k*k-s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;
typedef pair<int, int> Pair;
bool use[1001][1001];
char maze[1001][1001];
Pair p[10];
int m, n;
int dx[4] = {0, 1, -1, 0};
int dy[4] = {1, 0, 0, -1};
int d[1001][1001];
int bfs(int deep, int x, int y)
{
    int res = 0;
    queue<Pair> q;
    q.push(Pair(x, y));
    d[x][y] = 0;
    while(q.size())
    {
        int i;
        Pair now = q.front();
        q.pop();
        if(now.first == p[deep].first && now.second == p[deep].second)
            break;
        for(i = 0;i < 4;i++)
        {
            int nx, ny;
            nx = now.first + dx[i];
            ny = now.second + dy[i];
            if(nx >= 0 && nx < m && ny >= 0 && ny < n && maze[nx][ny] != 'X' && !use[nx][ny])
            {
                use[nx][ny] = true;
                q.push(Pair(nx, ny));
                d[nx][ny] = d[now.first][now.second] + 1;
            }
        }
    }
    return d[p[deep].first][p[deep].second];
}
int main()
{
    int k;
    while(scanf("%d%d%d", &m, &n, &k) != EOF)
    {
        int i, j;
        for(i = 0; i < m; i++)
            scanf("%s", maze[i]);
        int x, y;
        for(i = 0; i < m; i++)
            for(j = 0; j < n; j++)
                if(isdigit(maze[i][j]))
                {
                    p[maze[i][j] - '0'].first = i;
                    p[maze[i][j] - '0'].second = j;
                }
                else if(maze[i][j] == 'S')
                {
                    x = i;
                    y = j;
                }
        int ans = 0;
        for(i = 1; i <= k; i++)
        {
            memset(use, false, sizeof(use));
            ans += bfs(i, x, y);
            x = p[i].first;
            y = p[i].second;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 7084
#include<iostream>
int64_t N,P,a,c[1<<20],i,j;std::string S;main(){std::cin>>N>>P>>S;if(10%P)for(*c=j=1;N--;i+=(S[N]-48)*(j=j*10%P),a+=c[i%=P]++);else for(;i<N;a+=(S[i++]-8)%P?0:i);std::cout<<a;}

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    for( int i = 0; i < K; ++i ){
        if( i % 2 == 0 ){
            if( A % 2 ) --A;
            A /= 2;
            B += A;
        } else {
            if( B % 2 ) --B;
            B /= 2;
            A += B;
        }
    }

    cout << A << " " << B << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[] abc = new long[3];
        abc[0] = sc.nextLong();
        abc[1] = sc.nextLong();
        abc[2] = sc.nextLong();
        Arrays.sort(abc);
        long l = abc[2] - abc[2] / 2;
        long s = abc[2] / 2;
        System.out.println((l - s) * abc[0] * abc[1]);
    }

}


Measured memory_bytes: 23380
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL n, t, next, tail = 0, ans = 0;
	cin >> n >> t;
	for (LL i = 0; i < n; ++i) {
		cin >> next;
		ans += t - max(0LL, tail - next);
		tail = next + t;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//
//  main.cpp
//  hitachi2020B
//
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    int ans;
    int d_price=200001;
    int d_x,d_y,d_c;
    int A,B,M;
    int r_min=100007; // 一番安い冷蔵庫
    int m_min=100007; // 一番安い電子レンジ
    cin >>A>>B>>M;
    vector<int>r(A);
    vector<int>m(B);
    for (int i=0; i<A; i++) {
        cin >> r[i];
        r_min=min(r_min,r[i]);
    }
    for (int j=0; j<B; j++) {
        cin >> m[j];
        m_min=min(m_min,m[j]);
    }
    ans=r_min+m_min; // 割引券を使わない時の最安値（一番安い冷蔵庫＋一番安い電子レンジ）
    for (int k=0; k<M; k++) {
        cin >> d_x>>d_y>>d_c;
        d_price=r[d_x-1]+m[d_y-1]-d_c; // 割引券を使った時の金額
        ans=min(ans,d_price);
    }
        cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> graph[100002];
int dis[2][100002];
void dfs(int d,int v,int p){
	for(int i=0;i<graph[v].size();i++){
		int y=graph[v][i];
		if(y!=p){
			dis[d][y]=dis[d][v]+1;
			dfs(d,y,v);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	dis[0][1]=0;
	dfs(0,1,0);
	dis[1][n]=0;
	dfs(1,n,0);
	int cnt[2]={0};
	for(int i=1;i<=n;i++){
		cnt[dis[0][i]>dis[1][i]]++;
	}
	string ans[2]={"Fennec","Snuke"};
	cout<<ans[cnt[0]<=cnt[1]]<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    
    vl d(n);
    rep(i, n) {
        cin >> d[i];
    }
    sort(all(d));
    
    out(d[n/2] - d[n/2 - 1]);
    re0;
}

Measured memory_bytes: 1024
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll a, b, n; cin >> a >> b >> n;

    ll times = min(n, b-1);

    ld ans = a * times/b;

    cout << (ll)ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)


int cnt[5];

int main() {
	REP(i, 6) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	REP(i, 5) {
		if (cnt[i] >= 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
 	return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = [int(x) for x in input().split()]
b_list = [int(x) for x in input().split()]

ans = 0
for i in range(n):
    for j in range(2):
        temp = min(a_list[i + j], b_list[i])
        ans += temp
        a_list[i + j] -= temp
        b_list[i] -= temp
print(ans)

Measured memory_bytes: 18624
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int fib[50];
  fib[0]=fib[1]=1;
  int i;
  for(i=2;i<=n;i++){
    fib[i]=fib[i-2]+fib[i-1];
  }
  printf("%d\n",fib[n]);
  return 0;
}


Measured memory_bytes: 2100
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d[] = new int[n+1];
        int t[] = new int[n];
        
        for (int i = 0; i < n; i++){
            d[i]=in.nextInt();
        }
        
        t[0] = d[0];
        int length = 1;
        
        for(int i = 0; i < n; i++){
            if (t[length-1] < d[i]){
                t[length++] = d[i];
            }else{
                for (int j = 0; j <= length-1; j++){
                    if (t[j]>=d[i]){
                        t[j]=d[i];
                        break;
                    }                    
                }
            }
        }
        
        System.out.println(length);
    }  
}

Measured memory_bytes: 71096
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    x <- readLn
    putStrLn $ if x>=30 then "Yes" else "No"



Measured memory_bytes: 3876
/*input
2
10 10
*/
#include <bits/stdc++.h>
using namespace std;

int h[100005], dp[100005];

int main(){
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", h + i);
	}
	dp[1] = 0; dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	printf("%d\n", dp[n]);
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long int LLI;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if( b <= c or d <= a )
    	cout << 0;
    else if( c >= a and d <= b )
    	cout << d - c;
    else if( a >= c and b <= d )
    	cout << b - a;
    else if( c <= a and a <= d and d <= b )
    	cout << d - a;
    else
    	cout << b - c;
}

Measured memory_bytes: 3604
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll
#define all(a) begin(a),end(a)

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
string s;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>s;
	string z;
	for (int i=0;i<s.size()/2;++i) z+="hi";
	if (z==s) cout<<"Yes";
	else cout<<"No";
}





Measured memory_bytes: 256
N,K = map(int,input().split())
V = list(map(int,input().split()))
vmax = -10**9
for n1 in range(K+1):
    A = V[:n1]
    ind = min(n1,N)
    m = N-ind
    for n2 in range(min(K-n1,m)+1):
        B = V[N-n2:]
        C = A+B
        C = sorted(C,reverse=True)
        k = K-n1-n2
        for i in range(k):
            if len(C)==0 or C[-1]>=0:break
            C.pop()
        vmax = max(vmax,sum(C))
print(vmax)           

Measured memory_bytes: 44140
fun main(args: Array<String>) {
    val (H, N) = readLine()!!.split(" ").map(String::toInt)
    val AB = (1..N).map { readLine()!!.split(" ").map(String::toInt) }
    val A = arrayOf(0) + AB.map { a -> a[0] }
    val B = arrayOf(0) + AB.map { a -> a[1] }
    var dp = Array(N + 1) { IntArray(H + 1) }
    for (i in 1..N) dp[i][0] = 0
    for (j in 0..H) dp[0][j] = Int.MAX_VALUE
    for (i in 1..N) {
        for (j in 1..H) {
            val jj = Math.max(0, j - A[i])
            dp[i][j] = Math.min(dp[i - 1][j], dp[i][jj] + B[i])
        }
    }
    println(dp[N][H])
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int a, b;
	cin >> a >> b;
	if(a > 8 || b > 8)
		cout << ":(";
	else
		cout << "Yay!";





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 
  typedef pair<PLL,int> PPLLI;

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<PLL> v(N);
  rep(i,N) cin >> v[i].second;
  rep(i,N) cin >> v[i].first;
  sort(all(v));
  priority_queue<PLI,vector<PLI>,greater<PLI>> unsatque;
  rep(i,N) unsatque.push(PLI(v[i].second,i));
  priority_queue<PLI> pque;

  int count = 0;
  bool sat = true;

  rep(i,N){
    if(v[i].first>=v[i].second)continue;
    while(!unsatque.empty()){
      PLI p = unsatque.top();
      if(p.first > v[i].first) break;
      int index = p.second;
      pque.push(PLI(v[index].first,index));
      unsatque.pop();
    }

    while(true){
      if(pque.empty()){
        sat = false;
        break;
      }
      PLI p = pque.top();
      pque.pop();
      int index = p.second;
      ll vf = v[index].first;
      ll vs = v[index].second;
      if(index<i) continue;
      if(vf <= v[i].first){
        sat = false;
        break;
      }
      ++count;
      swap(v[index].second,v[i].second);
      unsatque.push(PLI(v[index].second,index));
      break;
    }
    if(!sat) break;
  }
  if(count>N-2)sat = false;
  YesNo(sat);
  return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

ll merge(vll& a, const int left, const int mid, const int right) {
    int n1 = mid - left, n2 = right - mid;

    vll l(n1 + 1), r(n2 + 1);
    rep(i, 0, n1) { l[i] = a[i + left]; }
    rep(i, 0, n2) { r[i] = a[i + mid]; }
    l[n1] = r[n2] = 1000000000;

    ll sum = 0;
    int i = 0, j = 0;
    rep(k, left, right) {
        if (l[i] <= r[j]) {
            a[k] = l[i++];
        }
        else {
            a[k] = r[j++];
            sum += n1 - i;
        }
    }
    return sum;
}

ll calc_inversion_num(vll& a, const int left, const int right) {
    ll sum = 0;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        sum += calc_inversion_num(a, left, mid);
        sum += calc_inversion_num(a, mid, right);
        sum += merge(a, left, mid, right);
    }
    return sum;
}


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

    vll A(n);
    rep(i, 0, n) { cin >> A[i]; }

    ll ans = calc_inversion_num(A, 0, n);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5940
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    k = f 0 . map (subtract 1) $ as
  print $ if k == 0 then (-1) else (n - k)

f :: Int -> [Int] -> Int
f i (x : xs) | x == i = f (succ i) xs
             | otherwise = f i xs
f i _ = i

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 8956
def main():

	n = int(input())

	num = 0
	sum = 0
	while sum <= n:
		if sum == n:
			print("Yes")
			break
		else:
			num += 1
			sum += num
	else:
		print("No")
		return
	
	Ss = []
	for i in range(num+1):
		Ss.append([])
	
	insert = 0
	for i in range(1,num+1)[::-1]:
		key = num - i
		for j in range(1,i+1):
			insert += 1
			Ss[key].append(insert)
			Ss[key+j].append(insert)
	
	print(len(Ss))
	for i in range(len(Ss)):
		ans = ""
		ans += str(len(Ss[i])) + " "
		ans += ' '.join(map(str, Ss[i]))
		print(ans)




if __name__ == '__main__':
	main()

Measured memory_bytes: 9172
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=200000+5;

map<char,char>mp1;
map<char,char>mp2;
void init()
{
    for(int i=0;i<26;i++)
    {
        mp1[i+'a']='a';
        mp2[i+'a']='a';
    }
}
char s1[N],s2[N];
int sz1[26],sz2[26];
int main()
{
    init();
    scanf("%s%s",s1,s2);
    int len=strlen(s1);
    /*for(int i=0;i<len;i++)
    {
        if(mp1[s1[i]]!=s2[i])
        {
            char c1=mp1[s1[i]],c2=mp2[s2[i]];
            mp1[s1[i]]=s2[i];
            mp2[s2[i]]=s1[i];
            mp1[c2]=c1;
            mp2[c1]=c2;
        }
    }
    for(int i=0;i<len;i++)
    {
        if(mp1[s1[i]]!=s2[i])
        {
            printf("No");return 0;
        }
        printf("%c",mp1[s1[i]]);
    }
    printf("Yes");*/
    memset(sz1,0,sizeof(sz1));
    memset(sz2,0,sizeof(sz2));
    for(int i=0;i<len;i++)
    {
        sz1[s1[i]-'a']++;
        sz2[s2[i]-'a']++;
    }

    sort(sz1,sz1+26);
    sort(sz2,sz2+26);
    for(int i=0;i<26;i++)
    {
        if(sz1[i]!=sz2[i])
        {
            printf("No");return 0;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 640
N = int(input())
S = [input() for i in range(N)]

ac = 0
wa = 0
tle = 0
re = 0

for i in S:
  if i == 'AC':
    ac += 1
  elif i == 'WA':
    wa += 1
  elif i == 'TLE':
    tle += 1
  else:
    re += 1
    
print("AC x", ac)
print("WA x", wa)
print("TLE x", tle)
print("RE x", re)

Measured memory_bytes: 16316
#include <cstring>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
    string x; cin >> x;
    while(x!="0"){
        int ans =0;
        for(int i=0; i<x.size(); i++){
            ans += x[i]-'0';
        }
        cout << ans << endl;
        cin >> x;
    }
    return 0;
}


Measured memory_bytes: 3184
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g,h,j,k;
	scanf("%d %d %d %d",&a,&s,&d,&f);
	scanf("%d %d %d %d",&g,&h,&j,&k);
	if(a+s+d+f>=g+h+j+k){
		printf("%d\n",a+s+d+f);
	}
	else{
		printf("%d\n",g+h+j+k);
	}
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> a(9);
  for(int i = 0; i<9 ; i++){
    cin >> a.at(i);
  }
  int flag = 0;
  for(int i = 0 ; i<= 100 ; i++){
    for(int j = 0 ; j<= 100; j++){
      for(int k = 0 ; k<= 100;k++){
        int a1,a2,a3;
        a1 = i;
        a2 = j;
        a3 = k;
        int b1,b2,b3;
        b1 = a.at(0) - a1;
        b2 = a.at(1) - a1;
        b3 = a.at(2) - a1;

        if( b1 < 0 || b2 < 0 || b3 < 0 ){
          break;
        }
        if( b1 >100 || b2 > 100 || b3 > 100){
          break;
        }
        if( a.at(3) == a2 + b1 && a.at(6) == a3 + b1 && a.at(4) == a2 + b2 && a.at(5) == a2 + b3 && a.at(7) == a3 + b2 && a.at(8) == a3 + b3){
          cout << "Yes" << endl;
          flag = 1;
        }
      }
      if(flag == 1){
        break;
      }
    }
    if(flag == 1){
      break;
    }
  }
  if(flag == 0){
    cout << "No" << endl;
  }
}

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

int main() {
	vector<int> x(3);
	for (int i = 0; i < 3; i++) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	for (int i = 0; i < 3; i++) {
		if (i < 2) {
			cout << x[i] << " " << flush;
		}
		else {
			cout << x[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3092
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    };
    let q = "keyence";
    if (0..7).any(|i| s.starts_with(&q[0..i]) && s.ends_with(&q[i..7])) { println!("YES") }
    else { println!("NO") }
}


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

int main(void)
{
    int r;
    cin >> r;
    if(r < 1200){cout << "ABC" << endl;}
    else if(r < 2800){cout << "ARC" << endl;}
    else{cout << "AGC" << endl;}
    return 0; 
}

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

using namespace std;


int main() {
    string x; cin>>x;
    int n = x.size();
    int s = 0 , t = 0;
    int cnt = 0;
    int mx = 0;
    bool toggle = 0;
    for(int i = 0 ; i < n; ++i){
        if(x[i] == 'S'){
            s++;
        }
        else if(x[i] == 'T' && s){
            s--;
            cnt++;
        }
    }
    cout<<n - cnt * 2<<"\n";
}

Measured memory_bytes: 640