akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

void Add(int &a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
}
 
void Mul(int &a, int b) {
  a = 1LL * a * b % MOD;
}
 
int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 
namespace Math {
  const int NMAX = (int)1e7;
  int pow2[1 + NMAX];
  int fact[1 + NMAX], tcaf[1 + NMAX];
  void Precalc() {
    fact[0] = pow2[0] = 1;
    for (int i = 1; i <= NMAX; ++i) {
      pow2[i] = pow2[i - 1];
      Add(pow2[i], pow2[i]);
 
      fact[i] = fact[i - 1];
      Mul(fact[i], i);
    }
    tcaf[NMAX] = Pow(fact[NMAX], -1);
    for (int i = NMAX - 1; i >= 0; --i) {
      tcaf[i] = tcaf[i + 1];
      Mul(tcaf[i], i + 1);
      assert(1LL * fact[i] * tcaf[i] % MOD == 1);
    }
  }
  int Choose(int n, int k) {
    if (k > n || n < 0) return 0;
    return 1LL * fact[n] * tcaf[n - k] % MOD * tcaf[k] % MOD;
  }
};

int main() {
    ll a,b;
    cin >> a >> b;
    if ((a+b)%3!=0) {cout << 0 << endl;return 0;}
    ll c=(a+b)/3;
    if (a<c || b<c) {cout << 0 << endl;return 0;}
    Math::Precalc();
    cout << Math::Choose(c,a-c) << endl;
}


Measured memory_bytes: 117376
#include <stdio.h>
int main (void){
	int a[10],b[10],i,j,n;
	for(i=0;i<10;i++)scanf("%d",&a[i]);
	for(i=0;i<10;i++)scanf("%d",&b[i]);
	for(i=0;i<10-1;i++){
		for(j=i;j<10;j++){
			if(a[i]<a[j]){
				n=a[i];
				a[i]=a[j];
				a[j]=n;
			}
		}
	}
	for(i=0;i<10-1;i++){
		for(j=i;j<10;j++){
			if(b[i]<b[j]){
				n=b[i];
				b[i]=b[j];
				b[j]=n;
			}
		}
	}
	printf("%d %d\n",a[0]+a[1]+a[2],b[0]+b[1]+b[2]);
	return 0;
}


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

using namespace std;

int main(){
	char from,to,cm;
	int num[200];
	fill(num,num+200,0);
	num['A']=1;
	while(cin>>from>>cm>>to){
		swap(num[from],num[to]);
	}
	if(num['A']){
		cout<<"A"<<endl;
	}
	else if(num['B']){
		cout<<"B"<<endl;
	}
	else
		cout<<"C"<<endl;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<set>
using namespace std;
int main(void)
{
  set<int> st;
  int n, x;
  int ans=0;
  cin>>n;
  for(int i=0; i<n; i++)
    {
      cin>>x;
      if(st.find(x)== st.end())
	{
	  st.insert(x);
	  ans++;
	}
      else
	{
	  st.erase(x);
	  ans--;
	}
    }
  cout<<ans<<endl;
  return 0;
}

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

const int INF = 1001001001;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> dp(h + 1, INF);
  dp[0] = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    rep(j, h) {
      int nj = min(j + a, h);
      dp[nj] = min(dp[nj], dp[j] + b);
    }
  }
  cout << dp[h] << endl;

  return 0;
}


Measured memory_bytes: 3656
function main(input) {
    var s = input.split('\n')[1];
    var r = 1;
    for (var i = 1; i < s.length; i++)
        if (s[i - 1] !== s[i]) r++;
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
int min_color = 0, max_color = 0;
vector<int> color(8, 1);

void count(int c) {
    if (color[c]) {
        min_color++;
        max_color++;
        color[c] = 0;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    rep(i, n) {
        int c, a = A[i];
        if (a <= 399) {
            c = 0;
            count(c);
        } else if (a <= 799) {
            c = 1;
            count(c);

        } else if (a <= 1199) {
            c = 2;
            count(c);

        } else if (a <= 1599) {
            c = 3;
            count(c);

        } else if (a <= 1999) {
            c = 4;
            count(c);
        } else if (a <= 2399) {
            c = 5;
            count(c);
        } else if (a <= 2799) {
            c = 6;
            count(c);
        } else if (a <= 3199) {
            c = 7;
            count(c);
        }else{
            max_color++;
            if (min_color == 0) {
                min_color++;
            }
        }
    }
    cout << min_color << " " << max_color << endl;

    return 0;
}

Measured memory_bytes: 3608
from sys import stderr
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
red.sort(key=lambda x:x[1], reverse=True)
blue.sort()
print(red,file=stderr)
print(blue,file=stderr)

ans = 0
for bx, by in blue:
    for rx, ry in red:
        if rx < bx and ry < by:
            ans += 1
            red.remove((rx,ry))
            break
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), k = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt();
		System.out.println(Math.min(n, k) * x + Math.max(n - k, 0) * y);
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 4e8;

int n, m;
int k[150];
int x[150][10];
int d[150][10];
int dp[150 * 10 * 76];

int index(int i, int j, int k){
	return (i * 10 + j) * (m + 1) + k;
}

int cost(int i, int j, int k, int l){
	int dx = x[i][j] - x[k][l];
	return (d[i][j] + d[k][l]) * (dx >= 0 ? dx : -dx);
}

int main(){
	while(true){
		scanf("%d%d", &n, &m);
		
		if(n == 0){
			break;
		}

		rep(i, n){
			scanf("%d", &k[i]);
			rep(j, k[i]){
				scanf("%d%d", &x[i][j], &d[i][j]);
			}
		}

		fill_n(dp, index(n, 0, 0), inf);

		rep(i, k[0]){
			dp[index(0, i, 0)] = 0;
		}
		if(m > 0){
			rep(i, k[1]){
				dp[index(1, i, 1)] = 0;
			}
		}

		for(int s = 1; s < n; ++s){
			rep(t, k[s]){
				rep(u, m + 1){
					rep(v, k[s - 1]){
						dp[index(s, t, u)] = min(dp[index(s, t, u)], dp[index(s - 1, v, u)] + cost(s - 1, v, s, t));
					}
					if(s >= 2 && u >= 1){
						rep(v, k[s - 2]){
							dp[index(s, t, u)] = min(dp[index(s, t, u)], dp[index(s - 2, v, u - 1)] + cost(s - 2, v, s, t));
						}
					}
				}
			}	
		}

		int ans = inf;
		rep(i, k[n - 1]){
			rep(j, m + 1){
				ans = min(dp[index(n - 1, i, j)], ans);
			}
		}
		rep(i, k[n - 2]){
			rep(j, m){
				ans = min(dp[index(n - 2, i, j)], ans);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1484
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    S = SS()

    # 1の塊の長さと位置を調べる
    l = []
    if S[0] == '1':
        l.append(0)
    else:
        l.append(0)
        l.append(0)
    for i in range(N - 1):
        if S[i] == '0' and S[i+1] == '1':
            l.append(i + 1)
        elif S[i] == '1' and S[i+1] == '0':
            l.append(i + 1)
    if S[-1] == '1':
        l.append(N)
    else:
        l.append(N)
        l.append(N)
    # print(S)
    # print(l)

    # 1の塊をK+1個くっつけた場合の長さを調べる
    ans = 0
    if len(l) // 2 - 1 < K:
        ans = N
    else:
        for i in range(len(l) // 2 - K):
            ans = max(l[2*i+2*K+1] - l[2*i], ans)

    # 端の0を逆立ちさせた場合
    # if S[0] == '0':
    #     ans = max(l[2*K-1], ans)
    # if S[-1] == '0':
    #     ans = max(N - l[len(l)-2*K], ans)
    
    # 全部1だった場合(塊の間も無いし端の0もない)
    # if l == [0, N]:
    #     ans = N

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14168
n = int(input())
e = [[int(i) for i in input().split()] for i in range(2)] 
n = len(e[0])
result = 0
for i in range(n):
    if e[0][i] > e[1][i]:
        result = result + (e[0][i] - e[1][i])
        
print(result)

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

int main(int argc,char* argv[])
{
   int N;
   int a=0,b=0,c=0;
   scanf("%d",&N);
   int tmp;
   for(int i=0;i<N;i++)
   {
   	  scanf("%d",&tmp);
   	  if(tmp%4==0) a++;
   	  else if(tmp%2==0) b++;
   	  else c++;
   }
   
   if(a==0)
   {
   	  if(b==N) printf("Yes");
   	  else printf("No");
   }
   else 
   {
   	  if(c<=a) printf("Yes");
   	  else if(c==a+1&&b==0)printf("Yes");
   	  else printf("No");
   	  
   }
   
   return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

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

Measured memory_bytes: 128
#include <iostream>
#include <string>
#define foor for(int i=0;i<n;i++)
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define ic int a;cin>>a;
#define ic2 ic int b;cin>>b;
#define ic3 ic2 int c;cin>>c;
int s = 0;
using namespace std;
int main() {
	ic2 cout << 6 - (a + b) << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<char> l(1,S.at(0));
  for(int i=0; i<N-1; i++){
    if(S.at(i) != S.at(i+1)){
      l.push_back(S.at(i+1));
    }
  }
  cout << l.size() << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int L;

signed main(){
    cin>>L;
    int N=20;
    vector<tuple<int,int,int>>es;

    rep(i,N-2){
        es.pb(make_tuple(N-1-(i+1),N-1-i,0));
        es.pb(make_tuple(N-1-(i+1),N-1-i,1<<i));
    }

    if(L>>19&1){
        es.pb(make_tuple(0,1,0));
        es.pb(make_tuple(0,1,1<<18));
    }

    for(int i=18;i>=0;i--){
        if(L>>i&1){
            int l=L;
            l-=l&((1<<(i+1))-1);
            es.pb(make_tuple(0,N-1-i,l));
        }
    }

    cout<<N<<" "<<es.size()<<endl;
    for(auto p:es){
        cout<<get<0>(p)+1<<" "<<get<1>(p)+1<<" "<<get<2>(p)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define PB push_back
#define fi first
#define se second
#define mkpr make_pair
#define reps(i,j,k) for(int i = j; i <k; i++)
#define rep(i,j) reps(i,0,j)
typedef pair < int , pair < int ,int > > P;
bool memo[23*60+60];
int main(){
    int n;
    vector < P > M;
    scanf("%d",&n);
    rep(i,n){
        int a,b;
        scanf("%d %d",&a,&b);
        if(memo[a*60+b]++)continue;
        M.PB(mkpr(a*60+b,mkpr(a,b)));
    }
    int m;
    scanf("%d",&m);
    rep(i,m){
        int a,b;
        scanf("%d %d",&a,&b);
        if(memo[a*60+b]++)continue;
        M.PB(mkpr(a*60+b,mkpr(a,b)));
    }
    stable_sort(M.begin(),M.end());
    rep(i,M.size()){
        printf("%d:%02d%c",M[i].se.fi,M[i].se.se,i == M.size()-1?'\n': ' ');
    }
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (2010)

//int n,k,dp[N][N][2];
//int main(){
//	scanf("%d%d",&n,&k);
//	dp[0][0][0]=1;
//	for (int i=1;i<=n;i++){//放i个球 
//		for (int j=min(i,k);j>=max(1,(i-(n-k)));j--){//放j个B 
//			for (int k=j;k>=1;k--){//k次 
//				dp[j][k][0]=(dp[j][k][0]+dp[j][k][1])%M;
//				dp[j][k][1]=(dp[j-1][k-1][0]+dp[j-1][k][1])%M;
//			}
//		}
//	}
//	for (int i=1;i<=k;i++) printf("%d\n",(dp[k][i][0]+dp[k][i][1])%M);
//}
////TLM
int n,k,c[N][N];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		c[i][1]=c[i][i]=1;
		for (int j=2;j<i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%M;
	}
	c[0][0]=1;
	for (int i=1;i<=k;i++){
		ll ans=0;
		for (int j=i-1;j<=n-k;j++)
			ans=(ans+1ll*c[k][i]*c[j][i-1]%M*(n-k-j+1)%M)%M;
		printf("%lld\n",ans);
	}
		
}
//B:C(i,k);
//R:C(i+1,n-k);



Measured memory_bytes: 15104
# 03-Getting_Started-Watch.py

# ????¨?
# ?§???????????????? SS ???????????????????????§???hh:mm:ss ?????¢?????????????????????????????????????????????
# ????????§???hh ????????????mm ??? 60 ???????????????ss ??? 60 ??????????§???¨????????????

# Input
# SS ?????????????????????????????????
# Output
# hh???mm???ss ??? :??????????????????????????§??????????????????????????????????????°?????????????????´??????0 ????????????????????¨???????????????????????????????????????

# Constraints
# 0???S<86400
# Sample Input
# 46979
# Sample Output
# 13:2:59

# print("ss?????\??????")
x=int(input())
# print("ss=%d."%x)

# hh????¨????
hh=int(x/3600)
hh_remain = x%3600

#mm????¨????
mm=int(hh_remain/60)
mm_remain = hh_remain%60

#ss????¨????
ss=mm_remain

print ("{0}:{1}:{2}".format(hh,mm,ss));

Measured memory_bytes: 7640
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int K; cin >> K;
    vector<int> l = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << l[K-1] << endl;
    return 0;
}


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

struct MaxFlowDinic {
	typedef int flow_t;
	struct Edge {
		int next;
		size_t inv; /* inverse edge index */
		flow_t res; /* residual */
	};
	int n;
	vector<vector<Edge>> G;
	vector<int> q, l, start;

	void init(int _n) {
		n = _n;
		G.resize(n);
		for (int i = 0; i < n; i++) G[i].clear();
	}
	void add_edge(int s, int e, flow_t cap, flow_t caprev = 0) {
		Edge forward{ e, G[e].size(), cap };
		Edge reverse{ s, G[s].size(), caprev };
		G[s].push_back(forward);
		G[e].push_back(reverse);
	}
	bool assign_level(int source, int sink) {
		int t = 0;
		memset(&l[0], 0, sizeof(l[0]) * l.size());
		l[source] = 1;
		q[t++] = source;
		for (int h = 0; h < t && !l[sink]; h++) {
			int cur = q[h];
			for (const auto& e : G[cur]) {
				if (l[e.next] || e.res == 0) continue;
				l[e.next] = l[cur] + 1;
				q[t++] = e.next;
			}
		}
		return l[sink] != 0;
	}
	flow_t block_flow(int cur, int sink, flow_t current) {
		if (cur == sink) return current;
		for (int& i = start[cur]; i < G[cur].size(); i++) {
			auto& e = G[cur][i];
			if (e.res == 0 || l[e.next] != l[cur] + 1) continue;
			if (flow_t res = block_flow(e.next, sink, min(e.res, current))) {
				e.res -= res;
				G[e.next][e.inv].res += res;
				return res;
			}
		}
		return 0;
	}
	flow_t solve(int source, int sink) {
		q.resize(n);
		l.resize(n);
		start.resize(n);
		flow_t ans = 0;
		while (assign_level(source, sink)) {
			memset(&start[0], 0, sizeof(start[0]) * n);
			while (flow_t flow = block_flow(source, sink, numeric_limits<flow_t>::max()))
				ans += flow;
		}
		return ans;
	}
};

const int inf = 1e5;
const int MAXN = 105;

int N, M;
char S[MAXN][MAXN];
int in[MAXN][MAXN], out[MAXN][MAXN];
int source, sink, v;

int px[4] = {1,-1,0,0};
int py[4] = {0,0,1,-1};

int main() {
	scanf("%d%d",&N,&M);
	for (int i = 1; i <= N; i++) {
		scanf("%s", S[i]+1);
	}
	source = 0;
	sink = N*M*2 + 1;
	v = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			in[i][j] = ++v;
			out[i][j] = ++v;
		}
	}
	MaxFlowDinic f;
	f.init(2*N*M + 2);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (S[i][j] == 'X') {
				if (i == 1 || i == N || j == 1 || j == M) {
					f.add_edge(source, in[i][j], inf);
				}
				f.add_edge(in[i][j], out[i][j], inf);
				f.add_edge(out[i][j], sink, inf);
			} else {
				if (i == 1 || i == N || j == 1 || j == M) {
					f.add_edge(source, in[i][j], 1);
				}
				f.add_edge(in[i][j], out[i][j], 1);
				for (int k = 0; k < 4; k++) {
					int x = i + px[k];
					int y = j + py[k];
					if (1 <= x && x <= N && 1 <= y && y <= M) {
						f.add_edge(out[i][j], in[x][y], inf);
					}
				}
			}
		}
	}
	int flow = f.solve(source, sink);
	if (flow >= inf) puts("-1");
	else printf("%d\n", flow);
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int m,n,s,i,j,m2,cnt,a[1000];
int main()
{
    cin>>n>>m;
    for(i=0; i<n; i++)
        cin>>a[i];
    s=accumulate(a,a+n,s);
    //m2=s/(4.0*m);
    sort(a,a+n);
    for(i=0; i<n; i++)
        if(a[i]>=s/(4.0*m))
            cnt++;
    if(cnt>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
    long long int h, w;
    long long int result;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        result = 1;
    }
    else {
        result = (h * w + 1) / 2;
    }
    
    cout << result << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    return 0;
}

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

int main(){
    int a,b,c;
    
    while(1){
        cin >> a >> b >> c;
        if(a==-1 && b==-1 && c==-1) break;
        int s=a+b;
        if(a==-1 || b==-1) cout << "F" << endl;
        else if((s) >= 80) cout << "A" << endl;
        else if((s) >= 65) cout << "B" << endl;
        else if((s) >= 50 || c >=50) cout << "C" << endl;
        else if((s) >= 30) cout << "D" << endl;
        else cout << "F" << endl;
    };
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int N,M,K;

#define TMAX 100000
vvi F,B;//friend,block
// vi visited(TMAX+1);
vi gid(TMAX+1);
// vi ans(TMAX+1);

// void dfs(int root, int parent){
// 	if(visited[parent]) return;
// 	visited[parent] = true;
// 	gid[root]++;
// 	for(auto c:F[parent]){
// 		dfs(root, c);
// 	}
// 	visited[parent] = false;
// }

void bfs(int root){
	// vi visited(N+1);
	queue<int> q;
	q.push(root);
	while(!q.empty()){
		int p = q.front(); q.pop();
		// if(visited[p]) continue;
		// visited[p] = true;
		if(gid[p]) continue;
		gid[p] = root;
		for(auto c:F[p]){
			// if(visited[c]) continue;
			if(gid[c]) continue;
			q.push(c);
		}
	}
}

int main(){
	cin>>N>>M>>K;

	F.resize(N+1);
	rp(i,0,M){
		int s,t; cin>>s>>t;
		F[s].push_back(t);
		F[t].push_back(s);
	}

	vi cnt(N+1);
	rp(i,1,N+1){
		// if(!gid[i]) bfs(i);
		bfs(i);
		cnt[gid[i]]++;
	}

	// rp(i,1,N+1){printf("%2d ",i);}puts("");///
	// rp(i,1,N+1){printf("%2d ",gid[i]);}puts("");///
	// rp(i,1,N+1){printf("%2d ",cnt[i]);}puts("");///

	B.resize(N+1);
	rp(i,0,K){
		int s,t; cin>>s>>t;
		if(gid[s] != gid[t]) continue;
		B[s].push_back(t);
		B[t].push_back(s);
	}

	// rp(i,1,N+1){
	// 	printf("%2d) ",i);
	// 	for(auto x:F[i])printf("%2d ",x);puts("");
	// }puts("");////

	// rp(i,1,N+1){
	// 	printf("%2d) ",i);
	// 	for(auto x:B[i])printf("%2d ",x);puts("");
	// }puts("");///

	int myself = 1;
	rp(i,1,N+1){
		cout<< cnt[gid[i]] - F[i].size() - B[i].size() - myself <<" ";
	}

}


Measured memory_bytes: 12536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"No"<<endl
#define YES() cout<<"Yes"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

ll powe(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

void solve()
{
    ll i,j,k=0,n,l;
    string s;
    cin>>s;
    n=s.length();
    ll ans=0;
    for(i=0;i<n;i++)
    {
        ans=ans*10+(s[i]-'0');
        ans%=9;
    }
    if(ans%9) NO();
    else YES();
    
}

int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

void dfs(int node,bool vis[],vector<int> v[])
{
	vis[node]=1;
	for(auto x:v[node])
		if(!vis[x])
			dfs(x,vis,v);
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n,m;
    cin>>n>>m;

    vector<int> v[n];
    for(int i=0;i<m;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }

    bool vis[n]={0};
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	if(!vis[i])
    	{
    		dfs(i,vis,v);
    		ans++;
    	}
    }

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

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

a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0

for i in range(n):
    eat=b[a[i]-1]
    ans=ans+eat
    if i==n-1:
        break
    if a[i+1]==a[i]+1:
        ans=ans+c[a[i]-1]

print(ans)

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int n, cnt = 0;
string s;

char c = 'a';

vector<string> ans;

void go(int i){
    if (i == n){
        ans.pb(s);
        return;
    }
    for (int j = 0; j < i; j++){
        s[i] = s[j];
        go(i+1);
    }
    s[i] = c++;
    go(i+1);
    c--;

}

void solve(){
    cin >> n;
    s.resize(n);
    go(0);
    sort(all(ans));
    ans.resize(unique(all(ans)) - ans.begin());
    for (string t : ans){
        cout << t << endl;
    }
}
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
   // cin >> t;
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 200544
#include <algorithm>
#include <cctype>
#include <cstdint>
#include <iostream>
#include <map>
#include <numeric>
#include <stdexcept>
#include <string>
#include <utility>

using Num = std::int64_t;

class Solver {
  public:
    std::string s;
    Num solve() {
      std::map<char, int> char_idx;
      std::string symbols = "=+-*01()";
      Num num = 0;
      for (auto c : s) {
        if (std::isalpha(c) and char_idx.count(c) == 0) {
          int x = char_idx.size();
          char_idx[c] = x;
        }
      }
      if (char_idx.size() > 8) return 0;
      s_ = s;
      s_.push_back('\0');
      std::sort(symbols.begin(), symbols.end());
      do {
        for (std::size_t i = 0; i < s_.size(); ++i) {
          s_[i] = (isalpha(s[i])? symbols[char_idx[s[i]]]: s[i]);
        }
        if (eval_q()) ++num;
        std::reverse(symbols.begin() + char_idx.size(), symbols.end());
      } while (std::next_permutation(symbols.begin(), symbols.end()));
      return num;
    }
  private:
    std::string s_;
    bool eval_q() {
      // std::cerr << "TRY: " << s_ << std::endl;
      try {
        std::size_t i = 0;
        Num left, right;
        left = eval_e(i);
        if (s_[i] != '=') throw std::runtime_error("left");
        ++i;
        right = eval_e(i);
        if (i < s.size()) throw std::runtime_error("right");
        // std::cerr << left << (left == right? " == ": " != ") << right << std::endl;
        return left == right;
      } catch (std::runtime_error &e) {
        // std::cerr << "FAIL: " << e.what() << std::endl;
        return false;
      }
    }
    Num eval_e(std::size_t &i) {
      Num n = eval_t(i);
      while (i < s.size()) {
        if (s_[i] == '+') {
          ++i;
          n += eval_t(i);
        } else if (s_[i] == '-') {
          ++i;
          n -= eval_t(i);
        } else {
          break;
        }
      }
      return n;
    }
    Num eval_t(std::size_t &i) {
      Num n = eval_f(i);
      while (s_[i] == '*') {
        ++i;
        n *= eval_f(i);
      }
      return n;
    }
    Num eval_f(std::size_t &i) {
      Num n;
      if (s_[i] == '-') {
        ++i;
        n = -eval_f(i);
      } else if (s_[i] == '(') {
        ++i;
        n = eval_e(i);
        if (s_[i] != ')') throw std::runtime_error(")");
        ++i;
      } else {
        n = eval_n(i);
      }
      return n;
    }
    Num eval_n(std::size_t &i) {
      if (s_[i] == '0' or s_[i] == '1') {
        Num n = s_[i] - '0';
        ++i;
        if (n == 0 and (s_[i] == '0' or s_[i] == '1')) throw std::runtime_error("leading zero");
        while (true) {
          if (s_[i] == '0' or s_[i] == '1') {
            n = 2 * n + s_[i] - '0';
            ++i;
          } else {
            break;
          }
        }
        return n;
      } else {
        throw std::runtime_error("N");
      }
    }
};

int main() {
  Solver s;
  std::cin >> s.s;
  std::cout << s.solve() << std::endl;
  return 0;
}

Measured memory_bytes: 3240
from functools import reduce

if __name__ == '__main__':
    def mod_comb(n, k, mod):
        child = reduce(lambda x, y: x * y % mod, range(n, n - k, -1))
        parent = reduce(lambda x, y: x * y % mod, range(1, k + 1))
        return child * pow(parent, mod - 2, mod) % mod


    MOD = 10 ** 9 + 7
    n, a, b = map(int, input().split())
    all_comb = pow(2, n, MOD)
    fa = mod_comb(n, a, MOD)
    fb = mod_comb(n, b, MOD)
    ans = all_comb - fa - fb - 1
    print(ans % MOD)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int tmp=ceil(n/1.08);
    if((int)(tmp*1.08)==n) cout << tmp << endl;
    else cout << ":(" << endl;
}


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

int main(void){
    int a,b; cin >> a >> b;

    if(a%3==0 or b%3==0 or (a+b)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

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

typedef long long ll;
#define PI 2 * acos (0.0)

int main()
{
  ll n ;
  string s ;
  cin >> s ;
  if(s == "SUN") n = 2 ;
  else if(s == "MON") n = 3 ;
  else if(s == "TUE") n = 4 ;
  else if(s == "WED") n = 5 ;
  else if(s == "THU") n = 6 ;
  else if(s == "FRI") n = 7 ;
  else if(s == "SAT") n = 1 ;


  if(2 - n > 0) cout << (2 - n) << endl ;
  else  cout << 7 + (2 - n) ;
}


Measured memory_bytes: 256
function Main(s){
  const n = s.length;
  var p = 0;
  for(var i = 0; i < n; i++){
    if(s[i] === "p") p++;
  }
  console.log(Math.floor(n / 2 - p));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7500
n = int(input())
if n % 2 != 0:
    print(0)
    exit()

m = 10
a = []
b = []
while m <= n:
    a.append(n // m)
    m *= 5
    if len(a) > 1:
      b.append(a[-2] - a[-1])
if a:
    b.append(a[-1])

ans = 0
for i in range(len(b)):
    ans += (i+1)*b[i]
print(ans)

Measured memory_bytes: 9120
#include <stdio.h>

int IsPrime(int n);

int main(void) {
	int n,i,x,count=0;
	scanf("%d",&n);
	if(n>=1&&n<=10000){
		for(i=0;i<n;i++){
			scanf("%d",&x);
			if(x>=2&&x<=100000000){
				if(IsPrime(x)) {
				count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

int IsPrime(int n){
	int i;
	for(i=2;i*i<=n;i++){
		if(n%i==0) return 0;
	}
	return 1;
}


Measured memory_bytes: 2124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void Yes() { print("Yes"); }
        private static void No() { print("No"); }
        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            var c = ReadInt();
            var a = Read();
            int r = 0, b = 0;
            for(int i = 0; i < a.Length;i++)
            {
                if(a[i] == 'R')
                {
                    r++;
                }
                else
                {
                    b++;
                }
               
            }

            if(r > b)
            {
                Yes();
            }
            else
            {
                No();
            }

        }
    }
}

Measured memory_bytes: 13140
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 18 for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    dp[i] = min([
        dp[i-1] + abs(h[i] - h[i-1]),
        dp[i-2] + abs(h[i] - h[i-2])
    ])
print(dp[-1])


Measured memory_bytes: 13924
#include <iostream>
using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;
#define rep(i,s,n)for(ll i = s;i<n;i++)
char s[Z];

int main() {
	cin >> s;
	int i = 0;
	while (s[i] != '\0') {
		if (i % 2 == 0) {
			cout << s[i];
		}
		i++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if (b>=a) cout << a << endl;
    else cout << a-1 << endl;
    return 0;
}


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

int main(){
    int N,M,s,c;
    cin >> N >> M;


    vector<int> num(N,10);
    for(int i=0;i<M;i++){
        cin >> s >> c;
        s--;
        if(num[s]==10){
            num[s]=c;
            if(N!=1&&c==0&&s==0){
                cout << -1 << endl;
                return 0;
            }
        }else if(num[s]!=c){
            cout << -1 <<endl;
            return 0;
        }
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if(num[i]!=10){
            ans+=num[i]*pow(10,N-i-1);
        }else if(i==0){
            ans+=pow(10,N-1);
        }
    }

    if(M==0&&N==1){
        ans=0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        int s[10000];
        long long int t[10000]={0},sum=0;

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

        sort(s,s+n);

        for(int i=0;i<n-1;i++){
            sum+=t[i+1]=t[i]+s[i];
        }

        cout<<sum<<endl;

    }

}

Measured memory_bytes: 1292
//*
// yarn compile template.ts で監視可能
{
  const process = (a: string): string => {
    return ""
  }

  const Main = (input: string): string => {
    //const n: number = parseInt(input)
    //const a: string[]  = input.split(" ")
    //const aa: string[][]  = input.split("\n").split(" ")
    const aa: string[][] = input.split("\n").map((e) => e.split(" "))
    const k = parseInt(aa[0][1]) - 1
    const strs = aa[1][0].split("")
    strs[k] = strs[k].toLowerCase()

    console.log(strs.join(""))
    return strs.join("")
  }

  // 提出時はこちらをアクティブにする
  Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}

// */


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
  int n, k;
  cin>>n>>k;
  ll ans = LONG_MAX;
  repn(i, 0, n)
  {
    ll aa = 1;
    rep(j, 0, i)
      aa = aa * 2;
    aa += (n-i)*k;

    ll bb = 1 + i*k;
    rep(j, i, n)
      bb *= 2;
    aa = min(aa, bb);
    //cout<<aa<<endl;
    ans = min(ans, aa);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
};

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll k, n;
  cin >> k >> n;
  ll arr[n + 5];
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
  }

  arr[n + 1] = arr[1] + k;

  ll res = 0;
  for (ll i = 1; i <= n; i++)
    res = max(res, arr[i + 1] - arr[i]);

  cout << k - res << en;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<pair<string,pii> > sp(n,pair<string,pii>());
    for (int i=0;i<n;i++){
        string s;
        int x;
        cin >> s >> x;
        sp[i] = make_pair(s,make_pair(-1*x,i+1));
    }
    sort(sp.begin(),sp.end());
    for (int i=0;i<n;i++){
        cout << sp[i].second.second << endl;
    }
}

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

int main(){
    int mid,end;
    int re;
    while(1){
        cin >> mid >> end >> re;
        if(mid==-1 && end==-1) 
            break;
        if(mid==-1 || end==-1)
            cout << "F" << endl;
        else if((mid+end)>=80)
            cout << "A" << endl;
        else if((mid+end)>=65)
            cout << "B" << endl;
        else if((mid+end)>=50)
            cout << "C" << endl;
        else if((mid+end)>=30)
            if(re>=50)  cout << "C" << endl;
            else cout << "D" << endl;
        else
            cout << "F" << endl;       
    }
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int H, W, h, w;

	cin >> H >> W;
	cin >> h >> w;

	cout << (H - h)*(W - w) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  char S[80];
  
  fgets(S,80,stdin);
  
  if(S[6] <= '4' && S[5] == '0'){
    puts("Heisei");
  }
  else{
    puts("TBD");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>

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

using namespace std;

int a[300001];
int b[3000001];

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

	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	map<int,bool> m;
	int t;

	rep(i,n)
	{
		cin >> t;
		m[t] = true;
	}

	t = -1;
	rep(i,300001)
	{
		b[i] = t;

		if(m[i]) t = i;
	}

	rep(i,q)
	{
		int x;
		cin >> x;
		int ans = 0;

		for(int j=0;j<300001;j += x)
		{
			if(b[j] != -1)
			{
				ans = max(ans,b[j]%x);
			}
		}

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

Measured memory_bytes: 28156
n, m = map(int, input().split())
sc = []
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    sc.append((s, c))

for nn in range(10**n):
    sn = str(nn)
    if len(sn) != n:
        continue
    for s, c in sc:
        if int(sn[s]) != c:
            break
    else:
        print(nn)
        break
else:
    print(-1)

Measured memory_bytes: 9180
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, m;
vi v[100];
int u[10];
int ans;

void dfs(int cur, int l = 0){
    u[cur] = 1;
    int cnt = 0;
    for(int i = 0; i < sz(v[cur]); ++i){
        int to = v[cur][i];
        if(!u[to]){
            dfs(to, l + 1);
            cnt++;
        }
    }
    if(cnt == 0 && l + 1 == n) ans++;
    u[cur] = 0;
}

int solve(){
    cin >> n >> m;
    for(int i = 0, x, y; i < m; ++i){
        cin >> x >> y;
        --x, --y;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(0);
    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
// Binary indexed tree supporting binary search.
 
 
#define x first
#define y second

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

typedef pair<int, int> pii;
//#define forn(i, a,b) for (int i = (int) a; i <= (int) b; ++i)
const int MAXN = 101;


int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin>>N;
    set<string> s1;
    forn(i,N){
    	string s;
    	cin>>s;
    	s1.insert(s);
	}
	cout<<s1.size()<<endl;
		
	

	return 0;	
}

Measured memory_bytes: 19132
#include <bits/stdc++.h>
#include <deque>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int n, q, query, t, x;
	cin >> n >> q;
	vector<priority_queue<int> > Q(n);
	
	rep(i, q)
	{
		cin >> query >> t;
		if (query == 0)
		{
			cin >> x;
			Q[t].push(x);
		}
		else if (query == 1)
		{
		    if (!Q[t].empty())
		    {
			    cout << Q[t].top() << endl;
		    }
		}
		else
		{
		    if (!Q[t].empty())
			{
			    Q[t].pop();
			}
		}
	}
}


Measured memory_bytes: 4088
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    if(n%2){cout<<0<<endl;return 0;}
    sort (v.begin(),v.end());
    a=v[n/2-1];
    b=v[n/2];
    cout<<b-a<<'\n';
    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  2019 = 3*673
}*/

signed main(){
  int l, r;
  cin >> l >> r;

  if(r-l >= 673){
    cout << 0 << endl;
  }else{
    int ans = inf;
    rep(i, l, r) rep(j, l+1, r+1){
      chmin(ans, i*j%2019);
    }
    cout << ans << endl;
  }

  return 0;
}


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

bool isExist[10000];
int n, k, m;

int main(){
	while (cin >> n >> k >> m) {
		if (!n) break;
		int i;
		
		for (i = 0; i < n; i++) { isExist[i] = true; }
		
		int cur = m - 1;
		isExist[cur] = false;
		for (i = 1; i < n; i++) {
			int step = (k - 1) % (n - i) + 1;
			while (true) {
				if (isExist[cur]) step--;
				if (step <= 0) break;
				cur++;
				if (cur == n) cur = 0;
			}
			isExist[cur] = false;
		}
		cout << cur + 1 << endl;
	}
	return 0;
}

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

int main(){
	long long t,b,ls;
	cin >> t;
	for(int i=1;i <= sqrt(t);i++){
		if(t % i == 0){
			b = t / i;
			ls = i + b;
		}
	}
	cout << ls - 2 << endl;
	return 0;
} 

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

using namespace std;

int main(){
    string ans = "War";
    int n,m,x,y,vx_max = -100,vy_min = 1000;
    cin >> n >> m >> x >> y;

    vector<int>vx(n);
    vector<int>vy(m);

    for(int i = 0;i < n;i++){
        cin >> vx[i];
        vx_max = max(vx_max,vx[i]);
    }

    for(int i = 0;i < m;i++){
        cin >> vy[i];
        vy_min = min(vy_min,vy[i]);
    }

    for(int i = vx_max+1;i < vy_min+1;i++){
        if(x < i && i <= y)ans = "No War";
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};




int main() {
    int h,w;
    cin >> h >> w;
    int si, sj;
    cin >> si >> sj;
    int ti,tj;
    cin >> ti >> tj;
    --si; --sj; --ti; --tj;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    const int INF = 1e9;
    vector<vector<int>> dist(h, vector<int>(w,INF));
    deque<P> q;
    dist[si][sj] = 0;
    q.emplace_back(si, sj);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];
        q.pop_front();
        rep(v,4){
            int ni = i+di[v], nj = j+dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni,nj);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj = j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni,nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

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

int n, k;
double ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=1; i<=n; ++i){
		double t = 1.0 / n;
		int c = 0;
		int j = i;
		while(j < k){
			j <<= 1;
			++c;
		}
		while(c > 0){
			t /= 2;
			--c;
		}
		ans += t;
	}
	cout << setprecision(15) << ans << "\n";
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let m: usize = s.next().unwrap().parse().unwrap();
	let mut xs = vec![];
	let mut ys = vec![];
	let mut vert = vec![];
	let mut horz = vec![];
	for _ in 0..n {
		let y0: i32 = s.next().unwrap().parse().unwrap();
		let y1: i32 = s.next().unwrap().parse().unwrap();
		let x: i32 = s.next().unwrap().parse().unwrap();
		vert.push((y0, y1, x));
		xs.push(x);
		ys.push(y0);
		ys.push(y1);
	}
	for _ in 0..m {
		let y: i32 = s.next().unwrap().parse().unwrap();
		let x0: i32 = s.next().unwrap().parse().unwrap();
		let x1: i32 = s.next().unwrap().parse().unwrap();
		horz.push((y, x0, x1));
		xs.push(x0);
		xs.push(x1);
		ys.push(y);
	}
	xs.sort();
	xs.dedup();
	ys.sort();
	ys.dedup();
	let mut field = vec![vec![false; xs.len() + 1]; ys.len() + 1];
	let mut fence = vec![vec![0u8; xs.len() + 1]; ys.len() + 1];
	for (y0, y1, x) in vert.iter() {
		let yl = ys.binary_search(y0).unwrap() + 1;
		let yr = ys.binary_search(y1).unwrap();
		let x = xs.binary_search(x).unwrap();
		for y in yl..=yr {
			fence[y][x] |= 2;
			fence[y][x + 1] |= 8;
		}
	}
	for (y, x0, x1) in horz.iter() {
		let xl = xs.binary_search(x0).unwrap() + 1;
		let xr = xs.binary_search(x1).unwrap();
		let y = ys.binary_search(y).unwrap();
		for x in xl..=xr {
			fence[y][x] |= 4;
			fence[y + 1][x] |= 1;
		}
	}

	let mut q = vec![];
	let ystart = match ys.binary_search(&0) {
		Ok(i) => i + 1,
		Err(i) => i,
	};
	let xstart = match xs.binary_search(&0) {
		Ok(i) => i + 1,
		Err(i) => i,
	};

	q.push((ystart as i32, xstart as i32));
	while let Some((y, x)) = q.pop() {
		field[y as usize][x as usize] = true;
		for (i, (dy, dx)) in [(-1, 0), (0, 1), (1, 0), (0, -1)].iter().enumerate() {
			let ny = y + dy;
			let nx = x + dx;
			if ny >= 0
				&& ny <= ys.len() as i32
				&& nx >= 0 && nx <= xs.len() as i32
				&& fence[y as usize][x as usize] & (1 << i) == 0
				&& !field[ny as usize][nx as usize]
			{
				q.push((ny, nx));
			}
		}
	}
	let mut ans = 0i64;
	for y in 0..=ys.len() {
		for x in 0..=xs.len() {
			if field[y][x] {
				ans = ans.saturating_add(if y == 0 || y == ys.len() || x == 0 || x == xs.len() {
					std::i64::MAX
				} else {
					let h = ys[y] as i64 - ys[y - 1] as i64;
					let w = xs[x] as i64 - xs[x - 1] as i64;
					h * w
				});
			}
		}
	}
	if ans == std::i64::MAX {
		println!("INF");
	} else {
		println!("{}", ans);
	}
}


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

int main(){
    char x,y;
    cin >> x >> y;
    char ans;
    if(x < y){
        ans = '<';
    }else if(x > y){
        ans = '>';
    }else{
        ans = '=';
    }
    cout << ans << endl;
}


Measured memory_bytes: 256