akhauriyash/Code-Regression huggingface dataset:
s = input()

pre = int(s[:2])
post = int(s[2::])

pre_month = False
pre_year = False
post_month = False
post_year = False

if 0 <= pre <= 99:
    pre_year = True
if 0 <= post <= 99:
    post_year = True
if 1 <= pre <= 12:
    pre_month = True
if 1 <= post <= 12:
    post_month = True

if (pre_year and post_month) and (pre_month and post_year):
    print("AMBIGUOUS")
elif pre_year and post_month:
    print("YYMM")
elif pre_month and post_year:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 38384
#include <stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(y-r < 0 || y+r > H || x-r < 0 || x+r > W) printf("No\n");
    else printf("Yes\n");
}
 


Measured memory_bytes: 2644
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e6+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
ll a[N],n,ans,sum[N];

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++) cin>>a[i];
  for(int i = 1;i <= n;i++) sum[i] = (sum[i-1] + a[i])%mod;
  for(int i = 1;i <= n;i++){
    ans = (ans + (a[i]*((sum[n]-sum[i] + mod)%mod))%mod)%mod;
  }
  cout<<ans<<endl;
  return 0;
}


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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    typedef pair<int, int> pair;
    vector<pair> a(n);
    rep(i, n){
        a[i].second = i+1;
        cin >> a[i].first;
    }
    sort(a.begin(), a.end());
    rep(i, n){
        cout << a[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
ll n,i,c=0,a;
cin>>n;
unordered_map<string,ll>mp;
for(i=0;i<n;i++)
{
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
}
for(auto it=mp.begin();it!=mp.end();it++)
{
    a=it->ss;
    c=c+((a*(a-1))/2);
}
cout<<c<<endl;
}


Measured memory_bytes: 10660
#include <stdio.h>

int main(void){
	char c;
	int a[31], b[31], answer[31], w, n, L, tmp;
	scanf("%d%d", &w, &n);
	for(L = 1; L <= w; L++){
		answer[L] = L;
	}
	for(L = 1; L <= n; L++){
		scanf("%d%c%d", &a[L], &c, &b[L]);
	}
	for(L = 1; L <= n; L++){
		tmp = answer[a[L]];
		answer[a[L]] = answer[b[L]];
		answer[b[L]] = tmp;
	}
	for(L = 1; L <= w; L++){
		printf("%d\n", answer[L]);
	}
	return 0;
}

Measured memory_bytes: 596
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
INF = float('inf')
dp = [INF] * N

dp[0] = 0
for i in range(1, N):
    for k in range(1, K + 1):
        start = max(i - k, 0)
        dp[i] = min(dp[i], dp[start] + abs(A[i] - A[start]))
    
print(dp[-1])

Measured memory_bytes: 55520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    bool ok = 1;
    rep(i, n + 1) {
        cin >> a[i];
    }
    if (n == 0) {
        if (a[0] == 1)
            cout << 1 << endl;
        else
            cout << -1 << endl;
        return 0;
    }

    vector<ll> r(n + 1, a[n]);
    for (int i = n - 1; i >= 0; i--) {
        r[i] = r[i + 1] + a[i];
    }

    ll x = 1, tot = 0;
    chmin(r[0], 1ll);
    for (int i = 1; i <= n; i++) {
        tot = min(r[i], 2 * x);
        x = tot - a[i];
        chmin(r[i], tot);
    }

    ll ans = 0;
    a[n]--;
    rep(i, n + 1) {
        if (r[i] <= a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans += r[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4852
#include <iostream>

int main() {
	int n;
	std::string s;

	std::cin >> n >> s;

	std::size_t red = 0;
	std::size_t blue = 0;
	for (auto c : s) {
		if (c == 'R') {
			++red;
		} else if (c == 'B') {
			++blue;
		}
	}

	if (red > blue) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Wed 01/07/2020
 * 19:17:30.14
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b, c;
    cin >> a >> b >> c;
    int maxval = max({a, b, c});
    int minval = min({a, b, c});
    int mid = a + b + c - maxval - minval;
    cout << mid + maxval * 10 + minval << endl;
    return 0;
}


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

int main() {

    int n;
    cin >> n;
    string com;
    int num;
    list<int> L;
    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'i') {
            cin >> num;
            L.push_front(num);
        }
        else if (com[6] == 'F') {
            L.pop_front();
        }
        else if (com[6] == 'L') {
            L.pop_back();
        }
        else {
            cin >> num;
            for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
                if (*it == num) {
                    L.erase(it);
                    break;
                }
            }
        }
    }
        int i = 0;
        for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
            if (i++) cout << ' ';
            cout << *it;
        }
        cout << '\n';

}





Measured memory_bytes: 34388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld ;
#define pb push_back
#define fi first
#define se second
const int N = 1e6+6;
const ll mod = 1e9+7;
ll po(ll a,ll b){
    if(b==0)return 1;
    ll x = po(a,b/2);
    x = (x*x)%mod;
    if(b&1)x = (x*a)%mod;
    return x;
}
ll a[N];
int cnt[N];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ll x = a[i];
        for(ll j=2;j*j<=x;j++){
            int trt = 0;
            while(x%j==0){
                trt++;
                x/=j;
            }
            cnt[j] = max(cnt[j],trt);
        }
        if(x>1)cnt[x] = max(cnt[x],1);
    }
    ll lcm = 1;
    for(int i=1;i<N;i++){
        if(cnt[i]==0)continue;
        lcm*=po(i,cnt[i]);
        lcm%=mod;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll trt = (lcm*po(a[i],mod-2))%mod;
        ans+=trt;
        ans%=mod;
    }
    cout<<ans<<endl;

}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    preprocess();
    int t =1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
string s;
int n;
vi newnum;
int ans=1e9+5;
set<int> st;
int main(int argc,char const* argv[])
{
  cin >> n;
  vi a(n);
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  sort(a.begin(),a.end());
  ans=min(ans,a[0]);
  if(ans==1)
    {
      cout << 1 << endl;
      return 0;
    }
  while(1)
    {
      bool change=false;
      for(int i=0;i<n;i++)
	{
	  if(a[i]%ans!=0 && a[i]%ans<ans)
	    {
	      change=true;
	      if(a[i]%ans==1)
		{
		  cout << 1 << endl;
		  return 0;
		}
	      ans=a[i]%ans;
	    }
	}
      if(!change) break;
    }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
ll C[2001][2001]={};
long long dp[2001][2001]={};
int main(void){
   int n,k;
    for(int i = 0; i <=2000; i++){
        C[i][0] = C[i][i] = 1;
        for(int j = 1; j < i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
    }
   cin>>n>>k;
   for(int i=1;i<=k;i++){
      cout<<(C[n-k+1][i]*(C[k-1][i-1]))%MOD<<endl;
   }
   return 0;
}

Measured memory_bytes: 32128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;

int cost[] = {2,5,5,4,5,6,3,7,6};

int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	int n, m;
	cin >> n >> m;

	vector<int> allowed(m);
	vector<int> corr_cost(m);
	for(int i = 0 ; i< m ; i++){
		cin >> allowed[i];
		corr_cost[i] = cost[allowed[i] - 1];
	}

	vector< vector<int> > a(n+1 , vector<int>(m , -10000000));

	for(int i = 0 ; i < m ; i++)
		a[0][i] = 0;

	for(int i = 1; i <= n; i++){
		for(int j = 0; j < m; j++){
			if (i - corr_cost[j] < 0)
				continue;
			for(int k = 0 ; k < m; k++){
				a[i][j] = max(1 + a[i - corr_cost[j]][k], a[i][j]); 
			}
			// trace1(a[i][j])
		}
	}

	// for(int i = 1; i <= n; i++){
	// 	for(int j = 0; j < m; j++){
	// 		cout << a[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	for(int i = n; i >= 0 ; i--){
		int max_elem = -1;
		int max_len = -1;
		int max_idx = -1;
		for(int j = 0 ; j < m;j++){
			// trace1(a[i][j])
			if(a[i][j] >= max_len){
				// trace4(a[i][j], j, max_len, max_elem)
				if(a[i][j] == max_len){
					if(allowed[j] > max_elem){
						max_elem = allowed[j];
						max_len = a[i][j];
						max_idx = j;
						// trace3(max_len, max_elem, max_idx)
					}
				}
				else{
					max_elem = allowed[j];
					max_len = a[i][j];
					max_idx = j;
					
				}
			}
		}
		// trace2(max_len, max_elem)
		if(max_len == 0)
			break;
		else{
			cout << max_elem;
			i = i - corr_cost[max_idx] + 1;
		}
			// continue;
	}

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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 dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<pair<ll,ll>> r(n+2);
    rep(i,n+1)cin >> a[i];
    r[n].first = r[n].second = a[n];
    for(int i=n-1;i>=0;i--){
        r[i].first = (r[i+1].first+1)/2 + a[i];
        r[i].second = r[i+1].second + a[i];
    }
    if(r[0].first > 1){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    ll cur = 1;
    for(int i=0;i<=n;i++){
        ans += cur;
        cur -= a[i];
        cur = min(cur*2,(ll)r[i+1].second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5208
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
typedef complex<double> Point;
int main(){
  int N;
  while(cin >> N && N){
    vector<Point> ps(N);
    REP(i, N) cin >> ps[i].real() >> ps[i].imag();
    int ans = 1;
    REP(i, N)REP(j, N) if(i != j){
      double d = abs(ps[i] - ps[j]) / 2;
      if(d > 1) continue;
      double t = sqrt(1 - d * d);
      Point start = ps[i] + (ps[j] - ps[i]) * 0.5;
      Point vect = (ps[j] - ps[i]) * Point(0.0, 1.0);
      vect /= abs(vect);
      for(int sign = -1; sign <= 1; sign += 2){
        Point center = start + vect * t * (double)sign;
        int sub_ans = 0;
        REP(k, N) if(abs(center - ps[k]) < 1.0 + EPS) sub_ans ++;
        ans = max(ans, sub_ans);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define INF 1<<29

int cnt[9][9];

int calc_dist(const vector<int> &v){
  int ret = 0;
  for(int i=0;i<9;i++){
    for(int j=i+1;j<9;j++){
      int dist_ij = abs(int(i/3) - int(j/3)) + abs(int(i%3) - int(j%3));
      //      cout << v[i] << " " << v[j] << " " << dist_ij << " " << cnt[v[i]-1][v[j]-1] << endl;
      ret += dist_ij * cnt[v[i]-1][v[j]-1];
    }
  }
  return ret;
}

int main(){
  memset(cnt, 0, sizeof(cnt));
  int N;
  string S;
  cin >> N >> S;
  for(int i=1;i<N;i++){
    cnt[S[i-1]-'1'][S[i]-'1']++;
    cnt[S[i]-'1'][S[i-1]-'1']++;
  }

  vector<int> v{1, 2, 3, 4, 5, 6, 7, 8, 9};
  vector<int> ret;
  int best_score = INF;
  do{
    int score = calc_dist(v);
    if(score < best_score){
      //      cout << score << endl;
      best_score = score;
      ret = v;
    }
}while(next_permutation(v.begin(), v.end()));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cout << ret[i*3+j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
using namespace std;
bool isOK(char grid[][52],int ii,int jj){
  //その位置が白なら無条件でOK
  if(grid[ii][jj] == '.'){
	return true;
  }
  //左
  if(grid[ii][jj-1] == '#'){
	return true;
  }
  //右
  if(grid[ii][jj+1] == '#'){
	return true;
  }
  //下
  if(grid[ii+1][jj] == '#'){
	return true;
  }
  //上
  if(grid[ii-1][jj] == '#'){
	return true;
  }
  return false;
}

int main(){
  int h,w,ii,jj;
  string str;
  cin >> h;
  cin >> w;
  char grid[52][52];

  for(ii = 0; ii <= 51 ; ii++){
	//grid[ii] = (char*)malloc(sizeof(char) * (w+2) );
	for(jj = 0; jj <= 51 ; jj++){
	  grid[ii][jj] = '.';
	}
  }
  
  for(ii = 1; ii <= h ; ii++){
	cin >> str;
	for(jj=0;jj<w;jj++){
	  grid[ii][jj+1] = str[jj];
	}
  }

  bool okFlg = true;
  for(ii = 1; ii <= h ; ii++){
	for(jj = 1; jj <= w ; jj++){
	  //cout << grid[ii][jj];
	  if(isOK(grid,ii,jj) == false){
		okFlg = false;
	  	break;
	  }
	}
	//cout << endl;
  }

  if(okFlg){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  if (n & 1) cout << 0 << endl;
  else {
    ll ans = 0, keta = 10;
    while (keta <= n) {
      ans += n / keta;
      keta *= 5;
    }
    cout << ans << endl;
  }


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define f(x, y) ((y)*w+(x))

using namespace std;

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

const int INF = 1e9;
const int N = 12;
int ch[N][N];
int d[N*N][N*N];
int dp[1 << N][N*N];

int main(){
	int h, w;
	while (cin >> h >> w, h|w){
		vector<int> v;
		rep(i, h) rep(j, w){
			cin >> ch[i][j];
			if (ch[i][j]) v.push_back(f(j, i));
		}

		int n = h*w, t = v.size();
		rep(i, n) rep(j, n) if (i != j) d[i][j] = INF;
		rep(i, h) rep(j, w){
			rep(k, 2){
				int nx = j + k, ny = i + !k;
				if (nx >= w || ny >= w) continue;
				d[f(j, i)][f(nx, ny)] = d[f(nx, ny)][f(j, i)] = 1;
			}
		}
		rep(i, n) rep(j, n) rep(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

		rep(i, 1 << t) rep(j, n) dp[i][j] = INF;
		rep(i, t) rep(j, n) dp[1 << i][j] = d[v[i]][j];
		rep(i, 1 << t) rep(p, n) rep(q, n) for (int j = i; j > 0; j = (j - 1)&i) dp[i][p] = min(dp[i][p], dp[i^j][q] + dp[j][q] + d[p][q]);

		int res = INF, all = (1 << t) - 1;
		rep(i, 1 << t) rep(p, n) res = min(res, dp[i][p] + dp[all^i][p]);

		if (res == INF) res = n;
		else ++res;

		cout << h * w - res << endl;
	}

	return 0;
}

Measured memory_bytes: 1332
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
 int a,b,c,d;
 cin >> a >> b >> c >> d;
 if(b <= c || d <= a){
     cout << 0 << endl;
 }
 else if(a <= c  && d <= b){
     cout << d - c << endl;
 }
 else if(c <= a && b <= d){
     cout << b-a << endl;
 }
 else if(a <=c){
     cout << abs(b-c) << endl;
 }
 else {
     cout << abs(d-a) << endl;
 }
 
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N-1) cin >> C[i];
  int ans = 0;
  rep(i, N) ans += B[i];
  rep(i, N-1){
    if(A[i+1]-A[i] == 1){
      ans += C[A[i]-1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	b := Scanner()
	if b == "A" {
		fmt.Println("T")
	} else if b == "T" {
		fmt.Println("A")
	} else if b == "C" {
		fmt.Println("G")
	} else {
		fmt.Println("C")
	}
}


Measured memory_bytes: 1768
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		int a[100000];
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		int max=0;
		int b[100000]={0};
		for(int i=0;i<n;i++)
		{
			b[a[i]]++;
		}
		for(int i=0;i<99998;i++)
		{
			int num=b[i]+b[i+1]+b[i+2];
			if(num>max)
				max=num;
		}
		cout<<max<<"\n";
	}
}

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

int main() {
  int A,B,C,D;
    cin >> A >> B >> C >> D;
  if(A+B > C+D) {cout << "Left" <<endl;}
  else if(A+B < C+D) {cout << "Right" <<endl;}
  else if(A+B==C+D) {cout << "Balanced" <<endl;}
}

Measured memory_bytes: 256
using System;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var p = Array.ConvertAll(new int[n], _ => Array.ConvertAll(Console.ReadLine().Split(), int.Parse));

		if (n == 2) { Console.WriteLine(Norm(p[0], p[1]) / 2); return; }

		var M = 0.0;
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)
				for (int k = j + 1; k < n; k++)
					M = Math.Max(M, GetRadius(p[i], p[j], p[k]));
		Console.WriteLine(M);
	}

	static double GetRadius(int[] p, int[] q, int[] r)
	{
		double a = Norm(p, q), b, c, t;
		if ((t = Norm(q, r)) > a) { b = a; a = t; }
		else b = t;
		if ((t = Norm(r, p)) > a) { c = a; a = t; }
		else c = t;

		var cos = (b * b + c * c - a * a) / 2 / b / c;
		return a / 2 / (cos < 0 ? 1 : Math.Sqrt(1 - cos * cos));
	}

	static double Norm(int[] p, int[] q) => Math.Sqrt(Math.Pow(p[0] - q[0], 2) + Math.Pow(p[1] - q[1], 2));
}


Measured memory_bytes: 11220
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0]);
    R = {}
    for(var i=1; i <= N;i++)
    {
        tmp = input[i].split(" ")
        if(!R[tmp[0]])
        {
            R[tmp[0]] = []
        }
        tmpR = {}
        tmpR.price = Number(tmp[1])
        tmpR.index = i
        R[tmp[0]].push(tmpR)
    }

    var keys=[];
    for(var key in R)keys.push(key);
    keys.sort()
    for(var i =0; i < keys.length; i++)
    {
        tmpR = R[keys[i]].sort((a,b) => b.price - a.price)
        for(var j =0; j < tmpR.length; j++){
            console.log(tmpR[j].index)
        }
    }
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("6\nkazan 36\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n");

Measured memory_bytes: 21064
package main
import(
  "fmt"
)
func main(){
  var n, i int
  var s string
  fmt.Scan(&n, &s)
  temp:=0
  for i=1;i<len(s);i++{
    if s[i-1]!=s[i]{
      temp++
    }
  }
  fmt.Println(temp+1)
}


Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>

namespace LegitStream
{
char bufdatum[BUFSIZ];
char *buf = bufdatum, *endbuf = bufdatum;

inline bool eof(void)
{
    if (endbuf == buf)
    {
        endbuf = (buf = bufdatum) + fread(bufdatum, 1, BUFSIZ, stdin);
        return endbuf == buf;
    }
    else
        return false;
}

inline int nextch(void)
{
    return eof() ? EOF : *buf++;
}

void legit(void) {}

template<typename Car, typename ...Cdr>
void legit(Car &var, Cdr &...Rest)
{
    int peek;
    while (!isdigit(peek = nextch())
#ifdef LEGIT_NEGI
        && peek != '-'
#endif  // LEGIT_NEGI
        )
        ;
#ifdef LEGIT_NEGI
    bool negi;
    if (peek == '-')
        negi = true;
    else
        negi = false;
#endif  // LEGIT_NEGI
    var = 0;
    do
        var = (((var << 2) + var) << 1) + (peek ^ '0');
    while (isdigit(peek = nextch()));
#ifdef LEGIT_NEGI
    if (negi)
        var = -var;
#endif  // LEGIT_NEGI
    legit(Rest...);
}
}
using LegitStream::nextch;
using LegitStream::eof;
using LegitStream::legit;

void solve(void);

int main(void)
{
#ifdef redirect
    freopen("check/data.in", "r", stdin);
    freopen("check/prog.out", "w", stdout);
    freopen("check/log.out", "w", stderr);
#endif  // redirect
#ifdef chrono
    auto begtm = clock();
#endif  // chrono
    solve();
#ifdef chrono
    auto endtm = clock();
    printf("%f\n", static_cast<float>(endtm - begtm) / CLOCKS_PER_SEC);
#endif  // chrono
    return 0;
}

const size_t MaxN = 100 + 7;

size_t n;
char str[MaxN];
bool pre[MaxN][MaxN], post[MaxN][MaxN];

void solve(void)
{
    // Init
    legit(n);
    for (size_t i = 0; i < n; ++i)
        str[i] = nextch();
    pre[0][str[0] - 'a'] = true;
    for (size_t i = 1; i < n; ++i)
    {
        for (size_t j = 0; j < 30; ++j)
            pre[i][j] = pre[i - 1][j];
        pre[i][str[i] - 'a'] = true;
    }
    post[n - 1][str[n - 1] - 'a'] = true;
    for (int i = n - 2; i >= 0; --i)
    {
        for (size_t j = 0; j < 30; ++j)
            post[i][j] = post[i + 1][j];
        post[i][str[i] - 'a'] = true;
    }
    int ans = 0;
    for (size_t pos = 0; pos < n - 1; ++pos)
    {
        int now = 0;
        for (size_t i = 0; i < 30; ++i)
            if (pre[pos][i] && post[pos + 1][i])
                ++now;
        ans = std::max(ans, now);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	ans := 1 << 60
	s := scanString()
	for i := 0; i < len(s)-2; i++ {
		a, _ := strconv.Atoi(s[i : i+3])
		ans = min(ans, abs(753-a))
	}
	fmt.Fprintln(wr, ans)

}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;

typedef long long int ll;
 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 

 
const ll N = 200005;
const ll mod = 998244353;
const long long int inf = 10e17;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{
	ll n,x,y;
	cin>>n>>x>>y;
	x--;
	y--;
	ll d1,d2,d3,d4;
	ll cnt[n];
	ll d;
	ll dx[n],dy[n];
	rep(i,n){
		d1 = min(i,x);
		d2 = max(i,x);
		d3 = min(i,y);
		d4 = max(i,y);
		dx[i] = d2-d1;
		dy[i] = d4-d3;
	}
	rep(i,n) cnt[i] =0;
	rep(i,n){
		for(ll j = i+1;j<n;j++){
			d1 = j-i;
			d2 = inf;
			d3 = dx[i]+1+dy[j];
			d4 = dx[j]+1+dy[i];
		//	cout<<"i = "<<i+1<<"j = "<<j+1<<" "<<d1<<" "<<d2<<" "<<d3<<" "<<d4<<endl;
			d = min(d1,d3);
			//d = min(d,d3);
			d = min(d,d4);
			cnt[d]++;
		}
	}
	rep1(i,n) cout<<cnt[i]<<endl;
}

	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

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

using namespace std;

/// 18:50

const int Nmax = 3e5 + 5;

int n, N, M, MX[Nmax], MN[Nmax], Y, W;

struct Pair
{
    int x, y;
    bool operator < (const Pair &other) const
    {
        return x < other.x;
    }
} a[Nmax];

struct DeQ
{
    deque<Pair> dq;
    bool c1, c2;
    int i, lim;
    Pair aux;

    void reset(int x, int l, int C1, int C2)
    {
        c1 = C1, c2 = C2;
        i = x; lim = l;
        while(dq.size()) dq.pop_front();
    }

    int query(int x, int y)
    {
        y = min(y, lim);
        if(x > y) return -1e9;

        for(; i<=y; ++i)
        {
            aux = {a[i].x, i};
            if(c1) aux.x += MN[i-1];
            if(c2) aux.x -= MX[i-1];

            while(dq.size() && dq.back() < aux) dq.pop_back();
            dq.push_back(aux);
        }

        while(dq.size() && dq.front().y < x) dq.pop_front();

        if(dq.size()) return dq.front().x;
        return -1e9;
    }
} dq1, dq2, dq3, dq4;

int divide(int st, int dr)
{
    if(st == dr) return 0;

    int mid = (st+dr)/2, i, min_pos = mid+1, max_pos = mid+1, Max = 0, Min = W;
    int ans = 0, v1, v2, v3, v4, now;

    MN[mid] = W; MX[mid] = 0;
    for(i = mid+1; i <= dr; ++i)
    {
        MN[i] = MN[i-1]; MX[i] = MX[i-1];
        if(a[i].y <= Y) MX[i] = max(MX[i], a[i].y);
            else MN[i] = min(MN[i], a[i].y);
    }

    dq1.reset(mid+1, dr, 0, 0); dq2.reset(mid+1, dr, 1, 0); dq3.reset(mid+1, dr, 0, 1); dq4.reset(mid+1, dr, 1, 1);

    for(i = mid; i >= st; --i)
    {
        while(min_pos <= dr && Min <= MN[min_pos]) ++ min_pos;
        while(max_pos <= dr && Max >= MX[max_pos]) ++ max_pos;

        v1 = dq1.query(mid+1, min(min_pos, max_pos)) + Min - Max;
        v2 = dq2.query(min_pos+1, max_pos) - Max;
        v3 = dq3.query(max_pos+1, min_pos) + Min;
        v4 = dq4.query(max(min_pos, max_pos) + 1, dr);

        now = max( max(v1, v2), max(v3, v4) );
        ans = max(ans, now - a[i].x);

        if(a[i].y > Y) Min = min(Min, a[i].y);
            else Max = max(Max, a[i].y);
    }

    ans = max(ans, divide(st, mid));
    ans = max(ans, divide(mid+1, dr));
    return ans;
}

int solve()
{
    int ans1, ans2, i;

    sort(a+1, a+n+1);
    Y = M/2; W = M;
    ans1 = divide(1, n);

    for(i=1; i<=n; ++i)
        swap(a[i].x, a[i].y);

    sort(a+1, a+n+1);
    Y = N/2; W = N;
    ans2 = divide(1, n);

    return max(ans1, ans2);
}

int main()
{
///    freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> N >> M >> n;

    int nr = 0, x, y, i;
    for(i=1; i<=n; ++i)
    {
        cin >> x >> y;
        if(x && y && x<N && y<M) a[++nr] = {x, y};
    }

    a[++nr] = {0, 0};
    a[++nr] = {N, M};

    n = nr;

    cout << 2 * solve() << '\n';
    return 0;
}


Measured memory_bytes: 6216
# a b c
# b e d
# c d f
# について、
#  a  b  c [a  b]
#  b  e  d [b  e]
#  c  d  f [c  d]
# [a  b  c  a  b]
# [b  e  d  b  e]
# 左上の1,1から始まるものが条件を満たすなら、
# 2,2から始まるものも3,3から始まるものも条件を満たす
# 一つ条件を満たすのであれば、N個条件を満たすことになる。
# 従い、以下を順にチェックして答えをN倍すれば良い
#  a  b  c [a  b]
#  b  e  d [b  e]
#  c  d  f [c  d]

import sys
readline = sys.stdin.readline

N = int(readline())
grid = [None] * N
for i in range(N):
  S = readline().rstrip()
  grid[i] = S + S[:-1]
  
# 左上の頂点を(0,0)~(N-1,0)の全てをチェックする
ans = 0
for p in range(N):
  # 左上の頂点はp
  ok = True
  for i in range(N):
    for j in range(i+1):
      if grid[i][j + p] != grid[j][i + p]:
        ok = False
        break
    if not ok:
      break
  if ok:
    ans += 1

print(ans * N)


Measured memory_bytes: 41964
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, A;
  cin >> N >> A;
  N %= 500;
  if (N <= A) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
from math import cos,radians, sqrt
a,b,h,m = map(int, input().split())
tan = h*(360//12)+(0.5*m)
naga = m*(360//60)
if abs(naga-tan) > 180:
    kakudo = 360 - abs(naga-tan)
else:
    kakudo = abs(naga-tan)
ans = sqrt(a**2 + b**2 - 2*a*b*cos(radians(kakudo)))

print(ans)


Measured memory_bytes: 9504
N,T=map(int,input().split())
list = list(map(int, input().split()))
x = 0
for i in range(N):
  if i > 0:
    if list[i]-list[i-1] >= T:
      x = x + T
    else:
      x = x + list[i]-list[i-1]
print(x+T)

Measured memory_bytes: 26708
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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

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


int main(){
    int n;
    cin >> n;
    vector<int> dp(n+1);
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2; i <=n; i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <list>
#include <set>

using namespace std;

int main()
{
    list<long long> lst;
    set<long long> result;
    long long a, b, k;
    
    cin >> a >> b >> k;

    if (k > (b - a + 1)) {
        k = (b - a + 1);
    }

    for (int i = 0; i < k; i++) {
        lst.push_back(a + i);
    }

    for (int i = k; i >= 0; i--) {
        lst.push_back(b - i);
    }

    list<long long>::iterator p = lst.begin();
    for (int i = 0; i < k; i++) {
        result.insert(*p);
        p++;
    }

    p = lst.end();
    for (int i = 0; i < k; i++) {
        p--;
        result.insert(*p);
    }

    set<long long>::iterator p2 = result.begin();
    while (p2 != result.end()) {
        cout << *p2 << endl;
        p2++;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	string s;
	cin >> s;
	bool flg = true;
	if (stoi(s.substr(0, 4)) > 2019)flg = false;
	else if (stoi(s.substr(5, 2))>4)flg = false;
	if (flg)cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;

bool judge[100010];


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

	 int n,m;cin>>n>>m;

	 rep(i,m){
		 int tmp;cin>>tmp;
		 judge[tmp] =true;
	 }

	 vector<ll> d(n+1);

	 d[0]  =1;

	 for(int i=1; i<=n; i++){

		 if(!judge[i]){
			 if(i-1 >=0){
			 d[i] += d[i-1];
			 }
			 if(i-2>=0){
			 d[i] += d[i-2];
			 }
			 d[i] %=1000000007;

		 }


	 }

	 writeln(d[n]);




}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();

        if(A-K >=0){
            System.out.println(A-K + " " + B);

        }else if(B >= K-A){
            System.out.println(0 + " " + (B-K+A) );
        }else{
            System.out.println(0 + " " + 0);
        }

    }
}


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

int main(){
  while(1){
  int N,M,P;
  int sum=0;
  cin>>N>>M>>P;
  if(N+M+P==0) break;
  int X[1001];
  for(int i=1;i<=N;i++){
    cin>>X[i];
    sum+=X[i];
  }
  sum*=100;
  sum=sum-(sum*P)/100;
  if(X[M]==0) sum=0;
  else sum/=X[M];
  cout<<sum <<endl;
  }
  
  return 0;
  }
  
  

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
main(){
    int n,m;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++)
    cin>>s[i];
    cin>>m;
    string t[m];
    for(int i=0;i<m;i++)
    cin>>t[i];
    int p=0;
    for(int i=0;i<n;i++){
        int q=0;
        for(int j=0;j<n;j++){
            if(s[j]==s[i])
            q++;
        }
        for(int j=0;j<m;j++){
            if(t[j]==s[i])
            q--;
        }
        if(q>p) p=q;
    }
    cout<<p;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void gcd(int max, int min) {
  int w = 1;
  while (w) {
    w = max % min;
    if (w) {
      max = min;
      min = w;
    }
  }
  printf("%d\n", min);
}

int main() {
  int x, y, z;

  scanf("%d %d", &x, &y);
  if (x > y) {
    gcd(x, y);
  } else if (x < y) {
    gcd(y, x);
  } else {
    printf("%d\n", x);
  }
  return 0;
}



Measured memory_bytes: 2036
a, b = map(int,input().split())

if a*b <= 0: #異符号もしくは0を含むなら
    print("Zero")

elif a > 0: #両方正なら
    print("Positive")

else: #両方負なら
    if (b-a)%2==0:
        print("Negative")
    else:
        print("Positive")

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

using namespace std;

#define nl '\n'

int main() {
  int n, w;
  cin >> n >> w;

  vector<vector<long long>> data(n+1, vector<long long>(2, 0)); // 0 is weight, 1 is value
  for (int i = 1; i <= n; i++) {
    cin >> data[i][0] >> data[i][1];
  }

  vector<vector<long long>> dp(n+1, vector<long long>(w+1, -1));
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 0;
  }
  for (int i = 0; i <= w; i++) {
    dp[0][i] = 0;
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= w; j++) {
      if (j < data[i][0]) {
        dp[i][j] = dp[i-1][j];
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-data[i][0]] + data[i][1]);
      }
    }
  }

  cout << dp[n][w] << nl;

  return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];
int main(){
    int a ;
    cin >> a;
    int b = a*a;
    int c = b*a;
    cout <<a+b+c<<endl;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int T[100100];

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    sort(T, T + N);
    ll ans = 1;
    int now = N - 2;
    int pers = 1;
    int bustime = T[N - 1];
    while (now >= 0) {
        if (pers < C && T[now] >= bustime - K) {
            pers++;
        } else {
            pers = 1;
            bustime = T[now];
            ans++;
        }
        now--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
# Aizu Problem 0060: Card Game
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def card_game(c1, c2, c3):
    cards = list(range(1, 11))
    for card in [c1, c2, c3]:
        cards.remove(card)
    S = c1 + c2
    cnt = 0
    for card in cards:
        if S + card <= 20:
            cnt += 1
    return cnt > 3
        

    
for line in sys.stdin:
    c1, c2, c3 = [int(_) for _ in line.split()]
    print("YES" if card_game(c1, c2, c3) else "NO")

Measured memory_bytes: 7712
A,B,C,D = list(map(int,input().split()))

for i in range(100000):
    if i%2==0:
        C-=B
        if C<=0:
            flag = True
            break
    else:
        A-=D
        if A<=0:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61588
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  
  int N, k, best = 0; cin >> N >> k;
  vector<vector<int>> cell(2 * k, vector<int>(2 * k, 0));

  auto get = [&](int bx, int by, int tx, int ty){
    int cur = cell[tx][ty];
    if(bx > 0) cur -= cell[bx - 1][ty];
    if(by > 0) cur -= cell[tx][by - 1];
    if(bx > 0 && by > 0) cur += cell[bx - 1][by - 1];

    return cur;
  };

  for(int rep = 0; rep < N; ++rep){
    int x, y; cin >> x >> y;
    char c; cin >> c;
    if(c == 'W') x += k;
    x %= 2 * k;
    y %= 2 * k;
    cell[x][y]++;
  }

  for(int r = 0; r < 2 * k; ++r){
    for(int c = 0; c < 2 * k; ++c){
      cell[r][c] += (r > 0 ? cell[r - 1][c] : 0)
                  + (c > 0 ? cell[r][c - 1] : 0)
                  - (r * c > 0 ? cell[r - 1][c - 1] : 0);
    }
  }
  
  for(int r = 0; r < k; ++r){
    for(int c = 0; c < k; ++c){
      int cur = 0;
      cur += get(0, 0, r, c)
           + get(r + 1, c + 1, r + k, c + k)
           + get(r + k + 1, c + k + 1, 2 * k - 1, 2 * k - 1)
           + get(r + k + 1, 0, 2 * k - 1, c)
           + get(0, c + k + 1, r, 2 * k - 1);
      best = max({best, cur, N - cur});
    }
  }

  cout << best << "\n";
  return 0;
}

Measured memory_bytes: 16000
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		boolean[] snuke = new boolean[N];
		for (int i=0;i<K;i++) {
			int d = sc.nextInt();
			for (int j=0;j<d;j++) {
				int A = sc.nextInt()-1;
				snuke[A] = true;
			}
		}
		int ans = 0;
		for (int i=0;i<N;i++) {
			if (!snuke[i]) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 46460