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

using namespace std;

typedef pair<long long, int> pii;

long long w, h;
vector<pii> costs;

int main()
{
	cin >> w >> h;
	for (int i = 0; i < w; i++)
	{
		int x;
		cin >> x;
		costs.emplace_back(x, 0);
	}
	for (int i = 0; i < h; i++)
	{
		int x;
		cin >> x;
		costs.emplace_back(x, 1);
	}
	w++;
	h++;
	sort(costs.begin(), costs.end());
	long long ans = 0;
	for (int i = 0; i < int(costs.size()); i++)
	{
		if (costs[i].second == 0)
		{
			ans += costs[i].first * h;
			w--;
		}
		else
		{
			ans += costs[i].first * w;
			h--;
		}
	}
	cout << ans << '\n';
	return 0;
}



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

int main() {
  int n;
  string s, t, ans;
  cin >> n >> s >> t;
  for(int i=0; i<n; i++){
    ans += s.at(i);
    ans += t.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 18

const int INF = 1001001001;

int n;
int cost[MAX_N][MAX_N];
int dp[1<<MAX_N][MAX_N];

int dfs(int x, int k){
    if(dp[x][k] != -1) return dp[x][k];

    if(x == (1<<n) - 1){
        dp[x][k] = cost[k][0];
        return dp[x][k];
    }

    dp[x][k] = INF;
    bitset<MAX_N> f(x);

    rep(i,n){
        if(f[i] == 0){
            dp[x][k] = min(dp[x][k], dfs(x|(1<<i), i) + cost[k][i]);
        }
    }

    return dp[x][k];
}

int main() {
    int m;
    cin >> n >> m;
    rep(i,n)rep(j,n)cost[i][j] = INF;

    rep(i,m){
        int s, t, d;
        cin >> s >> t >> d;
        cost[s][t] = d;
        // cost[t][s] = d;
    }

    rep(i,1<<n)rep(j,n)dp[i][j] = -1;

    int ans = dfs(1,0);

    if(ans >= INF) ans = -1;
    cout << ans << endl;
    return 0;
}
 
 



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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, ans;
    scanf("%lld", &N);
    //vector<ll> A(N),B(N);
    ans = ( N - 1 ) * N / 2LL;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import math

def main():
    A, B, C, D = map(int, input().split())
    lcm = C * D // math.gcd(C, D)
    C_div = B // C - (A - 1) // C
    D_div = B // D - (A - 1) // D
    C_D_div = B // lcm - (A - 1) //lcm
    print(B - A + 1 - C_div - D_div + C_D_div)


if __name__ == '__main__':
    main()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)

using namespace std;

int main(){
  
	int n,k,cnt,ans=0;
  	map<int,int> mp;
  	vector<int> ball;
  
  	cin >> n >> k;

  	
  	REP(x,n){
      int i;
      cin >> i;
      mp[i]++;
    }
  
  	for(auto m: mp){
       ball.push_back(m.second);
    }
  
  	sort(ball.rbegin(), ball.rend());
  
  
  	REP(x,ball.size()){
      	cnt++;
    	if(cnt > k) ans += ball[x];
    }
  
  	cout << ans << endl;

}

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

int main(){
  int64_t H; cin >> H;
  int64_t p =1;
  int64_t sum =0;
  while(H>0){
    sum += p;
    p *= 2;
    H /= 2;
  }
  cout << sum << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  string s;
  cin >> s;
  bool flag = 0;
  rep(i, 3) {
    if (s.at(i) == '7') flag = 1;
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
//#uisicafir}
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s1,s2;
	int a,b;
	cin>>s1>>s2;
	a=s1.size(),b=s2.size();
	for(int i=0; i<b; i++) cout<<s1[i]<<s2[i];
	if(a>b)	cout<<s1[a-1];
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
k = 0
import math
if n % 2 == 0 and d[math.floor((n-1)/2)] != d[math.ceil((n-1)/2)]:
    k = d[math.ceil((n-1)/2)] - d[math.floor((n-1)/2)]
elif n % 2 == 1 and d[(n-1)/2] != d[(n-1)/2 -1] and d[(n-1)/2] != d[(n-1)/2 + 1]:
    k = 1
else:
    k = 0
    
print(k)

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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *NIL, *root;

void insert(int x) {
    Node *p = NIL;
    Node *u = root;
    Node *in = (Node *)malloc(sizeof(Node));
    in->key = x;
    in->left = NIL;
    in->right = NIL;

    while (u != NIL) {
        p = u;
        if (in->key < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }

    in->parent = p;
    if (p == NIL) {
        root = in;
    } else if (in->key < p->key) {
        p->left = in;
    } else {
        p->right = in;
    }
}

bool find(Node *u, int x) {
    while (u != NIL && u->key != x) {
        if (x < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }

    if (u == NIL) {
        return false;
    } else {
        return true;
    }
}

void printPre(Node *u) {
    if (u == NIL) {
        return;
    }

    printf(" %d", u->key);
    printPre(u->left);
    printPre(u->right);
}

void printIn(Node *u) {
    if (u == NIL) {
        return;
    }

    printIn(u->left);
    printf(" %d", u->key);
    printIn(u->right);
}

int main() {
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string com;
        cin >> com;
        if (com == "insert") {
            int x;
            scanf("%d", &x);
            insert(x);
        } else if (com == "find") {
            int x;
            scanf("%d", &x);
            if (find(root, x)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        } else {
            printIn(root);
            printf("\n");
            printPre(root);
            printf("\n");
        }
    }
}


Measured memory_bytes: 22040
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int a[maxn];

bool h(int x, int y, int z){
  if(x==y||x==z||y==z)return false;
  vector<int>v = {x,y,z};
  sort(v.begin(),v.end());
  return v[0] + v[1]>v[2];
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int ret = 0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      for(int k=j+1;k<n;k++){
        if(h(a[i],a[j],a[k]))ret++;
      }
  cout<<ret<<endl;
  return 0;
}

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

#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 = std::int64_t;
using P = std::tuple<int,int>;

int N;
int A[110];

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
  }

  double res = 0;

  for(int i=0;i<N;++i){
      res += 1.0 / A[i];
  }

  res = 1.0 / res;

  printf("%.10f\n", res);
}


Measured memory_bytes: 256
a=int(input())
if a>=1800:
    print(1)
elif a>=1600 and a<1800:
    print(2)
elif a>=1400 and a<1600:
    print(3)
elif a>=1200 and a<1400:
    print(4)
elif a>=1000 and a<1200:
    print(5)
elif a>=800 and a<1000:
    print(6)
elif a>=600 and a<800:
    print(7)
elif a>=400 and a<600:
    print(8)

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

string canpas[31];

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) cin >> canpas[i];

    vector<P> pos;
    rep(r, H) rep(c, W) {
        if (canpas[r][c] == 'B') pos.emplace_back(r, c);
    }

    int ans = 0;
    rep(i, pos.size()) rep(j, pos.size()) {
        ans = max(ans, abs(pos[i].first-pos[j].first) + abs(pos[i].second - pos[j].second));
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3248
const input = require('fs').readFileSync('/dev/stdin', 'utf8')

let [a, b]: number[] = input.split('\n')[0].split(' ').map(Number)
let coins = 0
for (let i = 0; i < 2; i++) {
  if (a >= b) {
    coins += a
    a -= 1
  }
  else {
    coins += b
    b -= 1
  }
}
console.log(coins)

Measured memory_bytes: 7372
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

s = ns()
y = int(s[:4])
m = int(s[5:7])
d = int(s[8:])

if y < 2019 or (y == 2019 and m < 4) or (y == 2019 and m == 4 and d <= 30):
    print("Heisei")
else:
    print("TBD")

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(int &a, int b){
  if(a > b)
    a = b;
}
void chmax(int &a, int b){
  if(a < b)
    a = b;
}

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int n;
  cin >> n;
  vi x(n);
  rep(i, 0, n)
    cin >> x[i];
  
  int ans;
  
  rep(i, 1, 101){
    int sum = 0;
    rep(j, 0, n){
      sum += (x[j]-i)*(x[j]-i);
    }
    if(i == 1)
      ans = sum;
    else
      chmin(ans, sum);
  }
  
  cout << ans << endl;
  
  return 0;
  
}

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

int main() {
    long long x;
    cin >> x;
    long long ki = 100 , ans = 0;

    while (ki < x) {
        ki += ki * 0.01;
        ans++;
    }

    //cout << ki << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

vector<vector<int>> E;


int main(){ 
    int X, A;
    cin >> X >> A;

    if(X < A){
        cout << 0;
    }
    else{
        cout << 10;
    }
}



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

int main()
{
  int N;cin>>N;
  int a[N];
  for(int i=0;i<N;i++)cin>>a[i];
  int num[100001];fill(num,num+100001,0);
  int aminus=0;
  for(int i=0;i<N;i++)
  {
    num[a[i]+1]++;num[a[i]]++;num[a[i]-1]++;
    if(a[i]-1==-1)aminus++;
  }
  int ans=aminus;
  for(int i=0;i<100001;i++)ans=max(ans,num[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 4324
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner stdIn = new Scanner(System.in);
		int[] MonthNumOfDay = {
							       31,			// 1月
							       29,			// 2月
								   31,			// 3月
								   30,			// 4月
								   31,			// 5月
								   30,			// 6月
								   31,			// 7月
								   31,			// 8月
								   30,			// 9月
								   31,			//10月
								   30,			//11月
								   31,			//12月
							};
		while(stdIn.hasNext()){
			int numberOfDaysElapsed = 0;
			int[] day = {
						 	stdIn.nextInt(),	//月
						 	stdIn.nextInt()		//日
						};
			if(day[0] == 0 || day[1] == 0)break;
			for(int i = 0;i < day[0] - 1;i++){
				numberOfDaysElapsed += MonthNumOfDay[i];
			}
			numberOfDaysElapsed = numberOfDaysElapsed + day[1] - 1;		//1月1日からの経過日数(例：1月1日なら0日)
			switch (numberOfDaysElapsed % 7) {
			case 0:
				System.out.println("Thursday");
				break;
			case 1:
				System.out.println("Friday");
				break;
			case 2:
				System.out.println("Saturday");
				break;
			case 3:
				System.out.println("Sunday");
				break;
			case 4:
				System.out.println("Monday");
				break;
			case 5:
				System.out.println("Tuesday");
				break;
			case 6:
				System.out.println("Wednesday");
				break;
			default:
				System.out.println("error");
				break;
			}
		}
	}
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

void Muri(){
	cout<<-1<<endl;
	exit(0);
}

signed main(){
	string s=readString(),t=s;
	s+='a';
	reverse(ALL(t));
	t+='a';
	vector<pi> ps;
	int j=0,n=s.size();
	REP(i,n){
		if(s[i]=='x')continue;
		while(j<n&&t[j]=='x')j++;
		if(j==n||s[i]!=t[j]||(i==n-1&&j!=n-1))
			Muri();
		ps.PB(pi(i,j++));
	}
	int a=0,b=0;
	for(auto p:ps){
		int x=p.first+a,y=p.second+b;
		if(x>y)b+=x-y;
		else a+=y-x;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
#define mk make_pair
#define pi pair <int,int>
#define pl pair <ll,ll>
#define rep(a,b) for(int i=a;i<=b;i++)
#define rep_(a,b) for(int i=a;i>=b;i--)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin>>n;
    vi v(n);
    rep(0,n-1)
    	cin>>v[i];
	int max1=0,max2;
	rep(0,n-1)
	{
		if(v[max1]<v[i])
			max1=i;
	}
	max2=(max1==0)?1:0;
	rep(0,n-1)
	{
		if(max1==i)
			continue;
		if(v[max2]<v[i])
			max2=i;
	}
	rep(0,n-1)
	{
		if(i==max1)
		{
			cout<<v[max2]<<endl;
		}
		else
		{
			cout<<v[max1]<<endl;
		}
	}
}

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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

typedef struct insert
{
    int a, b;
};


ll min(ll x, ll y){
    if(x < y)return x;
    else return y;
}
int compare_int(const void *x, const void *y){
	struct insert *A = (struct insert *)x;
	struct insert *B = (struct insert *)y;
    return (A->a) - (B->a);
}

int main(void){
    int  n;
    ll k;
    scanf("%d %lld", &n, &k);
    struct insert aa[n];
    for(int i = 0;i < n;i++){
        scanf("%d %d", &aa[i].a, &aa[i].b);
    }
    qsort(aa, n, sizeof(struct insert), compare_int);
    for(int i = 0;i < n;i++){
        k -= aa[i].b;
        if(k <= 0){
            printf("%d\n", aa[i].a);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1788
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xx=[x[i+1]-x[i] for i in range(n-1)]
yy=[y[i+1]-y[i] for i in range(m-1)]
xsum=sum(xx[i]*(i+1)*(n-1-i) for i in range(n-1))%mod
ysum=sum(yy[i]*(i+1)*(m-1-i) for i in range(m-1))%mod
print(xsum*ysum%mod)

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

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = S.size() - T.size(); 0 <= i; i--) {
    bool ok = true;
    for (int j = 0; j < T.size(); j++) {
      if (S[i+j] != '?' && S[i+j] != T[j]) {
        ok = false;
        break;
      }
    }
    if (!ok) continue;
    for (int j = 0; j < S.size(); j++) {
      if (i <= j && j < i + T.size()) {
        cout << T[j-i];
      } else {
        cout << (S[j] == '?' ? 'a' : S[j]);
      }
    }
    cout << endl;
    return 0;
  }
  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repf(i, a, b) for(ll i = (a); i < (b) ; i++ )
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
cin >> n;
set<ll> s;

rep(i, n){
    ll a;
    cin >> a;
    s.insert(a);
}

ans=s.size();
if(ans%2==0)ans--;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 4992
// Stones.cpp
// https://atcoder.jp/contests/dp/tasks/dp_k


#include <iostream>
#include <cstring>
using namespace std;
typedef unsigned long long int llu;

int nNumbers;
int nStones;    
int numbers[100];

int memoTable[100001][2];

bool canTacoWin(int stonesLeft, bool tacoTurn){

    if(stonesLeft == 0){

        if(tacoTurn){
            return false;
        }
        return true;
    }

    if(memoTable[stonesLeft][tacoTurn] != -1){
        return memoTable[stonesLeft][tacoTurn];
    }

    bool isTacoWinner;

    if(tacoTurn){

        isTacoWinner = 0;

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

            if(numbers[i] > stonesLeft){
                break;
            }

            if(canTacoWin(stonesLeft - numbers[i], !tacoTurn)){
                isTacoWinner = 1;
                break;
            }

        }


    }else{

        isTacoWinner = 1;

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

            if(numbers[i] > stonesLeft){
                break;
            }

            if(!canTacoWin(stonesLeft - numbers[i], !tacoTurn)){
                isTacoWinner = 0;
                break;
            }

        }


    }

    memoTable[stonesLeft][tacoTurn] = isTacoWinner;
    return isTacoWinner;   

}

int main(){

    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); cout<<"Stones.cpp\n";

    cin >> nNumbers >> nStones;

    for(int i=0; i<nNumbers; ++i)
        cin >> numbers[i];

    memset(memoTable, -1, sizeof(memoTable));
    if(canTacoWin(nStones, true)){
        cout<<"First";
    }else{
        cout<<"Second";
    }
    return 0;
}



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

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


int main()
{
    int a,b,c;
    cin >>a>>b>>c;
    string res = "NO";
    FOR(i, 1, b+1){
        if((a*i)%b == c) {
            res = "YES";
            break;
        }
    }
    cout << res << endl;
} 

Measured memory_bytes: 256
def resolve():
    s = str(input())
    ans = 0
    ind = []
    for i, char in enumerate(s):
        if char == 'W':
            ind.append(i)
    lst = 0
    # print(ind)
    for i in ind:
        ans += (i - lst)
        lst += 1

    # idx = s.index('W')
    print(ans)
    return


resolve()

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

#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 MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  ll ans;
  for(ll i = 0; i*i <= N; i++){
    ans=i*i;
  }
  cout << ans << endl;

}





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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	cout << (a - 1) * (b - 1);
}

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

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

using llint = long long int;

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

class Graph{
public:
    ////////////グラフサイズを渡して作成する
    ////////////infの値は必要に応じて調整すること
    Graph(long long int n):g_size(n),edges(n,vector<long long int>(n,inf)){
        REP(i,n){
            edges[i][i] = 0;
        }


    }
    
    //////////// 枝のvector<>をわたして作成
    //////////// infの値は必要に応じて調整すること
    Graph(vector<pair<long long int,long long int>> v):g_size(v.size()),edges(v.size(),vector<long long int>(v.size(),inf)){
        REP(i,g_size){
            edges[i][i] = 0;
        }
        REP(i,v.size()){
            add_edge(v[i].first, v[i].second);
        }        
    }

    ///////////初期状態では有向
    ///////////無向にするときは
    /*  edges[b][a] = cost;  */
    //を追加
    void add_edge(long long int a,long long int b,long long int cost=1){
        edges[a][b] = cost;
        edges[b][a] = cost;
    }
      llint solve(){
        llint result = 0;
        result += search(0,1<<0);
        return result;
    }
    llint search(llint n,llint bit){
        if(bit==(1<<g_size)-1){
            return 1;
        }
        llint result = 0;
        REP(i,g_size){
            if(edges[n][i]!=1||((1<<i)&bit)){
                continue;
            }else if(((bit | (1 << i)))==(1<<g_size)-1){
                    return 1;
            }else{
                result += search(i, (bit | (1 << i)));
            }
        }
        return result;
    }
  

  
private:
    long long int g_size;
    vector<vector<long long int>> edges;
  
};

int main(){
    llint n, m;
    cin >> n >> m;
    Graph graph(n);
    llint tmpa, tmpb;
    REP(i,m){
        cin >> tmpa >> tmpb;
        graph.add_edge(tmpa-1, tmpb-1);
    }
    cout << graph.solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> v;
  string a;
  for(int i=0;i<n;i++){
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  int Max=0;
  int cnt=1;
  for(int i=1;i<n;i++){
    if(v[i]==v[i-1]){
      cnt++;
    }else{
      Max = max(Max,cnt);
      cnt = 1;
    }
  }
  Max = max(Max,cnt);
  cnt = 1;
  for(int i=1;i<n;i++){
    if(v[i]==v[i-1]){
      cnt++;
    }else{
      if(Max==cnt){
        cout << v[i-1] << endl;
      }
      cnt = 1;
    }
  }
  if(Max==cnt){
    cout << v[n-1] << endl;
  }
  return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, A, B, ans=0, tmp=0;
vector<ll> H;

signed main(){
    cin >> N >> A >> B;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        H.push_back(a);
    }
    ll ok = 10000000000;
    ll ng = 0;
    while(ok!=ng+1) {
        ll num = (ok+ng)/2;
        tmp = 0;
        for(int i=0;i<N;i++) {
            ll df = max(0LL, H[i]-num*B);
            tmp += df/(A-B);
            if(df%(A-B)!=0) tmp++;
        }
        if(tmp<=num) ok = num;
        else ng = num;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<set<int>> edge(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].insert(b), edge[b].insert(a);
    }
    int v = 0;
    vector<int> dist;
    for (int j = 0; j < 2; j++) {
        dist = vector<int>(N, -1);
        queue<pair<int, int>> q;
        q.push({v, 0});
        while(q.size()) {
            int x, d;
            tie(x, d) = q.front(); q.pop();
            dist[x] = d;
            for (auto y : edge[x]) {
                if (dist[y] >= 0) continue;
                q.push({y, d + 1});
            }
        }
        v = distance(dist.begin(), max_element(WHOLE(dist)));
    }
    int D = *max_element(WHOLE(dist));
    cout << (D % 3 != 1 ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 30852
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

typedef pair<ll, ll> pll;

pll min_diff(ll x, ll y) {
  ll diff = LLONG_MAX;
  if (y % 2 == 0) {
    diff = min(diff, (ll)0);
  } else {
    diff = min(diff, x);
  }
  if (x % 2 == 0) {
    diff = min(diff, (ll)0);
  } else {
    diff = min(diff, y);
  }
  return (pll){(x * y - diff) / 2, (x * y + diff) / 2};
}

int main() {
  ll h, w;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0) {
    printf("0\n");
    return 0;
  }

  ll ans = LLONG_MAX;
  FOR (i, 1, h) {
    ll bottom = i * w;
    auto md = min_diff(h-i, w);
    ll mi = min(md.first, bottom);
    ll ma = max(md.second, bottom);
    ans = min(ans, ma - mi);
  }
  FOR (i, 1, w) {
    ll bottom = i * h;
    auto md = min_diff(w-i, h);
    ll mi = min(md.first, bottom);
    ll ma = max(md.second, bottom);
    ans = min(ans, ma - mi);
  }

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

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cmath>
using namespace std;
double h[1010];
int main(){
	int i,n,t,a,ans;
	cin >> n >> t >> a;
	for(i=0;i<n;i++){
		cin >> h[i];
	}
	double mx = 1000000000;
	for(i=0;i<n;i++){
		double x = t - h[i]*0.006;
		if(mx>abs(a-x)){
			mx = abs(a-x);
			ans = i+1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    string n;
    int sum = 0;
    cin >> n;
    for(int i = 0; i < n.size(); i++){
        sum += (n[i] - '0');
    }
    if(sum % 9 == 0)    cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,a[(int)1e5+10];
int cnt,que[(int)1e5+10];

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

    int i,j,num[2]={0,0};
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    cnt=0,que[0]=-100000;
    for(i=n-1;i>-1;i--)
    {
        if(a[i]>=que[cnt])
            que[++cnt]=a[i];
        else
        {
            int l=1,r=cnt,mid;
            while(l<=r)
            {
                mid=(l+r)>>1;
                if(a[i]>=que[mid])
                    l=mid+1;
                else
                    r=mid-1;
            }
            que[l]=a[i];
        }
    }
    printf("%d\n",cnt);
    return 0;
}


/*

5
2 1 4 3 0

5
2 1 4 5 3


*/


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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N=100005;

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    // int t;cin>>t;while(t--)
    {
        int i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        for(i=1;i*i<=n;i++){
            if(n%i==0){
              cnt=i;sum=n/i;
              if(cnt<sum-1){
                ans+=sum-1;
              }
            }       
        }
        cout<<ans;
    }
}

Measured memory_bytes: 256
n,m,x = gets.chomp.split(" ").map(&:to_i)
a = Array.new.map{Array.new}
n.times do |i|
  a[i] = gets.chomp.split(" ").map(&:to_i)
end
ans = 100000000

[0, 1].repeated_permutation(n) do |bits|
  exp = Array.new(m,0)
  money = 0
  n.times do |i|
    if bits[i] == 1
      m.times do |j|
        exp[j] += a[i][j+1]
      end
      money += a[i][0]
    end
  end
  ans = money if (ans > money) && (exp.all?{ |y| y >= x })
end
puts ans != 100000000 ? ans : -1

Measured memory_bytes: 14552
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,k,xx,i=0,t,mini=1000000000;
  cin >> n >> k;
  vector<int> x;
  for (i=0;i<n;i++){
    cin >> xx;
    if (xx==0){
      k--;
      continue;
    }
    x.push_back(xx);
  }
  if (k==0){
    cout << 0 << endl;
    return 0;
  }
  i=0;
  while (i+k<x.size()&&x.at(i+k)<0) i++;
  do {
    t=min(abs(x.at(i)),abs(x.at(i+k-1)))+x.at(i+k-1)-x.at(i);
    if (mini>t) mini=t;
    i++;
  }while (i+k-1<x.size()&&x.at(i-1)<0);
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 892
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	static List<Integer> graph[];
	static int cnt[];
	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), q = fs.nextInt();
		graph = new ArrayList[n];
		for(int i=0;i<n;i++) graph[i] = new ArrayList<>();
		for(int i=0;i<n-1;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1;
			graph[a].add(b);
			graph[b].add(a);
		}
		
		cnt = new int[n];
		for(int i=0;i<q;i++) {
			int p = fs.nextInt()-1, x = fs.nextInt();
			cnt[p] += x;
		}
		
		dfs(0, -1, 0);
		for(int i=0;i<n;i++) {
			System.out.print(cnt[i] + " ");
		}
		System.out.println();
	}
	
	static void dfs(int v , int p, int x) {
		cnt[v] += x;
		x = cnt[v];
		
		for(int to:graph[v]) {
			if(to == p)continue;
			dfs(to, v, x);
		}
	}
	

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 129280
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int A, B;
    string S;

    cin >> A >> B >> S;

    for(int i = 0; i < A; i++){
        if(48 > S[i] || S[i] > 57){
            cout << "No" << endl;
            return 0;
        }
    }

    if(S[A] != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(int i = A+1; i < A+B+1; i++){
        if(48 > S[i] || S[i] > 57){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;


ll a, b, n;

int main() {
	cin >> a >> b >> n;
	
	n = min(n, b - 1);
	cout << (ll)(a * n / b);

	return 0;
}


Measured memory_bytes: 3628
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vll          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        998244353
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll dp[N][3];
ll a[3][N];
int main()
{
	ios
	ll i,j,n;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[0][i]>>a[1][i]>>a[2][i];
	dp[0][0]=a[0][0];
	dp[0][1]=a[1][0];
	dp[0][2]=a[2][0];
	for(i=1;i<n;i++){
		for(j=0;j<3;j++){
			if(j==0)
			dp[i][j]=max(dp[i][j],a[j][i]+max(dp[i-1][1],dp[i-1][2]));
			if(j==2)
			dp[i][j]=max(dp[i][j],a[j][i]+max(dp[i-1][1],dp[i-1][0]));
			if(j==1)
			dp[i][j]=max(dp[i][j],a[j][i]+max(dp[i-1][0],dp[i-1][2]));
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}

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

int main() {
  int A,B,H,M; cin>>A>>B>>H>>M;
  double thetaM = ((double)M/60)*2*M_PI;
  double thetaH = ((double)H/12)*2*M_PI + ((double)M/(60*12))*2*M_PI;
  double xm = A*cos(thetaM), ym = A*sin(thetaM);
  double xh = B*cos(thetaH), yh = B*sin(thetaH);
  printf("%.10f\n",sqrt(pow(xm-xh,2) + pow(ym-yh,2)));
}


Measured memory_bytes: 4032
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;



int main(){

	int n[102]={};

	int x,y;

	while(cin>>x>>y){
		n[x]++;n[y]++;

		if(x==0&&y==0){
			bool f=true;
			for(int i=1;i<101;i++){
				if(i<3&&n[i]%2==0)f=false;
				else if(i>2&&n[i]%2==1)f=false;}
		if(f==true)cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
		
		for(int i=1;i<101;i++)
			n[i]=0;

		}
		
	}
return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(int i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
int main(){
    fast;
    string s;
    cin>>s;
    int month=(s[5]-'0')*10+(s[6]-'0');
    int dat=(s[8]-'0')*10+(s[9]-'0');
    if(month<4 || (month==4 && dat<=30))
        cout<<"Heisei";
    else
        cout<<"TBD";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m, p[100010];
string s[100010];

map<int, vector<string>> mp;

int main() {
    cin >> n >> m;
    rep(i, m) cin >> p[i] >> s[i];

    rep(i, m) {
        mp[p[i]].push_back(s[i]);
    }

    int ns = 0, np = 0;
    for (auto it=mp.begin(); it != mp.end(); it++) {
        int now = it->first;
        auto v = it->second;

        int nnp = 0;
        for (int i = 0; i < v.size(); i++) {
            if (v[i] == "AC") {
                ns++;
                np += nnp;
                break;
            } else {
                nnp++;
            }
        }
    }
    cout << ns << " " << np << endl;
}


Measured memory_bytes: 17024
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int H, W, c, A, ans = 0;
	cin >> H >> W;
	vector<vector<pair<int, int>>> a(10);
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c;
			a[i].emplace_back(c, j);
		}
	}
	for (int i = 0; i < H * W; i++) {
		cin >> A;
		if (A == -1) continue;
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> b;
		b.emplace(0, A);
		vector<bool> d(10);
		vector<int> e(10, INT_MAX);
		e[A] = 0;
		while (!b.empty()) {
			pair<int, int> f = b.top();
			b.pop();
			d[f.second] = true;
			for (pair<int, int>& j : a[f.second]) {
				if (d[j.second]) continue;
				if (e[f.second] + j.first < e[j.second]) {
					e[j.second] = e[f.second] + j.first;
					b.emplace(e[j.second], j.second);
				}
			}
		}
		ans += e[1];
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        long A = in.nextLong();
        long B = in.nextLong();
        int bit[] = new int[41];

        if((B-A+1)%2 == 0){
            bit[0] = (int)(((B-A+1)/2)%2);
        } else {
            bit[0] = (int)(((B-A)/2 + B%2)%2);
        }

        for (int i=1; i<41; i++) {
            long ai = (long) (A % Math.pow(2, i+1));
            long bi = (long) (B % Math.pow(2, i+1));
            if(ai < Math.pow(2, i) && bi < Math.pow(2, i)){
                bit[i] = 0;
            } else if(ai >= Math.pow(2, i) && bi >= Math.pow(2, i)){
                bit[i] = (int) ((Math.max(ai, bi) - Math.min(ai, bi) + 1)%2);
            } else {
                if(bi > ai){
                    bit[i] = (int) ((bi + 1)%2);
                } else {
                    bit[i] = (int) ((ai)%2);
                }
            }
        }

        long sum = 0;
        for (int i=0; i<41; i++) {
            sum += bit[i] * Math.pow(2, i);
        }
        out.println(sum);
}

}
}





Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


vector<int> edge;
vector<vector<pair<int, int>>> g;


void dfs(int v, int p=-1, int pc=-1){
    int color=1;
    if(color==pc) color += 1;
    for(auto x: g[v]){
        if(x.first==p) continue;
        edge[x.second] = color;
        dfs(x.first, v, color);
        color += 1;
        if(color==pc) color += 1;
    }
}


int main(){
    int n;  cin >> n;
    g.resize(n);
    edge.assign(n-1, -1);

    REP(i, n-1){
        int a, b;   cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }
    int max_color=0;
    REP(i, n)   max_color = max(max_color, (int)g[i].size());
    dfs(0);
    cout << max_color << endl;
    for(auto x: edge)
        cout << x << endl;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
#define MP make_pair
#define PB emplace_back
#define MAX 2000000000LL
using namespace std;
typedef long long ll;
template<typename T>
inline T read(T&x){
    x=0;int f=0;char ch=getchar();
    while (ch<'0' || ch>'9') f|=(ch=='-'),ch=getchar();
    while (ch>='0'&& ch<='9') x=x*10+ch-'0',ch=getchar();
    return x=f?-x:x;
}
const int N=1e5+10;
int n,i,h[N],dp[N];
int main(){
	read(n);
	for (i=1;i<=n;++i) read(h[i]);
	for (i=2;i<=n;++i) dp[i]=2000000000;
	for (i=2;i<=n;++i){
		if (i-1>=1) dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		if (i-2>=1) dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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


using namespace std;



int main() {

	int n, p;
	cin >> n >> p;
	int a = 0, b = 0, s = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		s += x;
		if (x % 2)a++;
		else b++;
	}
	long long int ans = 1;
	if (a ==0) {
		if (p==1)cout << 0 << endl;
		else cout <<(long long) pow(2, n) << endl;
	}
	else cout <<(long long ) pow(2, n-1) << endl;
		return 0;

}




Measured memory_bytes: 512
def main():
    K,N = map(int,input().split())

    if K % 2 == 0:
        ans = [K//2]
        for i in range(N-1):
            ans.append(K)
    else:
        back = N // 2
        mid = K // 2 + 1
        ans = [mid for i in range(N)]
        for i in range(back):
            if ans[-1] == 1:
                ans.pop()
            else:
                ans[-1] -= 1
                while len(ans) < N:
                    ans.append(K)
    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 26520
#![allow(unused_imports)]
use proconio::input;
use proconio::marker::*;
use std::collections::{HashSet, HashMap};

fn size(
  parents: &mut Vec<isize>,
  i: isize
) -> isize {
  let ii = find(parents, i) as usize;
  -1 * parents[ii]
}

fn find(
  parents: &mut Vec<isize>,
  i: isize
) -> isize {
  let ui = i as usize;
  if -1 < parents[ui] {
    parents[ui] = find(parents, parents[ui]);
    parents[ui]
  } else {
    i
  }
}

fn connect(
  parents: &mut Vec<isize>,
  a: isize,
  b: isize,
) -> bool {
  let pa = find(parents, a);
  let pb = find(parents, b);
  
  if pa == pb { return false }
  
  let av = size(parents, pa);
  let bv = size(parents, pb);
  
  let upa = pa as usize;
  let upb = pb as usize;
  if av < bv {
    parents[upb] += parents[upa];
    parents[upa] = pb;
  } else {
    parents[upa] += parents[upb];
    parents[upb] = pa;
  }
  true
}

fn main() {
  input! {
    n: usize,
    m: usize,
    vals: [Usize1;n],
    queries: [(Isize1, Isize1);m]
  }
  
  let mut parents: Vec<isize> = vec![-1;n];
  for (a, b) in queries.iter() {
    connect(&mut parents, *a, *b);
  }
  for (a, b) in queries {
    connect(&mut parents, a, b);
  }
  
  let mut map: HashMap<usize, HashSet<usize>> = HashMap::new();
  
  for i in 0..n {
    let v = parents[i];
    if v < 0 {
      let entry = map.entry(i).or_insert(HashSet::new());
      entry.insert(i);
    } else {
      let uv = v as usize;
      let entry = map.entry(uv).or_insert(HashSet::new());
      entry.insert(i);
    }
  }
  
  let mut result = 0;
  for (_, v) in map {
    for vv in v.iter() {
      let vvv = vals[*vv];
      if v.contains(&vvv) {
        result += 1;
      }
    }
  }
  
  println!("{}", result);
}

Measured memory_bytes: 20280