akhauriyash/Code-Regression huggingface dataset:
#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<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

char mp[6][6];
void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(all(a), greater<int>());
	ll ans = 0;
	rep(i, n) {
		if (i == 0)continue;
		ans += a[i / 2];
	}
	cout << ans << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 20372
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

hasFound = False
search = N-M+1
for y in range(search):
    for x in range(search):
        if hasFound: break
        for h in range(M):
            src = A[y+h][x:x+M]
            dst = B[h]
            if dst != src:
                break
        else:
            hasFound = True


print("Yes" if hasFound else "No")


Measured memory_bytes: 3064
"""

https://atcoder.jp/contests/agc045/tasks/agc045_a

A[i]が正なので、最後が人1ならば絶対1がかつ

あとは最後が0の場合を考える
→人0が作れない数字を作れればおk

Xorは戻る演算であることを考慮

◎仮説
1の持ってる数それぞれについて、0がそれ以降の数を使って作れるなら0の勝ち。
そうでないなら1の勝ち

まず、1が持っているある数に関して、それ以降で打ち消せることが必要十分条件であることの証明
それ以前に0が対策しておいたとする。1が使わなかった場合、0はそれ以降で対策を打ち消さなくてはいけない。
すなわち、1が行動した後にできる行動 = 対策のためにできる行動
なので、必要十分である

1が持つ複数の数字に関して、それぞれ後ろで打ち消せればいいことの証明
S,Tという2つの数があり、それぞれ後ろで打ち消せるとする。
SとTを打ち消すための集合を全部選ぶと、そのXorはS^Tとなるので打ち消せる
よって示された

あとは、O(N**2)で求められればおk
追加するときに、まだ分離できていない桁かつ1の桁を見つけて分離すればおk

2**60なので

"""

from sys import stdin

TT = int(stdin.readline())

for loop in range(TT):

    N = int(stdin.readline())
    A = list(map(int,stdin.readline().split()))
    S = stdin.readline()
    S = S[:-1]

    zerolis = []
    root = [None] * 60

    for i in range(N-1,-1,-1):

        #0の時、掃き出し法をして新たな基底にする
        if S[i] == "0":

            #今まで作った基底の位を消す
            now = A[i]
            for j in range(60):
                if root[j] != None and now & (2**j) > 0:
                    now ^= zerolis[root[j]]

            #新たな基底にできる桁を探索
            for j in range(60):
                if root[j] == None and now & (2**j) > 0:
                    
                    for k in range(len(zerolis)):
                        if zerolis[k] & (2**j) > 0:
                            zerolis[k] ^= now

                    root[j] = len(zerolis)
                    zerolis.append(now)
                    break

        else: #1の時、今までの基底で打ち消せるか調べる

            now = A[i]
            for j in range(60):
                if root[j] != None and now & (2**j) > 0:
                    now ^= zerolis[root[j]]

            if now != 0:
                print (1)
                break
    else:
        print (0)
            


Measured memory_bytes: 74436
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin >> n >> m;
    int z = n - 1;
    int l = m - 1;
    
    int x = n * z;
    int a = x / 2;
    int y = m * l;
    int b = y / 2;
    
    cout << a + b << endl;
}

Measured memory_bytes: 3196
#include <iostream>
 
using namespace std;
 
int main(){
int W, H, x, y ,r;
cin >> W >> H >> x >> y >>r;
if( 0 > x || x > W
    || y < 0 || y > H)
{
cout << "No" << endl;
return 0;
}
 
if( x - r < 0 || x + r > W || y - r < 0 || y + r > H)
cout << "No" << endl;
else
cout << "Yes" << endl;
 
return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c=0;cin>>a;
  vector<int>b(2*a);
  rep(i,2*a)cin>>b[i];
  sort(b.begin(),b.end());
  for(int i=0;i<2*a;i+=2){
    c+=b[i];
  }
  cout<<c;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String input;
		Scanner sc=new Scanner(System.in);
		input=sc.next();
		int output=0;
		for(int i=0;i<input.length();i++) {
			int temp=0;
			for(int j=i;j<input.length();j++) {
				if(!input.substring(j, j+1).equals("A")&&!input.substring(j, j+1).equals("C")&&!input.substring(j, j+1).equals("G")&&!input.substring(j, j+1).equals("T")) {
					break;
				}else {
					temp++;
				}
			}
			if(temp>output) {
				output=temp;
			}
				
			}
		System.out.println(output);
		}

}


Measured memory_bytes: 22868
#include <cstdio>
#include <algorithm>

constexpr int six_pows[] = {1, 6, 36, 216, 1296, 7776, 46656, 279936};
constexpr int nine_pows[] = {1, 9, 81, 729, 6561, 59049, 531441};

int main() {
  int N;
  scanf("%d", &N);

  int res = N;
  for (int i = 0; i < nine_pows[6]; ++i) {
    int m = 0;
    int cur = 0;
    int k = i;
    for (int j = 0; j < 6; ++j) {
      m += (k % 9) * nine_pows[j];
      cur += k % 9;
      k /= 9;
    }
    if (m > N) continue;
    for (int j = 7; j--;) {
      while (m + six_pows[j] <= N) {
        m += six_pows[j];
        ++cur;
      }
    }
    res = std::min(res, cur);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
from math import floor, ceil

N, K = map(int, input().split())

ans = 0
for a in range(1, N + 1):
    if 2 * a % K != 0:
        continue
    ans += (floor((N + a) / K) - ceil((a + 1) / K) + 1) ** 2
print(ans)


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

using namespace std;

const int N = 300004;
int cnth[N], cntw[N], x[N], y[N];
map <int, bool> mp[N];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        mp[x[i]][y[i]] = true;
        cnth[x[i]]++, cntw[y[i]]++;
    }
    int mxh = 0, mxw = 0;
    for (int i = 0; i < N; i++) {
        mxh = max(mxh, cnth[i]);
        mxw = max(mxw, cntw[i]);
    }
    vector <int> hall, wall;
    for (int i = 0; i < N; i++) {
        if (cnth[i] == mxh) {
            hall.push_back(i);
        }
        if (cntw[i] == mxw) {
            wall.push_back(i);
        }
    }
    int cnt = 0, mx = 0;
    for (int i = 0; i < hall.size(); i++) {
        for (int j = 0; j < wall.size(); j++) {
            cnt++;
            if (cnt > N * 2)
                break;
            mx = max(mx, mxh + mxw - mp[hall[i]][wall[j]]);
        }
        if (cnt > N * 2)
            break;
    }
    cout << mx;
}

Measured memory_bytes: 66444
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }
inline void Yes (bool condition) { if(condition) { cout << "Yes" << endl; } else { cout << "No" << endl;} }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int k;
	cin>>k;
	queue<int> que;
	for(int i=1;i<=9;i++)que.push(i);
	for(int i=0;i<k-1;i++){
		int f=que.front();
		//cout<<f<<" ";
		que.pop();
		if(f%10!=0)que.push(f*10+f%10-1);
		que.push(f*10+f%10);
		if(f%10!=9)que.push(f*10+f%10+1);
	}
	cout<<que.front()<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 5;
const int mod = 0;

int main(){
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	printf(((x + z - 1) / z) > y ? "No" : "Yes");

}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    vector<string> ret{"mon", "tue", "wed", "thu", "fri", "sat", "sun"};
    int n;
    cin >> n;
    cout << ret[(n + 3) % 7] << endl;
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define		fast			ios::sync_with_stdio(false);cin.tie(0);cout.tie(NULL);
#define		rep(i,n)		for(int i = 1; i<=n; i++)
#define		all(p)			p.begin(),p.end()
#define		mem(ar,val)		memset(ar, val, sizeof(ar))
#define		sz(c)			(int)c.size()
#define		pb(x)			push_back(x)
#define		mkp(x,y)		make_pair(x,y)
#define 	deb			cout<<"hehehe\n"
#define		ff			first
#define		ss			second
#define 	pf 			printf
#define 	sf 			scanf
#define		ll			long long
#define		pii			pair<int, int>
#define 	pll			pair<ll, ll>
#define 	vll			vector<long long>
#define 	vi			vector<int>
#define		nl			"\n"
#define		pnl			printf("\n");
#define		S(a)			scanf("%lld",&a)
#define		SS(a,b)			scanf("%lld %lld",&a,&b)
#define		SSS(a,b,c)			scanf("%lld %lld %lld",&a,&b,&c)
#define		P(a)			printf("%lld\n",a)
#define		PP(a,b)			printf("%lld %lld\n",a,b)
#define 	total_bit(a)		__builtin_popcount(a)
#define 	UNIQUE(a)		sort(all(a)); a.erase(unique(all(a)), a.end())
#define		FI			freopen("input.txt", "r", stdin);
#define 	FO			freopen("output.txt", "w", stdout);
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x7f7f7f7f;
const int M = 1e9 + 7;
const int N = 1e6+7;
void solve()
{
	ll n;
	S(n);
	ll ar[n];
	unordered_map<ll, ll> mp;
	ll sum = 0;
	for(int i = 0; i<n; i++)
	{
		S(ar[i]);
		sum += ar[i];
		mp[ar[i]]++;
	}
	ll q,b,c;
	S(q);
	for(int i = 0; i<q; i++)
	{
		SS(b,c);
		ll x = mp[b];
		sum -= (x*b);
		mp[b] = 0;
		mp[c] += x;
		sum += (x*c);
		P(sum);
	}
}
int main()
{
//	ll t;
//	S(t);
//	while(t--)
//	{
		solve();
//	}
	return 0;
}


Measured memory_bytes: 8136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{

    static void Main(string[] args)
    {
        int N = GetInputInt();
        int[] input = GetInputsInt();

        if (input[0] != 1) input[0]--;

        for (int i = 1; i < N; i++)
        {
            if(input[i-1] < input[i])
            {
                input[i] -=1;
            }
            else if(input[i - 1] > input[i])
            {
                Console.WriteLine("No");
                return;
            }
        }
        

        Console.WriteLine("Yes");

    }



    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


Measured memory_bytes: 30044
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
vector<int> g[N];
queue<int> q;
int visited[N], d[N], ans, n, m;

int dfs(int i)
{
	visited[i] = 1;
	int k = 0;
	for(int j=0;j<g[i].size();j++)
	{
		if(!visited[g[i][j]])
			k = max(k,1+dfs(g[i][j]));
		else
			k = max(k,1+d[g[i][j]]);
	}
	d[i] = k;
	ans = max(ans, k);
	return d[i];
}

int32_t main()
{
	fast;

	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b; cin>>a>>b;
		g[a].push_back(b);
	}

	for(int i=1;i<=n;i++)
		if(!visited[i])
			dfs(i);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35072
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, d;
    cin >> n >> m >> d;
    if (d == 0) {
        cout << fixed << setprecision(12) << (m - 1.0)/n << endl;
    } else {
        cout << fixed << setprecision(12) << (m - 1.0) * ((n - d) * 2)/(n * n)<< endl;
    }

    return 0;
}
// 1 1 :0
// 1 2 :1
// 1 3: 0
// 2 1 :1
// 2 2: 0
///2 3: 1

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a = 0,b = 0;
    int area=0, perimeter=0;
    
    cin >> a >> b;
    
    area = a*b;
    
    perimeter = (a+b)*2;
    
    cout << area << " " << perimeter << endl;
    
    return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	int m=sz(s), n=stoi(s), ans =0;
	if(n<357){puts("0"); return 0;}
	int mt[] = {3,5,7};
	VI cnd, ct(m, 0);
	auto rec =[&](auto f, int idx)->void{
		if(idx>=3){
			int w =0; VI usd(3);
			rep(i, idx){
				w = w *10 + mt[ct[i]];
				usd[ct[i]]= 1;
			}
			if(w >=1 && w <=n && count(all(usd), 1)==3){ ans++;}
			if(idx==m) return;
		}
		rep(i, 3){
			ct[idx]=i;
			f(f, idx+1);
		}

	};
	
	rec(rec, 0);
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            boolean possible = a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0;
            out.println(possible ? "Possible" : "Impossible");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

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

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



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

int main(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end());

	while (s.size()!=0){

		if (s.substr(0,5)=="maerd" or s.substr(0,5)=="esare") s.erase(0,5);
		else if (s.substr(0,6)=="resare") s.erase(0,6);
		else if (s.substr(0,7)=="remaerd") s.erase(0,7);
		else break;
	}
	if (s.size()==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = scanner.nextInt();
        }
        int m = scanner.nextInt();
        int count = 0;
        while (m-- > 0) {
            int a = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                if (a == num[i]) {
                    count++;
                    break;
                }
 
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 39200
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k,s;
  cin>>n>>k>>s;
  rep(i,k){
    cout<<s<<' ';
  }
  ll tmp=n-k;
  rep(i,tmp){
    if(s<1000000000){
      cout<<s+1<<' ';
    }else{
      cout<<s-1<<' ';
    }
  }
  cout<<endl;
}

Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int):
    return YES if (N % 500) <= A else NO


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9068
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, c;
  cin>>a>>b>>c;
  if(a<b) swap(a, b);
  if(a<c) swap(a, c);
  cout<<(a==b+c?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=INF; cin>>n;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0) ans=min(ans,(i-1)+(n/i-1));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

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

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[225816],b[225816];

int main(void){
	int n,i;
	ll ans;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a[i] >> b[i];
	}
	std::sort(a,a+n);
	std::sort(b,b+n);
	if(n%2){
		ans = b[n/2]-a[n/2]+1;
	}else{
		ans = (b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2])+1;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
  int N;
  string S;
  cin>>N>>S;
  
  bool flag=true;
  if(N%2==1){
    flag=false;
  }else{
    for(int j=0;j<N/2;j++){
      if(S.at(j)!=S.at(N/2+j)){
        flag=false;
      }
    }
  }
  
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];

    ll cnt (0);
    rep(i,0,n-1)
    {
        ll minj = i;
        rep(j,i,n)
        {
            if (a[j] < a[minj])
                minj= j;
        }
        if (i!=minj)
            swap(a[i], a[minj]), cnt++;    
    }

    for (size_t i=0; i<a.size(); i++)
        if (a.size()-1 != i)
            cout << a[i] << ' ';
        else
            cout << a[i];
    cout << endl;

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3212
X, Y = map(int, input().split())

a = (4*X-Y)/2
b = X - a
d = a.is_integer()
e = b.is_integer()
if a==0 and b==0:
    print('No')
elif a>0 and b>=0:
    if d and e:
        print('Yes')
    else:
        print('No')
elif a>=0 and b>0:
    if d and e:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 9196
from copy import*
class UNION_FIND(object):
    def __init__(self,n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはParentの値を全て-1にする
        #こうすると全てバラバラになる
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        #Aがどのグループに属しているか調べる
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])  #親を再帰で探知 再帰は最後に上のifにひっかかる
            return self.parent[x]
 
    def size(self,x):
        #自分のいるグループの頂点数を調べる
        return -self.parent[self.root(x)]   #親をとってきたい
        
    def union(self,x,y):
        #AとBをくっ付ける
        #AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        #print(self.parent)
        x=self.root(x)
        y=self.root(y)
        #print(x,y)
        if x==y:   #すでにくっついてるからくっ付けない
            return False
            
        #大きい方(A)に小さいほう(B)をくっ付けたい
        #大小が逆だったらひっくり返しちゃう。
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]  #Aのサイズを更新する
        self.parent[y]=x   #Bの親をAに変更する
        return True

    
n,m=map(int,input().split())
ans=0

Input=[list(map(int,input().split()))for s in m*[0]]
for i in Input:
    uni=UNION_FIND(n)
    s=deepcopy(Input)
    s.remove(i)
    for j in s:
        x,y=j
        x-=1
        y-=1
        uni.union(x,y)
#    print(uni.parent)
    g,h=i
    g-=1
    h-=1
    if uni.root(g)!=uni.root(h):
        ans+=1
print(ans)

Measured memory_bytes: 3572
from sys import stdin
import math
from functools import reduce

k,n = [int(x) for x in stdin.readline().rstrip().split()]

a = [int(x) for x in stdin.readline().rstrip().split()]

l = 0
for i in range(n-1):
    l = max([l, a[i+1] - a[i]])

l = max([l, a[0]+k-a[n-1]])

print(k-l)

Measured memory_bytes: 33312
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int h,w,k;cin >> h >> w >> k;
  vector<vector<char>> s(h,vector<char>(w));
  rep(i,h) rep(j,w) cin >> s[i][j];

  vector<vector<int>> sum(h+1,vector<int>(w+1,0));
  rep1(i,h) rep1(j,w){
    int x = s[i-1][j-1] - '0';
    sum[i][j] = sum[i][j-1] + sum[i-1][j] - sum[i-1][j-1] + x;
  }

  // rep(i,h+1){
  //   rep(j,w+1) cout << sum[i][j] << " ";
  //   cout << "\n";
  // }
  
  int res = 1e+9;
  rep(mask,(1<<h)){
    //    if(mask == 1) break;
    vector<int> v;
    v.push_back(0);
    rep(i,h) if((mask >> i) & 1) v.push_back(i+1);
    v.push_back(h);
    int left = 0,cnt = 0;
    bool f = true;
    rep1(j,w){
      rep(i,v.size()-1){
  	int x = sum[ v[i+1] ][j] - sum[ v[i] ][j] - sum[ v[i+1] ][left] + sum[ v[i] ][left];
  	if(x > k){
  	  if(j - left == 1){
  	    f = false;
  	    break;
  	  }
  	  cnt++;
  	  left = --j;
  	}
      }
      if(!f) break;
    }
    int y =__builtin_popcount(mask);
    //    if(f && cnt + y < res) cout << mask << ":" << cnt + y << "\n";
    if(f) res = min(res , cnt + y);
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};


int main(){
    int N, M; cin >> N >> M;
    vector<int> p(N+1, 0);
    for(int i=1; i<=N; ++i) cin >> p[i];

    UnionFind uni(N+1);

    for(int i=0; i<M; ++i){
        int x,y; cin >> x >> y;
        uni.connect(p[x], p[y]);
    }

    int ans = 0;
    for(int i=1; i<=N; ++i){
        if(uni.root(i) == uni.root(p[i])) ++ans;
    }

    cout << ans << endl;
}

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





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

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;


    cin>>a;
    cout<<a+(a*a)+(a*a*a)<<"\n";

    return 0;


}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
#define INF 100000000000
using namespace std;
vector<int>s, t;
int a, b, p, q;
pair<int, int>fs(int k) {
	auto sk = lower_bound(s.begin(), s.end(), k);
	if (sk - s.begin() == 0)return make_pair(INF, *sk - p);
	else if (s.end() - sk == 0)return make_pair(p - *(--sk), INF);
	else return make_pair(p - *(--sk), *sk - p);
}
pair<int, int>ft(int k) {
	auto tk = lower_bound(t.begin(), t.end(), k);
	if (tk - t.begin() == 0)return make_pair(INF, *tk - p);
	else if (t.end() - tk == 0)return make_pair(p - *(--tk), INF);
	else return make_pair(p - *(--tk), *tk - p);
}
signed main() {
	int a, b, q; cin >> a >> b >> q;
	for (int i = 0; i < a; i++) {
		int p; cin >> p;
		s.push_back(p);
	} sort(s.begin(), s.end());
	for (int i = 0; i < b; i++) {
		int p; cin >> p;
		t.push_back(p);
	} sort(t.begin(), t.end());
	for (int i = 0; i < q; i++) {
		cin >> p;
		pair<int, int>sf = fs(p);
		pair<int, int>tf = ft(p);
		cout << min(min(max(sf.first, tf.first), max(sf.second, tf.second)), min(min(sf.first * 2 + tf.second, sf.second * 2 + tf.first), min(tf.first * 2 + sf.second, tf.second * 2 + sf.first))) << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int cnt = 0;
    for(i = 0; i < n; i++){
        if(a.at(i) != i+1){
            cnt++;
        }
    }
    if(cnt > 2){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}


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

int main() {
    int N, M;
    while (cin >> N >> M, N) {
        vector<int> p(N + 1);
        for (int i = 0; i < N; i++) cin >> p[i];
        p[N] = 0;
        // 半分全列挙
        vector<int> pp;
        for (int i = 0; i < N + 1; i++) {
            for (int j = 0; j < N + 1; j++) {
                pp.push_back(p[i] + p[j]);
            }
        }
        sort(pp.begin(), pp.end());
        // 二分探索
        int ma = 0;
        for (int i = 0; i < pp.size(); i++) {
            if (M - pp[i] >= 0) {
                int rest = *(upper_bound(pp.begin(), pp.end(), M - pp[i]) - 1);
                ma = max(ma, pp[i] + rest);
            }
        }
        cout << ma << endl;
    }
    return 0;
}


Measured memory_bytes: 10764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int count = 0;
  
  string judge = "E";
  
  for(int i = 0; i < N - 1; i++) {
   if(A.at(i) == A.at(i + 1)) {
     continue;
   }
     
   else if(A.at(i) < A.at(i + 1)) {
      if(judge == "D") {
        count++;
        judge = "E";
      }
      
      else if(judge == "E") {
        judge = "I";
      }
    }
    
    else if(A.at(i) > A.at(i + 1)) {
      if(judge == "I") {
        count++;
        judge = "E";
      }
      else if(judge == "E") {
        judge = "D";
      }
   }
 }
       
       cout << count + 1 << endl;
  return 0;
}
      
 

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)
	for i := 1; i < 1000001; i++ {
		if s == 4 || s == 2 || s == 1 {
			fmt.Println(i + 3)
			return
		}
		if s%2 == 0 {
			s /= 2
		} else {
			s = 3*s + 1
		}
	}
}


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

signed main() {
	int n, a, cnt = 0;
	cin >> n;
	vector<bool> num(1000000010);
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (!num[a]) {
			cnt++;
			num[a] = true;
		}
		else {
			cnt--;
			num[a] = false;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 122368
#include<bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    double a,b;
    cin>>a>>b;
    int x=b*10,ok=0;
    while(floor((double)x*0.1)==b){
        if(floor((double)x*0.08)==a){
            ok=1;
            break;
        }
        x++;
    }
    if(ok)cout<<x<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(a, (n % (a + b)));
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		long[] A = new long[N+1];
		//1-indexed
		for(int i=1;i<=N;i++) {
			A[i]=nextLong();
		}
		long[] ans = new long[N+1];

		long sum=0;
		long sumEven=0;
		for(int i=1;i<=N;i++) {
			if(i%2==0) {
				sumEven+=A[i];
			}
			sum+=A[i];
		}
		ans[1]=sum-2*sumEven;

		for(int i=1;i<N;i++) {
			ans[i+1]=2*A[i]-ans[i];
			pw.println(ans[i]);
		}
		pw.println(ans[N]);


	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m) { cin >> a[i] >> b[i]; }

    int ans[n] = {};
    rep(i, m) {
        ans[a[i]-1]++;
        ans[b[i]-1]++;
    }

    rep(i, n) { cout << ans[i] << endl; }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
function Main(args) {
  const inputs = args.split(" ");
  const n = inputs[0];
  const a = inputs[1];
  const b = inputs[2];
  if (a * n > b) {
    console.log(b);
    return;
  }
  console.log(a * n);
}

// 標準入力
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
N=int(input())
S=list(map(int,input().split()))
S.sort()
p=S[-1:]
r=S[:-1]
for i in range(N):
    nr=[]
    for p_ in p[::-1]:
        while r:
            r_=r.pop()
            if r_<p_:
                p.append(r_)
                break
            nr.append(r_)
    p.sort()
    r+=nr[::-1]
print("Yes" if len(r)==0 else "No")

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int k,x;
	cin >> k >> x;
	if(500*k>=x) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
/* Data Structure */
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <queue>

using namespace std;

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define debug cerr << "======= GOT_HERE ======\n"
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef map<int,int> mii;
typedef map<long long,long long> mll;
typedef set<int> si;
typedef set<long long> sll;

long long n,k;

string s;

int count(int a)
{
	string temp = to_string(a);
	int ans = 0;
	for(int i=0;i<temp.length();++i)
	{
		if(temp[i]!='0') ans++;
	}
	return ans;
}

int calc(int rem, int digit)
{
	if(rem>digit) return 0;
	if(rem==0) return 0;
	int ans = 1;
	int i=0;
	//cout << "rem is: " << rem << " digit is: " << digit << endl;
	while(i<rem)
	{
		ans*=(digit-i);
		i++;
	}
	int hold = rem;
	while(rem>0)
	{
		ans/=(rem--);
	}
	ans = ans*pow(9,hold);
	//cout << "ans is: " << ans << endl;
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>s>>k;
	if(k>s.length())
	{
		cout << "0" << endl;
		return 0;
	}
	ll ans = 0;
	while(k>0)
	{
		int mx = stoi(s.substr(0,1));
		//cout << "mx is: " << mx << endl;
		if(s.length()==1)
		{
			ans+=s[0]-'0';
			break;
		}
		for(int i=0;i<mx;++i)
		{
			int cnt = count(i);
			if(cnt>k) continue;
			if(cnt==k) ans++;
			int rem = k-cnt;
			int digit = s.length()-1;
			ans+=calc(rem,digit);


		}

		int mx_cnt = count(mx);
		if(mx_cnt==k) ans++;
		s = s.substr(1);
		k-=mx_cnt;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX 100

int n,Time;
int G[MAX][MAX],d[MAX],f[MAX];
bool used[MAX];

void dfs(int v){
  d[v] = Time++;
  used[v] = true;

  for(int i = 0 ; i < n ; i++){
    if(!used[i] && G[v][i]){
      dfs(i);
    }
  }

  f[v] = Time++;
}

int main(){
  cin >> n;

  for(int i = 0 ; i < n ; i++){
    int u,k,v;
    cin >> u >> k;
    for(int j = 0 ; j < k ; j++){
      cin >> v;
      G[u-1][v-1] = v-1;
    }
  }

  Time = 1;
  for(int i = 0 ; i < n ; i++){
    if(!used[i]){
      dfs(i);
    }
  }

  for(int i = 0 ; i < n ; i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>

using namespace std;


int main()
{
    int n;
    cin >> n;
    int Taro_score = 0, Hanako_score = 0;
    int m = 'a' - 'A';

    for (int i = 0; i <  n; i++)
        {
            string Taro_s, Hanako_s;
            cin >> Taro_s >> Hanako_s;

            if(Taro_s == Hanako_s)
            {
                Taro_score++;
                Hanako_score++;
            }
            else
            {
                int l = Taro_s.length();
                for (int i = 0; i <= l; i++)
                {
                    if (i == l)
                    {
                        Hanako_score += 3;
                        break;
                    }
                    else if(Hanako_s[i] == '\0')
                    {
                        Taro_score += 3;
                        break;
                    }
                    if (Taro_s[i] >= 'A' && Taro_s[i] <= 'Z')
                    {
                        Taro_s[i] += m;
                    }
                    if (Hanako_s[i] >= 'A' && Hanako_s[i] <= 'Z')
                    {
                        Hanako_s[i] += m;
                    }
                    if (Taro_s[i] > Hanako_s[i])
                    {
                        Taro_score += 3;
                        break;
                    }
                    else if (Taro_s[i] < Hanako_s[i])
                    {
                        Hanako_score += 3;
                        break;
                    }
                }
            }
        }
         
    cout << Taro_score << " " << Hanako_score << endl;
    return 0;
}



Measured memory_bytes: 3148
a,b,c,x,y = map(int, input().split())

mincost = a*x+b*y
for z in range(max(x,y)+1):
    x_ = max(0, x-z)
    y_ = max(0, y-z)
    cost = 2*c*z + a*x_ + b*y_
    mincost = min(mincost, cost)

print(mincost)


Measured memory_bytes: 9164
#include<stdio.h>
int main(void){
  int N,A,B,P[100],i;
  int sma=0,mid=0,big=0;
  int times=0;
  scanf("%d",&N);
  scanf("%d %d",&A,&B);
  for(i=0;i<N;i++){
      scanf("%d",&P[i]);
      if(P[i]<=A){
          sma++;
      }
      else if((P[i]>A)&&(P[i]<=B)){
          mid++;
      }
      else if(P[i]>B){
          big++;
      }
  }
    times=sma;
  if(times>mid){
      times=mid;
  }
  if(times>big){
      times=big;
  }

  printf("%d",times);
  return 0;
}

Measured memory_bytes: 128