akhauriyash/Code-Regression huggingface dataset:
//AtCoder ABC049 C - 白昼夢 / Daydream
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    string S;
    cin>>S;
    string tbl[]={
        "dream", "dreamer", "erase", "eraser"
    };

    auto check_func = [&](int pt){
        int ret=-1;
        for(const auto& cs:tbl){
            auto tmp=pt-cs.size();
            if (tmp<0) continue;
            if (strncmp(&cs[0], &S[tmp], cs.size())==0){
                ret = tmp;
                break;
            }
        }
        return ret;
    };

    int endpt=S.size();//終端から一致を確認していく
    while(endpt > 0){
        endpt = check_func(endpt);
    }
    cout<<(endpt==0?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 512
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

k = inp()
n = 50
x,b = k//50, k%50
a = x+(n-1)
print(n)
for i in range(n):
    if i < b:
        print(n+1-b+a)
    else:
        print(a-b)


Measured memory_bytes: 10496
#include<stdio.h>
typedef long long ll;
ll gcd(ll x,ll y){
  while(x%y!=0){
    ll tmp=x;
    x=y;
    y=tmp%y;
  }
  return y;
}
int main(void)
{
  int n;
  ll a[100010];
  ll result;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }

  ll min=1000000000;
  for(int i=0;i<n-1;i++){
    result=gcd(a[i],a[i+1]);
    if(result<min){
      min=result;
    }
  }

  printf("%lld\n",min);
  return 0;
}


Measured memory_bytes: 2468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

const string YES = "Yes";
const string NO = "No";

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;

  if ((A == B && A != C) || (A == C && A != B) || (B == C && B != A))
    cout << YES << endl;
  else
    cout << NO << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std; 
int main()
{
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int b[m];
    int c[n];
    for(int i = 0; i < n; i++){
        c[i] = 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;


int main() {
    
	int x;
    cin>>x;
 
    int q=x/100;
    int r=x%100;
 
    cout<<(r<=q*5)<<endl;
	}





Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
ll a[100001];
ll b[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll ans = 0;

    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    if (a[0] <= b[0])
    {
        ans += a[0];
        b[0] -= a[0];
    }
    else
    {
        ans += b[0];
        b[0] = 0;
    }
    for (int i = 1; i < n + 1; i++)
    {

        if (b[i - 1] <= a[i])
        {
            ans += b[i - 1];
            a[i] -= b[i - 1];
        }
        else
        {
            ans += a[i];
            a[i] = 0;
        }
        if (i == n)
            break;
        if (b[i] <= a[i])
        {
            ans += b[i];
            b[i] = 0;
        }
        else
        {
            ans += a[i];
            b[i] -= a[i];
        }
    }
    cout << ans << "\n";
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;


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

typedef vector<ll> vl;
typedef pair<ll, ll> pll;

#define St first
#define Nd second
#define Pb push_back
#define print_pair(p) cout<<p.St<<" "<<p.Nd
#define endl "\n"

#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REV(i,a,b) for(int i = a; i >= b; i--)

#define AritSum(a,d,n) ((n)*(2*(a)+((n)-1)*(d)))/2
#define Log(base, num) log2(num)/log2(base)

#define MOD 1000000007
ll binpow(ll x, ll y) {
	ll z = 1;
	while(y > 0) {
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
// a^-1 (mod m) = a^(m-2) (mod m) - m is prime
ll inv(ll x) {return binpow(x, MOD - 2);}
ll divide(ll x, ll y) {return x* inv(y);}

// ************* MAIN *******************



void solve() {
    REP(i,1,5) {
        int t; cin >> t;
        if (t==0) {
            cout << i << endl;
        }

    }
}

/*
g++ -std=c++14 -Wall -Wextra -O2 Test.cpp -o Test

./Test < in
*/
int main() {
    int _=1;
    // cin>>_;
    REP(t,1,_) {
        // cout << "Case #" << t << ": ";
        solve();
        // cout << ((solve())? "YES" : "NO") << endl;
        // cout << solve() << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100001
#define MAXN 1000000007
#define pb push_back
#define f first
#define s second

int main()
{
    int n, x, t; cin>>n>>x>>t;
    int k = (n/x)*x;
    if(k==n)    cout<<(n/x)*t<<endl;
    else    cout<<(n/x+1)*t<<endl;
}

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

int main(){
    ll N, W;  cin >> N >> W;
    vector<ll> w(N+1), v(N+1);
    ll Vsum = 0;
    for(int i=1; i<=N; i++){ 
        cin >> w[i] >> v[i];
        Vsum += v[i];
    }

    ll inf = 1e15;
    vector<vector<ll>> dp;
    dp = vector<vector<ll>>(N+1, vector<ll>(Vsum+1, inf));
    dp[1][0] = 0;
    dp[1][v[1]] = w[1];

    for(int i=2; i<=N; i++){
        for(int j=0; j<=Vsum; j++){
            if(v[i] <= j){
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    for(int i=Vsum; i>=0; i--){
        if(dp[N][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 80256
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod

    def H(self, n, r):
        if (n == 0 and r > 0) or r < 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

    def rising_factorial(self, n, r):  # 上昇階乗冪 n * (n+1) * ... * (n+r-1)
        return self.fac[n+r-1] * self.facinv[n-1] % self.mod

    def stirling_first(self, n, k):  # 第 1 種スターリング数  lru_cache を使うと O(nk)  # n 要素を k 個の巡回列に分割する場合の数
        if n == k: return 1
        if k == 0: return 0
        return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod

    def stirling_second(self, n, k):  # 第 2 種スターリング数 O(k + log(n))  # n 要素を区別のない k グループに分割する場合の数
        if n == k: return 1  # n==k==0 のときのため
        return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def balls_and_boxes_3(self, n, k):  # n 要素を区別のある k グループに分割する場合の数  O(k + log(n))
        return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def bernoulli(self, n):  # ベルヌーイ数  lru_cache を使うと O(n**2 * log(mod))
        if n == 0: return 1
        if n % 2 and n >= 3: return 0  # 高速化
        return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod

    def faulhaber(self, k, n):  # べき乗和 0^k + 1^k + ... + (n-1)^k
        # bernoulli に lru_cache を使うと O(k**2 * log(mod))  bernoulli が計算済みなら O(k * log(mod))
        return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod

    def lah(self, n, k):  # n 要素を k 個の空でない順序付き集合に分割する場合の数  O(1)
        return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod

    def bell(self, n, k):  # n 要素を k グループ以下に分割する場合の数  O(k**2 + k*log(mod))
        return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod

# x * x が選ばれ、かつそれ以外はすべて x 以下が選ばれる場合の数
N, K = map(int, input().split())
A = sorted(map(int, input().split()))
ans_max = ans_min = 0
mod = 10**9+7
comb = Combination(101010)
for i, a in enumerate(A):
    ans_max += a * comb.C(i, K-1)
    ans_min += a * comb.C(N-1-i, K-1)
ans = (ans_max - ans_min) % mod
print(ans)


Measured memory_bytes: 20916
import numpy as np
import sys
input = sys.stdin.readline

def main():
    n = input()
    t, a = map(float, input().split())
    heights = np.array(list(map(float, input().split())))
    diffs = np.abs(t - heights * 0.006 - a)
    print(np.argmin(diffs) + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12504
#include <bits/stdc++.h>
#include<algorithm>
#define ll long long
#define pb push_back
#define popb pop_back
#define ull unsigned long long 
#define beg begin
#define MAXN 1000000007
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
using namespace std;

ll f(ll n)
{
     return (n)*(n-1)*(n-2) + n*(n-1) * 3 + n ;
}

int main(void) {
     ios::sync_with_stdio(0);
     ll n , k , count = 0, count1 = 0;
     cin >> n >> k ;
     for(int i = 1 ; i <= n ; i++)
     {
          if(i%k ==0 )
               count++ ;
          if ((k%2 == 0) && ((i - k/2)%k == 0))
               count1++ ;
     }
     //cout << count1 << " " << count << endl ;
     n = count ;
     ll temp = count1 ;
          cout << f(n) + f(count1)  ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int N,M;
	cin>>N>>M;
	vector<int> ar1(N+1,0);  //問題に対するWA数
	vector<int> ar2(N+1,-1); //ACしたか
	for(int i=1; i<=M;i++){
		int p;
		string s;
		cin>>p>>s;
		if(s=="AC"){
          //cout<<p<<" "<<s<<endl;
			ar2[p]=1;
		}
		else if(s=="WA" && ar2[p]==-1){
			ar1[p]++;
		}
	}
	int ac=0,pena=0;
	for(int i=1; i<=N; i++){
        
		if(ar2[i]!=-1)ac+=ar2[i];
		if(ar1[i]!=-1&&ar2[i]==1) pena+=ar1[i];
	}
	cout<<ac<<" "<<pena<<endl;
		
	}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;

	rep(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#最大の最小値を求める問題は二部探索
#最大の最小値がちょうどokとngの境界になる
#求める値をlとするとその長さに全ての丸太をきるのに必要な回数を数えることができる
#その丸太をきる回数がk回以下であればいい
#絶対にだめ→０　絶対にオッケー→max(a)
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
#丸太をきる回数がk回以下かどうか調べる関数
def check(n):
  cnt=0
  for l in a:
    if l%n==0:
      cnt=cnt+l//n-1
    else:
      cnt=cnt+l//n
  if cnt<=k:
    return True
  else:
    return False
#二部探索  
left=0
right=max(a)
while right-left>1:
  mid=(right+left)//2
  if check(mid):
    right=mid
  else:
    left=mid
print(right)
  


Measured memory_bytes: 31952
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

ll mypow(ll a, ll b, ll mod) {
  if (b == 0) return 1;
  ll tmp = mypow(a, b / 2, mod);
  if (b % 2)
    return (((tmp * tmp) % mod) * a) % mod;
  else
    return (tmp * tmp) % mod;
}

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

  ll n, mod;
  cin >> n >> mod;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  if (mod == 2 || mod == 5) {
    ll ret = 0;
    for (int i = 0; i < n; i++) {
      int num = s[i] - '0';
      if (num % mod == 0) {
        ret += n - i;
      }
    }
    cout << ret << endl;
    return 0;
  }
  s = "$" + s;
  constexpr int MAX_N = 200010;
  vector<ll> sum(MAX_N, 0);
  map<ll, ll> mp;
  ll ten = 1;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + ten * (s[i] - '0');
    sum[i] %= mod;
    ten = ten * 10 % mod;
    mp[sum[i]]++;
  }
  ll ret = mp[0];
  for (int i = 1; i < n; i++) {
    mp[sum[i]]--;
    ret += mp[sum[i]];
  }
  cout << ret << endl;
}


Measured memory_bytes: 2640
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: i32 = read();
    let d: i32 = read();
    if n%(2*d+1)==0 {
	println!("{}",n/(2*d+1));
    }else {
	println!("{}",n/(2*d+1)+1);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int MAX = 55;

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

// 右手法
// right[d] := d方向（東から時計回り）を向いているときの優先順序
const int rightHand[4][4] = {
{1,0,3,2},
{2,1,0,3},
{3,2,1,0},
{0,3,2,1}
};

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

    char m[MAX][MAX];
    rep(i,h + 2) rep(j, w + 2) m[i][j] = '#';

    int dir = -1;
	int y = -1, x = -1;
    range(i,1,h + 1){
        range(j,1,w + 1){
            cin >> m[i][j];
            if(m[i][j] == '>') dir = 0;
            else if(m[i][j] == 'v') dir = 1;
            else if(m[i][j] == '<') dir = 2;
            else if(m[i][j] == '^') dir = 3;
            if(dir != -1 && x == -1){
				y = i;
				x = j;
			}
        }
    }
    m[y][x] = '.';

	bool u[MAX][MAX] = {{0}};
	int move = 1e4;
    while(m[y][x] != 'G'){
		//cout << x << ' ' << y << endl;
		move--;
		if(move == 0) break;
		u[y][x] = true;
        rep(i,4){
			int rh = rightHand[dir][i];
            int ny = y + dy[rh];
            int nx = x + dx[rh];
            if(ny < 1 || ny > h || nx < 1 || nx > w) continue;
            if(m[ny][nx] == '#') continue;
			x = nx;
			y = ny;
			dir = rh;
			break;
        }
    }

	if(move == 0){
		cout << -1 << endl;
		return 0;
	}

	int cnt = 1;
	rep(i,MAX) rep(j,MAX) if(u[i][j]) cnt++;
    cout << cnt << endl;
}



Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MSFJ2019C
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            Console.WriteLine(Solve(X) ? 1 : 0);
            Console.ReadLine();
        }

        private static bool Solve(int X)
        {
            for (int i = 1; i <= X/100; i++)
            {
                if (100 * i <= X && X <= 105 * i)
                {
                    return true;
                }
            }

            return false;

        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var weight = new List<long>();
        var value = new List<long>();
        var dp = new long[vals[0] + 1, vals[1] + 1];
        for (int i = 0; i < vals[0]; i++)
        {
            var tmp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            weight.Add(tmp[0]);
            value.Add(tmp[1]);
        }
        for (int i = 0; i < vals[0]; i++)
        {
            for (int w = 0; w <= vals[1]; w++)
            {
                if (w - weight[i] >= 0)
                {
                    dp[i + 1, w] = chmax(dp[i + 1, w], dp[i, w - weight[i]] + value[i]);
                }
                dp[i + 1, w] = chmax(dp[i + 1, w], dp[i, w]);
            }
        }
        Console.WriteLine(dp.Cast<long>().Max());
    }

    public static long chmin(long x, long y)
    {
        return x > y ? y : x;
    }

    public static long chmax(long x, long y)
    {
        return x > y ? x : y;
    }
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

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

int n;
vi arr;
void in(){
    cin >> n;
    rep(i,0,n) arr.push_back(input());
}

void solve(){

    vi lg, rg;
    int g = arr[0];
    lg.push_back(g);
    rep(i,1,n){
        g = gcd(g, arr[i]);
        lg.push_back(g);
    }

    rg.push_back(arr.back());
    g = arr.back();
    revrep(i,n - 2, -1){
        g = gcd(g, arr[i]);
        rg.push_back(g);
    }
    reverse(all(rg));

    int ans = 0;
    rep(i,0,n){
        if(i == 0){
            chmax(ans, rg[1]);
            continue;
        }
        if(i == n - 1){
            chmax(ans, lg[n - 2]);
            continue;
        }

        chmax(ans, gcd(lg[i - 1], rg[i + 1]));
        
    }


    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

const int N = 2e5 + 9;

vector<int>r[N], b[N];
int n, R, B, d[N], fa[N], ans;
bool vis[N];

void Dfs (int u) {
	for (auto v : b[u]) if (v != fa[u]) fa[v] = u, d[v] = d[u] + 1, Dfs(v);
}

bool Judge (int x, int y) {
	for (int i = 1; x != y; ++i) {
		if (d[x] > d[y]) x = fa[x];
		else y = fa[y];
		if (i > 2) return 1;
	}
	return 0;
}

void Dfs (int u, int k) {
	if (vis[u] || k >= d[u]) return ; vis[u] ^= 1;
	if (d[u] > ans) ans = d[u];
	for (auto v : r[u]) {
		Dfs(v, k + 1);
		if (Judge(u, v)) puts("-1"), exit(0);
	}
}

int main () {
	scanf("%d%d%d", &n, &R, &B);
	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d%d", &u, &v);
		r[u].emplace_back(v);
		r[v].emplace_back(u);
	}
	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d%d", &u, &v);
		b[u].emplace_back(v);
		b[v].emplace_back(u);
	}
	d[B] = 0; Dfs(B);
	Dfs(R, 0);
	printf("%d\n", ans << 1);
	return 0;
}

Measured memory_bytes: 32508
#include <iostream>

using namespace std;

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

    return 0;
}


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

struct Card { char suit, value; };

void bubble(struct Card A[], int N){
    for (int i=0; i<N; i++){
        for (int j=N-1; j>=i+1; j--){
            if (A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for (int i=0; i<N; i++){
        int minj = i;
        for (int j=i; j<N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for (int i=0; i<N; i++){
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

// バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N){
    for (int i=0; i<N; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i=0; i<N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i=0; i<N; i++) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
import math
from sys import stdin
input = stdin.readline


def prime_fatorization(n):
  # O(sqrt(n))
  from collections import defaultdict
  # a = []
  a = defaultdict(int)
  while not(n % 2):
    # a.append(2)
    a[2] += 1
    n //= 2
  f = 3
  while f * f <= n:
    if not(n % f):
      # a.append(f)
      a[f] += 1
      n //= f
    else:
      f += 2
  if n != 1:
    # a.append(n)
    a[n] += 1
  return a


def main():
  N, M = list(map(int, input().split()))
  A = list(map(lambda x: int(x)//2, input().split()))

  pre = A[0]

  for i in range(1, N):
    if pre % 2 != A[i] % 2:
      print(0)
      return

  if not A[0] % 2:
    fac2 = prime_fatorization(A[0])[2]
    for i in range(1, N):
      if not A[i]//(2**fac2) % 2:
        print(0)
        return

  lcm = A[0]
  for i in range(1, N):
    lcm = lcm * A[i] // math.gcd(lcm, A[i])
  print((M // lcm + 1) // 2)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 85708
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  for (int i=0;i<a;i++)
  {
    char c;
    cin>>c;
    if (!(c=='0' || c=='1' || c=='2' || c=='3' || c=='4' || c=='5'|| c=='6'|| c=='7'|| c=='8'|| c=='9'))
    {
      cout<<"No";
      exit(0);
    }
  }
  char c;
  cin>>c;
  if (c!='-')
  {
    cout<<"No";
    exit(0);
  }
  for (int i=0;i<b;i++)
  {
    char c;
    cin>>c;
    if (!(c=='0' || c=='1' || c=='2' || c=='3' || c=='4' || c=='5'|| c=='6'|| c=='7'|| c=='8'|| c=='9'))
    {
      cout<<"No";
      exit(0);
    }
  }
  cout<<"Yes";
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
using Graph = vector< vector<int> >;

double ans[150010], ex[150010];

void dfs(Graph &G, int cur, int par=-1) {
    int sz = G[cur].size();
    if(par != -1) sz--;

    double sum = 0.0;
    for(auto to : G[cur]) {
        if(to == par) continue;
        dfs(G, to, cur);
        sum += ex[to] + 1;
    }

    if(sz) ex[cur] = sum / sz;
}

void solve(Graph &G, int cur, int par=-1, double d_par=0.0) {
    double sum = 0.0;
    int sz = (int)G[cur].size();
    for(auto to : G[cur]) {
        if(to == par) sum += d_par + 1;
        else sum += ex[to] + 1;
    }

    ans[cur] = sum / sz;
    for(auto to : G[cur]) {
        if(to == par) continue;
        double n_sum = sum - ex[to] - 1;
        if(sz > 1) n_sum /= (sz - 1);
        solve(G, to, cur, n_sum);
    }
}

int main() {
    int N; scanf("%d", &N);

    Graph G(N);
    for(int i=0; i<N-1; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(G, 0);
    solve(G, 0);
    for(int i=0; i<N; i++) {
        printf("%.12f\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 19968
#include <cstdio>
#include <vector>

bool valid(const std::vector<int>& x, const std::vector<int> &y, int Z) {
  for (auto xi: x) if (xi >= Z) return false;
  for (auto yi: y) if (yi < Z) return false;
  return true;
}

int main() {
  size_t N, M;
  int X, Y;
  scanf("%zu %zu %d %d", &N, &M, &X, &Y);

  std::vector<int> x(N), y(M);
  for (auto& xi: x) scanf("%d", &xi);
  for (auto& yi: y) scanf("%d", &yi);

  for (int Z = X+1; Z <= Y; ++Z) 
    if (valid(x, y, Z))
      return puts("No War"), 0;

  puts("War");
}

Measured memory_bytes: 256
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//head
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	string s;
  	cin >> n >> s;
  	int maxi = 0;
  	int x = 0;
  	for(int i = 0; i < n; i++){
  		if(s[i] == 'I') x++;
  		else{
  			x--;
  		}
  		maxi = max(x, maxi);
  	}
  	cout << maxi << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)(1e9))
#define pi (1.0*acos(-1))
#define M ((int)(1e9 + 7))
#define NN ((ll)(305))
#define N ((int)(2e5+7))
#define eps 0
#define log 20


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;


typedef tree < ll,  null_type,  less < ll >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

char s[N];

int main()
{
    int n, a, b, c, d;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    scanf("%s",s);
    int cnt = 0;
    bool flag = 1;
    for(int i = b-1; i<d; i++)
    {

        if(s[i]=='#')
            cnt++;
        else
            cnt= 0;
        if(cnt>1)
        {
            flag = 0;
            break;
        }
    }
    cnt = 0;
    for(int i = a-1; i<c; i++)
    {
        if(s[i]=='#')
            cnt++;
        else
            cnt= 0;
        if(cnt>1)
        {
            flag = 0;
            break;
        }
    }
    if(c>d)
    {
        //cout<<"ok\n";
        flag = 0;
        for(int i = b-1; i<d; i++)
        {
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')
            {
                flag = 1;
                break;
            }
        }

        cnt = 0;

        for(int i = b-1; i<d; i++)
        {

            if(s[i]=='#')
                cnt++;
            else
                cnt= 0;
            if(cnt>1)
            {
                flag = 0;
                break;
            }
        }
        cnt = 0;
        for(int i = a-1; i<c; i++)
        {
            if(s[i]=='#')
                cnt++;
            else
                cnt= 0;
            if(cnt>1)
            {
                flag = 0;
                break;
            }
        }

        if(flag) printf("Yes\n");
        else printf("No\n");
    }
    else if(flag) printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;
vector<int> to[300005];
bool used[300005];
int dist[300005];

void dfs(int v, int p=-1) {
    if (used[v]) return;
    used[v] = true;
    int now = 1;
    for (int e: to[v]) {
        if (e==p) continue;
        dfs(e, v);
        chmax(now, dist[e]+1);
    }
    dist[v] = now;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    set<P> s1;
    set<P> s2;
    rep(i, n) {
        auto it1 = s1.lower_bound(P(a[i]-k, 0));
        while (it1!=s1.end()) {
            if (it1->first>a[i]) break;
            to[it1->second].pb(i);
            s1.erase(it1++);
            //debug(i);
        }
        auto it2 = s2.lower_bound(P(a[i]+1, 0));
        while(it2!=s2.end()) {
            if (it2->first>a[i]+k) break;
            to[it2->second].pb(i);
            s2.erase(it2++);
        }
        s1.insert(P(a[i], i));
        s2.insert(P(a[i], i));
    }
    rep(i, n) {
        if (!used[i]) dfs(i, -1);
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, dist[i]);
    }


    
    pr(ans);
    return 0;
}


Measured memory_bytes: 45536
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second


int main()
{
    int n;
    std::cin >> n;
    std::vector<long double> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    std::sort(a.begin(), a.end());
    /*
    int cur;
    if(n %2 == 0){
        cur =  (a[n / 2] + a[n / 2 - 1]) / 2;
    }else{
        cur =  a[n/2];
    }
    */
    long double cc;
    ll cnt = 0;
    cc = std::accumulate(a.begin(), a.end(), 0.0) / n;
    int cur = std::round(cc);

    for(int i = 0; i < n; i++){
        cnt += (a[i] - cur) * (a[i] - cur);
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 384
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,W,*vw = map(int, read().split())

    VW = []
    for v, w in zip(*[iter(vw)]*2):
        VW.append((v, w))

    dp = [[0] * (W+1) for _ in range(N+1)]

    for i in range(N):
        v_i, w_i = VW[i]
        for j in range(W+1):
            if j < w_i:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = max(dp[i][j - w_i] + v_i, dp[i][j])

    print(dp[N][W])    


if __name__ == "__main__":
    main()


Measured memory_bytes: 41936
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    V<string> vs(26);
    for(ll i = 0; i < 26; i++) {
        vs[i] += (char)('A' + i);
        vs[i] += (char)('A' + i);
    }
    string S;
    cin >> S;
    sort(ALL(S));
    for(ll i = 0; i < 26; i++) for(ll j = i + 1; j < 26; j++) {
        string IJ = vs[i] + vs[j];
        string JI = vs[j] + vs[i];
        if(IJ == S || JI == S) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(void){
    int a,b;
    char op;
    cin>>a>>op>>b;
    
    while(op !='?'){

    if(op =='+'){
        cout<<a+b<<endl;
        }
    if (op =='-'){
        cout<<a-b<<endl;
        }
    
    if(op =='*'){
        cout<<a*b<<endl;
    }
    if(op =='/'){
        cout<<a/b<<endl;
        }
    cin>>a>>op>>b;
    }
    return 0;
}




Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	/**
	 * ?????°??????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????´??° a ??¨ b
	 * ??????????????????????????§??????????????????????????????????????\????????????????????§????????????????????????a ??¨ b ??????????????´??°??¨????????????
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		 
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
		int a = sc.nextInt();
		int b = sc.nextInt();

		int divisorNum = 0;
		for (int i = 0; i <= 2; i++) {
			int sum = a + b;
			int keta = 1;
			divisorNum = 0; // ??¨????????????????????°
			while (true) {
				if (sum / keta > 0) {
					keta *= 10;
					divisorNum++;
				} else {
					break;
				}
			}

		}

		System.out.println(divisorNum);
		}
	}

}

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

int main(){
	int n,fe;
	string s;
	cin >> n ;
	cin >> s ;

	for(int i=0;i<s.size();i++){
		fe=s.at(i)-'A';
		fe+=n;
		fe%=26;
		s.at(i)=fe+'A';
	}

	cout << s << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main(){
  int n;
  cin >> n;
  set<string> s;
  
  for(int i = 0; i < n; i++){
    string sss;
    cin >> sss;
    s.insert(sss);
  }
  
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 19256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, C, K;
    cin >> N >> C >> K;

    vector<int> vec(N);
    for(int i = 0; i < N; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());

    int ans = 0;
    int t = 0;
    int places = 0;

    for(int x : vec)
    {
        if(x > t || places == 0)
        {
            t = x + K;
            ans++;
            places = C - 1;
        }
        else
        {
            places--;
        }
        
    }

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

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

int gcd(int large, int small)
{
    if (small == 0) return large;
	else if (large < small) gcd(large, small%large);
	else gcd(small, large%small);
}

int main()
{
	int A[2], small, large;
	int result;
	
	for(int i = 0; i < 2; i++) cin >> A[i];
	
    result = gcd(A[0], A[1]);
	
	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
    int K,ec=0,oc=0;
    cin >>K;
    for(int i=1;i<=K;i++)
    {
        if(i%2==0)
        {
          ec++;
        }
        else
        {
            oc++;
        }
    }
    cout<<ec*oc<<endl;
    return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: i, n, k
  integer, allocatable :: p(:), q(:)

  read *, n 
  allocate (p(n))
  read *, p

  do i = 1, n
    if (p(i) /= i) k = k + 1
  end do

  if (k <= 2) then
    print '(a)', 'YES'
  else
    print '(a)', 'NO'
  end if
end program

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

int main() {
  ll A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;

  if(W>V){
  cout << "NO" << endl;
  return 0;
  }

  if(abs(A-B)>T*abs(V-W)){
  cout << "NO" << endl;
  return 0;
  }
  else{
  cout << "YES" << endl;
  return 0;
  }

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vector<vi> to(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    --a;  --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int ans = 0;
  vi num(n-1); rep(i,n-1) num[i] = i+1;
  do{
    int now = 0;
    vi node(n);
    node[0] = 1;
    rep(i,n-1){
      for(auto next : to[now]){
        if(next != num[i]) continue;
        now = next;
        node[next] = 1;
        break;
      }
    }
    bool ok = true;
    rep(i,n) if(!node[i]) ok = false;
    if(ok) ans++;
  }while(next_permutation(all(num)));
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3640
-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE ScopedTypeVariables #-}
-- {-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE ViewPatterns #-}
-- {-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
-- import qualified Data.Vector.Algorithms.Merge as VAM
-- import qualified Data.Heap as HP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

--------------------------------------------------------------------------
solve xys time
    | VU.null xys = "Yes"
    | time + cos <= lim = solve (VU.tail xys) (time + cos)
    | otherwise = "No"
    where
        (lim,cos) = VU.head xys

main = do
    n <- int
    xys <- VU.fromList . sort . VU.toList . VU.map swap <$> multipleLinesToTupleV n
    putStrLn $ solve xys 0
--------------------------------------------------------------------------

-- Input Util
int :: IO Int
int = readLn 

double :: IO Double
double = readLn 

str :: IO String
str = getLine

strBC :: IO BC.ByteString
strBC = BC.getLine

singleLineToIntL :: IO [Int]
singleLineToIntL = getLine >>= return . map read . words

singleLineToDoubleL :: IO [Double]
singleLineToDoubleL = getLine >>= return . map read . words

singleLineToIntV :: Int -> IO (VU.Vector Int)
singleLineToIntV n = BC.getLine >>= return . VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace)

singleLineToDoubleV :: Int -> IO (VU.Vector Double)
singleLineToDoubleV n = BC.getLine >>= return . VU.fromList . map (read . BC.unpack) . BC.words

multipleLinesToIntL :: Int -> IO [Int]
multipleLinesToIntL n = replicateM n readLn

multipleLinesToDoubleL :: Int -> IO [Double]
multipleLinesToDoubleL n = replicateM n readLn

multipleLinesToIntV :: Int -> IO (VU.Vector Int)
multipleLinesToIntV n = VU.replicateM n readLn

multipleLinesToDoubleV :: Int -> IO (VU.Vector Double)
multipleLinesToDoubleV n = VU.replicateM n (BC.getLine >>= return . read . BC.unpack)

multipleLinesToTupleL :: Int -> IO [(Int, Int)]
multipleLinesToTupleL n = replicateM n (getLine >>= return . (\[a,b] -> (a,b)) . map read . words)

multipleLinesToTupleV :: Int -> IO (VU.Vector (Int, Int))
multipleLinesToTupleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, _) = BC.readInt $ BC.dropWhile isSpace bs'
    return (a,b)

-- others
strToChr :: String -> Char
strToChr [x] = x

chrToStr :: Char -> String
chrToStr x = [x]

m1 :: Int -> Int
m1 x = subtract 1 x

toDouble :: Int -> Double
toDouble x = fromIntegral x

toInt :: Double -> Int
toInt x = floor x

Measured memory_bytes: 57724
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    string A;
    cin >> A;
    
    // calculation
    ll month = stoll(A.substr(5, 2));
    ll day = stoll(A.substr(8, 2));
    
    if (month < 4) {
        cout << "Heisei" << "\n";
    } else if (month == 4) {
        if (day <= 30) {
            cout << "Heisei" << "\n";
        } else {
            cout << "TBD" << "\n";
        }
    } else {
        cout << "TBD" << "\n";
    }
    
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    ll a, b;
    int k;
    cin >> a >> b >> k;
    if (b - a > 2 * (k - 1)) {
        for (int i = 0; i < k; i++) {
            cout << a + i << endl;
        }
        for (int i = k - 1; i >= 0; i--) {
            cout << b - i << endl;
        }
    } else {
        for (ll i = a; i <= b; i++) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
function main(input){
    let lines = input.split("\n");
    let length = parseInt(lines[0]);
    let orders = lines.slice(1);
    let put="";
    
    for(let i=0;i<length;i++){
        let order = orders[i].split(" ")[0];
        let key = orders[i].split(" ")[1];
        
        if(order==="insert"){
            if(put===""){
                put=key;
            }else{
            put = key+" "+put;
                
            }
        }else if(order==="delete"){
            let list = put.split(" ");
            let index = list.indexOf(key);
            if(index!==-1){
                list.splice(index,1);
                put = list.join(" ");
            }
        


            
        }else if(order==="deleteFirst"){
            while(!isNaN(parseInt(put[0]))){
                put=put.slice(1);
            }
            put = put.trim();
        }else if(order==="deleteLast"){
            while(!isNaN(parseInt(put[put.length-1]))){
                put=put.slice(0,-1);
            }
            put=put.trim();
        }
    }
    
    
    console.log(put.trim());
    
}




main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 480224