akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::vector<int> digit(int128_t n, const int128_t b) {
    // 基数bでの表示。0は0桁。非常に大きい数を入れても問題ないようにint128_tとする。intやlong longを入れても問題ないはず。
    // size()をとれば桁数になる。
    assert(1 < b);
    std::vector<int> ret;
    while (0 < n) {
        ret.push_back(n % b);
        n /= b;
    }
    return ret;
}

std::vector<int64_t> divisor(int64_t n) {
    // nの約数をソートして列挙。1とnも含む。計算量はO(sqrt(n))なので、int64_tも入り得る。
    std::vector<int64_t> res;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    std::sort(res.begin(), res.end());
    return res;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int64_t N;

int main(int argc, char **argv) {
    std::cin >> N;

    auto divi = divisor(N);

    int ret = digit(N, 10).size();

    for (auto d : divi) {
        int v1 = digit(d, 10).size();
        int v2 = digit(N / d, 10).size();
        ret = std::min(ret, std::max(v1, v2));
    }

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
struct edge{int to,cap,rev;};
const int MAX_V=1000,inf=1e8;
vector<edge> G[MAX_V];
int level[MAX_V],iter[MAX_V],ord[10000];
int N,M,S,T,a[10000],b[10000];
void add_edge(int from,int to,int cap,int i){
	edge e1={to,cap,(int)G[to].size()},e2={from,0,(int)G[from].size()};
	G[from].pb(e1);
	G[to].pb(e2);
	ord[i]=G[from].size()-1;
}
void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		rep(i,G[v].size()){
			edge &e=G[v][i];
			if(e.cap>0&&level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}
int dfs(int v,int t,int f){
	if(v==t) return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e=G[v][i];
		if(e.cap>0&&level[v]<level[e.to]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	while(true){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,inf))>0) flow+=f;
	}
}
bool froms[MAX_V],tot[MAX_V];
void dfs1(int v){//from s
	froms[v]=1;
	for(auto e:G[v]){
		if(e.cap<=0) continue;
		if(froms[e.to]) continue;
		dfs1(e.to);
	}
}
void dfs2(int v){//to t
	tot[v]=1;
	for(auto e:G[v]){
		if(e.cap>0) continue;
		if(tot[e.to]) continue;
		dfs2(e.to);
	}
}
int main(){
	while(true){
		cin>>N>>M>>S>>T;
		if(N==0) break;
		rep(i,N) G[i].clear();
		S--,T--;
		rep(i,M) cin>>a[i]>>b[i];
		rep(i,M){
			a[i]--,b[i]--;
			add_edge(a[i],b[i],1,i);
		}
		int f=max_flow(S,T);
		int cnt=0;
		rep(i,N) froms[i]=0,tot[i]=0;
		dfs1(S);
		dfs2(T);
		rep(i,M){
			if(G[a[i]][ord[i]].cap<1) continue;
			if(froms[b[i]]&&tot[a[i]]) cnt++;
		}
		if(cnt>0) f++;
		cout<<f<<" "<<cnt<<endl;
	}
}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//

int main() {
	cin >> N;
	vector<string> S(N);
	for (i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	ll c = 1;
	ll M = 0;
	vector<string> Ans;
	for (i = 1; i < N; i++) {
		if (S[i - 1] == S[i]) {
			c++;
		}
		else {
			if (c == M) {
				Ans.push_back(S[i - 1]);
				c = 1;
			}
			else if (c > M) {
				Ans.clear();
				Ans.push_back(S[i - 1]);
				M = c;
				c = 1;
			}
			else {
				c = 1;
			}
		}
	}
	if (c == M) {
		Ans.push_back(S[i - 1]);
		c = 1;
	}
	else if (c > M) {
		Ans.clear();
		Ans.push_back(S[i - 1]);
		M = c;
		c = 1;
	}
	else {
		c = 0;
	}
	for (i = 0; i < Ans.size(); i++) {
		cout << Ans[i] << endl;
	}
}


Measured memory_bytes: 17268
#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++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string s,t;
    cin >> s >> t;
    ll ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }

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











Measured memory_bytes: 3920
//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define re register int 
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pa pair<int,int>
#define fr first
#define sd second
#define Z(x) (x>=mod?x-mod:x)
#define lowbit(x) (x&(-x))
#define N 1000010
#define ls (x<<1)
#define rs (x<<1|1)
#define mid ((l+r)>>1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
pa p[N],g[N];
int n;int st[N],top,f[N],s[N];
vector<int>v[N];
const int mod=1e9+7;
int minn[N<<2],maxn[N<<2];
void build(int l,int r,int x)
{
	if(l==r){minn[x]=maxn[x]=p[l].sd;return ;}
	build(l,mid,ls);build(mid+1,r,rs);
	minn[x]=min(minn[ls],minn[rs]);
	maxn[x]=max(maxn[ls],maxn[rs]);
}
int askl(int l,int r,int x,int val)
{
	if(maxn[x]<val)return inf;
	if(l==r){return l;}int t=askl(l,mid,ls,val);
	if(t!=inf)return t;
	else return askl(mid+1,r,rs,val);
}
int askr(int l,int r,int x,int val)
{
	if(minn[x]>val)return -inf;
	if(l==r){return l;}int t=askr(mid+1,r,rs,val);
	if(t!=-inf)return t;
	else return askr(l,mid,ls,val);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    n=read();
    FOR(i,1,n)p[i].sd=read(),p[i].fr=read();
    sort(p+1,p+n+1);build(1,n,1);
    FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
    //FOR(i,1,n)cout<<g[i].sd<<" "<<g[i].fr<<endl;
    FOR(i,1,n)v[g[i].fr].pb(g[i].sd);
    FOR(i,1,n)sort(v[i].begin(),v[i].end());
    f[0]=1;
    FOR(i,0,n)s[i]=1;
    FOR(i,1,n)
    {
    	s[i]=Z(s[i-1]+f[i]);
    	for(int x:v[i])
		{
			f[i]=Z(f[i]+Z(s[i]+mod-(x>1?s[x-2]:0)));
			s[i]=Z(s[i-1]+f[i]);
		}
		//cout<<"WTF:"<<i<<" "<<f[i]<<endl;
    }
    printf("%d\n",f[n]);
    return 0;
}
//code once,check twice

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}


struct union_find{
	int n;
  vector<int> par,rank,size;

  // 頂点xの根を見たいときはuf.find(x)を使う
  union_find(int _n) : n(_n),par(_n),rank(_n),size(_n){init(n);}

  void init(int n){
    rep(i,n) par[i]=i,rank[i]=i,size[i]=1;
  }

  int GetRoot(int x){
    if(par[x] == x) return x;
    else return GetRoot(par[x]);
  }

  int GetSize(int x){
    return size[GetRoot(x)];
  }

  ll getNumOfComponents(){
    ll num=0;
    rep(i,n)if(GetRoot(i)==i)num++;
    return num;
  }

  void Unite(int x,int y){
    x = GetRoot(x);
    y = GetRoot(y);
    if(x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      size[y]+=size[x];
    }else{
      par[y] = x;
      size[x]+=size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  bool Same(int x,int y){
    return GetRoot(x) == GetRoot(y);
  }
};

int main()
{
	ll n,m,q;
	cin>>n>>m>>q;
	vector<tp> query(q);
	rep(i,q){
		int a,b,c;
		cin>>a>>b>>c;
		query[i] = tp(c,a,b);
	}

	bool flag=false;
	union_find uf(n);
	rep(i,q){
		if(get<0>(query[i])==1){
			flag=true;
			continue;
		}
		int a=get<1>(query[i]), b = get<2>(query[i]);
		if(!uf.Same(a,b))uf.Unite(a,b);
	}

	rep(i,q){
		if(get<0>(query[i])==0) continue;
		int a=get<1>(query[i]), b = get<2>(query[i]);
		if(uf.Same(a,b)){
			cout<<"No"<<endl;
			return 0;
		}
	}

	ll comp = uf.getNumOfComponents();

	ll large = comp*(comp-1)/2 + (n-comp);
	ll small = (flag?n:n-1);

	if(small<=m&&m<=large)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

    mint m; ll n;
    cin >> m >> n;
    cout << m.pow(n) << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

int main(){
    string str; cin >> str;
    for(int i = 0; i < (int)str.size(); i++){
        printf("x");
    }
    printf("\n");
    return 0;
}


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

typedef long long ll;

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

    string S;
    cin >> S;

    for(int i = 0; i < 2; i++) {
        if(S[i] != S[i + 1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }    

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int keta(ll x)
{
    int k = 0;
    do {
        x /= 10;
        k++;
    } while (x);
    return k;
}

int main()
{
    ll n;
    cin >> n;
    int ans = 1e9;
    for (ll a = 1; a * a <= n; a++) {
        if (n % a != 0) continue;
        ll b = n / a;
        ans = min(ans, max(keta(a), keta(b)));
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int hoge(int a);

int a,b,ans;

signed main() {
    cin >> a >> b;
    ans = hoge(a-1)^hoge(b);
    cout << ans << endl;
}

int hoge(int a) {
    int tmp=0;
    for(int i=a-a%4;i<=a;i++) tmp ^= i;
    return tmp;
}

Measured memory_bytes: 256
#include <stdio.h>

char ch[100001];
int a, b;

int main(void)
{
  int i;
  
  scanf("%s", ch);
  if (ch[2] || ch[0] != ch[1]) a = b = -1;
  else a = -1 + (b = 2);
  for (i = 2; ch[i]; ++i)
  {
    if (ch[i-2] != ch[i-1] && ch[i-1] != ch[i] && ch[i-2] != ch[i]) continue;
    a = i-1;
    b = i+1;
    break;
  }
  printf("%d %d\n", a, b);
  
  return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
#print(n, q)

s = input()

v = [0] * n

for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        v[i] = 1

m = [0] * (n + 1)
for i in range(n):
    m[i + 1] = m[i] + v[i]


for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    ans = 0
    if r - l < 2:
        ans = 1
    else:
        ans = m[r] - m[l]
        if v[r - 1] == 1:
            ans -= 1
    print(ans)


Measured memory_bytes: 13924
<?php 
fscanf(STDIN, "%d %d %d", $a, $b, $c);
if ($a == $b) {
  echo $c;
}else {
  if($c-($a-$b) <0){
    echo "0";
  }else {
    echo $c-($a-$b);
  }
}
?>

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    int w,a,b;
    while(cin>>w>>a>>b)
    {
        int a1=a,a2=w+a;
        int b1=b,b2=w+b;
        int c=b1-a2,d=a1-b2;
        if(b1>=a1&&b1<=a2)
            cout<<0<<endl;
        else if(b2>=a1&&b2<=a2)
            cout<<0<<endl;
        else if(c<0)
            cout<<d<<endl;
        else
            cout<<c<<endl;
    }
    return 0;
}


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

bool check(int n){
  int S=a.size();
  for(int i=0;i<S;i++){
    int sum=a[i];
    for(int j=1;i+j<S&&sum<n;j++)sum=sum*10+a[i+j];
    if(sum==n) return 0;
  }
  return 1;
}

int main(){
  int n;
  cin>>n;
  a.resize(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int i=0;
  while(1)if(check(i++))break;
  cout <<i-1<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
string S;
int main(){
	int n;
	while(true){
		cin>>n;vector<string>vec;
		vector<pair<int,string> >w;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			S="";
			while(S==""){
				getline(cin,S);
			}
			S+=" ";string T;
			for(int i=0;i<S.size();i++){
				if(S[i]==' '){vec.push_back(T);T="";}
				else{T+=S[i];}
			}
		}
		char c;cin>>c;sort(vec.begin(),vec.end());
		if(vec[0][0]==c)w.push_back(make_pair(-1,vec[0]));
		for(int i=1;i<vec.size();i++){
			if(vec[i][0]==c){
				if(vec[i]==vec[i-1]){w[w.size()-1].first--;}
				else{w.push_back(make_pair(-1,vec[i]));}
			}
		}
		sort(w.begin(),w.end());
		if(w.size()==0){cout<<"NA";}
		else{
			for(int i=0;i<w.size();i++){
				if(i>=5){break;}
				if(i){cout<<' ';}
				cout<<w[i].second;
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1272
N,M = map(int, input().split())
ac = 0
count = [0 for i in range(N)]
done = [False for i in range(N)]
ans = 0
for i in range(M):
    p,s = input().split()
    p = int(p) - 1
    if done[p]:
        continue
    elif s == 'AC':
        done[p] = True
        ac += 1
        ans += count[p]
    else:
        count[p] += 1

print( ac, ans)

Measured memory_bytes: 4656
// Contest: AtCoder Beginner Contest 153 (https://atcoder.jp/contests/abc153)
// Problem: B: Common Raccoon vs Monster (https://atcoder.jp/contests/abc153/tasks/abc153_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cpp_lib_nonmember_container_access >= 201411
#   define sz(x) ((int)size(x))
#else
#   define sz(x) ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define all(a)         (a).begin(),(a).end()
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __has_cpp_attribute(maybe_unused) >= 201603
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18;
//endregion }}}

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

    int h, n; cin >> h >> n;
    ll s, ai;
    rep(i, n)
        cin >> ai, s += ai;

    cout << (s >= h ? "Yes" : "No") << '\n';

    return 0;
}

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



int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  ans = n * (n-1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=1e6+3;

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

      int l,r;
      cin>>l>>r;
      r=min(r,l+2*(2019));
      vector<int> a;
      for(int i=l;i<=r;i++)
      {
            for(int j=i+1;j<=r;j++)
            {
                  a.pb((i*j)%2019);
            }
      }
      sort(all(a));
      cout<<a[0];
}     
// k*2019-l=i*j;
// 
// I never lose. I either win or I learn

Measured memory_bytes: 67808
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  int h[n];
  for(int i = 0; i < n; ++i) cin >> h[i];
  double m = 1000000;
  int ans;
  for(int i = 0; i < n; ++i) {
    if(fabs(m - (double)a) > fabs(((double)t - (double)h[i] * 0.006) - (double)a)) { m = (double)t - (double)h[i] * 0.006; ans = i + 1; }
  }
  cout << ans << endl;
  return 0;
}

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

int F[100];
int main()
{
    int N;
    cin >> N;
    F[0]=1;
    F[1]=1;
    for(int i=2;i<=N;i++)
       F[i]=F[i-2]+F[i-1];
    cout << F[N] << endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
vector<vct> a;
int n;
void doer(vct b)
{
          if(b.size()==n){
                    a.pb(b);
                    return;
          }
          for(int i = 1 ; i <= n ; i++)
          {
                    if(find(all(b),i)==b.end())
                    {
                              b.pb(i);
                              doer(b);
                              b.pop_back();
                    }
          }
}


int main()
{
          
          cin>>n;
          vct x;
          doer(x);
          vct b,c;
          b.rz(n);
          c.rz(n);
          arrin(b,n);
          arrin(c,n);
          int i1,i2;
          fri(i,0,a.size())
          {
                    if(a[i]==b){
                              i1=i;
                    }
                    if(a[i]==c){
                              i2=i;
                    }
          }
          cout<<abs(i1-i2)<<endl;
}


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

int t[100005],a[100005];

int main() {
  string s;
  cin>>s;
  int now=0;
  while(now<s.size()){
    if(s.substr(now,7)=="dreamer"){
      if(s[now+7]=='a'){
	now+=5;
      }
      else{
	now+=7;
      }
    }
    else if(s.substr(now,5)=="dream"){
      now+=5;
    }
    else if(s.substr(now,6)=="eraser"){
      if(s[now+5]=='a'){
	now+=5;
      }
      else{
	now+=6;
      }
    }
    else if(s.substr(now,5)=="erase"){
      now+=5;
    }
    else {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

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

#dist[i][j] = iからjまでの最短距離
def floyd_warshall(dist):
    v = len(dist)
    for k in range(v):
        for i in range(v):
            for j in range(v):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    return dist

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
floyd_warshall(c)
A = [list(map(int, input().split())) for _ in range(H)]
ans = 0

#全ての座標について、-1以外の時はコスト足していく（1⇒1は0なのでOK）
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += c[A[i][j]][1]

print(ans)

Measured memory_bytes: 40412
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,d,x_2000;
    cin >> r >> d >> x_2000;
    int ans = x_2000;
    for (int i = 0; i < 10; i++)
    {
        ans = r * ans - d;
        cout << ans << endl;
    }   
}


Measured memory_bytes: 3624
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long
#define ull unsigned long long
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
//#define DEBUG
//#pragma GCC optimize(2)

const int MOD=1e9+7;

int n;
int a[200100];
int b[200100];

bool chk(int m)
{
	for(int i=0;i<n*2-1;i++)
		if(a[i]>m) b[i]=1;
		else b[i]=0;
	if(b[n-1]==b[n-2]||b[n-1]==b[n]) return b[n-1];
	for(int i=n-1;i>0;i--)
		if(b[i]==b[i-1])
			return b[i];
		else if(b[n*2-i-2]==b[n*2-i-1])
			return b[n*2-i-2];
	return b[0];
}

int main()
{
	#ifdef DEBUG
	clock_t tStart = clock();
	#endif
	scanf("%d",&n);
	rep(i,n*2-1) scanf("%d",&a[i]);
	int l=0,r=MOD;
	int res=0;
	while(l<=r)
	{
		int m=(l+r)/2;
		if(!chk(m)) r=m-1,res=m;
		else l=m+1;
	}
	printf("%d\n",res);
	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;int64_t M;
  cin>>N>>M;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t left=0;int64_t right=2*A.at(N-1)+1;
  while(1<right-left){
  int64_t mid=left+(right-left)/2;
    int64_t sum=0;
    for(int i=0;i<N;i++){
    auto itr=lower_bound(A.begin(),A.end(),mid-A.at(i));
      int64_t k=distance(A.begin(),itr);
      sum+=N-k;
    }if(sum<M)
      right=mid;
    else
      left=mid;
  }vector<int64_t>B(N);
  B.at(N-1)=A.at(N-1);
  for(int i=N-2;0<=i;i--)
    B.at(i)=B.at(i+1)+A.at(i);
  int64_t ans=0; int64_t num=0;
  for(int i=0;i<N;i++){
  auto itr=lower_bound(A.begin(),A.end(),right-A.at(i));
    int k=distance(A.begin(),itr);
     if(k!=N){ans+=B.at(k)+A.at(i)*(N-k); num+=N-k;}
  }ans+=(M-num)*left;
  cout<<ans<<endl;
  
    return 0;
}

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

string str="CODEFESTIVAL2016";

int main(void){
	string s;
	cin >> s;
	int cnt=0;
	for(int i=0;i<16;i++){
		if(s[i]!=str[i])cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    vector<ll> sumB;
    map<ll, ll> cntB;
    sumB.push_back(0);
    cntB[0] = 0;
    ll sum = 0;
    ll ans = 0;
    rep(i, M) {
        sum += B[i];
        sumB.push_back(sum);
        cntB[sum] = i + 1;
        if (sum <= K) ans = i + 1;
    }

    sum = 0;
    rep(i, N) {
        sum += A[i];
        if (sum > K) break;
        int pos = upper_bound(sumB.begin(), sumB.end(), K - sum) - sumB.begin() - 1;
        chmax(ans, i + 1 + cntB[sumB[pos]]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 20404
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		char[]color = stdIn.next().toCharArray();
		int cnt = 1;
		for(int i = 0; i < n-1; i++) {
			if(color[i]!= color[i+1]) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
		
		
		
		
		
		
		
		
		
	}

}


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

int main() {
  int H, A, X=1;
  cin >> H >> A;
  while(1){
    if(A*X>=H) break;
    X++;
  }
  cout << X << endl;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 2100;
int n;
string s;
vi e[maxn];

struct TRes {
    int s0, sd, mm;

    TRes mv() const {
        TRes r = *this;
        r.sd += r.s0;
        return r;
    }

    TRes operator+(TRes r) {
        TRes res = {s0 + r.s0, sd + r.sd, mm + r.mm};
        int S = min(sd, r.sd);
        res.mm = S + min((sd - S) / 2, mm) + min((r.sd - S) / 2, r.mm);
//        if (S) uax(res.mm, S - 1 + min((sd - S + 1) / 2, mm) + min((r.sd - S + 1) / 2, r.mm));
        return res;
    }
};

pii mv(pii p) {
    return {p.fi, p.fi + p.se};
}

pii operator+(pii a, pii b) {
    return {a.fi + b.fi, a.se + b.se};
}

TRes dfs(int v, int p) {
    TRes res = {s[v] - '0', 0, 0};
    for (int u: e[v]) {
        if (u == p) continue;
        res = res + dfs(u, v).mv();
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    cin >> n >> s;
    forn(i, n - 1) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        e[u].pb(v);
        e[v].pb(u);
    }

    i64 ans = 1e18;
    forn(v, n) {
        vector<TRes> ds;
        for (int u: e[v]) ds.pb(dfs(u, v).mv());
        sort(all(ds), [](TRes a, TRes b){return a.sd > b.sd;});
        i64 T = 0;
        for (auto w: ds) T += w.sd;
        if (T % 2) continue;
        if (ds[0].sd - 2 * ds[0].mm > T - ds[0].sd) continue;
//        if (ds[0].sd > T / 2) continue;
        uin(ans, T / 2);
//        cerr << v << ' ' << T / 2 << ' ' << ds[0].sd << ' ' << ds[0].mm << '\n';
    }
    if (ans > 1e17) ans = -1;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 640
N = int(input())
A = [int(input())for _ in range(N)]
all_m = max(A)
maxs = A.count(all_m)
for ind,i in enumerate(A):
    if(all_m==i):
        if(maxs>=2):
            print(all_m)
        else:
            print(max(A[:ind]+A[ind+1:]))
    else:
        print(all_m)

Measured memory_bytes: 15580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] d = new int[N];
        for (int i=0;i<N;i++) {
            d[i] = Integer.parseInt(sc.next());
        }
        int ans = 0;
        for (int i=0;i<N;i++) {
            for (int j=i+1;j<N;j++) {
                ans += d[i]*d[j];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include<iostream>
#include<string.h>
using namespace std;
int main(){
    string N;
    bool flag = false;
    cin >> N;

    for(int i=0;i<3;i++){
        if(N.at(i) == '7'){
            flag = true;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

unused = [3] * N
ans = 1
for i in range(N):
    if A[i] == 0:
        ans *= unused[0]
        unused[0] -= 1
    else:
        ans *= unused[A[i]] - unused[A[i]-1]
        unused[A[i]] -= 1
    ans %= mod
        
print(ans % mod)


Measured memory_bytes: 20704
#include<stdio.h>

int main(void){
	int S;
	int h, m, s;
	scanf("%d", &S);
	h = S/3600;
	m = (S%3600)/60;
	s = (S%3600)%60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br ;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt();
		int k = ob.nextInt();
		int h[] = new int[n];
		for (int i = 0; i < h.length; i++) {
			h[i] = ob.nextInt();
		}
		Arrays.parallelSort(h);
		long ans=0;
		for (int i = 0; i < h.length-k; i++) {
			ans+=h[i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 60924
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,c=0;
    cin>>n>>m;
    int h[n+1];
    int f[n+1]={};
    for(int i=1;i<n+1;i++)
        cin>>h[i];
    vector<int> r[n+1]; 
    for(int i=1;i<=m;i++)
    {
        int ai,bi;
        cin>>ai>>bi;
        if(!count(r[ai].begin(),r[ai].end(),bi))
        {
            r[ai].push_back(bi);
            if(h[ai]<=h[bi])
                f[ai]++;
        }
        if(!count(r[bi].begin(),r[bi].end(),ai))
        {
            r[bi].push_back(ai);
            if(h[bi]<=h[ai])
                f[bi]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!f[i])
            c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 9576
<?php

$N = trim(fgets(STDIN));
$in = explode(" ", $N);
$result = [];
for($i=1; $i<=100; $i++){
    if($in[0] % $i == 0 && $in[1] % $i == 0){
        $result[] = $i;
    }
}
echo $result[count($result) - $in[2]];
?>

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

const int maxn = 1e5 + 5;
char str[maxn];
bool stat = true;
int n;
int main(){
	scanf("%s",str+1);
	n = strlen(str+1);
	for(int i=1;i<=n;i+=2){
		if(str[i] != 'h' || str[i+1] != 'i') stat = false;
	}
	if(stat) printf("Yes\n");
	else printf("No\n");
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i]=1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        if(x<y)swap(x,y);
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        //int tmp=size[rx]+size[ry];
        if(!same(x,y))size[ry]+=size[rx];
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int getsize(int x){
        return size[root(x)];
    }
    
};
int main(){

    int N,M,K;
    cin>>N>>M>>K;
    /*
    vector<vector<int>>tomo(N);
    vector<vector<int>>block(N);
    */
    //bool tomo[N][N]={};
    //int cnt[N]={};
    //bool block[N][N]={};
    int cnt[N]={};

    UnionFind uf(N);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.unite(a,b);
        cnt[a]++;
        cnt[b]++;
        //tomo[a][b]=tomo[b][a]=true;
        //cnt[a]++;
        //cnt[b]++;
    }
    vector<vector<int>>block(N);
    rep(i,K){
        int a,b;
        cin>>a>>b;
        a--,b--;
        block[a].emplace_back(b);
        block[b].emplace_back(a);
        //block[a][b]=block[b][a]=true;
        
    }
    rep(i,N){
        int ans=0;
        /*
        rep(k,N){
            if(i==k)continue;
            //if(uf.same(i,k)&&  && !block[i][k])ans++;
        }
        */
        ans+=uf.getsize(i);
        //cout<<uf.getsize(i);
        //cout<<cnt[i]<<"!";
        ans-=cnt[i]+1;
        for(auto bl:block[i]){
            if(uf.same(i,bl))ans--;
        }

        cout<<ans<<" ";
    }
    cout<<endl;

    




    return 0;

}
/*


*/


Measured memory_bytes: 7424
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    ll pret = 0;
    ll prex = 0;
    ll prey = 0;
    rep(i, N) {
        ll t, x, y;
        cin >> t >> x >> y;
        ll time = t - pret;
        ll dist = abs(x - prex) + abs(y - prey);
        if (!(time >= dist && time % 2 == dist % 2)) {
            cout << "No" << endl;
            return 0;
        }
        pret = t;
        prex = x;
        prey = y;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, T;
  cin >> N >> T;
  vector<P> ab(N);
  for(int i = 0; i < N; i++){
    cin >> ab.at(i).first >> ab.at(i).second;
  }
  sort(ALL(ab));
  vvll dp(N+1, vll(6000, 0LL));

  for(int i = 1; i <= N; i++){
    for(int j = 0; j < 6000; j++){
      chmax(dp.at(i).at(j), dp.at(i-1).at(j));
      ll A = ab.at(i-1).first, B = ab.at(i-1).second;
      if(j - A >= 0) chmax(dp.at(i).at(j), dp.at(i-1).at(j-A) + B);
    }
  }
  
  ll ans = 0LL;
  
  for(int i = 1; i <= N; i++){
    ll A = ab.at(i-1).first, B = ab.at(i-1).second;
    chmax(ans, dp.at(i-1).at(T-1) + B);
  }

  cout << ans << endl;
}


Measured memory_bytes: 141184
class Node:
    def __init__(self, id):
        self.id = id
        self.parent = None
        self.left = None
        self.right = None

root = None
n = int(input())
node_list = []
for i in range(n):
    node_list.append(Node(i))

for i in range(n):
    id, left, right = list(map(int, input().split()))
    node = node_list[id]
    if left > -1:
        node_list[left].parent = node
        node.left = node_list[left]
    if right > -1:
        node_list[right].parent = node
        node.right = node_list[right]

root = None
for node in node_list:
    if node.parent is None:
        root = node
        break

def preorder(node):
    if node is None:
        return
    print(' ' + str(node.id), end='')
    preorder(node.left)
    preorder(node.right)

def inorder(node):
    if node is None:
        return
    inorder(node.left)
    print(' ' + str(node.id), end='')
    inorder(node.right)

def postorder(node):
    if node is None:
        return
    postorder(node.left)
    postorder(node.right)
    print(' ' + str(node.id), end='')

print('Preorder')
preorder(root)
print('')

print('Inorder')
inorder(root)
print('')

print('Postorder')
postorder(root)
print('')


Measured memory_bytes: 5616
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a == 1){
            System.out.println("Hello World");
        }else{
           int b = sc.nextInt();
            int c = sc.nextInt();
            System.out.println(b + c);
        }

    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#define M 500005
#define INF (1 << 30)
typedef long long ll;
using namespace std;

int arr[M];
ll cnt = 0;
int R[M / 2 + 2], L[M / 2 + 2];
void merge(int left, int mid,  int right)	//????????????
{
	if (right - left <= 1)
		return;
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; ++i)
		L[i] = arr[left + i];
	for (int i = 0; i < n2; ++i)
		R[i] = arr[mid + i];
	L[n1] = R[n2] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; ++k)
	{
		if (L[i] <= R[j])
		{
			arr[k] = L[i++];
		}
		else
		{
			cnt += n1 - i;
			arr[k] = R[j++];
		}
	}
}

void mergesort(int l, int r)
{
	if (r - l <= 1)
		return;
	int mid = (l + r) / 2;
	mergesort(l, mid);
	mergesort(mid, r);
	merge(l, mid, r);
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	cnt = 0;
	mergesort(0, n);
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

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

    ll k;
    cin >> k;
    ll res = 0;
    REP(a, k) {
        REP(b, k) {
            REP(c, k) {
                res += gcd(a + 1, gcd(b + 1, c + 1));
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
string a;
int i,ans;
int main() {
    cin >> a;
    for (i=0; i<a.size();i++)
        ans+=a[i]-'0';
    if (ans%9==0)
        cout<<"Yes";
    else
        cout<<"No";

}


Measured memory_bytes: 3732
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		System.out.println(sc.nextInt() < 1200 ? "ABC" : "ARC");
	}
}

Measured memory_bytes: 22996
# N,M = map(int,input().split())
N = int(input())

cnt_odd = 0
cnt_even = 0

for i in range(1,N+1):
  if i % 2 == 0:
    cnt_even += 1
  else:
    cnt_odd += 1

ans = cnt_odd / (N)
print(ans)

Measured memory_bytes: 2940
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        #print(i,j,n-i-j,i*1000+j*5000+(n-i-j)*1000)
        if i+j > n:
            break
        elif i*10000+j*5000+(n-i-j)*1000 == y:
            print(i,j,n-i-j)
            exit()

print('-1 -1 -1')

Measured memory_bytes: 3060
from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積）
)

n = int(input())
Sm, Sa, Sr, Sc, Sh = set(), set(), set(), set(), set()
for _ in range(n):
    s = input()
    if s[0]=='M':
        Sm.add(s)
    elif s[0]=='A':
        Sa.add(s)
    elif s[0]=='R':
        Sr.add(s)
    elif s[0]=='C':
        Sc.add(s)
    elif s[0]=='H':
        Sh.add(s)

ans = 0
S = [len(Sm), len(Sa), len(Sr), len(Sc), len(Sh)]

for v1, v2, v3 in combinations(S, 3):
    ans += v1*v2*v3

print(ans)

Measured memory_bytes: 14316
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    int a,b; cin >> a >> b;
    string s; cin >> s;
    if(SIZE(s) != a+b+1) no();
    else if(s[a] != '-') no();
    else {
        rep(i,a) if(s[i] < '0' || s[i] > '9'){
            no();
            return 0;
        }
        for(int i = a+1; i < SIZE(s); i++){
            if(s[i] < '0' || s[i] > '9'){
                no();
                return 0;
            }
        }
        yes();
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll N;
    cin >> N;

    ll sum = 0;
    vector<int> A(100005, 0);
    rep(i, N) {
        ll num;
        cin >> num;
        ++A[num];
        sum += num;
    }

    int Q;
    cin >> Q;
    vector<pll> que(Q);
    rep(i, Q) {
        ll b, c;
        cin >> b >> c;
        que[i] = make_pair(b, c);
    }

    for (auto &x : que) {
        ll b = x.first;
        ll c = x.second;

        sum += (c - b) * A[b];
        cout << sum << endl;

        A[c] += A[b];

        A[b] = 0;
    }
}

Measured memory_bytes: 5056