akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(ll, n, a);
    
    ll ans = 0;
    For(i, n) ans += a[i];
    For(i, n/2) ans -= 2*a[2*i+1];
    cout << ans << " ";
    
    For(i, n-1){
        ans = 2*a[i] - ans;
        cout << ans << " ";
    }
    Cout("");
}




Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

#define prev prev228

const int N = 100005;
int A[N], B[N];
int n, m;
vector<pii> G[N];
vector<int> H[N];
int X[N];

int q[N + N], qt;
int prev_odd[N];
int prev[N];
int prev_e[N];

void toggle(int i)
{
    swap(A[i], B[i]);
    X[A[i]] ^= 1;
    X[B[i]] ^= 1;
}

void move_back(int v, int to)
{
    while (v != to)
    {
        toggle(prev_e[v]);
        v = prev[v];
    }
}

void dfs(int v)
{
    int w = -1;
    for (int u : H[v])
    {
        dfs(u);
        if (X[u])
        {
            if (w == -1)
            {
                w = u;
            }
            else
            {
                move_back(u, v);
                move_back(w, v);
                X[u] = X[w] = 0;
                w = -1;
            }
        }
    }
    if (w != -1)
    {
        move_back(w, v);
        X[v] = X[w] = 0;
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    cin >> n >> m;
    if (m & 1)
    {
        cout << "-1\n";
        return 0;
    }
    for (int i = 0; i < m; ++i)
    {
        cin >> A[i] >> B[i];
        G[A[i]].pb(mp(B[i], i));
        G[B[i]].pb(mp(A[i], i));
        X[A[i]] ^= 1;
    }
    vector<int> odd;
    for (int v = 1; v <= n; ++v) if (X[v]) odd.pb(v);
    if (!odd.empty())
    {
        fill(prev_odd, prev_odd + n + 1, -1);
        q[0] = odd[0];
        qt = 1;
        prev_odd[q[0]] = -2;
        for (int i = 0; i < qt; ++i)
        {
            int v = q[i];
            int podd = prev_odd[v];
            if (X[v])
            {
                podd = v;
                if (prev_odd[v] != -2)
                {
                    H[prev_odd[v]].pb(v);
                }
            }
            for (auto &p : G[v])
            {
                int u = p.fi;
                int i = p.se;
                if (prev_odd[u] == -1)
                {
                    prev_odd[u] = podd;
                    prev[u] = v;
                    prev_e[u] = i;
                    q[qt++] = u;
                }
            }
        }
        dfs(q[0]);
    }
    for (int i = 0; i < m; ++i)
    {
        cout << A[i] << ' ' << B[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 15228
#include <iostream>
#include <cstdio>
using namespace std;
int N,K;
int main(){
  cin >> N >> K;
  long long int ans=1;
  if(N==1)printf("%d\n",K);
  else{
    for(int i=0;i<N-1;i++)ans*=(K-1);
      printf("%lld\n",ans*K);
  }
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	ans := -1
	if b >= a {
		ans = c
	} else if lack := a - b; lack >= c {
		ans = 0
	} else {
		ans = c - lack
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll x, y;
    cin>>x>>y;
    if (abs(x - y) <= 1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int r,c,k;
char grid[305][305];
int row[305];
int fin[305][305];
int main(){
    scanf("%d%d%d",&r,&c,&k);
    for (int x=0;x<r;x++){
        getchar();
        for (int y=0;y<c;y++){
            grid[x][y]=getchar();
            if (grid[x][y]=='#') row[x]++;
        }
    }

    for (int x=0;x<r;x++){
        if (row[x]==0 || k==0){
            if (x==0 || grid[x-1][0]==-1){
                fin[x][0]=-1;
            }
            else{
                for (int y=0;y<c;y++){
                    fin[x][y]=fin[x-1][y];
                }
            }
        }
        else{
            fin[x][0]=k;
            for (int y=1;y<c;y++){
                if (grid[x][y-1]=='#' && k!=0){
                    fin[x][y]=--k;
                }
                else{

                    fin[x][y]=k;
                }
            }

            if (grid[x][c-1]=='#' && k!=0){
                k--;
            }
            else{
                for (int y=c-1;grid[x][y]!='#';y--){
                    fin[x][y]=k+1;
                }
            }
        }
    }

    for (int x=r-1;x>=0;x--){
        if (fin[x][0]==-1){
            for (int y=0;y<c;y++) fin[x][y]=fin[x+1][y];
        }
    }

    int buffer=1;
    for (int x=0;x<r;x++){
        for (int y=0;y<c;y++) buffer=min(buffer,fin[x][y]);
    }

    for (int x=0;x<r;x++){
        for (int y=0;y<c;y++){
            if (buffer==0){
                if (fin[x][y]==1) printf("2 ");
                else if (fin[x][y]==0) printf("1 ");
                else printf("%d ",fin[x][y]);
            }
            else printf("%d ",fin[x][y]);
        }
        printf("\n");
    }

}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int h = s.nextInt(), n = s.nextInt();
		long z = 0;
		for(int i=0;i<n;i++) {
			z += s.nextLong();
		}
		if (z >= h) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 48576
#include <cstdio>
int main()
{
	int k, x;
	scanf("%d%d", &k, &x);
	for (int i = x - k + 1; i <= x + k - 1; i++) {
		if (i >= -1000000 && i <= 1000000)
			printf("%d ", i);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
struct Point{int x,y;};
int main(){
  int num,n,d,i,minx,miny,maxx,maxy;
  cin >> num;
  while(num!=0){
    Point ps[201];
    ps[0].x=0;ps[0].y=0;
    
    for(i=1;i<num;i++){
      cin >> n >> d;
      if(d==0) {
	ps[i].x=ps[n].x-1;
	ps[i].y=ps[n].y;
      }
      if(d==1) {
	ps[i].x=ps[n].x;
	ps[i].y=ps[n].y-1;
      }
      if(d==2) {
	ps[i].x=ps[n].x+1;
	ps[i].y=ps[n].y;
      }
      if(d==3) {
	ps[i].x=ps[n].x;
	ps[i].y=ps[n].y+1;
      }
    }
    minx=0;miny=0;maxx=0;maxy=0;
    for(i=0;i<num;i++){
      minx=min(minx,ps[i].x);
      maxx=max(maxx,ps[i].x);
      miny=min(miny,ps[i].y);
      maxy=max(maxy,ps[i].y);
    }
    cout << (maxx-minx+1) << " " << (maxy-miny+1) << endl;
    cin >> num;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n;
    cin>>n;
    vector<ll> v(n+1),sum(n+1);
    vector<vector<ll>> dp(n+1,vector<ll>(n+1));
    for(int i=1;i<=n;i++) cin>>v[i],sum[i]=sum[i-1]+v[i];
    for(int i=1;i<n;i++)
        for(int j=1;j+i<=n;j++)
        {
            dp[j][j+i]=1e18;
            for(int k=j;k<j+i;k++)
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]);
            dp[j][j+i]+=sum[j+i]-sum[j-1];
        }
    cout<<dp[1][n]<<'\n';
}

Measured memory_bytes: 4516
from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
    d[i+1]=l[i]
visited=set()
l=[]
i=1
while True:
    l.append(i)
    if i not in visited:
        visited.add(i)
    else:
        break
    i=d[i]
first=l.index(l[-1])
if k<first:
    print(l[k])
else:
    k=(k-first)%((len(l)-1)-first)
    k+=first
    print(l[k])

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

typedef long long ll;

ll N;
vector<ll> A;
ll MAX = 1'000'000'000'000'000'000ll;

ll solve() {
  for (ll a : A) {
    if (a == 0) return 0;
  }
  ll res = 1;
  for (ll a : A) {
    if (a > MAX / res) return -1;
    res *= a;
  }
  return res;
}
int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  cout << solve() << endl;
  return 0;
}


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

int cmp(const char *s1, const char *s2, int upcnt)
{
	int i;
	
	for (i = 0; s1[i] != 0; i++){
		if (s1[i] != s2[upcnt * i]) return i + 1;
	}
	return 0;
}

int main(void)
{
	int n;
	int cnt = 0;
	char name[32];
	
	scanf("%d", &n);
	scanf("%s", name);
	while (n-- > 0){
		char str[256] = {0};
		int i, j;
		int len;
		
		scanf("%s", str);
		len = strlen(str);
		
		for (i = 0; i < len - 2; i++){
			if (str[i] == name[0]){
				for (j = 1; j <= len / 2; j++){
					if (cmp(name, str + i, j) == 0){
						cnt++;
						i = len;
						break;
					}
				}
			}
		}
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
string s;
int main()
{fast
	int h,n,s=0,i,a[100005];
	cin>>h>>n;	
	for(i=0;i<n;i++)
	{	cin>>a[i];
		s+=a[i];
	}	
	if(s>=h)
		cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,b; cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    int DigitSum=0;
    int t=i;
    for(int j=0;j<5;j++){
      DigitSum += t%10;
      t/=10;
    }
    if(a<=DigitSum && DigitSum<=b){
      ans+=i;
    }
  } 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# 整数の入力
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

# 距離の和が最小：範囲間の隙間が最大値だとよい。
# よって、ソートしたでかい順に引けばよい
X.sort()


if N >= M:
    ans = 0
    
else:
    Y = []
    i = 1
    for i in range(M-1):
        sa = X[i+1]-X[i]
        Y.append(sa)
    Y.sort()

    sa = X[M-1]-X[0]

    
    ans = sa
    
    for i in range(N-1):
        ans = ans-Y[M-i-2]
        

    
print(ans)


Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int cost(int x,int y)
{
    return (x-y)*(x-y);
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll ans=INT_MAX,n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    for(int i=-10000; i<=10000;i++){
        ll cur=0;
        for(int j=0;j<n;j++){
            cur+=cost(arr[j],i);
        }
    ans=min(ans,cur);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
typedef long long ll;
const int  N_MAX = 200001;
const int INF = 1e9;
ll M = 1e9 + 7;
ll dp[N_MAX+1];
int C[N_MAX];
int lnum[N_MAX+1];

int main(){
  int N;
  cin >> N;
  for(int i = 0; i <= N_MAX; i++){
    if(i < N) cin >> C[i];
    dp[i] = 0;
    lnum[i] = INF;
  }
  dp[1] = 1;
  lnum[C[0]] = 1;
  for(int i = 1; i < N; i++){
    if(C[i] == C[i-1] || lnum[C[i]] == INF){
      dp[i+1] = dp[i];
      lnum[C[i]] = i + 1;
    }
    else{
      dp[i+1] = (dp[i] + dp[lnum[C[i]]]) % M;
      lnum[C[i]] = i + 1;
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 3328
n=int(input())
if n%2!=0:
    print(0)
else:
    f=[]
    five=10
    for i in range(27):
        x=n//five
        f.append(x)
        five*=5
    f2=[]
    for i in range(26):
        f2.append(f[i]-f[i+1])
    ans=0
    for i in range(26):
        ans+=(i+1)*f2[i]
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int n;
    ll t;
    cin >> n >> t;
    vector<ll> tt(n);
    rep(i,n) cin >> tt[i];

    ll ans = 0;
    rep(i,n-1){
        ans += min(tt[i+1] - tt[i], t);
    }
    cout << ans + t << endl;
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
const int N = 200005;
string s;
const int mod = 2019;
int cnt[2020];
int base[N];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    int power = 1;
    long long ans = 0;
    cnt[0] = 1;
    for(int i = s.size() - 1;i>=0;--i){
        base[i] = (base[i+1] + power * (s[i] - '0')) % mod;
        power = (power * 10) % 2019;
        ans+= cnt[base[i]];
        cnt[base[i]]++;
    }
    cout << ans;
}

Measured memory_bytes: 4528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int a[n]={};
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=a[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 3656
from collections import Counter as C
n=int(input())
S=list(input())
a=1
L=C(S).most_common(3)
for l in L:
  a*=l[1]
for i in range(1,n):
  for j in range(n-2*i):
    if len(set((S[j],S[j+i],S[j+2*i])))==3:
      a-=1
print(a if len(L)>2 else 0)

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

void solve(){
	// code starts from here
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	
	ll ans = 0;
	if(a >= k){
		cout << k << endl;
		return;
	}
	ans = a;
	k -= a;
	if(b >= k){
		cout << ans << endl;
		return;
	}
	k -= b;
	ans -= k;
	cout << ans << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3636
n,m,k=map(int,input().split())
import math
def f(x): return math.factorial(x)
def c(x,y): return f(x)//(f(x-y)*f(y))
print(((n**2*(m-1)*m*(m+1)//6+m**2*(n-1)*n*(n+1)//6)*c(m*n-2,k-2))%(10**9+7))

Measured memory_bytes: 74588
# C - Colon

from math import sin, cos, pi, sqrt

a, b, h, m = map(int, input().split())

ma = m * pi * 2 / 60  # 分針の角度
ha = (h + m / 60) * pi * 2 / 12  # 時針の角度

hx = a * cos(ha)
hy = a * sin(ha)
mx = b * cos(ma)
my = b * sin(ma)

print(sqrt((hx - mx) ** 2 + (hy - my) ** 2))


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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int CountWords(const string &w) {
	string t;
	int count = 0;
	for (cin >> t; t != "END_OF_TEXT"; cin >> t) {
		transform(t.begin(), t.end(), t.begin(), ::tolower);
		if (t == w) count++;
	}
	return count;
}

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

	string w;
	cin >> w;
	cout << CountWords(w) << endl;

	return 0;
}



Measured memory_bytes: 3200
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  int A, B, X;
  cin >> A >> B >> X;
  if (X >= A && X - A <= B) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}


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

int main() {
  int x,y;cin>>x>>y;
  if(x==4||x==6||x==9||x==11) x=3;
  else if(x==2) x=4;
  else x=2;
  
  if(y==4||y==6||y==9||y==11) y=3;
  else if(y==2) y=4;
  else y=2;
  
  if(x==y) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	set<int>v;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		v.insert(a[i]); 
	}
	if(v.size()!=n)
		cout<<"NO";
	else 
		cout<<"YES";

	return 0;
}

Measured memory_bytes: 10368
import sys
from itertools import permutations

def solve():
    N, M = map(int, input().split())
    Edge = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        Edge[a-1].append(b-1)
        Edge[b-1].append(a-1)
    count = 0
    for order in permutations(range(N)):
        if order[0] != 0: continue
        for i in range(N-1):
            if order[i+1] not in Edge[order[i]]: break
        else: count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

vector<int> G[200000];
int used[200000], d[200000], par[200000];
int n, k, ans = 0;
int dfs(int v){
	if(used[v])return 0;
	used[v] = 1;
	int mx = 0;
	rep(i,G[v].size()){
		chmax(mx, dfs(G[v][i])+1);
	}
	//if(v == 3)printf("*%lld*\n", mx);
	//if(par[v] == -1 and v != 0)printf("*%lld*\n", v);
	if(v == 0)return 0;
	if(par[v] == -1)ans++;
	else if(mx == k-1){
		if(par[v] == 0)return 0;
		//if(v == 3)printf("*%lld*\n", v);
		ans++;d[v] = -1;mx = -1;
	}
	return mx;
}

signed main(){
	fill(par, par+200000, -1);
	scanf("%lld%lld", &n, &k);
	rep(i,n){
		int x;
		scanf("%lld", &x);x--;
		if(i == 0){
			if(x != 0)ans++;
			continue;
		}
		par[i] = x;
		G[x].pb(i);
	}
	
	rep(i,n){
		if(used[i] == 0)dfs(i);
	}
	printf("%lld\n", ans);
	return 0;
}







Measured memory_bytes: 17408
def main():
    x = [int(s) for s in input()]
    x = x[::-1]
    print(solve(x))

def solve(x):
    M = 10 ** 9 + 7

    dp1 = [0 for _ in x]
    dp2 = [0 for _ in x]

    dp1[0] = 3
    dp2[0] = 3 if x[0] else 1

    for i in range(1, len(x)):
        dp1[i] = (dp1[i-1] * 3) % M
        if x[i]:
            dp2[i] = (dp1[i-1] % M + (dp2[i-1] * 2) % M) % M
        else:
            dp2[i] = dp2[i-1]

    return dp2[-1]

main()


Measured memory_bytes: 11660
N = int(input())
Ai = list(map(int, input().split()))

add_sum = 0
xor_sum = 0
count = 0

left = 0
right = 0
while True:
    while right < N:
        add_sum = add_sum + Ai[right]
        xor_sum = xor_sum ^ Ai[right]
        if add_sum != xor_sum:
            add_sum = add_sum - Ai[right]
            xor_sum = xor_sum ^ Ai[right]
            break
        right += 1
        count += (right - left)
    add_sum = add_sum - Ai[left]
    xor_sum = xor_sum ^ Ai[left]
    left += 1
    if left >= N:
        break

print(count)


Measured memory_bytes: 23560
N = int(input())
p = [int(input()) for i in range(N)]
#最大値を求める
max = p[0]
max_i = 0
for i in range(N):
    if max < p[i]:
        max = p[i]
        max_i = i
#maxが最大値
sum = 0
p[max_i] = p[max_i] / 2
for i in range(N):
    sum = sum + p[i]
print(int(sum))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll n, k;
    cin>>n>>k;
    
    vector<ll> h(n);
    loop(n) cin>>h[i];

    if(k>=n){
        cout<<0;
        return 0;
    }
    sort(h);
    ll as = 0;
    loop(n-k){
        as += h[i];
    }

    cout<<as;
    return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto M = RD;

	writeln(N*(N-1)/2 + M*(M-1)/2);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
  int a,b;
  cin >> a >> b;
  vector<int> sunuke(a);
  FOR(i,0,b){
      int d;
      cin >> d;
      FOR(j,0,d){
         int k;
         cin >> k;
         sunuke.at(k-1) = 1;
      }

      }
      int ans = 0;
      FOR(i,0,a) if(sunuke.at(i) ==  0) ans++;
      cout << ans << endl;

    return 0;

}


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

int main()
{
	int n; cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	n--;
	
	int ans = d[n / 2 + 1] - d[n / 2];

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

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            long N = Integer.parseInt(br.readLine());
            long ans = 1;
            for (long i = 1; i <= N; i++) {
                ans *= i;
                ans = ans % 1000000007;
            }

            ans = ans % 1000000007;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  char c;cin>>c;
  char vowel[] = {'a', 'i', 'u', 'e', 'o'};
  bool v = false;
  for(int i=0;i<5;i++){
  	if(c==vowel[i]){v=true;break;}
  }
  cout<<(v?"vowel":"consonant")<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {Scanner sc=new Scanner(System.in);
		int W=sc.nextInt(),H=sc.nextInt(),x=sc.nextInt(),y=sc.nextInt(),r=sc.nextInt();
	if(x-r>=0&&y-r>=0&&x+r<=H&&y+r<=H)
		{System.out.println("Yes");}
	 else {System.out.println("No");}
}
}

Measured memory_bytes: 17360
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
    double pai = 3.1415926535;
    double R;
    cin >> R;

    cout << 2*pai*R <<endl;


}

Measured memory_bytes: 3788
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = []
    first = (0, 0)
    sec = 0
    for i in range(N):
        a = int(input())
        A.append(a)
        if first[0] <= a:
            sec = first[0]
            first=(a, i)
        elif sec <a:
            sec =a

    if first[0] == sec:
        for i in range(N):
            print(sec)
    else:
        for i in range(N):
            if i == first[1]:
                print(sec)
            else:
                print(first[0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 81664
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    ll H, W, N;
    cin >> H >> W >> N;
    ll sr, sc;
    cin >> sr >> sc;
    string S, T;
    cin >> S >> T;
    bool ok = true;

    ll right = W + 1;
    ll left = 0;
    ll down = H + 1;
    ll up = 0;
    for (ll i = N - 1; i >= 0; --i) {
        if (T[i] == 'L') {
            right = min(right + 1, W + 1);
        } else if (T[i] == 'R') {
            left = max(left - 1, 0LL);
        }
        if (T[i] == 'U') {
            down = min(down + 1, H + 1);
        } else if (T[i] == 'D') {
            up = max(up - 1, 0LL);
        }
        if (S[i] == 'L') {
            left++;
        } else if (S[i] == 'R') {
            right--;
        }
        if (S[i] == 'U') {
            up++;
        } else if (S[i] == 'D') {
            down--;
        }

        if (right - left <= 1) {
            ok = false;
            break;
        }
        if (down - up <= 1) {
            ok = false;
            break;
        }
    }

    if (right <= sc || left >= sc) {
        ok = false;
    }

    if (up >= sr || down <= sr) {
        ok = false;
    }

    if (ok)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
 int W,H,x,y,r;
 cin >> W >> H >> x >> y >> r;

 if(r <= x && x <= W-r && r <= y && y <= H-r){
  cout << "Yes" << endl;
 }else {
  cout << "No" << endl;
 }

 return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,a[300010];
vector<int>v,sum={0};
map<int,int>mp;
bool check(int k,int m){
    int x=lower_bound(all(v),m)-v.begin();
    int res=sum[x]+(v.size()-x)*m;
    return res>=m*k;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(P p:mp)v.pb(p.se);
    sort(all(v));
    for(int i:v)sum.pb(sum.back()+i);
    for(int k=1;k<=n;k++){
        int ok=0,ng=n+1;
        while(ng-ok>1){
            int m=(ok+ng)/2;
            if(check(k,m))ok=m;
            else ng=m;
        }
        cout<<ok<<endl;
    }
    return 0;
}

Measured memory_bytes: 31724
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const N = input[0]
  const u = input[1].split(' ').map(n => Number(n)).sort((a, b) => a - b)
  while (u.length >= 2) {
    const a = u.shift()
    const b = u.shift()
    const tmp = (a + b) / 2
    u.push(tmp)
    u.sort((a, b) => a - b)
  }
  console.log(u[0])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N, M;
    cin >> N >> M;
    P(((N==M)? "Yes" : "No" ));
}

Measured memory_bytes: 256
x, y = map(int, input().split())
z = x + y
mod = 10 ** 9 + 7
if z % 3 == 0:
  w = z // 3
  a, b = sorted([x - w, y - w])
  if a < 0:
    print(0)
  elif a == 0:
    print(1)
  else:
    inv_mod = [1] * (a + 1)
    num = b + 1
    den = 1
    for i in range(2, a + 1):
      num = num * (b + i) % mod
      inv_mod[i] = -inv_mod[mod % i] * (mod // i) % mod
      den = den * inv_mod[i] % mod
    print(num * den % mod)
else:
  print(0)

Measured memory_bytes: 16116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    string s;
    cin >> s;
    int n = sz(s);
    vector<vector<mint>> dp(n+1, vector<mint>(4, 0));
    dp[0][0] = 1;
    rep(i, n) {
        if (s[i] == 'A') {
            rep(j, 4) dp[i+1][j] += dp[i][j];
            dp[i+1][1] += dp[i][0];
        }
        if (s[i] == 'B') {
            rep(j, 4) dp[i+1][j] += dp[i][j];
            dp[i+1][2] += dp[i][1];
        }
        if (s[i] == 'C') {
            rep(j, 4) dp[i+1][j] += dp[i][j];            
            dp[i+1][3] += dp[i][2];
        }
        if (s[i] == '?') {
            rep(j, 3) dp[i+1][j+1] += dp[i][j];
            rep(j, 4) dp[i+1][j] += mint(3) * dp[i][j];
        }
    }
    cout << dp[n][3] << endl;
}


Measured memory_bytes: 7376
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
enum FACE { TOP, BOTTOM, BACK, FRONT, RIGHT, LEFT };
struct Dice {
  int id[6];
  Dice() {
    REP(i, 6) id[i] = i;
  }
  void roll_r(int r){
    if(r == 0) roll(TOP, LEFT, BOTTOM, RIGHT);
    if(r == 1) roll(TOP, BACK, BOTTOM, FRONT);
    if(r == 2) roll(TOP, RIGHT, BOTTOM, LEFT);
    if(r == 3) roll(TOP, FRONT, BOTTOM, BACK);
  }
  void roll(int a, int b, int c, int d) {
    int tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  int to_int(){
    return id[TOP] * 6 * 6 + id[FRONT] * 6 + id[LEFT];
  }
  int color(){
    return id[TOP];
  }
};
int color_to_i(char c){
  string s = "rcgmbywk";
  REP(i, s.size()) if(c == s[i]) return i;
  assert(false);
  return -1;
}

int main(){
  int W, H;
  while(cin >> W >> H && W){
    vector<string> grid(H);
    REP(y, H) cin >> grid[y];
    string v;
    cin >> v;
    int ans = 0;
    int sx = -1, sy = -1;
    REP(y, H) REP(x, W) if(grid[y][x] == '#'){
      grid[y][x] = 'w';
      sx = x, sy = y;
    }
    int dist[30][30][7][216] = {};
    memset(dist, -1, sizeof(dist));
    Dice sd;
    queue<int> qx, qy, qs;
    queue<Dice> qd;
    qx.push(sx); qy.push(sy); qs.push(0); qd.push(sd);
    dist[sy][sx][0][sd.to_int()] = 0;
    bool ng = true;
    while(!qx.empty()){
      int x = qx.front(); qx.pop();
      int y = qy.front(); qy.pop();
      int s = qs.front(); qs.pop();
      Dice d = qd.front(); qd.pop();
      //printf("x = %d y = %d s = %d c = %d\n", x, y, s, d.color());
      if(s == 6){
        cout << dist[y][x][s][d.to_int()] << endl;
        ng = false;
        break;
      }
      REP(r, 4){
        int nx = x + dx[r];
        int ny = y + dy[r];
        if(!valid(nx, ny, W, H)) continue;
        if(grid[ny][nx] == 'k') continue;
        Dice nd = d;
        nd.roll_r(r);
        if(grid[ny][nx] != 'w' && (color_to_i(grid[ny][nx]) != nd.color() || grid[ny][nx] != v[s])) continue;
        int ns = (grid[ny][nx] == 'w') ? s : s + 1;
        if(dist[ny][nx][ns][nd.to_int()] != -1) continue;
        dist[ny][nx][ns][nd.to_int()] = dist[y][x][s][d.to_int()] + 1;
        qx.push(nx);
        qy.push(ny);
        qs.push(ns);
        qd.push(nd);
      }
    }
    if(ng) cout << "unreachable" << endl;
  }
  return 0;
}

Measured memory_bytes: 6608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  string S,T; cin>>S>>T;
  cout<<T<<S<<endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d\n", &n);
	string s = readln().chomp;
	int[] score = new int[n];

	{
		int cur = 0;
		foreach (i; 0..n) {
			score[i] += cur;
			if (s[i] == 'W') cur++;
		}
	}
	{
		int cur = 0;
		foreach_reverse (i; 0..n) {
			score[i] += cur;
			if (s[i] == 'E') cur++;
		}
	}
	int ans = n;
	foreach (i; 0..n) {
		ans = min(ans, score[i]);
	}
	writeln(ans);
}

Measured memory_bytes: 3924
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  map<ll, ll> mp;
  ll ans = 0, sum = 0;
  mp[sum] = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
    ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
while (n = gets.to_i) != 0 do
  sweets = []
  n.times do
    sweets << gets.split.map(&:to_i)
  end
  p, q, r, c = gets.split.map(&:to_i)

  can_eat_sweets = []
  sweets.each do |sweet|
    can_eat_sweets << sweet[0] if sweet[1] <= p and sweet[2] <= q and sweet[3] <= r and (sweet[1] + sweet[3]) * 4 + sweet[2] * 9 <= c
  end

  if can_eat_sweets.empty? then
    puts 'NA'
  else 
    puts can_eat_sweets.join"\n"
  end
end

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
using ll = long long; //10^19 < 9223372036854775807
#define REP(i,n) for(ll i=0;i<ll(n);i++)

int main(void)
{
    double N;
    cin >> N;
    printf("%.12lf\n", N*N*N/27);

    return 0;
}


Measured memory_bytes: 3716
#include <stdio.h>

int main(void)
{
    char b;
    scanf("%s",&b);
    if (b=='A') printf("T\n");
    else if (b=='T') printf("A\n");
    else if (b=='C') printf("G\n");
    else if (b=='G') printf("C\n");
    return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),t,h;
    for(int i=0;i<n;i++)    cin>>a[i];
    sort(a.begin(),a.end());
    int temp=n-2;
    t.push_back(a[n-1]);
    int ans = a[n-1];
    for(int i=n-2;i>=0;i--){
        if(temp>0&&a[i]>=0){
                ans+=a[i];
                t.push_back(a[i]);
                temp--;
        }
        else{
            ans+=(a[i]*-1);
            h.push_back(a[i]);
        }
    }
    cout << ans << endl;
    ll num;
    if(t.size()>1){
        num=h[0]-t[1];
        cout << h[0] <<" "<< t[1] << endl;
        for(int i=2;i<t.size();i++){
           cout << num <<" "<< t[i] << endl;
            num=num-t[i];
        }
        cout << t[0] << " " << num << endl;
        num = t[0]-num;
        for(int i=1;i<h.size();i++){
            cout << num <<" "<< h[i] << endl;
            num=num-h[i];
        }
    }
    else{
        num=t[0]-h[0];
        cout << t[0] <<" "<< h[0] << endl;
        for(int i=1;i<h.size();i++){
            cout << num << " " << h[i] << endl;
            num=num-h[i];
        }
    }
}


Measured memory_bytes: 2808
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define F first
#define S second 
using namespace std;
typedef pair<int,int> Pi;

int main(){
    int M,T,P,R;
    while(cin >> M >> T >> P >> R,M|T|P|R){
        vector<Pi> ST(T);
        vector<vector<int> > cnt(T, vector<int>(P));
        rep(i,R){
            int m,t,p,r;
            cin >> m >> t >> p >> r;
            t--; p--;
            if(r == 0){
                ST[t].F++;
                ST[t].S -= m+20*cnt[t][p];
            }
            else cnt[t][p]++;
        }
        vector<int> num(T);
        iota(num.begin(),num.end(),0);
        reverse(num.begin(),num.end());
		stable_sort(num.begin(),num.end(),[&](int i,int j){return ST[i]>ST[j];});
		cout << num[0]+1;
        for(int i=1; i<T; i++){
            if(ST[num[i]]==ST[num[i-1]]) cout << '=';
            else cout << ',';
            cout << num[i]+1;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e12)

using namespace std;
typedef long long int ll;

template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}

ll N;
int main(void){
    cin >> N;
    vector<ll> V = enum_div(N);
    ll A = V.size();
    ll res = INF;
    for(int i=0;i<A;i++){
        res = min(res, V[i]+N/V[i]-2);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {
	string S;
	cin >> S;
	int count = 0;
	if (S[0] == S[1]) {
		count += 1;
	}
	if (S[0] == S[2]) {
		count += 1;
	}
	if (S[0] == S[3]) {
		count += 1;
	}
	if (S[1] == S[2]) {
		count += 1;
	}
	if (S[1] == S[3]) {
		count += 1;
	}
	if (S[2] == S[3]) {
		count += 1;
	}
	if (count == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool flag = false;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i * j == N){
	flag = true;
      }
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	int a  , b ;
	cin>>a>>b;
	repu(i , 0 , 100000){
		if((i*8)/100==a && b == (i*10)/100){
			cout<<i;
			return;
		}
	}
	cout<<-1;
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256