akhauriyash/Code-Regression huggingface dataset:
class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split())
    P = list(map(int, input().split()))
    uf = UF_tree(2*N)
    for i, p in enumerate(P, start=1):
        uf.unite(i, p + N)

    for _ in range(M):
        x, y = map(int, input().split())
        uf.unite(x + N, y + N)

    ans = 0
    for i in range(1, N + 1):
        if uf.isSame(i, i + N):
            ans += 1
    print(ans)


Measured memory_bytes: 14452
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算nCk
ll com(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 二項係数計算nPk
ll per(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n-k] % MOD) % MOD;
}

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/


//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    string s;
    cin>>s;
    string t;
    rep(i,0,s.size()){
        if(s[i]=='0'){
            t+='0';
        }
        else if(s[i]=='1'){
            t+='1';
        }
        else{
            if(t.size()!=0){
                t.erase(t.size()-1,1);
            }
        }
    }
    cout<<t<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
struct edges
{
	int to,next;
}edge[10101];
int first[5050],now;
void adde(int x,int y)
{
	now++;
	edge[now].to=y;
	edge[now].next=first[x];
	first[x]=now;
}
int dp[5050][5050];
int h[5050];
int f[5050],siz[5050];
void work(int p,int fa)
{
	dp[p][1]=1;
	siz[p]=1;
	for(int e=first[p];e;e=edge[e].next)
		if(edge[e].to!=fa) 
		{
			work(edge[e].to,p);
			for(int i=0;i<=siz[p];i++)
			{
				f[i]=dp[p][i];
				dp[p][i]=0;
			}
			for(int i=0;i<=siz[p];i++)
				for(int j=0;j<=siz[edge[e].to];j++)
					dp[p][i+j]=((long long)f[i]*dp[edge[e].to][j]+dp[p][i+j])%mod;
			siz[p]+=siz[edge[e].to];
		}
	for(int i=1;i<=siz[p];i++)
		dp[p][0]=(dp[p][0]+mod-(long long)dp[p][i]*h[i]%mod)%mod;
}
int main()
{
	int n,u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		adde(u,v);
		adde(v,u);
	}
	h[0]=1;
	for(int i=1;i<=n;i++)
		if(i&1)
			h[i]=0;
		else
			h[i]=(long long)h[i-2]*(i-1)%mod;
	memset(dp,0,sizeof(dp));
	work(1,0);
	printf("%d",(mod-dp[1][0]))%mod;
	return 0;
}

Measured memory_bytes: 100480
import sys
from decimal import Decimal

def main():
    n = int(sys.stdin.readline().strip())
    money = Decimal('100000')
    rate = Decimal('1.05')
    
    for _ in range(n):
        money *= rate
        if money % 1000:
            money = money // 1000 * 1000 + 1000

    print(money)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9996
#include <cstdio>
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;

int N,M;
const int MAX_N = 200005;
int a[MAX_N],b[MAX_N];

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+N);

	for(int i=0,j=1;i<N;i=j++){
		while(j<N&&a[i]==a[j])j++;
		b[M++] = j-i;
	}
	unique(a,a+N);

	int ans = 0, t;
	for(int i=M-1;i>=0;i--){
		int j = 1;
		while(j<=a[i])j<<=1;
		int k = lower_bound(a,a+M,j-a[i])-a;
		if(a[k]+a[i]==j){
			if(k<i){
				t = min(b[k],b[i]);
				ans += t;
				b[k] -= t;
			}else{
				ans += b[i]/2;
			}
		}
	}

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

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, k, arr[100000], dp[100000];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    dp[0] = 0, dp[1] = abs(arr[0] - arr[1]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = 2147483647;
        for (int j = 1; j <= min(i, k); j++)
            dp[i] = min(dp[i], dp[i - j] + abs(arr[i - j] - arr[i]));
    }
    cout << dp[n - 1] << '\n';

    return 0;
}


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

int main(void){
  int N; cin >> N;
  for(int i = 0; i < N; i++){
    int ans = 0;
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double dist = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
    if(ra < rb && dist + ra < rb) ans = -2;
    else if(rb < ra && dist + rb < ra) ans = 2;
    else if(dist <= ra + rb) ans = 1;
    else if(dist > ra + rb) ans = 0;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	if (n % 2 != 0) {
		dunk(0);
		return 0;
	}
	n /= 2;

	const int five = 5;
	ll ans = 0;
	ll b = five;

	while (n >= b) {
		ans += n / b;
		b *= five;
	}
	dunk(ans);
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python

ar = []
while True:
  tmp = [int(i) for i in input().split()]
  if tmp == [0,0]:
    break
  else:
    ar.append(tmp)

for i in range(len(ar)):
  for j in range(ar[i][0]):
    for k in range(ar[i][1]):
      if j == 0 or j == ar[i][0] - 1 or k == 0 or k == ar[i][1] - 1:
        print('#' , end='' if k !=ar[i][1]-1 else '\n' if j != ar[i][0]-1 else '\n\n')
      else:
        print('.' , end='' if k !=ar[i][1]-1 else '\n' if j != ar[i][0]-1 else '\n\n')

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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  char prev = '9';
  int count = 0;
  for (int i = 0; i < n; ++i)
  {
    if (s[i] != prev)
    {
      ++count;
      prev = s[i];
    }
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


#define int ll




int n,m;
int p[100001];

signed main(){
    cin>>n;
    rep(i,0,n){
        cin>>p[i];
        p[i]--;
    }
    int cnt=0,i=0;
    for(i=0;i<n;++i){
        if(p[i]==i)cnt++,++i;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main(){
	int x, y;
	char a[110], b[110], c[110];
	scanf("%s %s %s", a, b, c);
	
	x = strlen(a); 
	y = strlen(b);

	if((a[x-1]==b[0])&&(b[y-1]==c[0])){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	
	return 0;
}
	
	
	


Measured memory_bytes: 128
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 101, V = 1e5 + 1;

int n, w;
int vi[N], wi[N];
long long dp[V];

int main()
{
  cin >> n >> w;
  for(int i = 0 ; i < n ; i++)
    cin >> wi[i] >> vi[i];
  for(int i = 1 ; i < V ; i++)
    dp[i] = 1e18;
  for(int i = 1 ; i <= n ; i++) {
    for(int j = V - 1; j >= 0 ; j--) {
      if(j - vi[i - 1] >= 0)
        dp[j] = min(dp[j], dp[j - vi[i - 1]] + wi[i - 1]);
    }
  }
  for(int i = V - 1; i >= 0 ; i--) {
    if(dp[i] <= w) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define fo(i,a,b) for(i=a; i<b; ++i)
#define foe(i,a,b) for(i=a; i<=b; ++i)
#define rep(i,n) for(i=1;i<=n;i++)
#define all(a) a.begin(), a.end()
#define pb push_back
#define ins insert
#define mk make_pair
#define f first
#define s second
#define mod 1000000007
#define vi vector<int>
#define vll	vector<ll>
#define vvi	vector<vi>
#define pii	pair<int,int> //typedef pair<int,int> pii;
#define pll	pair<ll , ll>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
//mp.reserve(4096);
//mp.max_load_factor(0.25);

int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	int m=s.size();
	int n=t.size();
	int dp[m+1][n+1],i,j;
	list<int>mylist;
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(i==0||j==0)
			dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			dp[i][j]=dp[i-1][j-1]+1;
			else if(s[i-1]!=t[j-1])
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	i=m;
	j=n;
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			mylist.push_front(s[i-1]);
			i--;
			j--;
		}
		else 
		{
			if(dp[i-1][j]>dp[i][j-1])
			i--;
			else
		    j--;
		}
	}
	for(char x:mylist)
	{
	   cout<<x;	
    }
	cout<<endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
ll cnt1[11][11], cnt2[11][11];

int get(int x) {
    while (x >= 10) {
        x /= 10;
    }
    return x;
}

void print() {
    for (int i = 1; i < 10; i++) {
        cout << i << ": ";
        for (int j = 1; j < 10; j++) {
            cout << cnt1[i][j] << "  ";
        }
        cout << "\n";
    }
}

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

    cin >> n;
    ll ans = 0LL;
    for (int i = 1; i <= n; i++) {
        int lastDig = i%10;
        int firstDig = get(i);
        ans += cnt1[lastDig][firstDig];
        ans += cnt2[firstDig][lastDig];
        if (lastDig != 0 && firstDig != 0) {
            cnt1[firstDig][lastDig]++;
            cnt2[lastDig][firstDig]++;
        }

        //print();


        if (lastDig == firstDig) ans++;
    }

    cout << ans;








    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF 1e8
using namespace std;
bool is_digit(char x){
    for(int i=48; i<=57; i++){
        if(x == i) return true;
    }
    return false;
}
int main(){
    int n;
    cin >> n;
    rep(k,n){
        string s,t;
        cin >> s >> t;
        for(int i=s.size()-1; i>=0; i--){
            //cout << t << endl;
            if(s[i] == 'J') rotate(t.rbegin(),t.rbegin()+1,t.rend());
            
            if(s[i] == 'C') rotate(t.begin(),t.begin()+1,t.end());
            if(s[i] == 'E') {
                rep(j,t.size()/2){
                    swap(t[j],t[t.size()-t.size()/2+j]);
                }
            }
            if(s[i] == 'A') reverse(t.begin(),t.end());
            if(s[i] == 'P') {
                rep(j,t.size()){
                    if(is_digit(t[j])) {
                        if(t[j] == 48) t[j] = 57;
                        else t[j]--;
                    }
                }
            }
            if(s[i] == 'M') {
                rep(j,t.size()){
                    if(is_digit(t[j])) {
                        if(t[j] == 57) t[j] = 48;
                        else t[j]++;
                    }
                }
            }
        }
        cout << t << endl;
    }
    return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
cin>>n;
long long int a[n];
long long int coun[n+1];
  for(long long int i=1;i<=n;i++)
    coun[i]=0;
   long long  int cou=0;
   for(long long int i=0;i<n;i++)
    {cin>>a[i];coun[a[i]]++;
    }
for(long long int i=1;i<=n;i++)
 {
     cou+=(coun[i])*(coun[i]-1)/2;

 }
 for(long long int i=0;i<n;i++)
 {
     if(coun[a[i]]<=1)
     {
         cout<<cou<<endl;

     }
     else
        cout<<cou+1-coun[a[i]]<<endl;

 }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

int n, q;
vector<int> v[1000010];
int a[1000010];

int dfs(int x, int p)
{
    a[x] += a[p];
    arep(i, v[x]) if (i != p) dfs(i, x);
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    cin >> n >> q;

    rep(i, 1, n)
    {
        int a, b;
        cin >> a >> b;
        eb(v[a], b);
        eb(v[b], a);
    }

    rep(i, 0, q)
    {
        int x, y;
        cin >> x >> y;
        a[x] += y;
    }

    dfs(1, 0);

    rep(i, 1, n + 1)
    {
        cout << a[i] << ' ';
    }
    cout << '\n';
    return 0;
}

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

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
    return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

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

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

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def num_roots(self):
    return len([i for i, x in enumerate(self.parents) if x < 0])

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
  a,b,c = map(int, input().split())
  uf.union(a-1,b-1)

print(uf.num_roots())

Measured memory_bytes: 81704
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s = Integer.parseInt(scanner.nextLine());

        Set<Integer> seen = new HashSet<>();
        int a = 0;
        for (int i = 1; i <= 1000000; i++) {
            if (i == 1) {
                a = s;
            } else {
                if (a % 2 == 0) {
                    a = a / 2;
                } else {
                    a = 3 * a + 1;
                }
            }
            if (seen.contains(a)) {
                System.out.println(i);
                return;
            } else {
                seen.add(a);
            }
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
 
typedef long long ll;
using namespace std;
constexpr ll MOD = 1e9 + 7;
 
int main() {
    int n;
    cin >> n;
    vector<ll> dp(1 << n);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        vector<ll> after(1 << n);
        for (int j = 0; j < n; j++) {
            int a;
            cin >> a;
            if (a == 1) {
                for (int bit = 0; bit < 1 << n; bit++) {
                    if (bit & (1 << j))continue;
                    after[bit | (1 << j)] += dp[bit], after[bit | (1 << j)] %= MOD;
                }
            }
        }
        swap(dp, after);
    }
 
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 33024
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

N,M = map(int, raw_input().split())

ans = 1
x = 1
a = []

while x * x <=M:
 if M%x==0:
  a.append(x)
  a.append(M/x)
  #print x, M/x
 x+=1
 

#print x, a
for i in a:
 if M/i >= N:
  ans = max(ans,i)
print ans


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 100000
#define psz 20
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdin);
//ios_base::sync_with_stdio(false);
 //cin.tie(NULL);
int main(){

    ll a,b,c,d;

    cin>>a>>b>>c>>d;

    ll lcm = c*d/__gcd(c,d);

    ll st1 = (a/c)*c;
    if(st1 < a) st1+=c;
    ll e1 = (b/c)*c;

    ll tot1 = e1-st1;
    ll s1 = tot1/c;

    ll st2 = (a/d)*d;
    if(st2 < a) st2+=d;
    ll e2 = (b/d)*d;

    ll tot2 = e2-st2;
   // cout<<"E  "<<e2<<"  "<<st2<<"  "<<e2-st2+1<<endl;

    ll s2 = tot2/d;

    //cout<<"S12  "<<s1<<"  "<<s2<<"   LCM   "<<lcm<<endl;

    ll st3 = (a/lcm)*lcm;

    if(st3 < a) st3 += lcm;
    ll e3 = (b/lcm)*lcm;

    ll tot3 = e3-st3;

    ll s3 = tot3/lcm;

   // cout<<s3<<endl;
    s1++, s2++, s3++;

    ll tt = s1+s2-s3;

   //  cout<<"S12  "<<s1<<"  "<<s2<<"   LCM   "<<s3<<endl;
    //cout<<"N  "<<tt<<endl;

    cout<<((b-a)+1)-tt<<endl;



    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

//行列の積。計算量は正方行列でO(n^3)
//modを使うときはコメントアウト側を使う
vector< vector<ll> > matrixproduct(vector< vector<ll> > &matA, vector< vector<ll> > &matB) {
    assert(matA[0].size() == matB.size());
    ll a = matA.size(), b = matB[0].size(), c = matA[0].size();
    vector< vector<ll> > ansmat(a, vector<ll>(b, 0));
    for (ll i = 0; i < a; i++) {
        for (ll j = 0; j < b; j++) {
            for (ll k = 0; k < c; k++) {
                // ansmat[i][j] += matA[i][k] * matB[k][j];
                ansmat[i][j] += (matA[i][k] * matB[k][j]) % mod;
                ansmat[i][j] %= mod;
            }
        }
    }
    return ansmat;
}

//正方行列の累乗。計算量はO(n^3log(pow))
//matrixproductが必要
vector< vector<ll> > matrixpow(vector< vector<ll> > mat, ll pow) {
    ll matrixsize = mat.size();
    vector< vector<ll> > ansmat(matrixsize, vector<ll>(matrixsize, 0));
    for (ll i = 0; i < matrixsize; i++) {
        ansmat[i][i] = 1;
    }
    while (pow > 0) {
        if (pow % 2 == 1) {
            ansmat = matrixproduct(ansmat, mat);
        }
        pow >>= 1;
        mat = matrixproduct(mat, mat);
    }
    return ansmat;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector< vector<ll> > a(N, vector<ll>(N));
    REP(i, 0, N) {
        REP(j, 0, N) {
            cin >> a[j][i];
        }
    }
    vector< vector<ll> > po = matrixpow(a, K);
    ll ans = 0;
    REP(i, 0, N) {
        REP(j, 0, N) {
            ans = (ans + po[i][j]) % mod;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int minn = INT_MAX, maxn = INT_MIN, midn;
	if (a > maxn) maxn = a;
	if (a < minn) minn = a;
	if (b > maxn) maxn = b;
	if (b < minn) minn = b;
	if (c > maxn) maxn = c;
	if (c < minn) minn = c;
	midn = a + b + c - maxn - minn;
	cout << maxn * 10 + midn + minn << endl;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
c = list()
for b in range(a):
  z, zz = input().split()
  c.append([z,int(zz)]) 

l = list()
tmp = sorted(c, key=lambda x:x[1], reverse=True)
x = sorted(tmp, key=lambda x:x[0])
for a in x:
  for y in c:
    if (a == y):
      l.append(c.index(a)+1)
[print(i) for i in l]

Measured memory_bytes: 3064
MAX = 100000

def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s = s + T[i]
            i = i + 1
            if i == n:
                return n
    return i

def solve():
    left = 0
    right = MAX * 10000
    while (right - left > 1):
        mid = (left + right) / 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

n, k = map(int, raw_input().split())
T = []

for i in range(n):
    T.append(input())

ans = solve()

print ans

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


long long gcd(long long a, long long b){
    while (a != 0 && b != 0){
        if (a >= b) a %= b;
        else b %= a;
    }
    return a + b;
}

signed main(){
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    ll ans = 1;
    for(ll i = 2, G = g; i * i <= G; i++){
        if(g % i == 0){
            ans++;
            while(g % i == 0) g /= i;
        }
    }
    if(g > 1) ans++;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
	int n;
	cin>>n;
	ll l=1,r=1;
	rep(i,n){
		ll a,b;
		cin>>a>>b;

		ll c = max( (l-1)/a+1 , (r-1)/b+1 );

		l=a*c, r=b*c;
	}
	cout<<l+r<<endl;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  long x = cin.next!long;
  if (x < 500) {
    writeln(x / 5 * 5);
  } else {
    writeln(x / 500 * 1000 + x % 500 / 5 * 5);
  }
}


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

// https://qiita.com/nomikura/items/4167cb3a7a889988e3b3

ll N;
ll a[20][20];
ll dp[1<<16];
ll use[1<<16];

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> a[i][j];
		}
	}

	for(int g=0;g<(1<<N);g++){
		ll sc = 0;
		for(int i=0;i<N;i++){
			for(int j=i;j<N;j++){
				if( g&(1<<i) and g&(1<<j)){
					sc += a[i][j];
				}
			}
		}
		use[g] = sc;
	}

	for(int used=0;used<(1<<N);used++){
		int unused = used ^ ((1<<N)-1);
		for(int g = unused; g > 0; g = (g-1)&unused){
			if(!(g>used))continue;
			dp[g|used] = max(dp[g|used],dp[used]+use[g]);  
		}
	}

	cout << dp[(1<<N)-1] << endl; 

}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        for (int j = 0; j < n; j++) {
            String[] input = br.readLine().split(" ");

            double p1x = Double.parseDouble(input[2]) - Double.parseDouble(input[0]);
            double p1y = Double.parseDouble(input[3]) - Double.parseDouble(input[1]);

            double p2x = Double.parseDouble(input[6]) - Double.parseDouble(input[4]);
            double p2y = Double.parseDouble(input[7]) - Double.parseDouble(input[5]);

            // 外積が1.0^-10(各値はそれぞれ小数点第5位まで、その積の誤差は小数点第10位まで考慮すればOK?)より小さい <=> 平行
            if (Math.abs(p1x * p2y - p1y * p2x) < 1.0e-10) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


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

// Contest: AtCoder Beginner Contest 143 (https://atcoder.jp/contests/abc143)
// Problem: C: Slimes (https://atcoder.jp/contests/abc143/tasks/abc143_c)

using namespace std;

using ll = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

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

    int n; cin >> n;
    for (int i = 1; i <= 9; ++i) {
        if (n % i == 0 && n / i <= 9) {
            cout << "Yes\n";
            return 0;
        }
    }

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


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MultiWayIf #-}

import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace (traceShow)
import qualified Data.ByteString.Char8 as B
readi b | Just (n, _) <- B.readInt b = n

f :: Int -> Int
f n = n * (n + 1) `div` 2

main :: IO ()
main = do
    n <- readLn :: IO Int
    let a = head $ dropWhile ((< n) . f) [1 .. n]
    let d = f a - n
    forM_ [1 .. a] $ \i -> do
        when (i /= d) $ do
            print i

Measured memory_bytes: 1020
# include <bits/stdc++.h>
# define IL inline
# define RG register
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const int _(1e5 + 10);

IL ll Read(){
	RG char c = getchar(); RG ll x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * z;
}

int n, X, Y, T;

int main(RG int argc, RG char* argv[]){
	n = Read();
	for(RG int i = 1, t, x, y; i <= n; ++i){
		t = Read(); x = Read(); y = Read(); RG int len = abs(X - x) + abs(Y - y) + T;
		if(len > t || ((abs(X - x) + abs(Y - y) + T - t) & 1)){  puts("No"); return 0;  }
		T = t; X = x; Y = y;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())

int iter[100005][2];

int main(){
     int n;
     int k;
     cin>>n>>k;
     std::vector<int> arr(n);
     fo(i,n) cin>>arr[i];
     fo(j,100005){
          fo(i,2){
               iter[i][j]=0;
          }
     }
     iter[0][0]=0;
     iter[0][1]=0;
     FOR(i,1,k){
          FOR(j,0,1){
                    int rival=j^1;
                    iter[i][j]=0;
                    
                    //cout<<"  "<<i<<" "<<j<<endl;
                    FOR(in,0,n-1){
                         if(arr[in]>i) break;
                         if(iter[i-arr[in]][rival]==0){iter[i][j]=1; break;}
                         

                    }
               
          }
     }

     //FOR(i,0,k) cout<<iter[k][0]<<" ";

     cout<<endl;

     if(iter[k][0]==1) cout<<"First"<<endl;
     else cout<<"Second"<<endl;




}

Measured memory_bytes: 1024
import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Data.Sequence         ((<|), (><), (|>))
import qualified Data.Sequence         as S

import           Data.Foldable         (toList)
import           Data.List             (foldl')

readi :: B.ByteString -> Int
readi bs | Just (n, _) <- B.readInt bs = n

splitElem :: Int -> S.Seq Int -> [S.Seq Int]
splitElem n s
    | Nothing <- midx = [s]
    | Just i <- midx =
        let (l, r) = S.splitAt i s
            (m S.:< r') = S.viewl r
         in [l, r', S.singleton m]
  where
    midx = S.elemIndexL n s

main :: IO ()
main = do
    n <- readLn :: IO Int
    ps <- fmap readi . B.words <$> B.getLine
    is <- S.fromList . fmap readi . B.words <$> B.getLine

    let as = foldl' (\acc p -> concatMap (splitElem p) acc) [is] ps
    let as' = foldr (><) S.empty as
    putStrLn . unwords . fmap show $ toList as'



Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1e9
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,m;
vector<int>G[100010];
int id[100010],ll[100010],rr[100010];
bool ok=1;
void dfs(int x,int p=-1){
	ll[x]=-INF-1;
	rr[x]=INF+1;
	if(id[x]!=-1)ll[x]=rr[x]=id[x];
	for(auto to:G[x]){
		if(to==p)continue;
		dfs(to,x);
		if(ll[to]<-INF/2)continue;
		if(ll[x]<-INF/2){
			ll[x]=ll[to]-1;
			rr[x]=rr[to]+1;
		}else{
			if(abs(ll[x])%2==abs(ll[to])%2){
				ok=0;
				return;
			}
			ll[x]=max(ll[x],ll[to]-1);
			rr[x]=min(rr[x],rr[to]+1);
		}
	}
	if(ll[x]>rr[x])ok=0;
}
void make(int x,int p=-1){
	if(x==1&&id[x]==-1)id[x]=ll[x];
	for(auto to:G[x]){
		if(to==p)continue;
		if(id[to]==-1){
			if(ll[to]<=id[x]-1&&id[x]-1<=rr[to])id[to]=id[x]-1;
			else id[to]=id[x]+1;
		}
		make(to,x);
	}
}
int main(){
	memset(id,-1,sizeof(id));
	cin>>n;
	for(int i=1,x,y;i<n;i++){
		cin>>x>>y;
		G[x].pb(y);
		G[y].pb(x);
	}
	cin>>m;
	for(int i=1,x,y;i<=m;i++){
		cin>>x>>y;
		id[x]=y;
	}
	dfs(1);
	if(ok){
		make(1);
		puts("Yes");
		for(int i=1;i<=n;i++)cout<<id[i]<<endl;
		// for(int i=1;i<=n;i++)cout<<ll[i]<<' '<<rr[i]<<endl;
	}else puts("No");
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x) 
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define fo(i, a, b) for (int i = a; i <= b; ++i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin >> n >> k;
    int h[n]; rep(i, n) cin >> h[i];

    int dp[n]; dp[n-1] = 0;
    for (int i = n-2; i >= 0; --i) {
        dp[i] = dp[i+1] + abs(h[i+1]-h[i]);
        for (int j = 1; j <= k && i+j < n; ++j) {
            dp[i] = min(dp[i], dp[i+j] + abs(h[i+j]-h[i]));
        }
    }
    cout << dp[0] << '\n';
}



Measured memory_bytes: 1024
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, D;
  vector<ll> X(N), Y(N);
  
  REP(i,N) {
    cin >> X[i] >> Y[i];
  }
  D *= D;
  
  ll r = 0;
  REP(i,N) {
    ll dis = X[i]*X[i]+Y[i]*Y[i];
    if (dis<=D)
      r++;
  }


  return r;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

int main() {
    ll x;
    cin >> x;
    ll now = 100;
    ll i = 0;
    while(now < x){
        now += now/100;
        ++i;
    }
    cout << i << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int x = 0;
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'I') {
            ++x;
        } else if (s[i] == 'D') {
            --x;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

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

int lcm(int a, int b) {
    int g = gcd(a, b);
    return a / g * b;
}

signed main() {
    int n;
    cin >> n;
    int t[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m; cin >> n>>m;
    vector<int> home[n+1];
    int cnt[n+1];
    rep(i,0,n+1) cnt[i] = 1;
    vector<pair<int,int>> ans;
    std::ostringstream ss1,ss2;
    rep(i,0,m){
        int ken,si;
        cin >> ken >> si;
        ans.push_back(make_pair(ken,si));
        home[ken].push_back(si);
    }
    rep(i,1,n+1) sort(all(home[i]));
    rep(i,0,m){
        int tmp = ans[i].first;
        cout << setw(6) << setfill('0') << ans[i].first;
        cout << setw(6) << setfill('0') << upper_bound(all(home[tmp]),ans[i].second)-home[tmp].begin()<<endl;
    }
}


Measured memory_bytes: 8180
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0ll, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , t ;
    cin >> n  >> t;
    vl v;
    forn(i , 1 , n ) {
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    ll minn = v[0];
    ll maxx = 0 ;
    forn(i , 1 , n - 1 ) {
       ll curr = v[i] ;
       if(curr < minn) minn = curr ;
       else if(curr == minn ) throw;
       else {
        if(curr > minn){
            ll pro = curr - minn;
            ll sells = t  / 2 ;
            pro = pro * sells;
            maxx = max(maxx , pro) ;
        }
       }
    }
    ll cnt = 0 ;
    minn = v[0] ;
    forn(i , 1 , n - 1 ) {
       ll curr = v[i] ;
       if(curr < minn) minn = curr;
       else {
        if(curr > minn){
            ll pro = curr - minn ;
            ll sells = t / 2 ;
            pro = pro * sells ;
            if(pro == maxx) ++cnt ;
        }
       }
    }
    cout << cnt << el ;
}































Measured memory_bytes: 1400
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(bf.readLine()),
            count = 0;
        String[] S = bf.readLine().split("");
        for(int i = 0; i < N; i++){
            if(S[i].equals(".")){
                count++;
            }
        }
        int min = count;
        for(int i = 0; i < N && 0 < min; i++){
            if(S[i].equals("#")){
                count++;
            } else{
                count--;
                if(count < min){
                    min = count;
                }
            }            
        }           
        System.out.println(min);
    }
}

Measured memory_bytes: 40044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n;
    cin>>n;
    ll K=1;
    bool exist=false;
    for(K=1;K<=n;K++){
        if(K*(K+1)/2==n){
            exist=true;
            break;
        }
    }

    if(!exist) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        cout<<K+1<<endl;
        vector<vector<ll>> res(K+1,vector<ll>());
        ll sum=1;
        for(int k=K;k>=1;k--){
            rep(i,k){
                res[K-k].push_back(sum+i);
                res[K-k+i+1].push_back(sum+i);
            }
            sum+=k;
        }

        rep(i,K+1){
            cout<<res[i].size();
            rep(j,res[i].size()) cout<<" "<<res[i][j];
            cout<<endl;
        }
    }
}


Measured memory_bytes: 5036
n = int(input())
n_lst = list(map(int,input().split()))
ans = 0

is_odd = 0
while not is_odd:
    for num in n_lst:
        is_odd += num%2
    if not is_odd:
        for i in range(len(n_lst)):
            n_lst[i] //= 2
        is_odd = 0
        ans += 1
print(ans)


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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,p,cnt,root[N],sz[N];

char s[N];

bool ok[N];

set<int> nxt[26];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int ans=1e9;
	for(int i=0;i+k<=n;i++)
		ans=min(ans,a[i+k-1]-a[i]);
	printf("%d\n",ans);
}



Measured memory_bytes: 2304
n=int(input())
points=[[i]+list(map(int,input().split())) for i in range(n)]
 
edges=[]
points.sort(key=lambda x: x[1])
for i in range(n-1):
    n1,x1,y1=points[i]
    n2,x2,y2=points[i+1]
    edges.append([n1,n2,x2-x1])
points.sort(key=lambda y: y[2])
for i in range(n-1):
    n1,x1,y1=points[i]
    n2,x2,y2=points[i+1]
    edges.append([n1,n2,y2-y1])

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n+1)]
        self.rank=[0]*(n+1)

    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1
    def same_check(self,x,y):
        return self.find(x)==self.find(y)

uf=UnionFind(n)
edges.sort(key=lambda c: c[2], reverse=True)
ans=0
i=0


while i!=n-1:
    x,y,cost=edges.pop()
    if not uf.same_check(x,y):
        ans+=cost
        uf.union(x,y)
        i+=1
print(ans)

Measured memory_bytes: 58524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  ll A,B,C; cin>>A>>B>>C;
  ll D=C-A-B;
  if(D>0&&4*A*B<D*D) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256