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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 2000005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < SIZE; ++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;

    }
}

// 組み合わせ（重複無し）
LL comb(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;

}

// 二項係数
LL Bin(LL n, LL k) {
    if(k < 0 || n < k) {
        return 0;

    }
    LL ret = 1;
    for(LL i = 1; i <= k; ++i) {
        ret *= n--;
        ret /= i;

    }
    return ret;
}

// 重複組み合わせ
LL comb_rep(int x, int y) {
    return comb(x + y - 1, x - 1);

}

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

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    combInit();

    LL res = 0;
    while(r1 <= r2) {
        LL tmp = comb(c2 + r1 + 1, r1 + 1) - comb(c1 + r1, r1 + 1);
        tmp = (tmp + MOD) % MOD;
        res = (res + tmp) % MOD;
        ++r1;
    }
    cout << res << endl;

    return 0;
}



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

int main(){
    ll X, Y;
    cin >> X >> Y;

    ll pre = X, next;
    ll ans = 1;
    while(true){
        next = 2 * pre;
        if(next > Y){
            break;
        }else{
            pre = next;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    cout << 1 - x << endl;
    return 0;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;

long long int gcd(long long int a,long long int b){

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

}


int main()
{
    
    long long int a, b;
    cin >> a >> b;
    if (a > b)swap(a, b);
  
    cout << (a * b) / gcd(a, b) << endl;


    
   

    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const ll INF = 1LL << 50;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)

void riffle(vector<int> &nums, int c){
	int n = nums.size();
	vector<int> B(nums.begin(), nums.begin() + n/2), A(nums.begin()+n/2, nums.end()), C;
	int pa = 0, pb = 0;
	while((int)C.size() < n){
		for(int i = 0; i < c && pa < (int)A.size(); i++){
			C.push_back(A[pa++]);
		}
		for(int i = 0; i < c && pb < (int)B.size(); i++){
			C.push_back(B[pb++]);
		}
	}
	nums = C;
}

int main(){
	int n, r, c;
	while(cin >> n >> r &&(n || r)){
		vector<int> nums;
		rep(i, n) nums.push_back(i);
		rep(i, r){
			cin >> c;
			riffle(nums, c);
		}
		cout << nums[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define pf push_front
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define pi acos(-1.0)
using namespace std;

const int maxn=1e3+10;
const int maxe=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

inline int read(){
    int x=0; bool flag=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();}
    if(flag) return x;
    return ~(x-1);
}
inline void write(int x){
    if(x<0) {x=~(x-1); putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

main(){
    fastio;
    string s,t;
    cin>>s>>t;
    int mi=inf;
    for(int i=0;i<s.length();++i){
        if(i+t.length()>s.length())break;
        int ans=0;
        for(int j=i;j<i+t.length();++j){
            if(s[j]!=t[j-i])ans++;
        }
        mi=min(ans,mi);
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
        long long int X;
        long long int t;
        scanf("%lld %lld", &X,&t);
        if (t>=X) {
                printf("0\n");
                return 0;
        }else{
                printf("%lld\n",X-t);
        }
        return 0;
}

Measured memory_bytes: 128
/************************************************
*Author        :  Jack
*Created Time  :  2019.10.27.20:24
*Mail          :  724033213@qq.com
*Problem       :  d
*Extra         :  
************************************************/
#include <bits/stdc++.h>
using namespace std;
using ldb = long double;
const ldb PI = 3.1415926535;
const ldb eps = 1e-7;
ldb a, b, x;
int main() {
//    freopen("d.in","r",stdin);
//    freopen("d.out","w",stdout);
    cin >> a >> b >> x;
	ldb hlf = a * a * b / 2;
//	cout << hlf << endl;
	if(hlf - x > eps || abs(hlf - x) < eps){
		ldb db = x / (b * a) * 2;
		ldb lb = b;
		ldb ans = atan(db / lb);
		ans *= 180; ans /= PI;
		printf("%.10Lf\n", 90 - ans);
	} else {
		x = a * a * b - x;
		ldb lb = x / (a * a) * 2;
		ldb db = a;
//		cout << lb << " " << db << endl;
//		printf("%.8Lf %.8Lf", lb, db);
		ldb ans = atan(db / lb);
		ans *= 180; ans /= PI;
		printf("%.10Lf\n", 90 - ans);
	}
    return 0;
}


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

int main() {
  int n, d, t, o = 0;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for(int i = 0; i < n; i++)
    for(int j = 0; j < d; j++)
      cin >> x.at(i).at(j);
  for(int i = 0; i < n - 1; i++) {
    for(int j = i + 1; j < n; j++) {
      t = 0;
      for(int k = 0; k < d; k++)
        t += (x.at(i).at(k) - x.at(j).at(k)) * (x.at(i).at(k) - x.at(j).at(k));
      if(t == (int)pow((int)sqrt(t), 2))
        o++;
    }
  }
  cout << o << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    string s;
    cin >> n >> s;
    FOR(i, 0, s.size() - 1)
    {
        int t = s[i];
        t = t + n;
        if(t > 'Z') t = 'A' + (t + n) % ('Z' + n + 1);
        cout << char(t);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, i, j, k, ans=0;
    cin >> n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                ans+=__gcd(__gcd(i,j),k);

            }
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	int m;cin>>m;
	vector<int> x;
	for(int i=0;i<m;i++)
	{
		int k;cin>>k;
		x.push_back(k);
	}
	sort(x.begin(),x.end());
	vector<int> dif;
	for(int i=0;i<m-1;i++)
	{
		dif.push_back(x[i+1]-x[i]);
	}
	sort(dif.begin(),dif.end());
	int ans=0;
	for(int i=0;i<m-n;i++)
	{
		ans+=dif[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
fn main() {
	let mut line = String::new();
	std::io::stdin().read_line(&mut line).unwrap();
	let n: u16 = line.trim().parse().unwrap();
	for i in 3..n+1 {
		if i%3 == 0 ||
			match i.to_string().find('3') {
				Some(_) => true,
				None => false,
			}
		{
			print!(" {}", i);
		}
	}
	println!("");
}


Measured memory_bytes: 5036
import math
A, B, H, M = map(int, input().split())

if 30 * H == 6 * M + (30 * M / 60):
    kakudo = 0
elif 30 * H > 6 * M + (30 * M / 60):
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H < 6 * M + (30 * M / 60):
    kakudo = 6 * M - 30 * H - (30 * M / 60)

if kakudo > 180:
    kakudo = 360 - kakudo

ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(kakudo))

print(ans ** (1/2))

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

int main(){
    int N; cin >> N;
    int X=N;
    int sum=0;
    while(X>0){
        sum +=(X%10);
        X/=10;
    }
    if(N%sum) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1111];
int main()
{
	int n,k,ba=0;
	cin>>n>>k;
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
	}
	sort(a,a+n);
	for(int t=0;t<k;t++)
	{
		ba+=a[t];
	}
	cout<<ba;
	return 0;
}

Measured memory_bytes: 3640
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = (int)1e5+5;

long long a[N], ans[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	long long sum = a[n-1];
	int cnt = 0;
	for(int i=n-2; i>=0; i--) {
		if(cnt % 2 == 0) sum -= a[i];
		else sum += a[i];
		cnt++;
	}
	ans[0] = sum;
	for(int i=0; i<n-1; i++) {
		ans[i+1] = (a[i] - ans[i]/2)*2;
	}
	for(int i=0; i<n; i++) cout << ans[i] << " ";
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

int tdist[100001];
int adist[100001];
vector<int> va;
vector<int> adj[100001];

void dfs(int cur, int pre, bool f)//false takahashi, true aoki
{
  for(int i = 0; i < adj[cur].size(); i++)
    if(adj[cur][i] != pre)
    {
      if(f)
        adist[adj[cur][i]] = adist[cur] + 1;
      else
        tdist[adj[cur][i]] = tdist[cur] + 1;
      
      dfs(adj[cur][i], cur, f);
    }
}

int main()
{
  FILE *inF, *outF;
  //inF = fopen("in", "r");
  //outF = fopen("out", "w");
  inF = stdin;
  outF = stdout;
  
  int n, u, v;
  fscanf(inF, "%d %d %d", &n, &u, &v);
  
  for(int i = 0; i < n-1; i++)
  {
    int a, b;
    fscanf(inF, "%d %d", &a, &b);
    
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  tdist[u] = 0;
  adist[v] = 0;
  
  dfs(u, -1, false);
  dfs(v, -1, true);
  
  for(int i = 1; i <= n; i++)
    va.push_back(i);
  
  sort(va.begin(), va.end(), [](int a, int b) -> bool {
    return adist[a] > adist[b];
  });
  
  //printf("%daa\n", adist[4]);
  
  for(int i = 0; i < n; i++)
    if(adist[va[i]] > tdist[va[i]])
    {
      printf("%d", adist[va[i]] - 1);
      break;
    }
  
  return 0;
}


Measured memory_bytes: 13564
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,x,y;
  cin >> n;
  vector<pair<int,int>> pts;
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    pts.emplace_back(x,y);
  }
  map<pair<int,int>,int> cnt;
  for(int i = 0; i < n; ++i){
    for(int j = i+1; j < n; ++j){
      int x = pts[i].first-pts[j].first;
      int y = pts[i].second-pts[j].second;
      ++cnt[make_pair(x,y)];
      ++cnt[make_pair(-x,-y)];
    }
  }
  int tot = 0;
  for(auto& p : cnt) tot = max(tot,p.second);
  cout << n-tot;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int N,A,B;
	cin>>N;
	if (N==1)
	{
		puts("Hello World");
		return 0;
	}
	cin>>A>>B;
	printf("%d\n",A+B);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    if (d.at(n / 2 - 1) == d.at(n / 2)) {
        cout << 0 << endl;
    }
    else cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

lint culc(lint a,lint b){
	lint ret=(a+b-1)/b;
	return ret-1;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	int n;
	in(n);
	vlint table(n+1,1);
	for(int i=2;i<=n;i++){
		for(int j=i;j<=n;j+=i)table[j]+=1;
	}
	lint ans=0;
	arep(i,1,n+1){
		ans+=table[i]*i;
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 81316
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],R[2<<17];
/*dfs1(u,p,i)
{
	dp1[u]=1;
	for(i=first[u];i;i=next[i])eb[i]-p?dfs1(eb[i],u),dp1[u]=dp1[u]*-~dp1[eb[i]]%M:0;
}*/
dfs1(u,p,i,I)
{
	dp1[u]=1;
	for(i=first[u];I=eb[i];i=next[i])I-p?dfs1(I,u),dp1[u]=dp1[u]*-~dp1[I]%M:0;
}
/*dfs2(u,p,x,i)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p,x);
	for(;i;i=next[i])
	{
		if(eb[i]!=p)dfs2(eb[i],u,L[i]*R[next[i]]%M+1);
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]-p?-~dp1[eb[i]]:1;
		make(x=next[i],p,t%M*x%M);
		R[i]=R[x]*t%M;
	}
}*/
/*
dfs2(u,p,x,i)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p);
	for(;i;i=next[i])eb[i]-p?dfs2(eb[i],u,R[next[i]]*x%M+1),x=x%M*-~dp1[eb[i]]%M:0;
}
*/
/**/
dfs2(u,p,x,i,I)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p);
	for(;I=eb[i];i=next[i])I-p?dfs2(I,u,R[next[i]]*x%M+1,0,0),x=x%M*-~dp1[I]%M:0;
}
/**/
make(i,p)
{
	if(i)
	{
		make(next[i],p);
		R[i]=R[next[i]]*(eb[i]-p?-~dp1[eb[i]]:1)%M;
	}
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v,i++:(n=u,M=v);
	for(;~scanf("%d%d",&u,&v);i++)i++?ea[i-1]=eb[i]=u,ea[i]=eb[i-1]=v:(n=u,M=v);
	for(;--i;first[ea[i]]=i)next[i]=first[ea[i]];
	dfs1(*R=1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool check(vector<ll> &a, int idx) {
	ll sum=0, n=a.size();
	for (int i=0; i<=idx; i++)
		sum+=a[i];
	for (int i=idx+1; i<n; i++) {
		if(sum*2<a[i])
			return false;
		sum+=a[i];
	}
	return true;
}
 
int main() {
	int n; cin>>n;
	vector<ll> a(n);
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	int l=0, r=n-1;
	while(l<r){
		int mid=(l+r)/2;
		if(check(a,mid)) r=mid;
		else l=mid+1;
	}
	cout<<n-l<<"\n";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N<=111) {
    cout << 111 << endl;
  }
  else if (112<=N && N<=222) {
    cout << 222 << endl;
  }
  else if (223<=N && N<=333) {
    cout << 333 << endl;
  }
  else if (334<=N && N<=444) {
    cout << 444 << endl;
  }
  else if (445<=N && N<=555) {
    cout << 555 << endl;
  }
  else if (556<=N && N<=666) {
    cout << 666 << endl;
  }
  else if (667<=N && N<=777) {
    cout << 777 << endl;
  }
  else if (778<=N && N<=888) {
    cout << 888 << endl;
  }
  else {
    cout << 999 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a[100005];
int b[200005];
int le;
int mid;
int main(void){
	int n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	//priority_queue<int> pque;
	b[100000]=a[0];
	b[99999]=-1;
	le=99998;
	for(int i=0;i<=99998;i++){
		b[i]=1000000007;
	}
	for(int i=1;i<n;i++){
		int l=le; int r=100001;
		while(r-l>1){
			mid=(l+r)/2;
			if(b[mid]>=a[i]){
				r=mid;
			}else{
				l=mid;
			}
		}
		//cout<<l<<endl;//" "<<le<<endl;
		if(l-1==le){
			b[l]=a[i];
			le--;
			b[le+1]=-1;
		}else{
			b[l]=a[i];
		}
		for(int i=le;i<=100000;i++){
			//cout<<b[i]<<" ";
		}
		//cout<<endl;
	}
	//cout<<le<<endl;
	cout<<100000-le-1<<endl;
	
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int w,h,n,x1=0,x2,y1=0,y2;
    int x[100],y[100],a[100];
    cin>>w>>h>>n;
    x2=w;
    y2=h;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>a[i];
        if(a[i]==1&&x1<x[i]){
            x1=x[i];
        }
        if(a[i]==2&&x2>x[i]){
            x2=x[i];
        }
        if(a[i]==3&&y1<y[i]){
            y1=y[i];
        }
        if(a[i]==4&&y2>y[i]){
            y2=y[i];
        }
    }
    if(y1<y2&&x1<x2){
        cout<<(x2-x1)*(y2-y1);
    }
    else{
        cout<<0;
    }
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc122/tasks/abc122_c

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

question = []
for _ in range(q):
    l, r = map(int, input().split())
    question.append((l - 1, r - 1))

nums = [0] * n
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        nums[i] = 1

for i in range(n - 1):
    nums[i + 1] += nums[i]

for l, r in question:
    ans = nums[r] - nums[l]
    print(ans)

Measured memory_bytes: 84924
n=int(input())
ans=10**6
for i in range(1,n+1):
    a=i
    b=n-i
    if a<=b:
        asum=sum(map(int,str(a)))
        bsum=sum(map(int,str(b)))
        if ans>(asum+bsum):
            ans=asum+bsum
print(ans)

Measured memory_bytes: 3060
import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


X = readint()

ans = 0
c = 100
while c < X:
    c *= 1.01
    c = int(c)
    ans += 1

print(ans)


Measured memory_bytes: 9124
#pragma region template

#include <bits/stdc++.h>
using namespace std;

// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
inline T udiv(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
inline T rdiv(T a, T b) {
    return (a + b / 2) / b;
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        // cin.tie(0);
        // ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans = 0;
#pragma endregion

void solve(long long A, long long B) {
    if (A < B * 2)
        ans = 0;
    else
        ans = A - B * 2;
}
signed main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    print(ans);
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
A = [[0] for j in range(n)]
b = [[0] for k in range(m)]

for i in range(n):
    A[i] = list(map(int, input().split()))
for j in range(m):
    b[j] = int(input())

count = 0
for i in range(n):
    for j in range(m):
        count += A[i][j] * b[j]
    print(count)
    count = 0


Measured memory_bytes: 6028
#include <bits/stdc++.h>
using namespace std;
int N;
vector<pair<int,int>> A;
int main() {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++ i) {
		int x;
		cin >> x;
		A[i] = {x, i};
	}
	sort(A.begin(), A.end());
	int r = 0;
	for (int i = 0; i < N; ++ i) {
		if (A[i].second % 2 != i % 2) ++ r;
	}
	cout << r / 2 << endl;
}


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

int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	if (n >= k) {
		cout << k * x + (n - k) * y << endl;
	}
	else {
		cout << n * x << endl;
	}

	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int a[200010];
 int ans[200010];
 int main(){
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }

Measured memory_bytes: 5248
n, m = map(int, input().split())
List = [0]*(n+1)
ans=0
for i in range(m):
    l, r = map(int, input().split())
    List[l-1]+=1
    List[r]-=1
if List[0]==m:
    ans+=1
for i in range(1, n):
    List[i]+=List[i-1]
    if List[i]==m:
        ans+=1
print(ans)

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

using namespace std;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for(auto a : v)
        os << a << " ";
    os << "]";
    return os;
}

int main() {
    cout << fixed << setprecision(0);
    double N, X, T;
    cin >> N >> X >> T;
    cout << T * ceil(N / X) << endl;
    return 0;
}

Measured memory_bytes: 3756
l,r=map(int,input().split())
ans=10**9+7
if l==0 or (r-l>=2019):
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans=min(ans,(i%2019)*(j%2019)%2019)
    print(ans)

Measured memory_bytes: 3060
a, b, k = gets.split.map(&:to_i)
k.times do |i|
  if i.even?
    a -= 1 if a.odd?
    a /= 2
    b += a
  else
    b -= 1 if b.odd?
    b /= 2
    a += b
  end
end
puts "#{a} #{b}"

Measured memory_bytes: 14324
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define MP(X,Y) make_pair(X,Y)
#define PB(X) push_back(X)
#define REP(X,N) for(int X=0;X<N;X++)
#define REP2(X,L,R) for(int X=L;X<=R;X++)
#define DEP(X,R,L) for(int X=R;X>L;X--)
#define DEP2(X,R,L) for(int X=R;X>=L;X--)
#define CLR(A,X) memset(A,X,sizeof(A))
#define IT iterator
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<int> VI;
#define X first
#define Y second
#define lson(X) ((X)<<1)
#define rson(X) ((X)<<1|1)
const int MAXN=1e7+5;


int phi[MAXN];
void eular(){
 	for(int i = 0; i<MAXN;i++) phi[i] = 1;
 	for(int i = 2; i<MAXN;i++)
 		if(phi[i] == 1)
 			for(int j = i+i;j<MAXN;j+=i)
 				phi[j] = 0;
 }
 
 
 int main(){
 	eular();
 	int n;
 	while(cin>>n)
 	{
 		int cnt=0;
 		REP2(i,2,n){
 			if(phi[i]) cnt++;
 		}	
 		cout<<cnt<<endl;
 		
	}
 	
 	
 	return 0;
 }

Measured memory_bytes: 40220
#include <stdio.h>
#include <float.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double r=0;
    double x=0,y =0;
    scanf("%lf",&r);
    x = r*r*M_PI;
    y = (r+r)*M_PI;
    printf("%lf %lf\n",x,y);
    
    return 0;
}

Measured memory_bytes: 648
n,k = map(int,input().split())
ans = 0
flag = False
prob = 1

for i in range(1,n+1):
  flag = False
  if i >= k:
    ans += 1/n
  else:
    while flag == False:
      prob *= 1/2
      i *= 2
      if i >= k:
        ans += prob/n
        flag = True
        prob = 1
print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner input  = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = input.nextInt();
		}
		System.out.println(func(n,arr,k));
	}
	static int func(int n,int arr[],int k) {
		int dp[] = new int[n];
		dp[0] = 0;
		for(int i=1;i<n;i++) {
			int ans = Integer.MAX_VALUE;
			for(int j=1;j<=k;j++) {
				if(i-j>=0) {
					ans = Math.min(ans,Math.abs(arr[i]-arr[i-j])+dp[i-j]);
				}
			}
			dp[i] = ans;
		}
		return dp[n-1];
	}
}


Measured memory_bytes: 50824
#include <stdio.h>
#define N 500001

int h,A[N];

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,largest,t;
  l = left(i);
  r = right(i);
  if(l<=h && A[l]>A[i]) largest = l;
  else largest = i;
  if(r<=h && A[r]>A[largest]) largest = r;
  if(largest != i){
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }
  for(i=h/2;i>=1;i--) maxHeapify(i);
  
  for(i=1;i<=h;i++){
    printf(" %d",A[i]);
  }
   printf("\n");
  return 0;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e3+20;
ll n,A,x[N];
ll dp[60][N];
int main()
{
	while(cin>>n>>A)
	{
		for(int i=1;i<=n;i++)
			cin>>x[i];
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int k=1;k<=n;k++)
		{
			for(int i=k;i>=1;i--)
			{
				for(int j=2500;j>=x[k];j--)
				{
					//dp[k][i][j]=dp[k-1][i][j]+dp[k-1][i-1][j-x[k]]
					if(j>=x[k])
						dp[i][j]=dp[i][j]+dp[i-1][j-x[k]];					
				}
			}
		}
		ll ans=0;
		for(int i=1;i<=n;i++)
			ans+=dp[i][i*A];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#dp[i]:i番目にたどり着くまでのコストの最小値
#dp[i] = min(dp[i-1]+abs(h[i]-h[i-2]), 
#dp[i-2]+abs(h[i]-h[i-1]))
#i番目にたどり着くのにi-1かi-2の辿ってきた総和が、小さい方から移動
N = int(input())
h = list(map(int, input().split()))

inf = 10*18
dp = [inf for i in range(N)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2, N):
    ab1 = abs(h[i]-h[i-2])
    ab2 = abs(h[i]-h[i-1])
    dp[i] = min(dp[i-2] + ab1, dp[i-1] + ab2)

print(dp[N-1])   

Measured memory_bytes: 13980
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
const int MAXN = 100010;
const int MOD = 998244353;
int _w;

int n, m, up[MAXN], down[MAXN], left[MAXN], right[MAXN];

namespace NT {
	int fac[MAXN*3], ifac[MAXN*3];
	int fpow( int a, int b ) {
		int c = 1;
		while(b) {
			if( b & 1 ) c = int((ll)c * a % MOD);
			a = int((ll)a * a % MOD);
			b >>= 1;
		}
		return c;
	}
	int inv( int a ) {
		return fpow(a, MOD-2);
	}
	void prelude() {
		fac[0] = 1;
		for( int i = 1; i < MAXN*3; ++i )
			fac[i] = int((ll)fac[i-1] * i % MOD);
		ifac[MAXN*3-1] = inv(fac[MAXN*3-1]);
		for( int i = MAXN*3-1; i > 0; --i )
			ifac[i-1] = int((ll)ifac[i] * i % MOD);
	}
	int C( int n, int m ) {
		return int((ll)fac[n] * ifac[m] % MOD * ifac[n-m] % MOD);
	}
}
using NT::C;

int calc( int a, int b, int c ) {
	return a ? C(a+b+c-1, a-1) : (b+c ? 0 : 1);
}

int solven() {
	int ltot = 0, rtot = 0, utot = 0, dtot = 0, uc = 0, dc = 0;
	for( int i = 1; i <= n; ++i )
		ltot += left[i], rtot += right[i];
	for( int i = 1; i <= m; ++i )
		utot += up[i], dtot += down[i];
	// printf( "ltot = %d, rtot = %d, utot = %d, dtot = %d\n", ltot, rtot, utot, dtot );
	int ans = 0, sl = 1;
	for( int R = 1; R <= m; ++R ) {
		if( !up[R] && !down[R] ) continue;
		if( up[R] && down[R] ) sl = (sl<<1) % MOD;
		ans = int(ans + (ll)sl * calc(rtot, utot-uc-up[R], dtot-dc-down[R]) % MOD) % MOD;
		uc += up[R], dc += down[R];
		sl = (sl + calc(ltot, uc, dc)) % MOD;
	}
	// printf( "solven = %d\n", ans );
	return ans;
}

int solvem() {
	int utot = 0, dtot = 0, ltot = 0, rtot = 0, lc = 0, rc = 0;
	for( int i = 1; i <= m; ++i )
		utot += up[i], dtot += down[i];
	for( int i = 1; i <= n; ++i )
		ltot += left[i], rtot += right[i];
	int ans = 0, su = 1;
	for( int D = 1; D <= n; ++D ) {
		if( !left[D] && !right[D] ) continue;
		if( left[D] && right[D] ) su = (su<<1) % MOD;
		ans = int(ans + (ll)su * calc(dtot, ltot-lc-left[D], rtot-rc-right[D]) % MOD) % MOD;
		lc += left[D], rc += right[D];
		su = (su + calc(utot, lc, rc)) % MOD;
	}
	// printf( "solvem = %d\n", ans );
	return ans;
}

int main() {
	NT::prelude();
	_w = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= n; ++i ) {
		char ch;
		_w = scanf( " %c", &ch );
		left[i] = ch - '0';
	}
	for( int i = 1; i <= n; ++i ) {
		char ch;
		_w = scanf( " %c", &ch );
		right[i] = ch - '0';
	}
	for( int i = 1; i <= m; ++i ) {
		char ch;
		_w = scanf( " %c", &ch );
		up[i] = ch - '0';
	}
	for( int i = 1; i <= m; ++i ) {
		char ch;
		_w = scanf( " %c", &ch );
		down[i] = ch - '0';
	}
	printf( "%d\n", max((solven() + solvem()) % MOD, 1) );
	return 0;
}


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

int main(){

  int n,m;
  
  while(scanf("%d %d",&n,&m),n+m != 0){

    int q;
    int Q[100]={0};
    vector< pair<int,int> > vp;
    for(int i=0; i < n; i++){
      for(int j=0; j < m; j++){
	scanf("%d",&q);
	if(q) Q[j]++;
      }
    }
    
    for(int i=0;i < m; i++)
      vp.push_back(make_pair(-Q[i],i+1));

    sort(vp.begin(),vp.end());
    for(int i=0; i < m; i++){
      if(i) printf(" ");
      printf("%d",vp[i].second);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 2580
N, K=map(int, input().split())
A=list(map(int, input().split()))
sa=set(A)
if len(sa)<=K:
  print(0)
else:
  # 書き換える要素の種類数
  sub=len(sa)-K
  # 少ないやつを書き換えたい
  A.sort()
  A.append(A[-1])
  a=[0]*len(sa)
  j=0
  for i in range(N):
    a[j]+=1
    if A[i]!=A[i+1]:
      j+=1
  
  a.sort()
  print(sum(a[:sub]))

Measured memory_bytes: 27012
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };


int main()
{
  int N;
  cin >> N;
  vll a(N);
  rep(i,N){
      cin >> a[i];
  }

  int count=0;
  ll minNum=LLINF;
  rep(i,N){
    if(a[i] < 0) count++;
    minNum = min(minNum,abs(a[i]));
  }
  //一旦中身を捨てて、全部＋－で考えてみると、ーが偶数なら全部＋できて、奇数なら絶対値で一番小さい奴を引けばいい
  ll sum=0;
  if(count%2==0){
      for(auto x:a){
          sum += abs(x);
      }
  }else{
      for(auto x:a){
          sum += abs(x);
      }
      sum-=minNum*2;//たとえば[3,4,5]だとすると12となっているが3は-にしなければいけないので[-3,4,5]となる、その場合6
  }

  fin(sum);


}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1168&lang=jp
typedef pair<int, int> pii;
typedef pair<int, double> pid;
const int INF = 1e9;
const double eps = 1e-9;
struct piece {
	int idx;
	int xl, xr;
	vector<pii> loc;
	double g;
	vector<int> next_piece;
	piece(): loc(4),idx(0),g(0.0),xl(-INF),xr(INF) {}
	void add_next(int nextidx) { this->next_piece.push_back(nextidx); }
	void init_loc(int x, int y) {
		loc[idx++] = { y,x };
		if (idx == 4) this->calc_gx();
	}
	void calc_gx() {
		for (int i = 0; i < 4;i++) {
			g += (0.5 + (double)loc[i].second);
		}
		g /= 4.0;
	}
	void calc_xlr(int x) {
		if (xl == -INF) {
			xl = x; xr = x + 1;
		}
		else {
			xl = min(xl, x); xr = max(xr, x + 1);
		}
	}
};

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

void calc_piece(int x, int y,int idx,vector<piece>& p, vector<vector<char>>&m, vector<vector<int>>& used) {
	used[y][x] = idx;
	if (idx == (int)p.size()) {
		p.push_back(piece());
	}
	p[idx].init_loc(x, y);
	for (int i = 0; i < 4;i++) {
		int ny = y + dy[i], nx = x + dx[i];
		if (m[ny][nx] == '#' || m[ny][nx] == '.')continue;
		if (used[ny][nx] != -1 && i == 1) {
			if (used[ny][nx] != idx)p[used[ny][nx]].calc_xlr(x);
		}
		if (used[ny][nx] != -1)continue;
		if (m[ny][nx] == m[y][x]) {
			calc_piece(nx, ny, idx, p, m, used);
		}
		else if (i == 1) {
			p[idx].add_next((int)p.size());
			calc_piece(nx, ny, (int)p.size(), p, m, used);
			p[used[ny][nx]].calc_xlr(x);
		}
	}
}

/* return { mass , center of gravity }*/
pid solve(int idx, vector<piece>& p) {
	int m = 4;
	double g = p[idx].g;
	double mg = m*g;
	for (int next : p[idx].next_piece) {
		auto up = solve(next, p);
		if (up.second > INF) {
			return make_pair(1, (double)(INF + 1.0));
		}
		m += up.first;
		mg += up.first * up.second;
	}
	double ret_g = mg / (double)m;

	if (ret_g - p[idx].xl > 0 && p[idx].xr - ret_g > 0) {
		return make_pair(m, ret_g);
	}
	else {
		return make_pair(1, (double)(INF + 1.0));
	}
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int w, h;
	while (cin >> w >> h, w | h) {
		vector<piece> p;
		vector<vector<char>> m(h + 2, vector<char>(w + 2, '#'));
		vector<vector<int>> used(h + 2, vector<int>(w + 2, -1));
		for (int i = h; i >= 1; i--)for (int j = 1; j <= w;j++)cin >> m[i][j];
		for (int i = 1; i <= w;i++) {
			if (m[1][i] == '.')continue;
			if (used[1][i] != -1) {
				p[0].calc_xlr(i);
				continue;
			}
			calc_piece(i, 1, (int)p.size(), p, m, used);
			p[0].calc_xlr(i);
		}
		
		auto Ans = solve(0, p);
		if (Ans.second > INF) {
			cout << "UNSTABLE" << endl;
		}
		else {
			cout << "STABLE" << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 1000000000000000000;
 
using namespace std;

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

void solve()
{
    int x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}   

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n; cin >> n;
    vector<string> out = {
        "pon", "pon", "hon", "bon", "hon",
        "hon", "pon", "hon", "pon", "hon"
        };
    
    cout << out[n%10] << endl;
    return 0;
}

Measured memory_bytes: 3604
import numpy as np

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

N = int(input())
A = np.array([int(x) for x in input().split()],dtype=object)
gcd = np.frompyfunc(gcd,2,1)

print(gcd.reduce(A))


Measured memory_bytes: 23124
// Atcoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k; cin >> n >> k;
	vector<int>a(n);
	for (int& ele : a)cin >> ele;
	sort(a.begin(), a.end()); int ans = 0;
	for (int i = 0; i < k; ++i) {
		ans += a[i];
	}
	cout << ans;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int D, N; 
  cin >> D >> N;

  cout << ((N != 100)? N: 101)*(int)pow(100, D) << "\n";

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
N = int(input())
h = list(map(int, input().split()))
memo = [-1]*N
def dp(i):
    if memo[i]>=0:
        return memo[i]
    if i == 0:
        memo[i] = 0
        return 0
    if i>=2:
        memo[i] = min(dp(i-1)+abs(h[i]-h[i-1]), dp(i-2)+abs(h[i]-h[i-2]))
    else:
        memo[i] = dp(i-1)+abs(h[i]-h[i-1])
    return memo[i]
print(dp(N-1))



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

int main() {

  int N;
  cin >> N;

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

  sort(d.begin(), d.end());

  int start = N / 2 - 1;
  int end = N / 2;

  int answer = d[end] - d[start];

  cout << answer << endl;

  return 0;

}

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

int a[200005];
int main()
{
    int n, m, i, j=0,mn=10000000;
    cin>>n;
    for(i=1; i<=n; i++) cin>>a[i];
    for(i=1; i<=n; i++){
            if(mn>=a[i])j++;
        mn=min(mn,a[i]);
    }
    cout<<j<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define INRANGE(a,b,c) ((((a)<=(b))&&((b)<=(c)))?(1):(0))
int number[6][8];
int check(int d,int r){
	int a=0;
	switch (d) {
		case 100:
		case 200:
		case 300:
		case 400:
		case 500:
			a+=2;
			break;
	}
	switch (r) {
		case 0:
		case 30:
		case 60:
		case 90:
		case 120:
		case 150:
		case 180:
			return a+3;
			break;
	}
	return a;
}

int main(void){
	int n;
	cin>>n;
	int d,r;
	for(int i=1;i<=5;i++){
		for(int j=1;j<=7;j++){
			number[i][j]=i*1+(j-1)*5;
		}
	}
	int i,j;
	while(n--){
		cin>>d>>r;
		if(check(d,r)==0){
			// 4
			for(i=0;i<180;i+=30){
				if(INRANGE(i,r,i+30)) break;
			}
			for(j=100;j<500;j+=100){
				if(INRANGE(j,d,j+100))break;
			}
			// max=j/100+1&&(i+30)/30+1
			j=j/100;
			i=(i+30)/30+1;
			cout<<number[j][i-1]<<" "<<number[j+1][i-1]<<" "<<number[j][i]<<" "<<number[j+1][i]<<endl;
		}else if(check(d,r)==2||check(d,r)==3){
			// 2
			if(check(d,r)==2){
				j=d/100;
				for(i=0;i<180;i+=30){
					if(INRANGE(i,r,i+30)) break;
				}
				i=(i+30)/30+1;
				cout<<number[j][i-1]<<" "<<number[j][i]<<endl;
			}else{
				for(j=100;j<500;j+=100){
					if(INRANGE(j,d,j+100))break;
				}
				j=j/100;
				i=(r+30)/30;
				cout<<number[j][i]<<" "<<number[j+1][i]<<endl;
			}
		}
		else{
			// 1
			cout<<number[d/100][(r+30)/30]<<endl;
		}
	}
}

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

int main(){
    int H, N;
    cin >> H >> N;
    int sum = 0;
    for(int i =0; i < N; i++){
        int a;
        cin >> a;
        sum += a;
    }
    if(sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    cur_x = 0
    cur_y = 0
    cur_t = 0
    can_travel = True
    for _ in range(n):
        next_t, next_x, next_y = list(map(int, input().split(" ")))
        time_diff = abs(next_t - cur_t)
        xy_diff = abs(next_x - cur_x) + abs(next_y - cur_y)

        if time_diff < xy_diff:
            can_travel = False
        elif time_diff > xy_diff:
            can_travel = ((time_diff - xy_diff) % 2 == 0)

        if not can_travel:
            break
        cur_t, cur_x, cur_y = next_t, next_x, next_y

    print("Yes" if can_travel else "No")



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

int main() {
  int x,y;
  cin >>x>>y;
  if(x>=0&&y>=0){
    if(x<=y)cout<<y-x<<endl;
    else {
      if(y==0)cout<<x-y+1<<endl;
      else cout<<x-y+2<<endl;
    }
  }else if(x>=0&&y<0){
    if(x <abs(y))cout<<abs(y)-x+1<<endl;
    else cout<<x-abs(y)+1<<endl;
  }else if(x<0&&y>=0){
    if(abs(x) <y)cout<<y-abs(x)+1<<endl;
    else if(y==0)cout<<abs(x)<<endl;
    else cout<<abs(x)-y+1<<endl;
  }else{
    if(abs(x)<abs(y))cout<<abs(y)-abs(x)+2<<endl;
    else cout<<abs(x)-abs(y)<<endl;
  }
  return 0;
}
    
       
  

Measured memory_bytes: 3564