akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

void solve()
{
	string S;
	cin >> S;
	ll ans = 0, tmp = 0;
	for (char c : S)
	{
		if (c == 'B') tmp++;
		else
		{
			ans += tmp;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pll;
const int N = (int)3e5 + 7;
const ll inf = 1e16;

ll n,m,k,x,y,ans=inf;

ll f(ll x){
    ll c=0;
    while (x) {
        c++;
        x/=10;
    }
    return c;
}


int main(){
    cin>>n;
    
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            m=max(f(i),f(n/i));
            ans=min(ans,m);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{

	int n, num;
	vector< int > a;

	while( 1 ) {
	
		cin >> n;
		if( n == 0 ) break;

		int Max = -100001;

		a.push_back( 0 );

		for( int i = 0; i < n; i++ ) {

			cin >> num;
			a.push_back( num );

		}

		for( int i = 1; i <= n; i++ ) {

			a[i] = max( a[i], a[i] + a[i - 1] );
			Max  = max( Max, a[i] );
		
		}

		cout << Max << endl;

		a.clear();
	
	}

	return 0;

}

Measured memory_bytes: 1244
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll L_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int A, B;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  int ans = A * B;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

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

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000010; 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() {
    int N,M;
    cin >> N >> M;
    COMinit();
    ll cnt = fac[M] * finv[M - N] % MOD;
    ll cnt2 = cnt;
    for(int i = 0;i < N;i++) {
        ll cnt3 = COM(N,i + 1) * fac[M - i - 1] % MOD * finv[M - N] % MOD;
        if(i % 2 == 0) {
            cnt2 = mod(cnt2 - cnt3);
        }
        else {
            cnt2 = (cnt2 + cnt3) % MOD;
        }
    }
    cout << mod(cnt * cnt2) << endl;
}

Measured memory_bytes: 26968
#include<bits/stdc++.h> 
using namespace std; 
 
 
int main() {
	int n,m;
	cin>>n>>m;
	int a[n];
	int s=0;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    s=s+a[i];
	}
	
	int z=s/(4*m);
    if(s%2!=0){
        z=z+1;
    }
	int cnt=0;
	for(int i=0;i<n;i++){
	    if(a[i]>=z){
	        cnt++;
	    }
	}
	if(cnt>=m){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std ;
bool is_war ( const vector <int >& x , const vector <int >& y ) {
	for ( int Z = -100; Z <= 100; ++ Z ) {
		bool is_ok = true ;
		for ( int i = 0; i < x . size (); ++ i ) {
			if ( x [ i ] >= Z ) is_ok = false ;
		}
		for ( int i = 0; i < y . size (); ++ i ) {
			if ( y [ i ] < Z ) is_ok = false ;
		}
		if ( is_ok ) return false ;
	}
	return true ;
}

int main () {
	int N , M ; cin >> N >> M ;
	vector <int > x ( N +1) , y ( M +1);
	cin >> x [0] >> y [0];
	for ( int i = 0; i < N ; ++ i ) {
		cin >> x [ i +1];
	}
	for ( int i = 0; i < M ; ++ i ) {
		cin >> y [ i +1];
	}
	if ( is_war (x , y )) {
		cout << " War " << endl ;
	}
	else {
		cout << "No War " << endl ;
	}
}


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

int main() {
  int N, i, j;
  int P[10], Q[10];
  int a=0, b=0;
  int v[8] = {40320, 5040, 720, 120, 24, 6, 2, 1};
  cin >> N;
  for (i = 0; i < N; i++)
    cin >> P[i];
  for (i = 0; i < N; i++)
    cin >> Q[i];
  for (i = 0; i < N; i++) {
    int cnt = 0;
    if (i != 0) {
      for (j = 0; j < i; j++) {
        if (P[j] < P[i])
          cnt += 1;
      }
    }
    if (i != N-1)
      a += (P[i]-1-cnt)*v[8-N+i+1];
    else
      a += P[i]-cnt;
  }
  for (i = 0; i < N; i++) {
    int cnt = 0;
    if (i != 0) {
      for (j = 0; j < i; j++) {
        if (Q[j] < Q[i])
          cnt += 1;
      }
    }
    if (i != N-1)
      b += (Q[i]-1-cnt)*v[8-N+i+1];
    else
      b += Q[i]-cnt;
  }
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void prim();  
 int g[100][100],a[100],f[100];
  int n,i,j,k=1,m=0,num,sum=0;
int main(){
 
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
prim();
    return 0;
}

void prim(){
  a[0]=0;
  f[0]=1;
    
  for(i=1;i<n;i++) f[i]=0;
    
  while(1){
    num=2000;
      
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
    if(g[a[i]][j]<num && g[a[i]][j]!=-1 && f[j]!=1){
      num=g[a[i]][j];
      m=j;
    }
      }
    }
      
    if(k!=n){
      a[k]=m;
      f[m]=1;
      sum+=num;
      k++;
    }
    else break;
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
double a,b,h,m,ans,kaku,pi,unit;
pi = 2.0 * asin(1.0);            /* πの値 */
unit   = pi / 180.0;   
cin >> a >> b >> h >> m;
h = h*30+m/2;
m *= 6;
kaku = min(360-abs(h-m),abs(m-h))*unit;

ans = a * a + b * b - 2 * a*b* cos(kaku);
ans = sqrt(ans);
printf("%.20f\n",ans);


return 0;
}


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

int dp[110][5],ap[110][5];

signed main(void){ 
  string N; cin >> N;
  int K; cin >> K;
  int n = (int)N.size();
  
  dp[0][1] = 1; //N[0]に一致する場合のみ
  ap[0][1] = (int)(N[0]-'0')-1; // 1,,,,N[0]-1までのみ
  ap[0][0] = 1; //0の場合
  
  for(int i = 0; i < n-1; i++){ 
    // N[i]からN[i+1]への遷移を考える
    for(int j = 0; j <= K; j++){ 
      
      ap[i+1][j+1] += ap[i][j]*9;
      ap[i+1][j] += ap[i][j]; //s+1個目で0を出した場合のみ
      
      if( N[i+1] != '0'){
        ap[i+1][j] += dp[i][j]*1;
        ap[i+1][j+1] += dp[i][j]*( (int)(N[i+1]-'0')-1 );
      }
      
      if(  N[i+1] != '0'){
        dp[i+1][j+1] += dp[i][j];
      }
      else{
        dp[i+1][j] += dp[i][j];
      }//else
    }//for-j
  }//for-i
  
  
  cout << dp[n-1][K] + ap[n-1][K] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   int N,M;
  cin >> N >> M;
  vector<vector<int>>vec(M,vector<int>(2));
  for(int i=0;i<M;i++){
    cin >> vec.at(i).at(0) >> vec.at(i).at(1);
  }
  vector<int>count(N);
  rep(i,N){
    for(int j=0;j<M;j++){
      if(vec.at(j).at(0)==i+1 || vec.at(j).at(1)==i+1){count[i]++;}
    }
  }
  rep(i,N){cout << count[i] << endl;}
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> s( H );
	for( int i = 0; i < H; i++ ) {
		cin >> s[i];
	}

	int dy[4] = { 1, -1, 0, 0 };
	int dx[4] = { 0, 0, 1, -1 };
	string ans = "Yes";
	for( int y = 0; y < H; y++ ) {
		for( int x = 0; x < W; x++ ) {
			if( s[y][x] != '#' ) continue;
			int flag = 0;
			for( int i = 0; i < 4; i++ ) {
				int ny = y + dy[i];
				int nx = x + dx[i];
				if( ny < 0 || ny >= H || nx < 0 || nx >= W ) continue;
				if( s[ny][nx] == '#' ) {
					flag = 1;
					break;
				}
			}
			if( flag == 0 ) {
				ans = "No";
				break;
			}
		}
		if( ans == "No" ) break;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3628
import sys
input=sys.stdin.readline
n,t=map(int,input().split())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a,b))
dp=[[0]*t for i in range(n+1)]
check=[[0]*t for i in range(n+1)]
for i in range(n):
    for j in range(t):
        if j>=l[i][0]:
            if dp[i+1][j]<dp[i][j]:
                dp[i+1][j]=dp[i][j]
            if dp[i+1][j-l[i][0]]<dp[i][j]+l[i][1]:
                dp[i+1][j-l[i][0]]=dp[i][j]+l[i][1]
                check[i+1][j-l[i][0]]=j
        else:
            if dp[i+1][j]<dp[i][j]:
                dp[i+1][j]=dp[i][j]
M=0
for j in range(t):
    M=max(M,dp[n][j])
m0=0
for j in range(t):
    if dp[n][j]==M:
        x=j
        g=[]
        for i in range(n,0,-1):
            if check[i][x]:
                x=check[i][x]
            else:
                g.append(i-1)
        m=0
        for i in g:
            m=max(m,l[i][1])
        m0=max(m0,m)
print(M+m0)
        
    


    



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

typedef long long ll;
const int MAX_N = 100000;

int main() {
	int N;
	static ll A[MAX_N], B[MAX_N], C[MAX_N];
	std::cin >> N;
	for(int i = 0; i < N; ++i) std::cin >> A[i];
	for(int i = 0; i < N; ++i) std::cin >> B[i];
	for(int i = 0; i < N; ++i) std::cin >> C[i];
	std::sort(A, A + N);
	std::sort(B, B + N);
	std::sort(C, C + N);

	ll ans = 0;
	for(int i = 0; i < N; ++i) {
		ll cnt_A, cnt_C;
		cnt_A = (ll) (std::lower_bound(A, A + N, B[i]) - std::begin(A));
		cnt_C = (ll) (std::begin(C) + N - std::upper_bound(C, C + N, B[i]));
		ans += cnt_A * cnt_C;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 2560
n  = int(input())
t, a = (int(x) for x in input().split())
h = [int(x) for x in input().split()]


total = None
result = 0

for i, x in enumerate(h):
    temp =   t - 0.006* x
    if total is None or abs(a - temp) < total:
        total = abs(a - temp)
        result = i + 1
print(result)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void solve(){

	lli l,r;
	cin>>l>>r;

	lli ans = INF;

	REP(cnt1,0,4000){
		if(l+cnt1>=r)break;
		REP(cnt2,1,4000){
			if(l+cnt1+cnt2>r)break;
			chmin(ans,((l+cnt1)*(l+cnt1+cnt2))%2019);
		}
	}
	cout<<ans<<endl;

	return ;
}

int main(){

	lli q;
	q=1;
	while(q--)solve();

    return 0;
}

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

const int MAX = 1e5;
const int INF = 1e9;
int N;
vector<vector<int> > edge(MAX);
int d1[MAX]; // マス1から各マスへの最短距離
int dN[MAX]; // マスNから各マスへの最短距離

// n:どのマスにいるか、d:始点からの距離
void dfs(int n, int d, bool flag) {
  for (int i = 0; i < edge[n].size(); i++) {
    if (flag) {
      if (edge[n][i] == N - 1) continue;
      if (d1[edge[n][i]] < INF) continue;
      d1[edge[n][i]] = d;
      dfs(edge[n][i], d + 1, true);
    } else {
      if (edge[n][i] == 0) continue;
      if (dN[edge[n][i]] < INF) continue;
      dN[edge[n][i]] = d;
      dfs(edge[n][i], d + 1, false);
    }
  }
}

int main() {
  cin >> N;
  int a, b;
  for (int i = 0; i < N - 1; i++) {
    scanf("%d %d", &a, &b);
    a--; b--;
    if (b != 0 && b != N - 1) edge[a].push_back(b);
    if (a != 0 && a != N - 1) edge[b].push_back(a);
  }

  // 深さ優先探索で1のマスからの各マスへの距離と、Nのマスから各マスへの距離を計算する
  fill(d1, d1 + N, INF);
  fill(dN, dN + N, INF);
  dfs(0, 1, true);
  dfs(N - 1, 1, false);

  // 各マスにおいて、d1 <= dNならば黒、そうでないなら白に塗られる
  // 全マスで計算して、多い方の勝ち。同じ場合は後手が勝つ
  int black, white;
  black = white = 1;
  for (int i = 1; i < N - 1; i++) {
    if (d1[i] <= dN[i]) black++;
    else white++;
  }

  // 解答
  cout << (black > white ? "Fennec" : "Snuke") << endl;

  return 0;
}


Measured memory_bytes: 11136
n = int(input())
s = input()

s_list = []

for item in s:
    if item == '.':
        s_list.append(0)
    else:
        s_list.append(1)

min_val = s_list.count(0)

left_val = 0
right_val = s_list.count(0)

for i in range(len(s_list)):
    if s_list[i] == 0:
        right_val -= 1
        min_val = min(left_val + right_val, min_val)
    else:
        left_val += 1

print(min_val)


Measured memory_bytes: 54748
# 凸包 Monotone Chain O(nlogn)
def det(p, q):
    return p[0]*q[1] - p[1]*q[0]
def sub(p, q):
    return (p[0]-q[0], p[1]-q[1])
def get_convex_hull(points):
    n = len(points)
    points.sort()
    size_convex_hull = 0
    ch = []
    for i in range(n):
        while size_convex_hull > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    t = size_convex_hull
    for i in range(n-2, -1, -1):
        while size_convex_hull > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    return ch[:-1]

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
ps = [(0, 0)]
for x, y in XY:
    ps_new = ps[:]
    for x_, y_ in ps:
        ps_new.append((x+x_, y+y_))
    ps = get_convex_hull(ps_new)
ans = 0
for x, y in ps:
    ans = max(ans, x*x+y*y)
print(ans ** 0.5)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

void solve();

const int N = 2e5 + 10;

int main() {
    fast_cin();

    int t=1;
    // cin >> t;
    while(t--) {
        solve();
    }
}

void solve() {
    int a, b;
    cin >> a >> b;
    // int a[N];
    // for (int i=1; i <= n; i++) { 
    //     cin >> a[i];
    // }

    ll product = 1LL * a * b;
    ll g = __gcd(a, b);
    
    cout << product / g << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
const int MAX_N = 1e7;
int _par[MAX_N];//親
int _rank[MAX_N];//木の深さ

bool judge(map<int, int> &mapBuff, int i){
  if(mapBuff[i] < 1) return false;
  return true;
}


//n要素で初期化 parは親の要素の番号
void init(int n){
  for(int i=0; i<n; i++){
    _par[i] = i;
    _rank[i]=0;
  }
}

//木の根を求める
int find(int x){
  if(_par[x]==x){
    return x;
  }
  else{
    return _par[x] = find(_par[x]);
  }
}

//xとyの属する集合の併合
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y) return;

  if (_rank[x] < _rank[y]){
    _par[x] = y;
  }else{
    _par[y]=x;
    if(_rank[x] == _rank[y])_rank[x]++;
  }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
  return find(x) == find(y);
}


int main(){
  int N,M;
  cin >> N >> M;
  int X[M], Y[M],Z[M];
  for(int i=0; i< M; i++){
    cin >> X[i] >> Y[i] >> Z[i];
  }


  init(N);
  for(int i=0; i< M; i++){
    if(!same(X[i], Y[i])){
      unite(X[i], Y[i]);
    }
  }
  //  int A[M];
  map<int, int> map;
  for(int i=0; i< N; i++){
    map[i]=0;
  }

  int ans=0;
  for(int i=0; i< N; i++){
    int parent = find(i);
    //    cout << parent << endl;
    if(map[parent] == 0){
      map[parent]=1;
      ans++;
    }
    else{
    }
    
  }
  cout << ans << endl;
 

}


Measured memory_bytes: 8576
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

long long func(long long n, long long x){
  if(n >= 0) return n / x + 1;
  else return 0;
}

int main() {
  long long a, b, x;
  cin>>a>>b>>x;

  cout<<func(b, x) - func(a-1, x)<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import deque

n,q = map(int,input().split())

edge = {}
for i in range(1,n+1):
    edge[i] = []

for i in range(n-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)

ans = [0] * (n+1)
for i in range(q):
    p,x = map(int,input().split())
    ans[p] += x

d = deque()
remains = set(range(1,n+1))
d.append(1)
remains.remove(1)

while(len(d) > 0):
    tmp = d.pop()
    for i in edge[tmp]:
        if(i in remains):
            ans[i] += ans[tmp]
            d.append(i)
            remains.remove(i)

print(' '.join(map(str, ans[1:])))

Measured memory_bytes: 131848
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv){
  int groupx;
  int groupy;
  int x;
  int y;
  scanf("%d %d",&x,&y);
  if(x==2){
    groupx=2;
  }
  else{
    if(x==4||x==6||x==9||x==11){
      groupx=1;
    }
    else{
      groupx=0;
    }
  }
  if(y==2){
    groupy=2;
  }
  else{
    if(y==4||y==6||y==9||y==11){
      groupy=1;
    }
    else{
      groupy=0;
    }
  }

  if(groupx==groupy){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
}


Measured memory_bytes: 128
while True:
    line = input()
    if line == '#':
        exit()

    g = line.split()[0]
    y, m, d = map(int, line.split()[1:])
    if y > 31 or y >= 31 and m >= 5:
        g = '?'
        y -= 30
    print(g, y, m, d)



Measured memory_bytes: 5596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	c := scanInt()

	ans := 0
	b := scanInts(m)

	for i := 0; i < n; i++ {
		a := scanInts(m)
		sum := 0
		for i := 0; i < m; i++ {
			sum += a[i]*b[i]
		}
		if sum+c > 0 {
			ans++
		}
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 640
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
        
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  ll n,i;cin>>n;
  ll X[n];
  fo(i,0,n)cin>>X[i];
  sort(X,X+n);
  ll x=X[0]-1;
  ll sum,mn=INT64_MAX; 
  for(;x<=X[n-1]+1;x++)
  {
      sum=0;
      fo(i,0,n)
      sum+=(X[i]-x)*(X[i]-x);
      
      mn=min(sum,mn);
  }
  cout<<mn<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 256
local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local mincost=1000000000000000
for i=-100,100 do
    local cost=0
    for j=1,n do
        cost=cost+(a[j]-i)*(a[j]-i)
    end
    mincost=math.min(cost,mincost)
end
print(mincost)

Measured memory_bytes: 884
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        struct Card
        {
            internal string suit;
            internal int value;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Card[] A1 = new Card[n];
            Card[] A2 = new Card[n];

            string[] input;
            for(int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');

                A1[i].suit = input[0];
                A2[i].suit = input[0];
                A1[i].value = int.Parse(input[1]);
                A2[i].value = int.Parse(input[1]);
            }

            QuickSort(A1, 0, n - 1);
            A2 = A2.OrderBy(a => a.value).ToArray();

            bool isStable = true;

            for(int i = 0; i < n; i++)
            {
                if (A1[i].suit != A2[i].suit)
                {
                    isStable = false;
                    break;
                }
            }

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(isStable ? "Stable" : "Not stable");
            foreach (var a in A1)
            {
                sb.AppendLine(a.suit + " " + a.value);
            }
            Console.Write(sb);
        }

        static void QuickSort(Card[] A,int p,int r)
        {
            if (p < r)
            {
                int q = Partition(A, p, r);
                QuickSort(A, p, q - 1);
                QuickSort(A, q + 1, r);
            }
        }

        static int Partition(Card[] A,int p,int r)
        {
            int x = A[r].value;
            int i = p - 1;
            Card temp;

            for(int j = p; j < r; j++)
            {
                if (A[j].value <= x)
                {
                    i++;

                    temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }

            temp = A[i + 1];
            A[i + 1] = A[r];
            A[r] = temp;

            return i + 1;
        }
    }
}

Measured memory_bytes: 29116
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 

int main(){
	string s;
	int ans=0;
	cin>>s;
	int dim=s.size();
	for(int i=0;i<dim;i++){
		if(i%2==0)continue;
		int ssize=i+1,count=0;
		string sub1=s.substr(0,ssize/2);
		string sub2=s.substr(ssize/2,ssize/2);
		REP(j,ssize){
			if(sub1[j]==sub2[j])count++;
		}
		DEB(ssize)DEB(sub1)DEB(sub2)DEB(count)END
		if(sub1==sub2&&ssize!=s.size()){
			ans=std::max(ans,ssize);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > A;
    rep(i,n)
    {
        int tmp_a;
        cin >> tmp_a;
        vector<pair<int, int> > tmp_xy(tmp_a);
        rep(j,tmp_a)
        {
            cin >> tmp_xy[j].first >> tmp_xy[j].second;
        }
        A.push_back(tmp_xy);
    }
    /*
    rep(i,n)
    {
        rep(j,A[i].size()) cout << A[i][j].first << " " << A[i][j].second << endl;
        cout << endl;
    }
    */

    int ANS = 0;

    rep(bit,(1<<n))
    {
        vector<int> S;
        rep(i,n)
        {
            if (bit & (1<<i)) S.push_back(i);
        }

        
        // Sに格納されていない人を正直者とする
        vector<int> ans(n,-1);
        int S_key = 0;
        bool flag = true;
        
        rep(i,n)
        {
            if( S.size() == 0 || i != S[S_key] ) continue;
            else 
            {
                S_key++;
                ans[i] = 0;
            }
        }

        S_key = 0;
        rep(i,n)
        {
            // 正直者の時
            if( S.size() == 0 || i != S[S_key] )
            {
                // 正直者の発言をansに格納していく
                rep(j,A[i].size())
                {
                    if( ans[A[i][j].first-1] == -1 ) ans[A[i][j].first-1] = A[i][j].second;
                    // 正直者の発言が矛盾している場合
                    else if( ans[A[i][j].first-1] != A[i][j].second )
                    {
                        flag = false;
                        break;
                    }
                }
            }
            else S_key++;

            // 正直者が矛盾している時
            if( !flag ) break;
        }
        
        if(flag)
        {
            /*
            cout << "S[i] is ";
            rep(i,S.size()) cout << S[i] << " ";
            cout << endl;
            rep(i,ans.size()) cout << ans[i] << " ";
            cout << endl;
            cout << endl;
            */

            // Sの配列の長さとans[i]に含まれている0の個数が異なる場合は答えに含めない
            int ans_zero_cnt = 0;
            rep(i,ans.size()) if( ans[i] == 0 ) ans_zero_cnt++;
            if( ans_zero_cnt == S.size() )ANS = max( ANS, (int)(n - S.size()) );
        }
    }
    cout << ANS << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{ 
	ll x;
	cin>>x;
	REP(i,-1000,1000){
		ll p = pow(i,5) - x;
		REP(j,-1000,1000){
			if(pow(j,5) == p){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	return 0;	
}  


Measured memory_bytes: 4100
import sys
import numpy as np
n = int(input())
input = sys.stdin.readline
a = np.array(list(map(int, input().split())))
for i in a:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            print('DENIED')
            exit()
print('APPROVED')


Measured memory_bytes: 12488
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int N=5000+5;
int n,m,a[N],b[N],f[N][N];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=m;i++)scanf("%lld",&b[i]);
	f[0][0]=1;
  	for(int i=0;i<=n;i++)
	  	for(int j=0;j<=m;j++)
		{
			if(i==0&&j==0)continue;
			int sum=0;
			if(i)sum+=f[i-1][j];
			if(j)sum+=f[i][j-1];
			if(i>0&&j>0)
			{
			  	sum-=f[i-1][j-1];
			  	if(a[i]==b[j])sum+=f[i-1][j-1];
			}
			sum=(sum%mod+mod)%mod;
    		f[i][j]=sum;
  		}
  	cout<<f[n][m];
}
/*
f[i][j],i和j配对的方案数
f[i][j]+=f[i+1][j+1] (a[i]==b[j])
f[i][j]+=f[i+1][j]+f[i][j+1]-f[i+1][j+1]
告非，我就是那个f[i+1][j+1]没想到，没想到会有重复的
就是(i+1,j)->(i+1,j+1)，(i,j+1)->(i+1,j+1),然后f(i+1,j+1)多加了一遍
初始f[0][0]=1;
答案f[n][m] 
*/

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll n,a[MAXN],ans;
int main()
{
    fast_io;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    for(ll i=0;i<n;i++){
        while(a[i]%2==0 && a[i]!=0){
            ans++;
            a[i]/=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
#include <iomanip>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    REP(i,n){
        v[i] = i;
    }
    vector<pair<double, double>> zahyou(n);
    REP(i,n){
        cin >> zahyou[i].first >> zahyou[i].second;

    }
    long long int num = 0;
    double result = 0;
    do{
        FOR(i,1,n){
            result += hypot(zahyou[v[i]].first - zahyou[v[i-1]].first, zahyou[v[i]].second - zahyou[v[i-1]].second);
        }
        num++;
    } while (next_permutation(v.begin(),v.end()));
    cout <<fixed<< setprecision(10)<<result / num << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
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; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  const int N = 1000005;
  vector<int> b(N);

  for (int x : a) {
    if (b[x] == 0) {
      for (int y = 2 * x; y < N; y += x) b[y]++;
    }
    b[x]++;
  }
  int ans = 0;
  for (int x : a) if (b[x] == 1) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 7968
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define MOD 1000000007
#define long long long

// x^n mod
long mod_pow(long x, long n, long mod){
  long res=1;
  x %= mod;
  while(n>0){
    if(n&1) res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}
long mod_inv(long x){ return mod_pow(x,MOD-2,MOD); }

long fact[1005];
long fact_inv[1005];
long comb(long n, long k){ return fact[n]*fact_inv[k]%MOD*fact_inv[n-k]%MOD; }

int main(){
  long n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  vector<vector<long>> dp(b+1, vector<long>(n+1,0));
  // dp[i][j] i人以下のグループのみからなる組み合わせをn人のうちのj人からつくる

  fact[0]=1;
  rep(i,1000) fact[i+1]=(i+1)*fact[i]%MOD;
  rep(i,1001) fact_inv[i]=mod_inv(fact[i]);

  dp[0][0]=1;
  rep(i,b) dp[i][0]=1;
  repl(i,a,b+1){
    repl(j,1,n+1){
      long tmp = 1;
      long x = n-j;
      dp[i][j] = dp[i-1][j];
      for(int k=1; k*i<=n; k++){
        if(k>d) break;
        if(j<i*k) break;
        x += i;
        tmp = tmp*comb(x,i)%MOD*mod_inv(k)%MOD;
        if(k<c) continue;
        dp[i][j] += tmp*dp[i-1][j-i*k];
        dp[i][j] %= MOD;
      }
    }
  }
//  rep(i,b+1)dbg(dp[i]);

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

  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int N,R;
    cin >> N >> R;
    cout << R+100*max(0,10-N) << endl;
    return 0;
}

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

int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    if (C*A<=B) cout<<C<<endl;
    else cout<<B/A<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int d;
	scanf("%d",&d);
	if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
	else if(d == 23) cout << "Christmas Eve Eve" << endl;
	else if(d == 24) cout << "Christmas Eve" << endl;
	else cout << "Christmas" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace::std;
using lint =long long;
#define rep(i,n) for(lint i=0;i<n;i++)
#define INF (1LL<<60)
using vec=vector<lint>;
int main(){
    lint n;
    cin>>n;
    vec c(4);
    vec v(4);
    rep(i,4)cin>>c[i];
    rep(i,4)cin>>v[i];
    lint ans=INF;
    rep(i,101)rep(j,101)rep(k,101){
        lint val=i*v[0]+j*v[1]+k*v[2];
        lint cos=i*c[0]+j*c[1]+k*c[2];
        if(val<=n){
            cos+=c[3]*((n-val-1)/v[3]+1);
        }
        ans=min(cos,ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3112
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N;
int arr[100005];
int sum  = 0;

int main()
{
	scanf("%d", &N);

	arr[0] = 0;
	arr[N + 1] = 0;
	for(int i = 1; i <= N; i++) {
		scanf("%d", &arr[i]);
	}
	for(int i = 0; i <= N + 1; i++) {
		sum += abs((arr[i] - arr[i + 1]));
	}

	for(int i = 1; i <= N; i++) {
		int ans = sum - abs(arr[i] - arr[i - 1]) - abs(arr[i + 1] - arr[i]) + abs(arr[i - 1] - arr[i + 1]);
		printf("%d\n", ans); 
	}

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1664
n,m=map(int,input().split())
x=[list(map(int,input().split())) for i in range(m)]
l=[]
r=[]
for i in range(m):
    l.append(x[i][0])
    r.append(x[i][1])
lm=max(l)
rm=min(r)
if rm<lm:
    print(0)
    exit()
else:
    print(rm-lm+1)

Measured memory_bytes: 29096
h = list(map(int, input().split()))

for i in range(1, h[0]+1):
    if 2 * i + 4 * (h[0]-i) == h[1]:
        print('Yes')
        exit()
for i in range(1, h[0]+1):
    if 4 * i + 2 * (h[0]-i) == h[1]:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 9056
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<"A"<<b[0]<<"C"<<endl;
    return 0;
}




Measured memory_bytes: 256
s = input()
if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
else:
    for i in range(len(s) - 2):
        temp = {}
        for j in range(3):
            temp.setdefault(s[i + j], 0)
            temp[s[i + j]] += 1
        if max(temp.values()) >= 2:
            print(i + 1, i + 3)
            break
    else:
        print(-1, -1)

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

#define MAX 3000

int main(){
  string s,t;
  cin >> s;
  cin >> t;

  s = " " + s;
  t = " " + t;
  int maxl_s = s.length();
  int maxl_t = t.length();
  int dp[maxl_s + 1][maxl_t + 1];
  for (int i = 0; i <= maxl_s; i++) {
    for (int j = 0; j <= maxl_t; j++) {
      dp[i][j] = 0;
    }
  }

  for (int i = 1; i < maxl_s; i++) {
    for (int j = 1; j < maxl_t; j++) {
      if (s[i] == t[j]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  string ans = "";
  int i = maxl_s - 1;
  int j = maxl_t - 1;
  while (0 < i && 0 < j) {
      if (dp[i][j] == dp[i-1][j]) {
        i--;
      } else if (dp[i][j] == dp[i][j-1]) {
        j--;
      } else {
        ans = s[i] + ans;
        i--;
        j--;
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<vector<int>> G(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int k; cin >> k;
  vector<int> col(n, inf);
  int root = -1;
  rep(i, k) {
    int v, p;
    cin >> v >> p;
    v--;
    col[v] = p;
    root = v;
  }
  int root_parity = col[root]%2;
  bool ok = true;
  auto dfs = [&](auto dfs, int cur, int par, int depth) -> void {
    if(col[cur] != inf) {
      if(((depth%2)^(col[cur]%2)) != root_parity) ok = false;
    }
    for(int ne: G[cur]) if(ne != par) dfs(dfs, ne, cur, depth+1);
  };
  dfs(dfs, root, -1, 0);
  vector<pair<int, int>> range(n);
  bool ok2 = true;
  auto dfs2 = [&](auto dfs2, int cur, int par) -> pair<int, int> {
    if(col[cur] != inf) range[cur].first = range[cur].second = col[cur];
    else {
      range[cur].first = -inf;
      range[cur].second = inf;
    }
    for(int ne: G[cur]) {
      if(ne != par) {
        pair<int, int> ret = dfs2(dfs2, ne, cur);;
        range[cur].first = max(range[cur].first, ret.first);
        range[cur].second = min(range[cur].second, ret.second);
      }
    }
    if(col[cur] != inf) {
      if(col[cur] < range[cur].first || range[cur].second < col[cur]) ok2 = false;
    } else {
      if(range[cur].first > range[cur].second) ok2 = false;
    }
    if(range[cur].first == -inf) {
      return range[cur];
    } else {
      return {range[cur].first-1, range[cur].second+1};
    }
  };
  dfs2(dfs2, root, -1);
  auto dfs3 = [&](auto dfs3, int cur, int par) -> void {
    for(int ne: G[cur]) {
      if(ne != par) {
        if(col[ne] == inf) {
          if(range[ne].first <= col[cur]-1 && col[cur]-1 <= range[ne].second) {
            col[ne] = col[cur]-1;
          } else {
            col[ne] = col[cur]+1;
          }
        }
        dfs3(dfs3, ne, cur);
      }
    }
  };
  if(ok) {
    if(ok2) {
      dfs3(dfs3, root, -1);
      cout << "Yes" << "\n";
      rep(i, n) cout << col[i] << "\n";
    } else {
      cout << "No" << "\n";
    }
  } else {
    cout << "No" << "\n";
  }
  return 0;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL; double Max = -1;
ll a, c, n, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	ll e;
	for (int i = 0; i < n; i++) {
		B[i + 1] = A[i];

	}
	for (int i = 0; i < n; i++) {
		B[i + 1] += B[i];

	}
	for (int i = 0; i <= n - a; i++) {
		ll g = B[i + a] - B[i];
		if (Max < g) { Max = g; e = i; }
	}
	double sum = 0,b;
	for (int j = e; j - e < a; j++) {
		b = (1 + (double)A[j]) * ((double)A[j] / 2);
		sum += b / (double)A[j];
	}



	cout << fixed << setprecision(15) << sum << endl;

	return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b){
        if(b <= c)
            cout << a << " " << b << " " << c << endl;
        else if(a <= c)
            cout << a << " " << c << " " << b << endl;
        else
            cout << c << " " << a << " " << b << endl;
    }else{
        if(a <= c)
            cout << b << " " << a << " " << c << endl;
        else if(b <= c)
            cout << b << " " << c << " " << a << endl;
        else
            cout << c << " " << b << " " << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  ll x = c-a-b;
  if(x < 0){
    printf("No");
    return 0;
  }
  if(4*a*b < x*x ) printf("Yes");
  else printf("No");
}

Measured memory_bytes: 256