akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int A, B;
  cin >> A >> B;
  if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  int X,Y,Z;
  cin >> X >> Y>>Z;
  int X2,Y2,Z2;
  X2=X;
  Y2=Y;
  Z2=Z;
  X=Z;
  Y=X2;
  Z=Y2;
  
  cout<<X<<" " << Y <<" "<<Z<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector<int> a[100010], b[100010];
int ans[100010];
int dfs(int x, int pa, int k){
    int tmp=1;
    for(int i=0; i<a[x].size(); ++i){
        if(a[x][i]==pa)
            continue;
        while(tmp==k)
            ++tmp;
        ans[b[x][i]]=tmp;
        dfs(a[x][i], x, tmp);
        ++tmp;
    }
}
int main(){
    int n;
    while(cin>>n){
        int x, y, mx=0;
        for(int i=0; i<n-1; ++i){
            scanf("%d%d",&x,&y);
            a[x].push_back(y);
            a[y].push_back(x);
            b[x].push_back(i);
            b[y].push_back(i);
            mx=max(mx, (int)(a[x].size()));
            mx=max(mx, (int)(a[y].size()));
        }
        dfs(1,-1,-1);
        cout<<mx<<endl;
        for(int i=0; i<n-1; ++i){
            cout<<ans[i]<<endl;
        }
    }
  return 0;
}




Measured memory_bytes: 13440
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

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

#define N 200005
ll n;
ll a[N];
stack<l_l>s;

void debug(ll m){
    cout<<m<<":";
    vector<l_l>v;
    while(!s.empty()){v.pb(s.top());s.pop();}
    reverse(v.begin(),v.end());
    for(auto x:v){
        rep(zz_,1,x.se)cout<<x.fi;
        s.push(x);
    }cout<<endl;
}

bool check(ll m){
    while(!s.empty())s.pop();
    ll l=0;
    rep(i,0,n-1){
        if(i==0){
            s.push({1,a[0]});
            l=a[0];
            //debug(m);
            continue;
        }
        if(l<a[i]){
            s.push({1,a[i]-l});
            l=a[i];
            //debug(m);
            continue;
        }
        bool f=true;
        while(!s.empty()){
            l_l fro=s.top();s.pop();
            if(l<a[i])f=false;
            l-=fro.se;
            if(l<a[i] && fro.fi!=m){
                if(f){
                    if(a[i]-l-1>=1)s.push({fro.fi,a[i]-l-1});
                    s.push({fro.fi+1,1});
                    l=a[i];
                }else{
                    if(fro.se-1>=1)s.push({fro.fi,fro.se-1});
                    s.push({fro.fi+1,1});
                    l+=fro.se;
                    if(a[i]-l>=1)s.push({1,a[i]-l});
                    l=a[i];
                }
                break;
            }
        }
        if(s.empty())return false;
        
        
        //debug(m);
    }
    return true;
}

int main(){fastio
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    ll ok=n+1,ng=0;
    while(abs(ok-ng)>1){
        ll m=(ok+ng)/2;
        if(check(m))ok=m;
        else ng=m;
    }
    cout<<ok<<endl;
    
    return 0;
}


Measured memory_bytes: 5172
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] sum = new int[26];
        for(int i = 0; i<26; i++) sum[i] = 0;
        while(sc.hasNextLine()){
        String S = sc.nextLine();
        String LS = S.toLowerCase();
        
        
        for(int i = 0; i<LS.length(); i++){
            char c = LS.charAt(i);
            if(c >= 97 && c<=122){
            sum[c-97]++;
            }
        }
        }
        for(int i = 0; i<26; i++){
            System.out.printf("%c : %d\n", i+97, sum[i]);
        }
        sc.close();
    }
}


Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> m(n);
  for(int i=0;i<n;i++){
    cin>>m[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans++;
    x-=m[i];
  }
  sort(m.begin(),m.end());
  while(m[0]<=x){
    ans++;
    x-=m[0];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

typedef long long ll;

int pow_mod(ll m, int n, int mod){
    ll x = 1;
    m = m % mod;
    while (n > 0) {
        if (n&1) {
            x = (x*m)%mod;
        }
        n >>= 1;
        m = (m*m)%mod;
    }
    return x;
}

int main(){
    int m,n;
    cin >> m >> n;
    printf("%d\n",pow_mod(m,n,1000000007));
    
    return 0;
}

Measured memory_bytes: 1144
import Data.Char
main = do
  [a,b,c,d] <- map digitToInt <$> getLine
  putStrLn $ f (a*10+b) (c*10+d)

f x y
  | isM x && isM y       = "AMBIGUOUS"
  | isM x && not (isM y) = "MMYY"
  | not (isM x) && isM y = "YYMM"
  | otherwise            = "NA"
  where
    isM n = 1 <= n && n <= 12

Measured memory_bytes: 380
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {


  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  printf("%d\n", a * b / 2);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> sraim{S[0]};
    for(int i = 1; i < N; i++){
        if(sraim.back() != S[i]){
            sraim.push_back(S[i]);
        }
    }
    cout << sraim.size();
}


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

#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

#define LOWBIT(x) ((x)&(-x))

#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
    static const int BUF = 1e7;
    static char buf[BUF], *bg = buf + BUF, *ed = bg;

    if(bg == ed) fread(bg = buf, 1, BUF, stdin);
    return *bg++;
}

inline int ri(){
    int x = 0, f = 1, c = gc();
    for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
    for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
    return x*f;
}

typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 3e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

LL N, M, K;

int main(){
    INIT();
    cin >> M >> K;
    N = (1 << M) - 1;

    if(K > N) cout << -1 << endl;
    else if(M == 1) {
        if(K == 1) cout << -1 << endl;
        else cout << "0 0 1 1" << endl;
    }
    else {
        For(i, 0, N) if(i != K) cout << i << " ";
        cout << K << " ";
        rFor(i, N, 0) if(i != K) cout << i << " ";
        cout << K << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
def p_e():
    h, w = map(int, input().split())
    t1 = [list(map(int, input().split())) for _ in range(h)]
    t2 = [list(map(int, input().split())) for _ in range(h)]
 
    # pythonでbitsetを用いる->boolのDPで2進数の1をTrue, 0をFalseとして扱う
    # 右にxシフト = その値にx足した値    (10001)<<4 -> (100010000)
    m = 160 * 80
    dp = [[0] * w for _ in range(h)]
    dp[0][0] = 1 << m
    for i in range(h):
        for j in range(w):
            v = abs(t1[i][j] - t2[i][j])
            if i > 0:
                dp[i][j] |= dp[i - 1][j]
            if j > 0:
                dp[i][j] |= dp[i][j - 1]
            dp[i][j] = (dp[i][j] << v) | (dp[i][j] >> v)
 
    ans = m
    for i in range(m * 2):
        if dp[h - 1][w - 1] & (1 << i) > 0:
            ans = min(ans, abs(m - i))
    print(ans)
    
p_e()

Measured memory_bytes: 57820
n = int(input())

R = list()
for i in range(n):
    R.append(int(input()))

differ_max = -2*10**9
rate_min = R[0]

for R_i in range(1, len(R)):
    differ_max = max(differ_max, R[R_i] - rate_min)
    rate_min = min(rate_min, R[R_i])

print(differ_max)


Measured memory_bytes: 13584
#include<stdio.h>
#include<string.h>

#define MAX 1000
#define MAX_A 150

int q;

int lcs(char* X,char*Y){
  int c[MAX+1][MAX+1];
  int n,m,max=0,i,j;
  n=strlen(X);
  m=strlen(Y);

  for(i=0;i<=n;i++){c[i][0]=0;}
  for(i=0;i<=m;i++){c[0][i]=0;}

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      if(X[i]==Y[j]){c[i+1][j+1]=c[i][j]+1;}
      else{
        if(c[i][j+1]>c[i+1][j]){c[i+1][j+1]=c[i][j+1];}
        else{c[i+1][j+1]=c[i+1][j];}
      }
      if(max<c[i+1][j+1])
      max=c[i+1][j+1];
    }
  }
  return max;
}

int main(){
  char x[MAX],y[MAX];
  int i,ans[MAX_A];

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%s",x);
    scanf("%s",y);
    ans[i]=lcs(x,y);
  }
  for(i=0;i<q;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}



Measured memory_bytes: 5660
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

// sの中に含まれるfromを全てtoに置換する
void replaceAll(string &s, string from, string to) {
  int pos;
  int len = from.size();
  while ((pos = s.find(from)) != string::npos) {
    s.replace(pos, len, to);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)
  
  string s; cin >> s;
  replaceAll(s, ",", " ");
  outl(s)
}


Measured memory_bytes: 888
#include <stdio.h>

#define MAX 10000

int main(){
  int n;
  long long num[MAX] = {};
  int count = 0;

  scanf("%d", &n);
  
  for(int i  = 0; i < n; i++){
    scanf("%lld", &num[i]);
  }

  for(int i = 0; i < n;){
    if(num[i]%2 == 1 || num[i] == 0){
      i++;
    } else{
      num[i] /= 2;
      count++;
    }
  }

  printf("%d", count);
  return 0;
}


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

int N;
std::vector<std::array<int64_t, 3>> position;

bool match(int, int);
int64_t calcHeight(int, int);

int main()
{
	scanf("%d", &N);
	position.resize(N);
	for (auto& e: position)
		for (auto& f: e)
			scanf("%lld", &f);
	for (int i{}; i <= 100; i++)
		for (int j{}; j <= 100; j++)
			if (match(i, j))
			{
				printf("%d %d %lld\n", i, j, calcHeight(i, j));
				break;
			}

	return 0;
}

bool match(int x, int y)
{
	int64_t height{calcHeight(x, y)};
	for (auto& e: position)
		if (e[2] != std::max((int64_t)0, height - std::abs(e[0] - x) - std::abs(e[1] - y)))
			return false;
	return true;
}

int64_t calcHeight(int x, int y)
{
	for (auto& e: position)
		if (e[2] != 0)
		return e[2] + std::abs(e[0] - x) + std::abs(e[1] - y);
	return (int64_t)-1;
}

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

using namespace std;

#define ll long long 

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

	int len = 5;
	vector<ll> arr(len);
	for (int i = 0; i < len; i++)
	{
		cin >> arr[i];
	}

	ll minEl = *min_element(arr.begin(), arr.end());

	if (n % minEl != 0)
	{
		cout << n / minEl + 5;
	}
	else 
	{
		cout << n / minEl + 4;
	}

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 210000;
const int K = 1000000;
const int mod = 200003;
int a[N], cnt[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int j = 1; j <= k; j++){
        memset(cnt, 0, sizeof(cnt));
        for (int i = 1; i <= n; i++){
            cnt[max(1LL, i - a[i])]++;
            cnt[min(n + 1, i + a[i] + 1)]--;
        }
        int x = 0;
        int q = 1;
        for (int i = 1; i <= n; i++){
            x += cnt[i];
            a[i] = x;
            if (x != n) q = 0;
        }
        if (q) break;
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
}


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



int main(){
    int n;
    cin>>n;
    long long a[n];
    int cnt=0,zero=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0) zero++;
        else if(a[i]<0) cnt++;
    }
    long long ans=0;
    if(zero){
        for(int i=0;i<n;i++){
            ans+=abs(a[i]);
        }
    }
    else{
        if(cnt%2==0){
            for(int i=0;i<n;i++)
            ans+=abs(a[i]);
        }
        else {
            long long m=1e9;
            for(int i=0;i<n;i++){
                ans+=abs(a[i]);
                m=(long long)min(abs(a[i]),m);
            }
            ans-=m;
            ans-=m;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n, x, a[2010];
int dp[2010][2010];
signed main() {
	cin >> n >> x;
	rep(i, n) {
		cin >> a[i];
		dp[0][i] = a[i];
	}
	for (int i = 1; i < n; i++) {
		rep(j, n) {
			dp[i][j] = min(dp[i - 1][j], a[(j - i + n) % n]);
		}
	}
	int ans = INF;
	rep(i, n) {
		int cnt = i*x;
		rep(j, n) {
			cnt += dp[i][j];
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

// ????°??????¨???
struct EdgeC{
  int to, cap, cost, rev;
  EdgeC(int to_=0, int cap_ = 0, int cost_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), cost(cost_), rev(rev_){}
};
using GraphC = vector<vector<EdgeC>>;
void add_edge(GraphC& G, int from, int to, int cap, int cost){
  G[from].emplace_back(to, cap, cost, G[to].size());
  G[to].emplace_back(from, 0, -cost, G[from].size()-1);
}

/**
 * ?????????????????????????????????
 * O(FVE)
 * ?§????s, ??????t, ?????????f ???????°??????¨?????? ?????¨??????????????°-INF
 */
int min_cost_flow(GraphC& G, int s, int t, int f){
  int V = G.size();
  vector<int> dist(V);
  vector<int> prevv(V), preve(V);
  int res = 0;
  
  while(f > 0){
	fill(begin(dist), end(dist), INF);
	dist[s] = 0;
	bool update = true;
	while(update){
	  update = false;
	  for(int v=0;v<V;++v){
		if(dist[v] == INF) continue;
		for(unsigned int i=0;i<G[v].size();++i){
		  auto& e = G[v][i];
		  if(e.cap > 0 && dist[v] + e.cost < dist[e.to]){
			dist[e.to] = dist[v] + e.cost;
			prevv[e.to] = v;
			preve[e.to] = i;
			update = true;
		  }
		}
	  }
	}
	if(dist[t] == INF) return -INF;

	int d = f;
	for(int v=t;v!=s;v=prevv[v])
	  d = min(d, G[prevv[v]][preve[v]].cap);

	f -= d;
	res += d * dist[t];
	for(int v=t;v!=s;v=prevv[v]){
	  auto& e = G[prevv[v]][preve[v]];
	  e.cap -= d;
	  G[v][e.rev].cap += d;
	}
  }
  
  return res;
}


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

  int V, E, F;
  cin >> V >> E >> F;
  GraphC G(V);
  REP(i,E){
	int u, v, c, d;
	cin >> u >> v >> c >> d;
	add_edge(G, u, v, c, d);
  }
  int res = min_cost_flow(G, 0, V-1, F);
  cout << (res==-INF?-1:res) << endl;

  return 0;
}

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

int main(){
int A,B,C,X;
cin>>A>>B>>C>>X;
int cnt=0;
for(int a=0;a<=A;a++){
for(int b=0;b<=B;b++){
for(int c=0;c<=C;c++){
if(500*a+100*b+50*c==X){
cnt++;
}
}
}
}
cout <<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int p, q, r;
	cin >> p >> q >> r;
	
	int ans[3];
	ans[0] = p + q;
	ans[1] = p + r;
	ans[2] = q + r;
	
	int min = ans[0];
	for (int i = 0; i < 3; i++) {
		if (ans[i] < min) {
			min = ans[i];
		}
	}
	
	cout << min << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Integer a[] = new Integer[n];
    
    boolean approved = true;
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
        approved = false;
        break;
      }
    }
    
    if (approved) {
      System.out.println("APPROVED");
    } else {
      System.out.println("DENIED");
    }
  }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

lint pow_mod(lint base,lint expo) { 
   lint ret = 1;
   for(;expo;) { 
      if(expo&1)  ret = (ret*base)%MOD; 

      expo = (expo>>1);
      base = (base*base)%MOD;
   }
   return ret;
}

/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  float r;
  cin >> r;

  cout << 3.14159265358979323846264338327950288419716939937510 * 2 * r << endl;
}

int main(){   
  
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

 solve();

 return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>
int a[1000001];
main(){
  int i,j,cnt=0,n=1000000,b;
  for(i=2;i<=n;i++){
    if(a[i]==0){
      for(j=2;i*j<=n;j++){
    a[i*j]=1;
      }    
    }
  }
  while(1){
    scanf("%d",&b);
    if(b==0)break;
    for(i=2;i<=b/2;i++){
      if(a[i]==0&&a[b-i]==0)cnt++;
    }
    printf("%d\n",cnt);
    cnt=0;
  }
  return 0;
}

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

int main()
{
	int E, Y;
	cin >> E;
	cin >> Y;
	if (E == 0) {
		if (Y > 1988) {
			cout << 'H' << Y - 1988<<endl;
			Y = 0;
		}
		if (Y > 1925) {
			cout << 'S' << Y - 1925<<endl;
			Y = 0;
		}
		if (Y > 1911) {
			cout << 'T' << Y - 1911<<endl;
			Y = 0;
		}
		if (Y != 0) {
			cout << 'M' << Y - 1867<<endl;
		}
	}
	if (E == 1) {
		cout << Y + 1867<<endl;
	}
	if (E == 2) {
		cout << Y + 1911<<endl;
	}
	if (E == 3) {
		cout << Y + 1925<<endl;
	}
	if (E == 4) {
		cout << Y + 1988<<endl;
	}
	return 0;
}

Measured memory_bytes: 3088
import java.io.*;
import java.util.*;

class Main {

    void solve(){

	Scanner sc = new Scanner( System.in );
	int n = sc.nextInt();
	
	int max_t = 0;
	int[] timing = new int[n];
	for ( int i=0; i<n; ++i ) {
	    timing[i] = sc.nextInt();
	    if ( timing[i] > max_t ) max_t = timing[i];
	}

	ArrayList< Integer > divisor = new ArrayList< Integer >();
	
	for ( int i=1; i<=max_t>>1; ++i ) {
	    if ( max_t%i == 0 ) divisor.add( i );
	}
	divisor.add( max_t );

	int adj = 0;
	for ( int t : timing ) {

	    for ( int d : divisor ) {
		if ( d >= t ) {
		    adj += d - t;
		    break;
		}
	    }
	}

	System.out.println( adj );
    }

    public static void main( String[] a ) {new Main().solve(); }
}



Measured memory_bytes: 69176
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
string s;
cin>>s;
n=s.size();
ll ans=0;
ll counta=0;
for(int i=0;i<n;i++)
{
    deb(counta);
    deb(ans);
    if(s[i]=='A')
    {
        counta++;
    }
    else if(s[i]=='B')
    {
        if(i==n-1)
        break;
        if(i==0)
        continue;
        if(s[i-1]=='A' && s[i+1]=='C')
        {
        ans+=counta;
        s[i+1]='A';
        i++;
        continue;
        }
        counta=0;
    }
    else if(s[i]=='C')
    counta=0;
}
cout<<ans;
return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n; cin >> n;
    ll sum = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0 || i % 15 == 0) continue;
        sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    char a[5];
    scanf("%s",a);
    if(strlen(a)==3)
    {
        for(int i=2; i>=0; i--)
        {
            printf("%c",a[i]);
        }
        cout<<endl;
    }
    else
    {
        for(int i=0; a[i]!='\0'; i++)
        {
            printf("%c",a[i]);
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long int N, A, B, oA, oB, nA, nB;

long long int mx(long long int A, long long int B){
    return A<B?B:A;
}

int main(){
    cin >> N;
    cin >> nA >> nB;
    oA = nA;
    oB = nB;
    for(int i=1;i<N;i++){
        cin >> A >> B;
        if(A == B){
            nA = mx(nA,nB);
            nB = nA;
        }
        else{
            long long int rslt = mx((long long int)ceil(nA/(long double)A),(long long int)ceil(nB/(long double)B));
            nA = rslt*A;
            nB = rslt*B;
        }
        oA = A;
        oB = B;
    }
    cout << (nA+nB) << endl;
}


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

struct P
{
    int x,y;

    bool operator<(const P &a)const{
              return x>a.x;
    }

};

vector<P> v[101103];
//bitset<4001000> b;
int a,c,i,b,k,n,d,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[100130];
int l[101103];
double j[1030];
int e[110];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=998244353;
long long z;
double pi=3.14159265;
P u[10600];
stack<int> s;

//set<int> s;
queue<int> q;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p,p1;
//list<int> l;

string r;
//char r[133];
//deque<int> de;
bool as(P a,P b)
{
    if(o[a.x]!=o[b.x])
    return o[a.x]<o[b.x];
    return a.y<b.y;
}


int main()
{
    cin>>r;
    scanf("%d",&a);
    for(int t=0;t<r.size();t+=a)
        printf("%c",r[t]);
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (a - b >= 0)
        cout << "delicious\n";
    else if (b - a <= x)
    {
        cout << "safe\n";
    }
    else
        cout << "dangerous\n";

    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

charMap 'J' = 0
charMap 'O' = 1
charMap 'I' = 2

main = do
    [m, n] <- getInts
    k <- getInt
    arr <- newArray ((0,0,0),(2,m,n)) 0 :: IO (IOUArray (Int,Int,Int) Int)
    forM_ [1..m] $ \y -> do
        s <- getLine
        forM_ (zip [1..n] s) $ \(x, c) -> do
            let tt = charMap c
            forM_ [0..2] $ \t -> (-) <$> ((+) <$> readArray arr (t,y-1,x) <*> readArray arr (t,y,x-1)) <*> readArray arr (t,y-1,x-1) >>= writeArray arr (t,y,x) . (+(cond 1 0 $ t==tt))
    replicateM_ k $ do
        [a,b,c,d] <- getInts
        sequence [(-) <$> ((+) <$> readArray arr (i,c,d) <*> readArray arr (i, a-1, b-1)) <*> ((+) <$> readArray arr (i,c,b-1) <*> readArray arr (i, a-1, d)) | i <- [0..2]] >>= putStrLn . sjoin
    return ()

Measured memory_bytes: 51292
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a,b,c=0,d=0,n,m1,n2,m2,min=100000,k=0,ans=0;
    string s,s2;
    cin >> a >> b;
    cin >> s;
    bool f = true;
    if(s[a]!='-'){
        f = false;
    }
    for(int i=0;i<a;i++){
        if(s[i]>='0'&&s[i]<='9'){
            c++;
        }
    }
    if(c!=a){
        f = false;
    }
    c=0;
    d=b;
    int i=a+1;
    while(d){
        if(s[i]>='0'&&s[i]<='9'){
            c++;
        }
        d--;
        i++;
    }
    if(c!=b){
        f = false;
    }
    if(f)
        cout << "Yes" <<endl; 
    else cout << "No" <<endl; 
    return 0;
}


Measured memory_bytes: 256
def main():
    mod = 998244353
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    a = [i for i in a if i <= s]
    dp = [0 for i in range(s+1)]
    half = pow(2, mod-2, mod)
    for i in a:
        dp2 = [j for j in dp]
        dp2[i] = (dp2[i]+pow(2, n-1, mod)) % mod
        for j in range(s-i+1):
            dp2[j+i] = (dp2[j+i]+dp[j]*half) % mod
        dp = dp2
    print(dp[s])


main()


Measured memory_bytes: 71796
#include <cstdio>
using namespace std;

int deg[5];

int main() {
    int u, v;
    for (int i = 0; i < 3; ++i) {
        scanf("%d%d", &u, &v);
        ++deg[u];
        ++deg[v];
    }
    bool ans = true;
    for (int i = 1; i <= 4; ++i) {
        if (deg[i] == 3 || deg[i] == 0) {
            ans = false;
            break;
        }
    }
    printf(ans ? "YES" : "NO");
    putchar('\n');
    return 0;
}

Measured memory_bytes: 760
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

N, M = inpl()
size = 2**N
F = [2**i for i in range(12)]

DP = [10**18] * size
DP[0] = 0

for _ in range(M):
    a, b = inpl()
    X = sum([F[i-1] for i in inpl()])
    
    for i in range(size):
        DP[i|X] = min(DP[i|X], DP[i] + a)

if DP[-1] == 10**18:
    print(-1)
else:
    print(DP[-1])



Measured memory_bytes: 42732
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string s;
    cin >> s;
    bool f = (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]);
    cout << (f ? "Bad" : "Good") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
#define eps 1e-15
typedef long long ll;
int main()
{
    int n,k;
    cin>>k>>n;

    vector<int>v(n);

    for (int i=0; i<n; ++i)
        cin>>v[i];

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

    int ans=0;

    for (int i=1; i<n; ++i)
        ans=max(ans,v[i]-v[i-1]);

    ans=max(ans,k-v[n-1]+v[0]);

    cout<<k-ans;












}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int i, j;
int h, w;
int dx[4] = {1, 0, -1,  0};
int dy[4] = {0, 1,  0, -1};
char **data;
char rLine[101];

void dfs(int x, int y, char fType)
{
	data[y][x] = 0;

	int k;
	for (k=0; k<4; k++) {
		int nx = x + dx[k];
		int ny = y + dy[k];
		if (nx>=0 && nx<w && ny>=0 && ny<h && data[ny][nx] == fType)
			dfs(nx, ny, data[ny][nx]);	
  }
}

int main()
{
	while (1) {
		scanf("%d%d ", &h, &w);
		if (!h && !w) break;
	
		data = (char **)calloc(h, sizeof(char *));
		for (i=0; i<h; i++)
			data[i] = (char *)calloc(w, sizeof(char));
		
		for (i=0; i<h; i++) {
			gets(rLine);
			for (j=0; j<w; j++) data[i][j] = rLine[j];
		}

		int res = 0;
		for (i=0; i<h; i++)
			for (j=0; j<w; j++)
				if (data[i][j] != 0) {
					dfs(j, i, data[i][j]);
					res++;
				}

		printf("%d\n", res);

		for (i=0; i<h; i++)	
			free(data[i]);
		free(data);
	}

	return 0;
}

Measured memory_bytes: 1096
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	int n, m, a[200000], b[200000], x[200000], y[200000];
	cin >> n >> m;
	for(int i=0;i<=n;i++)a[i]=1, b[i]=0;
	b[1]=1;
	for(int i=0;i<m;i++){
		cin >> x[i] >> y[i];
		if(b[x[i]]>=1)b[y[i]]++;
		if(a[x[i]]>=1)a[x[i]]--,a[y[i]]++;
		if(a[x[i]]<=0)b[x[i]]=0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(a[i]>=1&&b[i]>=1)ans++;

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


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

namespace id_0583cs
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var valMin = tmp.Min();
            foreach (var i in Enumerable.Range(1, valMin + 1))
            {
                if (tmp.All(x => x % i == 0))
                {
                    Console.WriteLine(i);
                }

            }
        }
    }
}



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

using namespace std;

int main() {
    long long d,n;
    while(cin >> d >> n) {
        if(d == 0) {
            if(n == 100) n++;
                cout << n  << endl;
        
            continue;
        }
        long long c;
        if(d == 1)
            c = 100;
        else c = 10000;
        if(n == 100) n++;
        cout << n * c << endl;
    }
    return 0;
}






//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 1e5 + 100;
//int a[maxn];
//int main() {
//    int n;
//     while(cin >> n){
//        int ans = 0;
//        for(int i = 1;i <= n;i++) cin >> a[i];
//        for(int i = 1;i <= n;i++){
//            while(a[i] % 2 == 0) ans++,a[i] /= 2;
//        }
//        cout << ans << endl;
//     }
//    return 0;
//}
//


Measured memory_bytes: 256
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;
ll dp[10004];
ll n,p;
string s;
ll mul(ll a, ll b) {
    return ((a % p) * (b % p)) % p;
}
ll add(ll a, ll b) {
    return ((a % p) + (b % p)) % p;
}
ll bpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1) ret = mul(ret, a);
        a = mul(a, a);
        b >>= 1;
    }
    return ret;
}
int main() {
    cin>>n>>p;
    cin>>s;
    ll ans = 0;
    if(p == 2 or p == 5) {
        for(int i = 0; i < (int) s.size(); ++i) {
            int dg = s[i] - '0';
            if(dg % p == 0) ans += (i + 1);
        }
    } else {
        reverse(s.begin(), s.end());
        ll rem = 0;
        dp[0] = 1;
        for(int i = 0; i < (int) s.size(); ++i) {
            ll pw = bpow(10, i);
            ll d = (s[i] - '0');
            ll cur = add(rem, mul(pw, d));
            // cout<<pw<<" "<<cur<<endl;
            dp[cur]++;
            rem = cur;
        }
        for(int i = 0; i < p; ++i) {
            if(dp[i] > 0) {
                ans += (dp[i] * (dp[i] - 1)) / 2;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 772
# coding: utf-8
import sys

ans = sys.maxsize

N, T = map(int, input().split())
for i in range(0, N):
    c, t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)

if ans == sys.maxsize:
    print("TLE")
else:
    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int N[20];
int ans, sum, n, k, s;

void subsetsum(int x, int y)
{
  FOR(i,x,n){
    if(y){
      sum += N[i];
      subsetsum(i+1,y-1);
      if(sum == s && y == 1)
        ans++;
      sum -= N[i];
    }else{
      break;
    }
  }
}

int main()
{
  REP(i,20)
    N[i] = i+1;
  while(1){
    ans = sum = 0;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    subsetsum(0,k);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

class BIT {
    int size;
    VL dat;
public:
    void init(int in) {
        size = in + 1;
        dat.clear();
        dat.resize(size, 0);
    }
    ll sum(int i) {
        ll ret = 0;
        while (i >= 0) {
            ret += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return ret;
    }
    void add(int i, ll x) {
        while (i <= size) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    int n;
    cin >> n;
    VI a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = (((ll)n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	string s;
	cin >> s;
	ll ret = 0;
	reverse(ALL(s));

	int n = s.size();

	int wh = 0;

	rep(i, n) {
		if (s[i] == 'W') {
			++wh;
		} else {
			ret += wh;
		}
	}

	cout << ret << endl;

	return 0;
}

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

int main(){
    long long int h,w,ans;
    cin >> h >> w;

    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }
    
    ans=h*w/2;

    if(h%2==1 && w%2==1){
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256