akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll w, h,n;
    cin >> w >> h >> n;
    vector<ll> z(n);
    int one = 0;
    int two = w;
    int the = 0;
    int fou = h;
    for (int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        if (c == 1)one = max(one, a);
        if (c == 2)two = min(two, a);
        if (c == 3)the = max(the, b);
        if (c == 4)fou = min(fou, b);
    }
    cout << max(0, two - one) * max(0, fou - the) << endl;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int Maxn=100;

int N,K;

vector<int> e[Maxn+5];

vector<int> ans1,ans2;

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&K);
	if((N-1)*(N-2)/2<K) {
		puts("-1");
		return 0;
	}
	for(int i=2;i<=N;i++) {
		e[i].push_back(1);
		e[1].push_back(i);
	}
	for(int i=2;i<=N;i++)
		ans1.push_back(1),ans2.push_back(i);
	int t=(N-1)*(N-2)/2-K;
	for(int i=2,k=1;i<=N;i++) {
		for(int j=i+1;j<=N;j++) {
			if(k>t)break;
			if(i==j)continue;
			ans1.push_back(i),ans2.push_back(j);
			k++;
		}
		if(k>t)break;
	}
	printf("%d\n",ans1.size());
	for(int i=0;i<ans1.size();i++)
		printf("%d %d\n",ans1[i],ans2[i]);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;

int main() {
	ll N;
	cin >> N;
	vector<ll> people(N);
	vector<ll> rate(9, 0);
	ll minrate = 0, maxrate = 0;
	for (ll i = 0; i < N; i++)
	{
		cin >> people[i];
		rate[min(8LL, people[i] / 400)]++;
	}
	ll count = 0;
	for (ll i = 0; i < 8; i++)
	{
		if (rate[i] > 0) count++;
	}
	cout << max(1LL, count) << ' ' << count + rate[8] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] ABCD = sc.nextLine().toCharArray();
		sc.close();
		int A = Character.getNumericValue(ABCD[0]);
		int B = Character.getNumericValue(ABCD[1]);
		int C = Character.getNumericValue(ABCD[2]);
		int D = Character.getNumericValue(ABCD[3]);
		
		String rt = "";
		boolean isStop = false;
		for (int i = 0; i < 2; i++) {
			boolean isAddA = false;
			int resultA = 0;
			if (i == 1) {
				isAddA = true;
			}
			if (isAddA) {
				resultA = A + B;
			} else {
				resultA = A - B;
			}
			for (int j = 0; j < 2; j++) {
				boolean isAddB = false;
				int resultB = 0;
				if (j == 1) {
					isAddB = true;
				}
				if (isAddB) {
					resultB = resultA + C;
				} else {
					resultB = resultA - C;
				}
				for (int k = 0; k < 2; k++) {
					boolean isAddC = false;
					if (k == 1) {
						isAddC = true;
					}
					int resultC = 0;
					if (isAddC) {
						resultC = resultB + D;
					} else {
						resultC = resultB - D;
					}
					if (resultC == 7) {
						if (isAddA) {
							rt = A + "+";
						} else {
							rt = A + "-";
						}
						if (isAddB) {
							rt = rt + B + "+";
						} else {
							rt = rt + B + "-";
						}
						if (isAddC) {
							rt = rt + C + "+" + D + "=7";
						} else {
							rt = rt + C + "-" + D + "=7";
						}
						isStop = true;
						break;
					}
				}
				if (isStop) {
					break;
				}
			}
			if (isStop) {
				break;
			}
		}
		System.out.println(rt);
	}
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    if(N >= M){
        cout << 10 << endl;
    }
    else cout << 0 << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    
    string s; int Q;
    cin >> s >> Q;
    
    vector<char> v (5 * 1e5, ' ');
    int first = 3*1e5, last = first + 1;
    for (int i = 0; i < s.size(); ++i) {
        v[last++] = s[i];
    }
    
    for (int i = 0; i < Q; ++i) {
        int t; cin >> t;
        if (t == 2) {
            int f; char c;
            cin >> f >> c;
            if (f == 1) {
                v[first] = c;
                if (first < last) first--; else first++;
            }
            if (f == 2) {
                v[last] = c;
                if (first < last) last++; else last--;
            }
        }  else {
            swap(first, last);
        }     
    } 
    string ans;
    int i = min(first, last);
    int j = max(first, last);
    for (int k = i + 1; k < j; ++k) {
        ans += v[k];
    }
    if (first > last) reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(),(x).end()

int main() {
	int t, x;
	cin >> t >> x;

	cout << (double)t / (double)x << endl;





    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;


public class Main {
    static int[] nums;
    static int n;
    static long count;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String[] nd = br.readLine().split(" ");
        n = Integer.parseInt(br.readLine());
        String[] line = br.readLine().split(" ");
        nums = new int[n+1];
        for (int i = 0; i < n; i++) {
            nums[i+1] = Integer.parseInt(line[i]);
        }
        
        //
        long[][] dp = new long [n][21];
        dp[1][nums[1]] = 1;
        
        for (int i = 2; i < n; i++) {
            for (int j = 0; j < 21; j++) {
                if (j-nums[i] >= 0) {
                    dp[i][j] += dp[i-1][j-nums[i]];
                }
                if (j+nums[i] <= 20) {
                    dp[i][j] += dp[i-1][j+nums[i]];
                }
            }
        }
        
        
        //System.out.println(dp[1][8]);
        System.out.println(dp[n-1][nums[n]]);
    }
    
}




Measured memory_bytes: 24384
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{

    ll n;
    cin >> n;

    ll k;
    cin >> k;

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

    ll count = 0;

    for (int i = 0; i < n; i++)
    {
        if (h[i] >= k)
        {
            count++;
        }
    }

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

    // int sum = 0;
    // for (int l = 0; l < n - 1; l++)
    // {
    //     int outsubmax = 0;
    //     for (int r = l + 1; r < n; r++)
    //     {

    //         int xl = l;
    //         int xr = r;
    //         int max = 0;
    //         int submax = 0;
    //         while (xl <= xr)
    //         {

    //             if (p[xl] > max)
    //             {
    //                 submax = max;
    //                 max = p[xl];
    //             }
    //             else if (p[xl] > submax)
    //             {
    //                 submax = p[xl];
    //             }
    //             xl++;
    //         }
    //         sum += submax;

    //         while (p[r + 1] <= submax)
    //         {
    //             r++;
    //             sum += submax;
    //         }
    //         outsubmax = submax;
    //     }

    //     while (p[l] <= outsubmax)
    //     {
    //         l++;
    //         for (int r = l + 1; r < n; r++)
    //         {
    //             sum += outsubmax;

    //             while (p[r + 1] <= outsubmax)
    //             {
    //                 r++;
    //                 sum += outsubmax;
    //             }
    //         }
    //     }
    // }

    cout << count << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    vector<string> max_str;
    map<string, int> cnt_mp;
    int n;
    string s;
    int max_cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> s;
        cnt_mp[s]++;
        if (max_cnt < cnt_mp[s]){
            max_cnt = cnt_mp[s];
        }
    }
    /* 最大出現回数文字列を求める */
    for (auto iter = cnt_mp.begin(); iter != cnt_mp.end(); iter++){
        if (max_cnt == iter->second){
            max_str.push_back(iter->first);
        }
    }
    /* 辞書順ソート */
    sort(max_str.begin(), max_str.end());
    for (int i = 0; i < max_str.size(); i++){
        cout << max_str[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 25584
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)

	var x int
	a := makeTrueSlice(n+1)
	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &x)
		a[x] = false}

	fmt.Println(resolve(n, a))
}

func resolve(n int, a []bool) int {
	dp := make([]int, n+1)
	dp[0] = 1
	
	mod := 1000000007
	for i := 1; i <= n; i++ {
		if a[i] {
			switch i {
			case 1:
				dp[i] = 1
				break
			default:
				dp[i] = (dp[i-1] + dp[i-2])%mod
			}
		}
	}
	return dp[n]
}

func makeTrueSlice(len int) []bool {
	slice := make([]bool, len)
	for i := 0; i<len; i++ {
		slice[i] = true
	}
	return slice
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef ll arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
struct arr_for_discrete
{
	int cnt, *addr;
	bool operator<(arr_for_discrete A) const { return cnt < A.cnt; }
} d[Maxn];
int Disc(int t)
{
	rg int tmp = 0;
	std::sort(d + 1, d + t + 1);
	for (int i = 1; i <= t; i++)
	{
		if (i == 1 || d[i].cnt != d[i - 1].cnt)
			d[++tmp] = d[i];
		*d[i].addr = tmp;
	}
	return tmp;
}
int n,S;
ll ans;
arr x,a;
vector<int>rk;
int main()
{
	rg int tmp;
	cin>>n>>S;
	for(rg int i=1;i<=n;i++)
	{
		x[i]=read();
		a[i]=read();
		if(x[i]==S)
		{
			i--;
			n--;
		}
	}
	rg int i,j;
	for(i=1,j=n;x[i]<S&&x[j]>S;)
	{
		if(a[i]>=a[j])			
		{
			rk.push_back(x[j]);
			a[i]+=a[j--];
		}
		else
		{
			rk.push_back(x[i]);
			a[j]+=a[i++];
		}
	}
	if(x[j]<S)
		for(rg int k=i;k<=j;k++)
			rk.push_back(x[k]);
	else
		for(rg int k=j;k>=i;k--)
			rk.push_back(x[k]);
	rk.push_back(S);
	for(rg int i=1;i<rk.size();i++)
		ans+=abs(rk[i]-rk[i-1]);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2428
a, b, c, x, y = map(int, input().split())
result = 0
if a + b > 2 * c:
  t = min(x, y)
  result += t * 2 * c
  x, y = x - t, y - t
else:
  t = min(x, y)
  result += t * a + t * b
  x, y = x - t, y - t
if x > 0:
  if a > 2 * c:
    result += x * 2 * c
  else:
    result += x * a
else:
  if b > 2 * c:
    result += y * 2 * c
  else:
    result += y * b
print(result)


Measured memory_bytes: 3064
s = input()
ans = 0
g = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        g += 1
        if g > ans:
            ans = g
    else:
        g = 0;
print(ans)

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

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> toll(m);
	for (int i = 0; i < m; i++) {
		cin >> toll[i];
	}
	sort(toll.begin(), toll.end());
	int forward = 0, backward = 0;
	for (int i = 0; i < m; i++) {
		if (toll[i] < x)
			forward++;
		else if (toll[i] > x)
			backward++;
	}
	cout << min(forward, backward) << endl;
	return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<ll> two(n+1);
  two[0] = 1;
  rep(i,n) two[i+1] = two[i]*2%mod;

  ll ans;
  rep(i,n) {
    ll l = i, r = n-1-i;
    ll now = two[r];
    if (r != 0) now += two[r-1]*r%mod;
    now =now * two[l]%mod;
    now =now * a[i]%mod;
    ans =(ans+now)%mod;
  }

  ans =ans * two[n]%mod;

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


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

class Program
{
    static void Main(string[] args)
    {
        var S = sc.ReadStr();
        var ans = 0;
        var before = S[0];
        for (int i = 1; i < S.Length; i++)
        {
            if (before != S[i]) ans++;
            before = S[i];
        }
        Console.WriteLine(ans);
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11988
#include<iostream>
using namespace std;
typedef long long LL;
int main()
{
    LL n, k; cin >> n >> k;
    LL ans = 0;
    for(LL b = k+1; b <= n; b++)
    {
        LL t = (n+1)/b;
        ans += t*(b-k);
        if(k==0)
            ans--;
        //next segment is [k+tb, (t+1)b-1] intersection [1,n]
        if(n < k+t*b)
            ans += 0;
        else
            ans += n-(k+t*b)+1;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int fst = n % 10;
  int scd = (n / 10) % 10;
  int trd = (n / 100) % 10;
  int fth = n / 1000;

  if (((fst == scd) && (scd == trd)) || ((scd == trd) && (trd == fth))) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}



int main()
{

ll n,k;cin>>n>>k;
vl a(n+1);
for(int i=1;i<=n;i++)cin>>a[i];

ll st=1;
vector<int>vis(200001);
ll cnt=1;
vis[st]=cnt;
ll rep=(ll)1e18+1;
while(cnt!=n+1)
{
cnt++;
st=a[st];
k--;
if(!vis[st])vis[st]=cnt;
else 
{
  rep=cnt-vis[st];
  break;
}
if(!k)break;
}

if(k)k=k%rep;
while(k)
{
k--;
st=a[st];
}

cout<<st<<"\n";

  return 0;

}

Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=4e5+10,size=1<<20,mod=998244353;
const ll inf=1e18;

template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

int n,dic[150],f[N*2][2],g[N*2][2];
ll ans=inf;
vector<pi> x[N],y[N];

int main() {
	qr(n);
	dic['U']=0;
	dic['D']=1;
	dic['R']=2;
	dic['L']=3;
	for(int i=1;i<=n;i++) {
		int a,b,c;qr(a); qr(b);
		char str[6]; scanf("%s",str);
		a++; b++; c=dic[str[0]];
		x[a].pb(mk(b,c));
		y[b].pb(mk(a,c));
	}
	for(int i=1;i<N;i++) {
		sort(all(x[i]));
		sort(all(y[i]));
		ll a,b;
		a=b=inf;
		for(auto j:x[i]) {
			if(j.se==0) a=j.fi;
			else if(j.se==1) b=j.fi;
			if(a<b) ans=min(ans,(b-a)*5);
		}
		a=b=inf;
		for(auto j:y[i]) {
			if(j.se==2) a=j.fi;
			else if(j.se==3) b=j.fi;
			if(a<b) ans=min(ans,(b-a)*5);
		}
	}
	for(int i=1;i<N;i++) 
		for(auto j:x[i]) {
			int t=j.fi;
			if(j.se==2) {
				f[j.fi-i+N][0]=i;
				f[j.fi+i][1]=i;
			}
			else if(j.se==3) {
				int k=g[j.fi+i][1];
				if(k) ans=min(ans,(i-k)*10LL);
				k=g[j.fi-i+N][0];
				if(k) ans=min(ans,(i-k)*10LL);
			}
			else if(j.se==1) {
				int k=f[j.fi-i+N][0];
				if(k) ans=min(ans,(i-k)*10LL);
				g[j.fi+i][1]=i;
			}
			else if(j.se==0) {
				int k=f[j.fi+i][1];
				if(k) ans=min(ans,(i-k)*10LL);
				g[j.fi-i+N][0]=i;
			}
		}
	if(ans>inf/2) puts("SAFE");
	else pr2(ans);
	return 0;
}

Measured memory_bytes: 40172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = N;
    rep(i,N - 1){
        if (S[i] == S[i + 1]){
            ans--;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (100010)
#define S (p[s[i]-'a'])
#define T (p[t[i]-'a'])
char s[N],t[N];
int ls,lt,as,ap;
vector<int>p[30];
signed main(){
	cin>>s+1>>t+1,ls=strlen(s+1),lt=strlen(t+1);
	Frn1(i,1,ls)S.push_back(i);
	Frn1(i,1,lt){
		if(!T.size())wr(-1),exit(0);
		if(*--T.end()<=ap)++as,ap=*T.begin();
		else ap=*upper_bound(T.begin(),T.end(),ap);
	}
	wr(as*ls+ap),exit(0);
}

Measured memory_bytes: 1656
import java.util.*;
 
class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        StringBuilder S = new StringBuilder(sc.next());
                        int N = sc.nextInt();
                        for (int i = 0; i < N; i++) {
                                String operator = sc.next();
                                        int a = sc.nextInt(), b = sc.nextInt() + 1;
                                if (operator.equals("print")) {
                                        System.out.println(S.substring(a, b));
                                } else if(operator.equals("reverse")) {
                                        S.replace(a, b, (new StringBuilder(S.substring(a, b))).reverse().toString());
                                } else {
                                        String x = sc.next();
                                        S.replace(a, b, x);
                                }
                        }
                }
        }
}


Measured memory_bytes: 29676
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

total_cost = 0
for i in range(1, N+2):
    total_cost += abs(A[i-1] - A[i])


for i in range(1, N+1):
    skip_cost = (abs(A[i-1] - A[i+1])) - \
        (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]))
    print(total_cost + skip_cost)


Measured memory_bytes: 14048
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  char X, Y;
  rd(X);
  rd(Y);
  if(X>Y){
    wt_L('>');
    wt_L('\n');
  }
  else if(X<Y){
    wt_L('<');
    wt_L('\n');
  }
  else{
    wt_L('=');
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// {
//   char X, Y;
//   rd(X, Y);
//   wt( if[X>Y, '>', X<Y, '<', '='] );
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000000000007LL
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

int n;
pair<pii, int> z[1005];

int dp[1005][20005];

bool cmp(pair<pii, int> x,pair<pii, int> y){
	pii a=x.fr,b=y.fr;
	return a.sc+a.fr > b.sc+b.fr;
}

int calc(int p,int s){
	if(s<0)return -M;
	if(p==n)return 0;
	int &ans=dp[p][s];
	if(ans!=-1)return ans;
	ans=calc(p+1,s);
	ans=max(ans,z[p].sc+calc(p+1,min(s-z[p].fr.fr,z[p].fr.sc)));
	return ans;
}

void solve(){
	mem1(dp);
	cin>>n;
	rep(i,0,n){
		cin>>z[i];
	}
	sort(z,z+n,cmp);
	// rep(i,0,n)cout<<z[i]<<"\n";
	int ans=0;
	ans=calc(0,20001);
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}

Measured memory_bytes: 157440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >> S;
    int N=S.size()/2;
    string x,y;
    x=S.substr(0,N);
    y=S.substr(N+1);
    string w=x;
    reverse(x.begin(),x.end());
    string q=y;
    reverse(y.begin(),y.end());
    if(x==y && x==w && y==q) cout << "Yes" << endl;
    else cout << "No" << endl;



}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#define N 100
#define FIRST 0
#define SECOUND 1
#define THIRD 2

int n,M[N][N];

void dijkstra(){
    int minv;
    int d[N],p[N];
    int i;

    for(i=0;i<n;i++){
        d[i]=INT_MAX;
        p[i]=FIRST;
    }
    
    d[0]=0;
    p[0]=SECOUND;
    
    while(1){
        minv=INT_MAX;
        int u= -1;
        for(int i=0;i<n;i++){
            if(minv> d[i] && p[i] != THIRD){
                u=i;
                minv=d[i];
            }
        }
        
        if(u==-1)break;
        p[u]=THIRD;
        
        for(int v=0;v<n;v++){
            if(p[v]!=THIRD && M[u][v]!=INT_MAX){
                if(d[v]>d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    p[v]=SECOUND;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        printf("%d %d\n",i,d[i]==INT_MAX ? -1 : d[i]);
    }
}

int main(){
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=INT_MAX;
        }  
    }

    int k,c,u,v;
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(int j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            M[u][v]=c;
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 2052
local N = io.read("n")
local A = {} for i=1,N do A[i] = io.read("n") end

local minus = false
local abs_min = 1000000001
local abs_sum = 0
for i=1,N do
    if A[i] < 0 then
        minus = not minus
    end
    abs_min = math.min(abs_min, math.abs(A[i]))
    abs_sum = abs_sum + math.abs(A[i])
end
local ans = abs_sum
if minus then
    ans = ans - 2 * abs_min
end
--print(minus, abs_min, abs_sum)
print(ans)


Measured memory_bytes: 2424
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

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

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

int test_counter=0;

int solve(int x, int y){
	int gap=abs(y)-abs(x);
	int ret=abs(gap);
	if(gap>0){
		ret+=(x<0)+(y<0);
	}else if(gap<0){
		ret+=(x>0)+(y>0);
	}else{
		ret+=(x!=y);
	}
	return ret;
}

void testUnit(int x, int y){
	cout<<"Test #"<<test_counter<<" :"<<solve(x,y)<<"\n";
	test_counter++;
}

void test(){
	test_counter=0;
	testUnit(10,20);
	testUnit(10,-10);
	testUnit(-10,-20);
	testUnit(-10,-5);
	testUnit(-10,5);
	testUnit(10,5);
	testUnit(0,-10);
}

int main(){
//	test();
	int x,y;
	cin>>x>>y;
	cout<<solve(x,y)<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main () {
  string s;
  cin >> s;

  reverse(ALL(s));
  rep(i,4) reverse(ALL(divide[i]));

  bool can = true;
  for (int i = 0; i < s.size(); ) {
    bool can2 = false;
    rep(j,4) {
      string d = divide[j];
      if (s.substr(i,d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

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

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

namespace The_Number_of_Chairs
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputStr = {};
            int result;
            List<int> numbers = new List<int>();

            while (inputStr.Length != 2 || numbers[0] < 1 || numbers[0] > 100 || numbers[1] < 1 || numbers[1] > 10)
            {
                inputStr = Console.ReadLine().Split(' ');
                foreach (string item in inputStr)
                {
                    numbers.Add(int.Parse(item));
                }
            }

            result = numbers[0] * numbers[1];
            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 19980
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll n=in();
    vector<ll>a(n+1),b(n);REP(i,n+1)a[i]=in();REP(i,n)b[i]=in();
    ll ans=0;
    REP(i,n){
        ll lmon=min(b[i],a[i]);
        ans+=lmon;
        if(lmon<b[i]){
            b[i]-=lmon;
            ll rmon=min(a[i+1],b[i]);
            ans+=rmon;
            a[i+1]-=rmon;
        }
    }
    cout<<ans<<endl;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


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

  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  for (int i = 0; i < h; i++){
    cin >> v[i];
  }

  int res = 0;

  queue<p> q;
  vector<int> count(h * w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(v[i][j] == '#'){
        q.push({i, j});
        count[0]++;
      }
    }
  }

  int now_count = 0;
  while(q.size() != 0){
    int ny = q.front().first;
    int nx = q.front().second;
    q.pop();
    if(ny - 1 >= 0 && v[ny-1][nx] == '.'){
      q.push({ny-1, nx});
      v[ny-1][nx] = '#';
      count[now_count+1]++;
    }
    if(ny + 1 < h && v[ny+1][nx] == '.'){
      q.push({ny+1, nx});
      v[ny+1][nx] = '#';
      count[now_count+1]++;
    }
    if(nx - 1 >= 0 && v[ny][nx-1] == '.'){
      q.push({ny, nx-1});
      v[ny][nx-1] = '#';
      count[now_count+1]++;
    }
    if(nx + 1 < w && v[ny][nx+1] == '.'){
      q.push({ny, nx+1});
      v[ny][nx+1] = '#';
      count[now_count+1]++;
    }
    count[now_count]--;
    if(count[now_count] == 0){
      now_count++;
      if(count[now_count] == 0) break;
      res++;
    }

  }

  cout << res << endl;

}


Measured memory_bytes: 13456
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

lli N;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (lli i = sqrt(N) + 1; i >= 1; --i)
	{
		if (N % i == 0)
		{
			cout << i + N / i - 2;
			return 0;
		}
	}
}

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

#define pb push_back

using namespace std;

typedef long long LL;

const int N = 1234567;

inline int read()
{
  int p=0; int f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

int a[N],k[N];

int SG(int x,int y)
{
  if(x%y==0) return x/y;
  if((x-(x/y*y)) % ((x/y)+1) == 0) return SG(x-((x-(x/y*y))/((x/y)+1)) * (x/y+1),y);
  else return SG(x-((x-(x/y*y))/((x/y)+1)+1) * (x/y+1),y);
}

int sg[N];

int main()
{

  int n = read();

  for(int i=1;i<=n;i++) a[i] = read(),k[i] = read(),sg[i] = SG(a[i],k[i]);

  int ans=0;
  for(int i=1;i<=n;i++) ans ^= sg[i];
  if(!ans) printf("Aoki\n");
  else printf("Takahashi\n");
  return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int X, N; cin >> X >> N;
    int cnt[102] = {};
    REP(i, 0, N) {
        int v; cin >> v;
        cnt[v]++;
    }

    int diff = 1 << 30, v = 1 << 30;
    for (int i = 0; i <= 101; i++) {
        if (cnt[i]) continue;
        if (abs(i - X) < diff) {
            diff = abs(i - X);
            v = i;
        }
    }
    cout << v << endl;
    return 0;
}

Measured memory_bytes: 3620
a=input()
for i in range(int(input())):
	odr=input().split()
	b=int(odr[1])
	c=int(odr[2])
	if odr[0]=='print':
		print(a[b:c+1])
	elif odr[0]=='replace':
		a=a[:b]+odr[3]+a[c+1:]
	elif odr[0]=='reverse':
		a=a[:b]+a[b:c+1][::-1]+a[c+1:]


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	int n;

	std::map<int, int> m;

	std::cin >> n;

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

		m[a]++;
	}

	long long count = 0;

	for (auto i : m) {
		if (i.first > i.second) {
			count += i.second;
		}
		else if (i.first < i.second) {
			count += i.second - i.first;
		}
	}

	std::cout << count << std::endl;

	
	return 0;

}


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

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
string vowel = "aiueo";
bool isvowel(char c){
  REP(i, 5)if(c == vowel[i]) return true;
  return false;
}
bool ksthp(char c){
  return (c == 'k' || c == 's' || c == 't' || c == 'h' || c == 'p');
}
bool iu(char c){
  return (c == 'i' || c == 'u');
}
bool ao(char c){
  return (c == 'a' || c == 'o');
}

int main(){
  string s;
  while(cin>>s && s != "#"){
    vector<string> mora;
    int N = s.size();
    string tmp;
    REP(i, N){
      if(tmp == "n" && !isvowel(s[i])){
        mora.push_back("n");
        tmp = s[i];
      }else if(s[i] == '\''){
        tmp += "'";
        mora.push_back(tmp);
        tmp = "";
      }else if(isvowel(s[i])){
        tmp += s[i];
        mora.push_back(tmp);
        tmp = "";
      }else{
        tmp += s[i];
      }
    }
    if(tmp != "")mora.push_back(tmp);
    int M = mora.size();
    vector<bool> rule1(M);
    vector<bool> rule2(M);
    REP(i, M - 1){
      if(ksthp(mora[i][0]) && ksthp(mora[i+1][0])){
        if(iu(mora[i][mora[i].size()-1])) rule1[i] = true;
        if(mora[i+1][0] != mora[i+1][1] && mora[i][mora[i].size()-1] == mora[i+1][mora[i+1].size()-1] && ao(mora[i][mora[i].size()-1])) rule2[i] = true;
      }
    }
    if(ksthp(mora[M-1][0]) && iu(mora[M-1][mora[M-1].size()-1])) rule1[M-1] = true;
    bool bf = false;
    REP(i, M){
      //cout<<mora[i]<<" ";
      if((rule1[i] || rule2[i]) && !bf) {
        cout<<mora[i].substr(0, mora[i].size()-1) + "(" + mora[i][mora[i].size()-1] + ")";
        bf = true;
      }else{
        bf = false;
        cout<<mora[i];
      }
    }
    cout<<endl;
    //REP(i, M - 1)if(kathp[mora[i][0])
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	ll a,b,v,w; cin>>a>>v>>b>>w;
	ll t; cin>>t;
	ll d=abs(b-a);
	ll e=v-w;

	if(e*t>=d) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;


	return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[310][310];

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


	string S;
	int K;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else A[k]++;
	}

	int kosuu = 0;
	dp[0][0] = 1;
	for (int i = k; i >= 0; i--) {
		if (i % 4 == 0) {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					dp[j][k] %= mod;
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		else {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		kosuu += A[i];
	}

	ll kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}

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

int main(){
  string N;
  cin >> N;
  int sum=0;
  for(int i=0;i<N.size();i++){
    if(N.at(i) == '7'){
      sum++;
    }
  }
  if(sum>0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;

int main(void)
{
	string s; cin>>s;
	for(int i = 0; i < 19; i++){
		if(i == 5 || i == 13){
			cout<<" ";
		}
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

A =[] 

for i in range(N):
  A.append([i+1,a[i]])


A.sort(key=lambda x: x[1], reverse=True)

dp = []
for i in range(N+1,-1,-1):
  dp.append([0] * (i+1))

for i in range(N+1):
  for x in range(i+1):
    y = i - x
    if x == 0 and y == 0:
      dp[x][y] = 0
    
    elif x == 0:
      dp[x][y] = dp[x][y-1] + A[y-1][1]*((N-y+1) - (A[y-1][0]))


    elif y == 0:
      dp[x][y] = dp[x-1][y] + A[x-1][1]*((A[x-1][0]) - x )


    else:
      dp[x][y] = max(dp[x][y-1] + A[x+y-1][1]*((N-y+1) - (A[x+y-1][0])) , dp[x-1][y] + A[x+y-1][1]*((A[x+y-1][0]) - x ))

ans = 0
for x in range(N+1):
  y = N - x
  ans = max(ans,dp[x][y])
  
print(ans)

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

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

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
      string s;cin >> s;
      int n = s.length();
      for(int i = 1;i <= n;i++){
            if((i & 1) && (s[i-1] == 'L'))return cout << "No", 0;
            else if(!(i & 1) && (s[i-1] == 'R'))return cout << "No", 0;
      }
      cout << "Yes";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        System.out.println(solve(a, b, c));
    }

    private static long solve(int[] a, int[] b, int[] c) {
        int n = a.length;
        long[] bmemo = new long[n];
        int cidx = 0;
        for (int j = 0; j < n; j++) {
            for (int k = cidx; k < n; k++) {
                if (b[j] >= c[k]) {
                    cidx++;
                } else {
                    bmemo[j] = n - k;
                    break;
                }
            }
        }
        for (int i = n - 2; i >= 0; i--) {
            bmemo[i] += bmemo[i + 1];
        }
        long sum = 0;
        int bidx = 0;
        for (int i = 0; i < n; i++) {
            for (int j = bidx; j < n; j++) {
                if (a[i] >= b[j]) {
                    bidx++;
                } else {
                    sum += bmemo[j];
                    break;
                }
            }
        }
        return sum;
    }
}


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

int main() {
  string S;
  cin >> S;

  int cnt=0;

     if(S[0] == S[1]){
      if(S[1] == S[2]){
        cout <<"Yes" << endl;
      }
      else {
        cout <<"No" << endl;
      }
     }
     else if(S[2] ==S[3]){
       if (S[2] ==S[1]){
         cout <<"Yes" << endl;
       }
       else{
        cout <<"No" << endl; 
       }
     }
     else{
         cout <<"No" << endl;
     }

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAXN=2e5+5;
int a[MAXN];


int main()
{
	int n;
	while(cin>>n)
	{
		for(int i=1;i<=n;++i)	
	    {
	    	cin>>a[i];
		}
		if(n&1)
		{
			cout<<a[n];
			for(int i=n-2;i>=1;i-=2)
			    cout<<" "<<a[i];
			for(int i=2;i<=n-1;i+=2)
			    cout<<" "<<a[i];
			cout<<endl;
		}else
		{
			cout<<a[n];
			for(int i=n-2;i>=2;i-=2)
			    cout<<" "<<a[i];
			for(int i=1;i<=n-1;i+=2)
			    cout<<" "<<a[i];
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2944