akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, m = map(int, input().split())
# スペース区切りの整数をリスト化する
li = list(map(int, input().split()))
# 得票数の合計の1/4m
s = sum(li)/(4*m)
# 条件に合う商品の数
x = 0
for i in li:
    if i >= s:
        x = x+1
# 出力
if x >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int n;

struct matrix{
	ll mat[51][51] = {};
	
	matrix(const matrix &m) {
	int i,j;
	for(i=0; i<51; i++)
		for(j=0; j<51; j++)
			mat[i][j] = m.mat[i][j];
	}
	
	matrix(){
	};
};


void print(matrix m){
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++)
			cout<<m.mat[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
}

matrix identity()
{
	matrix A;
	for(int i=0; i<n; i++) A.mat[i][i] = 1;
	return A;
}

//gets A B
matrix mul(matrix A, matrix B){
	matrix C;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			for(int k=0; k<n; k++)
				C.mat[i][j] = (C.mat[i][j] + ((A.mat[i][k]*B.mat[k][j])%mod))%mod;
	return C;
}


matrix bin_expo(matrix B, ll e)
{
	matrix out = identity();
	while(e)
	{
		if(e&1) out = mul(out, B);
		B = mul(B, B);
		e>>=1;
	}
	return out;
}

int main()
{
	int i,j,v; ll k, ans = 0;
	matrix inp;
	cin>>n>>k;
	for(i=0; i<n; i++)
		for(j=0; j<n; j++){
			cin>>v;
			inp.mat[i][j] = v;
		}

	matrix raised = bin_expo(inp, k);

	for(i=0; i<n; i++) for(j=0; j<n; j++) ans = (ans + raised.mat[i][j])%mod;
	cout<<ans;
}

Measured memory_bytes: 384
#include <iostream>
 
int main() {
  int N;
  std::cin >> N;
  uint32_t res = 0;
  for(int i = 1; i <= N; ++i) {
	if(i < 10) {++res;}
	else if(i > 99 && i < 1000) {++res;}
	else if(i > 9999 && i < 100000) {++res;}
  }
  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{

  int a;
  cin >> a;
  vector<long> b(a, 0);
  for (int i = 0; i < a; i++)
  {
    cin >> b[i];
  }
  sort(b.begin(), b.end());
  long c = b[0] - b[a - 1];
  if (c < 0)
  {
    c *= -1;
  }
  cout << c;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    int a  , b ;
    char op ;
    cin >> a >> op >> b ;
    if( op == '+' ){
        cout << a + b << endl;
    }else {
        cout << a - b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;


struct edge
{
    int to;
    int cost;
    edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector< vector < edge > > Graph;

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

    int N;
    cin >> N;
    vector<P> cityX, cityY;
    REP(i, N){
        int x, y;
        cin >> x >> y;
        cityX.pb(mp(x, i));
        cityY.pb(mp(y, i));
    }
    sort(All(cityX));
    sort(All(cityY));

    Graph G(N);
    REP(i, N-1) G[cityX[i].second].pb(edge(cityX[i+1].second, cityX[i+1].first - cityX[i].first));
    FOR(i, 1, N) G[cityX[i].second].pb(edge(cityX[i-1].second, cityX[i].first - cityX[i-1].first));

    REP(i, N-1) G[cityY[i].second].pb(edge(cityY[i+1].second, cityY[i+1].first - cityY[i].first));
    FOR(i, 1, N) G[cityY[i].second].pb(edge(cityY[i-1].second, cityY[i].first - cityY[i-1].first));

    vector<int> mincost(N, INF);
    vector<bool> used(N, false);
    priority_queue<P, vector<P>, greater<P>> Q; // cost, number
    int res = 0;

    Q.emplace(0, 0);
    while(!Q.empty()){
        P v = Q.top(); Q.pop();
        if(used[v.second]) continue;
        used[v.second] = true;
        res += v.first;
        for(auto &e : G[v.second]) {
            Q.emplace(e.cost, e.to);
        }
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 21732
import sys
input = sys.stdin.readline
d = []
f = []
time = 0
def search(r):
    global d,f,time,s
    if d[r] == 0:
        time += 1
        d[r] = time
    else:
        return
    for x in s[r]:
        search(x)
    time += 1
    f[r] = time


n = int(input())
s = [[] for i in range(n+1)]
for _ in range(n):
    d = list(map(int,input().split()))
    s[d[0]] = d[2:]

d = [0 for _ in range(n+1)]
f = [0 for _ in range(n+1)]

for i in range(1,n+1):
    if d[i] == 0:
        search(i)

for i in range(1,n+1):
    print (i,d[i],f[i])


Measured memory_bytes: 5668
w = input()
n = int(input())

for _ in range(n):
    ops = input().split()
    a = int(ops[1])
    b = int(ops[2])+1

    if ops[0] == 'print':
        print(w[a:b])

    if ops[0] == 'reverse':
        w = w[:a] + str(w[a:b])[::-1] + w[b:]

    if ops[0] == 'replace':
        p = ops[3]
        w = w[:a] + p + w[b:]



Measured memory_bytes: 5612
#include <stdio.h>

int main()
{
 long x;
scanf("%ld",&x);
long as;
long a=0;
long k=x/11;
long r=x%11;
if(r==0) as=0;
 else if(r<=6)
as=1;
else as=2;
a=2*k+as;
printf("%ld",a);




return 0;}



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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

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

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
    return 0;
}


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

void strchg(char *buf, const char *str1, const char *str2);

int main(void)
{
	char date[10];
	char bf[5], af[5];

	scanf("%s", date);

	sprintf(bf, "2017");
	sprintf(af, "2018");

	strchg(date, "2017", "2018");

	printf("%s\n", date);

}

void strchg(char *buf, const char *str1, const char *str2)
{
	char tmp[1024 + 1];
	char *p;

	while ((p = strstr(buf, str1)) != NULL)
	{
		*p = '\0';
		p += strlen(str1);
		strcpy(tmp, p);
		strcat(buf, str2);
		strcat(buf, tmp);
	}
}


Measured memory_bytes: 128
n, m =map(int,input().split())
s = [list(map(int, input().split())) for _ in range(m)]
#s[i][0]はkです
p = list(map(int, input().split()))
ans = 0
for _ in range(m):
  del s[_][0]

for i in range(2 ** n): #すいっち全探索
  on = [0]*m
  for j in range(n):
    if ((i>>j)&1): #もしj桁めが1なら
      for __ in range(m):
        if (j+1) in s[__]:
          on[__] += 1
  for _ in range(m):
    on[_] %= 2
  if p == on:
    ans += 1
print(ans)


Measured memory_bytes: 3064
N = int(input())
S = input()
S_uniquie = ''.join(set(S))
answer = 0
for left_s in S_uniquie:
    for i in range(N):
        if S[i] == left_s:
            left_pos = i
            break
    for right_s in S_uniquie:
        for i in range(N - 1, -1, -1):
            if S[i] == right_s:
                right_pos = i
                if left_pos + 2 <= right_pos:
                    answer += len(''.join(set(S[left_pos + 1:right_pos])))
                break

print(answer)


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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

int main(){
    int mod=1000000007;
    int n;
    double t=0.0;
    sc1(n);
    vector<int> a(n);
    vector<int> b(n);
    for(auto&e:a) sc1(e);
    for(auto&e:b) sc1(e);
    rep(i,n) t+=abs(a[i]-b[i])*1.0;
    printf("%.15lf\n",t);
    t=0.0;

    rep(i,n) t+=pow((a[i]-b[i]),2)*1.0;
    printf("%.15lf\n",sqrt(t));
    t=0.0;

    rep(i,n) t+=pow(abs(a[i]-b[i]),3)*1.0;
    printf("%.15lf\n",pow(t,1.0/3.0));
    t=0.0;

    rep(i,n) t=max(t,abs(a[i]-b[i])*1.0);
    printf("%.15lf\n",t);
    t=0.0;
    return 0;
}



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

using namespace std;

int cnty[300001];
int cntx[300001];

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

	int h,w,m,y,x;
	set <pair<int,int>> p;
	cin >> h >> w >> m;

	for(int i=0;i<m;i++)
	{
		cin >> y >> x;
		p.insert(make_pair(y,x));
		cnty[y]++;
		cntx[x]++;
	}

	vector <int> sy,sx;
	int Maxy = 0;
	int Maxx = 0;

	for(int i=1;i<=h;i++)
	{
		Maxy = max(Maxy,cnty[i]);
	}
	for(int i=1;i<=w;i++)
	{
		Maxx = max(Maxx,cntx[i]);
	}

	for(int i=1;i<=h;i++)
	{
		if(Maxy==cnty[i])
		{
			sy.push_back(i);
		}
	}
	for(int i=1;i<=w;i++)
	{
		if(Maxx==cntx[i])
		{
			sx.push_back(i);
		}
	}

	int res = 0;

	for(int i=0;i<min(10,(int)(sy.size()));i++)
	{
		int y = sy[i];
		for(auto x : sx)
		{
			int num = cnty[y] + cntx[x];
			if(p.find(make_pair(y,x))!=p.end())
			{
				num -= 1;
			}
			res = max(res,num);
		}
	}

	for(int i=0;i<min(10,(int)(sx.size()));i++)
	{
		int x = sx[i];
		for(auto y : sy)
		{
			int num = cnty[y] + cntx[x];
			if(p.find(make_pair(y,x))!=p.end())
			{
				num -= 1;
			}
			res = max(res,num);
		}
	}	

	cout << res << '\n';

	return 0;
}

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

int N, M, C;
int ans, ans2;
int b[30];
int a;

int main() {
	cin >> N >> M >> C;
	for (int j = 0; j < M; j++) {
		cin >> b[j];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> a;
			ans += a * b[j];
		}
		ans += C;
		if (ans > 0) {
			ans2++;
		}
		ans = 0;
	}

	cout << ans2 << endl;

	return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// UnionFind 解説：https://youtu.be/TdR816rqc3s?t=8424
struct UnionFind {
	vi d;
	UnionFind(int n = 0) : d(n, -1) {}

	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);

		if (x == y) return false;

		if (d[x] > d[x]) swap(d[x], d[x]);
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};

// ──────────────────────────────────────────────────────────────────

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

	vvi a(n, vi(n));
	vvb b(n, vb(n));

	rep(i, n) rep(j, n) cin >> a[i][j];

	rep(k, n) rep(i, n) rep(j, n) {
		if (a[i][j] > a[i][k] + a[k][j]) {
			cout << -1 << endl;
			return 0;
		}

		if (a[i][j] == a[i][k] + a[k][j] && a[i][k] > 0 && a[k][j] > 0)
			b[i][j] = true;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			//cout << i << " " << j << endl;
			if (b[i][j] == false) {
				ans += a[i][j];
			}

		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/algorithm/string/replace.hpp>
using namespace std;

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  ll a;
  string b;
  cin >> a >> b;

  boost::algorithm::replace_all(b, ".", "");

  int c = stoi(b);

  ll ans = ll(a * c)/100;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <cstdio>

unsigned long long sum = 0;
int n;

int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		sum += (i%3==0||i%5==0)? (0) : (i) ;
	}
	printf("%llu", sum);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010,mod=1000000007;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
inline int ksm(int a,int b)
{
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) res=1ll*res*a%mod;
	return res;
}
int fac[maxn],invfac[maxn];
inline int C(int n,int m){return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;}
int ans=0,n,m,a[maxn],b[maxn],out[maxn],e[1<<20],f[1<<20],sumf[1<<20];
int bitcnt[1<<20],fa[maxn],col[1<<20][21],c[maxn],num[1<<20],len[1<<20];
inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
int main()
{
	for(int i=fac[0]=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i%mod;
	invfac[maxn-1]=ksm(fac[maxn-1],mod-2);
	for(int i=maxn-2;i>=0;i--) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	for(int i=1;i<(1<<20);i++) bitcnt[i]=bitcnt[i&(i-1)]+1;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) scanf("%d%d",a+i,b+i),a[i]--,b[i]--;
	for(int i=0;i<m;i++) out[a[i]]|=1<<b[i],out[b[i]]|=1<<a[i];
	for(int i=0;i<(1<<n);i++) for(int j=0;j<n;j++) if((i>>j)&1)
		{e[i]=e[i^(1<<j)]+bitcnt[out[j]&i];break;}
	int all=(1<<(n-1))-1;
	for(int i=0;i<=all;i++)
	{
		for(int j=0;j<n;j++) fa[j]=j;
		for(int j=0;j<n-1;j++) if((i>>j)&1) fa[find(a[j])]=find(b[j]);
		int tot=0;
		for(int j=0;j<n;j++) if(find(j)==j) col[i][j]=++tot,c[tot]=0;
		for(int j=0;j<n;j++) col[i][j]=col[i][find(j)],c[col[i][j]]|=1<<j;
		for(int j=1;j<=tot;j++) num[i]+=e[c[j]]-bitcnt[c[j]]+1;
	}
	f[0]=1;
	for(int i=0;i<=all;i++) for(int j=0;j<n-1;j++) if(!((i>>j)&1))
	{
		int a=num[all^i]-num[all^i^(1<<j)],nxt=i|(1<<j);len[nxt]=len[i]+a+1;
		int getf=1ll*f[i]*fac[len[i]+a]%mod*invfac[len[i]]%mod;
		int getsum=(1ll*getf*(bitcnt[i]+1)%mod+1ll*sumf[i]*fac[len[i]+a+1]%mod*invfac[len[i]+1]%mod)%mod;
		Add(f[nxt],getf);Add(sumf[nxt],getsum);
	}
	printf("%d\n",sumf[all]);
	return 0;
}

Measured memory_bytes: 63244
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
	int n,d,x[11][11],ans=0;
	double cnt=0;
	cin>>n>>d;
	double dist;
	rep(i,1,n+1)rep(j,1,d+1){
		cin>>x[i][j];
	}
	rep(i,1,n)rep(j,i+1,n+1){
		cnt=0;
		rep(k,1,d+1){
			cnt+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
		}
		double tmp=sqrt(cnt);
		if(ceil(tmp)==float(tmp))ans++;
	}
	print(ans);
}

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


int main(){
    ll n; cin >> n;
    ll f;
    for(ll i = 1; i*i <= n; ++i) if(n % i == 0) f = i;
    cout << f+n/f-2 << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

int main(){
    int n,x;
    cin>>n>>x;
    int s[n+1];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    s[n]=INF;
    sort(s,s+n);
    int crt=0;
    ll dp[x+1]={};
    for(int i=0;i<=x;i++){
        while(s[crt]<=i)crt++;
        if(crt==0){
            dp[i]=i;
            continue;
        }
        ll inv=modpow(crt,MOD-2);
        for(int j=0;j<crt;j++){
            dp[i]=(dp[i]+dp[i%s[j]])%MOD;
        }
        dp[i]=(dp[i]*inv)%MOD;
    }
    ll ans=dp[x];
    for(int i=2;i<=n;i++){
        ans=(ans*i)%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
class Flow {
public:
    static constexpr int INF = 1E9;
    int n;
    vector<pair<int, int>> e;
    vector<vector<int>> g;
    vector<int> cur, h;
    bool bfs(int s, int t) {
        h.assign(n, -1);
        queue<int> que;
        h[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int u = que.front();
            que.pop();
            for (int i : g[u]) {
                int v, c;
                tie(v, c) = e[i];
                if (c > 0 && h[v] == -1) {
                    h[v] = h[u] + 1;
                    if (v == t)
                        return true;
                    que.push(v);
                }
            }
        }
        return false;
    }
    int dfs(int u, int t, int f) {
        if (u == t)
            return f;
        int r = f;
        for (int &i = cur[u]; i < g[u].size(); ++i) {
            int j = g[u][i];
            int v, c;
            tie(v, c) = e[j];
            if (c > 0 && h[v] == h[u] + 1) {
                int a = dfs(v, t, min(r, c));
                e[j].second -= a;
                e[j ^ 1].second += a;
                r -= a;
                if (r == 0)
                    return f;
            }
        }
        return f - r;
    }
    Flow(int n) : n(n) {g.resize(n);}
    void addEdge(int u, int v, int c) {
        g[u].push_back(e.size());
        e.emplace_back(v, c);
        g[v].push_back(e.size());
        e.emplace_back(u, 0);
    }
    int maxFlow(int s, int t) {
        int ans = 0;
        while (bfs(s, t)) {
            cur.assign(n, 0);
            ans += dfs(s, t, INF);
        }
        return ans;
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> e(n - 1);
    Flow f(2 * n);
    int s = 0, t = 2 * n - 1;
    for (int i = 0; i < n - 1; ++i) {
        f.addEdge(s, i + 1, 1);
        f.addEdge(i + n, t, 1);
    }
    for (int i = 0; i < n - 1; ++i) {
        int c;
        cin >> c;
        e[i].resize(c);
        for (int &j : e[i]) {
            cin >> j;
            --j;
            if (j != 0)
                f.addEdge(j, i + n, 1);
        }
    }
    if (f.maxFlow(s, t) != n - 1) {
        cout << -1 << "\n";
        return 0;
    }
    vector<int> match(n);
    for (int i = 1; i < n; ++i) {
        for (int j : f.g[i]) {
            int v, c;
            tie(v, c) = f.e[j];
            if (v >= n && c == 0) {
                match[i] = v - n;
                break;
            }
        }
    }
    vector<int> u(n - 1), v(n - 1, -1);
    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        for (int j : e[match[i]])
            if (i != j)
                g[j].push_back(i);
        u[match[i]] = i;
    }
    function<void(int)> dfs = [&](int u) {
        for (int _v : g[u]) {
            if (v[match[_v]] == -1) {
                v[match[_v]] = u;
                dfs(_v);
            }
        }
    };
    dfs(0);
    for (int i = 0; i < n - 1; ++i)
        cout << u[i] + 1 << " " << v[i] + 1 << "\n";
    return 0;
}

Measured memory_bytes: 38504
S = input()
for i in range(100000):
  if S[len(S)-5:]=="dream" or S[len(S)-5:]=="erase":
    S = S[:len(S)-5]
  elif S[len(S)-7:]=="dreamer":
    S = S[:len(S)-7]
  elif S[len(S)-6:]=="eraser":
    S = S[:len(S)-6]
  elif S == "":
    print("YES")
    break
  else:
    print("NO")
    break

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int h, w, i, j;

	while (scanf("%d%d", &h, &w) && h != 0 && w != 0){
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if ((i + j) % 2 == 0){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
print(180*(n-2))





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

using namespace std;
 
 

typedef long long ll;
//c++ templte for help............................................................................................................................................


template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
#define M int(1e9+7)
const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}


 

 
//c++ template for help...........................................................................................................................................

ll solve(){
	ll n,d;
	cin>>n>>d;
	
	vector<pair<ll,ll>> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i].first;
		cin>>vec[i].second;
	}
	
	ll ans=0;
	for(int i=0;i<(ll)vec.size();i++){
		ll a=vec[i].first;
		ll b=vec[i].second;
		if(sqrt(pow(a,2)+pow(b,2))<=(ll)d) ans++;
	}
	
	return ans;
}


int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ofstream myfile;
	//myfile.open ("output.txt");
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	//myfile.close();
	return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int N;
int F[110][20], P[110][20];
vector<string> S;

void shop(string W) {
	if (W.size() == 10) {
		S.push_back(W);
	}
	else {
		for (int i = 0; i <= 1; i++) {
			string tmp = W;
			tmp.push_back(i + '0');
			shop(tmp);
		}
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> F[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 10; j++) {
			cin >> P[i][j];
		}
	}
	string T; shop(T);
	int ans = -mod, m = 0;
	bool open[10] = { false };
	for (int i = 1; i < S.size(); i++) {
		for (int j = 0; j < 10; j++) {
			if (S[i][j] == '0') {
				open[j] = false;
			}
			else {
				open[j] = true;
			}
		}
		m = 0;
		for (int j = 0; j < N; j++) {
			int cnt = 0;
			for (int k = 0; k < 10; k++) {
				if (open[k] && F[j][k] == 1) {
					cnt++;
				}
			}
			m += P[j][cnt];
		}
		ans = max(ans, m);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 5.7 + c[j] * 6;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3680
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()

    l_c = [0] * 2001

    for li in l:
        l_c[li] += 1
    for i in range(2000):
        l_c[i + 1] += l_c[i]

    ans = 0

    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            ans += l_c[l[i] + l[j] - 1] - j - 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 39408
//#include "{algoritm.hpp}"

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll ggcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
 
  /* ユークリッドの互除法 */
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    ll a,b;
    cin>>a>>b;
    auto g=ggcd(a,b);
    int ans=1;
    //cout<<g<<endl;
    for(int i=2;i<=sqrt(g)+1;++i){
        //cout<<i<<endl;
        if(g%i==0){
            ans++;
            //cout<<i<<endl;
            while(g%i==0){
                g/=i;
            }
        }
    }
    if(g>1)ans++;
    cout<<ans<<endl;
}


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

int main(void){
    int n,k;
    cin >> n >> k;
    
    int a[1000] = {},d[k];
    for(int i = 0;i < k;i++){
        cin >> d[i];
        for(int j = 0;j < d[i];j++){
            int b;
            cin >> b;
            a[b]++;
        }
    }
    int sum = 0;
    for(int i = 1;i <= n;i++){
        if(a[i] == 0)sum++;
    }
    cout << sum;
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> num(n);
  for(int i=0;i<m;i++){
    int a, b;
    cin >> a >> b;
    num[a-1]++;
    num[b-1]++;
  }
  for(int i=0;i<num.size();i++){
    cout << num[i] << endl;
  }
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    uint64_t N;

    scanf("%"PRIu64, &N);

    uint64_t limit = (uint64_t)sqrt((double)N);
    uint64_t cnt = 0;

    for (uint64_t val = 1; val <= limit; val++) {
        if (N % val == 0 && val < N / val - 1) {
            cnt += N / val - 1;
        }
    }

    printf("%"PRIu64, cnt);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b){
        b = a^b;
        a = a^b;
        b = a^b;
    }
    if(b>c){
       c = b^c;
       b = b^c;
       c = b^c;        
    }
    if(a>b){
        b = a^b;
        a = a^b;
        b = a^b;
    }
    cout << a << ' ' << b << ' ' << c <<endl;
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    
    vector<int> A(N + 1);
    rep(i, N) cin >> A[i + 1];
    
    int ret = 0;
    for(int i = 1; i <= N; i++){
        if(i < A[i] && A[A[i]] == i) ret++;
    }
    
    output(ret);
    
    
    
    return 0;
}

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

int main()
{
    int m,a,b,c,cc,cs;
    while(~scanf("%d%d",&a,&b))
    {
       c=a+b;
       cc=a*b;
       cs=a-b;
       if(cc>=c&&cc>=cs)
        printf("%d\n",cc);
        else if(c>=cc&&c>=cs)
        printf("%d\n",c);
        else
        printf("%d\n",cs);

    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char C;
  cin >> C;
  C++;
  cout << C << endl;
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define pb push_back
# define mp make_pair
//# define int ll
using namespace std;

int n,m,a[maxn];

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> m;
    for(int i = 1;i <= m;i++)
    {
		int x,y;
		cin >> x >> y;
		a[x]++;
		a[y]++;
    }
    for(int i = 1;i <= n;i++) if(a[i] & 1) rc("NO");
    rc("YES");
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b,k;
  int i;
  scanf("%d %d %d",&a,&b,&k);
  int *sosuu;
  sosuu=malloc(k*sizeof(int));
  
  int max;
  if(a>b)
    max=a;
  else
    max=b;
  int count=0;
  
  for(i=max;i>0;i--){
    if(a%i==0&&b%i==0){
      sosuu[count++]=i;
    }
    if(count==k)
      break;
  }
  printf("%d",sosuu[k-1]);
    	
  return 0;
}

Measured memory_bytes: 128
//Go Home

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    ll a;cin>>a;
    int ans,c=0;
    for(ans=1;c<a;ans++){
        c+=ans;
    }
    cout<<ans-1<<nnn;
    return 0;
}

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

int main(void){
    
    int n;
    cin >> n;
    vector<int> length(n);
    for(int i=0;i<n;i++) cin >> length[i];
    sort(length.begin(),length.end());
    
   //vector<int> length={1,2,3,4};
   //int n=4;

    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            //cout << "a = " << length[i] << ", b = " << length[j] << endl;
            int c = length[i]+length[j];
            auto itr = lower_bound(length.begin(),length.end(),c);
            //cout << "itr: " << itr-length.begin() << endl;
            int dist = itr-(length.begin()+j+1);
            ans += dist;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 1e6+10;  
ll n,k;
ll a[maxn];
ll b[maxn];

int main(){
	cin>>n;
	F(i,1,n) cin>>a[i];
	if(n==2){
		cout<<a[2]<<" "<<a[1]<<endl;
		return 0;
	}
	F(i,2,n){
		b[1] = b[1]^a[i];
	}
	F(i,2,n){
		b[i] = a[i]^a[i-1]^b[i-1]; 
	} 
	F(i,1,n){
		cout<<b[i]<<" ";
	}
}

Measured memory_bytes: 6740
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define MN 200005
using namespace std;
const int mod=1e9+7;
int n,x,y,cc,tt,tot,ttmp[MN],head[MN],sum[MN],inv[MN],c[MN],w[MN],num[MN];
bool vis[MN];
struct edge{int to,next;}g[MN<<4];
void ins(int u,int v){g[++cc].next=head[u];head[u]=cc;g[cc].to=v;}
void insw(int u,int v){ins(u,v);ins(v,u);}
vector<pair<int,int> >now[MN],minx;
void dfs(int u){
	++tt,ttmp[++tot]=c[u],++num[c[u]];vis[u]=1;
	for(int i=head[u];i;i=g[i].next)if(!vis[g[i].to])dfs(g[i].to);
}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	sum[0]=sum[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=n;i++)sum[i]=1ll*sum[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=n;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
	for(int i=1;i<=n;i++)scanf("%d%d",&c[i],&w[i]),now[c[i]].push_back(make_pair(w[i],i));
	for(int i=1;i<=n;i++)if(now[i].size()){
		sort(now[i].begin(),now[i].end());minx.push_back(now[i][0]);
		for(int j=1;j<now[i].size();j++)if(now[i][j].first+now[i][0].first<=x)insw(now[i][j].second,now[i][0].second);
	}sort(minx.begin(),minx.end());
	if(minx.size()){
		int tmp=minx[0].second;
		for(int i=1;i<=n;i++)if(c[i]!=c[tmp]&&w[i]+w[tmp]<=y)insw(tmp,i);
	}
	if(minx.size()>1){
		int tmp=minx[1].second,nowmin=c[minx[0].second];
		for(int i=0;i<now[nowmin].size();i++)if(w[tmp]+now[nowmin][i].first<=y)insw(now[nowmin][i].second,tmp);
	}
	dfs(minx[0].second);long long ans=sum[tt];
	for(int i=1;i<=tot;i++)ans=ans*inv[num[ttmp[i]]]%mod,num[ttmp[i]]=0;printf("%lld\n",ans);
}

Measured memory_bytes: 22388
using System;
using System.Collections.Generic;

class MyClass
{
    static void Main(string[] args)
    {
        string str = "";
        while ((str = Console.ReadLine()) != "0 0")
        {
            int x = int.Parse(str.Split(' ')[0]);
            int y = int.Parse(str.Split(' ')[1]);
            if (x < y)
            {
                Console.WriteLine("{0} {1}", x, y);
            }
            else
            {
                Console.WriteLine("{0} {1}", y, x);
            }
        }
    }
}


Measured memory_bytes: 5776
#include <stdio.h>
 
/*
.0
3124
,5
*/
 
/* {top, front, right} */
int minase_inori[8][3] = {
    {0, 1, 2}, {0, 2, 4}, {0, 4, 3}, {0, 3, 1},
    {5, 1, 3}, {5, 3, 4}, {5, 4, 2}, {5, 2, 1}
};
 
int main(void) {
    int hayami_saori[6];
    int uesaka_sumire;
    int iguti_yuka, tamura_yukari, horie_yui;
    for (iguti_yuka = 0; iguti_yuka < 6; iguti_yuka++) {
        if (scanf("%d", &hayami_saori[iguti_yuka]) != 1) return 1;
    }
    for (iguti_yuka = 0; iguti_yuka < 8; iguti_yuka++) {
        for (tamura_yukari = 0; tamura_yukari < 3; tamura_yukari++) {
            minase_inori[iguti_yuka][tamura_yukari] = hayami_saori[minase_inori[iguti_yuka][tamura_yukari]];
        }
    }
    if (scanf("%d", &uesaka_sumire) != 1) return 1;
    for (iguti_yuka = 0; iguti_yuka < uesaka_sumire; iguti_yuka++) {
        int igarasi_hiromi, murakawa_rie;
        if (scanf("%d%d", &igarasi_hiromi, &murakawa_rie) != 2) return 1;
        for (tamura_yukari = 0; tamura_yukari < 8; tamura_yukari++) {
            for (horie_yui = 0; horie_yui < 3; horie_yui++) {
                if (minase_inori[tamura_yukari][horie_yui] == igarasi_hiromi &&
                minase_inori[tamura_yukari][(horie_yui + 1) % 3] == murakawa_rie) {
                    printf("%d\n", minase_inori[tamura_yukari][(horie_yui + 2) % 3]);
                    tamura_yukari = 334;
                    break;
                }
            }
        }
    }
    return 0;
}


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

const int dx[4] = { 0, 0, -1, 1 };
const int dy[4] = { -1, 1, 0, 0 };
const char mov[] = "UDLR";
const char tank[] = "^v<>";

int h, w, d, x, y;
string map[22], command;

int main()
{
    int t, n;
    cin >> t;
    map[0] = "######################";

    for(int i = 1; ; ++i)
    {
        cin >> h >> w;
        for(int j = 1; j <= h; ++j) {
            cin >> map[j];
            map[j] = "#" + map[j] + "#";
            for(int k = 0; k < 4; ++k)
				if(map[j].find(tank[k]) != string::npos)
					y = j, x = map[j].find(tank[k]), d = k, map[y][x] = '.';
        }
        map[h+1] = map[0];
        cin >> n >> command;

        for(int j = 0; j < n; ++j)
        {
            for(int k = 0; k < 4; ++k)
                if(command[j] == mov[k]) {
                    d = k;
                    if(map[y+dy[d]][x+dx[d]] == '.')
                        x += dx[d], y += dy[d];
                }

            if(command[j] == 'S')
                for(int xx = x, yy = y; map[yy][xx] != '#'; xx += dx[d], yy += dy[d])
                    if(map[yy][xx] == '*') { map[yy][xx] = '.'; break; }
        }

        map[y][x] = tank[d];

        for(int j = 1; j <= h; ++j)
            cout << map[j].substr(1, w) << endl;

        if(i == t) break;
        cout << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  for(int i = 1;i < pow(n,0.5000);i++){
    if((n-i)%i == 0){
        if((n-i)/i > i)ans += (n-i)/i;
    }
  }
  cout << ans << endl;
  cin >> n;
}

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

using namespace std;
int main(){
  long n;
  cin >> n;
  
  map<long,long> mp;
  for(long i=0;i<n;i++){
   long a;
    cin >> a;
    mp[a]++; 
  }
  
  long res=0;
  for(auto p:mp){
   if(p.first<=p.second) res+=p.second-p.first;
   else res+=p.second;
  }
  
  cout << res << endl;
  
}

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

mod=10**9+7

oks = [True]*(n+1)
for i in range(m):
    oks[a[i]] = False

dp=[0]*(n+1)
dp[0]=1
for now in range(0,n):
    for nex in range(now+1,min(n,now+2)+1):
        if oks[nex]:
            dp[nex]+=dp[now]
            dp[nex]%=mod
print(dp[n])

Measured memory_bytes: 51288
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;
    ll res = b;
    if(a <= 12) res /= 2;
    if(a <= 5) res = 0;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
    COUT(IN()==1?"Hello World" : to_string(IN()+IN()));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i,_n) for(ull _i = 0; _i < _n; _i++)
#define rep2(_i,_s,_n) for(ull _i = _s; _i < _n; _i++)
#define elif else if
#define push(_a) push_back(_a)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecUL(_name, _n) vec<ul> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecULL(_name, _n) vec<ull> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";
#define append(_x) push_back(_x)
#define mapLoop(_i, _name) for(auto i = _name.begin(); i != _name.end(); i++)
 

int main(){
   int N,M;
   cin >> N >> M;
   int L=0;
   int R=N+1;
   for(int i=0;i<M;i++){
      int l,r;
      cin >> l >> r;
      L=max(L,l);
      R=min(R,r);
   }
   cout << max((R-L)+1,0)<< endl;
   
   return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

alias Tuple!(int, int) Pair;

void main() {
	int n;
	scanf("%d", &n);
	int[][] graph = new int[][n];
	foreach (i; 0..n-1) {
		int v, w;
		scanf("%d%d", &v, &w);
		v--; w--;
		graph[v] ~= w;
		graph[w] ~= v;
	}
	Pair dfs(int v, int depth, int parent) {
		Pair ret = Pair(depth, v);
		foreach (u; graph[v]) {
			if (u == parent) continue;
			ret = max(ret, dfs(u, depth+1, v));
		}
		return ret;
	}
	int s = dfs(0,0,-1)[1];
	int t = dfs(s,0,-1)[1];

	int[] path;
	int[] used = new int[n];
	bool getpath(int v, int dist, int parent) {
		if (v == dist) {
			path ~= v;
			used[v] = true;
			return true;
		}
		foreach (u; graph[v]) {
			if (u == parent) continue;
			if (getpath(u, dist, v)) {
				path ~= v;
				used[v] = true;
				return true;
			}
		}
		return false;
	}
	getpath(s, t, -1);

	int[] generate() {
		int[] ret;
		foreach (v; path) {
			int cnt = 0;
			foreach (u; graph[v]) {
				if (used[u]) continue;
				cnt++;
			}
			int id = to!int(ret.length)+1;
			foreach (i; 0..cnt) {
				ret ~= id+1+i;
			}
			ret ~= id;
		}
		return ret;
	}
	int[] ans = generate();
	path.reverse();
	int[] ant = generate();
	if (ans.length < n) {
		writeln(-1);
	} else {
		ans = min(ans, ant);
		foreach (i; ans) writeln(i);
	}
}

Measured memory_bytes: 14204