akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long

#undef int
int main()
{
#define int long long
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            if (s[i - 1] == s[j - 1])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            ans = max(ans, min(j - i, dp[i][j]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 195840
import sys
import itertools


input = sys.stdin.readline


def cannot_attack(Q):
    for i in range(7):
        sx, sy = Q[i]
        for j in range(i+1, 8):
            tx, ty = Q[j]
            if abs(tx-sx) == abs(ty-sy):
                return False
    return True


def include_fq(sq):
    for e in fq:
        if e not in sq:
            return False
    return True


def main():
    Q = []
    for p in itertools.permutations(range(8)):
        Q = [(i, p[i]) for i in range(8)]
        if cannot_attack(Q) and include_fq(set(Q)):
            break
    for y, x in Q:
        print("."*x+"Q"+"."*(7-x))


if __name__ == "__main__":
    K = int(input())
    fq = [tuple(map(int, input().split())) for _ in range(K)]
    main()


Measured memory_bytes: 5652
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=205;
int n,a[maxn],ans;
inline char nc(){
	static char buf[100000],*p1,*p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
int main(){
	n=read()<<1;
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n);
	for (int i=1;i<n;++++i)
	ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>
#include<stack>
#include <cstdlib>


using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	cout << t << s;

	return 0;
}

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

#define pb  push_back
#define endl  '\n'
#define w(x)  int x; cin>>x; while(x--)
#define vi  vector<int>

// Tushar Goyal : Chalie Shuru karte hai
const int N = 1e5 + 5;
vi gr[N];
int dp[N];


int longest_path(int src)
{
	if (dp[src] != -1)return dp[src];

	bool isleaf = true;  // node with outdegree 0 ,we are naming it as leaf
	int lp = 0;
	for (int adj : gr[src])
	{
		isleaf = 0;
		lp = max(lp, 1 + longest_path(adj));
	}

	dp[src] = lp;
	return lp;
}

void solve()
{
	int n, m, k;
	cin >> n >> m;

	int x, y;
	for (int i = 1; i <= m ; i++)
	{
		cin >> x >> y;
		gr[x].pb(y);
	}

	memset(dp, -1, sizeof dp);

	int ans = 0;
	for (int i = 1 ; i <= n ; i++)
	{
		ans = max(ans, longest_path(i));
	}

	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 11432
#include<iostream>
#include<vector>
#define rep(i,j) for(int i=0;i<(int)(j);i++)
using namespace std;


//?????¨?????????abc010d

//???????±?????????¨??°??????????´??£????????????§??¨???

const int INF=1<<30;

vector< vector<int> > G; //??£??\??????

void add_arc(int n1,int n2,int capacity)
{
  //MEMO:????????§?????±???
  G[n1][n2]+=capacity;
}


//now ?????? end ???????¢??????§???????????????
int dfs(int now,int end,int min_capacity,vector<int> &is_visited){
  if(now==end)return min_capacity;
  if(!is_visited[now])
  {
    is_visited[now]=true;
    rep(i,G.size()){
      if(G[now][i]>0){//now??????i????????§??????????????????????????°????????§??????
        int ret=dfs(i,end,min(min_capacity,G[now][i]),is_visited);
        if(ret>0){//??´???????????????????????????????????§?¢???????????????????????????????????????´??°
          G[now][i]-=ret;
          G[i][now]+=ret;
          return ret;
        }
      }
    }
    return -2;//??´????????????????????????????????£???
  }
  else return -1;//?????§????¨???????????????£???
}

int get_maxFlow(int start,int end)
{
  int ans=0;
  //??´???????????????????????????????????§????????????????????????????????????????´¢
  vector<int> is_visited(G.size());
  while(true){
    rep(i,G.size())is_visited[i]=false;
    int inc_f=dfs(start,end,INF,is_visited);
    if(inc_f>0)ans+=inc_f;
    else return ans;
  }
}


int main(){

  int V,E;
  cin>>V>>E;

  G.resize(V,vector<int>(V,0));
  rep(i,E){
    int u,v,c;
    cin>>u>>v>>c;
    add_arc(u, v, c);
  }

  cout<<get_maxFlow(0, V-1)<<endl;
  
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
q main(){
    q i,b,c; cin>>i>>b>>c;
    q ans=0;
    if(i==b&&i==c)ans=1;
    if(i!=b)ans++;
    if(i!=c)ans++;
    if(b!=c)ans++;
    cout<<ans;






return 0;}


Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,k = map(int,input().split())
	h = []
	for i in range(n):
		h.append(int(input()))
	h.sort()
	ans = []
	for i in range(n-k+1):
		ans.append(h[i+k-1] - h[i])
	print(min(ans))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


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

int main(void) {
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    x -= z;
    for (int i = x; i >= (y+z);) {
        i -= (y+z);
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
l = []
for i in range(len(s)):
  if s[i] == "R":
    l.append(i)
if l ==[]:
  print(0)
elif l[0] < len(l):
  ans = 0
  for i in l:
    if i >len(l)-1:
      ans += 1
  print(ans)
else:
  print(len(l))

Measured memory_bytes: 17300
#!/usr/bin/env python3
# -*- coding: utf-8 -*-



def digits(n):
    while n > 0:
        yield n % 10
        n //= 10

def main():
    N, A, B = map(int, input().split())

    ans = sum(i for i in range(1,N+1) if A <= sum(digits(i)) <= B)
    print(ans)

if __name__ == "__main__": main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	long double n,d;
	cin >> n >> d;
	vector<pair<long double,long double>> v(n);
	FOR(i,0,n){
		long double a,b;
		cin >> a >> b;
		v[i]={a,b};
	}
	int ans=0;
	for(auto x:v){
		if(sqrt(pow(x.f,2)+pow(x.s,2)) <= d){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) cin >> l[i] >> r[i];

    int maxv = *max_element(ALL(l)), minv = *min_element(ALL(r));
    int cnt = 0;

    for (int i = 1; i <= 500000; i++)
        if (maxv <= i && i <= minv)
            cnt++;

    OP(cnt);

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] x = new int[3];
		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextInt();
		}
		int K = sc.nextInt();

		Arrays.sort(x);
		for (int i = 0; i < K; i++) {
			x[2] *= 2;
		}

		int sum = 0;
		for (int a : x) {
			sum += a;
		}

		System.out.println(sum);

	}
}

Measured memory_bytes: 19796
#include <iostream>
using namespace std;
int main(){
    int n, d, range, insp;
    cin >> n >> d;
    range = 2*d +1;
    if(n<=range){
        insp = 1;
    }
    else{
        if(n%range==0){
            insp = n/range;
        }
        else{
            insp = n/range+1;
        }
    }
    cout << insp << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize,s:String,};

    let r = s.match_indices('R').count();
    let g = s.match_indices('G').count();
    let b = s.match_indices('B').count();

    let s = s.as_bytes();
    let mut count = 0;
    for i in 0..n {
        for j in i + 1..n {
            let k = j * 2 - i;
            if k >= n {
                continue;
            }

            if s[i] != s[j] && s[j] != s[k] && s[k] != s[i] {
                count += 1;
            }
        }
    }

    println!("{}", r * g * b - count);
}


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

int main(){
	int L;
	while(cin >> L && L){
		int ok = 0 , oktime = 1e9;
		for(int i = 1 ; i <= 12 ; i++){
			int M,N;
			cin >> M >> N;
			ok += M - N;
			if( ok >= L ) oktime = min(oktime,i);
		}
		if( oktime > 1000 ) cout << "NA" << endl;
		else cout << oktime << endl;
	}
}

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

int main()
{
    int N, sum=1;

    cin >> N;
    vector<char> S(N);

    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }

    for (int i = 0; i < N-1 ; i++)
    {
        if(S.at(i)==S.at(i+1)){
            sum += 0;
        }
        else{
            sum += 1;
        }
    }
    cout << sum << endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
struct str{
	int x,y;
}st[N];
int arr[N]; 
int sum[N];
map<pair<int,int>,int>vis1,vis2;
int f[N];
int getf(int v){
	if(v==f[v]) return f[v];
	else{
		f[v]=getf(f[v]);
		return f[v];
	}
}
void merge(int u,int v){
	int t1=getf(u);
	int t2=getf(v);
	if(t1!=t2){
		f[max(t1,t2)]=min(t1,t2);
		sum[min(t1,t2)]+=sum[max(t1,t2)];
	}
}
map<int,int> ans;
vector<int> v[N];
map<int,int> mp;
signed main(){
	int n,m,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=0;i<=n;i++) f[i]=i,sum[i]=1;
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%lld%lld",&x,&y);
		st[i].x=x;st[i].y=y;
		merge(x,y);
		vis1[make_pair(min(x,y),max(x,y))]=1;
	}
	for(int i=0;i<m;i++){
		mp[st[i].x]++;
		mp[st[i].y]++;	
	}
	for(int i=0;i<k;i++){
		int x,y;
		scanf("%lld%lld",&x,&y);
		if(getf(x)==getf(y)){
			mp[x]++;
			mp[y]++;
		}
		vis2[make_pair(min(x,y),max(x,y))]=1;
	}

	for(int i=1;i<=n;i++) printf("%lld ",sum[getf(i)]-mp[i]-1);
	return 0;
}

Measured memory_bytes: 44160
#include<stdio.h>
int main(void)
{
    int i,number=0;
    char x[1001]={};
    int sum;
    while(1){
        sum=0;
        scanf("%s", x);
        if(x[0]=='0') break;
        for(i=0; ;i++)
        {
            if(x[i]=='\0') break;
            number = x[i] - '0';
            sum+=number;
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2104
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverce(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

itn main() {
	ios::sync_with_stdio(false);

	int n, m;

	cin >> n >> m;

	vector<int> s(m), c(m);

	REP(i, m) {
		cin >> s[i] >> c[i];
	}

	vector<int> mem(3, -1);

	REP(i, m) {
		if (mem[s[i] - 1] == -1) {
			if (n >= 2 && s[i] == 1 && !c[i]) {
				cout << -1;
				return 0;
			}
			else {
				mem[s[i] - 1] = c[i];
			}
		}
		else if (mem[s[i] - 1] != c[i]) {
			cout << -1;
			return 0;
		}
	}

	REP(i, n) {
		if (mem[i] == -1) {
			if (n >= 2 && !i) {
				cout << 1;
			}
			else {
				cout << 0;
			}
		}
		else {
			cout << mem[i];
		}
	}

	return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = IR(5)
    k = II()
    if max(a) - min(a) > k:
        print(":(")
    else:
        print("Yay!")
    return

#B
def B():
    a = IR(5)
    b = a[0]
    ans = 0
    for a_ in a:
        if a_ % 10 != 0:
            if b % 10> a_ % 10:
                b = a_
    flg = 0
    for a_ in a:
        if a_ != b or flg:
            ans += math.ceil(a_ / 10) * 10
        else:
            ans += b
            flg = 1
    print(ans)
            
    
    return

#C
def C():
    n = II()
    ai = IR(5)
    print(math.ceil(n / min(ai)) + 4)
        
        
    return

#D
def D():
    x, y, z, k = LI()
    a = LI()
    a.sort(reverse = True)
    b = LI()
    b.sort(reverse = True)
    c = LI()
    c.sort(reverse=True)
    ans = [0, 0, 0]
    print(a[ans[0]]+b[ans[1]]+c[ans[2]])
    for _ in range(k-1):
        ansa = a[ans[0] - 1] + b[ans[1]] + c[ans[2]]
        ansb = a[ans[0]] + b[ans[1] - 1] + c[ans[2]]
        ansc = a[ans[0]] + b[ans[1]] + c[ans[2] - 1]
        if ansa > ansb:
            if ansa > ansc:
                ans = [ans[0] - 1, ans[1], ans[2]]
            else:
                ans = [ans[0], ans[1], ans[2] - 1]
        else:
            if ansb > ansc:
                ans = [ans[0], ans[1] - 1, ans[2]]
            else:
                ans = [ans[0], ans[1], ans[2] - 1]

        print(a[ans[0]]+b[ans[1]]+c[ans[2]])
                    

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Measured memory_bytes: 4592
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto a = readln[0];
    switch (a) {
        case 'A': .. case 'Z':
            writeln("A");
            return;
        default:
            writeln("a");
            return;
    }
}

Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 
int main(){
  fio; cout<<fixed<<setprecision(25);	
  ll n , d; cin >> n >> d;
  ll ans = 0;
  ll x, y;
  for(int i = 1;i <= n ; ++i){
    cin >> x >> y;
    if(x*x + y*y <= d*d)
      ++ans;
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<vl> g(n);
  vl cnt(n, 0);
  rep(i, n + m - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    cnt[b]++;
    g[a].push_back(b);
  }
  queue<ll> q;
  vl d(n, 0), p(n, -1);
  rep(i, n) if(cnt[i] == 0) q.push(i);
  while(!q.empty()) {
    ll i = q.front();
    q.pop();
    for(auto v : g[i]) {
      cnt[v]--;
      if(d[v] < d[i] + 1) {
        d[v] = d[i] + 1;
        p[v] = i;
      }
      if(cnt[v] == 0) q.push(v);
    }
  }
  rep(i, n) cout << p[i] + 1 << '\n';
}

Measured memory_bytes: 11116
//Created Time:2019/12/9 8:57:49
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll __int128 
#define mod 1000000007

using namespace std;

ll f[100];

void init();
void work(ll, ll);
int calc(ll, ll, ll, ll);
ll read();

int main(){
	init(); int t; cin >> t;
	while(t--){
		ll x = read(), y = read();
		if(x > y) swap(x, y); work(x, y);
	}
	return 0;
}

void init(){
	f[1] = 1;
	for(int i = 2; i <= 88; ++i)
		f[i] = f[i - 1] + f[i - 2];
	return ;
}

int calc(ll x, ll y, ll a, ll b){
	int ans = ((y - b) / a + 1) % mod;
	if(b <= x) (ans += ((y - a) / b + 1) % mod) %= mod;
	return ans;
}

void work(ll x, ll y){
	if(x == 1){
		printf("%d %d\n", 1, y % mod);
		return ;
	}
	if(x == 2 && y == 2){
		puts("1 4");
		return ;
	}
	int pos = upper_bound(f + 1, f + 89, x) - f - 1;
	if(f[pos + 1] > y) --pos; printf("%d ", pos - 1);
	ll a = f[pos], b = f[pos + 1];
	int ans = calc(x, y, a, b);
	for(int i = 2; i < pos; ++i){
		for(int j = 1; j; ++j){
		ll na = a + f[pos - i] * f[i] * j, nb = b + f[pos - i + 1] * f[i] * j;
		if(na < a || nb < b || na > x || nb > y) break; 
		(ans += calc(x, y, na, nb)) %= mod;
		}
	}
	printf("%d\n", ans);
	return ;
}

ll read(){
	ll x = 0; char ch = getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	return x;
}


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

int main(){
  string S; cin >> S;
  
  if(S == "Sunny")
    cout << "Cloudy" << endl;
  else if(S == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int a[100005];

int main()
{
    int n , x, y;
    cin >> n;
    bool flag = false;
    x = y = 0;
    for(int i = 0; i < n; i++) cin>>a[i];
    for(int i = 0; i < n; i++)
    {
        if(a[i] % 4 == 0)
            x++;
        else if(a[i] % 2 == 0)
            y++;
        if(x * 2 + y >= n || x >= n / 2)
            flag = true;
    }
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 640
fun main(args : Array<String>){
    val dp = IntArray(111111,{1000000000})
    dp[0] = 0

    for(i in 0 until 111110){
        dp[i+1] = Math.min(dp[i+1],dp[i]+1)
        var tmp = 6
        for(j in 0 until 1000) {
            if (i + tmp > 100000) break
            dp[i + tmp] = Math.min(dp[i + tmp], dp[i] + 1)
            tmp *= 6
        }
        tmp = 9
        for(j in 0 until 1000) {
            if (i + tmp > 100000) break
            dp[i + tmp] = Math.min(dp[i + tmp], dp[i] + 1)
            tmp *= 9
        }
    }

    val n = readLine()!!.toInt()
    println(dp[n])
}

Measured memory_bytes: 40788
#include<cstdio>
#include<cstring>
char a[105];
char b[105];
char yes[] = "Yes";
char no[] = "No";
int main(){
        scanf("%s%s",a, b);
        int len = strlen (a);
        bool flag= true;
        for(int I = 0 ;I < len; I ++){
                flag = true;
                for(int i = 0;i<len;i++){
                        if( a[i] != b[(i+I)%len]){
                                flag = false;
                                break;
                        }
                }
                if(flag){
                        printf("%s", yes);
                        return 0;
                }
        }
        printf("%s", no);
        return 0;
}
 

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int s;
    set<int> st;

    cin >> s;
    st.insert(s);
    for(int i=2; true; i++){
        s = s % 2 == 0 ? s / 2 : s * 3 + 1;
        if(st.find(s) != st.end())
        {
            cout << i << endl;
            break;            
        }
        st.insert(s);
    }

    return 0;
}



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

int main() {
    ll n;
    ll input;
    ll a[200001] = {};

    cin >> n;
    for (ll i = 2;i <= n;i++) {
        cin >> input;
        a[input]++;
    }

    for (ll i = 1;i <= n;i++) {
        cout << a[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 5196
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long


 
int main(){
    
    int n,a[50][200]={},ans[200];
    string s;
    
    rep(i,0,200)ans[i]=INF;
    cin>>n;
    rep(i,0,n){
        cin>>s;
        rep(j,0,s.size()){
            a[i][s[j]]++;
        }
    }
    for(char c='a';c<='z';c++){
        rep(i,0,n){
            ans[c]=min(a[i][c],ans[c]);
        }
    }
    for(char c='a';c<='z';c++){
        rep(i,0,ans[c])cout<<c;
    }
    cout<<endl;
    
    return 0;
}

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

int main(){
  int k,n,sum=0; cin >>k >>n;
  vector<int>a(n);
    for(int i=0; i<n; i++)
    {int p; cin >>p; a[i]=p;}
  vector<int>b(n-1);
    for(int i=0; i<n-1; i++)
    {b[i]=a[i+1]-a[i];} 

  sort(b.begin(), b.end());
  if(k+a[0]-a[n-1]>b[n-2]){cout <<a[n-1]-a[0];}
  else{cout <<k-b[n-2];}

return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int D;
	int asumisu;
	if (scanf("%d", &D) != 1) return 1;
	printf("Christmas");
	for (asumisu = 25; asumisu > D; asumisu--) printf(" Eve");
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
// #define int long long

int main(){
    long long N;
    cin >> N;
    char zero = 'a' - 1;
    vector<char> ans;
    while(N > 0){
        int p = N%26;
        if(p == 0) p = 26;
        char c = zero + p;
        ans.push_back(c);
        N = (N - 1)/26;
    }
    reverse(ans.begin(), ans.end());
    for(auto c: ans){
        cout << c ;
    }
    cout  << endl;
}

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

int main() {
	int N, a;
	cin >> N;
	int total = 0;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> a;
		vec.at(i) = a;
	}
	for (int j = 0; j < N; j++) {
		if (vec.at(j) % 2 == 1 && j % 2 == 0) {
			total++;
		}
		else {
			continue;
		}
	}
	cout << total << endl;
}


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

int min(int a, int b) {
    return (a < b) ? a : b;
}

int main(){
    int n, k;
    cin >> n >> k;
    int *h;
    h = new int[n];
    for (int i = 0; i < n;i++){
        cin >> h[i];
    }
    ll *dp;
    dp = new ll[n];
    for (int i = 0; i < n;i++){
        dp[i] = __LONG_LONG_MAX__;
    }

    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; (j <= k) && (j <= i); j++)
        {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
char s[100002];

int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);

    deque<char> dq;
    for(int i=1;i<=n;i++){
        dq.push_back(s[i]);
    }
    int q;
    scanf("%d", &q);
    int st = 0;
    for(int i=0;i<q;i++){
        int t;
        scanf("%d", &t);
        if(t == 1){
            st ^= 1;
        }
        else{
            int f, c;
            char s[2];
            scanf("%d%s", &f, s);
            c = s[0];
            if(f == 1){
                if(st == 0){
                    dq.push_front(c);
                }
                else{
                    dq.push_back(c);
                }
            }
            else{
                if(st == 1){
                    dq.push_front(c);
                }
                else{
                    dq.push_back(c);
                }
            }
        }
    }
    if(st == 0){
        for(auto its=dq.begin();its != dq.end();its++){
            printf("%c", *its);
        }
    }
    else{
        for(auto its=dq.rbegin();its != dq.rend();its++){
            printf("%c", *its);
        }
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

class S{
public:
  double a, b, c;
  S(){}
  S(double a, double b, double c) : a(a), b(b), c(c) {}
};

vector<S> input;
bool data[20];
int n, m;
double ans;

double sq(double a, double b){
  return (a - b) * (a - b);
}

void calc(int p, int cnt){
  if(p == n){
    double sum = 0.0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(data[i] && data[j]){
          sum += sq(input[i].a, input[j].a) + sq(input[i].b, input[j].b) + sq(input[i].c, input[j].c);
        }
      }
    }
    ans = max(ans, sum);
  }else{
    if(cnt < m){
      data[p] = true;
      calc(p+1, cnt+1);
      data[p] = false;
    }
    calc(p+1, cnt);
  }
}

main(){
  cin >> n >> m;
  fill(data, data+20, false);
  for(int i=0;i<n;i++){
    S in;
    cin >> in.a >> in.b >> in.c;
    input.push_back(in);
  }
  ans = 0.0;
  calc(0, 0);
  printf("%.10f\n", ans);
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;


  cout << n+n*n+n*n*n << endl;

}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMonstersBattleRoyale

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		try {
			FastScannerMonstersBattleRoyale sc = new FastScannerMonstersBattleRoyale(System.in);
			int N = sc.nextInt();
			long[] A = new long[N];
			for (int i = 0; i < N; i++) {
				A[i] = sc.nextInt();
			}

			Gcd gcd = new Gcd();
			System.out.println(gcd.getGcds(N, A));

		} catch (

		Exception e) {
			e.printStackTrace();
		}

	}
}

class Gcd {

	/**
	 * ユークリッドの互除法で最大公約数を求める
	 */
	public long getGcd(long a, long b) {
		if (b == 0)
			return a;
		return getGcd(b, a % b);
	}

	/**
	 * 配列全ての最大公約数を求める。
	 */
	public long getGcds(int n, long[] a) {
		long cmd = a[0];
		//最大公約数を前から順次計算していく。
		for (int i = 1; i < n; i++) {
			cmd = this.getGcd(cmd, a[i]);
		}
		return cmd;
	}

}

//高速なScanner
class FastScannerMonstersBattleRoyale {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMonstersBattleRoyale(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 42500
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int f( int i )
{
    string tmp = to_string( i );
    vector<int> v( (int)tmp.size() );
    REP( i, (int)tmp.size() )
    {
        v[ i ] = abs( '0' - tmp[ i ] );
    }
    return accumulate( ALL( v ), 0 );
}
int main()
{
    int N;
    cin >> N;
    int res = INT_MAX;
    for( int i = 1; i < N; i++ )
    {
        res = min( res, f( i ) + f( N - i ) );
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;
typedef pair<double, double>Pdd;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a + b < x) puts("NO");
	else if (a > x) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    S = str(input())
    if S == 'AC':
        ac += 1
    elif S == 'WA':
        wa += 1
    elif S == 'TLE':
        tle += 1
    elif S == 'RE':
        re += 1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;
int x,y;

int main() {
  cin >> x >> y;
  int a = x;
  int b = 0;
  int l = x*2;
  bool ans = false;
  while (b <= x) {
    if (l == y) {
      ans = true;
      break;
    }
    a--;
    b++;
    l -= 2;
    l += 4;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;


V<V<int>> DP(1000, V<int>(1000, -1));

int f(int x, int y) {
	if (x < 2 && y < 2)
		return 0;
	if (DP[x][y] != -1)
		return DP[x][y];
	for (int i = 1; 2*i <= x; ++i) {
		if (!f(x-2*i, y+i))
			return DP[x][y] = 1;
	}
	for (int i = 1; 2*i <= y; ++i) {
		if (!f(x+i, y-2*i))
			return DP[x][y] = 1;
	}

	return DP[x][y] = 0;
}


int f2(int64_t x, int64_t y) {
	if (x < 2 && y < 2)
		return 0;


	if (y >= x-1 && y <= x+1) {
		return 0;
	} else {
		return 1;
	}

}


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

	int64_t X, Y;
	cin >> X >> Y;

	cout << (f2(X, Y) ? "Alice" : "Brown") << endl;


	// for (int x = 0; x < 100; ++x) {
	// 	for (int y = 0; y < 100; ++y) {
	// 		cout << x << " " << y << ": " << f(x, y) << endl;
	// 		assert(f(x,y) == f2(x, y));
	// 	}
	// }
	
}

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

#define MOD 1000000007
// #define INF 1000000000000

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

vector<vector<int>> G;
vector<int> dp;

int rec(int v) {
    if (dp[v] >= 0) return dp[v];
    int ret = 0;
    for (int u : G[v]) {
        ret = max(ret, rec(u) + 1);
    }
    return dp[v] = ret;
}

int main(int argc, char const *argv[]) {
    string S, T;
    cin >> S >> T;
    if (S.length() + 1 != T.length()) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

int main(){

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

    int a = c[1][0]-c[0][0],b = c[1][1]-c[0][1],g = c[1][2]-c[0][2];
    int d = c[2][0]-c[0][0],e = c[2][1]-c[0][1],f = c[2][2]-c[0][2];

    bool flag = false;
    if(a == b && a == g && g == b){
        if(d == e && d == f && e == f){
            flag = true;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=Math.min(a,b)+Math.min(c,d);
		System.out.println(e);
	}
}

Measured memory_bytes: 21844
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vb vector<bool>
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
const ll D=80*80*2;

ll A[88][88],B[88][88];
bool dp[88][88][2*D];

int main(void){
    ll H,W;cin>>H>>W;
    
    WREP(i,H,j,W)cin>>A[i][j];
    WREP(i,H,j,W)cin>>B[i][j];
    
    WREP(i,H,j,W)A[i][j]-=B[i][j];


    
    
    dp[0][0][D+A[0][0]]=true;
    WREP(i,H,j,W){
        REP(k,D*2){
            if(!dp[i][j][k])continue;//つくれない
            if(i+1<H){
                dp[i+1][j][k+A[i+1][j]]=true;
                dp[i+1][j][k-A[i+1][j]]=true;
            }
            if(j+1<W){
                dp[i][j+1][k+A[i][j+1]]=true;
                dp[i][j+1][k-A[i][j+1]]=true;
            }
        }
    }
    ll ans=INF;
    REP(k,D*2){
        if(dp[H-1][W-1][k]){
            //cout<<k-D<<":"<<abs(k-D)<<" ";
            ans=min(ans,abs(k-D));
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 175232
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using LL = long long;

LL n, t;
LL v[1234567];
LL imos[1234567];

int main(void)
{
	cin >> n >> t;
	vector<LL>vec;
	map<LL, LL>inv;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
		vec.push_back(v[i]);
		vec.push_back(v[i] + t);
	}
	vec.push_back(0);
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	for (int i = 0; i < vec.size(); ++i)
	{
		inv[vec[i]] = i;
	}
	for (int i = 0; i < n; ++i)
	{
		imos[inv[v[i]]]++;
		imos[inv[v[i] + t]]--;
	}
	for (int i = 0; i <= 1231234; ++i)
	{
		imos[i + 1] += imos[i];
	}
	LL ans = 0;
	for (int i = 0; i < vec.size() - 1; ++i)
	{
		if (imos[i])
		{
			ans += vec[i + 1] - vec[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 41196
#include<stdio.h>
int main() {
    int n, i ;
    long long ans = 0, c, x[100001], v[100001], p[100001][2], max[100001][2], k, sum[100001][2];
    scanf("%d%ld", &n, &c);
    for (i = 0; i < n; i++) {
        scanf("%ld%ld", &x[i], &v[i]);
    }
    for (i = 0; i < n; i++) {
        if (i == 0)
            sum[0][0] = v[0];
        else
            sum[i][0] = sum[i - 1][0] + v[i];
    }
    for (i = n - 1; i>= 0; i--) {
        if (i == n - 1)
            sum[i][1] = v[i];
        else
            sum[i][1] = sum[i + 1][1] + v[i];
    }
    for (i = 0; i < n; i++) {
        p[i][0]= sum[i][0] - x[i];
        if (i == 0)
            max[i][0] = p[i][0];
        else if (p[i][0] > max[i - 1][0])
            max[i][0] = p[i][0];
        else
            max[i][0] = max[i - 1][0];
        p[i][1]= sum[i][1] - c + x[i];
        if (p[i][0] > ans)
            ans = p[i][0];
        if (p[i][1] > ans)
            ans = p[i][1];
    }
    for (i = n - 1; i >= 0; i--) {
        if (i == n - 1)
            max[i][1] = p[i][1];
        else if (p[i][1] > max[i + 1][1])
            max[i][1] = p[i][1];
        else
            max[i][1] = max[i + 1][1];
    }
    for (i = 0; i < n - 1; i++) {
        k = sum[i][0] - (x[i] * 2) + max[i + 1][1];
        if (k > ans)
            ans = k;
    }
    for (i = n -1; i > 0; i--) {
        k = sum[i][1] - (c-x[i])* 2 + max[i - 1][0];
        if (k > ans)
            ans = k;
    }
  printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6400
n = int(input())
a = [int(x) for x in input().split()]

def gcd(x,y):
  while y != 0:
    x,y = y,x%y
  return x

def lcm(x,y):
  return (x*y) // gcd(x,y)

m = a[0]
for i in range(n):
  m = lcm(m,a[i])
m -= 1

ans = 0
for i in range(n):
  ans += m % a[i]

print(ans)

Measured memory_bytes: 9216
#! /usr/bin/python 
# -*- coding: utf-8 -*- 
#===============================================================================
# Date created  : 2019-03-30T11:32:28+09:00
# Date modified : 2019-03-30T11:56:45+09:00
# Author        : awk
# Description   : unanswered
#===============================================================================


S = input()
S = S[::-1] 
n = len(S)
while len(S) != 0:
    if S[:6] == "resare":
        S = S[6:]
    elif S[:7] == "remaerd":
        S = S[7:]
    elif S[:5] == "esare":
        S = S[5:]
    elif S[:5] == "maerd":
        S = S[5:]
    else:
        print("NO")
        quit()
print("YES")


Measured memory_bytes: 3188