akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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;
    }
}

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

struct mint {
    ll x;
    mint(ll x=0):x(x%MOD){}
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
};

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    
    COMinit();
    mint ans = 0;
    for (int i = 0; i < w-b; ++i) {
        mint tmp;
        tmp = COM(h-a-1+b+i, b+i);
        if (i != 0) tmp -= COM(h-a-1+b+i-1, b+i-1);
        tmp *= COM(a+w-b-i-1, w-b-i-1);
        ans += tmp;
    }
    cout << ans.x << endl;
}

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

typedef long long ll;
typedef long double ld;

int a[100005];
int b[100005];
int c[100005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	int x, y;
	cin >> x >> y;
	int A, B, C;
	cin >> A >> B >> C;
	for(int i=1; i<=A; i++){
        cin >> a[i];
	}
	for(int i=1; i<=B; i++){
        cin >> b[i];
	}
	for(int i=1; i<=C; i++){
        cin >> c[i];
	}
	sort(a+1, a+1+A);
	sort(b+1, b+1+B);
	sort(c+1, c+1+C);
	reverse(a+1, a+1+A);
	reverse(b+1, b+1+B);
	reverse(c+1, c+1+C);
	ll res = 0;
	priority_queue <int> q;
	for(int i=1; i<=x; i++){
        res += a[i];
        q.push(-a[i]);
	}
	for(int i=1; i<=y; i++){
        res += b[i];
        q.push(-b[i]);
	}
	for(int i=1; i<=C; i++){
        if(c[i] > -q.top()){
            res += q.top();
            q.pop();
            res += c[i];
            q.push(-c[i]);
        }
	}
	cout << res;
    return 0;
}


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


int main() {

	int count = 0, count_max = 0;
	int tmp;
	int i;

	unsigned int N;
	
	long int sum = 0;

	cin >> N;
	
	long int A[N], A_max;

	for ( i = 0; i < N; i++)
	{
		cin >> A[i];

		if (i == 0)
		{
			A_max = A[i]; 
		}
		else
		{
			if (A_max > A[i])
			{
				sum += (A_max-A[i]);
			}
			else
			{
				A_max = A[i];
			}
			
			
		}
		
	}
	

	cout << sum << endl;
	
		
	
	
}

Measured memory_bytes: 5196
S = input()
T = input()

def same_chara(list1, list2):
  count = 0
  for a, b in zip(list1, list2):
    if a == b:
      count += 1
  return count

m = 0
for i in range(len(S) - len(T) + 1):
  m = max(m, same_chara(S[i:len(T)+i], T))
  
print(len(T) - m)

Measured memory_bytes: 8904
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr ll INF = 1LL << 50;

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;

    vector<ll> a(m);
    vector<int> c(m);
    int nc, cc;
    for(int i=0;i<m;++i) {
        cin >> a[i] >> nc;
        for(int j=0;j<nc;++j) {
            cin >> cc;
            c[i] += (1 << (cc-1));
        }
    }

    vector<vector<ll>> dp(2, vector<ll>(1<<n, INF));
    dp[0][0] = 0;
    for(int j=0;j<m;++j) {
        for(int i=0;i<(1<<n);++i) {
            dp[1-(j%2)][i] = min(dp[1-(j%2)][i|c[j]], dp[j%2][i]);
            if(dp[j%2][i] == INF) continue;
            dp[1-(j%2)][i|c[j]] = min(dp[1-(j%2)][i|c[j]], dp[j%2][i] + a[j]);
        }
        for(int i=0;i<(1<<n);++i) dp[j%2][i] = INF;
    }

    cout << ((dp[m%2][(1<<n)-1] == INF) ? -1 : dp[m%2][(1<<n)-1]) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

// 123456789
// 255456376
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vi a(m);
	vi b={100,2,5,5,4,5,6,3,7,6};
	cin>>a;

	vs dp(n+1,"-");
	dp[0]="";
	rep(i,n){
		if(dp[i]=="-")continue;
		rep(j,m){
			if(i+b[a[j]]>n)continue;
			int c=-(lower_bound(dp[i].begin(),dp[i].end(),a[j]+'0')-dp[i].end());
			string nxt=dp[i].substr(0,c)+to_string(a[j])+dp[i].substr(c);
			if(dp[i+b[a[j]]].size()>nxt.size()) continue;
			if(dp[i+b[a[j]]].size()==nxt.size() and dp[i+b[a[j]]]>nxt) continue;
			dp[i+b[a[j]]]=nxt;
		}
	}
	puta(dp[n]);
	return 0;
}


Measured memory_bytes: 52992
/*
    Prodigia comploratus,
    silens, oro:
    "Regnet exitium."
*/
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 2e5 + 5, MOD = 1e9 + 7;
const ll inf = 1e15;
ll n, ans = 0;
int main(){

    cin >> n;
    vector<ll> v;
    for(ll i = 1; i * i <= n; i++){
        if(n%i == n / i)v.push_back(i);
    }
    ////(n/i-1) < sqrt(i)
    for(ll i = 1; i * i < n; i++){
        if(n % i == 0){
            v.push_back(n/i-1);
        }
    }

    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());

    for(auto x : v)if(n%x==n/x)ans += x;

    cout << ans << '\n';



    return 0;
}


Measured memory_bytes: 256
let [| L; R |] = stdin.ReadLine().Split() |> Array.map int64

let rec resolver m i j =
    if i = R then m
    elif m = 0L then m
    elif j = R + 1L then resolver m (i + 1L) (i + 2L)
    elif i * j % 2019L < m then resolver (i * j % 2019L) i (j + 1L)
    else resolver m i (j + 1L)

resolver 2019L L (L + 1L) |> stdout.WriteLine

Measured memory_bytes: 11220
x=int(input())
a=0
b=0
for i in range(1000):
    for j in range(1000):
        if i**5-j**5==x:
            a=i
            b=j
            break
        elif i**5+j**5==x:
            a=i
            b=-j
            break
    if a!=0 or b!=0:
        break
print(str(a)+" "+str(b))

Measured memory_bytes: 64472
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------

struct Query {
  int a, b, c, d;
};

int N, M, Q;
vector<Query> qs;

int dfs(int i, int x, vector<int> v) {
  v.push_back(x);
  if (v.size() == N) {
//    cout << v << endl;
    int score = 0;
    for (auto q : qs) {
      if (v[q.b-1]-v[q.a-1] == q.c) score += q.d;
    }
    return score;
  }

  int vmax = 0;
  for (int j = x; j <= M; ++j) {
    vmax = max(vmax, dfs(i + 1, j, v));
  }
  return vmax;
}

int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; ++i) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    qs.push_back({a, b, c, d});
  }

  int vmax = 0;
  for (int i = 1; i <= M; ++i) {
    vmax = max(vmax, dfs(0, i, {}));
  }
  cout << vmax << endl;
}


Measured memory_bytes: 3600
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

n,a,b = readInts()

if (b-a)%2==0:
	print("Alice")
else:
	print("Borys")

Measured memory_bytes: 9800
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k,x;
    cin >> k >> x;
    repf(i, x - k + 1, x + k) cout << i << " ";
    cout << ENDL;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	char b;
	cin>>b;
	if(b=='A') cout<<'T'<<endl;
	if(b=='G') cout<<'C'<<endl;
	if(b=='C') cout<<'G'<<endl;
	if(b=='T') cout<<'A'<<endl;
	return 0;
}


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

long long cost[100010] = {};
int calc[100010] = {};
int h[100010] = {};

long long jump(int pos, int k) {
    // cout << pos << endl;
    if (calc[pos] == 1) {
        return cost[pos];
    }
    if (pos <= 1) {
        return 0;
    }
    long long min_cost = LONG_MAX;
    for (int i = 1; i <= min(k, pos-1); i++) {
        long long cand_cost = jump(pos - i, k) + abs(h[pos - i] - h[pos]);
        if (min_cost > cand_cost) {
            min_cost = cand_cost;
        }
    }
    // cout << "pos: " << pos << endl;
    // cout << "cost: " << min_cost << endl;
    cost[pos] = min_cost;
    calc[pos] = 1;
    return cost[pos];
}

int main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    h[0] = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        h[i+1] = x;
    }
    cout << jump(n, k) << endl;
    return 0;
}


Measured memory_bytes: 9600
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int MOD;
int bin_pow_mod(int a, int b) {
  int ret = 1;
  while (b > 0) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}
signed main() {
  int N;
  cin >> N >> MOD;
  string S;
  cin >> S;

  if (MOD == 2) {
    int ans = 0;
    rep(i, 0, N) {
      if ((S[i] - '0') % 2 == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  if (MOD == 5) {
    int ans = 0;
    rep(i, 0, N) {
      if (S[i] == '0' || S[i] == '5') {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vi p10inv(N + 1);
  p10inv[0] = 1;
  int inv = bin_pow_mod(10, MOD - 2);
  rep(i, 1, N + 1) { p10inv[i] = p10inv[i - 1] * inv % MOD; }

  int ans = 0;
  map<int, int> cnt;
  cnt[0] = 1;
  int m = 0;
  rep(i, 0, N) {
    m = (m * 10 + S[i] - '0') % MOD;
    int x = p10inv[i] * m % MOD;
    ans += cnt[x];
    cnt[x]++;
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 2580
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> graph(n);
	for( int i = 0; i < n-1; ++i ){
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);		
	}
	vector<int> fennec(n);
	vector<int> snuke(n);
	for( int i = 0; i < n; ++i ){
		fennec.at(i) = -1;
		snuke.at(i) = -1;
	}
	fennec.front() = 0;
	snuke.back() = 0;
	queue<int> q;
	q.emplace(0);
	while( !q.empty() ){
		int cnt = q.front();
		q.pop();
		for( auto i : graph.at(cnt) ){
			if( fennec[i] == -1 ){
				fennec[i] = fennec[cnt]+1;
				q.emplace(i);
			}
		}
	}
	q.emplace(n-1);
	while( !q.empty() ){
		int cnt = q.front();
		q.pop();
		for( auto i : graph.at(cnt) ){
			if( snuke[i] == -1 ){
				snuke[i] = snuke[cnt]+1;
				q.emplace(i);
			}
		}
	}
	ll fennecpoint = 0; 
	ll snukepoint = 0;
	for( int i = 1; i < n-1; ++i ){
		if( snuke[i] >= fennec[i] ){
			++fennecpoint;
		} else { 
			++snukepoint;
		}
	}
	cout << ( fennecpoint > snukepoint ? "Fennec" : "Snuke" ) << endl;
	return 0;
}

Measured memory_bytes: 6528
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	vector<LL> A(N);
	vector<bool> use(N,false);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	for(int i=N-K;i<N;++i){
		use[i] = true;
	}
	LL ans = LINF;
	do{//見えるものを決めてコストを計算する
		LL MAX = 0;
		LL res = 0;
		for(int i=0;i<N;++i){
			if( use[i] ){
				if( MAX < A[i] ){
					MAX = A[i];
				}else{
					res += MAX-A[i]+1;
					MAX = MAX+1;
				}
			}else{
				if( MAX < A[i] ){//見えちゃう
					res = LINF;
					break;
				}
			}
		}
		ans = min(ans,res);
	}while( next_permutation(use.begin(),use.end()) );
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

vector<int> adj[MAXN];

ll arr[MAXN];

ll e[MAXN];

int n;

bool calc(vector<ll> vv, int lim) {
	vv.pb(lim);
	ll sum = 0;

	for (ll x : vv) {
		sum += x;
	}

	if (sum & 1) {
		return 0;
	}
	
	sum /= 2;

	for (ll x : vv) {
		if (x > sum) {
			return 0;			
		}
	}

	return 1;
}

bool dfs(int v, int pr) {
	if (adj[v].size() == 1) {
		e[v] = arr[v];
		return 1;
	}

	ll sum = 0, mx = 0;
	vector<ll> vv;

	for (int to : adj[v]) {
		if (to == pr) {
			continue;
		}

		if (!dfs(to, v)) {
			return 0;
		}

		vv.pb(e[to]);       
	}

	sort(all(vv));

	for (ll x : vv) {
		sum += x;
	}	

	e[v] = arr[v] * 2 - sum;

	if (e[v] < 0) {
		return 0;
	}

	if (pr == -1 && e[v] != 0) {
		return 0;
	}	
                 
	return calc(vv, e[v]);
}

void solve() {                   
	scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
    	scanf("%lld", &arr[i]);
    }    

    if (n == 2) {
		printf(arr[1] == arr[2] ? "YES\n" : "NO\n");
		return;
    }

    for (int i = 1, u, v; i < n; ++i) {
    	scanf("%d %d", &u, &v);
    	adj[u].pb(v);                                      
    	adj[v].pb(u);
    }

    int root = -1;

    for (int i = 1; i <= n; ++i) {
    	if (adj[i].size() > 1) {
    		root = i;
    		break;
    	}
    }
    
    printf(dfs(root, -1) ? "YES\n" : "NO\n");  
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }

int main(){
    int n;
    cin >> n;
    double p[3010];
    rep(i,n){
        cin >> p[i];
    }
    double dp[3100][3100];
    rep(i,3010){
        rep(j,3010){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        rep(j,n+1){
            if(j==0){
                dp[i][j]=dp[i-1][j]*(1-p[i-1]);
            }
            else{
                dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
            }
        }
    }
    double ans = 0;
    int middle = n/2+1;
    for(int i = middle;i<=n;i++){
        ans += dp[n][i];
    }
    printf("%.16lf\n",ans);
    return 0;
}



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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    auto ans = "No";
    if (s < t) {
        ans = "Yes";
    }

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


Measured memory_bytes: 256
#D
import math
a,b,x = map(int, input().split())

#print(x / (a**2))

#print(2*(a**2 * b - x) / a**3)

if (a**2 * b) <= x:
    print(0)

else:

    if ((a*b)/2) > x/a:
        print( math.degrees(math.atan( (a* b**2) / (2 * x) ) ) )
    else:
        print(math.degrees(math.atan(2*(a**2 * b - x) / a**3)))


Measured memory_bytes: 3060
use std::io;
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn str_join<T : std::string::ToString>(s: &Vec<T>) -> String {
    s.iter()
        .map(|i| i.to_string())
        .collect::<Vec<_>>()
        .join(" ")
}
fn main() {
    let _n : usize = read();
    let mut a : Vec<usize> = read_vec();
    a.reverse();
    println!("{}", str_join(&a));
}



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

int main(){
  int n;
  cin >> n;
  int x;
  cin >> x;
  
  int i;
  int a[1000];
  int sum1;
  sum1=0;
  
  int syou;
  syou=10000;
  
  for(i=0;i<n;i++){
    cin >> a[i];
    sum1+=a[i];
    syou=min(syou,a[i]);
  }
  
  int amari;
  amari=x-sum1;
  
  int tugi;
  tugi=amari/syou;
  
  cout << n+tugi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll A,B,Q;
  cin>>A>>B>>Q;
  vector<ll> S(A+2),T(B+2);
  S[0]=-INF,T[0]=-INF;
  RREP(i,A) cin>>S[i];
  RREP(i,B) cin>>T[i];
  S[A+1]=INF,T[B+1]=INF;
  
  REP(i,Q){
    ll X,ans=INF;
    cin>>X;
    
    auto itA=lower_bound(ALL(S),X);
    auto itB=lower_bound(ALL(T),X);
    ll AA=itA-S.begin(),BB=itB-T.begin();
    ll a=S[AA-1],b=T[BB-1],aa=S[AA],bb=T[BB];
    
    // 常にa<bとなるようにする
    if(a>b){
      swap(a,b);
      swap(aa,bb);
    }
    
    chmin(ans,X-a);
    if(aa<bb){
      chmin(ans,aa-b+min(aa-X,X-b));
      chmin(ans,bb-X);
    }
    else{
      chmin(ans,aa-X);
    }
    
    cout<<ans<<endl;
  }
  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1, t2 = h2 * 60 + m2;
    cout << (t2-k-t1) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n, -1);
    vector<int> ans(n);
    auto bfs = [&](int s) -> void {
        queue<int> que;
        dist[s] = 0;
        que.push(s);
        while(!que.empty()) {
            int cur = que.front();
            que.pop();
            for(auto &to : g[cur]) {
                if(dist[to] == -1) {
                    ans[to] = cur;
                    dist[to] = dist[cur] + 1;
                    que.push(to);
                }
            }
        }
    };
    
    bfs(0);
    rep(i,n) {
        if(dist[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    repf(i,1,n) {
        cout << ans[i]+1 << endl;
    }
    return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    ll n,k; cin >> n >> k;
    ll res = n%k;
    ll ans = min(res, abs(res-k));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int number,i,j,sum=0;
	scanf("%d",&number);
	int point[number];
	for(i=0;i<number;i++)
	{
	scanf("%d",&point[i]);
	}
	for(i=0;i<number;i++)
	{
		for(j=0;j<i;j++)
			sum+=point[i]*point[j]; 
	}
	printf("%d",sum);
	return 0;
 } 

Measured memory_bytes: 128
from sys import argv

debug = "a" in argv
n = int(input())
a = tuple(map(int, input().split()))
ans = 0
for x in range(n - 2):
    if debug:
        print(x, a[x], a[x + 1], a[x + 2])
    if sorted([a[x], a[x + 1], a[x + 2]])[1] == a[x + 1]:
        ans += 1
print(ans)

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	pair<long long,int> a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+n);
	long long ans=0LL;
	int cnt=0;
	for (int i = 0; i < n; ++i)
	{
		if (cnt+a[i].second<=m)
		{
			ans+=(long long)a[i].first*a[i].second;
			cnt+=a[i].second;
		}
		else
		{
			ans+=(long long)a[i].first*(m-cnt);
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]

use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let mut n:u128 = read!();
    let mut a:u128 = 0;
    let mut sum:u128 = 0;
    for i in 0..n {
        let c:u128 = read!();
        a+=c;
        sum+=c*c;
        sum%=2000000014;
        a%=2000000014;
    }
    println!("{}",((a*a)-sum)/2%1000000007);
}

Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if((a + b) > (c + d)){
    cout << "Left" << endl;
  }
  else if((a + b) < (c + d)){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b;
  char op;
  int res;

  while(1){
    scanf("%d %c %d", &a, &op, &b);

    if(op == '?') break;

    if(op == '+'){
      res = a + b;
    }
    else if(op == '-'){
      res = a - b;
    }
    else if(op == '*'){
      res = a * b;
    }
    else if(op == '/'){
      res = a / b;
    }

    printf("%d\n", res);
  }
  
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<int,int> P;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

struct UnionFind{
    vector<int> parent;
    vector<int> sizes;
    UnionFind(int n){
        parent.resize(n);
        sizes.resize(n);
        for(int i = 0; i < n; i++) {
            parent[i] = i;
            sizes[i] = 1;
        }
    }

    int root(int s){
        if(parent[s] == s) return s;
        return root(parent[s]);
    }

    void unionf(int s,int t){
        int rs = root(s);
        int rt = root(t);
        if(rs == rt) return;
        if(sizes[rs] >= sizes[rt]){
            parent[rt] = rs;
            sizes[rs] += sizes[rt];
        }
        else{
            parent[rs] = rt;
            sizes[rt] += sizes[rs];
        }
    }

    int size(int s){
        return sizes[root(s)];
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    vector<P> r(M);
    UnionFind uf(N);
    for(int i = 0; i < M; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        r[i] = make_pair(a,b);
        uf.unionf(a,b);
    }
    int count = 0;
    for(int i = 0; i < M; i++){
        UnionFind uftemp(N);
        for(int j = 0; j < M; j++){
            if(i == j) continue;
            int a = r[j].first;
            int b = r[j].second;
            uftemp.unionf(a,b);
        }
        if(uftemp.size(0) != N) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def fact(n)
  if n == 0
    1
  else
    n * fact(n - 1)
  end
end

def c(n, r)
  return fact(n) / (fact(n - r) * fact(r))
end

def calcCombine(n)
  n = n > 18 ? 36 - n : n
  if n >= 0 and n <= 9
    return c(n + 3, 3)
  elsif n >= 10 and n <= 18
    return c(n + 3, 3) - 4 * c(n - 7, 3)
  else
    return 0
  end
end

input = Array.new()

while (line = gets) != nil
  input.push(line.to_i)
end

for i in input
  puts calcCombine(i)
end

Measured memory_bytes: 6108
// C -  https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;
    cin >> N;
    int a[N],b[N],c[N];
    int dpa[N],dpb[N],dpc[N];
    for(int i=0;i<N;i++){
        cin >>a[i] >> b[i] >> c[i];
    }
    dpa[0]=a[0];
    dpb[0]=b[0];
    dpc[0]=c[0];
    for(int i=1;i<N;i++){
        dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i]);
        dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i]);
        dpc[i]=max(dpb[i-1]+c[i],dpa[i-1]+c[i]);
    }
    cout << max(dpa[N-1],max(dpb[N-1],dpc[N-1])) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;

int main()
{
    string s;
    cin >> s;
    vector<int> f(4, 0);
    for(int i=0; i<s.size(); i++){
        if(s[i]=='W')f[0]=1;
        else if(s[i]=='N')f[1]=1;
        else if(s[i]=='S')f[2]=1;
        else f[3]=1;
    }


    if(f[0]==f[3] && f[1]==f[2]) cout << "Yes";
    else cout << "No";


    

    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  reverse(all(s));
  ll n=s.size();
  string a="dream", b="dreamer", c="erase", d="eraser";
  reverse(all(a));
  reverse(all(b));
  reverse(all(c));
  reverse(all(d));
  ll pos=0;
  while(pos<n){
    if(pos+5<=n && s.substr(pos,5)==a || s.substr(pos,5)==c) pos+=5;
    else if(pos+6<=n && s.substr(pos,6)==d) pos+=6;
    else if(pos+7<=n && s.substr(pos,7)==b) pos+=7;
    else{
      // cout<<pos<<endl;
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll M=1e9+7;
ll a[200005], sum, n, ps[200005];
int main() {
   cin >> n;
   for (int i=0; i<n; i++) cin >> a[i];
   
   ps[n-1]=a[n-1];
   sum=(sum+(a[n-2]%M)*(ps[n-1]%M))%M;
   for (int i=n-2; i>=0; i--) {
       ps[i]=ps[i+1]+a[i];
       sum=(sum+(a[i-1]%M)*(ps[i]%M))%M;
    }
   
   cout << sum;
}

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


int main(){   
    char n;
    cin >> n;
    
    if('A' <= n && n <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[1<<18];
int max1[1<<18], max2[1<<18];

void update(int key, int val) {
      if (val > max1[key]) {
        max2[key] = max1[key];
        max1[key] = val;
      }
      else if (val > max2[key]) {
        max2[key] = val;
      }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, 1<<N) cin >> A[i];
  rep(i, 1<<N) max1[i] = A[i];
  rep(i, N) {
    rep(S, 1<<N) if (((S>>i)&1) == 0) {
      update(S|(1<<i), max1[S]);
      update(S|(1<<i), max2[S]);
    }
  }
  int ans = 0;
  rep(k, 1<<N) {
    if (max2[k] > 0) ans = max(ans, max1[k]+max2[k]);
    if (k) cout << ans << "\n";
  }
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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; }

ll n;
ll a[MAXN];
int main() {
    cin >> n;
    rep(i,n) {
        cin >> a[i];
    }

    sort(a, a+n);

    ll l = 0, r = n-2;
    ll mid;
    ll ans_n = a[n-1];
    while (r-l>1) {
        mid = (l+r)/2;
        if (a[mid] >= ans_n/2) {
            r = mid;
        } else {
            l = mid;
        }
    }
    ll ans_r = ((abs(a[l]-ans_n/2) < abs(a[r]-ans_n/2)) ? a[l] : a[r]);

    cout << ans_n << " " << ans_r << endl;

}



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

ll bc(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
         
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin>>n>>m;
	cout<<(bc(n,2)+bc(m,2))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    string X; cin >> X;
    stack<char> st;
    int N = X.size();

    for (int i = 0; i < N; i++) {
        if (st.empty()) {
            st.push(X[i]);
        }
        else {
            char lhs = st.top();
            if (lhs == 'S' && X[i] == 'T') {
                st.pop();
            }
            else {
                st.push(X[i]);
            }
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>

//#define PI 3.141592653589

using namespace std;


int main()
{
	int n;
	string input;
	int numbers[8];
	int min, max;
	
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> input;
		for (int i=0; i<8; i++)
		{
			numbers[i] = atoi(input.substr(i, 1).c_str());
		}
		sort(numbers, numbers+8);
		
		/*
		for (int i=0; i<8; i++)
		{
			cout << numbers[i] << " ";
		}
		*/
		
		max = 10000000*numbers[7]+1000000*numbers[6]+100000*numbers[5]+10000*numbers[4]+1000*numbers[3]+100*numbers[2]+10*numbers[1]+numbers[0];
		min = 10000000*numbers[0]+1000000*numbers[1]+100000*numbers[2]+10000*numbers[3]+1000*numbers[4]+100*numbers[5]+10*numbers[6]+numbers[7];
		cout << max - min << endl;
	}
	
	return 0;
}

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

void solve() {
    int N;
    cin >> N;
    bool ok = true;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) ok = false;
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <set>

using namespace std;

int main()
{
	multiset<int, greater<int> > n;
	multiset<int>::iterator ite;
	int a;

	for(int i=0; i<5; i++){
		cin >> a;
		n.insert(a);
	}
	int i=0;
	for(ite=n.begin(); i<5; ite++, i++){
		if(i==4){ cout << *ite << endl;}
		else{cout << *ite << " ";}
	}

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <cmath> // 追加

using namespace std;

int main() {
   
    int N;
    cin >> N;
    
    vector<int> count(100010, 0);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        count[a] ++;
    }
    
    int ans = 0;
    for (int i = 1; i < count.size() - 1; i++) {
        int sum = count[i - 1] + count[i] + count[i + 1];
        ans = max(ans, sum);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640