akhauriyash/Code-Regression huggingface dataset:
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {j : [] for j in range(n)}
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

result_ls = [[] for i in range(n)]
def dfs(pos, cnt, last):
    if len(result_ls[pos]) != 0:
        return result_ls[pos][1]
    res = cnt
    result_ls[pos] = [cnt, res]
    for candidate in graph[pos]:
        if candidate == last:
            continue
        _ = dfs(candidate, cnt + 1, pos)
        if _ < res:
            res = _
    result_ls[pos] = [cnt, res]
    return res

dfs(0, 0, -1)
cnt = 0
for res in result_ls:
    if res[0] > res[1]:
        cnt += 1
print(n - 1 - cnt)

Measured memory_bytes: 38256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n,q;
	string s;
	cin>>n>>s>>q;
	while(q--){
		ll k;
		cin>>k;
		ll dmc=0;
		ll d=0;
		ll m=0;
		ll c=0;
		ll dm=0;
		ll mc=0;

		REP(i,n){
			if(s[i]=='D'){
				d++;
			}else if(s[i]=='M'){
				m++;
				dm+=d;
			}else if(s[i]=='C'){
				c++;
				mc+=m;
				dmc+=dm;
			}
			if(i>=k-1){
				if(s[i-(k-1)]=='D'){
					d--;
					dm-=m;
				}else if(s[i-(k-1)]=='M'){
					m--;
					mc-=c;
				}else if(s[i-(k-1)]=='C'){
					c--;
				}
			}
		}
		cout<<dmc<<endl;
	}


	return 0;
}


Measured memory_bytes: 1948
// 2015/03/05 Tazoe

#include <iostream>
#include <queue>
using namespace std;

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

	queue<int> hm;
	for(int i=0; i<N; i++){
		int h, m;
		cin >> h >> m;

		hm.push(h*100+m);
	}

	int M;
	cin >> M;

	queue<int> kg;
	for(int i=0; i<M; i++){
		int k, g;
		cin >> k >> g;

		kg.push(k*100+g);
	}

	queue<int> me;

	while(true){
		if(hm.empty() && kg.empty())
			break;

		if(hm.empty()){
			me.push(kg.front());
			kg.pop();
			continue;
		}

		if(kg.empty()){
			me.push(hm.front());
			hm.pop();
			continue;
		}

		if(hm.front()==kg.front()){
			me.push(hm.front());
			hm.pop();
			kg.pop();
		}
		else if(hm.front()<kg.front()){
			me.push(hm.front());
			hm.pop();
		}
		else{
			me.push(kg.front());
			kg.pop();
		}
	}

	int t = me.front();
	me.pop();

	int t1 = t/100;
	int t2 = t%100;

	cout << t1 << ':' << t2/10 << t2%10;

	while(!me.empty()){
		t = me.front();
		me.pop();

		t1 = t/100;
		t2 = t%100;

		cout << ' ' << t1 << ':' << t2/10 << t2%10;
	}

	cout << endl;

	return 0;
}

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


int main() {
  ll n,m;cin >> n >> m;
  vector<string> a(n),b(m);
  rep(i,n) cin >> a.at(i);
  rep(i,m) cin >> b.at(i);


  for(ll i=0;i<=n-m;++i){//上からのズレ
    for(ll j=0;j<=n-m;++j){//左端からのズレ
      bool ok = true;
      rep(k,m){
        if( b.at(k) != a.at(i+k).substr(j,m) ){
          ok = false;
          break;
        }
      }
      if( ok ){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
	long long int n,m,i,k,a,b,max=0,p;
	cin>>k>>n;
	long long int ara[n];
	for(i=0;i<n;i++){
		cin>>ara[i];
	}
	for(i=0;i<n-1;i++){
	    a=ara[i+1]-ara[i];
	    if(a>max){
	    	max=a;
	    	b=i+1;
	    }
	}
	if(k-ara[n-1]+ara[0]>max){
		cout<<ara[n-1]-ara[0];
	}
	else{
	    cout<<(k-ara[b] + ara[b-1]);
	}

	return 0;
}

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

P data[101];
int N,W, DP[110][10010];

int main(){
	cin>>N>>W;
	for(int i=1;i<=N;i++){
		cin>>data[i].first>>data[i].second;
	}

	for(int i=1; i<=N; i++){
		int val=data[i].first, weight=data[i].second;

		for(int j=1; j<=W; j++){
			if(j-weight>=0){
				DP[i][j]=max(DP[i-1][j], DP[i][j-weight]+val);
			}else DP[i][j]=DP[i-1][j];
		}
	}

	cout<<DP[N][W]<<endl;
	return 0;
}



Measured memory_bytes: 7024
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    b, c = map(int, input().split())
    bc.append((b, c))

bc.sort(key=lambda x:-x[1])
cnt = 0
for b, c in bc:
    a.extend([c]*b)
    cnt += b
    if cnt>=n:
        break

a.sort(reverse=True)
print(sum(a[:n]))

Measured memory_bytes: 25596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for (int i=b;i<c+1;i++)
		if (i%a==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3592
#import <Foundation/Foundation.h>

@interface NSString (Extension)
-(NSInteger)countOfSubstring:(NSString *)pattern;
@end

@implementation NSString (Extension)
-(NSInteger)countOfSubstring:(NSString *)pattern
{
	NSMutableArray *matchingRanges = [NSMutableArray new];
	NSUInteger textLength = self.length;
	NSRange match = NSMakeRange(0, self.length);
	NSInteger count = 0;
	while(match.location != NSNotFound) {
		match = [self rangeOfString:pattern options:0L range:match];
		if (match.location != NSNotFound) {
			count++;
			match = NSMakeRange(match.location+1, self.length - match.location - 1);
		}
	}

	return count;
}
@end

int main() {
	@autoreleasepool {
		int n;
		int ans = 0;
		scanf("%d",&n);
		int x=0,y=0,z=0;
		for(int i=0;i<n;i++){
			char s[20];
			scanf("%s",s);
			NSString *S = [NSString stringWithUTF8String:s];
			NSInteger count = [S countOfSubstring:@"AB"];
			ans += count;
			char f = s[0];
			char l = s[strlen(s)-1];
			if(f=='B' && l!='A') x++;
			if(f!='B' && l=='A') y++;
			if(f=='B' && l=='A') z++;
		}
		if (z>=1) {
			ans += z-1;
			z = 1;
		}
		if(x==y){
			if(x>=1){
				ans += x+z;
			}
		}else{
			ans += MIN(x,y) + z;
		}
		printf("%d\n",ans);
	}
}


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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() {
  string s;
  cin >> s;
  vector<string> c = {"000", "111", "222", "3333", "444", "555", "666", "777", "888", "999"};
  bool ok = false;
  for (int i = 0; i < c.size(); ++i) {
    if (s.find(c[i]) != string::npos) {
      ok = true;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

#define mp make_pair

struct ev {
    int64_t x, h;
    bool inc;
    bool operator <(const ev& rhs ) const {
        return x > rhs.x || (x == rhs.x && inc);
    }
};

int main() {
    int N, D, A;
    cin >> N >> D >> A;
    priority_queue<ev> Q;
    for (int i = 0; i < N; ++i) {
        int x, h;
        cin >> x >> h;
        Q.push(ev{x, h, true});
    }
    int64_t sum = 0;
    int64_t nb = 0;
    while (!Q.empty()) {
        ev e = Q.top(); Q.pop();
        // cout << e.h << " at " << e.x << (e.inc ? " inc " : " dec ") << endl;
        if (e.inc) {
            if (e.h - sum > 0) {
                int64_t n = (e.h - sum + A - 1) / A;
                nb += n;
                sum += n * A;
                Q.push(ev{e.x + 2 * D + 1, n * A, false});
            }
        } else {
            sum -= e.h;
        }
    }
    cout << nb << endl;
}

Measured memory_bytes: 8560
import sys
import collections

class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * (size + 1)  # 非負なら親ノード，負ならグループの要素数

    def root(self, x):  # root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        elif self.parent[self.parent[x]] < 0:
            return self.parent[x]
        else:
            self.parent[x] = self.root(self.parent[x])  # xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y):  # merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]:  # xの要素数がyの要素数より「小さい」とき入れ替える
            x, y = y, x
        self.parent[x] += self.parent[y]  # xの要素数を更新
        self.parent[y] = x  # yをxにつなぐ
        return True

    def issame(self, x, y):  # same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

    def size(self, x):  # size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]


def do():
    sys.setrecursionlimit(100000000)

    N, M, K = map(int, input().split())
    friends = [list(map(int, input().split())) for _ in range(M)]
    blocks = [list(map(int, input().split())) for _ in range(K)]

    uf1 = UnionFind(N + 1) # 友達候補のUF
    friends_list= [set() for _ in range(N + 1)]
    block_list = [set() for _ in range(N + 1)]

    for query in friends :
        a,b= query
        uf1.merge(a,b)
        friends_list[a].add(b)
        friends_list[b].add(a)

    for query in blocks:
        a, b = query
        block_list[a].add(b)
        block_list[b].add(a)
    anss = []
    for i in range(1,N+1):
        s = uf1.size(i) -1 #ベースの人数

        friends = friends_list[i]
        for friend in friends:
            if uf1.issame(friend,i):
                s -=1

        blocks = block_list[i]
        for block in blocks:
            if uf1.issame(block,i):
                s -=1
        anss.append(s)
    print(*(anss))

if __name__ == "__main__":
    do()


Measured memory_bytes: 135896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt(),q=sc.nextInt();
		char[] str = sc.next().toCharArray();
		int[] flag = new int[n];
		int count = 0;
		for(int i=1;i<n;i++) {
			if(str[i-1]=='A' &&  str[i]=='C') count++;
			flag[i]=count;
		}
		for(int i=0;i<q;i++) {
			int l = sc.nextInt()-1, r = sc.nextInt()-1, ans;
			ans=flag[r]-flag[l];
			//if(r<n-1 && str[r]=='A' && str[r+1]=='C') ans--;
          	//if(str[l]=='A') ans++;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 65280
import sys
input = sys.stdin.readline
n = int(input())
s = input()
def multi_index(l,x):
  return tuple([i for i,_x in enumerate(l) if _x == x])

ans = 0
for i in range(10):
  e = 0
  if str(i) in s:
    c = multi_index(s,str(i))[0]
    for j in range(10):
      if str(j) in s and i!=j and c<=len(s)-2:
        for q in range(c+1,len(s)-1):
          if str(j) == s[q]:
            d = q
            break
        else:
          d = -1
      elif str(j) in s and i==j and len(multi_index(s,str(i)))>=2:
        d = multi_index(s,str(i))[1]
      else:
        d = -1
      if d > c:
        for l in range(10):
          if str(l) in s and i!=j and j!=l and i!=l:
            e = multi_index(s,str(l))[-1]
            if e > d:
              ans += 1
          if str(l) in s and i!=j and j==l:
            e = multi_index(s,str(l))[-1]
            if e > d:
              ans += 1
          if str(l) in s and i==j and j!=l:
            e = multi_index(s,str(l))[-1]
            if e > d:
              ans += 1
          if str(l) in s and i==j and j==l:
            e = multi_index(s,str(l))[-1]
            if e > d:
              ans += 1
          if str(l) in s and i==l and j!=l:
            e = multi_index(s,str(l))[-1]
            if e > d:
              ans += 1
print(ans)

Measured memory_bytes: 48220
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);

	for(int i=1; i<=5; i++) {
		int x; cin>>x;
		if(!x) {
			cout<<i<<endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
    long long int a,b,sum;
    char op;
    scanf("%lld %c %lld",&a,&op,&b);

    if(op=='+')
    {
        sum= a + b;
    }
    else if(op=='-')
    {
        sum= a - b;
    }
    printf("%lld\n",sum);

    return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repi(i, x) for (auto &i : (x))


using namespace std;

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

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N, S;
int T[10];
int R;

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> S;
    rep(i, S) {
        int t; cin >> t;
        rep(j, t) {
            int p; cin >> p;
            T[p-1] |= (1<<i);
        }
    }

    rep(i, S) {
        int p; cin >> p;
        R |= p<<i;
    }

    int res = 0;
    rep(i, 1<<N) {
        int c = 0;
        rep(j, N) if (i&(1<<j)) c ^= T[j];
        if (c == R) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  string s;
  cin >> s;
  s.push_back('.');

  int result = s.size();
  rep(i, 26) {
    char c = i + 'a';
    s.back() = c;
    int len = 0;
    int cost = 0;
    for (char p : s) {
      if (p == c) {
        cost = max(cost, len);
        len = 0;
      } else {
        len++;
      }
    }
    result = min(result, cost);
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 205
#define M 10000002
bool cf[M+5],vis[M+5];
int prime[M+5],tot;
int cy[N],a[N],b[N],cntx,cnty;
bool vs[N],c[N][N];
void shai()
{
	vis[1]=1;int i,j;
	for(i=1;i<=M;i++){
		if(!vis[i])prime[++tot]=i;
		for(j=1;j<=tot;j++){
			int tmp=i*prime[j];
			if(tmp>M)break;
			vis[tmp]=1;
			if(i%prime[j]==0)break;
		}
		if(cf[i]){
			if(i&1)a[++cntx]=i;
			else b[++cnty]=i;
		}
	}
}
//pay attention to vs
bool dfs(int i)
{
	for(int j=1;j<=cnty;j++){
		if(c[i][j]&&!vs[j]){
			vs[j]=1;
			if(!cy[j]||dfs(cy[j])){
				cy[j]=i;
				return 1;
			}
		}
	}
	return 0;
}
int maxmatch()
{
	memset(cy,0,sizeof(cy));
	int ret=0;
	for(int i=1;i<=cntx;i++){
		memset(vs,0,sizeof(vs));
		if(dfs(i))ret++;
	}
	return ret;
}
int ab(int x){return x<0?-x:x;}
int main()
{
	int n,i,j,x,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		cf[x]^=1;cf[x+1]^=1;
	}
	shai();
	for(i=1;i<=cntx;i++)
		for(j=1;j<=cnty;j++)
			if(!vis[ab(b[j]-a[i])])c[i][j]=1;
	ans=maxmatch();
	cntx-=ans;cnty-=ans;
	ans+=(cntx/2)*2+(cnty/2)*2;
	if(cntx%2==1&&cnty%2==1)ans+=3;
	printf("%d",ans);
}

Measured memory_bytes: 22784
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
 
const int N = 5005, P = 1000000007;
int n, m, cnt, ans, c[N], a[N], f[N], siz[N], g[N][N];
bool b[N];
int find(int x){ return f[x]==x?x:f[x]=find(f[x]);}
int Pow(ll x, int y=P-2){
	int ans=1;
	for(; y; y>>=1, x=x*x%P) if(y&1) ans=ans*x%P;
	return ans;
}
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; ++i) f[i]=i;
	for(int i=1; i<=n; ++i){
		scanf("%d", a+i);
		if(~a[i]) f[find(i)]=find(a[i]);
	}
	for(int i=1; i<=n; ++i) ++siz[find(i)], b[find(i)]|=a[i]==-1;
	for(int i=1; i<=n; ++i) if(find(i)==i){
		if(b[i]) c[++m]=siz[i];
		else ++cnt;
	}
	g[0][0]=1;
	for(int i=1; i<=m; ++i) for(int j=0; j<=i; ++j){
		g[i][j]=(ll)g[i-1][j]*(n-1)%P;
		if(j>1) g[i][j]=(g[i][j]+(j-1ll)*c[i]%P*g[i-1][j-1])%P;
		if(j==1) g[i][j]=(g[i][j]+(ll)g[i-1][j-1]*c[i])%P;
	}
	for(int i=2; i<=m; ++i) (ans+=g[m][i])%=P;
	for(int i=1; i<=m; ++i) ans=(ans+(ll)(c[i]-1)*Pow(n-1, m-1))%P;
	printf("%lld\n", ((ll)Pow(n-1, m)*(n-cnt)+P-ans)%P);
	return 0;
}

Measured memory_bytes: 70712
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
using namespace std;

signed main() {
	int a, b; scanf("%d%d", &a, &b);
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	if (a > b) {
		puts("Alice");
	}
	else if (a < b) {
		puts("Bob");
	}
	else {
		puts("Draw");
	}
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,a = m()

x = l()

ma = max(x)

dp = [[0 for j in range(ma*n+1)] for i in range(n+1)]

dp[0][0] = 1

for i in range(n):
    for j in range(1,n+1):
        for k in range(ma*n+1):
            if k-x[i] >= 0:
                dp[-(j)][k] += dp[-(j+1)][k-x[i]]

ans = 0

for i in range(1,n+1):
    if i*a <= ma*n:
        ans += dp[i][i*a]

print(ans)







Measured memory_bytes: 42988
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int n,m;
	cin >> n >> m;
	int arr[n+1] = {0};

	for(int i=0 ; i<m ; i++)
	{
		int u,v;
		cin >> u >> v;
		arr[u]++;
		arr[v]++;
	}
	
	for(int i=1 ; i<=n ; i++)
		cout << arr[i] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, max = 0, max_2 = 0, num;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (max < a) {
      max = a;
      num = i;
    }
    else if (max_2 < a) {
      max_2 = a;
    }
  }
  for (int i = 0; i < N; i++) {
    if (i == num) {
      cout << max_2 << endl;
    }
    else {
      cout << max << endl;
    }
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double L;
    cin >> L;
    double ans = L / 3;
    printf("%.10f\n", pow(ans, 3));
}


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

using namespace std;

template<typename ID_TYPE = uint64_t>
class UnionFindTreeBase
{
private:
  vector<ID_TYPE> root, rank;

public:
  UnionFindTreeBase(ID_TYPE N)
  {
    root = vector<ID_TYPE>(N);
    for (ID_TYPE n = 0; n < N; ++n) { root[n] = n; }
    rank = vector<ID_TYPE>(N, 0);
  }

  ID_TYPE find(ID_TYPE x)
  {
    if (root[x] == x) { return x; }

    root[x] = find(root[x]);

    return root[x];
  }

  void unite(ID_TYPE x, ID_TYPE y)
  {
    ID_TYPE x_root = find(x), y_root = find(y);

    if (rank[x_root] > rank[y_root]) {
      root[y_root] = x_root;
    } else if (rank[x_root] < rank[y_root]) {
      root[x_root] = y_root;
    } else if (x_root != y_root) {
      root[y_root] = x_root;
      ++rank[x_root]; 
    }
  }

  bool is_same(ID_TYPE x, ID_TYPE y)
  {
    return find(x) == find(y);
  }
};

typedef UnionFindTreeBase<uint64_t> UnionFindTree;

int main()
{
  uint64_t N, M;
  cin >> N >> M;
  
  UnionFindTree uf_tree(N);
  
  for (uint64_t m = 0; m < M; ++m) {
    uint64_t X, Y, Z;
    cin >> X >> Y >> Z;
    
    uf_tree.unite(X - 1, Y - 1);
  }
  
  set<uint64_t> s;
  for (uint64_t n = 0; n < N; ++n) {
    s.insert(uf_tree.find(n));
  }
  cout << s.size() << endl;
  
  return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

ll vi[100005],di[100005];
vector< pair<ll,ll> > aa[100005];

ll depth(ll xx)
{
    ll i;
    for(i=0;i<aa[xx].size();i++)
    {
        if(!vi[aa[xx][i].first])
        {
            vi[aa[xx][i].first]=1;
            di[aa[xx][i].first]=di[xx]+aa[xx][i].second;
            depth(aa[xx][i].first);
        }
    }
}

int main()
{
    Fast;

    ll n,i,uu,vv,ww;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
        cin>>uu>>vv>>ww;
        aa[uu].push_back(make_pair(vv,ww));
        aa[vv].push_back(make_pair(uu,ww));
    }
    vi[1]=1;
    depth(1);
    for(i=1;i<=n;i++)
        cout<<di[i]%2<<endl;
}


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

int main(int argc, char **argv)
{
	ll D, G; cin >> D >> G;
	vector<ll> p(D), c(D); for (ll i = 0; i < D; ++i) cin >> p[i] >> c[i];

	ll res{1ll << 50};
	for (ll bits = 0; bits < (1 << D); ++bits)
	{
		ll num{0}, sum{0};
		for (ll i = 0; i < D; ++i)
		{
			if (bits & (1 << i))
			{
				num += p[i];
				sum += p[i] * 100 * (i + 1);
				sum += c[i];
			}
		}
		
		if (sum < G)
		{
			for (ll i = D-1; i >= 0; --i)
			{
				if (bits & (1 << i)) continue;
				for (ll _ = 0; _ < p[i]; ++_)
				{
					if (sum >= G) goto exit_each_bit;
					sum += 100 * (i+1);
					++num;
				}
			}
		}
	exit_each_bit:
		if (sum >= G) res = min(res, num);
		
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct N {
  int p, l, r;
} Node;

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  c = T[u].l;
  for( i = 0 ; ; i++ ){
    if( c == NIL ) break;
    if(i) printf(", ");
    printf("%d", c);
    c = T[c].r;
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u] = p;
  if( T[u].r != NIL ) rec(T[u].r, p);
  if( T[u].l != NIL ) rec(T[u].l, p+1);
}

int main(){
  int i, j, d, v, c, l, r;

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d", &v, &d);
    for( j = 0 ; j < d ; j++ ){
      scanf("%d", &c);
      if( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    if( T[i].p == NIL ) r = i;
  }

  rec(r, 0);

  for( i = 0 ; i < n ; i++ ) print(i);

  return 0;
}



Measured memory_bytes: 6408
o = input()
e = input()
ans = ""
m = min(len(o),len(e))
for i in range(m):
    ans += o[i]
    ans += e[i]
if len(o) < len(e):
    ans += e[-1]
elif len(e) < len(o):
    ans += o[-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

  if(a > b){
    sum = b;
  }
  else{
    sum = a;
  }

  if(c > d){
    cout << sum + d << endl;
  }
  else{
    cout << sum + c << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 500000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
int p[N],v[N],f[N][2],n,top;
struct node{int l,r,s;node *lc,*rc;}pool[20*N],*rt[N][2];
node *newnode(int l,int r)
{node *x=pool+ ++top;x->l=l;x->r=r;x->s=0;x->lc=x->rc=0;return x;}
node *build(int l,int r,int QAQ)
{	node *x=newnode(l,r); x->s=QAQ;
	if(l==r) return x;
	int mid=(l+r)>>1;
	x->lc=build(l,mid,QAQ); x->rc=build(mid+1,r,QAQ);
	return x;
}
node *ins(node *la,int pos,int y)
{	if(y<=-1e9) return la;
	node *x=newnode(la->l,la->r); x->s=max(la->s,y); x->lc=la->lc; x->rc=la->rc;
	if(x->l==x->r) return x;
	int mid=(x->l+x->r)>>1;
	if(pos<=mid) x->lc=ins(la->lc,pos,y); else x->rc=ins(la->rc,pos,y);
	return x;
}
int query(node *x,int l,int r)
{	if(x->l==l&&x->r==r) return x->s;
	int mid=(x->l+x->r)>>1;
	if(r<=mid) return query(x->lc,l,r);
	else if(l>mid) return query(x->rc,l,r);
	else return max(query(x->lc,l,mid),query(x->rc,mid+1,r));
}
inline int check(int id,int h,int d){return d>=0&&query(rt[id][d&1],h,n)>=d;}
#define gao(a,b,c,d) (check(a+1,b,q-(d))||check(a+1,c,d+q))
int main()
{	int mx=0,q=0,h1=1,h2=1,d=0; cin>>n;
	for(rint i=1;i<=n;i++){scanf("%d",&p[i]);if(p[i]>mx)q++,mx=p[i],v[i]=1;}
	rt[n+1][0]=build(1,n,0); rt[n+1][1]=build(1,n,-2e9);
	for(rint i=n;i>=1;i--)
	{	if(!v[i])
		f[i][0]=query(rt[i+1][1],p[i],n)+1,f[i][1]=query(rt[i+1][0],p[i],n)+1;
		else
		f[i][0]=query(rt[i+1][0],p[i],n)+2,f[i][1]=query(rt[i+1][1],p[i],n)+2;
		rt[i][0]=ins(rt[i+1][0],p[i],f[i][0]); rt[i][1]=ins(rt[i+1][1],p[i],f[i][1]);
	}
	if(!check(1,1,q)) return !printf("-1"); q-=v[1];
	for(rint i=1;i<=n;q-=v[i+1],i++)
	if(gao(i,max(p[i],h1),h2,d+(p[i]>=h1))) printf("0"),d+=(p[i]>=h1),h1=max(p[i],h1);
	else printf("1"),d-=(p[i]>=h2),h2=max(p[i],h2);
	return 0;
}


Measured memory_bytes: 274816
a,b,f;main(e){for(;scanf("%d%d",&a,&b)*a;){if(f)puts("");e=1;for(a=~-a/4*4+4;a<=b;a+=4)if(!(a%4)&&a%25||!(a%400)){printf("%d\n",a);e=0;}if(e)puts("NA");f=1;}}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 612
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef long double f80;
 
// #define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ef emplace_front
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

ll pwr(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

bool dp[46][100005];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int k;
    cin >> k;
    queue<pii> q;
    fr(i, 1, 9) {
        dp[i][i % k] = 1;
        q.push({i, i % k});
    }
    while(!q.empty()) {
        pii u = q.front();
        q.pop();
        for(int j = 0; j <= 9; j++) {
            pii v = {u.fi + j, (u.se * 10 + j) % k};
            if(v.fi <= 45 && !dp[v.fi][v.se]) {
                dp[v.fi][v.se] = 1;
                q.push(v);
            }
        }
    }
    fr(j, 0, 45) {
        if(dp[j][0]) {
            cout << j << endl;
            return 0;
        }
    }
    assert(0);
    return 0;
}

Measured memory_bytes: 19768
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;

int main(){
  int n,m;
  cin>>n;
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    mp[d]++;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    int t;
    cin>>t;
    if(mp[t]==0){
      cout<<"NO"<<endl;
      return(0);
    }
    mp[t]--;
  }
  cout<<"YES"<<endl;
  return(0);
}


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class CountedHashSet
        {
            public class Counter : IComparable<Counter>
            {
                public Counter()
                {
                    count = 1;
                }

                public int count { get; set; }
                public int CompareTo(Counter e)
                {
                    return count.CompareTo(e.count);
                }
            }


            public Dictionary<int, Counter> keySet { get; private set; }

            public CountedHashSet()
            {
                keySet = new Dictionary<int, Counter>();
            }

            public void Add(int key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    c.count++;
                }
                else
                {
                    keySet.Add(key, new Counter());
                }
            }

            public int GetKeyCount(int key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    return c.count;
                }

                return 0;
            }
        }

        public class Counter2 : IComparable<Counter2>
        {
            public Counter2(int key, int count)
            {
                this.key = key;
                this.count = count;
            }
            public int key { get; private set; }
            public int count { get; private set; }
            public int CompareTo(Counter2 e)
            {
                return count.CompareTo(e.count);
            }
        }


        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');

            CountedHashSet hs = new CountedHashSet();
            for (int i = 0; i < N; i++)
            {
                int val = int.Parse(s[i]);
                hs.Add(val);
            }

            List<Counter2> v = new List<Counter2>();
            foreach(KeyValuePair<int, CountedHashSet.Counter> e in hs.keySet)
            {
                Counter2 c2 = new Counter2(e.Key, e.Value.count);
                v.Add(c2);
            }

            v.Sort();

            int ans = 0;
            for (int i = 0; i < v.Count - K; i++)
            {
                ans += v[i].count;
            }

            Console.WriteLine(ans);
        }
    }
}


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

ll getMaxVal(vector<vector<int>> &objects, int index, int weight, vector<vector<ll>> &mem){
    if(index >= objects.size() || weight == 0) return 0;
    if(mem[index][weight] != -1) return mem[index][weight];
    
    ll ans = getMaxVal(objects, index+1, weight, mem);
    if(weight-objects[index][0] >= 0)
        ans = max(ans, objects[index][1] + getMaxVal(objects, index+1, weight-objects[index][0], mem));

    mem[index][weight] = ans;
    return ans;

}
int main(){
    int N, W;
    cin >> N >> W;

    vector<vector<int>> objects(N, vector<int>(2));

    for(int i = 0; i < N; i++){
        cin >> objects[i][0] >> objects[i][1];
    } 

    vector<vector<ll>> mem(N, vector<ll>(W+1, -1));

    cout << getMaxVal(objects, 0, W, mem) << endl;

}

Measured memory_bytes: 82184
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        
        int n=sc.nextInt();
        int k=sc.nextInt();
        
        
            if(n%k==0){
                System.out.println(0);
            }else{
                System.out.println(n-k);
            }
        
    }
}


Measured memory_bytes: 23760
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    sx, sy, tx, ty = list(map(int, input().strip().split()))
    ans = ''
    for i in range(tx-sx):
        ans += 'R'
    for i in range(ty-sy):
        ans += 'U'
    for i in range(tx-sx):
        ans += 'L'
    for i in range(ty-sy):
        ans += 'D'
    ans += 'D'
    for i in range(tx-sx+1):
        ans += 'R'
    for i in range(ty-sy+1):
        ans += 'U'
    ans += 'L'
    ans += 'U'
    for i in range(tx-sx+1):
        ans += 'L'
    for i in range(ty-sy+1):
        ans += 'D'
    ans += 'R'
    print(ans)

if __name__ == '__main__':
    main()


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

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{
    ll x; cin >> x;
    
    ll a_ans, b_ans;
    
    while (true) {
        if (is_prime(x)) {
            break;
        }
        x++;
    }

    cout << x << endl;
    return 0;
}

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

int main()
{
    int x, n;
    vector<int> seq;
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        seq.push_back(tmp);
    }
    auto result = find(seq.begin(), seq.end(), x);
    if (result == seq.end()) {
        cout << x << endl;
        return 0;
    }
    
    for (int i = 0; i < n + 2; i++) {
        auto result1 = find(seq.begin(), seq.end(), x - (i + 1));
        auto result2 = find(seq.begin(), seq.end(), x + (i + 1));
        if (result1 == seq.end()) {
            cout << x - (i + 1) << endl;
            break;
        }
        if (result2 == seq.end()) {
            cout << x + (i + 1) << endl;
            break;
        }
    }
    return 0;
    
}



Measured memory_bytes: 3632
from collections import deque

n,m = (int(x) for x in input().split())

E = [[] for i in range(n+1)]

for i in range(m):
    a,b = (int(x) for x in input().split())
    E[a].append(b)
    E[b].append(a)

#print(E)   

flag = [False]*(n+1)
#vs = [1]
vs = deque([1])

flag[1] = True
res = [0]*(n+1)

while(vs):
    this_v = vs[0]
    for i in E[this_v]:
        if flag[i]:
            continue
        else:
            res[i] = this_v
            flag[i] = True
            vs.append(i)
    vs.popleft()
            
print("Yes")
for i in res[2:]:
    print(i)


Measured memory_bytes: 35912
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        x: f64
    }

    println!("{}", (((8.0 * x+1.0).sqrt()-1.0)/2.0).ceil());
}


Measured memory_bytes: 4352
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


template<typename T>
class UnionFind {
public:
    UnionFind(size_t  size) : data_(size, -1) {}

    bool unite(T x, T y) {
        x = root(x);
        y = root(y);

        if (x != y) {
            if (data_[y] < data_[x]) {
                std::swap(x, y);
            }
            data_[x] += data_[y];
            data_[y] = x;
        }
        return x != y;
    }

    bool isSameGroup(T x, T y) {
        return root(x) == root(y);
    }

    T root(T x) {
        return data_[x] < 0 ? x : data_[x] = root(data_[x]);
    }

    // --
    size_t size(T x) {
        return -data_[root(x)];
    }

private:
    std::vector<T> data_;
};



int main()
{
    int64_t N, M;
    std::cin >> N >> M;


    std::vector<int64_t> P;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        P.push_back(t);
    }

    UnionFind<int64_t> uf(N+1);
    for (decltype(M) i = 0; i < M; ++i) {
        int64_t x, y;
        std::cin >> x >> y;
        uf.unite(x, y);
    }

    size_t count = 0;
    for (int64_t i = 0; i < N; ++i) {
        if (uf.isSameGroup(i+1, P[i])) {
            count++;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

int main()
{
  int N;
  cin >> N;
  
  ld pi = 3.141592653589793;
  cout << fixed << (2*pi*N) << endl;
  return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    ll a,b;
    cin >>a>>b;
    ll ans = 0;

    ans = a - 2*b;
    if (ans<0)ans=0;

    cout << ans;


}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  char C = b.at(0);
  cout << 'A' << C << 'C' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,max1=0,max2=0;
    int a[200000+5],flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    	scanf("%d",&a[i]);
    	if(a[i]>max1)
    	{
    		max2=max1;
    		max1=a[i];
    		flag=0;
		}
		else if(a[i]>max2)
			max2=a[i];
		else if(a[i]==max1)
			flag=1;
	}
	if(flag==1)
		for(i=0;i<n;i++)
			printf("%d\n",max1);
	else
		for(i=0;i<n;i++)
			if(a[i]==max1)
				printf("%d\n",max2);
			else
				printf("%d\n",max1);
	
    return 0;
}


Measured memory_bytes: 2432
import numpy as np

N, M, C = map(int, input().split())
B = np.array([int(i) for i in input().split()])
A = np.array([[int(i) for i in input().split()] for j in range(N)])
res = 0

for row in A:
    if sum(row*B) + C > 0:
        res += 1

print(res)

Measured memory_bytes: 12448
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define N 300009
#define inf 1e18
int mod=1e9+7;
int maxN=1e9;

#define PI 3.141596535

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r;cin>>r;
    cout.precision(10);
    cout<<fixed;
    double ans=2.0*PI*r;
    
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>            //  IT'S NEVER TOO LATE...
    	using namespace std;
        #include<math.h>
    	#define ll long long
    	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
        #define forn(i, n) fore(i, 0, n)
        #define fori(i, l, r) fore(i, l, (r) + 1)
        #define sz(v) int((v).size())
        #define all(v) (v).begin(), (v).end()
        #define pb push_back
        #define mp make_pair
        #define ff first
        #define ss second

        const double PI = atan(1)*4;

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

    	
    	vector<int> ar[1000001];
        vector<pair<int,int>> path;
        int vis[1000001],dis[1000001];

        /*void dfs(int node)
        {
            vis[node]=1;

            for(int child : ar[node])
            {
                if(vis[child]==0)
                {
                    dis[child]=dis[node]+1;
                    dfs(child);
                }
            }
        }*/

    /*    void bfs(int i)
        {
            queue<int> q;
            q.push(i);
            vis[i]=1;
            dis[i]=0;

            while(!q.empty())
            {
                int curr=q.front();
                q.pop();

                for(int child : ar[curr])
                    if(vis[child]==0)
                    {
                        q.push(child);
                        dis[child]=dis[curr]+1;
                        vis[child]=1;
                    }
            }
        }*/

        bool isprime(int n)
        {
            for(int i=2;i*i<=n;i++)
                if(n%i==0)
                    return false;
            return true;
        }

        bool comp(pair<int,int> a, pair<int,int> b)
        {
            return b.ff < a.ff ;
        }

        int modpow(int b,int p,int m)
        {
            if(p==0) return 1%m;
            if(p%2) return (b*modpow(b,p-1,m))%m;
            int u=modpow(b,p/2,m);
            return (u*u)%m;
        }


    	int main()  
    	{

    		#ifndef ONLINE_JUDGE
    		freopen("input.txt","r", stdin);
    		freopen("output.txt", "w", stdout);
    		#endif
    		
    		int t=1;
    		//cin>>t;
    		
    		while(t--)        // string s contains 'H' for head and 'T' for tail.
    		{
                string s,tm;

                cin>>s>>tm;
                int cnt=0;

                forn(i,s.length())
                {
                    if(s[i]!=tm[i])
                        cnt++;
                }

                cout<<cnt;
            }
            return 0;
    	}

        //              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 27336
#include <bits/stdc++.h>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> two;

int main() {
    fast_io();
    int h, a;
    cin >> h >> a;
    cout << int(ceil(double(h) / a));

    return 0;
}


Measured memory_bytes: 256
using System;

namespace A_Coffee
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans = "No";
            string s = Console.ReadLine();
            if (s[2] == s[3] && s[4] == s[5])
            {
                ans = "Yes";
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092