akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            var A = ReadIntArray();

            int num = 1;
            bool found = false;
            for (int i = 0; i < A.Length; i++)
            {
                if (A[i] == num)
                {
                    num++;
                    found = true;
                }
            }

            if (found)
            {
                int ans = A.Length - num + 1;
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine(-1);
            }
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 35676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll n,m,c=0,x,y;
	cin>>n>>m;
	ll h[n+10];
	for(ll i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	map<ll,set<ll>> adj;
	while(m--)
	{
		cin>>x>>y;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	for(auto i:adj)
	{
		ll comp=i.first;
		for(auto j:i.second)
		{
			if(h[comp]<=h[j])
			{
				c++;
				break;
			}
		}
	}
	cout<<n-c;
}

Measured memory_bytes: 21896
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

struct UnionFind{
	vector<int> par,siz;
	UnionFind(int N): par(N), siz(N){
		rep(i, N){
			par[i] = i; siz[i] = 1;
		}
	}
	int root(int x){
		if(par[x]==x) return x;
		else return root(par[x]);
	}
	void unite(int x, int y){
		x=root(x); y=root(y);
		if(x==y) return;
		if(siz[x] < siz[y]) swap(x, y);
		par[y] = x;
		siz[x] += siz[y];
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int size(int x){
		return siz[root(x)];
	}
};

int main(){
  int n, m; cin >> n >> m;
  UnionFind uf(n);
  rep(i, m){
    int a, b; cin >> a >> b; a--; b--;
    uf.unite(a, b); uf.unite(b, a);
  }
  int ans = 0;
  rep(i, n){
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int n;
int u,v;
int ans;
vector<int> ne[100005];
int disu[100005],disv[100005];
bool vis1[100005],vis2[100005],vis3[100005];
void dfs1(int x, int d) {
	vis1[x] = true;
	disu[x] = d;
	for(int i=0; i<ne[x].size(); i++) {
		if(!vis1[ne[x][i]]) {
			dfs1(ne[x][i],d+1);
		}
	}
}
void dfs2(int x, int d) {
	vis2[x] = true;
	disv[x] = d;
	for(int i=0; i<ne[x].size(); i++) {
		if(!vis2[ne[x][i]]) {
			dfs2(ne[x][i],d+1);
		}
	}
}
void dfs3(int x) {
	vis3[x] = true;
	if(disv[x] <= disu[x]) return;
	if(disv[x]%2 == disu[x]%2) {
		ans = max(ans,disv[x]-1);
	} else {
		ans = max(ans,disv[x]-1);
	}
	for(int i=0; i<ne[x].size(); i++) {
		if(!vis3[ne[x][i]]) {
			dfs3(ne[x][i]);
		}
	}
}
int main() {
	cin >> n;
	cin >> u >> v;
	for(int i=1; i<n; i++) {
		int a,b;
		cin >> a >> b;
		ne[a].push_back(b);
		ne[b].push_back(a);
	} 
	dfs1(u,0);
	dfs2(v,0);
	dfs3(u);
	cout<<ans<<endl;
}

Measured memory_bytes: 10624
n=gets.chomp.to_i
d,x=gets.chomp.split(" ").map { |e| e.to_i }
a=n.times.map { gets.chomp.to_i  }
 
sum = 0
 
n.times do |i|
  sum += (d-1)/a[i] + 1
end
 
puts sum + x

Measured memory_bytes: 3836
n, m = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
a = [int(input()) for i in range(m)]
dp = [0 for i in range(n+1)]
dp[0] = 1
for i in range(m):
    dp[a[i]] = -1


for i in range(n):
    if dp[i] != -1:
        if dp[i+1] != -1:
            dp[i+1] += dp[i] % mod

        if i != n-1 and dp[i+2] != -1:
            dp[i+2] += dp[i] % mod

print(dp[-1] % mod)


Measured memory_bytes: 7856
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a * b << " " << (a + b) * 2 << endl;
	return 0;
}

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

int main(){

	int H, W;

	while(1){

		cin >> H >> W;

		if(H == 0 && W == 0) break;

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

			for(int j = 0; j < W; j++){

				if((i == 0 || i == H - 1) || ( j == 0|| j == W - 1)){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, Z, W; scanf("%d %d %d", &N, &Z, &W);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  int ans = INF;
  if (N == 1) {
    ans = abs(A[N -1] - W);
  }
  else {
    ans = max(abs(A[N - 2] - A[N - 1]), abs(A[N - 1] - W));
  }
  printf("%d\n", ans);
  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 <cassert>

// 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) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

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

string repl(string &s, string &a, string &b){
	string res;
	rep(i, s.size()){
		bool ok = false;
		if(i+a.size() <= s.size()){
			ok = true;
			rep(j, a.size()) if (s[i + j] != a[j]){
				ok = false;
				break;
			}
		}
		if (ok) res += b, i += a.size() - 1;
		else res += s[i];
	}
	return res;
}

int main(){
	int n;
	while (cin >> n, n){
		int pos = 0, time = 0;
		int dp[50][5];
		rep(i, 50) rep(j, 5) dp[i][j] = 1e9;
		dp[0][0] = 0;
		int failed = -1;
		int p, t;
		rep(i, n){
			cin >> p >> t;

			bool ok = false;
			rep(j, 4){
				if (dp[i][j] == 1e9) continue;
				if (time + pos*(j + 1) + p <= t){
					ok = true;
					dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + pos + p);
				}
				if (j < 3 && time + abs(pos - p)*(j + 1) <= t){
					ok = true;
					dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + abs(pos - p));
				}
			}
			if (failed < 0 && !ok) failed = i + 1;
			pos = p, time = t;
		}
		if (failed >= 0) cout << "NG " << failed << endl;
		else cout << "OK " <<  *min_element(dp[n], dp[n] + 4) + p << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int t, x;
	cin >> t >> x;
	cout << fixed << setprecision(10) << (double)t / x << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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


int main() { 
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) ans++; 
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)r=(r*a)%m;
		b = b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

ll addmod(ll a,ll b)
{
    if(a+b<mod)return a+b;
    else return a+b-mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll modinv(ll a)
{
    return modexp(a,mod-2,mod);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll k,n; cin>>k>>n;
	vi arr(n);
	rep(i,0,n)cin>>arr[i];
	ll mx = 0;
	rep(i,0,n-1)
	{
	    ll y =fabs((arr[i]-arr[i+1]));
	    mx = max(mx,y);
	}
	ll y = arr[0]+fabs(k-arr[n-1]);
	mx = max(mx,y);
	cout<<k-mx<<endl;
	return 0;
}
/*
6
1 2 3 4 5 -6
*/


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main()
{
    int N;
    cin >> N;
    ll dp[N + 1][3];

    memset(dp, 0, sizeof(dp));

    REP(i,0,N){
        int a, b, c;
        cin >> a >> b >> c;
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) +a;
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) +b;
        dp[i + 1][2] = max(dp[i][1], dp[i][0]) +c;
    }
    ll ans = 0;
    REP(i,0,3){
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
def resolve():
	n,m,x,y=map(int,input().split())
	xlist=list(map(int,input().split()))
	ylist=list(map(int,input().split()))
	
	mx=max(xlist)
	my=min(ylist)
	
	if mx<my:
		for z in range(mx+1,my+1):
			if x<z<=y:
				print('No War')
				break
		else:
			print('War')
	else:
		print('War')
resolve()

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

#include <iostream>

inline int min(int x, int y) {return x < y ? x : y;}
inline long min(long x, long y) {return x < y ? x : y;}
inline int max(int x, int y) {return x > y ? x : y;}
inline long max(long x, long y) {return x > y ? x : y;}

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

inline int euclid(int a, int b) {
    if (a > b) swap(a, b);
    int r = a % b;
    while (r > 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

using namespace std;

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

    int ret = A[0];
    for (int i = 1; i < N; i++) {
        ret = euclid(ret, A[i]);
    }

    cout << ret << endl;
    return 0;
}


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

namespace ABC154
{
    class B
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            for (int i = 0; i < S.Length; i++)
            {
                Console.Write('x');
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13140
n, q = map(int, input().split())
queue = []
for i in range(n):
  name, time = map(str, input().split())
  queue.append([name, int(time)])
    
length = 0
while queue:
  num = queue[0]
  if num[1] <= q:
    length += num[1]
    queue.pop(0)
    print(num[0], length)
  else:
    length += q
    queue.pop(0)
    queue.append([num[0], int(num[1]-q)])


Measured memory_bytes: 13012
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;


int main()
{
    int h,w;
    cin >> h >> w;
    int a = -1;
    for(int i=0;i<900;i++)
    {
        a++;
        string s;
        cin >> s;
        if(s == "snuke")
        {
            break;
        }
    }

    char tate = 'A' + a%w;
    int yoko = a/w;

    cout << tate << yoko + 1 << endl;

   return 0 ;
}


Measured memory_bytes: 256
#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++)

ll A[100100];

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a % b);
}

int main(){
    int N;
    cin >> N;
    REP(i, N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    ll ans = gcd(A[0], A[1]);
    for(int i = 2; i < N; i++){
        ans = gcd(ans, A[i]);
    }

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


Measured memory_bytes: 1024
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
ans=0
for i in range(N):
  if A[i]<=B[i]:
    B[i]-=A[i]
    ans+=A[i]
  else:
    ans+=B[i]
    B[i]=0
  if A[i+1]<=B[i]:
    ans+=A[i+1]
    A[i+1]=0
  else:
    ans+=B[i]
    A[i+1]-=B[i]
print(ans)

Measured memory_bytes: 82148
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m,q,k;
vector<edge> g[111111];
int d[111111];//kからの最短距離
int flag[111111];
void dfs(int v,int d2){
	d[v]=d2;
	flag[v]=1;
	for(auto e:g[v]){
		if(flag[e.to])continue;
		dfs(e.to,d2+e.cost);
	}
}

signed main(){

	cin>>n;	
	rep(i,n-1){
		int a,b,c;
		cin>>a>>b>>c;
		g[a-1].push_back({b-1,c});
		g[b-1].push_back({a-1,c});
	}
	fill(d,d+n,INF);
	cin>>q>>k;
	dfs(k-1,0);
	int x[111111],y[111111];
	rep(i,q){
		cin>>x[i]>>y[i];
	}
	rep(i,q)cout<<d[x[i]-1]+d[y[i]-1]<<endl;
}

Measured memory_bytes: 15360
/***from dust i have come, dust i will be***/

#include<bits/stdc++.h>

typedef long long int ll;
typedef unsigned long long int ull;

#define dbg printf("in\n")
#define nl printf("\n");
#define N 310
#define inf 1e9

#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)

#define pf(n) printf("%d",n)
#define pff(n,m) printf("%d %d",n,m)
#define pffl(n,m) printf("%I64d %I64d",n,m)
#define pfl(n) printf("%I64d",n)
#define pfs(s) printf("%s",s)

#define pb push_back
#define pp pair<int, int>

using namespace std;

ull bigMod(ull a, ull p, ull m)
{
    //a ^ 0 = 1
    if (p == 0)
        return 1;

    //odd
    if (p & 1)
    {
        //a^p = a * a^{p-1}
        return ((a%m)*bigMod(a, p - 1, m)) % m;
    }

    ull temp = bigMod(a, p / 2, m);
    return (temp*temp) % m;
}

int main()
{
    // freopen("in.txt", "r", stdin);

    int i, j, k;
    int n, m, t;

    sf(n);

    ull mod = 1e9 + 7;
    ull a[n];

    for(i = 0; i < n; i++)
        cin >> a[i];

    ull ans = 0, zc, oc, p = 0, mult;
    for(i = 0; i < 61; i++)
    {
        oc = 0, zc = 0;
        for(j = 0; j < n; j++)
        {
            if(a[j] & (1LL << i))
                oc++;
            else
                zc++;
        }

        mult = ((oc % mod) * (zc % mod)) % mod;
        mult = ((mult % mod) * bigMod(2, p, mod)) % mod;
//cout<<p<<" "<<oc<<" "<<zc<<" "<<mult;nl;
        ans = ((ans % mod) + (mult % mod)) % mod;


        p++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 2560
n = int(input())
S = list()
H = list()
C = list()
D = list()
for i in range(13):
  S.append(i+1)
  H.append(i+1)
  C.append(i+1)
  D.append(i+1)
  
for i in range(n):
  card = input().split()
  if card[0]=='S':
    S.remove(int(card[1]))
  if card[0]=='H':
    H.remove(int(card[1]))
  if card[0]=='C':
    C.remove(int(card[1]))
  if card[0]=='D':
    D.remove(int(card[1]))

for i in range(len(S)):
  print('S',S[i])
for i in range(len(H)):
  print('H',H[i])
for i in range(len(C)):
  print('C',C[i])
for i in range(len(D)):
  print('D',D[i])


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

#define SENTINEL 1200000000

typedef long long hyper;
hyper cnt = 0;

void Merge(int* A, int left, int mid, int right)
{
    int* L; int* R;
    int i, j, k, n1, n2;
    n1 = mid - left;
    n2 = right - mid;

    L = new int [n1 + 1]; R = new int [n2 + 1];
    if(L == NULL || R == NULL) return;

    for(i = 0; i < n1; i++) L[i] = A[i + left];
    for(j = 0; j < n2; j++) R[j] = A[j + mid];

    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    i = j = 0;

    // sorting.
    for(k = left; k < right; k++){

        if(L[i] <= R[j]){ A[k] = L[i]; i++; }

        else{ A[k] = R[j]; j++; cnt = cnt + n1 - i; } // add n1 - i.
    }
	delete [] L; delete [] R;
}

void MergeSort(int* A, int left, int right)
{
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}

int main()
{
    int* A;
    int i, n;
    cin >> n;

    A = new int [n];
    if(A == NULL) return 0;

    for(i = 0; i < n; i++) cin >> A[i];

    MergeSort(A, 0, n);
    cout << cnt << endl;

    delete [] A;

    return 0;
}

Measured memory_bytes: 2568
n = int(input())

while n >= 10:
    n -= 10

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
else:
    print("bon") 

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

struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};


int main() {
    int N, Q, t, u, v;
    cin >> N >> Q;
    dsu ds = dsu(N);
    for (int i = 0; i < Q; i++) {
        cin >> t >> u >> v;
        if (t) {
            cout << ds.same(u, v) << "\n";
        } else {
            ds.merge(u, v);
        }
    }

    return 0;
}


Measured memory_bytes: 3868
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,i=0,e=0,w=0,an=1e9,a[300003];
	char c[300003];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>c[i];
		a[i]=w;
		w+=c[i]==87;
	}
	for(i=n-1;i>-1;i--)
	{
		an=min(an,a[i]+e);
		e+=c[i]==69;
	}
	cout<<an<<endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;

int main(void) {
	ios::sync_with_stdio(false);
	int N, i, j, k;
	cin >> N;
	int L[N];
	for (i = 0; i < N; i++) cin >> L[i];
	sort(L, L + N, greater<int>());
	k = 0;
	for (i = 1; i < N; i++) {
		k += L[i];
	}
	if (L[0] < k) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
n,k=map(int, input().split())
a = list(map(int, input().split()))
mod=10**9+7
if n==k:
    ans=1
    for i in range(k):
        ans*=a[i]
        ans%=mod
    print(ans)
    exit()
minus=[i for i in a if i<0]
plus=[i for i in a if i>=0]
from collections import deque
minus=deque(sorted(minus))
plus=deque(sorted(plus,reverse=True))

n_minus=len(minus)
n_plus=len(plus)
if n_minus==n:
    ans=1
    if k%2==0:
        for i in range(k):
            ans*=minus.popleft()
            ans+=mod
            ans%=mod
        print(ans)
        exit()
    else:
        for i in range(k):
            ans*=minus.pop()
            ans+=mod
            ans%=mod
        print(ans)
        exit()

ans=1
while k>1:
    if n_minus>1 and n_plus>1 and k!=3:
        if minus[0]*minus[1]>=plus[0]*plus[1]:
            n_minus-=2
            k-=2
            for _ in range(2):
                ans*=minus.popleft()
                ans%=mod
        else:
            n_plus-=2
            k-=2
            for _ in range(2):
                ans*=plus.popleft()
                ans%=mod
    elif n_minus>1 and n_plus>2 and k==3:
        ans*=max(minus[0]*minus[1]*plus[0],plus[0]*plus[1]*plus[2])
        ans%=mod
        k-=3
    elif n_minus>1:
        n_minus-=2
        k-=2
        for _ in range(2):
            ans*=minus.popleft()
            ans%=mod
    elif n_plus>1:
        n_plus-=2
        k-=2
        for _ in range(2):
            ans*=plus.popleft()
            ans%=mod

if k==1:
    if plus:
        ans*=plus.popleft()
        ans%=mod

print(ans)


Measured memory_bytes: 113056
#include <iostream>

#define int long long

signed main() {
  int k, n;
  std::cin >> k >> n;

  int a[n];
  for(int i = 0; i < n; i++)
    std::cin >> a[i];

  int max = 0;
  for(int i = 0; i < n; i++) {
    int next = (a[i] - a[(n+i-1)%n] + k)%k;
    max = std::max(max, next);
  }

  std::cout << k-max << std::endl;
  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int N; string S;
  cin>>N>>S;
  int k=0;
  for(int i=0;i<N;i++)
    if(S.at(i)=='.')
      k++;
  int ans=k;
  for(int i=0;i<N;i++){
  if(S.at(i)=='.')
    k--;
    else
      k++;
    if(k<ans)
      ans=k;
 }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int a[210000],i,n,j,m,sum=0;
	
	scanf("%d%d", &n,&m);
	for(i=0; i<m;i++){
		scanf("%d", &a[i]);
        sum+=a[i];
	}
    if(sum>n){
    printf("-1\n");
    return 0;
    }
    printf("%d\n", n-sum);
    return 0;
}


Measured memory_bytes: 1756
from itertools import combinations
from copy import deepcopy
h,w,d = map(int,input().split())
c = []
kuro = 0
for i in range(h):
    s = list(input())
    kuro += s.count("#")
    c.append(s)
ans = 0
for i in range(h):
    for j in range(w):
        for k in combinations(range(h),r=i):
            for l in combinations(range(w),r=j):
                data = deepcopy(c)
                num = 0
                for m in k:
                    for a in range(w):
                        if data[m][a] == "#":
                            data[m][a] = "."
                            num += 1
                for n in l:
                    for b in range(h):
                        if data[b][n] == "#":
                            num += 1
                if kuro-num == d:
                    ans += 1
print(ans)                            

Measured memory_bytes: 9356
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long n,x,i,a[100005],ans;
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int main(){
	cin>>n>>x;
	for(i=1;i<=n;i++)
		cin>>a[i];
	ans=1;
	for(i=1;i<=n;i++){
		a[i]+=a[i-1];
		if(a[i]<=x)
			ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
$data = fgets(STDIN);
$now = 0;
$ans = 0;

$t = str_split($data);
foreach($t as $char)
{
    if($char == "R")
    {
        $now += 1;
    }
    else
    {
        $now = 0;
    }
    $ans = max($now,$ans); 
}
echo $ans;
?>

Measured memory_bytes: 15948
using System;using System.Collections.Generic;class MainClass{public static void Main(string[]args){string str;List<int>digit=new List<int>();while(!string.IsNullOrEmpty(str=Console.ReadLine())){string[]input=str.Split(' ');int a=int.Parse(input[0]);int b=int.Parse(input[1]);int c=a+b;digit.Add(c.ToString().Length);}
for(int i=0;i<digit.Count;i++){Console.WriteLine(digit[i]);}
Console.Read();}}

Measured memory_bytes: 9004
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
  a,b := 0,0
  for i := 1; ; i++{
    fmt.Scan(&a)
    fmt.Scan(&b)
    if a == 0 && b == 0{
      break
    }else{
      if a > b{
        fmt.Println(b,a)
      }else{
        fmt.Println(a,b)
      }
    }
  }
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


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

#define u(x, a, b) for(ll x = a; x < b; x++)
#define d(x, a, b) for(ll x = a; x > b; x--)

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

vector<ll> primes;

int main(){
	string s;
	cin >> s;
	
	ll n = s.size();

	vector<ll> rlswitch;
	ll cle = 1;
	
	u(one, 1, n){
		if(s[one]==s[one-1]){cle++;}
		else{rlswitch.push_back(cle); cle = 1;}
	}
	rlswitch.push_back(cle);
	
	ll ans[n] = {0};
	ll cpos = 0;
	ll cdir = 1; //1 is to right, -1 is to left
	
	u(one, 0, rlswitch.size()){
		if(cdir==1){
			ll x = rlswitch[one];
			cpos += x;
			ll small = x/2;
			ans[cpos] += small;
			ans[cpos-1] += x-small;
			cdir = -1;
		}
		else{
			ll x = rlswitch[one];
			ll small = x/2;
			ans[cpos-1] += small;
			ans[cpos] += x-small;
			cpos += x;
			cdir = 1;
		}
	}


	u(one, 0, n){cout << ans[one] << ' ';}
}


Measured memory_bytes: 4788
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    switch(n % 10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s,a[5];
	bool b=true;
	cin>>s;
	for(int i=0;i<4;i++)
	{
		a[i]=s%10;
		s/=10;
		if(i>0)
		{
			if(a[i]==a[i-1])
			{
				b=false;
			}	
		} 
	}
	if(b)
	{
		cout<<"Good";
	}	
	else
	{
		cout<<"Bad";
	}
} 

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
const int MAXL = 1e6 + 5;

char s[MAXL];

struct Node
{
	int l,r;
};
inline bool cmp_l(const Node &p,const Node &q){ return p.l<q.l;}
inline bool cmp_r(const Node &p,const Node &q){ return p.r<q.r;}
vector<Node> a,b;

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
	{
		scanf("%s",s+1);
		int l=0, r=0;
		for(int i=1; s[i]; ++i)
		{
			if(s[i]=='(') ++r;
			if(s[i]==')')
			{
				if(r) --r;
				else ++l;
			}
		}
		
		if(l<=r) a.push_back((Node){l,r});
		else b.push_back((Node){l,r});
	}
	
	sort(a.begin(),a.end(),cmp_l);
	int r=0;
	for(int i=0; i<(int)a.size(); ++i)
	{
		if(a[i].l > r){ printf("No"); return 0;}
		r = r - a[i].l + a[i].r;
	}
	
	sort(b.begin(),b.end(),cmp_r);
	int l=0;
	for(int i=0; i<(int)b.size(); ++i)
	{
		if(b[i].r > l){ printf("No"); return 0;}
		l = l - b[i].r + b[i].l;
	}
	
	if(l==r) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 10832
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        s[3] = '8';
        System.out.println(new String(s));
    }
}


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

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

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

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

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

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

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

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


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

int main(){
    int a; cin >> a;
    int ans = 0;
    for(int i = 1; i <= a; i++){
        int b = i;
        int keta = 0;
        while(b!=0){
            b /= 10;
            keta++;
        }
        if(keta%2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
    long n;
    cin>>n;
    deque<long> deq(0);
    for(int i=0;i<n;i++){
        long a;
        cin>>a;
        
        if(i%2==0) deq.push_back(a);
        else deq.push_front(a);
    }
    
    if(n%2==0){
        for(auto ite=deq.begin();ite!=deq.end();++ite) cout<<*ite<<" ";
    }else{
        for(auto ite=deq.rbegin();ite!=deq.rend();++ite) cout<<*ite<<" ";
    }
    
    cout<<endl;
}


Measured memory_bytes: 3840
a = int(input())
b = list(map(int, input().split()))
b.sort()
if a % 2 == 0:
    c = 1
    for i in range(len(b)):
        if i > 0 and i % 2 == 0:
            c += 2
        if b[i] != c:
            print(0)
            exit()
    print((2 ** (a // 2)) % (10 ** 9 + 7))
else:
    c = 0
    for i in range(len(b)):
        if i > 0 and i % 2 == 1:
            c += 2
        if b[i] != c:
            print(0)
            exit()
    print((2 ** ((a-1) // 2)) % (10 ** 9 + 7))


Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

int main(){
    string T; cin >> T;
    ll N = sz(T);
    string s = "";
    rep(i, 0, N){
        if(T[i] == '?'){
            s.pb('D');
        }else{
            s.pb(T[i]);
        }
    }
    prt(s);
}

Measured memory_bytes: 3924
import sys
def main():
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            break
        else:
            A = []
            B = []
            for _ in range(n):
                hoge, fuga = map(int, input().split())
                A.append(hoge)
                B.append(fuga)

            a, b = 0, 0
            for x in range(n):
                if A[x] == B[x]:
                    a += A[x]
                    b += B[x]
                else:
                    piyo = A[x] + B[x]
                    if A[x] > B[x]:
                        a += piyo
                    else:
                        b += piyo
            print(a, b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 7924
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
  string s;
  cin >> s;
  if(s[5]-'0' > 0 || s[6]-'4' > 0){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  int n, x, t;
  cin >> n >> x >> t;
  for (int i = 0;; i++)
  {
    if (i * x >= n)
    {
      cout << i * t << endl;
      break;
    }
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i].first>>vec[i].second;
    }
    sort(vec.rbegin(),vec.rend());
    cout<<vec[0].first+vec[0].second<<endl;
}

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

int main() {
    string a,b;
    int n;
    cin>>n;
	cin>>a>>b;
    int i=0;
    string ans;
    while(i<n){
        ans.push_back(a[i]);
        ans.push_back(b[i]);
        i++;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
int h,w,a,b;
std::map<int,int> mp;
std::multiset<int> s;
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
    std::cin>>h>>w;
    rep(i,0,w-1) mp[i]=i,s.insert(0);
    rep(i,0,h-1){
        std::cin>>a>>b; a--;
        auto pos=mp.lower_bound(a);
        int mx=-1;
        while(pos!=mp.end()&&pos->first<=b){
            mx=std::max(mx,pos->second);
            int x=pos->first-pos->second;
            s.erase(s.find(x));
            mp.erase(pos++);
        }
        if(mx!=-1&&b<w){
            s.insert(b-mx);
            mp[b]=mx;
        }
        std::cout<<(s.empty()?-1:*s.begin()+i+1)<<'\n';
    }
    return 0;
}

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

int main(){
  int n, a;
  cin >> n >> a;
  if (n%500==0){
    cout << "Yes" << endl;
  	}
  else {
    int div = n % 500; //余り<=aとなればいい
    if (a>=div){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val pass = Array.fill(n+1)(true)

  var l = 1
  var r = n
  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach { e =>
      l = l max e(0)
      r = r min e(1)
    }
  val ans =( r - l + 1) max 0
  println(ans)
}

Measured memory_bytes: 44448
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    string s;

    void solve(){
        cin >> s;
        vector<string> a;
        vector<string> b={"KIH","B","R"};
        for(int i=0; i<16; ++i){
            string tmp="";
            for(int j=0; j<4; ++j){
                if((i>>j)&1){
                    tmp+="A";
                }
                if(j<3)tmp+=b[j];
            }
            a.push_back(tmp);
        }
        bool ans = false;
        for(int i=0; i<16; ++i){
            if(s==a[i])ans=true;
        }
        if(ans)cout << "YES" <<"\n";
        else cout << "NO" <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    Problem p;
    p.solve();
    return 0;
}



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

int main(){
  
  long double a,b,h,m,ans;
  long double rad1,rad2,rad3;
  
  
  scanf("%Lf%Lf%Lf%Lf",&a,&b,&h,&m);
  
  rad1 = (h/12 + m/12/60) * 2*M_PI;
  rad2 = m/60 * 2*M_PI;
  rad3 = rad2 - rad1;
  
  //printf("rad1=%Lf rad2=%Lf rad3=%Lf\n",rad1,rad2,rad3);
  
  ans = sqrt(a*a + b*b - 2*a*b*cos(rad3));
  
  printf("%.20Lf\n",ans);
  
  return 0;
        
}

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

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

  int a[10][10] = {0};
  rep(i, n){
    string s = to_string(i);
    a[s.at(0)-'0'][i%10]++;
  }

  int count = 0;
  rep(i, 9){
    rep(j, 9){
      count += a[i][j] * a[j][i];
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 256
from collections import defaultdict
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = defaultdict(int)
sa = [0] * (n + 1)
# d[0] = 1
# if k == 1:
#     print(0)
#     exit()
for i in range(n):
    sa[i + 1] = sa[i] + a[i]
    sa[i + 1] %= k
ans = 0
for i in range(n + 1):
    v = sa[i] - i
    v %= k
    ans += d[v]
    d[v] += 1
    if 0 <= i - k + 1:
        vv = sa[i - k + 1] - (i - k + 1)
        vv %= k
        d[vv] -= 1
print(ans)
# from collections import defaultdict
# n, k = map(int, input().split())
# a = list(map(int, input().split()))
# d = defaultdict(int)
# sa = [0] * (n + 1)
# d[0] = 1
# if k == 1:
#     print(0)
#     exit()
# for i in range(n):
#     sa[i + 1] = sa[i] + a[i]
#     sa[i + 1] %= k
# ans = 0
# for i in range(1, n + 1):
#     v = sa[i] - i
#     v %= k
#     ans += d[v]
#     d[v] += 1
#     if 0 <= i - k + 1:
#         vv = sa[i - k + 1] - (i - k + 1)
#         vv %= k
#         d[vv] -= 1
# print(ans)


Measured memory_bytes: 48532
#include <iostream>

using namespace std;

int A[100010];

int partition(int a[], int p, int r) {
    int x = a[r];
    int i = p - 1;
    for (int j = p; j < r; ++j) if (a[j] <= x)swap(a[++i], a[j]);
    swap(a[++i], a[r]);
    return i;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];
    int q = partition(A, 0, n - 1);
    for (int i = 0; i < q; ++i) cout << A[i] << ' ';
    cout << '[' << A[q] << ']';
    for (int i = q + 1; i < n; ++i) cout << ' ' << A[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 3376
#include <cstdio>

using namespace std;

bool testcase_ends() {
    int m, d;
    scanf("%d %d", &m, &d);

    if (m == 0 && d == 0)
        return 1;

    int offset[]={
        0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
    };

    const char *day[]={
        "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun"
    };

    printf("%sday\n", day[(offset[m-1]+d+2)%7]);
    return 0;
}

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

Measured memory_bytes: 2544