akhauriyash/Code-Regression huggingface dataset:
N=int(input())
R,d,f,s=sorted(list(map(int,input().split()))for i in range(N))+[(2e9,0)],[0]*N+[1],[0]*N,1
for i in range(N-1,-1,-1):
    x=i+1
    while x<N and R[x][0]<sum(R[i]):x=f[x]
    f[i]=x
    d[i]=s=(s+d[x])%998244353
print(d[0])

Measured memory_bytes: 64040
#include <iostream>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

int main(){
  int n, x;
  

  while(1){
    cin >> n >> x;
    int ans = 0;
    if( n == 0 && x == 0 ){
      break;
    }
    for(int a = 1; a <= n-2; a++){
      for(int b = a+1; b <= n-1; b++){
        for(int c = b+1; c <=n; c++){
          if( a+b+c == x ){
            ans += 1;
          }
        }
      } 
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
n=gets.to_i
arr=[]
(n-1).times{
    
    arr<<gets.split.map(&:to_i)}
    
    
k=1
(n-1).times{

time=0
i=k-1
key=0
(n-k).times{
    if time<=arr[i][1]
        time=arr[i][1]+arr[i][0]
        i+=1
    elsif  time%arr[i][2]==0
        time+=arr[i][0]
        i+=1
   else 
       key=time/arr[i][2]
       time=(key+1)*arr[i][2]+arr[i][0]
        
        i+=1
        
    end
        
       
}
puts time

k+=1

}
puts 0

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

using namespace std;

vector<int> p;

void group(int node, vector<bool>& bes, vector<vector<int> >& adj, vector<int>& g1, vector<int>& g2){
    bes[node] = 1;
    g1.push_back(node);
    g2.push_back(p[node]);
    for(int ne: adj[node]){
        if(!bes[ne]){
            group(ne, bes, adj, g1, g2);
        }
    }
}

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

    for(int i = 0; i < n; i++){
        int pi;
        cin >> pi;
        p.push_back(pi-1);
    }

    vector<vector<int> > adj(n);

    for(int i = 0; i < m; i++){
        int xi, yi;
        cin >> xi >> yi;
        xi--;
        yi--;
        adj[xi].push_back(yi);
        adj[yi].push_back(xi);
    }

    vector<bool> bes(n);
    int sol = 0;

    for(int i = 0; i < n; i++){
        if(!bes[i]){
            vector<int> g1, g2;
            group(i, bes,adj, g1, g2);

            sort(g1.begin(), g1.end());
            sort(g2.begin(), g2.end());

            int p1 = 0;
            for(int i  = 0; i < g1.size(); i++){
                while(p1 < g1.size() && g1[i] > g2[p1]){
                    p1++;
                }

                if(p1 == g1.size()){
                    break;
                }

                if(g1[i] == g2[p1]){
                    sol++;
                    p1++;
                }
            }
        }
    }

    cout << sol << endl;

    return 0;
}

Measured memory_bytes: 12408
N = int(input())
A = list(map(int, input().split()))
count_a = [0 for i in range(N)]
key = max(A)
for i in range(N):
    while True:
        if A[i] % 2 != 0:
            break
        A[i] /= 2
        count_a[i] += 1
        if count_a[i] > key:
            break
    key = count_a[i]

        
print(min(count_a))


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

const int MAXN = 10010;

char S[MAXN];
int sfx[MAXN], ord[MAXN], aux[MAXN], rev[MAXN], cnt[MAXN], nord[MAXN], lcp[MAXN];
int mn[15][MAXN], mx[15][MAXN];

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

	cin >> N >> S;

	for(int i = 0; i < N; i++) {
		ord[i] = S[i] - 'a' + 1;
		sfx[i] = i;
	}
	int pnt = 1, p = 1;
	int cntt = 1000;
	while(1) {
		if(++cntt < 100) {
			printf("p = %d\nord : ", p);
			for(int i = 0; i < N; i++) printf("%d ", ord[i]);
			printf("\nsfx : ");
			for(int i = 0; i < N; i++) printf("%d ", sfx[i]);
			printf("\n");
		}
		memset(cnt, 0, (max(N, 26) + 5) * sizeof(int));
		for(int i = 0; i < N; i++) cnt[ord[min(i + p, N)]]++;
		for(int i = 1; i <= 26 || i <= N; i++) cnt[i] += cnt[i - 1];
		for(int i = N - 1; i >= 0; i--) aux[--cnt[ord[min(i + p, N)]]] = i;
		/*
		printf("aux : ");
		for(int i = 0; i < N; i++) printf("%d ", aux[i]);
		printf("\n");
		*/
		memset(cnt, 0, (max(N, 26) + 5) * sizeof(int));
		for(int i = 0; i < N; i++) cnt[ord[i]]++;
		for(int i = 1; i <= 26 || i <= N; i++) cnt[i] += cnt[i - 1];
		/*
		printf("cnt : ");
		for(int i = 0; i < N; i++) printf("%d ", cnt[i]);
		printf("\n");
		*/
		for(int i = N - 1; i >= 0; i--) sfx[--cnt[ord[aux[i]]]] = aux[i];
		/*
		printf("sfx : ");
		for(int i = 0; i < N; i++) printf("%d ", sfx[i]);
		printf("\n");
		*/
		if(pnt == N) break;
		pnt = 1;
		nord[sfx[0]] = 1;
		for(int i = 1; i < N; i++) {
			if(ord[sfx[i - 1]] != ord[sfx[i]] || ord[sfx[i - 1] + p] != ord[sfx[i] + p]) pnt++;
			nord[sfx[i]] = pnt;
		}
		memcpy(ord, nord, sizeof(int) * N);
		p *= 2;
	}
	for(int i = 0; i < N; i++) rev[sfx[i]] = i;

	int h = 0;
	for(int i = 0; i < N; i++) {
		if(rev[i]) {
			int prv = sfx[rev[i] - 1];
			while(S[prv + h] == S[i + h]) h++;
			lcp[rev[i]] = h;
		}
		h = max(h - 1, 0);
	}

	for(int i = 1; i < N; i++) mn[0][i] = mx[0][i] = sfx[i];
	for(int i = 1; (1 << i) < N; i++) for(int j = 1; j + (1 << i) <= N; j++) {
		mn[i][j] = min(mn[i - 1][j], mn[i - 1][j + (1 << (i - 1))]);
		mx[i][j] = max(mx[i - 1][j], mx[i - 1][j + (1 << (i - 1))]);
	}

	int s = 0, e = N;
	while(s < e) {
		int m = (s + e + 1) / 2;
		int t = 0;
		bool b = false;
		for(int i = 1; i <= N; i++) if(i == N || lcp[i] < m) {
			int l = 31 - __builtin_clz(i - t);
			if(max(mx[l][t], mx[l][i - (1 << l)]) - min(mn[l][t], mn[l][i - (1 << l)]) >= m) b = true;
			t = i;
		}
		if(b) s = m;
		else e = m - 1;
	}
	cout << s;
	return 0;
}


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

int main()
{
  string s;
  cin >> s;
 
  bool app[26];
  for (int i = 0; i < 26; ++i) {
    app[i] = false;
  }
  int n = s.size();
  for (int i = 0; i < n; i++) {
	app[s[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; ++i) {
    if (!app[i]){
      cout << (char)(i + 'a') << endl;
      return 0;
	}
  }
  cout << "None" << endl;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,sum=0;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(a[i]>b[i]){
			sum+=a[i]-b[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    vector<vector<int>> edges(N+1);
    rep(i,0,M) {
        edges[A[i]].push_back(B[i]);
        edges[B[i]].push_back(A[i]);
    }
    vector<int> answer(N+1, INT_MAX);
    answer[1] = 0;
    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        auto current = que.front();
        que.pop();
        for (const auto next : edges[current]) {
            if (answer[next] != INT_MAX) continue;
            answer[next] = current;
            que.push(next);
        }
    }
    cout << "Yes" << endl;
    rep(i,2,N+1) {
        cout << answer[i] << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

int main() {
  int N, T;
   cin >> N;
  
  T = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    
    int s = 0;
    for (int j = 0; A % 2 < 1; j++) {
      A /= 2;
      s++;
    }
    
    if (i == 0) {
      T = s;
    }
    
    else if (s < T) {
      T = s;
    }
    
    else if (s >= T) {
      continue;
    }
    
  }
    cout << T << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int n,mem[10];
  while(cin>>n,n){
    for(int i=0;i<n;i++)mem[i]=0;
    int st=0;
    char card;
    for(int i=0;i<100;i++){
      cin>>card;
      if(card=='M')mem[i%n]++;
      else if(card=='S'){
        st+=mem[i%n]+1;
        mem[i%n]=0;
      }else{
        mem[i%n]+=st+1;
        st=0;
      }
    }
    sort(mem,mem+n);
    for(int i=0;i<n;i++){
      cout<<mem[i]<<" ";
    }
    cout<<st<<endl;
  }
}

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

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

int main()
{
    ll n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);

    ll ans = 0;
    ll gp = n / (a + b);
    ans += a * gp;

    n %= (a + b);
    if (n >= a)
        ans += a;
    else
        ans += n;

    printf("%lld\n", ans);

    return 0;
}


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

long int h,w,m;

int main() {
	cin>>h>>w>>m;
	long int row[h]={0},col[w]={0};
	long int mx1=0,mx2=0,r,c;
	map<pair<long int,long int>,long int>mp;
	for(long int i=0;i<m;i++)
	{
	    long int aa,bb;
	    cin>>aa>>bb;
	    aa--;
	    bb--;
	    mp[{aa,bb}]++;
	    row[aa]++;
	    col[bb]++;
	    if(mx1<row[aa])
	    {
	        mx1=max(mx1,row[aa]);
	        r=aa;
	    }
	    if(mx2<col[bb])
	    {
	        mx2=max(mx2,col[bb]);
	        c=bb;
	    }
	}
	long int ans=0;
	for(long int j=0;j<w;j++)
	{
	    if(mp[{r,j}]==0)
	    ans=max(ans,row[r]+col[j]);
	    else
	    ans=max(ans,row[r]+col[j]-1);
	}
	for(long int j=0;j<h;j++)
	{
	    if(mp[{j,c}]==0)
	    ans=max(ans,row[j]+col[c]);
	    else
	    ans=max(ans,row[j]+col[c]-1);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 64484
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int a[n+1];
	bool check[n+1];
	rep(i,n){
		cin>>a[i+1];
		check[i+1]=false;
	}
	check[1]=true;
	bool tmp=false;
	int now=1,cnt=0;
	while(now!=2){
		now=a[now];
		cnt++;
		if(check[now]){
			tmp=true;
			break;
		}
		check[now]=true;
	}
	if(tmp)cout<<-1<<endl;
	else cout<<cnt<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  cout << (a / __gcd(a, b)) * b << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<int> p(101010), q(101010);
    rep(i,N) {
        if (i&1) p[A[i]]++;
        else q[A[i]]++;
    }

    int a = max_element(all(p)) - p.begin();
    int b = max_element(all(q)) - q.begin();
    if (a != b) {
        cout << N - *max_element(all(p)) - *max_element(all(q)) << ln;
    } else {
        int u = *max_element(all(p));
        int v = *max_element(all(q));
        p[a] = 0;
        q[b] = 0;
        cout << N - max(u + *max_element(all(q)),v + *max_element(all(p))) << ln;
    }
}

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

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; }

const long long INF = 1LL << 60;

int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(all(a));

  cout << a[2]*10 + a[1] + a[0] << endl;

  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [None for _ in range(k+1)]
#dp[i]: i個のときにどっちが勝つか
for i in range(a[0]):
	dp[i] = "Second"
dp[a[0]] = "First"
for i in range(a[0]+1, k+1):
	f = False
	for j in range(n):
		if i < a[j]:
			break
		else:
			if dp[i - a[j]] == "Second":
				f = True
				break
	if f:
		dp[i] = "First"
	else:
		dp[i] = "Second"

#print(dp)
print(dp[-1])

Measured memory_bytes: 46320
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const ll MOD=1e9+7;
const int MAXN=4e5+7;

ll ans=0;
ll n,k;
ll pot(ll pod,ll wyk){
    ll res=1;
    while(wyk){
        if(wyk&1)res*=pod,res%=MOD;
        pod*=pod;
        pod%=MOD;
        wyk/=2;
    }
    return res;
}
ll gcdE(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll g=gcdE(b,a%b,x1,y1);
    y=x1-(a/b)*y1;
    x=y1;
    return g;
}
ll modInv(ll a){
    ll x, y;
    ll g=gcdE(a,MOD,x,y);
    if(x<0)x+=MOD;
    return x;
}

ll modDiv(ll a,ll b){
    a%=MOD;
    ll inv=modInv(b);
    return (a*inv)%MOD;
}
ll sil[MAXN];
ll Nwt(ll d,ll g){
    ll l=sil[g],m=sil[d];
    m*=sil[g-d];
    m%=MOD;
    return modDiv(l,m);
}
ll Czp(ll g,ll d){
    ll l=1,m=1;
    l*=sil[d+g-1],l%=MOD;
    m*=sil[g],m%=MOD;
    m*=sil[d-1],m%=MOD;
    return modDiv(l,m);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    k=min(k,n-1);
    sil[0]=1;
    FOR(i,1,MAXN){
        sil[i]=(sil[i-1]*i)%MOD;
    }
    FORE(i,0,k){
        ans+=Czp(i,n-i)*Nwt(i,n);
        ans%=MOD;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

typedef long long LL;

using namespace std;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(1){
		c-=b;
		if(c<=0){
			cout << "Yes" << endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			cout << "No" << endl;
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3588
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B)
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F)
    return A, B, C, D, E, F, X, Y

def solve(A, B, C, D, E, F, X, Y):
    H, W = len(X), len(Y)
    N = H * W
    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    def set_ng(A, B, C, D, E, F, H, W):
        ng = np.zeros((H * W, 4), np.bool_)

        for i in range(len(A)):
            for x in range(A[i], B[i]):
                v = x * W + C[i]
                ng[v][1] = 1
                ng[v - 1][0] = 1

        for i in range(len(D)):
            for y in range(E[i], F[i]):
                v = D[i] * W + y
                ng[v][3] = 1
                ng[v - W][2] = 1
        return ng

    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    signature = '(i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1])'
    cc.export('solve', signature)(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()

from my_module import solve

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define mp make_pair 

signed main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	set<int> st;
	map<int, int> ma, mb;
	int cnt = 0;
	map<int, int> haiti;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		st.insert(a[i]);
		ma[a[i]]++;
		if(haiti.find(a[i]) == haiti.end()) haiti[a[i]] = cnt;
		cnt++;
	}

	for(int i = 0;i < n;i++){
		cin >> b[i];
		st.insert(b[i]);
		mb[b[i]]++;
	}

	priority_queue<pair<pair<pair<int, int>, int>, pair<int, int>>> que;

	for(auto e : st){
		que.push(mp(mp(mp(ma[e], ma[e]-mb[e]), e),mp(ma[e], mb[e])));
	}

	queue<int> tmp;
	queue<int> last;

	vector<int> ans(n);
	while(!que.empty()){
		int a = que.top().second.first;
		int b = que.top().second.second;
		int e = que.top().first.second;
		while(a--) tmp.push(e);
		while(b--){
			if(tmp.empty() || tmp.front() == e){
				last.push(e);
			}else{
				ans[haiti[tmp.front()]++] = e;
				tmp.pop();
			}
		}
		que.pop();
	}

	while(!last.empty()){
		int e = last.front();
		if(tmp.empty() || tmp.front() == e){
			cout << "No" << endl;
			return 0;
		}else{
			ans[haiti[tmp.front()]++] = e;
			tmp.pop();
		}
		last.pop();
	}

	cout << "Yes" << endl;

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

	return 0;
}


Measured memory_bytes: 63756
#include<stdio.h>

int A[10000];
main(){
  int i, j, a;
 
  scanf("%d", &a);
  for(i = 1; i <= a; i++){
    scanf("%d", &A[i]);
  }

  for(i = 1; i <= a; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(i != 1){
      printf("parent key = %d, ", A[parent(i)]);
    }
    j = left(i);
    if(j <= a){
      printf("left key = %d, ", A[j]);
    }
    j = right(i);
    if(j <= a){
      printf("right key = %d, ", A[j]);
    }
    printf("\n");
  }
  return 0;
}

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

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

using namespace std;
using ll = long long;

ll solve(vector<pair<int, int>> &a) {
	int n = a.size();
	vector<vector<int>> events(n + 1);
	for (auto [when, x] : a) {
		events[min(when, n)].push_back(x);
	}
	priority_queue<int> pq;
	ll res = 0;
	for (int i = n; i; i--) {
		for (auto el : events[i]) {
			pq.push(el);
		}
		if (pq.size()) {
			res += pq.top();
			pq.pop();
		}
	}
	return res;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		array<vector<pair<int, int>>, 2> want;
		ll ans = 0;
		for (int i = 0; i < n; i++) {
			int t, L, R;
			cin >> t >> L >> R;
			ans += min(L, R);
			want[L >= R].emplace_back(L >= R ? t : n - t, max(L, R) - min(L, R));
		}
		cout << ans + solve(want[0]) + solve(want[1]) << '\n';
	}
}

Measured memory_bytes: 9736
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a , b , answer;
    char op;

    while (1){
        cin >> a >> op >> b;
        if ( op == 63 ) break;
        if (47 == op){
            answer = a / b;
        }
        else if (42 == op){
            answer = a * b;
        }
    
        else if (43 == op){
            answer = a + b;
        }
        else if (45 == op){
            answer = a - b;
        }
    
        printf("%d\n", answer);
    }
    
}


Measured memory_bytes: 3240
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

cost = [0 for i in range(N)]
cost[0] = 0

for i in range(1,N):
    for j in range(1,K+1):
        if i-j<0:
            break
        #print(i,j)
        if j==1:
            cost_min = abs(h[i]-h[i-j]) + cost[i-j]
        else:
            cost_min = min(cost_min, abs(h[i]-h[i-j]) + cost[i-j])
    cost[i] = cost_min

print(cost[N-1])

Measured memory_bytes: 56544
a,b,x = gets.split.map(&:to_i)
half = (b*a**2)/2
if half >= x then
    z = 2*x/(a*b.to_f)
    rad = Math.atan(z/b)
else
    z = (2*x/(a**2).to_f) - b
    y = b - z
    rad = Math.atan(a/y)
end
puts 90 - rad*180/Math::PI

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vstr;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;
 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it it!= m.end(); it++)
 
const char nl = '\n';
const int MOD = 1e9 +7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 + 5;
 
int main(){
 
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
  ld t, tmp;
  cin >> n >> t >> tmp;
  ld a[n+2];
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  int ans;
  ld k = 1223123.123;
  for(int i =1; i <= n; i++){
    if(abs((t - a[i]*0.006) - tmp) < k)
    {
      k = abs((t - a[i]*0.006) - tmp);
      ans = i;
    }
  }
  cout << ans << nl;
 
 
 
 
 
 
 
  return 0;
}

Measured memory_bytes: 3724
N, M = map(int, input().split())
a, b, c, d = [], [], [], []
for i in range(N):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
for i in range(M):
    ci, di = map(int, input().split())
    c.append(ci)
    d.append(di)

def distance(x1, x2, y1, y2):
    return abs(x1 - x2) + abs(y1 - y2)


for i in range(N):
    min_dist = float('inf')
    min_checkpoint = -1
    for j in range(M):
        dist = distance(a[i], c[j], b[i], d[j])
        if dist < min_dist:
            min_dist = dist
            min_checkpoint = j + 1
    print(min_checkpoint)


Measured memory_bytes: 3064
n,m =map(int, input().split())
sc=[]
numbers =[]
for i in range(m):
    s,c =map(int, input().split())
    sc.append([s,c])

if n ==1:
    start =0
    end =9
elif n ==2:
    start =10
    end =99
elif n ==3:
    start =100
    end =999

for i in range(start ,end+1):
    i =str(i)
    flg =0
    for j in sc:
        if str(j[1]) != i[j[0]-1]:
            flg +=1
    
    if flg ==0:
        numbers.append(i)

if len(numbers) ==0:
    print(-1)
else:
    print(min(numbers))

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

int main() {
	ll A;
	double B;
	cin >> A >> B;
	ll C = B * 100 + 0.5;
	ll X = A * C / 100;
	cout << X << endl;
}

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

const int N = 1000 * 100 + 100;
int n, m, deg[N], digi[N], h[N];
vector<int> adj[N];
bool vis[N];

void dfs(int root) {
	int v = root;
	vis[root] = true;
	for (auto u: adj[root]) 
		if (!vis[u]) {
			h[u] = h[root] + 1;
			dfs(u);
			if (deg[u] & 1)
				cout << u << ' ' << v << endl, deg[u]++;
			else
				cout << v << ' ' << u << endl, deg[v]++;
		}
		else if (h[root] < h[u]) {
			if (deg[u] & 1)
				cout << u << ' ' << v << endl, deg[u]++;
			else
				cout << v << ' ' << u << endl, deg[root]++;
		}
}

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1, v, u; i <= m; i++) {
		cin >> v >> u;
		adj[v].push_back(u);
		adj[u].push_back(v);
		digi[v]++, digi[u]++;
	}
	int root = 1;
	for (int i = 1; i <= n; i++)
		if (digi[i] > digi[root])
			root = i;
	if (m & 1)
		return cout << -1 << endl, 0;
	dfs(root);
	return 0;
}


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

using namespace std;

int main(void) {
    auto getN = [](){int t;cin >> t;return t;};
    int n = getN();
    int x=getN();
    int a[100];
    for(int i = 0;i < n;i++) cin >> a[i];
    sort(a,a+n);
    int cur = 0,ans = 0;
    while(cur < n && a[cur] <= x) {
        ans++;
        x -= a[cur];
        cur++;
    }
    if(cur == n && x != 0) ans--;
    cout << ans;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
res = 0
for i in range(n):
    if i == 0:
        res += 1
        m = a[i]
        continue
    if m > a[i]:
        res += 1
        m = a[i]
print(res)


Measured memory_bytes: 96076
# // 2* nc2 * 10 **(n -2)
MOD = 10**9 + 7
def mpow(b,n):
    ## calculate 10 ^ n-2 mod 10**9 + 7

    # b = 10
    # n-=2
    ans = 1
    while n> 0:
        if n&1:
            ans = ans * b
            ans%= MOD
        b = b * b
        b%=MOD
        n>>=1 
    return ans



n = int(input())
# ans = (10**n) - 2*(9**n)+ 8**n
ans = mpow(10,n)
ans = ans - 2*(mpow(9,n))
if ans < 0:
    ans+=MOD
ans = ans+ mpow(8,n)
ans = ans%MOD
# print(ans%MOD)
print(ans)
# count = 0
# for i in range(10**(n)):
#     if ( '0' in str(i) or i < 10**(n-1) )and '9' in str(i):
#         count+=1
#         # print(i)
# print(count)
# count = 0
# for i in range(1000):
#     st  = '0'*(3-len(str(i))) + str(i)
#     if '0'  in st : #or '9' in st:
#         count+=1
#         print(st)


# print(count)

Measured memory_bytes: 9196
import math

while 1:
    lis = []
    st = []
    num = int(input())
    if num == 0:
        break
    else:
        lis = list(map(int, input().split()))
        m = sum(lis) / len(lis)
        for v in lis:
            st.append((v - m)**2)
        print(math.sqrt(sum(st)/num))
            
    


Measured memory_bytes: 5692
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int x = stdIn.nextInt();
        boolean s=false;
        if(x/100==7){
            s=true;
        }else if(x%100/10==7){
            s=true;
        }else if(x%10==7){
            s=true;
        }
        if(s){
           System.out.println("Yes"); 
        }else{
            System.out.println("No");
        }
    }
}


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


int main (){
    long double a, b, x;
    cin>>a>>b>>x;
   	long double Half=a*a*b/2;
  	//cout<<Half<<endl;
    if(Half>x){
        long double K=2*x/a/b/b;
      	//cout<<K<<"#";
      	long double L=atan(K)*180/M_PI;
        cout<<fixed<<setprecision(10)<<90-L<<endl;
    }
    else{
        long double M=2*(a*a*b-x)/a/a/a;
        cout<<fixed<<setprecision(10)<<atan(M)*180/M_PI;
    }
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    const C = parseInt(arg[0].split(" ")[2]);
    
    console.log(A * C <= B ? C : Math.floor(B / A));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    static long m=998244353;
  
    void solve() throws IOException {
        int n=ni();
        int[]A=new int[n];
        int[]B=new int[n];
        int[]C=new int[n];
        long[]P=new long[n];
        long[]Q=new long[n];
        long[]R=new long[n];
        A[0]=ni(); B[0]=ni(); C[0]=ni();
        P[0]=A[0]; Q[0]=B[0]; R[0]=C[0];
        for (int x=1;x<n;x++) {
            A[x]=ni(); B[x]=ni(); C[x]=ni();
            P[x]=A[x]+Math.max(Q[x-1],R[x-1]);
            Q[x]=B[x]+Math.max(P[x-1],R[x-1]);
            R[x]=C[x]+Math.max(P[x-1],Q[x-1]);
        }
        long ans=Math.max(P[n-1],Q[n-1]);
        ans=Math.max(ans,R[n-1]);
        System.out.println(ans);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

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

using namespace std;
typedef  long long ll;


int main(){
    ll a,b,c,d,e;
    cin>>a>>b>>c;

    if(a==0)
        d = -1;
    else
        d = (a-1)/c;

    e = b / c;
    cout<<e-d<<endl;
}


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

using namespace std;

string change(int n){
  int sum = 0;
  string str = ""; 

  while(n > 0){
    str += (n % 4) + '0'; 
    n /= 4;
  }
  reverse(str.begin(),str.end());
  return str;
}

int main(){
  int n;

  while(cin >> n , n != -1){
    if(n == 0){
      cout << 0 << endl;
      continue;
    }
    cout << change(n) << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  long long s[n];
  REP(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  REP(i,n){
    if(i==0){
      s[i]=a[i];
    }else{
      s[i]=s[i-1]+a[i];
    }
  }
  
  bool survive[n]={};
  survive[n-1]=true;
  for(int i=n-2;i>=0;i--){
    if(2*s[i]>=a[i+1]){
      survive[i]=survive[i+1];
    }else{
      survive[i]=false;
    }
  }
  
  int ans=0;
  REP(i,n){
    if(survive[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;

    vector<bool> is_prime(N + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (int j = 2; i*j <= N; j++) is_prime[i*j] = false;
        }
    }

    vector<int> prime_num(N + 1);
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            int p = i;
            while (p <= N) {
                prime_num[i] += N/p;
                p *= i;
            }
        }
    }

    vector<int> clf(5);
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            if (prime_num[i] >= 74) clf[0]++;
            else if (prime_num[i] >= 24) clf[1]++;
            else if (prime_num[i] >= 14) clf[2]++;
            else if (prime_num[i] >= 4) clf[3]++;
            else if (prime_num[i] >= 2) clf[4]++;
        }
    }

    vector<int> cclf(5);
    cclf[0] = clf[0];
    for (int i = 1; i < 5; i++) {
        cclf[i] = clf[i] + cclf[i - 1];
    }
    
    int ans;
    if (N == 1) ans = 0;
    else {
        ans = cclf[0]
            + cclf[1]*(cclf[4] - 1)
            + cclf[2]*(cclf[3] - 1)
            + cclf[3]*(cclf[3] - 1)*(cclf[4] - 2)/2;
    }

    cout << ans << endl;
    return 0;
}

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


int main() {
    int n = 0, m = 0;
    scanf("%d %d\n", &n, &m);
    int l = 1, r = n;
    int buf1 = 0, buf2 = 0;
    for (int i=0; i<m; i++) {
        scanf("%d %d", &buf1, &buf2);
        if (buf1 > l) l = buf1;
        if (buf2 < r) r = buf2;
        if (r < l) {
            printf("0\n");
            return 0;
        }
    }
    printf("%d\n", r-l+1);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int n;cin>>n;
    
    string ans="No";
    for(int i=0;4*i<=n;i++){
        for(int j=0;4*i+7*j<=n;j++){
            if(4*i+7*j==n) ans="Yes";
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
L = [[0]*3 for i in range(N)]

for i in range(N):
    S, P = map(str, input().split())
    P = int(P)
    L[i][0] = S
    L[i][1] = P
    L[i][2] = i+1

tmp = sorted(L, key=lambda x: x[1], reverse=True)
ans = sorted(tmp, key=lambda x: x[0])
for a in ans:
    print(a[2])


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e15)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

vll calc(vpii a) {
    int ni = sz(a);
    VSORT(a);
    vector<vll> dp(ni+1, vll(ni+1, INF));
    dp[0][0] = 0;
    rep(l, ni) {
        for (int r=l+1; r<=ni; ++r) {
            ll now = INF;
            for (int k=l+1; k<=r; ++k) {
                ll sum = 0;
                for (int i=l+1; i<=r; ++i) sum += abs(a[i-1].first-a[k-1].first) * (ll)a[i-1].second;
                now = min(now, sum);
            }
            rep(j, ni) dp[r][j+1] = min(dp[r][j+1], dp[l][j]+now);
            for (int i=l+1; i<=r; ++i) now += abs(a[i-1].first) * (ll)a[i-1].second;
            rep(j, ni+1) dp[r][j] = min(dp[r][j], dp[l][j]+now);
        }
    }
    return dp[ni];
}

int main(){
    int n;
    cin >> n;
    vi x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];
    vll ans(n+1, INF);
    rep(i, 1<<n) {
        vpii xi, yi;
        rep(j, n) {
            if ((i>>j)&1) xi.emplace_back(x[j], p[j]);
            else yi.emplace_back(y[j], p[j]);
        }
        vll resx = calc(xi);
        vll resy = calc(yi);
        vll res(n+1, INF);
        rep(j1, sz(resx)) rep(j2, sz(resy)) {
            res[j1+j2] = min(res[j1+j2], resx[j1]+resy[j2]);
        }
        rep(j, n+1) ans[j] = min(ans[j], res[j]);
    }
    rep(i, n+1) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3648
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> snacks(n + 1, 0);
    for(int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for(int j = 0; j < d; ++j) {
            int id;
            cin >> id;
            ++snacks[id];
        }
    }
    int cnt = 0;
    for(int id = 1; id <= n; ++id) cnt += snacks[id] == 0;
    cout << cnt << endl;
    return 0;
}



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

int main() {
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    n-=a;
  }
  if(n<0){
    cout<<"-1"<<endl;
  }
  else{
    cout<<n<<endl;
  }
}


Measured memory_bytes: 3592
s = gets.chomp
ans = 0
for i in 0..s.length do
  ans += 1 if s[i] != s[s.length - 1 - i]
end
puts(ans / 2)

# s = gets.chomp
# len = s.size
# ans = 0
# (len/2).times do |i|
#   ans += 1 if s[i] != s[-i-1]
# end

# puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  double r,g;cin >> r >> g;
  cout << 2*g-r << endl;
}


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


int main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<1000;i++)
	{
		if((b*i+c)%a==0)
		{
			cout<<"YES"<<endl;
			return 0;
		}
		 
	}cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    W = input()
    W_list = [W[i] for i in range(len(W))]
    
    if W_list[0] == '-':
        break
    
    n = int(input())
    
    shuffle_list_num = []
    for i in range(n):
        shuffle_list_num.append(int(input()))
    
    for k in shuffle_list_num:
        change_W_list = []
        for j in range(k):
            change_W_list.append(W_list.pop(0))
        W_list += change_W_list
        # print(W_list)
                
    print(''.join(W_list))


Measured memory_bytes: 5604
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

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

	auto V=enum_prime(55555);
	vector<ll> S;
	for(auto& x:V){
		if((x%5)==1) S.emplace_back(x);
	}
	
	int N=in();
	REP(i,N-1) cout << S[i] << ' ';
	out(S[N-1]);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
int dp[1000003];
int main(){
	int i,j,k,l,a,b,c,d;
	scanf("%d",&a);
    FOR(i, 2, a) scanf("%d",&b), dp[b]++;
    FOR(i, 1, a) printf("%d\n",dp[i]);
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 4500
#include <iostream>
using namespace std;
 
int day(int y, int m, int d) {
  int ans = 0;
  for(int i = 1; i < y; i++) {
    bool uruu = false;
    if(i % 4 == 0) {
      if(i % 100 == 0) {
    if(i % 400 == 0) {
      uruu = true;
    }
      } else {
    uruu = true;
      }
    }
    if(uruu) {
      ans += 366;
    } else {
      ans += 365;
    }
  }
  m--;
  if(m >= 1) ans += 31;
  if(m >= 2) {
    bool uruu = false;
    if(y % 4 == 0) {
      if(y % 100 == 0) {
    if(y % 400 == 0) {
      uruu = true;
    }
      } else {
    uruu = true;
      }
    }
    if(uruu) ans += 29;
    else     ans += 28;
  }
  if(m >= 3) ans += 31;
  if(m >= 4) ans += 30;
  if(m >= 5) ans += 31;
  if(m >= 6) ans += 30;
  if(m >= 7) ans += 31;
  if(m >= 8) ans += 31;
  if(m >= 9) ans += 30;
  if(m >= 10) ans += 31;
  if(m >= 11) ans += 30;
 
  ans += d;
 
  return ans;
}
 
int main() {
  int y1, m1, d1;
  int y2, m2, d2;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
    if(y1 == -1 && m1 == -1 && d1 == -1 && y2 == -1 && m2 == -1 && d2 == -1)
      break;
 
    cout << day(y2,m2,d2) - day(y1,m1,d1) << endl;
  }
  return 0;
}

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

 
int main()
{
	long int h,k;
	cin>>h>>k;
	if(h==1||k==1) cout<<"1";
	else
	cout<<(h*k+1)/2;
	return 0;
}


/*


#include<stdio.h>
int main() {
	//code
	long int n,m,s=0,d,k=1,l,r,i;
	scanf("%ld%ld",&n,&m);
	long int arr[n],a[n];
	for(i=0;i<n;i++) scanf("%ld",&arr[i]);
	for(i=0;i<n;i++) a[i]=0;
	a[0]=1;
	for(i=1;i<n;i++){
		if(arr[i]>=arr[s]&&i==s+1) d=0;
		if(arr[i]<arr[s]&&i==s+1) d=1;
		if(arr[i]<arr[i-1]){
			if(i==s+1){
				s=i;
				k++;
				a[i]=k;
				continue;
			}
			if(d==0){
				d=1;
			}
		}
		if(arr[i]>arr[i-1]){
			if(d==1){
				s=i;
				d=0;
				k++;
				a[i]=k;
			}
		}
		a[i]=k;
	}
	for(i=0;i<m;i++){
		scanf("%ld%ld",&l,&r);
		if(a[l-1]==a[r-1]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

*/









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num;
vector<long long> v;
long long a[200005], res=999999999999999999;
inline long long mx(long long i, long long j, long long k, long long l)
{
	return max(max(i, j), max(k, l));
}
inline long long mn(long long i, long long j, long long k, long long l)
{
	return min(min(i, j), min(k, l));
}
int main()
{
	cin>>num;
	a[0]=0;//       a[2]+a[3]+a[4]=a[4]-a[1]
	for(int i=1; i<=num; i++)
		cin>>a[i], a[i]+=a[i-1], v.push_back(a[i]);
	for(int i=1; i<num-2; i++)
	{
		long long n1=v[i], n2=(long long)v[num-1]-v[i];
		n1/=2, n2/=2;
		n2+=v[i];
		int p1=upper_bound(v.begin(), v.end(), n1)-v.begin();
		int p2=upper_bound(v.begin(), v.end(), n2)-v.begin();
		int p3=p1-1;
		int p4=p2-1;
		long long mx1, mx2, mx3, mx4, mn1, mn2, mn3, mn4;
		mx1=mx2=mx3=mx4=999999999999999998, mn1=mn2=mn3=mn4=-1;
		//   p1 p2
		if(p1>=0&&p2<num-1)
		mx1=mx(v[p1], v[i]-v[p1], v[p2]-v[i], v[num-1]-v[p2]), mn1=mn(v[p1], v[i]-v[p1], v[p2]-v[i], v[num-1]-v[p2]);
		if(p1>=0&&p4<num-1)
		mx2=mx(v[p1], v[i]-v[p1], v[p4]-v[i], v[num-1]-v[p4]), mn2=mn(v[p1], v[i]-v[p1], v[p4]-v[i], v[num-1]-v[p4]);
		if(p3>=0&&p2<num-1)
		mx3=mx(v[p3], v[i]-v[p3], v[p2]-v[i], v[num-1]-v[p2]), mn3=mn(v[p3], v[i]-v[p3], v[p2]-v[i], v[num-1]-v[p2]);
		if(p3>=0&&p4<num-1)
		mx4=mx(v[p3], v[i]-v[p3], v[p4]-v[i], v[num-1]-v[p4]), mn4=mn(v[p3], v[i]-v[p3], v[p4]-v[i], v[num-1]-v[p4]);
		res=min(res, mn(mx1-mn1, mx2-mn2, mx3-mn3, mx4-mn4));
	}
	cout<<res;
	return 0;
} 

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){int N,M;cin>>N;vector<string>a(N);for(int i=0;i<N;i++)cin>>a.at(i);
cin>>M;vector<string>b(M);for(int i=0;i<M;i++)cin>>b.at(i);
vector<int>c(N,1);int x=0;
for(int i=0;i<N;i++){int s=0;if(c.at(i)){for(int j=i;j<N;j++)if(a.at(i)==a.at(j)){s++;c.at(j)=0;}
for(int k=0;k<M;k++)if(a.at(i)==b.at(k))s--;if(x<s)x=s;}}
cout<<x<<endl;}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define fora(i, a, n) for(int i = a; i < n; i++)
#define forb(i, a, n) for (int i = a; i >= (n); --i)
#define PI 3.1415926535897932384626433832795
#define INF 1e9

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

int x; cin >> x;
int ans = 1000*(x/500);
x %= 500;
ans += 5*(x/5);
cout << ans;
}

Measured memory_bytes: 256
fun main (args:Array<String>){
    val (friends, heightReq) = readLine()!!.split(" ").map(String::toInt)
    val friendsList = readLine()!!.split(" ").map(String::toInt)
    var count = 0
    for(i in 0..friends-1){
        if(friendsList[i] >= heightReq) count++
    }
    print(count)
}

Measured memory_bytes: 49148