akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int N;
  cin >> N;
  vector<int> d(N);
  REP(i, N) cin >> d[i];
  SORT(d);
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

int main() {
  int l;
  cin>>l;
  int a,b,c,d;
  a=l/1000;
  l%=1000;
  b=l/100;
  l%=100;
  c=l/10;
  l%=10;
  d=l;
  if(a+b+c+d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a-b+c+d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a+b-c+d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a+b+c-d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a-b-c+d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a-b+c-d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a+b-c-d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
    return 0;
  }
  if(a-b-c-d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7<<endl;
    return 0;
  }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
int N, M;
char A[51][51], B[51][51];
bool valid(int offX, int offY) {
	for (int y=0; y<M; y++) {
		for (int x=0; x<M; x++) {
			if (A[offX+x][offY+y] != B[x][y] ) {
				return false;
			}
		}
	}
	return true;
}

int main(){
	cin >> N >> M;
	for (int y=0; y<N; ++y) {
		for (int x=0; x<N; x++) {
			cin >> A[x][y];
		}
	}
	for (int y=0; y<M; ++y) {
		for (int x=0; x<M; x++) {
			cin >> B[x][y];
		}
	}
	
	for (int offY=0; offY<=N-M; offY++) {
		for (int offX=0; offX<=N-M; offX++) {

			if (valid(offX, offY)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

const int H = 11, W = 1003, inf = 1008;
int h, w, k, tp, fp = inf, z[H], tz[H];
char a[H][W];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w >> k;
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < (1 << (h - 1)); ++i) {
		for(int j = 0; j < h; ++j) z[j] = 0;
		tp = __builtin_popcount(i);
		int sr = tp + 1;
		bool ab = 0;
		for(int j = 1; j <= w; ++j) {
			int zg = 0;
			for(int ii = 0; ii < sr; ++ii) {
				tz[ii] = 0;
			}
			for(int ii = 1; ii <= h; ++ii) {
				if(a[ii][j] == '1') ++tz[zg];
				if(i & (1 << (ii - 1))) ++zg;
			}
			for(int ii = 0; ii < sr; ++ii) {
				if(tz[ii] > k) {
					ab = 1;
					break;
				}
				if(z[ii] + tz[ii] > k) {
					++tp;
					for(int jj = 0; jj < sr; ++jj) {
						z[jj] = tz[jj];
					}
					break;
				}
				if(ii == sr - 1) {
					for(int jj = 0; jj < sr; ++jj) {
						z[jj] += tz[jj];
					}
					break;
				}
			}
			if(ab) {
				break;
			}
		}
		if(!ab) {
			fp = min(fp, tp);
		}
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d,n,i,j;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	if(a%c!=0)a=a/c+1;
	else a=a/c;
	if(b%d!=0)b=b/d+1;
	else b=b/d;
	if(b>a)a=b;
	printf("%d\n",n-a);
	return 0;
}


Measured memory_bytes: 2104
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let k, n = Scanf.sscanf (read_line ()) "%d %d" (
        fun k n -> 
                k, n
)

let lst = Str.split (Str.regexp " ") (read_line ())
          |> List.map int_of_string 
          |> List.sort compare

let rec f head tail lst =
        match lst with
                  [] -> []
                | first :: [] -> 
                        [head + (k - tail)] @ f head tail []  
                | first :: rest -> 
                        [(List.hd rest) - first] @ f head tail rest

let () =
        let tmplst = f (List.min lst) (List.max lst) lst in
        let mintmplst = List.min tmplst in
        let maxtmplst = List.max tmplst in
        let tmplst2 = 
                if  mintmplst = maxtmplst then
                        match tmplst with
                                  [] -> [0]
                                | first :: rest -> rest
                else
                        List.filter (fun elmnt -> elmnt != maxtmplst) tmplst 
        in
                List.fold_right (+) tmplst2 0
                |> Printf.printf "%d\n"


Measured memory_bytes: 27360
#include <iostream>
using namespace std;
int main(){
    int h1,h2,k1,k2,a,b,c,d,num1,num2,yam1,yam2,sum1,sum2;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;

    if(c==0){
        num1=0;
        num2=0;
    }
    else{
        num1=(h1/10)*c;
        num2=(k1/10)*c;
    }

    if(d==0){
        yam1=0;
        yam2=0;
    }
    else{
        yam1=(h2/20)*d;
        yam2=(k2/20)*d;
    }

    sum1=(h1*a)+(h2*b)+num1+yam1;
    sum2=(k1*a)+(k2*b)+num2+yam2;

    if(sum1>sum2){
        cout << "hiroshi";
    }
    else if(sum1<sum2){
        cout << "kenjiro";
    }
    else{
        cout << "even";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3084
maxCheck :: Int -> Int
maxCheck m = floor $ sqrt (fromIntegral m)

calc :: Int -> Int -> Int
calc n m = case ds of
             [] -> 1
             otherwise -> m `div` (last ds)
  where ds = takeWhile (n <=) $ divosors m

main = do
  [n,m] <- map read . words <$> getLine
  print $ calc n m

divosors :: Int -> [Int]
divosors m = divosors'' ++ reverse divosors'
  where
    mc = maxCheck m
    divosors' = [i| i <- [1..mc], m `mod` i == 0]
    divosors'' = map (div m) divosors'

Measured memory_bytes: 508
n = int(input())
AL = list(map(int, input().split()))
BL = list(map(int, input().split()))
ans = 0
for i in range(n):
    if BL[i] <= AL[i]:
        ans += BL[i]
    elif BL[i] > AL[i] and BL[i] <= AL[i]+AL[i+1]:
        ans += BL[i]
        AL[i+1] = AL[i+1] - BL[i] + AL[i]
    else:
        ans += AL[i]+AL[i+1]
        AL[i+1] = 0
print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>a,b,c;
int n;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int k;cin>>k;
		a.push_back(k);
		b.push_back(k);
		c.push_back(k);
	}
	if(prev_permutation(b.begin(),b.end()))
	{
		for(int i=0;i<n;i++)cout<<(i?" ":"")<<b[i];
		cout<<endl;
	}
	for(int i=0;i<n;i++)cout<<(i?" ":"")<<a[i];
	cout<<endl;
	if(next_permutation(c.begin(),c.end()))
	{
		for(int i=0;i<n;i++)cout<<(i?" ":"")<<c[i];
		cout<<endl;
	}
}


Measured memory_bytes: 3152
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

int n;
vector<int> gr[maxn];
int sub[maxn], depth[maxn], p[maxn];

void read_input()
{
    cin >> n;
    for(int i = 1; i < n; ++i)
    {
        int u, v;
        cin >> u >> v;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }
}

void dfs(int u, int par)
{
    p[u] = par;
    depth[u] = depth[par] + 1;
    sub[u] = 1;
    for(auto&v: gr[u])
        if(v != par)
    {
        dfs(v, u);
        sub[u] += sub[v];
    }
}

void solve()
{
    dfs(1, 0);
    int k = depth[n] - 2;
    int x = k / 2, cur = n;
    while(x > 0)
    {
        --x;
        cur = p[cur];
    }
    int cnt2 = sub[cur] - k / 2 - 1 - (k & 1);
    int cnt1 = sub[1] - sub[cur] - (k - k / 2) - 1;
    if(cnt1 <= cnt2)
        cout << "Snuke\n";
    else cout << "Fennec\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 16480
n = int(input())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
pre = [10**6 for _ in range(n)]
pre[0] = -1
pst = [[] for _ in range(n)]
rank = [[0]]
seen = [0 for _ in range(n)]
seen[0] = 1
now = [0]
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        now.append(y)
        pre[y] = x
        pst[x].append(y)
  rank.append(now)
rank = rank[1:-1]
#print(rank)

family = [1 for _ in range(n)]
rank.reverse()
for z in rank:
  for w in z:
    family[pre[w]] += family[w]
#print(pre)
#print(family)

mod = 10**9+7
half = 5*10**8+4
satoshi = 1
btc = [1]
for _ in range(n):
  satoshi *= half
  satoshi %= mod
  btc.append(btc[-1]*2%mod)
#print(satoshi,btc)

ans = 0
for i in range(n):
  if i == 0:
    if len(pst[i]) == 1:
      pass
    else:
      q = []
      for x in pst[i]:
        q.append(family[x])
      tmp = -len(q)+1
      for p in q:
        tmp += btc[p]
      tmp = btc[n-1] - tmp
      #print(tmp)
      ans += tmp
  else:
    if len(pst[i]) == 0:
      pass
    else:
      q = []
      for x in pst[i]:
        q.append(family[x])
      q.append(n-1-sum(q))
      tmp = -len(q)+1
      for p in q:
        tmp += btc[p]
      tmp = btc[n-1] - tmp
      #print(tmp)
      ans += tmp
  #try:
    #print(i,q)
  #except:
    #pass
ans *= satoshi
ans %= mod
print(ans)

Measured memory_bytes: 122472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n){
        if (i % 2 == 0) sum += a[i];
        else sum -= a[i];
    }
    vector<int> ans(n);
    ans[0] = sum / 2;
    for(int i = 1; i < n; i++){
        ans[i] = a[i-1] - ans[i-1];
    }
    rep(i,n) cout << 2 * ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3924
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
struct Tree {
	int depth;
	int parent;
	vector<int>v;
};
Tree tree[100000];
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		tree[i].parent = -1;
	}
	for (int i = 0; i < n; i++) {
		int key,childs;
		cin >> key>>childs;
		for (int i = 0; i < childs; i++) {
			int child;
			cin >> child;
			tree[key].v.push_back(child);
			tree[child].parent = key;
		}
	}
	int k = 0;
	for (; k < n; k++) {
		if (tree[k].parent == -1) break;
	}
	queue<int>q;
	q.push(k);
	while (!q.empty())
	{
		int i = q.front();
		for (vector<int>::iterator it = tree[i].v.begin(); it != tree[i].v.end(); it++)
		{
			tree[*it].depth = tree[i].depth + 1;
			q.push(*it);
		}
		q.pop();
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << tree[i].depth;
		cout << ", ";
		if (i == k) cout << "root, ";
		else if (tree[i].v.empty())cout << "leaf, ";
		else cout << "internal node, ";
		cout << "[";
		for (vector<int>::iterator it = tree[i].v.begin(); it != tree[i].v.end(); it++)
		{
			if (it != tree[i].v.begin()) cout << ", ";
			cout << *it;
		}
		cout << "]"<<endl;
	}
}


Measured memory_bytes: 7180
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

int main()
{
    int N,i,j;
    int a[2][100];
    int sum = 0;
    int answer = 0;

    scanf("%d", &N);

    for (i = 0; i < 2; i++) {
        for (j = 0; j < N; j++) {
            scanf("%d", &a[i][j]);
        }
    }


    for (i = 1; i <= N; i++) {
        sum = a[0][0];

        for (j = 1; j < i; j++) {
            sum += a[0][j];
        }

        sum += a[1][i-1];

        for (j = 0; j <N - i ; j++) {
            sum += a[1][i+j];
        }

        if (sum > answer)
            answer = sum;
    }

    printf("%d", answer);

    return 0;
}

Measured memory_bytes: 2116
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int N; cin >> N;
    vector<string> S(N); rep(i, N) cin >> S[i];

    map<string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    rep(i, N) {
        mp[S[i]]++;
    }
    
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}


Measured memory_bytes: 6428
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>
#define lld long long int
#define ld long int
#define mod 1000000007
#define pb push_back
#define ump unordered_map
#define fast1 ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define fors(n) for(int i=0;i<n;i++)
#define forse(i,a,b) for(int i=a;i<b;i++)
#define gogprnt cout<<"Case #"<<x<<": ";
using namespace std;
//lld mypower(lld x, lld n){	if (n == 0)	return 1;	if (n & 1) 	return (((x * mypower(x, n / 2))%mod) * (mypower(x, n / 2)%mod)%mod);return (((mypower(x, n / 2))%mod) * (mypower(x, n / 2)%mod))%mod;}
void solve()
{
    lld n;
    cin>>n;
    lld ar[n+1],b[n+1];lld sa=0,di=0;
    fors(n)
    cin>>ar[i+1];int i1=n-3;
    b[n-1]=abs(ar[n-1]-ar[n]);
    b[n-2]=min(abs(ar[n-2]-ar[n-1])+b[n-1],abs(ar[n-2]-ar[n]));
    while(i1>=1)
    {
        b[i1]=min(abs(ar[i1]-ar[i1+1])+b[i1+1],abs(ar[i1]-ar[i1+2])+b[i1+2]);
        i1--;
    }
    cout<<b[1]<<"\n";
    
}
int main() {fast1;
//int t;cin>>t;while(t--)
	  solve();
	return 0;
}


Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int n ;
    cin >> n  ;
    vector<vector<int64_t> > p(n,vector<int64_t> (3)) ;
    int64_t a,b ;
    for (size_t i = 0; i < n; i++)
    {
       cin >> a >> b ;
       p.at(i).at(0) = -1*(a+b) ;
       p.at(i).at(1) = a ;
       p.at(i).at(2) = b ;

    }
    sort(p.begin(),p.end()) ;
    int64_t ans = 0 ;
    for (size_t i = 0; i < n; i+= 2)
    {
        ans += p.at(i).at(1) ;
    }for (size_t i = 1; i < n; i+= 2)
    {
        ans -= p.at(i).at(2) ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    long a = 2;
    long b = 1;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        long c = a + b;
        a = b;
        b = c;
    }
    cout << a;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        if(list.Count(x => x == 1) == 1 &&
            list.Count(x => x == 9) == 1 &&
            list.Count(x => x == 7) == 1 &&
            list.Count(x => x == 4) == 1
        ){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }
    }
}


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

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

    int ans = 0;
    for(int i = k + 1; i <= n; i++){
        int cnt = i - k;
        int d = n / i;
        int m = n % i;
        ans += cnt * d + max((k == 0) ? m - k : m - k + 1, 0LL);
    }
    cout << ans << endl;
}

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

struct node{
	int key;
	int count;
	struct node *next;
};

struct node *add (int val, struct node *np){
	struct node *tmp;
	if (np == 0){
		tmp = (struct node*) malloc (sizeof (struct node));
		tmp->key = val;
		tmp->count = 1;
		tmp->next = 0;
		return tmp;
	}
	if (np->key == val){
		np->count++;
		return np;
	}else if (np->key > val){
		tmp = (struct node*) malloc (sizeof (struct node));
		tmp->key = val;
		tmp->count = 1;
		tmp->next = np;
		return tmp;
	}else{
		np->next = add (val, np->next);
		return np;
	}
}

int main(){
	int in, max;
	struct node *head, *search;

	head = 0;
	while (scanf ("%d", &in) != EOF){
		head = add (in, head);
	}

	max = 0;
	search = head;
	while (search != 0){
		if (search->count > max) max = search->count;
		search = search->next;
	}
	search = head;
	while (search != 0){
		if (search->count == max) printf ("%d\n", search->key);
		search = search->next;
	}
	return 0;
}

Measured memory_bytes: 596
max_time = 10
n = int(input())
f = [sum(v << max_time - k - 1 for k, v in
         enumerate(map(int, input().split())))
     for i in range(n)]
p = [[int(j) for j in input().split()] for i in range(n)]
pattern = [sum(i >> j & 1 for j in range(max_time))
           for i in range(2 ** max_time)]
print(max(sum(
    p[j][pattern[f[j] & i]] for j in range(n))
          for i in range(1, 2 ** max_time)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

int a[N], dp[N];

int main () {
	boost;
	int n, k;
	cin >> n >> k;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> a[i];
	}
	for (int i = 1 ; i < n ; ++ i) {
		dp[i] = inf;
		for (int j = i - 1 ; j >= 0 && i - j <= k ; -- j)
			dp[i] = min (dp[i], dp[j] + abs (a[i] - a[j]));
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 4736
N = int(input())
a = list(map(int, input().split()))
print(" ".join(list(map(str, a))))

#「整列していない部分」から、順番に1つずつ取り出していく
for i in range(1,len(a)):
    
    #「挿入する値」を、変数に取り出す
    tmp=a[i]
    
    #挿入する位置の変数を用意する
    ins=0
    
    #「整列済みの部分」のどこに挿入すればいいのかを、後ろから前に向かって順番に見ていく
    for j in range(i-1,-1,-1):
        
        #もし「挿入する値」が小さければ
        if tmp < a[j]:
            
            #そこに挿入できるように、調べた値を１つ後ろへずらす
            a[j+1]=a[j]
        else :
            
            #もし「挿入する値」が小さくなければ、そこでずらす処理を止める
            ins=j+1
            break
    
    #ずらす処理が終わった位置に「挿入する値」を入れる    
    a[ins]=tmp
    
    #ソート後の配列を表示する
    print(" ".join(list(map(str, a))))




Measured memory_bytes: 5600
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		
		
		System.out.printf("%1$d %2$d %3$.5f", d, r, f);

	}
}

Measured memory_bytes: 26244
#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>;

void Main(){
    int n; string s; cin >> n >> s;
    int cnt = count(all(s), 'R');
    s = s.substr(0, cnt);
    int l = count(all(s), 'R');
    cout << cnt - l << endl;
    return;
}

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

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<int,int> m;
  int64_t s=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    m[a]++;
    s+=a;
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int b,c;
    cin>>b>>c;
    s+=(int64_t)m[b]*(c-b);
    cout<<s<<endl;
    m[c]+=m[b];
    m[b]=0;
  }
}

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
const int MOD = 1e9+7;
const int MAX = 1e5+5;

ll a, b, c, k;

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);


    cin >> a >> b >> c >> k;
    if(k&1)
    	cout << b - a;
    else
    	cout << a - b;

    return 0;
}


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

int deg[55];

int main( )
{
    int n, m;
    int i, j, a, b;
    cin >> n >> m;
    for (i = 0; i < m; i++) {
        cin >> a >> b;
        deg[a]++;
        deg[b]++;
    }
    for (i = 1; i <= n; i++) {
        cout << deg[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        long[][] a = new long[n][m];  //行列A定義
        long[][] b = new long[m][l];  //行列B定義
        long[][] c = new long[n][l];  //行列C定義

        /* Aの値代入 */
        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                a[i][j] = sc.nextInt();
            }
        }

        /* Bの値代入 */
        for(int i = 0;i < m;i++){
            for(int j = 0;j < l;j++){
                b[i][j] = sc.nextInt();
            }
        }

        /* 演算処理　*/
        for(int i = 0;i < n;i++){
            for(int j = 0;j < l;j++){
                for(int k = 0;k < m;k++){
                    c[i][j] += a[i][k] * b[k][j];
                }
            }
        }

        /* 表示処理 */
        for(int i = 0;i < n;i++){
            for(int j = 0;j < l;j++){
                if(j != 0)  System.out.print(" ");
                System.out.print(c[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 53264
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
using T = tuple<int,int,int>;
void solve(){
	int N;
	cin >> N;
	vector<T>v(N);
	REP(i, N) {
		int k, l, r;
		cin >> k >> l >> r;
		v[i] = T(k, l, r);
	}

	int ret = 0;
	vector<pair<int,int>>ls, rs;
	REP(i, N) {
		auto[k, l, r] = v[i];
		int mi = min(l, r);
		l -= mi;
		r -= mi;
		ret += mi;
		if(l > r) {
			ls.emplace_back(k, l);
		} else {
			rs.emplace_back(N - k, r);
		}
	}
	auto f = [&](vector<pair<int,int>>&v) {
		sort(ALL(v));
		priority_queue<int,vector<int>,greater<int>>que;
		for(auto&&[k, val] : v) {
			que.push(val);
			while(que.size() > k) {
				que.pop();
			}
		}
		while(que.size()) {
			ret += que.top();
			que.pop();
		}
	};
	f(ls);
	f(rs);
	out(ret);
}

signed main(){
	IOS();
	int Q = 1;
	cin >> Q;
	while(Q--)solve();
}

Measured memory_bytes: 13000
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input!{
        H:usize, W:usize,
        ch:Usize1, cw:Usize1,
        dh:Usize1, dw:Usize1,
        g: [String; H]
    }
    let mut G: Vec<Vec<char>> = Vec::new();
    for x in g {
        G.push(x.chars().collect());
    }
    let arr: Vec<(i32, i32)> = vec![(0, 1), (1, 0), (0, -1), (-1, 0)];
    let mut dist = vec![vec![1_000_000i32; W]; H];
    dist[ch][cw] = 0;
    let mut q = BinaryHeap::new();
    q.push((0, ch, cw));
    while let Some((cost, y, x)) = q.pop() {
        if -cost > dist[y][x] { continue; };
        for &(du, dv) in &arr {
            let nu = y.wrapping_add(du as usize);
            let nv = x.wrapping_add(dv as usize);
            if nu < H && nv < W && G[nu][nv] == '.' && dist[nu][nv] > -cost {
                dist[nu][nv] = -cost;
                q.push((cost, nu, nv));
            }
        }
        for du in -2i32..3 {
            for dv in -2i32..3 {
                let nu = y.wrapping_add(du as usize);
                let nv = x.wrapping_add(dv as usize);
                if nu < H && nv < W && G[nu][nv] == '.' && dist[nu][nv] > -cost + 1 {
                    dist[nu][nv] = -cost + 1;
                    q.push((cost-1, nu, nv));
                }
            }
        }
    }
    let ans = dist[dh][dw];
    println!("{}", if ans == 1_000_000 {-1} else {ans});
}


Measured memory_bytes: 11156
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int plus = 0;
        int minus = 0;
        String a = sc.nextLine();
        char[] b = a.toCharArray();
        for(int i = 0; i < a.length(); i++){
            if(b[i] == '+'){
                plus++;
            } else if(b[i] == '-'){
                minus++;
            }
        }
        System.out.println(plus - minus);
    }
}


Measured memory_bytes: 21844
import Control.Applicative
import Control.Monad
import Data.List

f :: String -> Char -> String
f xs '0' = '0' : xs
f xs '1' = '1' : xs
f xs 'B' = drop 1 xs

main :: IO ()
main = do
    ss <- getLine
    putStrLn $ reverse $ foldl' f "" ss

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    multiset< pll > pq;
    ll n, m;
    cin>>n>>m;
    ll a[n+5], b[n+5];
    int i;
    FOR0(i, n)
    {
        cin>>a[i]>>b[i];
        pq.insert(mp(a[i], b[i]));
    }
    ll cur  = 0;
    ll ans = 0;
    while(cur<m)
    {
        pll cp = *pq.begin();
        pq.erase(pq.begin());
        ll req = m - cur;
        ll use = MIN2(req, cp.ss);
        cur += use;
        ans += cp.ff*use;
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long n, long long m, std::vector<long long> a){
    Vi b=a;
    while(1){
        bool check,endcheck=false;
        if(a[0]%2==0) check=true;
        else check=false;
        if(check){
            REP(i,0,n){
                if(a[i]%2==0) a[i]/=2;
                else {
                    cout<<0<<endl;
                    return;
                }
            }
        }else{
            REP(i,0,n){
                if(a[i]%2==0){
                    cout<<0<<endl;
                    return;
                }else{
                    if(i==n-1) endcheck=true;
                }
            }
        }
        if(endcheck) break;
    }

    int l=1;
    REP(i,0,n){
        l = lcm(l,b[i]/2);
    }
    cout<<RUP(m/l,2)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, M, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,m:usize,d:usize,
    }
    let mut v = (n - d) * 2;
    if d == 0 {
        v /= 2;
    }
    let mut ans = (m - 1) as f64 * v as f64 / n as f64 / n as f64;
    println!("{}", ans);
}


Measured memory_bytes: 2216
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/

//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return x * y / tmp;
}



int main() {

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

	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;






	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define rep_sn(i,s,n) for(int i=(s);i<(s)+(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	V<ll> a(n);
	rep(i, n)cin >> a[i];

	int r = 0;
	ll x = 0, ans = 0;
	rep(l, n) {
		bool last = false;
		while (true) {
			bool ten = false;
			rep(j, 20) {
				if (((x >> j) & 1) && (a[r] >> j) & 1)ten = true;
			}
			if (ten)break;
			x ^= a[r];
			r++;
			if (r==n) {
				last = true;
				break;
			}
		}
		if (last) {
			ans += (ll)(r - l + 1) * (r - l) / 2;
			break;
		}
		ans += r - l;
		x ^= a[l];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

class ECoinsRespawn {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    struct edge {
        int from, to, cost;

        edge(int _from, int _to, int _cost) : from(_from), to(_to), cost(_cost) {}

        edge() {}
    };

    int N, M, P;
    vector<edge> edges;
    vector<int> d;
    vector<bool> neg;

    void calc(int s) {
        REP(i, N) d[i] = INF;
        d[s] = 0;

        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j < edges.size(); j++) {
                auto e = edges[j];
                if (d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                }
            }
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < edges.size(); j++) {
                auto e = edges[j];
                if (d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    neg[e.to] = true;
                }
                //if (neg[e.from]) neg[e.to] = true;
            }
        }
        if (neg[N - 1]) {
            d[N - 1] = INF;
        }
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M >> P;
        edges.clear();
        d.resize(N);
        neg.resize(N);
        REP(i, M) {
            int a, b, c;
            cin >> a >> b >> c;
            edge e;
            a--;
            b--;
            c -= P;
            edges.push_back(edge(a, b, -c));
        }

        calc(0);

        if (d[N - 1] >= INF) {
            cout << -1 << endl;
        } else {
            cout << max(-d[N - 1], 0LL) << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ECoinsRespawn solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Battle | diff Battle.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Battle.cpp && ./a.out

/*
 
 4/26/2020
 
 5:02-
 
 */

int A,B,C,D;

bool solve() {
  int a=(C+B-1)/B,b=(A+D-1)/D;
  dump(a,b);
  return a<=b;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B>>C>>D;
  cout<<(solve()?"Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)


int main()
{
	 iostream::sync_with_stdio(false);
    cin.tie(0);
	string s,t;
	cin>>s>>t;
	ll x,y;
	x=s.size();
	y=t.size();
	ll dp[x+1][y+1];
	loop(i,0,max(x+1,y+1))
	{
		if(i<x+1)dp[i][0]=0;
		if(i<y+1)dp[0][i]=0;
	}
	ll k=0,f=1;

	loop(i,1,x+1)
	{
		loop(j,1,y+1)
		{	
			
			if(t[j-1]==s[i-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
				}
				else
				{
					
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
				
				
				
			
			}	
		
		
	}
	 string ans="\0";


	while(x&&y)
	{
		
		
		if(s[x-1]==t[y-1])
		{
			ans+=s[x-1];
			x--;
			y--;
		}
		else 
		{
				if(dp[x][y-1]>dp[x-1][y])
				{
					
					y--;
				}
				else 
				x--;
		}
		
	}
	
	reverse(ans.begin(),ans.end());
	cout<<ans;
	
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf (1 << 21)
#define mod 1000000007

int main() {
    string S; cin >> S;
    int s = S.size();
    vector<int> ans(s);
    int r = 0;
    for (int i = 1; i < s; i++) {
        if (S.at(i) == 'L') {
            int dist = i - r;
            if (dist % 2 == 0) {
                ans.at(r)++;
            }
            else {
                ans.at(r + 1)++;
            }
        }
        else {
            r = i;
        }
    }
    int l = s - 1;
    for (int i = s - 2; i >= 0; i--) {
        if (S.at(i) == 'R') {
            int dist = l - i;
            if (dist % 2 == 0) {
                ans.at(l)++;
            }
            else {
                ans.at(l - 1)++;
            }
        }
        else {
            l = i;
        }
    }
    for (int i = 0; i < s; i++) {
        if (i != s - 1) {
            cout << ans.at(i) << ' ';
        }
        else {
            cout << ans.at(i) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
A=list(map(int,input().split()))

color=[0 for i in range(8)]
upper=0

for a in A:
    if 1<=a<=399:
        color[0]=1
    elif 400<=a<=799:
        color[1]=1
    elif 800<=a<=1199:
        color[2]=1
    elif 1200<=a<=1599:
        color[3]=1
    elif 1600<=a<=1999:
        color[4]=1
    elif 2000<=a<=2399:
        color[5]=1
    elif 2400<=a<=2799:
        color[6]=1
    elif 2800<=a<=3199:
        color[7]=1
    else:
        upper+=1

lower=sum(color)
if lower==0:
    mn=1
    mx=upper
else:
    mn=lower
    mx=lower+upper
print(mn,mx)


Measured memory_bytes: 3064
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[300005],f(200005,0),b(200005,0),a(200005,0);
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> q;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
 
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n;cin>>n;
    if(n%2==0 or n%5==0)
    {
        cout<<-1<<endl;exit(0);
    }
    lli h=0,ans=0;
    while(h<n)
    {
        h*=10;
        h+=7;
        ans++;
    }
    //cout<<h<<endl;
    while(true)
    {
        h%=n;
        if(h==0)break;
        while(h<n)
        {
            h*=10;
            h+=7;
            ans++;
        }
        //7cout<<h<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15044
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}
 
ll mod = 1e9+7;
int main(){
    int n,k;
    cin>>n>>k;
    vector<double> a(n);
    rep(i,n){
        cin>>a[i];
    }
    Sort(a);
    double r=0,l=a[n-1];
    int c = 100;
    while(--c){
        double mid=(r+l)/2;
        int cnt=0;
        rep(i,n){
            cnt+=int((a[i]-1)/mid);
        }
        if(cnt>k) r =mid;
        else l = mid;
    }
    cout<<(int)l +1<<endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	//なんか
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	ll ruiseki = 0;
	int lastng = 0;
	rep(i,n){
		if(ruiseki * 2 < a[i]) lastng = i;
		ruiseki += a[i];
	}
	cout << n - lastng << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  int n;
  cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AC") {
      ac++;
    } else if (s == "WA") {
      wa++;
    } else if (s == "TLE") {
      tle++;
    } else if (s == "RE") {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3636