akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	vector<ll> s(n + 1);
	s[0] = 0;
	REP(i, n) {
		s[i + 1] = s[i] + a[i];
	}
	int m = -1;
	REP(i, n) {
		if (s[i] * 3 < s[i + 1]) {
			chmax(m, i);
		}
	}
	put(n - m);
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  cin>>n;
  vector<ll>v;
  vector<ll>vv;
  if((n&1)==1){
    for(ll i=1;i<n;i++){
      v.push_back(i);
      vv.push_back(n);
    }
    n--;
  }
  for(ll i=1;i<n;i++){
    for(ll j=i+1;j<=n;j++){
      if(j!=(n-i+1)){
        v.push_back(i);
        vv.push_back(j);
      }
    }
  }
  cout<<v.size()<<endl;
  for(ll i=0;i<(ll)v.size();i++){
    cout<<v[i]<<" "<<vv[i]<<endl;
  }
}


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

const int MAXN = 2e5+5;
const int MOD = 1e9+7;
int dp[MAXN],ix[26+3][MAXN],nx[26+3];
int main()
{
   
  string str;
  cin>>str;
  int n = str.size();
  for (int i = 0; i < 26; ++i)
  {
    nx[i] = n;
  }
  for (int i = n-1; i >=0; i--)
  {
    nx[str[i]-'a'] = i;
    for (int j = 0; j < 26; ++j)
    {
      ix[j][i] = nx[j];
    }
    dp[i] = MOD;
  }


  dp[n] = 1;
  for (int i = n-1; i > -1; --i)
    for (int j = 0; j < 26; ++j)
      dp[i] = min(dp[i],dp[ix[j][i]+1]+1);

  for (int i = 0; dp[0]; --dp[0])
  {
    for (int j = 0; j < 26; ++j)
    {
      if(dp[i]==dp[ix[j][i]+1]+1)
      {
        printf("%c",j+'a');
        i = ix[j][i]+1;
        break;
      }
    }
  }

  cout<<endl;

  return 0; 
}


Measured memory_bytes: 21764
#include <stdio.h>
int main(void) {
  int n,i,max=0,x=0;
  char s[111];
  scanf("%d%s",&n,s);
  for(i=0;i<n;i++) {
    if(s[i]=='I') x++;
    if(s[i]=='D') x--;
    if(x>max) max=x;
  }
  printf("%d",max);
}

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

vector<int>pes,color,ces,sz;
vector<ll>points;

void dfs(int u, int z){
	color[u]=z;
	points[color[u]]+=ces[u];
	sz[color[u]]++;

	int v = pes[u];
	if(color[v]==-1)dfs(v,z);
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;ll k;
	cin>>n>>k;
	pes=ces=sz=vector<int>(n+1);
	color.resize(n+1,-1);
	points.resize(n+1);

	
	for(int i=1;i<=n;i++){
		cin>>pes[i];
	}
	for(int i=1;i<=n;i++){
		cin>>ces[i];
	}
	int z = 0;
	for(int i=1;i<=n;i++){
		if(color[i]==-1){
			dfs(i,++z);
		}
	}
	ll ans=-5e18;
	for(int i =1;i<=n;i++){
		ll cnt=k/sz[color[i]];
		int len=k%sz[color[i]];
		ll tmp=0;
		ll foo1=-5e18,foo2=-5e18,foo3=-5e18;
		
		for(int u=pes[i],qtd=0;u!=i;u=pes[u],qtd++){
			tmp+=ces[u];
			foo1=max(tmp,foo1);
			if(qtd<len)foo2=max(tmp,foo2);
			if(qtd<k)foo3=max(tmp,foo3);
		}
		tmp+=ces[i];
		foo1=max(tmp,foo1);
		ans=max(foo3,ans);
		tmp=foo2+cnt*points[color[i]];
		if(cnt>0)tmp=max(tmp,foo1+(cnt-1)*points[color[i]]);
		ans=max(ans,tmp);
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
int main()
{
	std::string s;

	std::cin >> s;

	std::string YesNo = "Yes";
	int count;
	int count2 = 0;
	for(int i=0; i<3; i++){
		count = 0;
		for (int j = i+1; j < 4; j++) {
			if (s[i] == s[j])
				count++;
			if (count > 1)
				YesNo = "No";
		}
		if (count == 1)
			count2++;
	}

	if (count2 != 2)
		YesNo = "No";

	std::cout << YesNo << std::endl;
		
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int M = S.size();
  
  for(int i=0;i<M;i++){
    int x = S[i]-'A';
    x += N;
    if(x>=26) x -= 26;
    char c = x+'A';
    cout << c;
  }
  
  cout << endl;
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int cnt = 0;
  rep(i, a+1) rep(j, b+1) rep(k, c+1) {
    if(i*500+j*100+k*50 == x) ++cnt;
  }
  cout << cnt << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B;
	cin >> A >> B;
	cout << max({A + B, A - B, A * B});
	return 0;
}


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

int isprime(int n);

int main(void){
  int i,n,sum=0;
  int num;
  
  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&num);
     sum += isprime(num);
  }
  
  printf("%d\n",sum);
  
  
  return 0;
}

int isprime(int n){
  int i;
 
  if(n == 2) return 1;
  else if (n % 2 == 0) return 0;
  
  
  for(i = 3 ; i <= sqrt(n) ; i+=2){
    if(n % i == 0){
      return 0;
    }
  }
  return 1;
  
}

  



Measured memory_bytes: 2060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            CR.GetTexts();
            var inputs = CR.GetIntegers().ToList();
            var distinct = inputs.Distinct().ToList();
            return inputs.Count() == distinct.Count() ? "YES" : "NO";
        }
    }
}


Measured memory_bytes: 37072
#include <stdio.h>

int main()
{
  int n, a, b;
  int i, j, high, mid, x, y, z;
  int m;
  int max = -1;
  int low = 1;
  int h[100001] = {};
  scanf("%d %d %d", &n, &a, &b);

  for(i=0; i<n; i++)
  {
    scanf("%d", &h[i]);
    if(max < h[i])
    {
      max = h[i];
    }
  }

  high = max / b;

  while(low <= high)
  {
    mid = (low + high) / 2;
    z = 0;
    m = mid;
    for(j=0; j<n; j++)
    {
      x = h[j] - mid * b;
      if(x > 0)
      {
        y = x / (a-b);
        if(x % (a-b) != 0) y++;
        m = m - y;
          if(m < 0)
          {
            z = 1;
            break;
          }
      }
    }
    if(z == 1)
    {
      low = mid + 1;
    }
    else
    {
      high = mid - 1;
    }
  }

  printf("%d\n", low);

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n;
while(cin>>n){
   j=0;
   for(i=1;i<=n;i++)if(i%3!=0&&i%5!=0) j+=i;
   cout<<j<<endl;
} return 0;
}


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

int main(){
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB"){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
L=[]
R=[]
for _ in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

if max(L) > min(R):
    print(0)
else:
    print(int(min(R)-max(L)+1))


Measured memory_bytes: 10996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

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


int main() {
    ll N, M;
    cin >> N >> M;

    map<int, vector<pair<int,int>>> m;
    for(int i = 0; i < M;i++) {
        ll P, Y;
        cin >> P >> Y;
        m[P].push_back(make_pair(Y, i));
    }

    vector<pair<int,int>> v(M);
    for(auto itr = m.begin(); itr != m.end(); itr++) {
        sort(itr->second.begin(), itr->second.end());
        
        //for(auto itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++) {
        for(int i = 0; i < itr->second.size(); i++) {
            v[itr->second[i].second] = make_pair(itr->first, i);
        }
    }

    for(int i = 0; i < M; i++) {
        cout << setw(6) << setfill('0')  << v[i].first <<  setw(6) << setfill('0')  << v[i].second + 1 << endl;
    }




    return 0;
}


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

  int x,y,z;
  int max,mid,min;
  cin>>x>>y>>z;
  if(1<=x&&x<=10000&&1<=y&&y<=10000&&1<=z&&z<=10000){
  if(x>y&&y>z)
    cout<<z<<" "<<y<<" "<<x<<endl;
  else if(x>=z&&z>=y)
    cout<<y<<" "<<z<<" "<<x<<endl;
  else if(y>=z&&z>=x)
    cout<<x<<" "<<z<<" "<<y<<endl;
  else if(y>=x&&x>=z)
    cout<<z<<" "<<x<<" "<<y<<endl;
  else if(z>=x&&x>=y)
    cout<<y<<" "<<x<<" "<<z<<endl;
  else
    cout<<x<<" "<<y<<" "<<z<<endl;
  }

  else{}

  return 0;
}

Measured memory_bytes: 3104
N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]

"""
i番目まで見て、n個選んでいて、重さがwのときのvの最大値
ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする
dp[i][n][w] 
"""

dp = [[[-1]*(3*N+1) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(i+1):
        for j in range(3*N):
            if dp[i][n][j] == -1:continue
            dp[i+1][n+1][j+w] = max(dp[i][n][j] + v, dp[i][n][j+w])
            dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])

ans = 0
for i,a in enumerate(dp[N]):
    w = W - i*ws[0]
    if w >= 0:
        ans = max(ans,max(a[:w+1]))
print(ans)   


Measured memory_bytes: 31720
#include <stdio.h>
#include <math.h>

int main(void) {
	
	int n,a[10],num=0;
	
	while(scanf("%d",&n)!=EOF){
		if(n==0 && num>0){
			num--;
			printf("%d\n",a[num]);
		}
		else{
			a[num]=n;
			num++;
		}
	}

	return 0;
}

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

int main()
{
  int n,k,r,s,p;
  string t;
  cin>>n>>k;
  cin>>r>>s>>p;
  cin>>t;
  int i,j;
  long long score=0;
  for(j=0;j<k;j++)
  {
    int now=t.at(j);
    bool plusok=false;
    if(now=='r')score+=p;
    else if(now=='s')score+=r;
    else if(now=='p')score+=s;
    for(i=j+k;i<n;i+=k)
    {
      if(now!=t.at(i))
      {
        now=t.at(i);
        if(now=='r')score+=p;
        else if(now=='s')score+=r;
        else if(now=='p')score+=s;
        plusok=false;
      }
      else if(!plusok)plusok=true;
      else if(plusok)
      {
        if(now=='r')score+=p;
        else if(now=='s')score+=r;
        else if(now=='p')score+=s;
        plusok=false;
      }
    }
  }
  cout<<score<<endl;
}


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

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int k;
	cin >> k;
	vector<int> freq(k);
	for(int& x : freq) cin >> x;
	int minv = 1000000, maxv = -1;
	for(int x : freq){
		minv = min(minv, x); maxv = max(maxv, x);
	}
	int sum = 0;
	for(int x : freq) sum += x;
	if(minv * 2 < maxv){
		cout << -1 << '\n';
		return 0;
	}
	vector<int> ans;
	int maxworks = 0;
	while((int)ans.size() < sum){
		bool found = false;
		for(int nxt = 0; nxt < k; nxt++){
			vector<int> cans = ans;
			cans.push_back(nxt);
			int cmaxworks = maxworks;
			{
				if((int)cans.size() >= k){
					vector<int> d(k, 0);
					for(int i = 0; i < k; i++){
						d[cans[(int)cans.size() - 1 - i]]++;
					}
					bool works = true;
					for(int i = 0; i < k; i++) if(!d[i]) works = false;
					if(works) cmaxworks = (int)cans.size();
				}
			}
			vector<int> cfreq = freq;
			cfreq[nxt]--;
			if(cfreq[nxt] < 0) continue;
			vector<int> known;
			for(int f = cmaxworks; f < (int)cans.size(); f++) known.push_back(cans[f]);
			vector<int> zk = known;
			sort(zk.begin(), zk.end());
			if(unique(zk.begin(), zk.end()) != zk.end()) continue;
			bool ok = false;
			{
				vector<int> dfreq = cfreq;
				for(int i = 0; i < k; i++) dfreq[i]--;
				multiset<int> g;
				for(int f : dfreq) g.insert(f);
				if(*g.rbegin() <= 2 * *g.begin()) ok = true;
				reverse(known.begin(), known.end());
				for(int a : known){
					g.erase(g.find(dfreq[a]));
					dfreq[a]++;
					g.insert(dfreq[a]);
					if(*g.rbegin() <= 2 * *g.begin()) ok = true;
				}
				reverse(known.begin(), known.end());
			}
			{
				vector<int> dfreq = cfreq;
				for(int i = 0; i < k; i++) dfreq[i]--;
				for(int a : known){
					dfreq[a]++;
				}
				multiset<int> g;
				for(int f : dfreq) g.insert(f);
				vector<int> cur(k, 0);
				for(int a : known) cur[a] = 1;
				for(int b = cmaxworks - 1; b >= 0; b--){
					if(cur[cans[b]]) break;
					cur[cans[b]] = 1;
					int a = cans[b];
					g.erase(g.find(dfreq[a]));
					dfreq[a]++;
					g.insert(dfreq[a]);
					if(*g.rbegin() <= 2 * *g.begin()) ok = true;
				}
			}
			{
				vector<int> dfreq = cfreq;
				for(int i = 0; i < k; i++) dfreq[i]--;
				vector<int> cur(k, 0);
				for(int a : known) cur[a] = 1;
				int minval = 1000000;
				for(int b : dfreq) minval = min(minval, b);
				for(int i = 0; i < k; i++){
					if(cur[i]) continue;
					if(dfreq[i] > 2 * minval){
						dfreq[i]--;
						cur[i]--;
					}
				}
				int ming = 100000, maxg = 0;
				for(int b : dfreq) ming = min(ming, b);
				for(int b : dfreq) maxg = max(maxg, b);
				if(ming * 2 >= maxg){
					ok = true;
				}
			}
			if(ok){
				ans.push_back(nxt);
				maxworks = cmaxworks;
				found = true;
				freq[nxt]--;
				break;
			}
		}
		// for(int b : ans) cerr << b << ' ';
		// cerr << '\n';
		assert(found);
	}
	for(int b : ans) cout << b+1 << ' ';
	cout << '\n';
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
struct UnionFind{
	vl par,dist;
	UnionFind(int x){par.assign(x,-1); dist.assign(x,0);}
	ll find(ll x){return par[x]<0?x:find(par[x]);}
	ll depth(ll x){return par[x]<0?0:depth(par[x])+dist[x];}
	bool same(ll x,ll y){return find(x)==find(y);}
	ll size(ll x){return -par[find(x)];}
	ll diff(ll x,ll y){return same(x,y)?depth(x)-depth(y):-1;}
	void unite(ll x,ll y,ll k=0){
		k+=depth(y); k-=depth(x); k=-k;
		x=find(x); y=find(y);
		if(x==y)return;
		if(size(x)<size(y)){swap(x,y);k=-k;}
		par[x]+=par[y]; par[y]=x; dist[y]=k;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	
	UnionFind uf(n);
	rep(i,m){
		int t,a,b;
		cin>>t>>a>>b;
		if(t==0){
			uf.unite(a,b);
		}else{
			puta(uf.same(a,b));
		}
	}
	return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  map<string,int> s;
  int count_m=1;
  for (string x; n--; s[x]++) {
    cin >> x;
    if(count_m<=s[x]){
      count_m++;
    }
  }
  for(auto itr = s.begin(); itr != s.end(); ++itr) {
    if(itr->second==count_m){
    std::cout << itr->first<< "\n";
    }
    }
  return 0;
}

Measured memory_bytes: 25216
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll MOD = 1000000007;
const int SIZE = 1010;
ll inv[SIZE],fac[SIZE],finv[SIZE];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<SIZE;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll Combination (int a,int b) {
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
ll dp[1010][1010];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  make();
  FOR(i,0,1010) dp[i][0] = 1;
  FOR(i,a,b+1) {
    FOR(j,0,n+1) {
      if(dp[i][j] == 0) continue;
      if(j != 0) (dp[i+1][j] += dp[i][j]) %= MOD;
      ll p = 1;
      for(int k = 1; k <= d && j + i * k <= n; k++) {
        p = (((p * Combination(n - j - i * (k - 1), i) % MOD) * inv[k]) % MOD) % MOD;
        if(k >= c) (dp[i+1][j+i*k] += (dp[i][j] * p) % MOD) %= MOD;
      }
    }
  }
  cout << dp[b+1][n] << endl;
  return 0;
}

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

int main()
{
    int a,tmp,b,c;
    cin >> a;
    tmp = a;
    while(tmp!=0)
  {
    b = tmp % 10;
 
    c = c * 10 + b;
 
    tmp /= 10;
  }
    if( c== a ){
    cout << "Yes";
    }
  else{
    cout << "No"; 
} 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <fstream>
#include <sstream>
#include <math.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <time.h>
#include <stdio.h>
#include <deque>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

int N;
vi L;

void solve() {
	ll ans = 0;

	while (L.size() >= 2){
		sort(ALL(L));
		reverse(ALL(L));

		int f = L.front();  L.erase(L.begin());
		int s = L.front();  L.erase(L.begin());
		ans += s;
	}

	cout << ans << endl;
}

int main() {
	cin >> N;

	REP(i,N*2){
		int buf; cin >> buf;
		L.push_back(buf);
	}

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int cnt[10]={0},tmp;
		for(int i=0;i<n;i++){
			cin>>tmp;
			cnt[tmp]++;
		}
		for(int i=0;i<10;i++){
			if(cnt[i]==0)cout<<"-"<<endl;
			else for(int j=0;j<cnt[i];j++)(j==cnt[i]-1)?cout<<"*"<<endl:cout<<"*";
		}
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  
  //sorting->here including bug:2,3,4,1,5,3,6,7,8,0,
  sort(a.begin(), a.end(), greater<int>());

  //debag
  /*cout << "vec = ";
  for(int i=0;i<n;i++)
    cout << a.at(i) << ",";
  cout << endl;//*/

  //counting
  int alice = 0, bob = 0;
  for(int i=0;i<n;i+=2)
    alice+=a.at(i);
  for(int i=1;i<n;i+=2)
    bob+=a.at(i);
  cout << alice - bob << endl;//delete absolute
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();
		out.println(N*N);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 26708
N = int(input())
H = list(map(int, input().split()))

lst = []
for i, h in enumerate(H):
    if i == 0:
        lst.append(0)
    elif i == 1:
        lst.append(abs(H[i-1] - h))
    else:
        cost = min(lst[i-2] + abs(H[i-2] - h), lst[i-1] + abs(H[i-1] - h))
        lst.append(cost)

print(lst[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	// どこかの面が偶数のときは、そこで面を切れば差が0になる
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		printf("0\n");
	}
	// 偶数がないときはなるべく差が少ない面で切る
	else {
		ll ans = 0;
		// 体積の差は1直方体分
		ans =  min({a * b, a * c, b * c});
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
long long i,j,k,ans,a,b,c,d;
char s[10];
int main()
{
    cin>>s;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    for(i=43;i<=45;i+=2)
	{
        for(j=43;j<=45;j+=2)
		{
            for(k=43;k<=45;k+=2)
			{
                ans=a;
                if(i==43) ans+=b;
                else
                ans-=b;
                if(j==43) ans+=c;
                else
                ans-=c;
                if(k==43) ans+=d;
                else
				ans-=d;
                if(ans==7)
				{
                    cout<<a<<char(i)<<b<<char(j)<<c<<char(k)<<d<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    double total = 0;
    cout << fixed << setprecision(16);
    for (int i = 1; i <= n; i++) {
        long a = i; double count = 1.0 /n;
        while (a < k) {
            a *= 2;
            count = count / 2.0;
        }
      
        total += count;
    }
    
    cout << total << endl;
}





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

string a,b="CF"; //打表
int al,bl;
int asdfc;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ //当找到一个的时候加一
            bl++;
            if(bl==2)   //都找到的时候就退出
                break;
        }
    if(bl==2) cout<<"Yes"; //判断并且输出
    else cout<<"No";
    cout<<endl;//最后不要忘了打个换行
    return 0;
}

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

vector<int> prime(MAX);

void mk_prime(){
    for( int i = 0; i < MAX; i++){
        prime[i] = 1;
    }
    prime[0] = 0;
    prime[1] = 0;
    for( int i = 2; i < MAX; i++ ){
        if( prime[i] == 1 ){
            for( int j = 2 * i; j < MAX; j += i ){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    mk_prime();
    int k;

    while( 1 ){
        cin >> k;
        if( k == 0 ) return 0;
        if( prime[k] == 1 ){
            cout << 0 << endl;
            continue;
        }
        int s, e;
        for( int i = k - 1; ; i-- ){
            if( prime[i] == 1 ){
                s = i;
                break;
            }
        }
        for( int i = k + 1; ; i++ ){
            if( prime[i] == 1 ){
                e = i;
                break;
            }
        }
        int ans = e - s;
        cout << ans << endl;
    }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int ans;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        ans += 2 * min(x,K - x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char s[100001];
int main()
{
	cin>>s;
	int sum=0,len=strlen(s),ans=0;
	int k=len/2;//布最多能出的次数 
	for(int i=0;i<=len-1;i++)
		if(s[i]=='p'||s[i]=='P')
			ans++;
	cout<<k-ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;
char VOW[] = {'a','e','u','o','i','A','E','U','O','I'};

int a, b, c;
string s;

void saitama(){
//	freopen("INPUT.txt","r",stdin);	
	cin >> a;
	cin >> s;
	cin >> b;
	for (int i=0; i<s.size(); ++i){
		if (s[i] != s[b-1]){
			cout << '*';
		} else {
			cout << s[b-1];
		}
	}
}	

int main(){ FIO;
	saitama();
return 0;}

Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

template<typename T>
pair<vector<T>, vector<bool>> prime_sieve(T lim) {
	vector<T> primes = vector<T>();
	vector<bool> composite = vector<bool>(lim+1);
	for (T num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
	return {primes, composite};
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	auto [primes, composite] = prime_sieve((int)min(1e3+100, ceil(sqrt(maxx)) + 100));
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

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

using namespace std;

const int N = 2e5 + 8;
long long a[N] , n , x , cnt , t;
multiset<long long> s;

int main()
{
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> a[i];
		s.insert(a[i]);
	}
	sort(a , a + n);
	for(int i = n - 1 ; i >= 0 ; i--)
	{
		t = 1;
		if(s.find(a[i]) != s.end())
		{
			s.erase(s.find(a[i]));
			for(int j = 0 ; j < 40 ; j++)
			{
				t *= 2;
				if(s.find(t - a[i]) != s.end())
				{
					cnt++;
					s.erase(s.find(t - a[i]));
					break;
				}
			}
		}
	}
	cout << cnt;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, b, n, now;
  cin >> a >> b >> n;
  long long i = min(b, n);
  now = a*i/b - a*(i/b);
  for(; i > 0; i--){
    if(now > (a*i/b - a*(i/b))){
      break;
    }else{
      now = a*i/b - a*(i/b);
    }
  }
  cout << now;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = (int)sc.next().toCharArray()[0];
		int y = (int)sc.next().toCharArray()[0];

		if (x < y) {
			System.out.println("<");
		} else if ( x == y) {
			System.out.println("=");
		} else {
			System.out.println(">");
		}
	}

}


Measured memory_bytes: 23892
K = int(input())


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


result = 0
for i in range(1, K + 1):
    for j in range(1, i + 1):
        for k in range(1, j + 1):
            if i == j == k:
                result += i
            elif i == j:
                result += gcd(i, k) * 3
            elif j == k:
                result += gcd(i, k) * 3
            else:
                result += gcd(gcd(i, j), k) * 6

print(result)

Measured memory_bytes: 9212
#include <iostream>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (int)(b); i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int n,k;
  cin >> n >> k;
  int res = 1;
  rep(i,n){ res += (k*(k <= res)) + (res*(k > res)); }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var intList = _GetIntListReadLine();
		var evenNum = Enumerable.Range(0 , 2).Select(iIndex =>
		{
			var num = intList[iIndex];
			return (num > 1) ? _GetCombinationNum(num , 2) : 0;
		})
		.Sum();
		Console.WriteLine(evenNum);
	}

	private static int _GetCombinationNum(int iLeft , int iRight)
	{
		var left = Enumerable.Range(iLeft - iRight + 1 , iRight).Aggregate((iCurrent , iNext) => iCurrent * iNext);
		var right = Enumerable.Range(1 , iRight).Aggregate((iCurrent , iNext) => iCurrent * iNext);
		return left / right;
	}
	
	private static string		_GetReadLine()		  { return Console.ReadLine(); }
	private static int			_GetIntReadLine()	  { return int.Parse(_GetReadLine()); }
	private static List<string> _GetListReadLine()	  { return _GetReadLine().Split(' ').ToList(); }
	private static List<int>	_GetIntListReadLine() { return _GetListReadLine().Select(iText => int.Parse(iText)).ToList(); }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 100000

int main (void)
{
  int ans;
  int N;

  cin >> N;

  int A[N];

  rep(i,0,N) {
    cin >> A[i];
  }

  //広義単調減少列の最大長が答え
  //dp[i] 最後がA[i]の最大長
  // int dp[N];
  //
  // dp[0] = 1;
  // ans = 1;
  // rep(i,0,N) {
  //   dp[i] = 1;
  //   rep(j,0,i) {
  //     if (A[j] >= A[i]) {
  //       dp[i] = max(dp[i],dp[j]+1);
  //     }
  //   }
  //   ans = max(ans,dp[i]);
  // }

  //dp[i] i+1の長さになる最大の最後の値
  vector<int> v;

  rep(i,0,N) {
    A[i] = -A[i];
    auto itl = upper_bound(v.begin(),v.end(),A[i]);
    if(itl == v.end()) {
      v.push_back(A[i]);
    } else {
      *itl = A[i];
    }
  }

  ans = v.size();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




ll sum(ll n){
    ll s = 0;
    for(ll i = n; i > 0; i /= 10){
        s += i % 10;
    }
    return s;
}

int main() {
    ll k;
    cin >> k;
    
    cout << 1 << endl;
    ll n = 1, d = 1;
    for (ll i = 1;i < k;i ++) {
        if (sum(n + d) * (n + 10 * d) < sum(n + 10 * d) * (n + d)) d *= 10;
        n += d;
        cout << n << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            int n = sc.nextInt();
            if(n == 0) break;
            int[] s = new int [n];
            for (int i = 0; i < n; i++) {
                s[i] = sc.nextInt();
            }
            Arrays.sort(s);
            int ave = 0;
            for(int i = 1;i<n-1;i++)
            {
                ave += s[i];
            }
            ave /= (n-2);
            System.out.println(ave);
        }

        sc.close();
    }
    
    public static void printary(int[] a)
    {
        for ( int i = 0; i < a.length; i++) {
            if(i>0) System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 29280
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const ll mod = 1e9 + 7;

#define MAX_V 1000000
const int MAX = 510000;

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

void comInit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, MAX) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

ll comb(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;
}


map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for(ll i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

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

	comInit();
	ll N, M;
	cin >> N >> M;
	map<ll, ll> m = prime_factor(M);
	ll rsl = 1;
	for(map<ll, ll>::iterator itr = m.begin(); itr != m.end(); itr++) {
		rsl *= (comb(itr->second + N - 1, N - 1) % mod);
		rsl %= mod;
	}

	cout << rsl << endl;
}


Measured memory_bytes: 12160
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll a,b,c;
int main() {
    cin>>c;
    if(c==1){
        p("Hello World");
    }else{
        cin>>a>>b;
        p(a+b);
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int M, D, ans = 0;
    cin >> M >> D;
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= D; j++) {
            int m = i;
            int d1 = j % 10;
            int d10 = j / 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            int N;int K;
            Multi(out N, out K);
            var ans = Math.Floor(Math.Log(N, K)) + 1;

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }

        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11476
#include <stdio.h>
#include <stdlib.h>
int compare(const void*a,const void*b){
    if(*(int*)a<*(int *)b)return 1;
    return -1;
}
int main()
{   long long n,t,min=1000000007;
    scanf("%lld%lld",&n,&t);
    long long a[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    int b[n];
    for(int i=0;i<n;i++){
        if(a[i]<min){
            min=a[i];
            }
        b[i]=a[i]-min;
    }
    qsort(b,n,sizeof(int),compare);
    //for(int i=0;i<n;i++)printf("%d ",b[i]);
    int i=0;
    for(;i<n-1;i++){
        if(b[i]!=b[i+1])break;
    }
    printf("%d",i+1);

    return 0;
}


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  int a[200005];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> b;
  b.push_back(a[0]);
  for(int i=1;i<n;i+=2){
    b.push_back(a[i]);
  }
  reverse(b.begin(),b.end());
  for(int i=2;i<n;i+=2){
    b.push_back(a[i]);
  }
  if(n%2!=0)reverse(b.begin(),b.end());
  for(int i=0;i<n-1;i++){
    cout<<b[i]<<" ";
  }
  cout<<b[n-1]<<"\n";
  return 0;
}


Measured memory_bytes: 3828
// inputに入力データ全体が入る
function Main(input) {
    var obj = {};
    var N = input[0].split("").forEach(v=>obj[v]=true);
    console.log(Object.keys(obj).length==1?"No":"Yes");
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 22076
#include<stdio.h>
int main(){
    double x1,x2,x3,x4,y1,y2,y3,y4;
    while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)){
        bool ok1=true;
        bool ok2=true;
        if((x2-x1)*(y4-y1)-(x4-x1)*(y2-y1)<0)ok1=false;
        else ok2=false;
        if((x3-x2)*(y4-y2)-(x4-x2)*(y3-y2)<0)ok1=false;
        else ok2=false;
        if((x1-x3)*(y4-y3)-(x4-x3)*(y1-y3)<0)ok1=false;
        else ok2=false;
        printf((ok1||ok2)?"YES\n":"NO\n");
    }
}

Measured memory_bytes: 1044
#include <iostream>
using namespace std;
int main(void){
    
    int n;
    cin>>n;
    
    int c=0;
    for(int i=1; i<=n; i++){
        int t=i;
        
        int cnt=0;
        while(t>=1){
            t/=10;
            cnt++;
        }
        
        if(cnt%2==1){
            c++;
        }
    }
    
    cout<<c<<endl;
}


Measured memory_bytes: 256
import collections
N=int(input())
W=[]
for i in range(N):
    W.append(input())
a=collections.Counter(W)
a=sorted(a.items(),key=lambda x:x[1],reverse=True)
if a[0][1]>1:
    print('No')
else:
    c=0
    for i in range(N-1):
        if W[i][-1]!=W[i+1][0]:
            c=1
            break
    if c==0:
        print('Yes')
    else:
        print('No')




Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define sz(a) (int)(a).size()
const int mod=2e9;
signed main(){
	int n,k;
	sl(n);sl(k);
	int arr[n+1],dp[n+5];
	for(int i=1;i<=n+4;i++){
		dp[i]=mod;
	}
	dp[1]=0;
	for(int i=1;i<=n;i++)sl(arr[i]);
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
		 if(i+j<=n)
		    dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
	  }
	}
	
	//for(int i=1;i<=n;i++)cout<<dp[i]<<" ";
	
	cout<<dp[n]<<endl;
	
	
}




Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
n,m,q = map(int,input().split())
x = [list(map(int,input().split()))for i in range(q)]
ans = 0
def calc(l):
    res = 0
    
    for i in range(q):
        a,b,c,d = x[i][0],x[i][1],x[i][2],x[i][3]
        a -= 1
        b -= 1
        if l[b] - l[a] == c:res += d
    return res
def dfs(d,nums):
    if d == n:
        
        return calc(nums)
    res = 0
    for i in range(1,m+1):
        if len(nums) > 0 and nums[-1] > i:continue
        res = max(res,dfs(d+1,nums + [i]))
    return res

ans = dfs(0,[])
print(ans)
        


Measured memory_bytes: 9240
/**
File   :  1d_dp.cpp
Brief  :  一次元DPについて
Author :  S.SUGIHARA
Date   :  2020-09-20
Update :
*/

/**
Reference： AtCoder EDP Contest
Code test： https://atcoder.jp/contests/dp/tasks/dp_a
*/

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
//入力
int n;

//DPテーブル
int dp[100100]; //dp[i]: 足場iでの最小コスト
int h[100100]; //足場の高さ


int main() {
  //input
  cin >> n;
  for(int i = 1; i <= n; ++i) cin >> h[i];

  //DPの初期化
  dp[1] = 0;
  dp[2] = abs(h[2]-h[1]);

  //DPループ
  for(int i = 3; i <= n; ++i){
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }

  cout << dp[n] << endl;
}

Measured memory_bytes: 4400