akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HBonsai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BYYMMOrMMYY solver = new BYYMMOrMMYY();
        solver.solve(1, in, out);
        out.close();
    }

    static class BYYMMOrMMYY {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int S = Integer.parseInt(in.next());
            int former = S / 100;
            int later = S % 100;
            if ((former >= 1 && former <= 12) && (later >= 1 && later <= 12)) {
                out.println("AMBIGUOUS");
            } else if (former >= 1 && former <= 12) {
                out.println("MMYY");
            } else if (later >= 1 && later <= 12) {
                out.println("YYMM");
            } else {
                out.println("NA");
            }
        }

    }

    static class FastScanner implements Closeable {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public void close() {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
using namespace std;
long long k,s;
long long sol;

int main()
{
    cin>>k>>s;
    for (int i=0;i<=k;i++)
    {
        for (int j=0;j<=k;j++)
        {
            if (s-i-j>=0 and s-i-j<=k)
                sol++;
        }
    }
    cout<<sol<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int x,y,z,k;cin>>x>>y>>z>>k;
    vector<ll>X(x);for(int i=0;i<x;i++)cin>>X[i];
    vector<ll>Y(x);for(int i=0;i<y;i++)cin>>Y[i];
    vector<ll>Z(x);for(int i=0;i<z;i++)cin>>Z[i];
    vector<ll>A(x*y);
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            A[i*y+j]=X[i]+Y[j];
        }
    }
    sort(A.begin(),A.end(),greater<ll>());
    int f=min(x*y,3000);
    vector<ll>B(f*z);
    for(int i=0;i<f;i++){
        for(int j=0;j<z;j++){
            B[i*z+j]=A[i]+Z[j];
        }
    }
    sort(B.begin(),B.end(),greater<ll>());
    for(int i=0;i<k;i++)cout<<B[i]<<endl;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
    
    
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;

    vector<ll> v, v2;
    reps(i, 1, n+1){
        if(i%k == 0) v.push_back(i);
        if(k%2 == 0 && i%k == k/2) v2.push_back(i);
    }

    ll res = pow(v.size(), 3);

    if(k%2==1) cout << res << endl;
    else {
        res += pow(v2.size(), 3);
        cout << res << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

string alp;

ll hoge(char a){
    ll k=0;
    rep(i,0,25){
        if(a==alp[i]){
            k=i;
            break;
        }
    }
    if(k==0)return 0;
    return 26-k;
}

int main(){
    string s;cin>>s;
    ll k;cin>>k;
    alp="qwertyuiopasdfghjklzxcvbnm";
    sort(alp.begin(),alp.end());
    ll sum=0;
    rep(i,0,s.size()-1){
        if(sum+hoge(s[i])>k){
            continue;
        }else{
            sum+=hoge(s[i]);
            s[i]='a';
        }
    }
    s[s.size()-1]=alp[(26+k-sum-hoge(s[s.size()-1]))%26];
    cout<<s<<endl;
    
    return 0;
}



Measured memory_bytes: 512
w,h,x,y = map(int, input().split())
p = 0
if (x==0)|(x==w)|(y==0)|(y==h):
  mens = w*h/2
  p = 0
elif (x==(w/2))|(y==(h/2)):
  mens = w*h/2
  if (x==(w/2))&(y==(h/2)):
    p = 1
  else:
    p = 0
elif ((x/y)==(w/h))|(y == -(h/w)*x+h):
  p = 1
  mens = w*h/2
else:
  if ((y<h/w*x)&(y<-(h/w)*x+h))|((y>h/w*x)&(y>-(h/w)*x+h)):
    p = 0
    mens = w*h/2
  else:
    p = 0
    mens = w*h/2
print(mens, p)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

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


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
int main(){
  ll a,b,c,d,e;
  ll na,nb,nc;
  while( cin >> a >> b >> c >> d >> e && (a|b|c|d|e) ){
    cin >> na >> nb >> nc;
    v.clear();
    for(int i=0;i<nc;i++) v.push_back(c);
    for(int i=0;i<nb;i++) v.push_back(b);
    for(int i=0;i<na;i++) v.push_back(a);
    ll sum = 0;
    ll reg = na*a + nb*b + nc*c;
    ll res = reg;
    for(int i=0;i<na+nb+nc;i++){      
      sum += v[i];
      if( i+1 >= d ){
        res = min( res, reg - sum + ((ll)i+1)*e );
      } else {
        res = min( res, reg - sum + d * e );
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 5984
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] x = new int[n];
        int[] y = new int[n];

        for (int i = 0; i < n ; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        double sum = 0;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                int xDis = x[i] - x[j];
                int yDis = y[i] - y[j];
                xDis *= xDis;
                yDis *= yDis;
                sum += Math.sqrt(xDis + yDis);
            }
        }

        System.out.println(sum / n);
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                int c1 = int.Parse(temp[0]);
                int c2 = int.Parse(temp[1]);
                int c3 = int.Parse(temp[2]);

                bool[] memo = new bool[11];
                memo[c1] = memo[c2] = memo[c3] = true;

                bool flg = true;

                int limit = 20 - (c1 + c2);
                int cnt = 0;

                if (limit <= 5)
                {
                    for (int i = 1; i <= limit; i++)
                    {
                        if (!memo[i]) cnt++;
                    }
                    flg = cnt >= 4 ? true : false;
                }
                sb.AppendLine(flg ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 8816
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <unordered_set>
#include <numeric>
using namespace std;

const int MOD = 1e9 + 7;
#define ll long long


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

	unordered_set<int> broken;
	for (int i = 0; i < m; i++)
	{
		int a;
		cin >> a;
		broken.insert(a);
	}

	vector<int> res(n + 1);
	res[0] = 1;
	if (broken.find(1) == broken.end())
	{
		res[1] = 1;
	}

	for (int i = 2; i <= n; i++)
	{
		if (broken.find(i) == broken.end())
		{

			res[i] = (res[i - 1] + res[i - 2]) % MOD;
		}
	}

	cout << res[n] << endl;
}

Measured memory_bytes: 4772
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		Integer n;
		while(true){
			n = sc.nextInt();
			if(n.intValue() == 0){
				break;
			}
			list.add(n);
		}
		for(int i = 0;i < list.size(); i++){
			System.out.printf("Case %d: %d\n", i + 1, list.get(i).intValue());
		}
	}
}




Measured memory_bytes: 61420
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long  ll;
const int N = 1e5 + 4;

int a[N][3] , memo[N][4] , n;

int solve(int indx , int lst){
    if(indx == n)
        return 0;

    int &ret = memo[indx][lst];
    if(~ret)
        return ret;

    ret = 0;
    for(int i = 0 ; i < 3 ; ++i){
        if(lst == i)continue;
        ret = max(ret , solve(indx + 1 , i) + a[indx][i]);
    }
    return ret;
}

int main() {
    ios::sync_with_stdio() , cin.tie(0) , cout.tie();
    cin >> n;
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < 3 ; ++j)
            cin >> a[i][j];
    }

    memset(memo , -1 , sizeof memo);

    cout << solve(0 , 3) << '\n';
}


Measured memory_bytes: 10752
# -*- coding: utf-8 -*-
INF = 2**62-1

def read_int_n():
    return list(map(int, input().split()))

def slv(N, M):
    if N % 2 != 0:
        ans = [(i+1, N-i) for i in range(M)]
    else:
        ans = [(i+1 +(1 if i+1 > N//4 else 0), N-i) for i in range(M)]

    for a in ans:
        print(*a)


def main():
    N, M = read_int_n()
    (slv(N, M))



if __name__ == '__main__':
    main()


Measured memory_bytes: 73508
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18
#define mod (inf+7)

ll k,a[111111];
ll mx,mn;
void dfs1(int pos,ll ans){
		if(pos==k-1){
				mn=ans;
				return ;
		}
		ans=ans-ans%a[pos+1]+(ans%a[pos+1]==0?0: a[pos+1]);
		dfs1(pos+1,ans);
}
void dfs2(int pos,ll ans){
		if(pos==k-1){
				mx=ans+a[pos]-1;
				return ;
		}
		ans+=a[pos]-1;
		ans-=ans%a[pos+1];
		dfs2(pos+1,ans);
}
bool check(){
		ll sav=mn;
		for(int i=k-1;i>=0;i--){
				sav-=sav%a[i];
		}
		if(sav!=2)return 0;
		sav=mx;
		for(int i=k-1;i>=0;i--){
				sav-=sav%a[i];
		}
		return sav==2;

}

int main() {
		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		//freopen("out.out","w",stdout);
		cin>>k;
		FOR(i,0,k)cin>>a[i];
		reverse(a,a+k);
		dfs1(0,2);
		dfs2(0,2);
		if(check())cout<<mn<<" "<<mx<<endl;
		else cout<<-1<<endl;

		return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

void dfs(int p, vector<char> &op, vector<int> &num) {
    if (p == 3) {
        int sum = num[0];
        for (int i = 0; i < 3; ++i) {
            if (op[i] == '+')sum += num[i + 1];
            if (op[i] == '-')sum -= num[i + 1];
        }
        if (sum == 7) {
            cout << num[0];
            for (int i = 0; i < 3; i++)cout << op[i] << num[i + 1];
            cout << "=7" << endl;
            exit(0);
        }
        return;
    }

    //'+'の場合
    op[p] = '+';
    dfs(p + 1, op, num);

    //'-'の場合
    op[p] = '-';
    dfs(p + 1, op, num);

    op[p] = '?';
    return;
}

int main() {
    string t;
    cin >> t;
    vector<int> num(4);
    for (int i = 0; i < 4; i++)num[i] = t[i] - '0';
    vector<char> op(3, '?');

    dfs(0, op, num);

    return 0;
}

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



Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int A[200050], L[200050];

int main() {
  const int N = in();
  const Int K = lin();
  for (int i = 0; i < N; ++i) {
    A[i] = in();
  }

  vector<int> NX(200050, -1);
  NX[A[N - 1]] = N - 1;
  L[N] = 0;
  L[N - 1] = A[N - 1];
  for (int i = N - 2; i >= 0; --i) {
    if (NX[A[i]] < 0) {
      L[i] = A[i];
    } else {
      L[i] = L[NX[A[i]] + 1];
    }
    NX[A[i]] = i;
  }

  vector<int> H;
  H.push_back(0);
  while (true) {
    const int h = H.back();
    const int hh = (h == 0 ? L[0] : L[NX[h] + 1]);
    if (hh == 0) {
      break;
    }
    H.push_back(hh);
  }

  vector<int> ans;
  vector<int> have(200050, 0);
  const int f = H[(K - 1) % H.size()];
  if (f != 0) {
    ans.push_back(H[(K - 1) % H.size()]);
    ++have[ans[0]];
  }
  for (int i = 0; i < N; ++i) {
    const int a = A[i];
    if (have[a] == 0) {
      ans.push_back(a);
      ++have[a];
    } else {
      while (have[a] > 0) {
        --have[ans.back()];
        ans.pop_back();
      }
    }
  }

  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d%c", ans[i], i+1==ans.size() ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 6260
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


int N, K;
int P[5001];
int C[5001];

bool flg[5001];
vector<int> v;

int syaku(int n)
{
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += v[i];
	}
	int ma = sum;

	for (int i = 0; i < v.size(); i++)
	{
		int prev = i;
		int next = (i + n) % v.size();
		sum -= v[prev];
		sum += v[next];
		ma = max(ma, sum);
	}

	return ma;
}

signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> P[i + 1];
	REP(i, N) cin >> C[i + 1];

	int ans = LLONG_MIN;

	for (int i = 1; i <= N; i++)
	{
		if (flg[i]) continue;

		v.clear();
		int cur = i;
		int n = 0;
		int sum = 0;
		while (true)
		{
			if (flg[cur]) break;
			flg[cur] = true;
			v.push_back(C[cur]);
			sum += C[cur];
			cur = P[cur];
			n++;
		}

		int score = 0;
		int k = K;
		int ma;
		if (n < k)
		{
			int d = (k - 1) / n;
			if (sum > 0)
			{
				k = K - (n * d);
				score += d * sum;
			}
			else
			{
				k = n;
			}

			ma = LLONG_MIN;
			for (int j = 0; j <= k; j++)
			{
				int m = syaku(j);
				ma = max(ma, m);
			}
		}
		else
		{
			ma = LLONG_MIN;
			for (int j = 1; j <= k; j++)
			{
				int m = syaku(j);
				ma = max(ma, m);
			}
		}

		ans = max(ans, score + ma);
	}

	cout << ans << endl;
}



Measured memory_bytes: 3372
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

win_hand = {"r":"p", "s":"r", "p":"s"}
lose_hand = {"r":"s", "s":"p", "p":"r"}
score_hand = {"r":R, "s":S, "p":P}

score = 0

for k in range(K):
  n = k
  preb_hand = ""
  while n < N:
    if win_hand[T[n]] != preb_hand:
      score = score + score_hand[win_hand[T[n]]]
      preb_hand = win_hand[T[n]]
    else:
      if (n + K) < N:
        preb_hand = lose_hand[T[n + K]]
      else:
        preb_hand = ""
    n = n + K

print(score)

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

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n;
    cin >> n;

    ll two = 0, five = 0;

    ll a = 2;
    while(a <= n){
        if(n%2 == 0){
            two += n / a;
        }
        a *= 2;
    }

    a = 5;
    while(a <= n){
        if(n%2 == 0){
            five += n / a / 2;
        }else{
            five += Div(n/a, 2LL);
        }
        a *= 5;
    }

    cout << min(two, five) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import Data.List

judgeFunc :: Float -> Float -> (Int, Float) -> (Int, Float) -> (Int, Float)
judgeFunc t a acc x =
  let
    cur = abs $ a - (t - (snd x * 0.006))
  in
    if cur < snd acc
    then (fst x, cur)
    else acc

func :: Float -> Float -> [(Int,Float)] -> Int
func t a xs = fst $ foldl' (judgeFunc t a) (0, 10000) xs

main = do
  _ <- getLine
  line1 <- getLine
  line2 <- getLine
  let
    req = map read $ words line1 :: [Float]
    xs = map read $ words line2 :: [Float]
    t = req !! 0
    a = req !! 1
    ans = func t a $ zip [1..] xs
  putStrLn $ show ans


Measured memory_bytes: 1276
#include <stdio.h>

int main()
{
    int A, B, teste;
    
    scanf ("%d%d", &A, &B);
    
    teste = A * B;
    
    if ((teste * 1) % 2 == 0 && (teste * 2) % 2 == 0 && (teste * 3) % 2 == 0)
        printf ("No");
    else 
        printf ("Yes");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;

int main(void) {
    int s, w;
    cin >> s >> w;

    if (w>=s) puts("unsafe");
    else puts("safe");
    


	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
using namespace std;

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
 
    string str;
    getline(cin, str);
  
  	if( str == "ABC"){
    	cout << "ARC" << endl;
	}else{
    	cout << "ABC" << endl; 
    }
    return 0;
}


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;



int main()
{    
    int N;
	//scanf("%d",&N);
    cin >> N;
    int M=N;
    int f=0;
    for(int i=0;i<8;i++){
      f+=N%10;
      N/=10;
    }  
    if(M%f==0)cout<<"Yes"<<endl;
    else cout << "No" << endl; 
    
  
}  

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

ll par[100010];
ll r[100010];
ll siz[100010];

void init(ll n){
    rep(i,n){
        par[i]=i;
        r[i]=0;
        siz[i]=1;
    }
}

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

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(r[x] <r[y]){
        swap(x,y);
    }
    par[y] =x;
    siz[x] +=siz[y];
    if(r[x] ==r[y]) r[x]++;
}

ll getsize(ll x){
    return siz[find(x)];
}

bool same(ll x,ll y){
    return find(x) ==find(y);
}


int main(){
    ll N,M,A[100010],B[100010];
    ll C[100010];
    cin>>N>>M;
    rep(i,M){
        cin>>A[i]>>B[i];
        A[i]--;
        B[i]--;
    }
    init(N);
    C[M-1]=N*(N-1)/2;
    for(int i=M-1;i>0;i--){
        if(same(A[i],B[i])) C[i-1]=C[i];
        else{
            ll d=getsize(A[i])*getsize(B[i]);
            C[i-1]=C[i]-d;
            unite(A[i],B[i]);
        }
    }
    rep(i,M) cout <<C[i]<<endl;
    return 0;
}

Measured memory_bytes: 6016
#include <iostream>

long long count[101], res;

int main()
{
    long long n, k;
    std::cin >> n >> k;
    for (long long i = 0; i < k; i++)
    {
        long long d;
        std::cin >> d;
        for (long long i = 0; i < d; i++)
        {
            long long a;
            std::cin >> a;
            count[a]++;
        }
    }
    for (long long i = 1; i <= n; i++)
    {
        if (count[i] == 0)
        {
            res++;
        }
    }
    std::cout << res;
}

Measured memory_bytes: 3632
Imports System.Console
Module Module1
    Dim ans As Integer
    Dim money As Int64 = 1000
    Dim kabu As Int64
    Sub Main()
        Dim n As Integer = ReadLine()
        Dim s() As String = ReadLine().Split
        Dim a(n + 1) As Integer
        For i = 1 To n
            a(i) = s(i - 1)
        Next
        a(0) = 0
        'n = n + 1
        'Do While n > 1 AndAlso a(n - 1) >= a(n)
        '    n -= 1
        'Loop
        For i = 1 To n
            If a(i + 1) > a(i) Then
                Buy(a(i))
            Else
                Sell(a(i))
            End If
        Next
        WriteLine(money)
        ReadLine()
    End Sub
    Sub Buy(ne As Integer)
        kabu += money \ ne
        money = money Mod ne
    End Sub
    Sub Sell(ne As Integer)
        If kabu > 0 Then
            money += kabu * ne
            kabu = 0
        End If
    End Sub
End Module


Measured memory_bytes: 28376
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
  int i,j,tmp,n,a[10],top,k;
  for(i=0;i<10;i++)
    scanf("%d",&a[i]);

  for(i=0;i<10;i++){
    top=a[i];
    k=i;
    for(j=i+1;j<10;j++)
      if(a[j]>top){
	top=a[j];
	k=j;
      }
    tmp=a[i];a[i]=top;a[k]=tmp;
  }

  for(i=0;i<3;i++)
    printf("%d\n",a[i]);

  return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  int sum = accumulate(all(a),0ll);
  vi ans(n);
  for(int i = 0; i < n-1; i+= 2){
    sum -= 2*a[i];
  }
  dump(sum);
  ans[n-1] = sum;
  ROF(i,n-1,0){
    ans[i] = 2 * (a[i] - ans[i+1]/2);
  }
  assert(ans[0]+ans[n-1] == a[n-1] * 2);
  dump(ans);
  cout << ans[0];
  FOR(i,1,n) cout<< " " << ans[i];
  cout << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

typedef vvi graph;

void dfs(graph& g, vpii& ans, int& t, int v = 0)
{
    if (ans[v].first != 0) return;
    
    ans[v].first = ++t;
    
    for (int i = 0; i < g[v].size(); i++) {
        dfs(g, ans, t, g[v][i]);
    }
    
    ans[v].second = ++t;
}

int main()
{
    int n; cin >> n;
    graph g(n);
    rep(i, n) {
        int u, k; cin >> u >> k; u--;
        rep(j, k) {
            int v; cin >> v; v--;
            g[u].push_back(v);
        }
    }
    
    vpii ans(n, make_pair(0, 0));
    int t = 0;
    rep(v, n) dfs(g, ans, t, v);

    rep(i, n) {
        cout << i+1 << " " << ans[i].first << " " << ans[i].second << endl;
    }
}



Measured memory_bytes: 3168
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n; cin >> n;
  vector<i64> a(n + 1);
  i64 sum = 0;
  for (auto &x : a) cin >> x, sum += x;
  if (n == 0) {
    kek(a[0] == 1 ? 1 : -1);
  }
  if (a[0] != 0) kek(-1);
  i64 cnt = 1, ans = 1;
  for (int i = 1; i <= n; ++i) {
    cnt *= 2;
    uin(cnt, sum);
    if (cnt < a[i]) kek(-1);
    ans += cnt;
    sum -= a[i];
    cnt -= a[i];
  }
  kek(ans);
}


Measured memory_bytes: 4440
from collections import Counter
from collections import deque
def topological_sort(g, v):
    in_count = Counter(y for x in g.values() for y in x)
    s = deque([i for i in range(v) if in_count[i] == 0])
    while s:
        n = s.popleft()
        yield n
        for m in g[n]:
            in_count[m] -= 1
            if in_count[m] <= 0:
                s.append(m)

from sys import stdin
from collections import defaultdict
readline = stdin.readline

v, e = map(int, readline().split())
g = defaultdict(set)
for _ in range(e):
    s, t = map(int, readline().split())
    g[s] |= {t}
for i in topological_sort(g, v):
    print(i)

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

void solve(long long L){
    double element = (double)L / 3;
    double ans = element * element * element;
    cout << fixed << setprecision(12) << ans << endl;
    return;
}

int main(){
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

int main()
{
	INT a, b;
	cin >> a >> b;
	if (b % a == 0)
	{
		cout << (b + a) << endl;
	}
	else
	{
		cout << (b - a) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
	int n;
	cin >> n;
	cout << (n+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DGridGame {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int H, W, N;
        cin >> H >> W >> N;
        vector<int> X(N), Y(N);
        REP(i, N) {
            cin >> X[i] >> Y[i];
            X[i]--, Y[i]--;
        }

        vector<set<int>> v(W);
        REP(i, N) {
            v[Y[i]].insert(X[i]);
        }

        priority_queue<int, vector<int>, greater<>> pq;
        pq.push(H);
        if (!v[0].empty()) {
            pq.push(*v[0].begin());
        }
        int cur = 0;
        for (int i = 1; i < H; i++) {
            if (cur == W - 1) break;
            if (v[cur + 1].empty()) {
                cur++;
                continue;
            }
            auto itr = v[cur + 1].lower_bound(i);
            if (itr == v[cur + 1].end()) {
                cur++;
            } else if (*itr == i) {
                // nop
            } else {
                pq.push(*itr);
                cur++;
            }
        }
        cout << pq.top() << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DGridGame solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 22528
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N){
    ll L_0 = 2, L_1 = 1;
    rep(i, N) {
        if (i % 2) L_1 += L_0;
        else L_0 += L_1;
    }
    cout << ((N % 2) ? L_1 : L_0) << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    solve(N);
    return 0;
}

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

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

	std::vector<int> p(n);
	for (auto&& e : p)
		std::cin >> e;

	int ans = 0, min = p[0];
	for (auto&& e : p) {
		min = std::min(e, min);

		if (min >= e)
			++ans;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 1024
n=int(input())
lst=list (map (int, input().strip().split()))[:n]
sumi=0;dif=0;mndif=100000
sumn=sum(lst)
for i in range(n-1):
    sumi+=lst[i]
    dif=abs(sumn-2*sumi)
    if i==0:
        mndif=dif
    else:
       if mndif>dif:
          mndif=dif
print(mndif)





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

int main(){
    int N;
    string S;
    int ans = 0;
     cin >> N >> S;
     for(int i = 0;i < N - 2;i ++){
       if(S[i] == 'A' && S[i+ 1] == 'B' && S[i + 2] == 'C'){
         ans++;
       }
     }
     cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
int main(){
	int a[5]={0};
	for(int i=1;i<=6;++i)++a[getint()];
	for(int i=1;i<=4;++i)
	if((a[i]!=1)&&(a[i]!=2)){puts("NO");return 0;}
	puts("YES");
	return 0;
}

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

string a,b;
int al,bl;

int main(){
	cin>>a; al=a.length();
	cin>>b; bl=b.length();
	if(al!=bl) { cout<<"No"<<endl; return 0; }
	for(int i=0;i<al;i++)
		if(a[i]!=b[al-i-1]) { cout<<"NO"<<endl; return 0; }
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
 
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
 
template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
 
const ll INF = 1e9+7;
 
 
vector<pii> edge[100005];
int check(int n, int b = -1){
	//cout << n << " " << b << endl;
	int ret = 0;
	for(auto &&p: edge[n]) if( p.Y != b ){
		int r = check(p.Y, n);
		if( r < 0 ) return -1;
		if( ret == 0 ) ret++;
		ret += ( r > 0 );
		p.X = -r;
	}
	if( ret > 2 ) return -1;
	return ret;
}
 
vector<int> result;
int other_side;
void dfs(int n, int b = -1, bool res = false){
	int num = 0;
	for(auto p: edge[n]) if( p.Y != b ){
		dfs(p.Y, n, num != 0);
		if( num == 0 ) num = result.size() + 1;
	}
	if( num == 0 ) num = result.size() + res + 1;
	if( result.empty() ) other_side = n;
	result.push_back(num);
}
 
pii dr(int n, int b = -1, int d = 0){
	pii ret = {d, n};
	for(auto p: edge[n]) if( p.Y != b ){
		chmax(ret, dr(p.Y, n, d+1));
	}
	return ret;
}
 
int main(){
	ios_base::sync_with_stdio(false);
	int N;
 
	cin >> N;
	rep(i,N-1){
		int v, w;
		cin >> v >> w;
		v--; w--;
		edge[v].emplace_back(0, w);
		edge[w].emplace_back(0, v);
	}
 
	int start = -1;
	//rep(i,N) if( edge[i].size() == 1 ){
	{
		int i = dr(0).Y;
		i = dr(i).Y;
		int ret = check(i);
		i = dr(i).Y;
		ret = check(i);
		if( ret >= 0 ){
			start = i;
			//break;
		}
	}
 
	rep(i,N) sort( all(edge[i]) );
 
	//cout << "start: " << start << endl;
 
	if( start < 0 ){
		cout << -1 << endl;
		return 0;
	}
 
	vector<int> ans = {INF};
	result.clear();
	dfs(start);
	chmin(ans, result);
	//cout << "other_side: " << other_side << endl;
	result.clear();
	other_side = dr(start).Y;
	dfs(other_side);
	chmin(ans, result);
 
	for(auto t: ans) cout << t << " "; cout << endl;
 
	return 0;
}

Measured memory_bytes: 15096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		double a_min = a * 12.5;
		double a_max = a_min + 12.5;
		double b_min = b * 10;
		double b_max = b_min + 10;
		
		int min_Val = 0;
		
		if(b_min <= a_min && a_min < b_max) {
			min_Val = (int)Math.ceil(a_min);
		}else if(a_min <= b_min && b_min < a_max){
			min_Val = (int)Math.ceil(b_min);
		}else {
			System.out.println(-1);
			return;
		}
		
		if((double)min_Val < a_max && (double) min_Val < b_max) {
			System.out.println(min_Val);
		}else {
			System.out.println(-1);
		}
	}
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  string s,t; cin >> s >> t;
  int s_size = (int)s.size(), t_size = (int)t.size();

  for(int i=s_size;i>=0;i--) {
    if(s[i] == t[t_size-1] || s[i] == '?') {
      int l=1;
      string s0 = s;

      while(i-l+1>=0 && l<=t_size) {
        if(s[i-l+1] == '?') { s0[i-l+1] = t[t_size-l]; }
        else {
          if(s[i-l+1] != t[t_size-l]) { break; }
        }
        l++;
      }

      if(l == t_size+1) {
        for(int j=0;j<s_size;j++) {
          if(s0[j] == '?') { s0[j] = 'a'; }
        }
        cout << s0 << endl;
        return 0;        
      }
    }
  }

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


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N,Q,begin,end;
    string str;
    int count=0;

    cin >> N >> Q;
    cin >> str;

    int v[N] = {0};
    for (int i = 0; i < str.size() - 1; i++) {
        if ((str[i] == 'A')&&(str[i + 1] == 'C')) {
            v[i + 1] = v[i] + 1;
        } else {
            v[i + 1] = v[i];
        }
    }
    for (int i = 0; i < Q; i++) {
        cin >> begin >> end;
        cout << v[end - 1] - v[begin - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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 vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

bool isLeft(char c) {
	switch(c) {
	case 'q':
	case 'a':
	case 'z':
	case 'w':
	case 's':
	case 'x':
	case 'e':
	case 'd':
	case 'c':
	case 'r':
	case 'f':
	case 'v':
	case 't':
	case 'g':
	case 'b':
		return true;
	default:
		return false;
	}
}



int main() {
	string str;

	while(cin >> str, str != "#") {
		bool lastLeft;
		int num = 0;

		lastLeft = isLeft(str[0]);

		FOR(i, 1, str.size()) {
			if(lastLeft != isLeft(str[i])) {
				num++;
			}
			lastLeft = isLeft(str[i]);
		}

		cout << num << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

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

    int l[n];
    int sum = 0;
    int max = 1;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        sum += l;

        if (max < l)
        {
            max = l;
        }
    }

    sum -= max;
    
    cout << (max < sum ? "Yes" : "No") << endl;
    
    return 0;
}

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

int K[15] = { 0,1,2,3,4,5,6,7,8,9,5,4,3,2,1 };
int s, t, n, c, ok, q;
vector<int>x[15];
vector<int>p;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 15; j++) {
			x[j].clear();
		}
		p.clear();
		c = -1; ok = 0; q = 1145141919;
		cin >> s >> t;
		for (int j = 0; j < 15; j++) {
			if (K[j] == s) {
				for (int k = j; k < 15 + j; k++) {
					x[j].push_back(K[k % 15]);
					if (K[k % 15] == t) {
						break;
					}
				}
			}
		}
		for (int j = 0; j < 15; j++) {
			if (q > x[j].size() && x[j].size() >= 1) {
				q = x[j].size();
				p = x[j];
			}
		}
		for (int j = 0; j < p.size(); j++) {
			if (j >= 1) {
				cout << ' ';
			}
			cout << p[j];
		}
		cout << endl;
	}
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    ll k = sqrt(n);
    ll m = (n-1)/k + 1;

    vector<ll> hei(m, 0);
    vector<ll> a(n);

    for(i = 0;i < q;++i){
        ll com;
        cin >> com;
        if(com == 0){
            ll x,y;
            cin >> x >> y;
            --x;
            a.at(x) += y;
            hei.at(x/k) += y;
        }else{
            ll x,y;
            cin >> x >> y;
            --x;    --y;
            ll ans = 0;
            if(x/k == y/k){
                for(j = x;j <= y;++j) ans += a.at(j);
            }else{
                while(x%k != 0){
                    ans += a.at(x);
                    ++x;
                }
                while(y%k != 0){
                    ans += a.at(y);
                    --y;
                }
                ans += a.at(y--);
                while(x/k <= y/k){
                    ans += hei.at(x/k);
                    x += k;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
  int a,sum=0,ave,i;
  for(i=0;i<5;i++)
  {
    scanf("%d",&a);
    if(a<40) sum+=40;
    else sum+=a;
  }
  ave=sum/5;
  printf("%d\n",ave);
  return 0;
}



Measured memory_bytes: 2100