akhauriyash/Code-Regression huggingface dataset:
//Code Author:-code_kika //
//Institution:-IIT(BHU)  //
#include<bits/stdc++.h>
using namespace std;
//basic
#define pb push_back
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007LL

//typedefs
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vll vector<ll>
#define vi vector<int>

//functions
#define all(c) c.begin(),c.end()
#define mini(c) min_element(all(c))
#define maxi(c) max_element(all(c))
#define fill(c,val) memset(c,val,sizeof(c))

//debug
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

int main(){
	ll n,a[100005],b[100005],sum,x,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sum=0;
	for(i=n-1;i>=0;i--){
		a[i]+=sum;
		x=(a[i]%b[i]);
		if(x==0){
			sum+=0;
		}
		else{
			sum+=(b[i]-x);
		}
	}
	cout<<sum<<endl;
}

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

double ans[100010];

void MAIN(int n) {
    std::vector<double> prob;
    for(int i = 0; i < n; ++ i) {
        double p;
        scanf("%lf", &p);
        if(p < 0.995) {
            prob.push_back(p);
        } else if(prob.empty() || prob.back() < 0.995) {
            prob.push_back(p);
        } else {
            prob[prob.size() - 1] += 1;
        }
        ans[i] = 1e100;
    }
    n = prob.size();
    ans[n] = 0;
    for(int i = n - 1; i >= 0; -- i) {
        double now = 0;
        int upper = std::min(n, i + 700);
        for(int j = i + 1; j <= upper; ++ j) {
            if(prob[j - 1] >= 0.995) {
                now += prob[j - 1];
            } else {
                now = (now + 1) / prob[j - 1];
            }
            ans[i] = std::min(ans[i], now + ans[j] + 1);
        }
    }
    printf("%.11f\n", ans[0] - 1);
}

int main() {
    int n;
    while(scanf("%d", &n) == 1 && n > 0) {
        MAIN(n);
    }
    return 0;
}

Measured memory_bytes: 5436
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> l(n);
    vector<int> r(n);
    for(int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }

    vector<int> sum(n+1);
    sum[0] = 0;
    sum[1] = 0;
    for(int i = 1; i <= n; i++)
    {
        if(s[i-1] == 'A' && s[i] == 'C')
        {
            sum[i+1] = sum[i] + 1;
        }
        else sum[i+1] = sum[i];
    }

    for(int i = 0; i < q; i++)
    {
        cout << sum[r[i]] - sum[l[i]] << endl;
    }
}


Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
 
 
 
class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }
 
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
        string str = cin.next();

        char[] ch = new char[4];
        int[] count = new int[4];
        for(int i=0; i<4; i++) {
            for(int j=0; j<4; j++) {
                if(ch[j] == '\0') {
                    ch[j] = str[i];
                    count[j] = 1;
                    break;
                }
                else if(ch[j] == str[i]) {
                    count[j]++;
                    break;
                }
            }
        }
        int count2 = 0;
        for(int i=0; i<4; i++)
        {
            if(count[i] == 2) {
                count2++;
            }
        }
        if(count2 == 2){
            Console.WriteLine("Yes");
        }
        else{
            Console.WriteLine("No");
        } 
    }
}
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#スペース区切りの整数の入力
K, N = map(int, input().split())
#文字列の入力
A = input()
#コンマで区切る
A_list = A.split(' ')
for i in range(len(A_list)):
    A_list[i] = int(A_list[i])

amari = K-int(A_list[N-1])

aida_list = [0]*len(A_list)
for i in range(len(A_list)-1):
  aida_list[i] = A_list[i+1] - A_list[i]

aida_list[len(A_list)-1] = K - sum(aida_list)
#aida_list[len(A_list)-1] = amari

max_ = max(aida_list)

#print("aida",aida_list)
aida_list.remove(max_)

ans = sum(aida_list)

#print("A",A_list)
#print(aida_list)
print(ans)

Measured memory_bytes: 20684
import bisect
import itertools
import numpy as np

def search_cut(N, M, A):
    high_cut = A[-1] * 2
    low_cut = A[0] * 2

    while high_cut > low_cut + 1:
        mid = (high_cut + low_cut) // 2
        count = (N  - np.searchsorted(A, mid - A, side = 'left')).sum()

        if count > M:
            low_cut = mid
        else:
            high_cut = mid

    return low_cut, high_cut

def happiness(N, M, A, low_cut, high_cut):
    A_sum = np.zeros(N + 1)
    A_sum[1:] = np.cumsum(A)
    X = np.searchsorted(A, high_cut - A, side = 'left')
    happiness = (A_sum[-1] - A_sum[X]).sum()
    happiness += ((N - X) * A).sum()
    happiness += (M - (N - X).sum()) * low_cut

    return int(happiness)


N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A = np.sort(A)

low_cut, high_cut = search_cut(N, M, A)
ans = happiness(N, M, A, low_cut, high_cut)
print(ans)


Measured memory_bytes: 23428
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class mint {
public:
    long long x;

    constexpr mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}

    constexpr mint operator-() const {
        return mint(-x);
    }

    constexpr mint &operator+=(const mint &rhs) {
        if ((x += rhs.x) >= MOD) x -= MOD;
        return *this;
    }

    constexpr mint &operator-=(const mint &rhs) {
        if ((x += MOD - rhs.x) >= MOD) x -= MOD;
        return *this;
    }

    constexpr mint &operator*=(const mint &rhs) {
        (x *= rhs.x) %= MOD;
        return *this;
    }

    constexpr mint operator+(const mint &rhs) const {
        mint res(*this);
        return res += rhs;
    }

    constexpr mint operator-(const mint &rhs) const {
        mint res(*this);
        return res -= rhs;
    }

    constexpr mint operator*(const mint &rhs) const {
        mint res(*this);
        return res *= rhs;
    }

    [[nodiscard]] constexpr mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    [[nodiscard]] constexpr mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator/=(mint rhs) {
        return *this *= rhs.inv();
    }

    mint operator/(const mint rhs) const {
        return mint(*this) /= rhs;
    }

    constexpr bool operator==(const mint &rhs) const noexcept {
        return this->x == rhs.x;
    }

    constexpr bool operator!=(const mint &rhs) const noexcept {
        return this->x != rhs.x;
    }

    bool operator<(const mint &rhs) const noexcept {
        return this->x < rhs.x;
    }

    bool operator>(const mint &rhs) const noexcept {
        return this->x > rhs.x;
    }

    bool operator<=(const mint &rhs) const noexcept {
        return this->x <= rhs.x;
    }

    bool operator>=(const mint &rhs) const noexcept {
        return this->x >= rhs.x;
    }

    friend istream &operator>>(istream &is, mint &a) {
        long long t;
        is >> t;
        a = mint(t);
        return is;
    }

    friend ostream &operator<<(ostream &os, const mint &a) {
        return os << a.x;
    }
};


void solve() {
    ll S;
    cin >> S;
    vector<mint> dp(S + 1, 0);
    dp[0] = 1;
    rep(i, S + 1) {
        rep(j, i - 2){
            dp[i] += dp[j];
        }
    }
    cout << dp[S] << '\n';
}

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


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    vector<int> y = x;
    sort(y.begin(), y.end());

    for(int i = 0; i < n; i++) {
        if(x[i] < y[n / 2]) {
            cout << y[n / 2] << endl;
        } else {
            cout << y[n / 2 - 1] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include<string>

using namespace std;

int main()
{   string S;
    cin>>S;
    if (S!="SUN"&&S!="MON"&&S!="TUE"&&S!="WED"&&S!="THU"&&S!="FRI"&&S!="SAT"){
        cout<<"error"<<endl;
    }
    else if (S=="SUN"){
        cout<<"7"<<endl;
    }
    else if (S=="MON"){
        cout<<"6"<<endl;
    }
    else if (S=="TUE"){
        cout<<"5"<<endl;
    }
     else if (S=="WED"){
        cout<<"4"<<endl;
    }
     else if (S=="THU"){
        cout<<"3"<<endl;
    }
      else if (S=="FRI"){
        cout<<"2"<<endl;
    }
     else {
        cout<<"1"<<endl;
    }
    return 0;
}

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

using namespace std;
class Point{
public:
    double x,y;
    Point();
    Point(double _x,double _y);
};
const int MAX = 10010;
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
Point p[MAX];
int N,M;
class Edge{
public:
    int u,v;
    double w;
    Edge();
    Edge(int _u,int _v,double _w);
};
vector<Edge> vec;
int pre[MAX];
void init(){
    for(int i=1;i<=N;++i){
        pre[i] = i;
    }
}
double getLen(int u,int v){
    double res = (p[u].x-p[v].x)*(p[u].x-p[v].x) + (p[u].y-p[v].y)*(p[u].y-p[v].y);
    return sqrt(res);
}
int F(int x){
    int r = x;
    while(pre[r] != r)
        r = pre[r];
    int i = x,j;
    while(pre[i] != r){
        j = pre[i];
        pre[i] = r;
        i = j;
    }
    return r;
}
bool cmp(Edge A,Edge B){
    return (A.w - B.w > eps);
}
int main(void){
    cin >> N >> M;
    init();
    for(int i=1;i<=N;++i){
        cin >> p[i].x >> p[i].y;
    }
    double sum = 0;
    int u,v;
    for(int i=1;i<=M;++i){
        cin >> u >> v;
        double len = getLen(u,v);
        sum += len;
        vec.push_back(Edge(u,v,len));
    }
    sort(vec.begin(),vec.end(),cmp);
    double res = 0;
    int Count = 0;
    for(vector<Edge>::iterator it = vec.begin();it != vec.end();++it){
        int fx = F(it->u);
        int fy = F(it->v);
        if(fx != fy){
            res += it->w;
            pre[fx] = fy;
            Count++;
        }
        if(Count == N-1)
            break;
    }
    cout << fixed << setprecision(3) << sum-res << endl;
    return 0;
}

Point::Point(){
    x = y = 0;
}
Point::Point(double _x,double _y){
    x = _x;
    y = _y;
}
Edge::Edge(){
    u = v = 0;
    w = 0;
}
Edge::Edge(int _u,int _v,double _w){
    u = _u;
    v = _v;
    w = _w;
}



Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


vector <vector<int>> g;
vector <bool> used;
vector <int> v;

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

int main() {
    ll H,W;
    cin >> H >> W;
    vector <string> grid(H);
    REP(i,H)cin >> grid[i];

    ll dp[H][W];
    REP(i,H)
    {
        REP(j,W)
        {

            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;


    for(int y = 0; y < H; ++y)
    {
        for(int x = 0; x < W; ++x)
        {
            if(grid[y][x] == '#')continue;
            for(int i = 0; i < 2; ++i)
            {
                int cur_x = x + dx[i];
                int cur_y = y + dy[i];
                if(cur_x >= W || cur_y >= H)continue;

                dp[cur_y][cur_x] = dp[cur_y][cur_x] + dp[y][x];
                dp[cur_y][cur_x] %= MOD;
            }
        }
    }

    ll res;
    res = dp[H-1][W-1];

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>//stl和数据结构应该一起训练
using namespace std;
int dp[1401][1401];
int a[1401][1401];
int main()
{	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
	{
		cin>>a[i][j];
		dp[i][j]=!a[i][j];
	}	int maxn=0;//最少是1
		for(int i=0;i<=n;i++)dp[i][0]=0;
		for(int j=0;j<=m;j++)dp[0][j]=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				if(dp[i][j]==0)
					continue;
				else 
					{
						dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
						maxn=max(maxn,dp[i][j]);	
					}
			}
	
		cout<<maxn*maxn<<endl;
	return 0;
}


Measured memory_bytes: 18412
h, n = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(n)]
dp = [10 ** 9] * (h + 1)
dp[0]=0

for i in range(h):
    for j in ab:
        k = min(i + j[0], h)
        dp[k] = min(dp[k], dp[i] + j[1])
print(dp[-1])
        


Measured memory_bytes: 41708
def main():
    from collections import deque, namedtuple
    from operator import attrgetter
    import sys
    input = sys.stdin.readline

    Mon = namedtuple('Mon', 'x h')  # 座標xにライフh
    Eff = namedtuple('Eff', 'x cnt')  # [,x]区間にcnt回爆発

    N, D, A = map(int, input().split())

    ms = []
    for _ in range(N):
        x, h = map(int, input().split())
        m = Mon(x=x, h=h)
        ms.append(m)

    ms.sort(key=attrgetter('x'))

    dq = deque()

    effect = 0
    cnt = 0
    for m in ms:
        while dq and dq[0].x < m.x:
            e = dq.popleft()
            effect -= e.cnt * A
        need_dmg = max(0, m.h - effect)
        if need_dmg:
            need_cnt = (need_dmg + A - 1) // A
            e = Eff(x=m.x + D * 2, cnt=need_cnt)
            dq.append(e)
            effect += need_cnt * A
            cnt += need_cnt
    print(cnt)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 46976
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

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

int main() {
	int n, k; cin >> n >> k;
	vll a, b;
	Loop(i, n) {
		ll x; cin >> x;
		if (x < 0) a.push_back(abs(x));
		else if (x > 0) b.push_back(x);
		else --k;
	}
	reverse(a.begin(), a.end());
	ll ans = LLONG_MAX;
	if (k == 0) ans = 0;
	Loop(i, a.size()) {
		if (i < k - 1 && k - 2 - i < (int)b.size()) ans = min(ans, a[i] * 2 + b[k - 2 - i]);
		else if (i >= k - 1) ans = min(ans, a[i]);
	}
	Loop(i, b.size()) {
		if (i < k - 1 && k - 2 - i < (int)a.size()) ans = min(ans, b[i] * 2 + a[k - 2 - i]);
		else if (i >= k - 1) ans = min(ans, b[i]);
	}
	cout << ans << endl;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const ld PI = 3.1415926535;
const int MOD = 1000000007;
const int N = 250555;
const int M = 1155;

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

    VI p,q,v;
    int z = 1;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        p.PB(x);
        v.PB(i+1);
    }
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        q.PB(x);
        z *= i+1;
    }

    int P = 0, Q = 0, cnt = 1;
    while (true){
        if (p == v) P = cnt;
        if (q == v) Q = cnt;
        //for (auto now : v) cout << now << ' '; cout << endl;
        next_permutation(v.begin(), v.end());
        cnt++;
        if (cnt == z+1) break;
    }

    cout << abs(P-Q);

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    // cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
XList = list(map(int, input().split()))

ans = 0

if N < M:
    XList = sorted(XList)
    XXList = [0] * (M-1)
    for i in range(M-1):
        XXList[i] = XList[i+1] - XList[i]
    XXList = sorted(XXList)
    for i in range(M-N):
        ans += XXList[i]

print(ans)

Measured memory_bytes: 13960
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;
typedef long long llint;
typedef long double ld;
#define inf 1e18


llint n;
string s;
bool a,b,c,d;
void solve(){
	cin >> s;
	for(char x:s){
		if(x=='N')a=true;
		if(x=='S')b=true;
		if(x=='E')c=true;
		if(x=='W')d=true;
	}
	if(a^b || c^d){
		cout << "No";
	}
	else cout << "Yes";
	cout << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::BinaryHeap;
use std::cmp::Reverse;

#[fastout]
fn main() {
    input! {
        t: usize,
    }

    let mut cases = vec![];

    for _ in 0..t {
        input! {
            n: usize,
            klr: [(usize, usize, usize); n],
        }
        let mut left = BinaryHeap::new();
        let mut right = BinaryHeap::new();

        let mut left_sum = 0;
        let mut right_sum = 0;

        for (k, l, r) in klr {
            if l >= r {
                left_sum += r;
                left.push((Reverse(k), l - r));
            } else {
                right_sum += l;
                right.push((Reverse(n - k), r - l));
            }
        }

        cases.push((left, left_sum, right, right_sum));
    }

    for (left, left_sum, right, right_sum) in cases {
        let mut sum = 0;

        sum += left_sum;
        sum += f(left);
        sum += right_sum;
        sum += f(right);

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

fn f(mut heap: BinaryHeap<(Reverse<usize>, usize)>) -> usize {
    let mut pool = BinaryHeap::new();
    while let Some((Reverse(k), value)) = heap.pop() {
        pool.push(Reverse(value));
        while pool.len() > k {
            pool.pop();
        }
    }
    let mut sum = 0;
    while let Some(Reverse(value)) = pool.pop() {
        sum += value;
    }
    sum
}


Measured memory_bytes: 13744
X, N = [int(i) for i in input().split()]
if N==0:
    print(X)
    quit()
P = list(set(range(-10, 110)) - {int(i) for i in input().split()})
# X = 10
# P = list(set(range(-10, 110)) - set(range(1, 101)))

P.sort()

D = [abs(P[i]-X) for i in range(len(P))]

print(P[D.index(min(D))])

Measured memory_bytes: 9200
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	String[] s = str.split("");
    if(s[2].equals(s[3]) && s[4].equals(s[5])){
      	System.out.println("Yes");
      	return;
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int main() {
  int n=0;cin>>n;
  int previous1=-1;
  int happyness=0;
  int* arr=new int[3];
  int* pos=new int[2];
  int* dp=new int[3];
  int max1=-1,max2=0,pos1=0,pos2=0;
  for(int j=0;j<3;j++) {
  	cin>>dp[j];
    if(max2<=max1){
      if(max1<dp[j]){max2=max1;pos[1]=pos[0];}
      else if(max2<dp[j]){max2=dp[j];pos[1]=j;}
    }
    if(max1<dp[j]){
      max1=dp[j];
      pos[0]=j;
    }
  }
  //cout<<pos[0]<<" "<<pos[1]<<endl;
  for(int i=1;i<n;i++) {
    for(int j=0;j<3;j++){
      cin>>arr[j];
    }
    int t1=dp[pos[0]],t2=dp[pos[1]];
    for(int j=0;j<3;j++) {
      if(pos[0]==j) {
        dp[j]=t2+arr[j];
      } else {
      	dp[j]=t1+arr[j];
      }
    }
    max1=-1,max2=0,pos1=0,pos2=0;
    for(int j=0;j<3;j++) {
      if(max2<=max1){
        if(max1<dp[j]){max2=max1;pos[1]=pos[0];}
        else if(max2<dp[j]){max2=dp[j];pos[1]=j;}
      }
      if(max1<dp[j]){
        max1=dp[j];
        pos[0]=j;
      }
    }
  }
  cout<<dp[pos[0]];
  return 0;
}

Measured memory_bytes: 256
import math
def isMore(N,K):#- N以上の数で、０でないのが丁度K個
    #-len(N)よりもKがおおきかったら0 埋められない
    if len(N) < K:
        return 0
    #最高位の数字を1つ繰り上げれば、なんでも大きい。ただし、Kは1以上
    if K>=1:
        tmp = (9-int(N[0]))*fact[len(N)-1]//((fact[len(N)-K])*(fact[K-1]))*(9**(K-1))
        #一桁ならtmpを返す
        if len(N)==1:
            return tmp
        #２桁以上あるなら＆最高位が０なら、最高桁繰り上げ＋最高桁同じ＋０でないものがK個
        elif len(N)>1 and N[0]=='0':
            return tmp + isMore(N[1:],K)
        #２桁以上あるなら＆最高位が０以外なら、最高桁繰り上げ＋最高桁同じ＋０でないものがK-1個
        elif len(N)>1 and N[0]!='0':
            return tmp + isMore(N[1:],K-1)
    #Kが0ならどうやってもNより大きいものが作れない0
    if K == 0:
        return 0

N = input()
K = int(input())
lenN = len(N)
fact = [1]*101
for i in range(1,101):
    fact[i] = fact[i-1]*i

ans = fact[lenN]//((fact[lenN-K])*fact[K])*(9**K)
ans -= isMore(N,K)
print(ans)


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int a, b;
    cin >> a >> b;
    int t = b;
    if (b < 10)
        t += a * 10;
    else if (t < 100)
        t += a * 100;
    else
        t += a * 1000;
    string ans = "No";
    REP(i, t)
    {
        if (i * i == t)
            ans = "Yes";
    }
    cout << ans << endl ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Feb 16 21:00:33 JST 2020
 **/

signed main() {
    Int n, K;
    cin >> n >> K;
    vector<Int> a, b;
    REP(i, n) {
        Int x;
        cin >> x;
        (x >= 0 ? b : a).push_back(abs(x));
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    auto check = [&](Int mid) -> bool {
        Int cnt = 0;
        if (mid >= 0) {
            cnt += a.size() * b.size();
            REP(i, a.size()) {
                Int j = upper_bound(a.begin(), a.end(), mid / a[i]) - a.begin();
                cnt += max(0LL, j - i - 1);
            }
            REP(i, b.size()) {
                if (b[i] == 0) {
                    cnt += b.size() - i - 1;
                } else {
                    Int j = upper_bound(b.begin(), b.end(), mid / b[i]) - b.begin();
                    cnt += max(0LL, j - i - 1);
                }
            }
        } else {
            REP(i, a.size()) {
                Int j = lower_bound(b.begin(), b.end(), (-mid + a[i] - 1) / a[i]) - b.begin();
                cnt += max(0LL, (Int)b.size() - j);
            }
        }
        return cnt >= K;
    };
    Int ok = 2e18, ng = -2e18;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 2548
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<numeric>
using namespace std;
#define N (1000000000+7)
//#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

class UnionFind {
public:
	vector<int>par, rank, node;
	UnionFind(int n) :par(n), rank(n, 0),node(n,1) {
		for (int i = 0;i < n;i++)par[i] = i;
	}
	void init(int n) {
		for (int i = 0;i < n;i++) {
			par[i] = i;
			rank[i] = 0;
			node[i] = 1;
		}
	}
 
	int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	void unite_tree(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	int root_size(int x){
		return rank[find(x)];
	}
 
	int size(int x) {
		return node[find(x)];
	}
 
	void unite_node(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (size(x) < size(y))swap(x, y);
		node[x] += node[y];
		par[y] = par[x];
	}
};

int main(void){
    int n;
    cin>>n;
    vector<ll>x(n),y(n);
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];

    using pint = pair<int,int>;
    using Edge = pair<ll,pint>;
    vector<Edge>edges;
    vector<int>ids(n);
    iota(ids.begin(),ids.end(),0);
    sort(ids.begin(),ids.end(),[&](int i,int j){return x[i]<x[j];});
    for(int i=0;i+1<ids.size();i++){
        int u = ids[i],v = ids[i+1];
        edges.push_back(Edge(x[v]-x[u],pint(u,v)));
    }
    sort(ids.begin(),ids.end(),[&](int i,int j){return y[i]<y[j];});
    for(int i=0;i+1<ids.size();i++){
        int u = ids[i],v = ids[i+1];
        edges.push_back(Edge(y[v]-y[u],pint(u,v)));
    }
    sort(edges.begin(),edges.end());
    UnionFind uf = UnionFind(n+1);
    ll res = 0;
    for(auto e:edges){
        int u = e.second.first,v = e.second.second;
        ll cost = e.first;
        if(uf.same(u,v))continue;
        uf.unite_node(u,v);
        res+=cost;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 9648
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var p = input[1].split(" ").map(i => parseInt(i));
  p.sort((a,b)=>a-b);
  var ans = 0;
  for(var i=0;i<K;i++){
    ans += p[i];
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29276
#include<stdio.h>
 int main(){
 int x;
 scanf("%d",&x);
 int c500 = x/500; // 500 円硬貨の数
 int r500 = x%500; // 端数
 int c5 = r500/5; // 5 円硬貨の数
 printf("%d\n",c500*1000+c5*5);
 }


Measured memory_bytes: 1688
# Problem A - Prefix and Suffix

# input
N = int(input())
s = list(input())
t = list(input())

# initialization
ans_str = 't'*3*N

# count
for i in range(N+1):
    is_ok = True
    tmp_str = ['']*2*N
    for j in range(N):
        tmp_str[j] = s[j]
    for j in range(N):
        if tmp_str[i+j]=='':
            tmp_str[i+j] = t[j]
        elif not tmp_str[i+j]==t[j]:
            is_ok = False
            break
    if is_ok:
        if len(tmp_str)<len(ans_str):
            ans_str = "".join(tmp_str)

# output
print(len(ans_str))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


ll find_adv(vector<ll> arr) {
    ll basic = arr[1];
    for(int i = 2; i < arr.size(); i++)
        basic = __gcd(basic, arr[i]);

    ll sec = arr[0];
    int prime = 0;
    for(int i = 1; i < arr.size(); i++) {
        ll third = __gcd(sec, arr[i]);
        if (third == 1){
            if (prime == 0)
                prime += 1;
            else
                return max(basic, 1ll);
        } else {
            sec = third;
        }
    }
    return max(basic, sec);
}

int main() {
    int N;
    cin >> N;
    vector<ll> arr(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    // brute force 10^10
    ll common_gcd = arr[0];
    for(int i = 1; i < N; i++) {
        common_gcd = __gcd(common_gcd, arr[i]);
    }
    for(int i = 0; i < N; i++) {
        arr[i] /= common_gcd;
    }
    cout << common_gcd * find_adv(arr) << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    char a, b;
    cin >> a >> b;
    if(a == 'H'){
        cout << b << endl;
    }
    else{
        if(b == 'H'){
            cout << 'D' << endl;
        }
        else{
            cout << 'H' << endl;
        }
    }
}

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

struct Card{char suit,value;};

//??????????????????????????????
void show_array(struct Card a[],int n){
  for(int i=0;i<n;i++){
    if(i>0) cout << " ";
    cout << a[i].suit << a[i].value;
  }
  cout << endl;
}

void BubbleSort(struct Card a[],int n){
  for(int i=0;i<n;i++){
    for(int j=n-1;j>i;j--){
      if(a[j].value<a[j-1].value){
        struct Card temp=a[j];
        a[j]=a[j-1];
        a[j-1]=temp;
      }
    }
  }
}

void SelectionSort(struct Card a[],int n){
  for(int i=0;i<n;i++){
    int index=0;
    int minv=a[i].value;
    for(int j=i+1;j<n;j++){
      if(a[j].value<minv){
        minv=a[j].value;
        index=j;
      }
      }
    if(i<index){
      struct Card temp;
      temp=a[i];
      a[i]=a[index];
      a[index]=temp;
    }
    }
  }

int main(){
  int n;
  cin >> n;
  struct Card cards1[n],cards2[n];
  for(int i=0;i<n;i++) {
    cin >> cards1[i].suit;
    cin >> cards1[i].value;
    cards2[i].suit=cards1[i].suit;
    cards2[i].value=cards1[i].value;
  }
  BubbleSort(cards1,n);
  show_array(cards1,n);
  cout << "Stable" << endl;
  SelectionSort(cards2,n);
  show_array(cards2,n);
  bool flag=true;
  for(int i=0;i<n;i++){
    if(cards1[i].suit != cards2[i].suit) flag=false;
  }
  if(flag) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

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

int main(){
    int N, T;
    int a[100010];
    int ma[100010];
    int dif[100010];
    cin >> N >> T;
    for(int i = 0; i < N; i++)  cin >> a[i];

    ma[N-1] = a[N-1];
    dif[N-1] = 0;
    for(int i = N-2; i >= 0; i--){
        ma[i] = max(ma[i+1], a[i]);
        dif[i] = ma[i] - a[i];
    }

    sort(dif, dif+N);

    int res = 1;
    for(int i = N-2; i >= 0; i--){
        if(dif[i] < dif[N-1]) break;
        res++;
    }

    cout << res << endl;

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N, M;
	cin >> N >> M;
	vector<vector<int>> K(N+1);
	vector<vector<int>> G(N + 1);
	int h[110000] = { 0, };
	fz(M) {
		int x, y;
		cin >> x >> y;
		K[x].push_back(y);
		G[y].push_back(x);
		h[x]++;
	}
	vec(C);
	stack<int> P;
	fx(N) {
		if (K[x+1].size()==0) {
			P.push(x+1);
		}
	}

	while (!P.empty()) {
		int w = P.top(); P.pop();
		pb(C, w);
		fx(G[w].size()) {
			h[G[w][x]]--;
			if (h[G[w][x]]==0) {
				P.push(G[w][x]);
			}
		}
	}

	int ans[110000];
	fx(N) {
		ans[x + 1] = -1;
	}
	fz(N) {
		int x = C[z]-1;
		if (ans[x+1]>=0) {
			continue;
		}
		queue<pair<int,int>> where;
		ans[x + 1] = 0;
		where.push(make_pair(x+1,0));
		while (!where.empty()) {
			auto h = where.front();
			where.pop();
			fy(K[h.first].size()) {
				if (ans[K[h.first][y]]>=0) {
					ans[x+1] = max(ans[x+1], h.second + ans[K[h.first][y]]+1);
				}
				else {
					ans[x+1] = h.second + 1;
					where.push(make_pair(K[h.first][y], ans[x+1]));

				}
			}

		}

	}

	int answer = 0;
	fx(N) {
		answer = max(answer, ans[x + 1]);
	}
	ce(answer)

    return 0;
}



Measured memory_bytes: 12540
from collections import deque
n,m=map(int,input().split())
graph=[[] for i in range(n)]
sirusi=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
D=deque([0])
visited=[False]*n
visited[0]=True
while D:
    v=D.popleft()
    for i in graph[v]:
        if visited[i]:continue
        visited[i]=True
        sirusi[i]=v
        D.append(i)
print("Yes")
for i in range(1,n):
    print(sirusi[i]+1)


Measured memory_bytes: 34844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
int divi[1001];

int main(void) {
  ll n, a, b;
  cin >> n >> a >> b;
  arrll(x,n);

  ll ans=0;
  rep(i,n-1){
    ans+=min((x[i+1]-x[i])*a, b);
  }

  prt(ans);
}


Measured memory_bytes: 1024
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)

x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)

print(x3, y3, x4, y4)

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int>x(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i];
    }
    int ans = 1e9;
    for(int i = 0; i < N-K+1; i++) {
        int hidari = x[i];
        int migi = x[i+K-1];
        int hajime = min(abs(0-hidari),abs(0-migi));
        ans = min(ans,migi-hidari+hajime);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
         c-=b;

        if(c <= 0){
            g("Yes");
            return;
        }
        a-=d;

        if(a <= 0){
            g("No");
            return;
        }

    }
}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
  //  cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N, K;
  cin>>N>>K;
  int saidai=0;
  if(N==2){
    if(K==0) cout<<"1\n1 2"<<endl;
    else cout<<-1<<endl;
    return 0;
  }
  for(int i=1;i<=N-2;i++){
    saidai+=i;
  }
  if(saidai<K){
    cout<<-1<<endl;
    return 0;
  }
  cout<<saidai-K+N-1<<endl;
  for(int i=2;i<=N;i++){
    cout<<1<<" "<<i<<endl;
  }
  int val=saidai;
  if(val==K){
    return 0;
  }
  for(int i=2;i<N;i++){
    bool flag=true;
    for(int j=i+1;j<=N;j++){
      cout<<i<<" "<<j<<endl;
      val--;
      if(val==K) {
        flag=false;
        break;
      }
    }
    if(!flag) break;
  }
  return 0;
}



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


int dp[100'000+5];      /// dp[i] = min cost to get from 0 to i

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

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

    vector<int> input(n);
    for(int i = 0; i<n; i++)
        cin>>input[i];


    dp[0] = 0;
    for(int i = 1; i<n; i++){
        dp[i] = 2'000'000'000;
        for(int j = 1; j<=k; j++){
            if(i-j >= 0)
                dp[i] = min(dp[i], dp[i-j] + abs(input[i] - input[i-j]) );
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  cout << string(ty-sy,'U') << string(tx-sx,'R') << string(ty-sy,'D') << string(tx-sx+1,'L');
  cout << string(ty-sy+1,'U') << string(tx-sx+1,'R') << 'D' << 'R' << string(ty-sy+1,'D') << string(tx-sx+1,'L') << 'U';
}

Measured memory_bytes: 256
/**
 * 照らされるマスの最大値
 * 
 * 1 <= H <= 2000
 * 1 <= W <= 2000
 * S[i](1 <= i <= H) は '#' か '.' のみからなる長さ W の文字列
 * '#' は壁, '.' は空きマス
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
    int h, w;
    char s[2000][2000] = {0};

    cin >> h >> w;
    for(int i = 0; i < h; i++) cin >> s[i];

    // k: i 列目（縦方向）の '.' の連続数
    // l: j 行目（横方向）の '.' の連続数 
    int k[2000] = {}, l[2000] = {};

    // 上端, 左端から見た時の '.' の連続数を格納する
    for(int i = 0; i < h; i++){
        while(s[i][k[i]] == '.' && k[i] < w) k[i]++;
    }
    for(int j = 0; j < w; j++){
        while(s[l[j]][j] == '.' && l[j] < h) l[j]++;
    }

    //
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            // s[i][j] が '#' だったら, 
            if(s[i][j] == '#'){
                //その '#' の右方向と下方向の '.' の連続数を調べて k[i],l[j] を更新する
                k[i] = l[j] = 0;
                while(s[i][k[i] + j + 1] == '.' && k[i] + j + 1 < w) k[i]++;
                while(s[l[j] + i + 1][j] == '.' && l[j] + i + 1 < h) l[j]++;
                //cout << 0;
            }
            // s[i][j] が '.' だったら
            else{
                //そのマスから照らせるマスの数と現在のansを比較する
                ans = max(ans, k[i] + l[j] - 1);
                //cout << k[i] + l[j] - 1;
            }
        }
        //cout << endl;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int suma = 0;
    int sumb = 0;
    for(int i = 0; i < 3;i++)
    {
        if(s[i] == 'A') suma++;
        else sumb++;
    }
    if(suma == 0 || sumb == 0)
    {
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
}


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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

bool isPalin(string s)
{
    string temp = s;
    reverse(temp.begin(), temp.end());
    rep(i,0,s.size()) if(s[i] != temp[i]) return false;
    return true;
}

int main()
{
    FastIO
    string s;
    cin >> s;
    int n = s.size();
    if(isPalin(s))
    {
        if(isPalin(s.substr(0,(n-1)/2)))
        {
            if(isPalin(s.substr((n+3)/2 - 1, n+1)))
            {
                cout << "Yes\n";
            }
            else cout << "No\n";
        }
        else cout << "No\n";
    }
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
data = np.array([int(i) for i in input().split()])
while True:
  datamin = data.min()
  data = data%datamin
  
  if data.sum()<=1:
    if data.sum()==0:
      print(datamin)
      exit()
    else:
      print(data[data>0].min())
      exit()
  data = np.append(datamin,data)
  data = data[data>0]


Measured memory_bytes: 23116