akhauriyash/Code-Regression huggingface dataset:
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
ll n,MOD;
const ll MAX = 1e5+5;
vector<vector<ll>> dp(MAX,vector<ll>(2,-1));
vector<vector<ll>> G(MAX);
vector<ll> ans(MAX);
ll dfs(ll v,ll c,ll pre){
  if(dp[v][c]!=-1) return dp[v][c];
  ll res = 1;
  for(auto nv:G[v]){
    ll tmp = 0;
    if(nv==pre) continue;
    tmp += dfs(nv,1,v);
    if(c==0){
      tmp += dfs(nv,0,v);
    }
    tmp %= MOD;
    res = (res*tmp)%MOD;
  }
  return dp[v][c] = res;
}
void solve(ll v,ll pre){
  ll m = G[v].size();
  vector<ll> pr0(m,1),bc0(m,1);
  vector<ll> pr1(m,1),bc1(m,1);
  ll now_0 = dp[v][0],now_1 = dp[v][1];
  dp[v][0] = dp[v][1] = 1;
  for(ll i=0;i<m;i++){
    ll nv = G[v][i], bnv = G[v][m-1-i];
    dp[v][0] = (dp[v][0] * (dp[nv][0] + dp[nv][1])) % MOD;
    dp[v][1] = (dp[v][1] * dp[nv][1]) % MOD;

    pr0[i] = (dp[nv][0]+dp[nv][1])%MOD;
    bc0[m-1-i] = (dp[bnv][0]+dp[bnv][1])%MOD;

    pr1[i] = (dp[nv][1])%MOD;
    bc1[m-1-i] = (dp[bnv][1])%MOD;
    if(i!=0){
      pr0[i] = (pr0[i]*pr0[i-1])%MOD;
      bc0[m-1-i] = (bc0[m-1-i]*bc0[m-i])%MOD;

      pr1[i] = (pr1[i]*pr1[i-1])%MOD;
      bc1[m-1-i] = (bc1[m-1-i]*bc1[m-i])%MOD;
    }
  }
  ans[v] = dp[v][0];
  for(int i=0;i<m;i++){
    ll nv = G[v][i];
    if(nv==pre) continue;
    ll pre0=dp[v][0],pre1=dp[v][1];
    dp[v][0] = dp[v][1] = 1;
    if(i!=0){
      dp[v][0] = (dp[v][0] * pr0[i-1])%MOD;
      dp[v][1] = (dp[v][1] * pr1[i-1])%MOD;
    }
    if(i!=m-1){
      dp[v][0] = (dp[v][0] * bc0[i+1])%MOD;
      dp[v][1] = (dp[v][1] * bc1[i+1])%MOD;
    }
    solve(nv,v);
    dp[v][0] = pre0;
    dp[v][1] = pre1;
  }
  dp[v][0] = now_0;
  dp[v][1] = now_1;
}
signed main(){
  init_io();
  cin >> n >> MOD;
  vector<ll> x(n-1),y(n-1);
  for(int i=0;i<n-1;i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    G[y[i]].push_back(x[i]);
    G[x[i]].push_back(y[i]);
  }
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  dfs(0,0,-1);
  dfs(0,1,-1);
  solve(0,-1);
  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 34760
# -*- coding: utf-8 -*-

import sys
import os


for s in sys.stdin:
    a, b, c, d, e, f = list(map(int, s.split()))

    delta = a * e - b * d
    if delta == 0:
        break
    else:
        x = 1 / delta * (e * c - b * f)
        y = 1 / delta * (-d * c + a * f)
        print('{:.3f} {:.3f}'.format(x + 0, y + 0))

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll x;
    cin >> x;
    ll y = x/500;
    ll z = x%500;
    cout << y*1000 + 5*(z/5) << "\n";
}

int main()
{
    // FAST_IO;
    // #ifndef ONLINE_JUDGE 
      // OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int L;
str al = "bcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890a";
//str al = "abc";
map<char, int> mp, cnt;

int cntq = 0;
ll ask(str x){
	cntq ++;
	assert(cntq <= 800);
	cout << "? " << x << endl;
	ll res;
	cin >> res;
	return res;
}

bool CMP(str& a, str& b){
	return a.size() < b.size();
}

vector<str> V;
str ins[200];
str Merge(str a, str b){
	//swap(a, b);
	int n = a.size(), m = b.size();
	for(int i = 0; i <= n; i++) ins[i] = "";
	int p = 0;
	for(int i = 0; i < m; i++){
		
		while(true){
			ins[p] += b[i];
			str Q = ins[0];
			for(int j = 1; j <= n; j++){
				Q += a[j - 1];
				Q += ins[j];
			}
			if(p == n) break;
			if((p == n) || (ask(Q) == L - Q.size())) break;
			else {
				ins[p].pop_back();
				p ++;
			}
		}
	}
	str re = ins[0];
	for(int j = 1; j <= n; j++){
		re += a[j - 1];
		re += ins[j];
	}
	return re;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//assert(false);
	str Q="";
	int rc;//, L=-1;
	L = 0;
	for(auto c : al){
		Q = "";
		for(int i = 0; i < 128; i++) Q += c;
		rc = ask(Q);
		cnt[c] = 128 - rc;
		L += cnt[c];
	}
	for(auto c : al){
		if(cnt[c] == 0) continue;
		Q = "";
		for(int i = 0; i < cnt[c]; i++) Q += c;
		V.pb(Q);
	}
	while(V.size() > 1){
		sort(all(V), CMP);
		V[1] = Merge(V[0], V[1]);
		V.erase(V.begin());
	}
	cout << "! " << V[0] << endl;
	return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << 2. * M_PI * r  << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <stack>

using namespace std;

typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> xs(N);
  for(int i = 0; i < N; i++)
  {
	cin >> xs[i];
  }

  vector<int> vs;
  for(int i = 0; i < N; i++)
  {
	vs.push_back(i);
  }

  ll answer = 1;
  stack<ll> s;
  int index = 0;

  for(int i = 0; i < N; i++)
  {
	while(index < N && xs[index] >= 2 * s.size() + 1)
	{
	  s.push(xs[index++]);
	}
	if(index < N)
	{
	  s.push(xs[index++]);
	}
	
	answer *= s.size();
	answer %= 1000000007;
	s.pop();
  }
  cout << answer << endl;
}


Measured memory_bytes: 1912
import bisect
import sys
input = sys.stdin.readline
a,b,q = map(int,input().split())
x = [int(input()) for i in range(a)]
y = [int(input()) for i in range(b)]
osoi = [int(input()) for i in range(q)]
x.sort()
y.sort()
xx = [0]*a
yy = [0]*b
n = 0
for i in range(a):
    while n < b-1 and abs(x[i]-y[n]) > abs(x[i]-y[n+1]):
        n+=1
    xx[i] = abs(x[i]-y[n])
n = 0
for i in range(b):
    while n < a-1 and abs(y[i]-x[n]) > abs(y[i]-x[n+1]):
        n+=1

    yy[i] = abs(y[i]-x[n])

for i in range(q):
    z = osoi[i]
    ans = 1<<61
    n = bisect.bisect_left(x, z)
    if n<a:
        tmp = abs(x[n]-z)+xx[n]
        ans = min(ans,tmp)
    if n>0:
        tmp = abs(x[n-1]-z)+xx[n-1]
        ans = min(ans,tmp)

    n = bisect.bisect_left(y, z)
    if n<b:
        tmp = abs(y[n]-z)+yy[n]
        ans = min(ans,tmp)
    if n>0:
        tmp = abs(y[n-1]-z)+yy[n-1]
        ans = min(ans,tmp)
    print(ans)

Measured memory_bytes: 94044
#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int l_max = 0;
    int r_min = N;
    for(int i = 0; i < M; i++){
        int L, R;
        cin >> L >> R;
        l_max = max(l_max, L);
        r_min = min(r_min, R);
    }
    cout << max(0, r_min-l_max+1) << endl;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
long long n,ans=9223372036854775807;
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i*i<=n;i++)
	if(n%i==0) ans=min(i+n/i-2,ans);
	printf("%lld",ans);
	return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n; cin >> n;
    int p = 2;
    int ans = 0;
    for(int i = 1; i <= 30; i++){
        // cout << p << "\n";
        if(p <= n){
            ans = p;
        }
        p*=2;
    }
    cout << ans <<"\n";
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 


int main() {
    ll n, a, b;
    cin >> n >> a >> b; 
    ll ia = n / (a+b);
    ll pa = n % (a+b);
    ll ret = ia * a + min(pa, a);
    cout << ret << endl;
}

Measured memory_bytes: 256
#https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/3/ALDS1_3_D

s = str(input())
l = len(s)

h = [0]
for i in range(l):
    if s[i] == '\\':
        h.append(h[i]-1)
    elif s[i] == '/':
        h.append(h[i]+1)
    else:
        h.append(h[i])

a = []
m = -200000
n = 0
for i in range(l+1):
    if m == h[i] and i != 0:
        a.append([n,i,m])
        m = -200000
    if m < h[i] or i == 0:
        m = h[i]
        n = i
    if (m in h[i+1:]) == False:
        m = -200000

b = []
tmp = 0
for i in range(len(a)):
    for j in range(a[i][0],a[i][1]):
        tmp += a[i][2] - h[j]
        if s[j] == '/':
            tmp += 1 / 2
        elif s[j] == '\\':
            tmp -= 1 / 2
    b.append(int(tmp))
    tmp = 0

if len(b) != 0:
    i=0
    while True:
        if b[i] == 0:
            del b[i]
            i -= 1
        i += 1
        if i == len(b):
            break


A = sum(b)
k = len(b)

print(A)
print(k,end = '')
if k != 0:
    print(' ',end='')
    for i in range(k-1):
        print(b[i],end=' ')
    print(b[len(b)-1])
else:
    print('')



Measured memory_bytes: 8428
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) { //にぶたんgreater
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

vector<ll> Divisor(ll x) { // 約数列挙
	vector<ll> result;
	ll i=1LL;
	for( ; i*i<x; i++) {
		if(x%i) continue;
		result.push_back(i);
		result.push_back(x/i);
	}
	if(i*i==x&&x%i==0)
		result.push_back(i);
	
	sort(result.begin(),result.end());
	return result;
}

vector<llpair> PrimeFact(ll x) { // 素因数分解 {素因数,指数}
	vector<llpair> result;
	ll ex=0LL;
	if(x%2==0) {
		while(x%2==0) {
			x/=2;
			ex++;
		}
		result.push_back({2,ex});
	}

	for(ll i=3LL; i*i<=x; i+=2) {
		if(x%i) continue;

		ex=0LL;
		while(x%i==0) {
			x/=i;
			ex++;
		}
		result.push_back({i,ex});
	}

	if(x!=1) result.push_back({x,1});

	return result;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int main() {
	int N,M; cin>>N>>M;
	int A[N]; for(int i=0; i<N; i++) cin>>A[i];
	int sum=accumulate(A,A+N,0);
	gsort(A,A+N);

	for(int i=0; i<M; i++) {
		if(sum>A[i]*4*M) {
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> ss(n,0);//0からiまでのi+1文字を使って作れる個数。
  ss.at(0)=0;
  rep(i,n-1){
    ss.at(i+1)=ss.at(i);
    if(s.at(i)=='A'&&s.at(i+1)=='C')ss.at(i+1)++;
  }
  rep(i,q){
    int a,b;
    cin >> a >> b;
    cout<<ss.at(b-1)-ss.at(a-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
long long nibeki(long long a){
    long long t = 1;
    int cnt = 0;
    while(a > t){
        t = 2*t;
        cnt++;
    }
    return cnt;
}
long long nibekii(int a){
    long long k = 1;
    rep(i,a){
        k*=2;
    }
    return k;
}
int main(){
    long long l;
    cin >> l;
    int n = nibeki(l);
    vector<vector<long long>>ans;
    vector<long long> tem;
    rep(i,n-1){
        tem = {i+1,i+2,nibekii(i)};
        ans.push_back(tem);
        tem = {i+1,i+2,0};
        ans.push_back(tem);
    }
    long long teml = l - nibekii(n-1);
    long long temm = nibekii(n-1);
    for(int i = n-1;i>=1;i--){
        if(teml>=nibekii(i-1)){
            tem = {i,n,temm};
            ans.push_back(tem);
            teml-=nibekii(i-1);
            temm+=nibekii(i-1);
        }
    }
    if(teml == 1){
        tem = {1,n,l-1};
        ans.push_back(tem);
    }
    if(l!=2){
        cout << n << " " << ans.size() << endl;
        rep(i,ans.size()){
            cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
        }
    }
    else{
        cout << 2 << " " << 2 << endl;
        cout << 1 << " " << 2 << " " << 0 << endl;
        cout << 1 << " " << 2 << " " << 1 << endl;
    }
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: k-DMC
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 1000000;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
int dis[MAX_N], ms[MAX_N + 1], cs[MAX_N + 1];
ll mcs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, q;
  scanf("%d%s%d", &n, s, &q);

  int dn = 0;
  for (int i = 0; i < n; i++) {
    ms[i + 1] = ms[i], cs[i + 1] = cs[i], mcs[i + 1] = mcs[i];
    if (s[i] == 'D')
      dis[dn++] = i;
    else if (s[i] == 'M')
      ms[i + 1]++;
    else if (s[i] == 'C') {
      cs[i + 1]++;
      mcs[i + 1] += ms[i];
    }
  }

  while (q--) {
    int k;
    scanf("%d", &k);

    ll sum = 0;
    for (int i = 0; i < dn; i++) {
      int di = dis[i], dk = min(di + k, n);
      ll dmc = (mcs[dk] - mcs[di]) - (ll)(cs[dk] - cs[di]) * ms[di];
      sum += dmc;
    }
    printf("%lld\n", sum);
  }

  return 0;
}


Measured memory_bytes: 20736
#include <bitset>
#include <iostream>

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

	std::bitset<21> order;

	int prev = 0;
	std::cin >> prev;
	int input = 0;
	for (int i = 1; i < n; ++i)
	{
		std::cin >> input;
		order.set(prev, prev + 1 == input);
		prev = input;
	}

	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> input;
		ans += input;
	}

	for (int i = 1; i < n; ++i)
	{
		std::cin >> input;
		if (order[i])
		{
			ans += input;
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
n = int(input())
 
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1
 
 
while True:
  if is_prime(n):
    print(n)
    break
  else:
    n += 1

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

int main(){
  int n;cin >> n;
  vector<int> b(n-1);
  for (auto &&i : b)cin >> i;
  vector<int> a(n,INT32_MAX);
  for (int i = 0; i < n - 1; i++)
  {
    a.at(i) = min(a.at(i),b.at(i));
    a.at(i + 1) = b.at(i);
  }
  ll ans = 0;
 
  for (auto &&i : a)
  {
    ans += i;
  }
  cout << ans << endl;

  
}

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

void main_()
{
    string S;
    cin >> S;
    bool N_exist = S.find('N') != string::npos;
    bool S_exist = S.find('S') != string::npos;
    bool W_exist = S.find('W') != string::npos;
    bool E_exist = S.find('E') != string::npos;
    if (((N_exist && S_exist) || (!N_exist && !S_exist))
        && ((W_exist && E_exist) || (!W_exist && !E_exist))) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int A,B;
    while(scanf("%d %d",&A,&B)!=EOF)
    {
        if(A>=6&&A<=12)printf("%d\n",B/2);
        else if(A<=5)printf("%d\n",0);
        else printf("%d\n",B);
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

//AtCoder Beginner Contest 055 C
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long s = sc.nextLong();
		long c = sc.nextLong();

		long result = 0;
		if (c <= s * 2) {
			result = c / 2;
			c = c % 2;
		} else {
			result = s;
			c = c - s * 2;
			result = result + c / 4;
		}

		System.out.println(result);
		sc.close();
	}
}

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

using namespace std;

int main(void){

  
 int N, K, Q;

vector<int> A,P,count;

 cin >> N >> K >> Q ;

 for(int i = 0; i < Q ; i++){
   int tmp;
   cin >> tmp;
   A.push_back(tmp);
 }

  for(int i = 0; i < N ; i++){
    P.push_back(K);
    count.push_back(0);
  }

 for(int i = 0; i < Q ; i++){
       count.at(A.at(i)-1)++; 
 }

  for(int i = 0; i < N ; i++){
    P.at(i) =  P.at(i)- Q + count.at(i);
  }



  for(int i= 0; i< N; i++){
    if(P.at(i) > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2296
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

unordered_map<ll, unordered_set<ll>> joint;

unordered_set<ll> even;
unordered_set<ll> odd;

unordered_set<ll> checked;

void foo(ll current, ll depth) {
  if (depth % 2 == 0) even.insert(current);
  else odd.insert(current);
  checked.insert(current);
  for (auto it: joint[current]) {
    if (checked.count(it) > 0) continue;
    foo(it, depth + 1);
  }
}

void solve() {
  ll N;
  cin >> N;
  rep (i, N - 1) {
    ll a, b;
    cin >> a >> b;
    joint[a].insert(b);
    joint[b].insert(a);
  }
  foo(1, 0);

  ll num3k = N / 3;
  ll num3k_1 = (N + 2) / 3;
  ll num3k_2 = (N + 1) / 3;

  unordered_set<ll> smaller, larger;
  if (even.size() < odd.size()) {
    smaller = even;
    larger = odd;
  } else {
    smaller = odd;
    larger = even;
  }

  // cerr << smaller.size() << ", " << larger.size() << endl;

  map<ll, ll> ans;
  unordered_set<ll> rest;
  for (ll i = 1; i <= N; i++) rest.insert(i);

  if (smaller.size() <= num3k) {
    ll tmp = 0;
    for (auto it: smaller) {
      tmp += 3;
      ans[it] = tmp;
      rest.erase(tmp);
    }
    for (auto it: larger) {
      ans[it] = *rest.begin();
      rest.erase(rest.begin());
    }
  } else {
    ll tmp = -2;
    for (auto it: smaller) {
      tmp += 3;
      if (tmp > N) tmp = 3;
      ans[it] = tmp;
      rest.erase(tmp);
    }
    for (auto it: larger) {
      ans[it] = *rest.begin();
      rest.erase(rest.begin());
    }
  }
  bool flag = false;
  for (auto it: ans) {
    if (flag) cout << " ";
    flag = true;
    cout << it.second;
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 82704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	enum State{
		START, MOUTH, EYE_A, EYE_B, BODY_A1, BODY_A2, BODY_B1, BODY_B2, MID_A, TAIL_A, TAIL_B1, TAIL_B2, NA;
	}
	
	String snake(String s){
		State state=State.START;
		int length=0;
		
		LOOP:
		for(int i=0;i<s.length();++i){
			char next=s.charAt(i);
			
			switch(state){
			case START:
				if(next=='>') state=State.MOUTH;
				else state=State.NA;
				break;
			case MOUTH:
				if(next=='\'') state=State.EYE_A;
				else if(next=='^') state=State.EYE_B;
				else state=State.NA;
				break;
			case EYE_A:
				if(next=='='){
					state=State.BODY_A1;
					length=0;
				}
				else state=State.NA;
				break;
			case BODY_A1:
				++length;
				if(next=='=') state=State.BODY_A1;
				else if(next=='#') state=State.MID_A;
				else state=State.NA;
				break;
			case MID_A:
				if(next=='=') state=State.BODY_A2;
				else state=State.NA;
				break;
			case BODY_A2:
				--length;
				if(next=='=') state=State.BODY_A2;
				else if(next=='~'&&length==0) state=State.TAIL_A;
				else state=State.NA;
				break;
			case EYE_B:
				if(next=='Q') state=State.BODY_B1;
				else state=State.NA;
				break;
			case BODY_B1:
				if(next=='=') state=State.BODY_B2;
				else state=State.NA;
				break;
			case BODY_B2:
				if(next=='Q') state=State.BODY_B1;
				else if(next=='~') state=State.TAIL_B1;
				else state=State.NA;
				break;
			case TAIL_B1:
				if(next=='~') state=State.TAIL_B2;
				else state=State.NA;
				break;
			default:
				break LOOP;
			}
		}
		
		switch(state){
		case TAIL_A:
			return "A";
		case TAIL_B2:
			return "B";
		default:
			return "NA";
		}

	}
	
	BufferedReader input;
	
	int ni() throws NumberFormatException, IOException{
		return Integer.parseInt(input.readLine());
	}
	
	String ns() throws IOException{
		return input.readLine();
	}
	
	void io(){
		input=new BufferedReader(new InputStreamReader(System.in));
		
		try {
			int n=ni();
			for(int i=0;i<n;++i){
				System.out.println(snake(ns()));
			}
			input.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

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

int main(){
	double l[10], t[10], a, b;
	char c;
	while(cin >> l[0] >> c){
		t[0] = l[0];
		for(int i = 1;i< 10;i++){cin >> l[i] >> c;t[i] = t[i-1] + l[i];}
		cin >> a >> c >> b;
		double tmp = t[9]/(a+b)*a;
		int ans = 1;
		while(tmp > t[ans-1]){
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define MOD 998244353
#define INF 1000000000000000
ll t[3000000]={0};

void update(ll v, ll tl,ll tr,ll pos,ll new_val) {
    if (tl == tr) {
        t[v]= new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2+1, tl, tm, pos, new_val);
        else
            update(v*2+2, tm+1, tr, pos, new_val);
        if(t[2*v+1]>t[2*v+2])
        {
        	t[v]=t[2*v+1];
        }
        else
        	t[v]=t[2*v+2];
    }
}
ll sum(ll v, ll tl, ll tr, ll l, ll r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    ll tm = (tl + tr) / 2;
    if((sum(v*2+1, tl, tm, l, min(r, tm))>sum(v*2+2, tm+1, tr, max(l, tm+1), r)))
    	return sum(v*2+1, tl, tm, l, min(r, tm));
    else return sum(v*2+2, tm+1, tr, max(l, tm+1), r);


}
int main()
{
	
	ll n,m,i,k;
	cin>>n>>k;
	ll a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[300001]={0},j,ans=0;
	for(i=0;i<n;i++)
	{
		ll mini=max(0ll,a[i]-k);
		ll maxi=min(300000ll,a[i]+k);
		ll p=sum(0,0,300000,mini,maxi);
		ans=max(ans,p+1);
		update(0,0,300000,a[i],p+1);
		
	}
	
	cout<<ans;
}


Measured memory_bytes: 14096
main :: IO()
main = do
    n <- getLine
    let s = read n :: Int
    putStrLn $ toResult $ hasNine s

hasNine :: Int -> Bool
hasNine n 
    | (div n 10) == 9 || (mod n 10) == 9 = True
    | otherwise = False

toResult :: Bool -> String
toResult True = "Yes"
toResult False = "No"

Measured memory_bytes: 380
#include<iostream>
#include<map>

#define MOD 10000

using namespace std;

map<int,int>data;

int dp[200][3][3]={0};

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		data[a]=b;
	}
	
	for(int i=1;i<=n;i++){
		map<int,int>::iterator pa;
		bool it=false;
		if(data.find(i)!=data.end()){
			pa=data.find(i);
			it=true;
		}
		
		if(i==1){
			if(it){
				dp[i][pa->second-1][1]=1;
			}
			else {
				for(int j=0;j<3;j++){
					dp[i][j][1]=1;
				}
			}
		}
		else {
			if(it){
				for(int j=0;j<3;j++){
					if(j!=pa->second-1)dp[i][pa->second-1][1]+=dp[i-1][j][1]+dp[i-1][j][2];
					dp[i][pa->second-1][1]%=MOD;
				}
				dp[i][pa->second-1][2]=dp[i-1][pa->second-1][1];
			}
		
			else {
				for(int k=0;k<3;k++){
					for(int j=0;j<3;j++){
						if(j!=k)dp[i][k][1]+=dp[i-1][j][1]+dp[i-1][j][2];
						dp[i][k][1]%=MOD;
					}
					dp[i][k][2]=dp[i-1][k][1];
				}
				
			}
		}
		
	}
	
	int ans=0;
	for(int i=0;i<3;i++){
		ans+=dp[n][i][1]+dp[n][i][2];
	}
	cout<<ans%MOD<<endl;
}	

Measured memory_bytes: 1204
import kotlin.math.round
import kotlin.math.sqrt

fun main() {
    val n = readLine()?.toLong() ?: return
    var t = 0L
    1.until(round(sqrt(n.toDouble())).toInt()).forEach {
        if (n % it == 0L) {
            t += n / it - 1
        }
    }
    println(t.toString())
}


Measured memory_bytes: 34804
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

s = s()[::-1]
n = len(s)
# dp[i][j] := 先頭 i + 1 文字として考えられるもののうち，13 で割ったあまりが j であるものの数
dp = [[0 for _ in range(13)] for _ in range(n)]
# 初期値
if s[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(s[0])] = 1

# dp[i + 1][(10 * j + d) % 13] += dp[i][j]，i桁目がd（違う）
x = 10
for i in range(n - 1):
    if s[i + 1] == "?":
        start = 0
        end = 10
    else:
        start = int(s[i + 1])
        end = int(s[i + 1]) + 1
    for d in range(start, end):
        for j in range(13):
            dp[i + 1][(j + x * d) % 13] += dp[i][j]
            dp[i + 1][(j + x * d) % 13] %= mod
    x = x * 10 % 13

print(dp[n - 1][5] % mod)

Measured memory_bytes: 91736
#include <iostream>
using namespace std;
//3????????°??¨3???????????°??????????????????????????°??????

int main(){

	int n, b;
	char a;
	int card[4][13] = {};

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> a >> b;

		if (a == 'S')
			card[0][b - 1] = 1;
		if (a == 'H')
			card[1][b - 1] = 1;
		if (a == 'C')
			card[2][b - 1] = 1;
		if (a == 'D')
			card[3][b - 1] = 1;
	}


	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			if (card[i][j] == 0){
				switch (i){
				case 0:
					cout << "S " << j + 1 << endl;
					break;
				case 1:
					cout << "H " << j + 1 << endl;
					break;
				case 2:
					cout << "C " << j + 1 << endl;
					break;
				case 3:
					cout << "D " << j + 1 << endl;
					break;						
				}
				
				}
		
		}
	}


	return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  n-=2;
  cout << n*180 << endl;
    
  return 0;     
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        String N = sc.next();
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        int[] m = new int[c.length];
	        int[] mr = new int[c.length];
	        int[] mb = new int[c.length];
	        int[] mg = new int[c.length];
	        for(int i=0;i<c.length;i++) {
	        	if(i!=0) {
	           		mr[i]=mr[i-1];
	           		mb[i]=mb[i-1];
	           		mg[i]=mg[i-1];
	        	}
 	        	if(c[i]=='R') {
	        		m[i]=0;
	           		mr[i]++;
	        	} else if(c[i]=='B') {
	        		m[i]=1;
	           		mb[i]++;
	        	} else {
	        		m[i]=2;
	           		mg[i]++;
	        	}
	        }
	        
	        
	        
	        long ans=0;
	        for(int i=0;i<c.length-2;i++) {
	        	int[] kk=new int[3];
	        	kk[m[i]]++;
	        	for(int j=i;j<c.length-1;j++) {
	        		if(kk[m[j]]==1)continue;
	        		kk[m[j]]++;
	        		if(kk[0]==0) {
	        			ans=ans+mr[c.length-1]-mr[j];
	        			if(2*j-i<c.length&&c[2*j-i]=='R')ans--;
	        		}else if(kk[1]==0) {
	        			ans=ans+mb[c.length-1]-mb[j];
	        			if(2*j-i<c.length&&c[2*j-i]=='B')ans--;	        			
	        		} else {
	        			ans=ans+mg[c.length-1]-mg[j];
	        			if(2*j-i<c.length&&c[2*j-i]=='G')ans--;
	        		}
	        		kk[m[j]]--;
	        	}
	        }
	        
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
}

Measured memory_bytes: 37116
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

ll solve(ll n) {
	if (n % 2) {
		return ((n + 1) / 2) % 2;
	}
	else {
		return ((n / 2) % 2) ^ n;
	}
}

signed main() {
	ll a, b;

	cin >> a >> b;

	a = solve(a - 1);
	b = solve(b);

	cout << (a ^ b) << endl;
}

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

int main(){

    //入力
    int N, K;
    int A[200010];

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

    //処理　バケツを用意種類を数える　多かったら小さい順に並び変えたりする

    int b[200010]; // b[i]にiがいくつあるかを格納している
    int ans=0;

    for(int i=0; i< 200005; i++){
        b[i]=0;
    }

    for(int i = 0; i < N; i++){
        b[ A[i] ] = b[ A[i] ]+1;
    }

    int frag; //今の種類
/*    
    for(int i = 0; i < 200005 ;i++){
        if(b[i] > 0){
            frag++;
        }
    }

    if (frag <= K){
        ans = 0;
    }
*/
/*
        sort(b,b+N);
        int k; // ゼロでないやつ
        k=1;
        while(b[k]==0){
            k++;
        }
        if ((N-k) <= K ){ans = 0;}
        else{
            for(int i=0; i< N-K-k+1;i++){
                ans = ans + b[k+i];
            }
        }
    cout << ans << endl;

*/

    sort(b,b+N, greater<int>());

    int sum=0;
    for(int i=0; i< K; i++){
        sum=sum+b[i];
    }
    
    cout << N-sum << endl;
}

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

includes = False
for r in range(N - M + 1):
    for c in range(N - M + 1):
        matches = True
        for i in range(M):
            for j in range(M):
                if A[r + i][c + j] != B[i][j]:
                    matches = False
        if matches:
            includes = True

print('Yes' if includes else 'No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;

int n,max_dist;
int arr[N],MAX[N];
int dp[N][30];

int bin_search(int l,int val) {
	for(int i=20;i>=0;i--) {
		int r = l + (1<<i);
		if(r>n) continue;
		else {
			if(arr[r] - val <= max_dist) l += (1<<i);
		}
	}
	return l;
}

main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	cin>>max_dist;
	for(int i=1;i<=n;i++) {
		int id = bin_search(i,arr[i]);
		MAX[i] = id;
	}
	for(int i=1;i<=n;i++) dp[i][0] = MAX[i];
	for(int j=1;j<=20;j++) {
		for(int i=1;i<=n;i++) {
			dp[i][j] = dp[dp[i][j-1]][j-1];
		}
	}
	int q;	cin>>q;
	while(q--) {
		int a,b;	cin>>a>>b;
		if(a>b) swap(a,b);
		int ans = 0;
		for(int i=20;i>=0;i--) {
			if(dp[a][i] < b) {
				ans += (1<<i);
				a = dp[a][i];
			}
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a>=c||b>=c){
        out("No");
        return 0;
    }
    if(b*a*4<(c-a-b)*(c-a-b))out("Yes");
    else out("No");
}

Measured memory_bytes: 256
import sys,copy,itertools as it
sys.setrecursionlimit(10000)

dxy = zip([1,0,-1,0],[0,1,0,-1])
def check(A):
    if A[0] == _P[0][0] or A[-1] != c: return False
    for i in xrange(1,len(A)):
        if A[i-1] == A[i]: return False
    return True
    
def rec(x,y,b,c):
    P[y][x] = c
    for dx,dy in dxy:
        nx,ny = x+dx,y+dy
        if 0 <= nx < w and 0 <= ny < h and P[ny][nx] == b:
            rec(nx,ny,b,c)
    
while 1:
    h,w,c = map(int,raw_input().split())
    if h == 0: break
    _P = [map(int,raw_input().split()) for i in xrange(h)]

    ans = 0
    for change in it.product(range(1,7),repeat = 5):
        if not check(change): continue
        P = copy.deepcopy(_P)
        for c in change: rec(0,0,P[0][0],c)
        rec(0,0,P[0][0],0)
        ans = max(ans, sum(p.count(0) for p in P))

    print ans
    

Measured memory_bytes: 4484
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=300005;

int n,a[maxn],t,ans=0x3fffffff;
char s[maxn];

int main(){
    scanf("%d",&n),scanf("%s",s+1);
    for(int i=1;i<=n;i++)
        a[i]=a[i-1]+(s[i]=='E');
    t=a[n];
    for(int i=1;i<=n;i++)
        ans=min(ans,(i-1-a[i-1])+(t-a[i]));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1664
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[] P = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int ans = 0;
            for (var i = 1; i < N - 1; i++)
            {
                if ((P[i] < P[i - 1] && P[i] > P[i + 1]) ||
                    (P[i] < P[i + 1] && P[i] > P[i - 1]))
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[100005];
ll b[100005];
int main(){
   ll n;
   cin>>n;
   ll s=0;
   for(ll i=1;i<=n;i++){
   	for(ll j=1;j<=n;j++){
   		for(ll k=1;k<=n;k++){
   			s+=__gcd(i,__gcd(j,k));
		   }
	   }
   }
   cout<<s;
   
   
   
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    priority_queue<int> pq;
    int tot = 0;
    rep(i, n) {
        int l; cin >> l;
        tot += l;
        pq.push(l);
    }
    if(pq.top() < tot - pq.top()) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3600
package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scanf("%d", &n)

    a := make([]int, n)
    for i := 0; i< n; i++ {
        fmt.Scanf("%d", &a[i])
    }

    maxValue := max(a)
    sum := sumExOneMax(a, maxValue)

    // fmt.Println(maxValue, exMaxList, exListSum)

    if maxValue < sum {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }

}

func max(list []int) int {
    var m int
    for _, v := range list {
        if v > m {
            m = v
        }
    }
    return m
}

func sumExOneMax(list []int, max int) int {
    var s int
    ex := true
    for _, v := range list {
        // 最大値が複数ある場合を考慮。1つ目以外は加算できるようにする
        if ex && max == v {
            ex = false
            continue
        }
        s += v
    }
    return s
}



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

int main() {
  int N, K;
  cin >> N >> K;
  int A[100010];
  for (int i = 0; i < N; i++) cin >> A[i];

  int ans = 1;
  int num = K;
  while (num < N) {
    num += K - 1;
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b, c, d;

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

	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

module Main where

import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
-- import Data.Array.IO
import Data.Maybe
import qualified Data.Map as M
import Control.Monad.ST
import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf
    
solve :: Int -> [[Int]] -> [(Int, (Int, Int))]
solve n lst = toList (search initLog 0) where
    toList (_, l) = tail $ assocs l
    search log x
        | fvt log == 0 = recordB (foldl search (recordF log) (vertices!x))
        | otherwise = log where
            fvt (t, l) = fst (l!x)
            recordB (t, l) = (t+1, l // [(x, (fst (l!x), t))]) 
            recordF (t, l) = (t+1, l // [(x, (t, 0))])
    vertices = array (0, n) [(x, xs)| (x:_:xs) <- (0:n:[1..n]):lst]
    initLog = (0, listArray (0, n) $ (replicate (n+1) (0, 0)))

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' :: (Int, (Int, Int)) -> IO ()
print' (v, (f, b))= printf "%d %d %d\n" v f b

main :: IO() 
main = do
    n <- readIntLn
    l <- replicateM n readIntList
    mapM_ print' $ solve n l



Measured memory_bytes: 4144
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
int p=pow(10,9)+7;

map<int,int> mp;
void fact(int N){
    int M=sqrt(N)/1;
    for(int i=2;i<=M;i++){
        while(N%i==0){
            N/=i;
            mp[i]++;
        }
    }
    if(N!=1)mp[N]++;
}

int main(){
    int N;cin>>N;
    for(int i=2;i<=N;i++){
        fact(i);
    }
    ll ans=1;
    for(auto itr=mp.begin();itr!=mp.end();itr++)
        ans=(ans*(itr->second+1))%p;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  char s[100];
  scanf("%s", s);
  for(int i=0;i<12;++i) {
    printf("%c", s[i]);
    if (i==3) {
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
 
  // 文字が間違ってるかチェック
  for (int i = 0; i < S.length(); i++) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    } 
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3620