akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll x1, yy, x2, y2, x3, y3, x4, y4, dy, dx;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x1 >> yy >> x2 >> y2;
    dy = abs(y2 - yy), dx = abs(x2 - x1);
    if(yy > y2 && x1 >= x2){
        x3 = x2 + dy, y3 = y2 - dx;
        x4 = x1 + dy, y4 = yy - dx;
    }
    else if(x2 > x1 && yy >= y2){
        x3 = x2 + dy, y3 = y2 + dx;
        x4 = x1 + dy, y4 = yy + dx;
    }
    else if(y2 > yy && x2 >= x1){
        x3 = x2 - dy, y3 = y2 + dx;
        x4 = x1 - dy, y4 = yy + dx;
    }
    else if(x1 > x2 && y2 >= yy){
        x3 = x2 - dy, y3 = y2 - dx;
        x4 = x1 - dy, y4 = yy - dx;
    }
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4;
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import heapq
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L1=[]
for i in range(n):
  L1.append((l[i][0]-l[i][2],1,l[i][2]))
  L1.append((l[i][1]-l[i][2],-1,l[i][2]))
for i in range(q):
  L1.append((int(input()),2,0))
L1.sort()
L2=[]
heapq.heapify(L2)
L3=[]
L3=set(L3)
for i in range(len(L1)):
  if L1[i][1]==1:
    heapq.heappush(L2,L1[i][2])
    L3.add(L1[i][2])
  elif L1[i][1]==-1:
    L3.remove(L1[i][2])
  else:
    while L2 and L2[0] not in L3:
      heapq.heappop(L2)
    if L2:
      print(L2[0])
    else:
      print(-1)

Measured memory_bytes: 127196
from sys import stdin


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    nums = [0] * (N + 1)

    ng = -1
    for i, b in enumerate(B):
        ok = N
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if C[mid] > b:
                ok = mid
            else:
                ng = mid

        nums[i] = N - ok

    for i in range(N, 0, -1):
        nums[i - 1] += nums[i]

    ans = 0
    ng = -1
    for a in A:
        ok = N
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if B[mid] > a:
                ok = mid
            else:
                ng = mid

        ans += nums[ok]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23924
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))


s = input()

dfs(0, s[0], int(s[0]))

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

int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    if(A>=K){
        A -= K;
    }else if(B>=K-A){
        B -= K-A;
        A = 0;
    }else{
        A = 0;
        B = 0;
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = set()
w = str(input())
s.add(w)
for i in range(n-1):
    w_2 =str(input())
    if w[-1] != w_2[0]:
        print("No")
        exit()
    s.add(w_2)
    w = w_2
if len(s) == n:
    print("Yes")
else:
    print("No")

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

int main(){
  	string S;
  	cin >> S;
  	int n = S.size() - 1;
  	int num = 0;
  	for(int i = 0;i<S.size() / 2;i++){
      if(S.at(i) == S.at(n - i)){
        
      }else{
       num++;
        S.at(i) = S.at(n - i);
      }
    }
  	cout << num << endl;
	return 0;  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

#ifdef LOCAL
#include "local.h"
#endif

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

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

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


int main()
{
    int h, w;
    cin >> h >> w;
    int a[64][64], b[64][64];
    rep(y, h) rep(x, w)
        cin >> a[y][x];
    rep(y, h) rep(x, w)
        cin >> b[y][x];

    int ch, cw;
    int c[64][64];
    cin >> ch >> cw;
    rep(y, ch) rep(x, cw)
        cin >> c[y][x];

    const int inf = ten(9);
    int res = -inf;
    rep(sy, h - ch + 1) rep(sx, w - cw + 1)
    {
        int s = 0;
        bool ok = true;
        rep(y, ch) rep(x, cw)
        {
            ok &= c[y][x] == b[sy + y][sx + x];
            s += a[sy + y][sx + x];
        }
        if (ok)
            upmax(res, s);
    }
    if (res == -inf)
        cout << "NA" << endl;
    else
        cout << res << endl;
}


Measured memory_bytes: 1200
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
int solve(vi v)
{
    vi t=v;
    sort(t);
    int x=0;
    while(true)
    {
        x++;
        if(t==v)
        {
            return x;
        }
        next_permutation(all(t));
    }
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int n;
    cin>>n;
    vi a(n),b(n);
    f(i,n)cin>>a[i];
    f(i,n)cin>>b[i];
    int ans=abs(solve(a)-solve(b));
    print(ans)
}


Measured memory_bytes: 256
import sys
N, M = map(int, input().split())

ans = [-1] * (N + 1)  # not evaluated yet

for line in sys.stdin:
    ans[int(line)] = 0  # unreachable

ans[0] = 1  # reachable

if ans[1]:
    ans[1] = 1

for i in range(2, N + 1):
    if ans[i]:
        ans[i] = ans[i - 1] + ans[i - 2]

print(ans[N] % 1000000007)


Measured memory_bytes: 460020
#include<stdio.h>

int n, A[50];

//入力値のMから選んだ要素を引いていく再帰関数
int solve (int i, int m) {
    if ( m == 0 ) return 1;
    if ( i >= n ) return 0;
//i番目以降の要素を使ってmを作れる場合trueを返す
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]); //部分問題に分割。m-A[i]で「i番目の要素を使う」
    return res;
}

int main() {
    int q, M, i;

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


Measured memory_bytes: 2132
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		System.out.println(solve(s));
	}

	public static int solve(String s) {
		int result = 0;
		for (int j = 1; j < s.length(); j++)
			if (s.charAt(j) != s.charAt(j - 1))
				result++;
		return result;
	}

}



Measured memory_bytes: 11560
function main(input){
  var line1 = input[0].split(' ');
  var n = line1[0];
  var h = parseInt(line1[1]);
  var w = parseInt(line1[2]);
 
  var ans = 0;
  for (var i=1; i<input.length; i++){
    var line = input[i].split(' ');
    var a = parseInt(line[0]);
    var b = parseInt(line[1]);
    
    if (a>=h && b>=w) 
      ans ++;
  }

  console.log(ans);
}


function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 21192
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int n,k;
cin>>n>>k;
vector<int> h(n);
rep(i,n) cin>>h[i];
sort(h.begin(),h.end());//文字を小さい順に並べ替える
k=min(n,k);
rep(i,k)
h.pop_back();//後ろからK個削除
ll ans=0;
rep(i,h.size()) ans+=h[i];
cout<<ans<<endl;
return 0;
}




Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;

typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;

typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

const int maxn = 10+5;

int seq[maxn];
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	rep(i,10)
		tin(seq[i]);
	sort(seq,seq+10);
	_loop(i,10,7)
		printf("%d\n",seq[i]);
	return 0;
}  

Measured memory_bytes: 1204
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  int n;
  scanf("%d", &n);
  char c[n];
  scanf("%s", c);
  int r=0;
  int w=0;
  int i;
  for(i=0; i<n; i++){
    if(c[i] == 'W'){
      w++;
    }else{
      r++;
    }
  }
  int ans=0;
  for(i=0; i<=(r-1); i++){
    if(c[i]=='W'){
      ans++;
    }
  }
  if(w==0){
    printf("0\n");
    return 0;
  }else{
    printf("%d\n", ans);
    return 0;
  }
  
  return 0;
}

Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;

struct ClosestPair{
  typedef double T;
  typedef pair<T, T> P;
  const T TMAX = FLT_MAX;
  static bool compY(P a, P b){
    return a.second < b.second;
  }
  /////////////////////////////
  T _solve(P *a, int n){
    if(n <= 1) return TMAX;
    int m = n/2;
    T x = a[m].first, d = min(_solve(a, m), _solve(a+m, n-m));
    inplace_merge(a, a+m, a+n, compY);
    vector<P> b;
    FOR(i, 0, n){
      if(x<=a[i].first-d || a[i].first+d <= x) continue;
      int bs = b.size();
      FOR(j, 0, bs){
        T dx = a[i].first  - b[bs-j-1].first, dy = a[i].second - b[bs-j-1].second;
        if(dy >= d) break;
        d = min(d, sqrt(dx*dx + dy*dy));
      }
      b.push_back(a[i]);
    }
    return d;
  }
  T solve(P *a, int n){
    sort(a, a+n);
    return _solve(a, n);
  }
} cp;

int m;
pair<double, double> p[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> m;
  FOR(i, 0, m){
    double x, y;
    cin >> x >> y;
    p[i] = mp(x, y);
  }
  dout(cp.solve(p, m));
}


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

int main() {
  int N;
  cin >> N;
  
  bool ok = false;
  for (int i = 0; i <= N; i++)
    for (int j = 0; j <= N; j++)
	  	if (i * 4 + j * 7 == N) ok = true;
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
num=list(map(int, input().split()))
a=list(map(int, input().split()))
ok=[]
for i in range(len(a)):
  if a[i]>=sum(a)/(4*num[1]):
  	ok.append(a[i])
if len(ok)>=num[1]:
  print("Yes")
else:
  print("No")
#print(ok)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using std::min;

long long abs(long long a)
{
	return a>=0? a:-a;
}

const int SIZE = 200000+10;
long long A[SIZE];

int main (void)
{
	int N;
	long long sum=0;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%lld",A+i);
		sum += A[i];
	}
	
	long long MIN = 100000000000000000;
	long long now = 0;
	for(int i=0;i<N-1;i++){
		now += A[i];
		MIN = min( MIN , abs(  (now) - (sum-now) ) );
	}
	printf("%lld\n",MIN);
	
	return 0;
}







Measured memory_bytes: 1664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, k := nextInt(), nextInt(), nextInt()

	if a > b {
		a, b = b, a
	}

	c := 0
	for i := a; i >= 1; i-- {
		if a % i == 0 && b % i == 0 {
			c++
		}
		if c == k {
			fmt.Println(i)
			return
		}
	}
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> cnt(5);

    rep(i, N) {
        string T; cin >> T;
        if (T[0] == 'M') cnt[0]++;
        else if (T[0] == 'A') cnt[1]++;
        else if (T[0] == 'R') cnt[2]++;
        else if (T[0] == 'C') cnt[3]++;
        else if (T[0] == 'H') cnt[4]++;
    }

    int ans = 0;
    ans += cnt[0] * cnt[1] * cnt[2];
    ans += cnt[0] * cnt[1] * cnt[3];
    ans += cnt[0] * cnt[1] * cnt[4];
    ans += cnt[0] * cnt[2] * cnt[3];
    ans += cnt[0] * cnt[2] * cnt[4];
    ans += cnt[0] * cnt[3] * cnt[4];
    ans += cnt[1] * cnt[2] * cnt[3];
    ans += cnt[1] * cnt[2] * cnt[4];
    ans += cnt[1] * cnt[3] * cnt[4];
    ans += cnt[2] * cnt[3] * cnt[4];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
fi = x-1
aa = [1]
bb = [1]
a = 1
b = 1
for i in range(50):
    a = a*2 + 3
    b = b*2 + 1
    aa.append(a)
    bb.append(b)
    
def bu(lv , x):
    if lv == 0:
        return 1
    
    l = aa[lv-1]
    num = bb[lv-1]
    
    if x == 1:
        return 0
    elif x <= l+1:
        return bu(lv-1,x-1)
    elif x == l+2:
        return num +1
    elif x <= (l+1) * 2:
        return num + 1 + bu(lv-1,x-l-2)
    else:
        return num*2 + 1
    
print(bu(n,x))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FI(n) for(int i = 0; i < n; ++i)
#define FJ(n) for(int j = 0; j < n; ++j)
#define INT_MAX 2147483647
#define l first
#define r second
#define mp make_pair
#define pb push_back
using namespace std;
ofstream coutf;
ifstream cinf;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD=1000000007;
int solve()
{
    string s;
    cin>>s;
    int j=0;
    FI(s.length())
    {
        if(s[i]=='1') j++;
    }
    cout<<j;

    return 0;
}
int main()
{

    coutf.open("output.txt");
    cinf.open("input.txt");
    solve();
    cinf.close();
    coutf.close();
    return 0;
}


Measured memory_bytes: 256
x = input().split()

a = int(x[0])
b = int(x[1])
c = int(x[2])
k = int(x[3])

if(a > k): # a > k
  print(k)
  exit()
elif(a == k):
  print(a)
  exit()
elif(a+ b > k):  # k > a 
  print(a)
  exit()
elif(k-a == b):
  print(a)
  exit()
else:
  x = k - a - b
  print(a-x)
  exit()
  
  

Measured memory_bytes: 61900
import java.util.Scanner;
import java.util.*;
public class Main {
	
	
	
	public static int Frog1(int n, int h[]) {
		int dp[] = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1]-h[0]);
		
		for(int i=2;i<n;i++) {
			int op1 = Math.abs(h[i] - h[i-1]) + dp[i-1];
			int op2 = Math.abs(h[i] - h[i-2]) + dp[i-2];
			dp[i] = Math.min(op1, op2);
		}
		
		return dp[n-1];
	}
    
    public static void main(String[] arg) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int h[] = new int[n];
        for(int i=0;i<n;i++) {
        	h[i] = s.nextInt();
        }
        System.out.println(Frog1(n,h));
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> ans;
    if(n == 1) return ans;
    for(ll i = 2; i*i <= n; i++){
        int cnt = 0;
        while(n%i == 0){
            cnt++;
            n /= i;
        }
        if(cnt) ans.eb(i, cnt);
    }
    if(n != 1) ans.eb(n, 1);
    return ans;
}

vector<pair<ll, int>> unite(vector<pair<ll, int>> a, vector<pair<ll, int>> b){
    vector<pair<ll, int>> ans = a;
    bool ok;
    for(auto [p2, e2] : b){
        ok = false;
        for(auto & [p1, e1] : ans){
            if(p1 == p2) {
                e1 += e2;
                ok = true;
                break;
            }
        }
        if(!ok) ans.eb(p2, e2);
    }
    sort(all(ans));
    return ans;
}

vector<pair<ll, int>> subt(vector<pair<ll, int>> a, vector<pair<ll, int>> b){
    for(auto & [p, e] : b) {
        e *= -1;
    }
    return unite(a, b);
}

void Main(){
    int n; cin >> n;
    vector<pair<ll, int>> ndata;
    rep3(i, 1, n){
        auto tmp = factorize(i);
        ndata = unite(ndata, tmp);
    }
    
    vvi num = {{74}, {24, 2}, {14, 4}, {4, 4, 2}};
    vi c(5, 0);
    
    for(auto [p, e] : ndata){
        // cout << p << " " << e << endl;
        if(e >= 74) c[0]++;
        if(e >= 24) c[1]++;
        if(e >= 14) c[2]++;
        if(e >= 4) c[3]++;
        if(e >= 2) c[4]++;
    }
    
    // rep(i, 5) cout << c[i] << endl;
    
    ll ans = c[0];
    ans += c[1] * (c[4] - 1);
    ans += c[2] * (c[3] - 1);
    ans += c[3] * (c[3] - 1) * (c[4] - 2) / 2;
    
    cout << ans << endl;
    
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

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

    if (s == t.substr(0, t.length() - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
s = int(input())
a = s
A = []
A.append(s)
count = 0

while True:
  count += 1
  if a % 2 == 0:
    a = a/2
  else:
    a = 3*a + 1
  if a in A:
    break
  A.append(a)
  
print(count+1)

Measured memory_bytes: 9124
#include <stdio.h>
#include <stdlib.h>

// #define MAX_LEN_S (27)
#define MAX_LEN_S (100000)

int ans_a, ans_b;
int find_unbalanced(char *s, int b, int e) {
  int cntl[26] = {}, cntr[26] = {};
  int m = (b + e) / 2;
  if (e - b < 2)  // must be longer than 2
    return 0;
  // search for unbalanced including s[m - 1] and s[m]
  // reach to the left
  cntl[s[m] - 'a']++;
  for (int i = m - 1; i >= b; i--) {
    cntl[s[i] - 'a']++;
    for (int j = 0; j < 26; j++) {
      if (2 * cntl[j] > m - i + 1) {  // over half
        ans_a = i; ans_b = m;
        return 1;
      }
    }
  }
  // reach to the right
  cntr[s[m - 1] - 'a']++;
  for (int i = m; i < e; i++) {
    cntr[s[i] - 'a']++;
    for (int j = 0; j < 26; j++) {
      if (2 * cntr[j] > i - m + 2) {  // over half
        ans_a = m - 1; ans_b = i;
        return 1;
      }
    }    
  }
  // search left half and right half independently
  return find_unbalanced(s, b, m) || find_unbalanced(s, m, e);
}

int main(int argc, char *argv[]) {
  int len = 0;
  char s[MAX_LEN_S];
  for (int c = fgetc(stdin); c >= 'a' && c <= 'z'; c = fgetc(stdin))
    s[len++] = c;
  // printf("len = %d, s = %s\n", len, s);
  if (find_unbalanced(s, 0, len))
    printf("%d %d\n", ans_a + 1, ans_b + 1);
  else
    printf("-1 -1\n");
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program{
  static void Main(string[] args){
    int n=int.Parse(Console.ReadLine());
    string[] tmp=Console.ReadLine().Split(' ');
    int[] l=new int[n];
    for(int i=0;i<n;i++){l[i]=int.Parse(tmp[i]);}
    Array.Sort(l);
    int s=0;
    for(int i=0;i<n-1;i++){s+=l[i];}
    Console.WriteLine(l[n-1]<s?"Yes":"No");
  }
}

Measured memory_bytes: 11092
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;
	a = (a + 12) % 14;
	b = (b + 12) % 14;
	cout << (a == b ? "Draw" : (a > b ? "Alice" : "Bob")) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    print(max(map(len,re.findall('[ACGT]*', S))))


if __name__ == '__main__':
    main()


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int M=100006;
int f[M],inv[M];
int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M){
        f[i]=(1LL*i*f[i-1])%hell;
    }
    inv[M-1]=expo(f[M-1],hell-2,hell);
    for(int i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%hell;
    }
}
int C(int n,int r){
    if(n<r) return 0;
    return (1LL*((1LL*f[n]*inv[r])%hell)*inv[n-r])%hell;
}
int n,k;
void solve(){
    compute();
    cin>>n>>k;
    rep(i,1,k+1) cout<<C(n-k+1,i)*C(k-1,i-1)%hell<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
vector <int> g[100004];
int juv[100004];
int col[100004],qu;
void bfs(int s1,int d1,int c1){
	queue <pair<int,int> > q;
	q.push(make_pair(s1,0)); 
	while (!q.empty()){
		pair<int,int> x=q.front();
		q.pop();
		if (x.second!=d1 && d1-x.second<=juv[x.first]) continue;
		else juv[x.first]=d1-x.second;
		if (col[x.first]>0);
		else col[x.first]=c1;
		if (x.second>=d1) continue;
		else for (int i=0;i<g[x.first].size();i++)
			q.push(make_pair(g[x.first][i],x.second+1));  
	}
}
int s[100004],d[100004],c[100004];
int main(){
	memset (col,0,sizeof(col)); 
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cin>>q;
	for (int i=0;i<q;i++) cin>>s[i]>>d[i]>>c[i];
	reverse (s,s+q);
	reverse (d,d+q);
	reverse (c,c+q);
	for (int i=0;i<q;i++) bfs (s[i],d[i],c[i]);
	for (int i=1;i<=n;i++) cout<<col[i]<<endl;
	return 0;
}

Measured memory_bytes: 8952
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadLongArray(N);

            var ans = A[0];
            for (int i = 1; i < N; i++)
            {
                ans = gcd(ans, A[i]);
                if (ans == 1)
                {
                    break;
                }
            }
            Console.WriteLine(ans);
        }

        static long gcd(long a, long b)
        {
            return a == 0 ? b : gcd(b % a, a);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 20832
import sys
input = sys.stdin.readline
#str 注意
def main():
    n,k = map(int,input().split())
    d = [x for x in input().split()]
    d = set(d)

    while 1:
        if len(set(list(str(n))) & d)==0:
            print(n)
            exit()
        else:
            n +=1

if __name__=='__main__':
    main()

Measured memory_bytes: 40684
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        long x = sc.nextLong();
        int c = 1;
        while (true) {
            long l = (c+1)*c/2;
            if (l>=x) {
                System.out.println(c);
                break;
            }
            c++;
        }
    }
}


Measured memory_bytes: 22740
def stack
  arr = gets.chomp.split(" ")
  stack = []

  arr.each do |val|
    if val.match(/\d/)
      stack.push(val)
    else
      val1 = stack.pop.to_i
      val2 = stack.pop.to_i
      temp = if val == "*"
        val1 * val2
      elsif val == "-"
        val2 - val1
      else val == "+"
        val1 + val2
      end
      stack.push(temp)
    end
  end
  stack[0]
end

p stack

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

int main(){
int n;cin >>n;
vector<int> l(n);for(int i=0;i<n;i++)cin >>l[i];  
sort(l.begin(),l.end());
string ans;
  if (accumulate(l.begin(),l.end(),0)>l[n-1]*2)ans="Yes";
  else ans="No";
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int s, w;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> w;
	if(w >= s) cout << "unsafe\n";
	else cout << "safe\n";
	return 0;
}

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

int main() {
  int N;
  string S;
  bool color = false;
  
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y"){
      color = true;
    }
  }
  
  if (color){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

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

void dfs(int i, int sum, string s, string eq){
    if(i==4){
        if (sum == 7){
            cout << eq;
            cout << "=" <<sum<< endl;
            exit(0);
        }
        return;
    }

    string eq2 = eq + '+'+ s[i];
    int sum2 = sum + (s[i] - '0');
    dfs(i+1, sum2, s, eq2);
    
    eq2 = eq + '-' + s[i];
    sum2 = sum - (s[i] - '0');
    dfs(i+1, sum2, s, eq2);

    return;
}

int main()
{
    string s;
    cin >> s;
    string eq;
    eq += s[0];
    int sum = s[0] - '0';
    dfs(1, sum, s, eq);


   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;cin >> s;
  int ans=0;
  for(int i=0;i<s.size()-1;++i){
    if(s.at(i)!=s.at(i+1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
 
int main() {
 
  int g,f,e,d,c,b,a;
 
  string num[10] ;
  num[0] = "0111111";
  num[1] = "0000110";
  num[2] = "1011011";
  num[3] = "1001111";
  num[4] = "1100110";
  num[5] = "1101101";
  num[6] = "1111101";
  num[7] = "0100111";
  num[8] = "1111111";
  num[9] = "1101111";
 
  string ima,mae;
  mae.resize(7);
  ima.resize(7);
 
 
  int qu;
  while(1) {
  cin >> qu;
  if(qu == -1) break;
  for(int i=0;i<7;i++) ima[i] = '0';
  int n = 0;
  for(int j=0;j<qu;j++) {
    cin >> n;
     
 
    for(int i=0;i<7;i++) {
      if(num[n][i] != ima[i]) ima[i] = '1';
      else ima[i] = '0';
    }
    
    for(int i=0;i<7;i++) cout << ima[i];
    cout << endl;
    ima = num[n];
  }
  }
  return 0;
 
 
 
}
 

Measured memory_bytes: 1208
#include<iostream>
#include<cmath>

using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x, ullong n, ullong M){
  ullong tmp = 1;

  if ( n > 0 ){
    tmp = power(x, n/2, M);
    if ( n%2 == 0 ) tmp = (tmp*tmp)%M;
    else tmp = (((tmp*tmp)%M)*x)%M;
  }
  return tmp;
}

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

  cout << power(m, n, 1000000007) << endl;

  return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n,k;
  cin >> n >> k;

  vector<int> h(n);
  REP(i,n) cin >> h[i];
  
  sort(h.begin(),h.end(),less<>());

  int H = 0;

  REP(i,n-k){
    H += h[i];
  }

  cout << H << endl;

  return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

void divisor(ll n, set<ll>& ret) {
    for(ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.insert(i);
            if (i * i != n) ret.insert(n/i);
        }
    }
}

int solve(ll N) {
    if (N == 2) {
//        print(1);
        return 1;
    }

    ll ans = 0;

    set<ll> a;
    divisor(N - 1, a);
    a.insert(N - 1);
    ans += a.size();

    set<ll> b;
    divisor(N, b);
    b.insert(N);

    debug(a, b)

    for(auto e: b) {
        ll n = N;
        while(n % e == 0) n /= e;

        if (n % e == 1) ans++;
    }

    return ans;
}

void naive(int N, vll& ret) {
    FOR(i, 2, N + 1) {
        int n = N;

        while(n % i == 0) n /= i;

        if(n % i == 1) ret.pb(i);
    }
}

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

    ll N;
    cin >> N;

    print(solve(N));

}


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

using namespace std;

using int64 = long long;

int main() {
  int N, X[101], Y[101], H[101];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> H[i];

  for(int i = 0; i < 101; i++) {
    for(int j = 0; j < 101; j++) {
      vector< int > cand;
      for(int k = 0; k < N; k++) {
        int dist = abs(i - X[k]) + abs(j - Y[k]);
        cand.emplace_back(H[k] + dist);
      }
      for(auto &HH : cand) {
        bool ok = true;
        for(int k = 0; k < N; k++) {
          int dist = abs(i - X[k]) + abs(j - Y[k]);
          if(max(HH - dist, 0) != H[k]) ok = false;
        }
        if(ok) {
          cout << i << " " << j << " " << HH << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 A, V, B, W, T;
  std::cin >> A >> V >> B >> W >> T;
  std::cout << (V > W && tools::ceil(std::abs(A - B), V - W) <= T ? "YES" : "NO") << std::endl;
  return 0;
}

Measured memory_bytes: 3600
N, M = map(int, input().split())
PY = [0]*M

for m in range(M):
    PY[m] = [m] + list(map(int, input().split())) + [0] 
    
PY.sort(key = lambda x:x[2])
PY.sort(key = lambda x:x[1])

counter = 1 
for m in range(M):
    if m == 0:
        PY[m][3] = '000001'
    elif PY[m][1] == PY[m-1][1]:
        counter += 1
        l = len(str(counter))
        PY[m][3] = '0'*(6-l)+str(counter)
    else:
        PY[m][3] = '000001'
        counter = 1
        
PY.sort(key = lambda x:x[0])
for m in range(M):
    k = len(str(PY[m][1]))
    print('0'*(6-k)+str(PY[m][1])+str(PY[m][3]))

Measured memory_bytes: 37612
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    class P
    {
        public int key;
        public List<int> ad;
        public Dictionary<int, int> weights;
        public int Weight;
        public P Parent;
        public P(int key)
        {
            this.key = key;
            ad = new List<int>();
            weights = new Dictionary<int, int>();
        }
    }
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var gr = new P[num];
        for (var i = 0; i < num; i++)
            gr[i] = new P(i);
        for(var i = 0; i < num; i++)
        {
            var inp = Array.ConvertAll(ReadLine().Trim().Split(' '), int.Parse);
            for (var j = 1; j <=inp[1]; j++)
            {
                gr[i].ad.Add(inp[2 * j]);
                gr[i].weights[inp[2 * j]] = inp[2 * j + 1];
            }
        }
        for (var i = 0; i < num; i++)
            gr[i].Weight = int.MaxValue;
        gr[0].Weight = 0;
        var set = new HashSet<int>();
        while (true)
        {
            var minVal = int.MaxValue;
            var u = new P(-1);
            for(var i = 0; i < num; i++)
            {
                if (!set.Contains(i) && minVal > gr[i].Weight)
                {
                    minVal = gr[i].Weight;
                    u = gr[i];
                }
            }
            if (minVal == int.MaxValue) break;
            set.Add(u.key);

            foreach (var ad in u.ad)
            {
                if (!set.Contains(ad) && gr[ad].Weight > u.Weight+u.weights[ad])
                {
                    gr[ad].Weight = u.weights[ad]+u.Weight;
                }
            }
        }
        for (var i = 0; i < num; i++)
            WriteLine($"{i} {gr[i].Weight}");
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 18744
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string S,T;
  cin>>S>>T;
  if(S.size()!=T.size()-1){
 
cout<<"No"<<endl;
  }
  
  for(int i=0;i<S.size();i++){
if(S.at(i)==T.at(i)){
  continue;
}
    else{
cout<<"No"<<endl;
      return 0;
    }
    
  }
cout<<"Yes"<<endl;
}

    

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<string>
#include<vector>
#include<functional>

using namespace std;

const double EPS=1e-12;
const double INF=1e12;

typedef complex<double>Point;

namespace std{
    bool operator<(const Point &P,const Point &Q){
        return real(P)!=real(Q)?real(P)<real(Q):imag(P)<imag(Q);
    }
}

double dot(const Point &P,const Point &Q){
    return real(P)*real(Q)+imag(P)*imag(Q);
}

double cross(const Point &P,const Point &Q){
    return real(P)*imag(Q)-real(Q)*imag(P);
}

struct Line{
    Point a,b;
    Line(Point P,Point Q){
        a=P;b=Q;
    }
    Line(){}
};

struct Segment{
    Point a,b;
    Segment(Point P,Point Q){
        a=P;b=Q;
    }
    Segment(){}
};

struct Circle{
    Point c;
    double r;
    Circle(Point P,double l){
        c=P;r=l;
    }
};

typedef vector<Point>Polygon;

int ccw(Point A,Point B,Point C){
    B-=A;C-=A;
    if(cross(B,C)>0)return 1; //ccw
    if(cross(B,C)<0)return -1; //cw
    if(dot(B,C)<0)return 2; //c-b-a
    if(norm(B)<norm(C))return -2; //a-b-c
    return 0; //a-c-b
}
inline bool Parallelism(const Line &L,const Line &M){
    return fabs(cross(L.a-L.b,M.a-M.b))<EPS;
}

inline bool Parallelism(const Segment &S,const Segment &T){
    return fabs(cross(S.a-S.b,T.a-T.b))<EPS;
}

inline bool intersect(const Line &L,const Line &M){
    return cross(L.a-L.b,M.a-M.b)>EPS ||cross(L.a-L.b,M.a-M.b)<-EPS;
}

inline bool intersect(const Line &L,const Segment &S){
    return cross(L.b-L.a,S.a-L.a)*cross(L.b-L.a,S.b-L.a)<-EPS;
}

inline bool intersect(const Line &L,const Point &P){
    return abs(ccw(L.a,L.b,P))!=1;
}

inline bool intersect(const Segment &S, const Segment &T){
    return ccw(S.a,S.b,T.a)*ccw(S.a,S.b,T.b)<=0&&
        ccw(T.a,T.b,S.a)*ccw(T.a,T.b,S.b) <= 0;
}

inline bool intersect(const Segment &S,const Point &P){
    return ccw(S.a,S.b,P)==0;
}

inline bool intersect(const Circle &C,const Point &P){
    return abs(C.c-P)<=C.r+EPS;
}

inline bool intersect(const Circle &C,const Circle &D){
    return abs(C.c-D.c)<=C.r+D.r&&abs(C.c-D.c)>=fabs(C.r-D.r);
}

inline Point crossPoint(const Line &L,const Line &M){

}
double areaTriangle(Point A,Point B,Point C){
    B-=A;C-=A;
    return fabs(cross(B,C))*0.5;
}

double areaPolygon(Polygon &g){
    const int Sz=g.size();
    if(Sz<3)return 0;
    if(Sz==3)return areaTriangle(g[0],g[1],g[2]);

    double res=cross(g[Sz-1],g[0]);
    for(int i=1;i<Sz;i++)res+=cross(g[i-1],g[i]);

    return fabs(res)*0.5;
}



int main(){
    int N;
    Line L,M;
    cin>>N;
    while(N--){
        cin>>L.a.real()>>L.a.imag()>>L.b.real()>>L.b.imag();
        cin>>M.a.real()>>M.a.imag()>>M.b.real()>>M.b.imag();
        if(Parallelism(L,M))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll x,y;
	cin>>x>>y;
	if(x==1||y==1){
		cout << 1;
		return 0;
	}
	cout << ((x*y)-1+2)/2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256