akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
//~ int const MOD = 1e9 + 7;
int const MOD = 998244353;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  string s; cin >> s;
  if (s == "SUN") kek(7);
  if (s == "MON") kek(6);
  if (s == "TUE") kek(5);
  if (s == "WED") kek(4);
  if (s == "THU") kek(3);
  if (s == "FRI") kek(2);
  if (s == "SAT") kek(1);
  
  return 0;
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
ans = []

ac = [0]*(len(S)+1)
last = ''
for i in range(len(S)):
    s = S[i]
    if s=='C' and last == 'A':
        ac[i-1] = 1
    last = s

add = [0]*(len(S)+2)
for i in range(len(ac)):
    add[i+1] = add[i] + ac[i]

for j in range(Q):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    sub = add[r] - add[l]
    ans.append(sub)

for a in ans:
    print(a)
    
    


Measured memory_bytes: 59608
#include <algorithm>
#include <iostream>
#include <tuple>

int main() {
  using u64 = unsigned long long;

  int n;
  std::cin >> n;

  u64 ans = 0;
  for (int i = 0; i != n; ++i) {
    ans += u64(i + 1) * (n - i);
  }
  for (int i = 0; i != n - 1; ++i) {
    int u, v;
    std::cin >> u >> v;
    --u;
    --v;
    std::tie(u, v) = std::minmax({u, v});
    ans -= u64(u + 1) * (n - v);
  }

  std::cout << ans << std::endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using std::cin;
using std::cout;
using std::endl;

int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0;i--) fact *= i;
  return fact;
}


void count_order()
{
  int n;
  cin >> n;

  std::vector<int> p(n);
  std::vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];


  int p_cnt = 0, q_cnt = 0;
  for (int i = 0; i < n; i++)
  {
    p_cnt += (p[i]-1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (p[j] > p[i]) p[j]--;
    }
  }
  for (int i = 0; i < n; i++)
  {
    q_cnt += (q[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (q[j] > q[i]) q[j]--;
    }
  }
  cout << std::abs(p_cnt - q_cnt);
}


void welcome_atcoder()
{
  int n, m;
  cin >> n >> m;
  int pena = 0;
  std::vector<int> ac(n + 1, 0);//インデックスを無理やりpに合わせた
  std::vector<int> wa(n + 1, 0);

  for (int i = 0; i < m; i++) 
  {
    int p; 
    std::string s;
    cin >> p >> s;

    if (s == "WA") wa[p]++;
    if (ac[p] == 1) continue;
    if (ac[p] == 0 && s == "AC")
    {
      ac[p] = 1;
      pena += wa[p];
    }
  }

  int ans = 0;
  for (int i = 0; i < n + 1; i++) if (ac[i] == 1) ans++;
  cout << ans << " " << pena << endl;
}


void low_elements()
{
  int n;
  cin >> n;
  std::vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i]; 
  int min = 1000000;
  int cnt = 0;

  for (int i = 0; i < n; i++)
  {
    if (p[i] < min)
    {
      cnt++;
      min = p[i];
    }
  }
  cout << cnt << endl;
}


void fennec_vs_monster()
{
  int n, k;
  cin >> n >> k;
  std::vector<long> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  std::sort(h.begin(), h.end());
  long long int sum = 0;
  for (int i = 0; i < n - k; i++) sum += h[i];
  cout << sum << endl;
}


void distinct_or_not()
{
  int n;
  cin >> n;
  std::set<int> A;

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

    auto itr = A.find(a);
    if (itr != A.end() && *itr == a)
    {
      cout << "NO" << endl;
      return;
    }
    else A.insert(a);
  }
  cout << "YES" << endl;
}
int main() 
{
  //count_order();
  //welcome_atcoder();
  //low_elements();
  //fennec_vs_monster();
  distinct_or_not();
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2009;
vector< int >forbidden;
int a[MAXN];

int getX(int n, int k, int q) {
    vector< int >w;
    for (int i = 1; i < forbidden.size(); i++) {
        int len = forbidden[i]-forbidden[i-1]-k;
//        cout << "(" << forbidden[i-1] << "," << forbidden[i] << ")" << endl;
        if (len <= 0) continue;
        vector< int >v;
        for (int j = forbidden[i-1]+1; j < forbidden[i]; j++) v.push_back(a[j]);
        sort(v.begin(), v.end());
        for (int j = 0; j < len; j++) {
//            cout << "got " << v[j] << endl;
            w.push_back(v[j]);
        }
    }

    if (w.size() < q) return -1;
    sort(w.begin(), w.end());
    return w[q-1];
}

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    vector< int >v(n);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        v[i-1] = a[i];
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int ans = v.back()-v.front();

    forbidden.push_back(0);
    forbidden.push_back(n+1);

    for (int y : v) {
//        cout << "with " << y << endl;
        int x = getX(n, k, q);
        if (x != -1) ans = min(ans, x-y);

        for (int i = 1; i <= n; i++) {
            if (a[i]==y) forbidden.push_back(i);
        }
        sort(forbidden.begin(), forbidden.end());
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>


int vet[6], invert[6];

int olhaso(int k) {
	int n = k, t;
	for(int i = 0; i < 5; ++i) {
		t = n % 10;
		n = n/10;
		vet[4-i] = t;
		invert[i] = t;
	}
	for(int i = 0; i < 5; ++i) {
		if(vet[i] != invert[i])
			return 0;
	}
	return 1;
}

int main() {
	 int a, b, quant_pali = 0;
	 scanf("%d %d", &a, &b);
	 for(int i = a; i <= b; ++i) {
	 	if(olhaso(i))
	 		++quant_pali;
	 }
	 printf("%d\n", quant_pali);
	return 0;
}


Measured memory_bytes: 128
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, M = map(int, input().split())
    if N*M == 0:
        return False
    P = [0]+[int(input()) for _ in range(N)]
    # solve
    k = [P[i]+P[j] for i in range(N) for j in range(i, N)]
    k = sorted(k)

    ret = 0
    for tmp in k:
        if tmp > M:
            break
        else:
            r = M-tmp
            l = bisect.bisect_right(k, r)
            if l >= len(k):
                tmp += k[-1]
            elif l != 0:
                tmp += k[l-1]
            ret = max(ret, tmp)
    return ret


ans = []
while True:
    ret = solve()
    if ret:
        ans.append(ret)
    else:
        break
print("\n".join(map(str, ans)))



Measured memory_bytes: 31984
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<28;
 
typedef long long lli;
 
struct Edge {
  int v, w;
};
 
typedef vector<vector<Edge> > Graph;
 
vector<int> bfs(int src, const Graph &g) {
  const int n = g.size();
  vector<int> cost(n, INF);
  queue<int> que;
  cost[src] = 0;
  que.push(src);
  while(que.size()) {
    const int v = que.front();
    que.pop();
    for(int i = 0; i < g[v].size(); ++i) {
      int nv = g[v][i].v;
      if(cost[nv] != INF) continue;
      cost[nv] = cost[v] + 1;
      que.push(nv);
    }
  }
  return cost;
}
 
int main() {
  for(int N, M, s, t; cin >> N >> M >> s >> t; ) {
    --s; --t;
    Graph G(N);
    for(int i = 0; i < M; ++i) {
      int x, y; cin >> x >> y;
      --x; --y;
      G[x].push_back((Edge){y, 1});
      G[y].push_back((Edge){x, 1});
    }
    vector<int> cs = bfs(s, G);
    vector<int> ct = bfs(t, G);
    int mini = cs[t];
    sort(ct.begin(), ct.end());
    lli res = 0;
    for(int i = 0; i < N; ++i) {
      if(cs[i] == INF) continue;
      int target = mini - 2 - cs[i];
      res += upper_bound(ct.begin(), ct.end(), target)
        - lower_bound(ct.begin(), ct.end(), target);
    }
    cout << res << endl;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  string S;
  string ans="Three";
  
  for(int i=0; i < N; i++ ){
    cin >> S;
    if(S=="Y"){
      ans = "Four";
    }
  }

  cout << ans << endl;
}


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

int top, S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
 top--;
	return S[top+1];


}


int main(){
	int a,b;
	top = 0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		
		}
	}

	printf("%d\n",pop());
	return 0;
	
}





Measured memory_bytes: 2144
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)

for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]

print(ans)

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

int main() {
  int A, B, ans;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+')
    ans = A + B;
  else if (op == '-')
    ans = A - B;
  
  cout << ans << endl;

}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

ll read_long() {
    ll ans = 0;
    char c;
    bool started = false;
    bool is_negative = false;
    while (true) {
        c = getchar();
        if ((c < '0' || c > '9') && c != '-' && !started) continue;
        if ((c < '0' || c > '9') && c != '-' && started) break;
        if (started) {
            ans = ans * 10;
        }
        started = true;
        if (c == '-') is_negative = true;
        else ans += c - '0';
    }
    if (is_negative) ans *= -1;
    return ans;
}

string s;

int main(){

    cin >> s;

    if (s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
    else {
        if (s.size() < 26) {
            char c = 'a';
            while (true) {
                int pos = 0;
                while (pos < sz(s) && s[pos] != c) pos++;
                if (pos == sz(s)) break;
                c++;
            }
            s += c;
            cout << s << endl;
            return 0;
        }
        for (int len = 1; len <= 26; len++) {
            string t = "";
            for (int i = sz(s) - len; i < sz(s); i++) t += s[i];
            string cur = t;
            sort(all(cur));
            reverse(all(cur));
            if (cur == t) continue;
            int pos = -1;
            for (int i = 1; i < sz(t); i++) {
                if (t[i] > t[0]) {
                    if (pos == -1) pos = i;
                    else if (t[pos] > t[i]) pos = i;
                }
            }
            string ans = "";
            for (int i = 0; i < sz(s) - len; i++) ans += s[i];
            ans += t[pos];
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
//abc174_e.cpp
//Sat Sep 12 10:55:08 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	ll n,k;
	cin >> n >> k;

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

	sort(a,a+n,greater<ll>());

	if (k==0){
		cout << a[0] << endl;
		return 0;
	}

	ll ok = 1e9+1;
	ll ng = 0;
	while(abs(ok-ng)>1){
		ll mid = (ok+ng)/2;
		ll tmp = 0;
		int flag = 1;
		rep(i,n){
			if (a[i]>mid){
				ll cut = a[i]/mid;
				cut++;
				while(cut*mid>=a[i]){
					cut--;
				}
				// cout << a[i] << " " << mid << " " << cut << endl;
				tmp+=cut;
			}
			if (tmp>k){
				flag = 0;
				break;
			}
		}
		if(flag){
			ok = mid;
		}else {
			ng = mid;
		}
	}

	cout << ok << endl;
//	printf("%.4f\n",ans);
}

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

int main(void){
	long n, i;
	long a = LONG_MAX;
	scanf("%ld", &n);
	for(i=0; i<5; i++){
		long A;
		scanf("%ld", &A);
		if(A<a) a=A;
	}
	printf("%ld\n", (n+a-1)/a+4);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, K;
    cin>>N>>K;
    ll conne[300000], foot[300000];
    rep(i, N){
        foot[i]=-1;
        ll A;
        cin>>A;
        conne[i]=A-1;
    }
    ll index=0;
    foot[0]=0;
    ll d;
    while(true){
        K--;
        ll next=conne[index];
        //cout<<K<<next<<endl;
        if(K==0){
            cout<<next+1<<endl;
            return 0;
        }
        //cout<<K<<sp<<next+1<<endl;
        if(foot[next]!=-1){
            d=foot[index]+1-foot[next];
            index=next;
            break;
        }
        foot[next]=foot[index]+1;
        index=next;
    }
    K%=d;
    rep(i, K){
        ll next=conne[index];
        index=next;
    }
    cout<<index+1<<endl;
    return 0;
}

Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int x=9; x>0; --x){
		if(n%x!=0) continue;
		int y = n/x;
		if(x<10 and y<10){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int w,h,n;
  cin >> w >> h >> n;
  int left=0,right=w,down=0,up=h;
  int x[n],y[n],a[n];
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i] >> a[i];
    if(a[i]==1){
      left=max(left,x[i]);
    }
    else if(a[i]==2){
      right=min(right,x[i]);
    }
    else if(a[i]==3){
      down=max(down,y[i]);
    }
    else{
      up=min(up,y[i]);
    }
  }
  if((up-down)<0 || (right-left)<0) cout << 0 << endl;
  else cout << (up-down)*(right-left) << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define MAXN 200010
#define inf 1e18

using namespace std;

inline int read(int &T) {
    int s = 0, f = 0;
    char ch = getchar();
    while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
    while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
    return T = f ? -s : s;
}

void print(int x) {
    if (x < 0) x = -x, putchar('-');
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int n;

signed main() {
    n = read(n);
    n = n % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) puts("hon");
    if (n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
    if (n == 3) puts("bon");
}   

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<vector<int>>f(n,vector<int>(10)),p(n,vector<int>(11));
	for(auto&&i:f)for(auto&&j:i)cin>>j; for(auto&&i:p)for(auto&&j:i)cin>>j;
	int ans=-1e9;
	for(int i=0;i<(1<<10)-1;++i){
		vector<int>c(n,0);
		for(int j=0;j<10;++j){
			if(i&(1<<j))continue;
			for(int k=0;k<n;++k){
				c.at(k)+=f.at(k).at(j);
			}
		}
		int tans=0;
		for(int j=0;j<n;++j){
			tans+=p.at(j).at(c.at(j));
		}
		ans=max(ans,tans);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,d; cin >> n >> d;
  d = d*2+1;
  int ans = (n+d-1)/d;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,m,x; cin>>n>>m>>x;
    int ans = m;
    int cost = 0;
    for (int i = 0; i < m; i++) {
        int a; cin >> a;
        if (a < x)
        {
            cost++;
        } else {
            ans = min(cost,m-i);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
c = [list(map(int,input().split())) for i in range(3)]
b = [c[0][0] - 0,c[0][1] - 0,c[0][2] - 0]
a = [c[0][0] - b[0],c[1][0] - b[0],c[2][0] - b[0]]

for i in range(3):
    for j in range(3):
        if a[i] + b[j] != c[i][j]:
            print('No')
            exit(0)

print('Yes')

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int i = 0;
	while(a>0 and c>0)
	{
		if(i%2)
		a-=d;
		if(i%2==0)
			c-=b;
		i++;
		// cout<<a<<" "<<c<<endl;
	}
	// cout<<a<<" "<<c<<endl;
	if(a<=0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

	// if(b/a)
	// if(a+b>=c+d) cout<<"Yes"<<endl;
	// else cout<<"No"<<endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e16
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 103;
ll i,j,k,c,tot,m,n;
ll a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n) cin>>a[i];
    while(1){
        c = 0;
        rep(i,0,n) if(a[i] > 0)
            c += 1;
        if(c == 0)
            break;
        rep(i,0,n){
            j = i;
            m = MAX;
            while(j < n && a[j] > 0){
                m = min(m,a[j]);
                j += 1;
            }
            
            rep(k,i,j)
                a[k] -= m;
            if(j > i)
                tot += m;
            i = j;
        }
    }
    cout<<tot;
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  ll x = 1;
  FOR(i,1,n+1)(x*=i)%=MOD;
  cout<<x<<endl;
  return 0;
}


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

int cnt;
int m, num;
int cards[7][2];

void calc(int point, int sum) {
	for(int i=0; i<=cards[point][1]; i++) {
		int temp = sum;
		temp += cards[point][0]*i;
		if(temp == num) {
			cnt++;
			return;
		}
		else {
			if(point != m-1)
				calc(point+1, temp);
		}
	}
}

int main() {
	while(1) {
		cin >> m;
		if(m==0) break;

		for(int i=0; i<m; i++)
			cin >> cards[i][0] >> cards[i][1];

		int g;
		cin >> g;
		for(int i=0; i<g; i++) {
			cnt = 0;
			cin >> num;
			calc(0, 0);
			cout << cnt << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, q = ril()
s = rs()
acc = [0] * n
for i in range(1, n):
    if s[i - 1:i + 1] == 'AC':
        acc[i] = acc[i - 1] + 1
    else:
        acc[i] = acc[i - 1]
for _ in range(q):
    l, r = ril()
    print(acc[r - 1] - acc[l - 1])

Measured memory_bytes: 6436
#include<iostream>
#include<vector>
using namespace std;
#define int long long int
int count=0;
int answer=0;
void function(vector<int> &v,int initial,int final,int prev,int m,int arr[][4],int q)
{
	if(initial>final)
	{
		count++;
		int here=0;
		int j;
		for(j=0;j<q;j++)
		{
			int a=arr[j][0]-1;
			int b=arr[j][1]-1;
			int c=arr[j][2];
			int d=arr[j][3];
			if(v[b]-v[a]==c)
			{
				here+=d;
			}
		}
		answer=max(answer,here);
	}
	else
	{
		int j;
		for(j=prev;j<=m;j++)
		{
			v.push_back(j);
			function(v,initial+1,final,j,m,arr,q);
			v.pop_back();
		}
	}
}
int32_t main()
{
	int n,m,q;
	cin>>n>>m>>q;
	int arr[q][4];
	int j;
	for(j=0;j<q;j++)
	{
		for(int i=0;i<4;i++)
		   cin>>arr[j][i];
	}
	for(j=1;j<=m;j++)
	{
		vector<int> v;
		v.push_back(j);
		function(v,1,n-1,j,m,arr,q);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3608
a,b = list(map(int,input().split()))
s =input()
for i in range(a+b+1):
    if i == a:
        if s[i] !='-':
            print('No')
            break
    else:
        if s[i]=='-':
            print("No")
            break
            
        else:
            if int(s[i])<0 or 9<int(s[i]):
                print("No")
                break
else:
    print('Yes')

Measured memory_bytes: 9180
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \
 
*/
 
#import<bits/stdc++.h>
typedef long long ll;
#define num 10000000
#define root 10000
#define forll(i,a,b,c) for(int i=a; i<=b; i+=c)
#define forll2(i,a,b,c) for(int i=a; i>=b; i-=c)
#define pb(n) push_back(n)
 
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  int a,x=0;
  forll(i,0,n-1,1)
  {
    cin>>a;
    if((i+1)%2==1 && a%2==1) x++;
  }
  cout<<x<<"\n";
}

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

using namespace std;

int main() {
    int n, m, *k, **s, *p;   cin >> n >> m;
    k = new int[m];
    s = new int*[m];
    p = new int[m];
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        s[i] = new int[k[i]];
        for (int j = 0; j < k[i]; j++)
            cin >> s[i][j];
    }

    int ans = 0;

    for (int i = 0; i < m; i++)
        cin >> p[i];

    for (int bit = 0; bit < (1<<n); bit++) {
        vector<int> v;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i))
                v.push_back(i);
        }

        vector<int> cnt(n, 0);

        for (int i = 0; i < v.size(); i++) {
            cnt[v[i]] = 1;
        }

        bool can = true;

        for (int i = 0; i < m; i++) {
            int tmp = 0;
            for (int j = 0; j < k[i]; j++) {
                if (cnt[s[i][j]-1])
                    tmp++;
            }
            if (tmp % 2 != p[i])
                can = false;
        }

        if (can)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
M = 2**15+1
isPrime = [True]*M
isPrime[0],isPrime[1]=False,False
for i in xrange(M):
    if isPrime[i]:
        for j in xrange(i*i,M,i):
            isPrime[j] = False
while 1:
    n = input()
    if n==0: break
    ans = 0
    for i in xrange(2,n/2+1):
        if isPrime[i] and isPrime[n-i]: ans+=1
    print ans

Measured memory_bytes: 4472
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
x,y=0,10**9
while y>x+1:
    m = (x+y)//2
    c=0
    for i in l:
        c+=(i-1)//m
    if c<=k:
        y=m
    else:
        x=m
print(y)

Measured memory_bytes: 103968
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  double v[50];
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v,v+N);
  double sum=v[0];
  for(int i=1;i<N;i++){
    sum=(sum+v[i])/2;
  }
  printf("%.6lf\n",sum);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
ll n,a;
cin>>a>>n;
ll k;
string ans="No";
for(ll i=0;i<n;i++)
{
cin>>k;
a-=k;
if(a<=0)
{
ans="Yes";
break;
}
}
cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100,vector<ll>(3,0));
int main(){
  ll n;
  cin >> n;
  ll sum = 0;
  ll len;
  string str;
  REP(i,1,n+1){
    str = to_string(i);
    len = str.size();
    // cout << len << " ";
    if(len % 2 == 1){
      sum++;
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

bool is_palindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = is_palindrome(s);
  ok &= is_palindrome(s.substr(0, (n - 1) / 2));
  ok &= is_palindrome(s.substr((n + 2) / 2));
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans,x;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
       cin>>x;
        if(x<=k/2)
            ans+=x*2;
        else
            ans+=(k-x)*2;
    }
    cout<<ans;
} 

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

using namespace std;
#define ll long long
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int inf = 5000000 + 7;
const ll linf  = 1ll * inf * inf;
const int N = 100000 + 7;
const int M = 10000 + 7;
const int multipleTest = 0;
const double pi = acos(-1);

int n;
int a[N];
int b[N];
vector<int> uniq;

class FenWickTree{
public:
	static const int MAXN = 200000 + 7;
	static const int MID = MAXN / 2;
	int L[MAXN];
	
	void update(int x, int val) {
		x += MID;
		for (int t = x; t < MAXN; t += t & -t) L[t] += val;
	}
	
	int get(int x) {
		x += MID;
		int res = 0;
		for (int t = x; t > 0; t -= t & -t) {
			res += L[t];
		}
		return res;
	}
} fenwickTree;


ll check(int x) {
	for (int i = 0; i < n; ++i) b[i] = (a[i] >= x) ? 1 : -1;
	for (int i = 1; i < n; ++i) b[i] += b[i - 1];
	
	fenwickTree.update(0, 1);
	ll cnt = 0;
	for (int i = 0; i < n; ++i) {
		cnt += fenwickTree.get(-b[i] - 1);
		fenwickTree.update(-b[i], 1);
	}
	
	fenwickTree.update(0, -1);
	for (int i = 0; i < n; ++i) fenwickTree.update(-b[i], -1);
	
	return cnt;
}

void solve() {
	cin >> n;
	uniq.resize(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		uniq[i] = a[i];
	}
	sort(uniq.begin(), uniq.end());
	uniq.erase(unique(uniq.begin(), uniq.end()), uniq.end());
	
	int lo = 0, hi = uniq.size() - 1, res = uniq[0];
	const ll M = 1ll * n * (n + 1) / 2;
	const ll cnt = (M + 2) / 2;
	
	while (lo <= hi) {
		int mid = (lo + hi) >> 1;
		if (check(uniq[mid]) < cnt) {
			res = uniq[mid];
			lo = mid + 1;
		} else hi = mid - 1;
	}
	
	cout << res << '\n';
}

int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//	freopen("out.txt", "w", stdout);
#endif
	int Test = 1;
	if (multipleTest) {
		cin >> Test;
	}
	
	for(int i = 0; i < Test; ++i) {
		//		printf("Case #%d: ", i + 1);
		solve();
	}
#ifdef _LOCAL_
	cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 1792
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

int main(){
    ll x;
    in>>x;
    out<<1000*(x/500)+5*(x%500/5);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>0&&b>0)
	cout<<"Positive"<<endl;
	if(a<0&&b>0||a>0&&b<0)
	cout<<"Zero"<<endl;
	if(a<0&&b<0&&(-a+b)%2!=0)
	cout<<"Positive"<<endl;
	if(a<0&&b<0&&(-a+b)%2==0)
	cout<<"Negative"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
typedef long long LL;
const int Pt = 1e9 + 7;
using namespace std;

LL n , m;
int main()
{
	while(~scanf("%lld%lld" , &n , &m)){
		LL ans = 1;
		if(abs(n - m) > 1) printf("0\n");
		else if(n == m) {
			for(LL i = 1;i <= n;i++) ans = ans * i % Pt;
			ans = 2LL * ans * ans % Pt;
			printf("%lld\n" , ans);
		}
		else {
			for(LL i = 1;i <= n;i++) ans = ans * i % Pt;
			for(LL i = 1;i <= m;i++) ans = ans * i % Pt;
			printf("%lld\n" , ans);
		}
	}
}

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

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

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

int main(void){
  int N, AC, WA, TLE, RE;
  
  AC=WA=TLE=RE=0;
  
  string s;
  cin >> N;
  rep(i, N){
    cin >> s;
    if(s == "AC") AC++;
    else if(s == "WA") WA++;
    else if(s == "TLE") TLE++;
    else if(s == "RE") RE++;
    else cout << "error" << endl;
  }
    
    cout << "AC" << " x " << AC << endl;
    cout << "WA" << " x " << WA << endl;
    cout << "TLE" << " x " << TLE << endl;
    cout << "RE" << " x " << RE << endl;
  return 0; 
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

  int n; cin >> n;
	vector<int> v(n); for(int& x : v) cin >> x;

	int a, b;
	a = abs(v[0] - v[1]);
	if(n <= 2) b = a;
	else 
		b = min(abs(v[0] - v[2]), a + abs(v[1] - v[2]));
	for(int i = 3; i < n; i++){
		int t = min(a + abs(v[i] - v[i-2]), b + abs(v[i] - v[i-1]));
		a = b;
		b = t;
	}

	cout << b;


	#ifdef LOCAL
	cerr << "\n";
	#endif
	return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using ll = long long;
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n,b;cin >> n;
  vector<int> a(n,0);
  rep(i,n){
    cin >> b;
    a[b-1]=i+1;
  }
  rep(i,n-1){cout << a[i] << " ";}
  cout << a[n-1] << endl;
}

Measured memory_bytes: 1152
//It is made by Awson on 2018.3.17
#include <bits/stdc++.h>
using namespace std;
const int N = 100;

int n, a[N+5], b[N+5], c[N+5], d[N+5];
struct tt {int to, next; }edge[N*N+5];
int path[N+5], top;
int vis[N+5], match[N+5]; 

bool dfs(int u, int color) {
    for (int i = path[u]; i; i = edge[i].next)
	if (vis[edge[i].to] != color) {
	    vis[edge[i].to] = color;
	    if (match[edge[i].to] == 0 || dfs(match[edge[i].to], color)) {
		match[edge[i].to] = u; return true;
	    }
	}
    return false;
}
int max_match() {
    int tot = 0;
    for (int i = 1; i <= n; i++)
	if (dfs(i, i)) ++tot;
    return tot;
}
void add(int u, int v) {edge[++top].to = v, edge[top].next = path[u], path[u] = top; }
void work() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
	for (int i = 1; i <= n; i++) scanf("%d%d", &c[i], &d[i]);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (a[i] < c[j] && b[i] < d[j]) add(i, j);
	printf("%d\n", max_match());
}
int main() {work(); return 0; }

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

struct D{
    int id;
    LL d;
    LL val;
    D(int id,LL d,LL val = -1):id(id),d(d),val(val){;}
    bool operator<(const D &o) const{
        return d < o.d;
    }
};

struct C{
    int s,t,x;
    C(int s,int t,int x):s(s),t(t),x(x){;}
    bool operator<(const C &o) {
        return x < o.x;
    }
};

struct Cmp{
    bool operator()(const D &a,const D &b){
        return a.id < b.id;
    }

};

const int maxn = 2e5+5;


LL L[maxn];
LL R[maxn];
LL x[maxn];
vector<C> input;

set<D> mp;

int main()
{
    int N,Q;
    cin >> N >> Q;
    _for(i,0,N){
        LL s,t,x;
        scanf("%lld %lld %lld",&s,&t,&x);
        input.push_back(C(s,t,x));
    }
    sort(ALL(input));
    _for(i,0,N){
        x[i] = input[i].x;
        L[i] = input[i].s - input[i].x - 1;
        R[i] = input[i].t - input[i].x - 1;
    }


    _for(i,0,Q){
        LL d;
        scanf("%lld",&d);
        mp.insert(D(i,d,-1));
    }

    vector<D> ans;

    _for(i,0,N){
        LL lef = L[i];
        LL righ = R[i];
        auto it = mp.upper_bound(D(0,lef,-1));
        auto ed = mp.upper_bound(D(0,righ,-1));
        while(it != ed){
            D kk = *it;
            kk.val = x[i];
            ans.push_back(kk);
            it = mp.erase(it);
        }
    }
    for(auto a : mp){
        ans.push_back(a);
    }
    sort(ALL(ans),Cmp());

    _for(i,0,ans.size()){
        cout << ans[i].val << endl;
    }

    return 0;
}

Measured memory_bytes: 27504
#include <stdio.h>

static int n;
static int A[20];

int solve(int p, int t)
{
    int a, b;
    if(t == 0) {
        return 1;
    }
    if(p >= n) {
        return 0;
    }
    if(solve(p+1, t-A[p]) == 1) {
        return 1;
    }
    if(solve(p+1, t) == 1) {
        return 1;
    }
    return 0;
}

int main()
{
    int q;
    int m;

    int i, j, k;
    int pattern;
    int sum;
    int flag;
    int max;

    scanf("%d", &n);
    pattern = 1 << n;
    max = 0;
    for(i = 0; i < n; i++) {
        scanf("%d", &A[i]);
        max += A[i];
    }

    scanf("%d", &q);
    for(i = 0; i < q; i++) {
        scanf("%d", &m);

        if(solve(0, m) == 1) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2108
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, W; std::cin >> N >> W;
	std::vector<Int> w(N), v(N);
	rep(i, N)std::cin >> w[i] >> v[i];

	std::vector<std::array<Int, (Int)1e5 + 1000>> dp(N + 1);
	rep(i, N + 1)rep(j, (Int)1e5 + 1000) {
		dp[i][j] = INF;
	}
	dp[0][0] = 0;

	rep(i, N) {
		rep(j, (Int)1e5 + 1000) {
			if (j - v[i] >= 0) {
				dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			}
			dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j]);
		}
	}

	Int ans = 0;
	rep(j, (Int)1e5 + 1000) {
		if (dp[N][j] <= W)ans = j;
	}

	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 80768
x, y = map(int, input().split())

ans = 2* (10 **9)

if y - (-x) >= 0:
    ans = y + x + 1

if -y -x >= 0:
    ans = min(ans, -y -x + 1)

if -y - (-x) >= 0:
    ans = min(ans, -y +x +2)

if y - x >= 0:
    ans = min(ans, y-x)

print(ans)

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long fac(long long n){
	long long ret = 1;
	for(long long i = 1; i<=n; i++){
		ret*=i;
		ret%=mod;
	}
	return ret;
}
long long ferma(long long n,long long r){
	if(r==0) return (long long)1;
	if(r==1) return n;
	long long ret = ferma(n,r/2);
	ret*=ret;
	ret%=mod;
	if(r%2) ret*=n;
	return ret%mod;
}
int main(){
	long long x,y;
	cin>>x>>y;
	if(x<y) swap(x,y);
	if(x>2*y) cout<<0;
	else if(x==2*y) cout<<1;
	else{
		long long one = 0;
		while(x!=y){
			one++;
			x-=2;
			y--;
		}
		if(x%3) cout<<0;
		else{
			one+=x/3;
			long long two = x/3;
			long long a = fac(one)*fac(two);
			a = ferma(a%mod,mod-2);
			cout<<(fac(one+two)*a)%mod;
		}
	}
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int num[20000];
int pr[100];

int is_prime(int n)
{
    int m=sqrt(n+0.5);
    for(int i=2; i<=m; i++)
        if(n%i==0)
            return 0;
    return 1;
} 

int main()
{
    int cnt=0;
    for(int i=3; i<55555; i++)  //判断素数
        if(is_prime(i))
            num[cnt++]=i;
    int k=0;
    for(int i=0; i<cnt; i++)  //记录位数
    {
        if((num[i]-1)%5==0)
            pr[k++]=num[i];
        if(k==60)
            break;
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        if(i!=0)
            cout << ' ';
        cout << pr[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    d1_0, d2_0 = -1, -2
    d1_1, d2_1 = -1, -2
    d1_2, d2_2 = -1, -2
    for i in range(n):
        d1_2, d2_2 = d1_1, d2_1
        d1_1, d2_1 = d1_0, d2_0
        d1_0, d2_0 = map(int,input().split())
        if d1_0 == d2_0 and d1_1 == d2_1 and d1_2 == d2_2:
            print("Yes")
            sys.exit()
    print("No")

if __name__=='__main__':
    main()

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  bool ans = true;
  if(a <= 0&&b >= 0)
  {
    fin("Zero") exit(0);
  }
  if(b < 0)
  {
    if((abs(b - a) + 1) % 2 == 1)
    {
      fin("Negative") exit(0);
    }
  }
  fin("Positive")
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N],b[N];
struct edge{
	int x,y;
}e[N];
bool cmp(edge a,edge b){
	if(a.x!=b.x)return a.x<b.x;
	return a.y<b.y;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)swap(x,y);
		e[i].x=x;e[i].y=y;
	}
	
	if(a[e[0].x]<a[e[0].y])b[e[0].x]=true;
	else if(a[e[0].x]>a[e[0].y])b[e[0].y]=true;
	else {
		b[e[0].x]=true;b[e[0].y]=true;
	}
	for(int i=1;i<m;i++){
		if(e[i].x==e[i-1].x && e[i].y==e[i-1].y){
			b[e[i].x]=true;b[e[i].y]=true;
		}
		else {
			if(a[e[i].x]<a[e[i].y])b[e[i].x]=true;
			else if(a[e[i].x]>a[e[i].y])b[e[i].y]=true;
			else {
				b[e[i].x]=true;b[e[i].y]=true;
			}
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++){
		if(b[i]==false)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5220