akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    if(n == 2) {
        if(a[0] == a[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }

    function<ll(ll,ll)> dfs = [&](ll v, ll p) {
        ll sum = 0, max = -INF;
        vector<ll> ch_val;
        for(auto to: g[v]) if(to != p) {
            ll val = dfs(to, v);
            sum += val;
            chmax(max, val);
            ch_val.push_back(val);
        }
        if(ch_val.size() == 0) return a[v];
        // どうがんばってもペアをつくれない
        if((sum+1)/2 > a[v] || a[v] > sum) {
            cout << "NO" << endl;
            exit(0);
        }
        ll rest = (a[v] - (sum+1)/2)*2 + sum%2;
        // a[v]-rest 個のペアをつくれない
        if(max-rest > (sum-rest)/2) {
            cout << "NO" << endl;
            exit(0);
        } 
        return rest;
    };

    ll root = -1;
    REP(i, n) if(g[i].size() >= 2) root = i;
    dump(root);
    
    if(dfs(root, -1) == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	int N,K,X,Y;
	cin >> N >> K >> X >> Y;

	ll ans = 0;
	ans += X*min(K,N);
	ans += max(0,(N - K))*Y;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3540
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int h, w;
int a[505][505];

int main () {
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> a[i][j];

  int n = 0;
  vi y, x, yd, xd;
  rep(i,h) {
    rep(j,w-1) {
      if (a[i][j]&1) {
        a[i][j]--, a[i][j+1]++;
        n++;
        y.pb(i+1), x.pb(j+1), yd.pb(i+1), xd.pb(j+2);
      }
    }
  }

  rep(i,h-1) {
    if (a[i][w-1]&1) {
      a[i][w-1]--;
      a[i+1][w-1]++;
      n++;
      y.pb(i+1), x.pb(w), yd.pb(i+2), xd.pb(w);
    }
  }

  cout << n << '\n';
  rep(i,n) {
    printf("%d %d %d %d\n", y[i], x[i], yd[i], xd[i]);
  }
  return 0;
}

Measured memory_bytes: 5220
s = input()
t = input()
n = len(s)

pairs_s = {}
pairs_t = {}

for i in range(n):
  if s[i] in pairs_s.keys():
    if pairs_s[s[i]] != t[i]:
      print('No')
      break
  else:
    pairs_s[s[i]] = t[i]
      
  if t[i] in pairs_t.keys():
    if pairs_t[t[i]] != s[i]:
      print('No')
      break
  else:
    pairs_t[t[i]] = s[i]
      
else:
  print('Yes')

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,s,x[100010],p[100010];
long long nowl,nowr,suml[100010],sumr[100010],ans,pos[100010];
int main()
{
	scanf("%d %d",&n,&s);
	for(int i=1;i<=n;++i)scanf("%d %d",&x[i],&p[i]);
//	for(int i=1;i<=n;++i)suml[i]=suml[i-1]+p[i];
//	for(int i=n;i;--i)sumr[i]=sumr[i+1]+p[i];
	int ls,rs,l,r;
	for(int i=1;i<=n;++i)if(x[i]<s)ls=i;
	rs=ls+1;
	l=1,r=n;
	int last=-1;
	while(l<=ls&&r>=rs)
	{
		if(p[l]+nowl>=p[r]+nowr)
		{
			if(last!=1)ans+=x[r]-x[l];
			last=1;
		//	pos[r]=l-1;
			nowl+=p[r];
			nowl+=nowr,nowr=0;
			--r;
		}
		else
		{
			if(last!=2)ans+=x[r]-x[l];
			last=2;
		//	pos[l]=r+1;
			nowr+=p[l];
			nowr+=nowl,nowl=0;
			++l;
		}
	//	printf("%d %d %lld\n",l,r,ans);
	}
	if(l>ls)ans+=x[r]-s;
	else ans+=s-x[l];
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
const int ININF = 1000000;

int main() {
    int N, M;
    cin >> N >> M;
    Graph G;
    G.assign(N, vector<int>());
    rep(i, 0, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    vector<int> v;
    v.push_back(ININF);
    v.push_back(ININF);
    v.push_back(ININF);
    Graph d;
    d.assign(N, v);

    d[s][0] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(s, 0));
    // BFS 開始 (キューが空になるまで探索を行う)
    while(!que.empty()) {
        pair<int, int> tmp = que.front();
        que.pop();
        int a = tmp.first;
        int b = tmp.second;
        int neb = (b + 1) % 3;
        int count = d[a][b];

        for(auto ne : G[a]) {
            if(d[ne][neb] > count + 1) {
                d[ne][neb] = count + 1;
                que.push(make_pair(ne, neb));
            }
        }
    }
    if(d[t][0] == ININF) {
        cout << -1 << endl;
    } else {
        cout << d[t][0] / 3 << endl;
    }
}


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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

const int M = 1e9 + 7;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr int N = 1 << 17;
vector<int> g[N];
ll dp[N][2];

void dfs(int u, int p) {
	dp[u][0] = dp[u][1] = 1;
	trav(v, g[u]) {
		if (v == p) continue;
		dfs(v, u);
		dp[u][0] = 1ll * dp[u][0] * (dp[v][0] + dp[v][1]) % M;
		dp[u][1] = 1ll * dp[u][1] * dp[v][0] % M;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n;
	rep(i, 1, n) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].eb(v); g[v].eb(u);
	}
	dfs(0, 0);
	cout << (dp[0][0] + dp[0][1]) % M;
}

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

typedef long long ll;
const ll mod = 1E9 + 7;

int main() {
	int n;
	string s;
	while ( cin >> n >> s ) {
		int alpha[30] = {0};
		
		for (int i = 0; i < n; ++i) alpha[ s[i]-97 ]++ ;
		
		ll ans = 1;
		
		for (int i = 0; i < 26; ++i) {
			ans *= alpha[i] + 1;
			ans %= mod;
		}
		
		cout << (ans+mod-1)%mod << '\n';
	}
	return 0;
}

Measured memory_bytes: 512
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  for(i<-1 to 4) {
    val s = readLine.split(" ").map(_.toInt)
    s(0) match {
      case 1 => println(6000*s(1))
      case 2 => println(4000*s(1))
      case 3 => println(3000*s(1))
      case 4 => println(2000*s(1))
      case _ => throw new Exception("unexpected error")
    }
  }
}

Measured memory_bytes: 43860
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n;
int a[64],b[64];

set<ll> w[64][64];
set<ll> s[64];

int main(){
	fore(i,0,51){
		w[i][i].insert(0);
		fore(j,0,i)fore(k,j+1,i+1){
			for(ll z:w[i%k][j])w[i][j].insert(z|(1LL<<k));
		}
	}
	scanf("%d",&n);
	fore(i,0,n)scanf("%d",a+i);
	fore(i,0,n)scanf("%d",b+i);
	fore(i,0,n){
		if(!SZ(w[a[i]][b[i]])){puts("-1");return 0;}
		s[i]=w[a[i]][b[i]];
	}
	ll r=0;
	for(int k=51;k>=0;--k){
		bool c=true;
		fore(i,0,n)if((*s[i].begin())&(1LL<<k)){c=false;break;}
		if(c){
			fore(i,0,n){
				set<ll> t;
				for(ll x:s[i])if(!(x&(1LL<<k)))t.insert(x);
				s[i]=t;
				assert(SZ(s[i]));
			}
		}
		else {
			fore(i,0,n){
				set<ll> t;
				for(ll x:s[i])t.insert(x&(~(1LL<<k)));
				s[i]=t;
			}
			r|=1LL<<k;
		}
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 2304
import math

A,B = map(int,input().split())
anser = 0
for i in range(1, 1100):
    if math.floor(i * 0.08) == A:
        if math.floor(i * 0.1) == B:
            anser = i
            break
    else:
        anser = -1

print(anser)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

int main()
{
    int N,T;
    cin >> N >> T;
    vector<pair<int, int>> ct(N);
    for(int i = 0; i < N; ++i)
    {
        int c ,t;
        cin >> c >> t;
        ct[i] = make_pair(t,c);
    }
    
    sort(ct.begin(), ct.end());
    
    if(ct[0].first > T)
    {
        cout << "TLE" << endl;
        return 0;
    }

    int minc = ct[0].second;
    for(int i = 1; ct[i].first <= T && i < N; ++i)
    {
        if(ct[i].second < minc) minc = ct[i].second;
    }
    cout << minc << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

long long T[maxN];
const long long INF = 1000000000000000000ll;

void solve()
{
	int n;
	scanf ("%d", &n);
	long long res = 1ll;
	bool fail = false;
	FOR(i, 0, n)
	{
		scanf ("%lld", T+i);
		if (res != 0 and T[i] > INF / res)
			fail = true;
		else
			res *= T[i];
		if (T[i] == 0)
			res = 0, fail = false;
	}
	
	if (fail)
		res = -1ll;
	printf("%lld\n", res);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





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

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

/***** MAIN *****/
signed main() {
  int n;
  scanf("%d", &n);

  int nums[n];
  int max = 0, second = 0;
  REP(i,n) {
    scanf("%d", &nums[i]);
    if(nums[i] >= max) {
      second = max;
      max = nums[i];
    } else if(nums[i] >= second) {
      second = nums[i];
    }
  }

  REP(i,n) {
    if(nums[i] == max) {
      cout << second << endl;
      continue;
    }
    cout << max << endl;
  }
  return 0;
}
/***** MAIN *****/


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

int dv;
int maxDepth = -1;
int findDeepestV(int v, unordered_map<int, vector<int> > mp) {
    int visit[200001] = {0, }, cnt = -1;
    queue<pair<int, int> > q;
    q.push(make_pair(v, 1));
    visit[v] = 1;
    while (q.size() != 0) {
        pair<int, int> now = q.front();
        q.pop();
        if (cnt < now.second) cnt = now.second;
        for (auto child : mp[now.first]) {
            if (visit[child] == 0) {
                visit[child] = 1;
                q.push(make_pair(child, now.second + 1));
                dv = child;
            }
        }
    }
    return cnt;
}

int getDiameter(unordered_map<int, vector<int> > mp) {
    findDeepestV(1, mp);
    return findDeepestV(dv, mp);
}
 
int main() {
    int n, i, a, b;
    cin >> n;
    unordered_map<int, vector<int> > mp;
    for (i = 0; i < n - 1; i++) {
        cin >> a >> b;
        if (mp.find(a) == mp.end()) {
            mp.insert(make_pair(a, vector<int>()));
        }
        mp[a].push_back(b);
        if (mp.find(b) == mp.end()) {
            mp.insert(make_pair(b, vector<int>()));
        }
        mp[b].push_back(a);
    }
    int diameter = getDiameter(mp);
    int d[200001] = {0, };
    d[0] = -1;
    for (int i = 1; i <= diameter; i++) {
        d[i] = d[i - 1] == -1 ? 1 : -1;
        if (i > 2 && d[i] != 1) {
            d[i] = d[i - 2] == -1 ? 1 : -1;
        }
    }
    if (d[diameter] == 1) {
        cout << "First";
    } else cout << "Second";
    return 0;
}

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

using ll = long long int;
constexpr ll MOD = ll(1e9)+7;

vector<ll> factrial, inverse;  //階乗と逆元を保持

ll mod_power(ll x, ll n) {
    x %= MOD;
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return mod_power(x, MOD-2);
}

void init(ll n) {
    factrial.resize(n+1);
    inverse.resize(n+1);
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;
        inverse[i] = mod_power(factrial[i], MOD - 2);
    }
}

int n;
vector<vector<int> > g;
vector<ll> cnt, dp, ans;

void dfs1(int i, int p){
    cnt[i] = 1;
    dp[i] = 1;
    for(auto j : g[i]){
        if(j == p) continue;
        dfs1(j, i);
        cnt[i] += cnt[j];
        dp[i] *= dp[j]*inverse[cnt[j]]%MOD;
        dp[i] %= MOD;
    }
    dp[i] *= factrial[cnt[i]-1];
    dp[i] %= MOD;
}

void rmv(int i, int j){
    dp[i] *= factrial[cnt[j]]*factrial[cnt[i]-1-cnt[j]]%MOD*inverse[cnt[i]-1]%MOD*mod_inv(dp[j])%MOD;
    dp[i] %= MOD;
    cnt[i] -= cnt[j];
}

void add(int i, int j){
    dp[i] *= inverse[cnt[j]]*factrial[cnt[i]-1+cnt[j]]%MOD*inverse[cnt[i]-1]%MOD*dp[j]%MOD;
    dp[i] %= MOD;
    cnt[i] += cnt[j];
}

void dfs2(int i, int p){
    ans[i] = dp[i];
    for(auto j : g[i]){
        if(j == p) continue;
        rmv(i, j);
        add(j, i);
        dfs2(j, i);
        rmv(j, i);
        add(i, j);
    }
}

int main(){
    cin >> n;
    g.resize(n);
    cnt.resize(n);
    dp.resize(n);
    ans.resize(n);
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    init(n);
    dfs1(0,-1);
    dfs2(0,-1);
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 21748
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  //WW->WS->SW->SS
  char tmp[n];
  for(int q = 0; 4 > q; q++){
    tmp[0] = (q/2 == 0 ? 'W':'S');
    tmp[1] = (q%2 == 0 ? 'W':'S');

    for(int i = 2; s.size() > i; i++){
      if(tmp[i-1]=='W'){
        if(s[i-1]=='o'){
          if(tmp[i-2]=='W')tmp[i]='S';
          else tmp[i]='W';
        }else{
          tmp[i]=tmp[i-2];
        }
      }else{
        if(s[i-1]=='o'){
          tmp[i]=tmp[i-2];
        }else{
          if(tmp[i-2]=='W')tmp[i]='S';
          else tmp[i]='W';
          
        }
      }
      //cout << i << " " << tmp[i] << endl;
    }
    bool ok = false;
    if(s[s.size()-1] == 'o'){
      if(tmp[s.size()-1]=='S'){
        if(tmp[s.size()-2]==tmp[0]){
          ok = true;
        }
      }else{
        if(tmp[s.size()-2]!=tmp[0]){
          ok = true;
        }
      }
    }else{
      if(tmp[s.size()-1]=='S'){
        if(tmp[s.size()-2]!=tmp[0]){
          ok = true;
        }
      }else{
        if(tmp[s.size()-2]==tmp[0]){
          ok = true;
        }
      }
    }
    bool ok2 = false;
    if(ok){
      if(s[0]=='o'){
        if(tmp[0]=='S'){
          if(tmp[s.size()-1]==tmp[1]){
            ok2 = true;
          }
        }else{
          if(tmp[s.size()-1]!=tmp[1]){
            ok2=true;
          }
        }
      }else{
        if(tmp[0]=='S'){
          if(tmp[s.size()-1]!=tmp[1]){
            ok2 = true;
          }
        }else{
          if(tmp[s.size()-1]==tmp[1]){
            ok2 = true;
          }
        }
      }
    }
    if(ok2){
      for(int i = 0; n > i; i++){
        cout <<tmp[i];
      }
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;
ll mod = 1e10;
int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n+1,0),b(m+1,0);
    rep(i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];

    } 
    rep(i,m){
        cin>>b[i+1];
        b[i+1]+=b[i];

    } 
    ll ans=0;
    rep(i,n+1){
        ll s = k-a[i];
        if(s<0) break;
        int re = upper_bound(b.begin(),b.end(),s)-b.begin()-1;
        ans=max(ans,i+re);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6364
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline  #文字列入力では注意！
from copy import deepcopy
from functools import lru_cache
N,M = map(int,input().split())
graph = [[] for _ in range(N)]
s = set()
for i in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    s.add(y)
    graph[x].append(y)

@lru_cache(maxsize = None)
def dfs(x):
    if not graph[x]:
        return 0
    stack = deepcopy(graph[x])
    ret = 0
    while stack:
        now = stack.pop(0)
        ret = max(ret,dfs(now)+1)
    return ret

ans = 0
for i in range(N):
    if i not in s:
        ans = max(ans,dfs(i))
print(ans)


Measured memory_bytes: 294988
#include<iostream>
using namespace std;
int main(){
    
    int cnt=0, n, m, v, g, k, j;
    cin >> n;
    int A[n];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    
    v=0;
    m=0;
    while(v<=n){
        v = v*3 + 1;
        m++;
    }
    m -= 1;
    int G[m];
    G[m-1] = 1;
    k=1;
    for(int i=m-2;i>=0;i--){
        G[i] = k*3 +1;
        k=G[i];
    }
    for(int s=0;s<m;s++){
        g = G[s];
        for(int i=g;i<n;i++){
            v = A[i];
            j = i - g;
            while(j>=0 && A[j] > v){
                A[j+g] = A[j];
                j = j-g;
                cnt++;
            }
            A[j+g] = v;
        }
    }
    
    
    cout << m << endl;
    for(int i=0;i<m;i++){
        cout << G[i];
        if(i!=m-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    
    cout << cnt << endl;
    
    for(int i=0;i<n;i++){
        cout << A[i] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 6980
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int cnt=0;
  int n=s.size();
  REP(i,n){
    if(s[i]=='x'){
      cnt++;
    }
  }
  if(cnt<8){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
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 INF = 1e+18;
int iINF = 1e9;

int N;
int A, B, C;
int ans = iINF;

void
dfs(int len, P a, P b, P c, vector<int> bam)
{
  if(len == N){
    if(a.second < 1 || b.second < 1 || c.second < 1) return ;
    else {
      int mix = 0;
      mix += 10 * (a.second - 1);
      mix += 10 * (b.second - 1);
      mix += 10 * (c.second - 1);
      chmin(ans, abs(A - a.first) + abs(B - b.first) + abs(C - c.first) + mix);
      return ;
    }
  }

  dfs(len + 1, a, b, c, bam);
  dfs(len + 1, {a.first + bam[len], ++a.second}, b, c, bam); --a.second;
  dfs(len + 1, a, {b.first + bam[len], ++b.second}, c, bam); --b.second;
  dfs(len + 1, a, b, {c.first + bam[len], ++c.second}, bam); --c.second;
}

int main()
{
  cin >> N;
  cin >> A >> B >> C;
  vector<int> bam(N);
  rep(i, 0, N) cin >> bam[i];

  dfs(0, {0, 0}, {0, 0}, {0, 0}, bam);
  cout << ans << endl;

}


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

int Selection_sort(int a[], int n) {
	int i, j, min, counta = 0, hoge;
	for (i = 0; i < n; i++) {
		min = i;
		for (j = i+1; j < n; j++) {
			if (a[min] > a[j]) min = j;
		}
		if (min != i) {
			hoge = a[i];
			a[i] = a[min];
			a[min] = hoge;
			counta++;
		}
	}
	return counta;
}

void output(int a[],int n,int count) {
	for (int i = 0; i < n; i++) {
		if(i) cout << " ";
		cout << a[i];
	}
	cout << endl << count << endl;
	return;
}

int main() {
	int n, a[100], hoge;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	hoge = Selection_sort(a, n);
	output(a, n, hoge);
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<string> a(n), b(m);
    rep (i, n) cin >> a[i];
    rep (i, m) cin >> b[i];
    rep (y, n - m + 1) {
        rep (x, n - m + 1) {
            bool flg = true;
            rep (i, m) {
                rep (j, m) {
                    if (a[i + y][j + x] != b[i][j]) flg = false;
                }
            }
            if (flg) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    long long N, K;
    vector<vector<long long>> XY;

    cin >> N >> K;
    for (long long i = 0; i < N; i++)
    {
        long long x, y;
        cin >> x >> y;
        XY.push_back(vector<long long>{x, y});
    }

    long long min_area = LLONG_MAX;
    for (long long i = 0; i < N; i++)
    {
        for (long long j = 0; j < N; j++)
        {
            long long min_x = min(XY[i][0], XY[j][0]);
            long long max_x = max(XY[i][0], XY[j][0]);
            for (long long k = 0; k < N; k++)
            {
                for (long long l = 0; l < N; l++)
                {
                    if (i != j && k != l)
                    {
                        long long count = 0;
                        long long min_y = min(XY[k][1], XY[k][1]);
                        long long max_y = max(XY[l][1], XY[l][1]);
                        for (long long m = 0; m < N; m++)
                            if (XY[m][0] >= min_x && XY[m][0] <= max_x)
                                if (XY[m][1] >= min_y && XY[m][1] <= max_y)
                                    count++;
                        if (count >= K)
                            min_area = min(min_area, (max_x - min_x) * (max_y - min_y));
                    }
                }
            }
        }
    }

    cout << min_area << endl;
}

Measured memory_bytes: 256
n,m,c = gets.strip.split.map(&:to_i)
num = gets.strip.split.map(&:to_i)
cnt = 0
n.times do
  a = gets.strip.split.map(&:to_i)
  i = 0
  sum = c
  while i < m do
    sum += num[i]*a[i]
    i += 1
  end
  if sum > 0
    cnt += 1
  end
end
puts cnt



Measured memory_bytes: 14340
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int H,N,max1=0,max2=0;
	cin >> H >> N;
	int a;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		max1+=a;
	}
	if(max1>=H){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, m,x,ans=0;
	string s[110], t[110];
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> s[i];
	}
	cin >> m;
	for (int i = 1; i <= m;i++) {
		cin >> t[i];
	}
	for (int i = 1; i <= n; i++) {
		x = 0;
		for (int j = 1; j <= n; j++) {
			if (s[i] == s[j]) {
				x++;
			}
		}
		for (int j = 1; j <= m; j++) {
			if (s[i] == t[j]) {
				x--;
			}
		}
		if (ans < x) {
			ans = x;
		}
	}
	if (ans<0) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int n;
    cin >> n;

    vector<tuple<int, int, int>> x(n * 2);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        x[i*2] = make_tuple(a, i, 0);
        x[i*2+1] = make_tuple(b, i, 1);
    }
    sort(x.begin(), x.end());

    bool a, b; //A, Bを使ったか
    a = b = false;
    int ans = 0;
    bool dup = false; //A, Bの両方を使う頂点があるか
    set<int> s;
    rep(i, n){
        int id = get<1>(x[i]);
        if(s.find(id) != s.end()){
            dup = true;
        }
        s.insert(id);

        int type = get<2>(x[i]);
        if(type){
            b = true;
        }else{
            a = true;
        }

        ans += get<0>(x[i]);
    }

    //Bのみ or Aのみ or ABを両方使う頂点が一つ以上
    if(not a || not b || dup){
        cout << ans << endl;
        return 0;
    }

    ans = 0;
    s = set<int>();
    dup = false;
    rep(i, n-1){
        s.insert(get<1>(x[i]));
        ans += get<0>(x[i]);
    }

    //n-1, 個目を飛ばしたらOK
    if(s.find(get<1>(x[n])) != s.end()){
        cout << ans + get<0>(x[n]) << endl;
        return 0;
    }

    ans -= get<0>(x[n-2]);

    ans = min(ans + get<0>(x[n-2]) + get<0>(x[n+1]), ans + get<0>(x[n-1]) + get<0>(x[n]));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	if (N == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	vector< int > ans(N);
	int S = 0;
	int d[4] = {2, 3, 4, 6};
	int k = 0, i = 0, l = 0;
	for (k = 0; (k)*4 < N; k++) {
		for (l = 0; l < 4 && k * 4 + l < N; l++) {
			ans[i] = 6 * k + d[l];
			S += ans[i];
			i++;
		}
	}
	//cout << ans << S << endl;
	if (N % 8 == 5)
		--k;
	if (S % 6 == 2) {
		ans.erase(ans.begin() + 4);
		--k;
		ans.push_back(6 * k + 6);
	} else if (S % 6 == 3) {
		ans.erase(ans.begin() + 3);
		ans.push_back(6 * k + 3);
	} else if (S % 6 == 5) {
		ans.erase(ans.begin() + 4);

		ans.push_back(6 * k + 3);
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k, i, j;
	
	cin >> n;
	
	int a[n][3], dp[n][3];
	
	for(i=0; i<n; i++)
	{	
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		
		dp[i][0] = dp[i][1] = dp[i][2] = INT_MIN;
	}
	
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	
	for(i=1; i<n; i++)
	{
		dp[i][0] = max(dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
		
		dp[i][1] = max(dp[i-1][0]+a[i][1], dp[i-1][2]+a[i][1]);
		
		dp[i][2] = max(dp[i-1][0]+a[i][2], dp[i-1][1]+a[i][2]);
	}
	
	cout << max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);

	return 0;
}


Measured memory_bytes: 2560
import numpy as np
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
A = np.array(A)
B = np.array(B)
p = np.median(A)
q = np.median(B)
if N % 2 == 0:
    p = int(p * 2)
    q = int(q * 2)
else:
    p = int(p)
    q = int(q)

ans = q - p + 1
print(ans)

Measured memory_bytes: 44296
#include <stdio.h>
main(){
  int a[100],i,j,tmp;
  for(i=0;i<=9;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<9;i++){
    for(j=9;j>i;j--){
      if(a[j] >a [j-1]){
	tmp=a[j-1];
	a[j-1]=a[j];
	a[j]=tmp;
      }
    }
  }
  for(i=0;i<=2;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }

const long long INF = 1LL << 60;


int main () {
    int A, B ,C;
    cin >>A >> B >> C;

    if(A+B+1 >=C)cout << B+C << endl;
    else cout <<  A+2*B +1 << endl;



}

Measured memory_bytes: 256
def f(x, m):
    return x * x % m

def main():
    N, X, M = map(int, input().split())
    pre = set()
    pre.add(X)
    cnt = 1
    while cnt < N:
        X = f(X, M)
        if X in pre: break
        cnt += 1
        pre.add(X)
    if cnt == N:
        return sum(pre)
    ans = sum(pre)
    N -= cnt
    loop = set()
    loop.add(X)
    while cnt < N:
        X = f(X, M)
        if X in loop: break
        loop.add(X)
    
    left = N % len(loop)
    ans += sum(loop) * (N // len(loop))
    for i in range(left):
        ans += X
        X = f(X, M)
    return ans

print(main())


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

int min(int val1, int val2)
{
    if (val1 > val2)
        return val2;
    return val1;
}

int main(void)
{
    using namespace std;
    
    int n;
    cin >> n;

    vector<int> vec(n + 1);
    for (int i = 0; i < n; i++)
        cin >> vec.at(i);
    
    vector<int> dp(n + 1);
    for (int i = 0; i < n; i++)
        dp.at(i) = 10000;

    dp.at(0) = 0;
    for (int i = 1; i < n; i++)
    {
        int cost1 = dp.at(i - 1) + abs(vec.at(i - 1) - vec.at(i));
        int cost2 = 10000;
        if (i > 1)
            cost2 = dp.at(i - 2) + abs(vec.at(i - 2) - vec.at(i));
        
        dp.at(i) = min(cost1, cost2);
    }

    cout << dp.at(n - 1) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main () {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int ans = 0;
  while (A >= B) {
    ans ++;
    B *= 2;
  }
  while (B >= C) {
    ans ++;
    C *= 2;
  }
  cout << (ans <= K ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int cnt1 = 0, cnt2 = 0;
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++)
	{
		if (str[i] != (i & 1) + '0') cnt1++;
		else cnt2++;
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


/**
 * @brief a!に素因数pが幾つ含まれるか?
 * @note a=2^63-1, p=2でも64bit整数に収まる。
 */
std::int64_t factorial_prime_factorization(std::int64_t a, std::int64_t p){
  std::int64_t ret = 0, q = p;

  while(q <= a){
    std::int64_t t = a / q;

    ret += t;

    LLI k;
    if(__builtin_smulll_overflow(q, p, &k)) break;
    
    q = k;
  }
  return ret;
}




int main(){
  LLI N;
  while(cin >> N){

    if(N % 2 == 0){
      N /= 2;
      LLI five = factorial_prime_factorization(N, 5);
      LLI two = factorial_prime_factorization(N, 2);
      two += N;

      cout << min(five, two) << endl;
    }else{
      LLI five = factorial_prime_factorization(N, 5);
      LLI two = factorial_prime_factorization(N, 2);

      N /= 2;

      five -= factorial_prime_factorization(N, 5);
      two -= factorial_prime_factorization(N, 2);
      two -= N;

      cout << min(five, two) << endl;
    }
    

    
  }


  return 0;
}


Measured memory_bytes: 256
package main

import(
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)
	arr := map[string]string{"a": s1, "b": s2, "c": s3}
	key := "a"
	for arr[key] != "" {
		c := string(arr[key][0])
		arr[key] = arr[key][1:]
		key = c
	}
	fmt.Println(strings.ToUpper(key))
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	int a, b, h;
	
	cin >> a >> b >> h;

	cout << (a + b)*h / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
i = 0
a,s= divmod(n, -2)
if s == -1: a,s = a+1,1
s = str(s)
while a:
    a,b = divmod(a, -2)
    if b == -1: a,b = a+1,1
    s = str(b)+s
print(s)

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


int N, X[1000], Y[1000];
string ans[1000];
bool is_even;


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
    }
    for(int i = 0; i < N; i++){
        if(abs(X[0] + Y[0]) % 2 != abs(X[i] + Y[i]) % 2){
            cout << "-1" << endl;
            return 0;
        }
    }
    if(abs(X[0]+Y[0]) % 2 == 0){
        is_even = true;
        for(int i = 0; i < N; i++){
            X[i]--;
        }
    }
    int m = 31;
    cout << m + (is_even? 1: 0) << endl;
    if(is_even){
        cout << "1 ";
    }
    for(int i = 0; i < m; i++){
        if(i){
            cout << " ";
        }
        cout << (1 << i);
    }cout << endl;

    for(int i = 0; i < N; i++){
        if(is_even){
            cout << 'R';
        }
        long long u = X[i] + Y[i];
        long long v = X[i] - Y[i];
        for(int j = 0; j < m; j++){
            bool plus_u = ((u + ((1<<m) - 1)) >> (j+1)) & 1;
            bool plus_v = ((v + ((1<<m) - 1)) >> (j+1)) & 1;
            if(plus_u && plus_v){
                cout << 'R';
            }else if(plus_u && !plus_v){
                cout <<'U';
            }else if(!plus_u && plus_v){
                cout <<'D';
            }else{
                cout << 'L';
            }
        }cout << endl;
    }
}


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


int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int N;
    int K;
    cin >> N >> K;
    ll ans = 0;
    ll D = 0;
    int k = 0;
    vector<bool> have(N,false);
    for (int i = 0; i < K; i++)
    {
        cin >> D;
        for (int j = 0; j < D;j++)
        {
            cin >> k;
            have[k-1] = true;
        }
    }
    for (int i = 0; i < N;i++)
    {
        if(have[i] == false){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

char x[4],y[4] ;

int main(void){
    
    scanf ("%s%s",x,y) ;
    
    if ( x[0]==y[2] && x[1]==y[1] && x[2]==y[0] ){
        printf ("YES\n") ;
    } else {
        printf ("NO\n") ;
    }
    
    return 0 ;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PR pair<int, int>
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
//constexpr int MOD = 10e9+7;
constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int H,W;
  cin >> H >> W;
  char a[H][W];
  rep(i,H)rep(j,W) cin >> a[i][j];
  bool eraseC[H];
  bool eraseR[W];
  rep(i,H) eraseC[i] = true;
  rep(i,W) eraseR[i] = true;
  rep(i,H)
  {
    rep(j,W)
    {
      if(a[i][j] == '#')
      {
        eraseC[i] = false;
        break;
      }
    }
  }
  rep(j,W)
  {
    rep(i,H)
    {
      if(a[i][j] == '#')
      {
        eraseR[j] = false;
        break;
      }
    }
  }
  rep(i,H)
  {
    if(eraseC[i]) continue;
    rep(j,W)
    {
      if(eraseR[j]) continue;
      cout << a[i][j]; 
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
abc = [list(map(int, input().split(" "))) for i in range(N)]

dp = [[0 for i in range(3)] for j in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1, N):
    dp[i][0] = abc[i][0] + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = abc[i][1] + max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = abc[i][2] + max(dp[i-1][0], dp[i-1][1])

print(max(dp[-1]))


Measured memory_bytes: 47384
#include<stdio.h>
#include <string.h>
using namespace std;
int n,link[110][110],connect[110];
bool used[110];
bool find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(link[x][i]&&!used[i])
        {
            used[i]=true;
            if(connect[i]==0||find(connect[i]))
            {
                connect[i]=x;
                return true;
            }
        }
    }
    return false;
}
int main(void)
{
	int a[110],b[110],c[110],d[110];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&c[i],&d[i]);
    memset(connect,0,sizeof connect);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i]<c[j]&&b[i]<d[j])
                link[i][j]=true;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        memset(used,false,sizeof used);
        if(find(i)) ans++;
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>cl;
set<int>st;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    st.insert(a);
    cl[a]++;
  }
  for(auto itr=st.begin();itr!=st.end();++itr){
    if(cl[*itr]>*itr){
      while(cl[*itr]>*itr){
	cl[*itr]--;
	ans++;
      }
    }else if(cl[*itr]<*itr){
      ans+=cl[*itr];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=1e4;
int main()
{
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    cout<<(m-1)*(n-1)<<endl;
    return 0;
}


Measured memory_bytes: 256