akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-20;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[30][30];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&p[i][j]);
	int ret=mod;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		int tmp=0;
		for(int k=0;k<a;k++)for(int l=0;l<b;l++){
			tmp+=p[k][l]*min(ABS(i-k),ABS(j-l));
		}
		ret=min(ret,tmp);
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string S; cin >> S;
    reverse(S.begin(), S.end());
    int cnt = 0, hold = S.size();

    while(cnt < hold){
        //cout << "S.size()= " << S.size() << endl;
        if(S[0]=='r'){
            if(S[1]=='e' and S[2]=='m'){
                if(S[3]=='a' and S[4]=='e' and S[5]=='r' and S[6]=='d'){
                    cnt+=7;
                    S.erase(0,7);
                }else{
                    cout << "NO" << endl;
                    return 0;
                }
            }else if(S[1]=='e' and S[2]=='s'){
                if(S[3]=='a' and S[4]=='r' and S[5]=='e'){
                    cnt+=6;
                    S.erase(0,6);
                }else{
                    cout << "NO" << endl;
                    return 0;
                }
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else if(S[0]=='m'){
            if(S[1]=='a' and S[2]=='e' and S[3]=='r' and S[4]=='d'){
                cnt+=5;
                S.erase(0,5);
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else if(S[0]=='e'){
            if(S[1]=='s' and S[2]=='a' and S[3]=='r' and S[4]=='e'){
                cnt+=5;
                S.erase(0,5);
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;

}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

void fail() {
    cout << "Impossible\n";
    exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    int maxd = 0;
    forn(i, 0, n) {
        int x;
        cin >> x;
        d[x]++;
        maxd = max(maxd, x);
    }
    for (int i = 0, j = maxd; i <= maxd; j -= i % 2, ++i) {
        if (j < 0) fail();
        if (d[j] == 0) fail();
        --d[j];
    }
    int mind = (maxd + 1) / 2;
    fore(i, 0, mind) if (d[i]) fail();
    cout << "Possible\n";
}


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

const int maxS = 1e3 + 7;
char mat[maxS][maxS];
int dp[maxS][maxS];
int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N, M;
    cin >> N >> M;
    for(int i = 1;i <= N;i ++) {
        for(int j = 1;j <= M;j ++) {
            cin >> mat[i][j];
        }
    }
    for(int i = 0;i <= N;i ++) {
        for(int j = 0;j <= M;j ++) {
            dp[i][j] = 0;
        }
    }
    for(int i = 1;i <= N;i ++) {
        for(int j = 1;j <= M;j ++) {
            if(mat[i][j] == '#') {
                dp[i][j] = 0;
                continue;
            }
            if(i == 1 && j == 1) {
                dp[i][j] = 1;
            } else if(i == 1) {
                dp[i][j] = dp[i][j-1];
            } else if(j == 1) {
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]);
                if(dp[i][j] > mod) {
                    dp[i][j] -= mod;
                }
            }
        }
    }
    cout << dp[N][M] << "\n";
}

Measured memory_bytes: 5248
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys


def solve(data):
    result = []
    total_sales = [0 for _ in range(4000+1)]
    for id, unit_price, quantity in data:
        total_sales[id] += unit_price * quantity
        if total_sales[id] >= 1000000:
            if id not in result:
                result.append(id)

    #for i, sales in enumerate(total_sales):
    #    if sales >= 1000000:
    #        result.append(i)
    return result


def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])
    while True:
        num = int(input())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

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

public class Main {
	static final long INF = 2000000000000l;


	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int M = scn.nextInt();
		long L = scn.nextLong();

		long[][] d = new long[N][N];
		for(int i = 0;i < N;i++) {
			Arrays.fill(d[i], INF);
		}
		for(int i = 0;i < M;i++) {
			int A = scn.nextInt()-1, B = scn.nextInt()-1;
			long C = scn.nextLong();
			if(C <= L) {
				d[A][B] = C;
				d[B][A] = C;
			}
		}

		warshall_floyd(d);

		for(int i = 0;i < N;i++) {
			for(int j = 0;j < N;j++) {
				if(d[i][j] <=L) {
					d[i][j] = (d[i][j]==0)?0:1;
				}else {
					d[i][j] = INF;
				}
			}
		}
		warshall_floyd(d);


		int Q = scn.nextInt();
		for(int i = 0;i < Q;i++) {
			int s = scn.nextInt()-1, t = scn.nextInt()-1;
			System.out.println((d[s][t]<INF)?d[s][t]-1:-1);
		}
	}

	public static void warshall_floyd(long[][] d) {//@param d[][]:最初の経路のコスト情報
		int V = d.length;
		for(int i = 0;i < V;i++) {
			d[i][i] = 0;
		}
		for(int k = 0;k < V;k++) {
			for(int i = 0;i < V;i++) {
				for(int j = 0;j < V;j++) {
					if(d[i][k]<INF && d[k][j]<INF)
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
}


Measured memory_bytes: 89976
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,k;
	cin>>n>>k;
	vi co(n+1);
	rep(i,n){
		int a;cin>>a;
		co[a]--;
	}
	sort(all(co));
	int out=n;
	rep(i,k)out+=co[i];
	cout<<out<<endl;
}








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

int main()
{
	int a, b;

	cin >> a >> b;

	int d = a/b;
	int r = a%b;
	double f = 1.0 * a / b;

	cout << d << " " << r << " ";
	cout << fixed << setprecision(5) << f << endl;
}

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = -10e19;
    ans = max(ans, a * c);
    ans = max(ans, b * c);
    ans = max(ans, a * d);
    ans = max(ans, b * d);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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 dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    set<string> st;
    rep(i,n){
        string t;
        cin >> t;
        st.insert(t);
    }
    cout << st.size() << endl;
}

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

#define REP(i, n) for(int i=0; i<(n); i++)

using namespace std;

int zmin(int a, int b){
	if( a==0 ) return b;
	return min(a,b);
}

int main(){
	int n, m, a, b, c, u, t;
	vector<int> v[55];

	cin>>n>>m>>a>>b>>c;
	REP(i, m){
		cin>>u>>t;
		v[t].push_back(u);
	}
	if(a>b) swap(a,b);
	if(b>c) swap(c,b);
	if(a>b) swap(a,b);
	int l[3] = {a,b,c};

	int goal[55] = {}, gcount=0;
	goal[n] = 1;
	while(1){
		int reach[55][2]={};
		REP(i,n+1) if(goal[i]) reach[i][0] = goal[i];
		int len[55][3]={};
		REP(i,c+1){
			REP(j,n) reach[j+1][(i+1)%2] = 0;	// ????????????
			REP(j,n){
				if( reach[j+1][i%2] ){
					for(auto to: v[j+1]){
						reach[to][(i+1)%2] = zmin(reach[to][(i+1)%2], reach[j+1][i%2]);
					}
					if(i == a) len[j+1][0] = reach[j+1][i%2]+1;
					if(i == b) len[j+1][1] = reach[j+1][i%2]+1;
					if(i == c) len[j+1][2] = reach[j+1][i%2]+1;
				}
			}
			//REP(j,n) cout << reach[j+1][i%2] << " ";
			//cout << endl;
		}
		int count=0;
		REP(j,n){
			if( len[j+1][0]>0 && len[j+1][1]>0 && len[j+1][2]>0 ){
				goal[j+1] = zmin( goal[j+1], max( len[j+1][0], max(len[j+1][1], len[j+1][2]) ) );
			}
			if( goal[j+1] ) count++;
		}
		//cout << "count:" << count << endl;
		//cout << "goal: ";
		//REP(j,n) cout << goal[j+1] << " ";
		//cout << endl;
		if( gcount == count ) break;
		gcount = count;
	}
	if( goal[1] == 0 ) cout << "IMPOSSIBLE" << endl;
	else cout << (goal[1]-1) << endl;

	return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <math.h>

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

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

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int ans = min(a, b) + min(c, d);
	printf("%d\n", ans);


	//char buffer[128];
	//scanf("%s", buffer);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TWO(x) (1ULL << x)

template<class T>
class seg_tree{
public:
	static const T invalid = TWO(31) - 1; // ?????¨??????????????????

private:
	vector<T> dat;	ll n;
	
	// [a,b)????????????????°?????????????
	// k     : ?????¨??????????????\????????????
	// [l,r) : k?????????????????????
	T query(ll a, ll b, ll k, ll l, ll r){
		if (r <= a || b <= l) return invalid; //?????????
		if (a <= l && r <= b) return dat[k]; //[l,r) ??? [a,b)

		//[l,r)????????¨???[a,b)???????????????
		ll mid = (l + r) / 2; //[l,mid),[mid,r)
		T lval = query(a, b, k * 2 + 1, l, mid);
		T rval = query(a, b, k * 2 + 2, mid, r);
		return min(lval, rval);
	}
	
	void propagate(ll i){ dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]); }

public:
	seg_tree(ll size){
		n = 1; while(n < size) n <<= 1;
		dat = vector<T>(2 * n - 1, invalid);
	}

	seg_tree(const vector<T> & v){
		n = 1; while(n < v.size()) n <<= 1;
		dat = vector<T>(2 * n - 1, invalid);
		
		REP(i, v.size()) dat[n - 1 + i] = v[i];
		REP(i, n-2) propagate((n-2) - i);
	}
	
	void update(ll k, T val){ // ??????????????£???`dat[k] = val`??¨????????????????????´
		k += n - 1; // seg_tree??????index?????????
		dat[k] = val;
		while(k > 0) propagate(k = (k-1)/2);
	}
	T query(ll a, ll b) { return query(a, b, 0, 0, n); }
};



int main(){
	while (true) {
		ll r,c,q;
		cin >> r >> c >> q;
		if (q == 0) break;

		bool is_reverse = r > c;
		vector<seg_tree<ll>> segs(min(r,c), seg_tree<ll>(max(r,c)));
		REP(i, r) REP(j, c) {
			ll x = i, y = j;
			if (is_reverse) swap(x, y);
			ll grid; cin >> grid;
			segs[x].update(y, grid);
		}


		REP(i, q) {
			ll minimum = seg_tree<ll>::invalid;
			ll x_1, y_1, x_2, y_2;
			cin >> x_1 >> y_1 >> x_2 >> y_2;
			if (is_reverse) swap(x_1, y_1), swap(x_2, y_2);
			REP(i, x_2 + 1 - x_1) minimum = min(minimum, segs[x_1 + i].query(y_1, y_2 + 1));
			cout << minimum << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 33864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

ll digitsum(ll b, ll n) {
  ll ans = 0;
  while (n > 0) {
    ans += n % b;
    n /= b;
  }
  return ans;
}

int main() {
  ll n, s;
  cin >> n >> s;

  if (s > n) {
    cout << -1 << endl;
    return 0;
  }
  if (s == n) {
    cout << n + 1 << endl;
    return 0;
  }

  for (ll i = 2; i * i <= n; i++) {
    if (digitsum(i, n) == s) {
      cout << i << endl;
      return 0;
    }
  }

  ll maxp = sqrt(n - 1);
  for (ll i = maxp; i >= 1; i--) {
    if ((n - s) % i != 0) continue;
    ll b = (n - s) / i + 1;
    if (digitsum(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }
  cout << -1 << endl;






  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 20:57:48 2020

@author: black
"""


N, M = map(int, input().split())
A = list(map(int, input().split()))
SUM = sum(A)

if N-SUM <= -1:
    print(-1)
else:    
    print(N-SUM)

Measured memory_bytes: 10128
#include <bits/stdc++.h>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{
    unsigned ll n;
    cin >> n;
    vector<char> v(n);
    char c;
    unsigned ll wsum = 0, esum = 0;
    rep(i, n)
    {
        cin >> c;
        if (c == 'W') { ++wsum; }
        else
        {
            ++esum;
        }
        v[i] = c;
    }
    unsigned ll ans = ULLONG_MAX;
    unsigned ll ee = 0, ww = 0;
    rep(i, n)
    {
        if (v[i] == 'E') { ++ee; }
        ans = min(ans, ww + (esum - ee));
        if (v[i] == 'W') { ++ww; }
    }
    cout << ans << endl;
    return 0;
}

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
   int H,W,i,j;
   while(1){
   scanf("%d%d",&H,&W);
   if(H==0 && W==0){
    break;
   }
   for(i=1;i<=H;i++)
   {
       for(j=1;j<=W;j++)
       {
            if(i != 1 && i != H && j != 1 && j != W)
              {
                printf(".");
              }
            else {
              printf("#");
            }
       }
       printf("\n");
   }
   printf("\n");
     }
   return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
int A[12][12], row_price[12], alg_und[12];
int N, M, X;
int min_price = 1e9;
bitset<12> is_done_alg;


void solve(const int &cur_row, const int &cur_price)
{
    if (is_done_alg.count() == M)
    {
        min_price = min(min_price, cur_price);
        return;
    }
    if (cur_row == N)
    {
        return;
    }
  
    solve(cur_row + 1, cur_price);

    for (int j = 0; j < M; ++j)
    {
        alg_und[j] += A[cur_row][j];
        if (alg_und[j] >= X)
        {
            is_done_alg[j] = true;
        }
    }

    solve(cur_row + 1, cur_price + row_price[cur_row]);

    for (int j = 0; j < M; ++j)
    {
        alg_und[j] -= A[cur_row][j];
        if (alg_und[j] < X)
        {
            is_done_alg[j] = false;
        }
    }
}


int main()
{
    cin.sync_with_stdio(0);

    cin >> N >> M >> X;

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

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

    solve(0, 0);

    cout << (min_price == 1e9 ? -1 : min_price);
}


Measured memory_bytes: 3624
N,A,B=map(int,input().split())
H=0
K=0
S=input()
for i in range(N):
	if S[i]=="a":
		if K<A+B:
			print("Yes")
			K+=1
		else:
			print("No")
	elif S[i]=="b":
		if K<A+B:
			if H<B:
				print("Yes")
				H+=1
				K+=1
			else:
				print("No")
		else:
			print("No")
	elif S[i]=="c":
		print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%1000000007)

using namespace std;
const int maxn = 1e5 + 7;
LL n, m, ans;
char s[maxn], t[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    cin >> s >> t;
    LL tmp = __gcd(n, m);
    ans = n * m / tmp;
    LL a = ans / n, b = ans / m;
    int i = 0, j = 0;
    while(i < n && j < m)
    {
        if(a*i==b*j && s[i] != t[j])
        {
            cout << "-1";
            return 0;
        }
        if (a*i<b*j) i++;else j++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0)ans+=i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin >> a;
	if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]){
	cout << "No";}
	else{
	if(((a[0]==a[1])&&(a[2]==a[3])) or ((a[0]==a[2]) && (a[1]==a[3])) or ((a[0]==a[3]) && a[1]==a[2])){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
	8
	ABABBABA
										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()
	a := nextInts(n)

	ans := 0
	for i := 1; i < len(a); i++ {
		if a[i-1] > a[i] {
			ans += a[i-1] - a[i]
			a[i] = a[i-1]
		}
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func sign(x int) int {
	if x == 0 {
		return 0
	}
	if x > 0 {
		return 1
	}
	return -1
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}
func divCeil(shi, bo int) int {
	ans := shi / bo
	if shi%bo != 0 {
		ans++
	}
	return ans
}


Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int s;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>0;--i)
    {
    	if(n%i==0)
		{
            ans=n/i;
            break;
        }
	}
    while(ans>0)
	{ 
        s++;
        ans/=10;
    }
    cout<<s; 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int N;
int P[30];
int Q[30];
int ans;
int X[16];
void swap1(){
	swap(P[0],P[27]);
	swap(P[1],P[28]);
	swap(P[2],P[29]);
	swap(P[14],P[15]);
	swap(P[18],P[20]);
}
void swap2(){
	swap(P[0],P[23]);
	swap(P[3],P[26]);
	swap(P[6],P[29]);
	swap(P[9],P[20]);
	swap(P[15],P[17]);
}
void swap3(){
	swap(P[6],P[21]);
	swap(P[7],P[22]);
	swap(P[8],P[23]);
	swap(P[12],P[17]);
	swap(P[9],P[11]);
}
void swap4()
{
	swap(P[2],P[21]);
	swap(P[5],P[24]);
	swap(P[8],P[27]);
	swap(P[11],P[18]);
	swap(P[12],P[14]);
}
bool solve()
{
	for(int i=0;i<9;i++)if(P[0]!=P[i])return false;
	for(int i=9;i<12;i++)if(P[9]!=P[i])return false;
	for(int i=12;i<15;i++)if(P[12]!=P[i])return false;
	for(int i=15;i<18;i++)if(P[15]!=P[i])return false;
	for(int i=18;i<21;i++)if(P[18]!=P[i])return false;
	for(int i=21;i<30;i++)if(P[21]!=P[i])return false;
	return true;
}
int main()
{
	scanf("%d",&N);
	for(int Case=0;Case<N;Case++){
		ans=10;
		for(int i=0;i<30;i++)scanf("%d",&Q[i]);
		for(int j=0;j<30;j++)P[j]=Q[j];
		if(solve())ans=0;
		for(int i=0;i<(1<<16);i++){
			for(int j=0;j<30;j++)P[j]=Q[j];
			int I=i;
			for(int j=0;j<16;j++){
				X[j]=I&1;
				I=I>>1;
			}
			for(int k=0;k<8;k++){
				int s=X[2*k]*2+X[2*k+1];
				if(s==0)swap1();
				if(s==1)swap2();
				if(s==2)swap3();
				if(s==3)swap4();
				if(solve()){
					ans=min(ans,k+1);
					break;
				}	
			}	
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1192
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long

int main(void)
{
	int n;
	scanf("%d", &n);
	n %= 1000;
	printf("%d\n", (1000 - n) % 1000);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<int> a(n);
    int i,j;
    int tmp;
    for(i=0;i<n;i++)cin >> a.at(i);
    for(i=0;i<n;i++){
        for(j=1;j+i<n;j++){
            if(a.at(i)<a.at(i+j)){
                tmp=a.at(i);
                a.at(i)=a.at(i+j);
                a.at(i+j)=tmp;
            }
        }
    }
    int s,t;
    s=0;t=0;
    vector<int> A(50),B(50);
    for(i=0;i<a.size();i++){
        if(i%2==0)
        s+=a.at(i);
        else
        t+=a.at(i);
    }
    cout << s-t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include<algorithm>
#define pf printf
#define sf scanf
#define wh while
#define db double
#define LL long long
#define _USE_MATH_DEFINES
#define re(i,a,b) for(int i=a;i<b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
bool my(int i,int j){return (i>j);}
int main()
{
    int a[10];
    re(i,0,10)sf("%d",&a[i]);
    sort(a,a+10,my);
    re(i,0,3)pf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#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()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	int ans = inf;
	rep(bit, (1 << n)) {
		vector<int> tmp(m);
		rep(i, n) {
			if (!(bit & (1 << i))) continue;
			rep(j, m) {
				tmp[j] += a[i][j];
			}
		}
		bool ok = true;
		for (auto& c : tmp) if (c < x) ok = false;
		int cnt = 0;
		rep(i, n) if (bit & (1 << i)) cnt += c[i];
		if (ok) mins(ans, cnt);
	}
	if (ans == inf) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int tmp;
  int pre = 0;
  for(int i=0; i<n; i++){
    cin >> tmp;
    if(tmp==pre){pre = tmp;}
    else if((tmp-1)>=pre){pre = tmp-1;}
    else{cout << "No" << endl;return 0;}
    //cout << pre << endl;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n, x, m; cin >> n >> x >> m;
    ll sum = 0, more = 0, bef = 0, shu = 0, bef_long = 0, shu_long = 0;
    vector<ll> shu_v, A(m+1);
    map<ll, ll> mp;
    bool found = false, shuuki = false;
    Rep(i, 1, n+1){
        if(i == 1) A[i-1] = x;
        else A[i-1] = A[i-2]*A[i-2] % m;
        ll tmp = A[i-1];
        mp[tmp]++;
        if(mp[tmp] == 2){
            if(!shuuki) bef_long = i-1;
            shuuki = true;
            shu += tmp;
            sum += tmp;
            shu_v.push_back(tmp);
        }
        else if(mp[tmp] == 3){
            shu_long = i - bef_long - 1;
            found = true;
            break;
        }
        else{
            sum += tmp;
            bef += tmp;
        }
    }
    if(mp.count(0) || !found){
        cout << sum << endl;
        return 0;
    }
    rep(i, (n-bef_long)%shu_long){
        more += shu_v[i];
    }
    cout << bef + shu * ((n-bef_long)/shu_long) + more << endl;
}


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

int main() {
    int R, G, B, N, cnt = 0;

    cin >> R >> G >> B >> N;

    for (int i = 0; i <= N / R; i++) {
        for (int j = 0; j <= (N - R * i) / G; j++) {
            int tmp = N - R * i - G * j;
            if (tmp >= 0 && tmp % B == 0) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
 
using namespace std;
 
typedef pair<int, int> P;

const int N = 100000;
int dp[N+10][2];
int step[N+10];

int main(){
	string s;
	while(cin >> s, s != "#"){
		int n = s.size();
		rep(i, n){
			step[i] = (s[i]-'0')%3;
			if(!step[i]) step[i] = 3;
		}
		rep(i, 2) rep(j, N+10) dp[j][i] = 1<<29;
		dp[0][0] = dp[0][1] = 0;
		FOR(i, 1, n){
			if(step[i-1] <= step[i]) dp[i][0] = min(dp[i-1][0]+1, dp[i-1][1]);
			if(step[i-1] >= step[i]) dp[i][1] = min(dp[i-1][1]+1, dp[i-1][0]);
		}
		cout << min(dp[n-1][0], dp[n-1][1]) << endl;
	}
	

	return 0;
}

Measured memory_bytes: 2488
using namespace std;

#include <iostream>
#include <vector>
#include <algorithm>

int main(
){
    int     K = 0;
    int     N = 0;
    int     i = 0;
    int     ans = 0;
    vector<int>     A;
    vector<int>     distance;

    std::cin >> K >> N;
    A.resize(N);
    distance.resize(N);
   for(i = 0; i<N; i++){
        std::cin >> A[i];
    }

    for(i = 0; i<N; i++){
        if(i != N-1){
            distance[i] = A[i+1] - A[i];
        }else{
            distance[i] = K-A[i] + A[0];
        }
    }

    std::sort(distance.begin(), distance.end(), std::greater<int>());
    ans = K - distance[0];
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
    #define REP(i, n) for(int i = 0; i < int(n); i++)
    #define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
    using namespace std;
    typedef long long ll;
    const int MOD = 1e9 + 7;
    const int INF = 1e9 + 6;
    const ll LLINF = 1e18 + 1;
     
    int main() {
        int n, t; cin >> n >> t;
        vector<pair<int,int>> p(n);
        REP(i, n) cin >> p[i].first >> p[i].second;
        sort(p.begin(), p.end());
        // dp[i][j] : iまででj以内に食べるときの最大値
        vector < vector < ll >> dp(n + 1, vector<ll>(t + 1,0));
        REP(i, n) {
            REP(j, t+1) {
                dp[i + 1][j] = dp[i][j];
                if (j - p[i].first >= 0) dp[i + 1][j] = max(dp[i+1][j],dp[i][j - p[i].first] + p[i].second);
            }
        }
        ll ans = 0;
        REP(i, n) {
            REP(j, t) {
                ans = max({ans, dp[i][j] + p[i].second,dp[i + 1][j]});
            }
        }
        cout << ans << endl;
        return 0;
    }

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){


}


void solve(){

    int n,m,k;
    cin >> n >> m >> k; 
    ll a[n+1];
    ll b[m+1];
    for(int i=1;i<n+1;i++){
        cin >> a[i];
    }
    ll pre[m+1];
    pre[0] = 0;
    for(int i=1;i<m+1;i++)
        cin >> b[i] , pre[i] = pre[i-1] + b[i];
    vector<ll> dp(n+m+1,oo);
    dp[0] = 0;
    ll cur=0;
    for(ll i=0;i<n+1;i++){
        if(i)cur += a[i];
        if(cur > k)break;
        ll rem = k - cur;
        ll pos = upper_bound(pre+1,pre+m+1,rem) - pre;
        pos--;
        dp[i + pos] = min(dp[i + pos] , cur + pre[pos] );
    }
    ll ans=0;
    for(int i=1;i<=m+n;i++){
        if(dp[i] <= k)
            ans = max(ans , (ll)i);
    }
    cout << ans << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 11128
import sys
input = sys.stdin.readline

def dijkstra(edge_adj: list, node: int, start: int) -> list:
    # graph[node] = [(cost, to)]
    inf = 3 * 10 ** 9
    dist = [inf] * node
    used = [False] * node

    dist[start] = 0
    while True:
        v = -1
        for i in range(node):
            if not used[i] and (v == -1 or dist[v] > dist[i]):
                v = i

        if v == -1:
            break

        used[v] = True
        for i in range(node):
            if dist[i] > dist[v] + edge_adj[v][i]:
                dist[i] = dist[v] + edge_adj[v][i]

    return dist
    # dist = [costs to nodes]

xs, ys, xt, yt = map(int, input().split())
n = int(input())
circles = [(xs, ys, 0), (xt, yt, 0)]
for i in range(n):
    circles.append(tuple(map(int, input().split())))
n += 2

edges = [[0] * n for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        dist = ((circles[i][0] - circles[j][0]) ** 2 + (circles[i][1] - circles[j][1]) ** 2) ** 0.5
        cost = max(0, dist - circles[i][2] - circles[j][2])
        edges[i][j] = cost
        edges[j][i] = cost


dist = dijkstra(edges, n, 0)

print(dist[1])


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,x,a[N],ans=1,p;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>x;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		p+=a[i];
		if(p<=x)ans++;
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = input()
X = list(map(int, input().split()))
x = 0

for i in X:
  if i % 2 == 0 and (i % 3 != 0 and i % 5 != 0):
    x += 1
    
    
  else:
    x += 0
    
if x >= 1:
  print("DENIED")
  
else:
  print("APPROVED")
    
    


Measured memory_bytes: 2940
n = int(input())
D,X = map(int,input().split())
A = [int(input()) for _ in range(n)]
#print(A)
ref = 0
count = [0]*len(A)
for i in range(len(A)):
    ref = 0
    #print(count[i],A[i],i)
    while True:
        ref = count[i]*A[i]+1
        if ref <= D:
            count[i]+=1
        else:
            break
#print(count)
print(sum(count)+X)

Measured memory_bytes: 9072
#include<iostream>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int N, T, A;
    cin >> N >> T >> A;
    double d = 1000;
    int e = 0;
    vector<int> vec(N);
    vector<double> gap(N);
    rep(i, N){
        cin >> vec[i];
        if((T - vec[i]*0.006 - A)>0){
            gap[i] = T - vec[i]*0.006 - A;
        }
        else gap[i] = -(T - vec[i]*0.006 - A);
        if(d>gap[i]) e = i+1;
        d = min(d,gap[i]);
        
    }
    cout << e;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    size_t n;
    cin >> n;
    vector<lli> a(n + 1, 0);
    lli Sa = 0;
    for(size_t i = 1; i <= n; ++i){
        cin >> a[i];
        Sa += a[i];
    }
    // a[0] = a[n];

    vector<lli> b(n + 1, 0);
    
    
    lli sub = 0;
    for(size_t i = 2; i < n; i += 2){
        sub += a[i];   
    }
    

    for(size_t i = 1; i <= n; ++i){
        if(i == 1){
            b[i] = Sa - 2 * sub;
        }else{
            b[i] = 2 * a[i - 1] - b[i - 1];
        }
        char c = (i == n)? '\n' : ' ';
        cout << b[i] << c;
    }
    
    return 0;
}

Measured memory_bytes: 2944
//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;
const ll inf = 1e9, N = 1e4+5;
const ll INF = 1e18, MOD = 1e9+7;
ll power(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll gcd(ll a,ll b){if(b>a)swap(a,b);if(!b)return a;return gcd(b,a%b);}

int n, a[N], ans;

int main(){
    FIO;
    cout << setprecision(10) << fixed;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        while(!(x % 2) && x > 0)
            ++ans, x /= 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>adj[100005];
ll dfs(ll x,ll p=-1){
	ll xo=0;
	for(auto it:adj[x]){
		if(it!=p){
			xo^=dfs(it,x);
		}
	}
	return 1+xo;
}
int main(){
	ll n;
	cin>>n;
	for(ll i=1;i<n;i++){
		ll a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	ll ans=dfs(1);
	ans--;
	//cout<<ans<<endl;
	if(ans==0)cout<<"Bob"<<endl;
	else cout<<"Alice"<<endl;
}

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

using namespace std;

int toint(char c)
{
  if(c == 'S')
    return 0;
  if(c == 'H')
    return 1;
  if(c == 'C')
    return 2;
  if(c == 'D')
    return 3;
}
char tochar(int n)
{
  if(n == 0)
    return 'S';
  if(n == 1)
    return 'H';
  if(n == 2)
    return 'C';
  if(n == 3)
    return 'D';
}


bool state[4][14];
int main()
{
  int n;
  char m;
  int d;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> m >> d;
    state[toint(m)][d] = true;
  }

  for(int i = 0; i < 4; i++)
  {
    for(int j = 1; j <= 13; j++)
    {
      if(!state[i][j])
        cout << tochar(i) << " " << j << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, Near[101000], M;
long long A, B;
long long w[101000], BIT[101000], Mod = 1000000007, D[101000];
void Ins(int a, long long b){
    a++;
    while(a<=M){
        BIT[a] = (BIT[a]+b)%Mod;
        a+=(a&-a);
    }
}
long long Sum(int a){
    long long r = 0;
    a++;
    while(a){
        r = (r+BIT[a])%Mod;
        a-=(a&-a);
    }
    return r;
}
int main(){
    int i, pv = 0, pv2 = 0;
    scanf("%d%lld%lld",&n,&A,&B);
    M = n+2;
    if(A>B)swap(A,B);
    for(i=1;i<=n;i++){
        scanf("%lld",&w[i]);
        if(i>=2 && w[i]-w[i-1] < A) Near[i-1] = 1;
    }
    w[n+1] = 3e18;
    Ins(0,1);
    D[0] = 1;
    for(i=1;i<=n+1;i++){
        while(pv2 + 1 <= i && w[i] - w[pv2+1] >= B) pv2++;
        if(i>=3 && Near[i-2]){
            pv = i-2;
        }
        if(i>=4 && w[i-1] - w[i-3] < A){
            Ins(i-2, Mod-D[i-2]);
        }
        if(pv2 >= pv - 1) D[i] = (Sum(pv2) - Sum(pv - 1) + Mod)%Mod;
        else D[i] = 0;
        Ins(i, D[i]);
    }
    printf("%lld\n",D[n+1]);
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[105],b[105];
int main(){
    int n,sum=0;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>b[i];
    }
    sum=b[1]+b[n-1];
    for(int i=1;i<n;i++){
        sum+=min(b[i],b[i+1]);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func max(nums []int) int {
	max := nums[0]
	for _, v := range nums {
		if max < v {
			max = v
		}
	}
	return max
}

func sum(nums []int) int {
	sum := 0
	for _, v := range nums {
		sum += v
	}
	return sum
}

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)
	for i := range nums {
		fmt.Scan(&nums[i])
	}

	max := max(nums)
	sum := sum(nums) - max

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


Measured memory_bytes: 512
a = int(input())
s = input()
l = len(s)
target = [None for x in s]
target[0] = True
target[1] = True


def fill(b, n, i):
    if s[i] == "o":
        target[b] = target[n] if target[i] else not target[n]
    else:
        target[b] = not target[n] if target[i] else target[n]


def jud(b, n, i):
    if s[i] == "o":
        return target[b] == (target[n] if target[i] else not target[n])
    else:
        return target[b] == (not target[n] if target[i] else target[n])
    

def result(s1, s2):
    global target
    target = [None for x in s]
    target[0] = s1
    target[1] = s2
    for i in range(1, len(s)):
        b, n = i - 1, (i + 1) % l
        fill(n, b, i)
    return jud(-1, 1, 0) and jud(0, 2, 1)

for p in [[True, True], [True, False], [False, True], [False, False]]:
    if result(*p):
        print("".join(["S" if x else "W" for x in target]))
        break
else:
    print(-1)

Measured memory_bytes: 4956
a=input()
b=list(a)
c=1
x=0
ans={"L":1,"R":0,"U":0,"D":0}
ans2={"L":0,"R":1,"U":0,"D":0}
for i in b:
    if int(c)%2==1:
        x=x+ans[i]
    elif int(c)%2==0:
        x=x+ans2[i]
    c=c+1
if x>=1:
	print("No")
else:
  	print("Yes")
  		

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF 1e9
#define modulo 1000000007
#define forn(i, n) for(int i = 0; i < (n); i++)
#define FAST ios::sync_with_stdio(false); cin.tie(NULL);
#define end1 "\n" 
#define print(x) cout << x << end1



int main(){ 
FAST;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int n; cin >> n;
int ans =  0;
while(n > 0){
    if(n%10 == 7) {
        ans++;
        break;
    }
    n /= 10;
}
if(ans > 0) cout << "Yes";
else cout << "No" ;

}

Measured memory_bytes: 3660
s = list(map(int ,"1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ")))
k = int(input())

print(s[k-1])

Measured memory_bytes: 2940