akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int h, w, k;
	cin >> h >> w >> k;
	char a[h][w];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> a[i][j];
	int ans = 0;
	for (int i = 0; i < (1 << h); i++)
	{
		set<int> s1;
		for (int j = 0; j < h; j++)
		{
			if (i & (1 << j))
			{
				s1.insert(j);
			}
		}
		for (int ii = 0; ii < (1 << w); ii++)
		{
			set<int> s2;
			for (int jj = 0; jj < w; jj++)
			{
				if (ii & (1 << jj))
				{
					s2.insert(jj);
				}
			}
			int bl = 0;
			for (int x = 0; x < h; x++)
			{
				for (int y = 0; y < w; y++)
				{
					if (s1.count(x) or s2.count(y))
						continue;
					bl += (a[x][y] == '#');
				}
			}
			if (bl == k)
				ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 3e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

struct SegTree {
	int t[N * 4];
	void Maintain(int o) {
		t[o] = max(t[lch], t[rch]);
	}
	void Modify(int o, int L, int R, int pos, int det) {
		if (L == R) {
			t[o] += det;
			return;
		}
		int M = (L + R) / 2;
		if (pos <= M)
			Modify(lch, L, M, pos, det);
		else
			Modify(rch, M + 1, R, pos, det);
		Maintain(o);
	}
	int Query() {
		return t[1];
	}
};
SegTree seg;

int c[N];
vector<int> a[N];

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

	int n, m, cnt;
	cin >> n >> m >> cnt;
	for (int i = 1; i <= cnt; i++) {
		int x, y;
		cin >> x >> y;
		c[y]++;
		seg.Modify(1, 1, m, y, 1);
		a[x].push_back(y);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (auto y: a[i])
			seg.Modify(1, 1, m, y, -1);
		int now = int(a[i].size()) + seg.Query();
		ans = max(ans, now);
		for (auto y: a[i])
			seg.Modify(1, 1, m, y, 1);
	}
	cout << ans << endl;

	return 0;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int x[] = fs.nextIntArray(n);
		int y[] = fs.nextIntArray(m);

		//区間の足される回数で区間の和を求める方法
		long xsum = 0;
		for(int i=1;i<n;i++) {
			int len = x[i]-x[0];
			//足し引きされる回数(マイナスを足すのは-1回足す、とする)
			long times = i - (n-1-i);
			xsum = plus(xsum, mul(len,times));
		}
		
		long ysum = 0;
		for(int i=1;i<m;i++) {
			int len = y[i]-y[0];
			//足し引きされる回数(マイナスを足すのは-1回足す、とする)
			long times = i - (m-1-i);
			ysum = plus(ysum, mul(len,times));
		}
		
		long ans = mul(xsum,ysum);
		System.out.println(ans);
		
	}
	//MOD culculations
	static long plus(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x + y) % mod;
		return res;
	}

	static long sub(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x - y + mod) % mod;
		return res;
	}

	static long mul(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * y % mod;
		return res;
	}

	static long div(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * modpow(y, mod - 2) % mod;
		return res;
	}

	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

	
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 44788
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
  int N,X,min,tmp,rest;
  scanf("%d %d",&N,&X);
  min = X + 1;
  vector<int> m(101,0);
  tmp = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d",&m[i]);
    tmp += m[i];
    if (m[i] < min) min = m[i];
  }
  X -= tmp;
  rest = X / min;
  printf("%d\n",rest + N);
  return 0;
}


Measured memory_bytes: 256
import math as mt
N,K = [int(i) for i in input().rstrip().split()]
R = 0
for n in range(1,N+1):
    l = mt.floor(mt.log2(K/n) - 0.1**9)+1
    if l <= 0:
        R += 1/N*(N-n+1)
        #print(K,n,l,R)
        break
    else:
        R += 1/N*0.5**l
        #print(K,n,l,R)
print(R)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}
int main()
{
    fast
    ll a,b;
    cin>>a>>b;
    show(max(a*b,max(a-b,a+b)));
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

MATCH_NUM = [-1, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    # N 本で作れる桁の数
    dp = [-1 for _ in range(N+1)]
    dp[0] = 0
    for i in range(N+1):
        for a in A:
            if i < MATCH_NUM[a]:
                continue
            dp[i] = max(dp[i], dp[i-MATCH_NUM[a]] + 1)

    max_digit_num = dp[N]

    res = ''
    for _ in range(max_digit_num):
        m = -1
        for a in A:
            if N < MATCH_NUM[a]:
                continue
            if dp[N-MATCH_NUM[a]] == dp[N]-1:
                if a > m:
                    m = a
        res += str(m)
        N -= MATCH_NUM[m]
    print(res)
main()


Measured memory_bytes: 3380
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int ss[112345],s1[112345];
int main()
{
	int n,k,q,i;
	cin>>n>>k>>q;
	for(i=0;i<q;i++){
		cin>>s1[i];
	}
	for(i=0;i<n;i++){
		ss[i]=k-q;
	}
	for(i=0;i<q;i++){
		ss[s1[i]-1]++;
	}
	for(i=0;i<n;i++){
		if(ss[i]>0)	cout<<"Yes"<<endl;
		else	cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1408
var x1,x2,y1,y2:longint;

begin
 readln(x1,y1,x2,y2);
 write(y1+x2-y2,' ');
 write(x2+y2-x1,' ');
 write(x1+y1-y2,' ');
 write(y1+x2-x1,' ');
end.

Measured memory_bytes: 128
s = input()
n = len(s)

i = 0
tmp = ''
ans = 0
while i<n:
  
  if s[i] == tmp:
    if i == n-1:
      break
    tmp = s[i]+s[i+1]
    i+=2
  else:
    tmp = s[i]
    i+=1
  ans +=1
    
print(ans)

Measured memory_bytes: 3500
#include <iostream>
using namespace std;
long long n,m,a[100001],b[100001],ans[100001],par[100001],Size[100001],num;
int root(int x){
    if(par[x]==x)return x;
    else return par[x]=root(par[x]);
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)par[i]=i,Size[i]=1;
    for(int i=1;i<=m;i++)cin>>a[i]>>b[i];
    num=n*(n-1)/2;
    for(int i=m;i;i--){
        ans[i]=num;
        int x=root(a[i]),y=root(b[i]);
        if(x!=y){
            num-=Size[x]*Size[y];
            Size[x]+=Size[y];
            par[y]=x;
        }
    }
    for(int i=1;i<=m;i++)cout<<ans[i]<<endl;
}

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

int main() {
    int n,x;
    cin>>n>>x;
    int vec[n-1];
    int sum=0;
    int min=1000;
    for(int i=0;i<n;i++){
        cin>>vec[i];
        sum+=vec[i];
        if(vec[i]<min) min=vec[i];
    }
    cout<<n+(x-sum)/min<<endl;

}

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 vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<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 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 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;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vl a(n+1,0);
	rep(i,n)cin>>a[i+1];
	n++;
	sort(all(a));
	int l=0,r=n;
	while(r-l>1){
		int m=l+(r-l)/2;
		vl ca;
		rep(i,n)if(i!=m)ca.push_back(a[i]);
		vvb dp(n,vb(k+1,false));
		dp[0][0]=true;
		bool ok=true;
		rep(i,n-1)rep(j,k+1){
			int v=ca[i]+j;
			if(dp[i][j] and v<=k){
				dp[i+1][j]=true;
				dp[i+1][v]=true;
				if(k-a[m]<=v and v<k){
					ok=false;
					i=n;
					break;
				}
			}
		}
		if(ok){
			l=m;
		}else{
			r=m;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)
#define MOD (1000000007LL)

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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

#define vv(t) vector< vector< T > >
#define pb push_back
#define pu push
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define EQ(a,b) (abs((a)-(b))<EPS)

int main(void){
  ios_base::sync_with_stdio(0);
  int n;
  while(cin >> n, n){
    int tail = 1, sum = 0;
    int cnt = 0;
    for(int i = 1; i <= (n - 1) / 2 + 1; i++){
      if(sum < n) sum += i;

      if(sum >= n){
        if(sum == n) cnt++;
        sum -= tail++;
        if(sum >= n) i--;
      }
    }
    if(n != 1) cout << cnt << endl;
    else cout << 0 << endl;
  }
  return 0; 
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,a,b)       for(int i = a; i < b; i++)
#define mod				1000000007
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int dp[22][(1 << 22)];
int n;
int matching(vector<vi>&arr, int i, int women_subset)
{
	// if all men are paired and if no women left, return 1 else 0
	if (i == n)
		return (women_subset == 0) ? 1 : 0;

	if (dp[i][women_subset] != -1)
		return dp[i][women_subset];

	int ans = 0;
	for (int women = 0; women < n; women++)
	{
		bool avail = (1 << women )& women_subset;
		// if women is available and compatable
		if (avail && arr[i][women])
			ans = (ans + matching(arr, i + 1, women_subset ^ (1 << women))) % mod;
	}
	return dp[i][women_subset] = ans;
}

void solve()
{
	cin >> n;
	vector<vi>arr(n, vi(n));
	fr(i, 0, n)
	fr(j, 0, n)
	cin >> arr[i][j];
	memset(dp, -1, sizeof(dp));
	cout << matching(arr, 0, ((1 << n) - 1 )) << endl;
	return;
}

int32_t main()
{
	c_p_c();
	solve();
	return 0;
}

Measured memory_bytes: 724536
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

void solve()
{
    cout.precision(20);
    db N;
    cin >> N;
    cout << (N / 3) * (N / 3) * (N / 3) << "\n";
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

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

typedef struct { char c; int a; int id; } DATA;

void bubble_sort(int n, DATA *a)
{
	int i, f;
	DATA x;

	do {
		f = 0;
		for (i = n-1; i > 0; i--) {
			if (a[i].a < a[i-1].a) {
				x = a[i], a[i] = a[i-1], a[i-1] = x;
				f = 1;
			}
		}
	} while (f);
}

void selection_sort(int n, DATA *a)
{
	int i, j, minj;
	DATA x;

	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (a[j].a < a[minj].a) minj = j;
		}
		if (i != minj) {
			x = a[i], a[i] = a[minj], a[minj] = x;
		}
	}
}


//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

DATA a[102], b[102];

int main()
{
	int N, i, f;

	N = in();
	for (i = 0; i < N; i++) {
		a[i].c = getchar_unlocked();
		a[i].a = getchar_unlocked();
		a[i].id = i;
		getchar_unlocked();			// skip
	}
	memcpy(b, a, sizeof(DATA)*N);

	bubble_sort(N, a);
	f = 0;
	putchar(a[0].c), putchar(a[0].a);
	for (i = 1; i < N; i++) {
		putchar(' ');
		putchar(a[i].c), putchar(a[i].a);
		if (a[i-1].a == a[i].a && a[i-1].id > a[i].id) f = 1;
	}
	putchar('\n');
	puts(f? "Not stable": "Stable");

	selection_sort(N, b);
	f = 0;
	putchar(b[0].c), putchar(b[0].a);
	for (i = 1; i < N; i++) {
		putchar(' ');
		putchar(b[i].c), putchar(b[i].a);
		if (b[i-1].a == b[i].a && b[i-1].id > b[i].id) f = 1;
	}
	putchar('\n');
	puts(f? "Not stable": "Stable");
	return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S, T; cin >> S >> T;
    vector<int> A(S.size()+1), B(T.size()+1);
    for (int i = 0; i < S.size(); i++) {
        A[i+1] = A[i] + (S[i] == 'A' ? 1 : 2);
    }
    for (int i = 0; i < T.size(); i++) {
        B[i+1] = B[i] + (T[i] == 'A' ? 1 : 2);
    }
    int Q; cin >> Q;
    const char *YESNO[] = { "NO", "YES" };
    for (int i = 0; i < Q; i++) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        cout << YESNO[(A[b+1] - A[a]) % 3 == (B[d+1] - B[c]) % 3] << '\n';
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>

bool solve(int currPos, int totalPos, int *sourceArr, int targetVal);

int main() {
    int sourceLength, searchLength;
    int *sourceArr, *searchArr;

    std::cin >> sourceLength;
    sourceArr = (int *) calloc(sizeof(int), sourceLength + 1);
    for (int i = 0; i < sourceLength; i++) {
        std::cin >> sourceArr[i];
    }

    std::cin >> searchLength;
    searchArr = (int *) calloc(sizeof(int), searchLength + 1);
    for (int i = 0; i < searchLength; i++) {
        std::cin >> searchArr[i];
    }

    for (int i = 0; i < searchLength; i++) {
        if (solve(0, sourceLength, sourceArr, searchArr[i])) {
            std::cout << "yes" << std::endl;
        } else {
            std::cout << "no" << std::endl;
        }
    }

    free(sourceArr);
    free(searchArr);

    return 0;
}

bool solve(int currPos, int totalPos, int *sourceArr, int targetVal) {
    if (targetVal == 0) {
        return true;
    }

    if (currPos >= totalPos) {
        return false;
    }

    return solve(currPos + 1, totalPos, sourceArr, targetVal) || solve(currPos + 1, totalPos, sourceArr, targetVal - sourceArr[currPos]);
}


Measured memory_bytes: 3080
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す

        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # all_group_members O(N)かかるので注意
        return {r: self.members(r) for r in self.roots()}


adlist = UnionFind(n+1)
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    if adlist.same(a, b) == False:
        adlist.union(a, b)
print(adlist.group_count()-2)


Measured memory_bytes: 91548
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n, i = map(int, readline().split())
  print(n-i+1)
  
  
  
if __name__ == '__main__':
  main()

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<pair<int, int>> x(n);
  for (int i = 0; i < n; i++) cin >> x.at(i).first >> x.at(i).second;
  
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = x.at(i).first - x.at(j).first;
      int b = x.at(i).second - x.at(j).second;
      if (a < 0) {
        a *= -1;
        b *= -1;
      }
      else if(a == 0) b = abs(b);
      mp[make_pair(a, b)]++;
    }
  }
  
  int ans = n;
  for (auto i : mp) ans = min(ans, n - i.second);
  
  cout << ans << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pcase printf("Case %d:\n",ca)
#define mx 5000009
int ca=1;
using namespace std;
int main(){

    int n,d ;
    cin>>n>>d;
    int x[n][2];
    int sum = 0;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<2;j++){
            cin>>x[i][j];
        }
        double a = sqrt(pow(x[i][0],2)+pow(x[i][1],2));
        
        if(a<=d){sum++;}
    }
    cout<<sum<<nl;



}


Measured memory_bytes: 5256
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_N 500
#define INF 987654321
int graph[MAX_N][MAX_N];


void search(int n){
// Warshall Floyd
  for (int i = 0; i < n; i++){
    for (int s = 0; s < n; s++){
      for (int g = 0; g < n; g++){
        graph[s][g] = min(graph[s][g], graph[s][i] + graph[i][g]);
      }
    }
  }
}

int main() {
  int n,m;
  while (cin >> n >> m && n&&m ) {

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        graph[i][j] = INF;
      }
    }

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      graph[a][b] = 1;
      graph[b][a] = 1;
    }

    search(n);
    int ans = 0;

    for(int i = 1; i < n; i++){
      if(graph[i][0] <= 2)
        ans++;
    }

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

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int a; cin >> a;
    string s; cin >> s;

    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;


}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
mem = [0, 0, 0]
ans = 1
for i in range(n):
    ans *= mem.count(A[i])
    ans %= mod
    if ans == 0: break
    idx = mem.index(A[i])
    mem[idx] += 1
print(ans)

Measured memory_bytes: 20832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n;
  cin >> n;
  cout << (1000 - n % 1000 ) % 1000 << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(is, 1<<h) rep(js, 1<<w) {
        int count = 0;
        rep(i, h) rep(j, w) {
            if (is>>i & 1) continue;
            if (js>>j & 1) continue;
            if (s[i][j] == '#') count++;
        }
        if (count == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	string str;
	cin >> str;
	
	int len = str.length();
	
	int i=0, flag = 0;
	
	while(i<len)
	{
		if(str[i] == 'h' && str[i+1] == 'i')
		    i = i + 2;
		else
		{
			flag = 1;
			break;
		}
	}
	
	if(flag == 1)
	    cout << "No" << endl;
	else
	    cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
//itp1_7-a
#include <iostream>
using namespace std;

int main(){
 int m,f,r;
 char res;

 while(true){
  cin>>m>>f>>r;
  if(m==-1 && f==-1 &&r==-1) break;
  if((m==-1) || (f==-1)) cout<<'F'<<endl;
  else if((m+f)>=80) cout<<'A'<<endl;
  else if((m+f)>=65 && (m+f)<80) cout<<'B'<<endl;
  else if((m+f)>=50 && (m+f)<65) cout<<'C'<<endl;
  else if((m+f)>=30 && (m+f)<50){
   if(r>=50) cout<<'C'<<endl;
   else cout<<'D'<<endl;
  }
  else if((m+f)<30) cout<<'F'<<endl;
 }
 return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a<=b)
    {
        int n=b/a;
        if(n>c)
            cout<<c<<endl;
        else
            cout<<n<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;
const double PI = acos(-1);

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

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

void solve() {
    int n;
    cin >> n;
    int ans = (n / 2) + (n % 2);
    cout << ans << endl;
}

int main()
{
    IOS;
    //comment it out
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//#endif
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DPredictionAndRestriction {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      int r, s, p; cin >> r >> s >> p;
      string t; cin >> t;
      vector<bool> win(n);
      ll ans = 0;
      rep(i, n) {
        if (i < k || t[i] != t[i-k] || (!win[i-k])) {
          win[i] = true;
          if (t[i] == 'r') {
            ans += p;
          } else if (t[i] == 's') {
            ans += r;
          } else {
            ans += s;
          }
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  DPredictionAndRestriction solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 512
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
    }

    let mut reduce_map = HashMap::new();

    for i in 1..=n {
        let v = prime_factorize(i);
        for (key, value) in v {
            let entry = reduce_map.entry(key).or_insert(0);
            *entry += value;
        }
    }

    let mut greater_2 = 0;
    let mut greater_4 = 0;
    let mut greater_14 = 0;
    let mut greater_24 = 0;
    let mut greater_74 = 0;

    for (_, &value) in &reduce_map {
        if value >= 74 {
            greater_2 += 1;
            greater_4 += 1;
            greater_14 += 1;
            greater_24 += 1;
            greater_74 += 1;
        } else if value >= 24 {
            greater_2 += 1;
            greater_4 += 1;
            greater_14 += 1;
            greater_24 += 1;
        } else if value >= 14 {
            greater_2 += 1;
            greater_4 += 1;
            greater_14 += 1;
        } else if value >= 4 {
            greater_2 += 1;
            greater_4 += 1;
        } else if value >= 2 {
            greater_2 += 1;
        }
    }
    //println!("4 or more {}", greater_4);
    //println!("2 or more {}", greater_2);
    let mut ans = 0;
    // a^4 * b^4 * c^2
    ans += (greater_4 * (greater_4 - 1)) / 2 * (greater_2 - 2);
    //println!("1 {}", ans);
    // a^24 * b^2
    ans += greater_24 * (greater_2 - 1);
    //println!("2 {}", ans);
    // a^14 * b^4
    ans += greater_14 * (greater_4 - 1);
    //println!("3 {}", ans);
    // a^74
    ans += greater_74;
    //println!("4 {}", ans);

    println!("{}", ans);
}

fn prime_factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut res = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a += 1;
            continue;
        }
        let mut ex = 0;

        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        res.push((a, ex));
        a += 1;
    }
    if n != 1 {
        res.push((n, 1));
    }

    res
}


Measured memory_bytes: 2192
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;
struct query{
    int t, f;
    string c;
};

int main(){
    string s;int q, isreverse = 0;
    query qu;
    cin >> s >> q;
    for (int i = 0; i < q; i++){
        cin >> qu.t;
        if (qu.t == 1){
            isreverse++;
        }else{
            cin >> qu.f >> qu.c;
            if ((qu.f == 1 && isreverse % 2 == 0)
            ||qu.f == 2 && isreverse % 2 == 1){
                s.insert(0, qu.c);
            }else{
                s += qu.c;
            }
        }
    }
    if (isreverse % 2 == 1){
        reverse(s.begin(), s.end());
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  string s;
  cin >> s;
  int alph[26] = {};
  int n = s.size();
  rep(i,n){
      alph[s[i] - 'a']++;
  }
  int ans = n * (n-1) / 2 + 1;
  rep(i,26){
      ans -= alph[i] * (alph[i] - 1) / 2;
  }
  cout << ans << endl;


}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    double a,b,x,PI=3.14159265358979;
    cin>>a>>b>>x;
    if(a*a*b/2<x){
        double c=2*x/a/a-b;
        cout<<setprecision(10)<<atan((b-c)/a)/PI*180;
    }
    else{
        double c=2*x/a/b;
        cout<<setprecision(10)<<90-atan(c/b)/PI*180;
    }
}

Measured memory_bytes: 512
#include <iostream>
#define INF 1000000000
using namespace std;


struct edge{
	int from, to, cost;
};

int ans[100000];
int counter=0;
bool flag=true;

void solve(){
	int d[101][11];//地点と割引回数
	edge route[500];//路線
	int c,n,m,s,t;//割引回数,町数,路線数,出発駅,到着駅
	cin >> c>>n>>m>>s>>t;
	if(c==0) {flag=false; return;}
	
	for(int i=0;i<m;i++){
		cin >>route[i].from>>route[i].to>>route[i].cost;
	}
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<c+1;j++){//割引回数は割引無しも必要
			d[i][j]=INF;
		}
	}
	
	d[s][0]=0;
	bool update=true;
	while(update){
		update=false;
		for(int i=0;i<m;i++){
			edge e=route[i];//見やすく
			for(int j=0;j<=c;j++){
				//まずは割引無し
				if(d[e.from][j]!=INF && d[e.to][j]>d[e.from][j]+e.cost){
					d[e.to][j]=d[e.from][j]+e.cost; update=true;
				}
				if(d[e.to][j]!=INF && d[e.from][j]>d[e.to][j]+e.cost){
					d[e.from][j]=d[e.to][j]+e.cost; update=true;
				}
				
			}
			
			for(int j=0;j<c;j++){
				if(d[e.from][j]!=INF && d[e.to][j+1]>d[e.from][j]+e.cost/2){
					d[e.to][j+1]=d[e.from][j]+e.cost/2; update=true;
				}
				if(d[e.to][j]!=INF && d[e.from][j+1]>d[e.to][j]+e.cost/2){
					d[e.from][j+1]=d[e.to][j]+e.cost/2; update=true;
				}
			}
		}
	}
	int k=INF;
	for(int i=0;i<=c;i++){
		if(k>d[t][i]) k=d[t][i];
	}
	ans[counter]=k;
	counter++;
}

int main(){
	while(flag){
		solve();
	}
	for(int i=0;i<counter;i++){
		cout << ans[i]<<endl;
	}
}
	
	

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



int main(){

	vector <int> num_array;
	int car_num;
	size_t size();
	while (cin >> car_num){
	
		if (car_num != 0){
			num_array.push_back(car_num);
		}
		else if (car_num == 0){
			cout << num_array[num_array.size() - 1] << endl;
			num_array.pop_back();
		
		}
	}

	return 0;
}

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

namespace _2204
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int[] a = new int[n];
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    a[i] = x.Sum();
                }
                Array.Sort(a);
                Console.WriteLine(a[n - 1] + " " + a[0]);
            }
        }
    }
}

Measured memory_bytes: 9812
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Diff = [None]*N

for i in range(N):
  Diff[i] = A[i] - B[i]
  
sort_Diff= sorted(Diff,reverse=True)

flag=0
plus_sum=0
ans=0
minus=N+1

for i in range(N):
  if sort_Diff[i]<0:
    minus = i
    break
  plus_sum += sort_Diff[i]

if sum(sort_Diff)<0:
  print(-1)
else:
  ans = N - minus
  minus_sum = sum(sort_Diff)-plus_sum
#print(plus_sum)
#print(minus_sum)
    
  for i in range(N):
    if minus_sum + abs(sort_Diff[i]) < 0:
      minus_sum = minus_sum + abs(sort_Diff[i]) 
      if minus_sum ==0:
        break
      ans += 1
    else:
      ans = ans+1
      break

  print(ans)
     

Measured memory_bytes: 18612
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

const int MN = 100100;
vector<int> g[MN];

int k;

int b[MN];
int md[MN];

void dfs(int p) {
    md[p] = 0;
    for (int d: g[p]) {
        dfs(d);
        md[p] = max(md[p], md[d]);
    }
    if (md[p] == k-1) {
        b[p] = 0;
        md[p] = 0;
    } else {
        md[p]++;
    }
}

int main() {
    int n;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i]; a[i]--;
        b[i] = a[i];
    }
    for (int i = 1; i < n; i++) {
        g[a[i]].push_back(i);
    }

    b[0] = 0;
    dfs(0);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
const int N = 55,M = 55;
int n,m,ans;
int head[N],nxt[N*2],to[N*2],cnt = -1;
bool del[N*2];
bool vis[N];

inline void insert(int x,int y){
	to[++cnt] = y; nxt[cnt] = head[x]; head[x] = cnt;
	to[++cnt] = x; nxt[cnt] = head[y]; head[y] = cnt;
}

void dfs(int x,int fa){
	vis[x] = true;
	for(int i = head[x];i != -1;i = nxt[i])
		if((!del[i]) && (!vis[to[i]]))
			dfs(to[i],x);
}

int main(){
	scanf("%d%d",&n,&m);
	memset(head,-1,sizeof head);
	for(int i = 1;i <= m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		insert(x,y);
	}
	for(int i = 0;i <= cnt;i += 2){
		memset(vis,false,sizeof vis);
		del[i] = true; del[i^1] = true;
		dfs(1,1);
		for(int j = 1;j <= n;j++)
			if(vis[j] == false){
				ans++;
				break;
			}
		del[i] = false; del[i^1] = false;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
dislike = list(map(str, input().split()))
num = ["0","1","2","3","4","5","6","7","8","9"]
can_use = set(num) - set(dislike)

while not set(list(str(N))) <= can_use:
    N += 1

print(N)

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

int main(){
    int H[1000],W[1000];
    int tmph,tmpw;
    int i=0;
    cin>>tmph>>tmpw;
    while(tmph!=0 || tmpw!=0){
        H[i]=tmph;
        W[i]=tmpw;
        cin>>tmph>>tmpw;
        i++;
    }
    for(int j=0;j<i;++j){
        for(int h=0;h<H[j];++h){
            for(int w=0;w<W[j];++w){
                if((w+h)%2==0)cout<<'#';
                else cout<<'.';
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


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

vector<int> v;

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0)break;
        for(int i=0; i < n; i++){
            int tmp; cin >> tmp;
            v.push_back(tmp);
        }
        int sum = 0;
        sort(v.begin(), v.end());
        for(int i=1; i < n-1; i++){
            sum += v[i];
        }
        cout  << sum / (n - 2) << endl;
        v.clear();
    }

    return 0;
}



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

int main() {
  	int N;
  	cin >> N;
  	string X;
  	cin >> X;
  
  	int help[N + 1];
  	for (int i = 0; i < N + 1; i++) help[i] = 0;
  
  	for (int i = 0; i < N + 1; i++){
      	if (i == 0) continue;
      	int count = 0;
      	int a = 1;
      	int b = i;
      	while (a < i){
          	a *= 2;
        }
      	while (a != 0){
          	if (a > b) a /= 2;
          	else {
              	count++;
              	b -= a;
              	a /= 2;
            }
        }
      	help[i] = i % count;
    }
  
  	int dp[N + 1];
  	for (int i = 0; i < N + 1; i++){
      	if (i == 0){
          	dp[0] = 0;
          	continue;
        }
      	dp[i] = dp[help[i]] + 1;
    }
  
  	int one = 0; // 1の数
  	for (int i = 0; i < N; i++){
      	if (X[i] == '1') one++;
    }
  
  	int a = 1;
  	int second_pow_plus[N]; // 1が多い時の累積和
  	for (int i = 0; i < N; i++){
      	if (i >= 1) a *= 2;
      	a %= one + 1;
      	second_pow_plus[i] = a;
    }
  
  	a = 1;
  	int second_pow_minus[N]; // 1が少ない時の累積和
  	if (one >= 2) for (int i = 0; i < N; i++){
      	if (i >= 1) a *= 2;
      	a %= one - 1;
      	second_pow_minus[i] = a;
    }
  
  	int all_plus = 0; //1が多い時の元の数字
  	for (int i = 0; i < N; i++){
      	if (X[i] == '1'){
          	all_plus += second_pow_plus[N - i - 1];
          	all_plus %= one + 1;
        }
    }
  
  	int all_minus = 0; //1が少ない時の元の数字
  	if (one >= 2) for (int i = 0; i < N; i++){
      	if (X[i] == '1'){
          	all_minus += second_pow_minus[N - i - 1];
          	all_minus %= one - 1;
        }
    }
  
  	int res[N]; 
  	for (int i = 0; i < N; i++){
      	if (X[i] == '0'){
          	int aaaa = second_pow_plus[N - i - 1] + all_plus;
          	aaaa %= one + 1;
          	res[i] = dp[aaaa] + 1;
        }
      	if (X[i] == '1'){
          	if (one >= 2){
          	int aaaa = all_minus - second_pow_minus[N - i - 1];
          	aaaa += one - 1;
          	aaaa %= one - 1;
          	res[i] = dp[aaaa] + 1;
            }
          	else res[i] = 0;
        }
    }
  
  	for (int i = 0; i < N; i++){
      	cout << res[i] << endl;
    }
}

Measured memory_bytes: 7660
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K, D[10];
bool H[10];

bool hate(int V)
{
	while (V) {
		if (H[V % 10]) return false;
		V /= 10;
	}
	return true;
}

int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < 10; ++i) H[i] = false;
	for (int i = 0; i < K; ++i) {
		scanf("%d", D + i);
		H[D[i]] = true;
	}
	for (;;) {
		if (hate(N)) {
			printf("%d\n", N);
			break;
		}
		++N;
	}
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

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

  if(s.length() <= k) {
    cout << s;
  } else {
    for(int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "...";
  }
  cout << endl;

  return 0;
}

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for ( ll b = 1; b <= N; b++ ) {
        ans += (N/b) * max(b-K, 0LL);
        ans += K > 0 ? max(N%b-K+1, 0LL) : N%b;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k,s = readline() |> split |> parseMap
	if s<10^9
		for i in 1:k
			print(s," ")
		end
		for i in k+1:n
			print(s+1," ")
		end
	else
		for i in 1:k
			print(s," ")
		end
		for i in k+1:n
			print(s-1," ")
		end
	end
end
main()

Measured memory_bytes: 173452
#include <iostream> // cout, endl, cin
#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

#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int a;
  cin >> a;
  int h =  a / 3600;
  int m = a - (3600 * h);
  m = m / 60;
  int s = a - (3600 * h) - (60 * m);
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}



Measured memory_bytes: 3124
n, m = map(int, input().split())
l = sorted([list(map(int, input().split())) for i in range(n)])
money = 0

for j in range(n):
    m -= l[j][1]
    money += l[j][0] * l[j][1]

    if m < 0:
        money -= l[j][0] * -m
        break

print(money)

Measured memory_bytes: 28652
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int kaisu=0;
		String str="";
		int motometai=0;
		while(sc.hasNext()) {
			str=sc.next();
			motometai=Integer.parseInt(str);
			if(motometai==0) {
				System.exit(0);
			}
			int kotae=kaijyo0(motometai);
			System.out.println(kotae);
		}
	}

	public static int kaijyo0(int i) {		//かいじょうしたときの0の数
		 int kaisu=0;

		 if(i<5)return kaisu;
		 kaisu+=i/5+kaijyo0(i/5);
		 return kaisu;
	}
}


Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N){
    ll ans;
    ll d = N % 1000;
    if(d == 0) ans = 0;
    else ans = 1000 -d;
    cout << ans << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main() {
    int t=1;
    //cin >> t;
    while(t--){
        double n,d,i,cnt=0,a,b;
        cin >> n>>d;
        for(i=0;i<n;i++){
            cin >> a >> b;
            if((double)(sqrt((a*a) + (b*b)))<= (double)d){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3844