akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

void solve() {
    int N, X, T;
    cin >> N >> X >> T;
    print((N+X-1)/X * T);
}   

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3592
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    val dp = Array(n){Array(2){Pair(0L, 0L)}}
    when {
        a[0] > 0L -> {
            dp[0][0] = Pair(0, a[0])
            dp[0][1] = Pair(Math.abs(a[0]) + 1, -1)
        }
        a[0] == 0L -> {
            dp[0][0] = Pair(1, 1)
            dp[0][1] = Pair(1, -1)
        }
        a[0] < 0L -> {
            dp[0][0] = Pair(Math.abs(a[0]) + 1, 1)
            dp[0][1] = Pair(0, a[0])
        }
    }

    for(i in 1 until n){
        // j -> 0
        when{
            dp[i - 1][1].second + a[i] > 0L -> {
                dp[i][0] = Pair(dp[i - 1][1].first, dp[i - 1][1].second + a[i])
            }
            dp[i - 1][1].second + a[i] == 0L -> {
                dp[i][0] = Pair(dp[i - 1][1].first + 1, 1)
            }
            dp[i - 1][1].second + a[i] < 0L -> {
                dp[i][0] = Pair(dp[i - 1][1].first + Math.abs(dp[i - 1][1].second + a[i]) + 1, 1)
            }
        }
        // j -> 1
        when{
            dp[i - 1][0].second + a[i] > 0L -> {
                dp[i][1] = Pair(dp[i - 1][0].first + Math.abs(dp[i - 1][0].second + a[i]) + 1, -1)
            }
            dp[i - 1][0].second + a[i] == 0L -> {
                dp[i][1] = Pair(dp[i - 1][0].first + 1, -1)
            }
            dp[i - 1][0].second + a[i] < 0L -> {
                dp[i][1] = Pair(dp[i - 1][0].first, dp[i - 1][0].second + a[i])
            }
        }
    }
    println(Math.min(dp[n-1][0].first, dp[n-1][1].first))
}

Measured memory_bytes: 60148
from sys import stdin
import math

a, b, x = [int(x) for x in stdin.readline().rstrip().split()]

if x == (a ** 2) * b:
    print(0)
    exit()
if 2 * x >= (a ** 2) * b:
    v = (a ** 2) * b - x
    c = (2 * v) / (a ** 2)
    print(90 - math.atan(a / c) * 180 / math.pi)
else:
    c = 2 * x / (a * b)
    print(math.atan(b / c) * 180 / math.pi)


Measured memory_bytes: 38256
package main

import (
	"fmt"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	for i := 0; i < k; i++ {
		if s[i] != '1' {
			fmt.Println(string(s[i]))
			return
		}
	}
	fmt.Println("1")
}

Measured memory_bytes: 512
n = int(input())
h = [int(x) for x in input().split()]

for i in reversed(range(1, n)):
    if h[i - 1] > h[i]:
        h[i - 1] -= 1

flg = True
for i in range(n - 1):
    if h[i] > h[i + 1]:
        flg = False
        break
        
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14524
#include <iostream>
#include <vector>
using namespace std;
int N;

long long dfs(long long x, int bit, long long t){
  if(x > N) return 0;
  long long ret = (bit==7);
  ret += dfs(t*3+x, (bit|1), t*10);
  ret += dfs(t*5+x, (bit|2), t*10);
  ret += dfs(t*7+x, (bit|4), t*10);
  return ret;
}

int main(){
  cin >> N;
  cout << dfs(0,0,1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<pair<ll,ll>> tasks(n);

  for(int i=0;i<n;i++) cin >> tasks[i].second >> tasks[i].first;

  sort(tasks.begin(),tasks.end());

  ll time = 0;
  bool flag = true;
  for(int i=0;i<n;i++){
    time += tasks[i].second;
    if(time > tasks[i].first){
      flag = false;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3456
#include <iostream>
#include <queue>
using namespace std;
int main()
{
    int n, q, query, t, x;
    cin >> n >> q;
    vector<priority_queue<int>> pri(n);
    while (q--) {
        cin >> query;
        if (query == 0) {
            cin >> t >> x;
            pri[t].push(x);
        }
        else if (query == 1) {
            cin >> t;
            if (!pri[t].empty())
                cout << pri[t].top() << endl;
        }
        else if (query == 2) {
            cin >> t;
            if (!pri[t].empty())
                pri[t].pop();
        }
    }
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
using namespace std;
queue<ll> a[1050];
int main(){


ll N;
cin>>N;
ll tmp;
for(ll i=0;i<N;i++){
  for(ll j=0;j<N-1;j++){
    cin>>tmp;
    a[i].push(tmp-1);
  }
}

ll cheche=0;
ll cou=0;
while(1){

vector<bool> use(N,0);
bool tukau=0;

cou++;
for(ll i=0;i<N;i++){
  if(!(a[i].empty())){
  ll mo = a[i].front();
  if(mo>i&&!(a[mo].empty())&&a[mo].front()==i){
    ll ok=1;
    if(use[i]==1||use[mo]==1){
      ok=0;
    }
if(ok==1){
    a[mo].pop();
    a[i].pop();
    use[mo]=1;
    use[i]=1;
    tukau=1;
    }
  }
}
  if(i==N-1){
    if(tukau==0)
    cheche=1;
    break;
  }
}


for(ll i=0;i<N;i++){
  if(!(a[i].empty()))
  break;
  else if(i==N-1){
    cheche=2;
  }
}

if(cheche>0)
break;

}




if(cheche==1){
  cout<<-1<<endl;
}
if(cheche==2){
  cout<<cou<<endl;
}









}


Measured memory_bytes: 11008
n, a, b = [int(x) for x in input().split()]
sum_nums = 0
for i in range(1,n+1):
    sum_digits = 0
    j = int(i)
    while j > 0:
        sum_digits += j%10
        j //= 10
    if a <= sum_digits <= b:
        sum_nums += i
print(sum_nums)

Measured memory_bytes: 3060
open System

[<EntryPoint>]
let main argv =
    let input = stdin.ReadLine().Split(' ') |> Array.map int 
    let f a b = if a % 2 = 0 || b % 2 =0 then "Even" else "Odd"
    printfn "%s" (f input.[0] input.[1])
    0 // return an integer exit code


Measured memory_bytes: 14032
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

__int128_t hoge = 1000000000000000000;

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<__int128_t> a(n);
    rep(i,n) {
        ll x;
        cin>>x;
        a[i] = x;
        if (x == 0) {
            cout << 0 << '\n';
            return 0;
        }
    }

    __int128_t ans = 1;
    rep(i,n) {
        ans *= a[i];
        if (ans > hoge) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	string s;
	int n;
	int ans=0,mx=INT_MIN;
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
			ans++;
		else
			ans--;
		if(ans>mx)
			mx=ans;
	}
	cout<<max(mx,0);
	return 0;
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;


int main() {
	int V, E; cin >> V >> E;
	vector<vector<long long int>>edges(V, vector<long long int>(V,1e18));
	for (int i = 0; i < V; ++i)edges[i][i] = 0;
	for (int i = 0; i < E; ++i) {
		long long int a, b, c; cin >> a >> b >> c;
		edges[a][b] = min(edges[a][b], c);
	}
	bool ok = true;
	for (int l = 0; l < 2; ++l) {
		for (int k = 0; k < V; ++k) {
			for (int i = 0; i < V; ++i) {
				for (int j = 0; j < V; ++j) {
					long long int cost = edges[i][k] + edges[k][j];
					if (edges[i][j]>cost) {
						if (l == 1)ok = false;
						else {
							edges[i][j] = cost;
						}
					}
				}
			}
		}
	}
	
	if (ok) {
		for (int i = 0; i < V; ++i) {
			for (int j = 0; j < V; ++j) {
				if (edges[i][j]>1e10)cout << "INF";
				else cout << edges[i][j];

				if (j == V - 1)cout << endl;
				else cout << " ";
			}
		}
	}
	else {
		cout << "NEGATIVE CYCLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
  ll n,k;cin>>n>>k;
  ll ans=k,mx=pow(2,31)-1;
  while(--n){
    ans*=(k-1);
    if(ans>mx){ans=mx;break;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
t=[]
for _ in[0]*H:
    x=input()
    if x!='.'*W:
        t+=[x]
num=len(t)
k=[]
for s in zip(*t):
    s=''.join(s)
    if s!='.'*num:
        k+=[s]
for x in zip(*k[::-1]):
    print(''.join(x[::-1]))

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

using namespace std;

int main(){
	int N;
	cin>>N;
    vector <int>a(N);
    for(int i=0 ; i<N ; i++){
		cin>>a[i];
    }
	
	int address;
	int over=0;
	int min=0;
	vector <bool> color(8,false);
	for(int i=0 ; i<N ; i++){
		address=(int)(a[i]/400);
		if(address>=8){
			over+=1;
			continue;
		}
		color[address]=true;
	}
	for(int i=0 ; i<8 ; i++){
		if(color[i])min++;
	}
	if(min==0)cout<<1<<" "<<over<<"\n";
	else cout<<min<<" "<<min+over<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(7);
	
	string a[4];
	
	int n;
	int ans = 0;
	
	cin>>n;
	
	cin>>a[0]>>a[1]>>a[2];
	
	for(int i = 0; i < n; i++){
		set<int> se;
		for(int j = 0; j < 3; j++){
			se.insert(a[j][i]);
		}
		ans += se.size()-1;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sx, sy, tx, ty = [int(x) for x in input().split()]
dx = tx - sx
dy = ty - sy

lr = ["0", "R", "L"]
ud = ["0", "U", "D"]

lr_idx = 1 if dx > 0 else 2
ud_idx = 1 if dy > 0 else 2

first = lr[lr_idx] * abs(dx) + ud[ud_idx] * abs(dy)
second = lr[-lr_idx] * abs(dx) + ud[-ud_idx] * abs(dy)
third = ud[-ud_idx] + lr[lr_idx] + first + ud[ud_idx] + lr[-lr_idx]
fourth = ud[ud_idx] + lr[-lr_idx] + second + ud[-ud_idx] + lr[lr_idx]

print(first + second + third + fourth)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<vector<int>> mp(n, vector<int>(200));
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    for(int j = 0; j < s[i].length(); j++) {
      mp[i][s[i][j]]++;
    }
  }

  vector<int> ans(200, 0);
  for(int i = 0; i < 200; i++) {
    ans[i] = mp[0][i];
  }
  for(int i = 1; i < n; i++) {
    for(int j = 0; j < 200; j++) {
      if(ans[j] > 0) {
        ans[j] = min(ans[j], mp[i][j]);
      }
    }
  }
  for(int i = 0; i < 200; i++) {
    while(ans[i] > 0) {
      cout << (char)i;
      ans[i]--;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

vector<ll> h;
ll a, b;

bool enough( ll t ){
	vector<ll> cp(h);
	ll cnt = 0;
	for( auto &hp : cp ){
		hp -= b*t;
		if( hp > 0 ) cnt += (hp+a-b-1)/(a-b);
	}
	// cout << cnt << endl;
	if( cnt <= t ){
		return true;
	} else {
		return false;
	}
}

int main(){
	int n;
	cin >> n;
	cin >> a >> b;
	for( int i = 0; i < n; ++i ){
		ll temp; cin >> temp;
		h.push_back(temp);
	}
	sort(h.begin(), h.end(), greater<ll>() );
	ll l = 0;
	ll r = h[0];
	ll ans;
	while( l < r-1 ){
		ans = (l-r)/2+r;
		// cout << "l: " << l << ", mid: " << ans << ", r: " << r << endl;
		if( enough(ans) ){
			// cout << "true" << endl;
			r = ans;
		} else {
			// cout << "false" << endl;
			l = ans;
		}
	}
	cout << r << endl;
	return 0;
}

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

using namespace std;

int main()
{
int n; cin>>n;
vector<int> s(n); for (int i = 0; i < n; i++) cin>>s[i];
int q; cin>>q;
vector<int> t(q); for (int i = 0; i < q; i++) cin>>t[i];
sort(t.begin(), t.end());
int cnt = 0;
for (int i = 0; i < q; i++)
if(*lower_bound(s.begin(), s.end(), t[i]) == t[i]) cnt++;
cout << cnt << endl;
}



Measured memory_bytes: 3368
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def factorize_list_format_change(fact_list_old):
    fact_list_new = []
    for prime_num in fact_list_old:
        for _ in range(prime_num[1]):
            fact_list_new.append(prime_num[0])
    return fact_list_new


def calc_degit(num):
    return len(str(num))

def solve():
    N = int(input())
    fact_list_old = factorization(N)
    fact_list = factorize_list_format_change(fact_list_old)
    min_F = calc_degit(N)
    for i in range(1, 2**len(fact_list)):
        A = 1
        B = 1
        grouping_str = format(i, '0'+str(len(fact_list))+'b')
        for j in range(len(fact_list)):
            if grouping_str[j] == "0":
                A *= fact_list[j]
            else:
                B *= fact_list[j]
        min_F_temp = max(calc_degit(A), calc_degit(B))
        if(min_F_temp < min_F):
            min_F = min_F_temp
    print(min_F)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 74292
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	c = a*b;
	if(c%2==0) printf("Even\n");
	else printf("Odd\n");
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

const int NUM=2000005;
bool flag[NUM];
vector <LL> prime;
void sieve()
{
    flag[1]=true;
    for(LL i=4; i<NUM; i+=2)
        flag[i]=true;
    for(LL i=3; i*i<=NUM; i+=2)
    {
        if(!flag[i])
        {
            for(LL j=i*i; j<NUM; j+=(i<<1))
                flag[j]=true;
        }
    }
    prime.pb(2);
    for(LL i=3; i<NUM; i+=2)
        if(!flag[i])
            prime.pb(i);
    return;
}

map<LL,LL>mp;
void NOD(LL n)
{
    for(LL i=0; prime[i]*prime[i]<=n; i++)
    {
        if(n%prime[i]==0)
        {
            LL cnt=0;
            while(n%prime[i]==0)
            {
                n/=prime[i];
                cnt++;
            }
            mp[prime[i]]=cnt;
        }
    }
    if(n>1)
    {
        mp[n]=1;
    }
    return;
}

int main()
{
    sieve();
    LL n;
    cin >> n;
    NOD(n);
    LL cnt = 0;
    for(auto p:mp){
        LL x = p.ss;
        LL r = 1;
        while(x>=r){
            x-=r;
            r++;
            cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  bool flg = false;
  while(N>0){
    if(N%10==7) flg = true;
    N /= 10;
  }

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



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

using namespace std;

typedef long long llint;

const int MAXN = 100005;

int n, q;
vector <llint> v;
llint cnt[MAXN], sol[MAXN];

void refresh (int pos) {
    llint val = v[pos], fq = cnt[pos];
    if (fq == 0) return;
    while (val > 0) {
        int nxt = lower_bound(v.begin(), v.end(), val) - v.begin();
        if (nxt == 0) {
            sol[val] += fq;
            return;
        }
        nxt--;
        cnt[nxt] += val / v[nxt] * fq;
        val %= v[nxt];
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    v.push_back(n);
    for (int i=0; i<q; i++) {
        llint x;
        cin >> x;
        while (!v.empty() && v.back() >= x) v.pop_back();
        v.push_back(x);
    }
    cnt[v.size() - 1] = 1;
    for (int i=v.size()-1; i>=0; i--) {
        refresh(i);
    }
    for (int i=n; i>=1; i--) {
        sol[i] += sol[i+1];
    }
    for (int i=1; i<=n; i++) {
        cout << sol[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 4212
#include<iostream>
#include<string>
using namespace std;
string S;
int main() {
	cin >> S;
	long long sum = 0;
	for (int i = 0; i <= S.size(); i++) {
		for (int j = i + 1; j <= S.size(); j++) {
			int L = i, R = j;
			long long P = stoll(S.substr(i, j - i));
			int J = i - 1, K = S.size() - j - 1;
			if (J < 0)J = 0; if (K < 0)K = 0;
			sum += P*(1LL << (J + K));
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  
  vector<int>h(N);
int date=0;
  
  for(int i=0;i<N;i++){
cin>>h[i];
  }
  int sum=0;
  
  for(int i=1;i<N;i++){
if(i>=1){
if(h[i]<h[i-1]){
  sum+=h[i-1];
  date+=h[i];
}
}
  }

  cout<<sum-date+h[N-1]<<endl;
 
}
  
  
  

  
  

Measured memory_bytes: 256
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let (a1, a2, a3) = input!(i32, i32, i32);
    let mut a = vec![a1, a2, a3];
    a.sort();
    let ans = (a[0] - a[1]).abs() + (a[1] - a[2]).abs();
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  int k = 1;
  for(int i = 0;i<N;i++){
    if(a[i] == k){
      k++;
    }
  }
  if(k == 1){
    cout << "-1" << endl;
  }
  else{
    cout << N-k+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    a = LI()
    max_a = max(a)
    if max_a == 0 or max_a == 1:
        print(len(a))
        sys.exit()
    t = [0]*(max_a+1)
    for i in a:
        t[i] += 1
    ans = 0
    for i in range(1, len(t)-1):
        temp = t[i-1] + t[i] + t[i+1]
        ans = max(ans, temp)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 19732
import numpy as np
n = int(input())
w = np.array([int(i) for i in input().split()])
ans = 10000000
for t in range(1,n):
    s1 = w[:t].sum()
    s2 = w[t:].sum()
    ans = min(ans, np.abs(s1-s2))
print(ans)


Measured memory_bytes: 27248
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	//	"github.com/pkg/profile"
)

var n = 0

type maxHeap []int

func newHeap() maxHeap {
	return make([]int, 2000000)
}

func (h maxHeap) insert(x int) {
	h[n] = x
	h.raiseUp(n)
	n++
}

func (h maxHeap) extract() int {
	max := h[0]
	h[0] = h[n-1]
	n--
	h.maxHeapify(0)
	return max
}

func (h maxHeap) raiseUp(n int) {
	m := (n - 1) / 2
	if m >= 0 && h[n] > h[m] {
		h[n], h[m] = h[m], h[n]
		h.raiseUp(m)
	}
}

func (h maxHeap) maxHeapify(i int) {
	l := 2*i + 1
	r := 2 * (i + 1)
	m := i
	if l < n && h[i] < h[l] {
		m = l
	}
	if r < n && h[m] < h[r] {
		m = r
	}
	if m != i {
		h[m], h[i] = h[i], h[m]
		h.maxHeapify(m)
	}
}

/*
func (h maxHeap) print(w io.Writer, label string) {
	fmt.Fprintf(w, "tr %s len:%d cap:%d heap:", label, n, cap(h))
	for i := 0; i < n; i++ {
		fmt.Fprintf(w, " %d", h[i])
	}
	fmt.Fprintf(w, "\n")
}
*/

func main() {
	//	defer profile.Start(profile.ProfilePath(".")).Stop()
	var mh = newHeap()

	w := bufio.NewWriter(os.Stdout)

	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	var x int

	for s.Scan() && s.Text() != "end" {
		switch s.Text() {
		case "insert":
			s.Scan()
			x, _ = strconv.Atoi(s.Text())
			mh.insert(x)
		case "extract":
			x = mh.extract()
			fmt.Fprintf(w, "%d\n", x)
		}
	}

	if s.Err() != nil {
		log.Fatal("scan error")
	}
	_ = w.Flush()
}



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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust";
    else cout << "win";
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main(){
  int n;
  cin>>n;
  int p[n];
  for(int i=0;i<n;i++) cin>>p[i];
  int ans=0;
  for(int i=1;i<n-1;i++){
    if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])){
      ans++;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

dp = [1000] * (N + 1)
# 全部買うか全部うるか
for i in range(N):
    dp[i + 1] = dp[i]
    for j in range(i):
        dp[i + 1] = max(dp[i + 1], dp[j] // A[j] * A[i] + dp[j] % A[j])
print(dp[-1])
# print(dp)


Measured memory_bytes: 27224
#include<iostream>
#include<set>
#include<cmath>
using namespace std;

typedef long long ll;

int n;
set<ll> A;

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        A.insert(a);
    }

    ll mx = *A.rbegin();
    A.erase(mx);
    

    double sub = 1e9 + 7;
    ll ans;
    for(auto e : A) {
        if(sub > fabs(mx/2.0 - e)){
            sub = fabs(mx/2.0 - e);
            ans = e;
        }
    }

    cout << mx << " " << ans << endl;

    return 0;
} 

Measured memory_bytes: 4992
import java.util.Scanner;

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

        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();

            if(x == 0 && y == 0) {
                break;
            }

            if(x > y) {
                System.out.println(y + " " + x);
            } else {
                System.out.println(x + " " + y);
            }
        }
    }
}



Measured memory_bytes: 34928
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc086/tasks/abc086_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(a, b):
    c = int(a + b)
    d = int(c**0.5)
    if d**2 == c:
        return 'Yes'
    else:
        return 'No'


def main(args):
    a, b = input().split()
    ans = solve(a, b)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	int i, j, k, l;
	int n;
	int cou;
	int ans[10000];
	
	for (i = 0; i < 10000; i++) {
		ans[i] = 0;
	}
	
	cou = 0;
	
	while (scanf("%d", &n) != EOF) {
		for (i = 0; i <= 9; i++) {
			for (j = 0; j <= 9; j++) {
				for (k = 0; k <= 9; k++) {
					for ( l = 0; l <= 9; l++) {
						if (i + j + k + l == n) {
							ans[cou]++;
						}
					}
				}
			}
		}
		
		cou++;
	}
	
	for (i = 0; i < cou; i++) {
		printf("%d\n", ans[i]);
	}
	
	return (0);
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

signed main() {
    int i,j;
    string alp="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string S;
    int N;
    cin>>N>>S;
    rep(i,0,S.size()){
    int tmp=0;
        rep(j,0,alp.size()){
            if(alp.at(j)==S.at(i)){
                tmp=j;
                break;
            }
        }
        S.at(i)=alp.at((tmp+N)%26);
    }
    cout<<S<<endl;
return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c = [int(x) for x in input().split()]
    count = int(input())

    while not a < b:
        if count == 0:
            break
        b *= 2
        count -= 1
    while not b < c:
        if count == 0:
            break
        c *= 2
        count -= 1

    if a < b < c:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
//file_name:ABC54_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    string a[n];
    string b[m];
    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i];
    }

    int flag = 0;

    rep(i,n-m+1){
        rep(j,n-m+1){
            int f = 0;
            rep(k,m){
                rep(l,m){
                   if(a[i+k][j+l]!=b[k][l])f=1; 
                }
            }
            if(f==0){
                flag=1;
            }
        }
    }

    if(flag==1)yn;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    string s;
    cin >> s;
    map<string, int> m{
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        {"WED", 4},
        {"THU", 3},
        {"FRI", 2},
        {"SAT", 1}
    };
    cout << m[s] << '\n';
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ws = [str(input()) for _ in range(n)]

ans = "Yes"
used = {}
for i in range(n):
    if ws[i] in used or (0 < i and ws[i - 1][-1] != ws[i][0]):
        ans = "No"
        break
    used[ws[i]] = i
print(ans)

Measured memory_bytes: 38528
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> a(n);
    for (int i = 0; i < n;i++){
        cin >> x.at(i) >> y.at(i) >> a.at(i);
    }
    int hst = h;
    int lst = 0;
    int lft = 0;
    int rgt = w;

    for (int i = 0; i < n;i++){
        switch(a.at(i)){
            case 1:
                if(lft<x.at(i)) lft = x.at(i);
                break;
            case 2:
                if(rgt>x.at(i)) rgt = x.at(i);
                break;
            case 3:
                if (lst < y.at(i))lst = y.at(i);
                break;
            case 4:
                if (hst > y.at(i))hst = y.at(i);
                break;
        }
    }
    if ((hst - lst)<=0||(rgt - lft)<=0){
        cout << 0 << endl;
    }else{
        cout << (hst - lst) * (rgt - lft) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# Submit as pypy2


from __future__ import print_function, division, unicode_literals

__metaclass__ = type

try:
    input = raw_input
    range = xrange
except NameError:
    pass


import sys


# Test code requires python3
# from hypothesis import given
# from hypothesis import strategies as st
#
#
# def debug(*args, **kwargs):
#     print(*args, *('{}={}'.format(k, v) for k, v in kwargs.items()),
#           sep='; ', file=sys.stderr)


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    tot = sum(A)
    i = 0
    psum = 0
    while i < N and 2*psum < tot:
        psum += A[i]
        i += 1
    print(min(2*psum - tot, tot - 2*(psum - A[i - 1])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 56556
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

bool used[30010];

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

	if (N == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}

	vector<int> a;
	REP(i, 2, 30000) {
		if (i % 2 == 0 || i % 3 == 0) {
			a.push_back(i);
			used[i] = true;
			if (a.size() == N) break;
		}
	}

	int sum = 0;
	rep(i, N) sum += a[i];
	//cerr << "sum: " << sum << endl;

	if (sum % 2) {
		for (int j = N - 1; j >= 0; j--) {
			int num;
			for (num = a[j] + 1; num <= 30000; num++) {
				if (num % 2 != 0 && num % 3 != 0) continue;
				if ((sum - a[j] + num) % 2 != 0) continue;
				if (!used[num]) {
					break;
				}
			}
			if ((sum - a[j] + num) % 2 == 0 && num <= 30000 && !used[num]) {
				sum += num - a[j];
				//cerr << "!! " << a[j] << " -> " << num << endl;
				used[a[j]] = false;
				a[j] = num;
				used[num] = true;
				break;
			}
		}
	}

	//cerr << "sum: " << sum << endl;

	if (sum % 3) {
		for (int j = N - 1; j >= 0; j--) {
			int num;
			for (num = a[j] + 1; num <= 30000; num++) {
				if (num % 2 != 0 && num % 3 != 0) continue;
				if ((sum - a[j] + num) % 3 != 0 || (sum - a[j] + num) % 2 != 0) continue;
				if (!used[num]) {
					break;
				}
			}
			if ((sum - a[j] + num) % 2 == 0 && (sum - a[j] + num) % 3 == 0 && num <= 30000 && !used[num]) {
				//cerr << "!!! " << a[j] << " -> " << num << endl;
				a[j] = num;
				break;
			}
		}
	}

	cout << a[0];
	REP(i, 1, N - 1) cout << " " << a[i];
	cout << endl;

	sum = 0;
	rep(i, N) sum += a[i];

	rep(i, N) {
		if (gcd(sum - a[i], a[i]) == 1) {
			cerr << "ouch! " << a[i] << endl;
			return 0;
		}
	}

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const double INF = 1e5;
const double eps = 1e-8;

struct Star{
    double px,py,pz,vx,vy,vz,r,vr;
};

Star scan_star(){
    double px,py,pz,vx,vy,vz,r,vr;
    scanf(" %lf %lf %lf %lf %lf %lf %lf %lf", &px, &py, &pz, &vx, &vy, &vz, &r, &vr);
    return Star{px,py,pz,vx,vy,vz,r,vr};
}

inline double pw(double x){
    return x*x;
}

int main(){
    int n;
    while(scanf(" %d", &n),n){
        vector<Star> s(n);
        rep(i,n) s[i] = scan_star();

        vector<double> disappear(n);
        rep(i,n) disappear[i] = s[i].r/s[i].vr;

        auto f = [&](int i, int j, double t){
            return sqrt( pw((s[i].px+t*s[i].vx)-(s[j].px+t*s[j].vx)) + pw((s[i].py+t*s[i].vy)-(s[j].py+t*s[j].vy)) + pw((s[i].pz+t*s[i].vz)-(s[j].pz+t*s[j].vz)) ) - (s[i].r - t*s[i].vr) - (s[j].r - t*s[j].vr);
        };

        auto calc = [&](int i, int j){
            double l = 0, r = min(disappear[i], disappear[j]);
            rep(loop,80){
                double ml = (2*l+r)/3, mr = (l+2*r)/3;
                if(f(i,j,ml) < f(i,j,mr)) r = mr;
                else l = ml;
            }

            double argt = (l+r)/2;
            if(f(i,j,argt)>0) return INF;

            l = 0;
            r = argt;
            rep(loop,80){
                double m = (l+r)/2;
                if(f(i,j,m)>0) l = m;
                else r = m;
            }
            return r;
        };

        using pi = pair<int,int>;
        using P = pair<double, pi>;
        priority_queue<P, vector<P>, greater<P>> pq;

        rep(i,n)rep(j,i){
            double t = calc(i,j);
            if(t < INF - eps) pq.push({t,{i,j}});
        }

        vector<double> ans(disappear);
        vector<bool> rem(n,true);

        while(!pq.empty()){
            P now = pq.top();
            pq.pop();

            int u = now.se.fi, v = now.se.se;
            if(rem[u] && rem[v]){
                ans[u] = ans[v] = now.fi;
                rem[u] = rem[v] = false;
            }
        }

        rep(i,n) printf("%.10f\n", ans[i]);
    }
    return 0;
}



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

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair< int,int>
#define pll pair< ll,ll >
#define vi vector<int>
#define ss second
#define ff first
#define vii vector<pii>
#define vll vector<pll>
#define vl vector<ll>
#define vb vector<bool>
#define f(i,a,b) for(i = a;i < b;i++)
#define rf(i,a,b) for(i = a;i >= b;i--)
//template<class T> void print_data(T& a){ for(auto it : a) cout << it << " "; cout << endl; }

int main(){
	std::ios::sync_with_stdio(false);
	ll i,j,n;
	cin >> n;
	vl a(n);
	map<ll,ll> sum_map;
	sum_map[0] = 1;
	ll cur_sum = 0;
	ll ans = 0;
	f(i,0,n){
		cin >> a[i];
		cur_sum += a[i];
		if(sum_map.find(cur_sum) != sum_map.end()){
			ans += sum_map[cur_sum];
			sum_map[cur_sum]++;
		}
		else{
			sum_map[cur_sum] = 1;
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    
    string N;
    cin >> N;
    
    if (N[1] == N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    } else if (N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    } else if (N[0] == N[1] && N[1] == N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];
void merge(struct Card A[], int n, int left, int mid, int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    } else {
      A[k]=R[j++];
    }
  }
}
void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}
int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
A[i]=A[j];
A[j]=t;
    }
  }
  t=A[i+1];
A[i+1]=A[r];
A[r]=t;
  return i + 1;
}
void quickSort(struct Card A[],int n, int p, int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
int main() {
  int n,i,x;
  struct Card X[MAX],Y[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i =0;i<n;i++){
    scanf("%s %d",S,&x);
    X[i].suit=Y[i].suit=S[0];
    X[i].value=Y[i].value=x;
  }

  mergeSort(X,n,0,n);
  quickSort(Y,n,0,n-1);

  for(i=0;i<n;i++){
    if(X[i].suit!=Y[i].suit)stable=0;
  }

  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",Y[i].suit,Y[i].value);
  }

  return 0;
}



Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
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 main(void) {
    LL n,m,x,L=0,R=0;
    cin >> n >> m >> x;
    vector<int> A;
    rep(i, m){
      int a;
      cin >> a;
      A.pb(a);
    }
    SORT(A);
     rep(i,m){
        if(A[i]<x){
            L++;
        }else{
            R++;
        }
        }
    cout << min(L,R);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read()
{int x=0,f=0;
char c=getchar();
while (c<'0'||c>'9') 
{if (c=='-') f=1;
c=getchar();
}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
if (f) x=-x;
return x;
}
char s[200005],o[200005];
int cnt[27],n,u[27];
vector <int> vec[27];
int t[200005],p[200005];
inline int ask(int p)
{int s=0;
while (p)
{s+=t[p];p-=(p&(-p));}
return s;
}
inline void add(int p)
{while (p<=n)
{t[p]++;p+=(p&(-p));}
}
int main (){
	scanf ("%s",s+1);
	n=strlen(s+1);int i,num=0;
	for (i=1;i<=n;i++)
	{cnt[s[i]-'a']++;
	vec[s[i]-'a'].push_back(i);
	}
	for (i=0;i<26;i++)
	{if (cnt[i]%2==1) {num++;}
	}
	if (num>=2) {puts("-1");return 0;}
	for (i=1;i<=n;i++)
	{o[i]=s[n+1-i];}
	for (i=1;i<=n;i++)
	{p[i]=vec[o[i]-'a'][u[o[i]-'a']++];}
	ll ans=0;
	for (i=1;i<=n;i++)
	{ans+=ask(n)-ask(p[i]);
	add(p[i]);
	}
	printf ("%lld",ans/2);
	return 0;
}
	
	

Measured memory_bytes: 3200
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(input())
b = []
for i in range(m):
    b.append(input())

ans = "No"
for x in range(0,n-m+1):
    for y in range(0,n-m+1):
        bina = True
        for i in range(m):
            for j in range(m):
                if a[x+i][y+j] != b[i][j]:
                    bina = False
        if bina:
            ans = "Yes"

print(ans)

Measured memory_bytes: 41072
#include <iostream>
#include <vector>
#include <algorithm> 
#include <cmath>
#include <numeric>
using namespace std;


int main(void){
    // Your code here!
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256