akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

const int N = 2 * 1e5 + 123;
int n ,W , dp[N] , ans;
main(){
	scanf("%lld%lld" , &n , &W);
	//dp[j + v] = min(dp[j + v] ,dp[j] + w)
	for(int j = 0 ; j <= 1e5 ; j++)
		dp[j] = 1e18;
	dp[0] = 0;
	for(int i = 1 ; i <= n ; i++){
		int w , v;
		scanf("%lld%lld" , &w , &v);
		for(int j = 1e5 ; j >= 0 ; j--)
			dp[j + v] = min(dp[j + v] , dp[j] + w);
	}
	for(int j = 1e5 ; j >= 0 ; j--)
		if(dp[j] <= W){
			ans = j;
			break;
		}
	printf("%lld" , ans);
}

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

signed main() {
    int n, k;
    cin >> n >> k;
    vector <int> t(n), diff;
    rep (i, n) {
        cin >> t[i];
        if (i && t[i] - t[i - 1] != 1) diff.push_back(t[i] - t[i - 1] - 1);
    }

    int num = n - ((n - 1) - (int)diff.size());

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

    int ans = n;
    rep (i, num - k) ans += diff[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	ll n,k; cin >> n >> k;
	n = n%k;
	ll ans = min(n,abs(n-k));
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int a[n];
  FOR(i,0,n)cin>>a[i];
  sort(a,a+n);
  int ans=0;
  int d=2e9;
  FOR(i,0,n-1){
    if(d>abs(a[n-1]-a[i]-a[i])){
      ans=a[i];
      d=abs(a[n-1]-a[i]-a[i]);
    }
  }
  cout<<a[n-1]<<" "<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n],i,j,k;
    cin>>k;
	 int brr[n];
     for(i=0;i<n;i++)
     cin>>arr[i];
     brr[0]=0;
     brr[1]=brr[0]+abs(arr[1]-arr[0]);
     for(i=2;i<n;i++)
     {   int miin=INT_MAX;
     	for(j=max(0,i-k);j<i;j++)
     	{
     		if((brr[j]+abs(arr[j]-arr[i]))<miin)
     		miin=(brr[j]+abs(arr[j]-arr[i]));
		 }
		 brr[i]=miin;
	 }
	 //brr[i]=min(brr[i-1]+abs(arr[i]-arr[i-1]),brr[i-2]+abs(arr[i]-arr[i-2]));
     cout<<brr[n-1]; 
     
     
     return 0;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/abc144/tasks/abc144_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll A,B; cin>>A>>B;
    if(A>=1&&A<=9&&B>=1&&B<=9) cout<<A*B<<endl;
    else cout<<-1<<endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  long long int a[n],b[n];
  for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
  long long int ans=0;
  
  for(int i=n-1;i>=0;i--){
    a[i]+=ans;
    if(a[i]%b[i]==0);
    else ans+=b[i]-a[i]%b[i];
  }
  cout<<ans;
  
}

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

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

	auto is_square_number = [](int64_t x) {
		int64_t ok = 0, ng = (1LL << 30);

		while (1 < abs(ok - ng))
		{
			int64_t mid = (ok + ng) / 2;

			((mid * mid <= x) ? ok : ng) = mid;
		}

		return ok * ok == x;
	};

	cout << ((is_square_number(stoll(to_string(a) + to_string(b)))) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    int N,K,Q;cin>>N>>K>>Q;
    vector<int> A(Q),point(N,K-Q);
    for(int i=0;i<Q;i++){
        cin>>A[i];
        A[i]--;
        point[A[i]]++;
    }
    
    for(int i=0;i<N;i++){
        if(point[i]>0) cout<<"Yes\n";
        else cout<<"No\n";
    }
}



Measured memory_bytes: 1408
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

int main() {
  ll x, y;
  cin >> x >> y;

  rep(i, x+1) {
    ll j = x-i;
    if (i*2 + j*4 == y) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
}


Measured memory_bytes: 3620
#include <cstdlib>
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

struct Process
{
    string name;
    int time;
};

class Queue
{
private:
    int head;
    int tail;
    Process queue[100000];

public:
    Queue()
    {
        head = tail = 0;
    }

    void Enqueue(Process val)
    {
        queue[tail] = val;
        tail = (tail + 1) % 100000;
    }

    Process Dequeue()
    {
        Process val = queue[head];
        head = (head + 1) % 100000;
        return val;
    }

    bool IsEmpty()
    {
        return head == tail;
    }

    bool IsFull()
    {
        return head == (tail + 1) % 100000;
    }
};

int main()
{
    Queue queue;
    int processNum, roundTime;
    cin >> processNum >> roundTime;
    for (int i = 0; i < processNum; i++)
    {
        Process process;
        cin >> process.name >> process.time;
        queue.Enqueue(process);
    }

    int elapsedTime = 0;

    while (!queue.IsEmpty())
    {
        Process target = queue.Dequeue();

        if (target.time <= roundTime)
        {
            elapsedTime += target.time;
            cout << target.name << " " << elapsedTime << endl;
        }
        else
        {
            elapsedTime += roundTime;
            target.time -= roundTime;
            queue.Enqueue(target);
        }
    }
    return 0;
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
    ll x,ans;
    cin>>x;
    ans=(x/500)*1000;
    x-=(x/500)*500;
    //cout<<x<<endl;;
    ans+=(x/5)*5;
    cout<<ans<<endl;
}
   



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  ll h, w, i;
  cin >> h >> w;

  if(h%3==0||w%3==0){
    cout << 0 << endl;
    return 0;
  }

  ll ans = min(h,w);
  ll s[3];

  for(i=1;i<=h-1;i++){
    s[0] = i * w;
    s[1] = (h-i) * (w/2);
    s[2] = (h-i) * (w-w/2);

    sort(s,s+3);
    ans = min(ans,s[2]-s[0]);
  }

  swap(h,w);
  for(i=1;i<=h-1;i++){
    s[0] = i * w;
    s[1] = (h-i) * (w/2);
    s[2] = (h-i) * (w-w/2);

    sort(s,s+3);
    ans = min(ans,s[2]-s[0]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
struct W{int i,x;}w[510];int cnt[510],res[510];
bool cmp(W a,W b){return a.x<b.x;}
int n,p,tot,k;
int cntx[250010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) 
	{
		scanf("%d",&w[i].x);
		w[i].i=i;cntx[w[i].x]=i;
	}
	w[0]=W{500010,1};w[n+1]=W{500010,n*n+1};
	sort(w+1,w+n+1,cmp);
	for (int i=1;i<=n;i++) cnt[i]=w[i].i,res[i]=n-cnt[i];
	
	p=w[1].x;
	for (int i=1;i<=n;i++)
	{
		p-=cnt[i];
		if (p<0){printf("No");return 0;}
		p+=w[i+1].x-w[i].x;
	}
	p=w[n+1].x-w[n].x;
	for (int i=n;i;i--)
	{
		p-=res[i]+1;
		if (p<0) {printf("No");return 0;}
		p+=w[i].x-w[i-1].x;
	}
	
	printf("Yes\n");
	tot=1;k=1;
	for (int i=1;i<=n*n;i++)
	{
		if (cntx[i]) 
		{printf("%d ",cntx[i]);continue;}

		while (cnt[tot]<=1) tot++;		
		if (tot<=n) printf("%d ",w[tot].i),cnt[tot]--;
		else
		{
			while (!res[k]) k++;
			printf("%d ",w[k].i);res[k]--;
		}
	}
	
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2005;
string s[maxn];
int a[maxn][maxn];
int H[maxn];
int sta[maxn];
int main()
{
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++) cin>>s[i];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            a[i][j]=s[i][j]=='#';
    }
    int ans=max(h,w);
    for(int i=0;i<h;i++)
    {
        if(!i) for(int j=1;j<w;j++) H[j]=1;
        else{
            for(int j=1;j<w;j++)
            {
                if(a[i][j]^a[i][j-1]==a[i-1][j]^a[i-1][j-1])
                    H[j]++;
                else H[j]=1;
            }
        }
        stack<int> st;
        H[w]=-1;
        st.push(0);
        for(int j=1;j<=w;j++)
        {
            while(st.size()&&H[st.top()]>=H[j]) 
            {
                ans=max(ans,H[st.top()]*(j-sta[st.top()]));
                //dbg(i,j,st.top());
                st.pop();
            }
            if(j!=w)
                sta[j]=st.top();
            st.push(j);
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 20096
#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>;

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);  // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

using pint = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int> > p(n);
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    p[a].insert(b);
    p[b].insert(a);
    uf.merge(a, b);
  }

  ll ans = 0;
  rep(i, n) {
    ll mem = uf.size(i);
    ans = max(ans, mem);
  }
  cout << ans << endl;
}

Measured memory_bytes: 32300
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 159, task d, 2020/09/08
//ms,
/*
*/

int main(void){
  int N;
  vector<int64_t> rec(200001);//インデックスはボールに書かれた数字、要素は個数
  vector<int64_t> a;
  int64_t cases=0;

  for(int i=0;i<200000;i++) rec[i]=0;

  cin >>N;
  for(int i=0;i<N;i++){
    int tmp_a;
    cin >>tmp_a;
    rec[tmp_a]++;
    a.push_back(tmp_a);
  }

  for(int i=1;i<200000;i++) cases+=rec[i]*(rec[i]-1)/2;

  for(int i=0;i<N;i++){
    int64_t same_balls =rec[a[i]];
    int64_t ans=cases - same_balls*(same_balls-1)/2;
    ans += (same_balls-1)*(same_balls-2)/2;
    cout <<ans <<endl;

  }


  return 0;
}
/*
*/


Measured memory_bytes: 6920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e6 + 10;
const int Mod = 1e9 + 7;
int N;
int A[MAXN], B[MAXN];
int fac[MAXN], ifc[MAXN];
int f[4010][4010];
int ans;

inline int fp(int a, int b) {
	int x = 1;
	while(b) {
		if(b & 1) x = 1ll * x * a % Mod;
		a = 1ll * a * a % Mod; b >>= 1;
	}
	return x;
}

inline void init(int n) {
	register int i;
	for(*fac = i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % Mod;
	for(ifc[n] = fp(fac[n], Mod - 2), i = n; i; --i) ifc[i - 1] = 1ll * ifc[i] * i % Mod;
}

inline int C(int n, int k) {
	if(n < 0 || k < 0 || n < k) return 0;
	return 1ll * fac[n] * ifc[k] % Mod * ifc[n - k] % Mod;
}

int main() {
	register int i, j; init(1e6);
	scanf("%d", &N);
	for(i = 1; i <= N; ++i)
		scanf("%d%d", A + i, B + i),
		++f[2001 - A[i]][2001 - B[i]];
	for(i = 1; i <= 4001; ++i)
		for(j = 1; j <= 4001; ++j)
			f[i][j] = (f[i][j] + f[i - 1][j] + f[i][j - 1]) % Mod;
	for(i = 1; i <= N; ++i)
		ans = (ans + f[2001 + A[i]][2001 + B[i]]) % Mod,
		ans = (ans - C(2 * A[i] + 2 * B[i], 2 * A[i]) + Mod) % Mod;
	printf("%lld\n", 1ll * ans * fp(2, Mod - 2) % Mod);
	return 0;
}

Measured memory_bytes: 73856
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<char>vec(3);
  for(ll i=0;i<3;i++){
    cin>>vec.at(i);
  }
  ll a=0;
  for(ll i=0;i<3;i++){
    char d;
    cin>>d;
    if(vec.at(i)==d){
      a+=1;
    }
  }
  cout<<a<<endl;
  return 0;
}
  
    


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
  if(a.first != b.first) return a.first > b.first;
  else if(a.second != b.second) return a.second < b.second;
  return true;
}

 
int main(){
  int n,total=0;
  vector<int> v;
  cin >> n;
  for(int i = 0; i < n;i++){
    int a;
    cin >> a;
    v.push_back(a);
    total += a;
  }

  int min = INT_MAX;

  for(int i = -100; i  <= 100; i++){
    int t = 0;
    for(int j = 0; j < v.size(); ++j){
      t += pow(v[j] - i,2);
      if(t > min){
        break;
      }
    }

    if(t < min){
      min = t;
    }
  }
  cout << min << endl;

}

Measured memory_bytes: 256
S = input()
if S[0] != 'A':
    print('WA')
elif S.count('C') != 1:
    print('WA')
elif 'C' not in S[2:-1]:
    print('WA')
else:
    upper = 0
    for c in S:
        if c.isupper():
            upper += 1
    print('AC' if upper == 2 else 'WA')

Measured memory_bytes: 3060
S = input()[::-1]

#aのMOD求めるンゴ
MOD=2019
ls_rem_a=[]
d=1
for i in range(len(S)):
  ls_rem_a.append(int(S[i])*d%MOD)
  d = d*10%MOD

#次に累積和求めるンゴ
ls_rem_s=[0]
sum=0
for i in range(len(S)):
  sum+=ls_rem_a[i]
  sum%=MOD
  ls_rem_s.append(sum)

#最後にMODが同じやつの個数を調べるンゴ
from collections import Counter
C_rem = Counter(ls_rem_s)
ans=0
for i in C_rem.keys():
  n=C_rem[i]
  ans+=n*(n-1)//2
print(ans)

Measured memory_bytes: 89224
import collections
n = int(input())
s = input()
c = collections.Counter(list(s))
a = list(c.values())
count = 0
r = 1
for i in range(len(a)):
    if a[i] == 1:
        count += 1
    else:
        r *= (a[i] + 1)

print((2 ** count * r - 1) % (10 ** 9 + 7))


Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    string S;
    cin >> S;

    vector<ll> A(S.size()+1);
    A[0] = 0;
    for(int i=0; i<S.size(); i++){
        if(S[i] == '<') A[i+1] = A[i]+1;
        else A[i+1] = 0;
    }
    for(int i=S.size()-1; i>=0; i--){
        if(S[i] == '>') A[i] = max(A[i], A[i+1]+1);
    }

    // for(int i=0; i<=S.size(); i++) cout <<A[i]; cout << endl;
    ll ans = 0;
    for(int i=0; i<=S.size(); i++) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 4740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        int[] r = new int[n];
        int[] g = new int[n];
        int[] b = new int[n];
        for (int i = n - 1; i >= 0; i--) {
            if (s.charAt(i) == 'R') {
                r[i]++;
            } else if (s.charAt(i) == 'G') {
                g[i]++;
            } else {
                b[i]++;
            }
            if (i != 0) {
                r[i - 1] = r[i];
                g[i - 1] = g[i];
                b[i - 1] = b[i];
            }
        }
        long ans = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                if (s.charAt(i) == s.charAt(j)) {
                    continue;
                }
                int sub = j - i;
                if ((s.charAt(i) == 'R' && s.charAt(j) == 'G') || (s.charAt(i) == 'G' && s.charAt(j) == 'R')) {
                    ans += b[j + 1];
                    if ((j + sub) < n && s.charAt(j + sub) == 'B') {
                        ans--;
                    }
                } else if ((s.charAt(i) == 'G' && s.charAt(j) == 'B') || (s.charAt(i) == 'B' && s.charAt(j) == 'G')) {
                    ans += r[j + 1];
                    if ((j + sub) < n && s.charAt(j + sub) == 'R') {
                        ans--;
                    }
                } else {
                    ans += g[j + 1];
                    if ((j + sub) < n && s.charAt(j + sub) == 'G') {
                        ans--;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38848
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


A, B = map(int, input().split())


if (A*B)%2 == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define pii pair<long long,long long>
using namespace std;
int arr[55];
pii dp[55];
int n,p;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> p;
    for(int i=0;i<n;i++)
        cin >> arr[i];
    if(arr[0] & 1)
        dp[0].first++;
    else
        dp[0].second++;
    dp[0].second++;
    for(int i=1;i<n;i++)
	{
		if(arr[i]&1)
		{
			dp[i].first = dp[i-1].first + dp[i-1].second;
			dp[i].second = dp[i-1].first + dp[i-1].second;
		}
		else
		{
			dp[i].first = dp[i-1].first*2;
			dp[i].second = dp[i-1].second*2;
		}
	}
	if(p==1)
	    cout << dp[n-1].first << endl;
	else 
	    cout << dp[n-1].second << endl;
    return 0;
}


Measured memory_bytes: 256
"""
C - Candles
X ろうそく間の距離を出して、K本目まで距離を足せば良い
O 右にいくか　左に行くか　どっちが良いか
"""

N, K = map(int, input().split())

candles = []
for part in input().split():
    candles.append(int(part))

min_dist = 10 ** 10
for i in range(N - K + 1):
    l = i
    r = i + K - 1

    # 右に行ったとき
    r_dist = abs(candles[r]) + abs(candles[l] - candles[r])
    # 左に行ったとき
    l_dist = abs(candles[l]) + abs(candles[r] - candles[l])

    min_dist = min(min_dist, r_dist, l_dist)

print(min_dist)

Measured memory_bytes: 14536
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,a,b,c = LI()
    a = [a,b,c]
    l = [I() for _ in range(n)]
    r = inf
    for b in range(4**n):
        k = [[] for _ in range(4)]
        for i in range(n):
            k[b % 4].append(l[i])
            b //= 4
        nf = 0
        for i in range(3):
            if len(k[i]) == 0:
                nf = 1
                break
        if nf:
            continue

        t = 0
        for i in range(3):
            t += (len(k[i]) - 1) * 10 + abs(sum(k[i])-a[i])
        if r > t:
            r = t

    return r



print(main())




Measured memory_bytes: 5964
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include <stdio.h>
#include<string>
using namespace std;
int main() 
{
	int a = 0;
	int b = 0;
	cin >> a >> b;
	if (a%b == 0) {
		cout << '0';
	}
	else {
		cout << '1';
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	ll n, k;
	cin >> n >> k;

	//v[i][0]:おいしさ,v[i][1]:種類
	vector< vector<ll> >v(n,vector<ll>(2,0));
	vector<ll> kind(101010);

	rep(i, 0, n) {
		cin >> v[i][1] >> v[i][0];
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	deque<ll> tastepoint;
	ll tempkind = 0LL;
	ll temptaste = 0LL;

	rep(i, 0, k) {
		if (kind[v[i][1]] == 0LL) {
			kind[v[i][1]]++;
			tempkind++;
		}
		else {
			tastepoint.push_front(v[i][0]);
		}
		temptaste += v[i][0];
	}

	ll ans = temptaste + tempkind * tempkind;
	rep(i, k, n) {
		if (tastepoint.size()==0) {
			break;
		}
		if (kind[v[i][1]] == 0LL) {
			temptaste -= tastepoint.front();
			temptaste += v[i][0];
			tastepoint.pop_front();
			tempkind++;
			kind[v[i][1]]++;
		}
		ans = max(ans,temptaste + tempkind*tempkind);
	}

	cout << ans << endl;




	return 0;
}

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

int main()
{
    int N,W,V[101][10001],i,j;
    int v[1001],w[1001];
    cin >> N >> W;
    for(i=1;i<=N;i++)
        cin >> v[i] >> w[i];
    for(i=0;i<=N;i++)
        for(j=0;j<=W;j++)
            V[i][j]=0;
    for(i=1;i<=N;i++)
        for(j=1;j<=W;j++)
        {
            if(j-w[i]<0)
                V[i][j]=V[i-1][j];
            else    V[i][j]=max(V[i][j-w[i]]+v[i],V[i-1][j]);
        }
    cout << V[N][W] << endl;
    return 0;
}


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

#define fi first
#define se second

const int N = 1000300;
const long long mod = 1e9 + 7;

using namespace std;

long long f(long long a, long long b)
{
        if(!a || a == b){
                return a;
        } else if(a > b){
                return f(b, a);
        } else{
                return ((b - 1) / a) * 2 * a + f(b - (b - 1) / a * a, a);
        }
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        long long n, x;
        cin >> n >> x;
        cout << f(n - x, x) + n << "\n";
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b, h;
  cin >> a >> b >> h;
  int ans = (a+b) * h / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections

def combinations_count(n, r):
    return n * (n-1) // r


n = int(input())
l = [int(x) for x in input().split()]

l1 = []
l2 = []
c = collections.Counter(l)

total = sum([combinations_count(i, 2) for i in c.values()])

for a in l:
    l1.append(combinations_count(c[a], 2))
    l2.append(combinations_count(c[a]-1, 2))
# print(l1, l2)
for i in range(len(l)):
    print(total-l1[i]+l2[i])


Measured memory_bytes: 33316
#include <cstdio>
#include <cmath>

int main(void) {
	bool prime[512], p_flag;
	int n, ans;
	for(int i = 1; i < 512; i++) {
		if(i % 2) prime[i] = true;
	}
	prime[1] = false;  prime[2] = true;

	for(int i = 3; i < 512; i += 2) {
		if(prime[i]) {
			for(int j = i * i; j < 512; j += i) {
				prime[j] = false;
			}
		}
	}

	while(1) {
		ans = 0;
		scanf("%d", &n);
		if(!n) break;
		for(int i = n + 1; i <= 2 * n; i++) {
			p_flag = true;
			for(int j = 2; j <= (int)sqrt((double)2 * n); j++) {
				if(prime[j] == true && !(i % j)) {
					p_flag = false;
					break;
				}
			}
			if(p_flag) ans++;
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1032
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int[][] d = new int[c][c];
		for (int i = 0; i < c; i++) {
			for (int j = 0; j < c; j++) {
				d[i][j] = sc.nextInt();
			}
		}
		int[][][] a = new int[n][n][c];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int b = sc.nextInt() - 1;
				for (int k = 0; k < c; k++) {
					a[i][j][k] = d[b][k];
				}
			}
		}
		sc.close();

		if (n == 1) {
			System.out.println(0);
			return;
		}

		Obj[][] sum = new Obj[3][c];
		for (int k = 0; k < c; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					Obj o = sum[(i + j) % 3][k];
					if (o == null) {
						o = new Obj();
						o.col = k;
						sum[(i + j) % 3][k] = o;
					}
					o.val += a[i][j][k];
				}
			}
		}

		for (int i = 0; i < 3; i++) {
			Arrays.sort(sum[i], new Comparator<Obj>() {
				public int compare(Obj o1, Obj o2) {
					return o1.val - o2.val;
				}
			});
		}

		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (sum[0][i].col != sum[1][j].col
							&& sum[0][i].col != sum[2][k].col
							&& sum[1][j].col != sum[2][k].col) {
						ans = Math.min(ans, sum[0][i].val + sum[1][j].val + sum[2][k].val);
					}
				}
			}
		}
		System.out.println(ans);
	}

	static class Obj {
		int col, val;
	}
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, M;
vector<int> G[20];
int dp[10][1<<10];

int rec(int v, int visited){
    visited |= 1 << v;
    if(visited == (1 << N) - 1){
        return 1;
    }
    if(dp[v][visited] != -1){return dp[v][visited];}

    int res = 0;
    for(int w : G[v]){
        if(visited >> w & 1){continue;}

        res += rec(w, visited);
    }

    return dp[v][visited] = res;
}

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

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        int a, b;
        std::cin >> a >> b;

        --a; --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    memset(dp, -1, sizeof(dp));
    
    int res = rec(0, 0);
    std::cout << res << std::endl;
}


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

namespace abc129_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var h = CIn.ReadInt();
      var w = CIn.ReadInt();
      var s = CIn.ReadCharMatrix(h, w);

      var a = new int[h, w];

      for (var i = 0; i < h; i++)
      {
        var con = 0;
        for (var j = 0; j < w; j++)
        {
          if (s[i, j] == '#')
          {
            for (var k = j - con; k < j; k++) a[i, k] = con;
            con = 0;
          }
          else con++;
        }

        if (con != 0)
        {
            for (var k = w - con; k < w; k++) a[i, k] = con;
        }
      }

      for (var i = 0; i < w; i++)
      {
        var con = 0;
        for (var j = 0; j < h; j++)
        {
          if (s[j, i] == '#')
          {
            for (var k = j - con; k < j; k++) a[k, i] += con - 1;
            con = 0;
          }
          else con++;
        }

        if (con != 0)
        {
          for (var k = h - con; k < h; k++) a[k, i] += con - 1;
        }
      }

      var ans = 0;

      foreach (var e in a)
      {
        ans = Math.Max(ans, e);
      }

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }

    public static char[,] ReadCharMatrix(long n, long m)
    {
      var array = new char[n, m];

      for (var i = 0; i < n; i++)
      {
        var line = Console.ReadLine();

        for (var j = 0; j < m; j++)
        {
          array[i, j] = line[j];
        }
      }

      return array;
    }
  }
}

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

int main()
{
    ll n, k;
    cin>>n>>k;
    double ans =0;
    cout.precision(15);

    for(int i=1;i<=n;i++)
    {
        if( i>=k)
        {
            ans += (n-i+1)/double(n);
            break;
        } else
        {
            int times = 0;
            int temp =i;
            while( temp<k)
            {
                temp=temp*2;
                times++;
            }
            ans += ( ( 1/double(n) )*( double(1)/ pow(2,times)) );
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4140
def cost(a, x):
    c = 0
    for ai in a:
        c += (ai - x) * (ai - x)
    return c

N = int(input())
a = list(map(int, input().split()))
avg = 0
for n in a:
    avg += n
if avg % N == 0:
    print(cost(a, avg // N))
else:
    print(min(cost(a, avg // N), cost(a, avg // N + 1)))


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

int main()
{
  int m,n,one,two,ans;
  one=0;
  two=100001;
  cin>>n>>m;
  vector<vector<int>> data(m, vector<int>(2));
  for(int i=0;i<m;i++)//入力
  {
    for(int j=0;j<2;j++)
    {
      cin>>data.at(i).at(j);
    }
  }
  for(int i=0;i<m;i++)
  {
    if(data.at(i).at(0)>one)
    {
      one=data.at(i).at(0);
    }
  }
  for(int i=0;i<m;i++)
  {
    if(data.at(i).at(1)<two)
    {
      two=data.at(i).at(1);
    }
  }
  ans=two-one+1;
  if(ans<0)
  {
    ans=0;
  }
  cout<<ans<<endl;
}

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

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;
}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog oi.ender-zzm.pro
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

const int Mod = 1e9 + 7;

const int maxn = 10100;
#define int long long
int n, inv[maxn], fac[maxn];
int Pow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = 1ll * ans * x % Mod;
		y >>= 1;
		x = 1ll * x * x % Mod;
	}
	return ans;
}
int C(int x, int y) {
	if (y == 0) return 1;
	if (x < y) return 0;
	return 1ll * fac[x] * inv[y] % Mod* inv[x - y] % Mod;
}
signed main() {
	n = ri();
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = 1ll * fac[i - 1] * i % Mod;
	}
	inv[n] = Pow(fac[n], Mod - 2);
	for (int i = n - 1; i >= 0; i--) {
		inv[i] = 1ll * inv[i + 1] * (i + 1) % Mod;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int tmp = n;	
		tmp = n - 2 * i;
		if (tmp <= 0) break;
		(ans += C(tmp - 1, i - 1)) %= Mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
m = c.most_common()[0]

ans = []
for _c in c.items():
    if _c[1] == m[1]:
        ans.append(_c[0])

for v in sorted(ans):
    print(v)


Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N,M;
  cin >> N >> M;
  int A[M],B[M];
  vector<vector<int>> Ren(N,vector<int>());
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    Ren.at(A[i]).push_back(B[i]);
    Ren.at(B[i]).push_back(A[i]);
  }
  queue<int> seen;
  int Pr[N]; bool TA[N];
  for(int i=0;i<N;i++) TA[i]=false;
  for(int i=0;i<N;i++) Pr[i]=-1;
  TA[0]=true;
  seen.push(0);
  int ct=0;
  
  while(!(seen.empty()||ct==N)){
    int S =seen.front();
    for(int i=0;i<Ren.at(S).size();i++){
      int NextV = Ren.at(S).at(i);
      if(TA[NextV]) continue;
      Pr[NextV]=S;
      seen.push(NextV);
      TA[NextV]=true;
    }
    seen.pop();
    ct++;
  }
  
  cout << "Yes"<<endl;
  for(int i=1;i<N;i++){
    cout << Pr[i]+1 << endl;
  }
  
  
}


Measured memory_bytes: 12024
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in range(max_sugar // C + 1):
        for k in range((max_sugar - j * C) // D + 1):
            sugar = max(sugar, j * C + k * D)
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print(' '.join(map(str, ans)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n); for(long long i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
int main(){
  ll n; cin >> n;
  string s; cin >> s;
  ll ans = 1;
  rep(i,n-1){
    if(s[i] != s[i+1])ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	string str; cin >> str;
	int y = atoi(str.substr(0, 4).c_str());
	int m = atoi(str.substr(5, 2).c_str());
	int d = atoi(str.substr(8, 2).c_str());
	if (y >= 2019) {
		if (m > 4)cout << "TBD";
		else if (m == 4) {
			if (d >= 31)cout << "TBD";
			else cout << "Heisei";
		}
		else cout << "Heisei";
	}else cout << "Heisei";
	

	cout << endl;
	return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  string a,b,c; cin>>a>>b>>c;
  cout<<a[0]<<b[0]<<c[0]<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define int long long
signed main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    ll sum = 0, sum2 = 0;
    rep(i,n){
        sum += a[i];
        sum2 += b[i];
    }
    if(sum2 > sum){
        cout << -1 << endl;
        return 0;
    }
    sum = 0;
    vector<int>t;
    int ans = 0;
    rep(i,n){
        if(a[i] < b[i]){
            sum += b[i]-a[i];
            ans++;
        }else{
            t.push_back(a[i]-b[i]);
        }
    }
    sort(t.rbegin(),t.rend());
    rep(i,t.size()){
        if(sum<=0)break;
        sum-=t[i];
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

    if(x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t a;
    intmax_t ans = 0;

    scanf("%jd", &a);

    ans = a + a * a + a * a * a;

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> ans(N, -1);
    REP(i, M) {
        int s, c;
        cin >> s >> c;
        s--;
        if(s == 0 && c == 0 && N != 1) {
            cout << -1 << endl;
            return 0;
        }
        if(ans[s] == -1) {
            ans[s] = c;
        } else if(ans[s] != c) {
            cout << -1 << endl;
            return 0;
        }
    }
    REP(i, N) {
        if(ans[i] == -1) {
            if(i == 0 && N != 1) {
                ans[i] = 1;
            } else {
                ans[i] = 0;
            }
        }
    }
    REP(i, N) cout << ans[i];
    cout << endl;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  VI v(n);

  ll sum = 0;
  REP(i, n) {
    cin >> v[i];
    sum += v[i];
  }

  SORT(v);
  REVERSE(v);

  REP(i, m) {
    if (v[i] < sum * 1.0 / (4.0 * m)) {
      ANS("No");
      return 0;
    }
  }
  ANS("Yes");

  return 0;
}


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

int main() {
  int K, S; cin >> K >> S;
  int res = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      if (X + Y <= S && X + Y + K >= S) res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256