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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define endl "\n"


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
class union_find{
  private:
    ll N; //要素数
    vll par; // iの親
    vll rank; // 木の深さ
    
  public:
    // 要素の初期化
    union_find(ll n){
      N = n;
      par.resize(N); rank.resize(N);
      for(ll i=0;i<N;i++){
        par[i] = i; rank[i] = 0;
      }
    }

    // 木の根を求める
    ll root(ll x){
      if(par[x] == x) return x;
      else{
        ll r = root(par[x]);
        return par[x] = r;
      }
    }

    // 木の併合(rank基準) (wはxとyの重みの差 w = w(y) - w(x))
    void unite(ll x, ll y){
      x = root(x);
      y = root(y);
      if(x == y) return;

      if(rank[x] < rank[y]){
        par[x] = y;
      }
      else{
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
      }
    }

    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y){
      return root(x) == root(y);
    }
};

struct edge{
  ll from, to, cost;
  bool operator < (const edge &e){
    return cost < e.cost;
  }
};

ll kruskal(ll n, vector<edge> &edges){
  ll res = 0;
  sort(ALL(edges));
  union_find uf(n);

  for(ll i=0;i<edges.size();i++){
    edge e = edges[i];
    if(!uf.same(e.from, e.to)){
      res += e.cost;
      uf.unite(e.from, e.to);
    }
  }
  return res;
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, m;
  cin >> n >> m;
  vector<edge> vec(m);
  REP(i,m){
    ll s, t, w;
    cin >> s >> t >> w;
    vec[i] = {s, t, w};
  }

  cout << kruskal(n,vec) <<endl;

  return 0;
}




Measured memory_bytes: 5444
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>

namespace fuck
{
	const int N=100100,M=N*2;
	int begin[N],next[M],to[M];
	int n,e;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);
	}
	typedef std::map<int,int>::iterator mit;
	int f[N],g[N],lim;
	std::map<int,int> S;

	mit it;
	int w,dw,cnt;

	void dfs(int p=1,int h=0)
	{
		f[p]=g[p]=0;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)dfs(q,p);

		S.clear();
		cnt=0;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
			{
				f[p]+=f[q];
				S[g[q]+1]++;
				cnt++;
			}

		int maxw=-1;

		while(cnt>1)
		{
			it=S.end();it--;
			w=it->first,dw=lim-w;

			(it->second)--;
			if((it->second)==0)S.erase(it);
			cnt--;

			f[p]++;


			it=S.upper_bound(dw);
			if(it==S.begin())
			{
				maxw=w;
				continue;
			}
			else it--;

			(it->second)--;
			if((it->second)==0)S.erase(it);
			cnt--;
		}

		if(!cnt)
		{
			if(maxw>0)
			{
				f[p]--;
				g[p]=maxw;
			}
			else g[p]=0;
		}
		else g[p]=S.begin()->first;

		if(g[p]==lim)f[p]++,g[p]=0;
		if(p==1 && g[p]!=0)f[p]++,g[p]=0;
	}
	int c[N];
	void solve()
	{
		initialize();

		lim=n+10,dfs();
		int A=f[1],u=n,d=0;

		while(u>d)
		{
			lim=(u+d)>>1;
			dfs();
			if(f[1]==A)u=lim;
			else d=lim+1;
		}

		printf("%d %d\n",A,d);
	}
}

int main()
{
//	freopen("D.in","r",stdin);
//	freopen("D.out","w",stdout);

	fuck::solve();
	return 0;
}


Measured memory_bytes: 9600
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e3 + 10;

vector<pii> solve(int n);

vector<string> base[10];

int main() {
	base[4] = {
		"aabc",
		"ccbc",
		"abdd",
		"abcc"
	};
	base[5] = {
		"aabba",
		"bcc.a",
		"b..ab",
		"a..ab",
		"abbcc",
	};
	base[7] = {
		"aa.a.aa",
		".bbabb.",
		"..aba..",
		"..aba..",
		"a.cc..a",
		"a...a.a",
		"bb..abb",
	};
	fast_cin();
	int n; cin >> n;
	vector<string> a(n, string(n, '.'));
	if (n % 3 == 0) {
		for (int i = 0; i < n; i += 3) {
			a[i][i] = a[i][i + 1] = 'a';
			a[i + 1][i + 2] = a[i + 2][i + 2] = 'a';
		}
	} else {
		auto vals = solve(n);
		if (vals.empty()) {
			cout << -1 << endl;
			return 0;
		}
		int i = 0;
		for (auto& p : vals) {
			int val = p.first, cnt = p.second;
			while (cnt--) {
				for (int j = 0; j < val; ++j) {
					for (int k = 0; k < val; ++k) {
						a[i + j][i + k] = base[val][j][k];
					}
				}
				i += val;
			}
		}
	}
	for (auto& s : a) {
		cout << s << '\n';
	}
}

vector<pii> solve(int n) {
	for (int c4 = 0; c4 <= n; ++c4) {
		for (int c5 = 0; c5 <= n; ++c5) {
			if (4 * c4 + 5 * c5 > n) {
				break;
			}
			int left = n - 4 * c4 - 5 * c5;
			if (left % 7 == 0) {
				return {{4, c4}, {5, c5}, {7, left / 7}};
			}
		}
	}
	return {};
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<queue>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<28
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
static const int dx[7] = {0,0,1,1,0,-1,-1};
static const int dy[2][7] = {{0,1,0,-1,-1,-1,0},{0,1,1,0,-1,0,1}};//even,odd
static const int dif = 150;

int main(){
  int d[400][400][7];
  bool bmap[400][400];
  rep(i,400){
    rep(j,400){
      rep(k,7){
	d[i][j][k] = INF;
      }
      bmap[i][j] = false; 
    }
  }

  P s,g,l;
  int n,ans = INF;
  scanf("%d %d %d %d",&s.F,&s.S,&g.F,&g.S);
  scanf("%d",&n);
  rep(i,n){
    int x,y;
    scanf("%d %d",&x,&y);
    x += dif; y += dif;
    bmap[y][x] = true;
  }
  scanf("%d %d",&l.F,&l.S);
  queue<PP> que;
 
  que.push(PP(s,P(0,0)));
  d[s.S+dif][s.F+dif][0] = 0;

  /*
  deque<PP> deq;
  deq.push_front(PP(s,P(0,0)));
   
 while(!deq.empty() ){
    PP p = deq.front(); deq.pop_front();
    if(p.F == g){
      ans = p.S.S;
      break;
    }
    int burden = abs(p.F.F*p.F.S*p.S.F)%6,dir = (p.S.F+1)%6;
    rep(i,7){
      int nx = p.F.F+dx[i],ny = p.F.S+dy[p.F.F&1][i];
      if(bmap[ny+dif][nx+dif])continue;
      if(ny<-l.S || nx<-l.F || l.S<ny || l.F<nx)continue;
      
      if(i == burden){
	if(d[ny+dif][nx+dif][dir] > p.S.S){
	  d[ny+dif][nx+dif][dir] = p.S.S;
	  deq.push_front(PP(P(nx,ny),P(dir,p.S.S)));
	}
      }
      else{
	if(d[ny+dif][nx+dif][dir] > p.S.S+1){
	  d[ny+dif][nx+dif][dir] = p.S.S+1;
	  deq.push_back(PP(P(nx,ny),P(dir,p.S.S+1)));
	}
      }
    }
  }
  
  */


  
  
  while(!que.empty()){
    PP pp = que.front();que.pop();
    if(pp.F == g){
      ans = min(ans,pp.S.S);
      continue;
    }
 
    int burden = abs(pp.F.F*pp.F.S*pp.S.F)%6,dir = (pp.S.F+1)%6;
    
    rep(i,7){
      int nx = pp.F.F+dx[i],ny = pp.F.S+dy[pp.F.F&1][i];
      int Dcost = i==burden+1? pp.S.S:pp.S.S+1;
      if(ny<-l.S || nx<-l.F || l.S<ny || l.F<nx)continue;
      if( !bmap[ny+dif][nx+dif] && (ans > pp.S.S) && d[ny+dif][nx+dif][dir] > Dcost){
	//cout << "in! nx = " << nx-dif << ",ny = " << ny-dif  << ", Dcost = " << Dcost<< endl;
	d[ny+dif][nx+dif][dir] = Dcost;
	que.push(PP(P(nx,ny),P(dir,Dcost)));
      }
    }
    
  }
  
  //cout << ans << endl;
  if(ans != INF)printf("%d\n",ans);
  else printf("-1\n");
  return 0;
}

Measured memory_bytes: 8440
from sys import stdin
from collections import deque
H, W = [int(x) for x in stdin.readline().rstrip().split()]

data = []

for _ in range(H):
    data.append(list(input()))

searched = [[0]*(W+2)]

for _ in range(H):
    searched.append([0] + [1000000]*W + [0])
searched.append([0]*(W+2))

visit_p = deque()
for h,i in enumerate(data):
    for w, j in enumerate(i):
        if j == "#":
            searched[h+1][w+1] = 0
            visit_p.append((h+1, w+1, 0))
while visit_p:
    nh,nw,num = visit_p.popleft()
    if searched[nh][nw] < num:
        continue
    for dh,dw in [(0,1),(1,0),(0,-1),(-1,0)]:
        if searched[nh+dh][nw+dw] > num + 1:
            searched[nh+dh][nw+dw] = num + 1
            visit_p.append((nh+dh,nw+dw,num+1))
print(max(map(max, searched)))

Measured memory_bytes: 169436
n,x=map(int,input().split())
a=[int(j) for j in input().split()]
ref=[10**18]*n
ans=10**18
for i in range(n):
	ref=[min(ref[j],a[(j+i)%n]) for j in range(n)]
	ans=min(ans,sum(ref)+i*x)
print(ans)

Measured memory_bytes: 3188
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}



int main()
{
	long long int n, k, cnt = 0, cntf = 0;

	cin >> n >> k;

	vector<int> a(n);

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i] > a[j]) {
				cnt++;
				if (i < j)
					cntf++;
			}
		}
	}

	if(k % 2 == 0)
		cnt = ((((cnt * (k / 2)) % MOD) * (k - 1)) % MOD + (cntf * k) % MOD) % MOD;
	else
		cnt = ((((cnt * k) % MOD) * ((k - 1) / 2)) % MOD + (cntf * k) % MOD) % MOD;
	
	cout << cnt << endl;
	

	return 0;

}

Measured memory_bytes: 256
s = int(input())
 
t = [False] * 1000001
i = 1
while True:
  if s <= 1000000 and t[s] == True:
    break
  t[s] = True
  i += 1
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
 
print(i)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    ll res = 0;
    rep(i,n){
        int l,r;cin>>l>>r;
        res += r-l+1;
    }
    out(res);
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

void YES() {cout << "YES" << endl; exit(0);}
void NO() {cout << "NO" << endl; exit(0);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}


int main() {
  int n, m;
  cin >> n >> m;
  vector<pll> ab(n);
  rep (i, n) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(all(ab));
  int i = 0;
  ll ans = 0;
  while (m > 0) {
    if (m >= ab[i].second) {
      m -= ab[i].second;
      ans += ab[i].first * ab[i].second;
    }
    else {
      ans += ab[i].first * m;
      m = 0;
    }
    i++;
  }
  cout << ans << endl;
  
}


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

using namespace std;

struct edge{
    int to , next;
}e[1000005];
int n,N,cnt,ans,head[1000005],a[1005][1005],q[1000005],pre[1000005],dis[1000005];

void add_edge(int u, int v){
    e[++cnt].next = head[u];
    e[cnt].to = v;
    head[u] = cnt;
}
int main(){

    cin >> n;
    for(int i = 1; i < n; i++){
        for(int j = i+1; j <= n; j++){
            a[i][j] = ++N;
        }
    }
    int be,af,h=1,t=0;
    for(int i=1; i <= n; i++){
        cin >> be;
        for(int j=1; j < n-1; j++){
            cin >> af;
            add_edge(a[min(i,be)][max(i,be)],a[min(i,af)][max(i,af)]);
            pre[a[min(i,af)][max(i,af)]]++;
            be = af;
        }
    }
    
    for(int i=1; i <= N; i++){

        if(!pre[i]){
            q[++t] = i;
            dis[i] = 1;
        }
    }
    while (h <= t){
        int u = q[h];
        for(int i = head[u]; i ; i = e[i].next){
            int v = e[i].to;
            pre[v]--;
            dis[v] = max(dis[v],dis[u]+1);
            if(!pre[v]) q[++t] = v;
            
        }
        pre[u] = 0x7ffffff;
        h++;
    }
    if(t<N) cout << "-1";
    else{
        ans = 0;
        for(int i = 1; i <= N; i++){
            ans = max(ans,dis[i]);
        }
        cout << ans ;
    }
    return 0;
    
    }

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

int main(){
    long long N, A, B; cin >> N >> A >> B;
    long long line=0, ans=0;
    long long tmp;
    tmp = N/(A+B);
    line = (A+B)*tmp;
    ans = A*tmp;
    if(line+A <= N){
        ans += A;
    }else{ 
        ans += N-line;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string a,b; cin >> a >> b;
    a += b;
    ll x = atoll(a.c_str());
    if(x == floor(sqrt(x))*floor(sqrt(x))) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

int comp(const void *a, const void *b) {
    long *A = (long *)a;
    long *B = (long *)b;
    if (*A > *B) return 1;
    if (*A < *B) return -1;
    return 0;
}

int main(void) {
    int n, k;
    scanf("%d%d", &n, &k);
    long long int h[n];
    for (int i = 0; i < n; i++) scanf("%lld", &h[i]);

    qsort(h, sizeof(h) / sizeof(*h), sizeof(*h), comp);
    long long int sum = 0;
    for (int i = 0; i < n-k; i++) sum += h[i];

    printf("%lld\n", sum);

    return 0;
}


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

#define LLINF (1LL<<60)
typedef long long ll;

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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int A,B,C,D;
    cin >>A>>B>>C>>D;

    cout << min(A,B)+min(C,D) <<endl;
    return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        
        String[] array = input.split("");
        
        int count = 0;
        
        if ("0".equals(array[0])) {
            
            for (int i = 1; i < array.length; i++) {
                
                if (array[i].equals("0") && "0".equals(array[i - 1])) {
                    
                    array[i] = "1";
                    count++;
                }
                
                if ("1".equals(array[i]) && "1".equals(array[i - 1])) {
                    
                    array[i] = "0";
                    count++;
                }
            }
        }
        
        if (array[0].equals("1")) {
            
            for (int i = 1; i < array.length; i++) {
                
                if ("1".equals(array[i]) && "1".equals(array[i - 1])) {
                    
                    array[i] = "0";
                    count++;
                }
                
                if ("0".equals(array[i]) && "0".equals(array[i - 1])) {
                    
                    array[i] = "1";
                    count++;
                }
            }
        }
        
        System.out.println(count);
        
        sc.close();
    }
    
}


Measured memory_bytes: 34500
# Aizu Problem 0056: Goldbach's Conjecture
#
import sys, math, os, bisect

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


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(50000)
pset = set(primes)

while True:
    n = int(input())
    if n == 0:
        break
    S = 0
    for p in primes:
        if p > n // 2:
            break
        if n - p in pset:
            S += 1
    print(S)

Measured memory_bytes: 8136
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c, d, e = M()
ans = 0
if a == 0:
    ans = 1
elif b == 0:
    ans = 2
elif c == 0:
    ans = 3
elif d == 0:
    ans = 4
else:
    ans = 5
print(ans)

Measured memory_bytes: 68120
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
	int s, t, v, a[1000];
	string str;
	
	while(1){
		cin >> s >> t;
		if(s == 0 && t == 0){
			break;
		}
		queue<int> que;
		
		for(int i = 1; i <= s; i++){
			que.push(i);
		}
		
		for(int i = 1; i <= t; i++){
			cin >> str;
			if(que.size() == 1){
				continue;
			}
			if(i%3 == 0 && i%5 == 0){
				if(str == "FizzBuzz"){
					que.push(que.front());
				}
			} else if(i%3 == 0){
				if(str == "Fizz"){
					que.push(que.front());
				}
			} else if(i%5 == 0){
				if(str == "Buzz"){
					que.push(que.front());
				}
			} else {
				v = atoi(str.c_str());
				if(v == i){
					que.push(que.front());
				}
			}
			que.pop();
		}
		v = 0;
		while(!que.empty()){
			a[v++] = que.front();
			que.pop();
		}
		sort(a, a+v);
		
		cout << a[0];
		for(int i = 1; i < v; i++){
			cout << " " << a[i];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 944
def gcd(x, y):
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

n = int(input())
a = list(map(int, input().split()))

a.sort()

l = 1
for x in a:
    l = lcm(x, l)

ans = 0
for x in a:
    ans += l//x

print(ans%(10**9+7))

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

int main() {
    int  n; cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];

    int ans = 0;
    rep(i,n){
        if(v[i] > c[i]) ans += v[i]-c[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

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

bool solve(ll A, ll B, ll C, ll D) {
  if (A < B) { return false; }
  if (D < B) { return false; }
  if (C >= B) { return true; }
  // Now, A >= B, D >= B, C < B
  // The count is changed by (D % B). We can consider counts in MOD B.
  // If g = gcd(B, D % B), then the count can be (A % g + g * k) % B (k = 0, 1, ...). It has cycle.
  // e.g. A = 1, B = 7, D = 10, then g = 1 and (count % B) can be [1, 4, 0, 3, 6, 2, 5, 1, ...].
  // e.g. A = 1, B = 8, D = 10, then g = 2 and (count % B) can be [1, 3, 5, 7, 1, ...].
  // The maximum value is B - g + (A % g). We should check it.
  ll g = gcd(B, D % B);
  ll maximum = B - g + (A%g);
  return (maximum <= C);
}

int main(int argc, char** argv) {
  ll T;
  cin >> T;
  rep(i, T) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    bool ans = solve(A, B, C, D);
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>

bool check(int A[], int n, int i, int m) { //i??\?????§m??????????????????????????????A, n?????°???????????????????????????????????????
	if (m == 0) return true;
	if (i >= n) return false;
	bool chk = check(A, n, i + 1, m) || check(A, n, i + 1, m - A[i]);
	return chk;
}

int main() {
	int n, q;
	scanf("%d", &n);
	int A[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf ("%d", &q);
	for (int i = 0; i < q; i++) {
		int m;
		scanf("%d", &m);
		if (check(A, n, 0, m)) printf("yes\n");
		else printf("no\n");
	}
}

Measured memory_bytes: 1008
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;
 
int main() {
    int N;

    cin >> N;

    string s;
    while(N){
        if(N % 2){
            s += '1';
            N--;
        }else{
            s += '0';
        }
        N /= (-2);
    }
    reverse(s.begin(),s.end());

    if(s == "") cout << 0 << endl;
    else cout << s << endl;

	return 0;
}

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

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

    int ex = 2;// exchange
    int com = 3;// commodity

    vector<vector<int>> rate(ex, vector<int>(com));
    for(int i=0; i<ex; i++){
        for(int j=0; j<com; j++){
            cin >> rate[i][j];
        }
    }
    
    vector<vector<long long int>> dp1(com+1, vector<long long int>(n+1));
    dp1[0][0] = 0;
    for(int i=0; i<com; i++){
        for(int j=0; j<=n; j++){
            if(j - rate[0][i] >= 0){
                dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j-rate[0][i]] + rate[1][i]);
                dp1[i+1][j] = max(dp1[i+1][j], dp1[i+1][j-rate[0][i]] + rate[1][i]);
            }
            dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j]);
        }
    }

    long long int ans1 = 0;
    for(int i=0; i<n+1; i++){
        ans1 = max(ans1, dp1[com][i] + (n-i));
    }

    vector<vector<long long int>> dp2(com+1, vector<long long int>(ans1+1));
    dp2[0][0] = 0;
    for(int i=0; i<com; i++){
        for(int j=0; j<=ans1; j++){
            if(j - rate[1][i] >= 0){
                dp2[i+1][j] = max(dp2[i+1][j], dp2[i][j-rate[1][i]] + rate[0][i]);
                dp2[i+1][j] = max(dp2[i+1][j], dp2[i+1][j-rate[1][i]] + rate[0][i]);
            }
            dp2[i+1][j] = max(dp2[i+1][j], dp2[i][j]);
        }
    }
    
    long long int ans2 = 0;
    for(int i=0; i<ans1+1; i++){
        ans2 = max(ans2, dp2[com][i] + (ans1 - i));
    }
    cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 979964
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int N;
inline void solve(){
  IN(N);
  OUT(800*N-N/15*200);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
d = defaultdict(lambda:0)
for i in range(N):
    S = input()
    d[S] += 1
M = 0
for S in d:
    M = max(M,d[S])
ans = []
for S in d:
    if d[S]==M:
        ans.append(S)
ans.sort()
for s in ans:
    print(s)


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

using namespace std;
using ll = long long;

int main() {

  int n;
  string s;
  cin >> n;
  cin >> s;
  string r = "";
  for(int i = 0; i < (int)s.size(); i++){
    char c = s[i];
    int ci = (int)c - 65;
    r = r + (char)(((ci + n) % 26) + 65);
  }

  cout << r;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h,n;
	cin>>h>>n;
	vector<int> a(n);
	for(int &x:a)cin>>x;
	int s=0;
	for(int i=0;i<n;i++)s+=a[i];
	if(s>=h){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 640
#include <stdio.h>
#define N_MAX 100

unsigned long long dp[2][20 + 1];
short n,fml[N_MAX];

void solve(void){
	short i,j;
	i = 0;
	while(++i < n-1){
		int s = i & 1;
		for(j=0;j<=20;j++)dp[s][j] = 0;
		for(j=0;j<=20-fml[i];j++){
			if(!dp[1-s][j])continue;
			dp[s][j+fml[i]] += dp[1-s][j];
		}
		for(j=20;j>=fml[i];j--){
			if(!dp[1-s][j])continue;
			dp[s][j-fml[i]] += dp[1-s][j];
		}
	}
	printf("%llu\n", dp[n % 2][fml[n-1]]);
	return;
}

int main(void){
	int i;
	/* input */
	scanf("%hd",&n);
	for(i=0;i<n;i++)scanf("%hd",&fml[i]);
	/* solve */
	dp[0][fml[0]] = 1;
	solve();
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int arr[3];
  set<int>s;
  for(int i=0;i<3;i++)
  {cin>>arr[i];
   s.insert(arr[i]);
  }
  if(s.size()==2)
    cout<<"Yes";
  else
    cout<<"No";



}


Measured memory_bytes: 256
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    A = [int(c) for c in input().split()]
    B = [0] * (N + 1)

    for i in range(0, N):
        B[A[i]] = i + 1

    for i in range(1, N + 1):
        print(B[i], end="")
        if i != N:
            print(end=" ")
    print()



if __name__ == '__main__':
    main()

Measured memory_bytes: 23400
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
    static int i, j, prime[1000000];
    static int si[1000000];
    int n;
    for(i=0;i<1000000;i++)
    {
        prime[i]=1;
        si[i]=0;
    }

    prime[0]=0;
    prime[1]=0;

    for(i=2;i<1000000;i++)
    {
        if(prime[i]==1)
        {
            for(j=i+i;j<1000000;j=j+i)
            prime[j]=0;
        }
    }


int arr1[10009];
int arr2[10009];

    while(cin>>n)
{

    for(i=0;i<10009;i++)
    {
        arr1[i]=0;
        arr2[i]=0;
    }

    for(i=0;i<n;i++)
    {
        arr1[i]=i+1;
    }
    int h=0;
    for(i=n;i>=1;i--)
    {
        arr2[h++]=i;
    }
    int count=0;
    for(i=1;i<=n;i++)
    {
        if(prime[arr1[i]]!=0 && prime[arr2[i]]!=0)
        {
        count++;
        }
    }
    cout<<count<<endl;
}

    return 0;
}

Measured memory_bytes: 9048
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;

long long a, b, c, d, n, t, ans, i, j, k, x, cost;
map<long long, long long> dp;

long long solve(long long n) {
	if (n == 1) return d;
	if (n == 0) return 0;
	if (n < 0) return 1LL << 60;

	if (dp.find(n) != dp.end()) return dp[n];

	long long ans = 1LL << 60;

	if (n < (1LL << 62) / d) ans = n * d;

	if (n % 2 == 0) ans = min(ans, a + solve(n / 2));
	else {
		ans = min(ans, solve((n + 1) / 2) + a + d);
		ans = min(ans, solve((n - 1) / 2) + a + d);
	}
	
	if (n % 3 == 0) ans = min(ans, b + solve(n / 3));
	else {
		if ((n + 1) % 3 == 0) ans = min(ans, solve((n + 1) / 3) + b + d);
		if ((n + 2) % 3 == 0) ans = min(ans, solve((n + 2) / 3) + b + d + d);
		if ((n - 1) % 3 == 0) ans = min(ans, solve((n - 1) / 3) + b + d);
		if ((n - 2) % 3 == 0) ans = min(ans, solve((n - 2) / 3) + b + d + d);
	}
	if (n % 5 == 0) ans = min(ans, c + solve(n / 5));
	
	else {
		if ((n + 1) % 5 == 0) ans = min(ans, solve((n + 1) / 5) + c + d);
		if ((n + 2) % 5 == 0) ans = min(ans, solve((n + 2) / 5) + c + d + d);
		if ((n + 3) % 5 == 0) ans = min(ans, solve((n + 3) / 5) + c + d * 3);
		if ((n + 4) % 5 == 0) ans = min(ans, solve((n + 4) / 5) + c + d * 4);

		if ((n - 1) % 5 == 0) ans = min(ans, solve((n - 1) / 5) + c + d);
		if ((n - 2) % 5 == 0) ans = min(ans, solve((n - 2) / 5) + c + d + d);
		if ((n - 3) % 5 == 0) ans = min(ans, solve((n - 3) / 5) + c + d * 3);
		if ((n - 4) % 5 == 0) ans = min(ans, solve((n - 4) / 5) + c + d * 4);
	}

	dp[n] = ans;
	return ans;
}

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

	cin >> t;
	while (t--) {
		cin >> n >> a >> b >> c >> d;

		ans = solve(n);
		dp.clear();

		cout << ans << "\n";
	}

	return 0;
}




Measured memory_bytes: 3996
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import *

functions = dict()
functions['J'] = lambda s: s[1:]+s[0]
functions['C'] = lambda s: s[-1] + s[:-1]
functions['A'] = lambda s: ''.join(reversed(s))
functions['E'] = lambda s: s[ceil(len(s)/2):] + s[len(s)//2:ceil(len(s)/2)] + s[:len(s)//2]
functions['P'] = lambda s: ''.join([str((int(c)+1)%10) if c.isnumeric() else c for c in s])
functions['M'] = lambda s: ''.join([str((int(c)-1)%10) if c.isnumeric() else c for c in s])

inv = {'J':'C','C':'J','A':'A','E':'E','P':'M','M':'P'}

n = int(input())
for i in range(n):
    order = input()
    message = str(input())
    for o in list(reversed(order)):
        message = functions[inv[o]](message)
    print(message)

Measured memory_bytes: 6840
// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;

  if (V < W) drop("NO");

  ll dist = abs(A - B);
  ll velocity_diff = abs(V - W);
  bool can = dist <= velocity_diff * T;

  can ? drop("YES") : drop("NO");
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n;
    cin >> n;
    string str;
    int cnt = 0;
    for(int i = 1; i <= n; ++i){
        str = to_string(i);
        if(str.size() % 2 == 1){
            ++cnt; 
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, p;
  cin >> n >> p;
  vector<ll> cnt(2, 0);
  REP(i, n) {
    ll a;
    cin >> a;
    cnt[a % 2]++;
  }
  if (cnt[1] == 0) {
    cout << (p==1? 0 : (ll)(pow(2.0,n)))<< endl;
  } else {
    cout << (ll)(pow(2.0, n - 1)) << endl;
  }
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> primes;
    for (ll i = 2; i * i <= n; i++) {
        ll cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) {
            primes.push_back(cnt);
        }
    }
    if (n > 1) primes.push_back(1);

    // 2^40 > 1e12
    vector<ll> table(50, 0);
    for (int i = 1, j = 1; i < 50; i += j) {
        table[i] = j++;
    }
    rep(i, 49) {
        if (table[i + 1] == 0) {
            table[i + 1] = table[i];
        }
    }
    int ans = 0;
    for (ll c : primes) {
        ans += table[c];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <math.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    ll x,y,z; cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x <<" " << y <<" "<< z << endl;        
}


Measured memory_bytes: 256
from collections import Counter
from itertools import product
N = int(input())
S = input()
Left = Counter()
Right = Counter()
S_left = S[:N]
S_right = S[2*N-1:N-1:-1]
for B in product(range(2),repeat = N):
    red_left = ''
    blue_left = ''
    red_right = ''
    blue_right = ''
    for i in range(N):
        if B[i]:
            red_left += S_left[i]
            red_right += S_right[i]
        else:
            blue_left += S_left[i]
            blue_right += S_right[i]
    Left[red_left + '|' + blue_left] += 1
    Right[blue_right + '|' + red_right] += 1
ans = 0
for i in Left.keys():
    ans += Left[i]*Right[i]
print(ans)

Measured memory_bytes: 67720
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = input()
a = li()

cnt=0
for i in range(len(a)-1):
    if a[i] > a[i+1]:
        cnt += a[i]-a[i+1]
        a[i+1] += (a[i]-a[i+1])

print(cnt)

Measured memory_bytes: 32848
n = int(input())
p = [x for x in map(int, input().split())]
num = 0
for i in range(1, n-1):
  a = [p[i-1], p[i], p[i+1]]
  a.sort()
  if a[1] == p[i]:
    num+=1
print(num)
       

Measured memory_bytes: 2940
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)

Measured memory_bytes: 9252
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort

all = A.inject(:+)
rate = Rational(1, 4 * M)

M.times do
  a = A.pop

  if a < all * rate
    puts 'No'
    exit
  end
end

puts 'Yes'


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
  int N,K;
  cin >> N >> K;
  vector<long long int>A(N);
  for(int i=0; i < N; i++)
    cin >> A[i];

  vector<long long int>s(N);
  s[0] = A[0];
  for(int i=1; i < N; i++)
    s[i] = s[i-1]+A[i];
  vector<long long int>ps(N);
  if(A[0] >= 0)
    ps[0] = A[0];
  else
    ps[0] = 0;
  for(int i=1; i < N; i++){
    if(A[i] >=0)
      ps[i] = ps[i-1] + A[i];
    else
      ps[i] = ps[i-1];
  }

  long long int gsum = 0;
  for(int i=0; i < N-K+1; i++){
    long long int psum,sum,pss;
    if(i >= 1){
      psum  = s[i+K-1] - s[i-1];
      pss = ps[i+K-1] - ps[i-1];
    }else{
      psum = s[i+K-1];
      pss = ps[i+K-1];
    }
    if(psum >= 0)
      sum = psum + ps[N-1] - pss;
    else
      sum = ps[N-1] - pss;
    if(sum >= gsum)
      gsum = sum;
  }

  cout << gsum << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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 (b<a) { a=b; return true; } return false; }

#define FIND(a,b) find(all(a),b)!=a.end()

int main(){
	ll x;cin>>x;
	vector<ll>p(0);
	p.pb(2);
	ll i=3;
	ll pl=2;
	while(1){
		if(pl>=x)break;
		for(auto&y:p){
			if(!(i%y))break;
			if(y==pl){pl=i;p.pb(i);}
		}
		i++;

	}
	cout<<pl<<endl;
}





Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
    int n,u,k,i,j,G[101][101],v;
    scanf("%d", &n);
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++) G[i][j]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d", &u);
        scanf("%d", &k);
        for(j=0;j<k;j++){
            scanf("%d", &v);
            G[u][v] = 1;
        }
    }
    for(i=1;i<=n;i++){
        printf("%d",G[i][1]);
        for(j=2;j<=n;j++) printf(" %d",G[i][j]);
        printf("\n");
    }
    return 0;
}

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

int solve() {
  int x, y, z; cin >> x >> y >> z;
  if (x <= z && y <= z) {
    return x * y / 2;
  }else if (x <= y && z <= y) {
    return x * z / 2;
  }else if (y <= x && z <= x) {
    return y * z / 2;
  }else assert(false);
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  cout << solve() << endl;

  return 0;
}


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

using namespace std;

int n;
vector<int> vec;

int main() {
  cin >> n;
  vec.resize(n);
  rep(i, n) { cin >> vec[i]; }

  long ans = 0;
  rep(i, n) {
    rep(j, n) {
      if (j <= i) {
        continue;
      }
      ans += (vec[i] * vec[j]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int a[n],i;
	for(i=0;i<n;i++){
	   scanf("%d",&a[i]);
	   }
	 int j,k,tmp,count=1;
	  for(j=0;j<n;j++){
	  	for(k=n-1;k>j;k--){
	  		if(a[k]<a[k-1]){
	  			tmp=a[k];
	  			a[k]=a[k-1];
	  			a[k-1]=tmp;
	  			}
	  		}
	  	}
	  for(i=0;i<n-1;i++){
	  	if(a[i]!=a[i+1]){
	  		count++;
	  		}
	  	}
	  printf("%d",count);
	  
	  return 0;
}

Measured memory_bytes: 128