akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
#define ENDL printf("\n");
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}

struct D {
    int north();
    int south();
    int east();
    int west();
    void right();
    void left();
    void print(){
        cout << "t:" << top << " f:" << front << " bo:" << bottom << " ba:" << back << " r:" << rside << " l:" << lside << endl;
    }
    D(){
        this->top = 1;
        this->bottom = 6;
        this->front = 2;
        this->back = 5;
        this->rside = 3;
        this->lside = 4;
    };
        int front;
        int back;
        int rside;
        int lside;
        int top;
        int bottom;
};

int D::north(){
    int tmp = top;
    top = front; front = bottom; bottom = back; back = tmp;
    return top;
    }
int D::south(){
    int tmp = top;
    top = back; back = bottom; bottom = front; front = tmp;  
    return top;
}
int D::east(){
    int tmp = top;
    top = lside; lside = bottom; bottom = rside; rside = tmp;
    return top;
}
int D::west(){
    int tmp = top;
    top = rside; rside = bottom; bottom = lside; lside = tmp ;    
    return top;
}
void D::right(){
    int tmp = this->front;
    this->front = this->rside;
    this->rside = this->back;
    this->back = this->lside;
    this->lside = tmp;
    
}
void D::left(){
    int tmp = this->front;
    this->front = this->lside;
    this->lside = this->back;
    this->back = this->rside;
    this->rside = tmp;
}

signed main(){
    int n;
    while( cin >> n && n){
        vector<string> s(n);
        D d;
        rep(i ,n) cin >> s[i];
        int sum = 1;
        rep(i , n){
            if( s[i] == "North" ) sum += d.north();
            else if (s[i] == "South" ) sum += d.south();
            else if (s[i] == "East") sum += d.east();
            else if (s[i] == "West") sum += d.west();
            else if (s[i] == "Right") { sum += d.top; d.right(); }
            else if (s[i] == "Left") { sum += d.top; d.left(); }
            else fprintf( stderr , "error");
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 2000006;
const int mod2 = 987654319;
const int maxlog = 20;
const ll mod = 1000000007;

int main() {
    IOS
    int a, b; cin >> a >> b;
    if (a <= 9 && b <= 9) cout << a * b;
    else cout << -1;
}


Measured memory_bytes: 256
// =====================================================================================
// 
//       Filename:  A.cpp
//        Created:  2017년 09월 08일 04시 11분 15초
//       Compiler:  g++ -O2 -std=c++14
//         Author:  baactree ,  bsj0206@naver.com
//        Company:  Chonnam National University
// 
// =====================================================================================

#include <bits/stdc++.h>
using namespace std;
pair<double, pair<int, int> > a[4];
long long n;
int main(){
	for(int i=0;i<4;i++){
		scanf("%d", &a[i].second.first);
		a[i].first=a[i].second.first;
	}
	cin>>n;
	n*=4;
	a[1].first/=2;
	a[2].first/=4;
	a[3].first/=8;
	a[0].second.second=1;
	a[1].second.second=2;
	a[2].second.second=4;
	a[3].second.second=8;
	sort(a, a+4);
	long long ans=0;
	for(int i=0;i<4;i++){
		if(n>=a[i].second.second){
			long long k=n/a[i].second.second;
			ans+=k*a[i].second.first;
			n%=a[i].second.second;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] <= 'z' && s[i] >= 'a') {
			s[i] -= 32;
		}
		else if (s[i] <= 'Z' && s[i] >= 'A') {
			s[i] += 32;
		}
	}
	cout << s << endl;
}




Measured memory_bytes: 3120
K = int(input())

memo = [[None] * (K + 1) for _ in range(K + 1)]

def mygcd(a, b):
    if memo[a][b] != None: return memo[a][b]
    else:
        if a < b:
            ret = mygcd(b, a)
        elif b == 0:
            ret = a
        else:
            ret = mygcd(b, a % b)
        #
        memo[a][b] = ret
        memo[b][a] = ret
        return ret

ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        tmp = mygcd(a, b)
        for c in range(1, K + 1):
            ans += mygcd(tmp, c)

print(ans)

# 早くなってて間に合ったりしますように

Measured memory_bytes: 9356
A, B = list(map(int, input().split(' ')))
max_div_val = 0
min_A_B = min(A, B)
for i in range(min_A_B):
    div_val = i + 1
    if A % div_val == 0 and B % div_val == 0:
        max_div_val = div_val
A_divisor = A // max_div_val
B_divisor = B // max_div_val
print(A_divisor * B_divisor * max_div_val)

Measured memory_bytes: 3060
N = int(input())
A = list(str(input()))
B = list(str(input()))
C = list(str(input()))

res = 0
for i in range(N):
    if A[i] != B[i] or  A[i] != C[i] or  B[i] != C[i]:
        res+=1
    if A[i] != B[i] and A[i] != C[i] and B[i] != C[i]:
        res+=1
print(res)


Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card S[], int min, int mid, int max)
{
	int i, j, k;
	int n1 = mid - min;
	int n2 = max - mid;
	
	for(i = 0; i < n1; i++)
	{
		L[i] = S[min + i];
	}
	for(i = 0; i < n2; i++)
	{
		R[i] = S[mid + i];
	}
	
	L[n1].value = SENTINEL;
	R[n2].value = SENTINEL;
	i = 0;
	j = 0;
	
	for(k = min; k < max; k++)
	{
		if(L[i].value <= R[j].value)
		{
			S[k] = L[i];
			i++;
		}
		else
		{
			S[k] = R[j];
			j++;
		}
	}
}

void mergeSort(struct Card S[], int min, int max)
{
	if(min + 1 < max)
	{
		int mid = (min + max) / 2;
		mergeSort(S, min, mid);
		mergeSort(S, mid, max);
		merge(S,min, mid, max);
	}
}

int partition(struct Card S[], int p, int r)
{
	int i, j;
	struct Card temp, x;
	x = S[r];
	i = p - 1;
	for(j = p; j < r; j++)
	{
		if(S[j].value <= x.value)
		{
			i++;
			temp = S[i];
			S[i] = S[j];
			S[j] = temp;
		}
	}
	temp = S[i+1];
	S[i+1] = S[r];
	S[r] = temp;
	return i + 1;
}

void quickSort(struct Card S[], int p, int r)
{
	int q;
	if(p < r)
	{
		q = partition(S, p, r);
		quickSort(S, p, q - 1);
		quickSort(S, q + 1, r);
	}
}

int main(void)
{
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
		
	for(i = 0; i < n; i++)
	{
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, 0, n);
	quickSort(B, 0, n - 1);
	
	for(i = 0; i < n; i++)
	{
		if(A[i].suit != B[i].suit)
		{
			stable = 0;
		}
	}
	
	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");
	for(i = 0; i < n ; i++)
	{
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	return 0;
}


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

long lb(unsigned long a){
    long ret = 0;
    for(long s=32; s>0; s>>=1){
        if(a>>s){
            a >>= s;
            ret += s;
        }
    }
    return ret;
}

int main(void){
    long n;
    cin >> n;
    multiset<long,greater<long>> s;
    for(long i=0; i<n; i++){
        long t;
        cin >> t;
        s.insert(t); 
    }
    long cnt = 0;
    while(!s.empty()){
        const auto ix = s.begin();
        const auto y = (1l << lb(*ix<<1))-*ix;
        s.erase(ix);
        const auto iy = s.find(y);
        if(iy!=s.end()){
            s.erase(iy);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int dp[17][17];
int logdist(string s, string t) {
	int ls = s.length(), lt = t.length();
	rep(i, ls + 1) {
		rep(j, lt + 1) {
			dp[i][j] = mod;
		}
	}
	dp[0][0] = 0;
	rep(i, ls+1) {
		rep(j, lt + 1) {
			if (i < ls) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
			}
			if (j < lt) {
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
			}
			if (i < ls&&j < lt) {
				if (s[i] == t[j]) {
					dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
				}
				else {
					dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]+1);
				}
			}
		}
	}
	return dp[ls][lt];
}
int dist(string s, string t) {
	if (s.length() < t.length()) {
		swap(s, t);
	}
	int ret = logdist(s, t);
	int len = s.length();
	if (len - t.length() >= 2)return ret;
	if (s.length() == t.length()) {
		rep(i, len - 1) {
			rep(j, len - 1) {
				string u = s;
				swap(u[i], u[i + 1]);
				swap(u[j], u[j + 1]);
				if (u == t)ret = min(ret, 2);
			}
		}
		rep(i, len - 1) {
			string u = s;
			swap(u[i], u[i + 1]);
			int cnt = 0;
			rep(j, len) {
				if (u[j] != t[j])cnt++;
			}
			if (cnt == 0)ret = min(ret, 1);
			else if (cnt == 1)ret = min(ret, 2);
		}
		rep(i, len - 1) {
			string u = t;
			swap(u[i], u[i + 1]);
			int cnt = 0;
			rep(j, len) {
				if (u[j] != s[j])cnt++;
			}
			if (cnt == 0)ret = min(ret, 1);
			else if (cnt == 1)ret = min(ret, 2);
		}
	}
	else {
		rep(i, len) {
			string u = s;
			u.erase(u.begin() + i);
			rep(j, len - 2) {
				string z = u;
				swap(z[j], z[j + 1]);
				if (z == t)ret = min(ret, 2);
			}
		}
	}
	return ret;
}
void solve() {
	int n, d;
	while (cin >> n, n) {
		int d; cin >> d;
		vector<string> v(n);
		vector<pair<string, string>> ans;
		rep(i, n) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		rep(i, v.size()) {
			Rep(j, i + 1, v.size()) {
				if (dist(v[i], v[j]) <= d) {
					ans.push_back({ v[i],v[j] });
				}
			}
		}
		sort(ans.begin(), ans.end());
		rep(i, ans.size()) {
			cout << ans[i].first << "," << ans[i].second << endl;
		}
		cout << ans.size() << endl;
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}



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


int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  string ans = "NO";
  int a = sa.size()-1, b = sb.size()-1;
  if(sa[a] == sb[0] && sb[b] == sc[0]) ans = "YES";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N;
char S[30005];
signed main(){
    scanf("%lld %s",&N,S);
    int ans=0;
    for(int i=0;i<=999;i++){
        char K[3]={'0'+i/100,'0'+(i/10)%10,'0'+i%10};
        int now=0;
        rep(i,N){
            if(S[i]==K[now])now++;
            if(now==3){ans++;break;}
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
int i,j,n,m,dp,mini;

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

int main()
{
    int N;
    cin >> N;
    int A[N][3];
    int i=0;
    int j=0;
    int k=0;
    for(i=0;i<N;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>A[i][j];
        }

    }
    int happy [N][3];
    happy[0][0]=A[0][0];
    happy[0][1]=A[0][1];
    happy[0][2]=A[0][2];

    for(k=1;k<N;k++)
    {
        happy[k][0]=max(happy[k-1][1]+A[k][0],happy[k-1][2]+A[k][0]);
        happy[k][1]=max(happy[k-1][0]+A[k][1],happy[k-1][2]+A[k][1]);
        happy[k][2]=max(happy[k-1][1]+A[k][2],happy[k-1][0]+A[k][2]);
    }

    cout << max(happy[N-1][0],max(happy[N-1][1],happy[N-1][2]));
    return 0;

   
}

Measured memory_bytes: 6008
#include <iostream>

using namespace std;

const int MIN=-100000;
int main(){
    int n;

    cin>>n;
    while (n){
        int sum=0,max=MIN,t;
        for (int i=0;i<n;++i){
            cin>>t;
            sum+=t;
            if (sum>max) max=sum;
            if (sum<0) sum=0;
        }
        cout<<max<<endl;
        cin>>n;
    }
    return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n - 1].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var map = rs.Concat(rs.Select(r => new[] { r[1], r[0] })).GroupBy(r => r[0], r => r[1]).ToDictionary(g => g.Key, g => g.ToArray());

		var tour = new int[n + 1].Select(_ => new List<int>()).ToArray();
		var c = 0;
		var q = new Stack<int>();
		var parents = new Stack<int>();
		var u = new bool[n + 1];

		q.Push(1);
		parents.Push(0);
		while (q.Any())
		{
			var p = q.Peek();
			if (!u[p])
			{
				u[p] = true;
				var p0 = parents.Peek();
				if (p != 1) tour[p0].Add(++c);
				foreach (var x in map[p])
				{
					if (x == p0) continue;
					q.Push(x);
				}
				parents.Push(p);
			}
			else
			{
				if (p != 1) tour[p].Add(++c);
				q.Pop();
				parents.Pop();
			}
		}

		Console.WriteLine((tour.Select(l => Hole(l, n - 1)).Aggregate((x, y) => x + y) / 2).V);
	}

	static MInt Hole(List<int> l, int m)
	{
		if (l.Count < 2) return 0;

		MInt allWhite = 1, bSum = 0;
		for (int i = 0; i < l.Count; i++)
		{
			var c = ((l[(i + 1) % l.Count] - l[i]) / 2 + m) % m;
			var w = 1 / ((MInt)2).Pow(c);

			allWhite *= w;
			bSum += 1 / w - 1;
		}
		return 1 - allWhite * (1 + bSum);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x) => x;
	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 86496
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;

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

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=int_fast64_t;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double EPS=1e-9;
const int MOD=1e9+7;
struct UnionFind{
    vector<int> par,dep;
    UnionFind(int n){
        dep.assign(n,0);
        par.assign(n,0);
        for(int i=0;i<n;i++)par[i]=i;
    }
    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }
    bool unite(int u,int v){
        u=find(u);
        v=find(v);
        if(u==v)return false;
        if(dep[u]>dep[v]){
            par[v]=u;
        }else if(dep[u]<=dep[v]){
            par[u]=v;
            if(dep[u]==dep[v]){
                dep[v]++;
            }
        }
        return true;
    }
};
vector<int> col;
vector<vector<int>> G;
bool dfs(int i,int c,int p){
    if(col[i]!=-1){
        if(c==col[i]){
            return true;
        }else{
            return false;
        }
    }
    bool res=true;
    col[i]=c;
    for(auto e:G[i]){
        if(e==p)continue;
        res&=dfs(e,c^1,i);
    }
    return res;
}
int main(){
    ll n,m;cin>>n>>m;
    UnionFind uf(n);
    G.resize(n);
    for(int i=0;i<m;i++){
        int u,v;cin>>u>>v;--u;--v;
        G[u].push_back(v);
        G[v].push_back(u);
        uf.unite(u,v);
    }
    vector<ll> s(n,0);
    for(int i=0;i<n;i++){
        s[uf.find(i)]++;
    }
    ll ans=n*n;
    ll c1=0LL,c2=0LL,s1=0LL,s2=0LL;
    col.resize(n,-1);
    for(int i=0;i<n;i++){
        if(s[i]>=2LL){
            if(!dfs(i,0,-1)){
                ans-=s[i]*s[i]-1LL;
                ans-=((s1+s2)*s[i]-(c1+c2))*2LL;
                s1+=s[i];
                c1+=1LL;
            }else{
                ans-=s[i]*s[i]-2LL;
                ans-=((s1*s[i]-c1)+(s2*s[i]-c2*2LL))*2LL;
                s2+=s[i];
                c2+=1LL;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(void) {
  
  int N;
  cin >> N;
  //int A[N];
  int ans[N];
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    ans[tmp-1] = i+1;
  }

  for (int i = 0; i < N; i++) {
    cout << ans[i];
    if (i != N-1)
      cout << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <climits>
#include <stack>
#include <vector>

using namespace std;
static const int MAX=100000;
static const int NIL=-1;
int n;
vector <int> G[MAX];
int color[MAX];

void dfs(int r,int c)
{
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty())
    {
        int u=S.top();
        S.pop();
        for(int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            if(color[v]==NIL)
            {
                color[v]=c;
                S.push(v);
            }
        }
    }
}

void assign_color()
{
    int id=1;
    for(int i=0;i<n;i++) color[i]=NIL;
    for(int u=0;u<n;u++)
    {
        if(color[u]==NIL) dfs(u,id++);
    }
}

int main()
{
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assign_color();
    cin>>q;

    for(int i=0;i<q;i++)
    {
        cin>>s>>t;
        if(color[s]==color[t])
        {
            cout<<"yes"<<endl;
        }
        else
        {
            cout<<"no"<<endl;
        }
    }
    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;


void solve(string S){
	 vs chk;
   chk.push_back("dreamer");
   chk.push_back("eraser");
   chk.push_back("dream");
   chk.push_back("erase");
   
   while(S.size()){
    //  cout << S << "  S" << endl;
     bool flag = false;
     for(string s:chk){
       if(S.size() < s.size())continue;
       string c = S.substr(S.size()-s.size(),s.size());
      //  cout << c << " " << s << endl;
       if(c == s){
         S = S.substr(0,S.size()-s.size());
         flag = true; break;
       }
     }
     if(!flag){
       break;
     }
   }
   
   cout << (S.size() == 0?"YES":"NO") << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, p;
  cin >> a >> p;
  p += 3*a;
  cout << p/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main(){
    int A,B,C,D,E;
    cin >> A >> B;
    C = A+B;
    D = A-B;
    E = A*B;
    if(C>=D&&C>=E){
        cout << C << endl;
    }else if(D>=C&&D>=E){
        cout << D << endl;
    }else if(E>=C&&E>=D){
        cout << E <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,a,b,c,d;
  scanf("%d%d%d%d%d\n", &n, &a, &b, &c, &d);
  int road[n];
  char ch;
  for(int i = 0; i < n; ++i){
    scanf("%c",&ch);
    if(ch == '#') road[i] = 1;
    else if(ch == '.') road[i] = 0;
  }
  int flag = 0;
  int flag_two = 0, flag_two_bin = 0;//a~dに##が無いことが必要
  int flag_three = 1, flag_three_bin = 0;//d<cならb-1 ~ d+1に...が必要
  for(int i = a-1; i < d-1; ++i){
    if(flag_two_bin == 1 && road[i] == 1){
      flag_two = 1;
      break;
    }else if(road[i] == 0) flag_two_bin = 0;
    else if(road[i] == 1) flag_two_bin = 1;
  }
  if(d < c){
    for(int i = b-2; i <= d; ++i){
      if(flag_three_bin == 2 && road[i] == 0){
        flag_three = 0;
        break;
      }else if(road[i] == 1) flag_three_bin = 0;
      else if(flag_three_bin == 0 && road[i] == 0) flag_three_bin = 1;
      else if(flag_three_bin == 1 && road[i] == 0) flag_three_bin = 2;
    }
  }
  if(flag_two == 1) flag = 1;
  if(flag == 0 && flag_three == 1 && d < c) flag = 1;
  if(flag == 0) printf("Yes\n");
  else if(flag == 1) printf("No\n");
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=1;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,k;
int main(){
	n=read();k=read();
	rep(i,1,n)int x=read();
	printf("%d\n",(n-1)/(k-1)+((n-1)%(k-1)>0));
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

double pi = 3.141592;

double R;

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

  std::cout << 2*pi*R << std::endl;

  return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=200010,M=4010,O=1000000007;
inline int fpow(int x,int n){
	int a=1;
	for(;n;n>>=1,x=(lint)x*x%O){
		if(n&1){
			a=(lint)a*x%O;
		}
	}
	return a;
}
inline int inv(int x){
	return fpow(x,O-2);
}
int fac[N],invfac[N];
inline int C(int n,int k){
	return (lint)fac[n]*invfac[k]%O*invfac[n-k]%O;
}
inline void gmath(int n){
	fac[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=(lint)fac[i-1]*i%O;
	}
	invfac[n]=inv(fac[n]);
	for(int i=n;i>=1;i--){
		invfac[i-1]=(lint)invfac[i]*i%O;
	}
}
int x[N],y[N];
int f[M][M];
int main(){
	int n=ni,mx=0,my=0;
	for(int i=1;i<=n;i++){
		apmax(mx,x[i]=ni);
		apmax(my,y[i]=ni);
	}
	//transform:x->mx+x,y->my+y
	memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++){
		f[mx-x[i]][my-y[i]]++;
	}
	for(int i=0,ti=mx<<1;i<=ti;i++){
		for(int j=0,tj=my<<1;j<=tj;j++){
			if(i)(f[i][j]+=f[i-1][j])%=O;
			if(j)(f[i][j]+=f[i][j-1])%=O;
		}
	}
	gmath((mx+my)<<1);
	lint ans=0;
	for(int i=1;i<=n;i++){
		ans+=f[x[i]+mx][y[i]+my];
		ans-=C((x[i]+y[i])<<1,x[i]<<1);
	}
	printf("%lld\n",(ans%O+O)%O*inv(2)%O);
	return 0;
}

Measured memory_bytes: 65792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (998244353ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,k,i;
	ll a[123456],b[123456],ans=-INFLL;
	a[0] = 0ll;
	b[0] = 0ll;
	cin >> n >> k;
	for(i=1; i<=n; ++i){
		cin >> a[i];
		b[i] = ((a[i]>0ll)?a[i]:0ll);
		a[i] += a[i-1];
		b[i] += b[i-1];
	}
	for(i=k; i<=n; ++i){
		ans = max(ans,b[n]-(b[i]-b[i-k])+max((a[i]-a[i-k]),0ll));
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;
  vector<string> m(h);
  for (int i = 0; i < h; ++i) {
    cin >> m[i];
  }

  vector<vector<bool>> seen(h, vector<bool>(w, false));

  long long ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; j++) {
      long long b_cnt, w_cnt;
      b_cnt = w_cnt = 0;
      stack<array<int, 3>> st;
      st.push({i, j, m[0][0] == '#'});
      while (!st.empty()) {
        auto t = st.top();
        int y = t[0], x = t[1], p = t[2];
        st.pop();

        if (y < 0 || y >= h || x < 0 || x >= w) {
          continue;
        }

        if (seen[y][x] || p == m[y][x]) {
          continue;
        }

        seen[y][x] = true;

        if (m[y][x] == '.') {
          w_cnt++;
        } else {
          b_cnt++;
        }

        st.push({y - 1, x, m[y][x]});
        st.push({y + 1, x, m[y][x]});
        st.push({y, x + 1, m[y][x]});
        st.push({y, x - 1, m[y][x]});
      }

      ans += b_cnt * w_cnt;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 8496
#include<iostream>
long long digit_sum(long long num, long long p = 10)
{
	int result = 0;
	while (num > 0)
	{
		result += num % p;
		num /= p;
	}
	return result;
}
int main()
{
	int n;
	std::cin >> n;
	int answer = n;
	for (int i = 0; i <= n; i++)
	{
		int temp = digit_sum(i, 6) + digit_sum(n - i, 9);
		if (answer > temp)
		{
			answer = temp;
		}
	}
	std::cout << answer << std::endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if(a == b and b == c):
  if(a % 2 == 0):
    print(-1)
  else:
    print(0)
  exit()

result = 0

while(True):
  A = (b + c) / 2
  B = (c + a) / 2
  C = (a + b) / 2
  if((b - a) % 2 > 0 or (c - b) % 2 > 0 or (a - c) % 2 > 0):
    print(result)
    break
  a, b, c = A, B, C
  result += 1

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
	char str;
	int n[3]={},ans=0,x;
	while(cin>>str){
		if(str=='J'&&n[1]==0&&n[2]==0)n[0]++;
		else if(str=='O'&&n[1]<n[0]&&n[2]==0)n[1]++;
		else if(str=='I'&&n[2]<(x=min(n[0],n[1]))){if((n[2]+=1)==x)ans=max(ans,x);}
		else{
			for(int i=0;i<3;i++)n[i]=0;
			if(str=='J')n[0]=1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;

int main(int argc, char** argv) {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >>   t;
  if(n < m){
    swap(n, m);
    s.swap(t);
  }
  for(int i = 0;i < m;i++){
    if(1LL * i * n % m == 0 && t[i] != s[1LL * i * n / m]){
      cout << -1;
      return 0;
    }
  }
  cout << 1LL * n * m / __gcd(n, m);
  return 0;
}


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

using namespace std;

int main()
{
    int n, m, X, Y;
    int z = 0;
    bool xflg = true, yflg = true;

    cin >> n >> m >> X >> Y;

    int x[100], y[100];

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

    for (int i = 0; i < m; i++) {
        cin >> y[i];
    }

    for (z = -100; z <= 100; z++) {
        if (z <= X) continue;

        if (z > Y) break;

        for (int i = 0; i < n; i++) {
            if (z <= x[i]) xflg = false;
        }

        for (int i = 0; i < m; i++) {
            if (z > y[i]) yflg = false;
        }

        if (xflg == true && yflg == true) {
            cout << "No War" << endl;
            return (0);
        }
        xflg = true;
        yflg = true;
    }

    cout << "War" << endl;

    return (0);
}

    


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt
    var X = readLine().split(' ').map(_.toInt)

    var ans = X.map(a => a * a).sum
    for(P <- 0 to 100) {
      var sum = 0
      for(i <- 0 until X.size) {
        sum += (X(i) - P) * (X(i) - P)
      }
      if(sum < ans) ans = sum
    }
    println(ans)
  }
}


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

const LL M = 1000000007;

LL modpow(LL x, LL n) {
  LL r = 1;
  while(n) {
    if(n&1) r = r * x % M;
    x = x * x % M;
    n >>= 1;
  }
  return r;
}

vector<LL> fac(200000), ifac(200000);

void prepare() {
  fac[0] = 1;
  ifac[0] = 1;
  for(int i=1; i<200000; ++i) {
    fac[i] = fac[i-1] * i % M;
    ifac[i] = modpow(fac[i], M-2);
  }
}

LL comb(LL a, LL b) {
  return fac[a] * (ifac[b] * ifac[a-b] % M) % M;
}

int main() {
  prepare();
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  LL ret = 0;
  for(int x=B+1, y=H-A; x<=W && y > 0; ++x, --y) {
    ret = (ret + comb(x+y-2, x-1) * comb(H+W-x-y, H-y)) % M;
  }
  cout << ret << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

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

    int k;
    cin >> k;
    string str;
    cin >> str;

    if (str.length() <= k) {
        cout << str;
    } else {
        for (int i = 0; i < k; i++) {
            cout << str[i];
        }
        cout << "...";
    }

    return 0;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
H = list(map(int, input().split()))
good = [1 for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] == H[B - 1]:
        good[A - 1] = 0
        good[B - 1] = 0
    elif H[A - 1] > H[B - 1]:
        good[B - 1] = 0
    else:
        good[A - 1] = 0
print(good.count(1))


Measured memory_bytes: 20116
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long n,t[100005],x[100005],y[100005],tt,l,flap;
int main()
{
	
	t[0]=x[0]=y[0]=0;
	while(cin>>n)
	{
		flap=0;
		for(int i=1;i<=n;i++)
		{
			cin>>t[i]>>x[i]>>y[i];
			tt=t[i]-t[i-1];
			l=sqrt((x[i]-x[i-1])*(x[i]-x[i-1]))+sqrt((y[i]-y[i-1])*(y[i]-y[i-1]));
			if(l==0&&tt%2==0)
			{
				flap=1;
				continue;
			}
			if(l==0&&tt%2!=0)
			{
				flap=0;
				continue;
			}	
			if(tt<l)
			{
				flap=0;
				continue;
			}		
			if(tt%l==0)
			flap=1;
			else
			flap=0;
		}
		if(flap)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	return 0;
}


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

const int nm = 2e5;
int n, c, a[nm - 1];

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i];
	}
	sort(a, a + n - 1);
	int m = 1, c = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == m)
			c++;
		else {
			while (m != a[i]) {
				cout << c << endl;
				c = 0;
				m++;
			}
			c++;
		}
	}
	for (int i = m; i <= n; i++) {
		cout << c << endl;
		c = 0;
	}
}


Measured memory_bytes: 4388
import java.util.Scanner;
public class Main{
 public static void main(String args[]){
   Scanner sc=new Scanner(System.in);
   int N=sc.nextInt();
   int x[]=new int [N];
   int y[]=new int [N];
   int t[]=new int [N];
int xs=0,ys=0,d=0;
   for (int i=0;i<N;i++)
   {
if(i==0)
       t[i]=sc.nextInt();
else

      t[i]=sc.nextInt();
       x[i]=sc.nextInt();
       y[i]=sc.nextInt();
       
   }
   for (int i=0;i<N;i++)
   {
       if(i==0)
    {
       if((t[i]-(x[i]-xs+y[i]-ys))%2==0&&(t[i]-(x[i]-xs+y[i]-ys))>=0)

           d=1;
    }
       else
       {
          if((t[i]-t[i-1]-(x[i]-xs+y[i]-ys))%2==0&&(t[i]-(x[i]-xs+y[i]-ys))>=0)

           d=1;
       }

       if(d==0)
           break;
       if(i<(N-1))
       {
           xs=x[i];
           ys=y[i];
           d=0;
       }


   }
if(d==1)
    System.out.println("Yes");
else
    System.out.println("No");



   sc.close();
 }
}


Measured memory_bytes: 90320
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include <iomanip>
#include<unordered_map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn = 200005;

int a[maxn];
bool vis[maxn];

int main() {
   // freopen("in.cpp","r",stdin);
    int n,m;
    cin>>n>>m;
    int l = 2,r=n+n-2;
    if(m>=l&&m<=r) {
        cout<<"Yes"<<endl;
        a[n-1] = m;
        vis[m]=1;
        a[n-2] = 1;
        vis[1]=1;
        a[n] = n+n -1;
        vis[n+n-1]=1;
        if(m!=n+n-2) {
            a[n+1]=n+n-2;
            vis[n+n-2]=1;
        } else {
            a[n-3] = 2;
            vis[2]=1;
        }
        int pos=0;
        for(int i=1; i<=n+n-1; i++) {
            if(vis[i])continue;
            while(a[pos])pos++;
            a[pos]=i;
        }
        for(int i=0; i<n+n-1; i++)cout<<a[i]<<endl;
    } else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    int a[n+1];
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(int i=0; i<n-1; i++)sum+=a[i];
    if(sum>a[n-1])printf("Yes\n");
    else printf("No\n");
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int[] x= {0,0};
		int t=0;
		for(int i=n-1;i>=0;i--) {
			x[t]+=a[i];
			t=1-t;
		}
		System.out.println(x[0]-x[1]);

		}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  
#include <numeric>
#include <sys/resource.h>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
using ll = long long;
 
const int precision = 15;
const int modulo =  1000000007; // 10^9 + 7
const ll lmodulo =  1000000007; // 10^9 + 7
 
const double EPS = 1e-9;
const ll inf = 1e18;


void increaseStack() {
	const rlim_t kStackSize = 50 * 1024 * 1024;   // min stack size = 50 MB
	struct rlimit rl;
	int result;

	result = getrlimit(RLIMIT_STACK, &rl);
	if (result == 0) {
		if (rl.rlim_cur < kStackSize) {
			rl.rlim_cur = kStackSize;
		    result = setrlimit(RLIMIT_STACK, &rl);
		    if (result != 0) {
		    	fprintf(stderr, "setrlimit returned result = %d\n", result);
		    }
		}
	}
}


void solve () {
	int n; cin >> n;

	vector<ll> v(n);
	for (auto &it : v) cin >> it; 

	vector<vector<ll>> memo(n, vector<ll>(n, -1));
	function<ll(int, int)> getXY = [&](int l, int r) ->ll {
		if (l > r) return 0;
		if (l == r) return v[l];
		if(memo[l][r] != -1) return memo[l][r];

		ll ret = v[l] - getXY(l + 1, r);
		ret = max(ret, v[r] - getXY(l, r - 1));

		memo[l][r] = ret;
		return ret;
	};

	auto x = getXY(0, v.size() - 1);
	cout << x;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  solve();
  return 0;
}


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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}

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

   int a, b, c; cin >> a >> b >> c;
   set<int> ans;
   ans.insert(a);
   ans.insert(b);
   ans.insert(c);
   cout << sz(ans);
   return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n, m;
    scan(n, m);

    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= bi;
        adj[bi] ~= ai;
    }

    bool nibu = true;
    auto col = new int[](n);
    col[] = -1;
    col[0] = 0;

    void dfs(int u) {
        foreach (v ; adj[u]) {
            if (col[v] == -1) {
                col[v] = col[u] ^ 1;
                dfs(v);
            }
            else if (col[v] == col[u]) {
                nibu = false;
                return;
            }
        }
    }

    dfs(0);

    debug {
        writeln(col);
    }

    int x = col.count!"a == 0".to!int;
    int y = n - x;

    long ans;

    if (nibu) {
        ans = 1L * x * y - m;
    }
    else {
        ans = 1L * n * (n - 1) / 2 - m;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 13052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

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

vvint g;
mint dp[100005][2];

// 0は黒 1は白
void dfs(int v, int p = -1) {
    mint w = 1, b = 1;
    for (int n_v : g[v]) {
        if (n_v == p) continue;
        dfs(n_v,v);
        b *= dp[n_v][1];
        w *= dp[n_v][0] + dp[n_v][1];
    }
    dp[v][0] = b;
    dp[v][1] = w;
}

int main() {
    int n; cin >> n;
    g.resize(n);
    rep(i,n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0);
    cout << dp[0][0] + dp[0][1] << endl;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#include <math.h>
#include <ostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 && C > 0) {
    A -= D;
    C -= B;
  }
  if (C <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };

        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };

        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };

        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }

fn main() {
    input! {
            n: usize,
            d: usize,
            matrix: [[i32; d]; n],
        }
    
    let mut ans = 0;

    for i in 0..n-1 {
        for j in i+1..n {
            let distance_square : i32 = (0..d).into_iter().map(|current_d| (matrix[i][current_d] - matrix[j][current_d]).pow(2)).sum();
            if ((distance_square as f64).sqrt().floor() as i32).pow(2) == distance_square {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#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 FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> pqg;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    pqg a;
    REP(i, n)
    {
        int t;
        cin >> t;
        a.push(t);
    }

    priority_queue<p> cb;
    REP(i, m)
    {
        int bv, cv;
        cin >> bv >> cv;
        cb.push(make_pair(cv, bv));
    }

    ll ans = 0;
    bool flag = false;

    REP(i, min(m, n))
    {
        p cur_cb = cb.top();
        cb.pop();

        REP(j, cur_cb.second)
        {
            if (a.empty())
            {
                break;
            }
            else
            {
                int cur_a = a.top();
                a.pop();

                if (cur_a < cur_cb.first)
                {
                    ans += cur_cb.first;
                }else
                {
                    ans += cur_a;
                    flag = true;
                    break;
                }
                
            }
        }
        if (a.empty() || flag)
        {
            break;
        }
    }

    while(!a.empty())
    {
        ans += a.top(); a.pop();
    }

    cout << ans << endl;


}

Measured memory_bytes: 1784
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

class UnionFind {
public:
	UnionFind(ll n) {
		par_.resize(n);
		iota(par_.begin(), par_.end(), (ll)0);
		rank_.resize(n, 0);
	}

	//根を求める
	ll find(ll x) {
		return (par_[x] == x ? x : par_[x] = find(par_[x]));
	}

	//xとyの属する集合を併合
	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		if (rank_[x] < rank_[y]) {
			par_[x] = y;
		}
		else {
			par_[y] = x;
			if (rank_[x] == rank_[y]) {
				rank_[x]++;
			}
		}
	}

	//xとyが同じ集合に属するか否かを判定
	bool same(ll x, ll y) {
		return (find(x) == find(y));
	}
private:
	vector<ll> par_, rank_;
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> X(M), Y(M), Z(M);
	UnionFind uf(N);
	for (ll i = 0; i < M; i++) {
		cin >> X[i] >> Y[i] >> Z[i];
		uf.unite(X[i] - 1, Y[i] - 1);
	}

	set<ll> st;
	for (ll i = 0; i < N; i++) {
		st.insert(uf.find(i));
	}

	cout << st.size() << endl;
}

Measured memory_bytes: 8832
def solve():

    n,m = [int(i) for i in input().split()]
    
    
    s = [-1 for _ in range(m)]
    c = [-1 for _ in range(m)]
    
    for i in range(m):
        s[i],c[i] = [int(j) for j in input().split()]
    
    res = [-1 for _ in range(n)]
    
    for i in range(m):
        if(s[i] == 1 and c[i] == 0 and n != 1):
            print(-1)
            return
        elif(res[s[i]-1] != -1 and res[s[i]-1] != c[i]):
            print(-1)
            return
        
        else:
            res[s[i]-1] = c[i]
    
    if(res[0] == -1 and n!=1):
        res[0] = 1
    
    if(res[0] == 0 and n==1):
        print(0)
        return
    
    for i in range(n):
        if(res[i] == -1):
            res[i] = 0
    
    
    res = [str(_a) for _a in res]
    res = "".join(res)
    print(res)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
Q, H, S, D = map(int, input().split())
N = int(input())

q = Q

if 2*q < H:
    h = 2*q
else:
    h = H
    
if 2*h < S:
    s = 2*h
else:
    s = S

if 2*s < D:
    d = 2*s
else:
    d = D
    
print((N//2)*d + N%2*s)

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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r < 0 || x + r > W || y - r < 0 || y + r > H){
		cout << "No" << endl;
	}
	else if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104