akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<ll> table;

ll dp(ll n)
{
  if(n==0) return 0;
  if(table.at(n)<INF) return table.at(n);
  chmin(table.at(n),dp(n-1)+1);
  for(int i=1;i<=7;i++)
  {
    if(n-pow(6,i)>=0) chmin(table.at(n),dp(n-pow(6,i))+1);
  }
  for(int i=1;i<=6;i++)
  {
    if(n-pow(9,i)>=0) chmin(table.at(n),dp(n-pow(9,i))+1);
  }
  
  return table.at(n);
}  
  

int main() 
{
  ll N; cin>>N;
  table=vector<ll>(N+1,INF);
  //table.at(0)=0;
  cout<<dp(N)<<endl;
  return 0;
}

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

const double PI=3.141592653589793;

int main()
{
  vector<int> n(5);
  rep(i,5) 
    cin >> n.at(i);
  rep(i,5){
    if(n.at(i)==0) {
      cout << i+1 << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
#include<math.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  int x[n] , y[n];
  for(int i = 0;i < n;i ++){
    scanf("%d %d",&x[i],&y[i]);
  }
  double gou = 0;
  double ave = 0;

  for(int i = 0;i < n;i ++){
    for(int j = 0;j < n;j ++){
      int X = x[i] - x[j];
      int Y = y[i] - y[j];

      gou += sqrt((int)pow(X,2) + (int)pow(Y,2));
    }
    ave += gou/n;
    gou = 0;
  }

  printf("%lf\n",ave);

  return 0;
}

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

int main() {

    int N;
    cin >> N ;

for (int i=0;i<=10000;){
    if((N-1000*i)<=1000){
        cout << 1000*(i+1)-N << endl;
        break;
    }
    else{
       i++; 
    }
    }

    /*
    for (int i=0;i<=10000;i++){
    if((1000*i)>=N){
        cout << i << endl;
        cout << 1000*i-N << endl;
        break;
    }
    else{
        i++;
    }
    }
    */
    
    

   return 0;

}





Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m;
  cin >> n >> m;
  vector<ll> s(n+1),t(m+1);
  unordered_map<ll,vector<ll>> spos,tpos;
  for(ll i = 1; i <= n; ++i){
    cin >> s[i];
    spos[s[i]].push_back(i);
  }
  for(ll i = 1; i <= m; ++i){
    cin >> t[i];
    tpos[t[i]].push_back(i);
  }
  vector<vector<ll>> cnt(n+1,vector<ll>(m+1));
  vector<vector<ll>> cnt2(n+1,vector<ll>(m+1));
  vector<vector<ll>> ps(n+1,vector<ll>(m+1));
  for(ll i = 0; i <= n; ++i) cnt[i][0] = 1;
  for(ll j = 0; j <= m; ++j) cnt[0][j] = 1;
  cnt2[0][0] = 1;
  for(ll i = 1; i <= n; ++i){
    for(ll j = 1; j <= m; ++j){
      cnt[i][j] = cnt[i][j-1];
      ps[i][j] = ps[i-1][j];
      if(s[i] == t[j]){
        cnt2[i][j] = cnt[i-1][j-1];
        ps[i][j] = (ps[i][j]+cnt2[i][j])%MOD;
      }
      cnt[i][j] = (cnt[i][j]+ps[i][j])%MOD;
    }
  }
  cout << cnt[n][m]%MOD;
  return 0;
}


Measured memory_bytes: 94592
package main

import (
	"fmt"
)

func main()  {
	var n int
	//  	var n string
	fmt.Scan(&n)

	if n % 1000 == 0{
		fmt.Println("0")
		return
	}

	money := 0
	for i := 0; i < 10; i++ {
		money += 1000
		if n < money{
			fmt.Println(money - n)
			return
		}
	}

}


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


int P[100001];

int root(int x){
    if(P[x] == x){
        return x;
    }
    return P[x] = root(P[x]);
}

void unite(int x, int y){
    P[root(x)] = root(y);
}

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

int main(){
    for(int i = 1; i <= 100000; i++){
        P[i] = i;
    }
    
    int p_inv[100001], N, M;
    cin >> N >> M;
    for(int i = 1; i <= N; i++){
        int p;
        cin >> p;
        p_inv[p] = i;
    }
    for(int m = 1; m <= M; m++){
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }

    int ans = 0;
    for(int n = 1; n <= N; n++){
        if(is_same_set(p_inv[n], n)){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main (void){

 int a , b , c , i , count;
 
 scanf("%d %d %d", &a , &b, &c);
 
 for(i = a ; i <= b; i++){
     if(c % i == 0)
      count++;
 }
 
 printf("%d\n", count);
 return 0;
}

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

int main(){
    int a,b,k;
    vector<int> v = {};
    cin >> a >> b >> k;
    for(int i=1; i<=min(a,b); i++){
        if(a%i==0 && b%i==0) v.push_back(i);
    }
    auto it = v.end();
    for(int i=0; i<k; i++) it--;
    cout << *it << endl;

    return 0;
}

Measured memory_bytes: 256
line1 = input().split()
n = int(line1[0])
m = int(line1[1])
x = int(line1[2])

books = []
for i in range(n):
  line = input().split()
  book = [int(line[0])]
  for j in range(1, m + 1):
    book.append(int(line[j]))
  books.append(book)

# 全件検索する
prices = []
for p in range(2 ** n):
  u = [0] * m
  p_str = format(p, 'b').zfill(n)
  price = 0
  for k in range(len(p_str)):
    if p_str[k] == '1':
      price += books[k][0]
      for j in range(m):
        u[j] += books[k][j + 1]
  if min(u) >= x:
    prices.append(price)

if len(prices) > 0:
  print(min(prices))
else :
  print(-1)



Measured memory_bytes: 9292
N = int(input())

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

A = sorted(A, reverse=True)

c = 0
for l in range(N-2):
    for m in range(l+1, N-1):
        for n in range(m+1, N):
            if A[l] < A[m] + A[n] and A[l] != A[m] != A[n]:
                c+=1

print(c)


Measured memory_bytes: 9176
import Control.Applicative( (<$>))
import Data.Array.IArray( listArray, Array, (!))

main = do
    let
	readLine = map read . words <$> getLine
    [n_, p_] <- readLine
    as_ <- readLine
    let
	facts _ 0 = 1:(facts 1 1)
	facts 1 1 = 1:(facts 1 2)
	facts n i = let
		    a = n*toInteger i
		in
		    a:(facts a $ i+1)

	factArr::Array Int Integer
	factArr = listArray (0,n_) (facts undefined 0)

	fact 0 = 1
	fact 1 = 1
	fact n = factArr!n

	combi::Int->Int->Integer
	combi n r = (fact n) `quot` (fact r) `quot` (fact $ n-r)

	numEven = length $ filter even as_
	numOdd = n_ - numEven

	a = sum [ combi numEven  r | r<-[0..numEven]]
	p0 = let
		b = sum [ combi numOdd  r | r<-[0,2..numOdd]]
	    in
		a*b

	p1 = let
		b = sum [ combi numOdd  r | r<-[1,3..numOdd]]
	    in
		a*b
	
    print $ if p_==0
	    then p0
	    else p1

Measured memory_bytes: 764
ABCD = list(input())

for i in range(2 ** 3):
    ptn = ['-'] * 3
    for j in range(3):
        if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = '+'

    formula = ''.join([n + op for n, op in zip(ABCD, ptn + [''])])
    if eval(formula) == 7:
        print(formula + '=7')
        exit()


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

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll n;
    cin >> n;
    ll a,b,c;
        cin >> a >> b >> c;
    if(n==1){
        cout << max(a,max(b,c)) << endl;
    }
    else{
        n-=1;
        while(n--){
            ll a1,b1,c1;
            cin >> a1 >> b1 >> c1;
            ll arr[3];
            arr[0] = max(a1+b,a1+c);
            arr[1] = max(b1+a,b1+c);
            arr[2] = max(c1+a,c1+b);
            
            a=arr[0];
            b=arr[1];
            c=arr[2];
        }
        cout << max(a,max(b,c)) << endl;
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int k, x;cin>>k>>x;
  for(int i = max(x-k+1, -1000000); i <= min(x+k-1, 1000000); i++) cout << i << " ";

  
  cout << endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	string s;
	cin>>s;
	FOR (i, 0, SZ(s) - 8)
	{
		cout<<s[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#define INF 0x3f3f3f3f
#define LL long long
const int N = 100000+5;
using namespace std;
int x[N];
int dp[N][50];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&x[i]);
 
    int L,Q;
    scanf("%d%d",&L,&Q);
    for(int i=1; i<=n ;i++){
        int left=i+1,right=n;
        while(left<=right){
            int mid=(left+right)/2;
            if(x[mid]<=L+x[i])
                left=mid+1;
            else
                right=mid-1;
        }
        
        if(x[i]+L>=x[n])
            dp[i][0]=n;
        else
            dp[i][0]=left-1;
    }
 
    for(int i=1; i<=30; i++)
        for(int j=1; j<=n; j++)
            dp[j][i]=dp[dp[j][i-1]][i-1];
 
    while(Q--){
        int a,b;
        scanf("%d%d",&a,&b);
        if(b<a)
            swap(a,b);
        LL res=0;
        for(int i=30; i>=0; i--){
            if(dp[a][i]<b){
                res+=(1<<i);
                a=dp[a][i];
            }
        }
        printf("%lld\n",res+1);
    }
    return 0;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0
 
//link: https://atcoder.jp/contests/arc103/tasks/arc103_a
 
vector <int> e;
vector <int> o;
map <int, int> mpe;
map <int, int> mpo;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	bool can = true;
	int n; cin >> n;
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		if (i % 2 == 0) o.pb(x);
		else e.pb(x);
	}
	// find the top 2 modes
	for(auto it:e) {
		++mpe[it];
	}
	vector <pii> MPE; // convert to vector for sorting
	for(auto it:mpe) {
		MPE.pb(it);
	}
	sort(all(MPE), [] (pii &i, pii &j) {
		return i.second > j.second;
	});
	int e1 = MPE[0].first;
	int e2 = MPE[1].first;
	cerr << e1 << ' ' << e2 << '\n';
	// repeat!!
	for(auto it:o) {
		++mpo[it];
	}
	vector <pii> MPO;
	for(auto it:mpo) {
		MPO.pb(it);
	}
	sort(all(MPO), [] (pii &i, pii &j) {
		return i.second > j.second;
	});
	int o1 = MPO[0].first;
	int o2 = MPO[1].first;
	cerr << o1 << ' ' << o2 << '\n';
 
	if (e1 != o1) {
		// assert(0);
		int count = 0;
		for(auto it:e) {
			if (it != e1) ++count;
		}
		for(auto it:o) {
			if (it != o1) ++count;
		}
		cout << count;
		time;
	}
 
	// find the number of changes required for first type
	int count = 0;
	for(auto it:e) {
		if (it != e1) ++count;
	}
	for(auto it:o) {
		if (it != o2) ++count;
	}
	// second type
	int sum = 0;
	for(auto it:e) {
		if (it != e2) ++sum;
	}
	for(auto it:o) {
		if (it != o1) ++sum;
	}
	cout << min(count, sum);
}

Measured memory_bytes: 12624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int ans=0;
int N;
cin>>N;
for(int i=1;i<=N;++i){
  if(0<i && i<10){
    ans+=1;
  }
  else if(99<i && i<1000){
    ans+=1;
  }
  else if(9999<i && i<100000){
    ans+=1;
  }
}
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

from collections import Counter
c = Counter()
for i in range(n):
    tmp = list(map(int,input().split()))
    for j in tmp[1:]:
        c[j] += 1
cnt = 0
for i in c:
    if c[i] == n:
        cnt += 1
print(cnt)

Measured memory_bytes: 3316
N = int(input())
aList = list(map(int,input().split()))
oddnum = len(list(filter( lambda x: x % 2==1, aList)))
fournum = len(list(filter( lambda x: x % 4==0, aList)))

check = False
if oddnum == 0:
    check = True
elif oddnum <= fournum:
    check = True
elif oddnum - 1 == fournum and (oddnum + fournum) == N:
    check = True
else:
    check = False
print( 'Yes' if check else 'No')

Measured memory_bytes: 14252
#include<cstdio>
#include<algorithm>
#include<climits>
using namespace std;
int getMaxProfit(int[],int); 
 
int main(){
  int n;
  scanf("%d",&n);
  int data[n];
  for(int i=0;i<n;i++)
    scanf("%d",&data[i]);
 
  printf("%d\n",getMaxProfit(data, n));
  return 0;
}

int getMaxProfit(int data[],int n)
{
  int i=0,key,m=INT_MIN;
  
  key=data[0];
  for(int i=1;i<n;i++){
    if(data[i]-key>m)
      m=data[i]-key;
    if(key>data[i])
      key=data[i];
  }
  return m;
}

Measured memory_bytes: 1804
N = int(input())
xu = [list(map(str,input().split())) for i in range(N)]

Ans = []

for i in range(N):
    if xu[i][1] == "JPY":
        Ans.append(int(xu[i][0]))
    else:
        Ans.append(float(xu[i][0]) * 380000)

print(sum(Ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LL long long
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(x,l,r) for(int x=l,x##_=r;x<=x##_;x++)
#define FR(x,l,r) for(int x=l,x##_=r;x<x##_;x++)
#define DOR(x,r,l) for(int x=r,x##_=l;x>=x##_;x--)
using namespace std;
const int N=1000005;
bool mark[N];
int A[105][105];
int n,m,ans;
int main () {
	scanf("%d%d",&n,&m);
	FOR(i,1,n)FOR(j,1,m)scanf("%d",&A[i][j]);
	FOR(i,1,1000)mark[i*i]=1;
	FOR(i,1,n)FOR(j,i+1,n) {
		int s=0;
		FOR(k,1,m)s+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
		if(mark[s])ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
t=list(ss())
ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
print(ans)


Measured memory_bytes: 40864
#include<bits/stdc++.h>
using namespace std;
int a[3005];
vector<int> edge[3005];
bool dfs(int u){
	for(int i=0;i<edge[u].size();i++){
		int v=edge[u][i];
		if(a[u]>a[v]&&!dfs(v)){
			return 1;
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		if(dfs(i)) cout<<i<<" ";
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  int up=H,dw=0,ri=W,le=0;
  int x,y,a;
  while(N--) {
    cin >> x >> y >> a;
    switch(a) {
      case 1: le = max(le, x); break;
      case 2: ri = min(ri, x); break;
      case 3: dw = max(dw, y); break;
      case 4: up = min(up, y); break;
      default: break;
    }
  }
  //printf("%d %d %d %d\n", up, dw, ri, le);
  cout << max((ri-le),0) * max((up-dw),0) << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(){
    int W, H, x, y, r;
    while(scanf("%d %d %d %d %d", &W, &H, &x, &y, &r) == 5){
        if(x>=r && y>=r && (W-x)>= r && (H-y)>= r){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
return 0;
}



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

int count = 0;
void merge(int arr[], int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 = r - m; 

    int L[n1], R[n2]; 

    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  

    i = 0; 
    j = 0; 
    k = l; 
    while (i < n1 && j < n2) 
    { 
    	count++;
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++;
        } 
        else
        { 
            arr[k] = R[j]; 
            j++;
        } 
        k++; 
    } 
  

    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
        count++;
    } 
  

    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
        count++;
    } 
} 
  

void mergeSort(int arr[], int l, int r) 
{ 
    if (l < r) 
    { 
        int m = l+(r-l)/2; 

        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
} 

int main(){

	int n;

	cin >> n;

	int arr[n];

	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}

	mergeSort(arr, 0, n - 1); 

	for(int i = 0; i < n; i++)
	{
		if(i == n-1)
			cout << arr[i];
		else	
			cout << arr[i] << " ";
	}

	cout << endl;
	cout << count;
	cout << endl;

	return 0;
}


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

#define int long long

const int INF = 1e15;

int dp[55555];
int c[22];

int n, m;

signed main() {
  cin >> n >> m;
  for (int i = 0; i <= m; i++) {
    cin >> c[i];
  }

  fill(dp, dp+n+5, INF);
  dp[0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (i - c[j] >= 0) {
        dp[i] = min(dp[i], dp[i-c[j]] + 1);
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 3508
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	if (n < 1000)
		cout << "ABC" << endl;
	else
		cout << "ABD" << endl;
} 

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

int main()
{
    int h, w;
    char map[105][105];
 
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> map[i][j];
        }
    }
 
    for (int i = -1; i <= h; i++) {
        for (int j = -1; j <= w; j++) {
            if (i >= 0 && i < h &&
                    j >= 0 && j < w) {
                cout << map[i][j];
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
 
    return 0;
}

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

using namespace std;

int main()
{
    long long N, K;
    cin >> N >> K;
    long long ans = 0;
    if(N % K < abs(N % K - K)){
        ans = (N % K);
    }
    else{
        ans = abs(N % K -K);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int>> can(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%d", &can[i][j]);
        }
    }
    vector<int> dp(1 << n); // 2^n
    dp[0] = 1;
    //~ for(int a = 0; a < n; ++a) {
    for(int mask = 0; mask < (1 << n) - 1; ++mask) {
        int a = __builtin_popcount(mask); // the number of bits set to 1
        for(int b = 0; b < n; ++b) {
            if(can[a][b] && !(mask & (1 << b))) {
                int m2 = mask ^ (1 << b);
                //~ debug() << imie(mask) imie(m2) imie(dp[mask]);
                add_self(dp[m2], dp[mask]);
            }
        }
    }
    //~ }
    printf("%d\n", dp[(1<<n)-1]);
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll m,n,p,q,ct,s;
    vector<ll>v;
    cin>>m>>n;
    ct=s=0;
    for(ll i=0;i<m;i++)
    {
        cin>>p;
        v.push_back(p);
        s+=p;
    }
    //sort(v.begin(),v.end(), greater<int>());
    ct=0;
    for(ll i=0;i<m;i++)
    {
        if(v[i]*(4*n)>=s) ct++;
    }

    if(ct>=n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int w = sc.nextInt();
int h = sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
int r = sc.nextInt();

if(r<=x && x<=w-r && r<=y && y<=h-r){
System.out.println("Yes");
}
else{
System.out.println("No");
}

}
}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数
int long long GetDigitSum(int long long n){
    if(n < 10){
       return n;
    }
    return GetDigitSum(n/10) + n%10;
} //十進数の桁和
unsigned int long long unsignedGetDigitSum(unsigned int long long n){
    if(n < 10){
       return n;
    }
    return unsignedGetDigitSum(n/10) + n%10;
} //十進数の桁和
int long long divisorcount(int long long n){
	int long long ans = 1;
	vector<int> x(n + 1);
	int long long num = n; // 素因数分解する変数num 
	for (int long long i = 2; i <= n; i++) {
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
	}
	for (int i = 2; i <= n; i++){
		ans *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    return ans;
} //約数カウント

int main(){
    int N;
    cin >> N;
    vector<int> V(N+1);
    for(int i = 0; i < N; i++){
        cin >> V.at(i);
    }
    unsigned int long long ans = 0;
    if(N == 1){
        cout << ans << endl;
    }
    else{
        for(int i = 0; i < N-1; i++){
            if(V.at(i) > V.at(i+1)){
                ans = ans + (V.at(i) - V.at(i+1));
                V.at(i+1) = V.at(i+1) + (V.at(i) - V.at(i+1));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll N, M, K;

ll calc(ll L, ll C, ll W){
    ll ret = 0;
    REPi(m,1,L){
        ret += m*(L - m);
        ret %= MOD;
    }

    ret *= W;
    ret %= MOD;
    ret *= W;
    ret %= MOD;
    ret *= C;
    ret %= MOD;

    return ret;
}

//const int MAX_N = 200000;
//
//ll fact[MAX_N+100];
//ll frev[MAX_N+100];
//
//ll rev(ll a, ll p){
//    if(p == 0) return 1;
//    ll tmp = rev(a, p/2);
//    tmp = tmp * tmp % MOD;
//    if(p % 2 == 1) tmp = tmp * a % MOD;
//    return tmp;
//}
//
//
//void calc_fact(){
//    fact[0] = frev[0] = 1;
//    for(int i = 1; i <= MAX_N; i++){
//        fact[i] = (fact[i-1] * i) % MOD;
//        frev[i] = rev(fact[i], MOD-2);
//    }
//}
//
//
//ll comb(int n, int k){
//    if(n < 0 || k < 0 || n < k) return 0;
//    if(n == 0 || k == 0) return 1;
//    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
//}

//a**b
ll mod_pow(ll a, ll b){
    ll ret = 1;
    while(b > 0){
        if(b & 1) ret *= a;
        b >>= 1;
        a *= a;
        a %= MOD;
        ret %= MOD;
    }
    return ret;
}

//xCy
ll comb(ll x, ll y){
    ll top = 1, bot = 1;
    REP(i,y){
        top *= x-i;
        bot *= y-i;
        top %= MOD;
        bot %= MOD;
    }

    ll ret = top * mod_pow(bot, MOD-2);
    return ret % MOD;
}

int main(){
    cin >> N >> M >> K;

    ll ans = 0;

    //in main function
    //fact[0] = frev[0] = 1;
    //for(int i = 1; i <= MAX_N; i++){
    //    fact[i] = (fact[i-1] * i) % MOD;
    //    frev[i] = rev(fact[i], MOD-2);
    //}

    ll C = comb(N*M-2, K-2);

    ans += calc(N, C, M);
    ans %= MOD;
    ans += calc(M, C, N);
    ans %= MOD;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,a,b,c,d,flag;
int main() {
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    for (int i=0;i<n;i++) {
        int t = n-i-1;
        LL ll = a + 1LL * i * c;
        LL rr = a + 1LL * i * d;

        LL lll = b + 1LL * t * c;
        LL rrr = b + 1LL * t * d;

        LL tl = max(ll, lll);
        LL tr = min(rr, rrr);
        if (tl <= tr) flag = 1;
    }   
    puts(flag?"YES":"NO");
    return 0;       
}

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


int main() {

ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string a;

bool T=true;
int n;
cin >> n >> a;
if(n%2==1)
{
    cout<<"No";
    return 0;
}
for(int i=0; i<n/2; i++)
    if(a[i]!=a[i+(n/2)])
        T=false;


cout<<(T?"Yes":"No");
return 0;
}

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

int main()
{
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    //長針の作る角度
    double long_make = H * 30 + M * 0.5; 
    //短針の作る角度
    double short_make =  M * 6;

    //角度
    double angle = abs(long_make - short_make);
    //弧度法
    angle = (angle * M_PI) / 180;

    //余弦定理
    double result = sqrt(A * A + B * B - 2 * A * B * cos(angle));

    printf("%.9lf\n", result);

    return 0;

}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n, k;
  cin >> n >> k;
  double ans = 0.0;
  for(ll i = 1; i <= n; i++){
    double res = 1.0;
    ll cnt = i;
    while(cnt < k) cnt *= 2, res /= 2.0;
    ans += res;
  }
  ans /= n;
  printf("%.16f\n", ans);
  return 0;
}

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

int main()
{
    char str[5];
    char c='R';
    cin>>str;
    int ans=0;
    if(str[0]==c)
    {
        ans=1;
        if(str[1]==c)
        {
            ans++;
            if(str[2]==c)
            {
                ans++;
            }
        }

    }
    else
    {
        ans=0;
        if(str[1]==c)
        {
            ans++;
            if(str[2]==c)
            {
                ans++;
            }
        }
        else
        {
            if(str[2]==c)
            {
                ans++;
            }
        }
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  rep(i,n)a[i]--;
  vi a2(n);
  rep(i,n)a2[a[i]]=i;
  //sort(a2.begin(),a2.end());
  rep(i,n){
    cout<<a2[i]+1<<" ";
  }
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

	long long int x,y;
	long long ans;
	const long long maxs=1000000000000000000;
	bool abc;

int main()
{
	cin>>x>>y;
	if(!(x%y))
	{
		cout<<"-1";
		return 0;
	}
	for(long long i=2;i*x<=maxs;i++)
	{
		if((i*x)%y)
		{cout<<i*x;abc=1;break;}
	}
	if(!abc)cout<<"-1";
}

Measured memory_bytes: 256
#include<string>
#include<list>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      it = find(data.begin(),data.end(),x);
      if(it!=data.end())data.erase(it);
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it){
    cout << *it << " ";
  }
  cout << *it << endl;
}

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

long long operation(char operand,int num1,int num2){
  switch(operand){
    case '+': return num1+num2;
              break;
    case '-': return num2-num1;
              break;
    case '*': return num1*num2;
  }
}



long long pol[1000];
char item[1000];
char num[10];

long long pop(long long a[],int *top){
  *top = *top - 1;
  return a[*top];
}
void push(long long a[],long long value,int *top){
  a[*top] = value;
  *top = *top + 1;
}

int main(){
  
  
  
  int top = 0;
  
  char *c;
  
fgets(c=item,500,stdin);

int len = strlen(item);
int index = 0;

for(int i=0;i<len;i++){
    if(item[i]=='+' || item[i] == '-' || item[i] == '*'){
   long long num1 = pop(pol,&top);
   long long num2 = pop(pol,&top);
  long long result = operation(item[i],num1,num2);
    
   push(pol,result,&top);
  }
  else if(item[i]!=' '){
    num[index++] = item[i];
  }
  else if(item[i] == ' ' && item[i-1] != '+' && item[i-1]!='-' && item[i-1]!='*'){
    num[index] = '\0';
    long long num1 = atoi(num);
   push(pol,num1,&top);
    index = 0;
  }
}

 //for(int i=0;i<10;i++)printf("%lli ",pol.value[i]);
 printf("%lli\n",pol[0]);
 
  return 0;
}


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

using namespace std;
using ll = long long;
const int MAXN = 1.01e3;
const int inf = 1.01e8;
int ar[MAXN], br[MAXN];
int dp[MAXN][10 * MAXN];
int n;

int rec(int i, int h) {
  if(h <= 0) return 0;
  if(i == n) return inf;
  int &res = dp[i][h];
  if(res != -1) return res;
  return res = min(rec(i + 1, h), br[i] + rec(i, h - ar[i]));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int h; cin >> h;
  cin >> n; 
  for(int i = 0; i < n; ++i) {
    cin >> ar[i] >> br[i];
  }
  memset(dp, -1, sizeof dp);
  cout << rec(0, h) << '\n';
  return 0;
}


Measured memory_bytes: 40704
using System;

namespace _0014
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    break;
                }

                var sum = 0;
                var x = int.Parse(input);
                for (int num = 0; num < 600 ;)
                {
                    sum += (num * num) * x;
                    num += x;
                }
                System.Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 5588
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

int dx3[16010];
int dy3[16010];
int *dx = dx3+8005;
int *dy = dy3+8005;

int dx4[16010];
int dy4[16010];
int *dx2 = dx4+8005;
int *dy2 = dy4+8005;

int main(void) {
    string s;
    cin >> s;
    int gx, gy;
    cin >> gx >> gy;

    bool isX = true;
    int t = 0;
    vector<int> X, Y;
    for(int i=0; i<s.size(); ++i) {
        if(s[i] == 'F') t++;
        if(s[i] == 'T' || i==s.size()-1) {
            if(isX) {
                X.push_back(t);
            } else {
                Y.push_back(t);
            }
            t = 0;
            isX = !isX;
        }
    }
    dx[X[0]] = 1;
    for(int i=1; i<X.size(); ++i) {
        int mx = X[i];
        if(i%2==1) {
            for(int j=-8000; j<=8000; ++j) {
                if(dx[j] == 1) {
                    dx2[j+mx] = 1;
                    dx2[j-mx] = 1;
                    dx[j] = 0;
                }
            }
        } else {
            for(int j=-8000; j<=8000; ++j) {
                if(dx2[j] == 1) {
                    dx[j+mx] = 1;
                    dx[j-mx] = 1;
                    dx2[j] = 0;
                }
            }
        }
    }

    if(Y.size() > 0) {
        dy[Y[0]] = 1;
        dy[-Y[0]] = 1;
    } else {
        dy2[0] = 1;
    }
    for(int i=1; i<Y.size(); ++i) {
        if(i%2==1) {
            for(int j=-8000; j<=8000; ++j) {
                if(dy[j] == 1) {
                    dy2[j+Y[i]] = 1;
                    dy2[j-Y[i]] = 1;
                    dy[j] = 0;
                }
            }
        } else {
            for(int j=-8000; j<=8000; ++j) {
                if(dy2[j] == 1) {
                    dy[j+Y[i]] = 1;
                    dy[j-Y[i]] = 1;
                    dy2[j] = 0;
                }
            }
        }
    }

    bool okX = false;
    if(X.size()%2 == 0) {
        if(dx2[gx] == 1) okX = true;
    } else {
        if(dx[gx] == 1) okX = true;
    }
    bool okY = false;
    if(Y.size()%2 == 0) {
        if(dy2[gy] == 1) okY = true;
    } else {
        if(dy[gy] == 1) okY = true;
    }

    if(okX && okY) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

class Program
{
    private int N;
    private int[]A;
    
    
    public void Solve()
    {
        N=int.Parse(Console.ReadLine());
        A=new int[N];
        for(int i=0;i<N;i++)
        {
            A[i]=int.Parse(Console.ReadLine());
            
        }
        
        long ans=0;
        long sum=0;
        
        for(int i=0;i<N;i++)
        {
            if(A[i]==0)
            {
                ans+=sum/2;
                sum=0;
            }
            else
            {
                sum+=A[i];
            }
        }
        ans+=sum/2;
        Console.WriteLine(ans);
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
using namespace std;
const long MAX = 510000;
const long MOD = 998244353;
long PowM(long N, long P){
    if(P==0) return 1;
    if(P%2==0){
        long t = PowM(N, P/2);
        return t*t % MOD;
    }
    return N * PowM(N, P-1) % MOD;
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main () {
  long N, M, K;
  cin >> N >> M >> K;
  long d = 1;
  COMinit();
  long ans = 0, a;
  for(long i = 0; i <= K; i++){
    a = M * PowM(M - 1, N - 1 - i);
    a %= MOD;
    a *= COM(N - 1, i);
    a %= MOD;
    ans += a;
    ans %= MOD;
  }
  if(ans >= 0)cout << ans << endl;
  else cout << MOD + ans << endl;
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<string> s(N);
  rep (i, N)
  {
    cin >> s[i];
  }
  
  int M;
  cin >> M;
  vector<string> t(M);
  rep (i, M)
  {
    cin >> t[i];
  }
  
  int max_money = 0;
  rep (i, N)
  {
    int money = 0;
    
    rep (j, N)
    {
      if (s[i] == s[j])
      {
        money++;
      }
    }
    
    rep (k, M)
    {
      if (s[i] == t[k])
      {
        money--;
      }
    }
    
    if (money > max_money)
    {
      max_money = money;
    }
  }
  
  cout << max_money << endl;
}


Measured memory_bytes: 3580
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
ABBA
'''

def MAIN():
  # T_IN()
  if A():
    print("Yes")
  else:
    print("No")
  quit()

def A():
  s = IN_S()
  l = list(STR_SPLIT(s, 1))
  l.sort()
  if len(l) == 4 and l[0] == l[1] and l[2] == l[3] and l[1] != l[2]:
    return True
  return False


MAIN()


Measured memory_bytes: 3064
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author rn-sshawish
 */
public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        boolean [] state = new boolean[3];
        String s = input.nextLine();
        for (int i = 0; i < 3; i++) {
            state[s.charAt(i) - 'a'] = true;
        }
        boolean isPer = true;
        for (int i = 0; i < 3; i++) {
            isPer &= state[i];
        }
        System.out.println(isPer? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d/ %d/ %d/",&a,&b,&c);
	if(2019<a || (a<=2019 && 5<=b)){
		printf("TBD\n");
	}
	else{
		printf("Heisei\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
room = [[0 for i in range(30)] for j in range(4)]
s = "#"*20

for i in range(N):
    info = input().split()
    room[int(info[0])-1][(int(info[1])-1)*10+int(info[2])-1] += int(info[3])
for i in range(4):
    print("",*room[i][:10])
    print("",*room[i][10:20])
    print("",*room[i][20:30])
    if i != 3:
        print(s)



Measured memory_bytes: 5624
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int a, b;
	cin >> a >> b;
	cout << a - (a > b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int r; cin >> r;
  cout << r*r << endl;
  return 0;
}

// EOF


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

int N;

int main(int argc, char const *argv[])
{
  cin >> N;
  
  vector<LL> a(N, 0);
  vector<int> a_mod(N, 0);
  int cnt2 = 0;
  int cnt1 = 0;
  int cnt0 = 0;

  for (int i = 0; i < a.size(); i++) {
    cin >> a[i];
    if(a[i] % 4 == 0) {
      a_mod[i] = 2;
      cnt2++;
    }
    else if(a[i] % 2 == 0) {
      a_mod[i] = 1;
      cnt1++;
    }
    else {
      a_mod[i] = 0;
      cnt0++;
    }
  }

  if (cnt1 == 0) {
    if (cnt0 <= (cnt2 + 1)) {
      cout << "Yes\n";
    }
    else {
      cout << "No\n";
    }
  }
  else {
    if (cnt0 <= cnt2) {
      cout << "Yes\n";
    }
    else {
      cout << "No\n";
    }
    
  }
  
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
main(){
    long long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s>> t;
    long long L = n * m / __gcd(n, m);
    for(int i = 0; i < n; i++){
        if(i * m % n == 0){
            long long k = i * m / n;
            if(t[k] != s[i]){
                cout<<"-1"<<endl;
                return 0;
            }
        }
    }
    cout<<L<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    int max_x=X,min_y=Y;
    REP(i,N){
        int x; cin>>x;
        max_x=max(max_x,x);
    }
    REP(i,M){
        int y; cin>>y;
        min_y=min(min_y,y);
    }
    
    if(max_x<min_y)
        cout<<"No War"<<endl;
    else
        cout<<"War"<<endl;

}


Measured memory_bytes: 256
//https://codeforces.com/gym/102465/problem/E
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll gcd(ll x, ll y){
	return y == 0 ? x : gcd(y, x%y);
}
int main(){
	int n;
	cin >> n;
// 	int cnt = 0;
// 	ll ans = 0;
// 	for (int i = 1; i <= n; i++){
// 		for (int j = 1; j <= n;j++)
// 		for (int k = 1; k <= n; k++){
// 			ans += gcd(gcd(i, j), k);
// 		}
// 	}
// 	cout << ans << endl;
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}

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

int main () {
    int r,D,x,ans=0;
    cin >> r >> D >> x;
    for(int i=0;i<10;i++){
        if(i==0) ans=r*x-D;
        else ans=r*ans-D;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline void bubbleSort(vi a, int n) {
	bool flg = true;
	int cnt = 0;
	while(flg) {
		flg = false;
		rrep(j, n - 1, 0) {
			if(a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flg = true;
				++cnt;
			}
		}
	}
	rep(i, 0, n) {
		cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
	P(cnt);
}
int main() {
	int n; cin >> n;
	vi v(n); rep(i, 0, n) cin >> v[i];
	bubbleSort(v, n);
	return 0;
}

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

// semi-open range add maximum query

struct RBAQ{
  int sst[1<<18];
  int adt[1<<18];
  RBAQ(){
    memset(sst,0,sizeof(sst));
    memset(adt,0,sizeof(adt));
  }
  void add(int p, int q, int x, int k=0, int l=0, int r=(1<<17)){
    if(r <= p || q <= l) return;
    if(p <= l && r <= q){
      adt[k] += x;
      return;
    }
    add(p, q, x, 2*k+1, l, (l+r)/2);
    add(p, q, x, 2*k+2, (l+r)/2, r);
    sst[k]=max(sst[2*k+1]+adt[2*k+1],sst[2*k+2]+adt[2*k+2]);
  }
  int find(int p, int q, int k=0, int l=0, int r=(1<<17)){
    if(r <= p || q <= l) return 0;
    if(p <= l && r <= q) return sst[k]+adt[k];
    int m1, m2;
    m1 = find(p,q,2*k+1,l,(l+r)/2);
    m2 = find(p,q,2*k+2,(l+r)/2,r);
    return max(m1,m2)+adt[k];
  }
};

int main(){
  RBAQ a;
  int c,x,y,n,q;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    cin>>c;
    if(!c){
      cin>>x>>y>>c;
      a.add(x,y+1,c);
    }
    else{
      cin>>x;
      cout<<a.find(x,x+1)<<endl;
    }
  }
}


Measured memory_bytes: 5184