akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> a(N);
	for (auto &x : a) cin >> x;

	vector<long long> s(N);
	partial_sum(a.begin(), a.end(), s.begin());

	long long ans = numeric_limits<long long>::max();
	for (int i = 0; i + 1 < N; ++i) {
		long long x = s[i];
		long long y = s[N - 1] - s[i];
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,count = 0;
  int p[30];
  cin >> n;
  for(int i=0; i<n; i++) cin >> p[i];
  for(int i=1; i<n-1; i++){
    if(p[i-1] < p[i] && p[i] < p[i+1]) count++;
    else if(p[i+1] < p[i] && p[i] < p[i-1]) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 10000000;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main() {
  ll n;
  cin>>n;
  ll in[n][3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>in[i][j];
    }
  }
  vecllvec dp(n+1,vecll(3,0));
  for(int i=1;i<=n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k) continue;
        dp[i][j]=max(dp[i][j],dp[i-1][k]+in[i-1][j]);
      }
    }
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,m,q;
  cin>>n>>m>>q;
  vector<string> t(n+2);
  for(int i:irange(0,n)) {
    string s;
    cin>>s;
    t[i+1] = "0" + s + "0";
  }
  t[0] = t[n+1] = string(m+2, '0');
  vector<vecint> connects_v(n, vecint(m+1));
  vector<vecint> connects_h(n+1, vecint(m));
  for(int i:irange(0,n)) {
    for (int j:irange(0,m+1)) {
      bool left = t[i+1][j] == '1';
      bool right = t[i+1][j+1] == '1';
      if (left && right) {
        connects_v[i][j] = 1;
      }
    }
  }
  for (int i:irange(0,n+1)) {
    for (int j:irange(0,m)) {
      bool top = t[i][j+1] == '1';
      bool bottom = t[i+1][j+1] == '1';
      if (top && bottom) {
        connects_h[i][j] = 1;
      }
    }
  }
  vector<vecint> psumcv(n+1, vecint(m+2));
  vector<vecint> psumch(n+2, vecint(m+1));
  for(int i:irange(0,n)) {
    for (int j:irange(0,m+1)) {
      psumcv[i+1][j+1] = psumcv[i][j+1] + connects_v[i][j];
    }
  }
  for (int i:irange(0,n+1)) {
    for (int j:irange(0,m+1)) {
      psumcv[i][j+1] += psumcv[i][j];
    }
  }
  for (int i:irange(0,n+1)) {
    for (int j:irange(0,m)) {
      psumch[i+1][j+1] = psumch[i+1][j] + connects_h[i][j];
    }
  }
  for (int i:irange(0,n+1)) {
    for (int j:irange(0,m+1)) {
      psumch[i+1][j] += psumch[i][j];
    }
  }
  vector<vecint> surfs(n+1, vecint(m+1));
  for (int i:irange(0,n)) {
    for (int j:irange(0,m)) {
      if (t[i+1][j+1] == '1') {
        surfs[i+1][j+1] = 1;
      }
    }
  }
  for (int i:irange(0,n+1)) {
    for (int j:irange(0,m)) {
      surfs[i][j+1] += surfs[i][j];
    }
  }
  for (int i:irange(0,n)) {
    for (int j:irange(0,m+1)) {
      surfs[i+1][j] += surfs[i][j];
    }
  }
  for(int query : irange(0,q)) {
    int x1,y1,x2,y2;
    cin>>y1>>x1>>y2>>x2;
    int connects = 0;
    connects += psumcv[y2][x2] - psumcv[y1-1][x2] - psumcv[y2][x1] + psumcv[y1-1][x1];
    connects += psumch[y2][x2] - psumch[y2][x1-1] - psumch[y1][x2] + psumch[y1][x1-1];
    --y1;--x1;
    int s = surfs[y2][x2] - surfs[y2][x1] - surfs[y1][x2] + surfs[y1][x1];
    int res = s - connects;
    cout<<res<<endl;
  }
  return 0;
}


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

int main()
{
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;

  int x=0, y=0;
  for (auto c:s) {
    bool flg = false;
    if (c=='a') {
      if (x+y < a+b) {
        x++;
        flg = true;
      }
    }
    else if (c=='b') {
      if (x+y < a+b && y < b) {
        y++;
        flg = true;
      }
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

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 replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
/*
// シンプルな構文解析用
typedef string::const_iterator State;
class ParseError {};
//*/
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct Rectangle { int height;  int pos; };

int getLargestRectangle(int size, vi buffer) {
	stack<Rectangle> S;
	int maxv = 0;
	buffer[size] = 0;
	
	for (int i = 0; i <= size; i++) {	//
		Rectangle rect;
		rect.height = buffer[i];
		rect.pos = i;
		if (S.empty()) {
			S.push(rect);
		}
		else {
			if (S.top().height < rect.height) {
				S.push(rect);
			}
			else if (S.top().height > rect.height) {
				int target = i;
				while (!S.empty() && S.top().height >= rect.height) {
					Rectangle pre = S.top(); S.pop();
					int area = ((pre.height + 1) / 2) * ((i - pre.pos + 1) / 2);
					maxv = max(maxv, area);
					target = pre.pos;
				}
				rect.pos = target;
		        S.push(rect);
			}
		}
	}
	return maxv;	
}
int main(void) {
	int H, W;
	cin >> H >> W;
	vs s(H);
	rep(i, H) {
		cin >> s[i];
	}
	map<char, int> mp;
	mp['.'] = 0;
	mp['#'] = 1;
	vvb wall(2 * H - 1, vb(2 * W - 1, false));
	repl(i, 1, H) {
		repl(j, 1, W) {
			if ((mp[s[i][j]] + mp[s[i - 1][j]] + mp[s[i][j - 1]] + mp[s[i-1][j-1]]) % 2 == 1) {
				wall[2 * i - 1][2 * j - 1] = true;
			}
		}
	}
	H = 2 * H - 1;
	W = 2 * W - 1;
	vvi T(H, vi(W + 1, 0));

	rep(j, W) {
		int num = 1;
		rep(i, H) {
			if (wall[i][j]) {
				num = 1;
			}
			else {
				T[i][j] = num;
				num++;
			}
		}
	}
	/*
	rep(i, H) {
		rep(j, W) {
			cout << T[i][j];
		}
		cout << endl;
	}
	*/

	int ans = 0;
	rep(i, H) {
		ans = max(ans, getLargestRectangle(W, T[i]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 69248
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	cin >> n >> m;
	vector<pii> v(n),t(m);
	rep(i,0,n){
		cin >> v[i].first >> v[i].second;
	}
	rep(i,0,m){
		cin >> t[i].first >> t[i].second;
	}
	const int inf = 1e9;
	rep(i,0,n){
		int ans = 0, best = inf;
		rep(j,0,m){
			int d = abs(v[i].first - t[j].first) + abs(v[i].second - t[j].second);
			if(d < best){
				ans = j;
				best = d;
			}
		}
		cout << ans + 1 << '\n';
	}
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> maze(h);
  vector<vector<int>> num(h,vector<int>(w,1e9));
  for(int i=0;i<h;i++) {
    cin >> maze.at(i);
  }
  vector<int> idx={1,0,-1,0};
  vector<int> idy={0,1,0,-1};
  queue<pair<int,int>> q;
  q.push(pair<int,int> (0,0));
  num.at(0).at(0)=0;
  while(q.size()) {
    pair<int,int> temp=q.front();
    q.pop();
    for(int i=0;i<4;i++) {
      int ny=temp.first + idy.at(i);
      int nx=temp.second + idx.at(i);
      if(nx>-1&&ny>-1&&nx<w&&ny<h) {
        if(maze.at(ny).at(nx)=='.'&&num.at(ny).at(nx)==1e9) {
          num.at(ny).at(nx)=num.at(temp.first).at(temp.second)+1;
          q.push(pair<int,int> (ny,nx));
        }
      }
    }
  }
  int count=0;
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      if(maze.at(i).at(j)=='.') {
        count++;
      }
    }
  }
  int ans;
  if(num.at(h-1).at(w-1)==1e9) {
    ans = -1;
  }
  else {
    ans = count-num.at(h-1).at(w-1)-1;
  }
  cout << ans << endl;
}

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

long long fact(long long k){
  long long sum = 1;
  for(long long i = 2; i <= k; i++){
    sum = sum * i % mod;
  }
  return sum;
}

int main(){
  long long N, M;
  cin >> N >> M;
  long long ans;

  if(abs(N - M) >= 2){
    ans = 0;
  }
  else if(abs(N - M) == 1){
    ans = fact(N) * fact(M);
  }
  else{
    ans = (fact(N) * fact(M)) * 2;
  }

  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

typedef struct
{
    ll u, v, w;
} Edge;

int N;
vector<vector<P>> adj;
vector<ll> d;

void dfs(int n, int dist)
{
    d[n] = dist;
    REP(i, adj[n].size())
    {
        if(d[adj[n][i].first] == INF) dfs(adj[n][i].first, dist+adj[n][i].second);
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll N; cin >> N;
    vl A(N+1); REPS(i, N) cin >> A[i];
    vector<vl> T(N+1, vl(3, 0));
    REPS(i, N)
    {
        REP(j, 3)
        {
            T[i][j] = T[i-1][j];
        }
        REP(j, 3)
        {
            if(T[i-1][j] == A[i])
            {
                T[i][j]++;
                break;
            }
        }
    }
    /*
    REP(i, T.size()) 
    {
        REP(j, 3) cout << T[i][j] << " ";
        cout << endl;
    }
    */
    ll ans = 1;
    REPS(i, N)
    {
        int c = 0;
        REP(j, 3) if(T[i-1][j] == A[i]) c++;
        ans *= c;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main() {
	// your code goes here
	map<int,int>mp;
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
	{
	    int q;
	    cin>>q;
	    mp[q]=i;
	}
	for(int i=1;i<=n;++i)cout<<mp[i]<<" ";
}


Measured memory_bytes: 5504
n,m  = map(int,input().split()) 
z = []
for i in range(n):
  a,b = list(map(int,input().split()))
  z.append((a,b))  
z = sorted(z)
sum = 0
for a,b in z:
  if b <= m:
    sum += a * b
    m -= b
  else:
    sum += a * m
    break
print(sum)

Measured memory_bytes: 17736
S = input()

if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif int(S[:2]) >= 0 and 1 <= int(S[2:]) <= 12:
    print("YYMM")
elif int(S[2:]) >= 0 and 1 <= int(S[:2]) <= 12:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#include <stdio.h>

int a[105];
int cnt[10];

int main(){

	int N;

	scanf("%d",&N);

	int i;

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

	for(i=0;i<N;i++){
		if(1<=a[i]&&a[i]<=399){cnt[0]++;}
		else if(400<=a[i]&&a[i]<=799){cnt[1]++;}
		else if(800<=a[i]&&a[i]<=1199){cnt[2]++;}
		else if(1200<=a[i]&&a[i]<=1599){cnt[3]++;}
		else if(1600<=a[i]&&a[i]<=1999){cnt[4]++;}
		else if(2000<=a[i]&&a[i]<=2399){cnt[5]++;}
		else if(2400<=a[i]&&a[i]<=2799){cnt[6]++;}
		else if(2800<=a[i]&&a[i]<=3199){cnt[7]++;}
		else{cnt[8]++;}
	}

	int ans=0;

	for(i=0;i<8;i++){
		if(cnt[i]>0){ans++;}
	}

	if(ans==0){
		printf("%d %d\n",1,cnt[8]);
	}
	else{
		printf("%d %d\n",ans,ans+cnt[8]);
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
 
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int s[200005],t[200005],c[100005];
int res[200005],tmp[200005];
int main(){
     ll n;
     cin>>n;
     ll cnt=n/50;
     ll rem=n%50;
     cout<<50<<"\n";
     for(int i=0;i<50;i++){
          if(i<rem){
               cout<<(i+cnt+50-rem+1);
          }
          else cout<<(i+cnt-rem);
          cout<<" ";
     }
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

int main(){
	
	int n;
	cin>>n;
	int a;
	double ans = 0;
	for (int i=0;i<n;i++){
		cin>>a;
		ans = ans + (1.0/a);
	}
	cout<<setprecision(10);
	cout<<(1.0/ans);
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 5050;

int k, q;
vector<ll> _d;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>k>>q;
  _d.resize(k);
  for (int i=0; i<k; i++) {
    cin>>_d[i];
  }

  while (q--) {
    ll n, first, mod;
    cin>>n>>first>>mod;
    --n; // we only use n-1 "transitions" in array d
    vector<ll> d = _d;
    vector<ll> z(k);
    for (ll& x: d) x %= mod;
    
    for (int i=0; i<k; i++) {
      z[i] = (d[i]==0);
      if (i) z[i] += z[i-1];
    }
    
    for (int i=1; i<k; i++) d[i] += d[i-1];
    first %= mod;
    ll iters = n / k;

    ll zeros = iters*z[k-1] + (n%k>0 ? z[n%k - 1] : 0);
    ll around = first + iters*d[k-1] + (n%k>0 ? d[n%k - 1] : 0);
    ll res = n - zeros - around/mod;
    cout<<res<<"\n";    
  }
  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 384
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int> m;
    int n,ans=0; 
    cin>>n; 
    vi a(n);
    for (int i=0;i<n;i++) {
        cin >> a[i] ; 
        m[a[i]]++;
    }
    for (auto it: m) ans += (it.ss*(it.ss-1))/2 ; 
    for (int i=0;i<n;i++){
        int h=m[a[i]];
        cout << (ans-((h*(h-1))/2)+((h-1)*(h-2))/2) << endl; 
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 12708
// https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll N, A, B;
    scanf("%lld %lld %lld", &N, &A, &B);
    vector<ll> X(N);
    REP(i, N) scanf("%lld", &X[i]);
    ll d = 0;
    ll ans = 0;
    for (int i = 1; i < N; ++i) 
    {
        d = X[i] - X[i - 1];
        if (A * d >= B)
        {
            ans += B;
        }
        else
        {
            ans += A * d;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<=(n);i++)
#define mer(i,m,n) for(int i=(m);i>=(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<long long int> vll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<char> vc;
vector<string> vs;




int main() {
	int MAX = 1000;
	string S, T;
	cin >> S >> T;
	rep(i, 0, S.length() - T.length()) {
		int cnt = 0;
		rep(j, 0, T.length() - 1) {
			if (S.substr(i + j, 1) != T.substr(j, 1))++cnt;
		}
		if (cnt < MAX)MAX = cnt;
	}
	cout << MAX << '\n';

}

Measured memory_bytes: 3632
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        int q = stdIn.nextInt();
 
        for (int i=0; i<q; i++) {
            String com = stdIn.next();
            int a = stdIn.nextInt();
            int b = stdIn.nextInt();
 
            if(com.equals("reverse")){
                String rev = s.substring(a,b+1);
                String temp = s.substring(b+1);
                s = s.substring(0,a);
                for (int index=rev.length()-1; index>=0; index--) {
                    s += rev.charAt(index);
                }
                s += temp;
 
            }else if(com.equals("replace")){
                String p = stdIn.next();
                s = s.substring(0,a) + p + s.substring(b+1);
 
            }else{
                String temp = s.substring(a,b+1);
                System.out.println(temp);
            }
        }
    }
}


Measured memory_bytes: 62400
n, total = gets.chomp.split(" ").map(&:to_i)

xEnd = (total/10000).floor
xEnd = n if xEnd > n
for x in 0..xEnd do
  next if x*10000 + (n-x)*5000 < total

  yEnd = ((total-x*10000)/5000).floor
  yEnd = (n-x) if yEnd > (n-x)
  for y in 0..yEnd do
    z = n-x-y
    if x*10000 + y*5000 + z*1000 == total then
      puts "#{x} #{y} #{z}"
      exit
    end
  end
end
puts "-1 -1 -1"

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {

    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class COneQuadrillionAndOneDalmatians {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        lint N;
        in>>N;
        N--;
        string ans;
        bool flag = true;
        while(N>-1){
            ans += char('a'+N%26);
            N /= 26;
            N--;
        }
        reverse(ALL(ans));
        out<<ans<<'\n';
    }
};


int main() {
	COneQuadrillionAndOneDalmatians solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define mod 1000000007
#define N 200005
using namespace std;
int num[N],a[N],pre[N],bfr[N];
int main()
{
	int n; cin >> n ; bfr[0]=1;
	int cnt=0;
	for(int i=1;i<=n;i++) {scanf("%d",&num[i]); if(num[i]!=num[i-1]||i==1) a[++cnt]=num[i];}
	for(int i=1;i<=cnt;i++)
	{
		int x;
		if(pre[a[i]]) x=bfr[pre[a[i]]];
		else x=0;
		pre[a[i]]=i;
		bfr[i]=(bfr[i-1]+x)%mod;
	}
	cout << bfr[cnt] << endl ;
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <cassert>

using namespace std;

unsigned long long a(unsigned long long N, unsigned long long K){
    return (N-K+1)*K+1;
}

unsigned long long solve(unsigned long long N, unsigned long long K){
    unsigned long long ans=0;
    for(int i=K;i<=N+1;i++){
        unsigned long long temp = a(N, i)%1000000007;
        ans += temp;
        ans %= 1000000007;
        // if(temp<0){
            // cerr << N << " " << K << " " << i << " " << ans << endl;
        // }
    }
    ans %= 1000000007;
    cout << ans << "\n";
    return ans;
}

// class input{
//     public:
//     input(int _A, int _B, int _C, int _X, int _ans){
//         A = _A;
//         B = _B;
//         C = _C;
//         X = _X;
//         ans = _ans;
//     }
//     int A;
//     int B;
//     int C;
//     int X;
//     int ans;
// };

// int solve(input key){
//     return solve(key.A, key.B, key.C, key.X);
// }

int main(){
    int N, K;
    bool use_stdin = true;
    // use_stdin = false;
    if(use_stdin){    
        cin >> N >> K;
        solve(N, K);
    }else{
        // input keys[] = {
        //     {30,40,50,6000,213},
        //     {5,1,0,150,0},
        //     {2,2,2,100,2}
        // };
        // for(auto key:keys){
        //     assert(solve(key)==key.ans);
        // }
    }
    return 0;
}

Measured memory_bytes: 3636
k = int(input())

shou = k//50
amari = k%50

a = str(49-k+shou*51)
b = str(100-k+shou*51)

n = []

for i in range(amari):
    n.append(b)

for i in range(50-amari):
    n.append(a)

print('50')
nstr = ' '.join(n)
print(nstr)


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

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

    if(a-b>=0){
        cout<<"delicious"<<endl;
    }
    else if(a-b>=-x){
        cout<<"safe"<<endl;
    }
    else{
        cout<<"dangerous"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,m; cin >> n >> m;
    vector<pair<int, int>> h(m);
    rep(i,m) cin >> h[i].second >> h[i].first;
    sort(ALL(h));
    //vector<int> b(n-1, 1);
    int ans = 0;
    int done = 0;

    rep(i,m){
        if(i == 0){
            ans++;
            done = (h[0].first)-1;
            continue;
        }
        if(done >= h[i].second) continue;
        ans++;
        done = (h[i].first)-1;
    }

    cout << ans << endl;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, a[11];

int main(){
	cin >> n;
	int ans=1;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if((a[i]+10)%2==0){
			ans*=2;
		}
	}
	cout << int(pow(3,n)-ans) << endl;
	return 0;
}

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

int main(void){ 
    int n, cnt = 0, max = 0;
    cin >> n;
    vector<int> a1(n), a2(n);
    for(int i=0; i<n; i++){
        cin >> a1[i];
        if(a1[i] > max) max = a1[i];
    }
    vector<int> count(max+1);
    for(int i=0; i<n; i++) count[a1[i]]++;
    for(int i=1; i<=max; i++) count[i] += count[i-1];
    for(int i=0; i<n; i++){
        a2[count[a1[i]]-1] = a1[i];
        count[a1[i]]--;
    }
    vector<bool> p(max+1);
    for(int i=0; i<n; i++){
        if(p[a2[i]]) continue;
        cnt++;
        if(i != n-1 && a2[i] == a2[i+1]) cnt--;
        for(int t=a2[i]; t<=max; t+=a2[i]) p[t] = true;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 8780
#include<bits/stdc++.h>
#define nl '\n'
#define vi vector<long int>
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define int long int
using namespace std;

signed main(){
    ios;
    string s,t;
    cin>>s>>t;
    string ans="";
    int arr[s.length()+1][t.length()+1];
    for(int i=0;i<=s.length();i++){
        for(int j=0;j<=t.length();j++){
            if(i==0 or j==0) arr[i][j]=0;
            else if(s[i-1]==t[j-1]) {
                arr[i][j]=1+arr[i-1][j-1];
            }
            else {
                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
            }
        }
    }
//    for(int i=0;i<=s.length();i++){
//        for(int j=0;j<=t.length();j++){
//            cout<<arr[i][j]<<" ";
//        }
//        cout<<nl;
//    }
    int i=s.length();
    int j=t.length();
    while(i>0 and j>0){
        if(arr[i][j]=arr[i-1][j-1]+1) {
            if (s[i - 1] == t[j - 1]) {
                ans += s[i - 1];
                i-=1;
                j-=1;
            }
            else{
                if(arr[i][j]==arr[i-1][j]) i-=1;
                else j-=1;
            }
        }
        else{
            if(arr[i][j]==arr[i-1][j]) i-=1;
            else j-=1;
        }

    }
    for(int i=ans.length()-1;i>=0;i--){
        cout<<ans[i];
    }
}


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


int main() {
    int X;
    cin >> X;
    
    int N = X % 100;
    int cnt = 0;
    int j = 5;
    while (N > 0) {
        cnt += N / j;
        N %= j;
        --j;
    }
    if (X / 100 >= cnt) cout << 1 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string a,b;
    cin >> a >> b;

    if(a=="H"){
        if(b=="H"){
            cout << "H" << endl;
        }else{
            cout << "D" << endl;
        }
    }else{
        if(b=="H"){
            cout << "D" << endl;
        }else{
            cout << "H" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

string ans;
vector<string> S;
void ANS(ll A)
{
  cout << A << endl
       << flush;
  cin >> ans;

  if (ans == "Vacant")
    exit(0);
  S.at(A) = ans;
}

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

  S.resize(N + 1);

  ll L = 0, R = N;
  ANS(0);
  S.at(N) = ans;
  for (ll i = 0; i < 19; i++)
  {
    ll C = (L + R) / 2;
    ANS(C);

    if ((C - L) % 2 == 1)
    {
      if (S.at(L) == S.at(C))
        R = C;
      else
        L = C;
    }
    else
    {
      if (S.at(L) == S.at(C))
        L = C;
      else
        R = C;
    }
  }
}

Measured memory_bytes: 1620
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  bool same = (s.at(0) == s.at(n-1));

  if (same ^ (n%2 == 0)) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
}

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

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

#define forn(i, a, n) for (int i = (a); i < (int)n; i++)
#define trav(x, arr) for (auto &x : arr)
#define sz(x) (int)x.size()
#define Matrix(m, h, w) = std::vector<vector<int>> m(h, vector<int> (w)); 
using ll = long long;

#define vi vector<int>
#define vl vector<long>
#define vll vector<ll>

// benq
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;


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


    int a, b, c; cin >> a >> b >> c;

    if (a == b && a != c) cout << "Yes";
    else if (a == c && a != b) cout << "Yes";
    else if (b == c && b != a) cout << "Yes";
    else cout << "No";

    return 0;
}

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

int main()
{
    string X , Y;
    cin >> X >> Y;
    int d[X.length()+1][Y.length()+1];
    //int ans = 0;
    for (int i=0 ; i<=X.length() ; i++)
        d[i][0] = 0;
    for (int j=0 ; j<=Y.length() ; j++)
        d[0][j] = 0;
    for (int i=1 ; i<=X.length() ; i++)
        for (int j=1 ; j<=Y.length() ; j++)
        {
            d[i][j] = max(d[i][j-1] , d[i-1][j]);
            if (X[i-1] == Y[j-1])
            {
                d[i][j] = max(d[i-1][j-1] + 1 , d[i][j]);
                //ans = max(ans , d[i][j]);
            }
        }
    //cout << ans;
    string ans;
    for(int i=X.size()-1, j=Y.size()-1 ; i>=0 && j>=0 ; )
    {
        if( X[i] == Y[j] )
        {
            ans += X[i];
            j--;
            i--;
        }
        else if(d[i+1][j+1] == d[i][j+1])
            i--;
        else
            j--;
    }
    reverse(ans.begin() , ans.end());
    cout << ans;
}

Measured memory_bytes: 35456
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Map<String, List<Integer>> memo = new TreeMap<String, List<Integer>>();
		while (scanner.hasNext()) {
			String word = scanner.next();
			int page = scanner.nextInt();

			if (!memo.containsKey(word)) {
				List<Integer> list = new ArrayList<Integer>();
				list.add(page);
				memo.put(word, list);
			} else {
				List<Integer> newlist = memo.get(word);
				newlist.add(page);
				memo.put(word, newlist);
			}
		}
		for (Entry<String, List<Integer>> entry : memo.entrySet()) {
			Collections.sort(entry.getValue());
			System.out.println(entry.getKey());
			for (int i = 0; i < entry.getValue().size(); i++) {
				if (i != 0) {
					System.out.print(" ");
				}
				System.out.print(entry.getValue().get(i));
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 20456
#include <bits/stdc++.h>
#include <iostream>
#include <string>

#define f(i,n) for(int i = 0; i < n; i++)
#define fll(i,n) for(long long int i = 0; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define inf INT_MAX
#define pb push_back
#define all(x) x.begin(),x.end()
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
#define ans(x) cout<<x<<endl;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define mem(x,i) memset(x,i,sizeof x)

#define cin_vi(v,n) f(i,n){int temp;cin>>temp;v.pb(temp);}
#define cin_vll(v,n) fll(i,n){ll temp;cin>>temp;v.pb(temp);}
#define sort_desc(a) sort(a.begin(), a.end(), greater<int>());
#define sort_desc_ll(a) sort(a.begin(), a.end(), greater<long long int>());

using namespace std;

// ll factorial (ll n) {
// 	if (n==1){
// 		return 0;
// 	}
// 	if (n==2){
// 		return 1;
// 	}
// 	ll ans = 1;
// 	for (ll i = 1; i <= n; ++i){
// 		ans*=i;
// 		cout<<ans<<endl;
// 	}
// 	cout<<"ans for"<<n<<" is "<<ans;
// 	return ans;
// }

ll nC2 (ll n){
	// cout<<"Ans is"<<(n*n-1)/2<<endl;
	return (n*(n-1))/2;
}

int main () {
	
	fast;

	ll n,m;
	cin>>n>>m;

	cout<<nC2(n)+nC2(m)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;
long double s, l ,h;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    s = a * b / 2;
    if (c == 90)
        s = a * b / 2;
    else
        s = (a * b * sin(c * M_PI/180)) / 2;
    if (c == 90)
        l = a + b + sqrt(a * a + b * b);    
    else
        l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * M_PI/180));
    h = s * 2 / a;
    cout << fixed ;
    cout << s << endl;
    cout << l << endl;
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 3384
#include<cstdio>
#include<iostream>
using namespace std;
const long long mod=998244353;
long long c[4005][4005];
void init(long long n)
{
	c[0][0]=1;
	for(long long i=1;i<=n;i++)
	{
		c[i][0]=1;
		for(long long j=1;j<=i;j++)
		{
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	 } 
}
long long ksm(long long u,long long p)
{
	long long ans=1;
	while(p)
	{
		if(p&1) ans=(ans*u)%mod;
		u=(u*u)%mod;
		p>>=1;
	}
	return ans;
}
long long f(long long x,long long y,long long z)
{
	long long ans=0;
	for(long long p=0;p<=x;p++)
	{
	//	if(p+y-1<=p+y-1&&p+y-1>=0) 
			ans=(ans+c[x][p]*ksm(2,p)%mod*c[z+y-1][y+p-1])%mod;
	}
	return ans;
}
int main()
{
	long long n,m,cnt,ans=0;
	scanf("%lld%lld",&m,&n);
	init(n+m+1);
	for(long long i=2;i<=2*m;i++)
	{
		cnt=ans=0;
		for(long long j=1;j<=m;j++)
		{
			if(i-j>=1&&i-j<=m)
			{
				cnt++;
			}
		}
	//	cout<<cnt<<"  ff"<<endl;
		if(i%2==1)
		{
			ans=f(cnt>>1,m-cnt,n);
		}
		else
		{
			ans=f((cnt-1)>>1,m-cnt,n-1);
//			cout<<" dd"<<ans<<endl;
			ans+=f((cnt-1)>>1,m-cnt,n);
		}
		printf("%lld\n",ans%mod);
	}
	
	
	return 0;
} 

Measured memory_bytes: 123776
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, k;
vector<int>G[114514];
int one[114514], ans[114514];
void dfs(int x, int y) {
	ans[x] = max(0ll, k - one[x] - y);
	rep(i, G[x].size()) {
		if (ans[G[x][i]] == -1) {
			one[G[x][i]]++;
			dfs(G[x][i], one[x]);
			one[x]++;
		}
	}
}
signed main() {
	cin >> n >> k;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	fill(ans, ans + n, -1);
	dfs(0, 0);
	int memo = 1;
	rep(i, n) {
		memo *= ans[i];
		memo %= mod;
	}
	cout << memo << endl;
}

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

int main(){
  long long x;
  cin >> x;
  long long sum = 100;
  long long ans = 0;
  while(sum<x){
    sum = sum * 1.01;
    ans++;
  }
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
using System.Linq;
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            int[] v = str.Split(' ').Select(s => int.Parse(s)).ToArray();

            int right = v[1] >= v[2] ? v[1] : v[2];
            int left = v[1] < v[2] ? v[1] : v[2];
            int res = right  - (left + v[0]);
          
            Console.WriteLine(res < 0 ? 0 : res);
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int count = 0;
		int i = 0;
		while(a[i] % 2 == 0) {
			a[i] /= 2;
			if(i == n - 1) {
				count++;
				i = 0;
			}
			i++;
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <vector>

// #define LOOP(N) for(int i=0; i<N; i++)
#define LOOP(N, i) for(int i=0; i<N; i++)
// #define LOOP(N, i, start) for(int i=start; i<N; i++)


using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    int cm1 = 0, cm2 = 0, cnow;
    int hm1 = 0, hm2 = 0, hnow;
    cin >> hm2;
    cin >> hm1;
    cnow = abs(hm2 - hm1);
    // cout << cm2 << " " << cm1 << " " << cnow << endl;

    LOOP(N-2, i) {
        cin >> hnow;
        cm2 = cm1; cm1 = cnow;
        cnow = min(cm1 + abs(hm1 - hnow), cm2 + abs(hm2 - hnow));
        hm2 = hm1; hm1 = hnow;
        // cout << cm2 << " " << cm1 << " " << cnow << endl;
    }
    
    cout << cnow << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    if (D == 25) {
        cout << "Christmas" << endl;
    } else if (D == 24) {
        cout << "Christmas Eve" << endl;
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}


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

int main(){
    long long N,sum_p=0,sum_n=0,count_p=0,count_n=0;
    cin>>N;
    int A[N];
    for(int i=0;i<N;++i)cin>>A[i];

        for(int i=0;i<N;++i){
            sum_n+=A[i];

            if(i%2==0){
                if(sum_n<=0){
                    count_n+=1-sum_n;
                    sum_n=1;
                }
            }else{
                if(sum_n>=0){
                    count_n+=sum_n+1;
                    sum_n=-1;
                }
            }
        }



        for(int i=0;i<N;++i){
            sum_p+=A[i];

            if(i%2==1){
                if(sum_p<=0){
                    count_p+=1-sum_p;
                    sum_p=1;
                }
            }else{
                if(sum_p>=0){
                    count_p+=sum_p+1;
                    sum_p=-1;
                }
            }
        }
    long long ans=min(count_p,count_n);
        
cout<<ans;



}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin>>a>>b>>c;
	cout<<a+b+c-max(a,max(b,c))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int n;
int B,W;
int a[300050];
int s[300050];
bool judge(int x)
{
	int mn=0;
	if(s[n]>=x) return 1;
	for(int i=2;i<=n;++i)
	{
		if(s[i-1]-mn>=x)
		{
			if(s[n]-s[i]>=x) return 1;
			mn=min(mn,s[i]);
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(i&1)
		{
			B+=a[i];
			s[i]=s[i-1]+a[i];
		}
		else
		{
			W+=a[i];
			s[i]=s[i-1]-a[i];
		}
	}
	if(~n&1)
	{
		printf("%d %d\n",max(B,W),min(B,W));
		return 0;
	}
	int l=0,r=B,re=-1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(judge(mid)) l=mid+1,re=mid;
		else r=mid-1;
	}
	int an=max(B,W+re);
	printf("%d %d\n",an,B+W-an);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int memo[100010];
vector<vector<int>> nexts;

int f(int now) {
    if (memo[now] != -1) return memo[now];
    int ret = 0;
    for (int next : nexts[now]) {
        ret = max(ret, f(next) + 1);
    }
    memo[now] = ret;
    return ret;
}

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

    nexts.resize(N);

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        nexts[x].push_back(y);
    }

    rep(i, N) memo[i] = -1;

    int ret = 0;
    rep(i, N) {
        ret = max(ret, f(i));
    }

    cout << ret << endl;

    return 0;
}



Measured memory_bytes: 8576
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||(require'rubygems';exec({Z=>'50000000'},Gem.ruby,$0));def f(i)a=H[i].map{|e|-f(e)}.sort;(1..a.size).map{|i|i-a[i-1]}.max||0end;H=Hash.new{|h,k|h[k]=[]};2.upto(gets.to_i){|i|H[gets.to_i]<<i};p f 1

Measured memory_bytes: 224520
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;

	for(int i=0; i<s.size(); ++i){
		if(s[i]!=t[i]){
			cout << "No" << endl;
			return 0;
		}
	} 
	cout << "Yes" << endl;

}

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

int main() {

	string s; cin >> s;
	string ans = "Good";
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i - 1]) ans = "Bad";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main(void) {
int k, i;
std::vector<int> v(3);
std::cin >> v[0] >> v[1] >> v[2];
std::cin >> k;

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

for (i = 0; i < k; i++) {
  v[2] = v[2]*2;
}

std::cout << v[0] + v[1] + v[2] << '\n';

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++)
#define all(x) (x).begin(), (x).end()

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

    // start
    vector<int> w(26, 0);
    char x;
    while (cin >> x)
        w.at(x - 97)++;
    rep(i, 26)
    {
        if (w.at(i) % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
    int K;
    cin>>K;
    string S;
    cin>>S;
    if(S.size()<=K){
        cout<<S<<endl;
    }else{
        for(int i=0;i<K;i++){
            cout<<S.at(i);
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3632