akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline

N,M,K = map(int,readline().split())
A = [0] + list(map(int,readline().split()))
B = [0] + list(map(int,readline().split()))

for i in range(1, len(A)):
  A[i] += A[i - 1]

for i in range(1, len(B)):
  B[i] += B[i - 1]
  
ans = 0
b_ind = len(B) - 1
for i in range(len(A)):
  if A[i] > K:
    continue
  while b_ind >= 1 and A[i] + B[b_ind] > K:
    b_ind -= 1
    
  if i + b_ind > ans:
    ans = i + b_ind
    
print(ans)
    

Measured memory_bytes: 40920
/* 
 * Author: pawanmsr
 */

/*
 * Run in Mac using the following command:
 * g++ -std=c++14 <cpp_filename>
 * A binary will be generated. Then run:
 * ./a.out
 */

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <fstream>
#include <cstring>
#include <unordered_map>

// #include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
int a, b;

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif
    
    /* code */
    cin >> a >> b;
    if (a < b) {
        for (int i=0; i<b; i++) cout << a;
    }
    else {
        for (int i=0; i<a; i++) cout << b;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
Q, H, S, D = gets.split.map(&:to_i)
N = gets.to_i

water = [[Q/0.25, 0.25, Q], [H/0.5, 0.5, H], [S/1.0, 1.0, S], [D/2.0, 2.0, D]].sort_by {|a| a[0]}

remain = N
money = 0
water.each do |w|
  num = (remain / w[1]).to_i
  remain = remain - w[1] * num
  money += num * w[2]

  if remain == 0.0
    break
  end
end

p money


Measured memory_bytes: 1788
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]

c = 0
for k, v in Counter(A).items():
    if v % 2 != 1:
        c += 1

if c % 2 == 0:
    print(len(set(A)))
else:
    print(len(set(A)) - 1)


Measured memory_bytes: 18648
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {


	int N;
	cin >> N;

	string S;
	cin >> S;

	int count = 1;
	for (int i = 1; i < S.size();i++) {
		if (S[i] != S[i - 1]) {
			count++;
			//cout << i << endl;
		}
		
	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main()
{
    int a, b;
    char op;
    cin>>a>>op>>b;
    if(op=='+'){
        cout<<a+b;
    }
    if(op=='-'){
        cout<<a-b;
    }
    return 0;
}


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

int main(){
   int N,M;
   cin>>N>>M;
   int A[M];
   rep(i,M) cin>>A[i];
   int ans=N;
   rep(i,M){
       ans-=A[i];
   }
   if(ans<0) cout << "-1" <<endl;
   else cout << ans <<endl;
} 


Measured memory_bytes: 3636
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
while (s = gets)
  latch = false
  loop = 0
  s.each_char {|c|
    if latch && loop == 0
      loop = c.to_i
    elsif latch
      loop.times { 
        print c 
      }
      latch = false
      loop = 0
    elsif c == '@'
      latch = true
    else
      print c
    end
  }
end

Measured memory_bytes: 6092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 main () {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b >= c) yn;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ALL(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  ull x,y;
  cin >> x >> y;
  ll ans=0;
  while(y/2>=x){
    ans++;
    y/=2;
  }
  cout << ++ans << endl;
}


Measured memory_bytes: 256
// AOJ 2200 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2200)
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 200, MAX_R = 1000, INF = std::numeric_limits<int>::max()>>4;

int N, M, R;
int land[MAX_N][MAX_N], sea[MAX_N][MAX_N];
int dp[MAX_R+1][MAX_N];
int z[MAX_R];

int main()
{
	while( scanf( "%d%d", &N, &M ), N|M )
	{
		rep( i, N ) rep( j, N )
			land[i][j] = sea[i][j] = i==j?0:INF;

		rep( i, M )
		{
			int x, y, t;
			char sl[2];

			scanf( "%d%d%d%s", &x, &y, &t, sl );
			--x; --y;

			auto mat = *sl=='L'?land:sea;
			mat[x][y] = mat[y][x] = std::min( mat[x][y], t );
		}

		scanf( "%d", &R );
		rep( i, R )
			scanf( "%d", z+i ), --z[i];

		rep( k, N ) rep( i, N ) rep( j, N )
		{
			land[i][j] = std::min( land[i][j], land[i][k]+land[k][j] );
			sea[i][j] = std::min( sea[i][j], sea[i][k]+sea[k][j] );
		}

		rep( i, R+1 ) rep( j, N+1 )
			dp[i][j] = INF;
		
		dp[0][z[0]] = 0;
		rep( i, R-1 ) rep( j, N ) rep( k, N )
		{
			if( j != k )
				dp[i+1][j] = std::min( dp[i+1][j], dp[i][k]+land[z[i]][k]+sea[k][j]+land[j][z[i+1]] );
			else
				dp[i+1][j] = std::min( dp[i+1][j], dp[i][j]+land[z[i]][z[i+1]] );
		}

		printf( "%d\n", *std::min_element( dp[R-1], dp[R-1]+N ) );
	}

	return 0;
}

Measured memory_bytes: 2112
T = input()

N = T.count('N')
S = T.count('S')
W = T.count('W')
E = T.count('E')

if N > 0 and S == 0 or S > 0 and N == 0:
    print('No')
elif W > 0 and E == 0 or E > 0 and W == 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stdlib.h>
#include<vector>
#include<stack>
#include<string>
#include<cmath>
using namespace std;
const int maxn = 100000+10;
char num[maxn];
int main()
{
    while(scanf("%s", num)!=EOF)
    {
        int len=strlen(num);
        int numa=0, numb=0, numc=0;
        for(int i=0; i<len; i++)
        {

            if(num[i]=='a')
            {
                numa++;
            }
            if(num[i]=='b')
            {
                numb++;
            }
            if(num[i]=='c')
            {
                numc++;
            }
        }
            int max_=max(numa, numb);
            max_=max(max_, numc);
            int min_=min(numa, numb);
            min_=min(numc, min_);
            if(max_-min_>1)
            {
                printf("NO\n");
            }
            else
            {
                printf("YES\n");
            }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define inf 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0;i < 3;i++) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main(){
    vector<char> odd{'R', 'U', 'D'};
    vector<char> even{'L', 'U', 'D'};
    string s; cin>>s;
    for(int i=0; i<s.length(); i++){
        if(i%2 == 0 && find(ALL(odd), s[i]) == odd.end()){
            OUT("No");
            return 0;
        }
        if(i%2 == 1 && find(ALL(even), s[i]) == even.end()){
            OUT("No");
            return 0;
        }
    }
    OUT("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define y0 y12345
#define y1 y54321

#define INF 100000

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;
	debug("debug test\n");
	cin>>n>>m;
	
	vector<string> s(n);

	rep(i, n){
		cin>>s[i];
	}

	int ma = 0;
	rep(i, n){
		rep(j, m){
			if(s[i][j] == '#'){
				continue;
			}
			vector<vint> d(n, vint(m, INF));
			queue<P> q;
			d[i][j] = 0;
			q.push(P(i, j));
			while(!q.empty()){
				P p = q.front();q.pop();
				int px = p.first, py = p.second;
				int cost = d[p.first][p.second] + 1;
				debug("%d, %d, %d\n", px, py, cost);
				rep(k, 4){
					int nx = px + dx[k], ny = py + dy[k];
					if(nx >= 0 && nx < n && 0 <= ny && ny < m&& d[nx][ny] == INF && s[nx][ny] != '#'){
						q.push(P(nx, ny));
						d[nx][ny] = cost;
						chmax(ma, cost);
					}
				}
			}
		}
	}
	cout << ma << endl;
	return 0;
}


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

int main(){
	vector<long long> p;
	for(int i = 2 ; i <= 100000 ; i++){
		int f = true;
		for(int j = 2 ; j * j <= i ; j++)
			if( i % j == 0 ){f = 0; break; }
		if( f ){
			p.push_back(i);
		}
	}
	long long m,a,b;
	while(cin >> m >> a >> b && m ){
		long long ans = 0;
		long long A = 0;
		
		for(int i = 0 ; i < p.size() ; i++){
			//cout << i << " " << m << " " << p[i] << endl;
			int j = upper_bound(p.begin()+i,p.end(),m/p[i]) - p.begin();
			j = upper_bound(p.begin()+i,p.begin()+j,p[i]*b/a) - p.begin() - 1;
			if( j < i ) continue;
			//cout << p[i] << " " << p[j] << endl;
			//cout << "OK" << p[i] << " " << p[j] << " " << 1.0 * p[i] / p[j] << endl;
			if( p[i] * p[j] > m ) continue;
			if( p[i] * p[j] <= m && a*p[j] <= p[i]*b){
				if( p[i]*p[j] > ans ){
					ans = p[i]*p[j];
					A = p[i];
				}
			}
		}
		cout << A << " " << ans / A << endl;
	}
	
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}
ll N;
vector<ll> h;
ll ans = 1;

void print(l_l tmp) {
    cerr << "{" << tmp.first << ", " << tmp.second << "}" << endl;
}

l_l f(ll l, ll r, ll d) {
    l_l ret;
    /*
    if(r == l + 1) {
        ret.second = beki(2, h[l] - d);
        cerr << "f: " << l << " " << r << " " << d << endl;
        print(ret);
        return ret;
    }
    */
    ll mini = 1e10;
    ll maxi = 0;
    for(int i = l; i < r; i++) {
        chmin(mini, h[i]);
        chmax(maxi, h[i]);
    }
    if(mini == maxi) {
        ret.first = beki(2, r - l) - 2 + mod;
        ret.first %= mod;
        ret.second = 2 * beki(2, maxi - d - 1);
        ret.second %= mod;
        //cerr << "f: " << l << " " << r << " " << d << endl;
        //print(ret);
        return ret;
    }
    ll Left = l;
    ll mininum = 0;
    vector<l_l> v;
    for(int i = l; i < r; i++) {
        if(h[i] == mini) {
            mininum++;
            if(Left != i) {
                v.push_back(f(Left, i, mini));
            }
            Left = i + 1;
        }
    }
    if(Left != r) {
        v.push_back(f(Left, r, mini));
    }
    ll total = beki(2, mininum);
    ll Second = 2;
    for(auto tmp : v) {
        total *= tmp.first + tmp.second * 2;
        total %= mod;
        Second *= tmp.second;
        Second %= mod;
    }
    ret.second = Second;
    ret.first = total - Second + mod;
    ret.first %= mod;
    ret.second *= beki(2, mini - d - 1);
    ret.second %= mod;
    //cerr << "f: " << l << " " << r << " " << d << endl;
    //print(ret);
    return ret;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    h.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    ll l = 0;
    for(int r = 0; r < N; r++) {
        if(h[r] == 1) {
            ans *= 2;
            if(l != r) {
                auto tmp = f(l, r, 0);
                ans *= tmp.first + tmp.second;
                ans %= mod;
            }
            l = r + 1;
        }
    }
    if(l != N) {
        auto tmp = f(l, N, 0);
        ans *= tmp.first + tmp.second;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        s: chars,
    }

    let len = s.len()/2;
    let s_len = s.len();

    let mut ans = 0;
    for i in 0..len {
        let index = i as usize;
        if s[index] != s[s_len - index - 1] {
            ans = ans + 1;
        }
    }

    println!("{}", ans);
   
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e6 + 1;

void solve(){
    ll a , b , c , d , e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0) cout << 1 <<endl;
    else if(b == 0 ) cout << 2 << endl;
    else if(c == 0 ) cout << 3 << endl;
    else if( d == 0 ) cout << 4 << endl;
    else if (e == 0) cout << 5 << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int A = 0, T = 1, G = 2, C = 3;

int na, nt, ng, nc, m;
bool can[205][4];
ll dp[51][51][51][51];
int clen = 0;
map<string, vector<string>> def;

void parse(string type) {
	//cerr << "Enter parse " << type << endl;
	for (string token : def[type]) {
		//cerr << type << " " << token << " " << clen << endl;
		if (clen > na + nt + ng + nc) return;
		if (token[0] == '[') {
			//cerr << "Handle: " << token << endl;
			for (char c : token) {
				if (c == 'A') can[clen][A] = 1;
				if (c == 'T') can[clen][T] = 1;
				if (c == 'G') can[clen][G] = 1;
				if (c == 'C') can[clen][C] = 1;
			}
			clen++;
		} else {
			//cerr << "Recur: " << token << endl;
			parse(token);
		}
	}
}

int main() {
	cin >> na >> nt >> ng >> nc >> m;
	
	const ll mod = 1000000007ll;
	string rootterm, line, term, token;
	getline(cin, line);
	rep(i, 0, m) {
		getline(cin, line);
		stringstream ss(line);
		ss >> term;
		term.pop_back();
		
		if (i == 0)
			rootterm = term;

		while (ss >> token) {
			//cerr << term << " has " << token << endl;
			def[term].push_back(token);
		}
	}

	parse(rootterm);

	/*
	rep(i, 0, clen) {
		if (can[i][A]) cerr << 'A';
		if (can[i][T]) cerr << 'T';
		if (can[i][G]) cerr << 'G';
		if (can[i][C]) cerr << 'C';
		cerr << "; ";
	}
	cerr << endl;
	*/

	if (clen != na + nt + ng + nc) {
		cout << 0 << endl;
		return 0;
	}

	dp[na][nt][ng][nc] = 1;

	rep(i, 0, clen) {
		int curval = clen - i, nextval = clen - i - 1;
		for (int a = 0; a <= na && a <= curval; a++)
			for (int t = 0; t <= nt && a + t <= curval; t++)
				for (int g = 0; g <= ng && a + t + g <= curval; g++) {
					int c = curval - a - t - g;
					
					if (a && can[i][A]) (dp[a - 1][t][g][c] += dp[a][t][g][c]) %= mod;
					if (t && can[i][T]) (dp[a][t - 1][g][c] += dp[a][t][g][c]) %= mod;
					if (g && can[i][G]) (dp[a][t][g - 1][c] += dp[a][t][g][c]) %= mod;
					if (c && can[i][C]) (dp[a][t][g][c - 1] += dp[a][t][g][c]) %= mod;
				}
	}
	
	cout << dp[0][0][0][0] << endl;
}



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

using namespace std;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define lson node<<1
#define rson (node<<1)+1

const int maxn=1e6+10;
const ll mod=1e9+7;
const double pi=acos(-1);

int main()
{
    ll n;
    sll(n);
    string ans="";
    while(n)
    {
        n--;
        ans=(char('a'+n%26))+ans;
        n/=26;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3652
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
vector < int  >  Prime;
void ListofPrime()
{
    bool prime[N];
    memset(prime , 1 , sizeof(prime));
    prime[0] = 0 , prime[1] = 0 ;
    for(int i = 2 ; i <= sqrt(N) ; i++)
    {
        if(prime[i])
        {
            for(int j = i * i ; j <= N ; j += i)
                prime[j] = 0;
        }
    }
    for(int i = 2 ; i < N ; i++ )
    {
        if(prime[i])
            Prime.pb(i);
    }
    
}

signed main(){
	SaveTime;
	int T=1;
	// cin >> T;
	ListofPrime();
	while(T--){
		int n;
		cin >> n ;
		cout << *lower_bound(all(Prime),n)<<endl;
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 2424
from math import gcd
N=int(input())
a,b,g=0,0,0
X=[]
zeroandzero=0
D=dict()
for i in range(N):
  a,b=map(int,input().split())
  if a==b==0:
    zeroandzero+=1
    N-=1
    continue
  g=gcd(a,b)
  a//=g
  b//=g
  if b<0:
    a,b=-a,-b
  D[(a,b)]=D.get((a,b),0)+1
E=dict()
K=list(D.keys())
mod=10**9+7
inv2=(mod+1)//2
P=pow(2,N,mod)
for i in range(len(K)):
  if E.get(K[i],0):
    continue
  g=list(K[i])
  if g[0]<0:
    g=(K[i][1],-K[i][0])
  else:
    g=(-K[i][1],K[i][0])
  E[g]=1
  g=(D[K[i]],D.get(g,0))
  if g[1]:
    P=P*pow(inv2,g[0]+g[1],mod)*(pow(2,g[0],mod)+pow(2,g[1],mod)-1)%mod
print((P-1+zeroandzero)%mod)

Measured memory_bytes: 155676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int goukei=0;
		int max = 0;
		for(int i=0;i<N;i++){
		  int po = sc.nextInt();
		  goukei = goukei+po;
		  if(max<po){
		    max = po;
		  }
		}
		goukei = goukei - (max/2);
		System.out.println(goukei);
	}
}


Measured memory_bytes: 21844
N=int(input())
import numpy as np
A=np.array(list(map(int,input().split())))
m=np.sum(A<0)
flag=np.any(A==0)
A=np.abs(A)
ans=np.sum(A)
if (m%2==1)and(not flag):
  x=np.min(A)
  ans-=x*2

print(ans)

Measured memory_bytes: 23320
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
char c[4010];
int a[4010];

int wk[2][4010][2010];
int dp[2010][2010];
int idx[2][2010];

int INF = 1<<29;

void init() {

}

void input() {
	cin >> n;
	REP(i, n*2) {
		cin >> c[i] >> a[i];
		idx[c[i]=='B'][a[i]] = i;
	}
}

void solve() {
	MSET(wk, 0);
	for (int i = 0; i <= a[0]; i++) wk[c[0]=='B'][0][i] = 1;
	for (int i = 1; i < n*2; i++) {
		for(int j = 0; j <= n; j++) {
			wk[0][i][j] = wk[0][i-1][j];
			wk[1][i][j] = wk[1][i-1][j];
		}
		for (int j = 0; j <= a[i]; j++) wk[c[i]=='B'][i][j]++;
	}

	REP(i, n*2) for(int j = 1; j <= n; j++){
		// OUT2(i, j);
		// OUT(wk[0][i][j]);
		// OUT(wk[1][i][j]);
	}

	REP(i, n+1) REP(j, n+1) dp[i][j] = INF;
	dp[0][0] = 0;
	REP(i, n+1) REP(j, n+1) {
		if (i==0 && j==0) continue;
		if (i > 0) {
			int id = idx[0][i];
			chmin(dp[i][j], dp[i-1][j] + wk[0][id][i]-1 + wk[1][id][j+1]);
		}
		if (j > 0) {
			int id = idx[1][j];
			chmin(dp[i][j], dp[i][j-1] + wk[1][id][j]-1 + wk[0][id][i+1]);
		}
			// OUT2(i,j);
			// OUT(dp[i][j]);
	}


	cout << dp[n][n] << endl;
}

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


Measured memory_bytes: 78976
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if(C>=A && C<=B){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}

	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<string, int> PAIR;

int main(){
	vector<PAIR> vec;
	vector<PAIR>::iterator ite;
	vector<PAIR>::iterator max;
	string st, siz;
	while(cin >> st){
		if(st == "0") break;
		if(vec.empty()){
			vec.push_back(PAIR(st, 1));
			//max = vec.begin();
			//siz = st;
		}else{
			ite = vec.begin();
			while(1){
				if((*ite).first == st){
					(*ite).second++;
					//if((*max).second < (*ite).second) max = ite;
					break;
				}
				ite++;
				if(ite == vec.end()){
					vec.push_back(PAIR(st, 1));
					//if(siz.size() < st.size()) siz = st;
					break;
				}
			}
		}

		ite = vec.begin();
		max = vec.begin();
		siz = (*ite).first;
		while(ite != vec.end()){
			if((*max).second < (*ite).second) max = ite;
			if(siz.size() < (*ite).first.size()) siz = (*ite).first;
			ite++;
		}


	}
		cout << (*max).first << " " << siz << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    int D;
    cin >> D;
    if(D == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    if(D == 23) {
        cout << "Christmas Eve Eve" << endl;
    }
    if(D == 24) {
        cout << "Christmas Eve" << endl;
    }
    if(D == 25) {
        cout << "Christmas" << endl;
    }
    return 0;
}

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

int n, w;
int value[100], weight[100], dp[110][10010];

int main(){
        scanf("%d %d", &n, &w);
        for(int i=0; i<n; i++) scanf("%d %d", &value[i], &weight[i]);

        memset(dp, 0, n*w);
        for(int i=0; i<n; i++){
                for(int j=0; j<=w; j++){
                        if(j<weight[i]) dp[i+1][j] = dp[i][j];
                        else dp[i+1][j] = std::max(dp[i][j], dp[i][j-weight[i]]+value[i]);
                }
        }
        printf("%d\n", dp[n][w]);
        return 0;
}


Measured memory_bytes: 7180
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0; i * 7 <= n; i++) {
    if((n - i * 7) % 4 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n, ga, gb, sa, sb, ba, bb, i, j, k, ans, cn,p;
	cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
	cn = n;
	for (i = 0; ga*i <= n; i++) {
		for (j = 0; ga*i + sa * j <= n; j++) {
			p = n;
			if (ga < gb)
				p += (gb - ga)*i;
			if (sa < sb)
				p += (sb - sa)*j;
			k = (n - ga * i - sa * j) / ba;
			if (ba < bb)
				p += (bb - ba)*k;
			cn = max(cn, p);
		}
	}
	ans = cn;
	if (ga < gb) {
		for (i = 0; sb*i <= cn; i++) {
			p = cn;
			j = (cn - sb * i) / bb;
			if (bb < ba)
				p += (ba - bb)*j;
			if (sb < sa)
				p += (sa - sb)*i;
			ans = max(ans, p);
		}
	}
	else if (sa < sb) {
		for (i = 0; gb*i <= cn; i++) {
			p = cn;
			j = (cn - gb * i) / bb;
			if (bb < ba)
				p += (ba - bb)*j;
			if (gb < ga)
				p += (ga - gb)*i;
			ans = max(ans, p);
		}
	}
	else if (ba < bb) {
		for (i = 0; sb*i <= cn; i++) {
			p = cn;
			j = (cn - sb * i) / gb;
			if (gb < ga)
				p += (ga - gb)*j;
			if (sb < sa)
				p += (sa - sb)*i;
			ans = max(ans, p);
		}
	}
	else {
		for (i = 0; gb*i <= cn; i++) {
			for (j = 0; gb*i + sb * j <= cn; j++) {
				p = cn;
				if (gb < ga)
					p += (ga - gb)*i;
				if (sb < sa)
					p += (sa - sb)*j;
				k = (n - gb * i - sb * j) / bb;
				if (bb < ba)
					p += (ba - bb)*k;
				ans = max(ans, p);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define inf 2000000000
using namespace std;

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}
typedef struct {
  int a;
  int b;
  int c;
} data;

// n,a,b
int dp[100][1005][1005] = {0};
int a, b, n;
data d[100];

int solve();

int main() {
  cin >> n >> a >> b;
  for(int i = 0; i < n; ++i)
    cin >> d[i].a >> d[i].b >> d[i].c;
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = inf, x = 1;
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < 1001; ++i)
      for(int j = 0; j < 1001; ++j) dp[k][i][j] = inf;
  dp[0][d[0].a][d[0].b] = d[0].c;
  for(int i = 1; i < n; ++i) {
    data now = d[i];
    dp[i][now.a][now.b] = now.c;
    for(int j = 0; j < 1001; ++j)
      for(int k = 0; k < 1001; ++k) {
        int nc = dp[i - 1][j][k];
        if(nc == inf) continue;
        dp[i][j][k] = min(nc, dp[i][j][k]);
        dp[i][j + now.a][k + now.b] =
            min(dp[i][j + now.a][k + now.b], nc + now.c);
      }
  }
  while(a * x <= 1000 && b * x <= 1000) {
    if(dp[n - 1][a * x][b * x] != inf)
      ans = min(ans, dp[n - 1][a * x][b * x]);
    ++x;
  }
  if(ans == inf)
    return -1;
  else
    return ans;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A >= 2 * B) {
		cout << A - 2 * B << endl;
	}
	else cout << '0' << endl;
	

	return 0;
}

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

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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
  ll ans=1;
     while(n>0){
       if(n&1) ans=(ans*x)%mod;
       x=(x*x)%mod;
       n/=2;
     }
     return ans;
}



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

  int T=1;
  //cin >> T;
  while(T--){
    ll n;
    cin>>n;
    ll x,y;

    ll ans=(n*(n+1)*(n+2))/6;
    rep(i,n-1){
      cin>>x>>y;
      ans-=(min(x,y)*(n+1-max(x,y)));
    }
    
    cout<<ans<<el;
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

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

  FOR(i,x,200000){
    if(IsPrime(i)){
      ANS(i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
 
fn read_spc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    hina_arare();
}

fn hina_arare() {
    let n: i64 = read();
    let mut s: Vec<String> = read_spc();
    s.sort();
    s.dedup();
    let l = Vec::len(&s);
    if l == 3 {
        println!("Three");
    } else {
        println!("Four");
    }
}

Measured memory_bytes: 4352
import java.util.*;

// UVa 11504

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		if (a == b + c || b == a + c || c == a + b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 20948
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  string s,ans;
  cin>>s;
  for(int i=0;i<s.size();i+=2)ans+=s[i];
  cout<<ans<<endl;
}

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		ll a, v, b, w, t;
		cin >> a >> v >> b >> w >> t;
		
		if(a < b){
			ll bmax = b + w * t;
			ll amax = a + v * t;
			if(amax >= bmax)cout << "YES";
			else cout << "NO";
		}
		else{
			ll bmin = b - w * t;
			ll amin = a - v * t;
			if(amin <= bmin)cout << "YES";
			else cout << "NO";
		}
	}
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        int r;
        cin >> r;
        vector<vector<int>> li, lo;
        rep(i, r){
            vector<int> v(4);
            cin >> v[2] >> v[0] >> v[1] >> v[3];
            if(v[3] == 1) li.push_back(v);
            else  lo.push_back(v);
        }
        sort(li.begin(), li.end());
        sort(lo.begin(), lo.end());
        int o;
        cin >> o;
        rep(i, o){
            int s, e, m;
            cin >> s >> e >> m;
            bool b[2000];
            fill(b, b+2000, false);
            for(int i=0; i< li.size(); i++){
                if(li[i][1] == m){
                    for(int j=li[i][2]; j <= lo[i][2]; j++) b[j] = true;
                }
            }
            int ret = 0;
            for(int i=s; i <= e; i++){
                if(b[i]) ret++;
                if(b[i]&&(!b[i+1] || i == e))ret--;
            }
            cout << ret << endl;
        }
    }
}

Measured memory_bytes: 1280
function Main(input) {
    lines = input.split("\n")[0].split(" ")
    r = lines[0]
    g = lines[1]
    b = lines[2]
    n = lines[3]
    rn = gn = 0;
    ans = 0
    while(n - r * rn >= 0) {
        gn = 0
        while((n - r * rn) - g * gn >= 0) {
          if (((n - r * rn) - g * gn) % b == 0) {
            ans++
          }
          gn++
        }
        rn++
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
a, b = (int(i) for i in input().split())

if a >= b:
    c = a
    a = a - 1
else:
    c = b
    b = b - 1

if a >= b:
    c += a
    a = a - 1
else:
    c += b
    b = b - 1
    
print(c)

Measured memory_bytes: 3060
import math

def get_primes(m):
    if m == 2: return [2]
    elif m < 3: return []
     
    N = [0]+range(3, m + 2, 2)
    nroot = math.floor(m ** 0.5)
    n = len(N)
    for i in range(1, n):
        x = N[i]
        if x > nroot: break
        if x and i + x < n:
            for j in range(i+x, n, x):
                N[j] = 0
    x=[2] + filter(None, N[1:])
    return x

n=10000
primes=get_primes(50100)
while True:
    try: n=input()
    except: break

    for a in primes:
        if a<n: b=a
        elif a>n: break
    print b,a

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

static const int MAX_NUM = 25;
static const int NOELEM  = -1;

struct stNode {
    int parent;
    int left;
    int right;
};

void Preoder(stNode elem[], int root)
{
    if (root != NOELEM) {
        printf(" %d", root);
        Preoder(elem, elem[root].left);
        Preoder(elem, elem[root].right);
    }
    return;
}

void Inoder(stNode elem[], int root)
{
    if (root != NOELEM) {
        Inoder(elem, elem[root].left);
        printf(" %d", root);
        Inoder(elem, elem[root].right);
    }
    return;
}

void Postoder(stNode elem[], int root)
{
    if (root != NOELEM) {
        Postoder(elem, elem[root].left);
        Postoder(elem, elem[root].right);
        printf(" %d", root);
    }
    return;
}

int main(void)
{
    int i;
    int num;
    int key;
    int left, right;
    stNode elem[MAX_NUM];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        elem[i].parent = NOELEM;
        elem[i].left   = NOELEM;
        elem[i].right  = NOELEM;
    }

    for (i = 0; i < num; i++) {
        scanf("%d %d %d", &key, &left, &right);
        elem[key].left  = left;
        elem[key].right = right;
        elem[left].parent  = key;
        elem[right].parent = key;
    }

    for (i = 0; i < num; i++) {
        if (elem[i].parent == NOELEM) {
            key = i;
            break;
        }
    }

    printf("Preorder\n");
    Preoder(elem, key);
    printf("\n");

    printf("Inorder\n");
    Inoder(elem, key);
    printf("\n");

    printf("Postorder\n");
    Postoder(elem, key);
    printf("\n");

    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<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>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define 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 };

int main() {
  int n, i, j, k;
  cin >> n;
  vector<vii> f(n, vii(5, vi(2)));
  for (i = 0; i < n; i++) {
    for (j = 0; j < 5; j++) {
      for (k = 0; k < 2; k++) {
	cin >> f[i][j][k];
      }
    }
  }
  vii p(n, vi(11));
  for (i = 0; i < n; i++) {
    for (j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }
  int ans = -inf;
  for (int m = 1; m < 1024; m++) {
    int res = 0;
    for (i = 0; i < n; i++) {
      int cnt = 0;
      for (j = 0; j < 5; j++) {
	for (k = 0; k < 2; k++) {
	  int jun = j*2 + k;
	  if ((m & (1 << jun)) && f[i][j][k]) {
	    cnt++;
	  }
	}
      }
      res += p[i][cnt];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}

/*
1
1 1 0 1 0 0 0 1 0 1
3 4 5 6 7 8 9 -2 -3 4 -2

2
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1

3
1 1 1 1 1 1 0 0 1 1
0 1 0 1 1 1 1 0 1 0
1 0 1 1 0 1 0 1 0 1
-8 6 -2 -8 -8 4 8 7 -6 2 2
-9 2 0 1 7 -5 0 -2 -6 5 5
6 -6 7 -9 6 -5 8 0 -9 -7 -7

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	bool flag = false;
	while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
	if(ch == '-'){
		flag = true;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	if(flag) x = -x;
}
int L, R, n;
inline int sum(int L, int R){return (R - L + 1) * (L + R) >> 1;}
int main(){
	read(n); read(L);
	R = L + n - 1;
	if(L >= 0) printf("%d\n", sum(L + 1, R));
	else if(L < 0 && R > 0) printf("%d\n", sum(L, R));
	else if(R <= 0) printf("%d\n", sum(L, R - 1));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> streats;

    int a, b;
    for (auto i = 0; i < M; ++i) {
        cin >> a >> b;
        streats.push_back(make_pair(a, b));
    }

    vector<int> cnts(N);

    for (auto i = 0; i < streats.size(); ++i) {
        cnts[streats[i].first-1]++;
        cnts[streats[i].second-1]++;
    }

    for (auto i = 0; i < cnts.size(); ++i) {
        cout << cnts[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
        int xMax = w;
        int yMax = h;
        int xMin = 0;
        int yMin = 0;
        for(int i = 0; i < n; i++) {
          int x = sc.nextInt();
          int y = sc.nextInt();
          int a = sc.nextInt();
          switch (a) {
            case 1:
              if (x > xMin) {
                xMin = x;
              }
              break;
            case 2:
              if (x < xMax) {
                xMax = x;
              }
              break;
            case 3:
              if (y > yMin) {
                yMin = y;
              }
              break;
            case 4:
              if (y < yMax) {
                yMax = y;
              }
              break;
          }
        }
        w = xMax < xMin ? 0 : xMax - xMin;
        h = yMax < yMin ? 0 : yMax - yMin;
    
		// 出力
		System.out.println(w * h);
	}
}

Measured memory_bytes: 22228