akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl b = a;
    sort(all(b));
    map<ll,ll> mp;
    rep(i,n){
        mp[b[i]] = i % 2;
    }
    ll ans=0;
    rep(i,n){
        if(mp[a[i]] != i % 2) ans++;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int main(){
    int n;cin>>n;
    vector<int> d(n),cnt(n,0);
    for(int i=0;i<n;++i){
        cin>>d[i];
        cnt[d[i]]++;
    }
    bool flag=true;
    if(d[0]!=0) flag=false;
    if(cnt[0]!=1) flag=false;
    for(int i=1;i<n;++i){
        if(cnt[i-1]==0&&cnt[i]>0) flag=false;
    }
    if(!flag){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    ll mod=998244353;
    for(int i=0;i<n-1;++i){
        if(cnt[i]==0) break;
        ans=ans*mopow(cnt[i],cnt[i+1],mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4060
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int h,w,n;
int a[10010];
int ans[110][110];

int main() {
  cin>>h>>w;
  cin>>n;
  REP(i,n) cin>>a[i];
  int cur=0;
  REP(y,h)
  {
    if (y%2==0)
    {
      REP(x,w)
      {
        a[cur]--;
        ans[y][x] = cur+1;
        
        if (a[cur]==0) cur++;
      }
    }

    if (y%2==1)
    {
      REPB(x,w)
      {
        a[cur]--;
        ans[y][x] = cur+1;

        if (a[cur]==0) cur++;
      }
    }
  }

  REP(y,h)
  {
    REP(x,w) cout<<ans[y][x]<<" ";
    cout<<endl;
  }
  cout<<endl;
}


Measured memory_bytes: 384
'''
Created on 2020/09/04

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  H,W=map(int,pin().split())
  N=int(pin())
  a=list(map(int,pin().split()))
  l=[]
  for i in range(N):
    l+=[str(i+1) for _ in range(a[i])]
  s=1
  ans=[]
  for j in range(H):
    if s==1:
      ans=list(l[j*W:(j+1)*W])
      s=-1
    else:
      ans=list(l[j*W:(j+1)*W])
      ans.reverse()
      s=1
    u=" ".join(ans)
    print(u)
  return 
main()

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

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    int r[R];
    for(int i = 0; i < R; i++){
        cin >> r[i];
    }
    int roads[N][N];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            roads[i][j] = (i != j) * 1e9;
        }
    }
    for(int i = 0; i < M; i++){
        int start, goal, cost;
        cin >> start >> goal >> cost;
        roads[start - 1][goal - 1] = cost;
        roads[goal - 1][start - 1] = cost;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                roads[j][k] = min(roads[j][k], roads[j][i] + roads[i][k]);
            }
        }
    }
    sort(r, r + R);
    int ans = 2e9;
    do{
        int this_ans = 0;
        for(int i = 1; i < R; i++){
            this_ans += roads[r[i - 1] - 1][r[i] - 1];
        }
        ans = min(ans, this_ans);
    }while(next_permutation(r, r + R));
    cout << ans << endl;
}


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

// one-based numbering
template<class Abel> struct UnionFind {
	vector<int> data;
	vector<Abel> diff_weight;
	UnionFind(int n, Abel id) {
		data.resize(n+1, -1);
		diff_weight.resize(n+1, id);
	}
	int find(int x) {
		if(data[x] < 0) return x;
		else {
			int root = find(data[x]);
			diff_weight[x] += diff_weight[data[x]];
			return data[x] = root;
		}
	}
	int size(int x) {
		return -data[find(x)];
	}
	bool same(int x, int y) {
		x = find(x); y = find(y);
		return x == y;
	}
	bool unite(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = find(x); y = find(y);
		if(x == y) return false;
		if (data[x] > data[y]) swap(x, y), w = -w;
		data[x] += data[y];
		data[y] = x;
		diff_weight[y] = w;
		return true;
    }
	Abel weight(int x) {
		find(x);
		return diff_weight[x];
	}
	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
    int r, c, n; cin >> r >> c >> n;
    vector<vector<pair<int, long long>>> v(r+1);
    vector<long long> rv(r+1, 1e16), cv(c+1, 1e16);
    map<pair<int, int>, long long> m; 
    for (int i = 0; i < n; i++) {
        int c, d; long long a; cin >> c >> d >> a;
        v[c].emplace_back(d, a);
        m[{c, d}] = a;
    }
    UnionFind<long long> cuf(c, 0);
    for (auto vec: v) {
        if (vec.size() <= 1) continue;
        for (int i = 0; i < vec.size()-1; i++) {
            if (cuf.same(vec[i].first, vec[i+1].first)) {
                if (cuf.diff(vec[i].first, vec[i+1].first) != vec[i+1].second - vec[i].second) {
                    cout << "No" << endl;
                    return 0;
                }
            } else {
                cuf.unite(vec[i].first, vec[i+1].first, vec[i+1].second - vec[i].second);
            }
        }
    }
    map<long long, long long> mincv;
    for (int i = 1; i <= c; i++) {
        mincv[cuf.find(i)] = min(mincv[cuf.find(i)], cuf.weight(i));
    }
    for (int i = 1; i <= c; i++) {
        cv[i] = cuf.weight(i) - mincv[cuf.find(i)];
    }
    for (auto x: m) {
        long long t = x.second - cv[x.first.second];
        if (cv[x.first.second] == 1e16) t = 1e16;
        if (rv[x.first.first] != 1e16) {
            if (rv[x.first.first] != t) {
                cout << "No" << endl;
                return 0;
            }
        } else rv[x.first.first] = t;
    }
    sort(rv.begin(), rv.end());
    sort(cv.begin(), cv.end());
    if (rv.front() + cv.front() < 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 20992
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
   	int N; cin >> N;
   	vector<int> A(N+2);
   	A[0] = 0;
   	A[N+1] = 0;
   	for(int i = 1; i <= N; i++) cin >> A[i];
   	ll sum = 0;
   	for(int i = 0; i <= N; i++){
   	    sum += abs(A[i] - A[i+1]);
   	}
   	for(int i = 1; i <= N; i++){
   	    cout << sum - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]) << endl;
   	}
}



Measured memory_bytes: 1664
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int cl[120000];
int lst[120000];
vector <int> eds[120000];
int n,m,q;
void dfs(int v,int d,int c){
	if (!cl[v]) cl[v]=c;
	if (lst[v]>=d) return;
	lst[v]=d;
	if (d==0) return;
	for (int u: eds[v])
		dfs(u,d-1,c);
}
vector <tuple<int,int,int> > vv;
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		--a,--b;
		eds[a].push_back(b);
		eds[b].push_back(a);  
	}
	cin>>q;
	for (int i=0;i<q;i++){
		int v,d,c;
		cin>>v>>d>>c;
		--v;
		vv.push_back(make_tuple(v,d,c)); 
	}
	reverse (vv.begin(),vv.end());
	for (int i=0;i<q;i++){
		int v,d,c;
		tie(v,d,c)=vv[i];
		dfs(v,d,c);
	}
	for (int i=0;i<n;i++) cout<<cl[i]<<endl;
	return 0;
}

Measured memory_bytes: 9328
#include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<cmath>
    #include<climits>
    #include<iostream>
    #include<sstream>
    #include<utility>
    #include<map>
    #include<vector>
    #include<queue>
    #include<algorithm>
    #include<set>
    #include<stack>
    using namespace std;
    typedef unsigned long long ll;
    typedef pair<int,int>P;
     
    int main()
    {
    	int N;
    	ll T,a=1,b;
    	scanf("%d",&N);
    	for(int i=0;i<N;i++)
    	{
    		scanf("%lld",&T);
    		b=(a/__gcd(a,T)*T);
    		a=max(a,b);
    	}
    	cout<<a<<endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;

int n, i, mid;
pair<int, int> data[maxN];
int b[maxN];

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%d", &data[i].first);
        data[i].second = i;
    }

    sort(data + 1, data + n + 1);
    mid = n / 2;

    for (i = 1; i <= mid; i++) b[data[i].second] = data[mid + 1].first;
    for (i = mid + 1; i <= n; i++) b[data[i].second] = data[mid].first;

    for (i = 1; i <= n; i++) printf("%d\n", b[i]);


    return 0;
}


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

typedef long long ll;
using namespace std;

string s;
short dp[302][302][302];
int go(int l, int r, int k){
	if(l == r)
		return 1;
	if(l > r)
		return 0;
	if(dp[l][r][k] != -1)
		return dp[l][r][k];
	int ret = max(go(l + 1, r, k), go(l, r - 1, k));
	if(s[l] == s[r])
		ret = max(ret, go(l + 1, r - 1, k) + 2);
	else if(k)
		ret = max(ret, go(l + 1, r - 1, k - 1) + 2);
	return dp[l][r][k] = ret;
}

int main() {
	ios::sync_with_stdio(false);
	//	srand(time(NULL));
	int k; cin >> s >> k;
	memset(dp, -1, sizeof dp);
	cout << go(0, s.size() - 1, k) << endl;
	return 0;
}


Measured memory_bytes: 54144
import java.util.*;
public class Main {
    static int mod = 1000_000_007;
    static long[] frac;
    public static void main(String[] args) {
        frac = new long[200_001];
        frac[0] = 1;
        for (int i = 1; i < 200_001; i++) frac[i] = frac[i - 1] * i % mod;
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long ans = 0;
        for (int i = 0; i < h - a; i++) {
            ans += comb(i + b - 1, i) * comb(h + w - b - i - 2, w - b - 1) % mod;
            ans %= mod;
        }
        System.out.println(ans);
    }
    public static long comb(int a, int b) {
        return (frac[a] * modInv(frac[b]) % mod) * modInv(frac[a - b]) % mod;
    }
    public static long modInv(long n) {
        return exp(n, mod - 2) % mod;
    }
    public static long exp(long a, long b) {
        if (b == 0) return 1;
        if (b == 1) return a;
        long c = 1;
        if (b % 2 == 1) c = a;
        long d = exp(a, b / 2);
        return (d * d % mod) * c % mod;
    }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vll a(n);cin>>a[0];
    rep(i,n-1){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    int la,ra,ma,lb,rb,mb,ansa,ansb;ll minimum,maximum;
    ll ans=INF;
    rep2(i,1,n-2){
        la=0;ra=i;
        while(ra-la>1){
            ma=(la+ra)/2;
            if(a[ma]<a[i]-a[ma])la=ma;
            else ra=ma;
        }
        if(abs(a[la]-(a[i]-a[la]))<abs(a[ra]-(a[i]-a[ra])))ansa=la;
        else ansa=ra;
        lb=i+1;rb=n-1;
        while(rb-lb>1){
            mb=(lb+rb)/2;
            if(a[mb]-a[i]<a[n-1]-a[mb])lb=mb;
            else rb=mb;
        }
        if(abs((a[lb]-a[i])-(a[n-1]-a[lb]))<abs((a[rb]-a[i])-(a[n-1]-a[rb])))ansb=lb;
        else ansb=rb;
        maximum=max(a[ansa],max(a[i]-a[ansa],max(a[ansb]-a[i],a[n-1]-a[ansb])));
        minimum=min(a[ansa],min(a[i]-a[ansa],min(a[ansb]-a[i],a[n-1]-a[ansb])));
        ans=min(ans,maximum-minimum);
    }
    cout<<ans<<endl;
}


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

int N, M;
int a[50];
int b[50];
int dp[2][2][51][51][51][51];

const int INF = 1e9;

int f(int p, int pass, int ai, int an, int bi, int bn, int asum, int bsum) {
	int& d = dp[p][pass][ai][an][bi][bn];
	if(d != INF) return d;
	// pass
	int s = asum - bsum;
	int npass = pass;
	if(an == 0 && bn == 0) npass++;

	if(p == 0) {
		d = -INF;
		if(npass == 2) {
			d = max(d, s);
		}
		else {
			d = max(d, s + f(1 - p, npass, ai, 0, bi, 0, 0, 0));
		}
		// put
		if(ai < N) {
			int nasum = asum, nbsum = bsum;
			if(a[ai] == -1) nbsum = 0;
			else nasum += a[ai];
			d = max(d, f(1 - p, 0, ai + 1, an + 1, bi, bn, nasum, nbsum));
		}
	}
	else {
		d = INF;
		if(npass == 2) {
			d = min(d, s);
		}
		else {
			d = min(d, s + f(1 - p, npass, ai, 0, bi, 0, 0, 0));
		}
		// put
		if(bi < M) {
			int nasum = asum, nbsum = bsum;
			if(b[bi] == -1) nasum = 0;
			else nbsum += b[bi];
			d = min(d, f(1 - p, 0, ai, an, bi + 1, bn + 1, nasum, nbsum));
		}
	}
	return d;
}

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

	while(cin >> N >> M) {
		for(int i = 0; i < N; i++) {
			cin >> a[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> b[i];
		}
		fill((int*)begin(dp), (int*)end(dp), INF);
		cout << f(0, 0, 0, 0, 0, 0, 0, 0) << endl;
	}
}

Measured memory_bytes: 108928
#include <bits/stdc++.h>
using namespace std;
#define inf (1<<29)

int N,M,R;
int r[9];bool used[9];
long long int res;
long long int dp[201][201];


void dfs(int c,int las,int dist){
	
  if(c==R+1){
    if(res>dist)res=dist;
    return;
  }
  for(int i=1;i<=R;++i)if(!used[i]){
    used[i]=true;
    if(las==-1)dfs(c+1,i,0);
    else dfs(c+1,i,dist+dp[r[las]][r[i]]);
    used[i]=false;
  }
}

int main(){
  cin>>N>>M>>R;
  for(int i=1;i<=R;++i){
    cin>>r[i];
  }
  for(int i=1;i<=N;++i){
    for(int j=1;j<=N;++j){
      if(i!=j)dp[i][j]=inf;
    }
  }
  for(int i=1;i<=M;++i){
    int a,b,c;
    cin>>a>>b>>c;
    if(dp[a][b]>c)dp[a][b]=dp[b][a]=c;
  }

  for(int k=1;k<=N;++k){
    for(int i=1;i<=N;++i){
      for(int j=1;j<=N;++j){
          dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
        }
      }
    }
  res=inf;
  dfs(1,-1,0);
  cout<<res<<endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    d = inputList()
    
    ans = 0
    for i, val in enumerate(d):
        for j in range(i+1, N):
            vol = d[j]
            
            ans += val * vol
    
    print(ans)
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 40304
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		B.at(i) = A.at(i);
	}

	sort(A.begin(), A.end(), greater<int>());

	int max1 = A.at(0);
	int max2 = A.at(1);

	for (int i = 0; i < N; i++) {
		if (B.at(i) != max1) {
			cout << max1 << endl;
		}
		else {
			cout << max2 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main()
{
  string a,b;
  cin>>a;
  cin>>b;
  int l=a.length();
int c=0;
  for(int i=0;i<l;i++)
  {if(a[i]!=b[i])
    c++;
  }
  cout<<c;
  return 0;
  
}


Measured memory_bytes: 3880
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

double t, x;

void input() {
  cin >> t >> x;
}

void solve() {
  cout << t/x << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string s="XYZABCDEFGHIJKLMNOPQRSTUVW";
	string str;
	cin>>str;
	for(int i=0;i<str.length();i++){
		str[i]=s[str[i]-'A'];
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
using namespace std;
int main(void){
    
    int N,A,B,now=0,c_b = 0;
    string S;
    cin >> N >> A >> B >> S;
    
    int len = S.size();
    for(int i=0;i<len;i++){
        
        if(S.at(i) == 'a'){
            if(now < A + B){
                now++;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" <<endl;
            }
        }
        else if(S.at(i) == 'b'){
            c_b++;
            if(now < A + B && c_b <= B){
                now++;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" <<endl;
            }
        }
        else{
            cout << "No" <<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3732
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Edge[] edge=new Edge[m];
		for(int i = 0; i<m; i++){
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			long c = sc.nextLong();
			edge[i]=new Edge(a,b,-c);
		}
		long[] dist=new long[n];
		Arrays.fill(dist,Long.MAX_VALUE);
		dist[0]=0;
		boolean flag=true;
		int cnt=0;
		long ans=0;
		while(flag){
			flag=false;
			for(int i = 0; i<m; i++){
				if(dist[edge[i].from]!=Long.MAX_VALUE && dist[edge[i].to]>dist[edge[i].from]+edge[i].cost){
					flag=true;
					dist[edge[i].to]=dist[edge[i].from]+edge[i].cost;
				}
			}
			if(cnt==n){
				ans=-dist[n-1];
			}
			if(cnt==2*n){
				if(ans<-dist[n-1]){
					System.out.println("inf");
					return;
				}
				break;
			}
			cnt++;
		}
		System.out.println(-dist[n-1]);
	}
	static class Edge{
		int from;
		int to;
		long cost;
		public Edge(int from,int to,long cost){
			this.from=from;
			this.to=to;
			this.cost=cost;
		}
	}
}


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

typedef long long LL;
const LL N = 10010;
LL a[N], b[N], c[N];
LL n;
bool v[N];

inline LL gcd(LL a, LL b)
{
    return (b ? gcd(b, a % b) : a);
}
/*bool ok(int p) {
    if (a[0] % p) {
        return false;
    }
    for (int i = 0; i <= n; ++i) {
        b[i] = a[i];
    }
    for (int i = n; i >= p - 1; --i) {
        (b[i - (p - 1)] += b[i]) %= p;
        b[i] = 0;
    }
    for (int i = 0; i <= n; ++i) {
        if (b[i] % p) {
            return false;
        }
    }
    return true;
}*/
bool isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)return false;
    }
    return true;
}
int main()
{
    register LL p = 0, num = 0;
    scanf("%lld", &n);
    for (register LL i = n; i >= 0; --i) {
        scanf("%lld", &a[i]);
        p = gcd(p, abs(a[i])), b[i] = a[i];
    }
    /*for (register LL i = 2, q; i <= n; ++i) {
        if (v[i] == 1) continue;
        for (register LL j = 0; j <= n; ++j)
            a[j] = b[j];
        for (register LL j = n; j >= i - 1; --j)
            a[j - (i - 1)] = (a[j] + a[j - (i - 1)]) % i, a[j] = 0;
        int f=0;
        for (register LL j = 0; j <= n; ++j) {
            if (a[j] % i != 0) //goto nxt;
            {
                f=1;
                break;
            }
        }
        if(!f) c[++num] = i;
        //nxt:;
        q = n / i;
        for (register LL j = i; j <= q; ++j)
            v[i * j] = 1;
    }*/
    for(int i=2;i<=n;i++){
    if(!isprime(i))continue;
    if(b[0]%i!=0)continue;
    for (register LL j = 0; j <= n; ++j)
            a[j] = b[j];
        for (register LL j = n; j >= i - 1; --j)
            a[j - (i - 1)] = (a[j] + a[j - (i - 1)]) % i, a[j] = 0;
        int f=0;
        for (register LL j = 0; j <= n; ++j) {
            if (a[j] % i != 0) //goto nxt;
            {
                f=1;
                break;
            }
        }
        if(!f) c[++num] = i;
    }
    /*for(int i=2;i<=n;i++)
    {
        if(isprime(i)&&ok(i))c[++num]=i;
    }*/
    for (register LL i = 2; i*i <= p; ++i) {
        if (p % i == 0) {
            c[++num] = i;
            while (p % i == 0) p = p / i;
        }
    }
    if (p > 1) c[++num] = p;
    sort(c + 1, c + num + 1);
    for (register int i = 1; i <= num; ++i) {
        if (c[i] == c[i - 1]) continue;
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));


int dp[11000];

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

    ll H,W;
    int N;
    cin>>H>>W>>N;

    map<pll,int> M;
    for(int i=0;i<N;i++){
        ll a,b;
        cin>>a>>b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                M[pll(a+j,b+k)]++;
            }
        }
    }
    ll count[10]={};
    ll sum=0;
    for(auto it:M){
        int h=it.first.first,w=it.first.second;
        int x=it.second;
        if(h<=H && w<=W && h>=3 && w>=3){
            count[x]++;
            sum++;
        }
    }
    count[0]=(H-2)*(W-2)-sum;
    for(int i=0;i<10;i++){
        cout<<count[i]<<endl;
    }
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 1e5 + 41;

int n;
int a[MAX];
int F[MAX];

void upd(int x, int v) {
	while (x < MAX) {
		F[x] += v;
		x |= (x + 1);
	}
}

int getsum(int x) {
	int res = 0;
	while (x >= 0) {
		res += F[x];
		x = (x & (x + 1)) - 1;
	}
	return res;
}

ll calc(vi &b) {
	memset(F, 0, sizeof(F));	

	int sum = 0;
	vi vh;
	fi(0, sz(b) - 1) {
		sum += b[i];
		vh.pb(sum);
	}
	vh.pb(0);
	sort(vh.begin(), vh.end());
	vh.resize(unique(vh.begin(), vh.end()) - vh.begin());

	sum = 0;
	ll res = 0;

	fi(0, sz(vh) - 1) {
		if (vh[i] == 0) {
			upd(i, 1);
		}
	}

	fi(0, sz(b) - 1) {
		sum += b[i];
		int pos = (int) (lower_bound(vh.begin(), vh.end(), sum) - vh.begin());
		upd(pos, 1);
		int cur = (i + 2) - getsum(pos);
		res += cur;
	}
	err("res = %lld\n", res);
	return res;
}

void solve() {
	vi v;
	fi(1, n) {
		v.pb(a[i]);
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());

	ll want = (1LL + n) * n / 2 / 2 + 1;
	err("want = %lld\n", want);

	int l = -1;
	int r = sz(v);
	while (r - l > 1) {
		int h = (l + r) / 2;
		vi b;
		int cur = v[h];
		fi(0, n - 1) {
			if (a[i + 1] <= cur) {
				b.pb(-1);
			} else {
				b.pb(1);
			}
		}
		ll resp = calc(b);
		//
		err("cur = %d\n", cur);
		err("b: ");
		for (int x : b) {
			err("%d ", x);
		}
		err("\n want = %lld resp  %lld\n", want, resp);
		//
		if (resp >= want) {
			r = h;
			err("take r\n");
		} else {
			l = h;
			err("take l\n");
		}
	}
	printf("%d\n", v[r]);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n) {
  	scanf("%d", &a[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l.rbegin(), l.rend());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += l[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;
    if(a % x == 0){
        cout << b / x - a / x + 1 << "\n";
    }else{
        cout << b / x - a / x << "\n";
    }
    return 0;
}


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

using namespace std;

using Graph = vector<vector<bool>>;

void Dfs(const Graph &g, int node, vector<bool> &visited)
{
    visited[node] = true;
    for (size_t i = 0; i < g.size(); i += 1) {
        if (g[node][i] && !visited[i]) {
            Dfs(g, i, visited);
        }
    }
}

bool IsConnected(const Graph &g)
{
    vector<bool> visited(g.size(), false);
    Dfs(g, 0, visited);

    return all_of(visited.begin(), visited.end(), [](bool b) { return b; });
}

int CountBridges(Graph &g)
{
    int bridges = 0;
    for (size_t i = 0; i < g.size(); i += 1) {
        for (size_t j = i + 1; j < g.size(); j += 1) {
            if (!g[i][j]) {
                continue;
            }

            g[i][j] = g[j][i] = false;
            bridges += (IsConnected(g) ? 0 : 1);
            g[i][j] = g[j][i] = true;
        }
    }
    return bridges;
}

int main()
{
    int nodes, edges;
    cin >> nodes >> edges;

    Graph graph(nodes, vector<bool>(nodes, false));
    for (int i = 0; i < edges; i += 1) {
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }

    int bridges = CountBridges(graph);
    cout << bridges << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for( i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    int ans=0;
    rep(i,n) {
        cin >> a[i];
        ans+=a[i];
    }
    sort(a.begin(),a.end());
    if (ans%10==0) {
        rep(i,n) {
            if (a[i]%10>0) {
                ans-=a[i];
                break;
            }
        }
    }
    if (ans%10==0) ans=0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  vl a(3*n);
  rep(i,3*n) cin >> a.at(i);
  priority_queue<long, vl, greater<long>> que1;
  priority_queue<long> que2;
  vl l(n+1);
  vl r(n+1);
  rep(i,n){
    l.at(0) += a.at(i);
    que1.push(a.at(i));
  }
  rep(i,n){
    if(que1.top() < a.at(n+i)){
      l.at(i+1) = l.at(i) - que1.top() + a.at(n+i);
      que1.pop();
      que1.push(a.at(n+i));
    }else{
      l.at(i+1) = l.at(i);
    }
  }
  reverse(all(a));
  rep(i,n){
    r.at(0) += a.at(i);
    que2.push(a.at(i));
  }
  rep(i,n){
    if(que2.top() > a.at(n+i)){
      r.at(i+1) = r.at(i) - que2.top() + a.at(n+i);
      que2.pop();
      que2.push(a.at(n+i));
    }else{
      r.at(i+1) = r.at(i);
    }
  }
  long ans = l.at(0) - r.at(n);
  rep(i,n){
    ans = max(ans, l.at(i+1) - r.at(n-i-1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 6516
s = input()
if s == 'MON':
	print(6)
elif s == 'TUE':
	print(5)
elif s == 'WED':
	print(4)
elif s == 'THU':
	print(3)
elif s == 'FRI':
	print(2)
elif s == 'SAT':
	print(1)
else:
	print(7)


Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(100000)

n, k = map(int, input().split())
edges = [[] for _ in range(n)]
for a, b in [map(int, input().split()) for _ in range(n - 1)]:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

mod = 1000000007
def dfs(v, p, c):
    ret = max(k - c, 0)
    used = 1 + (1 if p >= 0 else 0)
    for w in edges[v]:
        if w != p:
            ret = (ret * dfs(w, v, used)) % mod
            used += 1
    return ret
print(dfs(0, -1, 0))

Measured memory_bytes: 93588
K = int(input())


def ns(n):
    ret, tmp = 0, n

    while tmp > 0:
        tmp, r = divmod(tmp, 10)
        ret += r

    return ret


ans, base = 0, 1
for _ in range(K):
    ans += base
    print(ans)

    if (ans + base) / ns(ans + base) > (ans + 10 * base) / ns(ans + 10 * base):
        base *= 10

Measured memory_bytes: 38640
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int solve(char num[12]){
    int q[11] = {2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6};
    int sum = 0;
    rep(i,11){
        sum += q[i] * (num[10 - i] - '0');
    }
    int mo = sum % 11;
    if(mo <= 1 && num[11] - '0' == 0){
        return 1;
    }
    if(11 - mo == num[11] - '0'){
        return 1;
    }
    return 0;
}

int main(){
    char num[12];
    int point;
    while(cin >> num){
        int ans = -1, count = 0;
        rep(i,12){
            if(num[i] == '?'){
                point = i;
                break;
            }
        }
        rep(i,10){
            num[point] = '0' + i;
            count += solve(num);
            if(count && ans == -1) ans = i;
            if(count == 2) break;
        }
        if(count != 2) cout << ans << endl;
        else cout << "MULTIPLE" << endl;
    }
}

Measured memory_bytes: 1144
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << s.substr(0, s.length() - 8) << "\n";
}


Measured memory_bytes: 768
/*相信玄学*/
#include<bits/stdc++.h>
using namespace std;
int a[200010],n,b[200010]={0};
int main()
{
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]+=1;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string now;
        cin >> now;
        s.insert(now);
    }
    cout << s.size() << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const ll MOD = (ll) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	string s;
	cin >> n >> s;
	
	ll cnt[26] = {};
	rep(i, n) {
		cnt[s[i] - 'a']++;
	}
	
	ll sum = 0;
	rep(i, n) {
		ll add = 1;
		rep(j, 26) {
			if (s[i] - 'a' != j) {
				add *= cnt[j] + 1;
				add %= MOD;
			}
		}
//		cout << add << endl;
		sum += add;
		cnt[s[i] - 'a']--;
	}
	sum %= MOD;
	cout << sum << endl;
	
	return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  vll b(n, 1);
  vb cand(n);
  cand[0] = true;
  rep(i, m) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    b[x]--;
    b[y]++;
    if (cand[x]) {
      cand[y] = true;
    }
    if (b[x] == 0) {
      cand[x] = false;
    }
  }

  ll ans = 0;
  rep(i, n) {
    if (cand[i])
      ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{    
    int sum = 0;
    rep(i,3) 
    {
        int a;
        cin >> a;
        sum += a;
    }

    cout << (sum >= 22 ? "bust" : "win") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/


int main()
{
  string s;cin>>s;
  if(s[2]==s[3] && s[4]==s[5]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
vector<P> v,v2;
string s;
int n,a,b,ok,ok2,A,B,cnt1,cnt2;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        a=0;
        b=0;
        for(int j=0;j<s.size();j++){
            if(s[j]=='('){
                cnt1++;
                a++;
            }
            else{
                cnt2++;
                if(a>0)a--;
                else b++;
            }
        }
        if(a>=b)v.push_back({b,a});
        else v2.push_back({a,b});
    }
    sort(v.begin(),v.end());
    sort(v2.begin(),v2.end());
    reverse(v2.begin(),v2.end());
    for(auto x:v){
        A-=x.F;
        if(A<0){cout<<"No"<<endl;return 0;}
        A+=x.S;
    }
    for(auto x:v2){
        A-=x.S;
        if(A<0){cout<<"No"<<endl;return 0;}
        A+=x.F;
    }
    if(A==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 11224
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void) {
	string S;
	cin >> S;
	string answer = "AC";
	if (S[0] != 'A') answer = "WA";

	int CCount = 0;
	int l = S.length();
	for (int i = 1; i < l; i++) {
		if (isupper(S[i])) {
			if (i == 1 || i == l - 1 || S[i] != 'C') answer = "WA";
			CCount++;
		}
	}
	if (CCount != 1) answer = "WA";

	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;

class Program
{
    static void Main()
    {
        var (a, b) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var d = b - a;

        var ans = (d + 1) * d / 2 - b;

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28000
class Node:
    def __init__(self, key):
        self.key = key
        self.prev = None
        self.next = None

class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil

    def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil

    def listSearch(self, key):
            cur = self.nil.next
            while cur != self.nil and cur.key != key:
                cur = cur.next
            return cur

    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

    def deleteFirst(self):
        self.deleteNode(self.nil.next)

    def deleteLast(self):
        self.deleteNode(self.nil.prev)

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key))

if __name__ == '__main__':
    import sys
    input = sys.stdin.readline  # 入力の高速化

    n = int(input())

    dll = DoublyLinkedList()

    for _ in range(n):
        '''
        以下のようにcomとkeyに分けるとTimeLimitExceededになるので、comだけで処理しました
        (別のいい方法があれば教えて欲しいです)
        com, *key = input().split()
        この場合keyがリストになるので、com[7:]をkey[0]で置き換える必要があります。
        (xがない命令ではkey=[]となるだけ)
        '''
        com = input().rstrip()
        # 以下、本と順番など多少異なります
        if com[0] == 'i':
            dll.insert(com[7:])
        elif com[6] == 'F':
            dll.deleteFirst()
        elif com[6] == 'L':
            dll.deleteLast()
        else:
            dll.deleteKey(com[7:])

    cur = dll.nil.next
    ans = []
    while cur != dll.nil:
        ans.append(cur.key)
        cur = cur.next

    print(' '.join(ans))


Measured memory_bytes: 227604
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

typedef long long ll;

ll N;
ll st[200007], arriba[200007];
int color[200007];
ll ans[200007];
vector<int>G[200007];

void dfs( int node, int padre ){

    if(G[node].size() == 1 && padre != -1){
        st[node] = 1;
        return;
    }

    for(int i = 0; i < G[node].size(); i++){
        int ady = G[node][i];
        if(ady == padre) continue;
        dfs(ady, node);
        st[node] += st[ady];
    }
    st[node] += 1;
}


void dfs1(int node, int padre){

    ans[color[node]] += (N - st[node] - arriba[color[node]] + 1ll)*st[node];

    ll abaj = st[node] - 1;

    for(int i = 0; i < G[node].size(); i++){
        int ady = G[node][i];
        if(ady !=  padre)
         abaj -= st[ady],
         ans[color[node]] += abaj*st[ady];
    }


    int aribb = arriba[color[node]];
    for(int i = 0; i < G[node].size(); i++){
        int ady = G[node][i];
        if(ady ==  padre)
         continue;

         arriba[color[node]] = N - st[ady];
         dfs1(ady, node);
    }
    arriba[color[node]] = aribb + st[node];
}

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

    cin >> N;


    for(int i = 1; i <= N; i++)
        cin >> color[i];
    int a, b;

    for(int i = 1; i < N; i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(1, -1);
    dfs1(1, -1);


    for(int i = 1; i <= N; i++)
     cout << ans[i] << '\n';

    return 0;
}


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

int main() {
  int h,w,n;
  cin >> h >> w >> n;
  
  int max;
  if(h > w)
    max = h;
  else
    max = w;

  int ans = n/max;

  if(ans * max >= n){
    cout << ans << endl;
  }else{
      cout << ans + 1 << endl;
    }
}


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

int main(){
    vector<int> v = vector<int>();
    int n, k, buf;
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> buf;
        v.push_back(buf);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for(int i=0; i<k; i++)
        sum += v[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	int x ;
	scanf ("%d", &x) ;
	
	if (x >= 30)
		cout << "Yes" << endl ;
	else
		cout << "No" << endl ;

	return 0 ;
}

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

int main()
{
	vector<int> v(3);
	for (auto& t : v) {
		cin >> t;
	}

	sort(v.begin(), v.end());

	cout << v[0] * v[1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set> 
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int d;
 cin>>d;
 if (d==25)
 cout<<"Christmas\n";
 if (d==24)
 cout<<"Christmas Eve\n";
 if (d==23)
 cout<<"Christmas Eve Eve\n";
 if (d==22)
 cout<<"Christmas Eve Eve Eve\n"; 
 system("pause");
 return 0;  }

Measured memory_bytes: 504