akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <x86intrin.h>
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

const int NMX = 2048;
int16_t d[NMX][NMX];

void f1(int N){
	for (int k = 0; k < N; k++) for (int i = 0; i < N; i++){
		int j = 0;
		const __m128i dik = _mm_set1_epi16(d[i][k]);
		for (;j+7<N;j+=8){
			__m128i dij = _mm_load_si128((__m128i*)(d[i] + j));
			__m128i dkj = _mm_load_si128((__m128i*)(d[k] + j));
			dkj = _mm_add_epi16(dkj, dik);
			dij = _mm_min_epi16(dij, dkj);
			_mm_store_si128((__m128i*)(d[i] + j), dij);
		}
 
		for (;j<N;j++){
		  d[i][j] = min<int>(d[i][j], d[i][k] + d[k][j]);
		}
	}
}
/*
void f2(int N){
	for (int k = 0; k < N; k++) for (int i = 0; i < N; i++){
		int j = 0;
		const __m256i dik = _mm256_set1_epi16(d[i][k]);
		for (;j+15<N;j+=16){
			__m256i dij = _mm256_load_si256((__m256i*)(d[i] + j));
			__m256i dkj = _mm256_load_si256((__m256i*)(d[k] + j));
			dkj = _mm256_add_epi16(dkj, dik);
			dij = _mm256_min_epi16(dij, dkj);
			_mm256_store_si256((__m256i*)(d[i] + j), dij);
		}
 
		for (;j<N;j++){
		  d[i][j] = min<int>(d[i][j], d[i][k] + d[k][j]);
		}
	}
}
*/
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, x, y;
	cin >>n >>x >>y;
	//vector<VI> a(n, VI(n, INF));
	//rep(i, n) a[i][i] = 0;
	//rep(i, n-1) a[i][i+1] = a[i+1][i] =1;
	//a[x-1][y-1] = a[y-1][x-1] =1;
	//rep(k,n) rep(i,n) rep(j,n) a[i][j] =min(a[i][j], a[i][k] + a[k][j]);
	
	rep(i, n+2) rep(j, n+2) d[i][j] = n;
	rep(i, n) d[i][i] = 0;
	rep(i, n-1) d[i][i+1]=d[i+1][i] =1;
	d[x-1][y-1] = d[y-1][x-1] =1;
	f1(n);
	//dbg("dd");
	VI ds(n+2);
	rep(i, n) rep2(j, i+1, n) ds[d[i][j]]++;
	
	//for(auto x :ds) cerr<<x<<" "; dbg();
	rep2(i, 1, n) cout << ds[i]<<"\n";
	return 0;

	return 0;
}


Measured memory_bytes: 8448
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int X;
	cin >> X;
	int ans;
	if (400 <= X && X <= 599) {
		ans = 8;
	} else if (600 <= X && X <= 799) {
		ans = 7;
	} else if (800 <= X && X <= 999) {
		ans = 6;
	} else if (1000 <= X && X <= 1199) {
		ans = 5;
	} else if (1200 <= X && X <= 1399) {
		ans = 4;
	} else if (1400 <= X && X <= 1599) {
		ans = 3;
	} else if (1600 <= X && X <= 1799) {
		ans = 2;
	} else if (1800 <= X && X <= 1999) {
		ans = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long ans=(n/(a+b))*a;
		ans+=Math.min(a,(n%(a+b)));
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int TEST;
string s[12];
bool u[12][9];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
set<P>st;
int dfs(int y,int x,char c){
  int res=1;
  u[y][x]=1;
  r(i,4){
    int yy=y+dy[i];
    int xx=x+dx[i];
    if(yy<0||xx<0||yy>11||xx>5)continue;
    if(s[yy][xx]==c&&!u[yy][xx])res+=dfs(yy,xx,c);
  }
  return res;
}
void ell(int y,int x,char c){
  s[y][x]='.';
  st.insert(P(y,x));
  r(i,4){
    int yy=y+dy[i];
    int xx=x+dx[i];
    if(yy<0||xx<0||yy>11||xx>5)continue;
    if(s[yy][xx]==c)ell(yy,xx,c);
  }
}
void fall(){
  r(i,12)r(j,6)if(s[i][j]=='O'){
    r(k,4){
      int y=i+dy[k];
      int x=j+dx[k];
      if(x<0||y<0||x>5||y>11)continue;
      if(st.count(P(y,x)))s[i][j]='.';
    }
  }
  r(k,12)r(i,6)for(int j=11;j>0;j--)
    if(s[j][i]=='.')swap(s[j][i],s[j-1][i]);
}
int solve(){
  for(int ans=0;;ans++){
    st.clear();
    int f=0;
    memset(u,0,sizeof(u));
    vector<P>v;
    r(i,12)r(j,6)if(!u[i][j]&&isalpha(s[i][j])&&s[i][j]!='O'){
      if(dfs(i,j,s[i][j])>=4)v.push_back(P(i,j));
    }
    if(!v.size())return ans;
    r(i,v.size())ell(v[i].first,v[i].second,s[v[i].first][v[i].second]);
    fall();
  }
}
int main(){
  cin>>TEST;
  while(TEST--){
    r(i,12)cin>>s[i];
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 2996
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut count = vec![0; n + 1];
    for i in 1..=n {
        let mut cur = i;
        while cur <= n {
            count[cur] += 1;
            cur += i;
        }
    }

    let mut ans = 0;
    for i in 1..=n {
        ans += count[i] * i;
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 80180
from collections import deque


def discard(c: str, da: deque, db: deque, dc: deque) -> str:
    if eval(f'len(d{c})'):
        c = eval(f'd{c}.popleft()')
    else:
        return c.upper()

    return discard(c, da, db, dc)


def answer(sa: str, sb: str, sc: str) -> str:
    deque_a = deque(list(sa))
    deque_b = deque(list(sb))
    deque_c = deque(list(sc))
    return discard(deque_a.popleft(), deque_a, deque_b, deque_c)


def main():
    sa, sb, sc = [input() for _ in range(3)]
    print(answer(sa, sb, sc))


if __name__ == '__main__':
    main()

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


typedef struct{
	int name;
	int wrong_time[11];
	int pena;
	int AC;
}DATA;

int main(){
	int T,P,R;
	while(cin>>T>>P>>R,T){
		DATA data[51];
		for(int i=1;i<=T;i++){
			data[i].name=i;
			for(int j=0;j<=10;j++)data[i].wrong_time[j]=0;
			data[i].pena=0;
			data[i].AC=0;
		}
		for(;R>0;R--){
			int t,p,time;
			string str;
			cin>>t>>p>>time>>str;
			if(str=="WRONG"){
				data[t].wrong_time[p]++;
			}
			else{
				data[t].AC++;
				data[t].pena+=(time+1200*data[t].wrong_time[p]);
			}
		}
		for(int i=0;i<=T;i++){
			for(int j=1;j<T;j++){
				if(data[j].AC<data[j+1].AC)swap(data[j],data[j+1]);
				if(data[j].AC==data[j+1].AC&&data[j].pena>data[j+1].pena)swap(data[j],data[j+1]);
				if(data[j].AC==data[j+1].AC&&data[j].pena==data[j+1].pena&&data[j].name>data[j+1].name)swap(data[j],data[j+1]);
			}
		}
		for(int i=1;i<=T;i++){
			cout<<data[i].name<<" "<<data[i].AC<<" "<<data[i].pena<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1216
#include <stdio.h>
#include <complex>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<double> P;
#define EPS (1e-12)

double cross(const P& a, const P& b) { return imag(conj(a)*b); }

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        double x1, y1, x2, y2, x3, y3, x4, y4;
        scanf("%lf%lf", &x1, &y1);
        scanf("%lf%lf", &x2, &y2);
        scanf("%lf%lf", &x3, &y3);
        scanf("%lf%lf", &x4, &y4);
        const bool a = (fabs(cross(P(x1-x2, y1-y2), P(x3-x4, y3-y4))) < EPS);
        puts(a ? "YES" : "NO");
    }
    return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if(a>=13){
		cout << b << endl;
	}
	else if(a>=6){
		cout << b/2 << endl;
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}


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

int main(void) {
	int n,count=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if((i+1)%2 == 1){
			if(a[i]%2 == 1){
				count++;
			}
		}
	}
	printf("%d\n",count);
}


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

#define fi first
#define se second
typedef pair<int,int> PII;


int inv[2], flips[2], n, t[2][1<<17], p[1<<17], a[5][1<<17];

void update(int idx, int idy) { for (;idx;idx-=(idx&-idx)) t[idy][idx]++; }
int get(int idx, int idy) {
    int ret = 0;
    for (; idx <= n; idx += (idx & -idx)) ret += t[idy][idx];
    return ret;
}

void lose() { cout << "No\n"; exit(0); }

int main() {
    cin >> n;
    for (int i = 1; i <= 3; i++) for (int j = 1; j <= n; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        if (abs(a[1][i] - a[2][i]) != 1 || abs(a[2][i] - a[3][i]) != 1) lose();
        if (a[2][i] % 3 != 2) lose();
        int j = (a[1][i] + 2) / 3;
        if ((i - j) % 2) lose();

        inv[i&1] = (inv[i&1] + (a[1][i] > a[3][i])) % 2;
        p[j] = i;
    }
    for (int i = 1; i <= n; i++) {
        int x = get(p[i],(i&1));
        flips[i&1] = (flips[i&1] + x) % 2;
        update(p[i],(i&1));
    }
    if (flips[0] != inv[1] || flips[1] != inv[0]) lose();
    cout << "Yes\n";
}


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

class dice {
    public:
    int top;
    int bottom;
    int north;
    int east;
    int south;
    int west;
    
    dice() {}
    
    void N() {
        int np = north;
        int tp = top;
        int sp = south;
        int bp = bottom;
        north = tp;
        top = sp;
        south = bp;
        bottom = np;
    }
    
    void S() {
        int np = north;
        int tp = top;
        int sp = south;
        int bp = bottom;
        north = bp;
        top = np;
        south = tp;
        bottom = sp;
    }
    
    void E() {
        int ep = east;
        int bp = bottom;
        int wp = west;
        int tp = top;
        east = tp;
        bottom = ep;
        west = bp;
        top = wp;
    }
    
    void W() {
        int ep = east;
        int bp = bottom;
        int wp = west;
        int tp = top;
        east = bp;
        bottom = wp;
        west = tp;
        top = ep;
    }
    
    void clock() {
        int ep = east;
        int sp = south;
        int wp = west;
        int np = north;
        east = np;
        south = ep;
        west = sp;
        north = wp;
    }
    
};

int check(dice dice1, dice dice2) {
    if (dice1.top == dice2.top && dice1.bottom == dice2.bottom
    &&dice1.north == dice2.north && dice1.east == dice2.east
    && dice1.south == dice2.south && dice1.west == dice2.west ) {
        return 1;
    } else {
        return 0;
    }
}


int main() {
    
  int n;
  cin >> n;
  
  dice d[n];
  for (int i=0; i<n; i++) {
     cin >> d[i].top >> d[i].south >> d[i].east;
     cin >> d[i].west >> d[i].north >> d[i].bottom;
  }
  
  int same = 0;
  string ans;
  
  for (int i=0; i<n-1; i++) {
      for (int j=i+1; j<n; j++) {
          for (int k=0; k<4 && check(d[i],d[j]) == 0; k++) {
              d[j].E();
              for (int l=0; l<4 && check(d[i],d[j]) == 0; l++) {
                  d[j].clock();
              }
          }
          for (int k=0; k<4 && check(d[i],d[j]) == 0; k++) {
              d[j].N();
              for (int l=0; l<4 && check(d[i],d[j]) == 0; l++) {
                  d[j].clock();
              }
          }
          if (check(d[i],d[j]) == 1) {
              same = 1;
              goto ANS;
          } else {
              same = 0;
          }
      }
  }
  
  ANS:
    if (same == 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

  return 0;
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)
	swap(a,b);
	if(a>c)
	swap(a,c);
	if(b>c)
	swap(b,c);
	cout<<a+b;
	return 0;
}

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

int main()
{
  int64_t X, count = 0;
  cin >> X;
  int64_t M = 100;
  
  while(M < X)
  {
    M += M / 100; 
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3636
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu(x) push_back(x)
#define eb(x) emplace_back(x)
#define pp pop_back()
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
const int MOD=1e9+7 , INF=INT_MAX;
const long long LINF=LLONG_MAX;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> ivc;
typedef pair<int,int> ipr;
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
  //  #ifndef ONLINE_JUDGE
  //  	freopen("input.txt", "r", stdin);
   // 	freopen("output.txt","w",stdout);
  //  #endif
    int n,i;
    cin>>n;
    ll a[n+1],b[n];
    f(i,0,n+1)
    {
    	cin>>a[i];
    }
    f(i,0,n)
    {
    	cin>>b[i];
    }
   	ll ans=0,p=0;
   	f(i,0,n)
   	{
   		ans+=min(p,a[i]);
   		a[i]-=min(p,a[i]);
   		ans+=min(a[i],b[i]);
   		p=b[i]-min(a[i],b[i]);
   	}
   	ans+=min(p,a[i]);
   	cout<<ans<<endl;
 
}

Measured memory_bytes: 1792
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val groups:List[List[Integer]] = List(List(1, 3, 5, 7, 8, 10, 12), List(4, 6, 9, 11), List(2))
    val sc = {
      new Scanner(System.in)
    }
    val x, y = sc.nextInt

    var answer = "No"

    groups.foreach( group => {
      if (group.contains(x) && group.contains(y)) {
        answer = "Yes"
      }
    })

    println(answer)
  }
}

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

using ld=long double;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    vector<vector<vector<ld>>> dp(n+1,vector<vector<ld>>(n+1,vector<ld>(n+1,0)));
    vector<ld> weight(n+1,0);
    for(int i=0;i<=n;i++){
        ld x=1;
        for(int j=0;j<=10000;j++){
            weight[i]+=(j+1)*x;
            x=x*i/n;
        }
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                if(i+j+k>n) continue;
                ld x=n-(i+j+k);
                if(i>0){
                    dp[i][j][k]+=dp[i-1][j+1][k]*i/(n-x)+weight[x]*i/n;
                }
                if(j>0){
                    dp[i][j][k]+=dp[i][j-1][k+1]*j/(n-x)+weight[x]*j/n;
                }
                if(k>0){
                    dp[i][j][k]+=dp[i][j][k-1]*k/(n-x)+weight[x]*k/n;
                }
            }
        }
    }
    int k=count(a.begin(),a.end(),1);
    int j=count(a.begin(),a.end(),2);
    int i=count(a.begin(),a.end(),3);
    cout<<fixed<<setprecision(10);
    cout<<dp[i][j][k]<<endl;
    return 0;
}

Measured memory_bytes: 431360
def checkPrime(num):
    isPrime = True
    for i in range(2,(num//2)+1):
        if(num%i == 0):
            isPrime = False
            break
    return isPrime
def nextPrime(num):
    if(checkPrime(num)):
        return num
    n = num-1 if(num%2==0) else num
    while(True):
        n +=2
        if(checkPrime(n)):
            result = n
            break
    return result

num = int(input())
print(nextPrime(num))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>
#include <queue>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define llint long long
#define inf 1e18
#define eps 1e-9
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct vec2d{
	double x, y;
	vec2d(){}
	vec2d(double x, double y){
		this->x = x, this->y = y;
	}
	double add(double a, double b){
		if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
		return a+b;
	}
	vec2d operator+(vec2d ope){
		return vec2d(add(x, ope.x), add(y, ope.y));
	}
	vec2d operator-(vec2d ope){
		return vec2d(add(x, -ope.x), add(y, -ope.y));
	}
	vec2d operator*(double t){
		return vec2d(x*t, y*t);
	}
	vec2d operator/(double t){
		return vec2d(x/t, y/t);
	}
	double dot(vec2d ope){
		return add(x*ope.x, y*ope.y);
	}
	double cross(vec2d ope){
		return add(x*ope.y, -y*ope.x);
	}
	double norm(){
		double d2 = dot(*this);
		if(d2 > 0) return sqrt(d2);
		return 0.0;
	}
};

double distPP(vec2d p, vec2d q){
	return (p-q).norm();
}

double distSP(vec2d p, vec2d q, vec2d x)
{
	if((x-p).dot(q-p) <= 0) return distPP(p, x);
	if((x-q).dot(p-q) <= 0) return distPP(q, x);
	return fabs( (x-p).cross(q-p) / distPP(p, q) );
}

bool isOnS(vec2d p, vec2d q, vec2d x)
{
	return (p-x).cross(q-x) == 0 && (p-x).dot(q-x) <= 0;
}

bool isCross(vec2d p, vec2d q, vec2d r, vec2d s)
{
	if((q-p).cross(s-r) == 0){
		return isOnS(p, q, r) || isOnS(p, q, s) || isOnS(r, s, p) || isOnS(r, s, q);	
	}
	double t = (r-p).cross(s-r) / (q-p).cross(s-r);
	vec2d x = p + (q-p)*t;
	return isOnS(p, q, x) && isOnS(r, s, x);
}

bool getCross(vec2d p, vec2d q, vec2d r, vec2d s, vec2d &ret)
{
	if((q-p).cross(s-r) == 0){
		return false;
	}
	double t = (r-p).cross(s-r) / (q-p).cross(s-r);
	ret = p + (q-p)*t;
	return true;
}

llint n;
vec2d p[55];

bool get(vec2d o, vec2d a, vec2d b, vec2d &ret)
{
	vec2d A = (o + a) * 0.5, B = (o + b) * 0.5;
	vec2d da = A - a, db = B - b;
	vec2d nA = vec2d(da.y, -da.x), nB = vec2d(db.y, -db.x);
	nA = nA / nA.norm(), nB = nB / nB.norm();
	//cout << o.x << " " << o.y << " " << a.x << " "  << a.y << " " << b.x << " " << b.y << endl;
	return getCross(A, A+nA, B, B+nB, ret);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y;
	
	if(n == 2){
		printf("%.11f\n", distPP(p[1], p[2])*0.5);
		return 0;
	}
	
	double ans = inf;
	for(int i = 1; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			vec2d c = (p[i] + p[j]) * 0.5;
			double r = distPP(c, p[i]);
			bool flag = true;
			for(int l = 1; l <= n; l++){
				if(distPP(c, p[l]) > r + eps){
					flag = false;
					break;
				}
			}
			if(flag) ans = min(ans, r);
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = i+1; j <= n; j++){
			for(int k = j+1; k <= n; k++){
				vec2d c;
				if(!get(p[i], p[j], p[k], c)) continue;
				double r = distPP(c, p[i]);
				//cout << c.x << " " << c.y << endl;
				bool flag = true;
				for(int l = 1; l <= n; l++){
					if(distPP(c, p[l]) > r + eps){
						flag = false;
						break;
					}
				}
				if(flag) ans = min(ans, r);
			}
		}
	}
	printf("%.11f\n", ans);
	
	return 0;
}

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

#define MAX 2000001
#define SCORE 10001


int n,nums; 
int counter[SCORE+1], maxi;
int list[MAX+1], sortedList[MAX+1];


void CountingSort() {
  memset(counter,0,sizeof counter);
  int i;
  for(i=0;i<n;++i) ++counter[list[i]];
  for(i=1;i<=maxi;++i) counter[i] += counter[i-1];
  for(i=n-1;i>=0;--i) {
    sortedList[--counter[list[i]]] = list[i];
  }
}

int main() {
  int i, id;
  while( scanf("%d",&n) != EOF ) {
    maxi = 0;
    for(i=0;i<n;++i) {
      scanf("%d",&nums);
      list[i] = nums;
      if( maxi < nums ) maxi = nums;
    }
    CountingSort();
    for(i=0;i<n;++i) {
      if( i ) printf(" ");
      printf("%d",sortedList[i]);
    } puts("");
  }
  return 0;
}



Measured memory_bytes: 17380
def resolve():
    import math
    a, b, h, m = map(int, input().split())
    ms = m*6
    hs = h*30+m*0.5
    theta = abs(hs-ms)
    if theta >= 180:
        theta = 360-theta
    ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(theta))
    ans = ans** 0.5
    print(ans)
resolve()

Measured memory_bytes: 9504
/* 実装例　Atcoder Beginers Contest 174-F Range Set query */
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,q; cin >> n >> q;
    int sq=sqrt(n);
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        c[i]--;
    }
    vector<int> l(q),r(q);
    rep(i,q){
        cin >> l[i] >> r[i];
        l[i]--;
    }
    
    vector<int> qu(q);
    rep(i,q) qu[i]=i;
    sort(ALL(qu),[&](int i,int j){if(l[i]/sq!=l[j]/sq) return l[i]<l[j]; else return r[i]<r[j];});
    
    vector<int> ans(q);
    vector<int> cnt(n,0);
    int nl=0,nr=0;
    int res=0;
    auto add=[&](int i){if(cnt[c[i]]++==0) res++;};
    auto del=[&](int i){if(--cnt[c[i]]==0) res--;};
    for(int i:qu){
        while(nl> l[i]) add(--nl);
        while(nl< l[i]) del(nl++);
        while(nr< r[i]) add(nr++);
        while(nr> r[i]) del(--nr);
        /* ここから結果 */
        ans[i]=res;
    }
    rep(i,q) cout << ans[i] << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using lint = long long;
using ulint = unsigned long long;

int main(void)
{
    ulint A;
    double B;
    cin >> A;
    cin >> B;

    lint X = (ulint)(B * 100 + 0.001);
    int c = 0; 
    cout << A * X / (ulint)100 << endl;
    
    return 0;
}

Measured memory_bytes: 3724
S = input()
leng = len(S)

def make_valid(leng):
    s0 = ''
    s1 = ''
    last0 = '0'
    last1 = '1'
    for i in range(leng):
        s0 = s0 + last0
        s1 = s1 + last1
        last0, last1 = last1, last0
    return (s0, s1)


def count_dif(s, s1):
    ret = 0
    for idx,c in enumerate(s):
        if c != s1[idx]:
            ret += 1
    return ret

v0,v1 = make_valid(leng)
min_dif = min(count_dif(S,v0), count_dif(S,v1))
print(min_dif)


Measured memory_bytes: 3316
x, y = gets.split.map &:to_i

# x = a + b
# y = 2(a + 2b)

def is_legal(x, y)
	0.upto(100) { |a|
		0.upto(100) { |b|
			return true if x == a + b and y == a * 2 + b * 4
		}
	}
	return false
end

puts (is_legal(x, y)) ? "Yes" : "No"

Measured memory_bytes: 14300
#include <stdio.h>
#define NIL -1

struct Node{
  int p,left,right;
};
struct Node T[1000000];
int n;

void preorder(int);
void inorder(int);
void postorder(int);

int main(){
  int id,i,left,right,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    T[id].left = left;
    T[id].right = right;

    if(left != NIL){
      T[left].p = id;
    }

    if(right != NIL){
      T[right].p = id;
    }

  }

  for(i=0;i<n;i++){
    if(T[i].p == NIL){
      root = i;
    }
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");

  return 0;
}


void preorder(int u){
  if(u == NIL) return;
  printf(" %d",u);
  preorder(T[u].left);
  preorder(T[u].right);
}

void inorder(int u){
  if(u == NIL) return;
  inorder(T[u].left);
  printf(" %d",u);
  inorder(T[u].right);
}
void postorder(int u){
  if(u == NIL) return;
  postorder(T[u].left);
  postorder(T[u].right);
  printf(" %d",u);
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    int n, ans1, ans2;
    cin >> n;
    int cnt = 0;
    vector<int> b(9, 0);
    for (int i = 0; i < n; i++) {
        int buf;
        cin >> buf;
        if (buf < 400) b[0]++;
        else if (buf < 800) b[1]++;
        else if (buf < 1200) b[2]++;
        else if (buf < 1600) b[3]++;
        else if (buf < 2000) b[4]++;
        else if (buf < 2400) b[5]++;
        else if (buf < 2800) b[6]++;
        else if (buf < 3200) b[7]++;
        else if (buf >= 3200) b[8]++;
    }
    for (int i = 0; i < 8; i++) {
        if (b[i] != 0) cnt++;
    }
    ans1 = cnt;
    ans2 = cnt + b[8];
    ans1 = max(1, ans1);
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const ll INF = 1e18;

int main(){
  int n;
  cin >> n;
  vector<ll> p2(n+1);
  ll pw = 1;
  rep(i, n+1){
    p2.at(i) = pw;
    if(pw < INF)pw *= 2;
    else pw = INF;
  }
  vector<ll> a(n+1);
  rep(i, n+1){
    ll in;
    cin >> in;
    a.at(i) = in;
  }
  a.push_back(0);
  vector<pair<ll, ll>> lim(n+1);
  lim.push_back(make_pair(0, 0));
  rrep(i, n+1){
    auto p = lim.at(i+1);
    pair<ll, ll> add;
    add.first = (p.first+1)/2+a.at(i);
    add.second = p.second+a.at(i);
    // cerr << i << " " << p.first << " " << p.second << " " << add.first << " " << add.second << " " << a.at(i) << endl;
    if(add.first > p2.at(i)){
      cout << -1 << endl;
      return 0;
    }
    if(add.second > p2.at(i)){
      add.second = p2.at(i);
    }
    lim.at(i) = add;
  }
  // rep(i, n+1){
  //   cerr << lim.at(i).first << " " << lim.at(i).second << endl;
  // }
  // cerr << endl;
  ll ans = 0;
  ll now = 1;
  rep(i, n+1){
    ans += now;
    now -= a.at(i);
    now *= 2;
    if(i != n) if(now > lim.at(i+1).second) now = lim.at(i+1).second;
    // cerr << ans << " " << now << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7876
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    cs <- U.unfoldrN n B.uncons <$> B.getLine
    q <- readLn :: IO Int
    ks <- map read.words <$> getLine
    mapM_ (print.solve cs) ks

solve :: U.Vector Char -> Int -> Int
solve cs k = fst $ U.foldl' step (U.foldl' step0 (0, emptyQ) pre) $ U.zip cs post
  where
    (pre, post) = U.splitAt k cs
    step0 (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c q

    step (!res, !q) (ck, c)
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c $ pop ck q

data Q = Q !Int !Int !Int

emptyQ :: Q
emptyQ = Q 0 0 0

push :: Char -> Q -> Q
push 'D' (Q d m dm) = Q (d + 1) m dm
push 'M' (Q d m dm) = Q d (m + 1) (dm + d)
push c q            = q

pop :: Char -> Q -> Q
pop c (Q d m dm) = case c of
    'D' -> Q (d - 1) m (dm - m)
    'M' -> Q d (m - 1) dm
    _   -> Q d m dm

score :: Q -> Int
score (Q _ _ dm) = dm


Measured memory_bytes: 7164
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,ans=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        string s=to_string(i),t;
        t=s;
        reverse(t.begin(),t.end());
        if(s==t)ans++;
        //cout<<s<<" "<<t<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    stack<char> s1, s2;
    bool is_exist = false;
    int ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '*') is_exist = true;
        else if (S[i] == '(') {
            if (is_exist) s2.push(S[i]);
            else s1.push(S[i]);
        }
        else {
            if (s2.empty()) {
                s1.pop();
                if (is_exist) ans++;
            }
            else s2.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3248
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, a, b) = (v[0] as usize, v[1], v[2]);
    let mut h = vec![];
    for i in 0..n {
        h.push(read::<i64>());
    }
    let criterion = |mid: i64| -> bool {
        let mut count = 0;
        for &num in h.iter() {
            let mut num = num;
            num -= b * mid;
            if num > 0 {
                count += (num + (a - b) - 1) / (a - b);
            }
        }
        count > mid
    };
    let (ok, ng) = binary_search(0, h.iter().max().unwrap() / b + 1, criterion);
    println!("{}", ng);
}

fn binary_search<F>(lb: i64, ub: i64, criterion: F) -> (i64, i64)
where
    F: Fn(i64) -> bool,
{
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 1 {
        let mid = (ng + ok) / 2;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

bool primes[1007];
int cnt[1007];

void sieve(int n)
{
    for (int i = 2; i <= n; i++) {
        if (primes[i]) continue;
        for (int j = i+i; j <= n; j += i) {
            primes[j] = 1;

            int tmp = j;
            while (tmp % i == 0) cnt[i]++, tmp /= i;
        }
        cnt[i]++;
    }
}

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

    sieve(n);

    ll nod = 1;
    for (int i = 2; i <= n; i++) {
        if (!primes[i]) nod = (nod * (cnt[i] + 1)) % mod;
    }

    cout << nod << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define ld long double
#define uint unsigned int
#define endl '\n'
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define eb emplace_back 
#define pll pair<long long ,long long > 
#define ppll pair < pll , pll > 
#define pd pair<int, int>
#define ppdd pair<pd, pd>
#define vd vector<int>
#define sd(x) scanf("%d",&x) 
#define sld(x) scanf("%lld",&x) 
#define deb(x) { cerr << #x << '=' << x << '\n'; }
#define tc(x) sd(x); while(x--)
#define INF 1e18 
#define eps 0.00001 
#define le length 
#define inc(il)
using namespace std;

void solve(){
    //code goes here
    int n,cnt=0;
    double d;
    cin >> n >> d;
    double x,y;
    for (int i = 1; i<=n; ++i){
        cin >> x >> y;
        double dist=sqrt(x*x+y*y);
        if (dist<=d) cnt++;
    }
    cout << cnt;
}

int main(){
    ios::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL); 
    solve();
    return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int counter(int x) {
  if(x == 0) return 0;
  return counter(x >> 1) + (x & 1);
}

int main(void) {
  int n;
  int xy[16][16][2];
  int a[16];
  scanf("%d", &n);
  rep(i, 0, n) {
    scanf("%d", &a[i]);
    rep(j, 0, a[i]) {
      scanf("%d %d", &xy[i][j][0], & xy[i][j][1]);
    }
  }
  
  // bit探索
  int ans = 0;
  rep(t, 0, 1 << n) {
    int ok = 1;
    rep(p, 0, n) {
      if ((t & (1 << p)) == 0) continue;
      rep(i, 0, a[p]) {
        if (((t >> (xy[p][i][0] - 1)) & 1) != xy[p][i][1]) 
          ok = 0;
      }
    }
    if (ok) ans = max(ans, counter(t));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); in.nextLine();
		String s = in.nextLine();
		
		String f = "."+s+".";
		String[] ary = f.split("");
		// System.out.println(Arrays.toString(ary));
		
		String left = "";
		String right = "";
		boolean matchFound = false;
		
		for ( int i = 1; i < ary.length; i++ ) {
			if ( ary[i].equals(")") ) {
				for ( int j = i-1; j >= 0; j-- ) {
					if ( ary[j].equals("(") ) {
						matchFound = true;
						ary[i] = ".";
						ary[j] = ".";
						break;
					}
				}
				// System.out.println(matchFound);
				if ( matchFound == false ) {
					left += "(";
					// matchFound = false;
				}
			} else if ( ary[i].equals("(") ) {
				for ( int k = i+1; k < ary.length; k++ ) {
					if ( ary[k].equals(")") ) {
						matchFound = true;
						ary[i] = ".";
						ary[k] = ".";
						break;
					}
				}
				if ( matchFound == false ) {
					right += ")";
				}
			}
			matchFound = false;
			// System.out.println(Arrays.toString(ary));
		}
		
		
		System.out.println(left+s+right);
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
using namespace std;
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int main()
{
    int n,m;
    cin>>n>>m;
    long long x[n],y[n],z[n];
    rep(i,n)
    {
        cin>>x[i]>>y[i]>>z[i];
    }
    long long sum[n],x1,y1,z1,ma=-INF2,sum2;
    rep(i,8)
    {
        if(i%2==0)x1=1;
        else x1=-1;
        if(i/4==0)y1=1;
        else y1=-1;
        if((i/2)%2==0)z1=1;
        else z1=-1;
        rep(j,n)
        {
            sum[j]=x1*x[j]+y1*y[j]+z1*z[j];
        }
        sort(sum,sum+n);
        sum2=0;
        rep(j,m)
        {
            sum2+=sum[n-1-j];
        }
        ma=max(ma,sum2);
    }
    W(ma)
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;

vi pre,in,post;
int root;

void rec(int l,int r){
    if(r-l<1)return;
    int m;
    Rep(i,l,r){
        if(in[i]==pre[root]){
            m=i;
            root++;
            break;
        }
    }
    rec(l,m);
    rec(m+1,r);
    post.pb(in[m]);
}

signed main(){
    int n;
    cin>>n;
    int v;
    rep(i,n){
        cin>>v;
        pre.pb(v);
    }
    rep(i,n){
        cin>>v;
        in.pb(v);
    }
    rec(0,n);
    rep(i,n){
        cout<<post[i]<<(i!=n-1?' ':'\n');
    }
    return 0;
}


Measured memory_bytes: 3140
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i=0;i<n;i++) {
			a.add(sc.nextInt());
		}
		sc.close();
		int idx=0;
		int ii=1;
		int cnt=0;
		boolean b = false;
		do {
			// 整数iが見つかる位置
			idx = a.indexOf(ii);
			if(idx>=0) {
				a = a.subList(idx, a.size());
				cnt +=(idx-1);
				ii++;
				b = true;
			}else{
				break;
			}
		}while(n>idx);
		if(n-cnt>a.size()) cnt+=a.size();
		System.out.println(b?cnt:-1);
	}
}


Measured memory_bytes: 76088
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String fst = br.readLine();
			int n = Integer.parseInt(fst);
			if(n==0){break;}
			String line = br.readLine();
			String[] str = line.split(" ");
			double[] s = new double[str.length];
			for (int j = 0; j<n ; j++ ) {
				s[j] = Double.parseDouble(str[j]);
			}

			double sum = 0.0;
			for (int j = 0; j<n ; j++ ) {
				sum += s[j];
			}
			double num = n;
			double avr = sum/num;
			double a = 0.0;
			for (int j = 0; j<n ; j++) {
				a += (s[j]-avr)*(s[j]-avr);		
			}
			a /= num;
			a = Math.sqrt(a);
			System.out.printf("%.6f\n",a);
		}
	}
}

Measured memory_bytes: 26480
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    char a;
    cin >> a;
    if (a == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
const int N = 2000000;
bool prime[N];
vector<int> primes;
void hurui()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;

	for (int i = 2; i*i < N; i++)
	{
		for (int j = 2; i*j < N; j++)
		{
			prime[i*j] = false;
		}
	}
	REP(i, N + 1)
	{
		if (prime[i]) primes.push_back(i);
	}
}


int main()
{
	hurui();
	int n; cin >> n;
	cout << n << ":";
	REP(i, primes.size())
	{
		while (n%primes[i] == 0)
		{
			cout << " " << primes[i];
			n /= primes[i];
		}
	}
	if (n != 1) cout << " " << n;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3940
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void chmax(T)(ref T a, in T b) {
	if (a < b) {
		a = b;
	}
}

void main() {
	auto n = readln.chomp.to!int;
	auto a = readln.chomp.split(' ').map!(to!int).array;
	long s = 0;

	foreach (i;1..n) {
		if (a[i] < a[i - 1]) {
			auto d = a[i - 1] - a[i];
			a[i] += d;
			s += d;
		}
	}

	writeln(s);
}


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

int main(){
  int n;
  cin>>n;
  int a,b;
  cin>>a>>b;
  int nearst = a/n*n;
  if(a%n==0) cout<<"OK"<<'\n';
  else{
    if(nearst+n<=b) cout<<"OK"<<'\n';
    else cout<<"NG";
  }
}

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
using namespace std;
ll ans, s, f[100009], rf[100009];
ll bin_pow (ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return bin_pow (a, n-1) * a % mod;
    else {
        ll b = bin_pow (a, n/2);
        return b * b % mod;
    }
}

ll C(ll n, ll k){
    if(k == 0)
        return 1;
    if(k < 0 || k > n)
        return 0;
    return f[n] * rf[k] % mod * rf[n - k] % mod;
}
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s;
    ll three = 2, pl = 1;
    f[0] = rf[0] = 1;
    for(int i = 1; i < 50009; i++) {
        f[i] = f[i - 1] * i % mod;
        rf[i] = bin_pow(f[i], mod - 2);
    }
    
    while(true) {
        ll cur = s - three;
        if(cur <= 0)
            break;
        //cout<<cur<<" "<<pl<<" "<<C(cur - 1, pl - 1)<<endl;
        ans += C(cur - 1, pl - 1);
        ans %= mod;
        three+=2;
        pl++;
    }
    cout<<ans;
}
/*
 2
 1 1
 1 0
 1 1
 1 1
 */


Measured memory_bytes: 4416
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private void solve(Scanner sc, PrintWriter out) {
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    out.println(((a + b) * h / 2));
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 21716
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long ll;

int f(ll p);
int n, k;
int T[MAX];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> T[i];
    }
    ll right = 1000000000;
    ll left = 0;
    ll mid;
    while (right - left > 1) {
        mid = (left + right) / 2;
        int d = f(mid);
        if (d >= n) {right = mid;}
        else left = mid;
    }
    cout << right << '\n';
}



int f(ll p) {
    int i = 0;
    for (ll j = 0; j < k; j++) {
        ll s = 0;
        while (s + T[i] <= p) {
            s += T[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}



Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
int main() {
  string S;
 cin >> S;
 
	int a = (S[0] - '0') * 10 + S[1] - '0';
	int b = (S[2] - '0') * 10 + S[3] - '0';
 
	bool YYMM = false;
	if (1 <= b and b <= 12) YYMM = true;
	bool MMYY = false;
	if (1 <= a and a <= 12) MMYY = true;
 
	if (YYMM and MMYY) cout << "AMBIGUOUS" << endl;
	else if (YYMM) cout << "YYMM" << endl;
	else if (MMYY) cout << "MMYY" << endl;
	else cout << "NA" << endl;
 
 
 }


 
 






Measured memory_bytes: 256
T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())
if T1*A1 + T2*A2 == T1*B1 + T2*B2:
    print("infinity")
else:
    if T1*A1 + T2*A2 > T1*B1 + T2*B2:
        A1, B1 = B1, A1
        A2, B2 = B2, A2
    if T1*A1 < T1*B1:
        print("0")
    else:
        forward = T1*A1 - T1*B1
        shrink = (T1*B1 + T2*B2) - (T1*A1 + T2*A2)
        #print(str(forward))
        #print(str(shrink))
        if forward % shrink == 0:
            print(str(2*forward//shrink))
        else:
            print(str((forward//shrink + 1)*2 - 1))

Measured memory_bytes: 3064