akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

const int MaxN = 1e5 + 15;
const int MOD = 1e9 + 7;
const long long INF = 1e18;

int n;
int a[MaxN];
int b[MaxN];

long long ans;
long long ans1;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

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

    sort(a, a + n);

    int l = n - 1;

    for(int i = 1; i < n; i += 2)
        b[i] = a[l--];

    b[0] = a[l--];
    for(int i = n - 1; i; --i)
        if(!b[i])
            b[i] = a[l--];

    for(int i = 1; i < n; ++i)
        ans += abs(b[i] - b[i - 1]);

    for(int i = 0; i < n; ++i)
    {
        a[i] = -a[i];
        b[i] = 0;
    }
    sort(a, a + n);

    l = n - 1;

    for(int i = 1; i < n; i += 2)
        b[i] = a[l--];

    b[0] = a[l--];
    for(int i = n - 1; i; --i)
        if(!b[i])
            b[i] = a[l--];

    for(int i = 1; i < n; ++i)
        ans1 += abs(b[i] - b[i - 1]);

    cout << max(ans1, ans) << '\n';
}


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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

vector <ll> adj[maxn], tpl, rev[maxn];
ll par[maxn], rt, n, m, pos[maxn];
bool vis[maxn];


void dfs(ll v) {
	vis[v] = true;
	for (auto u : adj[v])
		if (!vis[u])
			dfs(u);
	tpl.pb(v);
}

int main() {
	fio();
	cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		ll fr, to;
		cin >> fr >> to;
		fr--, to--;
		adj[fr].pb(to);	
		rev[to].pb(fr);
	}
	for (int i = 0; i < n; i++) {
		if (!vis[i])
			dfs(i);
	}
	reverse(tpl.begin(), tpl.end());
	for (int i = 0; i < n; i++) 
		pos[tpl[i]] = i;	
	rt = tpl[0];
	for (int i = 0; i < n; i++) {
		ll curPar = 0, curPos = -1;
		for (auto u : rev[i]) {
			if (pos[u] > curPos) {
				curPos = pos[u];
				curPar = u;	
			}
		}
		par[i] = curPar;
	}
	for (int i = 0; i < n; i++)
		(i == rt) ? cout << "0\n" : cout << par[i] + 1 << "\n";
	return 0;
}

Measured memory_bytes: 17528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
     long long int n,ans,k=0;
    cin>>n;
    ans=(n*(n+1))/2;
    for(int i=2;i<=n;i++){
     for(int j=i;j<=n;j+=i)
         {
            
           ans+=j;
            
          }
        }
   
      cout<<ans;
        
    
    
}

Measured memory_bytes: 3624
def Is_prime(n):
    # nが1以下ならFalse
    if n<=1:
        return False
    # nが2または3ならTrue
    if n==2 or n==3:
        return True
    # nが2の倍数ならFalse
    if n%2==0:
        return False
    # nの平方根を整数で取得
    sqrt_root = int(n**.5)
    # nがnの平方根以下の3以上の奇数で1回でも割れたらFalse
    for i in range(3,sqrt_root+1,2):
        if n%i==0:
            return False
    # 上の条件を全てぬけたものはTrue
    return True

N = int(input())
while True:
    if Is_prime(N):
        print(N)
        exit()
    N += 1

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

ll max(ll a,ll b)
{
  if(a > b)
  {
    return a;
  }
  return b;
}

int main()
{
  int n,m;
  cin >> n >> m;
  vector<ll> h(n+1);
  vector<ll> ma(n+1);
  for(int i = 1;i <= n;i++)
  {
    cin >> h[i];
    ma[i] = 0;
  }
  for(int i = 0;i < m;i++)
  {
    int a,b;
    cin >> a >> b;
    ma[a] = max(ma[a],h[b]);
    ma[b] = max(ma[b],h[a]);
  }
  int ans = 0;
  for(int i = 1;i <= n;i++)
  {
    if(h[i] > ma[i])
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  string s,t;
  cin>>n;
  cin>>s>>t;
  for(i=0;i<2*n;i++){
    if(i%2==0)cout<<s[i/2];
    else cout<<t[(i-1)/2];
  }
  cout<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

type Pair struct {
	b int
	c int
}

func solve(n, m int, a, b, c []int) int {
	p := make([]Pair, m)
	for i := 0; i < m; i++ {
		p[i] = Pair{b[i], c[i]}
	}
	sort.Slice(p, func(i, j int) bool {
		return p[i].c > p[j].c
	})

	d := make([]int, n)
	k := 0
	for i := 0; i < m; i++ {
		for j := 0; j < p[i].b; j++ {
			d[k] = p[i].c
			k++
			if k >= n {
				break
			}
		}
		if k >= n {
			break
		}
	}

	merged := append(a, d...)
	sort.Sort(sort.Reverse(sort.IntSlice(merged)))
	ans := 0
	for i := 0; i < n; i++ {
		ans += merged[i]
	}
	return ans
}

func main() {
	n, _ := strconv.Atoi(input())
	m, _ := strconv.Atoi(input())
	a := make([]int, n)
	b := make([]int, m)
	c := make([]int, m)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}
	for i := 0; i < m; i++ {
		b[i], _ = strconv.Atoi(input())
		c[i], _ = strconv.Atoi(input())
	}
	fmt.Println(solve(n, m, a, b, c))
}


Measured memory_bytes: 9872
#include<stdio.h>

int main(){
    int n,sum=0;
    int a[21];
    int b[21];
    int c[20];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int j=0;j<n;j++){
        scanf("%d",&b[j]);
    }
    for(int k=0;k<n-1;k++){
        scanf("%d",&c[k]);
    }
    for(int l=0;l<n;l++){
        sum+=b[a[l]-1];
        if((a[l]+1==a[l+1])&&(l<n-1)){
            sum+=c[a[l]-1];
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

struct LowestCommonAncestor {
    size_t n;
    size_t size() const { return n; }
    enum { B = 1000 };
    vector<int> color, par, depth, depthTop, goUp, vis;
    vector<vector<int>> g;
    LowestCommonAncestor(size_t n_) : n(n_), g(n) {}
    void addEdge(int u, int v){
        g[u].push_back(v); g[v].push_back(u);
    }
    void decomp(int root){
        color.assign(n, 0); par.assign(n, -1); depth.assign(n, 0);
        depthTop.assign(n, 0); goUp.assign(n, -1); vis.assign(n, false);
        vector<int> tord;
        vector<int> q(n+1); int l = 0, r = 0;
        q[r++] = root;
        while(l != r){
            int v = q[l++]; vis[v] = true;
            tord.push_back(v);
            for(int c : g[v]){
                if(vis[c]) continue;
                q[r++] = c;
                par[c] = v; depth[c] = depth[v] + 1;
            }
        }
        vis.assign(n, false);
        int c = 0;
        for(int u : tord){
            if(vis[u]) continue;
            l = 0, r = 0;
            q[r++] = u;
            for(int i = 0; i < B && l != r; i++){
                int v = q[l++];
                vis[v] = true; color[v] = c; goUp[v] = par[u]; depthTop[v] = depth[u];
                for(int c : g[v]) if(!vis[c]) q[r++] = c;
            }
            c++;
        }
    }
    int solve(int u, int v){
        while(color[u] != color[v]){
            if(depthTop[u] > depthTop[v]) u = goUp[u];
            else v = goUp[v];
        }
        while(u != v){
            if(depth[u] > depth[v]) u = par[u];
            else v = par[v];
        }
        return u;
    }
};

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

int main(){
    int n;
    cin >> n;
    LowestCommonAncestor g(n);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g.addEdge(i,c);
        }
    }
    g.decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << g.solve(u,v) << endl;
    }
}

Measured memory_bytes: 10288
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m; cin>>n>>m;
    //m個の要素を0で初期化する
    vector<int> count(m,0);
    //それぞれの数が好きな人数を数える
    for(int i=0;i<n;i++){
        int k; cin>>k;
        for(int j=0;j<k;j++){
            int a; cin>>a; a--;
            ++count[a];
        }
    }
    int ans=0;
    for(int i=0;i<m;i++){
        if(count[i]==n) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int minCoins(int coins[], int m, int value) {
    int dp[value+1];
 
    dp[0] = 0;
 
    for (int i=1; i<=value; i++)
        dp[i] = INT_MAX;
 
    for (int i=1; i<=value; i++)
    {
        for (int j=0; j<m; j++)
          if (coins[j] <= i)
          {
              int sub_res = dp[i-coins[j]];
              if (sub_res != INT_MAX && sub_res + 1 < dp[i])
                  dp[i] = sub_res + 1;
          }
    }
    return dp[value];
}

int main() {
    int coins[] =  {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 59049, 46656, 531441, 279936, 4782969};
    int m = sizeof(coins)/sizeof(coins[0]);
    int value;

    cin >> value;
    cout << minCoins(coins, m, value) << endl;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    int m=n, sum=0;
    while(m>0){
        sum+=(m%10);
        m/=10;
    }
    if(n%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int mn = n+1;
    int ans = 0;
    rep(i,n){
        if(a[i]<mn) ans++;
        chmin(mn,a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    problem_count = int(input())
    elapsed_times = list(map(int, input().split()))
    drink_kind_count = int(input())
    effects = [list(map(int, input().split())) for i in range(drink_kind_count)]

    total_elapsed_time = sum(elapsed_times)

    for problem_p, new_elapsed_time, in effects:
        print(total_elapsed_time + (new_elapsed_time - elapsed_times[problem_p - 1]))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <complex>
#include <iomanip>

#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ld a, b, x;
  std::cin >> a >> b >> x;
  if(x<=a*a*b/2){
    ld y = 2*x/(a*b);
    complex<ld> k(y, b);
    //std::cout << b << " " << y << '\n';
    std::cout << fixed << setprecision(20) << arg(k)/M_PI * 180.0 << '\n';
  }else{
    ld k = a*a*b - x;
    ld bd = 2*k/(a*a);
    complex<ld> t(a, bd);
    //std::cout << a << " " << bd << '\n';
    std::cout << fixed << setprecision(20) << arg(t)/M_PI * 180.0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    long long x,y;
    while(cin >> x >> y)
    {
        int i=0;
        for(i=0;i<70;i++)
        {
            if(x>y)
                break;
            x=x*2;
        }
         printf("%d\n",i);
    }
    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    vector<int> acard(a),bcard(b);
    for (int i = 0; i < a; ++i) {
        cin>>acard[i];
    }
    for (int i = 0; i < b; ++i) {
        cin>>bcard[i];
    }
    int ok=0;
    int ng=max(a,b)+1;
    int mid=(ok+ng)/2;
    bool canmake;
    while(ng-ok>1){//にぶたん
        mid=(ok+ng)/2;
        canmake=false;
        for (int i = 0; i+mid <= bcard.size(); ++i) {
            int pos=i;
            for (int j = 0; j < acard.size(); ++j) {
                if(acard[j]==bcard[pos])++pos;
            }
            if(pos-i==mid){
                canmake=true;
                break;
            }
        }
        if(canmake)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 3096
N = [int(i) for i in input()] 

flag = ["","",""]

for i in range(1 << len(N)-1):
	result = N[0]
	for j in range(len(N)-1):
		if ((i >> j) & 1) == 1:
			result += N[j+1]
			flag[j] = "+"
		else:
			result -= N[j+1]
			flag[j] = "-"

	if result == 7:
		break

print("%d%s%d%s%d%s%d=7" %(N[0],flag[0],N[1],flag[1],N[2],flag[2],N[3]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
T Prim(WeightedGraph<T> &g)
{
    T res = 0;
    vector<bool> used(g.size(), false);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    que.emplace(0, 0);
    while (que.empty() != true)
    {
        auto p = que.top();
        que.pop();
        if (used[p.second] == true)
            continue;
        used[p.second] = true;
        res += p.first;
        for (auto &e : g[p.second])
        {
            que.emplace(e.cost, e.to);
        }
    }
    return res;
}

int N;

int main()
{
    cin >> N;
    vector<pair<pair<int, int>, int>> x, y;
    WeightedGraph<int> G(N);

    for (int i = 0; i < N; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;
        x.emplace_back(make_pair(a, b), i);
        y.emplace_back(make_pair(b, a), i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int i = 0; i + 1 < N; i++)
    {
        int a, b, c, d, p1, p2;
        a = x[i].first.first, b = x[i].first.second, c = x[i + 1].first.first, d = x[i + 1].first.second, p1 = x[i].second, p2 = x[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - c), abs(b - d)));
        G[p2].emplace_back(p1, min(abs(a - c), abs(b - d)));

        a = y[i].first.first, b = y[i].first.second, c = y[i + 1].first.first, d = y[i + 1].first.second, p1 = y[i].second, p2 = y[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - c), abs(b - d)));
        G[p2].emplace_back(p1, min(abs(a - c), abs(b - d)));
    }

    printf("%d\n", Prim(G));
}

Measured memory_bytes: 14508
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	char n[10001];
	cin>>n;
	int m;
	int l=strlen(n);
	for(int i=0;i<l;i++){
		m=(int)n[i];
		m-=3;
		if(m<65){
			m+=26;
		}
		cout<<(char)m;
	}
	cout<<endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;
ll cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// 感覚gを指定した挿入ソート
void insertionSort(int A[], int n, int g){
    int v,j;
    for(int i = g; i < n; ++i){
        v = A[i];
        j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }

}

void shellSort(int A[],int n){
    // 数列G = {1,4,13,40,121,364,....}(g(n+1) = 3g(n)+1)を生成
    for(int h=1; ; ){
        if(h > n) break;
        G.push_back(h);
        h = 3*h+1;
    }
    for(int i = G.size()-1;i >= 0;--i){
        insertionSort(A,n,G[i]);
    }

}
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    REP(i,n) cin >> A[i];
    cnt = 0;

    shellSort(A,n);

    // 以下は表示
    cout << G.size() << endl;
    for(int i = G.size()-1;i >= 0;--i){
        cout <<  G[i];
        if(i) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    REP(i,n) cout << A[i] << endl;



    return 0;
}


Measured memory_bytes: 7136
#include<stdio.h>
int main(){
	int n=0,i=0,j;
	int A[10000],B[10000],a[10000],b[10000];
	for(j=0;;j++){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]>b[i]){
			A[j]=A[j]+a[i]+b[i];
		}
			else if(a[i]<b[i]){
			B[j]=B[j]+a[i]+b[i];
		}
			else if(a[i]==b[i]){
			A[j]=A[j]+a[i];
			B[j]=B[j]+b[i];
		}
	}
	printf("%d %d\n",A[j],B[j]);
}
	return 0;
}



Measured memory_bytes: 2012
def resolve():
    N = int(input())
    from collections import defaultdict
    cnt = defaultdict(int)
    for _ in range(N):
        cnt[input()] += 1
    items = sorted(cnt.items(), key=lambda x: (-x[1], x[0]))
    max_v = items[0][1]
    for item in items:
        if max_v != item[1]:
            break
        print(item[0])

resolve()

Measured memory_bytes: 59492
n,k=map(int,input().split())
s=input()

if n==1:
  print(s.lower())
elif k==1:
  print(s[0].lower()+s[1:])
elif k==n:
  print(s[:n-1]+s[n-1].lower())
else:
  print(s[:k-1]+s[k-1].lower()+s[k:])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

struct E{ll to,co,ti;};
struct P{ll ti,id,re;};
bool operator <(const P &a,const P &b) {return a.ti>b.ti;}
ll dp[50][5001],c[50],d[50],ans[50],n,m,s;
vector<E> edge[50];
priority_queue<P> que;

int main() {
  cin >> n >> m >> s;
  for(ll i=0;i<m;i++) {
    ll u,v,a,b;
    cin >> u >> v >> a >> b;
    u--;v--;
    edge[u].push_back({v,a,b});
    edge[v].push_back({u,a,b});
  }
  for(ll i=0;i<n;i++) cin >> c[i] >> d[i];
  que.push({1,0,min(5000LL,s)});
  while(que.size()) {
    P p=que.top();
    que.pop();
    if(dp[p.id][p.re])continue;
    dp[p.id][p.re]=p.ti;
    if(!ans[p.id])ans[p.id]=p.ti;
    for(E q:edge[p.id]) {
      if(p.re>=q.co&&!dp[q.to][p.re-q.co]) {
        que.push({p.ti+q.ti,q.to,p.re-q.co});
      }
    }
    if(p.re+c[p.id]<=5000) que.push({p.ti+d[p.id],p.id,p.re+c[p.id]});
  }
  for(ll i=1;i<n;i++) cout << --ans[i] << endl;
}

Measured memory_bytes: 17204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
int n;
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k;cin>>k;
        rep(j,k){
            int x;cin>>x;
            s[i].push_back(x);
        }
    }
    vector<int> p(m);
    rep(i,m) cin>>p[i];
    int res=0;
    for(int tmp=0;tmp<(1<<n);tmp++){
        bitset<10> ss(tmp);
        //cout<<ss<<endl;
        bool jud=false;
        rep(i,m){
            int t=0;
            rep(j,s[i].size()){
                int buf=s[i][j]-1;
                if(ss[buf]==1) t++;
            }
            if(t%2!=p[i]){
                jud=true;
                break;
            }
        }
        if(!jud){
            res++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMAX）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int Y[]={1,1, 1,0,0, 0,-1,-1,-1};
int X[]={1,0,-1,1,0,-1, 1, 0,-1};
int main(){
  int h,w,n,i,j,ny,nx;
  long long a,b,c[10]={0};
  scanf("%d %d %d",&h,&w,&n);//printf("%d %d %d\n",h,w,n);
  for(i=0;i<n;i++){//printf("%d\n",i);
    scanf("%lld %lld",&a,&b);
    for(j=0;j<9;j++){
      ny=a+Y[j];
      nx=b+X[j];
      if(ny>=h||ny<2||nx>=w||nx<2)continue;//printf("%d %d\n",ny-1,nx-1);
      hin((ny-1LL)*w+nx-1);
    }//printf("\n");
  }//printf("a\n");
  if(C-1){
    b=N[hout()];
    for(j=1;C-1;){//printf("%lld %lld\n",b/w,b%w);
      a=N[hout()];
      if(b==a)j++;
      else{
	c[j]++;
	j=1;
      }
      b=a;
    }
    c[j]++;
  }
  c[0]=(h-2LL)*(w-2);
  for(i=1;i<10;i++)c[0]-=c[i];
  for(i=0;i<10;i++)printf("%lld\n",c[i]);
  return 0;
}


Measured memory_bytes: 14208
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import heapq
INF = 10**18

def dijkstra(start, G):
    done = [False]*(len(G))
    dist = [INF]*(len(G))
    dist[start] = 0
    h = []
    heapq.heappush(h, [0, start])
    while h:
        _, cur = heapq.heappop(h)
        if done[cur]: continue
        done[cur] = True
        for to, cost in G[cur]:
            if dist[cur]+cost < dist[to]:
                dist[to] = dist[cur]+cost
                heapq.heappush(h, [dist[to], to])
    return dist

H, W = map(int, input().split())
sh, sw = map(lambda x: int(x)-1, input().split())
gh, gw = map(lambda x: int(x)-1, input().split())
S = [input() for _ in range(H)]
done = [[-1]*W for _ in range(H)]
def dfs(h, w, num):
    done[h][w] = num
    for dh, dw in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        nh, nw = h+dh, w+dw
        if not (0 <= nh < H and 0 <= nw < W and S[nh][nw] == "."):
            continue
        if done[nh][nw] == -1:
            dfs(nh, nw, num)
num = 0
for i in range(H):
    for j in range(W):
        if done[i][j] == -1 and S[i][j] == ".":
            dfs(i, j, num)
            num += 1
G = [[] for _ in range(num)]
done2 = {}
for h in range(H):
    for w in range(W):
        if S[h][w] != ".": continue
        fr = done[h][w]
        for ii in range(-2, 3):
            for jj in range(-2, 3):
                nh, nw = h+ii, w+jj
                if not (0 <= nh < H and 0 <= nw < W and S[nh][nw] == "."):
                    continue
                to = done[nh][nw]
                if fr != to and (not (fr, to) in done2):
                    done2[(fr, to)] = True
                    done2[(to, fr)] = True
                    G[fr].append((to, 1))
                    G[to].append((fr, 1))
D = dijkstra(done[sh][sw], G)
ans = D[done[gh][gw]]
if ans != INF:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 188688
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
  string S;
  cin >> S;
  
  sort((S).begin(), (S).end());
  int i=0;
  for(char a='a'; a<='z'; a++){
    int count=0;
    while( true){
      if(S[i] == a) {
       count++;
       i++;
      }else{
       break;
      } //if
    } //while
   
    if(count == 0){
     cout << a  << "\n";
     return 0;
    } //if
  }//for
   
  cout << "None" << "\n";
 }


Measured memory_bytes: 3728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B;

int main() {
  std::cin >> A >> B;
  --A; --B;

  std::cout << (B+A-1)/A << endl;

  return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> grid(H+2, vector<int>(W+2, 1));
    vector<vector<int>> now;
    vector<vector<int>> nxt;
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '.') grid[i+1][j+1] = 0;
            else now.push_back({i+1, j+1});
        }
    }
    int cnt = 0;
    while (!now.empty()) {
        for (vector<int> p : now) {
            vector<vector<int>> lrud;
            lrud = {{p[0]+1, p[1]}, {p[0]-1, p[1]}, {p[0], p[1]+1}, {p[0], p[1]-1}};
            for (vector<int> q : lrud) {
                if (grid[q[0]][q[1]] == 0) {
                    grid[q[0]][q[1]] = 1;
                    nxt.push_back(q);
                }
            }
        }
        if (nxt.empty()) break;
        now = nxt;
        nxt.clear();
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 60324
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=998244353;
int a[3005][3005];
ll dp[3005][3005][5];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r,c,k;
    cin>>r>>c>>k;
    while(k--)
    {
        int x,y,z;
        cin>>x>>y>>z;
        a[x][y]=z;
    }
    ll ans=0;

    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
            ans=max(ans,dp[i][j][0]);
            for(int x=1;x<=3;x++)
            {
                dp[i][j][x]=max(dp[i-1][j][3]+a[i][j],max(dp[i][j-1][x],dp[i][j-1][x-1]+a[i][j]));
                ans=max(ans,dp[i][j][x]);
            }
        }
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 390908
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)

int main(){
	ll n,m;
	cin>>n>>m;
	ll s=0;
	for(ll i=0;i<m;i++){
		ll val;
		cin>>val;
		s+=val;
	}
	if(s>n){
		cout<<-1;
		return 0;
	}else{
		cout<<(n-s);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#define rep(i,n) for(int i = 0 ; i < n ; i++)

using namespace std;

int a[4];

int calc(int a,char c,int b){
  if(c == '+'){
    return a + b;
  } else if(c == '-'){
    return a - b;
  }
  return a * b;
}

bool t(int res){
  if(res == 10){
    return true;
  }
  return false;
}

string op = "+-*";

void solve(bool &found){
  rep(i,3) rep(j,3) rep(k,3){
	if(t(calc(calc(a[0],op[i],calc(a[1],op[j],a[2])),op[k],a[3]))){
	  printf("((%d %c (%d %c %d)) %c %d)\n" 
		 ,a[0],op[i],a[1],op[j],a[2],op[k],a[3]);

	  found = true;
	  return;
	} 
	if(t(calc(calc(a[0],op[i],calc(a[1],op[j],a[2])),op[k],a[3]))){
	  printf("(%d %c (%d %c %d) %c %d)\n" 
		 ,a[0],op[i],a[1],op[j],a[2],op[k],a[3]);

	  found = true;
	  return;
	} 
	if(t(calc(calc(a[0],op[i],a[1]),op[j],calc(a[2],op[k],a[3])))){
	  printf("((%d %c %d) %c (%d %c %d))\n" 
		 ,a[0],op[i],a[1],op[j],a[2],op[k],a[3]);

	  found = true;
	  return;
	}
  }

}

int main(){
  while(true){
    rep(i,4){
      cin >> a[i]; 
    }

    if(a[0] == 0) break;
    sort(a,a+4);

    bool found = false;

    do{
      found = false;
      solve(found);
      if(found) break;
    } while(next_permutation(a,a+4));    

    if(!found){
      cout << "0" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1244
import math

a, b, c = map(float,input().split())
c = math.radians(c)
S = (1/2) * a * b * math.sin(c)

d = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * math.cos(c)))
L = a + b + d

H = (2 * S) / a

print(S,L,H)

Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int a,b; cin>>a>>b;
if((a%3==0) or(b%3==0) or((a+b)%3)==0) cout<<"Possible";
else cout<<"Impossible";
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

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

    int main(){
        string s;cin>>s;
        rep(i,s.size()-1){
            if(s[i]==s[i+1]){
                cout<<"Bad";
                return 0;
            }
        }
        cout<<"Good";
    }
    


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

using namespace std;

const int maxn=2e5, maxm=20;

int n;


vector < int > rek(int m, int a, int b, vector < bool > fiksirano){
	if(m==2){
		vector < int > l;
		l.push_back(a);
		l.push_back(b);
		return l;
	}
	int ind;
	for(int i=0; i<n; i++){
		if(((1<<i)&a)!=((1<<i)&b) && !fiksirano[i]){
			fiksirano[i]=1;
			ind=i;
			break;
		}
	}
	int c, d;
	for(int i=0; i<n; i++){
		if(!fiksirano[i]){
			c=a^(1<<i);
			d=c^(1<<ind);
			break;
		}
	}
	vector < int > v1, v2;
	v1=rek(m/2, a, c, fiksirano);
	v2=rek(m/2, d, b, fiksirano);
	for(int i=0; i<m/2; i++){
		v1.push_back(v2[i]);
	}
	return v1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	int a, b;
	cin >> a >> b;
	int br=0;
	for(int i=0; i<n; i++){
		if((a&(1<<i))!=(b&(1<<i))){
			br++;
		}
	}
	if(br%2==0){
		cout << "NO\n";
		return 0;
	}
	vector < bool > x(maxm, 0);
	cout << "YES\n";
	vector < int >  s=rek((1<<n), a, b, x);
	for(int i=0; i<(1<<n); i++){
		cout << s[i] << " ";
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <deque>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <map>
#include <stack>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//container util
//------------------------------------------
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())



int N;
vector<int> a;

int main(void)
{
    cin >> N;
    for(int i = 0; i < N; i++){
        int n;
        cin >> n;
        a.push_back(n);
    }

    //sort(a.begin(), a.end());
    int cnt = 0;
    for(int i = 0; i < N; i++){
        //printf("i=%d, a[i]=%d, a[a[i]]=%d\n", i, a[i], a[a[i]]);
        if(i + 1 == a[a[i]-1]){
            cnt++;
        }
    }
    
    printf("%d\n", cnt/2);
    return 0;
}


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

int main() {
	int a[5], k;
	bool check = true;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	if (a[4] - a[0] > k) check = false;
	if (!check) cout << ":(";
	else cout << "Yay!";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

int f(int x) {
  if (x == 3) return 100000;
  if (x == 2) return 200000;
  if (x == 1) return 300000;
  return 0;
}

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

  int x, y;
  cin >> x >> y;
  
  int ans = 0;
  if (x == 1 && y == 1) ans += 400000;
  ans += f(x);
  ans += f(y);
  cout << ans << endl;
}


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

using namespace std;
const int N = 2e6+100;
long long A[N],B[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>A[i];
	long long now=0;
	for(int i=1;i<=n;i++){
		if(i&1) now+=2*A[i];
		else now-=2*A[i];
	}
	B[1]=now/2;
	for(int i=2;i<=n-1;i++){
		B[i]=2*A[i-1]-B[i-1];
	}
	B[n]=2*A[n]-B[1];
	for(int i=1;i<=n-1;i++) cout<<B[i]<<' ';
		cout<<B[n]<<endl;
	return 0;
}

Measured memory_bytes: 6144
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()

ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
           ans += G(i, G(j, k))

print(ans)
            


Measured memory_bytes: 9356
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  double A, B, C, D;
  cin >> A >> B >> C >> D;
  string ans;
  while (true) {
    C -= B;
    if (C <= 0) {
      ans = "Yes";
      break;
    }
    A -= D;
    if (A <= 0) {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3748
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ios::sync_with_stdio(false);
  ll n, t;
  cin >> n >> t;
  vector<ll> vt(n);
  rep(i, n) cin >> vt.at(i);

  vector<ll> v(n);
  rep(i, n-1) v.at(i) = vt.at(i+1) -vt.at(i);
  v.at(n-1) = t;
  for (auto &i : v){
    if(i>=t) i=t;
  }
  ll sum = accumulate(all(v), 0);

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3456
package main

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

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	var n int
	n, _ = strconv.Atoi(inputln())
	r := make([]int, n)

	for i := range r {
		r[i], _ = strconv.Atoi(inputln())
	}
	minRate := r[0]
	maxVal := -2000000000

	for i := 1; i < n; i++ {
		maxVal = max(maxVal, r[i]-minRate)
		minRate = min(minRate, r[i])
	}

	fmt.Println(maxVal)
}



Measured memory_bytes: 5372
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


struct AB {
    int a;
    int b;
    
    bool operator<( const AB& right ) const {
        return a == right.a ? a < right.a : b < right.b;
    }
};


int main()
{
    int N, M;
    cin >> N >> M;
    
    vector<AB> ab(M);
    for( int i = 0; i < M; ++i ){
        int tmpa, tmpb;
        cin >> tmpa >> tmpb;
        ab[i].a = tmpa;
        ab[i].b = tmpb;;
        if( ab[i].b < ab[i].a )
            swap(ab[i].a, ab[i].b);
    }
    
    sort(ab.begin(), ab.end());
    
    /*
    for( auto itr = ab.begin(); itr != ab.end()-1; ++itr ){
        if( itr->a == (itr+1)->a && itr->b == (itr+1)->b ){
            ab.erase(itr+1);
            --itr;
        }
    }
    */
    
    
    vector<int> ans(N, 0);
    for( auto itr = ab.begin(); itr != ab.end(); ++itr ){
        ++ans[itr->a-1];
        ++ans[itr->b-1];
    }
    
    
    for( int i = 0; i < N; ++i ){
        cout << ans[i] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
X.sort()
min_HP = 10**9
for P in range(1,max(X)+1):
    S = 0
    for j in X:
        S += (j-P)**2
    if S<min_HP:
        min_HP = S
print(min_HP)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std; 
int main()
{
	ll x;
	cin>>x;
	ll now=100;
	ll cnt=0;
	while(now<x)
	{
		now=now*(1+0.01);
		cnt++;
	}
	cout<<cnt;
	return 0;
}

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

string s1, s2;

int main(){
	cin >> s1 >> s2;
	int ans = s1.size();
	rep(i, s1.size() - s2.size() + 1){
		int cnt = 0;
		rep(j, s2.size()){
			if(s2[j] != s1[i + j]) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){
	long long N;
	cin>>N;
	
	vector<long long> p(N);
	for(long long i=0;i<N;i++){
		cin>>p[i];
		p[i]--;
	}
	int k = 20005;
	vector<long long> a(N),b(N);
	for(long long i=0;i<N;i++){
		a[i]=(i+1)*k;b[i]=(N-(i))*k;
	}
	
	for(int i=0;i<N;i++){
		a[p[i]] += i+1;
	}
	
	
	for(long long i=0;i<N;i++){
		if(i!=0)cout<<' ';
		cout<<a[i];
	}
	cout<<endl;
	
	for(long long i=0;i<N;i++){
		if(i!=0)cout<<' ';
		cout<<b[i];
	}
	cout<<endl;
	
	
	
	
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------


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

	string ans="ai1333";
	int x;cin>>x;
	while(x) ans+='3',x-=100;
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include <utility>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
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; }

int n;
vector<vector <int>> happy(100010, vector<int>(3,-1));
vector<vector <int>> h_(100010, vector<int>(3, 0));


int main(){
	cin >> n;
	for (int i = 0;i<n;i++) cin >> h_.at(i).at(0) >> h_.at(i).at(1) >> h_.at(i).at(2);
	happy.at(0).at(0) = h_.at(0).at(0);
	happy.at(0).at(1) = h_.at(0).at(1);
	happy.at(0).at(2) = h_.at(0).at(2);

	for (int i = 1;i < n;i++){
		for (int j = 0;j < 3;j++){
			for (int k = 0;k < 3;k++){
				if (j == k) continue;
				chmax(happy.at(i).at(j), happy.at(i-1).at(k) + h_.at(i).at(j));
			}
		}
	}
	int kari = happy.at(n-1).at(0);
	chmax(kari, happy.at(n-1).at(1));
	chmax(kari, happy.at(n-1).at(2));
	cout << kari << endl;
}

Measured memory_bytes: 11136
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,0,n) cin >> d[i];
    int sum=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            sum+=d[i]*d[j];
        }
    }
    cout << sum ENDL;

    
    return 0;
}

Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            string sT = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < sT.Length; i++)
            {
                if (sS[i] == sT[i]) { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool fail() {
    cout << "UNSAFE" << endl;
    return true;
}

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;

    string S;
    cin >> S;

    vector<vector<bool>> dp(1 << 10, vector<bool>(10, false));
    int bit = 0;
    for (char c : S) {
        if (c == 'u') {
            bit = 0;
        } else {
            int ci = c - '0';
            int b = 1 << ci;
            if ((b & bit) != 0) return fail();

            dp[bit][ci] = true;
            bit |= (1 << ci);
        }
    }

    for (int A = 0; A < (1 << 10); ++A) {
        for (int B = 0; B < 10; ++B) {
            if (!dp[A][B]) continue;

            for (int C = 0; C < (1 << 10); ++C) {
                if ((A & C) || !((C >> B) & 1)) continue;

                for (int D = 0; D < 10; ++D) {
                    if (!dp[C][D]) continue;
                    dp[A | C][D] = true;
                }
            }
        }
    }

    for (int A = 0; A < (1 << 10); ++A) {
        for (int B = 0; B < 10; ++B) {
            if (!dp[A][B]) continue;

            for (int C = 0; C < (1 << 10); ++C) {
                if (A & C) continue;
                for (int D = 0; D < 10; ++D) {
                    if (!dp[C][D]) continue;

                    if (((A >> D) & 1) && ((C >> B) & 1)) {
                        return fail();
                    }
                }
            }
        }
    }

    cout << "SAFE" << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}


Measured memory_bytes: 3228