akhauriyash/Code-Regression huggingface dataset:
(defun string-split(str delim)
  (let ((start  0)
                (end 0)
                (res nil))
        (labels ((cnt (s start end)
                                  (if (not ( = (length s) end))
                                        (if (eq (char s end) delim)
                                          (progn
                                                (setf res (cons (subseq s start end) res))
                                                (setf start (+ end 1))
                                                (cnt s start (+ end 1)))
                                        (cnt s start (+ end 1)))
                                        (setq res (cons (subseq s start end) res))
                                  )
                         ))
        (cnt str start end)
        )
        )
  )
(defun pwgy (lst)
  (if (and (find #\Y lst :test #'string=) (find #\W lst :test #'string=) (find #\G lst :test #'string=) (find #\P lst :test #'string=))
        "Four"
        (if (and (find #\P lst :test #'string=) (find #\W lst :test #'string=) (find #\G lst  :test #'string=))
          "Three"
          )
        )
  )
(let* ((N (parse-integer (read-line)))
           (C (string-split (read-line) #\Space)))
        (format t "~A~%" (pwgy C))
  )

Measured memory_bytes: 15840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ab = abs(a-b);
    int bc = abs(b-c);
    int ac = abs(a-c);
    cout << ((ab <= d && bc <= d) || ac <= d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int months = sc.nextInt();
		int days = sc.nextInt();

		int ans = 0;
		for (int m = 1; m <= months; m++) {
			for (int d = 10; d <= days; d++) {
				int d1 = d % 10;
				int d10 = d / 10;
				if (d10 >= 2 && d1 >= 2 && m == d1 * d10) {
					ans++;
				}
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/07.
 */
public class Main implements Runnable {

    static Scanner sc = new Scanner(System.in);
    static int h, w;
    static int[] dx = {0, 1,  0, -1};
    static int[] dy = {1, 0, -1,  0};
    static char[][] grid = new char[105][105];

    public static boolean read() {
        h = sc.nextInt();
        w = sc.nextInt();
        if(h == 0 && w == 0) return false;

        for(int i = 0; i < h; i++) {
            grid[i] = sc.next().toCharArray();
        }
        return true;
    }

    public static void dfs(int i, int j , char c) {
        // stopping condition
        if(i < 0 || i >= h || j < 0 || j >= w) return;
        if(grid[i][j] != c) return;

        // marking
        grid[i][j] = '.';

        // recursion
        for(int k = 0; k < 4; k++) {
            dfs(i + dx[k], j + dy[k], c);
        }
    }

    public static void solve() {
        int ans = 0;

        // dfs
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(grid[i][j] != '.') {
                    ans++;
                    dfs(i, j, grid[i][j]);
                }

            }
        }

        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 32 * 1024 * 1024).start();
    }

    public void run() {
        while(read()) solve();
    }

}

Measured memory_bytes: 26544
import sys
from typing import List, Tuple


if __name__ == "__main__":
    V, E, r = map(lambda x: int(x), input().split())

    edges: List[List[Tuple[int, int]]] = [[] for _ in range(V)]
    dists = [sys.maxsize for _ in range(V)]
    dists[r] = 0

    for _ in range(E):
        s, t, dist = map(lambda x: int(x), input().split())
        edges[s].append((t, dist))

    for _ in range(V):
        for vertex in range(V):
            if sys.maxsize != dists[vertex]:
                for to, cost in edges[vertex]:
                    if cost + dists[vertex] < dists[to]:
                        dists[to] = cost + dists[vertex]

    for vertex in range(V):
        if sys.maxsize != dists[vertex]:
            for to, cost in edges[vertex]:
                if cost + dists[vertex] < dists[to]:
                    # If dist can be smaller than previous one, there is negative cycle.
                    print("NEGATIVE CYCLE")
                    exit(0)

    for dist in dists:
        if sys.maxsize == dist:
            print("INF")
        else:
            print(dist)



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

using namespace std;

int N;
int A[2][110];

int main() {
  cin >> N;
  for (int y = 0; y < 2; y++) {
    for (int x = 0; x < N; x++) {
      cin >> A[y][x];
    }
  }

  int result = 0;
  for (int downX = 0; downX < N; downX++) {
    int total = 0;
    for (int x = 0; x < downX; x++) {
      total += A[0][x];
    }
    total += A[0][downX];
    total += A[1][downX];
    for (int x = downX + 1; x < N; x++) {
      total += A[1][x];
    }

    result = max(result, total);
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io  ios_base::sync_with_stdio(false), cin.tie(NULL),cout.tie(NULL)
int mod=998244353;
int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}

int32_t main()
{
    io;
    int t;
    t=1;
    while(t--)
    {
        int n;
        cin>>n;
        cout<<(1000-n%1000)%1000;
    }
}


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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i,4){
		if (s[i] == '+') ans++;
		if (s[i] == '-') ans--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), t = sc.nextInt();
		int t1[] = new int[n];
		long ans = 0, tmp = 0;
		int pt = 0; 
		for(int i = 0; i < n; ++i) {
			t1[i] = sc.nextInt();
			int t2 = t1[i] - pt;
			if(t2 < tmp)tmp = t + t2;
			else {
				ans += tmp;
				pt = t1[i];
				tmp = t;
			}
		}
		ans += tmp;
		sc.close();
		System.out.println(ans);
	}

}


Measured memory_bytes: 64428
S,T=input(),input()
N=len(S)
link_a={}
link_b={}

for i in range(N):
    if  T[i] in link_a:
        if link_a[T[i]] == S[i]:
            continue
        else:
            print('No')
            exit()
    else:
        link_a[T[i]]=S[i]

for i in range(N):
    if  S[i] in link_b:
        if link_b[S[i]] == T[i]:
            continue
        else:
            print('No')
            exit()
    else:
        link_b[S[i]]=T[i]
print('Yes')



Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}
	static IntStream INS(int n){
		return REPS(n).map(i->getInt());
	}
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	
	public static void main(String[]$){
		System.out.println(INS(3).sorted().limit(2).sum());
	}
}


Measured memory_bytes: 26828
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
ll Mpow2(ll x){
    ll a=1;
    rep(i,x){
        a*=2;
        a%=MOD;
    }
    return a;
}
int main(){
    ll N;
    cin>>N;
    map<pll,pll> m;
    ll zero=0;
    rep(i,N){
        ll x,y;
        cin>>x>>y;
        if(x==0&&y==0){
            zero++;
            continue;
        }else if (x==0)
        {
            pll p=mp(0,1);
            m[p].first++;
            continue;
        }else if (y==0)
        {
            pll p=mp(0,1);
            m[p].second++;
            continue;
        }
        if(x<0){
            x*=-1;
            y*=-1;
        }
        ll G=__gcd(abs(x),abs(y));
        x/=G;
        y/=G;
        if(y<0){
            pll p=mp(-1*y,x);
            m[p].second++;
        }else{
            pll p=mp(x,y);
            m[p].first++;
        }
    }
    ll ans=1;
    for(auto p:m){
        ll x=p.second.first;
        ll y=p.second.second;
        ll num=Mpow2(x)+Mpow2(y)-1;
        num%=MOD;
        ans*=num;
        ans%=MOD;
    }
    ans=(ans+zero-1+MOD)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 19188
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

int main() {
    array<int, 10> A;
    for (int i = 0; i < 10; ++i) {
        cin >> A[i];
    }

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

    for (int i = 0; i < 3; ++i) {
        cout << A[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1172
n, m = map(int, input().split())
#全部シュミレートして、0個だったやつは弾く
#赤いボールが入っている可能性があったもの、からうつったものもすべて候補に入る
candidate = set([1])
ball = [1 for i in range(n+1)]
for i in range(m):
    x, y = map(int, input().split())
    if x in candidate:
        candidate.add(y)
    else:
        if ball[y] == 0 and y in candidate:
            candidate.remove(y)
    ball[x] -= 1
    ball[y] += 1
for i in range(1,n+1):
    if ball[i] == 0 and i in candidate:
        candidate.remove(i)
print(len(candidate))    

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

int n;
map<int, int> mp;
int res = 1;
bool det[24]={};

void rec(int k){
    if(k==12){
        int ans = 12;
        rep(i,24)rep(j,i){
            if(det[i] && det[j]){
                ans = min(ans,min(24-i+j,i-j));
            }
        }
        res = max(res,ans);
        return;
    }
    if(mp[k]==1){
        det[k] = true;
        rec(k+1);
        det[k] = false;
        det[24-k] = true;
        rec(k+1);
        det[24-k] = false;
    }else{
        rec(k+1);
    }
}

int solve(){
    cin>>n;
    mp[0]++;
    rep(i,n){
        int d;
        cin>>d;
        mp[d]++;
        if(mp[d] >= 3) return 0;
    }
    if(mp[0] >= 2 || mp[12] >= 2) return 0;
    
    det[0] = true;
    if(mp[12]==1) det[12] = true;
    rep(i,12) if(mp[i]==2) det[i] = det[24-i] = true;
    rec(1);
    return res;
}

int main(void){
    cout<<solve()<<endl;
    return 0;
}


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

int main() {
  string S;
  cin>>S;
  int n=S.size();
  int i=0;
  int ans=0;
  int tmp=0;
  while(i<n){
    
  if (S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
    tmp ++;
    i++;
    //cout<<S[i]<<endl;
  }
  else{
    ans=max(ans,tmp);
    tmp=0;
    i++;
  }
  }
  ans=max(ans,tmp);
cout<<ans<<endl;
  }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        long ret = 0L;
        long count_a = 0L;
        for (char c : new Scanner(System.in).next().replaceAll("BC", "X").toCharArray()) {
            if (c == 'A') {
                count_a++;
            } else if (c == 'X') {
                ret += count_a;
            } else {
                count_a = 0L;
            }
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 33164
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		// A();
		// B();
		C();

	}

	private static void C() throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		String[] line = br.readLine().split(" ");

		br.close();
		int[] ar = new int[N];
		for (int i = 0; i < line.length; i++) {
			ar[i] = Integer.parseInt(line[i]);
		}

		int cost_work = 0;

		for (int i = -100; i <= 100; i++) {
			// iに変換する際のコストを計算する
			int cost_total = 0;
			for (int j = 0; j < ar.length; j++) {
				cost_total += (int) Math.pow((ar[j] - i), 2);
			}
			if (i == -100)
				cost_work = cost_total;
			if (cost_work > cost_total) {
				cost_work = cost_total;
			}

		}

		System.out.println(cost_work);

	}

	private static void B() throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String S = br.readLine();

		br.close();

		String[] AR = S.split("");
		String[] BR = new String[AR.length];

		for (int i = 0, j = 0; i < AR.length; i++) {
			if (!AR[i].equals("B")) {
				BR[j] = AR[i];
				j++;

			} else if (j > 0) {
				j--;
				BR[j] = null;
			}
		}

		for (int i = 0; i < BR.length; i++) {
			if (BR[i] == null)
				break;
			System.out.print(BR[i]);

		}
		System.out.println("");

	}

	private static void A() throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		int kosuu = 0;
		br.close();

		for (int i = 0; i <= N; i++) {

			kosuu += i;

		}

		System.out.println(kosuu);
		;

	}

}


Measured memory_bytes: 8020
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, c = 0, d = 0, e;
	cin >> a;
	for (int h = 1; h <= a; h++) {
		cin >> b;
		c = b + c;
		d = max(b, d);
	}
	if (d < c - d) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
	cin >> e;
}


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

int main(){
	string o, e, ans;
		cin >> o >> e;
		ans = "";
		for(int i = 0;;i++){
			if (o.size() > i) {
				ans += o[i];
			}
			else break;
			if (e.size() > i) {
				ans += e[i];
			}
		}
		cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n;
string s;

bool is_ok(int mid){
	vector<pair<string, int>> v;
	REP(i, n-mid+1){
		v.push_back(make_pair(s.substr(i, mid), i));
	}
	sort(ALL(v));
	int i=n-mid;
	bool res=false;
	while(i>0){
		auto x=v[i];
		string t=x.first;
		int u=x.second;
		while(i>=0 && v[i].first==t){
			--i;
		}
		if(i>=0 && v[i].first==t){
			if(v[i].second+mid<=u){
				res=true;
				break;
			}
		}
		if(i<n-1 && v[i+1].second+mid<=u){
			res=true;
			break;
		}
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n>>s;
	int lb=0, ub=n;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		if(is_ok(mid)){
			lb=mid;
		}
		else{
			ub=mid;
		}
	}
	cout<<lb<<'\n';
	return 0;
}


Measured memory_bytes: 6588
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline int read() {
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
} 
int n;
int vis[N*10];
int main(){
	int n;
	cin>>n;
	ll sum=0;
	rep(i,1,n){
		if(i%3==0&&i%5==0){
			vis[i]=1;
		}
		else if(i%3==0){
			vis[i]=1;
		}
		else if(i%5==0){
			vis[i]=1;
		}
		
	}
	rep(i,1,n){
		if(!vis[i])sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 7488
#include <iostream>
using namespace std;
const int maxn = 2e5 + 5;
long long a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	long long sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum ^= a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		long long temp = sum ^ a[i];
		cout << temp << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5148
#include <stdio.h>
#define MAX 200000
int max(int a,int b){return a>b? a:b;}
int min(int a,int b){return a<b? a:b;}
int main(void){
    int R[MAX], i, n;
    scanf("%d",&n);
    for(i = 0;i<n;i++)scanf("%d",&R[i]);
    int maxv = -2000000000;
    int minv = R[0];
    for(int i=1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    printf("%d\n",maxv);
    
    return 0;
}



Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7<<endl;
    }
    else if(s=="MON")
    {
        cout<<6<<endl;
    }   
    else if(s=="TUE")
    {
        cout<<5<<endl;
    }
    else if(s=="WED")
    {
        cout<<4<<endl;
    }
    else if(s=="THU")
    {
        cout<<3<<endl;
    }
    else if(s=="FRI")
    {
        cout<<"2\n";
    }
    else
    {
        cout<<"1\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL D;
	cin >> D;
	cout << "Christmas";
	for (; D < 25; D++) {
		cout << " Eve";
	}
	cout << "\n";
	return 0;
}

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

int main()
{
	string S, T;
	cin >> S >> T;

	if (S + T[T.length() - 1] == T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3584
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque
import numpy as np
def main():
    r = int(input())
    print(2 * np.pi  *r)
if __name__ == '__main__':
    main()


Measured memory_bytes: 27116
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
vector<ll> a;
int n;
vector<vector<ll>> memo;
const int off = 4;
const ll inf = 1e18;
ll solve(int ind, int taken) {
    if(ind >= n) {
        if(taken == n/2) return 0;
        return -inf;
    }
    if(ind-2*taken > 3 || ind-2*taken < -3) return -inf;
    ll &ret = memo[ind][ind-2*taken+off];
    if(ret != -inf-1) return ret;
    return ret = max(solve(ind+1, taken), a[ind]+solve(ind+2, taken+1));
}
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    memo.assign(n+2, vector<ll>(11, -inf-1));
    cout << solve(0, 0) << "\n";
    // f[i][j] = f[i-2][j], f[i-3][j+1], f[]





    return 0;
    
}

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

int main(){
  int n,m,i,co,lma,rmi;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  co=0;
  lma=0;
  rmi=1000000000;

  for(i=0;i<m;++i){
    cin >> l[i] >> r[i];
  }
  for(i=0;i<m;++i){
    lma=max(l[i],lma);
    rmi=min(r[i],rmi);

  }
  if(lma>rmi){
    co=0;
  }else{
    co=rmi-lma+1;
  }
  cout << co << endl;
  return 0;


}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;
long long DP[100010];
vector<vector<int> > G;

long long memo(long long v){

    long long max = -1;
    long long tmp;

    if(DP[v] != -1) return DP[v];

    for( long long av : G[v]){

        tmp = memo(av) + 1;
        max = (std::max)(max,tmp);

    }

    DP[v] = max;

    return DP[v];

}

int main(){

long long N,M;

cin >> N >> M;

G.assign(N, vector<int>());

for (long long i = 0; i < 100010; ++i) DP[i] = -1;

for (long long i = 0; i < M; ++i) {
    long long x, y; cin >> x >> y;
    --x, --y;
    G[x].push_back(y);
}

long long ans = -1;

for(long long i = 0;i < N;++i) ans = (std::max)(ans,memo(i));

cout << ans+1 << endl;

return 0;

}   


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;

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

    cin>>n;
    if(n%2==0)
    {
        cout<<n*(n-2)/2<<endl;
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                if(n-i+1!=j)
                    cout<<i<<" "<<j<<endl;
    }
    else
    {
        cout<<(n-1)*(n-3)/2+(n-1)<<endl;
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                if(n-i!=j)
                    cout<<i<<" "<<j<<endl;
    }

	return 0;
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
matrix1 = []
matrix2 = []
for i in range(n+m):
  list_ = list(map(int, input().split()))
  if i+1 <= n:
    matrix1.append(list_)
  else:
    matrix2.append(list_)

for j in range(n):
  list_ = []
  for k in range(l):
    sum_ = 0
    for mm in range(m):
      sum_ += matrix1[j][mm] * matrix2[mm][k]
    list_.append(sum_)
  print(' '.join(list(map(str, list_))))


Measured memory_bytes: 6248
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int x1[200],y1[200];
  vector< pair<int,int> > p;
  int n,m,x,y;
  while(cin>>m,m){
    cin>>x>>y;
    p.clear();
    for(int i=1;i<m;++i){
      cin>>x1[i]>>y1[i];
      x1[i]-=x;y1[i]-=y;
    }
    cin>>n;
    for(int i=0;i<n;++i){
      pair<int,int> q;
      cin>>q.first>>q.second;
      p.push_back(q);
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;++i){
      bool f=true;
      for(int j=1;j<m;++j){
	pair<int,int> xy(p[i].first+x1[j],p[i].second+y1[j]);
	if(!binary_search(p.begin(),p.end(),xy)){
	    f=false;break;
	  }
      }
      if(f){
	cout<<p[i].first-x<<' '<<p[i].second-y<<endl;
	break;
      }
    }
  } 
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++)  cin >> a.at(i);

  int ans=0;
  for(int i=0;i<N;i+=2) if(a.at(i)%2==1)  ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	

	int a,b,c,y;
	cin >> a>>b>>c>>y;
	
	
	
	cout << (min(a,b))*c+(max(a-b,0))*y<< endl;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 4 6");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 4 3");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1 7 10");
            //0
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("1 3 3");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
        long N = wkArr[0];
        long A = wkArr[1];
        long B = wkArr[2];

        if (A > B) {
            Console.WriteLine(0);
            return;
        }

        if (N == 1) {
            if (A == B) Console.WriteLine(1);
            else Console.WriteLine(0);
        }
        else {
            long RestCnt = N - 2;
            long MinSum = A + B + RestCnt * A;
            long MaxSum = A + B + RestCnt * B;

            Console.WriteLine(MaxSum - MinSum + 1);
        }
    }
}


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

int main(){
  string S;
  cin >> S;
  int ans = -4;
  if (S.at(0) == '+') ans += 2;
  if (S.at(1) == '+') ans += 2;
  if (S.at(2) == '+') ans += 2;
  if (S.at(3) == '+') ans += 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int n, k;
	cin >> n >> k;
	int ans = k;
	for(int i = 1;i < n;i++){
		ans *= (k - 1);
	}
	cout << ans << endl;
	return 0;
}

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

vector<int> data_bit;

struct BIT{
    void init(int n){
        data_bit.assign(n+1, 0);// 1-indexed [1,n]
    }

    void add(int i, int x){
        while(i < data_bit.size()){
            data_bit[i] += x;
            i += (i & -i);
        }
    }

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += data_bit[i];
            i -= (i & -i);
        }
        return s;
    }
};

int main(){
    int n, q;
    cin >> n >> q;

    vector<int> c(n);
    for(int i=0; i<n; i++){
        cin >> c[i];
      	c[i] -= 1;
    }

    vector<pair<pair<int, int>, int>> query(q);
    for(int i=0; i<q; i++){
        cin >> query[i].first.second >> query[i].first.first;
        query[i].second = i;
    }
    sort(query.begin(),query.end());

    BIT bit; 
    bit.init(n+1);

    int current = 0;
    vector<int> rightmost(n, -1);
    vector<int> ans(q);

    for(int i=0; i<q; i++){
        int l = query[i].first.second - 1;
        int r = query[i].first.first - 1;
        int id = query[i].second;

        while(current <= r){
            bit.add(rightmost[c[current]]+2, -1);
            bit.add(current+2, 1);

            rightmost[c[current]] = current;
            current += 1;
        }
        
        ans[id] = bit.sum(r+2) - bit.sum(l+1);// [1,(y+1)-1] - [1,x-1] = [x,y]
    }

    for(int i=0; i<q; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 17376
#include <bits/stdc++.h>
using namespace std;
#define V 100001
vector<int> G[V],rG[V],v;
bool u[V];
int n,cmp[V];

void add_edge(int x, int y) {
  G[x].push_back(y);
  rG[y].push_back(x);
}
void dfs(int x) {
  u[x]=1;
  for(int i=0; i<G[x].size(); i++) {
    if(!u[G[x][i]]) dfs(G[x][i]);
  }
  v.push_back(x);
}
void rdfs(int x, int k) {
  u[x]=1;
  cmp[x]=k;
  for(int i=0; i<rG[x].size(); i++) {
    if(!u[rG[x][i]]) rdfs(rG[x][i],k);
  }
}
int scc() {
  memset(u,0,sizeof(u));
  v.clear();
  for(int i=0; i<n; i++) {
    if(!u[i]) dfs(i);
  }
  memset(u,0,sizeof(u));
  int k = 0;
  for(int i=v.size()-1; i>=0; i--) {
    if(!u[v[i]]) rdfs(v[i],k++);
  }
  return k;
}
int main() {
  while(cin >> n && n) {
    for(int i=0; i<n; i++) G[i].clear(),rG[i].clear();
    double p[n];
    for(int i=0,m; i<n; i++) {
      cin >> p[i] >> m;
      for(int j=0; j<m; j++) {
        int x;
        cin >> x;
        x--;
        add_edge(i,x);
      }
    }
    int cnt=scc();
    int c[n],d[n];memset(c,0,sizeof(c));memset(d,0,sizeof(d));
    for(int i=0; i<n; i++) {
      for(int j=0; j<G[i].size(); j++) {
        if(cmp[G[i][j]]!=cmp[i]) c[cmp[G[i][j]]]=1;
      }
      d[cmp[i]]=1;
    }
    double ans=1;
    for(int i=0; i<n; i++) {
      if(!c[i]&&d[i]) {
        double x=1;
        for(int j=0; j<n; j++) {
          if(cmp[j]==i) x*=p[j];
        }
        ans*=1.0-x;
      }
    }
    printf("%.10f\n",ans);
  }
  return 0;
}


Measured memory_bytes: 8164
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            int A = cin.nextInt();
            int B = cin.nextInt();
            Console.WriteLine(A * B);
        }
    }
}


Measured memory_bytes: 27652
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (s, w) = [int(e) for e in lines[0].split(' ')]

    return (s, w)


def solve(s, w):

    if w >= s:
        result = 'unsafe'
    else:
        result = 'safe'
    
    return  result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    string s;
    cin >> s;

    printf("%c%d%c", s[0], s.size() - 2, s[s.size() - 1]);
    return (0);
}


Measured memory_bytes: 3732
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <limits.h>
#include <utility>
#include <stack>

using namespace std;

#define fs first
#define sc second

typedef long long ll;
typedef pair<ll, ll> P;

ll dp[1010000];

int main(){
    int N;  cin >> N;
    string s;   cin >> s;
    int Q, K[75];
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> K[i];
    }

    int numD[1010000], numM[1010000];
    numD[0] = 0; numM[0] = 0;
    for(int i = 0; i < N; i++){
        numM[i+1] = numM[i] + (s[i] == 'M');
        numD[i+1] = numD[i] + (s[i] == 'D');
    }

    for(int ki = 0; ki < Q; ki++){
        int k = K[ki];
        ll res = 0;
        dp[0] = 0;
        for(int i = 1; i <= N; i++){
            dp[i] = dp[i-1];
            if(s[i-1] == 'C'){
                res += dp[i];
            }
            if(s[i-1] == 'M'){
                dp[i] += numD[i] - numD[max(0, i-k+1)];
            }
            if(i - k >= 0 && s[i-k] == 'D'){
                dp[i] -= numM[i-1] - numM[i-k+1];
            }
        }
        cout << res << endl;
    }


    return 0;
}

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

std::vector<std::vector<long long> > v;
std::vector<long long> xy;

void dfs(long long t,long long score,long long be=-1){
  // std::cout << "now:" <<t<<" score:"<<score<<" xy[t]:"<<xy[t]<<'\n';
  xy[t]+=score;
  // std::cout << score << '\n';

  for (long long i = 0; i < v[t].size(); i++) {
    if(be==v[t][i])continue;
    dfs(v[t][i],xy[t],t);
  }
  // std::cout << "endnow:" <<t<<" score:"<<score<<'\n';
}

int main(){
  long long n,q,tmp,tmp2;
  std::cin >> n>>q;
  v.resize(n);
  xy.resize(n);

  for (int i = 0; i < n-1; i++){
    std::cin >> tmp>>tmp2;
    v[tmp-1].push_back(tmp2-1);
    v[tmp2-1].push_back(tmp-1);
    xy[i]=0;
  }

  for (int i = 0; i < q; i++) {
    std::cin >> tmp>>tmp2;
    xy[tmp-1]+=tmp2;
  }
  dfs(0,0);
  for (int i = 0; i < n; i++) {
    std::cout << xy[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int K, N; cin >> K >> N;
  vector<int> A(N), B(0);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for(int i = 1; i < N; i++) {
    B.push_back(A.at(i) - A.at(i - 1));
    if(i == N - 1) {
      B.push_back(K - A.at(i) + A.at(0));
    }
  }
  sort(B.begin(), B.end(), greater<int>());
  int l = K - B.at(0);
  cout << l << endl;
}

Measured memory_bytes: 2168
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

bool check(int n, int a, int b) {
	int x, y;
	x = n * 0.08;
	y = n * 0.1;
	return x == a && y == b;
}

int main() {
	int a, b;
	cin >> a >> b;
	REP(i, 1000) {
		if(check(i + 1, a, b)) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
using ll = long long;


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

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

  vector<ll> ko(n,1);
  vector<ll> kanosei(n,0);
  kanosei.at(0) = 1;

  ll x, y;
  rep(i, m){
    cin >> x >> y;
    --x; --y;
    --ko.at(x);
    ++ko.at(y);
    if(kanosei.at(x) == 1) kanosei.at(y) = 1;
    if(ko.at(x) == 0) kanosei.at(x) =0;
  }
  ll cnt=0;
  for (const auto& i : kanosei){
    if(i==1) ++ cnt;
  }

  cout << cnt << endl;






  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    int n;
    scanf("%d\n", &n);
    int cont = n;
    char a[n+10];
    scanf("%[^\n]", a);
    for (int i = 0; i < n; ++i){
        if (a[i] == a[i+1]) cont -= 1;
    }
    printf("%d\n", cont);



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::string S1, S2;
  std::cin >> N >> S1 >> S2;
  long long ans = 1;
  const long long MOD = 1000000007;
  for (int i = 0; i < N; ++i) {
    if (S1[i] == S2[i]) {
      if (i == 0) {
        ans *= 3;
        ans %= MOD;
      }
      else {
        if (S1[i - 1] == S2[i - 1]) {
          ans *= 2;
          ans %= MOD;
        }
      }
    } else {
      if (i == 0) {
        ans *= 6;
        ans %= MOD;
      }
      else {
        if (S1[i - 1] == S1[i]) {
          continue;
        }
        if (S1[i - 1] == S2[i - 1]) {
          ans *= 2;
          ans %= MOD;
        } else {
          ans *= 3;
          ans %= MOD;
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M;

  std::cin >> N >> M;

  std::cout << N * (N - 1) / 2 + M * (M - 1) / 2<< std::endl;

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  string a;
  for (int i = 0; i < s.size(); i++) {
    if(s[i] == 'B'){
      if(!a.empty())
        a.pop_back();
    }else{
      a.push_back(s[i]);
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
moji=input()
s=[]

for c in moji:
    if(c=="<"):
        s.append(1)
    else:
        s.append(-1)

#print(s)

temp=0

yama=[]


n=len(s)+1
a=[-1]*(n)
#print(len(a))

for i in range(n-1):
    temp+=s[i]
    if(i==n-2):
        yama.append(temp)
    else:
        if(s[i]*s[i+1]==-1):
            yama.append(temp)
            temp=0

#print(yama)

l=len(yama)
ans=0
for i in range(l):
    if(i==0 and yama[i]<0):
        tasu=-yama[i]
        ans+=(tasu+1)*tasu//2
        continue
    if(i==l-1 and yama[i]>0):
        tasu=yama[i]
        ans+=(tasu+1)*tasu//2
        continue
    if(i==l-1):
        continue
    if(yama[i]<0 or yama[i+1]>0):
        continue
    dai=max(yama[i],-yama[i+1])
    sho=min(yama[i],-yama[i+1])
    ans+=(dai+1)*dai//2
    ans+=sho*(sho-1)//2

print(ans)

Measured memory_bytes: 14240
apex = ((1,2,3),
        (1,4,2),
        (1,5,4),
        (1,3,5),

        (2,1,4),
        (2,3,1),
        (2,6,3),
        (2,4,6),

        (3,1,2),
        (3,5,1),
        (3,6,5),
        (3,2,6),

        (4,1,5),
        (4,2,1),
        (4,6,2),
        (4,5,6),

        (5,3,6),
        (5,1,3),
        (5,4,1),
        (5,6,4),

        (6,3,2),
        (6,5,3),
        (6,4,5),
        (6,2,4)
        )

dice = {}
label = []
label[:] = map(int,input().split())
#print('label: {}'.format(label))

for i in range(0,6):
    dice[label[i]] = i+1
#print('dice: {}'.format(dice))


q = int(input())

for _ in range(0,q):
    numbers = []
    numbers[:] = map(int,input().split())
    right = 0
    for t in apex:
        if (t[0] == dice[numbers[0]] and t[1] == dice[numbers[1]]):
            right = t[2]
            #print('{} {} {}'.format(t[0],t[1],t[2]))
            break
    for key, n in dice.items():
        if (n == right):
            print(key)
            break



Measured memory_bytes: 5616
N = int(input())
S = input()
from collections import deque
T = [deque([0, 0]),
     deque([0, 1]),
     deque([1, 0]),
     deque([1, 1])]
for s in S:
    for t in T:
        l = len(t)
        if (s == 'o') ^ t[l-1]:
            t.append(t[l-2])
        else:
            t.append(t[l-2]^1)

ans = '-1'
wrap = lambda x:'{' + str(x) + '}'
for t in T:
    if t[0] == t[N] and t[1] == t[N+1]:
        t.pop(); t.popleft()
        ans = ''.join(wrap(i) for i in t).format('S','W')
        break
print(ans)


Measured memory_bytes: 20152
#include<stdio.h>

int main(){
	int n=1,x=1,a=0;
	int i,j,k;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0&&x==0) break;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x){
						a++;
					}
				}
			}
		}
		printf("%d\n",a);
		a=0;
	}
	return 0;
}

Measured memory_bytes: 600
def main():
    N = int(input())
    blue = [input() for _ in range(N)]
    M = int(input())
    red = [input() for _ in range(M)]
    words = set(blue+red)
    x = -1000
    for w in words:
        pos = blue.count(w)
        neg = red.count(w)
        x = max(x, pos - neg)

    if x > 0:
        print(x)
    else:
        print(0)
main()

Measured memory_bytes: 3060