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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n, x, y;
int distFromRoot[MAX_N];
int distFromSecond[MAX_N];
int lowest[MAX_N];
vector<int> G[MAX_N];

void dfs(int root, int v, int par) {
    if (par != -1) {
        if (root == y) {
            distFromRoot[v] = distFromRoot[par] + 1;
        } else {
            distFromSecond[v] = distFromSecond[par] + 1;
        }
    }

    if (v != y && root == y && G[v].size() == 1) {
        lowest[v] = distFromRoot[v];
    }

    for (auto to: G[v]) {
        if (to == par) continue;
        dfs(root, to, v);
        if (root == y) {
            lowest[v] = max(lowest[v], lowest[to]);
        }
    }
}

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

    cin >> n >> x >> y;
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(y, y, -1);
    dfs(x, x, -1);

    /*for (int i = 1; i <= n; i++) {
        cout << i << ":   " << distFromRoot[i] << "  " << distFromSecond[i] << "  " << lowest[i] << "\n";
    }*/

    int ans = -inf;
    for (int i = 1; i <= n; i++) {
        if (distFromSecond[i] < distFromRoot[i]) {
            ans = max(ans, lowest[i] - 1);
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 16384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

#include <bits/stdc++.h>

using namespace std;

const int mxN = 110;

class TaskK {
public:
	int N, K, a[mxN];
	vector<int> dp;

	void solve(std::istream& in, std::ostream& out) {
		in >> N >> K;
		dp.resize(K + 1, -1);
		for (int i = 0; i < N; i++) in >> a[i];
		if (rec(K))
			out << "First";
		else
			out << "Second";
	}

	int rec(int k) {
		if (dp[k] != -1) return dp[k];
		dp[k] = 0;
		for (int i = 0; i < N; i++) {
			if (k < a[i])
				break;
			dp[k] = dp[k] | (rec(k - a[i]) == 0);
		}
		return dp[k];
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskK solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8196
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }
long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
double memo[301][301][301];
int n;
double func(int cnt3, int cnt2, int cnt1) {
    if (cnt3 == 0 && cnt2 == 0 && cnt1 == 0) {
        return 0;
    }
    if (memo[cnt3][cnt2][cnt1] > 0) {
        return memo[cnt3][cnt2][cnt1];
    }
    double ans = 1;
    if (cnt3 > 0) {
        ans += (double(cnt3) / n) * func(cnt3 - 1, cnt2 + 1, cnt1);
    }
    if (cnt2 > 0) {
        ans += (double(cnt2) / n) * func(cnt3, cnt2 - 1, cnt1 + 1);
    }
    if (cnt1 > 0) {
        ans += (double(cnt1) / n) * func(cnt3, cnt2, cnt1 - 1);
    }
    memo[cnt3][cnt2][cnt1] = (ans) / (1 - double(n - cnt3 - cnt2 - cnt1) / n);
    return memo[cnt3][cnt2][cnt1];
}
signed main() {
    cin >> n;
    Fill(memo, -1);
    map<int, int> cnt;
    REP(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    cout << func(cnt[3], cnt[2], cnt[1]) << endl;
}

Measured memory_bytes: 213376
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    long long int x, y, n, a, b, ans;
    cin >> x >> y >> n;
    a=y/n;
    b=x/n;
    ans=a-b;
    if(x%n==0)
        ans+=1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x;
    scanf("%lld",&n);
    x = sqrt(n);
    while(1)
    {
        if(n%x==0)
        {
            printf("%lld\n",((n/x)+x)-2);
            return 0;
        }
        x--;
    }
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (200006)
int n, k, A[MAXN];
struct node {
	int v;
	node *l,*r;
	node(ll _S,ll _E){
		v=0;
		l=r=0;
	}
	void update(ll s, ll e, ll x,ll nval) {
		ll m=(s+e)>>1;
		if(s==e) {
			v += nval;
			return;
		}
		if(x>m) cr(m+1,e), r->update(m+1,e,x,nval); else cl(s,m), l->update(s,m,x,nval);
		v=(l?l->v:0)+(r?r->v:0);
	}
	ll rmq(ll s,ll e,ll x,ll y) {
		ll m=(s+e)>>1;
		if(s==x&&e==y) return v;
		if(x>m) return r?r->rmq(m+1,e,x,y):0;
		else if(y<=m) return l?l->rmq(s,m,x,y):0;
		else return (l?l->rmq(s,m,x,m):0)+(r?r->rmq(m+1,e,m+1,y):0);
	}
	void cl(ll s,ll e) { if(!l) l=new node(s,e); }
	void cr(ll s,ll e) { if(!r) r=new node(s,e); }
} *seg;
int main()
{
	FAST
	cin>>n>>k;
	FOR(i,1,n) cin>>A[i];
	ll sum = 0, ans = 0;
	ll ofs=2e14;
	seg=new node(0, 4e14);
	seg->update(0, 4e14, ofs, 1);
	FOR(i,1,n) {
		sum += A[i];
		ans += seg->rmq(0, 4e14, 0, sum-i*k+ofs);
		seg->update(0, 4e14, sum-i*k+ofs, 1); 
	}
	cout<<ans<<'\n';
}


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

int main() {
  int N;
  int64_t Q=1000000007;
  cin>>N;
  vector<int> q(1000000);
  int64_t H=0;
  for(int i=0;i<N;i++){
    int64_t A;
    cin>>A;
    int64_t M=Q-2; //ここから
       int64_t a=1,b=0,c=1;
       while(M>0){
         a*=2;
         if(M%a!=0){
           M-=a/2;
           int64_t d=A;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      } //ここまで
    H+=c;
    H%=Q;
    for(int64_t j=2;j<1000;j++){
      if(A%j==0){
        int d=0;
        while(A%j==0){
          d++;
          A/=j;
        }
        q.at(j)=max(q.at(j),d);
      }
    }
    if(q.at(A)==0){
      q.at(A)++;
    }
  }
  for(int i=0;i<1000000;i++){
    for(int j=0;j<q.at(i);j++){
      H*=i;
      H%=Q;
    }
  }
  cout<<H<<endl;
}

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

#define DEBUG 0

int compare(const void *a, const void *b)
{
	return *(long long *)b - *(long long *)a;
}

int main(int argc,char *argv[])
{
	int n,i,over,under;
	long long *a, sumA;
	long long *b, sumB;
	long long *c, need;
	int ans=0;

	scanf("%d",&n);
	a = (long long *)malloc(sizeof(long long) * n);
	b = (long long *)malloc(sizeof(long long) * n);
	c = (long long *)malloc(sizeof(long long) * n);
	sumA = 0;
	sumB = 0;
	for (i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		sumA += a[i];
	}
	for (i=0;i<n;i++) {
		scanf("%lld",&b[i]);
		sumB += b[i];
	}

	// check enable
	if (sumA < sumB) {
		printf("-1\n");
		return 0;
	}

	// scan extra score
	over = 0;
	under = 0;
	need = 0;
	for (i=0;i<n;i++) {
		c[i] = a[i] - b[i];
		if (c[i] < 0) {
			under++;
			need += c[i] * (-1);
			if (DEBUG) printf("i=%03d under\n",i);
		}	else {
			over++;
			if (DEBUG) printf("i=%03d over\n",i);
		}
	}

	qsort(c,n,sizeof(long long),compare);

	if (DEBUG) printf("need = %lld\n",need);
	for (i=0;i<n;i++) {
		if (need <= 0) break;
		need -= c[i];
		ans++;
	}
	ans += under;

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

	return 0;
}


Measured memory_bytes: 3324
H = int(input())
A = [None] + [int(i) for i in input().split()]

def maxHeapify(H, A, i):
    left = 2*i
    right = left + 1

    if left <= H and A[left] > A[i]:
        largest = left
    else: largest = i
    if right <= H and A[right] > A[largest]:
        largest = right
    if largest != i:
        A[i], A[largest] = A[largest],A[i]
        maxHeapify(H,A,largest)

def buildmaxHeap(H,A):
    for i in range(H//2,0,-1):
        maxHeapify(H,A,i)

buildmaxHeap(H,A)

for i in A[1:]:
    print(" " + str(i), end="")
print("")

Measured memory_bytes: 65852
N, K = map(int, input().split())

if K % 2 == 0:
	ans1 = N // K
	if (N % K) >= (K // 2):
		ans2 = ans1 + 1
	else:
		ans2 = ans1
	ans = (ans1 ** 3) + (ans2 ** 3)
else:
	ans = (N // K)**3

print(ans)

Measured memory_bytes: 2940
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for(int i=1;i<10;i++){
      for(int j=1;j<10;j++){
        if(i*j==N){
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 35712
import os
import sys
from io import BytesIO, IOBase
def main():
    h1,m1,h2,m2,k=map(int,input().split())
    ht=h2-h1
    ht*=60
    if(m2>=m1):
        ht+=m2-m1
    else:
        ht+=(m2-m1)
    print(ht-k)

# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()


Measured memory_bytes: 62684
#include<iostream>
#include<vector>


using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  vector<int> q(N);
  for(int i=0; i< N; i++){
    cin >> p[i] ;
    q[i] = p[i];
  }

  int flag =0;
  for(int i=0; i< N; i++){
    for(int j =0; j < N;j++){
      for(int k =0; k < N;k++)p[k] = q[k];
      int cnt =0;
      int a = p[i];
      p[i] = p[j];
      p[j] = a;
      for(int k =0; k < N-1; k++){
        if(p[k] < p[k+1])cnt++;
        if(cnt == N-1)flag = 1;
      }
  //    for(int k =0; k < N;k++)cout << p[k] << " ";
  //    cout << endl;
  //    cout << "i:" << i << "j;" << j << "cnt " << cnt << endl;
    }
  }

  if(!flag)cout << "NO" << endl;
  else cout << "YES" << endl;
}



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

using namespace std;

const int N = 5e5 + 10;

int n, q;
int a[N], res[N], bit[N];
vector<int> pos[N];
vector<pair<int, int>> query[N];

void update(int x, int p) { for (; x <= n; x += x & -x) bit[x] += p; }
int get(int x) { int ret = 0; for (; x; x -= x & -x) ret += bit[x]; return ret; }

int main() {
    vector<int> rar;
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        rar.push_back(a[i]);
    }
    sort(rar.begin(), rar.end());
    rar.resize(unique(rar.begin(), rar.end()) - rar.begin());
    for (int i = 1; i <= n; i++) {
        a[i] = upper_bound(rar.begin(), rar.end(), a[i]) - rar.begin();
        if (pos[a[i]].empty()) update(i, 1);
        pos[a[i]].push_back(i);
    }
    for (int i = 1; i <= n; i++)
        reverse(pos[i].begin(), pos[i].end());
    for (int i = 1; i <= q; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        query[l].push_back(make_pair(r, i));
    }
    for (int i = 1; i <= n; i++) {
        for (pair<int, int> p: query[i])
            res[p.second] = get(p.first);
        update(pos[a[i]].back(), -1);
        pos[a[i]].pop_back();
        if (pos[a[i]].size()) update(pos[a[i]].back(), 1);
    }
    for (int i = 1; i <= q; i++)
        printf("%d\n", res[i]);
}


Measured memory_bytes: 60576
import heapq
K = int(input())
l = [i + 1 for i in range(0, 9)]
heapq.heapify(l)
count = 1
ans = 0
while count < K:
    x = heapq.heappop(l)
    l_digit = x % 10
    if l_digit != 0:
        heapq.heappush(l, 10 * x + l_digit - 1)
    heapq.heappush(l, 10 * x + l_digit)
    if l_digit != 9:
        heapq.heappush(l, 10 * x + l_digit + 1)
    count += 1
print(heapq.heappop(l))


Measured memory_bytes: 11764
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("Yes\n")
#define ptn printf("No\n")
//==========================Code here==========================
LL n, a, b, c, d;
char s[200000 + 5];
int main() {
	cin >> n >> a >> b >> c >> d;
	scanf("%s", s + 1);
	s[++n] = '#';
	
	for (LL i = b; i < d; ++i) {
		if (s[i] == '#' && s[i + 1] == '#') return ptn, 0;
	} 
	for (LL i = a; i < c; ++i) {
		if (s[i] == '#' && s[i + 1] == '#') return ptn, 0;
	}
	
	if (c < d) return pty, 0;
	
	for (LL i = b - 1; i <= d - 1; ++i) {
		if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') return pty, 0;
	}
	//if(s[b-1]=='.'&&s[b+1]=='.') return pty, 0;
	
	return ptn, 0;
	
	/*LL maxi = 0, cnt=0;
	for(int i=b;i<=d+1;i++)
	{
		if(s[i]=='.') cnt++;
		else cnt=0;
		maxi=max(maxi,cnt);
	}
	if(s[b-1]=='.'&&s[b+1]=='.') maxi=3;
	if(maxi<=2)
		printf("No");
	else printf("Yes");*/
	
	return 0;
}
/*
11 5 9 9 11
..##..#..#.

9 4 6 9 8 
.##...#..
*/

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int broken[100001];
long long dp[100001];

int stair(int n) {
	dp[1] = (broken[1] == 0) * 1;
	dp[2] = (dp[1] + 1) * (broken[2] == 0);
	
	for (int i = 3; i <= n; i++) {
		if ((broken[i-1] == 0)&&(broken[i-2] == 0)) {
			dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
		}
		else if ((broken[i-1] == 0)&&(broken[i-2] != 0)) {
			dp[i] = (dp[i - 1]) % 1000000007;
		}
		else if ((broken[i-1] != 0)&&(broken[i-2] == 0)) {
			dp[i] = (dp[i - 2]) % 1000000007;
		}
		else {
			dp[n] = 0;
			break;
		}
	}

	return dp[n];
}

int main()
{
	bool isable = true;
	int n, m;
	vector<int> a;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int tmp;
		cin >> tmp;
		broken[tmp] = 1;
	}

	cout << stair(n) << endl;
	return 0;
}

Measured memory_bytes: 1408
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
n = -1
for x in range(1000):
    x = str(x)
    if len(x)!=N:continue
    ind = 0
    for i in range(M):
        s,c = A[i]
        if x[int(s)-1]!=str(c):
            ind=1
            break
    if ind==0:
        n = x
        break
print(n)

Measured memory_bytes: 63332
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<29;
const double EPS = 1e-8;
const int MOD = 1000000007;

#define X first
#define Y second
#define MAXSIZE 1001
int n;
pii p[MAXSIZE];
int X[MAXSIZE][MAXSIZE];
int K[MAXSIZE][MAXSIZE];

int solve(int n) {
  memset(X, 63, sizeof(X));
  for (int i = 0; i <= n; ++i) {
    X[i][i] = X[i][i+1] = 0;
    K[i][i] = K[i][i+1]= i;
  }
  for (int w = 2; w <= n; ++w) 
    for (int i = 0, j; (j = i+w) <= n; ++i) 
      for (int r = K[i][j-1]; r <= K[i+1][j]; ++r)  {
        int c = X[i][r] + X[r][j] + p[r-1].Y - p[j-1].Y + p[r].X - p[i].X;
        if (X[i][j] > c) { X[i][j] = c; K[i][j] = r; }
      }
  return X[0][n];
}
main(){
	ios::sync_with_stdio(false);
	scanf("%d", &n);
	REP(i, n) scanf("%d%d", &p[i].X, &p[i].Y);
	printf("%d\n", solve(n));
	return 0;
}

Measured memory_bytes: 9056
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
signed main() {
	int n, k; cin >> n >> k;
	int a[123456], sum = 0, sum1 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i < k)sum += a[i];
		else sum1 += max((int)0, a[i]);
	}
	int ans = max(sum, (int)0) + sum1;
	for (int i = 0; i < n - k; i++) {
		sum -= a[i];
		sum1 += max((int)0, a[i]);
		sum1 -= max((int)0, a[i + k]);
		sum += a[i + k];
		ans = max(ans, max(sum, (int)0) + sum1);
	}
	cout << ans << endl;}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define pai 3.141592653589
typedef long long ll;

int main(void)
{
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    int tmp = m + h * 60;
    //printf("%d ", tmp);

    double degH = (double)tmp / 720 * 360, degM = (double)tmp / 60 * 360;
    double rad;
    if (degH > degM)
        rad = (degH - degM) * (pai / 180);
    else
        rad = (degM - degH) * (pai / 180);

    //printf("%f ", rad);

    double ans = a * a + b * b - 2 * a * b * cos(rad);

    printf("%.12f\n", sqrt(ans));

    return 0;
}

Measured memory_bytes: 2604
#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 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;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 long long int ll;

using namespace std;



signed main(){
    
    string s;
    cin>>s;
	for(int i=0;i<s.size()-1;i++){
	    if(s[i]==s[i+1]){
	        cout<<i+1<<" "<<i+2<<endl;
	        return 0;
	    }
	    if(i<s.size()-2 && s[i]==s[i+2]){
	        cout<<i+1<<" "<<i+3<<endl;
	        return 0;
	    }
	}
	cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    ll n,m;
    cin>>n>>m;
    ll a[n],i,r,c=0,s=0;
    for(i=0;i<n;i++)
    {cin>>a[i];s+=a[i];}
    sort(a,a+n); 
    r=ceil(double (s)/double((4*m)));
    for(i=n-1;i>=0;i--)
    {
        if(c==m||a[i]<r)break;
        if(a[i]>=r)
        c++;
    }
    //  cout<<c;
    if(c==m)
    cout<<"Yes";
    else
    cout<<"No";
}
        

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define N 101
int main(){
	int n,time,c[N]={},t[N]={},min=1001;
	cin >> n >> time;
	for(int i=0;i<n;i++){
		cin >> c[i] >> t[i];
	}
	for(int i=0;i<n;i++){
		if(t[i]<=time){
			if(c[i]<min){
				min = c[i];
			}
		}
	}
	if(min<1001){
		cout << min << endl;
	}else{
		cout << "TLE" << endl;
	}
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

lint dp[100005][13];  // dp[上からi桁まで][余りの数]

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

  string s;
  cin >> s;

  dp[0][0] = 1;
  for (int i = 0; i < s.size(); i++) {
    int c;
    if (s[i] == '?')
      c = -1;
    else
      c = s[i] - '0';

    for (int j = 0; j < 10; j++) {
      if (c != -1 && c != j) continue;
      for (int ki = 0; ki < 13; ki++) {
        dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
      }
    }
    for (int j = 0; j < 13; j++) dp[i + 1][j] %= MOD;
  }

  cout << dp[s.size()][5] << endl;

  return 0;
}

Measured memory_bytes: 10704
#include <iostream>
using namespace std;
int main(void){
    bool history[100001];
    int  list[100001];
    int n;
    
    scanf("%d", &n);
    for (int i=1;i<=n;i++)
        scanf("%d", list+i);

    for (int i=0;i<=n;i++)
        history[i] = false;
    history[1] = true;
    
    int i=1;
    int count=0;
    while(1){
        i = list[i]; count++;
        if (i==2 || history[i])
            break;
        history[i] = true;
    }
    if (i==2) printf("%d\n", count);
    else printf("-1");
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  vector<int> A(3);
  rep(i,3) cin>>A[i];
  sort(all(A));
  cout<<A[2]*10+A[0]+A[1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ji=0,ou=0;
	for(int i=1;i<=n;i++)
	{
		if(i%2)
		ji++;
		else
		ou++;
	}
	printf("%0.10f",ji*1.0/(ji+ou));
}

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

int main(){
    long long n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    long long minMove = min({a, b, c, d, e}); //ボトルネック
    long long ans = ((n + minMove) - 1) / minMove + 4;
    cout << ans << endl;
}

//最小容量の交通機関に合わせる
//最小容量の人数ずつn人を分ける⇒グループ数はn/x + 1
//グループを0秒から順次出発させる
//最後のグループが出発するのはn/x秒後
//最後のグループは5つの交通機関を使い、1分ずつ計5分でゴール


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

typedef tuple<int, int, int, int> TP;
TP narabi(int a, int b, int c, int d) {
	TP kari[4];
	kari[0] = tie(a, b, c, d);
	kari[1] = tie(b, c, d, a);
	kari[2] = tie(c, d, a, b);
	kari[3] = tie(d, a, b, c);
	return *min_element(kari, kari + 4);
}

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


	int N;
	cin >> N;
	TP C[400];
	int cnum[1000] = {};
	rep(i, N) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		C[i] = narabi(a, b, c, d);
		cnum[a]++;
		if(a != b) cnum[b]++;
		if(c != a && c != b) cnum[c]++;
		if(d != a && d != b && d != c) cnum[d]++;
	}

	sort(C, C + N);
	int kazu[400] = {};
	rep(i, N) {
		int k = i;
		while (k + 1 < N && C[k + 1] == C[i]) k++;
		kazu[i] = k - i + 1;
		i = k;
	}

	ll kotae = 0;
	rep(i, N) {
		int inum = lower_bound(C, C + N, C[i]) - C;
		kazu[inum]--;
		rep(j, N) if (i != j) {

			int a, b, c, d, e, f, g, h;
			a = get<0>(C[i]);
			b = get<1>(C[i]);
			c = get<2>(C[i]);
			d = get<3>(C[i]);
			e = get<0>(C[j]);
			f = get<1>(C[j]);
			g = get<2>(C[j]);
			h = get<3>(C[j]);
			if (cnum[a] <= 2) continue;
			if (cnum[b] <= 2) continue;
			if (cnum[c] <= 2) continue;
			if (cnum[d] <= 2) continue;
			if (cnum[e] <= 2) continue;
			if (cnum[f] <= 2) continue;
			if (cnum[g] <= 2) continue;
			if (cnum[h] <= 2) continue;

			int bairitu = kazu[inum] + 1;
			int jnum = lower_bound(C, C + N, C[j]) - C;
			bairitu *= kazu[jnum]--;

			rep(x, 4) {
				TP D[4];
				D[0] = narabi(a, d, f, e);
				D[1] = narabi(a, e, h, b);
				D[2] = narabi(b, h, g, c);
				D[3] = narabi(c, g, f, d);
				TP* itr[4];
				rep(k, 4) itr[k] = lower_bound(C, C + N, D[k]);
				ll kari = bairitu;
				rep(k, 4) {
					if (itr[k] != C + N && *(itr[k]) == D[k]) {
						kari *= kazu[itr[k] - C]--;
						if (get<0>(D[k]) == get<2>(D[k]) && get<1>(D[k]) == get<3>(D[k])) {
							kari *= 2;
							if (get<1>(D[k]) == get<2>(D[k])) kari *= 2;
						}
					}
					else {
						kari = 0;
						break;
					}
				}
				rep(k, 4) {
					if (itr[k] != C + N && *itr[k] == D[k]) {
						kazu[itr[k] - C]++;
					}
					else break;
				}
				kotae += kari;

				int tmp = e;
				e = f;
				f = g;
				g = h;
				h = tmp;
			}
			j += kazu[jnum]++;
		}
		i += kazu[inum]++;
	}
	co(kotae / 6);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#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>
#include <bits/stdc++.h>
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 ;
 
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b))<<endl;
}


Measured memory_bytes: 256
#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 << "Balanced" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
vector<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
vector<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int INF = 1001001001;

int main () {
    int n; cin >> n;
    V<P> v(n);
    rep(i, n) {
        int x, l; cin >> x >> l;
        v[i].first = x + l;
        v[i].second = x - l;
    }
    sort(all(v));
    int r = -INF;
    int ans = 0;
    rep(i, n) {
        if (r <= v[i].second) {
            ans++;
            r = v[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3972
M, N, X, Y = list(map(int, input().split(" ")))
x = list(map(int, input().split(" ")))
y = list(map(int, input().split(" ")))

x_max = max(x)
y_min = min(y)

if(y_min <= x_max):
    print("War")
    exit()

flag = 0
for i in range(x_max, y_min+1, 1):
    if(X <= i and i <= Y):
        flag = 0
    else:
        print("War")
        exit()
        
if(flag == 0): print("No War")
else: print("War")

Measured memory_bytes: 3064
#include<cstdio>

using namespace std;

typedef long long ll;

int main(){
	for(ll n;scanf("%lld",&n),n;){
		ll ans1=4*2*n; // 奥行き
		ll ans2=4*n-4; // 一番外側の幅 1 の部分

		ll ans3=0,x; // 左下 1/4 の ans2 を除いた部分
		for(x=1;x*x<n/2;x++) ans3+=(n+2*x-1)/(2*x)-1;
		ans3=2*ans3-(x-1)*(x-1);

		printf("%lld\n",ans1+2*(ans2+4*ans3));
	}

	return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> res(n);
  for (int v = 1; v < n; ++v) {
    int a;
    cin >> a;
    --a;
    ++res[a];
  }
  for (auto e : res) {
    cout << e << '\n';
  }
}


Measured memory_bytes: 3984
from collections import Counter
def main():
    N = int( input())
    A = list( map( int, input().split()))
    C = Counter(A)
    ans = 0
    ANS = []
    for t in C:
        ans += C[t]*(C[t]-1)//2
    for a in A:
        if C[a] == 1:
            ANS.append(ans)
            continue
        ANS.append( ans - C[a]*(C[a]-1)//2 + (C[a]-1)*(C[a]-2)//2)
    print("\n".join( map( str, ANS)))
if __name__ == '__main__':
    main()


Measured memory_bytes: 39468
import java.util.*;

public class Main {
  
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        String r = lcs(s, t);

        System.out.println(r);
    }

    private static String lcs(String s, String t) {
        int[][] dp = new int[s.length() + 1][t.length() + 1];

        for (int i = s.length() - 1; i >= 0; i--) {
            for (int j = t.length() - 1; j >= 0; j--) {
                if (s.charAt(i) == t.charAt(j)) {
                    dp[i][j] = dp[i + 1][j + 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        int i = 0, j = 0;
        while (i < s.length() && j < t.length()) {
            if(s.charAt(i) == t.charAt(j)) {
                sb.append(s.charAt(i));
                i++;
                j++;
            } else if(dp[i+1][j] > dp[i][j+1]) {
                i++;
            } else {
                j++;
            }
        }
        return sb.toString();
    }

}

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

using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
  
    ll n;
    cin >> n;

    char abc[26];
    for (char i = 'a'; i <= 'z'; i ++) {
        abc[i - 'a'] = i;
    }

    string result;
    for (;;) {
        n -= 1;
        result = abc[n % 26] + result;
        n /= 26;
        if (n <= 0)
            break;
    }

    cout << result;

    return 0;
}

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int ans = 0;
  while(k > 0){
    if (a > 0 && k > 0){
      ans++;
      k--;
      a--;
    }
    else if (b > 0 && k > 0){
      k--;
      b--;
    }
    else if (c > 0 && k > 0){
      ans--;
      k--;
      c--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
using LL = long long;

void show(vector<LL> &v) {
	for (auto e : v) {
		printf("%2lld\n", e);
	}
	cout << endl;
}

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

	vector<LL> a(3 * n, 0);
	for (int i = 0; i < 3 * n; i++) {
		cin >> a[i];
	}

	priority_queue<LL, vector<LL>, greater<LL>> que1;
	priority_queue<LL> que2;
	vector<LL> sum1(3 * n, 0), sum2(3 * n, 0);

	LL sum = 0;
	for (int i = 0; i < 2 * n; i++) {
		que1.push(a[i]);
		sum += a[i];

		if (que1.size() > n) {
			sum -= que1.top();
			que1.pop();
		}

		sum1[i] = sum;
	}

	sum = 0;
	for (int i = 3 * n - 1; i >= n; i--) {
		que2.push(a[i]);
		sum += a[i];

		if (que2.size() > n) {
			sum -= que2.top();
			que2.pop();
		}

		sum2[i] = sum;
	}

	// show(sum1);
	// show(sum2);

	LL ans = -1e18;
	for (int i = n - 1; i < 2 * n; i++) {
		ans = max(ans, sum1[i] - sum2[i + 1]);
	}

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


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
const int inf=1e9+7;
int n,edge[222][222];
void folid()
{
    rep(k,1,n+1)rep(i,1,n+1)rep(j,1,n+1)
    edge[i][j]=min(edge[i][j],edge[i][k]+edge[k][j]);
}
int col[222],flag=1;
void dfs(int now,int co)
{
    if(col[now]&&col[now]!=co){flag=0;return;}
    if(col[now])return;
    col[now]=co;
    rep(i,1,n+1)if(edge[now][i]!=inf&&now!=i)
        dfs(i,co==1?2:1);
}
char s[222];
int main()
{
    scanf("%d",&n);
    rep(i,1,n+1)
    {
        scanf("%s",s+1);
        rep(j,1,n+1)
        if(s[j]=='1')
            edge[i][j]=1;
        else edge[i][j]=inf;
        edge[i][i]=0;
    }
    dfs(1,1);
    if(!flag){printf("-1\n");return 0;}
    folid();
    int res=0;
    rep(i,1,n+1)rep(j,1,n+1)res=max(res,edge[i][j]);
    printf("%d\n",res+1);
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int apart[4][3][10];
	int b, f, r, v;
    int i, j, k, n;
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				apart[i][j][k] = 0;
			}
		}
	}
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf(" %d %d %d %d", &b, &f, &r, &v);
	    apart[b - 1][f - 1][r - 1] += v;
	}
	
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 10; k++){
				printf(" %d",apart[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3){
			printf("####################\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 612
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = Integer.parseInt(s.substring(0,4));
		int b = Integer.parseInt(s.substring(5,7));
		int c = Integer.parseInt(s.substring(8,10));
		int ans = a*10000+b*100+c;
		if(ans > 20190430){
			System.out.print("TBD");
		}else{
			System.out.print("Heisei");
		}
		//System.out.print(ans);
	}
}


Measured memory_bytes: 23124
// AOJ 2134: Deadly Dice Game
// 2017.11.9 bal4u@uu

#include <stdio.h>
#include <string.h>

double a[2002][2002];

char buf[2002], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, t, i, j, jj, k;
	double p, ans;
	
	while (fgets(bp=buf, 20, stdin) && *bp != '0') {
		n = getint(), bp++, t = getint();
		memset(a, 0, sizeof(a));
		fgets(bp=buf, sizeof(buf), stdin);
		for (i = 0; i < n; i++) a[0][i] = (*bp++ == 'R');
		for (i = 0; i < t; i++) for (j = 0; j < n; j++) {
			jj = j, p = a[i][j]/6;
			k = 6; while (k--) { if (++jj == n) jj = 0; a[i+1][jj] += p; }
		}
		for (ans = 0, i = 0; i < n; i++) if (a[t][i] > ans) ans = a[t][i];
		printf("%.12f\n", ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	vi v;
	v.PB(0);
	int tmp = 0;
	for(char c: s){
		if(c == 'E') ++tmp;
		v.PB(tmp);
	}
	int ans = INT_MAX;
	REP(i, 1, n+1){
		ans = min(ans, (i-1)- v[i-1] + v[n]- v[i]);
	}
	cout << ans;
			

}


Measured memory_bytes: 2812
#include <stdio.h>

int main(void)
{
    // 九九を出力する
    // 掛け算記号はxで代用
    
    int i,j;

    for(i=1; i<=9; i++)
    {
        for(j=1; j<=9; j++)
        {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }

    return(0);
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
ll x, a, b;
int main(){
	scanf("%lld", &x);
	for(a = 1; a < 150; a++) for(b = -150; b < a; b++){
		if(a*a*a*a*a - b*b*b*b*b == x){
			printf("%lld %lld\n", a, b);
			return 0;
		}
	}
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;cin>>n>>m>>x;
  int a[m];for(int i=0;i<m;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    if(a[i]>x){
      y=i;
      break;
    }
  }
  cout<<min(y,m-y)<<endl;
}
  


Measured memory_bytes: 256
import io
import sys

import sys
def solve(T,A,listH):
    sa = 1000
    for x in range(len(listH)):
        if sa >= abs(A - (T - (int(listH[x]) * 0.006))):
            sa = abs(A - (T - (int(listH[x]) * 0.006)))
            a = x+1
    return a

def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    line2 = sys.stdin.readline().rstrip()
    list1 = line2.split(" ")
    line3 = sys.stdin.readline().rstrip()
    list2 = line3.split(" ")
    return int(list1[0]),int(list1[1]),list2

def main():
    t,a,h = readQuestion()
    answer = solve(t,a,h)
    print(answer)
    
if __name__ == '__main__':
    main()

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

int main(){
  string S;
  cin >> S;
  long long A;
  for(int i=0;i<S.size();i++){
    int B=S.at(i)-'0';
    A+=B;
  }
  if(A%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3712
let quick_sort a cmp =
  let partition p r =
    let x = a.(r) in
    let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec doit i j =
      if j >= r then i
      else begin
        if cmp a.(j) x <= 0 then (swap (i + 1) j; doit (i + 1) (j + 1))
        else doit i (j + 1)
      end
    in
    let i = doit (p - 1) p in
    swap (i + 1) r;
    i + 1
  in
  let rec doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end
  in
  doit 0 (Array.length a - 1)

let stable_p a n =
  let p (xi, _, xd) (yi, _, yd) = xd = yd && xi > yi
  in
  let rec doit i =
    if i = n - 1 then true
    else if p a.(i) a.(i + 1) then false
    else doit (i + 1)
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.init n (fun i -> Scanf.scanf "%c %d\n" (fun c d -> (i, c, d))) in
  quick_sort a (fun (_, _, x) (_, _, y) -> compare x y);
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 8936
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	string a,b,c;
	cin>>a>>b>>c;
	a[0]=toupper(a[0]);
	cout<<a[0]<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string s;
    cin >> s;
    int N = s.size();
    int K;
    cin >> K;
    set<string> st;

    for (int i = 0; i <= N - 1; ++i) {
        string S = "";
        S += s[i];
        st.insert(S);
        if (i <= N - 2) {
            S += s[i + 1];
            st.insert(S);
        }
        if (i <= N - 3) {
            S += s[i + 2];
            st.insert(S);
        }
        if (i <= N - 4) {
            S += s[i + 3];
            st.insert(S);
        }
        if (i <= N - 5) {
            S += s[i + 4];
            st.insert(S);
        }
    }
    int now = 1;
    for(auto e:st){
        if(now == K) {
            cout << e << endl;
            return 0;
        }
        else ++now;
    }
}

Measured memory_bytes: 1664
#include<iostream>
#include<queue>
#include<vector>
#include<set>
#include<iomanip>

using namespace std;

const int INF = 1001001001;
const int MOD = 1000000007;

using ll = long long;

int main(){
	int n;cin >> n;
	int a[n];	// 上司番号
	for (int i = 0;i < n-1;i++){
		cin >> a[i];
	}

	int b[n] = {0};	// 部下番号
	for (int i = 0;i < n-1;i++){
		b[a[i]-1]++;
	}

	for (int i = 0;i < n;i++){
		cout << b[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5184
fun main() {
    val n= readLine()!!.toInt()
    val a= IntArray(n){ readLine()!!.toInt()}
    fun IntArray.lowerBounds(e:Int):Int{
        var l=-1
        var r=this.size
        while (r-l>1){
            val mid=(l+r)/2
            if (this[mid]<e){l=mid}
            else{r=mid}
        }
        return l
    }
    var dp=IntArray(n){ -1}
    for (i in a){
        val ind=dp.lowerBounds(i)
        dp[ind]=i
    }
    var ans=n-dp.count { it==-1 }
    println(ans)
}

Measured memory_bytes: 57240
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>L(m);
  vector<int>R(m);
  for(int i=0;i<m;i++){
    cin>>L.at(i)>>R.at(i);
  }
  int l=0,r=999999;
  for(int i=0;i<m;i++){
    l=max(l,L.at(i));
    r=min(r,R.at(i));
  }
  int ans=0;
  for(int i=0;i<=n;i++){
    if(i>=l&&i<=r){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    rep(i, A+1) {
        rep(j, B+1) {
            rep(k, C+1) {
                if (i * 500 + j * 100 + k * 50 == X) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892