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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll H,W,M; cin>>H>>W>>M;
    vint h(M), w(M);
    // bool b[H][W];
    // rep(i,H)rep(j,W) b[i][j] = false;
    using P = pair<ll,ll>;
    set<P> s;

    vint yoko(H,0), tate(W,0);
    rep(i,M) {cin>>h[i]>>w[i]; h[i]--; w[i]--;  yoko[h[i]]++; tate[w[i]]++; s.insert(make_pair(h[i], w[i]));}


    // for(auto e:yoko) cout<<e<<" "; cout<<endl;
    // for(auto e:tate) cout<<e<<" "; cout<<endl;

    ll maxy = *max_element(ALL(yoko));
    ll maxt = *max_element(ALL(tate));

    vint candy, candt;
    rep(i,H){
        if(yoko[i] == maxy) candy.push_back(i);
    }
    rep(i,W){
        if(tate[i] == maxt) candt.push_back(i);
    }

    for(auto y:candy){
        for(auto t:candt){
            if(s.count(make_pair(y,t))) continue;
            cout<<maxy+maxt<<endl;
            return 0;
        }
    }
    cout<<maxy+maxt-1<<endl;

    // ll ans = 0;
    // using P = pair<ll,ll>;
    // set<P> s;

    // rep(i,M){
    //     chmax(ans, yoko[h[i]] + tate[w[i]] - 1);
    //     // ll tmp = yoko[h[i]] + tate[w[i]] - 1;
    //     // if(tmp == ans){
    //     //     s.insert(make_pair(h[i], w[i]));
    //     // }else if(tmp < ans){
    //     //     continue;
    //     // }else{
    //     //     ans = tmp;
    //     //     s.clear();
    //     //     s.insert(make_pair(h[i], w[i]));
    //     // }
    // }

    // cout<<max(ans, )


    // // ll ans2 = maxy + maxt;

    // // if(ans2 - ans == 1) cout<<ans<<endl;
    // // else cout<<ans2<<endl;



    // cout<<ans<<endl;













    return 0;

}

Measured memory_bytes: 39756
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

using mint=modint998244353;

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

struct S{
  mint a;
  int size;
};

S op(S l, S r){
  return S{l.a+r.a,l.size+r.size};
}

S e(){
  return S{0,0};
}

struct F{
  mint a,b;
};

S mapping(F l, S r){
  return S{r.a*l.a+r.size*l.b,r.size};
}

F composition(F l, F r){
  return F{l.a*r.a,r.b*l.a+l.b};
}

F id(){
  return F{1,0};
}

int main(){
  int N,Q;
  scanf("%d%d",&N,&Q);
  
  vector<S> a(N);
  rep(i,N){
    int x;
    scanf("%d",&x);
    a[i]={x,1};
  }
  
  lazy_segtree<S, op, e, F, mapping, composition, id> st(a);
  
  rep(i,Q){
    int t;
    scanf("%d",&t);
    if(t==0){
      int l,r,b,c;
      scanf("%d%d%d%d",&l,&r,&b,&c);
      st.apply(l,r,F{b,c});
    }
    else if(t==1){
      int l,r;
      scanf("%d%d",&l,&r);
      printf("%d\n",st.prod(l,r).a.val());
    }
  }
  
  return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n ; cin >> n ;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	int active = 0 ;
	int ans = 0;
	rep(i,n){
		if(active < a[i]){
			ans += a[i] - active;
			active = a[i];
		}
		else if(active > a[i]){
			active = a[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

ll prefix[N];
int main() {
    prefix[0] = 0;
    prefix[1] = 1;
    for(int i = 2; i < N; ++i) {
        prefix[i] = prefix[i-1] + i;
    }
    int n, k;
    while(~scanf("%d %d", &n, &k)) {
        int stNum = (k % 2 == 0) ? k/2 : k;
        int foot = (k % 2 == 0) ? k/2 : k;
        ll ans = 0;
        for(int i = stNum; i <= n; i += foot) {
            int t1 = n / k;
            if( (k % 2 == 0) && (i % k) ) {
                t1 = (n + k/2) / k;
            }
            ans += 1ll * t1 * t1;
        }

        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];
int main(){
    int n,m,T;
    rep(i,0,3){
        cin>>n>>m;
        a[n]++;
        a[m]++;
    }
    rep(i,1,5){
        if(a[i]>2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;

	void doIt() {
		int n = sc.nextInt();
		UnionFindTree utf = new UnionFindTree(n);
		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			int z = sc.nextInt();
			utf.unite(x, y);
		}
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			if(utf.par[i] == i) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}
	class UnionFindTree{
		int n;
		int[] par;
		int[] rank;
		UnionFindTree(int n){
			this.n = n;
			par = new int[n];
			rank = new int[n];
			for(int i = 0; i < n; i++) {
				par[i] = i;
				rank[i] = 0;
			}
		}
		int find(int x) {
			if(par[x] == x) {
				return x;
			}
			else {
				return par[x] = find(par[x]);
			}
		}
		
		void unite(int x, int y) {
			x = find(x);
			y = find(y);
			if(x == y) return;
			if(rank[x] < rank[y]) par[x] = y;
			else {
				par[y] = x;
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		
		boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}
	

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 90672
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

void solve(void){

  long long int r,D,x;
  cin >> r >> D >> x;
  
	for(int i=0;i<10;i++){
      if(r*x-D>0) x=r*x-D;
      else x=0;
      cout << x <<endl;
    }
    
return;
}
int main(void){
  
	solve();
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,k;
	cin>>a>>b>>k;
	ll dif=min(a,k);
	a-=dif;
	k-=dif;
	dif=min(b,k);
	b-=dif;
	k-=dif;
	puta(a,b);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n,a,c=0;
	char s[50];
	scanf("%d %s",&n,s);
	a=strlen(s);
	for(int i=0;i<a;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') c++;
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 1704
#include <stdio.h>

int main(void)
{
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  if (a >= 0 && b >= 0 && c >= 0 && a <= 100 && b <= 100 && c <= 100) {
    if (a < b && b < c) {
      puts("Yes");
    } else {
      puts("No");
    }
  }

  return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int ans = 0;

		int ans1 = A * X + B * Y;
		int tmp = Math.min(X, Y);
		int ans2 = C * tmp * 2;
		ans2 += A * (X - tmp);
		ans2 += B * (Y - tmp);
		int tmp2 = Math.max(X, Y);
		int ans3 = C * tmp2 * 2;

		if (ans1 < ans2) {
			if (ans1 < ans3) {
				ans = ans1;
			} else {
				ans = ans3;
			}
		} else {
			if (ans2 < ans3) {
				ans = ans2;
			} else {
				ans = ans3;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
mod = 1000000007
def ff(a, b):
  ans = 1
  while b:
    if b & 1: ans = ans * a % mod
    b >>= 1
    a = a * a % mod
  return ans
n=int(input())
print(((ff(10,n)-2*ff(9,n)+ff(8,n))%mod+mod)%mod)

Measured memory_bytes: 9060
#include<cstdio>

int main(){
	int r, c, t;
	scanf("%d %d", &r, &c);
	int a[c];

	for(int i = 0; i < c; i++){
		a[i] = 0;
	}

	for(int i = 0; i < r; i++){
		int s = 0;
		for(int j = 0; j < c; j++){
			scanf("%d", &t);
			printf("%d ", t);
			s += t;
			a[j] += t;
		}
		printf("%d\n", s);
	}

	int b = 0;
	for(int i = 0; i < c; i++){
		printf("%d ", a[i]);
		b += a[i];
	}
	printf("%d\n", b);
}	

Measured memory_bytes: 1028
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int N;
    cin >> N;

    vld p(N);
    rep(i, N) cin >> p[i];

    vvld dp(N + 1, vld(N + 1, 0));
    dp[0][0] = 1;

    reple(i, 1, N)
    {
        reple(j, 0, N)
        {
            if (j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
            dp[i][j] +=dp[i - 1][j] * (1 - p[i - 1]);
        }
    }

    ld ans = 0;
    reple(i, N / 2 + 1, N) ans += dp[N][i];

    cout << setprecision(10) << setiosflags(ios::fixed);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 141056
#!/usr/bin/env python3
import sys


def solve(N: int, B: "List[int]"):
    A = [0 for i in range(N)]
    for i in range(N):
        if i==0:
            A[i] = B[i]
        elif i < N-1:
            A[i] = min(B[i], B[i-1])
        elif i==N-1:
            A[i] = B[i-1]
    print(sum(A))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

typedef unsigned long long ull;

// 文字数を返す
int calc(ull num, char *str, int i)
{
	ull div;
	int mod;

	--num;
	div = num / 26;
	mod = num % 26;

	// ansに逆順（左詰めで入れる感じ）でcharをいれる
	str[i] = mod + 97;
	if (div == 0)
		return ++i;
	return calc(div, str, ++i);
}

int main(void)
{
	ull n;
	int cnt;
	char ans[20];

	scanf("%llu", &n);

	cnt = calc(n, ans, 0);
	while (0 < cnt)
		printf("%c", ans[--cnt]);
	return (0);
}

Measured memory_bytes: 1656
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<pair<ll, ll>> a(n);
	for (ll i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		a[i].first = x;
		a[i].second = y;
	}

	vector<pair<ll, ll>> b(m);
	for (ll i = 0; i < m; i++)
	{
		ll x, y;
		cin >> x >> y;
		b[i].first = x;
		b[i].second = y;
	}

	for (ll i = 0; i < n; i++)
	{
		ll d = inf;
		ll id = -1;
		for (ll j = 0; j < m; j++)
		{
			ll c = abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
			if (d > c)
			{
				d = c;
				id = j + 1;
			}
		}

		println(id);
	}
}


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

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

  // 'a'から'z'までのパターンを全てシミュレーションして、操作回数の最小値を求める
  int mini = 1e9;
  for (char c = 'a'; c <= 'z'; c++) {
    // 文字列tmpの文字が全てcになるまで繰り返す
    string tmp = s;
    int cnt = 0;
    while (1) {
      bool flag = true;
      for (int i = 0; i < tmp.size(); i++) {
        if (tmp[i] != c) flag = false;
      }
      if (flag) {
        mini = min(mini, cnt);
        break;
      }

      // tmpにcが見つかればその位置 + 1の文字をcに変えて、それ以外の任意の文字を削除する
      vector<int> v; // cに変える添え字を格納する
      for (int i = 0; i < tmp.size(); i++) {
        if (tmp[i] == c) v.push_back(i+1);
      }
      // 文字をcに変える
      for (int i = 0; i < v.size(); i++) {
        tmp[v[i]] = c;
      }
      // 先頭を削除する
      tmp.erase(tmp.begin());
      cnt++;
    }
  }

  // 解答
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
#define EPR(msg) cerr << msg << endl;
#define AST(exp, msg) EPR(msg) assert(exp);
#define TAST(exp, msg) EPR(msg) while(!exp){}
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];


  map<int, ll> mp;
  REP(i,N) mp[A[i]] += 1;

  EPR(mp[A[0]])

  ll total = 0;
  for(auto p : mp) {
    ll num = p.second;
    if (num > 1) {
      total += num * (num -1) / 2;
    }
  }
  EPR(total)

  REP(i,N) {
    ll  ans = total;

    ll num = mp[A[i]];
    if (num >= 2) {
      ll nC2 = num*(num-1)/2;
      ll n_1C2 = (num-1)*(num-2)/2;
      ans = ans - nC2 + n_1C2;
    }

    cout << ans << endl;
  }


  return 0;
}

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

int top = 0,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];
  
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      push(atoi(s));
    }
  }

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

  return 0;
}
      

Measured memory_bytes: 548
#include <iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	int r_total=0,b_total=0;
	for (int i=1;i<=a;i++)
	{
		char s;
		cin>>s;
		if (s=='B')  b_total++;
		else if (s=='R')  r_total++;
	}
	if (b_total<r_total)  cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    l, r = 0, len(s) - 1
    ans = 0
    while r > l:
        if s[l] == s[r]:
            l += 1
            r -= 1
        else:
            if s[l] == 'x':
                l += 1
            elif s[r] == 'x':
                r -= 1
            else:
                print(-1)
                exit()
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
program ABC_092_A_TravelingBudget
   implicit none
   integer(8) A, B, C, D
   read(*, *) A
   read(*, *) B
   read(*, *) C
   read(*, *) D
    if(A < B) then
	   if(C < D) then
	       write(*, *) A + C
	   else 
	       write(*, *) A + D	      
       end if
    else 
	   if(C < D) then
	       write(*, *) B + C
	   else 
	       write(*, *) B + D
	   end if
	end if
end program ABC_092_A_TravelingBudget

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N=3e3+5;

int n;
int a[N];
LL dp[N][N];
LL dfs(int l,int r,bool t)
{
	if(l==r+1) return 0;
	if(dp[l][r]) return dp[l][r];
	if(t) dp[l][r]=min(dfs(l+1,r,0)-a[l],dfs(l,r-1,0)-a[r]);
	else dp[l][r]=max(dfs(l+1,r,1)+a[l],dfs(l,r-1,1)+a[r]);
	return dp[l][r];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	printf("%lld\n",dfs(1,n,0));
	
	return 0;
}

Measured memory_bytes: 70272
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    double w, h;
    cin >> w >> h;
    if(w==1 || h ==1) cout << 1 << endl;
    else cout << setprecision(30) << ceil(w*h/2.0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,n,a[105];
int main()
{
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<endl;
        return 0;
    }
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=0;i<=100;i++)
  {
      int a1=x-i,a2=x+i,f1=1,f2=1;
      
      for(int j=1;j<=n;j++)
      {
          if(a[j]==a1) f1=0;
          if(a[j]==a2) f2=0;
      }
      if(f1==1 && f2==0) 
      {
          cout<<a1<<endl;
          return 0;
      }
      
      if(f1==0 && f2==1)
      {
        cout<<a2<<endl;  
        return 0;
      }
      
      if(f1==1 && f2==1) 
      {
          cout<<a1<<endl;
          return 0;
      }
      
  }
  
  return 0;
}


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

int c[50000][4]{};

bool check(int i, int j) {
    for (int k = 0; k < 4; k++) {
        int t = 1<<k;
        if ((t & j) != 0 && c[i][k] == 1) return false;
    }
    return true;
}

int main() {
    int H, N;
    cin >> H >> N;
    int x[N], y[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        c[y[i]][x[i]] = 1;
    }

    int d[H][16]{};
    fill(d[0], d[H], -1);
    int a = 0;
    
    for (int i = 0; i < 4; i++) {
        if (c[0][i] == 1) a += (1<<i);
    }
    d[0][a] = 0;
    
    // 0000 1100 0110 0011 1111
    // 0    3    6    12    15
    for (int i = 1; i < H; i++) {
        int t = 0; // i-1 列目の配置
        int u = 0; // i列目の配置
        for (int j = 0; j < 4; j++) {
            if (c[i - 1][j] == 1) t += (1<<j);
            if (c[i][j] == 1) u += (1<<j);
        }
        // 何も置かない
        for (int j = 0; j < 16; j++) {
            d[i][u] = max(d[i][u], d[i - 1][j]);
        }
        
        for (int j = 0; j < 16; j++) {
            if (d[i - 1][j] < 0) continue;
            for (int k = 0; k < 3; k++) {
                int c = (1<<k) + (1<<(k + 1));
                if (check(i - 1, c) && check(i, c) && (j & c) == 0) {
                    d[i][u | c] = max(d[i][u | c], d[i - 1][j] + 1);
                }
            }
            if (check(i, 15) && check(i - 1, 15) && (j & 15) == 0) {
                d[i][15] = max(d[i][15], d[i - 1][j] + 2);
            }
        }
    }
    int v = 0;
    for (int i = 0; i < 16; i++) {
        v = max(v, d[H - 1][i]);
    }
    cout << v << "\n";
    
    return 0;
}


Measured memory_bytes: 4192
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let lines = input.split('\n');

  let mut iter = lines.map(|l| l.parse::<u32>().unwrap());

  let (sum, min) = iter.by_ref().take(4)
    .fold((0, 100), |(sum, min), n|
      (sum + n, if n < min { n } else { min })
    );
  let max = iter.take(2).max().unwrap();

  println!("{}", sum - min + max);
}



Measured memory_bytes: 5012
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

vector <int> dv;
vector <ll> dp;

ll mpow(ll n,ll t)
{
	if(t==0) return 1LL;
	ll ret=mpow(n,t/2);
	ret=ret*ret%MOD;
	if(t%2==1) ret=ret*n%MOD;
	return ret;
}
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			dv.push_back(i);
			if(i<n/i) dv.push_back(n/i);
		}
	}
	sort(dv.begin(),dv.end());
	dp.resize(dv.size());
	ll ret=0;
	for(int i=0;i<dv.size();i++)
	{
		dp[i]=mpow(k,(dv[i]+1)/2);
		for(int j=0;j<i;j++)
		{
			if(dv[i]%dv[j]==0)
			{
				dp[i]-=dp[j];
				if(dp[i]<0) dp[i]+=MOD;
			}
		}
		ret+=dp[i]*(ll) (dv[i]%2==1?dv[i]:dv[i]/2)%MOD;
		if(ret>=MOD) ret-=MOD;
	}
	printf("%lld\n",ret);
	return 0;
}


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

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

  int a, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    int cnt = 0;
    while (a % 2 == 0) {
    cnt++;
    a /= 2;
    }
    if (i == 0) 
      ans = cnt;
    else if (cnt < ans)
      ans = cnt;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define MAX 2000000
#define INFTY (1<<30)
using namespace std;

int H;

void maxHeapify(int A[], int i){
    int l = 2 * i;
    int r = 2 * i + 1;
    int largest;
    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int A[]){
    for(int i = H/2; i > 0; i--){
        maxHeapify(A, i);
    }
}

void heapIncreaseKey(int A[],int i, int key){
    if(key < A[i]) cout << "新しいキーは現在のキーより小さい\n";
    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        swap(A[i], A[i/2]);
        i = i/2;
    }
}

void insert(int A[], int key){
    H++;
    A[H] = -INFTY;
    heapIncreaseKey(A, H, key);
}

int extractMax(int A[]){
    int max;
    if( H < 0) cout << "error" << endl;
    else{
        max = A[1];
        A[1] = A[H+1];
        maxHeapify(A, 1);
    }
    return max;
}

int main(){
    string com;
    int key, A[MAX+1];
    for(int i = 0; i < MAX+1; i++){
        A[i] = 0;
    }
    H = 0;
    cin >> com;
    while(com != "end"){
        if(com == "insert"){
            cin >> key;
            insert(A, key);
        }else if(com == "extract"){
            H--;
            cout << extractMax(A) << endl;
        }
        cin >> com;
    }

    return 0;
}


Measured memory_bytes: 10968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Queue;
import java.util.Set;

public class Main {
	public static void main(String args[])throws IOException{
		BufferedReader br=
				new BufferedReader(new InputStreamReader(System.in));
		int cNum=Integer.parseInt(br.readLine());
		for(int i=0;i<cNum;i++){
			String buf=br.readLine();
			String sbuf[]=buf.split(" ");
			int cubes[]=new int[30];
			for(int j=0;j<30;j++) cubes[j]=Integer.parseInt(sbuf[j]);
			System.out.println(searchAnswer(cubes));
		}
	}
	static int searchAnswer(int cubes[]){
		if(isClear(cubes)) return 0;

		Set<String> check=new HashSet<String>();
		check.add(Arrays.toString(cubes));

		int originalCubes[]=new int[30];
		for(int i=0;i<30;i++) originalCubes[i]=cubes[i];

		int dequeueSize=4;
		Queue<Integer> paths = new ArrayDeque<Integer>();
		for(int i=0;i<dequeueSize;i++) paths.add(i+1);

		for(int i=1,digit=10;i<9;i++,digit*=10){
			int newDequeueSize=0;
			for(int j=0;j<dequeueSize;j++){
				int opes=paths.poll();
				int back=0;
				//System.out.println("?????????"+opes);
				for(int ope=opes%10,opes2=opes;opes2>0;opes2/=10,ope=opes2%10){
					operate(ope,cubes);
					back=back*10+ope;
				}

				//for(int count=0;count<cubes.length;count++)
				//	System.out.print(cubes[count]);
				//System.out.println();

				if(isClear(cubes)) return i;
				if(!check.contains(Arrays.toString(cubes))){
					//System.out.println("??????");
					for(int k=1;k<=4;k++){
						if(back%10==k) continue;
					//	System.out.println(opes+k*digit);
						paths.add(opes+k*digit);
					}
					//System.out.println("?????????");
					newDequeueSize+=3;
					check.add(Arrays.toString(cubes));
					//System.out.println(Arrays.toString(cubes));
				}
				for(int k=0;k<30;k++) cubes[k]=originalCubes[k];
			}
			dequeueSize=newDequeueSize;
		}
		return -1;
	}
	static boolean isClear(int cubes[]){
		int cmp=cubes[0];
		for(int i=1;i<9;i++)
			if(cmp!=cubes[i]) return false;
		if(cubes[9]!=cubes[10]||cubes[10]!=cubes[11]) return false;
		if(cubes[12]!=cubes[13]||cubes[13]!=cubes[14]) return false;
		if(cubes[15]!=cubes[16]||cubes[16]!=cubes[17]) return false;
		if(cubes[18]!=cubes[19]||cubes[19]!=cubes[20]) return false;
		return true;
	}
	static void operate(int pat,int cubes[]){
		int replace[][][]={
				{{0,27},{1,28},{2,29},{14,15},{20,18}},
				{{2,21},{5,24},{8,27},{18,11},{12,14}},
				{{6,21},{7,22},{8,23},{9,11},{12,17}},
				{{0,23},{3,26},{6,29},{15,17},{9,20}},
		};
		for(int i=0;i<replace[pat-1].length;i++){
			int select[][]=replace[pat-1];
			int tmp=cubes[select[i][0]];
			cubes[select[i][0]]=cubes[select[i][1]];
			cubes[select[i][1]]=tmp;
		}
	}
}

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

int main()
{ 
  int i,j,n,s,k,matchcounter=0;
  cin>>n;

  if (n > 100000) { return 0;}

  int* nums = new int[n];
  for (int i = 0; i< n ; i++) {
        cin>>nums[i];
  }

  cin>>s;

  if (s > 50000) { return 0;}
  int* numz = new int[s];
  for (i = 0; i  < s; i++) {
        cin>>numz[i];
  }

  k = n/2;

  for(i=0;i<s;i++)
     {
                if (numz[i] >= nums[k]) {

                        for(j=k;j<n;j++)
                        {
                                if(numz[i]==nums[j])
                                {
                                        matchcounter++;
                                        break;
                                }
                        }
                }
                else {
                        for (j=0; j<k; j++) {

                                if(numz[i]==nums[j])
                                {
                                        matchcounter++;
                                        break;
                                }
                        }

                }
     }
         cout<<matchcounter<<endl;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long long n,x,s[200],dp[201][100001]={0},mod=1e9+7;
  cin>>n>>x;
  rep(i,n) cin>>s[i];
  sort(s,s+n);
  rep(i,x+1) dp[1][i]=i%s[0];
  for(int i=1;i<n;i++)rep(j,x+1) dp[i+1][j]=(dp[i][j%s[i]]+dp[i][j]*i)%mod;
  cout<<dp[n][x];
}

Measured memory_bytes: 157312
package main

import "fmt"

// https://atcoder.jp/contests/abc127/tasks/abc127_b
func main() {
	var r, d, x int
	fmt.Scan(&r, &d, &x)
	gram := x
	for i := 0; i < 10; i++ {
		gram = gram * r -d
		fmt.Println(gram)
	}
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int n;
long long count[125252];
long long k;
int main(void){
    // Here your code !
    scanf("%d",&n);
    scanf("%lld",&k);
    while(n--){
        int a,b;
        scanf("%d%d",&a,&b);
        count[a] += b;
    }
    for(int i=0;i<125252;i++){
        k -= count[i];
        if(k <= 0){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k ; cin >> n >> k;
  if(n / 2 + n % 2 >= k) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> ii;

ll a[100002], b[100002];

int main(){
	fastio;
	int n; cin >> n;
	for(int i = 0; i < n + 1; ++ i) cin >> a[i];
	for(int i = 0; i < n; ++ i) cin >> b[i];
	ll ans = 0;
	for(int i = 0; i < n; ++ i){
		if(b[i] > a[i]){
			b[i] -= a[i];
			ans += a[i];
			a[i] = 0;
		}
		else{
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}

		if(b[i] > a[i + 1]){
			ans += a[i + 1];
			b[i] -= a[i+1];
			a[i+1] = 0;
		}
		else{
			ans += b[i];
			a[i+1] -= b[i];
			b[i] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5152
using System;
namespace a
{
  class b
  {
    static void Main()
    {
      int goukei = int.Parse(Console.ReadLine());
      int[] z = new int [4];
      for (int x = 0;x < goukei;x++)
      {
        string kotae = Console.ReadLine();
        if (kotae == "AC")
        {
          z[0] = z[0] + 1;
        }
        if (kotae == "WA")
        {
          z[1] = z[1] + 1;
        }
        if (kotae == "TLE")
        {
          z[2] = z[2] + 1;
        }
        if (kotae == "RE")
        {
          z[3] = z[3] + 1;                   
        }
      }
      Console.WriteLine("AC x " + z[0]);
      Console.WriteLine("WA x " + z[1]);
      Console.WriteLine("TLE x " + z[2]);
      Console.WriteLine("RE x " + z[3]);
    }
  }
}

Measured memory_bytes: 30636
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
 
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
 
int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
 
  int a, b; cin >> a >> b;
  int c = max(a, b);
  if(a == b) cout << 2 * c << endl;
  else cout << 2 * c - 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,i,j,Mod=1000000007,k,ans1,ans2;
long long x1=1,x2=1,y11=1,y2=1;
long long get(long long x,long long y){
    long long ans=1,cur=x;
    while(y){
        if(y & 1){
            ans = ans * cur % Mod;
        }
        cur = cur * cur % Mod;
        y >>= 1;
    }
    return ans;
}
int main(){
    
    cin>>n>>a>>b;
    k=get(2,n)-1;
    
    for(i=n-a+1;i<=n;i++)x1=x1*i%Mod;
    for(i=1;i<=a;i++)y11=y11*i%Mod;
    
    for(i=n-b+1;i<=n;i++)x2=x2*i%Mod;
    for(i=1;i<=b;i++)y2=y2*i%Mod;
    
    ans1=(x1*get(y11,Mod-2))%Mod;
    ans2=(x2*get(y2,Mod-2))%Mod;
    
    cout<<(k-ans1-ans2+3*Mod)%Mod<<endl;
}

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


int main(){

    int n; cin >> n;

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int main(){
    int n1=0,n2=0,n3=0;
    int n,ans,len,sum=0;
    string s;

    cin >>n;

    for (int i = 0; i < n; i++){
        cin >>s;
        len=s.length();

        for (int j = 0; j < len-1; j++){
            if(s[j]=='A'&&s[j+1]=='B')sum++;
        }

        if(s[0]=='B' && s[len-1]=='A'){
            n3++;
        }else if(s[len-1]=='A'){
            n1++;
        }else if(s[0]=='B'){
            n2++;
        }
    }

    if(n3>0){
        if(n2>0 && n1>0){
            ans = sum + n3 + min(n1-1,n2-1) + 1;
        }else if(n1>0 || n2>0){
            ans = sum + n3;
        }else{
            ans =sum + n3 -1;
        }
    }else{
        if(n2>0 && n1>0){
            ans = sum + min(n1,n2);
        }else{
            ans = sum;
        }
    }



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


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m,i,xy[100000][2];
	int b[100000],anss[100000]={1},ans=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		xy[i][0]=x;
		xy[i][1]=y;
	}
	for(i=0;i<n;i++)b[i]=1;
	for(i=0;i<m;i++){
		b[xy[i][0]]--;
		b[xy[i][1]]++;
		if(anss[xy[i][0]]==1)anss[xy[i][1]]=1;
		if(b[xy[i][0]]==0)anss[xy[i][0]]=0;
	}
	for(i=0;i<n;i++)ans+=anss[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n) {
  int ret = 1;
  for (int i = 1; i < n + 1; ++i) {
    ret = ret * i;
  }
  return ret;
}

/* 最大公約数 */
template <typename T>
T gcd(T x, T y) { return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>
T lcm_n(vector<T> &numbers) {
  T l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); ++i) {
    l = lcm(l, numbers[i]);
  }
  return l;
}

/*
 * DP向け
 */
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

  cout << (s == t.substr(0, s.length()) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int a, b, c , d,e,K;
  cin >> a >> b >> c >> d >> e >> K;

  if(e-a <= K){
   cout << "Yay!" << endl;
  }
    
  
  else cout << ":(" << endl;
  
 
  return 0;
}

Measured memory_bytes: 256
def counting_sort(A, k):
    B = [0 for _ in range(len(A))]
    C = [0 for _ in range(k)]
    for i in range(len(A)):
        C[A[i]] += 1

    for i in range(1, k):
        C[i] = C[i] + C[i-1]

    for i in range(len(A)-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] = C[A[i]] - 1
    
    return B
    
n = int(input())
A = list(map(int, input().split()))
k = max(A) + 1
B = counting_sort(A, k)
print(*B)


Measured memory_bytes: 224388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,k;
  cin>>n>>k;
  ll a[n],i=0;
  while(i<n)
    cin>>a[i++];
  sort(a,a+n);
  i=0;
  ll ans=0;
  while(i<k)
  {
    ans+=a[i];
    i++;
  }
  deb(ans)

}

Measured memory_bytes: 3640
# 始めカッコの個数を先に確定させる
# ある特定の時点で")"の方が多いなら、あとから"("が出て来ても遅い
ans = 0  # これの最小値になった絶対値分を文頭につける
N = int(input())
S = input()
hazimekakko = 0
owarikakko = 0
for i in range(N):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1
    ans = max(ans, owarikakko-hazimekakko)
# 終わりかっこの方が多いタイミングのその量を確定させる
S = abs(ans)*"(" + S

hazimekakko = 0
owarikakko = 0
for i in range(len(S)):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1

S = S + (hazimekakko-owarikakko)*")"
print(S)


Measured memory_bytes: 3064
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
import sys
sys.setrecursionlimit(10**6)
t=N()
INF=float("inf")
def f(n):
    if n in dp:
        return dp[n]
    r=INF
    for i,j in zip([2,3,5],[a,b,c]):
        x=(n//i)*i
        y=n-x
        r=min(r,f(x//i)+min(j+y*d,(n-x//i)*d))
        x=((n+i-1)//i)*i
        y=x-n
        r=min(r,f(x//i)+min(j+y*d,(n-x//i)*d))
    dp[n]=r
    return r
for i in range(t):
    dp=dict()
    n,a,b,c,d=NM()
    dp[2]=min(d*2,d+a)
    dp[1]=d
    dp[0]=0
    print(f(n))

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

long long a[10], b[10];

int main(){
	for (int i = 0; i < 4; i++) scanf("%lld", &a[i]), b[i] = 1 << i;
	long long n;
	scanf("%lld", &n); n = n * 4;
	vector<pair<int, int > > res; res.push_back({a[0], b[0]});
	for (int i = 1; i < 4; i++){
		if (a[i] * res[res.size() - 1].second < res[res.size() - 1].first * b[i]){
			res.push_back({a[i], b[i]});
		}
	}	
	reverse(res.begin(), res.end());
	long long ans = 0;
	for (pair<int, int > v : res){
		ans += n / v.second * v.first;
		n = n % v.second;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;cin>>x;
  for(ll i=x;;i++){
    bool fl=true;
    for(ll j=2;j<=sqrt(x);j++){
      if(i%j==0){fl=false;break;}
    }
    if(fl){cout<<i<<endl;return 0;}
  }
  return 0;
}


Measured memory_bytes: 256
import sys
t = sys.stdin.readline()

t1 = t.rstrip()

t2 = t1.split(' ')

T = int(t2[0])
A = int(t2[1])
B = int(t2[2])
p1 = A*T

if B < p1:
    print(B)
elif B > p1:
    print(p1)
else:
    print(B)


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

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

int main(){
    ll a,b;
    cin>>a>>b;
    if(a<=0 and 0<=b){
        cout << "Zero" << endl;
        return 0;
    }

    if(0<a){
        cout << "Positive" << endl;
        return 0;
    }

    if(b<0){
        ll num = b-a+1;
        if(num%2==0){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<=c*b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

using namespace std;


int main(){
	int n;
	string s,t;
	
	cin >> n >> s >> t;
	
	for(int i=0;i<n;i++){
		cout << s[i] << t[i];
	}
	
	cout << endl;
	
	
	return 0;
}

Measured memory_bytes: 256